@axiom-lattice/gateway 10.1.0 → 10.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (24) hide show
  1. package/dist/{chunk-T2HIWZGP.mjs → chunk-BIMO2ILH.mjs} +1 -1
  2. package/dist/chunk-BIMO2ILH.mjs.map +1 -0
  3. package/dist/embed/{embed-page-AgentDetailSideApp-5L5GY5TY.js → embed-page-AgentDetailSideApp-HNSIMIXX.js} +1 -1
  4. package/dist/embed/{embed-page-AgentGovernanceWorkbench-RKNSCQUM.js → embed-page-AgentGovernanceWorkbench-QBEH3KYW.js} +1 -1
  5. package/dist/embed/{embed-page-MessageGraph-HDJYCYZV.js → embed-page-MessageGraph-GXEC7IPB.js} +1 -1
  6. package/dist/embed/{embed-page-ReactChart-KJS73V5Q.js → embed-page-ReactChart-LW6COMT3.js} +1 -1
  7. package/dist/embed/{embed-page-TasksSideApp-X2YZGU7K.js → embed-page-TasksSideApp-Q76BWXUV.js} +1 -1
  8. package/dist/embed/{embed-page-TopologyRuntimeView-LZTSYJE5.js → embed-page-TopologyRuntimeView-POBS44XX.js} +1 -1
  9. package/dist/embed/{embed-page-WorkflowAutomationView-KIKV62O2.js → embed-page-WorkflowAutomationView-UH633BXC.js} +1 -1
  10. package/dist/embed/{embed-page-chunk-5HWN5HSA.js → embed-page-chunk-62CAXPZK.js} +1 -1
  11. package/dist/embed/{embed-page-chunk-FF2HNPMW.js → embed-page-chunk-AJV2ISVF.js} +1 -1
  12. package/dist/embed/{embed-page-chunk-BBIV2YA2.js → embed-page-chunk-KKNZYZVB.js} +1 -1
  13. package/dist/embed/{embed-page-chunk-MVT6CPWE.js → embed-page-chunk-KWZEITYQ.js} +59 -59
  14. package/dist/embed/{embed-page-chunk-DI5UAV2I.js → embed-page-chunk-NGO5C5RH.js} +1 -1
  15. package/dist/embed/{embed-page-chunk-4BPMGDDV.js → embed-page-chunk-NR4M6XSO.js} +1 -1
  16. package/dist/embed/embed-page.js +1 -1
  17. package/dist/index.js +12 -0
  18. package/dist/index.js.map +1 -1
  19. package/dist/index.mjs +18 -2
  20. package/dist/index.mjs.map +1 -1
  21. package/dist/{mcp-apps-QVUK6UBA.mjs → mcp-apps-MZECSNN2.mjs} +2 -2
  22. package/package.json +3 -3
  23. package/dist/chunk-T2HIWZGP.mjs.map +0 -1
  24. /package/dist/{mcp-apps-QVUK6UBA.mjs.map → mcp-apps-MZECSNN2.mjs.map} +0 -0
@@ -577,4 +577,4 @@ export {
577
577
  resolveMcpAppDeps,
578
578
  registerMcpAppRoutes
579
579
  };
580
- //# sourceMappingURL=chunk-T2HIWZGP.mjs.map
580
+ //# sourceMappingURL=chunk-BIMO2ILH.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/routes/mcp-apps.ts","../src/services/mcp-ui/UiResourceResolver.ts","../src/services/mcp-ui/McpUiResourceCacheStore.ts","../src/services/mcp-ui/buildCsp.ts","../src/services/mcp-ui/sandboxPage.ts","../src/services/plugins/tenantPluginResolver.ts"],"sourcesContent":["/**\n * MCP App routes.\n *\n * Exposes the two thin HTTP seams the sandboxed MCP App frame needs: resolving a\n * UI resource and proxying a whitelisted JSON-RPC envelope to the owning MCP\n * server. The pure handler factory keeps the security-relevant decisions\n * (ref parsing, method allow-list, plugin tool scoping) framework-agnostic and\n * unit-testable; {@link registerMcpAppRoutes} only translates HTTP to those\n * handlers.\n */\n\nimport type { FastifyInstance, FastifyRequest } from \"fastify\";\nimport {\n parseMcpUiRef,\n type McpUiRef,\n type McpUiResourcePayload,\n type Plugin,\n type SandboxPluginManifest,\n} from \"@axiom-lattice/protocols\";\nimport {\n getSandboxPluginCatalog,\n mcpManager,\n resolvePluginConnections,\n verifyMcpUiScope,\n type SandboxPluginInvokeArgs,\n} from \"@axiom-lattice/core\";\nimport { UiResourceResolver } from \"../services/mcp-ui/UiResourceResolver\";\nimport { InMemoryMcpUiResourceCacheStore } from \"../services/mcp-ui/McpUiResourceCacheStore\";\nimport { buildCsp } from \"../services/mcp-ui/buildCsp\";\nimport { SANDBOX_HTML } from \"../services/mcp-ui/sandboxPage\";\nimport { resolveTenantPluginByType } from \"../services/plugins/tenantPluginResolver\";\nimport {\n invokePluginTool,\n PluginToolScopeError,\n} from \"../services/plugins/pluginToolExecution\";\n\nconst SANDBOX_HTML_CONTENT_TYPE = \"text/html; charset=utf-8\";\n\n// Re-exported so existing importers keep resolving the error from this module;\n// the class itself now lives in the shared plugin tool execution helper.\nexport { PluginToolScopeError };\n\n/**\n * Thrown by the plugin backend for MCP methods the plugin surface does not\n * support (Plan 2 serves UI resources and the plugin's own tool calls only).\n * {@link makeMcpAppHandlers} maps it to 403.\n */\nexport class PluginMethodNotSupportedError extends Error {\n /**\n * @param method - Unsupported JSON-RPC method.\n */\n constructor(method: string) {\n super(`plugin backend does not support ${method}`);\n this.name = \"PluginMethodNotSupportedError\";\n }\n}\n\n/**\n * Client-facing scope denial from the plugin tool path.\n *\n * `status`/`code` are stable so the MCP App host can surface a precise error\n * instead of a generic 502.\n */\nexport class McpAppScopeError extends Error {\n /**\n * @param status - HTTP status to return.\n * @param code - Stable machine-readable denial code.\n */\n constructor(\n readonly status: 403 | 409,\n readonly code:\n | \"SCOPE_INVALID\"\n | \"SCOPE_MISMATCH\"\n | \"CONNECTION_REQUIRED\"\n | \"CONNECTION_NOT_ALLOWED\",\n ) {\n super(code);\n this.name = \"McpAppScopeError\";\n }\n}\n\n/** Result envelope returned by the pure handlers. */\nexport interface McpAppHandlerResult<T = unknown> {\n status: number;\n body: T;\n}\n\n/**\n * Request-scoped run context forwarded from the console request to plugin\n * execution.\n *\n * Plugin handlers run in a project-isolated sandbox whose path layout is\n * `/project/<plugin>/...`; without the workspace/project the executor resolves a\n * tenant-level sandbox and tool calls read the wrong (empty) files.\n */\nexport interface McpAppRunContext {\n tenantId: string;\n workspaceId?: string;\n projectId?: string;\n}\n\n/** Injectable seams for scope verification/connection resolution in tests. */\nexport interface McpAppScopeDeps {\n verifyScope?: typeof verifyMcpUiScope;\n resolveConnections?: typeof resolvePluginConnections;\n}\n\n/** Log and build a scope denial. */\nfunction denyScope(\n status: 403 | 409,\n code: McpAppScopeError[\"code\"],\n detail: Record<string, unknown>,\n): McpAppScopeError {\n console.warn(JSON.stringify({ event: \"mcp-apps:scope-denied\", ...detail, code }));\n return new McpAppScopeError(status, code);\n}\n\n/** Dependencies injected into the route handlers. */\nexport interface McpAppRouteDeps {\n resolveUiResource: (tenantId: string, ref: McpUiRef) => Promise<McpUiResourcePayload>;\n callTool: (\n tenantId: string,\n ref: McpUiRef,\n name: string,\n args: Record<string, unknown>,\n context?: McpAppRunContext,\n ) => Promise<unknown>;\n readResource: (tenantId: string, ref: McpUiRef, uri: string) => Promise<unknown>;\n listTools: (tenantId: string, ref: McpUiRef) => Promise<unknown>;\n}\n\n/**\n * Arguments the plugin backend forwards to the sandbox executor.\n *\n * Aliased to core's executor contract so the shared {@link invokePluginTool}\n * seam cannot drift from the real executor.\n */\nexport type McpAppPluginInvokeArgs = SandboxPluginInvokeArgs;\n\n/** Normalized sandbox handler outcome consumed by the plugin backend. */\nexport interface McpAppPluginInvokeResult {\n ok: boolean;\n result?: unknown;\n error?: string;\n}\n\n/** Minimal tenant plugin catalog surface needed by the plugin backend. */\nexport interface McpAppPluginCatalog {\n readPluginFile: (tenantId: string, pluginType: string, relPath: string) => Promise<string>;\n /**\n * Validated (normalized) manifest for the plugin.\n *\n * This is the authoritative source for handler paths and tool caps: it is the\n * output of the manifest validator, not a fresh parse of the raw\n * `plugin.json`, so execution cannot diverge from what validation accepted.\n */\n getValidatedManifest: (tenantId: string, pluginType: string) => Promise<SandboxPluginManifest | undefined>;\n getExecutor: () => {\n invoke: (args: McpAppPluginInvokeArgs) => Promise<McpAppPluginInvokeResult>;\n };\n}\n\n/**\n * Plugin seam injected into {@link resolveMcpAppDeps}: the tenant plugin\n * resolver plus the sandbox catalog/executor. Extracted so tests can supply a\n * fake and exercise the real plugin backend without touching the module\n * singleton.\n */\nexport interface McpAppPluginBackend {\n resolvePlugin: (tenantId: string, type: string) => Promise<Plugin | undefined>;\n catalog: McpAppPluginCatalog;\n}\n\nconst ALLOWED_METHODS = new Set([\"tools/call\", \"tools/list\", \"resources/read\"]);\n\n/** Narrow an unknown value to a plain data record, otherwise `undefined`. */\nfunction asRecord(value: unknown): Record<string, unknown> | undefined {\n return typeof value === \"object\" && value !== null && !Array.isArray(value)\n ? (value as Record<string, unknown>)\n : undefined;\n}\n\n/**\n * Build pure, framework-agnostic handlers for the MCP app routes.\n *\n * @param deps Backend proxies.\n * @returns `resource` and `rpc` handlers.\n */\nexport function makeMcpAppHandlers(deps: McpAppRouteDeps) {\n return {\n /**\n * Resolve the `mcp_app` UI resource for a parsed ref.\n *\n * @param tenantId Tenant scope.\n * @param rawRef Untrusted ref payload.\n * @returns The resource payload plus a ready-to-use `cspPolicy` string\n * ({@link buildCsp}, always non-empty), or a 400/502 error envelope.\n */\n async resource(tenantId: string, rawRef: unknown): Promise<McpAppHandlerResult> {\n const ref = parseMcpUiRef(rawRef);\n if (!ref) return { status: 400, body: { error: \"INVALID_REF\" } };\n if (ref.kind === \"plugin\" && ref.pluginType === \"\") {\n return { status: 400, body: { error: \"INVALID_REF\" } };\n }\n try {\n const payload = await deps.resolveUiResource(tenantId, ref);\n return { status: 200, body: { ...payload, cspPolicy: buildCsp(payload.csp) } };\n } catch (error) {\n console.warn(JSON.stringify({\n event: \"mcp-apps:resource-failed\",\n tenantId,\n kind: ref.kind,\n error: error instanceof Error ? error.message : String(error),\n }));\n return { status: 502, body: { error: \"RESOURCE_UNAVAILABLE\" } };\n }\n },\n\n /**\n * Proxy an allow-listed JSON-RPC method for a parsed ref.\n *\n * @param tenantId Tenant scope.\n * @param rawRef Untrusted ref payload.\n * @param method JSON-RPC method name.\n * @param params JSON-RPC params.\n * @param context Request-scoped run context forwarded to `tools/call`.\n * @returns The backend result, or a 400/403/502 error envelope.\n */\n async rpc(\n tenantId: string,\n rawRef: unknown,\n method: string,\n params: Record<string, unknown>,\n context?: McpAppRunContext,\n ): Promise<McpAppHandlerResult> {\n const ref = parseMcpUiRef(rawRef);\n if (!ref) return { status: 400, body: { error: \"INVALID_REF\" } };\n if (!ALLOWED_METHODS.has(method)) return { status: 403, body: { error: \"METHOD_NOT_ALLOWED\" } };\n try {\n if (method === \"tools/call\") {\n const name = typeof params.name === \"string\" ? params.name : \"\";\n if (name === \"\") return { status: 400, body: { error: \"INVALID_PARAMS\" } };\n if (\"pluginType\" in ref && ref.pluginType === \"\") {\n return { status: 400, body: { error: \"INVALID_REF\" } };\n }\n return {\n status: 200,\n body: await deps.callTool(tenantId, ref, name, asRecord(params.arguments) ?? {}, context),\n };\n }\n if (method === \"resources/read\") {\n const uri = typeof params.uri === \"string\" ? params.uri : \"\";\n if (uri === \"\") return { status: 400, body: { error: \"INVALID_PARAMS\" } };\n return { status: 200, body: await deps.readResource(tenantId, ref, uri) };\n }\n return { status: 200, body: { tools: await deps.listTools(tenantId, ref) } };\n } catch (error) {\n if (error instanceof McpAppScopeError) {\n return { status: error.status, body: { error: error.code } };\n }\n if (error instanceof PluginToolScopeError) {\n return { status: 403, body: { error: \"PLUGIN_TOOL_SCOPE\" } };\n }\n if (error instanceof PluginMethodNotSupportedError) {\n return { status: 403, body: { error: \"PLUGIN_METHOD_UNSUPPORTED\" } };\n }\n const context: Record<string, unknown> = { tenantId, kind: ref.kind, method };\n if (method === \"resources/read\") context.uri = typeof params.uri === \"string\" ? params.uri : \"\";\n if (method === \"tools/call\") context.name = typeof params.name === \"string\" ? params.name : \"\";\n console.warn(JSON.stringify({\n event: \"mcp-apps:rpc-failed\",\n ...context,\n error: error instanceof Error ? error.message : String(error),\n }));\n return { status: 502, body: { error: \"RPC_FAILED\" } };\n }\n },\n };\n}\n\n/**\n * Read a plugin UI resource and enrich it with the declaring tool's\n * CSP/permissions/border preferences.\n *\n * Two backends serve plugin UIs:\n * - **Global plugins** declare inline `meta.uiResources[resource]` HTML, keyed\n * by the `ui://` resource itself (the same key a tool's `ui.resource` points\n * at). That HTML is returned directly with no sandbox read and defaults to\n * `text/html;profile=mcp-app`.\n * - **Tenant sandbox plugins** declare a relative `ui/<tool>.html` path; the\n * file is read from the tenant volume and served as `text/html`.\n *\n * In both cases the resource must be declared by a tool of the plugin, so an\n * arbitrary `uiResources` key or volume path cannot be fetched.\n *\n * @param backend Plugin resolver + sandbox catalog seam.\n * @param tenantId Tenant scope.\n * @param pluginType Plugin type addressed by the ref.\n * @param resource Resource key: an inline `ui://` key for global plugins, or a\n * safe relative `.html` path for tenant plugins.\n * @returns The UI resource payload.\n * @throws When the plugin, declaring tool, or file is missing. A resource not\n * declared by any tool is rejected before the catalog is asked to read it.\n *\n * @remarks\n * Tenant plugin files live under the tenant-level configured agents root/plugins, so\n * unlike tool execution this path needs no workspace/project context.\n */\nexport async function fetchPluginUiResource(\n backend: McpAppPluginBackend,\n tenantId: string,\n pluginType: string,\n resource: string,\n): Promise<McpUiResourcePayload> {\n const plugin = await backend.resolvePlugin(tenantId, pluginType);\n if (!plugin) throw new Error(`plugin \"${pluginType}\" not found`);\n const tool = (plugin.meta.tools ?? []).find((t) => t.ui?.resource === resource);\n if (!tool?.ui) throw new Error(`plugin \"${pluginType}\" has no tool declaring ui resource \"${resource}\"`);\n\n const inline = plugin.meta.uiResources?.[resource];\n if (inline) {\n return {\n mimeType: inline.mimeType ?? \"text/html;profile=mcp-app\",\n html: inline.html,\n csp: inline.csp ?? tool.ui.csp,\n permissions: tool.ui.permissions,\n prefersBorder: tool.ui.prefersBorder,\n };\n }\n\n const html = await backend.catalog.readPluginFile(tenantId, pluginType, resource);\n return {\n mimeType: \"text/html\",\n html,\n csp: tool.ui.csp,\n permissions: tool.ui.permissions,\n prefersBorder: tool.ui.prefersBorder,\n };\n}\n\n/**\n * Execute one of a plugin's own tools through the injected sandbox executor.\n *\n * A scope-bearing ref is verified, its connection key is resolved against the\n * tenant Connection Store, and the connection is injected. A scope-less legacy\n * ref keeps the request-context path; a connection-declaring plugin without a\n * scope fails with `CONNECTION_REQUIRED`.\n *\n * @param backend - Plugin resolver + sandbox catalog seam.\n * @param tenantId - Tenant scope.\n * @param ref - Parsed plugin ref.\n * @param name - Tool name requested by the app.\n * @param args - Tool arguments.\n * @param context - Legacy request context for scope-less refs.\n * @param deps - Injectable scope/connection seams for tests.\n * @returns The handler result.\n * @throws McpAppScopeError when the scope is invalid/mismatched or its\n * connection key is disallowed/missing.\n */\nexport async function callPluginTool(\n backend: McpAppPluginBackend,\n tenantId: string,\n ref: Extract<McpUiRef, { kind: \"plugin\" }>,\n name: string,\n args: Record<string, unknown>,\n context?: McpAppRunContext,\n deps?: McpAppScopeDeps,\n): Promise<unknown> {\n const scope = ref.scope ? (deps?.verifyScope ?? verifyMcpUiScope)(ref.scope) : null;\n if (ref.scope && !scope) {\n throw denyScope(403, \"SCOPE_INVALID\", {\n tenantId,\n pluginType: ref.pluginType,\n tool: name,\n });\n }\n if (scope) {\n const mismatched =\n scope.tid !== tenantId ||\n scope.plugin !== ref.pluginType ||\n scope.resource !== ref.resource;\n if (mismatched) {\n throw denyScope(403, \"SCOPE_MISMATCH\", {\n tenantId,\n pluginType: ref.pluginType,\n tool: name,\n jti: scope.jti,\n threadId: scope.thid,\n });\n }\n }\n\n const manifest = await backend.catalog.getValidatedManifest(tenantId, ref.pluginType);\n const rawConnectionKey = args.connectionKey;\n const explicit =\n typeof rawConnectionKey === \"string\" ? rawConnectionKey : undefined;\n const scoped = scope?.ck;\n const connectionRelevant = Boolean(manifest?.connection) || scoped !== undefined;\n if (\n connectionRelevant &&\n (explicit !== undefined\n ? explicit !== scoped\n : rawConnectionKey !== undefined)\n ) {\n throw denyScope(403, \"CONNECTION_NOT_ALLOWED\", {\n tenantId,\n pluginType: ref.pluginType,\n tool: name,\n jti: scope?.jti,\n threadId: scope?.thid,\n });\n }\n\n let connection: Record<string, unknown> | undefined;\n let connectionKey: string | undefined;\n if (scoped !== undefined) {\n const resolveConnections = deps?.resolveConnections ?? resolvePluginConnections;\n const resolved = await resolveConnections(\n ref.pluginType,\n { connections: [scoped] },\n { tenantId },\n );\n if (resolved.length === 0) {\n throw denyScope(403, \"CONNECTION_NOT_ALLOWED\", {\n tenantId,\n pluginType: ref.pluginType,\n tool: name,\n jti: scope?.jti,\n threadId: scope?.thid,\n });\n }\n connection = resolved[0]!.config;\n connectionKey = resolved[0]!.key;\n }\n\n if (manifest?.connection && !connectionKey) {\n throw denyScope(409, \"CONNECTION_REQUIRED\", {\n tenantId,\n pluginType: ref.pluginType,\n tool: name,\n jti: scope?.jti,\n threadId: scope?.thid,\n });\n }\n\n const identity = scope\n ? {\n workspaceId: scope.wid,\n projectId: scope.pid,\n threadId: scope.thid,\n assistantId: scope.aid,\n }\n : {\n workspaceId: context?.workspaceId,\n projectId: context?.projectId,\n };\n\n return invokePluginTool(backend, tenantId, ref.pluginType, name, args, {\n ...identity,\n ...(connection === undefined ? {} : { connection }),\n });\n}\n\n/**\n * Default plugin backend: the shared tenant plugin resolver plus the\n * process-wide sandbox plugin catalog and executor.\n *\n * @returns The live plugin backend.\n */\nfunction createDefaultPluginBackend(): McpAppPluginBackend {\n return {\n resolvePlugin: (tenantId, type) => resolveTenantPluginByType(tenantId, type),\n catalog: {\n readPluginFile: (tenantId, pluginType, relPath) =>\n getSandboxPluginCatalog().readPluginFile(tenantId, pluginType, relPath),\n getValidatedManifest: (tenantId, pluginType) =>\n getSandboxPluginCatalog().getValidatedManifest(tenantId, pluginType),\n getExecutor: () => getSandboxPluginCatalog().getExecutor(),\n },\n };\n}\n\n/**\n * Process-wide UI resource resolver installed by the default route wiring.\n *\n * @remarks The plugin-catalog-change subscriber invalidates a tenant's plugin\n * UI resources through this so an edited `ui/*.html` re-resolves immediately\n * instead of being served from the 5-minute TTL cache.\n */\nlet uiResourceResolverSingleton: UiResourceResolver | undefined;\n\n/**\n * The UI resource resolver used by the live MCP app routes.\n *\n * @returns The resolver installed by {@link resolveMcpAppDeps}, or `undefined`\n * before the routes are registered.\n */\nexport function getMcpUiResourceResolver(): UiResourceResolver | undefined {\n return uiResourceResolverSingleton;\n}\n\n/**\n * Wire the handler deps to the live MCP runtime and tenant plugin backend.\n *\n * @param pluginBackend Plugin seam; defaults to the live catalog/executor.\n * @returns The concrete route dependencies.\n */\nexport function resolveMcpAppDeps(\n pluginBackend: McpAppPluginBackend = createDefaultPluginBackend(),\n): McpAppRouteDeps {\n const uiResourceResolver = new UiResourceResolver({\n store: new InMemoryMcpUiResourceCacheStore(),\n fetchMcp: (tenantId, serverKey, resourceUri) => mcpManager.readUiResource(tenantId, serverKey, resourceUri),\n fetchPlugin: (tenantId, pluginType, resource) =>\n fetchPluginUiResource(pluginBackend, tenantId, pluginType, resource),\n });\n uiResourceResolverSingleton = uiResourceResolver;\n return {\n resolveUiResource: (tenantId, ref) => uiResourceResolver.resolve(tenantId, ref),\n callTool: (tenantId, ref, name, args, context) =>\n ref.kind === \"mcp\"\n ? mcpManager.callServerTool(tenantId, ref.serverKey, name, args)\n : callPluginTool(pluginBackend, tenantId, ref, name, args, context),\n // Plugin refs reach these only after `tools/call`; the handler treats the\n // rejection as an unsupported method (403). The branches are live because\n // the pure handler deliberately delegates method policy to the deps.\n readResource: (tenantId, ref, uri) =>\n ref.kind === \"mcp\"\n ? mcpManager.readServerResource(tenantId, ref.serverKey, uri)\n : Promise.reject(new PluginMethodNotSupportedError(\"resources/read\")),\n listTools: (tenantId, ref) =>\n ref.kind === \"mcp\"\n ? mcpManager.getAvailableTools(tenantId, ref.serverKey)\n : Promise.reject(new PluginMethodNotSupportedError(\"tools/list\")),\n };\n}\n\ntype RequestWithUser = FastifyRequest & { user?: { tenantId?: string } };\n\n/** Read a header as a single value, using the first entry when repeated. */\nfunction firstHeader(request: FastifyRequest, name: string): string | undefined {\n const header = request.headers[name];\n return Array.isArray(header) ? header[0] : header;\n}\n\n/** Resolve the tenant from the console session, then the legacy header. */\nfunction tenantOf(request: FastifyRequest): string {\n const user = (request as RequestWithUser).user;\n return user?.tenantId ?? firstHeader(request, \"x-tenant-id\") ?? \"default\";\n}\n\n/**\n * Build the request-scoped run context from the console request.\n *\n * The console sends the active workspace/project on every API call\n * (`x-workspace-id`/`x-project-id`); forwarding them lets a UI-initiated\n * `tools/call` resolve the same project-isolated sandbox the agent run used.\n */\nfunction runContextOf(request: FastifyRequest): McpAppRunContext {\n return {\n tenantId: tenantOf(request),\n workspaceId: firstHeader(request, \"x-workspace-id\"),\n projectId: firstHeader(request, \"x-project-id\"),\n };\n}\n\n/**\n * Register MCP app routes on the Fastify instance.\n *\n * @param fastify Gateway Fastify instance.\n * @param deps Route dependencies; defaults to live runtime wiring.\n * @remarks Resource/rpc derive `tenantId` from the console session. The sandbox\n * bootstrap page is loaded as an iframe navigation (no `Authorization` header),\n * so `GET /mcp-apps/sandbox.html` is added to the console-auth bypass list; it\n * is a static document carrying no secrets and no identity, while the\n * `/api/mcp-apps/*` seams stay authenticated. The MCP Apps spec prefers the\n * sandbox proxy origin to differ from the console SPA origin (defense-in-depth\n * containment); single-origin deployments are supported, where the outer proxy\n * frame shares the console origin.\n */\nexport function registerMcpAppRoutes(\n fastify: FastifyInstance,\n deps: McpAppRouteDeps = resolveMcpAppDeps(),\n): void {\n const handlers = makeMcpAppHandlers(deps);\n\n fastify.get(\"/mcp-apps/sandbox.html\", async (_request, reply) => {\n return reply\n .header(\"content-type\", SANDBOX_HTML_CONTENT_TYPE)\n .header(\"x-content-type-options\", \"nosniff\")\n .header(\"cache-control\", \"no-store\")\n .send(SANDBOX_HTML);\n });\n\n fastify.post(\"/api/mcp-apps/resource\", async (request, reply) => {\n const body = asRecord(request.body) ?? {};\n const result = await handlers.resource(tenantOf(request), body.ref);\n return reply.code(result.status).send(result.body);\n });\n\n fastify.post(\"/api/mcp-apps/rpc\", async (request, reply) => {\n const body = asRecord(request.body) ?? {};\n const params = asRecord(body.params) ?? {};\n const context = runContextOf(request);\n const result = await handlers.rpc(\n context.tenantId,\n body.ref,\n String(body.method ?? \"\"),\n params,\n context,\n );\n return reply.code(result.status).send(result.body);\n });\n}\n","import { createHash } from \"node:crypto\";\nimport type { McpUiRef, McpUiResourcePayload } from \"@axiom-lattice/protocols\";\nimport type { McpUiCacheEntry, McpUiResourceCacheStore } from \"./McpUiResourceCacheStore\";\n\n/** Dependencies for {@link UiResourceResolver}. */\nexport interface UiResourceResolverDeps {\n store: McpUiResourceCacheStore;\n fetchMcp: (tenantId: string, serverKey: string, resourceUri: string) => Promise<McpUiResourcePayload>;\n fetchPlugin: (tenantId: string, pluginType: string, resource: string) => Promise<McpUiResourcePayload>;\n ttlMs?: number;\n}\n\nconst DEFAULT_TTL_MS = 5 * 60 * 1000;\n\n/** Public payload fields, excluding internal cache metadata (`hash`/`fetchedAt`/`stale`). */\ntype McpUiPublicFields = Omit<McpUiResourcePayload, \"stale\">;\n\nfunction publicFieldsOf(payload: McpUiResourcePayload): McpUiPublicFields {\n return {\n mimeType: payload.mimeType,\n html: payload.html,\n ...(payload.csp !== undefined ? { csp: payload.csp } : {}),\n ...(payload.permissions !== undefined ? { permissions: payload.permissions } : {}),\n ...(payload.prefersBorder !== undefined ? { prefersBorder: payload.prefersBorder } : {}),\n };\n}\n\n/**\n * Resolve `mcp_app` refs from either the MCP or plugin backend, with a\n * stale-while-error cache.\n *\n * @remarks Concurrent resolves for the same tenant/ref share a single backend\n * fetch (single-flight). On backend failure, a cached entry (even expired) is\n * returned with `stale: true` instead of throwing.\n */\nexport class UiResourceResolver {\n private readonly inFlight = new Map<string, Promise<McpUiResourcePayload>>();\n\n constructor(private deps: UiResourceResolverDeps) {}\n\n private keyOf(ref: McpUiRef): string {\n return ref.kind === \"mcp\"\n ? `mcp\\u0000${ref.serverKey}\\u0000${ref.resourceUri}`\n : `plugin\\u0000${ref.pluginType}\\u0000${ref.resource}`;\n }\n\n private fullKey(tenantId: string, ref: McpUiRef): string {\n return `${tenantId}\\u0000${this.keyOf(ref)}`;\n }\n\n /**\n * Resolve a UI resource for a tenant.\n *\n * @param tenantId Tenant scope.\n * @param ref The fence ref.\n * @returns Public UI resource payload (no cache metadata).\n */\n async resolve(tenantId: string, ref: McpUiRef): Promise<McpUiResourcePayload> {\n const key = this.fullKey(tenantId, ref);\n const ttl = this.deps.ttlMs ?? DEFAULT_TTL_MS;\n const cached = await this.deps.store.get(key);\n if (cached && Date.now() - cached.fetchedAt < ttl) return publicFieldsOf(cached);\n\n const existing = this.inFlight.get(key);\n if (existing) return existing;\n\n const promise = this.fetchAndCache(tenantId, ref, key, cached);\n this.inFlight.set(key, promise);\n try {\n return await promise;\n } finally {\n this.inFlight.delete(key);\n }\n }\n\n /**\n * Evict the cached entry for a tenant/ref.\n *\n * @param tenantId Tenant scope.\n * @param ref The fence ref.\n */\n async invalidate(tenantId: string, ref: McpUiRef): Promise<void> {\n await this.deps.store.delete(this.fullKey(tenantId, ref));\n }\n\n /**\n * Evict every cached plugin UI resource for a tenant.\n *\n * @param tenantId Tenant whose plugin UI resources to drop.\n * @remarks Called when a tenant's plugin catalog changes so an edited\n * `ui/*.html` is re-fetched instead of being served from the TTL cache\n * (which is keyed by ref identity, not content).\n */\n async invalidateTenantPlugins(tenantId: string): Promise<void> {\n await this.deps.store.deleteByPrefix(`${tenantId}\\u0000plugin\\u0000`);\n }\n\n private async fetchAndCache(\n tenantId: string,\n ref: McpUiRef,\n key: string,\n cached: McpUiCacheEntry | undefined,\n ): Promise<McpUiResourcePayload> {\n try {\n const fresh =\n ref.kind === \"mcp\"\n ? await this.deps.fetchMcp(tenantId, ref.serverKey, ref.resourceUri)\n : await this.deps.fetchPlugin(tenantId, ref.pluginType, ref.resource);\n const entry: McpUiCacheEntry = {\n ...publicFieldsOf(fresh),\n hash: createHash(\"sha256\").update(fresh.html).digest(\"hex\"),\n fetchedAt: Date.now(),\n };\n await this.deps.store.set(key, entry);\n return publicFieldsOf(fresh);\n } catch (error) {\n if (cached) return { ...publicFieldsOf(cached), stale: true };\n throw error;\n }\n }\n}\n","import type { McpUiResourcePayload } from \"@axiom-lattice/protocols\";\n\n/** Cache entry with provenance. */\nexport interface McpUiCacheEntry extends McpUiResourcePayload {\n hash: string;\n fetchedAt: number;\n}\n\n/** Persistence seam for resolved UI resources. */\nexport interface McpUiResourceCacheStore {\n get(key: string): Promise<McpUiCacheEntry | undefined>;\n set(key: string, entry: McpUiCacheEntry): Promise<void>;\n delete(key: string): Promise<void>;\n deleteByPrefix(prefix: string): Promise<void>;\n}\n\n/** Process-local cache implementation. */\nexport class InMemoryMcpUiResourceCacheStore implements McpUiResourceCacheStore {\n private map = new Map<string, McpUiCacheEntry>();\n\n async get(key: string): Promise<McpUiCacheEntry | undefined> {\n return this.map.get(key);\n }\n\n async set(key: string, entry: McpUiCacheEntry): Promise<void> {\n this.map.set(key, entry);\n }\n\n async delete(key: string): Promise<void> {\n this.map.delete(key);\n }\n\n async deleteByPrefix(prefix: string): Promise<void> {\n for (const key of this.map.keys()) {\n if (key.startsWith(prefix)) this.map.delete(key);\n }\n }\n}\n","import type { McpUiCsp } from \"@axiom-lattice/protocols\";\n\n// `'wasm-unsafe-eval'` permits WebAssembly compilation (e.g. CesiumJS) without\n// the broader `'unsafe-eval'`; MCP Apps' declared CSP has no wasm field, so the\n// host always grants it. Browsers without support simply ignore the token.\nconst DEFAULT_CSP = [\n \"default-src 'none'\",\n \"script-src 'self' 'unsafe-inline' 'wasm-unsafe-eval'\",\n \"style-src 'self' 'unsafe-inline'\",\n \"img-src 'self' data:\",\n \"media-src 'self' data:\",\n // Fonts are restricted to the document origin; declared `resourceDomains`\n // are the only origins ever added (no `data:` — a base64-embedded font must\n // be served from a declared origin).\n \"font-src 'self'\",\n \"object-src 'none'\",\n \"connect-src 'none'\",\n \"frame-src 'none'\",\n \"base-uri 'self'\",\n].join(\"; \");\n\n/**\n * A single safe CSP source expression: an explicit `http(s)://` / `ws(s)://`\n * origin (optionally with a leading `*.` wildcard subdomain and optionally with\n * a path). The negated class forbids whitespace and the `;`, `,`, `'`, `\"`\n * characters, and — because `*` is only allowed as the leading label via the\n * `(\\*\\.)?` group — a bare `*` or a non-leading wildcard is rejected too, so a\n * declared value cannot terminate the token or smuggle an extra directive.\n */\nconst ORIGIN_PATTERN = /^(https?|wss?):\\/\\/(\\*\\.)?[^\\s;,'\"*]+$/;\n\n/** Keep only well-formed origin strings, silently dropping junk or injections. */\nfunction declaredOrigins(domains: string[] | undefined): string[] {\n if (!Array.isArray(domains)) return [];\n return domains.filter((domain) => typeof domain === \"string\" && ORIGIN_PATTERN.test(domain));\n}\n\n/**\n * Build a CSP header value from a UI resource's declared origins.\n *\n * @param csp Declared CSP metadata (may be undefined).\n * @returns A CSP string. Never loosens beyond declared origins.\n * @remarks Omitted `csp` yields the restrictive MCP Apps default.\n */\nexport function buildCsp(csp: McpUiCsp | undefined): string {\n if (!csp) return DEFAULT_CSP;\n const resourceOrigins = declaredOrigins(csp.resourceDomains);\n const resource = resourceOrigins.join(\" \");\n // Per MCP Apps, `resourceDomains` covers scripts/styles/fonts as well as\n // images and media, so the same validated origins feed every resource\n // directive. Only declared origins are ever appended.\n const withResourceOrigins = (base: string): string => (resource ? `${base} ${resource}` : base);\n const img = [\"'self'\", \"data:\", ...resourceOrigins].join(\" \");\n const connect = declaredOrigins(csp.connectDomains);\n const frame = declaredOrigins(csp.frameDomains);\n const baseUri = declaredOrigins(csp.baseUriDomains);\n const parts = [\n \"default-src 'none'\",\n withResourceOrigins(\"script-src 'self' 'unsafe-inline' 'wasm-unsafe-eval'\"),\n withResourceOrigins(\"style-src 'self' 'unsafe-inline'\"),\n `img-src ${img}`,\n `media-src ${[\"'self'\", \"data:\", ...resourceOrigins].join(\" \")}`,\n withResourceOrigins(\"font-src 'self'\"),\n \"object-src 'none'\",\n `connect-src ${connect.length ? connect.join(\" \") : \"'none'\"}`,\n `frame-src ${frame.length ? frame.join(\" \") : \"'none'\"}`,\n `base-uri ${baseUri.length ? baseUri.join(\" \") : \"'self'\"}`,\n ];\n return parts.join(\"; \");\n}\n","/**\n * Static bootstrap document for the MCP App double-iframe sandbox proxy.\n *\n * The MCP Apps spec prefers the host and the sandbox proxy to be cross-origin\n * (defense-in-depth), so this page is served from the gateway origin; the\n * console SPA typically runs on its own origin, but single-origin deployments\n * are supported (the outer proxy then shares the console origin). It owns\n * exactly two responsibilities:\n *\n * 1. On load, announce `ui/notifications/sandbox-proxy-ready` to its parent.\n * The host then sends `ui/notifications/sandbox-resource-ready` with the\n * resource `{ html, sandbox?, csp? }`, and this page builds the nested\n * View iframe (opaque origin, `allow-scripts` by default).\n * 2. Relay JSON-RPC between host and View, skipping the control channel:\n * messages whose method starts with `ui/notifications/sandbox-` are\n * consumed here and never forwarded. Relaying is direction-aware so a View\n * response is never echoed back into the View.\n *\n * CSP delivery: the View document is loaded through `srcdoc`, which has no\n * HTTP response of its own, so a response header is impossible and a\n * parent-document `<meta>` (processed only during that document's parse) cannot\n * apply a per-resource policy. The only faithful mechanism is to splice a\n * `<meta http-equiv=\"Content-Security-Policy\">` into the resource HTML before\n * assigning `srcdoc`; the browser then enforces it against the View document.\n *\n * The host sends `params.csp` as a ready-to-use CSP header string (the gateway\n * resource route returns `cspPolicy`). If it is missing or not a string, the\n * page injects the restrictive {@link buildCsp} default rather than\n * `String()`-coercing an object into `[object Object]`.\n *\n * CONTRACT: the host MUST forward the resource's `cspPolicy` string as\n * `params.csp`; it must NOT forward the raw `csp` object from the resource\n * payload (that object is only the declared-origin input to `buildCsp`).\n *\n * Kept as a string constant (rather than a `public/` file plus a build copy\n * step) because the page is a single small document with no runtime imports.\n */\nimport { buildCsp } from \"./buildCsp\";\n\nconst DEFAULT_CSP_LITERAL = JSON.stringify(buildCsp(undefined));\n\nexport const SANDBOX_HTML = `<!doctype html>\n<html lang=\"en\">\n <head>\n <meta charset=\"utf-8\" />\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" />\n <title>MCP App Sandbox</title>\n <style>html, body { margin: 0; height: 100%; }</style>\n </head>\n <body>\n <script>\n (function () {\n var HOST_READY = \"ui/notifications/sandbox-proxy-ready\";\n var RESOURCE_READY = \"ui/notifications/sandbox-resource-ready\";\n var CONTROL_PREFIX = \"ui/notifications/sandbox-\";\n var DEFAULT_CSP = ${DEFAULT_CSP_LITERAL};\n\n function withCsp(html, csp) {\n var policy = typeof csp === \"string\" && csp.length > 0 ? csp : DEFAULT_CSP;\n var escaped = policy.replace(/&/g, \"&amp;\").replace(/\"/g, \"&quot;\");\n var meta = '<meta http-equiv=\"Content-Security-Policy\" content=\"' + escaped + '\">';\n // Insert at the very start (after an optional doctype) so the parser\n // places the meta in the implicit head. Never search for a literal\n // <head>: a resource could hide a decoy inside a comment/string and\n // slip its real head past the splice.\n var doctype = /^\\\\s*<!doctype[^>]*>/i.exec(html);\n if (doctype) {\n return html.slice(0, doctype[0].length) + meta + html.slice(doctype[0].length);\n }\n return meta + html;\n }\n\n // Size reporter injected into every View document. The host renders the\n // View inside an opaque-origin iframe it cannot measure, so auto-height\n // only happens when the View posts ui/notifications/size-changed. Most\n // hand-written plugin apps never do; this script makes every app report\n // its own content size. It only measures and postMessages — it never\n // mutates the app's DOM.\n var SIZE_REPORTER = [\n \"(function(){\",\n \"function send(){\",\n \"try{\",\n \"var d=document.documentElement,b=document.body;\",\n \"var w=Math.ceil(Math.max(d?d.scrollWidth:0,b?b.scrollWidth:0));\",\n \"var h=Math.ceil(Math.max(d?d.scrollHeight:0,b?b.scrollHeight:0));\",\n \"window.parent.postMessage({jsonrpc:'2.0',method:'ui/notifications/size-changed',params:{width:w,height:h}},'*');\",\n \"}catch(e){}\",\n \"}\",\n \"send();\",\n \"window.addEventListener('load',send);\",\n \"if(typeof ResizeObserver!=='undefined'){\",\n \"var ro=new ResizeObserver(send);\",\n \"ro.observe(document.documentElement);\",\n \"if(document.body)ro.observe(document.body);\",\n \"}else{window.addEventListener('resize',send);}\",\n \"})();\"\n ].join(\"\");\n\n function withSizeReporter(html) {\n // Split the closing tag so this template literal never contains a\n // literal script terminator that would end the sandbox page's own\n // script block during HTML parsing.\n var tag = \"<scr\" + \"ipt>\" + SIZE_REPORTER + \"<\" + \"/scr\" + \"ipt>\";\n var lower = html.toLowerCase();\n var bodyEnd = lower.lastIndexOf(\"</body>\");\n if (bodyEnd >= 0) return html.slice(0, bodyEnd) + tag + html.slice(bodyEnd);\n return html + tag;\n }\n\n var inner = null;\n\n window.parent.postMessage({ jsonrpc: \"2.0\", method: HOST_READY, params: {} }, \"*\");\n\n window.addEventListener(\"message\", function (event) {\n if (event.source !== window.parent) return;\n var data = event.data;\n if (!data || typeof data !== \"object\") return;\n\n if (data.method === RESOURCE_READY) {\n var params = data.params || {};\n if (inner && inner.parentNode) inner.parentNode.removeChild(inner);\n inner = document.createElement(\"iframe\");\n inner.setAttribute(\"sandbox\", params.sandbox || \"allow-scripts\");\n inner.setAttribute(\"srcdoc\", withCsp(withSizeReporter(String(params.html || \"\")), params.csp));\n inner.style.cssText = \"width:100%;height:100%;border:0;display:block\";\n document.body.appendChild(inner);\n return;\n }\n\n if (typeof data.method === \"string\" && data.method.indexOf(CONTROL_PREFIX) === 0) return;\n if (inner && inner.contentWindow) inner.contentWindow.postMessage(data, \"*\");\n });\n\n window.addEventListener(\"message\", function (event) {\n if (inner && event.source === inner.contentWindow) {\n var data = event.data;\n if (data && typeof data === \"object\" && typeof data.method === \"string\"\n && data.method.indexOf(CONTROL_PREFIX) === 0) return;\n window.parent.postMessage(event.data, \"*\");\n }\n });\n })();\n </script>\n </body>\n</html>\n`;\n","import { listTenantPlugins } from \"@axiom-lattice/core\";\nimport type { Plugin } from \"@axiom-lattice/protocols\";\n\n/**\n * Load and merge the global ∪ tenant plugin set for a tenant.\n *\n * Thin gateway re-export of the core {@link listTenantPlugins} primitive — the\n * single source of truth for tenant plugin resolution, shared with tenant\n * plugin agents, the architect's `list_middleware_types`, and the connection\n * routes. Kept as a module so gateway services keep one import site.\n */\nexport { listTenantPlugins };\n\n/**\n * Resolve one merged plugin by `meta.type` for a tenant.\n *\n * @param tenantId - Tenant whose plugins to search.\n * @param type - Plugin type to resolve.\n * @returns The merged plugin, or `undefined` when no source declares the type.\n */\nexport async function resolveTenantPluginByType(\n tenantId: string,\n type: string,\n): Promise<Plugin | undefined> {\n return (await listTenantPlugins(tenantId)).find((p) => p.meta.type === type);\n}\n"],"mappings":"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","names":["context"]}
@@ -1 +1 @@
1
- import{k as R}from"./embed-page-chunk-FF2HNPMW.js";import"./embed-page-chunk-5HWN5HSA.js";import"./embed-page-chunk-DI5UAV2I.js";import"./embed-page-chunk-4BPMGDDV.js";import"./embed-page-chunk-HQLSH3FC.js";import"./embed-page-chunk-5AWYMAAX.js";import"./embed-page-chunk-D7YTSCUO.js";import"./embed-page-chunk-S4XZPBRM.js";import"./embed-page-chunk-BBIV2YA2.js";import{U as L,h as E}from"./embed-page-chunk-MVT6CPWE.js";import"./embed-page-chunk-54M4265G.js";import{a as P}from"./embed-page-chunk-3XPHW2C7.js";import"./embed-page-chunk-5QZRLAW2.js";import"./embed-page-chunk-F7ZUYG42.js";import{l as C}from"./embed-page-chunk-3FNSGFP2.js";import{a as F}from"./embed-page-chunk-QV7QAJ4N.js";import"./embed-page-chunk-VW3NF5NT.js";import"./embed-page-chunk-Z4Z6VCUZ.js";import"./embed-page-chunk-L7GPZSYD.js";import{Ja as T,W as p,_ as m,aa as b,za as I}from"./embed-page-chunk-BUFWD6SE.js";import{a as O}from"./embed-page-chunk-R5QL57JJ.js";import"./embed-page-chunk-QOWM3LMZ.js";import"./embed-page-chunk-EUOOO2LS.js";import"./embed-page-chunk-5JDQ456X.js";import{f as u}from"./embed-page-chunk-QBTAJ2YI.js";var n=u(O());var t=u(F()),$={component_key:"workspace_assistants",data:{}},J=d=>{let i=d;if(typeof d=="string")try{i=JSON.parse(d)}catch{return{}}return i!==null&&typeof i=="object"&&!Array.isArray(i)?i:{}},X=({data:d})=>{let{message:i}=b.useApp(),{assistantId:l,initialTab:B}=d??{},{get:f,put:A,del:y}=P(),e=C(),v=E(),[g,w]=(0,n.useState)(null),[_,h]=(0,n.useState)([]),[j,S]=(0,n.useState)(!1),[x,k]=(0,n.useState)(null),c=(0,n.useCallback)(()=>{v({...$,message:e("governance.detail.listCardMessage")})},[v,e]),o=(0,n.useCallback)(async()=>{S(!0),k(null);try{let s=(await f("/api/assistants")).data?.records??[];h(s),w(s.find(r=>r.id===l)??null)}catch{k(e("governance.detail.loadFailed"))}finally{S(!1)}},[f,l,e]);(0,n.useEffect)(()=>{l&&o()},[o,l]);let z=(0,n.useCallback)(async(a,s)=>{let r=J(a.graphDefinition),D;try{D=await A(`/api/assistants/${a.id}`,{name:s.name!==void 0?s.name:a.name,description:s.description!==void 0?s.description:a.description,graphDefinition:{...r,...s}})}catch(N){throw i.error(e("governance.detail.saveFailed")),N}if(!D.success)throw i.error(e("governance.detail.saveFailed")),new Error("Failed to save agent");i.success(e("common.saved")),await o()},[A,o,e]),U=(0,n.useCallback)(a=>{w(s=>s&&s.id===a.id?a:s),h(s=>s.map(r=>r.id===a.id?a:r))},[]),G=(0,n.useCallback)(async a=>{if(!(await y(`/api/assistants/${a}`)).success)throw new Error("Failed to delete agent");i.success(e("governance.detail.deleted")),c()},[y,c,e]);return l?g?(0,t.jsx)("div",{style:{height:"100%",overflow:"auto"},children:(0,t.jsx)(L,{children:(0,t.jsx)(R,{assistant:g,allAssistants:_,onBack:c,onDeleted:G,onSave:z,onAssistantUpdated:U,onAgentListInvalidated:()=>void o(),initialTab:B})},g.id)}):j?(0,t.jsx)("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",height:"100%"},children:(0,t.jsx)(T,{})}):x?(0,t.jsx)("div",{style:{padding:24},children:(0,t.jsx)(p,{type:"error",showIcon:!0,message:e("governance.detail.loadFailed"),"data-testid":"detail-error",action:(0,t.jsxs)(I,{children:[(0,t.jsx)(m,{size:"small",onClick:()=>void o(),children:e("common.retry")}),(0,t.jsx)(m,{size:"small",type:"primary",onClick:c,children:e("governance.detail.backToList")})]})})}):(0,t.jsx)("div",{style:{padding:24},children:(0,t.jsx)(p,{type:"warning",showIcon:!0,message:e("governance.detail.notFound"),"data-testid":"detail-not-found",action:(0,t.jsx)(m,{size:"small",type:"primary",onClick:c,children:e("governance.detail.backToList")})})}):(0,t.jsx)("div",{style:{padding:24},children:(0,t.jsx)(p,{type:"warning",showIcon:!0,message:e("governance.detail.missingId"),"data-testid":"detail-missing-id"})})};export{X as AgentDetailSideApp};
1
+ import{k as R}from"./embed-page-chunk-AJV2ISVF.js";import"./embed-page-chunk-62CAXPZK.js";import"./embed-page-chunk-NGO5C5RH.js";import"./embed-page-chunk-NR4M6XSO.js";import"./embed-page-chunk-HQLSH3FC.js";import"./embed-page-chunk-5AWYMAAX.js";import"./embed-page-chunk-D7YTSCUO.js";import"./embed-page-chunk-S4XZPBRM.js";import"./embed-page-chunk-KKNZYZVB.js";import{U as L,h as E}from"./embed-page-chunk-KWZEITYQ.js";import"./embed-page-chunk-54M4265G.js";import{a as P}from"./embed-page-chunk-3XPHW2C7.js";import"./embed-page-chunk-5QZRLAW2.js";import"./embed-page-chunk-F7ZUYG42.js";import{l as C}from"./embed-page-chunk-3FNSGFP2.js";import{a as F}from"./embed-page-chunk-QV7QAJ4N.js";import"./embed-page-chunk-VW3NF5NT.js";import"./embed-page-chunk-Z4Z6VCUZ.js";import"./embed-page-chunk-L7GPZSYD.js";import{Ja as T,W as p,_ as m,aa as b,za as I}from"./embed-page-chunk-BUFWD6SE.js";import{a as O}from"./embed-page-chunk-R5QL57JJ.js";import"./embed-page-chunk-QOWM3LMZ.js";import"./embed-page-chunk-EUOOO2LS.js";import"./embed-page-chunk-5JDQ456X.js";import{f as u}from"./embed-page-chunk-QBTAJ2YI.js";var n=u(O());var t=u(F()),$={component_key:"workspace_assistants",data:{}},J=d=>{let i=d;if(typeof d=="string")try{i=JSON.parse(d)}catch{return{}}return i!==null&&typeof i=="object"&&!Array.isArray(i)?i:{}},X=({data:d})=>{let{message:i}=b.useApp(),{assistantId:l,initialTab:B}=d??{},{get:f,put:A,del:y}=P(),e=C(),v=E(),[g,w]=(0,n.useState)(null),[_,h]=(0,n.useState)([]),[j,S]=(0,n.useState)(!1),[x,k]=(0,n.useState)(null),c=(0,n.useCallback)(()=>{v({...$,message:e("governance.detail.listCardMessage")})},[v,e]),o=(0,n.useCallback)(async()=>{S(!0),k(null);try{let s=(await f("/api/assistants")).data?.records??[];h(s),w(s.find(r=>r.id===l)??null)}catch{k(e("governance.detail.loadFailed"))}finally{S(!1)}},[f,l,e]);(0,n.useEffect)(()=>{l&&o()},[o,l]);let z=(0,n.useCallback)(async(a,s)=>{let r=J(a.graphDefinition),D;try{D=await A(`/api/assistants/${a.id}`,{name:s.name!==void 0?s.name:a.name,description:s.description!==void 0?s.description:a.description,graphDefinition:{...r,...s}})}catch(N){throw i.error(e("governance.detail.saveFailed")),N}if(!D.success)throw i.error(e("governance.detail.saveFailed")),new Error("Failed to save agent");i.success(e("common.saved")),await o()},[A,o,e]),U=(0,n.useCallback)(a=>{w(s=>s&&s.id===a.id?a:s),h(s=>s.map(r=>r.id===a.id?a:r))},[]),G=(0,n.useCallback)(async a=>{if(!(await y(`/api/assistants/${a}`)).success)throw new Error("Failed to delete agent");i.success(e("governance.detail.deleted")),c()},[y,c,e]);return l?g?(0,t.jsx)("div",{style:{height:"100%",overflow:"auto"},children:(0,t.jsx)(L,{children:(0,t.jsx)(R,{assistant:g,allAssistants:_,onBack:c,onDeleted:G,onSave:z,onAssistantUpdated:U,onAgentListInvalidated:()=>void o(),initialTab:B})},g.id)}):j?(0,t.jsx)("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",height:"100%"},children:(0,t.jsx)(T,{})}):x?(0,t.jsx)("div",{style:{padding:24},children:(0,t.jsx)(p,{type:"error",showIcon:!0,message:e("governance.detail.loadFailed"),"data-testid":"detail-error",action:(0,t.jsxs)(I,{children:[(0,t.jsx)(m,{size:"small",onClick:()=>void o(),children:e("common.retry")}),(0,t.jsx)(m,{size:"small",type:"primary",onClick:c,children:e("governance.detail.backToList")})]})})}):(0,t.jsx)("div",{style:{padding:24},children:(0,t.jsx)(p,{type:"warning",showIcon:!0,message:e("governance.detail.notFound"),"data-testid":"detail-not-found",action:(0,t.jsx)(m,{size:"small",type:"primary",onClick:c,children:e("governance.detail.backToList")})})}):(0,t.jsx)("div",{style:{padding:24},children:(0,t.jsx)(p,{type:"warning",showIcon:!0,message:e("governance.detail.missingId"),"data-testid":"detail-missing-id"})})};export{X as AgentDetailSideApp};
@@ -1 +1 @@
1
- import{a as Ie,b as De,c as xt,d as wt,e as Tt,f as It,g as St,h as Ft,i as Pt,j as Rt,k as Dt}from"./embed-page-chunk-FF2HNPMW.js";import{a as Ge}from"./embed-page-chunk-5HWN5HSA.js";import"./embed-page-chunk-DI5UAV2I.js";import"./embed-page-chunk-4BPMGDDV.js";import"./embed-page-chunk-HQLSH3FC.js";import{b as Ve,e as _e,f as yt,g as ht,h as Ct,i as At,l as bt,m as kt}from"./embed-page-chunk-5AWYMAAX.js";import"./embed-page-chunk-D7YTSCUO.js";import{a as dt,b as gt,c as pt,d as mt,e as ut}from"./embed-page-chunk-SV2BM3WO.js";import"./embed-page-chunk-S4XZPBRM.js";import"./embed-page-chunk-BBIV2YA2.js";import{U as vt,e as ct,h as ft,r as Oe}from"./embed-page-chunk-MVT6CPWE.js";import{i as lt}from"./embed-page-chunk-54M4265G.js";import{a as me}from"./embed-page-chunk-3XPHW2C7.js";import{o as Ye}from"./embed-page-chunk-5QZRLAW2.js";import{C as tt,La as rt,Q as nt,U as at,ba as ot,n as Te,oa as it,ua as st}from"./embed-page-chunk-F7ZUYG42.js";import{l as z}from"./embed-page-chunk-3FNSGFP2.js";import{a as D}from"./embed-page-chunk-QV7QAJ4N.js";import"./embed-page-chunk-VW3NF5NT.js";import"./embed-page-chunk-Z4Z6VCUZ.js";import{Ja as et,Q as Qe,g as Je,na as Re,za as Xe}from"./embed-page-chunk-L7GPZSYD.js";import{Da as F,Ia as O,Ka as Ne,Ma as pe,Sa as We,Za as we,_ as $,_a as Ze,aa as Fe,bb as J,fa as xe,ha as Ue,na as Pe,ua as Le,va as qe,xa as He,za as $e}from"./embed-page-chunk-BUFWD6SE.js";import{a as ge}from"./embed-page-chunk-R5QL57JJ.js";import"./embed-page-chunk-QOWM3LMZ.js";import"./embed-page-chunk-EUOOO2LS.js";import"./embed-page-chunk-5JDQ456X.js";import{f as T}from"./embed-page-chunk-QBTAJ2YI.js";var C=T(ge());var X=T(ge());var W=T(ge());var Mt=T(ge());var ie=T(D()),Et=60,Kt=72,ze=(0,Mt.memo)(({data:a})=>{let c=Ie(a.type),f=Math.min(12+Math.sqrt(a.subAgentCount)*10,48);return(0,ie.jsxs)("div",{style:{display:"flex",flexDirection:"column",alignItems:"center"},children:[(0,ie.jsx)(_e,{type:"target",position:Ve.Top,style:{left:"50%",top:"50%",transform:"translate(-50%, -50%)",background:"transparent",border:"none",width:0,height:0},isConnectable:!1}),(0,ie.jsx)("div",{title:a.label,style:{width:f,height:f,borderRadius:"50%",background:De(c.color),display:"flex",alignItems:"center",justifyContent:"center",color:"#fff",fontSize:Math.max(10,f*.4),fontWeight:600,cursor:"pointer",boxShadow:"0 2px 8px rgba(0,0,0,0.15)"},children:a.label.charAt(0).toUpperCase()}),(0,ie.jsx)("div",{style:{fontSize:11,maxWidth:120,textAlign:"center",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",marginTop:4},children:a.label}),(0,ie.jsx)(_e,{type:"source",position:Ve.Top,style:{left:"50%",top:"50%",transform:"translate(-50%, -50%)",background:"transparent",border:"none",width:0,height:0},isConnectable:!1})]})});ze.displayName="AgentGraphNode";var Q=T(D()),tn=({assistants:a,onNodeClick:c})=>{let[f,A,d]=Ct([]),[g,i,e]=At([]),[l,I]=(0,W.useState)(null),m=(0,W.useMemo)(()=>({agent:ze}),[]),R=(0,W.useMemo)(()=>Tt(a),[a]);(0,W.useEffect)(()=>{let u=R.nodes.map(o=>({id:o.id})),P=R.edges.map(o=>({source:o.source,target:o.target})),M=new Map(R.nodes.map(o=>[o.id,o])),_=mt(u).force("link",pt(P).id(o=>o.id).distance(80)).force("charge",ut().strength(-220)).force("center",dt(0,0)).force("collide",gt(45)).stop();for(let o=0;o<300;o++)_.tick();let q=u.map(o=>({id:o.id,type:"agent",data:M.get(o.id),position:{x:o.x-Et/2,y:o.y-Kt/2}})),r=R.edges.map(o=>({id:`e${o.source}-${o.target}`,source:o.source,target:o.target,style:{stroke:"#1677ff",strokeWidth:2},type:"straight"}));A(q),i(r)},[R,A,i]);let U=(0,W.useMemo)(()=>l===null?f:f.map(u=>{let P=u.id===l||g.some(M=>M.source===l&&M.target===u.id||M.target===l&&M.source===u.id);return{...u,style:{opacity:P?1:.2,transition:"opacity 0.2s ease"}}}),[f,g,l]),y=(0,W.useMemo)(()=>l===null?g.map(u=>({...u,style:{stroke:"#1677ff",strokeWidth:1.5,opacity:.25,transition:"opacity 0.2s ease"}})):g.map(u=>{let P=u.source===l||u.target===l;return{...u,style:{stroke:"#1677ff",strokeWidth:P?2.5:1,opacity:P?1:.04,transition:"opacity 0.2s ease"}}}),[g,l]);return(0,Q.jsx)("div",{style:{width:"100%",height:"100%",background:"#fafafa",position:"relative"},children:(0,Q.jsxs)(ht,{nodes:U,edges:y,onNodesChange:d,onEdgesChange:e,onNodeMouseEnter:(u,P)=>I(P.id),onNodeMouseLeave:()=>I(null),onNodeClick:(u,P)=>c?.(String(P.id)),nodeTypes:m,fitView:!0,fitViewOptions:{padding:.25},children:[(0,Q.jsx)(bt,{color:"#eee",gap:20}),(0,Q.jsx)(kt,{})]})})},Bt=a=>(0,Q.jsx)(yt,{children:(0,Q.jsx)(tn,{...a})});var w=T(D()),nn=[{key:"all",labelKey:"governance.list.tab.all"},{key:"capability",labelKey:"governance.list.tab.capability"},{key:"orchestrator",labelKey:"governance.list.tab.orchestrator"},{key:"workflow",labelKey:"governance.list.tab.workflow"}],Lt=({items:a,assistants:c=[],loading:f,onItemClick:A,onOpenPlayground:d,onOpenEval:g,onCreate:i,onDelete:e})=>{let l=z(),[I,m]=(0,X.useState)("all"),[R,U]=(0,X.useState)(null),[y,u]=(0,X.useState)(null),P=(0,X.useMemo)(()=>{let r=new Set;return a.forEach(o=>o.tags.forEach(te=>r.add(te))),Array.from(r).map(o=>({value:o,label:o}))},[a]),M=(0,X.useMemo)(()=>a.filter(r=>!(I!=="all"&&r.type!==I||R&&!r.tags.includes(R)||y&&r.status!==y)),[a,I,R,y]),_=[{key:"edit",icon:st,label:l("common.edit"),onClick:r=>A(r.id)},{key:"playground",icon:tt,label:l("governance.list.action.playground"),onClick:r=>d(r.id)},{key:"eval",icon:at,label:l("governance.list.action.eval"),onClick:r=>g(r.id)}];e&&_.push({key:"delete",icon:rt,label:l("common.delete"),danger:!0,onClick:r=>e(r.id)});let q=(0,X.useMemo)(()=>[{mode:"graph",icon:it,label:l("governance.list.viewMode.graph"),render:()=>(0,w.jsx)(Bt,{assistants:c,onNodeClick:A})}],[c,A,l]);return(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)("span",{"data-testid":"agent-list-state","data-loading":String(f),"data-count":M.length,hidden:!0,"aria-hidden":"true"}),(0,w.jsx)(ct,{title:l("governance.list.title"),itemName:"common.item.agent",items:M,loading:f,keyExtractor:r=>r.id,tabs:nn.map(r=>({key:r.key,label:l(r.labelKey)})),activeTab:I,onTabChange:r=>m(r),headerLeft:(0,w.jsxs)("div",{style:{display:"flex",gap:8,alignItems:"center"},children:[(0,w.jsx)(Oe,{value:R,onChange:U,options:P,placeholder:l("governance.list.filter.domain"),allLabel:l("governance.list.filter.allDomains")}),(0,w.jsx)(Oe,{value:y,onChange:u,options:[{value:"enabled",label:l("governance.list.status.enabled")},{value:"draft",label:l("governance.list.status.draft")},{value:"disabled",label:l("governance.list.status.disabled")}],placeholder:l("governance.list.filter.status"),allLabel:l("governance.list.filter.allStatuses")})]}),renderIcon:r=>{let o=De(Ie(r.type).color);return(0,w.jsx)("div",{title:l("governance.list.typeIconTitle",{type:r.type}),style:{width:32,height:32,borderRadius:8,background:`${o}1A`,color:o,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:(0,w.jsx)(Te,{size:18})})},renderPrimary:r=>(0,w.jsx)("span",{"data-testid":"agent-name","data-agent-id":r.id,children:r.name}),renderSecondary:r=>r.description||void 0,renderDetails:r=>(0,w.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",gap:8,flexWrap:"wrap"},children:[(0,w.jsxs)("div",{style:{display:"flex",gap:4,flexWrap:"wrap",alignItems:"center"},children:[r.tags.map(o=>(0,w.jsx)(we,{color:"magenta",style:{margin:0,borderRadius:10,border:"none"},children:o},o)),(0,w.jsx)(we,{color:Ie(r.type).color,style:{margin:0,borderRadius:10,border:"none"},children:r.type})]}),(0,w.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,flexShrink:0},children:[(0,w.jsx)(Ue,{title:l("governance.list.statusTooltip",{status:r.status}),children:(0,w.jsx)("span",{style:{width:8,height:8,borderRadius:"50%",background:xt(r.status),display:"inline-block",cursor:"help"}})}),(0,w.jsx)("span",{style:{fontSize:12,color:"#8c8c8c"},children:r.version})]})]}),itemActions:_,actionsStyle:"icon",actionsPosition:"hover",onItemClick:r=>A(r.id),createLabel:l("governance.list.create"),onCreateClick:i,viewModeExtensions:q,emptyIcon:(0,w.jsx)(Te,{size:48,style:{opacity:.5}}),emptyTitle:l("governance.list.emptyTitle"),emptyDescription:l("governance.list.emptyDescription")})]})};var b=T(ge());var se=T(ge());var ue=T(D()),{Text:an}=J,Nt=({onSelect:a,value:c,placeholder:f})=>{let A=z(),d=f??A("chatConfig.parentAgent.selectPlaceholder"),[g,i]=(0,se.useState)([]),[e,l]=(0,se.useState)(!1),{get:I}=me(),m=(0,se.useCallback)(async()=>{l(!0);try{let y=await I("/api/assistants");y.success&&i(y.data?.records||[])}catch(y){console.error("Failed to fetch assistants:",y)}finally{l(!1)}},[I]);return(0,se.useEffect)(()=>{m()},[m]),(0,ue.jsx)(xe,{showSearch:!0,allowClear:!0,value:c,placeholder:d,loading:e,onChange:y=>{if(!y){a(null);return}let u=g.find(P=>P.id===y);a(u||null)},onDropdownVisibleChange:y=>{y&&m()},optionFilterProp:"label",style:{width:"100%"},options:g.map(y=>({value:y.id,label:y.name||y.id,description:y.description})),optionRender:y=>(0,ue.jsxs)("div",{children:[(0,ue.jsx)("div",{children:y.label}),y.data.description&&(0,ue.jsx)(an,{type:"secondary",style:{fontSize:12},children:y.data.description})]})})};var B=T(D()),{Text:Ot}=J,Vt=({subAgentKeys:a,decisions:c,onChange:f})=>{let{token:A}=Ze.useToken(),d=z(),g=(e,l)=>{let I=c.map(m=>m.originalKey===e?{...m,clone:l,cloneKey:l?`${e}_clone`:void 0}:m);f(I)},i=(e,l)=>{let I=c.map(m=>m.originalKey===e?{...m,cloneKey:l}:m);f(I)};return a.length===0?null:(0,B.jsxs)("div",{children:[(0,B.jsx)(Ot,{type:"secondary",style:{display:"block",marginBottom:8},children:d("chatConfig.subAgentInherit.hint")}),(0,B.jsx)(Ne,{size:"small",bordered:!0,dataSource:c,style:{borderRadius:A.borderRadius},renderItem:e=>(0,B.jsxs)(Ne.Item,{style:{display:"flex",flexDirection:"column",alignItems:"stretch",gap:8,padding:"8px 16px"},children:[(0,B.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[(0,B.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.clone?(0,B.jsx)(Re,{style:{color:A.colorPrimary}}):(0,B.jsx)(Xe,{style:{color:A.colorTextSecondary}}),(0,B.jsx)(Ot,{style:{fontFamily:"monospace"},children:e.originalKey})]}),(0,B.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8},children:[(0,B.jsx)(we,{color:e.clone?"blue":"default",children:e.clone?d("chatConfig.subAgentInherit.clone"):d("chatConfig.subAgentInherit.reuse")}),(0,B.jsx)(We,{size:"small",checked:e.clone,onChange:l=>g(e.originalKey,l)})]})]}),e.clone&&(0,B.jsx)(O,{size:"small",placeholder:d("chatConfig.subAgentInherit.cloneKeyPlaceholder"),value:e.cloneKey,onChange:l=>i(e.originalKey,l.target.value),style:{fontFamily:"monospace",fontSize:12},addonBefore:d("chatConfig.keyValue.key")})]})})]})};function _t(a,c){return a.mode!=="local"||a.templateKey||typeof a.executable=="string"&&a.executable.trim().length>0?null:c?c("chat.config.executableRequired"):"Choose a template or enter a custom executable"}var n=T(D()),{TextArea:Gt}=O,{Text:ee}=J,zt="/.well-known/agent-card.json",on=[{value:"http://",label:"http://"},{value:"https://",label:"https://"}],sn={react:"chatConfig.createAssistant.typeDesc.react",deep_agent:"chatConfig.createAssistant.typeDesc.deepAgent",a2a_remote:"chatConfig.createAssistant.typeDesc.a2aRemote"};function jt(a,c,f="https://"){let A=String(a??"").trim();if(!A)return"";let d=c==="http://"||c==="https://"?c:f,i=(/^https?:\/\//i.test(A)?A:`${d}${A.replace(/^\/+/,"")}`).replace(/\/+$/,"");return i.endsWith(zt)?i:`${i}${zt}`}function rn(a){try{return new URL(a).port||void 0}catch{return}}function ln(a){return a.some(c=>c==="--port"||c==="-p"||/^--port=/.test(c)||/^-p=/.test(c))}function Ut(a,c){let f=[...a.args],A=rn(c);return A&&!ln(f)&&f.push("--port",A),{...a,args:f,...a.env?{env:{...a.env}}:{}}}var qt=({open:a,onCancel:c,onSuccess:f,initialMode:A,initialValues:d})=>{let{message:g}=Fe.useApp(),[i]=F.useForm(),e=z(),[l,I]=(0,b.useState)(!1),[m,R]=(0,b.useState)("learn"),[U,y]=(0,b.useState)(""),[u,P]=(0,b.useState)(null),[M,_]=(0,b.useState)([]),q=F.useWatch("type",i)||"react",r=q==="a2a_remote",[o,te]=(0,b.useState)("remote"),[H,fe]=(0,b.useState)(void 0),[re,ye]=(0,b.useState)([]),[Se,le]=(0,b.useState)(!1),ne=(0,b.useRef)(0),[ae,oe]=(0,b.useState)(!1),[Me,Z]=(0,b.useState)(!1),{get:L,post:Y,put:he}=me(),Ee=Ye("agent-architect"),{workspaceId:Ce,trainingProjects:ce,loading:de}=lt(),[Ke,Ae]=(0,b.useState)(null),Be=JSON.stringify(d??null),E=ce.find(t=>t.id===Ke)??ce[0]??null,[be,ke]=(0,b.useState)([]),p=(0,b.useCallback)(()=>{P(null),_([])},[]),k=(0,b.useCallback)(()=>{i.resetFields(),p(),R("learn"),y(""),ke([]),Ae(null),te("remote"),fe(void 0),ye([]),Z(!1),oe(!1)},[i,p]);(0,b.useEffect)(()=>{if(a){k(),R(A??"learn");let t=d?.a2aMode;(t==="remote"||t==="local")&&te(t),i.setFieldsValue({type:"react",agentCardProtocol:"https://",a2aMode:"remote",timeout:3e5,...d})}},[a,i,A,Be,k]),(0,b.useEffect)(()=>{let t=++ne.current,s=!0;return a&&r?(i.setFieldValue("prompt",""),o==="local"?(le(!0),L("/api/local-a2a/templates").then(v=>{s&&t===ne.current&&v?.data?.records&&ye(v.data.records)}).catch(()=>{s&&t===ne.current&&ye([])}).finally(()=>{s&&t===ne.current&&le(!1)})):le(!1)):le(!1),()=>{s=!1,ne.current+=1}},[i,r,o,L,a]);let x=re.find(t=>t.key===H),j=(0,b.useCallback)(()=>{let t=_t({mode:o,templateKey:H,executable:i.getFieldValue("commandExecutable")},e);return t?(Z(!0),i.setFields([{name:"commandExecutable",errors:[t]}]),g.warning(t),!1):!0},[o,H,i,e]);(0,b.useEffect)(()=>{x&&i.setFieldsValue({agentCardProtocol:"http://"})},[i,x]);let ve=(0,b.useCallback)(async()=>{if(!j())return;let t=jt(i.getFieldValue("agentCardUrl"),i.getFieldValue("agentCardProtocol"),o==="local"?"http://":"https://");if(!t){g.warning(e("chatConfig.createAssistant.a2aUrlWarning"));return}oe(!0);try{let s={agentCardUrl:t,apiKey:i.getFieldValue("apiKey")};if(o==="local"){let h=x;if(h)s.localRuntime={label:i.getFieldValue("name")||void 0,agentCardUrl:t,command:Ut(h.command,t)};else{let K=i.getFieldValue("commandArgs")||"",G=K?K.split(/\s+/).filter(Boolean):[],S=String(i.getFieldValue(["command","cwd"])||"").trim();s.localRuntime={label:i.getFieldValue("name")||void 0,agentCardUrl:t,command:{executable:String(i.getFieldValue("commandExecutable")||"").trim(),args:G,...S?{cwd:S}:{}}}}}let v=await Y("/api/a2a/test-connection",s);if(v.data?.reachable){let h=v.data.agentCard;g.success(e("chatConfig.createAssistant.connectedTo",{name:v.data.agentName||t}))}else g.error(v.data?.error||e("chatConfig.createAssistant.connectionFailed"))}catch{g.error(e("chatConfig.createAssistant.connectionTestFailed"))}finally{oe(!1)}},[i,Y,o,x,j,e]),Wt=(0,b.useCallback)(t=>{if(P(t),!t){i.resetFields(["key","name","description","type","prompt"]),_([]);return}let s=typeof t.graphDefinition=="object"&&t.graphDefinition!==null?t.graphDefinition:{},v=s.key||t.id,h=t.name||s.name||"";i.setFieldsValue({key:`${v}_ext`,name:h?`${h} (Extended)`:"",description:t.description||s.description||"",type:s.type||"react",prompt:s.prompt||""});let K=s.subAgents||[];_(K.map(G=>({originalKey:G,clone:!1})))},[i]),Zt=async(t,s)=>{let v=await L(`/api/assistants/${t}`);if(!v.success)throw new Error(e("chatConfig.createAssistant.cloneFetchFailed",{key:t}));let h=v.data,K=typeof h.graphDefinition=="object"?h.graphDefinition:{},G={id:s,name:`${h.name} (Clone)`,description:h.description||"",graphDefinition:{...K,key:s,name:`${h.name} (Clone)`}},S=await Y("/api/assistants",G);if(!S.success)throw new Error(S.message||e("chatConfig.createAssistant.cloneFailed",{key:t}));return S.data},Yt=t=>{let s={id:t.key,name:t.name,description:t.description||"",graphDefinition:{key:t.key,name:t.name,description:t.description||"",type:t.type,prompt:t.prompt||"",tools:[],skills:[],subAgents:t.type==="deep_agent"?[]:void 0,middleware:[]}};if(t.type==="a2a_remote"&&(s.graphDefinition.agentCardUrl=jt(t.agentCardUrl,t.agentCardProtocol,(t.a2aMode||o)==="local"?"http://":"https://"),t.apiKey&&(s.graphDefinition.apiKey=t.apiKey),t.timeout&&(s.graphDefinition.timeout=t.timeout),(t.a2aMode||o)==="local")){let v=x;if(v)s.graphDefinition.localRuntime={label:t.name||void 0,agentCardUrl:s.graphDefinition.agentCardUrl,command:Ut(v.command,s.graphDefinition.agentCardUrl)};else{let h=t.commandArgs||"",K=h?h.split(/\s+/).filter(Boolean):[],G=String(t.command?.cwd||"").trim();s.graphDefinition.localRuntime={label:t.name||void 0,agentCardUrl:s.graphDefinition.agentCardUrl,command:{executable:String(t.commandExecutable||"").trim(),args:K,...G?{cwd:G}:{}}}}}return s},Jt=async(t,s)=>{if(!u)throw new Error(e("chatConfig.createAssistant.noParentAgent"));let v=M.filter(S=>S.clone);for(let S of v){if(!S.cloneKey||!S.cloneKey.trim())throw new Error(e("chatConfig.createAssistant.cloneKeyRequired",{key:S.originalKey}));if(!/^[a-zA-Z][a-zA-Z0-9_-]*$/.test(S.cloneKey))throw new Error(e("chatConfig.createAssistant.cloneKeyInvalid",{key:S.cloneKey,originalKey:S.originalKey}))}let h=[];for(let S of M)if(S.clone){let en=await Zt(S.originalKey,S.cloneKey);s.push(en),h.push(S.cloneKey)}else h.push(S.originalKey);let K=typeof u.graphDefinition=="object"?u.graphDefinition:{},G={key:t.key,name:t.name,description:t.description||"",extendsAgent:u.id,type:t.type||K.type};return t.prompt&&t.prompt!==K.prompt&&(G.prompt=t.prompt),(h.length>0||K.subAgents&&K.subAgents.length>0)&&(G.subAgents=h),{id:t.key,name:t.name,description:t.description||"",graphDefinition:G}},Qt=async()=>{if(m==="learn"){let t=U.trim();if(!t){g.error(e("chatConfig.createAssistant.trainingGoalRequired"));return}if(!E){g.error(e("chatConfig.createAssistant.noTrainingProject"));return}I(!0);try{let s=`agent-${St(t+Date.now())}`,v=await Y("/api/assistants",{id:s,name:s,graphDefinition:{key:s,name:s,description:"",type:"react",prompt:"To be trained",metadata:{trainingProjectId:E.id,learningPlaceholder:"true",architectureStatus:"undecided"}}});if(!v.data)throw new Error(e("chatConfig.createAssistant.agentCreateFailed"));let{roundTaskId:h}=await Pt({goal:t,targetAgentId:s,workspaceId:Ce??void 0,projectId:E.id,existingThreadId:Ft(Ee.tenantId,s),files:be,post:Y,put:he});g.success(e("chatConfig.createAssistant.agentCreated")),y(""),ke([]),R("learn"),f?.(v.data,{initialMessage:Rt({goal:t,roundTaskId:h,targetAgentId:s,targetMode:"placeholder",files:be,projectId:E.id,workspaceId:E.workspaceId??Ce??void 0}),projectId:E.id,initialMessageCustomRunConfig:{execution:{taskId:h}}}),c()}catch(s){g.error(s instanceof Error?s.message:e("chatConfig.createAssistant.agentCreateFailed"))}finally{I(!1)}return}try{if(m==="scratch"&&r&&!j())return;let t=await i.validateFields();I(!0);let s=[],v=m==="scratch"?Yt(t):await Jt(t,s),h=await Y("/api/assistants",v);if(h.success){g.success(m==="extend"?e("chatConfig.createAssistant.createdByExtending",{name:u?.name??""}):e("chatConfig.createAssistant.created")),k();for(let K of s)f?.(K);f?.(h.data),c()}else g.error(h.message||e("chatConfig.createAssistant.createFailed"))}catch(t){if(t?.errorFields){let s={key:e("chatConfig.createAssistant.field.key"),name:e("chatConfig.createAssistant.field.name"),description:e("chatConfig.createAssistant.field.description"),prompt:e("chatConfig.createAssistant.field.systemPrompt")},v=t.errorFields.map(h=>s[String((h.name??[])[0])]??String((h.name??[])[0])).filter(Boolean);g.warning(v.length>0?e("chatConfig.createAssistant.requiredFields",{fields:[...new Set(v)].join(", ")}):e("chatConfig.createAssistant.requiredFieldsGeneric"));return}g.error(t.message||e("chatConfig.createAssistant.createError"))}finally{I(!1)}},je=u?.graphDefinition?.subAgents||[],Xt=m==="extend"&&u&&je.length>0;return(0,n.jsxs)(pe,{title:e("chatConfig.createAssistant.title"),open:a,onCancel:()=>{k(),c()},footer:[(0,n.jsx)($,{onClick:()=>{k(),c()},children:e("common.cancel")},"cancel"),(0,n.jsx)($,{type:"primary",icon:m==="extend"?(0,n.jsx)(Re,{}):m==="learn"?(0,n.jsx)(Qe,{}):(0,n.jsx)(et,{}),loading:l,disabled:m==="learn"&&(de||!E),onClick:Qt,children:e(m==="extend"?"chatConfig.createAssistant.createExtend":m==="learn"?"chatConfig.createAssistant.startLearning":"common.create")},"submit")],width:760,children:[m==="extend"&&(0,n.jsxs)("div",{style:{marginBottom:20},children:[(0,n.jsx)(ee,{type:"secondary",style:{display:"block",marginBottom:8},children:e("chatConfig.createAssistant.parentAgent")}),(0,n.jsx)(Nt,{value:u?.id,onSelect:Wt}),u&&(0,n.jsx)(ee,{type:"secondary",style:{display:"block",marginTop:4,fontSize:12},children:e("chatConfig.createAssistant.inheritHint")})]}),m==="extend"&&u&&(0,n.jsx)(Le,{style:{margin:"12px 0"}}),m==="learn"&&(0,n.jsxs)("div",{children:[(0,n.jsx)(ee,{style:{display:"block",marginBottom:8},children:e("chatConfig.createAssistant.learnHint")}),(0,n.jsx)(O.TextArea,{rows:3,value:U,onChange:t=>y(t.target.value),placeholder:e("chatConfig.createAssistant.learnGoalPlaceholder")}),E&&(0,n.jsxs)("div",{style:{marginTop:12},children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:12,marginBottom:8},children:[(0,n.jsx)(ee,{type:"secondary",children:e("chatConfig.createAssistant.referenceFiles")}),(0,n.jsx)(Ge,{project:E,value:E?.id??null,onChange:Ae,loading:de})]}),(0,n.jsx)(It,{projectId:E.id,value:be,onChange:ke}),(0,n.jsx)(ee,{type:"secondary",style:{display:"block",marginTop:6,fontSize:12},children:e("chatConfig.createAssistant.referenceFilesHint")})]}),!E&&!de&&(0,n.jsx)("div",{style:{marginTop:12},children:(0,n.jsx)(Ge,{project:E,value:null,onChange:Ae,loading:de})})]}),m!=="learn"&&(0,n.jsxs)(F,{form:i,layout:"vertical",autoComplete:"off",initialValues:{type:"react",agentCardProtocol:"https://",a2aMode:"remote"},children:[(0,n.jsx)(F.Item,{name:"key",label:e("chatConfig.createAssistant.field.key"),rules:[{required:!0,message:e("chatConfig.createAssistant.validation.keyRequired")},{pattern:/^[a-zA-Z][a-zA-Z0-9_-]*$/,message:e("chatConfig.createAssistant.validation.keyPattern")}],style:{marginBottom:16},children:(0,n.jsx)(O,{placeholder:e("chatConfig.createAssistant.keyPlaceholder")})}),(0,n.jsx)(F.Item,{name:"name",label:e("chatConfig.createAssistant.field.name"),rules:[{required:!0,message:e("chatConfig.createAssistant.validation.nameRequired")}],style:{marginBottom:16},children:(0,n.jsx)(O,{placeholder:e("chatConfig.createAssistant.namePlaceholder")})}),(0,n.jsx)(F.Item,{name:"description",label:e("chatConfig.createAssistant.field.description"),rules:[{required:!0,message:e("chatConfig.createAssistant.validation.descriptionRequired")}],style:{marginBottom:16},children:(0,n.jsx)(Gt,{placeholder:e("chatConfig.createAssistant.descriptionPlaceholder"),autoSize:{minRows:2,maxRows:4}})}),(0,n.jsx)(F.Item,{name:"type",label:e("chatConfig.createAssistant.field.agentType"),rules:[{required:!0}],style:{marginBottom:16},children:(0,n.jsx)(qe,{options:[{value:"react",label:e("chatConfig.agentType.executor")},{value:"deep_agent",label:e("chatConfig.agentType.orchestrator")},{value:"a2a_remote",label:e("chatConfig.agentType.a2aRemote")}],block:!0})}),(0,n.jsx)(ee,{type:"secondary",style:{fontSize:12,display:"block",marginTop:-12,marginBottom:16,lineHeight:1.5},children:e(sn[q]??"chatConfig.createAssistant.typeDesc.react")}),r&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(F.Item,{label:e("chatConfig.createAssistant.field.connectionMode"),style:{marginBottom:16},children:(0,n.jsxs)(Pe.Group,{value:o,onChange:t=>{let s=t.target.value;te(s),i.setFieldValue("a2aMode",s),s==="local"&&i.setFieldValue("agentCardProtocol","http://"),fe(void 0)},optionType:"button",buttonStyle:"solid",children:[(0,n.jsx)(Pe.Button,{value:"remote",children:e("chatConfig.createAssistant.mode.remoteUrl")}),(0,n.jsx)(Pe.Button,{value:"local",children:e("chatConfig.createAssistant.mode.localManaged")})]})}),(0,n.jsx)(F.Item,{name:"a2aMode",noStyle:!0,hidden:!0,children:(0,n.jsx)(O,{})}),o==="local"&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(F.Item,{label:e("chatConfig.createAssistant.field.template"),style:{marginBottom:16},children:(0,n.jsx)(xe,{placeholder:e("chatConfig.createAssistant.templatePlaceholder"),allowClear:!0,loading:Se,value:H,onChange:t=>{fe(t),t&&Z(!1)},options:re.map(t=>({value:t.key,label:t.name||t.key})),notFoundContent:Se?void 0:(0,n.jsx)(ee,{type:"secondary",style:{padding:8,display:"block"},children:e("chatConfig.createAssistant.noTemplates")})})}),!H&&(0,n.jsx)(n.Fragment,{children:Me?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(F.Item,{name:"commandExecutable",label:e("chatConfig.createAssistant.field.executable"),rules:[{required:!0,whitespace:!0,message:e("chatConfig.createAssistant.validation.executableRequired")}],style:{marginBottom:16},children:(0,n.jsx)(O,{placeholder:e("chatConfig.createAssistant.executablePlaceholder")})}),(0,n.jsx)(F.Item,{name:"commandArgs",label:e("chatConfig.createAssistant.field.arguments"),style:{marginBottom:16},children:(0,n.jsx)(O,{placeholder:e("chatConfig.createAssistant.argumentsPlaceholder")})}),(0,n.jsx)(F.Item,{name:["command","cwd"],label:e("chatConfig.createAssistant.field.workingDirectory"),style:{marginBottom:16},children:(0,n.jsx)(O,{placeholder:e("chatConfig.createAssistant.workingDirectoryPlaceholder")})}),(0,n.jsx)($,{type:"link",onClick:()=>{Z(!1),i.setFieldsValue({commandExecutable:"",commandArgs:"",command:{cwd:void 0}})},style:{padding:0,marginBottom:16,display:"block"},children:e("chatConfig.createAssistant.hideCustomCommand")})]}):(0,n.jsx)($,{type:"link",onClick:()=>Z(!0),style:{padding:0,marginBottom:16,display:"block"},children:e("chatConfig.createAssistant.customCommand")})})]}),(0,n.jsx)(F.Item,{label:e("chatConfig.createAssistant.field.agentCardUrl"),required:!0,style:{marginBottom:16},children:(0,n.jsxs)($e.Compact,{style:{width:"100%"},children:[(0,n.jsx)(F.Item,{name:"agentCardProtocol",noStyle:!0,children:(0,n.jsx)(xe,{style:{width:100},options:on})}),(0,n.jsx)(F.Item,{name:"agentCardUrl",noStyle:!0,rules:[{required:!0,message:e("chatConfig.createAssistant.validation.urlRequired")}],children:(0,n.jsx)(O,{placeholder:o==="local"?"localhost:4301":"host:port or full URL"})}),(0,n.jsx)($,{icon:(0,n.jsx)(Je,{}),onClick:ve,loading:ae,children:e("chatConfig.connection.action.test")})]})}),o==="remote"&&(0,n.jsx)(F.Item,{name:"apiKey",label:e("chatConfig.createAssistant.field.apiKeyOptional"),style:{marginBottom:16},children:(0,n.jsx)(O.Password,{placeholder:e("chatConfig.createAssistant.apiKeyPlaceholder")})}),(0,n.jsx)(F.Item,{name:"timeout",label:e("chatConfig.createAssistant.field.timeout"),style:{marginBottom:16},initialValue:3e5,children:(0,n.jsx)(He,{min:1e3,max:36e5,style:{width:"100%"},placeholder:"300000"})})]}),!r&&(0,n.jsx)(F.Item,{name:"prompt",label:e(m==="extend"&&u?"chatConfig.createAssistant.field.systemPromptInherit":"chatConfig.createAssistant.field.systemPrompt"),rules:m==="scratch"?[{required:!0,message:e("chatConfig.createAssistant.validation.systemPromptRequired")}]:[],children:(0,n.jsx)(Gt,{placeholder:e(m==="extend"&&u?"chatConfig.createAssistant.systemPromptInheritPlaceholder":"chatConfig.createAssistant.systemPromptPlaceholder"),autoSize:{minRows:4,maxRows:8},style:{fontFamily:"monospace",fontSize:13,lineHeight:1.6}})})]}),Xt&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(Le,{style:{margin:"12px 0"}}),(0,n.jsx)(ee,{strong:!0,style:{display:"block",marginBottom:8},children:e("chatConfig.createAssistant.subAgents")}),(0,n.jsx)(Vt,{subAgentKeys:je,decisions:M,onChange:_})]})]})};var N=T(D()),{Paragraph:cn,Text:Ht}=J,dn=[{key:"manual",icon:Te,titleKey:"governance.creation.manual.title",descriptionKey:"governance.creation.manual.description"},{key:"external",icon:nt,titleKey:"governance.creation.external.title",descriptionKey:"governance.creation.external.description"},{key:"learn",icon:ot,titleKey:"governance.creation.learn.title",descriptionKey:"governance.creation.learn.description"}],$t=({open:a,onCancel:c,onSelectMethod:f,focusTriggerAfterClose:A=!0})=>{let d=z();return(0,N.jsx)(pe,{title:d("governance.creation.title"),open:a,onCancel:c,footer:null,width:560,centered:!0,destroyOnHidden:!0,focusTriggerAfterClose:A,children:(0,N.jsxs)("div",{style:{padding:"8px 4px 4px"},children:[(0,N.jsx)(cn,{style:{color:"#595959",fontSize:15,margin:"8px 0 24px"},children:d("governance.creation.subtitle")}),(0,N.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:12},children:dn.map(g=>{let i=g.icon,e=d(g.titleKey);return(0,N.jsxs)($,{type:"default",onClick:()=>f(g.key),"aria-label":e,style:{display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"flex-start",gap:16,width:"100%",minHeight:88,height:"auto",padding:16,borderRadius:16,textAlign:"left",whiteSpace:"normal"},children:[(0,N.jsx)("div",{style:{width:40,height:40,borderRadius:12,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,color:"#6366f1",background:"#eeeeff"},children:(0,N.jsx)(i,{size:19})}),(0,N.jsxs)("div",{style:{minWidth:0},children:[(0,N.jsx)(Ht,{strong:!0,style:{display:"block",fontSize:15,marginBottom:3},children:e}),(0,N.jsx)(Ht,{style:{color:"#737373",lineHeight:1.5},children:d(g.descriptionKey)})]})]},g.key)})}),(0,N.jsx)("div",{style:{display:"flex",justifyContent:"flex-end",gap:8,flexWrap:"wrap",marginTop:24},children:(0,N.jsx)($,{onClick:c,children:d("governance.creation.notNow")})})]})})};var V=T(D()),gn=a=>{let c=a;if(typeof a=="string")try{c=JSON.parse(a)}catch{return{}}return c!==null&&typeof c=="object"&&!Array.isArray(c)?c:{}},va=()=>{let{message:a}=Fe.useApp(),{get:c,del:f,put:A}=me(),d=z(),[g,i]=(0,C.useState)([]),[e,l]=(0,C.useState)(!1),[I,m]=(0,C.useState)(null),[R,U]=(0,C.useState)("graph"),[y,u]=(0,C.useState)(null),[P,M]=(0,C.useState)(null),[_,q]=(0,C.useState)(null),[r,o]=(0,C.useState)(!1),[te,H]=(0,C.useState)(!0),[fe,re]=(0,C.useState)(!1),[ye,Se]=(0,C.useState)("learn"),[le,ne]=(0,C.useState)({}),[ae,oe]=(0,C.useState)(null),[Me,Z]=(0,C.useState)(!1),L=(0,C.useCallback)(async()=>{l(!0);try{let p=await c("/api/assistants");p.success&&p.data?.records&&i(p.data.records)}catch{a.error(d("governance.workbench.loadFailed"))}finally{l(!1)}},[c,d]);(0,C.useEffect)(()=>{L()},[L]);let Y=C.default.useMemo(()=>wt(g),[g]),he=g.find(p=>p.id===I)??null,Ee=(0,C.useCallback)((p,k="graph")=>{m(p),U(k),u(null),q(null)},[]),Ce=ft(),ce=(0,C.useCallback)((p,k)=>{let x=g.find(j=>j.id===p)?.name??d("governance.workbench.agentFallback");Ce({component_key:"agent_detail_side_app",data:{assistantId:p,initialTab:k},message:x})},[g,Ce,d]),de=(0,C.useCallback)(()=>{H(!0),o(!0)},[]),Ke=(0,C.useCallback)(p=>{let x={manual:{mode:"scratch",values:{}},external:{mode:"scratch",values:{type:"a2a_remote"}},learn:{mode:"learn",values:{}}}[p];Se(x.mode),ne(x.values),H(!1),o(!1),re(!0)},[]),Ae=(0,C.useCallback)(async(p,k)=>{let x=gn(p.graphDefinition),j;try{j=await A(`/api/assistants/${p.id}`,{name:k.name!==void 0?k.name:p.name,description:k.description!==void 0?k.description:p.description,graphDefinition:{...x,...k}})}catch(ve){throw a.error(d("governance.detail.saveFailed")),ve}if(!j.success)throw a.error(d("governance.detail.saveFailed")),new Error("Failed to save agent");a.success(d("common.saved")),L()},[A,L,d]),Be=(0,C.useCallback)(p=>{i(k=>k.map(x=>x.id===p.id?p:x))},[]),E=(0,C.useCallback)(p=>{oe(p)},[]),be=(0,C.useCallback)(async()=>{if(ae){Z(!0);try{(await f(`/api/assistants/${ae}`)).success?(a.success(d("governance.detail.deleted")),i(k=>k.filter(x=>x.id!==ae)),L(),oe(null)):a.error(d("governance.detail.deleteFailed"))}catch{a.error(d("governance.detail.deleteFailed"))}finally{Z(!1)}}},[ae,f,L,d]),ke=(0,C.useCallback)(async p=>{if(!(await f(`/api/assistants/${p}`)).success)throw new Error("Failed to delete agent");a.success(d("governance.detail.deleted")),i(x=>x.filter(j=>j.id!==p)),L()},[f,L,d]);return(0,V.jsxs)("div",{style:{height:"100%",background:"#fafafa",overflow:"hidden"},children:[he?(0,V.jsx)(vt,{defaultProjectId:_??void 0,children:(0,V.jsx)(Dt,{assistant:he,allAssistants:g,onBack:()=>m(null),onDeleted:ke,onSave:Ae,onAssistantUpdated:Be,onAgentListInvalidated:L,initialTab:R,initialMessage:y,initialMessageCustomRunConfig:P,initialProjectId:_})},he.id):(0,V.jsx)(V.Fragment,{children:(0,V.jsx)(Lt,{items:Y,assistants:g,loading:e,onItemClick:p=>ce(p,"graph"),onOpenPlayground:p=>ce(p,"playground"),onOpenEval:p=>ce(p,"eval"),onCreate:de,onDelete:E})}),(0,V.jsx)($t,{open:r,onCancel:()=>{H(!0),o(!1)},onSelectMethod:Ke,focusTriggerAfterClose:te}),(0,V.jsx)(qt,{open:fe,initialMode:ye,initialValues:le,onCancel:()=>re(!1),onSuccess:(p,k)=>{re(!1),i(x=>x.some(ve=>ve.id===p.id)?x:[p,...x]),Ee(p.id,"graph"),u(k?.initialMessage??null),M(k?.initialMessageCustomRunConfig??null),q(k?.projectId??null),L()}}),(0,V.jsx)(pe,{title:d("governance.deleteAgent"),open:ae!==null,onCancel:()=>oe(null),onOk:be,okText:d("common.delete"),okButtonProps:{danger:!0,loading:Me},cancelText:d("common.cancel"),children:(0,V.jsx)("p",{children:d("governance.delete.irreversible")})})]})};export{va as AgentGovernanceWorkbench};
1
+ import{a as Ie,b as De,c as xt,d as wt,e as Tt,f as It,g as St,h as Ft,i as Pt,j as Rt,k as Dt}from"./embed-page-chunk-AJV2ISVF.js";import{a as Ge}from"./embed-page-chunk-62CAXPZK.js";import"./embed-page-chunk-NGO5C5RH.js";import"./embed-page-chunk-NR4M6XSO.js";import"./embed-page-chunk-HQLSH3FC.js";import{b as Ve,e as _e,f as yt,g as ht,h as Ct,i as At,l as bt,m as kt}from"./embed-page-chunk-5AWYMAAX.js";import"./embed-page-chunk-D7YTSCUO.js";import{a as dt,b as gt,c as pt,d as mt,e as ut}from"./embed-page-chunk-SV2BM3WO.js";import"./embed-page-chunk-S4XZPBRM.js";import"./embed-page-chunk-KKNZYZVB.js";import{U as vt,e as ct,h as ft,r as Oe}from"./embed-page-chunk-KWZEITYQ.js";import{i as lt}from"./embed-page-chunk-54M4265G.js";import{a as me}from"./embed-page-chunk-3XPHW2C7.js";import{o as Ye}from"./embed-page-chunk-5QZRLAW2.js";import{C as tt,La as rt,Q as nt,U as at,ba as ot,n as Te,oa as it,ua as st}from"./embed-page-chunk-F7ZUYG42.js";import{l as z}from"./embed-page-chunk-3FNSGFP2.js";import{a as D}from"./embed-page-chunk-QV7QAJ4N.js";import"./embed-page-chunk-VW3NF5NT.js";import"./embed-page-chunk-Z4Z6VCUZ.js";import{Ja as et,Q as Qe,g as Je,na as Re,za as Xe}from"./embed-page-chunk-L7GPZSYD.js";import{Da as F,Ia as O,Ka as Ne,Ma as pe,Sa as We,Za as we,_ as $,_a as Ze,aa as Fe,bb as J,fa as xe,ha as Ue,na as Pe,ua as Le,va as qe,xa as He,za as $e}from"./embed-page-chunk-BUFWD6SE.js";import{a as ge}from"./embed-page-chunk-R5QL57JJ.js";import"./embed-page-chunk-QOWM3LMZ.js";import"./embed-page-chunk-EUOOO2LS.js";import"./embed-page-chunk-5JDQ456X.js";import{f as T}from"./embed-page-chunk-QBTAJ2YI.js";var C=T(ge());var X=T(ge());var W=T(ge());var Mt=T(ge());var ie=T(D()),Et=60,Kt=72,ze=(0,Mt.memo)(({data:a})=>{let c=Ie(a.type),f=Math.min(12+Math.sqrt(a.subAgentCount)*10,48);return(0,ie.jsxs)("div",{style:{display:"flex",flexDirection:"column",alignItems:"center"},children:[(0,ie.jsx)(_e,{type:"target",position:Ve.Top,style:{left:"50%",top:"50%",transform:"translate(-50%, -50%)",background:"transparent",border:"none",width:0,height:0},isConnectable:!1}),(0,ie.jsx)("div",{title:a.label,style:{width:f,height:f,borderRadius:"50%",background:De(c.color),display:"flex",alignItems:"center",justifyContent:"center",color:"#fff",fontSize:Math.max(10,f*.4),fontWeight:600,cursor:"pointer",boxShadow:"0 2px 8px rgba(0,0,0,0.15)"},children:a.label.charAt(0).toUpperCase()}),(0,ie.jsx)("div",{style:{fontSize:11,maxWidth:120,textAlign:"center",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",marginTop:4},children:a.label}),(0,ie.jsx)(_e,{type:"source",position:Ve.Top,style:{left:"50%",top:"50%",transform:"translate(-50%, -50%)",background:"transparent",border:"none",width:0,height:0},isConnectable:!1})]})});ze.displayName="AgentGraphNode";var Q=T(D()),tn=({assistants:a,onNodeClick:c})=>{let[f,A,d]=Ct([]),[g,i,e]=At([]),[l,I]=(0,W.useState)(null),m=(0,W.useMemo)(()=>({agent:ze}),[]),R=(0,W.useMemo)(()=>Tt(a),[a]);(0,W.useEffect)(()=>{let u=R.nodes.map(o=>({id:o.id})),P=R.edges.map(o=>({source:o.source,target:o.target})),M=new Map(R.nodes.map(o=>[o.id,o])),_=mt(u).force("link",pt(P).id(o=>o.id).distance(80)).force("charge",ut().strength(-220)).force("center",dt(0,0)).force("collide",gt(45)).stop();for(let o=0;o<300;o++)_.tick();let q=u.map(o=>({id:o.id,type:"agent",data:M.get(o.id),position:{x:o.x-Et/2,y:o.y-Kt/2}})),r=R.edges.map(o=>({id:`e${o.source}-${o.target}`,source:o.source,target:o.target,style:{stroke:"#1677ff",strokeWidth:2},type:"straight"}));A(q),i(r)},[R,A,i]);let U=(0,W.useMemo)(()=>l===null?f:f.map(u=>{let P=u.id===l||g.some(M=>M.source===l&&M.target===u.id||M.target===l&&M.source===u.id);return{...u,style:{opacity:P?1:.2,transition:"opacity 0.2s ease"}}}),[f,g,l]),y=(0,W.useMemo)(()=>l===null?g.map(u=>({...u,style:{stroke:"#1677ff",strokeWidth:1.5,opacity:.25,transition:"opacity 0.2s ease"}})):g.map(u=>{let P=u.source===l||u.target===l;return{...u,style:{stroke:"#1677ff",strokeWidth:P?2.5:1,opacity:P?1:.04,transition:"opacity 0.2s ease"}}}),[g,l]);return(0,Q.jsx)("div",{style:{width:"100%",height:"100%",background:"#fafafa",position:"relative"},children:(0,Q.jsxs)(ht,{nodes:U,edges:y,onNodesChange:d,onEdgesChange:e,onNodeMouseEnter:(u,P)=>I(P.id),onNodeMouseLeave:()=>I(null),onNodeClick:(u,P)=>c?.(String(P.id)),nodeTypes:m,fitView:!0,fitViewOptions:{padding:.25},children:[(0,Q.jsx)(bt,{color:"#eee",gap:20}),(0,Q.jsx)(kt,{})]})})},Bt=a=>(0,Q.jsx)(yt,{children:(0,Q.jsx)(tn,{...a})});var w=T(D()),nn=[{key:"all",labelKey:"governance.list.tab.all"},{key:"capability",labelKey:"governance.list.tab.capability"},{key:"orchestrator",labelKey:"governance.list.tab.orchestrator"},{key:"workflow",labelKey:"governance.list.tab.workflow"}],Lt=({items:a,assistants:c=[],loading:f,onItemClick:A,onOpenPlayground:d,onOpenEval:g,onCreate:i,onDelete:e})=>{let l=z(),[I,m]=(0,X.useState)("all"),[R,U]=(0,X.useState)(null),[y,u]=(0,X.useState)(null),P=(0,X.useMemo)(()=>{let r=new Set;return a.forEach(o=>o.tags.forEach(te=>r.add(te))),Array.from(r).map(o=>({value:o,label:o}))},[a]),M=(0,X.useMemo)(()=>a.filter(r=>!(I!=="all"&&r.type!==I||R&&!r.tags.includes(R)||y&&r.status!==y)),[a,I,R,y]),_=[{key:"edit",icon:st,label:l("common.edit"),onClick:r=>A(r.id)},{key:"playground",icon:tt,label:l("governance.list.action.playground"),onClick:r=>d(r.id)},{key:"eval",icon:at,label:l("governance.list.action.eval"),onClick:r=>g(r.id)}];e&&_.push({key:"delete",icon:rt,label:l("common.delete"),danger:!0,onClick:r=>e(r.id)});let q=(0,X.useMemo)(()=>[{mode:"graph",icon:it,label:l("governance.list.viewMode.graph"),render:()=>(0,w.jsx)(Bt,{assistants:c,onNodeClick:A})}],[c,A,l]);return(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)("span",{"data-testid":"agent-list-state","data-loading":String(f),"data-count":M.length,hidden:!0,"aria-hidden":"true"}),(0,w.jsx)(ct,{title:l("governance.list.title"),itemName:"common.item.agent",items:M,loading:f,keyExtractor:r=>r.id,tabs:nn.map(r=>({key:r.key,label:l(r.labelKey)})),activeTab:I,onTabChange:r=>m(r),headerLeft:(0,w.jsxs)("div",{style:{display:"flex",gap:8,alignItems:"center"},children:[(0,w.jsx)(Oe,{value:R,onChange:U,options:P,placeholder:l("governance.list.filter.domain"),allLabel:l("governance.list.filter.allDomains")}),(0,w.jsx)(Oe,{value:y,onChange:u,options:[{value:"enabled",label:l("governance.list.status.enabled")},{value:"draft",label:l("governance.list.status.draft")},{value:"disabled",label:l("governance.list.status.disabled")}],placeholder:l("governance.list.filter.status"),allLabel:l("governance.list.filter.allStatuses")})]}),renderIcon:r=>{let o=De(Ie(r.type).color);return(0,w.jsx)("div",{title:l("governance.list.typeIconTitle",{type:r.type}),style:{width:32,height:32,borderRadius:8,background:`${o}1A`,color:o,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:(0,w.jsx)(Te,{size:18})})},renderPrimary:r=>(0,w.jsx)("span",{"data-testid":"agent-name","data-agent-id":r.id,children:r.name}),renderSecondary:r=>r.description||void 0,renderDetails:r=>(0,w.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",gap:8,flexWrap:"wrap"},children:[(0,w.jsxs)("div",{style:{display:"flex",gap:4,flexWrap:"wrap",alignItems:"center"},children:[r.tags.map(o=>(0,w.jsx)(we,{color:"magenta",style:{margin:0,borderRadius:10,border:"none"},children:o},o)),(0,w.jsx)(we,{color:Ie(r.type).color,style:{margin:0,borderRadius:10,border:"none"},children:r.type})]}),(0,w.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,flexShrink:0},children:[(0,w.jsx)(Ue,{title:l("governance.list.statusTooltip",{status:r.status}),children:(0,w.jsx)("span",{style:{width:8,height:8,borderRadius:"50%",background:xt(r.status),display:"inline-block",cursor:"help"}})}),(0,w.jsx)("span",{style:{fontSize:12,color:"#8c8c8c"},children:r.version})]})]}),itemActions:_,actionsStyle:"icon",actionsPosition:"hover",onItemClick:r=>A(r.id),createLabel:l("governance.list.create"),onCreateClick:i,viewModeExtensions:q,emptyIcon:(0,w.jsx)(Te,{size:48,style:{opacity:.5}}),emptyTitle:l("governance.list.emptyTitle"),emptyDescription:l("governance.list.emptyDescription")})]})};var b=T(ge());var se=T(ge());var ue=T(D()),{Text:an}=J,Nt=({onSelect:a,value:c,placeholder:f})=>{let A=z(),d=f??A("chatConfig.parentAgent.selectPlaceholder"),[g,i]=(0,se.useState)([]),[e,l]=(0,se.useState)(!1),{get:I}=me(),m=(0,se.useCallback)(async()=>{l(!0);try{let y=await I("/api/assistants");y.success&&i(y.data?.records||[])}catch(y){console.error("Failed to fetch assistants:",y)}finally{l(!1)}},[I]);return(0,se.useEffect)(()=>{m()},[m]),(0,ue.jsx)(xe,{showSearch:!0,allowClear:!0,value:c,placeholder:d,loading:e,onChange:y=>{if(!y){a(null);return}let u=g.find(P=>P.id===y);a(u||null)},onDropdownVisibleChange:y=>{y&&m()},optionFilterProp:"label",style:{width:"100%"},options:g.map(y=>({value:y.id,label:y.name||y.id,description:y.description})),optionRender:y=>(0,ue.jsxs)("div",{children:[(0,ue.jsx)("div",{children:y.label}),y.data.description&&(0,ue.jsx)(an,{type:"secondary",style:{fontSize:12},children:y.data.description})]})})};var B=T(D()),{Text:Ot}=J,Vt=({subAgentKeys:a,decisions:c,onChange:f})=>{let{token:A}=Ze.useToken(),d=z(),g=(e,l)=>{let I=c.map(m=>m.originalKey===e?{...m,clone:l,cloneKey:l?`${e}_clone`:void 0}:m);f(I)},i=(e,l)=>{let I=c.map(m=>m.originalKey===e?{...m,cloneKey:l}:m);f(I)};return a.length===0?null:(0,B.jsxs)("div",{children:[(0,B.jsx)(Ot,{type:"secondary",style:{display:"block",marginBottom:8},children:d("chatConfig.subAgentInherit.hint")}),(0,B.jsx)(Ne,{size:"small",bordered:!0,dataSource:c,style:{borderRadius:A.borderRadius},renderItem:e=>(0,B.jsxs)(Ne.Item,{style:{display:"flex",flexDirection:"column",alignItems:"stretch",gap:8,padding:"8px 16px"},children:[(0,B.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[(0,B.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.clone?(0,B.jsx)(Re,{style:{color:A.colorPrimary}}):(0,B.jsx)(Xe,{style:{color:A.colorTextSecondary}}),(0,B.jsx)(Ot,{style:{fontFamily:"monospace"},children:e.originalKey})]}),(0,B.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8},children:[(0,B.jsx)(we,{color:e.clone?"blue":"default",children:e.clone?d("chatConfig.subAgentInherit.clone"):d("chatConfig.subAgentInherit.reuse")}),(0,B.jsx)(We,{size:"small",checked:e.clone,onChange:l=>g(e.originalKey,l)})]})]}),e.clone&&(0,B.jsx)(O,{size:"small",placeholder:d("chatConfig.subAgentInherit.cloneKeyPlaceholder"),value:e.cloneKey,onChange:l=>i(e.originalKey,l.target.value),style:{fontFamily:"monospace",fontSize:12},addonBefore:d("chatConfig.keyValue.key")})]})})]})};function _t(a,c){return a.mode!=="local"||a.templateKey||typeof a.executable=="string"&&a.executable.trim().length>0?null:c?c("chat.config.executableRequired"):"Choose a template or enter a custom executable"}var n=T(D()),{TextArea:Gt}=O,{Text:ee}=J,zt="/.well-known/agent-card.json",on=[{value:"http://",label:"http://"},{value:"https://",label:"https://"}],sn={react:"chatConfig.createAssistant.typeDesc.react",deep_agent:"chatConfig.createAssistant.typeDesc.deepAgent",a2a_remote:"chatConfig.createAssistant.typeDesc.a2aRemote"};function jt(a,c,f="https://"){let A=String(a??"").trim();if(!A)return"";let d=c==="http://"||c==="https://"?c:f,i=(/^https?:\/\//i.test(A)?A:`${d}${A.replace(/^\/+/,"")}`).replace(/\/+$/,"");return i.endsWith(zt)?i:`${i}${zt}`}function rn(a){try{return new URL(a).port||void 0}catch{return}}function ln(a){return a.some(c=>c==="--port"||c==="-p"||/^--port=/.test(c)||/^-p=/.test(c))}function Ut(a,c){let f=[...a.args],A=rn(c);return A&&!ln(f)&&f.push("--port",A),{...a,args:f,...a.env?{env:{...a.env}}:{}}}var qt=({open:a,onCancel:c,onSuccess:f,initialMode:A,initialValues:d})=>{let{message:g}=Fe.useApp(),[i]=F.useForm(),e=z(),[l,I]=(0,b.useState)(!1),[m,R]=(0,b.useState)("learn"),[U,y]=(0,b.useState)(""),[u,P]=(0,b.useState)(null),[M,_]=(0,b.useState)([]),q=F.useWatch("type",i)||"react",r=q==="a2a_remote",[o,te]=(0,b.useState)("remote"),[H,fe]=(0,b.useState)(void 0),[re,ye]=(0,b.useState)([]),[Se,le]=(0,b.useState)(!1),ne=(0,b.useRef)(0),[ae,oe]=(0,b.useState)(!1),[Me,Z]=(0,b.useState)(!1),{get:L,post:Y,put:he}=me(),Ee=Ye("agent-architect"),{workspaceId:Ce,trainingProjects:ce,loading:de}=lt(),[Ke,Ae]=(0,b.useState)(null),Be=JSON.stringify(d??null),E=ce.find(t=>t.id===Ke)??ce[0]??null,[be,ke]=(0,b.useState)([]),p=(0,b.useCallback)(()=>{P(null),_([])},[]),k=(0,b.useCallback)(()=>{i.resetFields(),p(),R("learn"),y(""),ke([]),Ae(null),te("remote"),fe(void 0),ye([]),Z(!1),oe(!1)},[i,p]);(0,b.useEffect)(()=>{if(a){k(),R(A??"learn");let t=d?.a2aMode;(t==="remote"||t==="local")&&te(t),i.setFieldsValue({type:"react",agentCardProtocol:"https://",a2aMode:"remote",timeout:3e5,...d})}},[a,i,A,Be,k]),(0,b.useEffect)(()=>{let t=++ne.current,s=!0;return a&&r?(i.setFieldValue("prompt",""),o==="local"?(le(!0),L("/api/local-a2a/templates").then(v=>{s&&t===ne.current&&v?.data?.records&&ye(v.data.records)}).catch(()=>{s&&t===ne.current&&ye([])}).finally(()=>{s&&t===ne.current&&le(!1)})):le(!1)):le(!1),()=>{s=!1,ne.current+=1}},[i,r,o,L,a]);let x=re.find(t=>t.key===H),j=(0,b.useCallback)(()=>{let t=_t({mode:o,templateKey:H,executable:i.getFieldValue("commandExecutable")},e);return t?(Z(!0),i.setFields([{name:"commandExecutable",errors:[t]}]),g.warning(t),!1):!0},[o,H,i,e]);(0,b.useEffect)(()=>{x&&i.setFieldsValue({agentCardProtocol:"http://"})},[i,x]);let ve=(0,b.useCallback)(async()=>{if(!j())return;let t=jt(i.getFieldValue("agentCardUrl"),i.getFieldValue("agentCardProtocol"),o==="local"?"http://":"https://");if(!t){g.warning(e("chatConfig.createAssistant.a2aUrlWarning"));return}oe(!0);try{let s={agentCardUrl:t,apiKey:i.getFieldValue("apiKey")};if(o==="local"){let h=x;if(h)s.localRuntime={label:i.getFieldValue("name")||void 0,agentCardUrl:t,command:Ut(h.command,t)};else{let K=i.getFieldValue("commandArgs")||"",G=K?K.split(/\s+/).filter(Boolean):[],S=String(i.getFieldValue(["command","cwd"])||"").trim();s.localRuntime={label:i.getFieldValue("name")||void 0,agentCardUrl:t,command:{executable:String(i.getFieldValue("commandExecutable")||"").trim(),args:G,...S?{cwd:S}:{}}}}}let v=await Y("/api/a2a/test-connection",s);if(v.data?.reachable){let h=v.data.agentCard;g.success(e("chatConfig.createAssistant.connectedTo",{name:v.data.agentName||t}))}else g.error(v.data?.error||e("chatConfig.createAssistant.connectionFailed"))}catch{g.error(e("chatConfig.createAssistant.connectionTestFailed"))}finally{oe(!1)}},[i,Y,o,x,j,e]),Wt=(0,b.useCallback)(t=>{if(P(t),!t){i.resetFields(["key","name","description","type","prompt"]),_([]);return}let s=typeof t.graphDefinition=="object"&&t.graphDefinition!==null?t.graphDefinition:{},v=s.key||t.id,h=t.name||s.name||"";i.setFieldsValue({key:`${v}_ext`,name:h?`${h} (Extended)`:"",description:t.description||s.description||"",type:s.type||"react",prompt:s.prompt||""});let K=s.subAgents||[];_(K.map(G=>({originalKey:G,clone:!1})))},[i]),Zt=async(t,s)=>{let v=await L(`/api/assistants/${t}`);if(!v.success)throw new Error(e("chatConfig.createAssistant.cloneFetchFailed",{key:t}));let h=v.data,K=typeof h.graphDefinition=="object"?h.graphDefinition:{},G={id:s,name:`${h.name} (Clone)`,description:h.description||"",graphDefinition:{...K,key:s,name:`${h.name} (Clone)`}},S=await Y("/api/assistants",G);if(!S.success)throw new Error(S.message||e("chatConfig.createAssistant.cloneFailed",{key:t}));return S.data},Yt=t=>{let s={id:t.key,name:t.name,description:t.description||"",graphDefinition:{key:t.key,name:t.name,description:t.description||"",type:t.type,prompt:t.prompt||"",tools:[],skills:[],subAgents:t.type==="deep_agent"?[]:void 0,middleware:[]}};if(t.type==="a2a_remote"&&(s.graphDefinition.agentCardUrl=jt(t.agentCardUrl,t.agentCardProtocol,(t.a2aMode||o)==="local"?"http://":"https://"),t.apiKey&&(s.graphDefinition.apiKey=t.apiKey),t.timeout&&(s.graphDefinition.timeout=t.timeout),(t.a2aMode||o)==="local")){let v=x;if(v)s.graphDefinition.localRuntime={label:t.name||void 0,agentCardUrl:s.graphDefinition.agentCardUrl,command:Ut(v.command,s.graphDefinition.agentCardUrl)};else{let h=t.commandArgs||"",K=h?h.split(/\s+/).filter(Boolean):[],G=String(t.command?.cwd||"").trim();s.graphDefinition.localRuntime={label:t.name||void 0,agentCardUrl:s.graphDefinition.agentCardUrl,command:{executable:String(t.commandExecutable||"").trim(),args:K,...G?{cwd:G}:{}}}}}return s},Jt=async(t,s)=>{if(!u)throw new Error(e("chatConfig.createAssistant.noParentAgent"));let v=M.filter(S=>S.clone);for(let S of v){if(!S.cloneKey||!S.cloneKey.trim())throw new Error(e("chatConfig.createAssistant.cloneKeyRequired",{key:S.originalKey}));if(!/^[a-zA-Z][a-zA-Z0-9_-]*$/.test(S.cloneKey))throw new Error(e("chatConfig.createAssistant.cloneKeyInvalid",{key:S.cloneKey,originalKey:S.originalKey}))}let h=[];for(let S of M)if(S.clone){let en=await Zt(S.originalKey,S.cloneKey);s.push(en),h.push(S.cloneKey)}else h.push(S.originalKey);let K=typeof u.graphDefinition=="object"?u.graphDefinition:{},G={key:t.key,name:t.name,description:t.description||"",extendsAgent:u.id,type:t.type||K.type};return t.prompt&&t.prompt!==K.prompt&&(G.prompt=t.prompt),(h.length>0||K.subAgents&&K.subAgents.length>0)&&(G.subAgents=h),{id:t.key,name:t.name,description:t.description||"",graphDefinition:G}},Qt=async()=>{if(m==="learn"){let t=U.trim();if(!t){g.error(e("chatConfig.createAssistant.trainingGoalRequired"));return}if(!E){g.error(e("chatConfig.createAssistant.noTrainingProject"));return}I(!0);try{let s=`agent-${St(t+Date.now())}`,v=await Y("/api/assistants",{id:s,name:s,graphDefinition:{key:s,name:s,description:"",type:"react",prompt:"To be trained",metadata:{trainingProjectId:E.id,learningPlaceholder:"true",architectureStatus:"undecided"}}});if(!v.data)throw new Error(e("chatConfig.createAssistant.agentCreateFailed"));let{roundTaskId:h}=await Pt({goal:t,targetAgentId:s,workspaceId:Ce??void 0,projectId:E.id,existingThreadId:Ft(Ee.tenantId,s),files:be,post:Y,put:he});g.success(e("chatConfig.createAssistant.agentCreated")),y(""),ke([]),R("learn"),f?.(v.data,{initialMessage:Rt({goal:t,roundTaskId:h,targetAgentId:s,targetMode:"placeholder",files:be,projectId:E.id,workspaceId:E.workspaceId??Ce??void 0}),projectId:E.id,initialMessageCustomRunConfig:{execution:{taskId:h}}}),c()}catch(s){g.error(s instanceof Error?s.message:e("chatConfig.createAssistant.agentCreateFailed"))}finally{I(!1)}return}try{if(m==="scratch"&&r&&!j())return;let t=await i.validateFields();I(!0);let s=[],v=m==="scratch"?Yt(t):await Jt(t,s),h=await Y("/api/assistants",v);if(h.success){g.success(m==="extend"?e("chatConfig.createAssistant.createdByExtending",{name:u?.name??""}):e("chatConfig.createAssistant.created")),k();for(let K of s)f?.(K);f?.(h.data),c()}else g.error(h.message||e("chatConfig.createAssistant.createFailed"))}catch(t){if(t?.errorFields){let s={key:e("chatConfig.createAssistant.field.key"),name:e("chatConfig.createAssistant.field.name"),description:e("chatConfig.createAssistant.field.description"),prompt:e("chatConfig.createAssistant.field.systemPrompt")},v=t.errorFields.map(h=>s[String((h.name??[])[0])]??String((h.name??[])[0])).filter(Boolean);g.warning(v.length>0?e("chatConfig.createAssistant.requiredFields",{fields:[...new Set(v)].join(", ")}):e("chatConfig.createAssistant.requiredFieldsGeneric"));return}g.error(t.message||e("chatConfig.createAssistant.createError"))}finally{I(!1)}},je=u?.graphDefinition?.subAgents||[],Xt=m==="extend"&&u&&je.length>0;return(0,n.jsxs)(pe,{title:e("chatConfig.createAssistant.title"),open:a,onCancel:()=>{k(),c()},footer:[(0,n.jsx)($,{onClick:()=>{k(),c()},children:e("common.cancel")},"cancel"),(0,n.jsx)($,{type:"primary",icon:m==="extend"?(0,n.jsx)(Re,{}):m==="learn"?(0,n.jsx)(Qe,{}):(0,n.jsx)(et,{}),loading:l,disabled:m==="learn"&&(de||!E),onClick:Qt,children:e(m==="extend"?"chatConfig.createAssistant.createExtend":m==="learn"?"chatConfig.createAssistant.startLearning":"common.create")},"submit")],width:760,children:[m==="extend"&&(0,n.jsxs)("div",{style:{marginBottom:20},children:[(0,n.jsx)(ee,{type:"secondary",style:{display:"block",marginBottom:8},children:e("chatConfig.createAssistant.parentAgent")}),(0,n.jsx)(Nt,{value:u?.id,onSelect:Wt}),u&&(0,n.jsx)(ee,{type:"secondary",style:{display:"block",marginTop:4,fontSize:12},children:e("chatConfig.createAssistant.inheritHint")})]}),m==="extend"&&u&&(0,n.jsx)(Le,{style:{margin:"12px 0"}}),m==="learn"&&(0,n.jsxs)("div",{children:[(0,n.jsx)(ee,{style:{display:"block",marginBottom:8},children:e("chatConfig.createAssistant.learnHint")}),(0,n.jsx)(O.TextArea,{rows:3,value:U,onChange:t=>y(t.target.value),placeholder:e("chatConfig.createAssistant.learnGoalPlaceholder")}),E&&(0,n.jsxs)("div",{style:{marginTop:12},children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:12,marginBottom:8},children:[(0,n.jsx)(ee,{type:"secondary",children:e("chatConfig.createAssistant.referenceFiles")}),(0,n.jsx)(Ge,{project:E,value:E?.id??null,onChange:Ae,loading:de})]}),(0,n.jsx)(It,{projectId:E.id,value:be,onChange:ke}),(0,n.jsx)(ee,{type:"secondary",style:{display:"block",marginTop:6,fontSize:12},children:e("chatConfig.createAssistant.referenceFilesHint")})]}),!E&&!de&&(0,n.jsx)("div",{style:{marginTop:12},children:(0,n.jsx)(Ge,{project:E,value:null,onChange:Ae,loading:de})})]}),m!=="learn"&&(0,n.jsxs)(F,{form:i,layout:"vertical",autoComplete:"off",initialValues:{type:"react",agentCardProtocol:"https://",a2aMode:"remote"},children:[(0,n.jsx)(F.Item,{name:"key",label:e("chatConfig.createAssistant.field.key"),rules:[{required:!0,message:e("chatConfig.createAssistant.validation.keyRequired")},{pattern:/^[a-zA-Z][a-zA-Z0-9_-]*$/,message:e("chatConfig.createAssistant.validation.keyPattern")}],style:{marginBottom:16},children:(0,n.jsx)(O,{placeholder:e("chatConfig.createAssistant.keyPlaceholder")})}),(0,n.jsx)(F.Item,{name:"name",label:e("chatConfig.createAssistant.field.name"),rules:[{required:!0,message:e("chatConfig.createAssistant.validation.nameRequired")}],style:{marginBottom:16},children:(0,n.jsx)(O,{placeholder:e("chatConfig.createAssistant.namePlaceholder")})}),(0,n.jsx)(F.Item,{name:"description",label:e("chatConfig.createAssistant.field.description"),rules:[{required:!0,message:e("chatConfig.createAssistant.validation.descriptionRequired")}],style:{marginBottom:16},children:(0,n.jsx)(Gt,{placeholder:e("chatConfig.createAssistant.descriptionPlaceholder"),autoSize:{minRows:2,maxRows:4}})}),(0,n.jsx)(F.Item,{name:"type",label:e("chatConfig.createAssistant.field.agentType"),rules:[{required:!0}],style:{marginBottom:16},children:(0,n.jsx)(qe,{options:[{value:"react",label:e("chatConfig.agentType.executor")},{value:"deep_agent",label:e("chatConfig.agentType.orchestrator")},{value:"a2a_remote",label:e("chatConfig.agentType.a2aRemote")}],block:!0})}),(0,n.jsx)(ee,{type:"secondary",style:{fontSize:12,display:"block",marginTop:-12,marginBottom:16,lineHeight:1.5},children:e(sn[q]??"chatConfig.createAssistant.typeDesc.react")}),r&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(F.Item,{label:e("chatConfig.createAssistant.field.connectionMode"),style:{marginBottom:16},children:(0,n.jsxs)(Pe.Group,{value:o,onChange:t=>{let s=t.target.value;te(s),i.setFieldValue("a2aMode",s),s==="local"&&i.setFieldValue("agentCardProtocol","http://"),fe(void 0)},optionType:"button",buttonStyle:"solid",children:[(0,n.jsx)(Pe.Button,{value:"remote",children:e("chatConfig.createAssistant.mode.remoteUrl")}),(0,n.jsx)(Pe.Button,{value:"local",children:e("chatConfig.createAssistant.mode.localManaged")})]})}),(0,n.jsx)(F.Item,{name:"a2aMode",noStyle:!0,hidden:!0,children:(0,n.jsx)(O,{})}),o==="local"&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(F.Item,{label:e("chatConfig.createAssistant.field.template"),style:{marginBottom:16},children:(0,n.jsx)(xe,{placeholder:e("chatConfig.createAssistant.templatePlaceholder"),allowClear:!0,loading:Se,value:H,onChange:t=>{fe(t),t&&Z(!1)},options:re.map(t=>({value:t.key,label:t.name||t.key})),notFoundContent:Se?void 0:(0,n.jsx)(ee,{type:"secondary",style:{padding:8,display:"block"},children:e("chatConfig.createAssistant.noTemplates")})})}),!H&&(0,n.jsx)(n.Fragment,{children:Me?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(F.Item,{name:"commandExecutable",label:e("chatConfig.createAssistant.field.executable"),rules:[{required:!0,whitespace:!0,message:e("chatConfig.createAssistant.validation.executableRequired")}],style:{marginBottom:16},children:(0,n.jsx)(O,{placeholder:e("chatConfig.createAssistant.executablePlaceholder")})}),(0,n.jsx)(F.Item,{name:"commandArgs",label:e("chatConfig.createAssistant.field.arguments"),style:{marginBottom:16},children:(0,n.jsx)(O,{placeholder:e("chatConfig.createAssistant.argumentsPlaceholder")})}),(0,n.jsx)(F.Item,{name:["command","cwd"],label:e("chatConfig.createAssistant.field.workingDirectory"),style:{marginBottom:16},children:(0,n.jsx)(O,{placeholder:e("chatConfig.createAssistant.workingDirectoryPlaceholder")})}),(0,n.jsx)($,{type:"link",onClick:()=>{Z(!1),i.setFieldsValue({commandExecutable:"",commandArgs:"",command:{cwd:void 0}})},style:{padding:0,marginBottom:16,display:"block"},children:e("chatConfig.createAssistant.hideCustomCommand")})]}):(0,n.jsx)($,{type:"link",onClick:()=>Z(!0),style:{padding:0,marginBottom:16,display:"block"},children:e("chatConfig.createAssistant.customCommand")})})]}),(0,n.jsx)(F.Item,{label:e("chatConfig.createAssistant.field.agentCardUrl"),required:!0,style:{marginBottom:16},children:(0,n.jsxs)($e.Compact,{style:{width:"100%"},children:[(0,n.jsx)(F.Item,{name:"agentCardProtocol",noStyle:!0,children:(0,n.jsx)(xe,{style:{width:100},options:on})}),(0,n.jsx)(F.Item,{name:"agentCardUrl",noStyle:!0,rules:[{required:!0,message:e("chatConfig.createAssistant.validation.urlRequired")}],children:(0,n.jsx)(O,{placeholder:o==="local"?"localhost:4301":"host:port or full URL"})}),(0,n.jsx)($,{icon:(0,n.jsx)(Je,{}),onClick:ve,loading:ae,children:e("chatConfig.connection.action.test")})]})}),o==="remote"&&(0,n.jsx)(F.Item,{name:"apiKey",label:e("chatConfig.createAssistant.field.apiKeyOptional"),style:{marginBottom:16},children:(0,n.jsx)(O.Password,{placeholder:e("chatConfig.createAssistant.apiKeyPlaceholder")})}),(0,n.jsx)(F.Item,{name:"timeout",label:e("chatConfig.createAssistant.field.timeout"),style:{marginBottom:16},initialValue:3e5,children:(0,n.jsx)(He,{min:1e3,max:36e5,style:{width:"100%"},placeholder:"300000"})})]}),!r&&(0,n.jsx)(F.Item,{name:"prompt",label:e(m==="extend"&&u?"chatConfig.createAssistant.field.systemPromptInherit":"chatConfig.createAssistant.field.systemPrompt"),rules:m==="scratch"?[{required:!0,message:e("chatConfig.createAssistant.validation.systemPromptRequired")}]:[],children:(0,n.jsx)(Gt,{placeholder:e(m==="extend"&&u?"chatConfig.createAssistant.systemPromptInheritPlaceholder":"chatConfig.createAssistant.systemPromptPlaceholder"),autoSize:{minRows:4,maxRows:8},style:{fontFamily:"monospace",fontSize:13,lineHeight:1.6}})})]}),Xt&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(Le,{style:{margin:"12px 0"}}),(0,n.jsx)(ee,{strong:!0,style:{display:"block",marginBottom:8},children:e("chatConfig.createAssistant.subAgents")}),(0,n.jsx)(Vt,{subAgentKeys:je,decisions:M,onChange:_})]})]})};var N=T(D()),{Paragraph:cn,Text:Ht}=J,dn=[{key:"manual",icon:Te,titleKey:"governance.creation.manual.title",descriptionKey:"governance.creation.manual.description"},{key:"external",icon:nt,titleKey:"governance.creation.external.title",descriptionKey:"governance.creation.external.description"},{key:"learn",icon:ot,titleKey:"governance.creation.learn.title",descriptionKey:"governance.creation.learn.description"}],$t=({open:a,onCancel:c,onSelectMethod:f,focusTriggerAfterClose:A=!0})=>{let d=z();return(0,N.jsx)(pe,{title:d("governance.creation.title"),open:a,onCancel:c,footer:null,width:560,centered:!0,destroyOnHidden:!0,focusTriggerAfterClose:A,children:(0,N.jsxs)("div",{style:{padding:"8px 4px 4px"},children:[(0,N.jsx)(cn,{style:{color:"#595959",fontSize:15,margin:"8px 0 24px"},children:d("governance.creation.subtitle")}),(0,N.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:12},children:dn.map(g=>{let i=g.icon,e=d(g.titleKey);return(0,N.jsxs)($,{type:"default",onClick:()=>f(g.key),"aria-label":e,style:{display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"flex-start",gap:16,width:"100%",minHeight:88,height:"auto",padding:16,borderRadius:16,textAlign:"left",whiteSpace:"normal"},children:[(0,N.jsx)("div",{style:{width:40,height:40,borderRadius:12,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,color:"#6366f1",background:"#eeeeff"},children:(0,N.jsx)(i,{size:19})}),(0,N.jsxs)("div",{style:{minWidth:0},children:[(0,N.jsx)(Ht,{strong:!0,style:{display:"block",fontSize:15,marginBottom:3},children:e}),(0,N.jsx)(Ht,{style:{color:"#737373",lineHeight:1.5},children:d(g.descriptionKey)})]})]},g.key)})}),(0,N.jsx)("div",{style:{display:"flex",justifyContent:"flex-end",gap:8,flexWrap:"wrap",marginTop:24},children:(0,N.jsx)($,{onClick:c,children:d("governance.creation.notNow")})})]})})};var V=T(D()),gn=a=>{let c=a;if(typeof a=="string")try{c=JSON.parse(a)}catch{return{}}return c!==null&&typeof c=="object"&&!Array.isArray(c)?c:{}},va=()=>{let{message:a}=Fe.useApp(),{get:c,del:f,put:A}=me(),d=z(),[g,i]=(0,C.useState)([]),[e,l]=(0,C.useState)(!1),[I,m]=(0,C.useState)(null),[R,U]=(0,C.useState)("graph"),[y,u]=(0,C.useState)(null),[P,M]=(0,C.useState)(null),[_,q]=(0,C.useState)(null),[r,o]=(0,C.useState)(!1),[te,H]=(0,C.useState)(!0),[fe,re]=(0,C.useState)(!1),[ye,Se]=(0,C.useState)("learn"),[le,ne]=(0,C.useState)({}),[ae,oe]=(0,C.useState)(null),[Me,Z]=(0,C.useState)(!1),L=(0,C.useCallback)(async()=>{l(!0);try{let p=await c("/api/assistants");p.success&&p.data?.records&&i(p.data.records)}catch{a.error(d("governance.workbench.loadFailed"))}finally{l(!1)}},[c,d]);(0,C.useEffect)(()=>{L()},[L]);let Y=C.default.useMemo(()=>wt(g),[g]),he=g.find(p=>p.id===I)??null,Ee=(0,C.useCallback)((p,k="graph")=>{m(p),U(k),u(null),q(null)},[]),Ce=ft(),ce=(0,C.useCallback)((p,k)=>{let x=g.find(j=>j.id===p)?.name??d("governance.workbench.agentFallback");Ce({component_key:"agent_detail_side_app",data:{assistantId:p,initialTab:k},message:x})},[g,Ce,d]),de=(0,C.useCallback)(()=>{H(!0),o(!0)},[]),Ke=(0,C.useCallback)(p=>{let x={manual:{mode:"scratch",values:{}},external:{mode:"scratch",values:{type:"a2a_remote"}},learn:{mode:"learn",values:{}}}[p];Se(x.mode),ne(x.values),H(!1),o(!1),re(!0)},[]),Ae=(0,C.useCallback)(async(p,k)=>{let x=gn(p.graphDefinition),j;try{j=await A(`/api/assistants/${p.id}`,{name:k.name!==void 0?k.name:p.name,description:k.description!==void 0?k.description:p.description,graphDefinition:{...x,...k}})}catch(ve){throw a.error(d("governance.detail.saveFailed")),ve}if(!j.success)throw a.error(d("governance.detail.saveFailed")),new Error("Failed to save agent");a.success(d("common.saved")),L()},[A,L,d]),Be=(0,C.useCallback)(p=>{i(k=>k.map(x=>x.id===p.id?p:x))},[]),E=(0,C.useCallback)(p=>{oe(p)},[]),be=(0,C.useCallback)(async()=>{if(ae){Z(!0);try{(await f(`/api/assistants/${ae}`)).success?(a.success(d("governance.detail.deleted")),i(k=>k.filter(x=>x.id!==ae)),L(),oe(null)):a.error(d("governance.detail.deleteFailed"))}catch{a.error(d("governance.detail.deleteFailed"))}finally{Z(!1)}}},[ae,f,L,d]),ke=(0,C.useCallback)(async p=>{if(!(await f(`/api/assistants/${p}`)).success)throw new Error("Failed to delete agent");a.success(d("governance.detail.deleted")),i(x=>x.filter(j=>j.id!==p)),L()},[f,L,d]);return(0,V.jsxs)("div",{style:{height:"100%",background:"#fafafa",overflow:"hidden"},children:[he?(0,V.jsx)(vt,{defaultProjectId:_??void 0,children:(0,V.jsx)(Dt,{assistant:he,allAssistants:g,onBack:()=>m(null),onDeleted:ke,onSave:Ae,onAssistantUpdated:Be,onAgentListInvalidated:L,initialTab:R,initialMessage:y,initialMessageCustomRunConfig:P,initialProjectId:_})},he.id):(0,V.jsx)(V.Fragment,{children:(0,V.jsx)(Lt,{items:Y,assistants:g,loading:e,onItemClick:p=>ce(p,"graph"),onOpenPlayground:p=>ce(p,"playground"),onOpenEval:p=>ce(p,"eval"),onCreate:de,onDelete:E})}),(0,V.jsx)($t,{open:r,onCancel:()=>{H(!0),o(!1)},onSelectMethod:Ke,focusTriggerAfterClose:te}),(0,V.jsx)(qt,{open:fe,initialMode:ye,initialValues:le,onCancel:()=>re(!1),onSuccess:(p,k)=>{re(!1),i(x=>x.some(ve=>ve.id===p.id)?x:[p,...x]),Ee(p.id,"graph"),u(k?.initialMessage??null),M(k?.initialMessageCustomRunConfig??null),q(k?.projectId??null),L()}}),(0,V.jsx)(pe,{title:d("governance.deleteAgent"),open:ae!==null,onCancel:()=>oe(null),onOk:be,okText:d("common.delete"),okButtonProps:{danger:!0,loading:Me},cancelText:d("common.cancel"),children:(0,V.jsx)("p",{children:d("governance.delete.irreversible")})})]})};export{va as AgentGovernanceWorkbench};
@@ -1,4 +1,4 @@
1
- import{c as $,d as J}from"./embed-page-chunk-HQLSH3FC.js";import{b as R,d as V,e as S}from"./embed-page-chunk-5AWYMAAX.js";import"./embed-page-chunk-S4XZPBRM.js";import{j as N,k as H,l as L,m as U,n as W,x as A,y as K,z as Y}from"./embed-page-chunk-MVT6CPWE.js";import"./embed-page-chunk-54M4265G.js";import"./embed-page-chunk-3XPHW2C7.js";import"./embed-page-chunk-5QZRLAW2.js";import"./embed-page-chunk-F7ZUYG42.js";import{l as w}from"./embed-page-chunk-3FNSGFP2.js";import{a as g}from"./embed-page-chunk-QV7QAJ4N.js";import"./embed-page-chunk-VW3NF5NT.js";import"./embed-page-chunk-Z4Z6VCUZ.js";import{Aa as G,Oa as _,ab as z,bb as k,eb as F,t as E,y as D}from"./embed-page-chunk-L7GPZSYD.js";import{Za as P,_ as T,ha as B}from"./embed-page-chunk-BUFWD6SE.js";import{a as b}from"./embed-page-chunk-R5QL57JJ.js";import"./embed-page-chunk-QOWM3LMZ.js";import"./embed-page-chunk-EUOOO2LS.js";import"./embed-page-chunk-5JDQ456X.js";import{f}from"./embed-page-chunk-QBTAJ2YI.js";var n=f(b());var I=f(b());var o=f(g());var ae="tracePulse 1.4s ease-in-out infinite",le={running:(0,o.jsx)(G,{style:{color:"#1890ff"}}),success:(0,o.jsx)(E,{style:{color:"#52c41a"}}),error:(0,o.jsx)(D,{style:{color:"#ff4d4f"}})};function de({kind:e}){switch(e){case"human":return(0,o.jsx)(F,{});case"agent":return(0,o.jsx)(z,{});case"tool":return(0,o.jsx)(k,{});case"ai":return(0,o.jsx)(_,{});default:return(0,o.jsx)(k,{})}}var M=I.default.createContext({}),ce=()=>I.default.useContext(M),pe=({data:e,selected:i})=>{let l=w(),{onJumpToMessage:t}=ce(),s=e.isAnswer===!0,a=e.status==="running",p=(e.parallelCount??1)>1,m=!!(t&&e.messageId&&!e.messageId.startsWith("summary:")),v=e.toolCall?L(e.toolCall.name):e.label,y=()=>{if((e.kind==="tool"||e.kind==="agent")&&e.toolCall){let h=U(e.toolCall.response);return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(H,{data:{name:e.toolCall.name,parameters:e.toolCall.args,type:"tool_call"},component_key:`${e.toolCall.id}-params`,interactive:!1}),h&&(0,o.jsx)("div",{style:{marginTop:8},children:(0,o.jsx)(N,{content:h})}),(0,o.jsx)(W,{ui:e.toolCall.ui})]})}return e.content?(0,o.jsx)(N,{content:e.content}):(0,o.jsx)("span",{style:{color:"#8c8c8c"},children:e.label})};return(0,o.jsxs)("div",{"data-testid":"trace-card",style:{height:"100%",display:"flex",flexDirection:"column",border:`1px solid ${s||i?"#6366f1":a?"#91caff":"#e5e7eb"}`,borderRadius:12,background:s?"#eef2ff":"#fff",boxShadow:a?"0 0 0 2px rgba(24,144,255,0.18)":i?"0 0 0 2px rgba(99,102,241,0.2)":"none",animation:a?ae:void 0,overflow:"hidden",fontSize:13},children:[(0,o.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"8px 12px",borderBottom:"1px solid #f0f0f0",background:"rgba(0,0,0,0.02)"},children:[(0,o.jsx)(de,{kind:e.kind}),(0,o.jsx)("span",{style:{fontWeight:s?700:600,flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:v}),p&&(0,o.jsx)(P,{color:"purple",style:{marginInlineEnd:0,fontSize:10},children:l("chat.trace.parallelBadge",{count:e.parallelCount??1})}),le[e.status],m&&(0,o.jsx)(T,{type:"text",size:"small",onClick:()=>t?.(e.messageId),children:l("chat.trace.jumpToChat")})]}),(0,o.jsx)("div",{style:{flex:1,minHeight:0,overflow:"auto",padding:12},children:y()})]})},fe=({data:e,selected:i})=>(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(S,{type:"target",position:R.Top}),(0,o.jsx)(pe,{data:e,selected:i}),(0,o.jsx)(S,{type:"source",position:R.Bottom})]}),j={trace:fe};var Z=f(b());var u=f(g()),ue={running:"#1890ff",success:"#52c41a",error:"#ff4d4f"},q=({graph:e,activeNodeId:i,onSelectNode:l})=>{let t=Z.default.useMemo(()=>new Map(e.nodes.map(s=>[s.id,s])),[e.nodes]);return(0,u.jsx)("div",{"data-testid":"trace-overview-rail",style:{display:"flex",flexDirection:"column",gap:10,width:160,padding:8,overflowY:"auto",borderRight:"1px solid #f0f0f0"},children:e.phases.map(s=>(0,u.jsxs)("div",{"data-testid":"trace-rail-phase",children:[(0,u.jsx)("div",{style:{fontSize:12,color:"#8c8c8c",marginBottom:4},children:s.title}),(0,u.jsx)("div",{style:{display:"flex",flexWrap:"wrap",gap:4},children:s.nodeIds.map(a=>{let p=t.get(a);if(!p)return null;let m=a===i;return(0,u.jsx)(B,{title:p.data.label,children:(0,u.jsx)("button",{type:"button","data-testid":"trace-rail-tick",onClick:()=>l?.(a),style:{width:m?12:8,height:m?12:8,borderRadius:"50%",border:"none",padding:0,cursor:"pointer",background:ue[p.data.status],outline:m?"2px solid #6366f1":"none"}})},a)})})]},s.id))})};var d=f(g()),Q=3,X=()=>{},me=`
1
+ import{c as $,d as J}from"./embed-page-chunk-HQLSH3FC.js";import{b as R,d as V,e as S}from"./embed-page-chunk-5AWYMAAX.js";import"./embed-page-chunk-S4XZPBRM.js";import{j as N,k as H,l as L,m as U,n as W,x as A,y as K,z as Y}from"./embed-page-chunk-KWZEITYQ.js";import"./embed-page-chunk-54M4265G.js";import"./embed-page-chunk-3XPHW2C7.js";import"./embed-page-chunk-5QZRLAW2.js";import"./embed-page-chunk-F7ZUYG42.js";import{l as w}from"./embed-page-chunk-3FNSGFP2.js";import{a as g}from"./embed-page-chunk-QV7QAJ4N.js";import"./embed-page-chunk-VW3NF5NT.js";import"./embed-page-chunk-Z4Z6VCUZ.js";import{Aa as G,Oa as _,ab as z,bb as k,eb as F,t as E,y as D}from"./embed-page-chunk-L7GPZSYD.js";import{Za as P,_ as T,ha as B}from"./embed-page-chunk-BUFWD6SE.js";import{a as b}from"./embed-page-chunk-R5QL57JJ.js";import"./embed-page-chunk-QOWM3LMZ.js";import"./embed-page-chunk-EUOOO2LS.js";import"./embed-page-chunk-5JDQ456X.js";import{f}from"./embed-page-chunk-QBTAJ2YI.js";var n=f(b());var I=f(b());var o=f(g());var ae="tracePulse 1.4s ease-in-out infinite",le={running:(0,o.jsx)(G,{style:{color:"#1890ff"}}),success:(0,o.jsx)(E,{style:{color:"#52c41a"}}),error:(0,o.jsx)(D,{style:{color:"#ff4d4f"}})};function de({kind:e}){switch(e){case"human":return(0,o.jsx)(F,{});case"agent":return(0,o.jsx)(z,{});case"tool":return(0,o.jsx)(k,{});case"ai":return(0,o.jsx)(_,{});default:return(0,o.jsx)(k,{})}}var M=I.default.createContext({}),ce=()=>I.default.useContext(M),pe=({data:e,selected:i})=>{let l=w(),{onJumpToMessage:t}=ce(),s=e.isAnswer===!0,a=e.status==="running",p=(e.parallelCount??1)>1,m=!!(t&&e.messageId&&!e.messageId.startsWith("summary:")),v=e.toolCall?L(e.toolCall.name):e.label,y=()=>{if((e.kind==="tool"||e.kind==="agent")&&e.toolCall){let h=U(e.toolCall.response);return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(H,{data:{name:e.toolCall.name,parameters:e.toolCall.args,type:"tool_call"},component_key:`${e.toolCall.id}-params`,interactive:!1}),h&&(0,o.jsx)("div",{style:{marginTop:8},children:(0,o.jsx)(N,{content:h})}),(0,o.jsx)(W,{ui:e.toolCall.ui})]})}return e.content?(0,o.jsx)(N,{content:e.content}):(0,o.jsx)("span",{style:{color:"#8c8c8c"},children:e.label})};return(0,o.jsxs)("div",{"data-testid":"trace-card",style:{height:"100%",display:"flex",flexDirection:"column",border:`1px solid ${s||i?"#6366f1":a?"#91caff":"#e5e7eb"}`,borderRadius:12,background:s?"#eef2ff":"#fff",boxShadow:a?"0 0 0 2px rgba(24,144,255,0.18)":i?"0 0 0 2px rgba(99,102,241,0.2)":"none",animation:a?ae:void 0,overflow:"hidden",fontSize:13},children:[(0,o.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"8px 12px",borderBottom:"1px solid #f0f0f0",background:"rgba(0,0,0,0.02)"},children:[(0,o.jsx)(de,{kind:e.kind}),(0,o.jsx)("span",{style:{fontWeight:s?700:600,flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:v}),p&&(0,o.jsx)(P,{color:"purple",style:{marginInlineEnd:0,fontSize:10},children:l("chat.trace.parallelBadge",{count:e.parallelCount??1})}),le[e.status],m&&(0,o.jsx)(T,{type:"text",size:"small",onClick:()=>t?.(e.messageId),children:l("chat.trace.jumpToChat")})]}),(0,o.jsx)("div",{style:{flex:1,minHeight:0,overflow:"auto",padding:12},children:y()})]})},fe=({data:e,selected:i})=>(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(S,{type:"target",position:R.Top}),(0,o.jsx)(pe,{data:e,selected:i}),(0,o.jsx)(S,{type:"source",position:R.Bottom})]}),j={trace:fe};var Z=f(b());var u=f(g()),ue={running:"#1890ff",success:"#52c41a",error:"#ff4d4f"},q=({graph:e,activeNodeId:i,onSelectNode:l})=>{let t=Z.default.useMemo(()=>new Map(e.nodes.map(s=>[s.id,s])),[e.nodes]);return(0,u.jsx)("div",{"data-testid":"trace-overview-rail",style:{display:"flex",flexDirection:"column",gap:10,width:160,padding:8,overflowY:"auto",borderRight:"1px solid #f0f0f0"},children:e.phases.map(s=>(0,u.jsxs)("div",{"data-testid":"trace-rail-phase",children:[(0,u.jsx)("div",{style:{fontSize:12,color:"#8c8c8c",marginBottom:4},children:s.title}),(0,u.jsx)("div",{style:{display:"flex",flexWrap:"wrap",gap:4},children:s.nodeIds.map(a=>{let p=t.get(a);if(!p)return null;let m=a===i;return(0,u.jsx)(B,{title:p.data.label,children:(0,u.jsx)("button",{type:"button","data-testid":"trace-rail-tick",onClick:()=>l?.(a),style:{width:m?12:8,height:m?12:8,borderRadius:"50%",border:"none",padding:0,cursor:"pointer",background:ue[p.data.status],outline:m?"2px solid #6366f1":"none"}})},a)})})]},s.id))})};var d=f(g()),Q=3,X=()=>{},me=`
2
2
  @keyframes tracePulse {
3
3
  0%, 100% { box-shadow: 0 0 0 2px rgba(24,144,255,0.18); }
4
4
  50% { box-shadow: 0 0 0 6px rgba(24,144,255,0.05); }
@@ -1 +1 @@
1
- import{s as D}from"./embed-page-chunk-UDSGGVJH.js";import{i as E}from"./embed-page-chunk-MVT6CPWE.js";import"./embed-page-chunk-54M4265G.js";import"./embed-page-chunk-3XPHW2C7.js";import{a as T}from"./embed-page-chunk-5QZRLAW2.js";import"./embed-page-chunk-F7ZUYG42.js";import{l as v}from"./embed-page-chunk-3FNSGFP2.js";import{a as C}from"./embed-page-chunk-QV7QAJ4N.js";import"./embed-page-chunk-VW3NF5NT.js";import"./embed-page-chunk-Z4Z6VCUZ.js";import"./embed-page-chunk-L7GPZSYD.js";import{qa as x}from"./embed-page-chunk-BUFWD6SE.js";import{a as w}from"./embed-page-chunk-R5QL57JJ.js";import"./embed-page-chunk-QOWM3LMZ.js";import"./embed-page-chunk-EUOOO2LS.js";import"./embed-page-chunk-5JDQ456X.js";import{f as p}from"./embed-page-chunk-QBTAJ2YI.js";var u=p(w());var R=p(T());var y=p(C());function g(l,i){if(!l||l.length===0)return{title:{text:i("genui.chart.title"),left:"left"},tooltip:{trigger:"axis"},legend:{right:0,orient:"vertical"},xAxis:{type:"category",data:[]},yAxis:{type:"value"},series:[{type:"line",name:i("genui.chart.seriesDefault",{n:1}),data:[]}],grid:{left:"3%",right:"4%",bottom:"3%",containLabel:!0}};let s=l[0],t=Object.keys(s);if(t.length===0)return g([],i);let r=t.filter(e=>{let n=s[e];return typeof n=="number"||!isNaN(Number(n))});if(r.length>0){let e=r[0],n=t.find(a=>!r.includes(a))||t[0],o=l.map((a,c)=>a[n]!==void 0?String(a[n]):i("genui.chart.itemDefault",{n:c+1})),f=l.map(a=>{let c=a[e];return typeof c=="number"?c:Number(c)||0});return{title:{text:i("genui.chart.title"),left:"left"},tooltip:{trigger:"axis"},legend:{right:0,orient:"vertical",data:[e]},xAxis:{type:"category",data:o},yAxis:{type:"value"},series:[{type:"line",name:e,data:f}],grid:{left:"3%",right:"4%",bottom:"3%",containLabel:!0}}}return{title:{text:i("genui.chart.title"),left:"left"},tooltip:{trigger:"axis"},legend:{right:0,orient:"vertical"},xAxis:{type:"category",data:l.map((e,n)=>i("genui.chart.itemDefault",{n:n+1}))},yAxis:{type:"value"},series:[{type:"bar",name:i("genui.chart.countSeries"),data:l.map(()=>1)}],grid:{left:"3%",right:"4%",bottom:"3%",containLabel:!0}}}function j(l,i){if(!l||typeof l!="object"||!l.series||!Array.isArray(l.series)||l.series.length===0)return null;let s=l.series.map((e,n)=>{if(!e||typeof e!="object"||!e.type||!e.data||!Array.isArray(e.data)||e.data.length===0)return null;let o={...e,name:e.name||i("genui.chart.seriesDefault",{n:n+1})};if(e.type==="pie"){let f=e.data.map((a,c)=>typeof a=="object"&&a!==null&&"value"in a?{value:a.value,name:a.name||i("genui.chart.itemDefault",{n:c+1})}:typeof a=="number"?{value:a,name:i("genui.chart.itemDefault",{n:c+1})}:null).filter(a=>a!==null);return f.length===0?null:{...o,data:f}}return o}).filter(e=>e!==null);if(s.length===0)return null;let t={...l,series:s},r=s[0].type;if(r!=="pie"){if(!t.xAxis)t.xAxis={type:"category",data:[]};else if(typeof t.xAxis=="object"&&!Array.isArray(t.xAxis)){let e=t.xAxis;if(e.type||(e.type="category"),e.type==="category"&&!e.data){let n=s[0].data;Array.isArray(n)&&n.length>0?Array.isArray(n[0])?e.data=n.map(o=>o[0]):e.data=n.map((o,f)=>i("genui.chart.itemDefault",{n:f+1})):e.data=[]}t.xAxis=e}t.yAxis?typeof t.yAxis=="object"&&!Array.isArray(t.yAxis)&&(t.yAxis.type||(t.yAxis.type="value")):t.yAxis={type:"value"}}if(!t.title)t.title={text:i("genui.chart.title"),left:"left"};else if(typeof t.title=="object"){let e=t.title;e.left||(e.left="left"),e.text||(e.text=i("genui.chart.title")),t.title=e}if(t.tooltip||(t.tooltip={trigger:r==="pie"?"item":"axis"}),!t.legend)s.length>1&&(t.legend={right:0,orient:"vertical"});else if(typeof t.legend=="object"){let e=t.legend;t.legend=e}return r!=="pie"&&!t.grid&&(t.grid={left:"3%",right:"4%",bottom:"3%",containLabel:!0}),t}function O(l,i){let s=null;try{let n=typeof l=="string"?l:l.join("");s=(0,R.parse)(n)}catch(n){return{data:null,error:`Failed to parse JSON: ${n instanceof Error?n.message:String(n)}`}}if(!s||typeof s!="object")return{data:null,error:"Parsed data is not an object"};let t=s.series&&Array.isArray(s.series)&&s.series.length>0,r={table:Array.isArray(s.table)?s.table:void 0},e=null;if(s.echarts?e=s.echarts:t&&(e=s),e){let n=j(e,i);if(n)r.echarts=n;else if(r.table&&r.table.length>0)r.echarts=g(r.table,i);else return{data:null,error:"ECharts configuration is invalid or incomplete. Required: series array with at least one series containing type and data."}}else r.table&&r.table.length>0?r.echarts=g(r.table,i):r.echarts=g([],i);return{data:r,error:null}}var K=l=>{let{children:i}=l,s=v(),t=(0,u.useRef)(null),r=(0,u.useRef)(null),e=(0,u.useRef)(null),[n,o]=(0,u.useState)(null);(0,u.useEffect)(()=>{if(!t.current)return;r.current||(r.current=D(t.current));let a=null;if((typeof i=="string"||Array.isArray(i))&&(a=i),!a){r.current&&r.current.clear(),o(null);return}let{data:c,error:m}=O(a,s);if(m||!c){console.warn("ReactChart failed to parse chart data:",m||"Unknown parse error"),r.current&&r.current.clear(),o(null);return}if(c.table&&Array.isArray(c.table)&&o(c.table),c.echarts)try{r.current.setOption(c.echarts,!0)}catch(d){let A=d instanceof Error?d.message:"Failed to render chart";console.error("Failed to set ECharts option:",d),r.current&&r.current.clear(),o(null)}let h=()=>{r.current&&r.current.resize()};return e.current&&(e.current.disconnect(),e.current=null),t.current&&typeof ResizeObserver<"u"&&(e.current=new ResizeObserver(d=>{requestAnimationFrame(()=>{h()})}),e.current.observe(t.current)),window.addEventListener("resize",h),()=>{e.current&&(e.current.disconnect(),e.current=null),window.removeEventListener("resize",h)}},[i,s]),(0,u.useEffect)(()=>()=>{e.current&&(e.current.disconnect(),e.current=null),r.current&&(r.current.dispose(),r.current=null)},[]);let f=a=>{if(!a||a.length===0)return[];if(Array.isArray(a[0])){let c=a[0];return a.slice(1).map((h,d)=>{let A={};return h.forEach((S,b)=>{A[c[b]||`col_${b}`]=S}),A})}return a};return(0,y.jsxs)(x,{children:[(0,y.jsx)("div",{ref:t,style:{width:"100%",height:"400px",minHeight:"300px"}}),n&&n.length>0&&(0,y.jsx)("div",{style:{marginTop:16},children:(0,y.jsx)(E,{component_key:"chart_table_data",data:{dataSource:f(n),message:s("genui.chart.dataDetails")},interactive:!0,default_open_in_side_app:!0})})]})};export{K as ReactChart};
1
+ import{s as D}from"./embed-page-chunk-UDSGGVJH.js";import{i as E}from"./embed-page-chunk-KWZEITYQ.js";import"./embed-page-chunk-54M4265G.js";import"./embed-page-chunk-3XPHW2C7.js";import{a as T}from"./embed-page-chunk-5QZRLAW2.js";import"./embed-page-chunk-F7ZUYG42.js";import{l as v}from"./embed-page-chunk-3FNSGFP2.js";import{a as C}from"./embed-page-chunk-QV7QAJ4N.js";import"./embed-page-chunk-VW3NF5NT.js";import"./embed-page-chunk-Z4Z6VCUZ.js";import"./embed-page-chunk-L7GPZSYD.js";import{qa as x}from"./embed-page-chunk-BUFWD6SE.js";import{a as w}from"./embed-page-chunk-R5QL57JJ.js";import"./embed-page-chunk-QOWM3LMZ.js";import"./embed-page-chunk-EUOOO2LS.js";import"./embed-page-chunk-5JDQ456X.js";import{f as p}from"./embed-page-chunk-QBTAJ2YI.js";var u=p(w());var R=p(T());var y=p(C());function g(l,i){if(!l||l.length===0)return{title:{text:i("genui.chart.title"),left:"left"},tooltip:{trigger:"axis"},legend:{right:0,orient:"vertical"},xAxis:{type:"category",data:[]},yAxis:{type:"value"},series:[{type:"line",name:i("genui.chart.seriesDefault",{n:1}),data:[]}],grid:{left:"3%",right:"4%",bottom:"3%",containLabel:!0}};let s=l[0],t=Object.keys(s);if(t.length===0)return g([],i);let r=t.filter(e=>{let n=s[e];return typeof n=="number"||!isNaN(Number(n))});if(r.length>0){let e=r[0],n=t.find(a=>!r.includes(a))||t[0],o=l.map((a,c)=>a[n]!==void 0?String(a[n]):i("genui.chart.itemDefault",{n:c+1})),f=l.map(a=>{let c=a[e];return typeof c=="number"?c:Number(c)||0});return{title:{text:i("genui.chart.title"),left:"left"},tooltip:{trigger:"axis"},legend:{right:0,orient:"vertical",data:[e]},xAxis:{type:"category",data:o},yAxis:{type:"value"},series:[{type:"line",name:e,data:f}],grid:{left:"3%",right:"4%",bottom:"3%",containLabel:!0}}}return{title:{text:i("genui.chart.title"),left:"left"},tooltip:{trigger:"axis"},legend:{right:0,orient:"vertical"},xAxis:{type:"category",data:l.map((e,n)=>i("genui.chart.itemDefault",{n:n+1}))},yAxis:{type:"value"},series:[{type:"bar",name:i("genui.chart.countSeries"),data:l.map(()=>1)}],grid:{left:"3%",right:"4%",bottom:"3%",containLabel:!0}}}function j(l,i){if(!l||typeof l!="object"||!l.series||!Array.isArray(l.series)||l.series.length===0)return null;let s=l.series.map((e,n)=>{if(!e||typeof e!="object"||!e.type||!e.data||!Array.isArray(e.data)||e.data.length===0)return null;let o={...e,name:e.name||i("genui.chart.seriesDefault",{n:n+1})};if(e.type==="pie"){let f=e.data.map((a,c)=>typeof a=="object"&&a!==null&&"value"in a?{value:a.value,name:a.name||i("genui.chart.itemDefault",{n:c+1})}:typeof a=="number"?{value:a,name:i("genui.chart.itemDefault",{n:c+1})}:null).filter(a=>a!==null);return f.length===0?null:{...o,data:f}}return o}).filter(e=>e!==null);if(s.length===0)return null;let t={...l,series:s},r=s[0].type;if(r!=="pie"){if(!t.xAxis)t.xAxis={type:"category",data:[]};else if(typeof t.xAxis=="object"&&!Array.isArray(t.xAxis)){let e=t.xAxis;if(e.type||(e.type="category"),e.type==="category"&&!e.data){let n=s[0].data;Array.isArray(n)&&n.length>0?Array.isArray(n[0])?e.data=n.map(o=>o[0]):e.data=n.map((o,f)=>i("genui.chart.itemDefault",{n:f+1})):e.data=[]}t.xAxis=e}t.yAxis?typeof t.yAxis=="object"&&!Array.isArray(t.yAxis)&&(t.yAxis.type||(t.yAxis.type="value")):t.yAxis={type:"value"}}if(!t.title)t.title={text:i("genui.chart.title"),left:"left"};else if(typeof t.title=="object"){let e=t.title;e.left||(e.left="left"),e.text||(e.text=i("genui.chart.title")),t.title=e}if(t.tooltip||(t.tooltip={trigger:r==="pie"?"item":"axis"}),!t.legend)s.length>1&&(t.legend={right:0,orient:"vertical"});else if(typeof t.legend=="object"){let e=t.legend;t.legend=e}return r!=="pie"&&!t.grid&&(t.grid={left:"3%",right:"4%",bottom:"3%",containLabel:!0}),t}function O(l,i){let s=null;try{let n=typeof l=="string"?l:l.join("");s=(0,R.parse)(n)}catch(n){return{data:null,error:`Failed to parse JSON: ${n instanceof Error?n.message:String(n)}`}}if(!s||typeof s!="object")return{data:null,error:"Parsed data is not an object"};let t=s.series&&Array.isArray(s.series)&&s.series.length>0,r={table:Array.isArray(s.table)?s.table:void 0},e=null;if(s.echarts?e=s.echarts:t&&(e=s),e){let n=j(e,i);if(n)r.echarts=n;else if(r.table&&r.table.length>0)r.echarts=g(r.table,i);else return{data:null,error:"ECharts configuration is invalid or incomplete. Required: series array with at least one series containing type and data."}}else r.table&&r.table.length>0?r.echarts=g(r.table,i):r.echarts=g([],i);return{data:r,error:null}}var K=l=>{let{children:i}=l,s=v(),t=(0,u.useRef)(null),r=(0,u.useRef)(null),e=(0,u.useRef)(null),[n,o]=(0,u.useState)(null);(0,u.useEffect)(()=>{if(!t.current)return;r.current||(r.current=D(t.current));let a=null;if((typeof i=="string"||Array.isArray(i))&&(a=i),!a){r.current&&r.current.clear(),o(null);return}let{data:c,error:m}=O(a,s);if(m||!c){console.warn("ReactChart failed to parse chart data:",m||"Unknown parse error"),r.current&&r.current.clear(),o(null);return}if(c.table&&Array.isArray(c.table)&&o(c.table),c.echarts)try{r.current.setOption(c.echarts,!0)}catch(d){let A=d instanceof Error?d.message:"Failed to render chart";console.error("Failed to set ECharts option:",d),r.current&&r.current.clear(),o(null)}let h=()=>{r.current&&r.current.resize()};return e.current&&(e.current.disconnect(),e.current=null),t.current&&typeof ResizeObserver<"u"&&(e.current=new ResizeObserver(d=>{requestAnimationFrame(()=>{h()})}),e.current.observe(t.current)),window.addEventListener("resize",h),()=>{e.current&&(e.current.disconnect(),e.current=null),window.removeEventListener("resize",h)}},[i,s]),(0,u.useEffect)(()=>()=>{e.current&&(e.current.disconnect(),e.current=null),r.current&&(r.current.dispose(),r.current=null)},[]);let f=a=>{if(!a||a.length===0)return[];if(Array.isArray(a[0])){let c=a[0];return a.slice(1).map((h,d)=>{let A={};return h.forEach((S,b)=>{A[c[b]||`col_${b}`]=S}),A})}return a};return(0,y.jsxs)(x,{children:[(0,y.jsx)("div",{ref:t,style:{width:"100%",height:"400px",minHeight:"300px"}}),n&&n.length>0&&(0,y.jsx)("div",{style:{marginTop:16},children:(0,y.jsx)(E,{component_key:"chart_table_data",data:{dataSource:f(n),message:s("genui.chart.dataDetails")},interactive:!0,default_open_in_side_app:!0})})]})};export{K as ReactChart};
@@ -1,4 +1,4 @@
1
- import{a as Ze}from"./embed-page-chunk-4BPMGDDV.js";import{c as qe,d as Ke}from"./embed-page-chunk-HQLSH3FC.js";import{b as Ne,e as Ie,h as He,i as We}from"./embed-page-chunk-5AWYMAAX.js";import"./embed-page-chunk-S4XZPBRM.js";import{C as Ve,D as Ue,E as ue,F as Re,G as Ye,H as Qe,I as Je,K as Xe,L as et,M as tt,N as ot,r as Ge}from"./embed-page-chunk-MVT6CPWE.js";import{g as q,i as _e}from"./embed-page-chunk-54M4265G.js";import"./embed-page-chunk-3XPHW2C7.js";import{l as Ee,o as Oe}from"./embed-page-chunk-5QZRLAW2.js";import{I as Fe,Qa as me,n as ce,ya as pe}from"./embed-page-chunk-F7ZUYG42.js";import{l as j}from"./embed-page-chunk-3FNSGFP2.js";import{a as A}from"./embed-page-chunk-QV7QAJ4N.js";import"./embed-page-chunk-VW3NF5NT.js";import"./embed-page-chunk-Z4Z6VCUZ.js";import"./embed-page-chunk-L7GPZSYD.js";import{Da as W,Ia as Ce,Ja as J,Ma as ze,Sa as le,Za as Me,_ as ae,aa as Be,ba as Le,bb as de,fa as be,va as De}from"./embed-page-chunk-BUFWD6SE.js";import{a as se}from"./embed-page-chunk-R5QL57JJ.js";import"./embed-page-chunk-QOWM3LMZ.js";import"./embed-page-chunk-EUOOO2LS.js";import"./embed-page-chunk-5JDQ456X.js";import{f as T}from"./embed-page-chunk-QBTAJ2YI.js";var n=T(se());var it=T(se());var s=T(A()),Tt=[{key:"pending",color:"#7A7A7A"},{key:"in_progress",color:"#3b82f6"},{key:"failed",color:"#ef4444"},{key:"interrupted",color:"#8b5cf6"},{key:"completed",color:"#22c55e"}],rt={high:"#ef4444",medium:"#f59e0b",low:"#22c55e"};function bt(e){return e==="high"||e==="low"?e:"medium"}function Ct(e,i){let f=typeof e=="string"?new Date(e):e,a=new Date().getTime()-f.getTime(),k=Math.floor(a/1e3),o=Math.floor(k/60),r=Math.floor(o/60),l=Math.floor(r/24);return k<60?i("common.time.justNow"):o<60?i("common.time.minutesAgo",{count:o}):r<24?i("common.time.hoursAgo",{count:r}):l<30?i("common.time.daysAgo",{count:l}):f.toLocaleDateString(i.locale)}var Nt=q(({css:e,token:i})=>({container:e`
1
+ import{a as Ze}from"./embed-page-chunk-NR4M6XSO.js";import{c as qe,d as Ke}from"./embed-page-chunk-HQLSH3FC.js";import{b as Ne,e as Ie,h as He,i as We}from"./embed-page-chunk-5AWYMAAX.js";import"./embed-page-chunk-S4XZPBRM.js";import{C as Ve,D as Ue,E as ue,F as Re,G as Ye,H as Qe,I as Je,K as Xe,L as et,M as tt,N as ot,r as Ge}from"./embed-page-chunk-KWZEITYQ.js";import{g as q,i as _e}from"./embed-page-chunk-54M4265G.js";import"./embed-page-chunk-3XPHW2C7.js";import{l as Ee,o as Oe}from"./embed-page-chunk-5QZRLAW2.js";import{I as Fe,Qa as me,n as ce,ya as pe}from"./embed-page-chunk-F7ZUYG42.js";import{l as j}from"./embed-page-chunk-3FNSGFP2.js";import{a as A}from"./embed-page-chunk-QV7QAJ4N.js";import"./embed-page-chunk-VW3NF5NT.js";import"./embed-page-chunk-Z4Z6VCUZ.js";import"./embed-page-chunk-L7GPZSYD.js";import{Da as W,Ia as Ce,Ja as J,Ma as ze,Sa as le,Za as Me,_ as ae,aa as Be,ba as Le,bb as de,fa as be,va as De}from"./embed-page-chunk-BUFWD6SE.js";import{a as se}from"./embed-page-chunk-R5QL57JJ.js";import"./embed-page-chunk-QOWM3LMZ.js";import"./embed-page-chunk-EUOOO2LS.js";import"./embed-page-chunk-5JDQ456X.js";import{f as T}from"./embed-page-chunk-QBTAJ2YI.js";var n=T(se());var it=T(se());var s=T(A()),Tt=[{key:"pending",color:"#7A7A7A"},{key:"in_progress",color:"#3b82f6"},{key:"failed",color:"#ef4444"},{key:"interrupted",color:"#8b5cf6"},{key:"completed",color:"#22c55e"}],rt={high:"#ef4444",medium:"#f59e0b",low:"#22c55e"};function bt(e){return e==="high"||e==="low"?e:"medium"}function Ct(e,i){let f=typeof e=="string"?new Date(e):e,a=new Date().getTime()-f.getTime(),k=Math.floor(a/1e3),o=Math.floor(k/60),r=Math.floor(o/60),l=Math.floor(r/24);return k<60?i("common.time.justNow"):o<60?i("common.time.minutesAgo",{count:o}):r<24?i("common.time.hoursAgo",{count:r}):l<30?i("common.time.daysAgo",{count:l}):f.toLocaleDateString(i.locale)}var Nt=q(({css:e,token:i})=>({container:e`
2
2
  display: flex;
3
3
  flex-direction: column;
4
4
  height: 100%;
@@ -1,4 +1,4 @@
1
- import{a as ue,c as fe}from"./embed-page-chunk-DI5UAV2I.js";import{a as xe}from"./embed-page-chunk-HQLSH3FC.js";import{a as ie,b as G,e as V,f as U,g as re,h as se,i as ae,k as le,l as de,m as ce,n as pe}from"./embed-page-chunk-5AWYMAAX.js";import"./embed-page-chunk-S4XZPBRM.js";import{j as O}from"./embed-page-chunk-MVT6CPWE.js";import"./embed-page-chunk-54M4265G.js";import{a as j}from"./embed-page-chunk-3XPHW2C7.js";import"./embed-page-chunk-5QZRLAW2.js";import{A as oe,E as $,Pa as ne,g as te,ma as H,y as L}from"./embed-page-chunk-F7ZUYG42.js";import{l as N}from"./embed-page-chunk-3FNSGFP2.js";import{a as D}from"./embed-page-chunk-QV7QAJ4N.js";import"./embed-page-chunk-VW3NF5NT.js";import"./embed-page-chunk-Z4Z6VCUZ.js";import{G as Q,Ma as ee}from"./embed-page-chunk-L7GPZSYD.js";import{Ja as M,Ka as K,Oa as Z,Sa as X,Za as I,ba as P,bb as q,ha as B,ya as J,za as F}from"./embed-page-chunk-BUFWD6SE.js";import{a as Y}from"./embed-page-chunk-R5QL57JJ.js";import"./embed-page-chunk-QOWM3LMZ.js";import"./embed-page-chunk-EUOOO2LS.js";import"./embed-page-chunk-5JDQ456X.js";import{f as T}from"./embed-page-chunk-QBTAJ2YI.js";var s=T(Y());var _=T(xe());var ge=T(Y());var ye=T(D()),me=({steps:t,graphDefinition:o,assistantId:r})=>{let n=(0,ge.useMemo)(()=>fe(o),[o]);return(0,ye.jsx)(ue,{dsl:n,steps:t,assistantId:r})};var e=T(D()),ve=`
1
+ import{a as ue,c as fe}from"./embed-page-chunk-NGO5C5RH.js";import{a as xe}from"./embed-page-chunk-HQLSH3FC.js";import{a as ie,b as G,e as V,f as U,g as re,h as se,i as ae,k as le,l as de,m as ce,n as pe}from"./embed-page-chunk-5AWYMAAX.js";import"./embed-page-chunk-S4XZPBRM.js";import{j as O}from"./embed-page-chunk-KWZEITYQ.js";import"./embed-page-chunk-54M4265G.js";import{a as j}from"./embed-page-chunk-3XPHW2C7.js";import"./embed-page-chunk-5QZRLAW2.js";import{A as oe,E as $,Pa as ne,g as te,ma as H,y as L}from"./embed-page-chunk-F7ZUYG42.js";import{l as N}from"./embed-page-chunk-3FNSGFP2.js";import{a as D}from"./embed-page-chunk-QV7QAJ4N.js";import"./embed-page-chunk-VW3NF5NT.js";import"./embed-page-chunk-Z4Z6VCUZ.js";import{G as Q,Ma as ee}from"./embed-page-chunk-L7GPZSYD.js";import{Ja as M,Ka as K,Oa as Z,Sa as X,Za as I,ba as P,bb as q,ha as B,ya as J,za as F}from"./embed-page-chunk-BUFWD6SE.js";import{a as Y}from"./embed-page-chunk-R5QL57JJ.js";import"./embed-page-chunk-QOWM3LMZ.js";import"./embed-page-chunk-EUOOO2LS.js";import"./embed-page-chunk-5JDQ456X.js";import{f as T}from"./embed-page-chunk-QBTAJ2YI.js";var s=T(Y());var _=T(xe());var ge=T(Y());var ye=T(D()),me=({steps:t,graphDefinition:o,assistantId:r})=>{let n=(0,ge.useMemo)(()=>fe(o),[o]);return(0,ye.jsx)(ue,{dsl:n,steps:t,assistantId:r})};var e=T(D()),ve=`
2
2
  @keyframes spin {
3
3
  from { transform: rotate(0deg); }
4
4
  to { transform: rotate(360deg); }
@@ -1,3 +1,3 @@
1
- import{a as $e,b as Ue}from"./embed-page-chunk-5HWN5HSA.js";import{b as Xe,c as me}from"./embed-page-chunk-DI5UAV2I.js";import"./embed-page-chunk-HQLSH3FC.js";import{f as Ye}from"./embed-page-chunk-5AWYMAAX.js";import"./embed-page-chunk-S4XZPBRM.js";import{T as Ge,j as Ke}from"./embed-page-chunk-MVT6CPWE.js";import{i as te}from"./embed-page-chunk-54M4265G.js";import{a as ne}from"./embed-page-chunk-3XPHW2C7.js";import"./embed-page-chunk-5QZRLAW2.js";import{Ea as q,Ha as fe,I as ce,Ja as qe,O as pe,Ra as ue,Sa as ee,Ta as He,Y as je,_ as Ee,aa as ge,fa as _e,ia as Fe,l as Oe,na as Be,o as de,t as Pe,za as Ne}from"./embed-page-chunk-F7ZUYG42.js";import{l as O}from"./embed-page-chunk-3FNSGFP2.js";import{a as j}from"./embed-page-chunk-QV7QAJ4N.js";import"./embed-page-chunk-VW3NF5NT.js";import"./embed-page-chunk-Z4Z6VCUZ.js";import{Ba as De,G as Te,Ja as le,Ra as Le,sa as Me}from"./embed-page-chunk-L7GPZSYD.js";import{Da as J,Ia as V,Ja as ae,Ma as Q,Oa as Ae,W as ze,_ as $,ba as U,bb as Z,ha as X,qa as Ie}from"./embed-page-chunk-BUFWD6SE.js";import{a as se}from"./embed-page-chunk-R5QL57JJ.js";import"./embed-page-chunk-QOWM3LMZ.js";import"./embed-page-chunk-EUOOO2LS.js";import"./embed-page-chunk-5JDQ456X.js";import{f as I}from"./embed-page-chunk-QBTAJ2YI.js";var i=I(se());var oe=I(se());var P=I(j());function ft(r){let o=r.split(/[\n\r.。;;!!??]+/).filter(Boolean)[0]?.trim()||"";return o=o.replace(/[,,]+$/,"").trim(),o.length>50&&(o=o.slice(0,50)),o||(o=r.slice(0,50).trim()),o}function ut(r){let e=5381;for(let o=0;o<r.length;o++)e=(e<<5)+e+r.charCodeAt(o)>>>0;return e.toString(36).slice(0,6)}var be=({open:r,onCancel:e,onCreated:o})=>{let{post:w}=ne(),v=O(),{trainingProjects:d,loading:u}=te(),[y,p]=(0,oe.useState)(null),[g]=J.useForm(),b=d.find(h=>h.id===y)??d[0]??null;(0,oe.useEffect)(()=>{r&&(g.resetFields(),p(null))},[r,g]);let R=async()=>{if(!b)return;let m=((await g.validateFields()).purpose||"").trim(),A=ft(m),z=`wf-${ut(m+Date.now())}`,E={key:z,name:A,description:m,type:"workflow",prompt:"Complete the assigned task accurately and concisely.",metadata:{trainingProjectId:b?.id},workflowYaml:`name: ${z}
1
+ import{a as $e,b as Ue}from"./embed-page-chunk-62CAXPZK.js";import{b as Xe,c as me}from"./embed-page-chunk-NGO5C5RH.js";import"./embed-page-chunk-HQLSH3FC.js";import{f as Ye}from"./embed-page-chunk-5AWYMAAX.js";import"./embed-page-chunk-S4XZPBRM.js";import{T as Ge,j as Ke}from"./embed-page-chunk-KWZEITYQ.js";import{i as te}from"./embed-page-chunk-54M4265G.js";import{a as ne}from"./embed-page-chunk-3XPHW2C7.js";import"./embed-page-chunk-5QZRLAW2.js";import{Ea as q,Ha as fe,I as ce,Ja as qe,O as pe,Ra as ue,Sa as ee,Ta as He,Y as je,_ as Ee,aa as ge,fa as _e,ia as Fe,l as Oe,na as Be,o as de,t as Pe,za as Ne}from"./embed-page-chunk-F7ZUYG42.js";import{l as O}from"./embed-page-chunk-3FNSGFP2.js";import{a as j}from"./embed-page-chunk-QV7QAJ4N.js";import"./embed-page-chunk-VW3NF5NT.js";import"./embed-page-chunk-Z4Z6VCUZ.js";import{Ba as De,G as Te,Ja as le,Ra as Le,sa as Me}from"./embed-page-chunk-L7GPZSYD.js";import{Da as J,Ia as V,Ja as ae,Ma as Q,Oa as Ae,W as ze,_ as $,ba as U,bb as Z,ha as X,qa as Ie}from"./embed-page-chunk-BUFWD6SE.js";import{a as se}from"./embed-page-chunk-R5QL57JJ.js";import"./embed-page-chunk-QOWM3LMZ.js";import"./embed-page-chunk-EUOOO2LS.js";import"./embed-page-chunk-5JDQ456X.js";import{f as I}from"./embed-page-chunk-QBTAJ2YI.js";var i=I(se());var oe=I(se());var P=I(j());function ft(r){let o=r.split(/[\n\r.。;;!!??]+/).filter(Boolean)[0]?.trim()||"";return o=o.replace(/[,,]+$/,"").trim(),o.length>50&&(o=o.slice(0,50)),o||(o=r.slice(0,50).trim()),o}function ut(r){let e=5381;for(let o=0;o<r.length;o++)e=(e<<5)+e+r.charCodeAt(o)>>>0;return e.toString(36).slice(0,6)}var be=({open:r,onCancel:e,onCreated:o})=>{let{post:w}=ne(),v=O(),{trainingProjects:d,loading:u}=te(),[y,p]=(0,oe.useState)(null),[g]=J.useForm(),b=d.find(h=>h.id===y)??d[0]??null;(0,oe.useEffect)(()=>{r&&(g.resetFields(),p(null))},[r,g]);let R=async()=>{if(!b)return;let m=((await g.validateFields()).purpose||"").trim(),A=ft(m),z=`wf-${ut(m+Date.now())}`,E={key:z,name:A,description:m,type:"workflow",prompt:"Complete the assigned task accurately and concisely.",metadata:{trainingProjectId:b?.id},workflowYaml:`name: ${z}
2
2
  steps: []
3
3
  `};await w("/api/assistants",{id:z,name:A,description:m,graphDefinition:E}),g.resetFields(),o(z,m,b?.id)};return(0,P.jsx)(Q,{title:v("chatConfig.workflow.create.title"),open:r,onCancel:e,onOk:R,okText:v("common.create"),okButtonProps:{disabled:u||!b},destroyOnClose:!0,children:(0,P.jsxs)(J,{form:g,layout:"vertical",initialValues:{purpose:""},children:[(0,P.jsx)(J.Item,{name:"purpose",label:v("chatConfig.workflow.field.purpose"),rules:[{required:!0,message:v("chatConfig.workflow.validation.purposeRequired")}],children:(0,P.jsx)(V.TextArea,{placeholder:v("chatConfig.workflow.field.purposePlaceholder"),rows:4})}),(0,P.jsx)($e,{project:b,value:b?.id??null,onChange:p,loading:u})]})})};var Qe=I(se());var t=I(j()),{Text:ye}=Z;function mt(r){if(!r||typeof r!="object")return null;let e=r;return{modelKey:e.modelKey||e.model||void 0,tools:Array.isArray(e.tools)?e.tools:[],middleware:Array.isArray(e.middleware)?e.middleware.filter(o=>o&&typeof o=="object"&&o.type):[],subAgents:Array.isArray(e.subAgents)?e.subAgents:[],skillCategories:Array.isArray(e.skillCategories)?e.skillCategories:[],runConfig:e.runConfig&&typeof e.runConfig=="object"?e.runConfig:void 0}}var bt={filesystem:(0,t.jsx)(je,{size:12}),code_eval:(0,t.jsx)(qe,{size:12}),browser:(0,t.jsx)(ge,{size:12}),sql:(0,t.jsx)(pe,{size:12}),skill:(0,t.jsx)(fe,{size:12}),http:(0,t.jsx)(Fe,{size:12}),scheduler:(0,t.jsx)(ce,{size:12}),metrics:(0,t.jsx)(Oe,{size:12}),ask_user_to_clarify:(0,t.jsx)(Be,{size:12}),widget:(0,t.jsx)(de,{size:12}),date:(0,t.jsx)(Pe,{size:12}),task:(0,t.jsx)(Ee,{size:12}),custom:(0,t.jsx)(Ne,{size:12}),claw:(0,t.jsx)(q,{size:12}),collection:(0,t.jsx)(_e,{size:12})},yt={filesystem:{bg:"rgba(34,197,94,0.08)",text:"#16a34a",border:"rgba(34,197,94,0.2)"},code_eval:{bg:"rgba(99,102,241,0.08)",text:"#4f46e5",border:"rgba(99,102,241,0.2)"},browser:{bg:"rgba(59,130,246,0.08)",text:"#2563eb",border:"rgba(59,130,246,0.2)"},sql:{bg:"rgba(249,115,22,0.08)",text:"#ea580c",border:"rgba(249,115,22,0.2)"},skill:{bg:"rgba(168,85,247,0.08)",text:"#9333ea",border:"rgba(168,85,247,0.2)"},http:{bg:"rgba(20,184,166,0.08)",text:"#0d9488",border:"rgba(20,184,166,0.2)"},scheduler:{bg:"rgba(245,158,11,0.08)",text:"#d97706",border:"rgba(245,158,11,0.2)"},metrics:{bg:"rgba(236,72,153,0.08)",text:"#db2777",border:"rgba(236,72,153,0.2)"},ask_user_to_clarify:{bg:"rgba(245,158,11,0.08)",text:"#d97706",border:"rgba(245,158,11,0.2)"},widget:{bg:"rgba(20,184,166,0.08)",text:"#0d9488",border:"rgba(20,184,166,0.2)"},date:{bg:"rgba(139,92,246,0.08)",text:"#7c3aed",border:"rgba(139,92,246,0.2)"},task:{bg:"rgba(99,102,241,0.08)",text:"#4f46e5",border:"rgba(99,102,241,0.2)"},custom:{bg:"rgba(107,114,128,0.08)",text:"#4b5563",border:"rgba(107,114,128,0.2)"},claw:{bg:"rgba(107,114,128,0.08)",text:"#4b5563",border:"rgba(107,114,128,0.2)"},collection:{bg:"rgba(6,182,212,0.08)",text:"#0891b2",border:"rgba(6,182,212,0.2)"}},wt={bg:"rgba(107,114,128,0.08)",text:"#4b5563",border:"rgba(107,114,128,0.2)"};function ht(r){let e=r.split(/[_-]+/).filter(Boolean);return e.length===1?e[0].slice(0,2).toUpperCase():e.map(o=>o[0]).join("").toUpperCase().slice(0,2)}var Je=[{bg:"rgba(99,102,241,0.1)",text:"#6366f1"},{bg:"rgba(34,197,94,0.1)",text:"#22c55e"},{bg:"rgba(245,158,11,0.1)",text:"#f59e0b"},{bg:"rgba(59,130,246,0.1)",text:"#3b82f6"},{bg:"rgba(239,68,68,0.1)",text:"#ef4444"},{bg:"rgba(168,85,247,0.1)",text:"#a855f7"},{bg:"rgba(20,184,166,0.1)",text:"#14b8a6"},{bg:"rgba(236,72,153,0.1)",text:"#ec4899"}];function Ve(r){return Je[r%Je.length]}var H=({icon:r,label:e,count:o,children:w})=>(0,t.jsxs)("div",{style:{marginBottom:10},children:[(0,t.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:6},children:[(0,t.jsx)("span",{style:{color:"#6366f1",display:"flex",alignItems:"center"},children:r}),(0,t.jsx)(ye,{strong:!0,style:{fontSize:11,color:"#52525b",textTransform:"uppercase",letterSpacing:"0.3px"},children:e}),(0,t.jsx)("span",{style:{fontSize:9,fontWeight:600,color:"#a1a1aa",background:"rgba(0,0,0,0.04)",borderRadius:8,padding:"1px 6px",lineHeight:"16px"},children:o})]}),w]}),Ze=({graphDef:r})=>{let e=O(),o=(0,Qe.useMemo)(()=>mt(r),[r]);if(!o)return null;let w=o.middleware.filter(d=>d.enabled!==!1),v=!1;return o.tools.length===0&&w.length===0&&o.subAgents.length===0?null:(0,t.jsx)("div",{style:{pointerEvents:"auto"},children:(0,t.jsxs)("div",{style:{background:"rgba(255,255,255,0.5)",borderRadius:8,width:250,transition:"all 0.25s ease",overflow:"hidden"},children:[(0,t.jsx)("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"8px 12px",background:"rgba(99,102,241,0.02)",borderBottom:"1px solid rgba(0,0,0,0.03)"},children:(0,t.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8},children:[(0,t.jsx)("div",{style:{width:24,height:24,borderRadius:6,background:"rgba(99,102,241,0.05)",display:"flex",alignItems:"center",justifyContent:"center",color:"#6366f1"},children:(0,t.jsx)(q,{size:13})}),(0,t.jsx)(ye,{strong:!0,style:{fontSize:12,color:"#1a1a1a"},children:e("chat.environment.title")})]})}),(0,t.jsxs)("div",{style:{padding:"10px 12px 12px",maxHeight:"calc(60vh - 48px)",overflowY:"auto"},children:[o.tools.length>0&&(0,t.jsx)(H,{icon:(0,t.jsx)(He,{size:12}),label:e("chat.environment.tools"),count:o.tools.length,children:(0,t.jsx)("div",{style:{display:"flex",flexWrap:"wrap",gap:4},children:o.tools.map((d,u)=>{let y=Ve(u);return(0,t.jsx)(X,{title:d,placement:"top",children:(0,t.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:4,padding:"3px 8px",borderRadius:6,fontSize:10,fontWeight:500,color:y.text,background:y.bg,cursor:"default",whiteSpace:"nowrap",lineHeight:"16px"},children:[(0,t.jsx)("span",{style:{fontWeight:700,fontSize:9,opacity:.7},children:ht(d)}),(0,t.jsx)("span",{children:d})]})},d)})})}),w.length>0&&(0,t.jsx)(H,{icon:(0,t.jsx)(de,{size:12}),label:e("chat.environment.capabilities"),count:w.length,children:(0,t.jsx)("div",{style:{display:"flex",flexWrap:"wrap",gap:4},children:w.map(d=>{let u=yt[d.type]||wt,y=bt[d.type]||(0,t.jsx)(q,{size:12});return(0,t.jsx)(X,{title:d.name||d.type,placement:"top",children:(0,t.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:4,padding:"3px 8px",borderRadius:6,fontSize:10,fontWeight:500,color:u.text,background:u.bg,border:`1px solid ${u.border}`,cursor:"default",whiteSpace:"nowrap",lineHeight:"16px"},children:[y,(0,t.jsx)("span",{children:d.name||d.type})]})},d.type)})})}),o.subAgents.length>0&&(0,t.jsx)(H,{icon:(0,t.jsx)(ue,{size:12}),label:e("chat.environment.subAgents"),count:o.subAgents.length,children:(0,t.jsx)("div",{style:{display:"flex",flexWrap:"wrap",gap:4},children:o.subAgents.map((d,u)=>{let y=Ve(u+3);return(0,t.jsx)(X,{title:d,placement:"top",children:(0,t.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:4,padding:"3px 8px",borderRadius:6,fontSize:10,fontWeight:500,color:y.text,background:y.bg,cursor:"default",whiteSpace:"nowrap",lineHeight:"16px"},children:[(0,t.jsx)(ue,{size:10}),(0,t.jsx)("span",{children:d})]})},d)})})}),(o.modelKey||o.runConfig)&&(0,t.jsx)(H,{icon:(0,t.jsx)(ce,{size:12}),label:e("chat.environment.runtime"),count:o.modelKey?1:0,children:(0,t.jsxs)("div",{style:{display:"flex",flexWrap:"wrap",gap:4},children:[o.modelKey&&(0,t.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:4,padding:"3px 8px",borderRadius:6,fontSize:10,fontWeight:500,color:"#4f46e5",background:"rgba(99,102,241,0.08)",border:"1px solid rgba(99,102,241,0.2)",cursor:"default",whiteSpace:"nowrap",lineHeight:"16px"},children:[(0,t.jsx)(q,{size:10}),(0,t.jsx)("span",{children:e("chat.environment.model",{model:o.modelKey})})]}),!!o.runConfig?.databaseKey&&(0,t.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:4,padding:"3px 8px",borderRadius:6,fontSize:10,fontWeight:500,color:"#ea580c",background:"rgba(249,115,22,0.08)",border:"1px solid rgba(249,115,22,0.2)",cursor:"default",whiteSpace:"nowrap",lineHeight:"16px"},children:[(0,t.jsx)(pe,{size:10}),(0,t.jsx)("span",{children:e("chat.environment.db",{db:String(o.runConfig?.databaseKey)})})]}),o.skillCategories&&o.skillCategories.length>0&&(0,t.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:4,padding:"3px 8px",borderRadius:6,fontSize:10,fontWeight:500,color:"#9333ea",background:"rgba(168,85,247,0.08)",border:"1px solid rgba(168,85,247,0.2)",cursor:"default",whiteSpace:"nowrap",lineHeight:"16px"},children:[(0,t.jsx)(fe,{size:10}),(0,t.jsx)("span",{children:e("chat.environment.skills",{skills:o.skillCategories.join(", ")})})]})]})}),v&&(0,t.jsx)(H,{icon:(0,t.jsx)(ge,{size:12}),label:e("chat.environment.channels"),count:0,children:(0,t.jsx)(ye,{type:"secondary",style:{fontSize:10,fontStyle:"italic"},children:e("chat.environment.noChannels")})})]})]})})};var n=I(j()),{Text:K}=Z,xt=300;function et(r){if(typeof r=="string")try{let e=JSON.parse(r);return e&&typeof e=="object"&&!Array.isArray(e)?e:null}catch{return null}return r&&typeof r=="object"&&!Array.isArray(r)?r:null}function kt(r){let e=null;if(typeof r=="string")try{e=JSON.parse(r)}catch{return null}else r&&typeof r=="object"&&(e=r);if(!e)return null;if(e.type!=="workflow")return console.warn("[extractDSL] type is not 'workflow':",e.type),null;if(typeof e.workflowYaml!="string")return console.warn("[extractDSL] workflowYaml not found or not a string, keys:",Object.keys(e)),null;try{return me(e.workflowYaml)}catch(o){return console.error("[extractDSL] expandWorkflow failed:",o.message,o),null}}function vt({workflows:r,selectedId:e,onSelect:o,onCreate:w,onDelete:v,dsl:d,agentNameMap:u,onSpecClick:y,environmentConfig:p}){let g=O(),b=r.find(f=>f.id===e),[R,h]=(0,i.useState)(!0),[m,A]=(0,i.useState)(""),z=(0,i.useMemo)(()=>{let f=m.trim().toLowerCase();return f?r.filter(C=>C.name.toLowerCase().includes(f)||C.description.toLowerCase().includes(f)):r},[r,m]);(0,i.useEffect)(()=>{e?h(!1):(h(!0),A(""))},[e]);let E=f=>{o(f),h(!1)};return(0,n.jsx)("div",{style:{display:"flex",height:"100%",width:"100%"},children:(0,n.jsxs)("div",{style:{flex:1,position:"relative"},children:[b?(0,n.jsxs)(n.Fragment,{children:[d?(0,n.jsx)(Xe,{dsl:d,agentNameMap:u}):(0,n.jsx)("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",height:"100%"},children:(0,n.jsx)(ae,{tip:g("chatWorkspace.workflowAutomation.loadingDsl")})}),!R&&(0,n.jsx)("div",{style:{position:"absolute",top:12,left:12,zIndex:10},children:(0,n.jsx)($,{type:"default",icon:(0,n.jsx)(De,{}),onClick:()=>h(!0),style:{width:32,height:32,borderRadius:10,boxShadow:"0 2px 12px rgba(0,0,0,0.08)",border:"1px solid #f0f0f0",background:"rgba(255,255,255,0.95)",color:"#6366f1",display:"flex",alignItems:"center",justifyContent:"center"}})}),(0,n.jsxs)("div",{style:{position:"absolute",top:12,left:R?12:56,zIndex:10,display:"flex",alignItems:"center",gap:6,height:32,padding:"0 14px",background:"rgba(255,255,255,0.95)",borderRadius:10,boxShadow:"0 2px 12px rgba(0,0,0,0.08)",border:"1px solid #f0f0f0"},children:[(0,n.jsx)(ee,{size:16,color:"#6366f1"}),(0,n.jsx)(K,{strong:!0,style:{fontSize:13},children:b.name}),(0,n.jsx)(Me,{style:{color:"#6366f1",cursor:"pointer",fontSize:15},onClick:y})]}),(0,n.jsx)("div",{style:{position:"absolute",top:12,right:12,zIndex:10,display:"flex",alignItems:"center",height:32,padding:"0 14px",background:"rgba(255,255,255,0.95)",borderRadius:10,boxShadow:"0 2px 12px rgba(0,0,0,0.08)",border:"1px solid #f0f0f0"},children:(0,n.jsx)(Ae,{title:g("chatWorkspace.workflowAutomation.deleteTitle"),description:g("chatWorkspace.workflowAutomation.deleteBody"),onConfirm:()=>v(b.id),okText:g("common.delete"),cancelText:g("common.cancel"),okButtonProps:{danger:!0},children:(0,n.jsx)(Te,{style:{color:"#ff4d4f",cursor:"pointer",fontSize:15}})})}),!R&&(0,n.jsx)("div",{style:{position:"absolute",top:52,left:R?12:56,zIndex:20},children:(0,n.jsx)(Ze,{graphDef:p},b.id)})]}):(0,n.jsx)("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",height:"100%"},children:(0,n.jsx)(U,{description:g("chatWorkspace.workflowAutomation.selectWorkflow")})}),R&&(0,n.jsxs)(n.Fragment,{children:[e&&(0,n.jsx)("div",{onClick:()=>h(!1),style:{position:"absolute",inset:0,zIndex:25,background:"transparent"}}),(0,n.jsxs)(Ie,{size:"small",title:(0,n.jsx)(K,{strong:!0,style:{fontSize:15,color:"#1a1a1a"},children:g("chatWorkspace.workflowAutomation.title")}),extra:(0,n.jsx)($,{type:"text",size:"small",icon:(0,n.jsx)(le,{}),onClick:w,style:{color:"#6366f1"}}),styles:{body:{padding:"12px 16px 16px"},header:{padding:"14px 16px 10px",borderBottom:"1px solid rgba(0,0,0,0.04)"}},style:{position:"absolute",left:16,top:e?56:48,bottom:16,width:300,zIndex:30,borderRadius:16,boxShadow:"0 4px 24px rgba(0,0,0,0.12)",border:"1px solid #f0f0f0",overflow:"auto",background:"rgba(255, 255, 255, 0.92)"},children:[(0,n.jsx)("div",{style:{marginBottom:12},children:(0,n.jsx)(V,{prefix:(0,n.jsx)(Le,{style:{color:"#bbb"}}),placeholder:g("chatWorkspace.workflowAutomation.filterPlaceholder"),value:m,onChange:f=>A(f.target.value),allowClear:!0,size:"small",style:{borderRadius:10,border:"1px solid rgba(0,0,0,0.06)"}})}),z.length===0?(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:"32px 16px",color:"#bbb"},children:[(0,n.jsx)(ee,{size:28,style:{marginBottom:10,opacity:.4}}),(0,n.jsx)(K,{type:"secondary",style:{fontSize:13},children:m.trim()?g("chatWorkspace.workflowAutomation.noMatch"):g("chatWorkspace.workflowAutomation.emptyTitle")})]}):z.map(f=>{let C=e===f.id;return(0,n.jsxs)("div",{onClick:()=>E(f.id),style:{display:"flex",alignItems:"center",gap:12,padding:"13px 15px",borderRadius:12,cursor:"pointer",transition:"all 0.2s ease",background:C?"rgba(99, 102, 241, 0.07)":"rgba(255, 255, 255, 0.5)",border:C?"1px solid rgba(99, 102, 241, 0.25)":"1px solid transparent",marginBottom:6},onMouseEnter:S=>{C||(S.currentTarget.style.background="rgba(255, 255, 255, 0.92)",S.currentTarget.style.boxShadow="0 2px 8px rgba(0,0,0,0.05)",S.currentTarget.style.transform="translateY(-1px)",S.currentTarget.style.borderColor="rgba(0,0,0,0.06)")},onMouseLeave:S=>{C||(S.currentTarget.style.background="rgba(255, 255, 255, 0.5)",S.currentTarget.style.boxShadow="none",S.currentTarget.style.transform="translateY(0)",S.currentTarget.style.borderColor="transparent")},children:[(0,n.jsx)("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",width:38,height:38,borderRadius:10,background:C?"rgba(99, 102, 241, 0.12)":"rgba(0, 0, 0, 0.04)",flexShrink:0,transition:"background 0.2s ease"},children:(0,n.jsx)(ee,{size:18,color:C?"#6366f1":"#888"})}),(0,n.jsxs)("div",{style:{flex:1,minWidth:0},children:[(0,n.jsx)(K,{strong:!0,ellipsis:{tooltip:f.name},style:{fontSize:14,color:C?"#6366f1":"#1a1a1a",transition:"color 0.2s ease"},children:f.name}),f.description&&(0,n.jsx)("div",{style:{fontSize:12,color:"#999",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",marginTop:3,lineHeight:"18px"},children:f.description})]})]},f.id)})]})]})]})})}var Ct=()=>{let r=O(),{get:e,del:o}=ne(),{workspaceId:w,trainingProjects:v,loading:d}=te(),[u,y]=(0,i.useState)([]),[p,g]=(0,i.useState)(null),[b,R]=(0,i.useState)(null),[h,m]=(0,i.useState)(null),[A,z]=(0,i.useState)([]),[E,f]=(0,i.useState)(new Map),C=(0,i.useCallback)(async()=>{try{let s=await e("/api/assistants");if(s.success&&s.data?.records){let c=[],a=new Map;for(let l of s.data.records){if(l.id&&l.name){let x=typeof l.graphDefinition=="object"&&l.graphDefinition!==null?l.graphDefinition:void 0;a.set(l.id,{name:l.name,type:x?.type??"unknown"})}if(l.graphDefinition)if(typeof l.graphDefinition=="string")try{c.push(JSON.parse(l.graphDefinition))}catch{}else typeof l.graphDefinition=="object"&&c.push(l.graphDefinition)}z(c),f(a)}}catch{}},[e]),[S,we]=(0,i.useState)(!0),[re,tt]=(0,i.useState)(420),_=(0,i.useRef)(null),[nt,ot]=(0,i.useState)(!0),[he,xe]=(0,i.useState)(null),[rt,ke]=(0,i.useState)(!1),[ve,F]=(0,i.useState)(!1),[it,Ce]=(0,i.useState)(null),st=(0,i.useMemo)(()=>["create_workflow","update_workflow","validate_workflow","create_agent","update_agent","delete_agent"],[]),T=(0,i.useCallback)(async()=>{let s=await e("/api/assistants");if(s.success&&s.data?.records){let c=s.data.records.filter(a=>(et(a.graphDefinition)??void 0)?.type==="workflow").map(a=>{let l=et(a.graphDefinition)??void 0,x=typeof l?.workflowYaml=="string"?l.workflowYaml:"",B=l?.metadata,N=0;try{N=me(x).nodes.filter(W=>W.type!=="terminal").length}catch{}return{id:a.id,name:a.name,description:a.description||"",type:"workflow",stepCount:N,trainingProjectId:typeof B?.trainingProjectId=="string"?B.trainingProjectId:void 0}});y(c)}xe(null)},[e]),Y=(0,i.useCallback)(async s=>{try{let c=await e(`/api/assistants/${s}`);if(c.success&&c.data){let a=c.data.graphDefinition,l=kt(a);if(R(l),!a)m(null);else if(typeof a=="string")try{m(JSON.parse(a))}catch{m(null)}else m(typeof a=="object"?a:null)}}catch{R(null),m(null)}},[e]);(0,i.useEffect)(()=>{let s=!1;return(async()=>{try{await T(),await C()}catch(a){s||xe(a instanceof Error?a.message:r("chatWorkspace.workflowAutomation.loadFailed"))}finally{s||ot(!1)}})(),()=>{s=!0}},[T]),(0,i.useEffect)(()=>{p?Y(p):R(null)},[p,Y]);let at=(0,i.useCallback)(s=>{s.preventDefault(),_.current={startX:s.clientX,startWidth:re}},[re]);(0,i.useEffect)(()=>{let s=a=>{if(!_.current)return;let l=_.current.startX-a.clientX,x=Math.min(900,Math.max(400,_.current.startWidth+l));tt(x)},c=()=>{_.current=null};return window.addEventListener("mousemove",s),window.addEventListener("mouseup",c),()=>{window.removeEventListener("mousemove",s),window.removeEventListener("mouseup",c)}},[]);let D=(0,i.useRef)(null),Se=(0,i.useRef)({fetchWorkflows:T,fetchDSL:Y});Se.current={fetchWorkflows:T,fetchDSL:Y};let Re=(0,i.useRef)(p);Re.current=p;let lt=(0,i.useCallback)(()=>{D.current&&clearTimeout(D.current),D.current=setTimeout(()=>{D.current=null;let{fetchWorkflows:s,fetchDSL:c}=Se.current;s().catch(l=>{console.warn("Failed to refresh workflows:",l)});let a=Re.current;a&&c(a).catch(l=>{console.warn("Failed to refresh workflow DSL:",l)})},xt)},[]);(0,i.useEffect)(()=>()=>{D.current&&(clearTimeout(D.current),D.current=null)},[]);let dt=(0,i.useCallback)(s=>{g(s)},[]),We=(0,i.useCallback)((s,c,a)=>{F(!1),T().then(()=>{g(s),a&&y(l=>l.map(x=>x.id===s?{...x,trainingProjectId:a}:x)),c&&Ce({requestId:s,content:c})})},[T]),ct=(0,i.useCallback)(async s=>{await o(`/api/assistants/${s}`),p===s&&g(null),await T()},[o,T,p]),L=(0,i.useMemo)(()=>u.find(s=>s.id===p)||null,[u,p]),G=L?.trainingProjectId??v[0]?.id??null,pt=(0,i.useMemo)(()=>p&&L?{id:p,name:L.name,type:"workflow"}:null,[p,L]),gt=(0,i.useMemo)(()=>{let s=b?.nodes.filter(k=>k.type!=="terminal"&&k.ref).map(k=>k.ref).filter((k,W,M)=>M.indexOf(k)===W)??[];if(s.length===0)return h;let c=A.filter(k=>{let W=k.key;return W&&s.includes(W)});if(c.length===0)return h;let a={...h??{}},l=new Set(a.tools??[]),x=[...a.middleware??[]],B=new Set(a.subAgents??[]),N=new Set(x.map(k=>k.type).filter(Boolean));for(let k of c){let W=k;for(let M of W.tools??[])l.add(M);for(let M of W.middleware??[]){let ie=M.type;ie&&!N.has(ie)&&(x.push(M),N.add(ie))}for(let M of W.subAgents??[])B.add(M)}return a.tools=Array.from(l),a.middleware=x,a.subAgents=Array.from(B),a},[b,h,A]);return nt?(0,n.jsx)("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",height:"100%"},children:(0,n.jsx)(ae,{size:"large",tip:r("chatWorkspace.workflowAutomation.loading")})}):he?(0,n.jsx)(U,{description:he}):u.length===0?(0,n.jsxs)("div",{style:{width:"100%",height:"100%"},children:[(0,n.jsx)(be,{open:ve,onCancel:()=>F(!1),onCreated:We}),(0,n.jsx)(U,{description:r("chatWorkspace.workflowAutomation.noDefinitions"),children:(0,n.jsx)($,{type:"primary",icon:(0,n.jsx)(le,{}),onClick:()=>F(!0),children:r("chatWorkspace.workflowAutomation.createWorkflow")})})]}):(0,n.jsxs)("div",{style:{width:"100%",height:"100%"},children:[(0,n.jsx)(be,{open:ve,onCancel:()=>F(!1),onCreated:We}),(0,n.jsx)(Q,{title:L?.name,open:rt,onCancel:()=>ke(!1),footer:null,width:"85vw",centered:!0,styles:{body:{maxHeight:"calc(85vh - 120px)",overflow:"auto",padding:"12px 24px 24px"}},children:L?.description?(0,n.jsx)(Ke,{content:L.description}):(0,n.jsx)(K,{type:"secondary",children:r("chatWorkspace.workflowAutomation.noDescription")})}),(0,n.jsx)(Ye,{children:(0,n.jsxs)("div",{style:{height:"100%",width:"100%",position:"relative",overflow:"hidden"},children:[v.length===0&&!d&&(0,n.jsx)(ze,{type:"warning",showIcon:!0,style:{position:"absolute",top:48,left:"clamp(16px, 32vw, 332px)",right:16,zIndex:40,margin:0},message:r("governance.learning.noProject"),description:r("governance.learning.noProjectDescription")}),(0,n.jsx)(vt,{workflows:u,selectedId:p,onSelect:dt,onCreate:()=>F(!0),onDelete:ct,dsl:b,agentNameMap:E,onSpecClick:()=>ke(!0),environmentConfig:gt}),!S&&p&&G&&(0,n.jsx)("div",{style:{position:"absolute",right:0,top:"50%",transform:"translateY(-50%)",zIndex:20},children:(0,n.jsx)("div",{onClick:()=>we(!0),style:{writingMode:"vertical-rl",textOrientation:"mixed",padding:"16px 8px",background:"#6366f1",color:"#fff",borderRadius:"8px 0 0 8px",cursor:"pointer",fontSize:12,fontWeight:500,userSelect:"none"},children:r("chatWorkspace.workflowAutomation.copilot")})}),S&&p&&G&&!d&&(0,n.jsxs)("div",{style:{position:"absolute",right:16,top:48,bottom:12,zIndex:15,width:re,borderRadius:16,overflow:"hidden",boxShadow:"0 4px 24px rgba(0,0,0,0.12)"},children:[(0,n.jsx)("div",{onMouseDown:at,style:{position:"absolute",left:0,top:0,bottom:0,width:6,cursor:"ew-resize",zIndex:2,background:"transparent"}}),(0,n.jsx)(Ge,{defaultWorkspaceId:w??void 0,defaultProjectId:G??void 0,children:(0,n.jsx)(Ue,{workflowContext:pt,onClose:()=>we(!1),onToolCompleted:s=>{st.includes(s)&&lt()},initialMessageRequest:it,onInitialMessageSubmitted:s=>Ce(c=>c?.requestId===s?null:c)})},`${w??"default"}:${G??"default"}`)]})]})})]})},Zt=Ct;export{Ct as WorkflowAutomationView,Zt as default};
@@ -1,2 +1,2 @@
1
- import{A as T,B as C,a as S,s as P}from"./embed-page-chunk-MVT6CPWE.js";import{o as I}from"./embed-page-chunk-5QZRLAW2.js";import{l as d}from"./embed-page-chunk-3FNSGFP2.js";import{a as p}from"./embed-page-chunk-QV7QAJ4N.js";import{z as x}from"./embed-page-chunk-L7GPZSYD.js";import{W as y,_ as v,bb as b}from"./embed-page-chunk-BUFWD6SE.js";import{a as L}from"./embed-page-chunk-R5QL57JJ.js";import{f as s}from"./embed-page-chunk-QBTAJ2YI.js";var u=s(L());var t=s(p()),{Text:c}=b,H=({workflowContext:e,onClose:l,onToolCompleted:g,initialMessageRequest:n,onInitialMessageSubmitted:m,attemptedInitialMessageRequestIdsRef:o,rawInitialMessage:a,showHeader:A=!0})=>{let r=d(),M=I("agent-architect"),f=e?.id?`${M.tenantId}:${e.id}`:null,R=(0,u.useMemo)(()=>{if(e?.id&&e?.name)return e.type==="agent"?`[Context: You're viewing agent "${e.name}" (assistant: ${e.id})]`:`[Context: You're viewing workflow "${e.name}" (agent: ${e.id})]`},[e]),$=(0,u.useMemo)(()=>{if(!n||!e?.id)return null;if(a)return n;let h=[`Purpose: ${n.content.trim()}`,"",`Workflow "${e.id}" has been created with an empty YAML DSL. Based on the purpose above, load the 'create-workflow' skill, design the workflow using the YAML needs+if DSL, and update it via update_workflow. Make sure to include a descriptive name.`].join(`
1
+ import{A as T,B as C,a as S,s as P}from"./embed-page-chunk-KWZEITYQ.js";import{o as I}from"./embed-page-chunk-5QZRLAW2.js";import{l as d}from"./embed-page-chunk-3FNSGFP2.js";import{a as p}from"./embed-page-chunk-QV7QAJ4N.js";import{z as x}from"./embed-page-chunk-L7GPZSYD.js";import{W as y,_ as v,bb as b}from"./embed-page-chunk-BUFWD6SE.js";import{a as L}from"./embed-page-chunk-R5QL57JJ.js";import{f as s}from"./embed-page-chunk-QBTAJ2YI.js";var u=s(L());var t=s(p()),{Text:c}=b,H=({workflowContext:e,onClose:l,onToolCompleted:g,initialMessageRequest:n,onInitialMessageSubmitted:m,attemptedInitialMessageRequestIdsRef:o,rawInitialMessage:a,showHeader:A=!0})=>{let r=d(),M=I("agent-architect"),f=e?.id?`${M.tenantId}:${e.id}`:null,R=(0,u.useMemo)(()=>{if(e?.id&&e?.name)return e.type==="agent"?`[Context: You're viewing agent "${e.name}" (assistant: ${e.id})]`:`[Context: You're viewing workflow "${e.name}" (agent: ${e.id})]`},[e]),$=(0,u.useMemo)(()=>{if(!n||!e?.id)return null;if(a)return n;let h=[`Purpose: ${n.content.trim()}`,"",`Workflow "${e.id}" has been created with an empty YAML DSL. Based on the purpose above, load the 'create-workflow' skill, design the workflow using the YAML needs+if DSL, and update it via update_workflow. Make sure to include a descriptive name.`].join(`
2
2
  `);return{...n,content:h}},[n?.requestId,n?.content,e?.id,a]);return(0,t.jsxs)("div",{style:{height:"100%",display:"flex",flexDirection:"column",borderLeft:"1px solid #f0f0f0",background:"rgba(255, 255, 255, 0.92)"},children:[A&&(0,t.jsxs)("div",{style:{padding:"12px 12px",borderBottom:"1px solid #f0f0f0",display:"flex",justifyContent:"space-between",alignItems:"flex-start"},children:[(0,t.jsxs)("div",{children:[(0,t.jsx)(c,{strong:!0,children:r("chat.copilot.agentBuilder")}),e&&(0,t.jsx)("div",{children:(0,t.jsx)(c,{type:"secondary",style:{fontSize:12},children:r("chat.copilot.viewing",{name:e.name})})})]}),l&&(0,t.jsx)(v,{type:"text",size:"small","aria-label":r("chat.copilot.close"),icon:(0,t.jsx)(x,{}),onClick:l})]}),f?(0,t.jsxs)(S,{threadId:f,assistantId:"agent-architect",options:{streaming:!0},onToolCompleted:g,children:[(0,t.jsx)(T,{request:$,onSubmitted:m,attemptedRequestIdsRef:o}),(0,t.jsx)(C,{showHeader:!1,showEmptyState:!1,showDatabaseSlot:!1,showSkillSlot:!1,showAgentSlot:!1,showMetricsDataSourceSlot:!1,systemContext:R})]}):(0,t.jsxs)("div",{style:{flex:1,minHeight:0,display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center",height:"100%",textAlign:"center",gap:4,padding:"0 8px"},children:[(0,t.jsx)(c,{strong:!0,children:r("chat.copilot.agentBuilder")}),(0,t.jsx)(c,{type:"secondary",children:r("chat.copilot.selectWorkflow")})]})]})};var i=s(p()),_=({project:e,value:l,onChange:g,selectable:n=!0,loading:m})=>{let o=d();return e?(0,i.jsxs)("div",{"data-testid":"training-context-card",style:{display:"flex",alignItems:"center",gap:8},children:[(0,i.jsx)("span",{style:{fontSize:12,color:"rgba(0,0,0,0.45)",flexShrink:0},children:o("governance.learning.projectLabel")}),n?(0,i.jsx)(P,{kinds:["training"],value:l??e.id,onChange:a=>{a&&g?.(a)},style:{minWidth:0}}):(0,i.jsx)("span",{style:{fontSize:12,fontWeight:500},children:e.name})]}):m?null:(0,i.jsx)(y,{type:"warning",showIcon:!0,message:o("governance.learning.noProject"),description:o("governance.learning.noProjectDescription")})};export{_ as a,H as b};
@@ -1,4 +1,4 @@
1
- import{a as gr,b as Pn}from"./embed-page-chunk-5HWN5HSA.js";import{b as qi,c as $i}from"./embed-page-chunk-DI5UAV2I.js";import{a as Io}from"./embed-page-chunk-4BPMGDDV.js";import{c as xo,d as To}from"./embed-page-chunk-HQLSH3FC.js";import{b as st,c as Li,d as ko,e as xt,f as wo,g as Mi,h as Cn,i as Sn,j as Ni,l as Oi,m as Fi}from"./embed-page-chunk-5AWYMAAX.js";import{a as pn}from"./embed-page-chunk-D7YTSCUO.js";import{a as Ki,b as Hi}from"./embed-page-chunk-BBIV2YA2.js";import{J as _i,K as Ro,L as Co,M as So,N as Wi,O as Ao,P as zi,Q as Bi,R as Po,S as ji,T as An,V as pr,W as Gi,b as Ci,d as mo,e as Si,f as yo,g as vo,j as Rn,o as In,p as ho,q as Ai,t as Pi,u as Ei,v as Di,w as bo}from"./embed-page-chunk-MVT6CPWE.js";import{g as Ii,i as Lt}from"./embed-page-chunk-54M4265G.js";import{a as et}from"./embed-page-chunk-3XPHW2C7.js";import{b as Yr,j as Xr,l as Jr,o as yt,t as co}from"./embed-page-chunk-5QZRLAW2.js";import{Da as wi,H as ci,J as ui,La as xi,N as pi,Q as gi,S as fi,Sa as fo,Ta as Ti,U as go,Ua as Ri,ba as mi,g as si,m as li,n as Gn,ra as yi,sa as vi,ta as hi,va as bi,wa as ki,z as di}from"./embed-page-chunk-F7ZUYG42.js";import{l as _}from"./embed-page-chunk-3FNSGFP2.js";import{a as z}from"./embed-page-chunk-QV7QAJ4N.js";import{B as ni,G as uo,Ja as Dt,Oa as ri,P as Tn,Q as oi,Qa as ii,Ra as cr,Sa as ur,bb as ai,ea as dr,i as ei,s as ti,sa as po,z as jn}from"./embed-page-chunk-L7GPZSYD.js";import{Da as fe,Ia as _e,Ja as wt,Ma as Be,W as Pt,Ya as lo,Za as He,_ as Z,_a as Vr,aa as Ve,ba as Gt,bb as Ge,db as Qr,fa as at,ha as Jt,ja as sr,ka as lr,pa as Hr,sa as un,va as Ur,ya as Zr,za as Et}from"./embed-page-chunk-BUFWD6SE.js";import{a as Pe}from"./embed-page-chunk-R5QL57JJ.js";import{f as I}from"./embed-page-chunk-QBTAJ2YI.js";var Hs={react:{label:"capability",color:"blue"},capability:{label:"capability",color:"blue"},deep_agent:{label:"orchestrator",color:"orange"},orchestrator:{label:"orchestrator",color:"orange"},processing:{label:"workflow",color:"purple"},workflow:{label:"workflow",color:"purple"},a2a_remote:{label:"remote",color:"cyan"},remote:{label:"remote",color:"cyan"}};function En(e){return Hs[e]??{label:"capability",color:"blue"}}var Us={enabled:"green",draft:"orange",disabled:"default"};function Zi(e){return Us[e]??"default"}var Ui={blue:"#3b82f6",orange:"#f59e0b",green:"#22c55e",purple:"#a855f7",cyan:"#06b6d4"};function Kn(e){return Ui[e]??Ui.cyan}function Yd(e){let t={enabled:"#22c55e",draft:"#f59e0b",disabled:"#d9d9d9"};return t[e]??t.disabled}function Dn(e){return typeof e.graphDefinition=="object"&&e.graphDefinition!==null?e.graphDefinition:{}}function mr(e){return((Dn(e).metadata??{}).tags??"").split(",").map(r=>r.trim()).filter(Boolean)}function yr(e){let o=(Dn(e).metadata??{}).version;return o?o.startsWith("v")?o:`v${o}`:"v1"}function vr(e){let o=(Dn(e).metadata??{}).status??"enabled";return o==="draft"||o==="disabled"?o:"enabled"}function fr(e){let n=Dn(e).subAgents??[],o=Array.isArray(n)?n.filter(Boolean):[];return Array.from(new Set(o))}function Xd(e){return e.map(t=>{let n=Dn(t),o=String(n.type??"react");return{id:t.id,name:t.name,description:t.description,type:En(o).label,tags:mr(t),version:yr(t),status:vr(t),subAgents:fr(t)}})}function Jd(e){let t=new Set(e.map(r=>r.id)),n=e.map(r=>({id:r.id,label:r.name,type:En(String(Dn(r).type??"react")).label,subAgentCount:fr(r).length})),o=[];for(let r of e)for(let i of fr(r))t.has(i)&&o.push({source:r.id,target:i});return{nodes:n,edges:o}}var Ee=I(Pe());var te=I(Pe());var k=I(z()),{TextArea:Zs}=_e,{Text:Tt}=Ge,Vi=["data","execution","workflow","assistant"],Qi={data:"chatConfig.agentPanel.category.data",execution:"chatConfig.agentPanel.category.execution",workflow:"chatConfig.agentPanel.category.workflow",assistant:"chatConfig.agentPanel.category.assistant",other:"chatConfig.agentPanel.category.other"},Vs={react:"chatConfig.agentPanel.typeDesc.react",deep_agent:"chatConfig.agentPanel.typeDesc.deepAgent"},qn=(e,t)=>{if(Array.isArray(e)){let n=e.map(o=>qn(o));return(t==="tools"||t==="subAgents")&&n.every(o=>typeof o=="string")?[...n].sort():n}return e!==null&&typeof e=="object"?Object.fromEntries(Object.entries(e).sort(([n],[o])=>n.localeCompare(o)).map(([n,o])=>[n,qn(o,n)])):e},Yi=e=>{if(typeof e!="string")return qn(e??null);try{return qn(JSON.parse(e))}catch{return e}},Xi=e=>JSON.stringify(qn({...e,tools:[...e.tools].sort(),subAgents:[...e.subAgents].sort()})),Qs=Ii(({token:e,css:t})=>({modalBody:t`
1
+ import{a as gr,b as Pn}from"./embed-page-chunk-62CAXPZK.js";import{b as qi,c as $i}from"./embed-page-chunk-NGO5C5RH.js";import{a as Io}from"./embed-page-chunk-NR4M6XSO.js";import{c as xo,d as To}from"./embed-page-chunk-HQLSH3FC.js";import{b as st,c as Li,d as ko,e as xt,f as wo,g as Mi,h as Cn,i as Sn,j as Ni,l as Oi,m as Fi}from"./embed-page-chunk-5AWYMAAX.js";import{a as pn}from"./embed-page-chunk-D7YTSCUO.js";import{a as Ki,b as Hi}from"./embed-page-chunk-KKNZYZVB.js";import{J as _i,K as Ro,L as Co,M as So,N as Wi,O as Ao,P as zi,Q as Bi,R as Po,S as ji,T as An,V as pr,W as Gi,b as Ci,d as mo,e as Si,f as yo,g as vo,j as Rn,o as In,p as ho,q as Ai,t as Pi,u as Ei,v as Di,w as bo}from"./embed-page-chunk-KWZEITYQ.js";import{g as Ii,i as Lt}from"./embed-page-chunk-54M4265G.js";import{a as et}from"./embed-page-chunk-3XPHW2C7.js";import{b as Yr,j as Xr,l as Jr,o as yt,t as co}from"./embed-page-chunk-5QZRLAW2.js";import{Da as wi,H as ci,J as ui,La as xi,N as pi,Q as gi,S as fi,Sa as fo,Ta as Ti,U as go,Ua as Ri,ba as mi,g as si,m as li,n as Gn,ra as yi,sa as vi,ta as hi,va as bi,wa as ki,z as di}from"./embed-page-chunk-F7ZUYG42.js";import{l as _}from"./embed-page-chunk-3FNSGFP2.js";import{a as z}from"./embed-page-chunk-QV7QAJ4N.js";import{B as ni,G as uo,Ja as Dt,Oa as ri,P as Tn,Q as oi,Qa as ii,Ra as cr,Sa as ur,bb as ai,ea as dr,i as ei,s as ti,sa as po,z as jn}from"./embed-page-chunk-L7GPZSYD.js";import{Da as fe,Ia as _e,Ja as wt,Ma as Be,W as Pt,Ya as lo,Za as He,_ as Z,_a as Vr,aa as Ve,ba as Gt,bb as Ge,db as Qr,fa as at,ha as Jt,ja as sr,ka as lr,pa as Hr,sa as un,va as Ur,ya as Zr,za as Et}from"./embed-page-chunk-BUFWD6SE.js";import{a as Pe}from"./embed-page-chunk-R5QL57JJ.js";import{f as I}from"./embed-page-chunk-QBTAJ2YI.js";var Hs={react:{label:"capability",color:"blue"},capability:{label:"capability",color:"blue"},deep_agent:{label:"orchestrator",color:"orange"},orchestrator:{label:"orchestrator",color:"orange"},processing:{label:"workflow",color:"purple"},workflow:{label:"workflow",color:"purple"},a2a_remote:{label:"remote",color:"cyan"},remote:{label:"remote",color:"cyan"}};function En(e){return Hs[e]??{label:"capability",color:"blue"}}var Us={enabled:"green",draft:"orange",disabled:"default"};function Zi(e){return Us[e]??"default"}var Ui={blue:"#3b82f6",orange:"#f59e0b",green:"#22c55e",purple:"#a855f7",cyan:"#06b6d4"};function Kn(e){return Ui[e]??Ui.cyan}function Yd(e){let t={enabled:"#22c55e",draft:"#f59e0b",disabled:"#d9d9d9"};return t[e]??t.disabled}function Dn(e){return typeof e.graphDefinition=="object"&&e.graphDefinition!==null?e.graphDefinition:{}}function mr(e){return((Dn(e).metadata??{}).tags??"").split(",").map(r=>r.trim()).filter(Boolean)}function yr(e){let o=(Dn(e).metadata??{}).version;return o?o.startsWith("v")?o:`v${o}`:"v1"}function vr(e){let o=(Dn(e).metadata??{}).status??"enabled";return o==="draft"||o==="disabled"?o:"enabled"}function fr(e){let n=Dn(e).subAgents??[],o=Array.isArray(n)?n.filter(Boolean):[];return Array.from(new Set(o))}function Xd(e){return e.map(t=>{let n=Dn(t),o=String(n.type??"react");return{id:t.id,name:t.name,description:t.description,type:En(o).label,tags:mr(t),version:yr(t),status:vr(t),subAgents:fr(t)}})}function Jd(e){let t=new Set(e.map(r=>r.id)),n=e.map(r=>({id:r.id,label:r.name,type:En(String(Dn(r).type??"react")).label,subAgentCount:fr(r).length})),o=[];for(let r of e)for(let i of fr(r))t.has(i)&&o.push({source:r.id,target:i});return{nodes:n,edges:o}}var Ee=I(Pe());var te=I(Pe());var k=I(z()),{TextArea:Zs}=_e,{Text:Tt}=Ge,Vi=["data","execution","workflow","assistant"],Qi={data:"chatConfig.agentPanel.category.data",execution:"chatConfig.agentPanel.category.execution",workflow:"chatConfig.agentPanel.category.workflow",assistant:"chatConfig.agentPanel.category.assistant",other:"chatConfig.agentPanel.category.other"},Vs={react:"chatConfig.agentPanel.typeDesc.react",deep_agent:"chatConfig.agentPanel.typeDesc.deepAgent"},qn=(e,t)=>{if(Array.isArray(e)){let n=e.map(o=>qn(o));return(t==="tools"||t==="subAgents")&&n.every(o=>typeof o=="string")?[...n].sort():n}return e!==null&&typeof e=="object"?Object.fromEntries(Object.entries(e).sort(([n],[o])=>n.localeCompare(o)).map(([n,o])=>[n,qn(o,n)])):e},Yi=e=>{if(typeof e!="string")return qn(e??null);try{return qn(JSON.parse(e))}catch{return e}},Xi=e=>JSON.stringify(qn({...e,tools:[...e.tools].sort(),subAgents:[...e.subAgents].sort()})),Qs=Ii(({token:e,css:t})=>({modalBody:t`
2
2
  padding: 0;
3
3
  height: 92vh;
4
4
  width: 100%;