@axiom-lattice/gateway 4.7.0 → 4.8.0

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 (54) hide show
  1. package/dist/{OrphanRecoveryRuntime-MQDEJX3M.mjs → OrphanRecoveryRuntime-BEFILJMU.mjs} +2 -2
  2. package/dist/{chunk-2POW27EI.mjs → chunk-7CG57LEF.mjs} +2 -2
  3. package/dist/{chunk-WKNZ7GBC.mjs → chunk-EXPERMZR.mjs} +1 -1
  4. package/dist/chunk-EXPERMZR.mjs.map +1 -0
  5. package/dist/{chunk-52SUWMOX.mjs → chunk-JUA3VJE7.mjs} +3 -2
  6. package/dist/chunk-JUA3VJE7.mjs.map +1 -0
  7. package/dist/{chunk-TJAUXMYJ.mjs → chunk-URXZPI2F.mjs} +8 -1
  8. package/dist/chunk-URXZPI2F.mjs.map +1 -0
  9. package/dist/{chunk-KDQKTU3N.mjs → chunk-ZBTG3T7K.mjs} +44 -8
  10. package/dist/chunk-ZBTG3T7K.mjs.map +1 -0
  11. package/dist/embed/{embed-page-AgentDetailSideApp-2C2ZR62Q.js → embed-page-AgentDetailSideApp-NTLAFO5C.js} +1 -1
  12. package/dist/embed/{embed-page-AgentGovernanceWorkbench-GG4ONSTS.js → embed-page-AgentGovernanceWorkbench-QPVBOMLH.js} +1 -1
  13. package/dist/embed/{embed-page-MessageGraph-WMYTVUUC.js → embed-page-MessageGraph-JAJGMYKH.js} +1 -1
  14. package/dist/embed/{embed-page-ReactChart-7XCMDMH6.js → embed-page-ReactChart-WUG6TEAZ.js} +1 -1
  15. package/dist/embed/{embed-page-SkillFlow-XMMHEHQL.js → embed-page-SkillFlow-TSBZ4V2P.js} +1 -1
  16. package/dist/embed/{embed-page-TasksSideApp-4ZJ4Q4CL.js → embed-page-TasksSideApp-TJI22YGD.js} +1 -1
  17. package/dist/embed/{embed-page-TeamWorkspace-H5OOEN3K.js → embed-page-TeamWorkspace-OJJLN5VI.js} +1 -1
  18. package/dist/embed/{embed-page-TopologyRuntimeView-QMXWERVC.js → embed-page-TopologyRuntimeView-ZFU4N6TV.js} +1 -1
  19. package/dist/embed/{embed-page-WorkflowAutomationView-L2OEGCA5.js → embed-page-WorkflowAutomationView-ALXV7VQQ.js} +1 -1
  20. package/dist/embed/{embed-page-chunk-CZE4IEB3.js → embed-page-chunk-DZQBVJ7Z.js} +1 -1
  21. package/dist/embed/{embed-page-chunk-N2ISCAS7.js → embed-page-chunk-IPIJ2SG6.js} +1 -1
  22. package/dist/embed/{embed-page-chunk-SUMYB6ZA.js → embed-page-chunk-N22EGQAJ.js} +1 -1
  23. package/dist/embed/{embed-page-chunk-OHDEKFTU.js → embed-page-chunk-O72XBKQH.js} +2 -2
  24. package/dist/embed/{embed-page-chunk-XIXSRYJY.js → embed-page-chunk-QMVIL4BJ.js} +190 -185
  25. package/dist/embed/{embed-page-chunk-2G54EIW2.js → embed-page-chunk-UT3WYBZH.js} +1 -1
  26. package/dist/embed/embed-page-chunk-YPNSOZYW.js +8 -0
  27. package/dist/embed/embed-page.js +1 -1
  28. package/dist/index.d.mts +146 -17
  29. package/dist/index.d.ts +146 -17
  30. package/dist/index.js +1190 -328
  31. package/dist/index.js.map +1 -1
  32. package/dist/index.mjs +649 -97
  33. package/dist/index.mjs.map +1 -1
  34. package/dist/{open-STFMNRO5.mjs → open-UVKMONVE.mjs} +5 -4
  35. package/dist/open-UVKMONVE.mjs.map +1 -0
  36. package/dist/{open-files-NPNQQ6TY.mjs → open-files-X3HXVEEM.mjs} +4 -4
  37. package/dist/{open-session-IHDGAXL3.mjs → open-session-2Y7XJJW2.mjs} +3 -3
  38. package/dist/{resources-DXPXAXEZ.mjs → resources-2L3KSUUU.mjs} +2 -2
  39. package/dist/sandboxOpenCredentialProvider-USIU7Z7H.mjs +275 -0
  40. package/dist/sandboxOpenCredentialProvider-USIU7Z7H.mjs.map +1 -0
  41. package/dist/{sandboxProvider-I3P66VXT.mjs → sandboxProvider-DUYWHYJN.mjs} +2 -2
  42. package/package.json +14 -8
  43. package/dist/chunk-52SUWMOX.mjs.map +0 -1
  44. package/dist/chunk-KDQKTU3N.mjs.map +0 -1
  45. package/dist/chunk-TJAUXMYJ.mjs.map +0 -1
  46. package/dist/chunk-WKNZ7GBC.mjs.map +0 -1
  47. package/dist/embed/embed-page-chunk-HEMNMC4X.js +0 -7
  48. package/dist/open-STFMNRO5.mjs.map +0 -1
  49. /package/dist/{OrphanRecoveryRuntime-MQDEJX3M.mjs.map → OrphanRecoveryRuntime-BEFILJMU.mjs.map} +0 -0
  50. /package/dist/{chunk-2POW27EI.mjs.map → chunk-7CG57LEF.mjs.map} +0 -0
  51. /package/dist/{open-files-NPNQQ6TY.mjs.map → open-files-X3HXVEEM.mjs.map} +0 -0
  52. /package/dist/{open-session-IHDGAXL3.mjs.map → open-session-2Y7XJJW2.mjs.map} +0 -0
  53. /package/dist/{resources-DXPXAXEZ.mjs.map → resources-2L3KSUUU.mjs.map} +0 -0
  54. /package/dist/{sandboxProvider-I3P66VXT.mjs.map → sandboxProvider-DUYWHYJN.mjs.map} +0 -0
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  createOrphanRecoveryRuntime
3
- } from "./chunk-KDQKTU3N.mjs";
3
+ } from "./chunk-ZBTG3T7K.mjs";
4
4
  import "./chunk-NFEGQTCC.mjs";
5
5
  export {
6
6
  createOrphanRecoveryRuntime
7
7
  };
8
- //# sourceMappingURL=OrphanRecoveryRuntime-MQDEJX3M.mjs.map
8
+ //# sourceMappingURL=OrphanRecoveryRuntime-BEFILJMU.mjs.map
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  init_openToken,
3
3
  signOpenToken
4
- } from "./chunk-WKNZ7GBC.mjs";
4
+ } from "./chunk-EXPERMZR.mjs";
5
5
 
6
6
  // src/services/open/previewToken.ts
7
7
  init_openToken();
@@ -24,4 +24,4 @@ export {
24
24
  BROWSER_GRANTS,
25
25
  buildPreviewTokenScript
26
26
  };
27
- //# sourceMappingURL=chunk-2POW27EI.mjs.map
27
+ //# sourceMappingURL=chunk-7CG57LEF.mjs.map
@@ -53,4 +53,4 @@ export {
53
53
  openToken_exports,
54
54
  init_openToken
55
55
  };
56
- //# sourceMappingURL=chunk-WKNZ7GBC.mjs.map
56
+ //# sourceMappingURL=chunk-EXPERMZR.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/services/open/openToken.ts"],"sourcesContent":["/**\n * Open-surface stateless bearer tokens (sandbox / browser tokens).\n *\n * Reuses the HMAC-SHA256 scheme from createConsoleSessionToken\n * (base64url payload + signature), with a dedicated secret so a leaked\n * console session does not yield open tokens.\n */\n\nimport { randomBytes, createHmac, timingSafeEqual } from \"crypto\";\n\nexport interface SandboxTokenPayload {\n kind: \"sandbox_token\";\n tenantId: string;\n workspaceId: string;\n projectId: string;\n sandboxName: string;\n /** Current orchestration depth; nested mints pass depth+1. */\n depth?: number;\n grants: unknown;\n exp: number;\n}\n\nexport interface BrowserTokenPayload {\n kind: \"browser_token\";\n tenantId: string;\n projectId: string;\n workspaceId?: string;\n shareId?: string;\n /** Internal-preview variant (viewfile-injected, no share). */\n preview?: boolean;\n grants: unknown;\n exp: number;\n}\n\nexport type OpenTokenPayload = SandboxTokenPayload | BrowserTokenPayload;\n\nfunction secret(): string {\n return (\n process.env.OPEN_TOKEN_SECRET ||\n process.env.AUTH_TOKEN_SECRET ||\n \"open-token-dev-secret-fallback\"\n );\n}\n\n/** Sign an open-token payload (15-min TTL default). */\nexport function signOpenToken(\n payload:\n | (Omit<SandboxTokenPayload, \"exp\"> & { exp?: number })\n | (Omit<BrowserTokenPayload, \"exp\"> & { exp?: number }),\n): string {\n const data = { ...payload, exp: payload.exp ?? Date.now() + 15 * 60 * 1000 };\n const encoded = Buffer.from(JSON.stringify(data)).toString(\"base64url\");\n const sig = createHmac(\"sha256\", secret()).update(encoded).digest(\"base64url\");\n return `${encoded}.${sig}`;\n}\n\n/** Verify a signed open bearer token; null if missing, expired, or tampered. */\nexport function verifyOpenToken(bearer: string | undefined): OpenTokenPayload | null {\n if (!bearer) return null;\n const parts = bearer.split(\".\");\n if (parts.length !== 2) return null;\n const [encoded, sigStr] = parts;\n if (!/^[A-Za-z0-9_-]{43}$/.test(sigStr)) return null;\n try {\n const actual = Buffer.from(sigStr, \"base64url\");\n if (actual.toString(\"base64url\") !== sigStr) return null;\n const expected = createHmac(\"sha256\", secret()).update(encoded).digest();\n if (actual.length !== expected.length || !timingSafeEqual(actual, expected)) return null;\n const payload: unknown = JSON.parse(Buffer.from(encoded, \"base64url\").toString(\"utf8\"));\n if (typeof payload !== \"object\" || payload === null) return null;\n const p = payload as Record<string, unknown>;\n if (\n typeof p.exp !== \"number\" ||\n p.exp < Date.now() ||\n (p.kind !== \"sandbox_token\" && p.kind !== \"browser_token\") ||\n typeof p.tenantId !== \"string\" ||\n typeof p.projectId !== \"string\" ||\n typeof p.grants !== \"object\"\n ) {\n return null;\n }\n return p as unknown as OpenTokenPayload;\n } catch {\n return null;\n }\n}"],"mappings":";;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAQA,SAAsB,YAAY,uBAAuB;AA4BzD,SAAS,SAAiB;AACxB,SACE,QAAQ,IAAI,qBACZ,QAAQ,IAAI,qBACZ;AAEJ;AAGO,SAAS,cACd,SAGQ;AACR,QAAM,OAAO,EAAE,GAAG,SAAS,KAAK,QAAQ,OAAO,KAAK,IAAI,IAAI,KAAK,KAAK,IAAK;AAC3E,QAAM,UAAU,OAAO,KAAK,KAAK,UAAU,IAAI,CAAC,EAAE,SAAS,WAAW;AACtE,QAAM,MAAM,WAAW,UAAU,OAAO,CAAC,EAAE,OAAO,OAAO,EAAE,OAAO,WAAW;AAC7E,SAAO,GAAG,OAAO,IAAI,GAAG;AAC1B;AAGO,SAAS,gBAAgB,QAAqD;AACnF,MAAI,CAAC,OAAQ,QAAO;AACpB,QAAM,QAAQ,OAAO,MAAM,GAAG;AAC9B,MAAI,MAAM,WAAW,EAAG,QAAO;AAC/B,QAAM,CAAC,SAAS,MAAM,IAAI;AAC1B,MAAI,CAAC,sBAAsB,KAAK,MAAM,EAAG,QAAO;AAChD,MAAI;AACF,UAAM,SAAS,OAAO,KAAK,QAAQ,WAAW;AAC9C,QAAI,OAAO,SAAS,WAAW,MAAM,OAAQ,QAAO;AACpD,UAAM,WAAW,WAAW,UAAU,OAAO,CAAC,EAAE,OAAO,OAAO,EAAE,OAAO;AACvE,QAAI,OAAO,WAAW,SAAS,UAAU,CAAC,gBAAgB,QAAQ,QAAQ,EAAG,QAAO;AACpF,UAAM,UAAmB,KAAK,MAAM,OAAO,KAAK,SAAS,WAAW,EAAE,SAAS,MAAM,CAAC;AACtF,QAAI,OAAO,YAAY,YAAY,YAAY,KAAM,QAAO;AAC5D,UAAM,IAAI;AACV,QACE,OAAO,EAAE,QAAQ,YACjB,EAAE,MAAM,KAAK,IAAI,KAChB,EAAE,SAAS,mBAAmB,EAAE,SAAS,mBAC1C,OAAO,EAAE,aAAa,YACtB,OAAO,EAAE,cAAc,YACvB,OAAO,EAAE,WAAW,UACpB;AACA,aAAO;AAAA,IACT;AACA,WAAO;AAAA,EACT,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AArFA;AAAA;AAAA;AAAA;AAAA;","names":[]}
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  init_openToken,
3
3
  verifyOpenToken
4
- } from "./chunk-WKNZ7GBC.mjs";
4
+ } from "./chunk-EXPERMZR.mjs";
5
5
 
6
6
  // src/services/open/openCredentialService.ts
7
7
  init_openToken();
@@ -45,6 +45,7 @@ var OpenCredentialService = class {
45
45
  projectId: token.projectId,
46
46
  workspaceId: token.workspaceId,
47
47
  sandboxName: token.sandboxName,
48
+ depth: token.depth,
48
49
  grants: token.grants
49
50
  };
50
51
  }
@@ -118,4 +119,4 @@ export {
118
119
  OpenCredentialService,
119
120
  OpenAuditService
120
121
  };
121
- //# sourceMappingURL=chunk-52SUWMOX.mjs.map
122
+ //# sourceMappingURL=chunk-JUA3VJE7.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/services/open/openCredentialService.ts","../src/services/open/openAuthService.ts","../src/services/open/openAuditService.ts"],"sourcesContent":["/**\n * Unified Open credential resolution: tries stateless tokens first, then the\n * unified API key store. Produces a single OpenCredential shape consumed by\n * the /open/mcp route and provider executors.\n */\n\nimport type {\n A2AApiKeyStore,\n OpenGrant,\n ProjectStore,\n} from \"@axiom-lattice/protocols\";\nimport { effectiveGrants } from \"@axiom-lattice/protocols\";\nimport { verifyOpenToken } from \"./openToken\";\nimport { OpenAuthService, type OpenRequestContext } from \"./openAuthService\";\n\nexport interface OpenCredential {\n credentialId: string;\n kind: \"api_key\" | \"sandbox_token\" | \"browser_token\";\n tenantId: string;\n projectId: string;\n workspaceId?: string;\n /** Only set for sandbox tokens — the self-binding target. */\n sandboxName?: string;\n /** Only set for sandbox tokens — current orchestration depth (0 for non-Open). */\n depth?: number;\n grants: OpenGrant[];\n}\n\nexport class OpenCredentialService {\n private readonly auth: OpenAuthService;\n\n constructor(\n keyStore: A2AApiKeyStore,\n private readonly projectStore?: ProjectStore,\n ) {\n this.auth = new OpenAuthService(keyStore);\n }\n\n async resolve(bearer: string | undefined): Promise<OpenCredential | null> {\n if (!bearer) return null;\n\n // Stateless tokens first (no store hit, self-contained).\n const token = verifyOpenToken(bearer);\n if (token) {\n if (token.kind === \"sandbox_token\") {\n return {\n credentialId: `sandbox:${token.sandboxName}`,\n kind: \"sandbox_token\",\n tenantId: token.tenantId,\n projectId: token.projectId,\n workspaceId: token.workspaceId,\n sandboxName: token.sandboxName,\n depth: token.depth,\n grants: token.grants as OpenGrant[],\n };\n }\n return {\n credentialId: `browser:${token.preview ? \"preview:\" : \"\"}${token.shareId ?? token.tenantId}`,\n kind: \"browser_token\",\n tenantId: token.tenantId,\n projectId: token.projectId,\n workspaceId: token.workspaceId,\n grants: token.grants as OpenGrant[],\n };\n }\n\n const ctx: OpenRequestContext | null = await this.auth.resolve(bearer);\n if (!ctx) return null;\n // API keys carry tenant+project only; backfill the addressing workspaceId\n // so sandbox resolution targets the right sandbox (authorization stays\n // tenant+project — see design §6.2).\n let workspaceId: string | undefined;\n if (this.projectStore) {\n try {\n const project = await this.projectStore.getProjectById(\n ctx.tenantId,\n ctx.projectId,\n );\n workspaceId = project?.workspaceId;\n } catch {\n // Project lookup unavailable — leave workspaceId unset.\n }\n }\n return {\n credentialId: ctx.credentialId,\n kind: \"api_key\",\n tenantId: ctx.tenantId,\n projectId: ctx.projectId,\n workspaceId,\n grants: ctx.grants,\n };\n }\n}\n\nexport { effectiveGrants };\n","/**\n * OpenAuthService — resolves an Open-door bearer credential against the\n * unified API key store and produces the request context (tenant/project\n * always from the stored record, never from the caller).\n *\n * The A2A door keeps its own A2AAuthService (assistantIds semantics, env\n * fallback); this service is store-only and grants-based.\n */\n\nimport type { A2AApiKeyStore, OpenGrant } from \"@axiom-lattice/protocols\";\nimport { effectiveGrants } from \"@axiom-lattice/protocols\";\n\nexport interface OpenRequestContext {\n credentialId: string;\n kind: \"api_key\";\n tenantId: string;\n projectId: string;\n grants: OpenGrant[];\n}\n\nexport class OpenAuthService {\n constructor(private readonly keyStore: A2AApiKeyStore) {}\n\n async resolve(bearer: string | undefined): Promise<OpenRequestContext | null> {\n if (!bearer) return null;\n const record = await this.keyStore.findByKey(bearer);\n if (!record || !record.enabled) return null;\n return {\n credentialId: record.id,\n kind: \"api_key\",\n tenantId: record.tenantId,\n projectId: record.projectId,\n grants: effectiveGrants(record),\n };\n }\n}\n","/**\n * OpenAuditService — records every Open-surface invocation (append-only).\n * Auditing must never break a request, so all failures are swallowed.\n */\n\nimport type { OpenAuditStore, OpenCredentialKind } from \"@axiom-lattice/protocols\";\n\nconst SENSITIVE_KEY = /pass(word)?|secret|token|api[-_]?key|authorization|credential/i;\nconst MAX_ARGS_CHARS = 2000;\n\n/** Recursively mask sensitive fields and truncate oversized payloads. */\nexport function redactArgs(args: unknown, depth = 0): unknown {\n if (args === null || typeof args !== \"object\") return args;\n if (depth > 6) return \"[depth-limit]\";\n if (Array.isArray(args)) return args.map((v) => redactArgs(v, depth + 1));\n const out: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(args as Record<string, unknown>)) {\n out[key] = SENSITIVE_KEY.test(key) ? \"[redacted]\" : redactArgs(value, depth + 1);\n }\n return out;\n}\n\nfunction truncate(value: unknown): unknown {\n const s = JSON.stringify(value ?? null);\n if (s.length <= MAX_ARGS_CHARS) return value ?? null;\n return `${s.slice(0, MAX_ARGS_CHARS)}...[truncated]`;\n}\n\nexport interface OpenAuditInput {\n tenantId: string;\n credentialId: string;\n credentialKind: OpenCredentialKind;\n projectId: string;\n domain: string;\n action: string;\n args: unknown;\n status: \"ok\" | \"error\";\n errorCode?: string;\n durationMs: number;\n}\n\nexport class OpenAuditService {\n constructor(private readonly store: OpenAuditStore) {}\n\n async record(input: OpenAuditInput): Promise<void> {\n try {\n await this.store.append({\n ...input,\n args: truncate(redactArgs(input.args)),\n });\n } catch {\n // Never let audit failures affect the request.\n }\n }\n}\n"],"mappings":";;;;;;AAYA;AADA,SAAS,mBAAAA,wBAAuB;;;ACDhC,SAAS,uBAAuB;AAUzB,IAAM,kBAAN,MAAsB;AAAA,EAC3B,YAA6B,UAA0B;AAA1B;AAAA,EAA2B;AAAA,EAExD,MAAM,QAAQ,QAAgE;AAC5E,QAAI,CAAC,OAAQ,QAAO;AACpB,UAAM,SAAS,MAAM,KAAK,SAAS,UAAU,MAAM;AACnD,QAAI,CAAC,UAAU,CAAC,OAAO,QAAS,QAAO;AACvC,WAAO;AAAA,MACL,cAAc,OAAO;AAAA,MACrB,MAAM;AAAA,MACN,UAAU,OAAO;AAAA,MACjB,WAAW,OAAO;AAAA,MAClB,QAAQ,gBAAgB,MAAM;AAAA,IAChC;AAAA,EACF;AACF;;;ADPO,IAAM,wBAAN,MAA4B;AAAA,EAGjC,YACE,UACiB,cACjB;AADiB;AAEjB,SAAK,OAAO,IAAI,gBAAgB,QAAQ;AAAA,EAC1C;AAAA,EAEA,MAAM,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IAAI,CAAC,MAAM,WAAW,GAAG,QAAQ,CAAC,CAAC;AACxE,QAAM,MAA+B,CAAC;AACtC,aAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,IAA+B,GAAG;AAC1E,QAAI,GAAG,IAAI,cAAc,KAAK,GAAG,IAAI,eAAe,WAAW,OAAO,QAAQ,CAAC;AAAA,EACjF;AACA,SAAO;AACT;AAEA,SAAS,SAAS,OAAyB;AACzC,QAAM,IAAI,KAAK,UAAU,SAAS,IAAI;AACtC,MAAI,EAAE,UAAU,eAAgB,QAAO,SAAS;AAChD,SAAO,GAAG,EAAE,MAAM,GAAG,cAAc,CAAC;AACtC;AAeO,IAAM,mBAAN,MAAuB;AAAA,EAC5B,YAA6B,OAAuB;AAAvB;AAAA,EAAwB;AAAA,EAErD,MAAM,OAAO,OAAsC;AACjD,QAAI;AACF,YAAM,KAAK,MAAM,OAAO;AAAA,QACtB,GAAG;AAAA,QACH,MAAM,SAAS,WAAW,MAAM,IAAI,CAAC;AAAA,MACvC,CAAC;AAAA,IACH,QAAQ;AAAA,IAER;AAAA,EACF;AACF;","names":["effectiveGrants"]}
@@ -3,6 +3,13 @@ import { z } from "zod";
3
3
  import { sandboxLatticeManager } from "@axiom-lattice/core";
4
4
  var MAX_OUTPUT_BYTES = 64e3;
5
5
  async function resolveContextSandbox(ctx) {
6
+ const sandboxName = ctx.runConfig?.sandboxName;
7
+ if (typeof sandboxName === "string" && sandboxName.length > 0) {
8
+ try {
9
+ return await sandboxLatticeManager.getSandbox(sandboxName);
10
+ } catch {
11
+ }
12
+ }
6
13
  return sandboxLatticeManager.getSandboxFromConfig({
7
14
  assistant_id: "",
8
15
  thread_id: "",
@@ -106,4 +113,4 @@ export {
106
113
  resolveContextSandbox,
107
114
  createOpenSandboxProvider
108
115
  };
109
- //# sourceMappingURL=chunk-TJAUXMYJ.mjs.map
116
+ //# sourceMappingURL=chunk-URXZPI2F.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/services/open/providers/sandboxProvider.ts"],"sourcesContent":["/**\n * Built-in sandbox provider for the Open surface: project-scoped file\n * read/list and shell execution with self-binding for sandbox tokens.\n *\n * API keys that hold sandbox-domain grants resolve the sandbox by the\n * credential's tenant + project (their project's sandbox). Sandbox tokens\n * with self-binding are resolved by the token's sandboxName field.\n */\n\nimport { z } from \"zod\";\nimport type { OpenExecutionContext, OpenExecutionResult } from \"@axiom-lattice/protocols\";\nimport { sandboxLatticeManager } from \"@axiom-lattice/core\";\nimport type { OpenProviderDeclaration } from \"../openLattice\";\n\nconst MAX_OUTPUT_BYTES = 64000;\n\n/** Resolve the credential-addressed sandbox (self-binding when the token names one). */\nexport async function resolveContextSandbox(ctx: OpenExecutionContext) {\n const sandboxName = ctx.runConfig?.sandboxName;\n if (typeof sandboxName === \"string\" && sandboxName.length > 0) {\n try {\n return await sandboxLatticeManager.getSandbox(sandboxName);\n } catch {\n // fall through to config resolution (e.g. sandbox not materialized yet)\n }\n }\n return sandboxLatticeManager.getSandboxFromConfig({\n assistant_id: \"\",\n thread_id: \"\",\n tenantId: ctx.tenantId,\n workspaceId: ctx.workspaceId ?? \"\",\n projectId: ctx.projectId,\n });\n}\n\nexport function createOpenSandboxProvider(): OpenProviderDeclaration {\n return {\n domain: \"sandbox\",\n label: \"Sandbox\",\n source: \"builtin\",\n scopeKind: \"project\",\n actions: [\n {\n name: \"files_read\",\n label: \"Read files\",\n description: \"Read a file from the project sandbox.\",\n schema: { path: z.string().min(1) },\n annotations: { readOnlyHint: true, destructiveHint: false },\n },\n {\n name: \"files_list\",\n label: \"List files\",\n description: \"List files under a directory in the project sandbox.\",\n schema: { path: z.string(), recursive: z.boolean().optional() },\n annotations: { readOnlyHint: true, destructiveHint: false },\n },\n {\n name: \"files_write\",\n label: \"Write files\",\n description: \"Write content to a file in the project sandbox.\",\n schema: { path: z.string().min(1), content: z.string() },\n annotations: { readOnlyHint: false, destructiveHint: true },\n },\n {\n name: \"shell_exec\",\n label: \"Run shell commands\",\n description:\n \"Execute a shell command in the project sandbox. Returns stdout (up to 64KB) and exit code.\",\n schema: {\n command: z.string().min(1),\n exec_dir: z.string().optional(),\n timeout: z.number().int().min(1000).optional(),\n },\n annotations: { readOnlyHint: false, destructiveHint: true },\n },\n ],\n execute: async (\n actionName: string,\n args: unknown,\n ctx: OpenExecutionContext,\n ): Promise<OpenExecutionResult> => {\n // Self-binding is inherent: the sandbox is resolved from the credential's\n // tenant/workspace/project triple (minted server-side, unforgeable), so a\n // sandbox token can only ever reach the sandbox it was issued for.\n const sandbox = await resolveContextSandbox(ctx);\n\n switch (actionName) {\n case \"files_read\": {\n const { path } = args as { path: string };\n const file = await sandbox.file.readFile(path);\n return { content: [{ type: \"text\", text: file.content }] };\n }\n case \"files_list\": {\n const { path, recursive } = args as { path: string; recursive?: boolean };\n const listing = await sandbox.file.listPath(path, { recursive });\n return {\n content: [{ type: \"text\", text: JSON.stringify(listing.files) }],\n };\n }\n case \"files_write\": {\n const { path, content } = args as { path: string; content: string };\n await sandbox.file.writeFile(path, content);\n return { content: [{ type: \"text\", text: `wrote ${path}` }] };\n }\n case \"shell_exec\": {\n const { command, exec_dir, timeout } = args as {\n command: string;\n exec_dir?: string;\n timeout?: number;\n };\n const result = await sandbox.shell.execCommand({\n command,\n exec_dir,\n timeout: timeout ?? 120_000,\n });\n const truncated =\n result.output.length > MAX_OUTPUT_BYTES\n ? result.output.slice(0, MAX_OUTPUT_BYTES) +\n `\\n...[truncated ${result.output.length - MAX_OUTPUT_BYTES} bytes]`\n : result.output;\n return {\n content: [\n {\n type: \"text\",\n text: `exit_code: ${result.exit_code}\\n${truncated}`,\n },\n ],\n };\n }\n default:\n return {\n content: [\n { type: \"text\", text: `Unknown sandbox action: ${actionName}` },\n ],\n isError: true,\n };\n }\n },\n };\n}"],"mappings":";AASA,SAAS,SAAS;AAElB,SAAS,6BAA6B;AAGtC,IAAM,mBAAmB;AAGzB,eAAsB,sBAAsB,KAA2B;AACrE,QAAM,cAAc,IAAI,WA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,YACL,SAAS;AAAA,cACP;AAAA,gBACE,MAAM;AAAA,gBACN,MAAM,cAAc,OAAO,SAAS;AAAA,EAAK,SAAS;AAAA,cACpD;AAAA,YACF;AAAA,UACF;AAAA,QACF;AAAA,QACA;AACE,iBAAO;AAAA,YACL,SAAS;AAAA,cACP,EAAE,MAAM,QAAQ,MAAM,2BAA2B,UAAU,GAAG;AAAA,YAChE;AAAA,YACA,SAAS;AAAA,UACX;AAAA,MACJ;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
@@ -57,7 +57,7 @@ async function backfillTopCallerGroup(tasks, top, deps) {
57
57
  results.push({ id: task.id, reason: "skipped:no_caller_link" });
58
58
  continue;
59
59
  }
60
- if (registry.isLive(task.id)) {
60
+ if (registry.isLive(task.id) || deps.isTaskLive && await deps.isTaskLive(task)) {
61
61
  results.push({ id: task.id, reason: "skipped:live" });
62
62
  continue;
63
63
  }
@@ -104,14 +104,15 @@ async function recoverTask(task, deps) {
104
104
  return { kind: "skipped", reason: "not_in_progress" };
105
105
  }
106
106
  const registry = deps.registry ?? taskRunRegistry;
107
- if (registry.isLive(task.id)) {
107
+ if (registry.isLive(task.id) || deps.isTaskLive && await deps.isTaskLive(task)) {
108
108
  return { kind: "skipped", reason: "live" };
109
109
  }
110
110
  const { convergedTasks } = await reconcileStaleTaskRuns({
111
111
  tasks: [task],
112
112
  actor: "system:on-demand-recovery",
113
113
  lifecycle: deps.lifecycle,
114
- ...deps.registry ? { registry: deps.registry } : {}
114
+ ...deps.registry ? { registry: deps.registry } : {},
115
+ ...deps.isTaskLive ? { isTaskLive: deps.isTaskLive } : {}
115
116
  });
116
117
  const converged = convergedTasks[0];
117
118
  if (!converged) {
@@ -127,7 +128,8 @@ async function recoverTask(task, deps) {
127
128
  const reason = await recoverTopCaller(converged, top, {
128
129
  callerFor: deps.callerFor,
129
130
  resume: deps.resume,
130
- ...deps.registry ? { registry: deps.registry } : {}
131
+ ...deps.registry ? { registry: deps.registry } : {},
132
+ ...deps.isTaskLive ? { isTaskLive: deps.isTaskLive } : {}
131
133
  });
132
134
  if (reason === "recovered") return { kind: "recovered" };
133
135
  if (reason === "skipped:no_pending_task_call") return { kind: "converged_no_call" };
@@ -184,7 +186,8 @@ async function runOrphanRecovery(deps) {
184
186
  try {
185
187
  const results = await backfillTopCallerGroup(tasks, top, {
186
188
  callerFor: deps.callerFor,
187
- resume: deps.resume
189
+ resume: deps.resume,
190
+ ...deps.isTaskLive ? { isTaskLive: deps.isTaskLive } : {}
188
191
  });
189
192
  for (const { id, reason } of results) {
190
193
  (reason === "recovered" ? recovered : skipped).push(`${id}:${reason}`);
@@ -234,6 +237,33 @@ function syntheticPublicProjectOwnerMembership(task, room) {
234
237
  };
235
238
  }
236
239
 
240
+ // src/services/collaboration/taskRunLiveness.ts
241
+ import {
242
+ storeLatticeManager,
243
+ taskRunLeaseKey,
244
+ threadRunLeaseKey
245
+ } from "@axiom-lattice/core";
246
+ function createTaskRunLiveness() {
247
+ try {
248
+ storeLatticeManager.getStoreLattice("default", "lease");
249
+ } catch {
250
+ return void 0;
251
+ }
252
+ return async (task) => {
253
+ try {
254
+ const store = storeLatticeManager.getStoreLattice("default", "lease").store;
255
+ if (await store.get(taskRunLeaseKey(task.id))) return true;
256
+ const threadId = typeof task.context?.thread_id === "string" ? task.context.thread_id : void 0;
257
+ if (threadId && task.ownerId) {
258
+ if (await store.get(threadRunLeaseKey(task.tenantId, task.ownerId, threadId))) return true;
259
+ }
260
+ return false;
261
+ } catch {
262
+ return true;
263
+ }
264
+ };
265
+ }
266
+
237
267
  // src/services/collaboration/OrphanRecoveryRuntime.ts
238
268
  function createOrphanRecoveryRuntime(deps) {
239
269
  const lifecycle = deps.lifecycle ?? createTaskLifecycleService({
@@ -242,6 +272,7 @@ function createOrphanRecoveryRuntime(deps) {
242
272
  });
243
273
  return {
244
274
  async recoverAll() {
275
+ const isTaskLive = deps.isTaskLive ?? createTaskRunLiveness();
245
276
  return runOrphanRecovery({
246
277
  reconcile: () => reconcileAllTenantTaskRuns({
247
278
  actor: "system:orphan-recovery",
@@ -250,10 +281,12 @@ function createOrphanRecoveryRuntime(deps) {
250
281
  },
251
282
  taskStore: deps.taskStore,
252
283
  lifecycle,
253
- include: (t) => !isProjectLifecycleTask(t)
284
+ include: (t) => !isProjectLifecycleTask(t),
285
+ ...isTaskLive ? { isTaskLive } : {}
254
286
  }),
255
287
  callerFor: deps.callerFor,
256
288
  resume: deps.resume,
289
+ ...isTaskLive ? { isTaskLive } : {},
257
290
  log: deps.log
258
291
  });
259
292
  },
@@ -264,12 +297,14 @@ function createOrphanRecoveryRuntime(deps) {
264
297
  return { kind: "skipped", reason: "project_task" };
265
298
  }
266
299
  const orphans = await deps.taskStore.list({ tenantId: input.tenantId, status: "in_progress" });
300
+ const isTaskLive = deps.isTaskLive ?? createTaskRunLiveness();
267
301
  return recoverTask(task, {
268
302
  lifecycle,
269
303
  registry: taskRunRegistry2,
270
304
  orphans,
271
305
  callerFor: deps.callerFor,
272
- resume: deps.resume
306
+ resume: deps.resume,
307
+ ...isTaskLive ? { isTaskLive } : {}
273
308
  });
274
309
  }
275
310
  };
@@ -283,6 +318,7 @@ export {
283
318
  recoverTask,
284
319
  resolveTopCaller,
285
320
  runOrphanRecovery,
321
+ createTaskRunLiveness,
286
322
  createOrphanRecoveryRuntime
287
323
  };
288
- //# sourceMappingURL=chunk-KDQKTU3N.mjs.map
324
+ //# sourceMappingURL=chunk-ZBTG3T7K.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/services/collaboration/OrphanRecoveryRuntime.ts","../src/services/collaboration/TopCallerRecovery.ts","../src/services/collaboration/projectTaskScope.ts","../src/services/collaboration/taskRunLiveness.ts"],"sourcesContent":["/**\n * Shared orphan-recovery runtime: the startup sweep and the on-demand\n * single-task entry point share one dependency shape and one lifecycle.\n *\n * @remarks\n * `recoverAll()` is the behavior-preserving move of the gateway startup block\n * (reconcile every tenant's orphaned ordinary tasks, then backfill the\n * top-level caller). `recoverTask()` is the A-lite on-demand entry: no HTTP\n * route, just a programmatic call used by the `task:recover` CLI/script.\n */\nimport type { TaskStore, TaskWorkItemStore, TenantStore } from \"@axiom-lattice/protocols\";\nimport {\n createTaskLifecycleService,\n reconcileAllTenantTaskRuns,\n taskRunRegistry,\n type TaskLifecycleService,\n} from \"@axiom-lattice/core\";\nimport {\n recoverTask as recoverSingleTask,\n runOrphanRecovery,\n type RecoverTaskResult,\n type TopCallerRecoveryDeps,\n} from \"./TopCallerRecovery\";\nimport { isProjectLifecycleTask } from \"./projectTaskScope\";\nimport { createTaskRunLiveness, type TaskLivenessProbe } from \"./taskRunLiveness\";\n\n/** Dependencies shared by the startup sweep and the single-task entry. */\nexport interface OrphanRecoveryRuntimeDeps {\n /** Task store used to enumerate tenants' orphans and read one task by id. */\n taskStore: TaskStore;\n /** Work-item store used to build the lifecycle when `lifecycle` is omitted. */\n workItemStore: TaskWorkItemStore;\n /** Tenant store supplying `getAllTenants()` for the startup sweep. */\n tenantStore: Pick<TenantStore, \"getAllTenants\">;\n /** Lifecycle used to converge orphans (built from the stores when omitted). */\n lifecycle?: Pick<TaskLifecycleService, \"failTask\">;\n /** Resolve a caller's agent client + config from the resolved top caller. */\n callerFor: TopCallerRecoveryDeps[\"callerFor\"];\n /** Resume the continuation (tests can call client.invoke(null, config)). */\n resume: TopCallerRecoveryDeps[\"resume\"];\n /**\n * Cross-replica liveness probe; defaults to the shared cross-replica probe\n * ({@link createTaskRunLiveness()}); inherit it unless a test injects one.\n */\n isTaskLive?: TaskLivenessProbe;\n /** Structured logger. */\n log: { info(msg: string, ctx: Record<string, unknown>): void; warn(msg: string, ctx: Record<string, unknown>): void };\n}\n\n/** Entry points returned by {@link createOrphanRecoveryRuntime}. */\nexport interface OrphanRecoveryRuntime {\n /** Startup/interval sweep over every tenant's orphaned ordinary tasks. */\n recoverAll(): Promise<{ recovered: string[]; skipped: string[] }>;\n /**\n * On-demand recovery of exactly one task within one tenant.\n *\n * @remarks Offline/maintenance: run when the Gateway is stopped, or from the\n * Gateway process. The `live` guard reads the process-local task registry and,\n * when a lease store is registered, also consults the cross-replica liveness\n * probe so a run held by another process is not converged. Governed Project\n * tasks are refused (`skipped:project_task`) so this never bypasses their\n * managed runtime.\n */\n recoverTask(input: { tenantId: string; taskId: string }): Promise<RecoverTaskResult>;\n}\n\n/**\n * Builds the shared orphan-recovery runtime.\n *\n * @param deps Task/work-item/tenant stores, optional lifecycle, caller\n * resolver, resume hook, and logger.\n * @returns `recoverAll()` (startup sweep) and `recoverTask()` (on-demand).\n * @remarks\n * Governed Project tasks are excluded from `recoverAll()` (they have their own\n * observer-based reconciliation) and from `recoverTask()`\n * (`skipped:project_task`), so the on-demand entry can never bypass the managed\n * Project runtime. `recoverTask()` delegates to {@link recoverSingleTask} with\n * the shared lifecycle, the process-local live-run registry, and the\n * cross-replica liveness probe (built from the shared `\"lease\"` store unless\n * `isTaskLive` is supplied), so it does not converge a task a live run still\n * holds — in this process or a peer replica. The liveness probe is advisory: a\n * benign race exists between the probe read and `failTask` (no\n * fencing/heartbeat support yet).\n *\n * @example\n * ```ts\n * const runtime = createOrphanRecoveryRuntime({ taskStore, workItemStore, tenantStore, callerFor, resume, log });\n * await runtime.recoverAll();\n * const outcome = await runtime.recoverTask({ tenantId, taskId });\n * ```\n */\nexport function createOrphanRecoveryRuntime(\n deps: OrphanRecoveryRuntimeDeps,\n): OrphanRecoveryRuntime {\n const lifecycle = deps.lifecycle ?? createTaskLifecycleService({\n taskStore: deps.taskStore,\n workItemStore: deps.workItemStore,\n });\n\n return {\n async recoverAll() {\n const isTaskLive = deps.isTaskLive ?? createTaskRunLiveness();\n return runOrphanRecovery({\n reconcile: () => reconcileAllTenantTaskRuns({\n actor: \"system:orphan-recovery\",\n tenantStore: {\n listTenants: async () => (await deps.tenantStore.getAllTenants()).map((tenant) => ({ id: tenant.id })),\n },\n taskStore: deps.taskStore,\n lifecycle,\n include: (t) => !isProjectLifecycleTask(t),\n ...(isTaskLive ? { isTaskLive } : {}),\n }),\n callerFor: deps.callerFor,\n resume: deps.resume,\n ...(isTaskLive ? { isTaskLive } : {}),\n log: deps.log,\n });\n },\n\n async recoverTask(input) {\n const task = await deps.taskStore.getById(input.tenantId, input.taskId);\n if (!task) return { kind: \"skipped\", reason: \"not_found\" };\n if (isProjectLifecycleTask(task)) {\n return { kind: \"skipped\", reason: \"project_task\" };\n }\n const orphans = await deps.taskStore.list({ tenantId: input.tenantId, status: \"in_progress\" });\n const isTaskLive = deps.isTaskLive ?? createTaskRunLiveness();\n return recoverSingleTask(task, {\n lifecycle,\n registry: taskRunRegistry,\n orphans,\n callerFor: deps.callerFor,\n resume: deps.resume,\n ...(isTaskLive ? { isTaskLive } : {}),\n });\n },\n };\n}\n","/**\n * Collapse recovery: backfill the top-level caller of converged orphan tasks.\n *\n * @remarks Only direct children of the top-level caller are backfilled; middle\n * task runs are frozen by the collapse design. Four guards: A skip a caller\n * with a pending interrupt (HITL), B skip live tasks (process-local registry\n * OR the optional cross-replica liveness probe), C derive the tool node name\n * from state, D use the task's real terminal state.\n */\nimport { ToolMessage } from \"@langchain/core/messages\";\nimport type { TaskItem } from \"@axiom-lattice/protocols\";\nimport {\n reconcileStaleTaskRuns,\n taskRunRegistry,\n type TaskLifecycleService,\n type TaskRunRegistry,\n} from \"@axiom-lattice/core\";\nimport { type TaskLivenessProbe } from \"./taskRunLiveness\";\n\n/** Minimal caller-graph client surface used by recovery. */\nexport interface RecoveryCallerClient {\n getState(config: unknown): Promise<unknown>;\n updateState(config: unknown, values: unknown, asNode?: string): Promise<unknown>;\n invoke(input: unknown, config: unknown): Promise<unknown>;\n}\n\nexport interface TopCallerRecoveryDeps {\n /**\n * Resolve a caller's agent client + config from the resolved top caller.\n *\n * @param top The resolved top-level caller thread + assistant.\n * @param tenantId The orphan task's tenant, used to scope the caller client.\n */\n callerFor(\n top: { threadId: string; assistantId?: string },\n tenantId: string,\n ): Promise<{ client: RecoveryCallerClient; config: unknown; agent?: unknown } | undefined>;\n /** Live-run registry (defaults to the shared Core singleton). */\n registry?: { isLive(taskId: string): boolean };\n /**\n * Optional cross-replica liveness probe consulted by Guard B, so a run held\n * by a peer replica is not converged/backfilled. Mutually additive with the\n * process-local `registry`.\n */\n isTaskLive?: TaskLivenessProbe;\n /** Resume the continuation (tests can call client.invoke(null, config)). */\n resume(client: RecoveryCallerClient, config: unknown, agent?: unknown): Promise<void>;\n}\n\n/** Dependencies for an on-demand single-task recovery ({@link recoverTask}). */\nexport interface RecoverTaskDeps {\n /** Lifecycle used to converge the orphan to `failed(no_executor)`. */\n lifecycle: Pick<TaskLifecycleService, \"failTask\">;\n /** Live-run registry (defaults to the shared Core singleton). */\n registry?: TaskRunRegistry;\n /**\n * The tenant's other orphan candidates (normally every `in_progress` task),\n * used to walk the caller chain up to the true top-level caller.\n *\n * @remarks\n * Without this set {@link resolveTopCaller} can only see the target itself,\n * so a nested middle run would be mistaken for a direct child of its\n * immediate (frozen) caller. Defaults to `[converged]` when omitted.\n */\n orphans?: TaskItem[];\n /**\n * Optional cross-replica liveness probe consulted by Guard B, so a run held\n * by a peer replica is not converged. Forwarded to\n * {@link reconcileStaleTaskRuns} and to {@link recoverTopCaller}.\n */\n isTaskLive?: TaskLivenessProbe;\n /** Resolve a caller's agent client + config from the resolved top caller. */\n callerFor: TopCallerRecoveryDeps[\"callerFor\"];\n /** Resume the continuation (tests can call client.invoke(null, config)). */\n resume: TopCallerRecoveryDeps[\"resume\"];\n}\n\n/**\n * Outcome of an on-demand single-task recovery attempt.\n *\n * @remarks\n * - `recovered`: the task was converged and its top-level caller was resumed.\n * - `skipped`: nothing was changed; `reason` names the guard (for example\n * `not_in_progress`, `live`, `middle`, `project_task`, `no_top_caller`,\n * `not_found`).\n * - `converged_no_call`: the task was converged to `failed`, but the caller had\n * no pending `task` call left to resolve, so no continuation was resumed.\n */\nexport type RecoverTaskResult =\n | { kind: \"recovered\" }\n | { kind: \"skipped\"; reason: string }\n | { kind: \"converged_no_call\" };\n\n/** A `task` tool call that still has no tool result. */\ninterface PendingTaskCall {\n id: string;\n taskId?: string;\n}\n\n/** Guard A: a caller waiting for a human is never touched. */\nfunction hasPendingInterrupts(state: Record<string, unknown>): boolean {\n return ((state.tasks as Array<{ interrupts?: unknown[] }> | undefined) ?? [])\n .some((t) => (t.interrupts?.length ?? 0) > 0);\n}\n\n/** Collects every pending `task` tool call, keyed by its `args.taskId` when present. */\nfunction pendingTaskCalls(state: Record<string, unknown>): PendingTaskCall[] {\n const messages = ((state.values as { messages?: Array<Record<string, unknown>> } | undefined)?.messages) ?? [];\n const resolved = new Set(\n messages\n .filter((m) => (m as { tool_call_id?: string }).tool_call_id)\n .map((m) => (m as { tool_call_id: string }).tool_call_id),\n );\n const calls: PendingTaskCall[] = [];\n for (const m of messages) {\n const typed = m as { getType?: () => string };\n if (typeof typed.getType !== \"function\" || typed.getType() !== \"ai\") continue;\n const toolCalls = (m as {\n tool_calls?: Array<{ id?: string; name?: string; args?: { taskId?: unknown } }>;\n }).tool_calls;\n if (!Array.isArray(toolCalls)) continue;\n for (const c of toolCalls) {\n if (c.name !== \"task\" || !c.id || resolved.has(c.id)) continue;\n const taskId = typeof c.args?.taskId === \"string\" ? c.args.taskId : undefined;\n calls.push({ id: c.id, ...(taskId ? { taskId } : {}) });\n }\n }\n return calls;\n}\n\n/** Guard D: the outcome follows the task's real terminal state. */\nfunction outcome(task: TaskItem): string {\n if (task.status === \"completed\") {\n return JSON.stringify({ success: true, taskId: task.id, result: task.result ?? \"\" });\n }\n if (task.status === \"failed\") {\n return JSON.stringify({ success: false, code: \"TASK_FAILED\", retryable: false, taskId: task.id, error: task.failureReason ?? \"\" });\n }\n return JSON.stringify({\n success: false,\n code: \"TASK_INTERRUPTED\",\n retryable: false,\n taskId: task.id,\n error: \"Run ended before completion; the task is interrupted and awaiting a decision.\",\n });\n}\n\n/** Per-task recovery outcome. */\ninterface RecoveryEntry {\n id: string;\n reason: string;\n}\n\n/**\n * Backfills a batch of converged direct-child tasks that share one top caller.\n *\n * @param tasks The direct-child orphans whose top caller is `top`.\n * @param top The resolved top-level caller.\n * @param deps Caller resolver, live-run registry, and resume hook.\n * @returns One `\"recovered\"` or `\"skipped:<reason>\"` entry per task.\n * @remarks\n * Reads the caller state once, matches each task to its pending `task` tool\n * call by `args.taskId`, injects every matched result in a single\n * `updateState`, then resumes once.\n */\nasync function backfillTopCallerGroup(\n tasks: TaskItem[],\n top: { threadId: string; assistantId?: string },\n deps: TopCallerRecoveryDeps,\n): Promise<RecoveryEntry[]> {\n const registry = deps.registry ?? taskRunRegistry;\n const results: RecoveryEntry[] = [];\n const eligible: TaskItem[] = [];\n for (const task of tasks) {\n if (!task.context?.caller_thread_id) {\n results.push({ id: task.id, reason: \"skipped:no_caller_link\" });\n continue;\n }\n if (registry.isLive(task.id) || (deps.isTaskLive && await deps.isTaskLive(task))) { // Guard B\n results.push({ id: task.id, reason: \"skipped:live\" });\n continue;\n }\n eligible.push(task);\n }\n if (eligible.length === 0) return results;\n\n const target = await deps.callerFor(top, eligible[0].tenantId);\n if (!target) {\n return [...results, ...eligible.map((task) => ({ id: task.id, reason: \"skipped:no_caller_client\" }))];\n }\n const state = (await target.client.getState(target.config)) as Record<string, unknown>;\n if (hasPendingInterrupts(state)) { // Guard A\n return [...results, ...eligible.map((task) => ({ id: task.id, reason: \"skipped:hitl\" }))];\n }\n const nodeName = ((state.tasks as Array<{ name?: string }> | undefined) ?? [])[0]?.name; // Guard C\n if (!nodeName) {\n return [...results, ...eligible.map((task) => ({ id: task.id, reason: \"skipped:no_pending_node\" }))];\n }\n\n const calls = pendingTaskCalls(state);\n const matched: Array<{ task: TaskItem; call: PendingTaskCall }> = [];\n for (const task of eligible) {\n const call = calls.find((candidate) => candidate.taskId === task.id);\n if (!call) {\n results.push({ id: task.id, reason: \"skipped:no_pending_task_call\" });\n continue;\n }\n matched.push({ task, call });\n }\n if (matched.length === 0) return results;\n\n await target.client.updateState(target.config, {\n messages: matched.map(({ task, call }) =>\n new ToolMessage({ content: outcome(task), tool_call_id: call.id, name: \"task\" })),\n }, nodeName); // Guard D via outcome()\n await deps.resume(target.client, target.config, target.agent);\n return [...results, ...matched.map(({ task }) => ({ id: task.id, reason: \"recovered\" }))];\n}\n\n/**\n * Backfills one converged direct-child task's top-level caller.\n *\n * @param task The converged orphan task (must carry `context.caller_thread_id`).\n * @param top The resolved top-level caller.\n * @param deps Caller resolver, live-run registry, and resume hook.\n * @returns `\"recovered\"` or a `\"skipped:<reason>\"` string.\n */\nexport async function recoverTopCaller(\n task: TaskItem,\n top: { threadId: string; assistantId?: string },\n deps: TopCallerRecoveryDeps,\n): Promise<string> {\n if (!task.context?.caller_thread_id) return \"skipped:no_caller_link\";\n // Only direct children may be backfilled; a middle run is frozen by design.\n if (task.context.caller_thread_id !== top.threadId) return \"skipped:middle\";\n const [first] = await backfillTopCallerGroup([task], top, deps);\n return first?.reason ?? \"skipped:no_pending_task_call\";\n}\n\n/**\n * Recovers a single orphan task on demand, reusing the collapse logic.\n *\n * @param task The candidate task (any status).\n * @param deps Lifecycle, live-run registry, orphan candidate set (for the\n * caller-chain walk), caller resolver, and resume hook.\n * @returns A discriminated outcome: `recovered`, `skipped:<reason>`, or\n * `converged_no_call` when the task was converged but the caller had no\n * pending `task` call to resolve.\n * @remarks\n * Mirrors {@link runOrphanRecovery} for exactly one task: anything not\n * `in_progress`, or still held by a live run, is skipped; the rest is converged\n * to `failed` (`no_executor`, ADR-143) and its **top-level** caller is\n * backfilled. `deps.orphans` must carry the tenant's other `in_progress`\n * candidates so a nested middle run is correctly skipped (`middle`) instead of\n * being mistaken for a direct child of its frozen immediate caller.\n *\n * This is an **offline/maintenance** entry point (the `task:recover` CLI): run\n * it when the Gateway is stopped, or from within the Gateway process. Guard B\n * reads the process-local {@link taskRunRegistry}; when the optional\n * `isTaskLive` cross-replica probe is supplied (the gateway's lease-backed\n * probe), it also detects a run held by a peer replica.\n *\n * The convergence actor is `system:on-demand-recovery` (distinct from the\n * startup sweep's `system:orphan-recovery`), so on-demand convergences are\n * auditable in the task work-item trail. No HTTP route is added and recovery\n * semantics are unchanged.\n */\nexport async function recoverTask(\n task: TaskItem,\n deps: RecoverTaskDeps,\n): Promise<RecoverTaskResult> {\n if (task.status !== \"in_progress\") {\n return { kind: \"skipped\", reason: \"not_in_progress\" };\n }\n const registry = deps.registry ?? taskRunRegistry;\n if (registry.isLive(task.id) || (deps.isTaskLive && await deps.isTaskLive(task))) { // Guard B\n return { kind: \"skipped\", reason: \"live\" };\n }\n\n const { convergedTasks } = await reconcileStaleTaskRuns({\n tasks: [task],\n actor: \"system:on-demand-recovery\",\n lifecycle: deps.lifecycle,\n ...(deps.registry ? { registry: deps.registry } : {}),\n ...(deps.isTaskLive ? { isTaskLive: deps.isTaskLive } : {}),\n });\n const converged = convergedTasks[0];\n if (!converged) {\n return { kind: \"skipped\", reason: \"convergence_failed\" };\n }\n\n const top = resolveTopCaller(converged, deps.orphans ?? [converged]);\n if (!top) {\n return { kind: \"skipped\", reason: \"no_top_caller\" };\n }\n // Only direct children may be backfilled; a middle run is frozen by design.\n if (converged.context?.caller_thread_id !== top.threadId) {\n return { kind: \"skipped\", reason: \"middle\" };\n }\n\n const reason = await recoverTopCaller(converged, top, {\n callerFor: deps.callerFor,\n resume: deps.resume,\n ...(deps.registry ? { registry: deps.registry } : {}),\n ...(deps.isTaskLive ? { isTaskLive: deps.isTaskLive } : {}),\n });\n if (reason === \"recovered\") return { kind: \"recovered\" };\n if (reason === \"skipped:no_pending_task_call\") return { kind: \"converged_no_call\" };\n return { kind: \"skipped\", reason: reason.replace(/^skipped:/, \"\") };\n}\n\n/** Walks caller links up to the thread that is not any orphan's run thread. */\nexport function resolveTopCaller(\n task: TaskItem,\n orphans: TaskItem[],\n): { threadId: string; assistantId?: string } | undefined {\n const tenantId = task.tenantId;\n const runThreadToTask = new Map(\n orphans.map((orphan) => [`${orphan.tenantId}:${orphan.context?.thread_id}`, orphan]),\n );\n let threadId = task.context?.caller_thread_id as string | undefined;\n let assistantId = task.context?.caller_assistant_id as string | undefined;\n const seen = new Set<string>();\n while (threadId) {\n const scopeKey = `${tenantId}:${threadId}`;\n if (!runThreadToTask.has(scopeKey) || seen.has(scopeKey)) break;\n seen.add(scopeKey);\n const parent = runThreadToTask.get(scopeKey)!;\n threadId = parent.context?.caller_thread_id as string | undefined;\n assistantId = parent.context?.caller_assistant_id as string | undefined;\n }\n return threadId ? { threadId, ...(assistantId ? { assistantId } : {}) } : undefined;\n}\n\n/**\n * Runs the whole collapse recovery once: reconcile orphan tasks, then backfill\n * the top-level caller of every direct-child orphan, grouped per top caller.\n * Best-effort; a failing group is contained and never aborts the others.\n *\n * @param deps Reconcile source, caller resolution, resume, and logger.\n * @returns The recovered and skipped `taskId:reason` entries.\n */\nexport async function runOrphanRecovery(deps: {\n reconcile: () => Promise<{ convergedTasks: TaskItem[] }>;\n callerFor: TopCallerRecoveryDeps[\"callerFor\"];\n resume: TopCallerRecoveryDeps[\"resume\"];\n isTaskLive?: TaskLivenessProbe;\n log: { info(msg: string, ctx: Record<string, unknown>): void; warn(msg: string, ctx: Record<string, unknown>): void };\n}): Promise<{ recovered: string[]; skipped: string[] }> {\n let convergedTasks: TaskItem[];\n try {\n ({ convergedTasks } = await deps.reconcile());\n } catch (error) {\n deps.log.warn(\"Task orphan recovery reconcile failed\", {\n error: error instanceof Error ? error.message : String(error),\n });\n return { recovered: [], skipped: [\"reconcile:error\"] };\n }\n const orphans = convergedTasks;\n const recovered: string[] = [];\n const skipped: string[] = [];\n\n const groups = new Map<string, { top: { threadId: string; assistantId?: string }; tasks: TaskItem[] }>();\n for (const task of orphans) {\n const top = resolveTopCaller(task, orphans);\n if (!top) { skipped.push(`${task.id}:skipped:no_top_caller`); continue; }\n // Only direct children are backfilled; middle task runs are frozen by design.\n if (task.context?.caller_thread_id !== top.threadId) {\n skipped.push(`${task.id}:skipped:middle`);\n continue;\n }\n const key = `${task.tenantId}:${top.threadId}`;\n const group = groups.get(key);\n if (group) group.tasks.push(task);\n else groups.set(key, { top, tasks: [task] });\n }\n\n for (const { top, tasks } of groups.values()) {\n try {\n const results = await backfillTopCallerGroup(tasks, top, {\n callerFor: deps.callerFor,\n resume: deps.resume,\n ...(deps.isTaskLive ? { isTaskLive: deps.isTaskLive } : {}),\n });\n for (const { id, reason } of results) {\n (reason === \"recovered\" ? recovered : skipped).push(`${id}:${reason}`);\n }\n } catch (error) {\n for (const task of tasks) skipped.push(`${task.id}:error`);\n deps.log.warn(\"Task orphan recovery group failed\", {\n threadId: top.threadId,\n error: error instanceof Error ? error.message : String(error),\n });\n }\n }\n\n deps.log.info(\"Task orphan recovery complete\", { recovered, skipped });\n return { recovered, skipped };\n}\n","import type {\n Project,\n ProjectBotMembership,\n ProjectRoom,\n TaskItem,\n} from \"@axiom-lattice/protocols\";\n\n/**\n * Whether a task belongs to the Project lifecycle scope enforced by this host.\n *\n * Host-owned business predicate (ADR-118): Core no longer interprets\n * `context.source`; the gateway decides which tasks its Project runtime owns.\n *\n * @param task Task snapshot whose durable scope and host-stamped origin are inspected.\n * @returns True for Project Room, Project Task, or human `user` origins with an explicit scope.\n *\n * @remarks ADR-118 §6: classification is **explicit scope presence + host-stamped\n * `context.source`** — there is no `\"default\"` sentinel. A source of\n * `project_room`/`project_task` is stamped only by the host's trusted run context,\n * which always carries a real workspace/project id. `user` marks UI/human-created\n * Project tasks, which share the same durable Project queue runtime.\n */\nexport function isProjectLifecycleTask(task: TaskItem): task is TaskItem & {\n workspaceId: string;\n projectId: string;\n} {\n const source = task.context?.source;\n return typeof task.workspaceId === \"string\" && task.workspaceId.length > 0\n && typeof task.projectId === \"string\" && task.projectId.length > 0\n && (source === \"project_room\" || source === \"project_task\" || source === \"user\");\n}\n\n/**\n * Whether a Project's public (general) kind is exempt from roster authority.\n *\n * @param project Project row being inspected, or `null`/`undefined` when absent.\n * @returns True only for `kind === \"public\"`.\n *\n * @remarks The public project kind is the workspace-wide general space: it has no\n * authored roster, so any available agent may own its tasks. Every other kind\n * (`business`, `training`, `personal`, legacy omitted) keeps strict roster\n * validation. The decision is a project property, not a task-source property.\n */\nexport function isRosterExemptProject(project: Pick<Project, \"kind\"> | null | undefined): boolean {\n return project?.kind === \"public\";\n}\n\n/**\n * Resolves the owner membership that authorizes a Project task's execution thread.\n *\n * @param task Exact Project task whose owner is being resolved.\n * @param project Exact Project row; `kind` decides roster exemption.\n * @param room Exact Project main room the owner executes in.\n * @param membership Roster lookup result for `task.ownerId`, if any.\n * @returns The active exact-scope roster membership, or a synthesized membership\n * for a public-project task whose owner is not an active roster bot, or\n * `undefined` when the owner is not an active roster bot and the project is not\n * public.\n *\n * @remarks Public-project tasks may use any available agent as owner, so the\n * Project runtime synthesizes a stable, task-scoped membership descriptor instead\n * of requiring a roster row. Roster authority is unchanged everywhere else.\n */\nexport function resolveTaskOwnerMembership(\n task: TaskItem,\n project: Pick<Project, \"kind\"> | null | undefined,\n room: ProjectRoom,\n membership: ProjectBotMembership | undefined,\n): ProjectBotMembership | undefined {\n const active = membership && membership.status === \"active\"\n && membership.tenantId === task.tenantId && membership.workspaceId === task.workspaceId\n && membership.projectId === task.projectId && membership.assistantId === task.ownerId\n && membership.roomId === room.id;\n if (active) return membership;\n if (!isRosterExemptProject(project)) return undefined;\n return syntheticPublicProjectOwnerMembership(task, room);\n}\n\n/**\n * Builds the stable, task-scoped owner membership used for a public-project task\n * whose owner agent has no active Project roster row.\n *\n * @param task Exact public-project task.\n * @param room Exact Project main room.\n * @returns A descriptor-safe `active` membership matching the task's exact scope\n * and owner, with a deterministic synthetic id so subsequent `ensure`/recovery\n * reads resolve the same canonical Task Thread metadata.\n */\nexport function syntheticPublicProjectOwnerMembership(task: TaskItem, room: ProjectRoom): ProjectBotMembership {\n const threadId = typeof task.context?.thread_id === \"string\" && task.context.thread_id.length > 0\n ? task.context.thread_id\n : task.ownerId;\n return {\n id: `public-project-owner:${task.projectId}:${task.ownerId}`,\n tenantId: task.tenantId,\n workspaceId: task.workspaceId!,\n projectId: task.projectId!,\n roomId: room.id,\n assistantId: task.ownerId,\n role: \"specialist\",\n title: task.ownerId,\n mentionName: task.ownerId,\n status: \"active\",\n roomThreadId: threadId,\n joinedAt: task.createdAt,\n updatedAt: task.updatedAt,\n };\n}\n","import type { LeaseStore, TaskItem } from \"@axiom-lattice/protocols\";\nimport {\n storeLatticeManager,\n taskRunLeaseKey,\n threadRunLeaseKey,\n} from \"@axiom-lattice/core\";\n\n/** Cross-replica liveness probe: resolves true when a peer still owns the task's run. */\nexport type TaskLivenessProbe = (task: TaskItem) => Promise<boolean>;\n\n/**\n * Builds a cross-replica task-liveness probe from the registered `\"lease\"` store.\n *\n * @returns A {@link TaskLivenessProbe}, or `undefined` only when no `lease`\n * store is registered (a test-only path); with the default in-memory lease\n * store a probe is always returned (single-process safe because the in-memory\n * store has no peer).\n * @remarks\n * A task is considered live when EITHER lease is currently held:\n * - `task-run:<taskId>` — the immediate executor's run-lifetime lease, or\n * - `thread-run:<tenantId>:<ownerId>:<thread_id>` — the queue processor\n * executing the task's run thread (dispatched workers run through this).\n *\n * Fail-safe: any lease-store error resolves `true`, so an unknown liveness\n * state never causes a live run to be converged as an orphan.\n *\n * The probe is advisory: there is a benign race between the probe read and\n * `failTask` (a run could acquire its lease in that window), and no\n * fencing/heartbeat-expiry detection is provided yet — consistent with the\n * framework's current no-lease posture.\n *\n * @example\n * ```ts\n * const probe = createTaskRunLiveness();\n * if (probe && await probe(task)) return; // a peer replica owns it\n * ```\n */\nexport function createTaskRunLiveness(): TaskLivenessProbe | undefined {\n try {\n storeLatticeManager.getStoreLattice(\"default\", \"lease\");\n } catch {\n return undefined;\n }\n return async (task: TaskItem): Promise<boolean> => {\n try {\n const store = storeLatticeManager.getStoreLattice(\"default\", \"lease\").store as LeaseStore;\n if (await store.get(taskRunLeaseKey(task.id))) return true;\n const threadId =\n typeof task.context?.thread_id === \"string\" ? task.context.thread_id : undefined;\n if (threadId && task.ownerId) {\n if (await store.get(threadRunLeaseKey(task.tenantId, task.ownerId, threadId))) return true;\n }\n return false;\n } catch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AAC5D,aAAO,YAAkB,MAAM;AAAA,QAC7B;AAAA,QACA,UAAUC;AAAA,QACV;AAAA,QACA,WAAW,KAAK;AAAA,QAChB,QAAQ,KAAK;AAAA,QACb,GAAI,aAAa,EAAE,WAAW,IAAI,CAAC;AAAA,MACrC,CAAC;AAAA,IACH;AAAA,EACF;AACF;","names":["taskRunRegistry","taskRunRegistry"]}
@@ -1 +1 @@
1
- import{l as C}from"./embed-page-chunk-CZE4IEB3.js";import"./embed-page-chunk-2G54EIW2.js";import"./embed-page-chunk-SUMYB6ZA.js";import"./embed-page-chunk-N2ISCAS7.js";import"./embed-page-chunk-KEL6XU6R.js";import"./embed-page-chunk-AC6X2XRH.js";import"./embed-page-chunk-S4XZPBRM.js";import"./embed-page-chunk-OHDEKFTU.js";import{Fa as T,rb as B}from"./embed-page-chunk-XIXSRYJY.js";import{r as P}from"./embed-page-chunk-HEMNMC4X.js";import{a as I}from"./embed-page-chunk-MB65DZAX.js";import"./embed-page-chunk-VW3NF5NT.js";import"./embed-page-chunk-5JDQ456X.js";import"./embed-page-chunk-Z7USDLHI.js";import{U as c,W as p,oa as D,va as b,xa as l}from"./embed-page-chunk-O4QK5LWZ.js";import{a as U}from"./embed-page-chunk-4BKXE5ON.js";import"./embed-page-chunk-IX4WLWCY.js";import"./embed-page-chunk-EUOOO2LS.js";import{e as u}from"./embed-page-chunk-6Y3UYJ6Z.js";var e=u(U());var t=u(I()),G={component_key:"workspace_assistants",data:{},message:"Assistants"},N=r=>{let i=r;if(typeof r=="string")try{i=JSON.parse(r)}catch{return{}}return i!==null&&typeof i=="object"&&!Array.isArray(i)?i:{}},H=({data:r})=>{let{assistantId:i,initialTab:F}=r??{},{get:m,put:f,del:A}=P(),y=T(),[g,w]=(0,e.useState)(null),[R,h]=(0,e.useState)([]),[E,v]=(0,e.useState)(!1),[L,S]=(0,e.useState)(null),d=(0,e.useCallback)(()=>{y(G)},[y]),a=(0,e.useCallback)(async()=>{v(!0),S(null);try{let s=(await m("/api/assistants")).data?.records??[];h(s),w(s.find(o=>o.id===i)??null)}catch{S("Failed to load agent")}finally{v(!1)}},[m,i]);(0,e.useEffect)(()=>{i&&a()},[a,i]);let _=(0,e.useCallback)(async(n,s)=>{let o=N(n.graphDefinition),k;try{k=await f(`/api/assistants/${n.id}`,{name:s.name!==void 0?s.name:n.name,description:s.description!==void 0?s.description:n.description,graphDefinition:{...o,...s}})}catch(z){throw l.error("Failed to save agent"),z}if(!k.success)throw l.error("Failed to save agent"),new Error("Failed to save agent");l.success("Saved"),await a()},[f,a]),j=(0,e.useCallback)(n=>{w(s=>s&&s.id===n.id?n:s),h(s=>s.map(o=>o.id===n.id?n:o))},[]),x=(0,e.useCallback)(async n=>{if(!(await A(`/api/assistants/${n}`)).success)throw new Error("Failed to delete agent");l.success("Agent deleted"),d()},[A,d]);return i?g?(0,t.jsx)("div",{style:{height:"100%",overflow:"auto"},children:(0,t.jsx)(B,{children:(0,t.jsx)(C,{assistant:g,allAssistants:R,onBack:d,onDeleted:x,onSave:_,onAssistantUpdated:j,onAgentListInvalidated:()=>void a(),initialTab:F})},g.id)}):E?(0,t.jsx)("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",height:"100%"},children:(0,t.jsx)(b,{})}):L?(0,t.jsx)("div",{style:{padding:24},children:(0,t.jsx)(c,{type:"error",showIcon:!0,message:"Failed to load agent","data-testid":"detail-error",action:(0,t.jsxs)(D,{children:[(0,t.jsx)(p,{size:"small",onClick:()=>void a(),children:"Retry"}),(0,t.jsx)(p,{size:"small",type:"primary",onClick:d,children:"Back to list"})]})})}):(0,t.jsx)("div",{style:{padding:24},children:(0,t.jsx)(c,{type:"warning",showIcon:!0,message:"Agent not found","data-testid":"detail-not-found",action:(0,t.jsx)(p,{size:"small",type:"primary",onClick:d,children:"Back to list"})})}):(0,t.jsx)("div",{style:{padding:24},children:(0,t.jsx)(c,{type:"warning",showIcon:!0,message:"Missing agent id","data-testid":"detail-missing-id"})})};export{H as AgentDetailSideApp};
1
+ import{l as C}from"./embed-page-chunk-DZQBVJ7Z.js";import"./embed-page-chunk-UT3WYBZH.js";import"./embed-page-chunk-N22EGQAJ.js";import"./embed-page-chunk-IPIJ2SG6.js";import"./embed-page-chunk-KEL6XU6R.js";import"./embed-page-chunk-AC6X2XRH.js";import"./embed-page-chunk-S4XZPBRM.js";import"./embed-page-chunk-O72XBKQH.js";import{Ba as T,nb as B}from"./embed-page-chunk-QMVIL4BJ.js";import{y as P}from"./embed-page-chunk-YPNSOZYW.js";import{a as I}from"./embed-page-chunk-MB65DZAX.js";import"./embed-page-chunk-VW3NF5NT.js";import"./embed-page-chunk-5JDQ456X.js";import"./embed-page-chunk-Z7USDLHI.js";import{U as c,W as p,oa as D,va as b,xa as l}from"./embed-page-chunk-O4QK5LWZ.js";import{a as U}from"./embed-page-chunk-4BKXE5ON.js";import"./embed-page-chunk-IX4WLWCY.js";import"./embed-page-chunk-EUOOO2LS.js";import{e as u}from"./embed-page-chunk-6Y3UYJ6Z.js";var e=u(U());var t=u(I()),G={component_key:"workspace_assistants",data:{},message:"Assistants"},N=r=>{let i=r;if(typeof r=="string")try{i=JSON.parse(r)}catch{return{}}return i!==null&&typeof i=="object"&&!Array.isArray(i)?i:{}},H=({data:r})=>{let{assistantId:i,initialTab:F}=r??{},{get:m,put:f,del:A}=P(),y=T(),[g,w]=(0,e.useState)(null),[R,h]=(0,e.useState)([]),[E,v]=(0,e.useState)(!1),[L,S]=(0,e.useState)(null),d=(0,e.useCallback)(()=>{y(G)},[y]),a=(0,e.useCallback)(async()=>{v(!0),S(null);try{let s=(await m("/api/assistants")).data?.records??[];h(s),w(s.find(o=>o.id===i)??null)}catch{S("Failed to load agent")}finally{v(!1)}},[m,i]);(0,e.useEffect)(()=>{i&&a()},[a,i]);let _=(0,e.useCallback)(async(n,s)=>{let o=N(n.graphDefinition),k;try{k=await f(`/api/assistants/${n.id}`,{name:s.name!==void 0?s.name:n.name,description:s.description!==void 0?s.description:n.description,graphDefinition:{...o,...s}})}catch(z){throw l.error("Failed to save agent"),z}if(!k.success)throw l.error("Failed to save agent"),new Error("Failed to save agent");l.success("Saved"),await a()},[f,a]),j=(0,e.useCallback)(n=>{w(s=>s&&s.id===n.id?n:s),h(s=>s.map(o=>o.id===n.id?n:o))},[]),x=(0,e.useCallback)(async n=>{if(!(await A(`/api/assistants/${n}`)).success)throw new Error("Failed to delete agent");l.success("Agent deleted"),d()},[A,d]);return i?g?(0,t.jsx)("div",{style:{height:"100%",overflow:"auto"},children:(0,t.jsx)(B,{children:(0,t.jsx)(C,{assistant:g,allAssistants:R,onBack:d,onDeleted:x,onSave:_,onAssistantUpdated:j,onAgentListInvalidated:()=>void a(),initialTab:F})},g.id)}):E?(0,t.jsx)("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",height:"100%"},children:(0,t.jsx)(b,{})}):L?(0,t.jsx)("div",{style:{padding:24},children:(0,t.jsx)(c,{type:"error",showIcon:!0,message:"Failed to load agent","data-testid":"detail-error",action:(0,t.jsxs)(D,{children:[(0,t.jsx)(p,{size:"small",onClick:()=>void a(),children:"Retry"}),(0,t.jsx)(p,{size:"small",type:"primary",onClick:d,children:"Back to list"})]})})}):(0,t.jsx)("div",{style:{padding:24},children:(0,t.jsx)(c,{type:"warning",showIcon:!0,message:"Agent not found","data-testid":"detail-not-found",action:(0,t.jsx)(p,{size:"small",type:"primary",onClick:d,children:"Back to list"})})}):(0,t.jsx)("div",{style:{padding:24},children:(0,t.jsx)(c,{type:"warning",showIcon:!0,message:"Missing agent id","data-testid":"detail-missing-id"})})};export{H as AgentDetailSideApp};
@@ -1,4 +1,4 @@
1
- import{a as Re,b as Ne,c as Dt,d as Rt,e as Pt,f as Ft,g as Mt,h as Et,i as Nt,j as Lt,k as Bt,l as Ot}from"./embed-page-chunk-CZE4IEB3.js";import"./embed-page-chunk-2G54EIW2.js";import{a as Ue}from"./embed-page-chunk-SUMYB6ZA.js";import"./embed-page-chunk-N2ISCAS7.js";import"./embed-page-chunk-KEL6XU6R.js";import{b as Ge,e as ze,f as xt,g as wt,h as vt,i as kt,l as St,m as It}from"./embed-page-chunk-AC6X2XRH.js";import{a as ft,b as yt,c as ht,d as bt,e as At}from"./embed-page-chunk-SV2BM3WO.js";import"./embed-page-chunk-S4XZPBRM.js";import"./embed-page-chunk-OHDEKFTU.js";import{$ as dt,Ea as ut,Fa as Ct,G as st,J as it,P as lt,Qa as Ve,da as ct,k as De,oa as pt,rb as Tt,va as mt,w as rt,wa as gt}from"./embed-page-chunk-XIXSRYJY.js";import{m as et,r as ye}from"./embed-page-chunk-HEMNMC4X.js";import{a as M}from"./embed-page-chunk-MB65DZAX.js";import"./embed-page-chunk-VW3NF5NT.js";import"./embed-page-chunk-5JDQ456X.js";import"./embed-page-chunk-Z7USDLHI.js";import{Db as nt,Fa as Qe,Ia as Te,Ja as Xe,La as X,Ua as tt,W as J,_ as Se,aa as Ie,ac as Ee,ea as Me,ka as Ke,la as Ze,ma as Je,mc as at,oa as Ye,ra as R,ta as V,wa as _e,xa as v,ya as fe,yc as ot}from"./embed-page-chunk-O4QK5LWZ.js";import{a as ue}from"./embed-page-chunk-4BKXE5ON.js";import"./embed-page-chunk-IX4WLWCY.js";import"./embed-page-chunk-EUOOO2LS.js";import{e as x}from"./embed-page-chunk-6Y3UYJ6Z.js";var u=x(ue());var te=x(ue());var Y=x(ue());var $t=x(ue());var ie=x(M()),Kt=60,_t=72,je=(0,$t.memo)(({data:n})=>{let r=Re(n.type),p=Math.min(12+Math.sqrt(n.subAgentCount)*10,48);return(0,ie.jsxs)("div",{style:{display:"flex",flexDirection:"column",alignItems:"center"},children:[(0,ie.jsx)(ze,{type:"target",position:Ge.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:n.label,style:{width:p,height:p,borderRadius:"50%",background:Ne(r.color),display:"flex",alignItems:"center",justifyContent:"center",color:"#fff",fontSize:Math.max(10,p*.4),fontWeight:600,cursor:"pointer",boxShadow:"0 2px 8px rgba(0,0,0,0.15)"},children:n.label.charAt(0).toUpperCase()}),(0,ie.jsx)("div",{style:{fontSize:11,maxWidth:120,textAlign:"center",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",marginTop:4},children:n.label}),(0,ie.jsx)(ze,{type:"source",position:Ge.Top,style:{left:"50%",top:"50%",transform:"translate(-50%, -50%)",background:"transparent",border:"none",width:0,height:0},isConnectable:!1})]})});je.displayName="AgentGraphNode";var ee=x(M()),sn=({assistants:n,onNodeClick:r})=>{let[p,l,g]=vt([]),[o,f,k]=kt([]),[d,S]=(0,Y.useState)(null),H=(0,Y.useMemo)(()=>({agent:je}),[]),m=(0,Y.useMemo)(()=>Pt(n),[n]);(0,Y.useEffect)(()=>{let w=m.nodes.map(i=>({id:i.id})),P=m.edges.map(i=>({source:i.source,target:i.target})),N=new Map(m.nodes.map(i=>[i.id,i])),z=bt(w).force("link",ht(P).id(i=>i.id).distance(80)).force("charge",At().strength(-220)).force("center",ft(0,0)).force("collide",yt(45)).stop();for(let i=0;i<300;i++)z.tick();let F=w.map(i=>({id:i.id,type:"agent",data:N.get(i.id),position:{x:i.x-Kt/2,y:i.y-_t/2}})),s=m.edges.map(i=>({id:`e${i.source}-${i.target}`,source:i.source,target:i.target,style:{stroke:"#1677ff",strokeWidth:2},type:"straight"}));l(F),f(s)},[m,l,f]);let T=(0,Y.useMemo)(()=>d===null?p:p.map(w=>{let P=w.id===d||o.some(N=>N.source===d&&N.target===w.id||N.target===d&&N.source===w.id);return{...w,style:{opacity:P?1:.2,transition:"opacity 0.2s ease"}}}),[p,o,d]),K=(0,Y.useMemo)(()=>d===null?o.map(w=>({...w,style:{stroke:"#1677ff",strokeWidth:1.5,opacity:.25,transition:"opacity 0.2s ease"}})):o.map(w=>{let P=w.source===d||w.target===d;return{...w,style:{stroke:"#1677ff",strokeWidth:P?2.5:1,opacity:P?1:.04,transition:"opacity 0.2s ease"}}}),[o,d]);return(0,ee.jsx)("div",{style:{width:"100%",height:"100%",background:"#fafafa",position:"relative"},children:(0,ee.jsxs)(wt,{nodes:T,edges:K,onNodesChange:g,onEdgesChange:k,onNodeMouseEnter:(w,P)=>S(P.id),onNodeMouseLeave:()=>S(null),onNodeClick:(w,P)=>r?.(String(P.id)),nodeTypes:H,fitView:!0,fitViewOptions:{padding:.25},children:[(0,ee.jsx)(St,{color:"#eee",gap:20}),(0,ee.jsx)(It,{})]})})},Vt=n=>(0,ee.jsx)(xt,{children:(0,ee.jsx)(sn,{...n})});var E=x(M()),ln=n=>{if(!n)return"\u2014";let r=Date.now()-new Date(n).getTime(),p=Math.floor(r/6e4);if(p<1)return"just now";if(p<60)return`${p}m ago`;let l=Math.floor(p/60);return l<24?`${l}h ago`:`${Math.floor(l/24)}d ago`},dn=n=>n===null?"#d9d9d9":n>=80?"#22c55e":n>=50?"#f59e0b":"#ef4444",cn=mt(({css:n})=>({row:n`
1
+ import{a as Re,b as Ne,c as Dt,d as Rt,e as Pt,f as Ft,g as Mt,h as Et,i as Nt,j as Lt,k as Bt,l as Ot}from"./embed-page-chunk-DZQBVJ7Z.js";import"./embed-page-chunk-UT3WYBZH.js";import{a as Ue}from"./embed-page-chunk-N22EGQAJ.js";import"./embed-page-chunk-IPIJ2SG6.js";import"./embed-page-chunk-KEL6XU6R.js";import{b as Ge,e as ze,f as xt,g as wt,h as vt,i as kt,l as St,m as It}from"./embed-page-chunk-AC6X2XRH.js";import{a as ft,b as yt,c as ht,d as bt,e as At}from"./embed-page-chunk-SV2BM3WO.js";import"./embed-page-chunk-S4XZPBRM.js";import"./embed-page-chunk-O72XBKQH.js";import{$ as ct,Aa as ut,Ba as Ct,C as st,F as it,L as lt,Ma as Ve,X as dt,g as De,ka as pt,nb as Tt,ra as mt,s as rt,sa as gt}from"./embed-page-chunk-QMVIL4BJ.js";import{t as et,y as ye}from"./embed-page-chunk-YPNSOZYW.js";import{a as M}from"./embed-page-chunk-MB65DZAX.js";import"./embed-page-chunk-VW3NF5NT.js";import"./embed-page-chunk-5JDQ456X.js";import"./embed-page-chunk-Z7USDLHI.js";import{Db as nt,Fa as Qe,Ia as Te,Ja as Xe,La as X,Ua as tt,W as J,_ as Se,aa as Ie,ac as Ee,ea as Me,ka as Ke,la as Ze,ma as Je,mc as at,oa as Ye,ra as R,ta as V,wa as _e,xa as v,ya as fe,yc as ot}from"./embed-page-chunk-O4QK5LWZ.js";import{a as ue}from"./embed-page-chunk-4BKXE5ON.js";import"./embed-page-chunk-IX4WLWCY.js";import"./embed-page-chunk-EUOOO2LS.js";import{e as x}from"./embed-page-chunk-6Y3UYJ6Z.js";var u=x(ue());var te=x(ue());var Y=x(ue());var $t=x(ue());var ie=x(M()),Kt=60,_t=72,je=(0,$t.memo)(({data:n})=>{let r=Re(n.type),p=Math.min(12+Math.sqrt(n.subAgentCount)*10,48);return(0,ie.jsxs)("div",{style:{display:"flex",flexDirection:"column",alignItems:"center"},children:[(0,ie.jsx)(ze,{type:"target",position:Ge.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:n.label,style:{width:p,height:p,borderRadius:"50%",background:Ne(r.color),display:"flex",alignItems:"center",justifyContent:"center",color:"#fff",fontSize:Math.max(10,p*.4),fontWeight:600,cursor:"pointer",boxShadow:"0 2px 8px rgba(0,0,0,0.15)"},children:n.label.charAt(0).toUpperCase()}),(0,ie.jsx)("div",{style:{fontSize:11,maxWidth:120,textAlign:"center",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",marginTop:4},children:n.label}),(0,ie.jsx)(ze,{type:"source",position:Ge.Top,style:{left:"50%",top:"50%",transform:"translate(-50%, -50%)",background:"transparent",border:"none",width:0,height:0},isConnectable:!1})]})});je.displayName="AgentGraphNode";var ee=x(M()),sn=({assistants:n,onNodeClick:r})=>{let[p,l,g]=vt([]),[o,f,k]=kt([]),[d,S]=(0,Y.useState)(null),H=(0,Y.useMemo)(()=>({agent:je}),[]),m=(0,Y.useMemo)(()=>Pt(n),[n]);(0,Y.useEffect)(()=>{let w=m.nodes.map(i=>({id:i.id})),P=m.edges.map(i=>({source:i.source,target:i.target})),N=new Map(m.nodes.map(i=>[i.id,i])),z=bt(w).force("link",ht(P).id(i=>i.id).distance(80)).force("charge",At().strength(-220)).force("center",ft(0,0)).force("collide",yt(45)).stop();for(let i=0;i<300;i++)z.tick();let F=w.map(i=>({id:i.id,type:"agent",data:N.get(i.id),position:{x:i.x-Kt/2,y:i.y-_t/2}})),s=m.edges.map(i=>({id:`e${i.source}-${i.target}`,source:i.source,target:i.target,style:{stroke:"#1677ff",strokeWidth:2},type:"straight"}));l(F),f(s)},[m,l,f]);let T=(0,Y.useMemo)(()=>d===null?p:p.map(w=>{let P=w.id===d||o.some(N=>N.source===d&&N.target===w.id||N.target===d&&N.source===w.id);return{...w,style:{opacity:P?1:.2,transition:"opacity 0.2s ease"}}}),[p,o,d]),K=(0,Y.useMemo)(()=>d===null?o.map(w=>({...w,style:{stroke:"#1677ff",strokeWidth:1.5,opacity:.25,transition:"opacity 0.2s ease"}})):o.map(w=>{let P=w.source===d||w.target===d;return{...w,style:{stroke:"#1677ff",strokeWidth:P?2.5:1,opacity:P?1:.04,transition:"opacity 0.2s ease"}}}),[o,d]);return(0,ee.jsx)("div",{style:{width:"100%",height:"100%",background:"#fafafa",position:"relative"},children:(0,ee.jsxs)(wt,{nodes:T,edges:K,onNodesChange:g,onEdgesChange:k,onNodeMouseEnter:(w,P)=>S(P.id),onNodeMouseLeave:()=>S(null),onNodeClick:(w,P)=>r?.(String(P.id)),nodeTypes:H,fitView:!0,fitViewOptions:{padding:.25},children:[(0,ee.jsx)(St,{color:"#eee",gap:20}),(0,ee.jsx)(It,{})]})})},Vt=n=>(0,ee.jsx)(xt,{children:(0,ee.jsx)(sn,{...n})});var E=x(M()),ln=n=>{if(!n)return"\u2014";let r=Date.now()-new Date(n).getTime(),p=Math.floor(r/6e4);if(p<1)return"just now";if(p<60)return`${p}m ago`;let l=Math.floor(p/60);return l<24?`${l}h ago`:`${Math.floor(l/24)}d ago`},dn=n=>n===null?"#d9d9d9":n>=80?"#22c55e":n>=50?"#f59e0b":"#ef4444",cn=mt(({css:n})=>({row:n`
2
2
  display: flex;
3
3
  justify-content: space-between;
4
4
  align-items: flex-end;
@@ -1,4 +1,4 @@
1
- import{c as W,d as V}from"./embed-page-chunk-KEL6XU6R.js";import{b as N,d as U,e as k}from"./embed-page-chunk-AC6X2XRH.js";import"./embed-page-chunk-S4XZPBRM.js";import{Ha as b,Ja as z,Ka as F,La as H,Ma as L,Wa as R,Xa as $,Ya as J}from"./embed-page-chunk-XIXSRYJY.js";import"./embed-page-chunk-HEMNMC4X.js";import{a as g}from"./embed-page-chunk-MB65DZAX.js";import"./embed-page-chunk-VW3NF5NT.js";import"./embed-page-chunk-5JDQ456X.js";import"./embed-page-chunk-Z7USDLHI.js";import{Dc as D,Ia as O,Rc as G,Sc as w,Vc as _,W as v,aa as M,gb as P,lb as B,nc as E}from"./embed-page-chunk-O4QK5LWZ.js";import{a as C}from"./embed-page-chunk-4BKXE5ON.js";import"./embed-page-chunk-IX4WLWCY.js";import"./embed-page-chunk-EUOOO2LS.js";import{e as p}from"./embed-page-chunk-6Y3UYJ6Z.js";var s=p(C());var S=p(C());var o=p(g());var se="tracePulse 1.4s ease-in-out infinite",ie={running:(0,o.jsx)(E,{style:{color:"#1890ff"}}),success:(0,o.jsx)(P,{style:{color:"#52c41a"}}),error:(0,o.jsx)(B,{style:{color:"#ff4d4f"}})};function ae({kind:e}){switch(e){case"human":return(0,o.jsx)(_,{});case"agent":return(0,o.jsx)(G,{});case"tool":return(0,o.jsx)(w,{});case"ai":return(0,o.jsx)(D,{});default:return(0,o.jsx)(w,{})}}var I=S.default.createContext({}),le=()=>S.default.useContext(I),de=({data:e,selected:i})=>{let{onJumpToMessage:a}=le(),t=e.isAnswer===!0,r=e.status==="running",d=(e.parallelCount??1)>1,m=!!(a&&e.messageId&&!e.messageId.startsWith("summary:")),f=e.toolCall?F(e.toolCall.name):e.label,y=()=>{if((e.kind==="tool"||e.kind==="agent")&&e.toolCall){let h=H(e.toolCall.response);return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(z,{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)(b,{content:h})}),(0,o.jsx)(L,{ui:e.toolCall.ui})]})}return e.content?(0,o.jsx)(b,{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 ${t||i?"#6366f1":r?"#91caff":"#e5e7eb"}`,borderRadius:12,background:t?"#eef2ff":"#fff",boxShadow:r?"0 0 0 2px rgba(24,144,255,0.18)":i?"0 0 0 2px rgba(99,102,241,0.2)":"none",animation:r?se: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)(ae,{kind:e.kind}),(0,o.jsx)("span",{style:{fontWeight:t?700:600,flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:f}),d&&(0,o.jsxs)(O,{color:"purple",style:{marginInlineEnd:0,fontSize:10},children:["\u5E76\u53D1 \xD7",e.parallelCount]}),ie[e.status],m&&(0,o.jsx)(v,{type:"text",size:"small",onClick:()=>a?.(e.messageId),children:"\u5BF9\u8BDD"})]}),(0,o.jsx)("div",{style:{flex:1,minHeight:0,overflow:"auto",padding:12},children:y()})]})},ce=({data:e,selected:i})=>(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(k,{type:"target",position:N.Top}),(0,o.jsx)(de,{data:e,selected:i}),(0,o.jsx)(k,{type:"source",position:N.Bottom})]}),K={trace:ce};var Y=p(C());var u=p(g()),pe={running:"#1890ff",success:"#52c41a",error:"#ff4d4f"},Z=({graph:e,activeNodeId:i,onSelectNode:a})=>{let t=Y.default.useMemo(()=>new Map(e.nodes.map(r=>[r.id,r])),[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(r=>(0,u.jsxs)("div",{"data-testid":"trace-rail-phase",children:[(0,u.jsx)("div",{style:{fontSize:12,color:"#8c8c8c",marginBottom:4},children:r.title}),(0,u.jsx)("div",{style:{display:"flex",flexWrap:"wrap",gap:4},children:r.nodeIds.map(d=>{let m=t.get(d);if(!m)return null;let f=d===i;return(0,u.jsx)(M,{title:m.data.label,children:(0,u.jsx)("button",{type:"button","data-testid":"trace-rail-tick",onClick:()=>a?.(d),style:{width:f?12:8,height:f?12:8,borderRadius:"50%",border:"none",padding:0,cursor:"pointer",background:pe[m.data.status],outline:f?"2px solid #6366f1":"none"}})},d)})})]},r.id))})};var l=p(g()),j=3,q=()=>{},fe=`
1
+ import{c as W,d as V}from"./embed-page-chunk-KEL6XU6R.js";import{b as N,d as U,e as k}from"./embed-page-chunk-AC6X2XRH.js";import"./embed-page-chunk-S4XZPBRM.js";import{Da as b,Fa as z,Ga as F,Ha as H,Ia as L,Sa as R,Ta as $,Ua as J}from"./embed-page-chunk-QMVIL4BJ.js";import"./embed-page-chunk-YPNSOZYW.js";import{a as g}from"./embed-page-chunk-MB65DZAX.js";import"./embed-page-chunk-VW3NF5NT.js";import"./embed-page-chunk-5JDQ456X.js";import"./embed-page-chunk-Z7USDLHI.js";import{Dc as D,Ia as O,Rc as G,Sc as w,Vc as _,W as v,aa as M,gb as P,lb as B,nc as E}from"./embed-page-chunk-O4QK5LWZ.js";import{a as C}from"./embed-page-chunk-4BKXE5ON.js";import"./embed-page-chunk-IX4WLWCY.js";import"./embed-page-chunk-EUOOO2LS.js";import{e as p}from"./embed-page-chunk-6Y3UYJ6Z.js";var s=p(C());var S=p(C());var o=p(g());var se="tracePulse 1.4s ease-in-out infinite",ie={running:(0,o.jsx)(E,{style:{color:"#1890ff"}}),success:(0,o.jsx)(P,{style:{color:"#52c41a"}}),error:(0,o.jsx)(B,{style:{color:"#ff4d4f"}})};function ae({kind:e}){switch(e){case"human":return(0,o.jsx)(_,{});case"agent":return(0,o.jsx)(G,{});case"tool":return(0,o.jsx)(w,{});case"ai":return(0,o.jsx)(D,{});default:return(0,o.jsx)(w,{})}}var I=S.default.createContext({}),le=()=>S.default.useContext(I),de=({data:e,selected:i})=>{let{onJumpToMessage:a}=le(),t=e.isAnswer===!0,r=e.status==="running",d=(e.parallelCount??1)>1,m=!!(a&&e.messageId&&!e.messageId.startsWith("summary:")),f=e.toolCall?F(e.toolCall.name):e.label,y=()=>{if((e.kind==="tool"||e.kind==="agent")&&e.toolCall){let h=H(e.toolCall.response);return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(z,{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)(b,{content:h})}),(0,o.jsx)(L,{ui:e.toolCall.ui})]})}return e.content?(0,o.jsx)(b,{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 ${t||i?"#6366f1":r?"#91caff":"#e5e7eb"}`,borderRadius:12,background:t?"#eef2ff":"#fff",boxShadow:r?"0 0 0 2px rgba(24,144,255,0.18)":i?"0 0 0 2px rgba(99,102,241,0.2)":"none",animation:r?se: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)(ae,{kind:e.kind}),(0,o.jsx)("span",{style:{fontWeight:t?700:600,flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:f}),d&&(0,o.jsxs)(O,{color:"purple",style:{marginInlineEnd:0,fontSize:10},children:["\u5E76\u53D1 \xD7",e.parallelCount]}),ie[e.status],m&&(0,o.jsx)(v,{type:"text",size:"small",onClick:()=>a?.(e.messageId),children:"\u5BF9\u8BDD"})]}),(0,o.jsx)("div",{style:{flex:1,minHeight:0,overflow:"auto",padding:12},children:y()})]})},ce=({data:e,selected:i})=>(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(k,{type:"target",position:N.Top}),(0,o.jsx)(de,{data:e,selected:i}),(0,o.jsx)(k,{type:"source",position:N.Bottom})]}),K={trace:ce};var Y=p(C());var u=p(g()),pe={running:"#1890ff",success:"#52c41a",error:"#ff4d4f"},Z=({graph:e,activeNodeId:i,onSelectNode:a})=>{let t=Y.default.useMemo(()=>new Map(e.nodes.map(r=>[r.id,r])),[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(r=>(0,u.jsxs)("div",{"data-testid":"trace-rail-phase",children:[(0,u.jsx)("div",{style:{fontSize:12,color:"#8c8c8c",marginBottom:4},children:r.title}),(0,u.jsx)("div",{style:{display:"flex",flexWrap:"wrap",gap:4},children:r.nodeIds.map(d=>{let m=t.get(d);if(!m)return null;let f=d===i;return(0,u.jsx)(M,{title:m.data.label,children:(0,u.jsx)("button",{type:"button","data-testid":"trace-rail-tick",onClick:()=>a?.(d),style:{width:f?12:8,height:f?12:8,borderRadius:"50%",border:"none",padding:0,cursor:"pointer",background:pe[m.data.status],outline:f?"2px solid #6366f1":"none"}})},d)})})]},r.id))})};var l=p(g()),j=3,q=()=>{},fe=`
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 C}from"./embed-page-chunk-OOZDPBUK.js";import{Ga as v}from"./embed-page-chunk-XIXSRYJY.js";import{a as w}from"./embed-page-chunk-HEMNMC4X.js";import{a as x}from"./embed-page-chunk-MB65DZAX.js";import"./embed-page-chunk-VW3NF5NT.js";import"./embed-page-chunk-5JDQ456X.js";import"./embed-page-chunk-Z7USDLHI.js";import{ga as b}from"./embed-page-chunk-O4QK5LWZ.js";import{a as D}from"./embed-page-chunk-4BKXE5ON.js";import"./embed-page-chunk-IX4WLWCY.js";import"./embed-page-chunk-EUOOO2LS.js";import{e as d}from"./embed-page-chunk-6Y3UYJ6Z.js";var c=d(D());var E=d(w());var f=d(x());function p(s){if(!s||s.length===0)return{title:{text:"Chart",left:"left"},tooltip:{trigger:"axis"},legend:{right:0,orient:"vertical"},xAxis:{type:"category",data:[]},yAxis:{type:"value"},series:[{type:"line",name:"Series 1",data:[]}],grid:{left:"3%",right:"4%",bottom:"3%",containLabel:!0}};let i=s[0],t=Object.keys(i);if(t.length===0)return p([]);let r=t.filter(e=>{let n=i[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=s.map((a,l)=>a[n]!==void 0?String(a[n]):`Item ${l+1}`),u=s.map(a=>{let l=a[e];return typeof l=="number"?l:Number(l)||0});return{title:{text:"Chart",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:u}],grid:{left:"3%",right:"4%",bottom:"3%",containLabel:!0}}}return{title:{text:"Chart",left:"left"},tooltip:{trigger:"axis"},legend:{right:0,orient:"vertical"},xAxis:{type:"category",data:s.map((e,n)=>`Item ${n+1}`)},yAxis:{type:"value"},series:[{type:"bar",name:"Count",data:s.map(()=>1)}],grid:{left:"3%",right:"4%",bottom:"3%",containLabel:!0}}}function S(s){if(!s||typeof s!="object"||!s.series||!Array.isArray(s.series)||s.series.length===0)return null;let i=s.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||`Series ${n+1}`};if(e.type==="pie"){let u=e.data.map((a,l)=>typeof a=="object"&&a!==null&&"value"in a?{value:a.value,name:a.name||`Item ${l+1}`}:typeof a=="number"?{value:a,name:`Item ${l+1}`}:null).filter(a=>a!==null);return u.length===0?null:{...o,data:u}}return o}).filter(e=>e!==null);if(i.length===0)return null;let t={...s,series:i},r=i[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=i[0].data;Array.isArray(n)&&n.length>0?Array.isArray(n[0])?e.data=n.map(o=>o[0]):e.data=n.map((o,u)=>`Item ${u+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:"Chart",left:"left"};else if(typeof t.title=="object"){let e=t.title;e.left||(e.left="left"),e.text||(e.text="Chart"),t.title=e}if(t.tooltip||(t.tooltip={trigger:r==="pie"?"item":"axis"}),!t.legend)i.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 j(s){let i=null;try{let n=typeof s=="string"?s:s.join("");i=(0,E.parse)(n)}catch(n){return{data:null,error:`Failed to parse JSON: ${n instanceof Error?n.message:String(n)}`}}if(!i||typeof i!="object")return{data:null,error:"Parsed data is not an object"};let t=i.series&&Array.isArray(i.series)&&i.series.length>0,r={table:Array.isArray(i.table)?i.table:void 0},e=null;if(i.echarts?e=i.echarts:t&&(e=i),e){let n=S(e);if(n)r.echarts=n;else if(r.table&&r.table.length>0)r.echarts=p(r.table);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=p(r.table):r.echarts=p([]);return{data:r,error:null}}var T=s=>{let{children:i}=s,t=(0,c.useRef)(null),r=(0,c.useRef)(null),e=(0,c.useRef)(null),[n,o]=(0,c.useState)(null);(0,c.useEffect)(()=>{if(!t.current)return;r.current||(r.current=C(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:l,error:g}=j(a);if(g||!l){console.warn("ReactChart failed to parse chart data:",g||"Unknown parse error"),r.current&&r.current.clear(),o(null);return}if(l.table&&Array.isArray(l.table)&&o(l.table),l.echarts)try{r.current.setOption(l.echarts,!0)}catch(h){let m=h instanceof Error?h.message:"Failed to render chart";console.error("Failed to set ECharts option:",h),r.current&&r.current.clear(),o(null)}let y=()=>{r.current&&r.current.resize()};return e.current&&(e.current.disconnect(),e.current=null),t.current&&typeof ResizeObserver<"u"&&(e.current=new ResizeObserver(h=>{requestAnimationFrame(()=>{y()})}),e.current.observe(t.current)),window.addEventListener("resize",y),()=>{e.current&&(e.current.disconnect(),e.current=null),window.removeEventListener("resize",y)}},[i]),(0,c.useEffect)(()=>()=>{e.current&&(e.current.disconnect(),e.current=null),r.current&&(r.current.dispose(),r.current=null)},[]);let u=a=>{if(!a||a.length===0)return[];if(Array.isArray(a[0])){let l=a[0];return a.slice(1).map((y,h)=>{let m={};return y.forEach((R,A)=>{m[l[A]||`col_${A}`]=R}),m})}return a};return(0,f.jsxs)(b,{children:[(0,f.jsx)("div",{ref:t,style:{width:"100%",height:"400px",minHeight:"300px"}}),n&&n.length>0&&(0,f.jsx)("div",{style:{marginTop:16},children:(0,f.jsx)(v,{component_key:"chart_table_data",data:{dataSource:u(n),message:"Data Details"},interactive:!0,default_open_in_side_app:!0})})]})};export{T as ReactChart};
1
+ import{s as C}from"./embed-page-chunk-OOZDPBUK.js";import{Ca as v}from"./embed-page-chunk-QMVIL4BJ.js";import{h as w}from"./embed-page-chunk-YPNSOZYW.js";import{a as x}from"./embed-page-chunk-MB65DZAX.js";import"./embed-page-chunk-VW3NF5NT.js";import"./embed-page-chunk-5JDQ456X.js";import"./embed-page-chunk-Z7USDLHI.js";import{ga as b}from"./embed-page-chunk-O4QK5LWZ.js";import{a as D}from"./embed-page-chunk-4BKXE5ON.js";import"./embed-page-chunk-IX4WLWCY.js";import"./embed-page-chunk-EUOOO2LS.js";import{e as d}from"./embed-page-chunk-6Y3UYJ6Z.js";var c=d(D());var E=d(w());var f=d(x());function p(s){if(!s||s.length===0)return{title:{text:"Chart",left:"left"},tooltip:{trigger:"axis"},legend:{right:0,orient:"vertical"},xAxis:{type:"category",data:[]},yAxis:{type:"value"},series:[{type:"line",name:"Series 1",data:[]}],grid:{left:"3%",right:"4%",bottom:"3%",containLabel:!0}};let i=s[0],t=Object.keys(i);if(t.length===0)return p([]);let r=t.filter(e=>{let n=i[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=s.map((a,l)=>a[n]!==void 0?String(a[n]):`Item ${l+1}`),u=s.map(a=>{let l=a[e];return typeof l=="number"?l:Number(l)||0});return{title:{text:"Chart",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:u}],grid:{left:"3%",right:"4%",bottom:"3%",containLabel:!0}}}return{title:{text:"Chart",left:"left"},tooltip:{trigger:"axis"},legend:{right:0,orient:"vertical"},xAxis:{type:"category",data:s.map((e,n)=>`Item ${n+1}`)},yAxis:{type:"value"},series:[{type:"bar",name:"Count",data:s.map(()=>1)}],grid:{left:"3%",right:"4%",bottom:"3%",containLabel:!0}}}function S(s){if(!s||typeof s!="object"||!s.series||!Array.isArray(s.series)||s.series.length===0)return null;let i=s.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||`Series ${n+1}`};if(e.type==="pie"){let u=e.data.map((a,l)=>typeof a=="object"&&a!==null&&"value"in a?{value:a.value,name:a.name||`Item ${l+1}`}:typeof a=="number"?{value:a,name:`Item ${l+1}`}:null).filter(a=>a!==null);return u.length===0?null:{...o,data:u}}return o}).filter(e=>e!==null);if(i.length===0)return null;let t={...s,series:i},r=i[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=i[0].data;Array.isArray(n)&&n.length>0?Array.isArray(n[0])?e.data=n.map(o=>o[0]):e.data=n.map((o,u)=>`Item ${u+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:"Chart",left:"left"};else if(typeof t.title=="object"){let e=t.title;e.left||(e.left="left"),e.text||(e.text="Chart"),t.title=e}if(t.tooltip||(t.tooltip={trigger:r==="pie"?"item":"axis"}),!t.legend)i.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 j(s){let i=null;try{let n=typeof s=="string"?s:s.join("");i=(0,E.parse)(n)}catch(n){return{data:null,error:`Failed to parse JSON: ${n instanceof Error?n.message:String(n)}`}}if(!i||typeof i!="object")return{data:null,error:"Parsed data is not an object"};let t=i.series&&Array.isArray(i.series)&&i.series.length>0,r={table:Array.isArray(i.table)?i.table:void 0},e=null;if(i.echarts?e=i.echarts:t&&(e=i),e){let n=S(e);if(n)r.echarts=n;else if(r.table&&r.table.length>0)r.echarts=p(r.table);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=p(r.table):r.echarts=p([]);return{data:r,error:null}}var T=s=>{let{children:i}=s,t=(0,c.useRef)(null),r=(0,c.useRef)(null),e=(0,c.useRef)(null),[n,o]=(0,c.useState)(null);(0,c.useEffect)(()=>{if(!t.current)return;r.current||(r.current=C(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:l,error:g}=j(a);if(g||!l){console.warn("ReactChart failed to parse chart data:",g||"Unknown parse error"),r.current&&r.current.clear(),o(null);return}if(l.table&&Array.isArray(l.table)&&o(l.table),l.echarts)try{r.current.setOption(l.echarts,!0)}catch(h){let m=h instanceof Error?h.message:"Failed to render chart";console.error("Failed to set ECharts option:",h),r.current&&r.current.clear(),o(null)}let y=()=>{r.current&&r.current.resize()};return e.current&&(e.current.disconnect(),e.current=null),t.current&&typeof ResizeObserver<"u"&&(e.current=new ResizeObserver(h=>{requestAnimationFrame(()=>{y()})}),e.current.observe(t.current)),window.addEventListener("resize",y),()=>{e.current&&(e.current.disconnect(),e.current=null),window.removeEventListener("resize",y)}},[i]),(0,c.useEffect)(()=>()=>{e.current&&(e.current.disconnect(),e.current=null),r.current&&(r.current.dispose(),r.current=null)},[]);let u=a=>{if(!a||a.length===0)return[];if(Array.isArray(a[0])){let l=a[0];return a.slice(1).map((y,h)=>{let m={};return y.forEach((R,A)=>{m[l[A]||`col_${A}`]=R}),m})}return a};return(0,f.jsxs)(b,{children:[(0,f.jsx)("div",{ref:t,style:{width:"100%",height:"400px",minHeight:"300px"}}),n&&n.length>0&&(0,f.jsx)("div",{style:{marginTop:16},children:(0,f.jsx)(v,{component_key:"chart_table_data",data:{dataSource:u(n),message:"Data Details"},interactive:!0,default_open_in_side_app:!0})})]})};export{T as ReactChart};
@@ -1 +1 @@
1
- import{b as J,c as me,e as Q,f as Se,g as he,h as xe,i as ke,l as ve,m as be}from"./embed-page-chunk-AC6X2XRH.js";import{a as pe,b as ye,c as ge,d as fe,e as ue}from"./embed-page-chunk-SV2BM3WO.js";import"./embed-page-chunk-S4XZPBRM.js";import{m as le,q as ne,r as U,s as Te}from"./embed-page-chunk-HEMNMC4X.js";import{a as _}from"./embed-page-chunk-MB65DZAX.js";import{Ia as D,Ja as j,La as ie,Tb as de,W as k,ab as ae,fc as ce,ka as te,oa as I,qb as re,rb as se,ta as N,xa as T,ya as oe,yc as K}from"./embed-page-chunk-O4QK5LWZ.js";import{a as ee}from"./embed-page-chunk-4BKXE5ON.js";import"./embed-page-chunk-EUOOO2LS.js";import{e as B}from"./embed-page-chunk-6Y3UYJ6Z.js";var S=B(ee());var m=B(ee());var e=B(_()),{Text:d}=ie,{TextArea:Ce}=N,Me=({data:v})=>{let{token:o}=j.useToken(),{config:C}=ne(),{put:V}=U(),R=me(t=>t.transform[2])>.6,q=le("__GLOBAL__");if(!v)return null;let{skill:g,onClick:F,onDelete:h}=v;if(!g)return null;let[i,A]=(0,m.useState)(g),O=i.subSkills&&i.subSkills.length>0,f=i.subSkills?.length||0,E=(0,m.useMemo)(()=>Math.min(12+Math.sqrt(f)*10,48),[f]),Y=i.metadata&&i.metadata.category||"global",b=(0,m.useMemo)(()=>i.metadata?Object.entries(i.metadata).filter(([t,n])=>t&&n):[],[i.metadata]),L=t=>{if(!t)return"";let n=t instanceof Date?t:new Date(t);return Number.isNaN(n.getTime())?"":n.toLocaleString()},G=t=>{navigator.clipboard.writeText(t)},[z,x]=(0,m.useState)(!1),[c,a]=(0,m.useState)({...g,id:g.name}),[s,u]=(0,m.useState)(b.map(([t,n])=>({key:t,value:n}))),[W,M]=(0,m.useState)(!1),[X,P]=(0,m.useState)(!1);(0,m.useEffect)(()=>{x(!1),A(g),a({...g,id:g.name}),u(Object.entries(g.metadata||{}).map(([t,n])=>({key:t,value:n})))},[g]);let l=(t,n)=>{if(t==="name"){a(r=>({...r,name:n,id:n}));return}a(r=>({...r,[t]:n}))},$=async t=>{t?.stopPropagation(),t?.preventDefault();try{let n=i.id||i.name;if(!n){T.error("Skill ID is missing");return}await q.skills.delete(n),T.success("Skill deleted successfully"),M(!1),h&&await h()}catch(n){T.error(n?.message||"An error occurred while deleting the skill")}},H=t=>{u(t);let n=t.reduce((r,p)=>(p.key&&(r[p.key]=p.value),r),{});a(r=>({...r,metadata:n}))},Z=(t,n,r)=>{let p=[...s];p[t]={...p[t],[n]:r},H(p)},ze=()=>{H([...s,{key:"",value:""}])},Be=async()=>{try{P(!0);let t={"Content-Type":"application/json"};C.apiKey&&(t.Authorization=`Bearer ${C.apiKey}`);let n={name:c.name,description:c.description,license:c.license||void 0,compatibility:c.compatibility||void 0,metadata:c.metadata||void 0,content:c.content||void 0,subSkills:c.subSkills||void 0},r=await V(`/api/skills/${i.id}`,n);if(r.success){T.success("Skill updated successfully");let p=r.data||c;A(p),a({...p,id:p.name}),u(Object.entries(p.metadata||{}).map(([Re,Ee])=>({key:Re,value:Ee}))),x(!1),F?.(p)}else T.error(r.message||"Failed to update skill")}catch(t){T.error(t.message||"An error occurred while updating the skill")}finally{P(!1)}},Ie=(0,e.jsxs)("div",{style:{display:"flex",flexDirection:"row",gap:24},children:[(0,e.jsxs)("div",{style:{flex:"0 0 320px",display:"flex",flexDirection:"column",gap:12},children:[(0,e.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[(0,e.jsx)(d,{style:{fontSize:12,color:o.colorTextSecondary},children:"Description"}),(0,e.jsx)(Ce,{value:c.description,onChange:t=>l("description",t.target.value),placeholder:"Description",rows:3})]}),(0,e.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[(0,e.jsx)(d,{style:{fontSize:12,color:o.colorTextSecondary},children:"License"}),(0,e.jsx)(N,{value:c.license,onChange:t=>l("license",t.target.value),placeholder:"License"})]}),(0,e.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[(0,e.jsx)(d,{style:{fontSize:12,color:o.colorTextSecondary},children:"Compatibility"}),(0,e.jsx)(N,{value:c.compatibility,onChange:t=>l("compatibility",t.target.value),placeholder:"Compatibility"})]}),(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8},children:[(0,e.jsx)(d,{style:{fontSize:12,color:o.colorTextSecondary,fontWeight:500},children:"Metadata"}),(0,e.jsx)(k,{size:"small",icon:(0,e.jsx)(K,{}),onClick:ze,children:"Add"})]}),(0,e.jsxs)(I,{direction:"vertical",size:8,style:{width:"100%"},children:[s.length===0&&(0,e.jsx)(d,{style:{fontSize:11,color:o.colorTextTertiary},children:"No metadata yet. Use Add to create one."}),s.map((t,n)=>(0,e.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:4,width:"100%"},children:[(0,e.jsxs)(d,{style:{fontSize:11,color:o.colorTextSecondary},children:["Meta ",n+1]}),(0,e.jsxs)(I,{style:{width:"100%"},size:8,wrap:!0,children:[(0,e.jsx)(N,{value:t.key,placeholder:"Key",style:{width:120},onChange:r=>Z(n,"key",r.target.value)}),(0,e.jsx)(N,{value:t.value,placeholder:"Value",style:{flex:1,minWidth:160},onChange:r=>Z(n,"value",r.target.value)})]})]},n))]})]}),(0,e.jsxs)("div",{style:{flex:1,display:"flex",flexDirection:"column",gap:6,minWidth:400},children:[(0,e.jsx)(d,{style:{fontSize:12,color:o.colorTextSecondary},children:"Content"}),(0,e.jsx)(Ce,{value:c.content,onChange:t=>l("content",t.target.value),placeholder:"Enter skill content here...",rows:30,style:{fontFamily:"monospace",fontSize:13,flex:1,minHeight:600}})]})]}),Ne=(0,e.jsxs)("div",{style:{width:z?960:720,maxHeight:"95vh",overflowY:"auto",padding:24},children:[(0,e.jsx)("div",{style:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",marginBottom:16},children:(0,e.jsxs)("div",{style:{flex:1},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:8},children:[(0,e.jsx)(d,{strong:!0,style:{fontSize:18,fontWeight:600,color:o.colorText},children:i.name}),(0,e.jsx)(D,{style:{margin:0,fontSize:10,padding:"2px 8px",fontWeight:600},color:"geekblue",children:Y.toUpperCase()})]}),(0,e.jsx)("div",{style:{display:"flex",alignItems:"center",gap:6},children:(0,e.jsx)(d,{style:{fontSize:11,color:o.colorTextTertiary,fontFamily:"monospace"},children:`>_ ${i.id}`})})]})}),z?Ie:(0,e.jsxs)(e.Fragment,{children:[i.description&&(0,e.jsx)("div",{style:{marginBottom:16},children:(0,e.jsxs)(d,{style:{fontSize:12,color:o.colorText,lineHeight:1.6,fontStyle:"italic"},children:['"',i.description,'"']})}),b.length>0&&(0,e.jsxs)("div",{style:{marginBottom:16},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:8},children:[(0,e.jsx)(ce,{style:{fontSize:14,color:o.colorTextSecondary}}),(0,e.jsxs)(d,{style:{fontSize:12,color:o.colorTextSecondary,fontWeight:500},children:["Metadata (",b.length,")"]})]}),(0,e.jsx)("div",{style:{border:`1px solid ${o.colorBorderSecondary}`,borderRadius:6,overflow:"hidden"},children:b.map(([t,n],r)=>(0,e.jsxs)("div",{style:{display:"flex",alignItems:"stretch",borderBottom:r===b.length-1?"none":`1px solid ${o.colorBorderSecondary}`},children:[(0,e.jsx)("div",{style:{width:140,padding:"8px 10px",background:o.colorFillTertiary,borderRight:`1px solid ${o.colorBorderSecondary}`,fontSize:11,color:o.colorTextSecondary,fontWeight:600,textTransform:"capitalize"},children:t}),(0,e.jsx)("div",{style:{flex:1,padding:"8px 10px",fontSize:11,color:o.colorText,wordBreak:"break-word"},children:n})]},t))})]}),O&&(0,e.jsxs)("div",{style:{marginBottom:16},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:8},children:[(0,e.jsx)(ae,{style:{fontSize:14,color:o.colorTextSecondary}}),(0,e.jsxs)(d,{style:{fontSize:12,color:o.colorTextSecondary,fontWeight:500},children:["Sub-Skills (",i.subSkills.length,")"]})]}),(0,e.jsx)(I,{size:[8,8],wrap:!0,children:i.subSkills.map((t,n)=>(0,e.jsx)(D,{style:{fontSize:11,padding:"4px 12px",backgroundColor:o.colorFillTertiary,color:o.colorText,border:`1px solid ${o.colorBorderSecondary}`},children:t},n))})]}),(i.license||i.compatibility)&&(0,e.jsx)("div",{style:{marginBottom:16},children:(0,e.jsxs)(I,{size:[8,8],wrap:!0,children:[i.license&&(0,e.jsx)(D,{icon:(0,e.jsx)(se,{}),style:{margin:0,fontSize:11,padding:"4px 12px",borderRadius:6,backgroundColor:o.colorInfoBg,color:o.colorInfo,border:`1px solid ${o.colorInfoBorder}`,fontWeight:500,lineHeight:"16px"},children:i.license}),i.compatibility&&(0,e.jsx)(D,{style:{margin:0,fontSize:11,padding:"4px 12px",borderRadius:6,backgroundColor:o.colorSuccessBg,color:o.colorSuccess,border:`1px solid ${o.colorSuccessBorder}`,fontWeight:500,lineHeight:"16px",display:"inline-flex",alignItems:"center",gap:4},children:i.compatibility})]})}),(i.createdAt||i.updatedAt)&&(0,e.jsx)("div",{style:{marginBottom:16},children:(0,e.jsxs)(I,{direction:"vertical",size:4,children:[i.createdAt&&(0,e.jsxs)(d,{style:{fontSize:11,color:o.colorTextTertiary,fontFamily:"monospace"},children:["Created: ",L(i.createdAt)]}),i.updatedAt&&(0,e.jsxs)(d,{style:{fontSize:11,color:o.colorTextTertiary,fontFamily:"monospace"},children:["Updated: ",L(i.updatedAt)]})]})}),i.content&&(0,e.jsxs)("div",{style:{marginBottom:0},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:8},children:[(0,e.jsx)(de,{style:{fontSize:14,color:o.colorTextSecondary}}),(0,e.jsx)(d,{style:{fontSize:12,color:o.colorTextSecondary,fontWeight:600,letterSpacing:.5},children:"CONTENT"})]}),(0,e.jsx)("div",{style:{padding:16,background:o.colorFillTertiary,border:`1px solid ${o.colorBorderSecondary}`,borderRadius:6,maxHeight:400,overflowY:"auto"},children:(0,e.jsx)(d,{style:{fontSize:12,color:o.colorText,lineHeight:1.7,whiteSpace:"pre-wrap",fontFamily:"monospace"},children:i.content})})]})]}),(0,e.jsx)(te,{style:{margin:"16px 0"}}),(0,e.jsx)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8},children:z?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(k,{block:!0,onClick:()=>{x(!1),a(g)},style:{flex:1},children:"Cancel"}),(0,e.jsx)(k,{type:"primary",block:!0,onClick:Be,loading:X,style:{flex:1},children:"Save"})]}):(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(k,{type:"primary",block:!0,onClick:()=>x(!0),style:{flex:1},children:"Edit Skill"}),(0,e.jsx)(k,{danger:!0,onClick:t=>{t.stopPropagation(),$(t)},children:"Delete"}),(0,e.jsx)(k,{icon:(0,e.jsx)(re,{}),onClick:()=>G(i.id),title:"Copy ID"})]})})]});return(0,e.jsxs)("div",{style:{position:"relative",padding:4,overflow:"visible"},children:[(0,e.jsx)(Q,{type:"source",position:J.Top,style:{left:"50%",top:"50%",transform:"translate(-50%, -50%)",background:"transparent",border:"none",width:1,height:1,borderRadius:"50%",pointerEvents:"none"},isConnectable:!1}),(0,e.jsx)(Q,{type:"target",position:J.Top,style:{left:"50%",top:"50%",transform:"translate(-50%, -50%)",background:"transparent",border:"none",width:1,height:1,borderRadius:"50%",pointerEvents:"none"},isConnectable:!1}),(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6,cursor:"pointer",position:"relative"},onClick:()=>M(!0),children:[(0,e.jsx)("div",{style:{width:E,height:E,borderRadius:"50%",background:"#999",flexShrink:0,boxShadow:"0 1px 4px rgba(0,0,0,0.15)",transition:"transform 0.15s ease"},onMouseEnter:t=>{t.currentTarget.style.transform="scale(1.15)"},onMouseLeave:t=>{t.currentTarget.style.transform="scale(1)"}}),R&&(0,e.jsx)(d,{style:{position:"absolute",top:"100%",left:"50%",transform:"translateX(-50%)",marginTop:4,fontSize:10,color:o.colorTextSecondary,opacity:.45,whiteSpace:"nowrap",pointerEvents:"none",userSelect:"none"},children:i.name})]}),(0,e.jsx)(oe,{open:W,onCancel:()=>{M(!1),x(!1),a({...i,id:i.name})},footer:null,width:z?1e3:760,destroyOnClose:!0,title:null,styles:{body:{padding:0}},children:Ne})]})},we=Me;var y=B(_()),De=({onNodeClick:v})=>{let[o,C,V]=xe([]),[w,R,q]=ke([]),[g,F]=(0,S.useState)(!1),[h,i]=(0,S.useState)([]),[A,O]=(0,S.useState)(!1),[f,E]=(0,S.useState)(null),{token:Y}=j.useToken(),{get:b}=U(),L=(0,S.useMemo)(()=>({skill:we}),[]),G=(0,S.useMemo)(()=>f===null?o:o.map(a=>{let s=a.id===f||w.some(u=>u.source===f&&u.target===a.id||u.target===f&&u.source===a.id);return{...a,style:{opacity:s?1:.2,transition:"opacity 0.2s ease"}}}),[o,w,f]),z=(0,S.useMemo)(()=>f===null?w.map(a=>({...a,style:{stroke:"#1677ff",strokeWidth:1.5,opacity:.25,transition:"opacity 0.2s ease"}})):w.map(a=>{let s=a.source===f||a.target===f;return{...a,style:{stroke:"#1677ff",strokeWidth:s?2.5:1,opacity:s?1:.04,transition:"opacity 0.2s ease"}}}),[w,f]),x=async()=>{O(!0);try{let a=await b("/api/skills");a.success&&a.data&&Array.isArray(a.data.records)&&i(a.data.records)}catch(a){console.error("Failed to fetch skills:",a),i([])}finally{O(!1)}};(0,S.useEffect)(()=>{x()},[]),(0,S.useEffect)(()=>{if(!h||h.length===0){C([]),R([]);return}let a=[],s=new Map,u=[];h.forEach(l=>{s.set(l.name,l),l.subSkills&&l.subSkills.length>0&&l.subSkills.forEach($=>{h.find(H=>H.name===$)&&u.push({source:l.name,target:$})})});let W=h.map(l=>({id:l.name})),M=u.map(l=>({source:l.source,target:l.target})),X=fe(W).force("link",ge(M).id(l=>l.id).distance(80)).force("charge",ue().strength(-300)).force("center",pe(0,0)).force("collide",ye(30)).stop();for(let l=0;l<300;l++)X.tick();let P=W.map(l=>({id:l.id,type:"skill",data:{skill:s.get(l.id),onClick:()=>v?.(s.get(l.id)),onDelete:x},position:{x:l.x,y:l.y}}));u.forEach(l=>{s.has(l.source)&&s.has(l.target)&&a.push({id:`e${l.source}-${l.target}`,source:l.source,target:l.target,style:{stroke:"#1677ff",strokeWidth:2},type:"straight"})}),C(P),R(a)},[h,C,R,v]);let c=async()=>{await x()};return A?(0,y.jsx)("div",{style:{width:"100%",height:"100%",display:"flex",justifyContent:"center",alignItems:"center",background:"#fafafa"},children:"Loading skills..."}):(0,y.jsxs)("div",{style:{width:"100%",height:"100%",background:"#fafafa",position:"relative"},children:[(0,y.jsxs)(he,{nodes:G,edges:z,onNodesChange:V,onEdgesChange:q,onNodeMouseEnter:(a,s)=>E(s.id),onNodeMouseLeave:()=>E(null),nodeTypes:L,fitView:!0,children:[(0,y.jsx)(ve,{color:"#eee",gap:20}),(0,y.jsx)(be,{})]}),(0,y.jsx)("div",{style:{position:"absolute",top:20,right:20,zIndex:10},children:(0,y.jsx)(k,{type:"primary",size:"large",icon:(0,y.jsx)(K,{}),onClick:()=>F(!0),style:{height:48,width:48,borderRadius:"50%",boxShadow:Y.boxShadowTertiary,display:"flex",alignItems:"center",justifyContent:"center",padding:0}})}),(0,y.jsx)(Te,{open:g,onCancel:()=>F(!1),onSuccess:c})]})},Fe=v=>(0,y.jsx)(Se,{children:(0,y.jsx)(De,{...v})}),it=Fe;export{it as default};
1
+ import{b as J,c as me,e as Q,f as Se,g as he,h as xe,i as ke,l as ve,m as be}from"./embed-page-chunk-AC6X2XRH.js";import{a as pe,b as ye,c as ge,d as fe,e as ue}from"./embed-page-chunk-SV2BM3WO.js";import"./embed-page-chunk-S4XZPBRM.js";import{t as le,x as ne,y as U,z as Te}from"./embed-page-chunk-YPNSOZYW.js";import{a as _}from"./embed-page-chunk-MB65DZAX.js";import{Ia as D,Ja as j,La as ie,Tb as de,W as k,ab as ae,fc as ce,ka as te,oa as I,qb as re,rb as se,ta as N,xa as T,ya as oe,yc as K}from"./embed-page-chunk-O4QK5LWZ.js";import{a as ee}from"./embed-page-chunk-4BKXE5ON.js";import"./embed-page-chunk-EUOOO2LS.js";import{e as B}from"./embed-page-chunk-6Y3UYJ6Z.js";var S=B(ee());var m=B(ee());var e=B(_()),{Text:d}=ie,{TextArea:Ce}=N,Me=({data:v})=>{let{token:o}=j.useToken(),{config:C}=ne(),{put:V}=U(),R=me(t=>t.transform[2])>.6,q=le("__GLOBAL__");if(!v)return null;let{skill:g,onClick:F,onDelete:h}=v;if(!g)return null;let[i,A]=(0,m.useState)(g),O=i.subSkills&&i.subSkills.length>0,f=i.subSkills?.length||0,E=(0,m.useMemo)(()=>Math.min(12+Math.sqrt(f)*10,48),[f]),Y=i.metadata&&i.metadata.category||"global",b=(0,m.useMemo)(()=>i.metadata?Object.entries(i.metadata).filter(([t,n])=>t&&n):[],[i.metadata]),L=t=>{if(!t)return"";let n=t instanceof Date?t:new Date(t);return Number.isNaN(n.getTime())?"":n.toLocaleString()},G=t=>{navigator.clipboard.writeText(t)},[z,x]=(0,m.useState)(!1),[c,a]=(0,m.useState)({...g,id:g.name}),[s,u]=(0,m.useState)(b.map(([t,n])=>({key:t,value:n}))),[W,M]=(0,m.useState)(!1),[X,P]=(0,m.useState)(!1);(0,m.useEffect)(()=>{x(!1),A(g),a({...g,id:g.name}),u(Object.entries(g.metadata||{}).map(([t,n])=>({key:t,value:n})))},[g]);let l=(t,n)=>{if(t==="name"){a(r=>({...r,name:n,id:n}));return}a(r=>({...r,[t]:n}))},$=async t=>{t?.stopPropagation(),t?.preventDefault();try{let n=i.id||i.name;if(!n){T.error("Skill ID is missing");return}await q.skills.delete(n),T.success("Skill deleted successfully"),M(!1),h&&await h()}catch(n){T.error(n?.message||"An error occurred while deleting the skill")}},H=t=>{u(t);let n=t.reduce((r,p)=>(p.key&&(r[p.key]=p.value),r),{});a(r=>({...r,metadata:n}))},Z=(t,n,r)=>{let p=[...s];p[t]={...p[t],[n]:r},H(p)},ze=()=>{H([...s,{key:"",value:""}])},Be=async()=>{try{P(!0);let t={"Content-Type":"application/json"};C.apiKey&&(t.Authorization=`Bearer ${C.apiKey}`);let n={name:c.name,description:c.description,license:c.license||void 0,compatibility:c.compatibility||void 0,metadata:c.metadata||void 0,content:c.content||void 0,subSkills:c.subSkills||void 0},r=await V(`/api/skills/${i.id}`,n);if(r.success){T.success("Skill updated successfully");let p=r.data||c;A(p),a({...p,id:p.name}),u(Object.entries(p.metadata||{}).map(([Re,Ee])=>({key:Re,value:Ee}))),x(!1),F?.(p)}else T.error(r.message||"Failed to update skill")}catch(t){T.error(t.message||"An error occurred while updating the skill")}finally{P(!1)}},Ie=(0,e.jsxs)("div",{style:{display:"flex",flexDirection:"row",gap:24},children:[(0,e.jsxs)("div",{style:{flex:"0 0 320px",display:"flex",flexDirection:"column",gap:12},children:[(0,e.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[(0,e.jsx)(d,{style:{fontSize:12,color:o.colorTextSecondary},children:"Description"}),(0,e.jsx)(Ce,{value:c.description,onChange:t=>l("description",t.target.value),placeholder:"Description",rows:3})]}),(0,e.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[(0,e.jsx)(d,{style:{fontSize:12,color:o.colorTextSecondary},children:"License"}),(0,e.jsx)(N,{value:c.license,onChange:t=>l("license",t.target.value),placeholder:"License"})]}),(0,e.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[(0,e.jsx)(d,{style:{fontSize:12,color:o.colorTextSecondary},children:"Compatibility"}),(0,e.jsx)(N,{value:c.compatibility,onChange:t=>l("compatibility",t.target.value),placeholder:"Compatibility"})]}),(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8},children:[(0,e.jsx)(d,{style:{fontSize:12,color:o.colorTextSecondary,fontWeight:500},children:"Metadata"}),(0,e.jsx)(k,{size:"small",icon:(0,e.jsx)(K,{}),onClick:ze,children:"Add"})]}),(0,e.jsxs)(I,{direction:"vertical",size:8,style:{width:"100%"},children:[s.length===0&&(0,e.jsx)(d,{style:{fontSize:11,color:o.colorTextTertiary},children:"No metadata yet. Use Add to create one."}),s.map((t,n)=>(0,e.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:4,width:"100%"},children:[(0,e.jsxs)(d,{style:{fontSize:11,color:o.colorTextSecondary},children:["Meta ",n+1]}),(0,e.jsxs)(I,{style:{width:"100%"},size:8,wrap:!0,children:[(0,e.jsx)(N,{value:t.key,placeholder:"Key",style:{width:120},onChange:r=>Z(n,"key",r.target.value)}),(0,e.jsx)(N,{value:t.value,placeholder:"Value",style:{flex:1,minWidth:160},onChange:r=>Z(n,"value",r.target.value)})]})]},n))]})]}),(0,e.jsxs)("div",{style:{flex:1,display:"flex",flexDirection:"column",gap:6,minWidth:400},children:[(0,e.jsx)(d,{style:{fontSize:12,color:o.colorTextSecondary},children:"Content"}),(0,e.jsx)(Ce,{value:c.content,onChange:t=>l("content",t.target.value),placeholder:"Enter skill content here...",rows:30,style:{fontFamily:"monospace",fontSize:13,flex:1,minHeight:600}})]})]}),Ne=(0,e.jsxs)("div",{style:{width:z?960:720,maxHeight:"95vh",overflowY:"auto",padding:24},children:[(0,e.jsx)("div",{style:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",marginBottom:16},children:(0,e.jsxs)("div",{style:{flex:1},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:8},children:[(0,e.jsx)(d,{strong:!0,style:{fontSize:18,fontWeight:600,color:o.colorText},children:i.name}),(0,e.jsx)(D,{style:{margin:0,fontSize:10,padding:"2px 8px",fontWeight:600},color:"geekblue",children:Y.toUpperCase()})]}),(0,e.jsx)("div",{style:{display:"flex",alignItems:"center",gap:6},children:(0,e.jsx)(d,{style:{fontSize:11,color:o.colorTextTertiary,fontFamily:"monospace"},children:`>_ ${i.id}`})})]})}),z?Ie:(0,e.jsxs)(e.Fragment,{children:[i.description&&(0,e.jsx)("div",{style:{marginBottom:16},children:(0,e.jsxs)(d,{style:{fontSize:12,color:o.colorText,lineHeight:1.6,fontStyle:"italic"},children:['"',i.description,'"']})}),b.length>0&&(0,e.jsxs)("div",{style:{marginBottom:16},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:8},children:[(0,e.jsx)(ce,{style:{fontSize:14,color:o.colorTextSecondary}}),(0,e.jsxs)(d,{style:{fontSize:12,color:o.colorTextSecondary,fontWeight:500},children:["Metadata (",b.length,")"]})]}),(0,e.jsx)("div",{style:{border:`1px solid ${o.colorBorderSecondary}`,borderRadius:6,overflow:"hidden"},children:b.map(([t,n],r)=>(0,e.jsxs)("div",{style:{display:"flex",alignItems:"stretch",borderBottom:r===b.length-1?"none":`1px solid ${o.colorBorderSecondary}`},children:[(0,e.jsx)("div",{style:{width:140,padding:"8px 10px",background:o.colorFillTertiary,borderRight:`1px solid ${o.colorBorderSecondary}`,fontSize:11,color:o.colorTextSecondary,fontWeight:600,textTransform:"capitalize"},children:t}),(0,e.jsx)("div",{style:{flex:1,padding:"8px 10px",fontSize:11,color:o.colorText,wordBreak:"break-word"},children:n})]},t))})]}),O&&(0,e.jsxs)("div",{style:{marginBottom:16},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:8},children:[(0,e.jsx)(ae,{style:{fontSize:14,color:o.colorTextSecondary}}),(0,e.jsxs)(d,{style:{fontSize:12,color:o.colorTextSecondary,fontWeight:500},children:["Sub-Skills (",i.subSkills.length,")"]})]}),(0,e.jsx)(I,{size:[8,8],wrap:!0,children:i.subSkills.map((t,n)=>(0,e.jsx)(D,{style:{fontSize:11,padding:"4px 12px",backgroundColor:o.colorFillTertiary,color:o.colorText,border:`1px solid ${o.colorBorderSecondary}`},children:t},n))})]}),(i.license||i.compatibility)&&(0,e.jsx)("div",{style:{marginBottom:16},children:(0,e.jsxs)(I,{size:[8,8],wrap:!0,children:[i.license&&(0,e.jsx)(D,{icon:(0,e.jsx)(se,{}),style:{margin:0,fontSize:11,padding:"4px 12px",borderRadius:6,backgroundColor:o.colorInfoBg,color:o.colorInfo,border:`1px solid ${o.colorInfoBorder}`,fontWeight:500,lineHeight:"16px"},children:i.license}),i.compatibility&&(0,e.jsx)(D,{style:{margin:0,fontSize:11,padding:"4px 12px",borderRadius:6,backgroundColor:o.colorSuccessBg,color:o.colorSuccess,border:`1px solid ${o.colorSuccessBorder}`,fontWeight:500,lineHeight:"16px",display:"inline-flex",alignItems:"center",gap:4},children:i.compatibility})]})}),(i.createdAt||i.updatedAt)&&(0,e.jsx)("div",{style:{marginBottom:16},children:(0,e.jsxs)(I,{direction:"vertical",size:4,children:[i.createdAt&&(0,e.jsxs)(d,{style:{fontSize:11,color:o.colorTextTertiary,fontFamily:"monospace"},children:["Created: ",L(i.createdAt)]}),i.updatedAt&&(0,e.jsxs)(d,{style:{fontSize:11,color:o.colorTextTertiary,fontFamily:"monospace"},children:["Updated: ",L(i.updatedAt)]})]})}),i.content&&(0,e.jsxs)("div",{style:{marginBottom:0},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:8},children:[(0,e.jsx)(de,{style:{fontSize:14,color:o.colorTextSecondary}}),(0,e.jsx)(d,{style:{fontSize:12,color:o.colorTextSecondary,fontWeight:600,letterSpacing:.5},children:"CONTENT"})]}),(0,e.jsx)("div",{style:{padding:16,background:o.colorFillTertiary,border:`1px solid ${o.colorBorderSecondary}`,borderRadius:6,maxHeight:400,overflowY:"auto"},children:(0,e.jsx)(d,{style:{fontSize:12,color:o.colorText,lineHeight:1.7,whiteSpace:"pre-wrap",fontFamily:"monospace"},children:i.content})})]})]}),(0,e.jsx)(te,{style:{margin:"16px 0"}}),(0,e.jsx)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8},children:z?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(k,{block:!0,onClick:()=>{x(!1),a(g)},style:{flex:1},children:"Cancel"}),(0,e.jsx)(k,{type:"primary",block:!0,onClick:Be,loading:X,style:{flex:1},children:"Save"})]}):(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(k,{type:"primary",block:!0,onClick:()=>x(!0),style:{flex:1},children:"Edit Skill"}),(0,e.jsx)(k,{danger:!0,onClick:t=>{t.stopPropagation(),$(t)},children:"Delete"}),(0,e.jsx)(k,{icon:(0,e.jsx)(re,{}),onClick:()=>G(i.id),title:"Copy ID"})]})})]});return(0,e.jsxs)("div",{style:{position:"relative",padding:4,overflow:"visible"},children:[(0,e.jsx)(Q,{type:"source",position:J.Top,style:{left:"50%",top:"50%",transform:"translate(-50%, -50%)",background:"transparent",border:"none",width:1,height:1,borderRadius:"50%",pointerEvents:"none"},isConnectable:!1}),(0,e.jsx)(Q,{type:"target",position:J.Top,style:{left:"50%",top:"50%",transform:"translate(-50%, -50%)",background:"transparent",border:"none",width:1,height:1,borderRadius:"50%",pointerEvents:"none"},isConnectable:!1}),(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6,cursor:"pointer",position:"relative"},onClick:()=>M(!0),children:[(0,e.jsx)("div",{style:{width:E,height:E,borderRadius:"50%",background:"#999",flexShrink:0,boxShadow:"0 1px 4px rgba(0,0,0,0.15)",transition:"transform 0.15s ease"},onMouseEnter:t=>{t.currentTarget.style.transform="scale(1.15)"},onMouseLeave:t=>{t.currentTarget.style.transform="scale(1)"}}),R&&(0,e.jsx)(d,{style:{position:"absolute",top:"100%",left:"50%",transform:"translateX(-50%)",marginTop:4,fontSize:10,color:o.colorTextSecondary,opacity:.45,whiteSpace:"nowrap",pointerEvents:"none",userSelect:"none"},children:i.name})]}),(0,e.jsx)(oe,{open:W,onCancel:()=>{M(!1),x(!1),a({...i,id:i.name})},footer:null,width:z?1e3:760,destroyOnClose:!0,title:null,styles:{body:{padding:0}},children:Ne})]})},we=Me;var y=B(_()),De=({onNodeClick:v})=>{let[o,C,V]=xe([]),[w,R,q]=ke([]),[g,F]=(0,S.useState)(!1),[h,i]=(0,S.useState)([]),[A,O]=(0,S.useState)(!1),[f,E]=(0,S.useState)(null),{token:Y}=j.useToken(),{get:b}=U(),L=(0,S.useMemo)(()=>({skill:we}),[]),G=(0,S.useMemo)(()=>f===null?o:o.map(a=>{let s=a.id===f||w.some(u=>u.source===f&&u.target===a.id||u.target===f&&u.source===a.id);return{...a,style:{opacity:s?1:.2,transition:"opacity 0.2s ease"}}}),[o,w,f]),z=(0,S.useMemo)(()=>f===null?w.map(a=>({...a,style:{stroke:"#1677ff",strokeWidth:1.5,opacity:.25,transition:"opacity 0.2s ease"}})):w.map(a=>{let s=a.source===f||a.target===f;return{...a,style:{stroke:"#1677ff",strokeWidth:s?2.5:1,opacity:s?1:.04,transition:"opacity 0.2s ease"}}}),[w,f]),x=async()=>{O(!0);try{let a=await b("/api/skills");a.success&&a.data&&Array.isArray(a.data.records)&&i(a.data.records)}catch(a){console.error("Failed to fetch skills:",a),i([])}finally{O(!1)}};(0,S.useEffect)(()=>{x()},[]),(0,S.useEffect)(()=>{if(!h||h.length===0){C([]),R([]);return}let a=[],s=new Map,u=[];h.forEach(l=>{s.set(l.name,l),l.subSkills&&l.subSkills.length>0&&l.subSkills.forEach($=>{h.find(H=>H.name===$)&&u.push({source:l.name,target:$})})});let W=h.map(l=>({id:l.name})),M=u.map(l=>({source:l.source,target:l.target})),X=fe(W).force("link",ge(M).id(l=>l.id).distance(80)).force("charge",ue().strength(-300)).force("center",pe(0,0)).force("collide",ye(30)).stop();for(let l=0;l<300;l++)X.tick();let P=W.map(l=>({id:l.id,type:"skill",data:{skill:s.get(l.id),onClick:()=>v?.(s.get(l.id)),onDelete:x},position:{x:l.x,y:l.y}}));u.forEach(l=>{s.has(l.source)&&s.has(l.target)&&a.push({id:`e${l.source}-${l.target}`,source:l.source,target:l.target,style:{stroke:"#1677ff",strokeWidth:2},type:"straight"})}),C(P),R(a)},[h,C,R,v]);let c=async()=>{await x()};return A?(0,y.jsx)("div",{style:{width:"100%",height:"100%",display:"flex",justifyContent:"center",alignItems:"center",background:"#fafafa"},children:"Loading skills..."}):(0,y.jsxs)("div",{style:{width:"100%",height:"100%",background:"#fafafa",position:"relative"},children:[(0,y.jsxs)(he,{nodes:G,edges:z,onNodesChange:V,onEdgesChange:q,onNodeMouseEnter:(a,s)=>E(s.id),onNodeMouseLeave:()=>E(null),nodeTypes:L,fitView:!0,children:[(0,y.jsx)(ve,{color:"#eee",gap:20}),(0,y.jsx)(be,{})]}),(0,y.jsx)("div",{style:{position:"absolute",top:20,right:20,zIndex:10},children:(0,y.jsx)(k,{type:"primary",size:"large",icon:(0,y.jsx)(K,{}),onClick:()=>F(!0),style:{height:48,width:48,borderRadius:"50%",boxShadow:Y.boxShadowTertiary,display:"flex",alignItems:"center",justifyContent:"center",padding:0}})}),(0,y.jsx)(Te,{open:g,onCancel:()=>F(!1),onSuccess:c})]})},Fe=v=>(0,y.jsx)(Se,{children:(0,y.jsx)(De,{...v})}),it=Fe;export{it as default};
@@ -1,4 +1,4 @@
1
- import{a as Je}from"./embed-page-chunk-2G54EIW2.js";import{c as Ge,d as We}from"./embed-page-chunk-KEL6XU6R.js";import{b as be,e as Ce,h as _e,i as Fe}from"./embed-page-chunk-AC6X2XRH.js";import"./embed-page-chunk-S4XZPBRM.js";import{C as ze,Qa as He,ab as Ve,bb as qe,cb as pe,db as Ne,eb as Ke,fb as Ue,ga as de,gb as Ye,ib as Qe,jb as Xe,k as le,kb as Ze,lb as et,qa as ce,va as G,wa as Oe}from"./embed-page-chunk-XIXSRYJY.js";import{j as Me,m as Ee}from"./embed-page-chunk-HEMNMC4X.js";import{a as $}from"./embed-page-chunk-MB65DZAX.js";import"./embed-page-chunk-VW3NF5NT.js";import"./embed-page-chunk-5JDQ456X.js";import"./embed-page-chunk-Z7USDLHI.js";import{Fa as ae,Ia as De,La as se,W as ne,Y as Ae,Z as Be,_ as we,la as je,ra as F,ta as Te,va as Y,ya as Le}from"./embed-page-chunk-O4QK5LWZ.js";import{a as ie}from"./embed-page-chunk-4BKXE5ON.js";import"./embed-page-chunk-IX4WLWCY.js";import"./embed-page-chunk-EUOOO2LS.js";import{e as v}from"./embed-page-chunk-6Y3UYJ6Z.js";var i=v(ie());var ot=v(ie());var a=v($()),vt=[{key:"pending",label:"Pending",color:"#7A7A7A"},{key:"in_progress",label:"In Progress",color:"#3b82f6"},{key:"review",label:"Review",color:"#f59e0b"},{key:"failed",label:"Failed",color:"#ef4444"},{key:"interrupted",label:"Interrupted",color:"#8b5cf6"},{key:"completed",label:"Completed",color:"#22c55e"}],tt={high:{label:"High",color:"#ef4444"},medium:{label:"Medium",color:"#f59e0b"},low:{label:"Low",color:"#22c55e"}};function wt(e){let o=typeof e=="string"?new Date(e):e,u=new Date().getTime()-o.getTime(),n=Math.floor(u/1e3),g=Math.floor(n/60),s=Math.floor(g/60),r=Math.floor(s/24);return n<60?"just now":g<60?`${g}m ago`:s<24?`${s}h ago`:r<30?`${r}d ago`:o.toLocaleDateString("en-US")}var Tt=G(({css:e,token:o})=>({container:e`
1
+ import{a as Je}from"./embed-page-chunk-UT3WYBZH.js";import{c as Ge,d as We}from"./embed-page-chunk-KEL6XU6R.js";import{b as be,e as Ce,h as _e,i as Fe}from"./embed-page-chunk-AC6X2XRH.js";import"./embed-page-chunk-S4XZPBRM.js";import{$a as Ne,Ma as He,Ya as Ve,Za as qe,_a as pe,ab as Ke,bb as Ue,ca as de,cb as Ye,eb as Qe,fb as Xe,g as le,gb as Ze,hb as et,ma as ce,ra as G,sa as Oe,y as ze}from"./embed-page-chunk-QMVIL4BJ.js";import{q as Me,t as Ee}from"./embed-page-chunk-YPNSOZYW.js";import{a as $}from"./embed-page-chunk-MB65DZAX.js";import"./embed-page-chunk-VW3NF5NT.js";import"./embed-page-chunk-5JDQ456X.js";import"./embed-page-chunk-Z7USDLHI.js";import{Fa as ae,Ia as De,La as se,W as ne,Y as Ae,Z as Be,_ as we,la as je,ra as F,ta as Te,va as Y,ya as Le}from"./embed-page-chunk-O4QK5LWZ.js";import{a as ie}from"./embed-page-chunk-4BKXE5ON.js";import"./embed-page-chunk-IX4WLWCY.js";import"./embed-page-chunk-EUOOO2LS.js";import{e as v}from"./embed-page-chunk-6Y3UYJ6Z.js";var i=v(ie());var ot=v(ie());var a=v($()),vt=[{key:"pending",label:"Pending",color:"#7A7A7A"},{key:"in_progress",label:"In Progress",color:"#3b82f6"},{key:"review",label:"Review",color:"#f59e0b"},{key:"failed",label:"Failed",color:"#ef4444"},{key:"interrupted",label:"Interrupted",color:"#8b5cf6"},{key:"completed",label:"Completed",color:"#22c55e"}],tt={high:{label:"High",color:"#ef4444"},medium:{label:"Medium",color:"#f59e0b"},low:{label:"Low",color:"#22c55e"}};function wt(e){let o=typeof e=="string"?new Date(e):e,u=new Date().getTime()-o.getTime(),n=Math.floor(u/1e3),g=Math.floor(n/60),s=Math.floor(g/60),r=Math.floor(s/24);return n<60?"just now":g<60?`${g}m ago`:s<24?`${s}h ago`:r<30?`${r}d ago`:o.toLocaleDateString("en-US")}var Tt=G(({css:e,token:o})=>({container:e`
2
2
  display: flex;
3
3
  flex-direction: column;
4
4
  height: 100%;
@@ -1,4 +1,4 @@
1
- import{d as Pe,f as Ge,g as Be,h as _e,i as Fe,l as We,m as je}from"./embed-page-chunk-AC6X2XRH.js";import"./embed-page-chunk-S4XZPBRM.js";import{$ as Ae,$a as He,A as ye,C as Z,I as Ce,Ia as Ee,N as Se,R as $e,T as Ne,U as Ie,W as we,X as Me,Y as B,Z as oe,_ as De,_a as Oe,g as he,ia as Le,n as J,o as ve,p as Te,q as Q,qa as se,r as O,ra as Re,t as G,va as I,z as be,za as ze}from"./embed-page-chunk-XIXSRYJY.js";import"./embed-page-chunk-HEMNMC4X.js";import{a as N}from"./embed-page-chunk-MB65DZAX.js";import"./embed-page-chunk-VW3NF5NT.js";import"./embed-page-chunk-5JDQ456X.js";import"./embed-page-chunk-Z7USDLHI.js";import{Da as re,Ea as V,Ia as E,Ka as xe,La as R,W as ce,Z as X,aa as z,da as K,fa as me,ga as W,ja as j,ka as pe,oa as q,ua as ge,va as fe,ya as ue}from"./embed-page-chunk-O4QK5LWZ.js";import{a as H}from"./embed-page-chunk-4BKXE5ON.js";import"./embed-page-chunk-IX4WLWCY.js";import"./embed-page-chunk-EUOOO2LS.js";import{e as h}from"./embed-page-chunk-6Y3UYJ6Z.js";var ie=h(H());var ee=h(H());var f=h(N()),pt=I(({token:e,css:t})=>({container:t`
1
+ import{d as Pe,f as Ge,g as Be,h as _e,i as Fe,l as We,m as je}from"./embed-page-chunk-AC6X2XRH.js";import"./embed-page-chunk-S4XZPBRM.js";import{E as Ce,Ea as Ee,J as Se,N as $e,P as Ne,Q as Ie,S as we,T as Me,U as B,V as oe,W as De,Wa as Oe,X as Ae,Xa as He,c as he,ea as Le,j as J,k as ve,l as Te,m as Q,ma as se,n as O,na as Re,p as G,ra as I,v as be,va as ze,w as ye,y as Z}from"./embed-page-chunk-QMVIL4BJ.js";import"./embed-page-chunk-YPNSOZYW.js";import{a as N}from"./embed-page-chunk-MB65DZAX.js";import"./embed-page-chunk-VW3NF5NT.js";import"./embed-page-chunk-5JDQ456X.js";import"./embed-page-chunk-Z7USDLHI.js";import{Da as re,Ea as V,Ia as E,Ka as xe,La as R,W as ce,Z as X,aa as z,da as K,fa as me,ga as W,ja as j,ka as pe,oa as q,ua as ge,va as fe,ya as ue}from"./embed-page-chunk-O4QK5LWZ.js";import{a as H}from"./embed-page-chunk-4BKXE5ON.js";import"./embed-page-chunk-IX4WLWCY.js";import"./embed-page-chunk-EUOOO2LS.js";import{e as h}from"./embed-page-chunk-6Y3UYJ6Z.js";var ie=h(H());var ee=h(H());var f=h(N()),pt=I(({token:e,css:t})=>({container:t`
2
2
  display: flex;
3
3
  flex-direction: column;
4
4
  height: 100%;
@@ -1,4 +1,4 @@
1
- import{a as ce,c as pe}from"./embed-page-chunk-N2ISCAS7.js";import{a as xe}from"./embed-page-chunk-KEL6XU6R.js";import{a as ne,b as O,e as j,f as G,g as oe,h as ie,i as re,k as se,l as ae,m as le,n as de}from"./embed-page-chunk-AC6X2XRH.js";import"./embed-page-chunk-S4XZPBRM.js";import{Ha as H,Y as L,h as Q,pa as te,s as F,u as ee,y as M}from"./embed-page-chunk-XIXSRYJY.js";import{r as $}from"./embed-page-chunk-HEMNMC4X.js";import{a as I}from"./embed-page-chunk-MB65DZAX.js";import"./embed-page-chunk-VW3NF5NT.js";import"./embed-page-chunk-5JDQ456X.js";import"./embed-page-chunk-Z7USDLHI.js";import{Aa as J,Bc as K,Fa as Z,Ia as D,La as X,Z as E,aa as P,na as _,oa as A,tb as q,va as B,wa as Y}from"./embed-page-chunk-O4QK5LWZ.js";import{a as U}from"./embed-page-chunk-4BKXE5ON.js";import"./embed-page-chunk-IX4WLWCY.js";import"./embed-page-chunk-EUOOO2LS.js";import{e as k}from"./embed-page-chunk-6Y3UYJ6Z.js";var r=k(U());var V=k(xe());var ue=k(U());var ge=k(I()),fe=({steps:t,graphDefinition:o,assistantId:n})=>{let l=(0,ue.useMemo)(()=>pe(o),[o]);return(0,ge.jsx)(ce,{dsl:l,steps:t,assistantId:n})};var e=k(I()),ve=`
1
+ import{a as ce,c as pe}from"./embed-page-chunk-IPIJ2SG6.js";import{a as xe}from"./embed-page-chunk-KEL6XU6R.js";import{a as ne,b as O,e as j,f as G,g as oe,h as ie,i as re,k as se,l as ae,m as le,n as de}from"./embed-page-chunk-AC6X2XRH.js";import"./embed-page-chunk-S4XZPBRM.js";import{Da as H,U as L,d as Q,la as te,o as F,q as ee,u as M}from"./embed-page-chunk-QMVIL4BJ.js";import{y as $}from"./embed-page-chunk-YPNSOZYW.js";import{a as I}from"./embed-page-chunk-MB65DZAX.js";import"./embed-page-chunk-VW3NF5NT.js";import"./embed-page-chunk-5JDQ456X.js";import"./embed-page-chunk-Z7USDLHI.js";import{Aa as J,Bc as K,Fa as Z,Ia as D,La as X,Z as E,aa as P,na as _,oa as A,tb as q,va as B,wa as Y}from"./embed-page-chunk-O4QK5LWZ.js";import{a as U}from"./embed-page-chunk-4BKXE5ON.js";import"./embed-page-chunk-IX4WLWCY.js";import"./embed-page-chunk-EUOOO2LS.js";import{e as k}from"./embed-page-chunk-6Y3UYJ6Z.js";var r=k(U());var V=k(xe());var ue=k(U());var ge=k(I()),fe=({steps:t,graphDefinition:o,assistantId:n})=>{let l=(0,ue.useMemo)(()=>pe(o),[o]);return(0,ge.jsx)(ce,{dsl:l,steps:t,assistantId:n})};var e=k(I()),ve=`
2
2
  @keyframes spin {
3
3
  from { transform: rotate(0deg); }
4
4
  to { transform: rotate(360deg); }