feat(saas): industry agent template assignment system
Some checks failed
CI / Lint & TypeCheck (push) Has been cancelled
CI / Unit Tests (push) Has been cancelled
CI / Build Frontend (push) Has been cancelled
CI / Rust Check (push) Has been cancelled
CI / Security Scan (push) Has been cancelled
CI / E2E Tests (push) Has been cancelled
Some checks failed
CI / Lint & TypeCheck (push) Has been cancelled
CI / Unit Tests (push) Has been cancelled
CI / Build Frontend (push) Has been cancelled
CI / Rust Check (push) Has been cancelled
CI / Security Scan (push) Has been cancelled
CI / E2E Tests (push) Has been cancelled
Phase 1-8 of industry-agent-delivery plan: - DB migration: accounts.assigned_template_id (ON DELETE SET NULL) - SaaS API: 4 new endpoints (assign/get/unassign/create-agent) - Service layer: assign_template_to_account, get_assigned_template, unassign_template, create_agent_from_template) - Types: AssignTemplateRequest, AgentConfigFromTemplate (capabilities merged into tools) - Frontend SaaS Client: assignTemplate, getAssignedTemplate, unassignTemplate, createAgentFromTemplate - saasStore: assignedTemplate state + login auto-fetch + actions - saas-relay-client: fix unused import and saasUrl reference error - connectionStore: fix relayModel undefined error - capabilities default to glm-4-flash - Route registration: new template assignment routes Cospec and handlers consolidated Build: cargo check --workspace PASS, tsc --noEmit Pass
This commit is contained in:
@@ -472,6 +472,19 @@ export const useConnectionStore = create<ConnectionStore>((set, get) => {
|
||||
// agent management local via KernelClient.
|
||||
// baseUrl = saasUrl + /api/v1/relay → kernel appends /chat/completions
|
||||
// apiKey = SaaS JWT token → sent as Authorization: Bearer <jwt>
|
||||
|
||||
// Fetch available models from SaaS relay (shared by both branches)
|
||||
let relayModels: Array<{ id: string }>;
|
||||
try {
|
||||
relayModels = await saasClient.listModels();
|
||||
} catch {
|
||||
throw new Error('无法获取可用模型列表,请确认管理后台已配置 Provider 和模型');
|
||||
}
|
||||
|
||||
if (relayModels.length === 0) {
|
||||
throw new Error('SaaS 平台没有可用模型,请先在管理后台配置 Provider 和模型');
|
||||
}
|
||||
|
||||
if (isTauriRuntime()) {
|
||||
if (!session.token) {
|
||||
throw new Error('SaaS 中转模式需要认证令牌,请重新登录 SaaS 平台');
|
||||
@@ -479,20 +492,8 @@ export const useConnectionStore = create<ConnectionStore>((set, get) => {
|
||||
|
||||
const kernelClient = getKernelClient();
|
||||
|
||||
// Fetch available models from SaaS relay
|
||||
let models: Array<{ id: string }>;
|
||||
try {
|
||||
models = await saasClient.listModels();
|
||||
} catch {
|
||||
throw new Error('无法获取可用模型列表,请确认管理后台已配置 Provider 和模型');
|
||||
}
|
||||
|
||||
if (models.length === 0) {
|
||||
throw new Error('SaaS 平台没有可用模型,请先在管理后台配置 Provider 和模型');
|
||||
}
|
||||
|
||||
// Use first available model (TODO: let user choose preferred model)
|
||||
const relayModel = models[0];
|
||||
const relayModel = relayModels[0];
|
||||
|
||||
kernelClient.setConfig({
|
||||
provider: 'custom',
|
||||
@@ -525,9 +526,21 @@ export const useConnectionStore = create<ConnectionStore>((set, get) => {
|
||||
baseUrl: `${session.saasUrl}/api/v1/relay`,
|
||||
});
|
||||
} else {
|
||||
// Non-Tauri (browser) — simple connected state without kernel
|
||||
set({ connectionState: 'connected', gatewayVersion: 'saas-relay' });
|
||||
log.debug('Connected to SaaS relay (browser mode)');
|
||||
// Non-Tauri (browser) — use SaaS relay gateway client for agent listing + chat
|
||||
const { createSaaSRelayGatewayClient } = await import('../lib/saas-relay-client');
|
||||
const relayModelId = relayModels[0].id;
|
||||
const relayClient = createSaaSRelayGatewayClient(session.saasUrl, relayModelId);
|
||||
|
||||
set({
|
||||
connectionState: 'connected',
|
||||
gatewayVersion: 'saas-relay',
|
||||
client: relayClient as unknown as GatewayClient,
|
||||
});
|
||||
|
||||
const { initializeStores } = await import('./index');
|
||||
initializeStores();
|
||||
|
||||
log.debug('Connected to SaaS relay (browser mode)', { relayModel: relayModelId });
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user