@axiom-lattice/gateway 11.1.0 → 11.2.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.
- package/dist/{chunk-JUA3VJE7.mjs → chunk-MQQGGIWU.mjs} +5 -19
- package/dist/{chunk-JUA3VJE7.mjs.map → chunk-MQQGGIWU.mjs.map} +1 -1
- package/dist/chunk-PSOMTQPW.mjs +138 -0
- package/dist/chunk-PSOMTQPW.mjs.map +1 -0
- package/dist/embed/embed-page-AgentDetailSideApp-UGLFIWJ3.js +1 -0
- package/dist/embed/embed-page-AgentGovernanceWorkbench-HZXQSMH2.js +1 -0
- package/dist/embed/{embed-page-LangfuseDashboard-HEHIDTTV.js → embed-page-LangfuseDashboard-L2LCWTBP.js} +1 -1
- package/dist/embed/embed-page-MessageGraph-BQUYKIK3.js +6 -0
- package/dist/embed/embed-page-ReactChart-5C6FIRZ4.js +1 -0
- package/dist/embed/embed-page-SkillFlow-MP72HEKD.js +1 -0
- package/dist/embed/{embed-page-TasksSideApp-PJ5LIIMG.js → embed-page-TasksSideApp-5JDZKFUH.js} +1 -1
- package/dist/embed/embed-page-TenantMonitorPanel-TIGNG44X.js +1 -0
- package/dist/embed/embed-page-ThreadMaintenancePanel-3OPCUQTF.js +1 -0
- package/dist/embed/{embed-page-TopologyRuntimeView-4UNE3VG5.js → embed-page-TopologyRuntimeView-7BRFAWID.js} +1 -1
- package/dist/embed/{embed-page-WorkflowAutomationView-AMNUEPOW.js → embed-page-WorkflowAutomationView-DKFNUAZY.js} +1 -1
- package/dist/embed/{embed-page-abnfDiagram-N423BO3Z-4HBLZWO7.js → embed-page-abnfDiagram-N423BO3Z-CRB43OW3.js} +1 -1
- package/dist/embed/embed-page-all-BS2CILLD.js +1 -0
- package/dist/embed/{embed-page-architectureDiagram-T3A2C74G-ZMH2RUZR.js → embed-page-architectureDiagram-T3A2C74G-N4QJM7EZ.js} +1 -1
- package/dist/embed/{embed-page-chunk-YW3P73TT.js → embed-page-chunk-32KEPBH4.js} +1 -1
- package/dist/embed/{embed-page-chunk-DFAZQFX4.js → embed-page-chunk-36VOH7DG.js} +13 -13
- package/dist/embed/{embed-page-chunk-UE7LEPK3.js → embed-page-chunk-77S6GKXR.js} +1 -1
- package/dist/embed/{embed-page-chunk-QPWSDWJ2.js → embed-page-chunk-7EEAFSMK.js} +1 -1
- package/dist/embed/{embed-page-chunk-EEHCG6K2.js → embed-page-chunk-A4EW4WEZ.js} +1 -1
- package/dist/embed/{embed-page-chunk-2LEOOAXJ.js → embed-page-chunk-A4I7H7RP.js} +1 -1
- package/dist/embed/{embed-page-chunk-UWC5QL3B.js → embed-page-chunk-BPNG3LLL.js} +1 -1
- package/dist/embed/{embed-page-chunk-YGBGMNRQ.js → embed-page-chunk-CBD4QXF2.js} +1 -1
- package/dist/embed/{embed-page-chunk-W4W6GR5T.js → embed-page-chunk-CR6PEMSJ.js} +1 -1
- package/dist/embed/{embed-page-chunk-JUZFORQA.js → embed-page-chunk-CS6LWVK2.js} +1 -1
- package/dist/embed/{embed-page-chunk-GD245YMF.js → embed-page-chunk-CSRF4YQD.js} +6 -6
- package/dist/embed/{embed-page-chunk-RPGUOUD3.js → embed-page-chunk-EMCH2FMD.js} +1 -1
- package/dist/embed/{embed-page-chunk-V5NE4FIR.js → embed-page-chunk-F52TPGBP.js} +1 -1
- package/dist/embed/embed-page-chunk-F5RPCW5O.js +216 -0
- package/dist/embed/embed-page-chunk-FYIVKZA2.js +1 -0
- package/dist/embed/{embed-page-chunk-TUVY65HW.js → embed-page-chunk-HGFIZATQ.js} +1 -1
- package/dist/embed/{embed-page-chunk-52VIWQVA.js → embed-page-chunk-HJYCGHWQ.js} +139 -139
- package/dist/embed/{embed-page-chunk-BJESMNTG.js → embed-page-chunk-I6Q3MSI4.js} +1 -1
- package/dist/embed/{embed-page-chunk-ZYYH2WHW.js → embed-page-chunk-IKESLNJH.js} +1 -1
- package/dist/embed/{embed-page-chunk-7IPWMDQ3.js → embed-page-chunk-OZUFLDHF.js} +1 -1
- package/dist/embed/embed-page-chunk-Q54ZBF3I.js +2 -0
- package/dist/embed/{embed-page-chunk-TWJOR2LG.js → embed-page-chunk-QWLZN3EX.js} +102 -102
- package/dist/embed/embed-page-chunk-VRVIRMMM.js +1 -0
- package/dist/embed/{embed-page-chunk-7TINC3YA.js → embed-page-chunk-WMHFEZXB.js} +1 -1
- package/dist/embed/{embed-page-chunk-SFG3O43S.js → embed-page-chunk-XGZYUTPS.js} +1 -1
- package/dist/embed/{embed-page-chunk-NY2J2ZAX.js → embed-page-chunk-ZX5EBQI5.js} +1 -1
- package/dist/embed/{embed-page-classDiagram-JCYQIIEL-QS7YU54N.js → embed-page-classDiagram-JCYQIIEL-NUQ6QNVB.js} +1 -1
- package/dist/embed/{embed-page-classDiagram-v2-OCEON4UE-EMQVQCCM.js → embed-page-classDiagram-v2-OCEON4UE-PGDM7DLE.js} +1 -1
- package/dist/embed/{embed-page-code-highlighter-LFX62WWR.js → embed-page-code-highlighter-VEQOWOHE.js} +1 -1
- package/dist/embed/{embed-page-cynefinDiagram-MW4NZA55-PAQOPJV2.js → embed-page-cynefinDiagram-MW4NZA55-WVU5T5A4.js} +1 -1
- package/dist/embed/{embed-page-dagre-VZM6K2ZE-35URH6ZO.js → embed-page-dagre-VZM6K2ZE-CAXZPEHO.js} +1 -1
- package/dist/embed/{embed-page-diagram-7IWD3JNH-CYEWFX2M.js → embed-page-diagram-7IWD3JNH-2RDNXDA6.js} +1 -1
- package/dist/embed/{embed-page-diagram-B4RE2ZJO-YQLA7HKI.js → embed-page-diagram-B4RE2ZJO-ZQTDRA2Q.js} +1 -1
- package/dist/embed/{embed-page-diagram-LBJQPF4R-R5X23WLT.js → embed-page-diagram-LBJQPF4R-QMUPQDDN.js} +1 -1
- package/dist/embed/{embed-page-diagram-Q27KOJAE-CSOUXGQI.js → embed-page-diagram-Q27KOJAE-SNK7KL7X.js} +1 -1
- package/dist/embed/{embed-page-diagram-UB23O5K3-ZYKI7DKR.js → embed-page-diagram-UB23O5K3-BTZB45HL.js} +1 -1
- package/dist/embed/{embed-page-ebnfDiagram-BXEA7PRR-AXHHSO6J.js → embed-page-ebnfDiagram-BXEA7PRR-6YXIIO2V.js} +1 -1
- package/dist/embed/{embed-page-en-3ML3AIGI.js → embed-page-en-2PUUB6AU.js} +1 -1
- package/dist/embed/embed-page-en-WCGOIHE7.js +1 -0
- package/dist/embed/{embed-page-erDiagram-JOGREHBK-TIWNY54V.js → embed-page-erDiagram-JOGREHBK-L5HOOC7O.js} +1 -1
- package/dist/embed/{embed-page-flowDiagram-UKHOOZJN-YZBV5FD5.js → embed-page-flowDiagram-UKHOOZJN-DG3SO7VX.js} +1 -1
- package/dist/embed/{embed-page-gitGraphDiagram-DS77QQ5N-JXOCEBS4.js → embed-page-gitGraphDiagram-DS77QQ5N-N2FD2D7W.js} +1 -1
- package/dist/embed/{embed-page-infoDiagram-6WML65LV-JXXYLFOE.js → embed-page-infoDiagram-6WML65LV-EQW3XJ3V.js} +1 -1
- package/dist/embed/{embed-page-kanban-definition-27J2QSJJ-GLES277J.js → embed-page-kanban-definition-27J2QSJJ-N2UULQCD.js} +1 -1
- package/dist/embed/{embed-page-mermaid-TRGRXQWI.js → embed-page-mermaid-VMLRSGBS.js} +2 -2
- package/dist/embed/{embed-page-mindmap-definition-FAOFIHXS-IK7SJKOY.js → embed-page-mindmap-definition-FAOFIHXS-HTKLKWBW.js} +1 -1
- package/dist/embed/{embed-page-pegDiagram-VL7TDLO6-WTW3QO5Z.js → embed-page-pegDiagram-VL7TDLO6-SA6LNRAH.js} +1 -1
- package/dist/embed/{embed-page-pieDiagram-7S7Q4E2Y-IO7RF3AF.js → embed-page-pieDiagram-7S7Q4E2Y-OMYAEVGG.js} +1 -1
- package/dist/embed/{embed-page-railroadDiagram-AXF67PYL-OW3L5JI4.js → embed-page-railroadDiagram-AXF67PYL-BDS2I2BL.js} +1 -1
- package/dist/embed/{embed-page-requirementDiagram-LRYGKXZP-APMTCGOA.js → embed-page-requirementDiagram-LRYGKXZP-7TQTEVRC.js} +1 -1
- package/dist/embed/{embed-page-stateDiagram-OKZ733FA-DYGG6K57.js → embed-page-stateDiagram-OKZ733FA-AJO67KCZ.js} +1 -1
- package/dist/embed/{embed-page-stateDiagram-v2-UEYNNEHI-BZIFN7WW.js → embed-page-stateDiagram-v2-UEYNNEHI-4ISQYRGQ.js} +1 -1
- package/dist/embed/{embed-page-swimlanes-SLNWSIFB-OKHSRANK.js → embed-page-swimlanes-SLNWSIFB-PEXIKADL.js} +1 -1
- package/dist/embed/{embed-page-swimlanesDiagram-ULZ7WXOC-CTOAIWO4.js → embed-page-swimlanesDiagram-ULZ7WXOC-M76ES3LS.js} +1 -1
- package/dist/embed/embed-page-t4-vb-FJS5HDYF.js +1 -0
- package/dist/embed/{embed-page-wardleyDiagram-T6FBY63Y-DL57P2VA.js → embed-page-wardleyDiagram-T6FBY63Y-B4SOYBIA.js} +1 -1
- package/dist/embed/embed-page-zh-JI3RZIRT.js +1 -0
- package/dist/embed/{embed-page-zh-ARIKNWNS.js → embed-page-zh-NFR2SOHA.js} +1 -1
- package/dist/embed/embed-page.js +1 -1
- package/dist/embed/mcp-app-page.js +36 -36
- package/dist/index.js +1383 -1075
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +606 -452
- package/dist/index.mjs.map +1 -1
- package/dist/{open-TJLQARLV.mjs → open-IA7RD66P.mjs} +3 -2
- package/dist/{open-TJLQARLV.mjs.map → open-IA7RD66P.mjs.map} +1 -1
- package/dist/open-audit-B756NMRP.mjs +67 -0
- package/dist/open-audit-B756NMRP.mjs.map +1 -0
- package/dist/{open-files-QIMOTHSN.mjs → open-files-JKHNZ5FF.mjs} +3 -2
- package/dist/{open-files-QIMOTHSN.mjs.map → open-files-JKHNZ5FF.mjs.map} +1 -1
- package/package.json +8 -8
- package/dist/embed/embed-page-AgentDetailSideApp-CZFD577F.js +0 -1
- package/dist/embed/embed-page-AgentGovernanceWorkbench-BPNTELS5.js +0 -1
- package/dist/embed/embed-page-MessageGraph-W5KMRMHF.js +0 -6
- package/dist/embed/embed-page-ReactChart-LOQULL4T.js +0 -1
- package/dist/embed/embed-page-SkillFlow-4KLNJILK.js +0 -1
- package/dist/embed/embed-page-ThreadMaintenancePanel-NTWT4SEQ.js +0 -1
- package/dist/embed/embed-page-all-6R5IZE46.js +0 -1
- package/dist/embed/embed-page-chunk-LMWLK4X2.js +0 -1
- package/dist/embed/embed-page-chunk-ZZPEVBX2.js +0 -217
- package/dist/embed/embed-page-t4-vb-5IKMGA3I.js +0 -1
- package/dist/open-audit-UJ3NXCGW.mjs +0 -32
- package/dist/open-audit-UJ3NXCGW.mjs.map +0 -1
- /package/dist/embed/{embed-page-chunk-XRN4MSDO.js → embed-page-chunk-3NCDEXPW.js} +0 -0
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import {
|
|
2
|
+
redactAndCapAuditValue
|
|
3
|
+
} from "./chunk-PSOMTQPW.mjs";
|
|
1
4
|
import {
|
|
2
5
|
init_openToken,
|
|
3
6
|
verifyOpenToken
|
|
@@ -83,23 +86,6 @@ var OpenCredentialService = class {
|
|
|
83
86
|
};
|
|
84
87
|
|
|
85
88
|
// src/services/open/openAuditService.ts
|
|
86
|
-
var SENSITIVE_KEY = /pass(word)?|secret|token|api[-_]?key|authorization|credential/i;
|
|
87
|
-
var MAX_ARGS_CHARS = 2e3;
|
|
88
|
-
function redactArgs(args, depth = 0) {
|
|
89
|
-
if (args === null || typeof args !== "object") return args;
|
|
90
|
-
if (depth > 6) return "[depth-limit]";
|
|
91
|
-
if (Array.isArray(args)) return args.map((v) => redactArgs(v, depth + 1));
|
|
92
|
-
const out = {};
|
|
93
|
-
for (const [key, value] of Object.entries(args)) {
|
|
94
|
-
out[key] = SENSITIVE_KEY.test(key) ? "[redacted]" : redactArgs(value, depth + 1);
|
|
95
|
-
}
|
|
96
|
-
return out;
|
|
97
|
-
}
|
|
98
|
-
function truncate(value) {
|
|
99
|
-
const s = JSON.stringify(value ?? null);
|
|
100
|
-
if (s.length <= MAX_ARGS_CHARS) return value ?? null;
|
|
101
|
-
return `${s.slice(0, MAX_ARGS_CHARS)}...[truncated]`;
|
|
102
|
-
}
|
|
103
89
|
var OpenAuditService = class {
|
|
104
90
|
constructor(store) {
|
|
105
91
|
this.store = store;
|
|
@@ -108,7 +94,7 @@ var OpenAuditService = class {
|
|
|
108
94
|
try {
|
|
109
95
|
await this.store.append({
|
|
110
96
|
...input,
|
|
111
|
-
args:
|
|
97
|
+
args: redactAndCapAuditValue(input.args)
|
|
112
98
|
});
|
|
113
99
|
} catch {
|
|
114
100
|
}
|
|
@@ -119,4 +105,4 @@ export {
|
|
|
119
105
|
OpenCredentialService,
|
|
120
106
|
OpenAuditService
|
|
121
107
|
};
|
|
122
|
-
//# sourceMappingURL=chunk-
|
|
108
|
+
//# sourceMappingURL=chunk-MQQGGIWU.mjs.map
|
|
@@ -1 +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
|
|
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\";\nimport {\n redactAndCapAuditValue,\n redactAuditValue,\n} from \"../platform-audit/PlatformAuditService\";\n\n/** Recursively mask sensitive fields using the shared audit redactor. */\nexport function redactArgs(args: unknown): unknown {\n return redactAuditValue(args);\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: redactAndCapAuditValue(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,QAAQ,QAA4D;AACxE,QAAI,CAAC,OAAQ,QAAO;AAGpB,UAAM,QAAQ,gBAAgB,MAAM;AACpC,QAAI,OAAO;AACT,UAAI,MAAM,SAAS,iBAAiB;AAClC,eAAO;AAAA,UACL,cAAc,WAAW,MAAM,WAAW;AAAA,UAC1C,MAAM;AAAA,UACN,UAAU,MAAM;AAAA,UAChB,WAAW,MAAM;AAAA,UACjB,aAAa,MAAM;AAAA,UACnB,aAAa,MAAM;AAAA,UACnB,OAAO,MAAM;AAAA,UACb,QAAQ,MAAM;AAAA,QAChB;AAAA,MACF;AACA,aAAO;AAAA,QACL,cAAc,WAAW,MAAM,UAAU,aAAa,EAAE,GAAG,MAAM,WAAW,MAAM,QAAQ;AAAA,QAC1F,MAAM;AAAA,QACN,UAAU,MAAM;AAAA,QAChB,WAAW,MAAM;AAAA,QACjB,aAAa,MAAM;AAAA,QACnB,QAAQ,MAAM;AAAA,MAChB;AAAA,IACF;AAEA,UAAM,MAAiC,MAAM,KAAK,KAAK,QAAQ,MAAM;AACrE,QAAI,CAAC,IAAK,QAAO;AAIjB,QAAI;AACJ,QAAI,KAAK,cAAc;AACrB,UAAI;AACF,cAAM,UAAU,MAAM,KAAK,aAAa;AAAA,UACtC,IAAI;AAAA,UACJ,IAAI;AAAA,QACN;AACA,sBAAc,SAAS;AAAA,MACzB,QAAQ;AAAA,MAER;AAAA,IACF;AACA,WAAO;AAAA,MACL,cAAc,IAAI;AAAA,MAClB,MAAM;AAAA,MACN,UAAU,IAAI;AAAA,MACd,WAAW,IAAI;AAAA,MACf;AAAA,MACA,QAAQ,IAAI;AAAA,IACd;AAAA,EACF;AACF;;;AE/DO,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,uBAAuB,MAAM,IAAI;AAAA,MACzC,CAAC;AAAA,IACH,QAAQ;AAAA,IAER;AAAA,EACF;AACF;","names":["effectiveGrants"]}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
// src/services/platform-audit/PlatformAuditService.ts
|
|
2
|
+
var PLATFORM_AUDIT_MAX_CAPTURE_BYTES = 16 * 1024;
|
|
3
|
+
var REDACTED = "[redacted]";
|
|
4
|
+
var CIRCULAR = "[circular]";
|
|
5
|
+
var MAX_DEPTH_MARKER = "[max-depth]";
|
|
6
|
+
var UNSERIALIZABLE = "[unserializable]";
|
|
7
|
+
var MAX_DEPTH = 6;
|
|
8
|
+
var SENSITIVE_FRAGMENTS = [
|
|
9
|
+
"password",
|
|
10
|
+
"passwd",
|
|
11
|
+
"secret",
|
|
12
|
+
"token",
|
|
13
|
+
"apikey",
|
|
14
|
+
"clientsecret",
|
|
15
|
+
"credential",
|
|
16
|
+
"authorization",
|
|
17
|
+
"cookie",
|
|
18
|
+
"privatekey",
|
|
19
|
+
"accesskey",
|
|
20
|
+
"session"
|
|
21
|
+
];
|
|
22
|
+
var UNSAFE_KEYS = /* @__PURE__ */ new Set(["__proto__", "constructor", "prototype"]);
|
|
23
|
+
var BEARER_PATH_PATTERNS = [
|
|
24
|
+
/(\/invite\/)([^/?#\s"'<>]+)/gi,
|
|
25
|
+
/(\/s\/)([^/?#\s"'<>]+)/gi
|
|
26
|
+
];
|
|
27
|
+
var SECRET_PARAM_PATTERN = /(^|[?&;])(token|access_token|refresh_token|api_key|secret|key)=([^&#\s"']+)/gi;
|
|
28
|
+
function redactString(value) {
|
|
29
|
+
let output = value;
|
|
30
|
+
for (const pattern of BEARER_PATH_PATTERNS) {
|
|
31
|
+
output = output.replace(pattern, "$1[redacted]");
|
|
32
|
+
}
|
|
33
|
+
return output.replace(SECRET_PARAM_PATTERN, "$1$2=[redacted]");
|
|
34
|
+
}
|
|
35
|
+
function isSensitiveKey(key) {
|
|
36
|
+
const normalized = key.replace(/[_-]/g, "").toLowerCase();
|
|
37
|
+
return SENSITIVE_FRAGMENTS.some((fragment) => normalized.includes(fragment));
|
|
38
|
+
}
|
|
39
|
+
function isPlainObject(value) {
|
|
40
|
+
const prototype = Object.getPrototypeOf(value);
|
|
41
|
+
return prototype === Object.prototype || prototype === null;
|
|
42
|
+
}
|
|
43
|
+
function leafValue(value) {
|
|
44
|
+
if (value instanceof RegExp) return redactString(value.toString());
|
|
45
|
+
if (value instanceof URL) return redactString(value.toString());
|
|
46
|
+
if (value instanceof Error) {
|
|
47
|
+
return redactString(`${value.name}: ${value.message}`);
|
|
48
|
+
}
|
|
49
|
+
const text = String(value);
|
|
50
|
+
return text === "[object Object]" ? UNSERIALIZABLE : redactString(text);
|
|
51
|
+
}
|
|
52
|
+
function redact(value, depth = 0, seen = /* @__PURE__ */ new WeakSet()) {
|
|
53
|
+
if (value === null) return value;
|
|
54
|
+
if (typeof value === "string") return redactString(value);
|
|
55
|
+
if (typeof value !== "object") return value;
|
|
56
|
+
if (seen.has(value)) return CIRCULAR;
|
|
57
|
+
if (depth >= MAX_DEPTH) return MAX_DEPTH_MARKER;
|
|
58
|
+
if (value instanceof Date) return redactString(value.toISOString());
|
|
59
|
+
if (value instanceof Map) {
|
|
60
|
+
seen.add(value);
|
|
61
|
+
const entries = [];
|
|
62
|
+
for (const [key, entry] of value) {
|
|
63
|
+
entries.push([key, entry]);
|
|
64
|
+
}
|
|
65
|
+
const output2 = redact(Object.fromEntries(entries), depth + 1, seen);
|
|
66
|
+
seen.delete(value);
|
|
67
|
+
return output2;
|
|
68
|
+
}
|
|
69
|
+
if (value instanceof Set) {
|
|
70
|
+
seen.add(value);
|
|
71
|
+
const output2 = redact(Array.from(value), depth + 1, seen);
|
|
72
|
+
seen.delete(value);
|
|
73
|
+
return output2;
|
|
74
|
+
}
|
|
75
|
+
if (Array.isArray(value)) {
|
|
76
|
+
seen.add(value);
|
|
77
|
+
const output2 = value.map((entry) => redact(entry, depth + 1, seen));
|
|
78
|
+
seen.delete(value);
|
|
79
|
+
return output2;
|
|
80
|
+
}
|
|
81
|
+
if (!isPlainObject(value)) {
|
|
82
|
+
return leafValue(value);
|
|
83
|
+
}
|
|
84
|
+
seen.add(value);
|
|
85
|
+
const output = {};
|
|
86
|
+
for (const [key, entry] of Object.entries(value)) {
|
|
87
|
+
if (UNSAFE_KEYS.has(key)) continue;
|
|
88
|
+
output[key] = isSensitiveKey(key) ? REDACTED : redact(entry, depth + 1, seen);
|
|
89
|
+
}
|
|
90
|
+
seen.delete(value);
|
|
91
|
+
return output;
|
|
92
|
+
}
|
|
93
|
+
function serializedByteLength(value) {
|
|
94
|
+
try {
|
|
95
|
+
const serialized = JSON.stringify(value);
|
|
96
|
+
return serialized === void 0 ? 0 : Buffer.byteLength(serialized);
|
|
97
|
+
} catch {
|
|
98
|
+
return PLATFORM_AUDIT_MAX_CAPTURE_BYTES + 1;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
function capCapture(value) {
|
|
102
|
+
const bytes = serializedByteLength(value);
|
|
103
|
+
if (bytes > PLATFORM_AUDIT_MAX_CAPTURE_BYTES) {
|
|
104
|
+
return { truncated: true, bytes };
|
|
105
|
+
}
|
|
106
|
+
return value;
|
|
107
|
+
}
|
|
108
|
+
function redactAndCapAuditValue(value, maxBytes = PLATFORM_AUDIT_MAX_CAPTURE_BYTES) {
|
|
109
|
+
const redacted = redact(value);
|
|
110
|
+
const bytes = serializedByteLength(redacted);
|
|
111
|
+
return bytes > maxBytes ? { truncated: true, bytes } : redacted;
|
|
112
|
+
}
|
|
113
|
+
var PlatformAuditService = class {
|
|
114
|
+
constructor(store) {
|
|
115
|
+
this.store = store;
|
|
116
|
+
}
|
|
117
|
+
async record(input) {
|
|
118
|
+
return this.store.append({
|
|
119
|
+
...input,
|
|
120
|
+
summary: capCapture(redact(input.summary)),
|
|
121
|
+
...input.before ? { before: capCapture(redact(input.before)) } : {},
|
|
122
|
+
...input.after ? { after: capCapture(redact(input.after)) } : {}
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
async get(id) {
|
|
126
|
+
return this.store.get(id);
|
|
127
|
+
}
|
|
128
|
+
async query(params) {
|
|
129
|
+
return this.store.query(params);
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
export {
|
|
134
|
+
PLATFORM_AUDIT_MAX_CAPTURE_BYTES,
|
|
135
|
+
redactAndCapAuditValue,
|
|
136
|
+
PlatformAuditService
|
|
137
|
+
};
|
|
138
|
+
//# sourceMappingURL=chunk-PSOMTQPW.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/services/platform-audit/PlatformAuditService.ts"],"sourcesContent":["import type {\n PlatformAuditAppendInput,\n PlatformAuditQuery,\n PlatformAuditRecord,\n PlatformAuditStore,\n} from \"@axiom-lattice/protocols\";\n\n/**\n * Upper bound for a single captured audit payload (summary/before/after).\n *\n * The HTTP hook applies the same budget to request/response bodies. The service\n * enforces it again because Ops tools and other direct writers bypass the hook;\n * oversized values are replaced with a `{ truncated, bytes }` marker rather\n * than stored verbatim.\n */\nexport const PLATFORM_AUDIT_MAX_CAPTURE_BYTES = 16 * 1024;\n\nconst REDACTED = \"[redacted]\";\nconst CIRCULAR = \"[circular]\";\nconst MAX_DEPTH_MARKER = \"[max-depth]\";\nconst UNSERIALIZABLE = \"[unserializable]\";\nconst MAX_DEPTH = 6;\n\nconst SENSITIVE_FRAGMENTS = [\n \"password\",\n \"passwd\",\n \"secret\",\n \"token\",\n \"apikey\",\n \"clientsecret\",\n \"credential\",\n \"authorization\",\n \"cookie\",\n \"privatekey\",\n \"accesskey\",\n \"session\",\n] as const;\n\nconst UNSAFE_KEYS = new Set([\"__proto__\", \"constructor\", \"prototype\"]);\n\n/**\n * Bearer secrets that live in URL path segments. Invite links and share links\n * grant access with the token alone, so they must never reach the audit store.\n */\nconst BEARER_PATH_PATTERNS = [\n /(\\/invite\\/)([^/?#\\s\"'<>]+)/gi,\n /(\\/s\\/)([^/?#\\s\"'<>]+)/gi,\n] as const;\n\n/** Query/body parameters whose values are bearer credentials. */\nconst SECRET_PARAM_PATTERN =\n /(^|[?&;])(token|access_token|refresh_token|api_key|secret|key)=([^&#\\s\"']+)/gi;\n\n/**\n * Value-level redactor for string leaves. Key-based redaction cannot catch a\n * token hidden under a harmless key such as `url`, so secrets embedded in URLs\n * and parameter strings are scrubbed while the surrounding text is preserved.\n */\nfunction redactString(value: string): string {\n let output = value;\n for (const pattern of BEARER_PATH_PATTERNS) {\n output = output.replace(pattern, \"$1[redacted]\");\n }\n return output.replace(SECRET_PARAM_PATTERN, \"$1$2=[redacted]\");\n}\n\nfunction isSensitiveKey(key: string): boolean {\n const normalized = key.replace(/[_-]/g, \"\").toLowerCase();\n return SENSITIVE_FRAGMENTS.some((fragment) => normalized.includes(fragment));\n}\n\nfunction isPlainObject(value: object): boolean {\n const prototype = Object.getPrototypeOf(value);\n return prototype === Object.prototype || prototype === null;\n}\n\nfunction leafValue(value: object): unknown {\n if (value instanceof RegExp) return redactString(value.toString());\n if (value instanceof URL) return redactString(value.toString());\n if (value instanceof Error) {\n return redactString(`${value.name}: ${value.message}`);\n }\n const text = String(value);\n return text === \"[object Object]\" ? UNSERIALIZABLE : redactString(text);\n}\n\nfunction redact(\n value: unknown,\n depth = 0,\n seen = new WeakSet<object>(),\n): unknown {\n if (value === null) return value;\n if (typeof value === \"string\") return redactString(value);\n if (typeof value !== \"object\") return value;\n if (seen.has(value)) return CIRCULAR;\n if (depth >= MAX_DEPTH) return MAX_DEPTH_MARKER;\n if (value instanceof Date) return redactString(value.toISOString());\n if (value instanceof Map) {\n seen.add(value);\n const entries: [PropertyKey, unknown][] = [];\n for (const [key, entry] of value) {\n entries.push([key as PropertyKey, entry]);\n }\n const output = redact(Object.fromEntries(entries), depth + 1, seen);\n seen.delete(value);\n return output;\n }\n if (value instanceof Set) {\n seen.add(value);\n const output = redact(Array.from(value), depth + 1, seen);\n seen.delete(value);\n return output;\n }\n if (Array.isArray(value)) {\n seen.add(value);\n const output = value.map((entry) => redact(entry, depth + 1, seen));\n seen.delete(value);\n return output;\n }\n if (!isPlainObject(value)) {\n return leafValue(value);\n }\n seen.add(value);\n const output: Record<string, unknown> = {};\n for (const [key, entry] of Object.entries(value as Record<string, unknown>)) {\n if (UNSAFE_KEYS.has(key)) continue;\n output[key] = isSensitiveKey(key) ? REDACTED : redact(entry, depth + 1, seen);\n }\n seen.delete(value);\n return output;\n}\n\nfunction serializedByteLength(value: unknown): number {\n try {\n const serialized = JSON.stringify(value);\n return serialized === undefined ? 0 : Buffer.byteLength(serialized);\n } catch {\n return PLATFORM_AUDIT_MAX_CAPTURE_BYTES + 1;\n }\n}\n\n/** Bounds a redacted payload to the capture budget with a truncation marker. */\nfunction capCapture(\n value: unknown,\n): Record<string, unknown> {\n const bytes = serializedByteLength(value);\n if (bytes > PLATFORM_AUDIT_MAX_CAPTURE_BYTES) {\n return { truncated: true, bytes };\n }\n return value as Record<string, unknown>;\n}\n\n/** Redact a value using the same rules as platform audit (no size cap). */\nexport function redactAuditValue(value: unknown): unknown {\n return redact(value);\n}\n\n/** Redact and bound a value to the platform audit capture budget. */\nexport function redactAndCapAuditValue(\n value: unknown,\n maxBytes = PLATFORM_AUDIT_MAX_CAPTURE_BYTES,\n): unknown {\n const redacted = redact(value);\n const bytes = serializedByteLength(redacted);\n return bytes > maxBytes ? { truncated: true, bytes } : redacted;\n}\n\nexport class PlatformAuditService {\n constructor(private readonly store: PlatformAuditStore) {}\n\n async record(input: PlatformAuditAppendInput): Promise<PlatformAuditRecord> {\n return this.store.append({\n ...input,\n summary: capCapture(redact(input.summary)),\n ...(input.before\n ? { before: capCapture(redact(input.before)) }\n : {}),\n ...(input.after\n ? { after: capCapture(redact(input.after)) }\n : {}),\n });\n }\n\n async get(id: string): Promise<PlatformAuditRecord | null> {\n return this.store.get(id);\n }\n\n async query(params: PlatformAuditQuery): Promise<PlatformAuditRecord[]> {\n return this.store.query(params);\n }\n}\n"],"mappings":";AAeO,IAAM,mCAAmC,KAAK;AAErD,IAAM,WAAW;AACjB,IAAM,WAAW;AACjB,IAAM,mBAAmB;AACzB,IAAM,iBAAiB;AACvB,IAAM,YAAY;AAElB,IAAM,sBAAsB;AAAA,EAC1B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAEA,IAAM,cAAc,oBAAI,IAAI,CAAC,aAAa,eAAe,WAAW,CAAC;AAMrE,IAAM,uBAAuB;AAAA,EAC3B;AAAA,EACA;AACF;AAGA,IAAM,uBACJ;AAOF,SAAS,aAAa,OAAuB;AAC3C,MAAI,SAAS;AACb,aAAW,WAAW,sBAAsB;AAC1C,aAAS,OAAO,QAAQ,SAAS,cAAc;AAAA,EACjD;AACA,SAAO,OAAO,QAAQ,sBAAsB,iBAAiB;AAC/D;AAEA,SAAS,eAAe,KAAsB;AAC5C,QAAM,aAAa,IAAI,QAAQ,SAAS,EAAE,EAAE,YAAY;AACxD,SAAO,oBAAoB,KAAK,CAAC,aAAa,WAAW,SAAS,QAAQ,CAAC;AAC7E;AAEA,SAAS,cAAc,OAAwB;AAC7C,QAAM,YAAY,OAAO,eAAe,KAAK;AAC7C,SAAO,cAAc,OAAO,aAAa,cAAc;AACzD;AAEA,SAAS,UAAU,OAAwB;AACzC,MAAI,iBAAiB,OAAQ,QAAO,aAAa,MAAM,SAAS,CAAC;AACjE,MAAI,iBAAiB,IAAK,QAAO,aAAa,MAAM,SAAS,CAAC;AAC9D,MAAI,iBAAiB,OAAO;AAC1B,WAAO,aAAa,GAAG,MAAM,IAAI,KAAK,MAAM,OAAO,EAAE;AAAA,EACvD;AACA,QAAM,OAAO,OAAO,KAAK;AACzB,SAAO,SAAS,oBAAoB,iBAAiB,aAAa,IAAI;AACxE;AAEA,SAAS,OACP,OACA,QAAQ,GACR,OAAO,oBAAI,QAAgB,GAClB;AACT,MAAI,UAAU,KAAM,QAAO;AAC3B,MAAI,OAAO,UAAU,SAAU,QAAO,aAAa,KAAK;AACxD,MAAI,OAAO,UAAU,SAAU,QAAO;AACtC,MAAI,KAAK,IAAI,KAAK,EAAG,QAAO;AAC5B,MAAI,SAAS,UAAW,QAAO;AAC/B,MAAI,iBAAiB,KAAM,QAAO,aAAa,MAAM,YAAY,CAAC;AAClE,MAAI,iBAAiB,KAAK;AACxB,SAAK,IAAI,KAAK;AACd,UAAM,UAAoC,CAAC;AAC3C,eAAW,CAAC,KAAK,KAAK,KAAK,OAAO;AAChC,cAAQ,KAAK,CAAC,KAAoB,KAAK,CAAC;AAAA,IAC1C;AACA,UAAMA,UAAS,OAAO,OAAO,YAAY,OAAO,GAAG,QAAQ,GAAG,IAAI;AAClE,SAAK,OAAO,KAAK;AACjB,WAAOA;AAAA,EACT;AACA,MAAI,iBAAiB,KAAK;AACxB,SAAK,IAAI,KAAK;AACd,UAAMA,UAAS,OAAO,MAAM,KAAK,KAAK,GAAG,QAAQ,GAAG,IAAI;AACxD,SAAK,OAAO,KAAK;AACjB,WAAOA;AAAA,EACT;AACA,MAAI,MAAM,QAAQ,KAAK,GAAG;AACxB,SAAK,IAAI,KAAK;AACd,UAAMA,UAAS,MAAM,IAAI,CAAC,UAAU,OAAO,OAAO,QAAQ,GAAG,IAAI,CAAC;AAClE,SAAK,OAAO,KAAK;AACjB,WAAOA;AAAA,EACT;AACA,MAAI,CAAC,cAAc,KAAK,GAAG;AACzB,WAAO,UAAU,KAAK;AAAA,EACxB;AACA,OAAK,IAAI,KAAK;AACd,QAAM,SAAkC,CAAC;AACzC,aAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,KAAgC,GAAG;AAC3E,QAAI,YAAY,IAAI,GAAG,EAAG;AAC1B,WAAO,GAAG,IAAI,eAAe,GAAG,IAAI,WAAW,OAAO,OAAO,QAAQ,GAAG,IAAI;AAAA,EAC9E;AACA,OAAK,OAAO,KAAK;AACjB,SAAO;AACT;AAEA,SAAS,qBAAqB,OAAwB;AACpD,MAAI;AACF,UAAM,aAAa,KAAK,UAAU,KAAK;AACvC,WAAO,eAAe,SAAY,IAAI,OAAO,WAAW,UAAU;AAAA,EACpE,QAAQ;AACN,WAAO,mCAAmC;AAAA,EAC5C;AACF;AAGA,SAAS,WACP,OACyB;AACzB,QAAM,QAAQ,qBAAqB,KAAK;AACxC,MAAI,QAAQ,kCAAkC;AAC5C,WAAO,EAAE,WAAW,MAAM,MAAM;AAAA,EAClC;AACA,SAAO;AACT;AAQO,SAAS,uBACd,OACA,WAAW,kCACF;AACT,QAAM,WAAW,OAAO,KAAK;AAC7B,QAAM,QAAQ,qBAAqB,QAAQ;AAC3C,SAAO,QAAQ,WAAW,EAAE,WAAW,MAAM,MAAM,IAAI;AACzD;AAEO,IAAM,uBAAN,MAA2B;AAAA,EAChC,YAA6B,OAA2B;AAA3B;AAAA,EAA4B;AAAA,EAEzD,MAAM,OAAO,OAA+D;AAC1E,WAAO,KAAK,MAAM,OAAO;AAAA,MACvB,GAAG;AAAA,MACH,SAAS,WAAW,OAAO,MAAM,OAAO,CAAC;AAAA,MACzC,GAAI,MAAM,SACN,EAAE,QAAQ,WAAW,OAAO,MAAM,MAAM,CAAC,EAAE,IAC3C,CAAC;AAAA,MACL,GAAI,MAAM,QACN,EAAE,OAAO,WAAW,OAAO,MAAM,KAAK,CAAC,EAAE,IACzC,CAAC;AAAA,IACP,CAAC;AAAA,EACH;AAAA,EAEA,MAAM,IAAI,IAAiD;AACzD,WAAO,KAAK,MAAM,IAAI,EAAE;AAAA,EAC1B;AAAA,EAEA,MAAM,MAAM,QAA4D;AACtE,WAAO,KAAK,MAAM,MAAM,MAAM;AAAA,EAChC;AACF;","names":["output"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{k as R}from"./embed-page-chunk-32KEPBH4.js";import"./embed-page-chunk-U6PURUXV.js";import"./embed-page-chunk-HGFIZATQ.js";import"./embed-page-chunk-A4EW4WEZ.js";import"./embed-page-chunk-XGZYUTPS.js";import"./embed-page-chunk-I6Q3MSI4.js";import"./embed-page-chunk-7EEAFSMK.js";import"./embed-page-chunk-S4XZPBRM.js";import"./embed-page-chunk-IKESLNJH.js";import{U as L,h as E}from"./embed-page-chunk-HJYCGHWQ.js";import{a as P}from"./embed-page-chunk-A4I7H7RP.js";import"./embed-page-chunk-F5RPCW5O.js";import"./embed-page-chunk-FYIVKZA2.js";import"./embed-page-chunk-Q54ZBF3I.js";import"./embed-page-chunk-CSRF4YQD.js";import"./embed-page-chunk-BNA3NXXX.js";import{o as C}from"./embed-page-chunk-36VOH7DG.js";import{a as F}from"./embed-page-chunk-L2PNY33P.js";import"./embed-page-chunk-DLSQ2OWQ.js";import"./embed-page-chunk-F52TPGBP.js";import"./embed-page-chunk-WMHFEZXB.js";import{Ha as I,Ra as T,ba as p,fa as m,ha as b}from"./embed-page-chunk-QWLZN3EX.js";import{a as O}from"./embed-page-chunk-MPQBYKDM.js";import"./embed-page-chunk-3KBY77YU.js";import"./embed-page-chunk-U2CG7PH5.js";import{e as u}from"./embed-page-chunk-45A47GH2.js";var n=u(O());var t=u(F()),$={component_key:"workspace_assistants",data:{}},J=d=>{let i=d;if(typeof d=="string")try{i=JSON.parse(d)}catch{return{}}return i!==null&&typeof i=="object"&&!Array.isArray(i)?i:{}},X=({data:d})=>{let{message:i}=b.useApp(),{assistantId:l,initialTab:B}=d??{},{get:f,put:A,del:y}=P(),e=C(),v=E(),[g,w]=(0,n.useState)(null),[_,h]=(0,n.useState)([]),[j,S]=(0,n.useState)(!1),[x,k]=(0,n.useState)(null),c=(0,n.useCallback)(()=>{v({...$,message:e("governance.detail.listCardMessage")})},[v,e]),o=(0,n.useCallback)(async()=>{S(!0),k(null);try{let s=(await f("/api/assistants")).data?.records??[];h(s),w(s.find(r=>r.id===l)??null)}catch{k(e("governance.detail.loadFailed"))}finally{S(!1)}},[f,l,e]);(0,n.useEffect)(()=>{l&&o()},[o,l]);let z=(0,n.useCallback)(async(a,s)=>{let r=J(a.graphDefinition),D;try{D=await A(`/api/assistants/${a.id}`,{name:s.name!==void 0?s.name:a.name,description:s.description!==void 0?s.description:a.description,graphDefinition:{...r,...s}})}catch(N){throw i.error(e("governance.detail.saveFailed")),N}if(!D.success)throw i.error(e("governance.detail.saveFailed")),new Error("Failed to save agent");i.success(e("common.saved")),await o()},[A,o,e]),U=(0,n.useCallback)(a=>{w(s=>s&&s.id===a.id?a:s),h(s=>s.map(r=>r.id===a.id?a:r))},[]),G=(0,n.useCallback)(async a=>{if(!(await y(`/api/assistants/${a}`)).success)throw new Error("Failed to delete agent");i.success(e("governance.detail.deleted")),c()},[y,c,e]);return l?g?(0,t.jsx)("div",{style:{height:"100%",overflow:"auto"},children:(0,t.jsx)(L,{children:(0,t.jsx)(R,{assistant:g,allAssistants:_,onBack:c,onDeleted:G,onSave:z,onAssistantUpdated:U,onAgentListInvalidated:()=>void o(),initialTab:B})},g.id)}):j?(0,t.jsx)("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",height:"100%"},children:(0,t.jsx)(T,{})}):x?(0,t.jsx)("div",{style:{padding:24},children:(0,t.jsx)(p,{type:"error",showIcon:!0,message:e("governance.detail.loadFailed"),"data-testid":"detail-error",action:(0,t.jsxs)(I,{children:[(0,t.jsx)(m,{size:"small",onClick:()=>void o(),children:e("common.retry")}),(0,t.jsx)(m,{size:"small",type:"primary",onClick:c,children:e("governance.detail.backToList")})]})})}):(0,t.jsx)("div",{style:{padding:24},children:(0,t.jsx)(p,{type:"warning",showIcon:!0,message:e("governance.detail.notFound"),"data-testid":"detail-not-found",action:(0,t.jsx)(m,{size:"small",type:"primary",onClick:c,children:e("governance.detail.backToList")})})}):(0,t.jsx)("div",{style:{padding:24},children:(0,t.jsx)(p,{type:"warning",showIcon:!0,message:e("governance.detail.missingId"),"data-testid":"detail-missing-id"})})};export{X as AgentDetailSideApp};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as Ie,b as De,c as xt,d as wt,e as Tt,f as It,g as St,h as Ft,i as Pt,j as Rt,k as Dt}from"./embed-page-chunk-32KEPBH4.js";import"./embed-page-chunk-U6PURUXV.js";import{a as Ge}from"./embed-page-chunk-HGFIZATQ.js";import"./embed-page-chunk-A4EW4WEZ.js";import"./embed-page-chunk-XGZYUTPS.js";import"./embed-page-chunk-I6Q3MSI4.js";import{b as Ve,e as _e,f as yt,g as ht,h as Ct,i as At,l as bt,m as kt}from"./embed-page-chunk-7EEAFSMK.js";import{a as dt,b as gt,c as pt,d as mt,e as ut}from"./embed-page-chunk-SV2BM3WO.js";import"./embed-page-chunk-S4XZPBRM.js";import"./embed-page-chunk-IKESLNJH.js";import{U as vt,e as ct,h as ft,r as Oe}from"./embed-page-chunk-HJYCGHWQ.js";import{a as me}from"./embed-page-chunk-A4I7H7RP.js";import{f as lt}from"./embed-page-chunk-F5RPCW5O.js";import"./embed-page-chunk-FYIVKZA2.js";import"./embed-page-chunk-Q54ZBF3I.js";import{o as Ye}from"./embed-page-chunk-CSRF4YQD.js";import{C as tt,La as rt,Q as nt,U as at,ba as ot,n as Te,oa as it,ua as st}from"./embed-page-chunk-BNA3NXXX.js";import{o as z}from"./embed-page-chunk-36VOH7DG.js";import{a as D}from"./embed-page-chunk-L2PNY33P.js";import"./embed-page-chunk-DLSQ2OWQ.js";import"./embed-page-chunk-F52TPGBP.js";import{Ja as et,Q as Qe,g as Je,na as Re,za as Xe}from"./embed-page-chunk-WMHFEZXB.js";import{Ba as Le,Ca as qe,Ea as He,Ha as $e,La as F,Qa as O,Sa as Ne,Ua as pe,_a as We,fa as $,fb as we,gb as Ze,ha as Fe,jb as J,ma as xe,oa as Ue,ua as Pe}from"./embed-page-chunk-QWLZN3EX.js";import{a as ge}from"./embed-page-chunk-MPQBYKDM.js";import"./embed-page-chunk-3KBY77YU.js";import"./embed-page-chunk-U2CG7PH5.js";import{e as T}from"./embed-page-chunk-45A47GH2.js";var C=T(ge());var X=T(ge());var W=T(ge());var Mt=T(ge());var ie=T(D()),Et=60,Kt=72,ze=(0,Mt.memo)(({data:a})=>{let c=Ie(a.type),f=Math.min(12+Math.sqrt(a.subAgentCount)*10,48);return(0,ie.jsxs)("div",{style:{display:"flex",flexDirection:"column",alignItems:"center"},children:[(0,ie.jsx)(_e,{type:"target",position:Ve.Top,style:{left:"50%",top:"50%",transform:"translate(-50%, -50%)",background:"transparent",border:"none",width:0,height:0},isConnectable:!1}),(0,ie.jsx)("div",{title:a.label,style:{width:f,height:f,borderRadius:"50%",background:De(c.color),display:"flex",alignItems:"center",justifyContent:"center",color:"#fff",fontSize:Math.max(10,f*.4),fontWeight:600,cursor:"pointer",boxShadow:"0 2px 8px rgba(0,0,0,0.15)"},children:a.label.charAt(0).toUpperCase()}),(0,ie.jsx)("div",{style:{fontSize:11,maxWidth:120,textAlign:"center",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",marginTop:4},children:a.label}),(0,ie.jsx)(_e,{type:"source",position:Ve.Top,style:{left:"50%",top:"50%",transform:"translate(-50%, -50%)",background:"transparent",border:"none",width:0,height:0},isConnectable:!1})]})});ze.displayName="AgentGraphNode";var Q=T(D()),tn=({assistants:a,onNodeClick:c})=>{let[f,A,d]=Ct([]),[g,i,e]=At([]),[l,I]=(0,W.useState)(null),m=(0,W.useMemo)(()=>({agent:ze}),[]),R=(0,W.useMemo)(()=>Tt(a),[a]);(0,W.useEffect)(()=>{let u=R.nodes.map(o=>({id:o.id})),P=R.edges.map(o=>({source:o.source,target:o.target})),M=new Map(R.nodes.map(o=>[o.id,o])),_=mt(u).force("link",pt(P).id(o=>o.id).distance(80)).force("charge",ut().strength(-220)).force("center",dt(0,0)).force("collide",gt(45)).stop();for(let o=0;o<300;o++)_.tick();let q=u.map(o=>({id:o.id,type:"agent",data:M.get(o.id),position:{x:o.x-Et/2,y:o.y-Kt/2}})),r=R.edges.map(o=>({id:`e${o.source}-${o.target}`,source:o.source,target:o.target,style:{stroke:"#1677ff",strokeWidth:2},type:"straight"}));A(q),i(r)},[R,A,i]);let U=(0,W.useMemo)(()=>l===null?f:f.map(u=>{let P=u.id===l||g.some(M=>M.source===l&&M.target===u.id||M.target===l&&M.source===u.id);return{...u,style:{opacity:P?1:.2,transition:"opacity 0.2s ease"}}}),[f,g,l]),y=(0,W.useMemo)(()=>l===null?g.map(u=>({...u,style:{stroke:"#1677ff",strokeWidth:1.5,opacity:.25,transition:"opacity 0.2s ease"}})):g.map(u=>{let P=u.source===l||u.target===l;return{...u,style:{stroke:"#1677ff",strokeWidth:P?2.5:1,opacity:P?1:.04,transition:"opacity 0.2s ease"}}}),[g,l]);return(0,Q.jsx)("div",{style:{width:"100%",height:"100%",background:"#fafafa",position:"relative"},children:(0,Q.jsxs)(ht,{nodes:U,edges:y,onNodesChange:d,onEdgesChange:e,onNodeMouseEnter:(u,P)=>I(P.id),onNodeMouseLeave:()=>I(null),onNodeClick:(u,P)=>c?.(String(P.id)),nodeTypes:m,fitView:!0,fitViewOptions:{padding:.25},children:[(0,Q.jsx)(bt,{color:"#eee",gap:20}),(0,Q.jsx)(kt,{})]})})},Bt=a=>(0,Q.jsx)(yt,{children:(0,Q.jsx)(tn,{...a})});var w=T(D()),nn=[{key:"all",labelKey:"governance.list.tab.all"},{key:"capability",labelKey:"governance.list.tab.capability"},{key:"orchestrator",labelKey:"governance.list.tab.orchestrator"},{key:"workflow",labelKey:"governance.list.tab.workflow"}],Lt=({items:a,assistants:c=[],loading:f,onItemClick:A,onOpenPlayground:d,onOpenEval:g,onCreate:i,onDelete:e})=>{let l=z(),[I,m]=(0,X.useState)("all"),[R,U]=(0,X.useState)(null),[y,u]=(0,X.useState)(null),P=(0,X.useMemo)(()=>{let r=new Set;return a.forEach(o=>o.tags.forEach(te=>r.add(te))),Array.from(r).map(o=>({value:o,label:o}))},[a]),M=(0,X.useMemo)(()=>a.filter(r=>!(I!=="all"&&r.type!==I||R&&!r.tags.includes(R)||y&&r.status!==y)),[a,I,R,y]),_=[{key:"edit",icon:st,label:l("common.edit"),onClick:r=>A(r.id)},{key:"playground",icon:tt,label:l("governance.list.action.playground"),onClick:r=>d(r.id)},{key:"eval",icon:at,label:l("governance.list.action.eval"),onClick:r=>g(r.id)}];e&&_.push({key:"delete",icon:rt,label:l("common.delete"),danger:!0,onClick:r=>e(r.id)});let q=(0,X.useMemo)(()=>[{mode:"graph",icon:it,label:l("governance.list.viewMode.graph"),render:()=>(0,w.jsx)(Bt,{assistants:c,onNodeClick:A})}],[c,A,l]);return(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)("span",{"data-testid":"agent-list-state","data-loading":String(f),"data-count":M.length,hidden:!0,"aria-hidden":"true"}),(0,w.jsx)(ct,{title:l("governance.list.title"),itemName:"common.item.agent",items:M,loading:f,keyExtractor:r=>r.id,tabs:nn.map(r=>({key:r.key,label:l(r.labelKey)})),activeTab:I,onTabChange:r=>m(r),headerLeft:(0,w.jsxs)("div",{style:{display:"flex",gap:8,alignItems:"center"},children:[(0,w.jsx)(Oe,{value:R,onChange:U,options:P,placeholder:l("governance.list.filter.domain"),allLabel:l("governance.list.filter.allDomains")}),(0,w.jsx)(Oe,{value:y,onChange:u,options:[{value:"enabled",label:l("governance.list.status.enabled")},{value:"draft",label:l("governance.list.status.draft")},{value:"disabled",label:l("governance.list.status.disabled")}],placeholder:l("governance.list.filter.status"),allLabel:l("governance.list.filter.allStatuses")})]}),renderIcon:r=>{let o=De(Ie(r.type).color);return(0,w.jsx)("div",{title:l("governance.list.typeIconTitle",{type:r.type}),style:{width:32,height:32,borderRadius:8,background:`${o}1A`,color:o,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:(0,w.jsx)(Te,{size:18})})},renderPrimary:r=>(0,w.jsx)("span",{"data-testid":"agent-name","data-agent-id":r.id,children:r.name}),renderSecondary:r=>r.description||void 0,renderDetails:r=>(0,w.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",gap:8,flexWrap:"wrap"},children:[(0,w.jsxs)("div",{style:{display:"flex",gap:4,flexWrap:"wrap",alignItems:"center"},children:[r.tags.map(o=>(0,w.jsx)(we,{color:"magenta",style:{margin:0,borderRadius:10,border:"none"},children:o},o)),(0,w.jsx)(we,{color:Ie(r.type).color,style:{margin:0,borderRadius:10,border:"none"},children:r.type})]}),(0,w.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,flexShrink:0},children:[(0,w.jsx)(Ue,{title:l("governance.list.statusTooltip",{status:r.status}),children:(0,w.jsx)("span",{style:{width:8,height:8,borderRadius:"50%",background:xt(r.status),display:"inline-block",cursor:"help"}})}),(0,w.jsx)("span",{style:{fontSize:12,color:"#8c8c8c"},children:r.version})]})]}),itemActions:_,actionsStyle:"icon",actionsPosition:"hover",onItemClick:r=>A(r.id),createLabel:l("governance.list.create"),onCreateClick:i,viewModeExtensions:q,emptyIcon:(0,w.jsx)(Te,{size:48,style:{opacity:.5}}),emptyTitle:l("governance.list.emptyTitle"),emptyDescription:l("governance.list.emptyDescription")})]})};var b=T(ge());var se=T(ge());var ue=T(D()),{Text:an}=J,Nt=({onSelect:a,value:c,placeholder:f})=>{let A=z(),d=f??A("chatConfig.parentAgent.selectPlaceholder"),[g,i]=(0,se.useState)([]),[e,l]=(0,se.useState)(!1),{get:I}=me(),m=(0,se.useCallback)(async()=>{l(!0);try{let y=await I("/api/assistants");y.success&&i(y.data?.records||[])}catch(y){console.error("Failed to fetch assistants:",y)}finally{l(!1)}},[I]);return(0,se.useEffect)(()=>{m()},[m]),(0,ue.jsx)(xe,{showSearch:!0,allowClear:!0,value:c,placeholder:d,loading:e,onChange:y=>{if(!y){a(null);return}let u=g.find(P=>P.id===y);a(u||null)},onDropdownVisibleChange:y=>{y&&m()},optionFilterProp:"label",style:{width:"100%"},options:g.map(y=>({value:y.id,label:y.name||y.id,description:y.description})),optionRender:y=>(0,ue.jsxs)("div",{children:[(0,ue.jsx)("div",{children:y.label}),y.data.description&&(0,ue.jsx)(an,{type:"secondary",style:{fontSize:12},children:y.data.description})]})})};var B=T(D()),{Text:Ot}=J,Vt=({subAgentKeys:a,decisions:c,onChange:f})=>{let{token:A}=Ze.useToken(),d=z(),g=(e,l)=>{let I=c.map(m=>m.originalKey===e?{...m,clone:l,cloneKey:l?`${e}_clone`:void 0}:m);f(I)},i=(e,l)=>{let I=c.map(m=>m.originalKey===e?{...m,cloneKey:l}:m);f(I)};return a.length===0?null:(0,B.jsxs)("div",{children:[(0,B.jsx)(Ot,{type:"secondary",style:{display:"block",marginBottom:8},children:d("chatConfig.subAgentInherit.hint")}),(0,B.jsx)(Ne,{size:"small",bordered:!0,dataSource:c,style:{borderRadius:A.borderRadius},renderItem:e=>(0,B.jsxs)(Ne.Item,{style:{display:"flex",flexDirection:"column",alignItems:"stretch",gap:8,padding:"8px 16px"},children:[(0,B.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[(0,B.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.clone?(0,B.jsx)(Re,{style:{color:A.colorPrimary}}):(0,B.jsx)(Xe,{style:{color:A.colorTextSecondary}}),(0,B.jsx)(Ot,{style:{fontFamily:"monospace"},children:e.originalKey})]}),(0,B.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8},children:[(0,B.jsx)(we,{color:e.clone?"blue":"default",children:e.clone?d("chatConfig.subAgentInherit.clone"):d("chatConfig.subAgentInherit.reuse")}),(0,B.jsx)(We,{size:"small",checked:e.clone,onChange:l=>g(e.originalKey,l)})]})]}),e.clone&&(0,B.jsx)(O,{size:"small",placeholder:d("chatConfig.subAgentInherit.cloneKeyPlaceholder"),value:e.cloneKey,onChange:l=>i(e.originalKey,l.target.value),style:{fontFamily:"monospace",fontSize:12},addonBefore:d("chatConfig.keyValue.key")})]})})]})};function _t(a,c){return a.mode!=="local"||a.templateKey||typeof a.executable=="string"&&a.executable.trim().length>0?null:c?c("chat.config.executableRequired"):"Choose a template or enter a custom executable"}var n=T(D()),{TextArea:Gt}=O,{Text:ee}=J,zt="/.well-known/agent-card.json",on=[{value:"http://",label:"http://"},{value:"https://",label:"https://"}],sn={react:"chatConfig.createAssistant.typeDesc.react",deep_agent:"chatConfig.createAssistant.typeDesc.deepAgent",a2a_remote:"chatConfig.createAssistant.typeDesc.a2aRemote"};function jt(a,c,f="https://"){let A=String(a??"").trim();if(!A)return"";let d=c==="http://"||c==="https://"?c:f,i=(/^https?:\/\//i.test(A)?A:`${d}${A.replace(/^\/+/,"")}`).replace(/\/+$/,"");return i.endsWith(zt)?i:`${i}${zt}`}function rn(a){try{return new URL(a).port||void 0}catch{return}}function ln(a){return a.some(c=>c==="--port"||c==="-p"||/^--port=/.test(c)||/^-p=/.test(c))}function Ut(a,c){let f=[...a.args],A=rn(c);return A&&!ln(f)&&f.push("--port",A),{...a,args:f,...a.env?{env:{...a.env}}:{}}}var qt=({open:a,onCancel:c,onSuccess:f,initialMode:A,initialValues:d})=>{let{message:g}=Fe.useApp(),[i]=F.useForm(),e=z(),[l,I]=(0,b.useState)(!1),[m,R]=(0,b.useState)("learn"),[U,y]=(0,b.useState)(""),[u,P]=(0,b.useState)(null),[M,_]=(0,b.useState)([]),q=F.useWatch("type",i)||"react",r=q==="a2a_remote",[o,te]=(0,b.useState)("remote"),[H,fe]=(0,b.useState)(void 0),[re,ye]=(0,b.useState)([]),[Se,le]=(0,b.useState)(!1),ne=(0,b.useRef)(0),[ae,oe]=(0,b.useState)(!1),[Me,Z]=(0,b.useState)(!1),{get:L,post:Y,put:he}=me(),Ee=Ye("agent-architect"),{workspaceId:Ce,trainingProjects:ce,loading:de}=lt(),[Ke,Ae]=(0,b.useState)(null),Be=JSON.stringify(d??null),E=ce.find(t=>t.id===Ke)??ce[0]??null,[be,ke]=(0,b.useState)([]),p=(0,b.useCallback)(()=>{P(null),_([])},[]),k=(0,b.useCallback)(()=>{i.resetFields(),p(),R("learn"),y(""),ke([]),Ae(null),te("remote"),fe(void 0),ye([]),Z(!1),oe(!1)},[i,p]);(0,b.useEffect)(()=>{if(a){k(),R(A??"learn");let t=d?.a2aMode;(t==="remote"||t==="local")&&te(t),i.setFieldsValue({type:"react",agentCardProtocol:"https://",a2aMode:"remote",timeout:3e5,...d})}},[a,i,A,Be,k]),(0,b.useEffect)(()=>{let t=++ne.current,s=!0;return a&&r?(i.setFieldValue("prompt",""),o==="local"?(le(!0),L("/api/local-a2a/templates").then(v=>{s&&t===ne.current&&v?.data?.records&&ye(v.data.records)}).catch(()=>{s&&t===ne.current&&ye([])}).finally(()=>{s&&t===ne.current&&le(!1)})):le(!1)):le(!1),()=>{s=!1,ne.current+=1}},[i,r,o,L,a]);let x=re.find(t=>t.key===H),j=(0,b.useCallback)(()=>{let t=_t({mode:o,templateKey:H,executable:i.getFieldValue("commandExecutable")},e);return t?(Z(!0),i.setFields([{name:"commandExecutable",errors:[t]}]),g.warning(t),!1):!0},[o,H,i,e]);(0,b.useEffect)(()=>{x&&i.setFieldsValue({agentCardProtocol:"http://"})},[i,x]);let ve=(0,b.useCallback)(async()=>{if(!j())return;let t=jt(i.getFieldValue("agentCardUrl"),i.getFieldValue("agentCardProtocol"),o==="local"?"http://":"https://");if(!t){g.warning(e("chatConfig.createAssistant.a2aUrlWarning"));return}oe(!0);try{let s={agentCardUrl:t,apiKey:i.getFieldValue("apiKey")};if(o==="local"){let h=x;if(h)s.localRuntime={label:i.getFieldValue("name")||void 0,agentCardUrl:t,command:Ut(h.command,t)};else{let K=i.getFieldValue("commandArgs")||"",G=K?K.split(/\s+/).filter(Boolean):[],S=String(i.getFieldValue(["command","cwd"])||"").trim();s.localRuntime={label:i.getFieldValue("name")||void 0,agentCardUrl:t,command:{executable:String(i.getFieldValue("commandExecutable")||"").trim(),args:G,...S?{cwd:S}:{}}}}}let v=await Y("/api/a2a/test-connection",s);if(v.data?.reachable){let h=v.data.agentCard;g.success(e("chatConfig.createAssistant.connectedTo",{name:v.data.agentName||t}))}else g.error(v.data?.error||e("chatConfig.createAssistant.connectionFailed"))}catch{g.error(e("chatConfig.createAssistant.connectionTestFailed"))}finally{oe(!1)}},[i,Y,o,x,j,e]),Wt=(0,b.useCallback)(t=>{if(P(t),!t){i.resetFields(["key","name","description","type","prompt"]),_([]);return}let s=typeof t.graphDefinition=="object"&&t.graphDefinition!==null?t.graphDefinition:{},v=s.key||t.id,h=t.name||s.name||"";i.setFieldsValue({key:`${v}_ext`,name:h?`${h} (Extended)`:"",description:t.description||s.description||"",type:s.type||"react",prompt:s.prompt||""});let K=s.subAgents||[];_(K.map(G=>({originalKey:G,clone:!1})))},[i]),Zt=async(t,s)=>{let v=await L(`/api/assistants/${t}`);if(!v.success)throw new Error(e("chatConfig.createAssistant.cloneFetchFailed",{key:t}));let h=v.data,K=typeof h.graphDefinition=="object"?h.graphDefinition:{},G={id:s,name:`${h.name} (Clone)`,description:h.description||"",graphDefinition:{...K,key:s,name:`${h.name} (Clone)`}},S=await Y("/api/assistants",G);if(!S.success)throw new Error(S.message||e("chatConfig.createAssistant.cloneFailed",{key:t}));return S.data},Yt=t=>{let s={id:t.key,name:t.name,description:t.description||"",graphDefinition:{key:t.key,name:t.name,description:t.description||"",type:t.type,prompt:t.prompt||"",tools:[],skills:[],subAgents:t.type==="deep_agent"?[]:void 0,middleware:[]}};if(t.type==="a2a_remote"&&(s.graphDefinition.agentCardUrl=jt(t.agentCardUrl,t.agentCardProtocol,(t.a2aMode||o)==="local"?"http://":"https://"),t.apiKey&&(s.graphDefinition.apiKey=t.apiKey),t.timeout&&(s.graphDefinition.timeout=t.timeout),(t.a2aMode||o)==="local")){let v=x;if(v)s.graphDefinition.localRuntime={label:t.name||void 0,agentCardUrl:s.graphDefinition.agentCardUrl,command:Ut(v.command,s.graphDefinition.agentCardUrl)};else{let h=t.commandArgs||"",K=h?h.split(/\s+/).filter(Boolean):[],G=String(t.command?.cwd||"").trim();s.graphDefinition.localRuntime={label:t.name||void 0,agentCardUrl:s.graphDefinition.agentCardUrl,command:{executable:String(t.commandExecutable||"").trim(),args:K,...G?{cwd:G}:{}}}}}return s},Jt=async(t,s)=>{if(!u)throw new Error(e("chatConfig.createAssistant.noParentAgent"));let v=M.filter(S=>S.clone);for(let S of v){if(!S.cloneKey||!S.cloneKey.trim())throw new Error(e("chatConfig.createAssistant.cloneKeyRequired",{key:S.originalKey}));if(!/^[a-zA-Z][a-zA-Z0-9_-]*$/.test(S.cloneKey))throw new Error(e("chatConfig.createAssistant.cloneKeyInvalid",{key:S.cloneKey,originalKey:S.originalKey}))}let h=[];for(let S of M)if(S.clone){let en=await Zt(S.originalKey,S.cloneKey);s.push(en),h.push(S.cloneKey)}else h.push(S.originalKey);let K=typeof u.graphDefinition=="object"?u.graphDefinition:{},G={key:t.key,name:t.name,description:t.description||"",extendsAgent:u.id,type:t.type||K.type};return t.prompt&&t.prompt!==K.prompt&&(G.prompt=t.prompt),(h.length>0||K.subAgents&&K.subAgents.length>0)&&(G.subAgents=h),{id:t.key,name:t.name,description:t.description||"",graphDefinition:G}},Qt=async()=>{if(m==="learn"){let t=U.trim();if(!t){g.error(e("chatConfig.createAssistant.trainingGoalRequired"));return}if(!E){g.error(e("chatConfig.createAssistant.noTrainingProject"));return}I(!0);try{let s=`agent-${St(t+Date.now())}`,v=await Y("/api/assistants",{id:s,name:s,graphDefinition:{key:s,name:s,description:"",type:"react",prompt:"To be trained",metadata:{trainingProjectId:E.id,learningPlaceholder:"true",architectureStatus:"undecided"}}});if(!v.data)throw new Error(e("chatConfig.createAssistant.agentCreateFailed"));let{roundTaskId:h}=await Pt({goal:t,targetAgentId:s,workspaceId:Ce??void 0,projectId:E.id,existingThreadId:Ft(Ee.tenantId,s),files:be,post:Y,put:he});g.success(e("chatConfig.createAssistant.agentCreated")),y(""),ke([]),R("learn"),f?.(v.data,{initialMessage:Rt({goal:t,roundTaskId:h,targetAgentId:s,targetMode:"placeholder",files:be,projectId:E.id,workspaceId:E.workspaceId??Ce??void 0}),projectId:E.id,initialMessageCustomRunConfig:{execution:{taskId:h}}}),c()}catch(s){g.error(s instanceof Error?s.message:e("chatConfig.createAssistant.agentCreateFailed"))}finally{I(!1)}return}try{if(m==="scratch"&&r&&!j())return;let t=await i.validateFields();I(!0);let s=[],v=m==="scratch"?Yt(t):await Jt(t,s),h=await Y("/api/assistants",v);if(h.success){g.success(m==="extend"?e("chatConfig.createAssistant.createdByExtending",{name:u?.name??""}):e("chatConfig.createAssistant.created")),k();for(let K of s)f?.(K);f?.(h.data),c()}else g.error(h.message||e("chatConfig.createAssistant.createFailed"))}catch(t){if(t?.errorFields){let s={key:e("chatConfig.createAssistant.field.key"),name:e("chatConfig.createAssistant.field.name"),description:e("chatConfig.createAssistant.field.description"),prompt:e("chatConfig.createAssistant.field.systemPrompt")},v=t.errorFields.map(h=>s[String((h.name??[])[0])]??String((h.name??[])[0])).filter(Boolean);g.warning(v.length>0?e("chatConfig.createAssistant.requiredFields",{fields:[...new Set(v)].join(", ")}):e("chatConfig.createAssistant.requiredFieldsGeneric"));return}g.error(t.message||e("chatConfig.createAssistant.createError"))}finally{I(!1)}},je=u?.graphDefinition?.subAgents||[],Xt=m==="extend"&&u&&je.length>0;return(0,n.jsxs)(pe,{title:e("chatConfig.createAssistant.title"),open:a,onCancel:()=>{k(),c()},footer:[(0,n.jsx)($,{onClick:()=>{k(),c()},children:e("common.cancel")},"cancel"),(0,n.jsx)($,{type:"primary",icon:m==="extend"?(0,n.jsx)(Re,{}):m==="learn"?(0,n.jsx)(Qe,{}):(0,n.jsx)(et,{}),loading:l,disabled:m==="learn"&&(de||!E),onClick:Qt,children:e(m==="extend"?"chatConfig.createAssistant.createExtend":m==="learn"?"chatConfig.createAssistant.startLearning":"common.create")},"submit")],width:760,children:[m==="extend"&&(0,n.jsxs)("div",{style:{marginBottom:20},children:[(0,n.jsx)(ee,{type:"secondary",style:{display:"block",marginBottom:8},children:e("chatConfig.createAssistant.parentAgent")}),(0,n.jsx)(Nt,{value:u?.id,onSelect:Wt}),u&&(0,n.jsx)(ee,{type:"secondary",style:{display:"block",marginTop:4,fontSize:12},children:e("chatConfig.createAssistant.inheritHint")})]}),m==="extend"&&u&&(0,n.jsx)(Le,{style:{margin:"12px 0"}}),m==="learn"&&(0,n.jsxs)("div",{children:[(0,n.jsx)(ee,{style:{display:"block",marginBottom:8},children:e("chatConfig.createAssistant.learnHint")}),(0,n.jsx)(O.TextArea,{rows:3,value:U,onChange:t=>y(t.target.value),placeholder:e("chatConfig.createAssistant.learnGoalPlaceholder")}),E&&(0,n.jsxs)("div",{style:{marginTop:12},children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:12,marginBottom:8},children:[(0,n.jsx)(ee,{type:"secondary",children:e("chatConfig.createAssistant.referenceFiles")}),(0,n.jsx)(Ge,{project:E,value:E?.id??null,onChange:Ae,loading:de})]}),(0,n.jsx)(It,{projectId:E.id,value:be,onChange:ke}),(0,n.jsx)(ee,{type:"secondary",style:{display:"block",marginTop:6,fontSize:12},children:e("chatConfig.createAssistant.referenceFilesHint")})]}),!E&&!de&&(0,n.jsx)("div",{style:{marginTop:12},children:(0,n.jsx)(Ge,{project:E,value:null,onChange:Ae,loading:de})})]}),m!=="learn"&&(0,n.jsxs)(F,{form:i,layout:"vertical",autoComplete:"off",initialValues:{type:"react",agentCardProtocol:"https://",a2aMode:"remote"},children:[(0,n.jsx)(F.Item,{name:"key",label:e("chatConfig.createAssistant.field.key"),rules:[{required:!0,message:e("chatConfig.createAssistant.validation.keyRequired")},{pattern:/^[a-zA-Z][a-zA-Z0-9_-]*$/,message:e("chatConfig.createAssistant.validation.keyPattern")}],style:{marginBottom:16},children:(0,n.jsx)(O,{placeholder:e("chatConfig.createAssistant.keyPlaceholder")})}),(0,n.jsx)(F.Item,{name:"name",label:e("chatConfig.createAssistant.field.name"),rules:[{required:!0,message:e("chatConfig.createAssistant.validation.nameRequired")}],style:{marginBottom:16},children:(0,n.jsx)(O,{placeholder:e("chatConfig.createAssistant.namePlaceholder")})}),(0,n.jsx)(F.Item,{name:"description",label:e("chatConfig.createAssistant.field.description"),rules:[{required:!0,message:e("chatConfig.createAssistant.validation.descriptionRequired")}],style:{marginBottom:16},children:(0,n.jsx)(Gt,{placeholder:e("chatConfig.createAssistant.descriptionPlaceholder"),autoSize:{minRows:2,maxRows:4}})}),(0,n.jsx)(F.Item,{name:"type",label:e("chatConfig.createAssistant.field.agentType"),rules:[{required:!0}],style:{marginBottom:16},children:(0,n.jsx)(qe,{options:[{value:"react",label:e("chatConfig.agentType.executor")},{value:"deep_agent",label:e("chatConfig.agentType.orchestrator")},{value:"a2a_remote",label:e("chatConfig.agentType.a2aRemote")}],block:!0})}),(0,n.jsx)(ee,{type:"secondary",style:{fontSize:12,display:"block",marginTop:-12,marginBottom:16,lineHeight:1.5},children:e(sn[q]??"chatConfig.createAssistant.typeDesc.react")}),r&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(F.Item,{label:e("chatConfig.createAssistant.field.connectionMode"),style:{marginBottom:16},children:(0,n.jsxs)(Pe.Group,{value:o,onChange:t=>{let s=t.target.value;te(s),i.setFieldValue("a2aMode",s),s==="local"&&i.setFieldValue("agentCardProtocol","http://"),fe(void 0)},optionType:"button",buttonStyle:"solid",children:[(0,n.jsx)(Pe.Button,{value:"remote",children:e("chatConfig.createAssistant.mode.remoteUrl")}),(0,n.jsx)(Pe.Button,{value:"local",children:e("chatConfig.createAssistant.mode.localManaged")})]})}),(0,n.jsx)(F.Item,{name:"a2aMode",noStyle:!0,hidden:!0,children:(0,n.jsx)(O,{})}),o==="local"&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(F.Item,{label:e("chatConfig.createAssistant.field.template"),style:{marginBottom:16},children:(0,n.jsx)(xe,{placeholder:e("chatConfig.createAssistant.templatePlaceholder"),allowClear:!0,loading:Se,value:H,onChange:t=>{fe(t),t&&Z(!1)},options:re.map(t=>({value:t.key,label:t.name||t.key})),notFoundContent:Se?void 0:(0,n.jsx)(ee,{type:"secondary",style:{padding:8,display:"block"},children:e("chatConfig.createAssistant.noTemplates")})})}),!H&&(0,n.jsx)(n.Fragment,{children:Me?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(F.Item,{name:"commandExecutable",label:e("chatConfig.createAssistant.field.executable"),rules:[{required:!0,whitespace:!0,message:e("chatConfig.createAssistant.validation.executableRequired")}],style:{marginBottom:16},children:(0,n.jsx)(O,{placeholder:e("chatConfig.createAssistant.executablePlaceholder")})}),(0,n.jsx)(F.Item,{name:"commandArgs",label:e("chatConfig.createAssistant.field.arguments"),style:{marginBottom:16},children:(0,n.jsx)(O,{placeholder:e("chatConfig.createAssistant.argumentsPlaceholder")})}),(0,n.jsx)(F.Item,{name:["command","cwd"],label:e("chatConfig.createAssistant.field.workingDirectory"),style:{marginBottom:16},children:(0,n.jsx)(O,{placeholder:e("chatConfig.createAssistant.workingDirectoryPlaceholder")})}),(0,n.jsx)($,{type:"link",onClick:()=>{Z(!1),i.setFieldsValue({commandExecutable:"",commandArgs:"",command:{cwd:void 0}})},style:{padding:0,marginBottom:16,display:"block"},children:e("chatConfig.createAssistant.hideCustomCommand")})]}):(0,n.jsx)($,{type:"link",onClick:()=>Z(!0),style:{padding:0,marginBottom:16,display:"block"},children:e("chatConfig.createAssistant.customCommand")})})]}),(0,n.jsx)(F.Item,{label:e("chatConfig.createAssistant.field.agentCardUrl"),required:!0,style:{marginBottom:16},children:(0,n.jsxs)($e.Compact,{style:{width:"100%"},children:[(0,n.jsx)(F.Item,{name:"agentCardProtocol",noStyle:!0,children:(0,n.jsx)(xe,{style:{width:100},options:on})}),(0,n.jsx)(F.Item,{name:"agentCardUrl",noStyle:!0,rules:[{required:!0,message:e("chatConfig.createAssistant.validation.urlRequired")}],children:(0,n.jsx)(O,{placeholder:o==="local"?"localhost:4301":"host:port or full URL"})}),(0,n.jsx)($,{icon:(0,n.jsx)(Je,{}),onClick:ve,loading:ae,children:e("chatConfig.connection.action.test")})]})}),o==="remote"&&(0,n.jsx)(F.Item,{name:"apiKey",label:e("chatConfig.createAssistant.field.apiKeyOptional"),style:{marginBottom:16},children:(0,n.jsx)(O.Password,{placeholder:e("chatConfig.createAssistant.apiKeyPlaceholder")})}),(0,n.jsx)(F.Item,{name:"timeout",label:e("chatConfig.createAssistant.field.timeout"),style:{marginBottom:16},initialValue:3e5,children:(0,n.jsx)(He,{min:1e3,max:36e5,style:{width:"100%"},placeholder:"300000"})})]}),!r&&(0,n.jsx)(F.Item,{name:"prompt",label:e(m==="extend"&&u?"chatConfig.createAssistant.field.systemPromptInherit":"chatConfig.createAssistant.field.systemPrompt"),rules:m==="scratch"?[{required:!0,message:e("chatConfig.createAssistant.validation.systemPromptRequired")}]:[],children:(0,n.jsx)(Gt,{placeholder:e(m==="extend"&&u?"chatConfig.createAssistant.systemPromptInheritPlaceholder":"chatConfig.createAssistant.systemPromptPlaceholder"),autoSize:{minRows:4,maxRows:8},style:{fontFamily:"monospace",fontSize:13,lineHeight:1.6}})})]}),Xt&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(Le,{style:{margin:"12px 0"}}),(0,n.jsx)(ee,{strong:!0,style:{display:"block",marginBottom:8},children:e("chatConfig.createAssistant.subAgents")}),(0,n.jsx)(Vt,{subAgentKeys:je,decisions:M,onChange:_})]})]})};var N=T(D()),{Paragraph:cn,Text:Ht}=J,dn=[{key:"manual",icon:Te,titleKey:"governance.creation.manual.title",descriptionKey:"governance.creation.manual.description"},{key:"external",icon:nt,titleKey:"governance.creation.external.title",descriptionKey:"governance.creation.external.description"},{key:"learn",icon:ot,titleKey:"governance.creation.learn.title",descriptionKey:"governance.creation.learn.description"}],$t=({open:a,onCancel:c,onSelectMethod:f,focusTriggerAfterClose:A=!0})=>{let d=z();return(0,N.jsx)(pe,{title:d("governance.creation.title"),open:a,onCancel:c,footer:null,width:560,centered:!0,destroyOnHidden:!0,focusTriggerAfterClose:A,children:(0,N.jsxs)("div",{style:{padding:"8px 4px 4px"},children:[(0,N.jsx)(cn,{style:{color:"#595959",fontSize:15,margin:"8px 0 24px"},children:d("governance.creation.subtitle")}),(0,N.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:12},children:dn.map(g=>{let i=g.icon,e=d(g.titleKey);return(0,N.jsxs)($,{type:"default",onClick:()=>f(g.key),"aria-label":e,style:{display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"flex-start",gap:16,width:"100%",minHeight:88,height:"auto",padding:16,borderRadius:16,textAlign:"left",whiteSpace:"normal"},children:[(0,N.jsx)("div",{style:{width:40,height:40,borderRadius:12,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,color:"#6366f1",background:"#eeeeff"},children:(0,N.jsx)(i,{size:19})}),(0,N.jsxs)("div",{style:{minWidth:0},children:[(0,N.jsx)(Ht,{strong:!0,style:{display:"block",fontSize:15,marginBottom:3},children:e}),(0,N.jsx)(Ht,{style:{color:"#737373",lineHeight:1.5},children:d(g.descriptionKey)})]})]},g.key)})}),(0,N.jsx)("div",{style:{display:"flex",justifyContent:"flex-end",gap:8,flexWrap:"wrap",marginTop:24},children:(0,N.jsx)($,{onClick:c,children:d("governance.creation.notNow")})})]})})};var V=T(D()),gn=a=>{let c=a;if(typeof a=="string")try{c=JSON.parse(a)}catch{return{}}return c!==null&&typeof c=="object"&&!Array.isArray(c)?c:{}},va=()=>{let{message:a}=Fe.useApp(),{get:c,del:f,put:A}=me(),d=z(),[g,i]=(0,C.useState)([]),[e,l]=(0,C.useState)(!1),[I,m]=(0,C.useState)(null),[R,U]=(0,C.useState)("graph"),[y,u]=(0,C.useState)(null),[P,M]=(0,C.useState)(null),[_,q]=(0,C.useState)(null),[r,o]=(0,C.useState)(!1),[te,H]=(0,C.useState)(!0),[fe,re]=(0,C.useState)(!1),[ye,Se]=(0,C.useState)("learn"),[le,ne]=(0,C.useState)({}),[ae,oe]=(0,C.useState)(null),[Me,Z]=(0,C.useState)(!1),L=(0,C.useCallback)(async()=>{l(!0);try{let p=await c("/api/assistants");p.success&&p.data?.records&&i(p.data.records)}catch{a.error(d("governance.workbench.loadFailed"))}finally{l(!1)}},[c,d]);(0,C.useEffect)(()=>{L()},[L]);let Y=C.default.useMemo(()=>wt(g),[g]),he=g.find(p=>p.id===I)??null,Ee=(0,C.useCallback)((p,k="graph")=>{m(p),U(k),u(null),q(null)},[]),Ce=ft(),ce=(0,C.useCallback)((p,k)=>{let x=g.find(j=>j.id===p)?.name??d("governance.workbench.agentFallback");Ce({component_key:"agent_detail_side_app",data:{assistantId:p,initialTab:k},message:x})},[g,Ce,d]),de=(0,C.useCallback)(()=>{H(!0),o(!0)},[]),Ke=(0,C.useCallback)(p=>{let x={manual:{mode:"scratch",values:{}},external:{mode:"scratch",values:{type:"a2a_remote"}},learn:{mode:"learn",values:{}}}[p];Se(x.mode),ne(x.values),H(!1),o(!1),re(!0)},[]),Ae=(0,C.useCallback)(async(p,k)=>{let x=gn(p.graphDefinition),j;try{j=await A(`/api/assistants/${p.id}`,{name:k.name!==void 0?k.name:p.name,description:k.description!==void 0?k.description:p.description,graphDefinition:{...x,...k}})}catch(ve){throw a.error(d("governance.detail.saveFailed")),ve}if(!j.success)throw a.error(d("governance.detail.saveFailed")),new Error("Failed to save agent");a.success(d("common.saved")),L()},[A,L,d]),Be=(0,C.useCallback)(p=>{i(k=>k.map(x=>x.id===p.id?p:x))},[]),E=(0,C.useCallback)(p=>{oe(p)},[]),be=(0,C.useCallback)(async()=>{if(ae){Z(!0);try{(await f(`/api/assistants/${ae}`)).success?(a.success(d("governance.detail.deleted")),i(k=>k.filter(x=>x.id!==ae)),L(),oe(null)):a.error(d("governance.detail.deleteFailed"))}catch{a.error(d("governance.detail.deleteFailed"))}finally{Z(!1)}}},[ae,f,L,d]),ke=(0,C.useCallback)(async p=>{if(!(await f(`/api/assistants/${p}`)).success)throw new Error("Failed to delete agent");a.success(d("governance.detail.deleted")),i(x=>x.filter(j=>j.id!==p)),L()},[f,L,d]);return(0,V.jsxs)("div",{style:{height:"100%",background:"#fafafa",overflow:"hidden"},children:[he?(0,V.jsx)(vt,{defaultProjectId:_??void 0,children:(0,V.jsx)(Dt,{assistant:he,allAssistants:g,onBack:()=>m(null),onDeleted:ke,onSave:Ae,onAssistantUpdated:Be,onAgentListInvalidated:L,initialTab:R,initialMessage:y,initialMessageCustomRunConfig:P,initialProjectId:_})},he.id):(0,V.jsx)(V.Fragment,{children:(0,V.jsx)(Lt,{items:Y,assistants:g,loading:e,onItemClick:p=>ce(p,"graph"),onOpenPlayground:p=>ce(p,"playground"),onOpenEval:p=>ce(p,"eval"),onCreate:de,onDelete:E})}),(0,V.jsx)($t,{open:r,onCancel:()=>{H(!0),o(!1)},onSelectMethod:Ke,focusTriggerAfterClose:te}),(0,V.jsx)(qt,{open:fe,initialMode:ye,initialValues:le,onCancel:()=>re(!1),onSuccess:(p,k)=>{re(!1),i(x=>x.some(ve=>ve.id===p.id)?x:[p,...x]),Ee(p.id,"graph"),u(k?.initialMessage??null),M(k?.initialMessageCustomRunConfig??null),q(k?.projectId??null),L()}}),(0,V.jsx)(pe,{title:d("governance.deleteAgent"),open:ae!==null,onCancel:()=>oe(null),onOk:be,okText:d("common.delete"),okButtonProps:{danger:!0,loading:Me},cancelText:d("common.cancel"),children:(0,V.jsx)("p",{children:d("governance.delete.irreversible")})})]})};export{va as AgentGovernanceWorkbench};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as X}from"./embed-page-chunk-U6PURUXV.js";import{K as q,Na as Q,P as J,Wa as de,a as j}from"./embed-page-chunk-BNA3NXXX.js";import{k as G,n as H}from"./embed-page-chunk-DFAZQFX4.js";import{a as Y}from"./embed-page-chunk-L2PNY33P.js";import{Aa as c,Ya as p,ba as T,fb as w,ib as R,xa as F}from"./embed-page-chunk-TWJOR2LG.js";import"./embed-page-chunk-MPQBYKDM.js";import{e as I}from"./embed-page-chunk-45A47GH2.js";var re=I(de());var t=I(Y()),O=["#6366f1","#8b5cf6","#10b981","#f59e0b","#ef4444","#0ea5e9","#ec4899","#14b8a6"],Z="#6366f1",ee="#10b981",te="#8b5cf6",oe="#ef4444",be="#f59e0b",ue="#0ea5e9";function v(o){return o!==null&&typeof o=="object"&&!Array.isArray(o)}function d(o){return Array.isArray(o)&&o.every(e=>v(e)&&typeof e.bucket=="string"&&(e.value===null||typeof e.value=="number"))}function pe(o){if(!v(o)||!v(o.kpis)||!v(o.series))return!1;let e=o.series,n=e.tokens,r=e.latency;return typeof o.samplingRate=="number"&&typeof o.kpis.traces=="number"&&typeof o.kpis.costUsd=="number"&&typeof o.kpis.inputTokens=="number"&&typeof o.kpis.outputTokens=="number"&&typeof o.kpis.errorRate=="number"&&d(e.traces)&&d(e.cost)&&d(e.errorRate)&&d(e.toolCalls)&&v(n)&&d(n.input)&&d(n.output)&&v(r)&&d(r.p50)&&d(r.p95)&&d(r.p99)&&Array.isArray(o.agents)&&Array.isArray(o.models)&&Array.isArray(o.tools)}function ne(o,e){let n=(0,re.default)(o);return e==="7d"||e==="30d"?n.format("MM-DD"):n.format("MM-DD HH:mm")}function k(o,e){return o.map(n=>ne(n.bucket,e))}function b(o){return o.map(e=>e.value??0)}function u(o){return o.some(e=>(e.value??0)!==0)}var ye=new Intl.NumberFormat(void 0,{notation:"compact",maximumFractionDigits:1});function D(o){return ye.format(o)}function P(o){return Number.isFinite(o)?o.toLocaleString():"0"}function ae(o){return`$${(Number.isFinite(o)?o:0).toFixed(4)}`}function ie(o,e){let n=Number(o);if(!Number.isFinite(n))return"\u2014";switch(e){case"currency":return ae(n);case"tokens":return D(n);case"percent":return`${(n*100).toFixed(1)}%`;case"ms":return`${Math.round(n)} ms`;default:return P(n)}}function se(o){return{backgroundColor:o.background,borderColor:o.border,borderWidth:1,textStyle:{color:o.text,fontSize:12},extraCssText:"box-shadow: 0 12px 32px rgba(15, 23, 42, 0.12); border-radius: 12px;"}}function he(o,e){return{color:o.textSecondary,fontSize:11,...e?{formatter:e}:{}}}function V(o,e,n=!1){return{type:"category",data:e,axisLine:{show:!1},axisTick:{show:!1},axisLabel:{color:o.textSecondary,fontSize:11,hideOverlap:!0,...n?{formatter:r=>r.length>18?`${r.slice(0,17)}\u2026`:r}:{}},splitLine:{show:!1}}}function $(o,e,n){return{type:"value",...e?{max:1}:{},axisLine:{show:!1},axisTick:{show:!1},axisLabel:he(o,e?r=>`${Math.round(r*100)}%`:void 0),splitLine:{lineStyle:{color:o.border,type:"dashed"}},...n==="number"?{}:{}}}function C(o,e,n){let r=n.kind??(n.percent?"percent":"number");return{color:O,tooltip:{trigger:"axis",...se(n.theme),valueFormatter:i=>ie(i,r)},legend:{top:0,right:0,icon:"circle",itemWidth:8,itemHeight:8,textStyle:{color:n.theme.textSecondary,fontSize:11}},grid:{left:8,right:16,top:36,bottom:8,containLabel:!0},xAxis:V(n.theme,o),yAxis:$(n.theme,n.percent===!0,r),series:e.map((i,s)=>({name:i.name,type:"line",smooth:.35,symbol:"none",lineStyle:{width:2},...n.stacked?{stack:"total"}:{},...n.area?{areaStyle:{opacity:n.stacked?.18:.12,color:O[s%O.length]}}:{},data:i.data}))}}function y(o,e,n){let r=n.kind??(n.percent?"percent":"number"),i=n.horizontal===!0;return{color:O,tooltip:{trigger:"axis",...se(n.theme),valueFormatter:s=>ie(s,r)},legend:{top:0,right:0,icon:"circle",itemWidth:8,itemHeight:8,textStyle:{color:n.theme.textSecondary,fontSize:11}},grid:i?{left:8,right:24,top:16,bottom:8,containLabel:!0}:{left:8,right:16,top:36,bottom:8,containLabel:!0},xAxis:i?$(n.theme,n.percent===!0,r):V(n.theme,o),yAxis:i?V(n.theme,o,!0):$(n.theme,n.percent===!0,r),series:e.map(s=>({name:s.name,type:"bar",...n.stacked?{stack:"total"}:{},barMaxWidth:i?18:28,itemStyle:{borderRadius:i?[0,6,6,0]:[6,6,0,0]},emphasis:{focus:"series"},data:s.data}))}}var A=({title:o,value:e,hint:n,accent:r,icon:i})=>{let{token:s}=w.useToken();return(0,t.jsx)(F,{size:"small",style:{borderRadius:16,border:`1px solid ${s.colorBorderSecondary}`,background:s.colorBgContainer,boxShadow:s.boxShadowTertiary,height:"100%"},styles:{body:{padding:16}},children:(0,t.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:12},children:[(0,t.jsx)("div",{style:{width:40,height:40,flexShrink:0,borderRadius:12,display:"grid",placeItems:"center",background:`${r}1a`,color:r},children:i}),(0,t.jsxs)("div",{style:{minWidth:0},children:[(0,t.jsx)("div",{style:{fontSize:11,fontWeight:600,letterSpacing:.6,textTransform:"uppercase",color:s.colorTextSecondary,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:o}),(0,t.jsx)("div",{style:{fontSize:24,fontWeight:700,lineHeight:1.2,color:s.colorText,fontVariantNumeric:"tabular-nums"},children:e}),(0,t.jsx)("div",{style:{fontSize:11,color:s.colorTextTertiary,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:n})]})]})})},f=({title:o,accent:e})=>(0,t.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,marginTop:4},children:[(0,t.jsx)("span",{style:{width:4,height:16,borderRadius:2,background:e}}),(0,t.jsx)(R.Text,{strong:!0,style:{fontSize:14},children:o})]}),m=({title:o,option:e,hasData:n})=>{let{token:r}=w.useToken(),i=H();return(0,t.jsx)(F,{size:"small",title:(0,t.jsx)("span",{style:{fontSize:12,fontWeight:600,color:r.colorTextSecondary},children:o}),style:{borderRadius:16,border:`1px solid ${r.colorBorderSecondary}`,background:r.colorBgContainer,boxShadow:r.boxShadowTertiary,height:"100%"},styles:{header:{borderBottom:"none",padding:"12px 16px 0",minHeight:0},body:{padding:"4px 8px 10px"}},children:n?(0,t.jsx)(X,{option:e,height:200}):(0,t.jsx)("div",{style:{height:200,display:"grid",placeItems:"center"},children:(0,t.jsx)(R.Text,{type:"secondary",style:{fontSize:12},children:i("common.observability.empty")})})})},Te=({data:o})=>{let e=H(),{token:n}=w.useToken();if(o.version!==G)return(0,t.jsx)(T,{type:"warning",showIcon:!0,message:e("common.observability.unsupportedVersion")});if(!pe(o.payload))return(0,t.jsx)(T,{type:"warning",showIcon:!0,message:e("common.observability.unsupportedVersion")});let r=o.payload,i=o.range,s=r.series.traces,L=r.series.cost,_=r.series.costByModel??[],x=r.series.tokens,h=r.series.latency,E=r.series.errorRate,z=r.series.toolCalls,l={text:n.colorText,textSecondary:n.colorTextTertiary,border:n.colorBorderSecondary,background:n.colorBgElevated},W=r.agents.map(a=>a.name&&a.name.trim()?a.name:a.assistantId==="unattributed"?e("common.observability.unknownAgent"):a.assistantId?a.assistantId.slice(0,8):e("common.observability.unknownAgent")),B=r.models.map(a=>a.model),ce=r.tools.slice(0,10).map(a=>a.tool),K=new Set;for(let a of _)for(let g of a.points)K.add(g.bucket);let U=[...K].sort(),le=U.map(a=>ne(a,i)),M=_.map(a=>{let g=new Map(a.points.map(S=>[S.bucket,S.value??0]));return{name:a.model,data:U.map(S=>g.get(S)??0)}}),N=M.length>0,me=r.agents.reduce((a,g)=>a+g.errorCount,0);return(0,t.jsxs)("div",{style:{display:"grid",gap:20},children:[(0,t.jsx)(R.Text,{type:"secondary",style:{fontSize:12},children:e("common.observability.scopeNote",{environment:r.environment??e("common.observability.allEnvironments"),range:i})}),o.warnings&&o.warnings.length>0?(0,t.jsx)(T,{type:"warning",showIcon:!0,message:e("common.observability.partial")}):null,r.samplingRate<1?(0,t.jsx)(T,{type:"info",showIcon:!0,message:e("common.observability.sampling",{rate:Math.round(r.samplingRate*100)})}):null,(0,t.jsxs)(p,{gutter:[12,12],children:[(0,t.jsx)(c,{xs:12,md:6,children:(0,t.jsx)(A,{title:e("common.observability.kpi.traces"),value:P(r.kpis.traces),hint:e("common.observability.kpi.tracesHint"),accent:Z,icon:(0,t.jsx)(j,{size:18})})}),(0,t.jsx)(c,{xs:12,md:6,children:(0,t.jsx)(A,{title:e("common.observability.kpi.cost"),value:ae(r.kpis.costUsd),hint:"USD",accent:ee,icon:(0,t.jsx)(J,{size:18})})}),(0,t.jsx)(c,{xs:12,md:6,children:(0,t.jsx)(A,{title:e("common.observability.kpi.tokens"),value:D(r.kpis.inputTokens+r.kpis.outputTokens),hint:e("common.observability.kpi.tokensHint",{input:D(r.kpis.inputTokens),output:D(r.kpis.outputTokens)}),accent:te,icon:(0,t.jsx)(q,{size:18})})}),(0,t.jsx)(c,{xs:12,md:6,children:(0,t.jsx)(A,{title:e("common.observability.kpi.errorRate"),value:`${(r.kpis.errorRate*100).toFixed(2)}%`,hint:e("common.observability.kpi.errorsHint",{count:P(me)}),accent:oe,icon:(0,t.jsx)(Q,{size:18})})})]}),(0,t.jsx)(f,{title:e("common.observability.section.traces"),accent:Z}),(0,t.jsxs)(p,{gutter:[16,16],children:[(0,t.jsx)(c,{xs:24,md:12,children:(0,t.jsx)(m,{title:e("common.observability.chart.tracesByAssistant"),hasData:r.agents.length>0,option:y(W,[{name:e("common.observability.table.calls"),data:r.agents.map(a=>a.calls)}],{theme:l,horizontal:!0,kind:"number"})})}),(0,t.jsx)(c,{xs:24,md:12,children:(0,t.jsx)(m,{title:e("common.observability.chart.tracesOverTime"),hasData:u(s),option:y(k(s,i),[{name:e("common.observability.kpi.traces"),data:b(s)}],{theme:l,kind:"number"})})})]}),(0,t.jsx)(f,{title:e("common.observability.section.cost"),accent:ee}),(0,t.jsxs)(p,{gutter:[16,16],children:[(0,t.jsx)(c,{xs:24,md:12,children:(0,t.jsx)(m,{title:e("common.observability.chart.costByModel"),hasData:r.models.length>0,option:y(B,[{name:e("common.observability.kpi.cost"),data:r.models.map(a=>a.costUsd)}],{theme:l,kind:"currency"})})}),(0,t.jsx)(c,{xs:24,md:12,children:(0,t.jsx)(m,{title:e(N?"common.observability.chart.costByModelOverTime":"common.observability.chart.costOverTime"),hasData:N?M.some(a=>a.data.some(g=>g!==0)):u(L),option:N?C(le,M,{theme:l,stacked:!0,area:!0,kind:"currency"}):C(k(L,i),[{name:e("common.observability.kpi.cost"),data:b(L)}],{theme:l,area:!0,kind:"currency"})})})]}),(0,t.jsx)(f,{title:e("common.observability.section.tokens"),accent:te}),(0,t.jsxs)(p,{gutter:[16,16],children:[(0,t.jsx)(c,{xs:24,md:12,children:(0,t.jsx)(m,{title:e("common.observability.chart.tokensByModel"),hasData:r.models.length>0,option:y(B,[{name:e("common.observability.table.inputTokens"),data:r.models.map(a=>a.inputTokens)},{name:e("common.observability.table.outputTokens"),data:r.models.map(a=>a.outputTokens)}],{theme:l,stacked:!0,kind:"tokens"})})}),(0,t.jsx)(c,{xs:24,md:12,children:(0,t.jsx)(m,{title:e("common.observability.chart.tokensOverTime"),hasData:u(x.input)||u(x.output),option:C(k(x.input,i),[{name:"input",data:b(x.input)},{name:"output",data:b(x.output)}],{theme:l,area:!0,stacked:!0,kind:"tokens"})})})]}),(0,t.jsx)(f,{title:e("common.observability.section.errors"),accent:oe}),(0,t.jsxs)(p,{gutter:[16,16],children:[(0,t.jsx)(c,{xs:24,md:12,children:(0,t.jsx)(m,{title:e("common.observability.chart.errorRateByAssistant"),hasData:r.agents.length>0,option:y(W,[{name:e("common.observability.kpi.errorRate"),data:r.agents.map(a=>a.errorRate)}],{theme:l,horizontal:!0,percent:!0})})}),(0,t.jsx)(c,{xs:24,md:12,children:(0,t.jsx)(m,{title:e("common.observability.chart.errorRateOverTime"),hasData:u(E),option:C(k(E,i),[{name:e("common.observability.kpi.errorRate"),data:b(E)}],{theme:l,percent:!0,area:!0})})})]}),(0,t.jsx)(f,{title:e("common.observability.section.latency"),accent:be}),(0,t.jsxs)(p,{gutter:[16,16],children:[(0,t.jsx)(c,{xs:24,md:12,children:(0,t.jsx)(m,{title:e("common.observability.chart.p95ByModel"),hasData:r.models.length>0,option:y(B,[{name:e("common.observability.kpi.p95"),data:r.models.map(a=>a.p95LatencyMs??0)}],{theme:l,horizontal:!0,kind:"ms"})})}),(0,t.jsx)(c,{xs:24,md:12,children:(0,t.jsx)(m,{title:e("common.observability.chart.latencyOverTime"),hasData:u(h.p50)||u(h.p95)||u(h.p99),option:C(k(h.p95,i),[{name:"p50",data:b(h.p50)},{name:"p95",data:b(h.p95)},{name:"p99",data:b(h.p99)}],{theme:l,kind:"ms"})})})]}),(0,t.jsx)(f,{title:e("common.observability.section.tools"),accent:ue}),(0,t.jsxs)(p,{gutter:[16,16],children:[(0,t.jsx)(c,{xs:24,md:12,children:(0,t.jsx)(m,{title:e("common.observability.chart.toolsByTool"),hasData:r.tools.length>0,option:y(ce,[{name:e("common.observability.table.calls"),data:r.tools.slice(0,10).map(a=>a.count)}],{theme:l,horizontal:!0,kind:"number"})})}),(0,t.jsx)(c,{xs:24,md:12,children:(0,t.jsx)(m,{title:e("common.observability.chart.toolsOverTime"),hasData:u(z),option:y(k(z,i),[{name:e("common.observability.table.calls"),data:b(z)}],{theme:l,kind:"number"})})})]})]})};export{Te as LangfuseDashboard};
|
|
1
|
+
import{a as X}from"./embed-page-chunk-U6PURUXV.js";import{K as q,Na as Q,P as J,Wa as de,a as j}from"./embed-page-chunk-BNA3NXXX.js";import{k as G,o as H}from"./embed-page-chunk-36VOH7DG.js";import{a as Y}from"./embed-page-chunk-L2PNY33P.js";import{Aa as c,Za as p,ba as T,gb as w,jb as R,xa as F}from"./embed-page-chunk-QWLZN3EX.js";import"./embed-page-chunk-MPQBYKDM.js";import{e as I}from"./embed-page-chunk-45A47GH2.js";var re=I(de());var t=I(Y()),O=["#6366f1","#8b5cf6","#10b981","#f59e0b","#ef4444","#0ea5e9","#ec4899","#14b8a6"],Z="#6366f1",ee="#10b981",te="#8b5cf6",oe="#ef4444",be="#f59e0b",ue="#0ea5e9";function v(o){return o!==null&&typeof o=="object"&&!Array.isArray(o)}function d(o){return Array.isArray(o)&&o.every(e=>v(e)&&typeof e.bucket=="string"&&(e.value===null||typeof e.value=="number"))}function pe(o){if(!v(o)||!v(o.kpis)||!v(o.series))return!1;let e=o.series,n=e.tokens,r=e.latency;return typeof o.samplingRate=="number"&&typeof o.kpis.traces=="number"&&typeof o.kpis.costUsd=="number"&&typeof o.kpis.inputTokens=="number"&&typeof o.kpis.outputTokens=="number"&&typeof o.kpis.errorRate=="number"&&d(e.traces)&&d(e.cost)&&d(e.errorRate)&&d(e.toolCalls)&&v(n)&&d(n.input)&&d(n.output)&&v(r)&&d(r.p50)&&d(r.p95)&&d(r.p99)&&Array.isArray(o.agents)&&Array.isArray(o.models)&&Array.isArray(o.tools)}function ne(o,e){let n=(0,re.default)(o);return e==="7d"||e==="30d"?n.format("MM-DD"):n.format("MM-DD HH:mm")}function k(o,e){return o.map(n=>ne(n.bucket,e))}function b(o){return o.map(e=>e.value??0)}function u(o){return o.some(e=>(e.value??0)!==0)}var ye=new Intl.NumberFormat(void 0,{notation:"compact",maximumFractionDigits:1});function D(o){return ye.format(o)}function P(o){return Number.isFinite(o)?o.toLocaleString():"0"}function ae(o){return`$${(Number.isFinite(o)?o:0).toFixed(4)}`}function ie(o,e){let n=Number(o);if(!Number.isFinite(n))return"\u2014";switch(e){case"currency":return ae(n);case"tokens":return D(n);case"percent":return`${(n*100).toFixed(1)}%`;case"ms":return`${Math.round(n)} ms`;default:return P(n)}}function se(o){return{backgroundColor:o.background,borderColor:o.border,borderWidth:1,textStyle:{color:o.text,fontSize:12},extraCssText:"box-shadow: 0 12px 32px rgba(15, 23, 42, 0.12); border-radius: 12px;"}}function he(o,e){return{color:o.textSecondary,fontSize:11,...e?{formatter:e}:{}}}function V(o,e,n=!1){return{type:"category",data:e,axisLine:{show:!1},axisTick:{show:!1},axisLabel:{color:o.textSecondary,fontSize:11,hideOverlap:!0,...n?{formatter:r=>r.length>18?`${r.slice(0,17)}\u2026`:r}:{}},splitLine:{show:!1}}}function $(o,e,n){return{type:"value",...e?{max:1}:{},axisLine:{show:!1},axisTick:{show:!1},axisLabel:he(o,e?r=>`${Math.round(r*100)}%`:void 0),splitLine:{lineStyle:{color:o.border,type:"dashed"}},...n==="number"?{}:{}}}function C(o,e,n){let r=n.kind??(n.percent?"percent":"number");return{color:O,tooltip:{trigger:"axis",...se(n.theme),valueFormatter:i=>ie(i,r)},legend:{top:0,right:0,icon:"circle",itemWidth:8,itemHeight:8,textStyle:{color:n.theme.textSecondary,fontSize:11}},grid:{left:8,right:16,top:36,bottom:8,containLabel:!0},xAxis:V(n.theme,o),yAxis:$(n.theme,n.percent===!0,r),series:e.map((i,s)=>({name:i.name,type:"line",smooth:.35,symbol:"none",lineStyle:{width:2},...n.stacked?{stack:"total"}:{},...n.area?{areaStyle:{opacity:n.stacked?.18:.12,color:O[s%O.length]}}:{},data:i.data}))}}function y(o,e,n){let r=n.kind??(n.percent?"percent":"number"),i=n.horizontal===!0;return{color:O,tooltip:{trigger:"axis",...se(n.theme),valueFormatter:s=>ie(s,r)},legend:{top:0,right:0,icon:"circle",itemWidth:8,itemHeight:8,textStyle:{color:n.theme.textSecondary,fontSize:11}},grid:i?{left:8,right:24,top:16,bottom:8,containLabel:!0}:{left:8,right:16,top:36,bottom:8,containLabel:!0},xAxis:i?$(n.theme,n.percent===!0,r):V(n.theme,o),yAxis:i?V(n.theme,o,!0):$(n.theme,n.percent===!0,r),series:e.map(s=>({name:s.name,type:"bar",...n.stacked?{stack:"total"}:{},barMaxWidth:i?18:28,itemStyle:{borderRadius:i?[0,6,6,0]:[6,6,0,0]},emphasis:{focus:"series"},data:s.data}))}}var A=({title:o,value:e,hint:n,accent:r,icon:i})=>{let{token:s}=w.useToken();return(0,t.jsx)(F,{size:"small",style:{borderRadius:16,border:`1px solid ${s.colorBorderSecondary}`,background:s.colorBgContainer,boxShadow:s.boxShadowTertiary,height:"100%"},styles:{body:{padding:16}},children:(0,t.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:12},children:[(0,t.jsx)("div",{style:{width:40,height:40,flexShrink:0,borderRadius:12,display:"grid",placeItems:"center",background:`${r}1a`,color:r},children:i}),(0,t.jsxs)("div",{style:{minWidth:0},children:[(0,t.jsx)("div",{style:{fontSize:11,fontWeight:600,letterSpacing:.6,textTransform:"uppercase",color:s.colorTextSecondary,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:o}),(0,t.jsx)("div",{style:{fontSize:24,fontWeight:700,lineHeight:1.2,color:s.colorText,fontVariantNumeric:"tabular-nums"},children:e}),(0,t.jsx)("div",{style:{fontSize:11,color:s.colorTextTertiary,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:n})]})]})})},f=({title:o,accent:e})=>(0,t.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,marginTop:4},children:[(0,t.jsx)("span",{style:{width:4,height:16,borderRadius:2,background:e}}),(0,t.jsx)(R.Text,{strong:!0,style:{fontSize:14},children:o})]}),m=({title:o,option:e,hasData:n})=>{let{token:r}=w.useToken(),i=H();return(0,t.jsx)(F,{size:"small",title:(0,t.jsx)("span",{style:{fontSize:12,fontWeight:600,color:r.colorTextSecondary},children:o}),style:{borderRadius:16,border:`1px solid ${r.colorBorderSecondary}`,background:r.colorBgContainer,boxShadow:r.boxShadowTertiary,height:"100%"},styles:{header:{borderBottom:"none",padding:"12px 16px 0",minHeight:0},body:{padding:"4px 8px 10px"}},children:n?(0,t.jsx)(X,{option:e,height:200}):(0,t.jsx)("div",{style:{height:200,display:"grid",placeItems:"center"},children:(0,t.jsx)(R.Text,{type:"secondary",style:{fontSize:12},children:i("common.observability.empty")})})})},Te=({data:o})=>{let e=H(),{token:n}=w.useToken();if(o.version!==G)return(0,t.jsx)(T,{type:"warning",showIcon:!0,message:e("common.observability.unsupportedVersion")});if(!pe(o.payload))return(0,t.jsx)(T,{type:"warning",showIcon:!0,message:e("common.observability.unsupportedVersion")});let r=o.payload,i=o.range,s=r.series.traces,L=r.series.cost,_=r.series.costByModel??[],x=r.series.tokens,h=r.series.latency,E=r.series.errorRate,z=r.series.toolCalls,l={text:n.colorText,textSecondary:n.colorTextTertiary,border:n.colorBorderSecondary,background:n.colorBgElevated},W=r.agents.map(a=>a.name&&a.name.trim()?a.name:a.assistantId==="unattributed"?e("common.observability.unknownAgent"):a.assistantId?a.assistantId.slice(0,8):e("common.observability.unknownAgent")),B=r.models.map(a=>a.model),ce=r.tools.slice(0,10).map(a=>a.tool),K=new Set;for(let a of _)for(let g of a.points)K.add(g.bucket);let U=[...K].sort(),le=U.map(a=>ne(a,i)),M=_.map(a=>{let g=new Map(a.points.map(S=>[S.bucket,S.value??0]));return{name:a.model,data:U.map(S=>g.get(S)??0)}}),N=M.length>0,me=r.agents.reduce((a,g)=>a+g.errorCount,0);return(0,t.jsxs)("div",{style:{display:"grid",gap:20},children:[(0,t.jsx)(R.Text,{type:"secondary",style:{fontSize:12},children:e("common.observability.scopeNote",{environment:r.environment??e("common.observability.allEnvironments"),range:i})}),o.warnings&&o.warnings.length>0?(0,t.jsx)(T,{type:"warning",showIcon:!0,message:e("common.observability.partial")}):null,r.samplingRate<1?(0,t.jsx)(T,{type:"info",showIcon:!0,message:e("common.observability.sampling",{rate:Math.round(r.samplingRate*100)})}):null,(0,t.jsxs)(p,{gutter:[12,12],children:[(0,t.jsx)(c,{xs:12,md:6,children:(0,t.jsx)(A,{title:e("common.observability.kpi.traces"),value:P(r.kpis.traces),hint:e("common.observability.kpi.tracesHint"),accent:Z,icon:(0,t.jsx)(j,{size:18})})}),(0,t.jsx)(c,{xs:12,md:6,children:(0,t.jsx)(A,{title:e("common.observability.kpi.cost"),value:ae(r.kpis.costUsd),hint:"USD",accent:ee,icon:(0,t.jsx)(J,{size:18})})}),(0,t.jsx)(c,{xs:12,md:6,children:(0,t.jsx)(A,{title:e("common.observability.kpi.tokens"),value:D(r.kpis.inputTokens+r.kpis.outputTokens),hint:e("common.observability.kpi.tokensHint",{input:D(r.kpis.inputTokens),output:D(r.kpis.outputTokens)}),accent:te,icon:(0,t.jsx)(q,{size:18})})}),(0,t.jsx)(c,{xs:12,md:6,children:(0,t.jsx)(A,{title:e("common.observability.kpi.errorRate"),value:`${(r.kpis.errorRate*100).toFixed(2)}%`,hint:e("common.observability.kpi.errorsHint",{count:P(me)}),accent:oe,icon:(0,t.jsx)(Q,{size:18})})})]}),(0,t.jsx)(f,{title:e("common.observability.section.traces"),accent:Z}),(0,t.jsxs)(p,{gutter:[16,16],children:[(0,t.jsx)(c,{xs:24,md:12,children:(0,t.jsx)(m,{title:e("common.observability.chart.tracesByAssistant"),hasData:r.agents.length>0,option:y(W,[{name:e("common.observability.table.calls"),data:r.agents.map(a=>a.calls)}],{theme:l,horizontal:!0,kind:"number"})})}),(0,t.jsx)(c,{xs:24,md:12,children:(0,t.jsx)(m,{title:e("common.observability.chart.tracesOverTime"),hasData:u(s),option:y(k(s,i),[{name:e("common.observability.kpi.traces"),data:b(s)}],{theme:l,kind:"number"})})})]}),(0,t.jsx)(f,{title:e("common.observability.section.cost"),accent:ee}),(0,t.jsxs)(p,{gutter:[16,16],children:[(0,t.jsx)(c,{xs:24,md:12,children:(0,t.jsx)(m,{title:e("common.observability.chart.costByModel"),hasData:r.models.length>0,option:y(B,[{name:e("common.observability.kpi.cost"),data:r.models.map(a=>a.costUsd)}],{theme:l,kind:"currency"})})}),(0,t.jsx)(c,{xs:24,md:12,children:(0,t.jsx)(m,{title:e(N?"common.observability.chart.costByModelOverTime":"common.observability.chart.costOverTime"),hasData:N?M.some(a=>a.data.some(g=>g!==0)):u(L),option:N?C(le,M,{theme:l,stacked:!0,area:!0,kind:"currency"}):C(k(L,i),[{name:e("common.observability.kpi.cost"),data:b(L)}],{theme:l,area:!0,kind:"currency"})})})]}),(0,t.jsx)(f,{title:e("common.observability.section.tokens"),accent:te}),(0,t.jsxs)(p,{gutter:[16,16],children:[(0,t.jsx)(c,{xs:24,md:12,children:(0,t.jsx)(m,{title:e("common.observability.chart.tokensByModel"),hasData:r.models.length>0,option:y(B,[{name:e("common.observability.table.inputTokens"),data:r.models.map(a=>a.inputTokens)},{name:e("common.observability.table.outputTokens"),data:r.models.map(a=>a.outputTokens)}],{theme:l,stacked:!0,kind:"tokens"})})}),(0,t.jsx)(c,{xs:24,md:12,children:(0,t.jsx)(m,{title:e("common.observability.chart.tokensOverTime"),hasData:u(x.input)||u(x.output),option:C(k(x.input,i),[{name:"input",data:b(x.input)},{name:"output",data:b(x.output)}],{theme:l,area:!0,stacked:!0,kind:"tokens"})})})]}),(0,t.jsx)(f,{title:e("common.observability.section.errors"),accent:oe}),(0,t.jsxs)(p,{gutter:[16,16],children:[(0,t.jsx)(c,{xs:24,md:12,children:(0,t.jsx)(m,{title:e("common.observability.chart.errorRateByAssistant"),hasData:r.agents.length>0,option:y(W,[{name:e("common.observability.kpi.errorRate"),data:r.agents.map(a=>a.errorRate)}],{theme:l,horizontal:!0,percent:!0})})}),(0,t.jsx)(c,{xs:24,md:12,children:(0,t.jsx)(m,{title:e("common.observability.chart.errorRateOverTime"),hasData:u(E),option:C(k(E,i),[{name:e("common.observability.kpi.errorRate"),data:b(E)}],{theme:l,percent:!0,area:!0})})})]}),(0,t.jsx)(f,{title:e("common.observability.section.latency"),accent:be}),(0,t.jsxs)(p,{gutter:[16,16],children:[(0,t.jsx)(c,{xs:24,md:12,children:(0,t.jsx)(m,{title:e("common.observability.chart.p95ByModel"),hasData:r.models.length>0,option:y(B,[{name:e("common.observability.kpi.p95"),data:r.models.map(a=>a.p95LatencyMs??0)}],{theme:l,horizontal:!0,kind:"ms"})})}),(0,t.jsx)(c,{xs:24,md:12,children:(0,t.jsx)(m,{title:e("common.observability.chart.latencyOverTime"),hasData:u(h.p50)||u(h.p95)||u(h.p99),option:C(k(h.p95,i),[{name:"p50",data:b(h.p50)},{name:"p95",data:b(h.p95)},{name:"p99",data:b(h.p99)}],{theme:l,kind:"ms"})})})]}),(0,t.jsx)(f,{title:e("common.observability.section.tools"),accent:ue}),(0,t.jsxs)(p,{gutter:[16,16],children:[(0,t.jsx)(c,{xs:24,md:12,children:(0,t.jsx)(m,{title:e("common.observability.chart.toolsByTool"),hasData:r.tools.length>0,option:y(ce,[{name:e("common.observability.table.calls"),data:r.tools.slice(0,10).map(a=>a.count)}],{theme:l,horizontal:!0,kind:"number"})})}),(0,t.jsx)(c,{xs:24,md:12,children:(0,t.jsx)(m,{title:e("common.observability.chart.toolsOverTime"),hasData:u(z),option:y(k(z,i),[{name:e("common.observability.table.calls"),data:b(z)}],{theme:l,kind:"number"})})})]})]})};export{Te as LangfuseDashboard};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import{c as $,d as J}from"./embed-page-chunk-I6Q3MSI4.js";import{b as R,d as V,e as S}from"./embed-page-chunk-7EEAFSMK.js";import"./embed-page-chunk-S4XZPBRM.js";import{j as N,k as H,l as L,m as U,n as W,x as A,y as K,z as Y}from"./embed-page-chunk-HJYCGHWQ.js";import"./embed-page-chunk-A4I7H7RP.js";import"./embed-page-chunk-F5RPCW5O.js";import"./embed-page-chunk-FYIVKZA2.js";import"./embed-page-chunk-Q54ZBF3I.js";import"./embed-page-chunk-CSRF4YQD.js";import"./embed-page-chunk-BNA3NXXX.js";import{o as w}from"./embed-page-chunk-36VOH7DG.js";import{a as g}from"./embed-page-chunk-L2PNY33P.js";import"./embed-page-chunk-DLSQ2OWQ.js";import"./embed-page-chunk-F52TPGBP.js";import{Aa as G,Oa as _,ab as z,bb as k,eb as F,t as E,y as D}from"./embed-page-chunk-WMHFEZXB.js";import{fa as T,fb as P,oa as B}from"./embed-page-chunk-QWLZN3EX.js";import{a as b}from"./embed-page-chunk-MPQBYKDM.js";import"./embed-page-chunk-3KBY77YU.js";import"./embed-page-chunk-U2CG7PH5.js";import{e as f}from"./embed-page-chunk-45A47GH2.js";var n=f(b());var I=f(b());var o=f(g());var ae="tracePulse 1.4s ease-in-out infinite",le={running:(0,o.jsx)(G,{style:{color:"#1890ff"}}),success:(0,o.jsx)(E,{style:{color:"#52c41a"}}),error:(0,o.jsx)(D,{style:{color:"#ff4d4f"}})};function de({kind:e}){switch(e){case"human":return(0,o.jsx)(F,{});case"agent":return(0,o.jsx)(z,{});case"tool":return(0,o.jsx)(k,{});case"ai":return(0,o.jsx)(_,{});default:return(0,o.jsx)(k,{})}}var M=I.default.createContext({}),ce=()=>I.default.useContext(M),pe=({data:e,selected:i})=>{let l=w(),{onJumpToMessage:t}=ce(),s=e.isAnswer===!0,a=e.status==="running",p=(e.parallelCount??1)>1,m=!!(t&&e.messageId&&!e.messageId.startsWith("summary:")),v=e.toolCall?L(e.toolCall.name):e.label,y=()=>{if((e.kind==="tool"||e.kind==="agent")&&e.toolCall){let h=U(e.toolCall.response);return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(H,{data:{name:e.toolCall.name,parameters:e.toolCall.args,type:"tool_call"},component_key:`${e.toolCall.id}-params`,interactive:!1}),h&&(0,o.jsx)("div",{style:{marginTop:8},children:(0,o.jsx)(N,{content:h})}),(0,o.jsx)(W,{ui:e.toolCall.ui})]})}return e.content?(0,o.jsx)(N,{content:e.content}):(0,o.jsx)("span",{style:{color:"#8c8c8c"},children:e.label})};return(0,o.jsxs)("div",{"data-testid":"trace-card",style:{height:"100%",display:"flex",flexDirection:"column",border:`1px solid ${s||i?"#6366f1":a?"#91caff":"#e5e7eb"}`,borderRadius:12,background:s?"#eef2ff":"#fff",boxShadow:a?"0 0 0 2px rgba(24,144,255,0.18)":i?"0 0 0 2px rgba(99,102,241,0.2)":"none",animation:a?ae:void 0,overflow:"hidden",fontSize:13},children:[(0,o.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"8px 12px",borderBottom:"1px solid #f0f0f0",background:"rgba(0,0,0,0.02)"},children:[(0,o.jsx)(de,{kind:e.kind}),(0,o.jsx)("span",{style:{fontWeight:s?700:600,flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:v}),p&&(0,o.jsx)(P,{color:"purple",style:{marginInlineEnd:0,fontSize:10},children:l("chat.trace.parallelBadge",{count:e.parallelCount??1})}),le[e.status],m&&(0,o.jsx)(T,{type:"text",size:"small",onClick:()=>t?.(e.messageId),children:l("chat.trace.jumpToChat")})]}),(0,o.jsx)("div",{style:{flex:1,minHeight:0,overflow:"auto",padding:12},children:y()})]})},fe=({data:e,selected:i})=>(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(S,{type:"target",position:R.Top}),(0,o.jsx)(pe,{data:e,selected:i}),(0,o.jsx)(S,{type:"source",position:R.Bottom})]}),j={trace:fe};var Z=f(b());var u=f(g()),ue={running:"#1890ff",success:"#52c41a",error:"#ff4d4f"},q=({graph:e,activeNodeId:i,onSelectNode:l})=>{let t=Z.default.useMemo(()=>new Map(e.nodes.map(s=>[s.id,s])),[e.nodes]);return(0,u.jsx)("div",{"data-testid":"trace-overview-rail",style:{display:"flex",flexDirection:"column",gap:10,width:160,padding:8,overflowY:"auto",borderRight:"1px solid #f0f0f0"},children:e.phases.map(s=>(0,u.jsxs)("div",{"data-testid":"trace-rail-phase",children:[(0,u.jsx)("div",{style:{fontSize:12,color:"#8c8c8c",marginBottom:4},children:s.title}),(0,u.jsx)("div",{style:{display:"flex",flexWrap:"wrap",gap:4},children:s.nodeIds.map(a=>{let p=t.get(a);if(!p)return null;let m=a===i;return(0,u.jsx)(B,{title:p.data.label,children:(0,u.jsx)("button",{type:"button","data-testid":"trace-rail-tick",onClick:()=>l?.(a),style:{width:m?12:8,height:m?12:8,borderRadius:"50%",border:"none",padding:0,cursor:"pointer",background:ue[p.data.status],outline:m?"2px solid #6366f1":"none"}})},a)})})]},s.id))})};var d=f(g()),Q=3,X=()=>{},me=`
|
|
2
|
+
@keyframes tracePulse {
|
|
3
|
+
0%, 100% { box-shadow: 0 0 0 2px rgba(24,144,255,0.18); }
|
|
4
|
+
50% { box-shadow: 0 0 0 6px rgba(24,144,255,0.05); }
|
|
5
|
+
}
|
|
6
|
+
`;function ge(e){let i=e.nodes.map(t=>({id:t.id,...A[t.data.kind]})),l=e.edges.map(t=>({from:t.from,to:t.to}));return $(i,l,{nodesep:48,ranksep:80,rankdir:"TB"})}function ye({focusNodeId:e,follow:i}){let l=V();return(0,n.useEffect)(()=>{if(!i||!e)return;let t=l.getNode(e);if(!t)return;let s=t.style?.width??0,a=t.style?.height??0;l.setCenter(t.position.x+s/2,t.position.y+a/2,{zoom:1,duration:300})},[e,i,l]),null}var _e=({messages:e,isLoading:i,onJumpToMessage:l})=>{let t=w(),[s,a]=(0,n.useState)(),[p,m]=(0,n.useState)(!1),[v,y]=(0,n.useState)(!0),h=(0,n.useDeferredValue)(e),x=(0,n.useMemo)(()=>K(h,{isLoading:i,t}),[h,i,t]),c=(0,n.useMemo)(()=>p?x:Y(x,Q,t),[x,p,t]),ee=(0,n.useMemo)(()=>`${c.nodes.map(r=>r.id).join(",")}|${c.edges.map(r=>r.id).join(",")}`,[c]),O=(0,n.useMemo)(()=>ge(c),[ee]),oe=(0,n.useMemo)(()=>c.nodes.map(r=>{let C=A[r.data.kind];return{id:r.id,type:"trace",position:O.get(r.id)??{x:0,y:0},data:r.data,draggable:!1,style:{width:C.width,height:C.height}}}),[c,O]),te=(0,n.useMemo)(()=>c.edges.map(r=>({id:r.id,source:r.from,target:r.to,animated:r.kind==="invoke",style:{stroke:r.kind==="invoke"?"#6366f1":r.kind==="result"?"#a5b4fc":"#d9d9d9"}})),[c]),re=c.nodes[c.nodes.length-1]?.id,ne=s??re,se=x.phases.length>Q,ie=(0,n.useMemo)(()=>({onJumpToMessage:l}),[l]);return(0,d.jsxs)(M.Provider,{value:ie,children:[(0,d.jsx)("style",{children:me}),(0,d.jsxs)("div",{style:{display:"flex",height:"100%",minHeight:0,width:"100%",overflow:"hidden"},children:[(0,d.jsx)(q,{graph:c,activeNodeId:s,onSelectNode:a}),(0,d.jsxs)("div",{style:{flex:1,minWidth:0,minHeight:0,display:"flex",flexDirection:"column"},children:[(0,d.jsxs)("div",{style:{display:"flex",justifyContent:"flex-end",alignItems:"center",gap:4,padding:"4px 8px"},children:[!v&&(0,d.jsx)(T,{size:"small",type:"text",onClick:()=>{a(void 0),y(!0)},children:t("chat.trace.backToCurrent")}),se&&(0,d.jsx)(T,{size:"small",type:"text",onClick:()=>m(r=>!r),children:t(p?"chat.trace.collapseOlder":"chat.trace.expandAll")})]}),(0,d.jsx)("div",{style:{flex:1,minHeight:0},children:(0,d.jsx)(J,{nodes:oe,edges:te,nodeTypes:j,onNodesChange:X,onEdgesChange:X,nodesDraggable:!1,nodesConnectable:!1,fitView:!0,miniMap:{pannable:!0,zoomable:!0},onMoveStart:()=>y(!1),onNodeClick:(r,C)=>{a(C.id),y(!0)},children:(0,d.jsx)(ye,{focusNodeId:ne,follow:v})})})]})]})]})};export{_e as MessageGraph};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{s as D}from"./embed-page-chunk-CWVHIM56.js";import{i as E}from"./embed-page-chunk-HJYCGHWQ.js";import"./embed-page-chunk-A4I7H7RP.js";import"./embed-page-chunk-F5RPCW5O.js";import"./embed-page-chunk-FYIVKZA2.js";import"./embed-page-chunk-Q54ZBF3I.js";import{a as T}from"./embed-page-chunk-CSRF4YQD.js";import"./embed-page-chunk-BNA3NXXX.js";import{o as v}from"./embed-page-chunk-36VOH7DG.js";import{a as C}from"./embed-page-chunk-L2PNY33P.js";import"./embed-page-chunk-DLSQ2OWQ.js";import"./embed-page-chunk-F52TPGBP.js";import"./embed-page-chunk-WMHFEZXB.js";import{xa as x}from"./embed-page-chunk-QWLZN3EX.js";import{a as w}from"./embed-page-chunk-MPQBYKDM.js";import"./embed-page-chunk-3KBY77YU.js";import"./embed-page-chunk-U2CG7PH5.js";import{e as p}from"./embed-page-chunk-45A47GH2.js";var u=p(w());var R=p(T());var y=p(C());function g(l,i){if(!l||l.length===0)return{title:{text:i("genui.chart.title"),left:"left"},tooltip:{trigger:"axis"},legend:{right:0,orient:"vertical"},xAxis:{type:"category",data:[]},yAxis:{type:"value"},series:[{type:"line",name:i("genui.chart.seriesDefault",{n:1}),data:[]}],grid:{left:"3%",right:"4%",bottom:"3%",containLabel:!0}};let s=l[0],t=Object.keys(s);if(t.length===0)return g([],i);let r=t.filter(e=>{let n=s[e];return typeof n=="number"||!isNaN(Number(n))});if(r.length>0){let e=r[0],n=t.find(a=>!r.includes(a))||t[0],o=l.map((a,c)=>a[n]!==void 0?String(a[n]):i("genui.chart.itemDefault",{n:c+1})),f=l.map(a=>{let c=a[e];return typeof c=="number"?c:Number(c)||0});return{title:{text:i("genui.chart.title"),left:"left"},tooltip:{trigger:"axis"},legend:{right:0,orient:"vertical",data:[e]},xAxis:{type:"category",data:o},yAxis:{type:"value"},series:[{type:"line",name:e,data:f}],grid:{left:"3%",right:"4%",bottom:"3%",containLabel:!0}}}return{title:{text:i("genui.chart.title"),left:"left"},tooltip:{trigger:"axis"},legend:{right:0,orient:"vertical"},xAxis:{type:"category",data:l.map((e,n)=>i("genui.chart.itemDefault",{n:n+1}))},yAxis:{type:"value"},series:[{type:"bar",name:i("genui.chart.countSeries"),data:l.map(()=>1)}],grid:{left:"3%",right:"4%",bottom:"3%",containLabel:!0}}}function j(l,i){if(!l||typeof l!="object"||!l.series||!Array.isArray(l.series)||l.series.length===0)return null;let s=l.series.map((e,n)=>{if(!e||typeof e!="object"||!e.type||!e.data||!Array.isArray(e.data)||e.data.length===0)return null;let o={...e,name:e.name||i("genui.chart.seriesDefault",{n:n+1})};if(e.type==="pie"){let f=e.data.map((a,c)=>typeof a=="object"&&a!==null&&"value"in a?{value:a.value,name:a.name||i("genui.chart.itemDefault",{n:c+1})}:typeof a=="number"?{value:a,name:i("genui.chart.itemDefault",{n:c+1})}:null).filter(a=>a!==null);return f.length===0?null:{...o,data:f}}return o}).filter(e=>e!==null);if(s.length===0)return null;let t={...l,series:s},r=s[0].type;if(r!=="pie"){if(!t.xAxis)t.xAxis={type:"category",data:[]};else if(typeof t.xAxis=="object"&&!Array.isArray(t.xAxis)){let e=t.xAxis;if(e.type||(e.type="category"),e.type==="category"&&!e.data){let n=s[0].data;Array.isArray(n)&&n.length>0?Array.isArray(n[0])?e.data=n.map(o=>o[0]):e.data=n.map((o,f)=>i("genui.chart.itemDefault",{n:f+1})):e.data=[]}t.xAxis=e}t.yAxis?typeof t.yAxis=="object"&&!Array.isArray(t.yAxis)&&(t.yAxis.type||(t.yAxis.type="value")):t.yAxis={type:"value"}}if(!t.title)t.title={text:i("genui.chart.title"),left:"left"};else if(typeof t.title=="object"){let e=t.title;e.left||(e.left="left"),e.text||(e.text=i("genui.chart.title")),t.title=e}if(t.tooltip||(t.tooltip={trigger:r==="pie"?"item":"axis"}),!t.legend)s.length>1&&(t.legend={right:0,orient:"vertical"});else if(typeof t.legend=="object"){let e=t.legend;t.legend=e}return r!=="pie"&&!t.grid&&(t.grid={left:"3%",right:"4%",bottom:"3%",containLabel:!0}),t}function O(l,i){let s=null;try{let n=typeof l=="string"?l:l.join("");s=(0,R.parse)(n)}catch(n){return{data:null,error:`Failed to parse JSON: ${n instanceof Error?n.message:String(n)}`}}if(!s||typeof s!="object")return{data:null,error:"Parsed data is not an object"};let t=s.series&&Array.isArray(s.series)&&s.series.length>0,r={table:Array.isArray(s.table)?s.table:void 0},e=null;if(s.echarts?e=s.echarts:t&&(e=s),e){let n=j(e,i);if(n)r.echarts=n;else if(r.table&&r.table.length>0)r.echarts=g(r.table,i);else return{data:null,error:"ECharts configuration is invalid or incomplete. Required: series array with at least one series containing type and data."}}else r.table&&r.table.length>0?r.echarts=g(r.table,i):r.echarts=g([],i);return{data:r,error:null}}var K=l=>{let{children:i}=l,s=v(),t=(0,u.useRef)(null),r=(0,u.useRef)(null),e=(0,u.useRef)(null),[n,o]=(0,u.useState)(null);(0,u.useEffect)(()=>{if(!t.current)return;r.current||(r.current=D(t.current));let a=null;if((typeof i=="string"||Array.isArray(i))&&(a=i),!a){r.current&&r.current.clear(),o(null);return}let{data:c,error:m}=O(a,s);if(m||!c){console.warn("ReactChart failed to parse chart data:",m||"Unknown parse error"),r.current&&r.current.clear(),o(null);return}if(c.table&&Array.isArray(c.table)&&o(c.table),c.echarts)try{r.current.setOption(c.echarts,!0)}catch(d){let A=d instanceof Error?d.message:"Failed to render chart";console.error("Failed to set ECharts option:",d),r.current&&r.current.clear(),o(null)}let h=()=>{r.current&&r.current.resize()};return e.current&&(e.current.disconnect(),e.current=null),t.current&&typeof ResizeObserver<"u"&&(e.current=new ResizeObserver(d=>{requestAnimationFrame(()=>{h()})}),e.current.observe(t.current)),window.addEventListener("resize",h),()=>{e.current&&(e.current.disconnect(),e.current=null),window.removeEventListener("resize",h)}},[i,s]),(0,u.useEffect)(()=>()=>{e.current&&(e.current.disconnect(),e.current=null),r.current&&(r.current.dispose(),r.current=null)},[]);let f=a=>{if(!a||a.length===0)return[];if(Array.isArray(a[0])){let c=a[0];return a.slice(1).map((h,d)=>{let A={};return h.forEach((S,b)=>{A[c[b]||`col_${b}`]=S}),A})}return a};return(0,y.jsxs)(x,{children:[(0,y.jsx)("div",{ref:t,style:{width:"100%",height:"400px",minHeight:"300px"}}),n&&n.length>0&&(0,y.jsx)("div",{style:{marginTop:16},children:(0,y.jsx)(E,{component_key:"chart_table_data",data:{dataSource:f(n),message:s("genui.chart.dataDetails")},interactive:!0,default_open_in_side_app:!0})})]})};export{K as ReactChart};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{b as Q,c as Se,e as Z,f as xe,g as ve,h as be,i as Te,l as Ce,m as we}from"./embed-page-chunk-7EEAFSMK.js";import{a as ge,b as me,c as ue,d as ke,e as he}from"./embed-page-chunk-SV2BM3WO.js";import"./embed-page-chunk-S4XZPBRM.js";import{a as q,b as Ne}from"./embed-page-chunk-A4I7H7RP.js";import{d as re}from"./embed-page-chunk-FYIVKZA2.js";import{o as ne}from"./embed-page-chunk-CSRF4YQD.js";import{o as H}from"./embed-page-chunk-36VOH7DG.js";import{a as j}from"./embed-page-chunk-L2PNY33P.js";import{D as de,E as pe,Ja as _,ea as ye,o as ce,sa as fe}from"./embed-page-chunk-WMHFEZXB.js";import{Ba as le,Ha as B,Qa as R,Ua as ae,fa as h,fb as A,gb as L,ha as ie,jb as se}from"./embed-page-chunk-QWLZN3EX.js";import{a as oe}from"./embed-page-chunk-MPQBYKDM.js";import{e as W}from"./embed-page-chunk-45A47GH2.js";var u=W(oe());var m=W(oe());var e=W(j()),{Text:d}=se,{TextArea:ze}=R,Ae=({data:b})=>{let{message:S}=ie.useApp(),n=H(),{token:o}=L.useToken(),{config:D}=re(),{put:T}=q(),K=Se(t=>t.transform[2])>.6,U=ne("__GLOBAL__");if(!b)return null;let{skill:p,onClick:x,onDelete:I}=b;if(!p)return null;let[i,F]=(0,m.useState)(p),k=i.subSkills&&i.subSkills.length>0,M=i.subSkills?.length||0,P=(0,m.useMemo)(()=>Math.min(12+Math.sqrt(M)*10,48),[M]),V=i.metadata&&i.metadata.category||"global",C=(0,m.useMemo)(()=>i.metadata?Object.entries(i.metadata).filter(([t,s])=>t&&s):[],[i.metadata]),$=t=>{if(!t)return"";let s=t instanceof Date?t:new Date(t);return Number.isNaN(s.getTime())?"":s.toLocaleString()},Y=t=>{navigator.clipboard.writeText(t)},[v,w]=(0,m.useState)(!1),[l,r]=(0,m.useState)({...p,id:p.name}),[y,z]=(0,m.useState)(C.map(([t,s])=>({key:t,value:s}))),[G,E]=(0,m.useState)(!1),[X,a]=(0,m.useState)(!1);(0,m.useEffect)(()=>{w(!1),F(p),r({...p,id:p.name}),z(Object.entries(p.metadata||{}).map(([t,s])=>({key:t,value:s})))},[p]);let N=(t,s)=>{if(t==="name"){r(c=>({...c,name:s,id:s}));return}r(c=>({...c,[t]:s}))},J=async t=>{t?.stopPropagation(),t?.preventDefault();try{let s=i.id||i.name;if(!s){S.error(n("chatWorkspace.skillNode.idMissing"));return}await U.skills.delete(s),S.success(n("chatWorkspace.skillNode.deleted")),E(!1),I&&await I()}catch(s){S.error(s?.message||n("chatWorkspace.skillNode.deleteFailed"))}},ee=t=>{z(t);let s=t.reduce((c,f)=>(f.key&&(c[f.key]=f.value),c),{});r(c=>({...c,metadata:s}))},te=(t,s,c)=>{let f=[...y];f[t]={...f[t],[s]:c},ee(f)},Be=()=>{ee([...y,{key:"",value:""}])},Re=async()=>{try{a(!0);let t={"Content-Type":"application/json"};D.apiKey&&(t.Authorization=`Bearer ${D.apiKey}`);let s={name:l.name,description:l.description,license:l.license||void 0,compatibility:l.compatibility||void 0,metadata:l.metadata||void 0,content:l.content||void 0,subSkills:l.subSkills||void 0},c=await T(`/api/skills/${i.id}`,s);if(c.success){S.success(n("chatWorkspace.skillNode.updated"));let f=c.data||l;F(f),r({...f,id:f.name}),z(Object.entries(f.metadata||{}).map(([Me,Ee])=>({key:Me,value:Ee}))),w(!1),x?.(f)}else S.error(c.message||n("chatWorkspace.skillNode.updateFailed"))}catch(t){S.error(t.message||n("chatWorkspace.skillNode.updateError"))}finally{a(!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:n("chatWorkspace.skills.field.description")}),(0,e.jsx)(ze,{value:l.description,onChange:t=>N("description",t.target.value),placeholder:n("chatWorkspace.skills.field.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:n("chatWorkspace.skills.field.license")}),(0,e.jsx)(R,{value:l.license,onChange:t=>N("license",t.target.value),placeholder:n("chatWorkspace.skills.field.license")})]}),(0,e.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[(0,e.jsx)(d,{style:{fontSize:12,color:o.colorTextSecondary},children:n("chatWorkspace.skills.field.compatibility")}),(0,e.jsx)(R,{value:l.compatibility,onChange:t=>N("compatibility",t.target.value),placeholder:n("chatWorkspace.skills.field.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:n("chatWorkspace.skills.field.metadata")}),(0,e.jsx)(h,{size:"small",icon:(0,e.jsx)(_,{}),onClick:Be,children:n("chatWorkspace.skillNode.add")})]}),(0,e.jsxs)(B,{direction:"vertical",size:8,style:{width:"100%"},children:[y.length===0&&(0,e.jsx)(d,{style:{fontSize:11,color:o.colorTextTertiary},children:n("chatWorkspace.skillNode.noMetadata")}),y.map((t,s)=>(0,e.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:4,width:"100%"},children:[(0,e.jsx)(d,{style:{fontSize:11,color:o.colorTextSecondary},children:n("chatWorkspace.skillNode.meta",{index:s+1})}),(0,e.jsxs)(B,{style:{width:"100%"},size:8,wrap:!0,children:[(0,e.jsx)(R,{value:t.key,placeholder:n("chatWorkspace.skillNode.keyPlaceholder"),style:{width:120},onChange:c=>te(s,"key",c.target.value)}),(0,e.jsx)(R,{value:t.value,placeholder:n("chatWorkspace.skillNode.valuePlaceholder"),style:{flex:1,minWidth:160},onChange:c=>te(s,"value",c.target.value)})]})]},s))]})]}),(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:n("chatWorkspace.skills.field.content")}),(0,e.jsx)(ze,{value:l.content,onChange:t=>N("content",t.target.value),placeholder:n("chatWorkspace.skillNode.contentPlaceholder"),rows:30,style:{fontFamily:"monospace",fontSize:13,flex:1,minHeight:600}})]})]}),Fe=(0,e.jsxs)("div",{style:{width:v?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)(A,{style:{margin:0,fontSize:10,padding:"2px 8px",fontWeight:600},color:"geekblue",children:V.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}`})})]})}),v?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,'"']})}),C.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)(fe,{style:{fontSize:14,color:o.colorTextSecondary}}),(0,e.jsx)(d,{style:{fontSize:12,color:o.colorTextSecondary,fontWeight:500},children:n("chatWorkspace.skillNode.metadataCount",{count:C.length})})]}),(0,e.jsx)("div",{style:{border:`1px solid ${o.colorBorderSecondary}`,borderRadius:6,overflow:"hidden"},children:C.map(([t,s],c)=>(0,e.jsxs)("div",{style:{display:"flex",alignItems:"stretch",borderBottom:c===C.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:s})]},t))})]}),k&&(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:["Sub-Skills (",i.subSkills.length,")"]})]}),(0,e.jsx)(B,{size:[8,8],wrap:!0,children:i.subSkills.map((t,s)=>(0,e.jsx)(A,{style:{fontSize:11,padding:"4px 12px",backgroundColor:o.colorFillTertiary,color:o.colorText,border:`1px solid ${o.colorBorderSecondary}`},children:t},s))})]}),(i.license||i.compatibility)&&(0,e.jsx)("div",{style:{marginBottom:16},children:(0,e.jsxs)(B,{size:[8,8],wrap:!0,children:[i.license&&(0,e.jsx)(A,{icon:(0,e.jsx)(pe,{}),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)(A,{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)(B,{direction:"vertical",size:4,children:[i.createdAt&&(0,e.jsxs)(d,{style:{fontSize:11,color:o.colorTextTertiary,fontFamily:"monospace"},children:["Created: ",$(i.createdAt)]}),i.updatedAt&&(0,e.jsxs)(d,{style:{fontSize:11,color:o.colorTextTertiary,fontFamily:"monospace"},children:["Updated: ",$(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)(ye,{style:{fontSize:14,color:o.colorTextSecondary}}),(0,e.jsx)(d,{style:{fontSize:12,color:o.colorTextSecondary,fontWeight:600,letterSpacing:.5},children:n("chatWorkspace.skillNode.contentSection")})]}),(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)(le,{style:{margin:"16px 0"}}),(0,e.jsx)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8},children:v?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(h,{block:!0,onClick:()=>{w(!1),r(p)},style:{flex:1},children:n("common.cancel")}),(0,e.jsx)(h,{type:"primary",block:!0,onClick:Re,loading:X,style:{flex:1},children:n("common.save")})]}):(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(h,{type:"primary",block:!0,onClick:()=>w(!0),style:{flex:1},children:n("chatWorkspace.skillNode.edit")}),(0,e.jsx)(h,{danger:!0,onClick:t=>{t.stopPropagation(),J(t)},children:n("common.delete")}),(0,e.jsx)(h,{icon:(0,e.jsx)(de,{}),onClick:()=>Y(i.id),title:n("chatWorkspace.skillNode.copyId")})]})})]});return(0,e.jsxs)("div",{style:{position:"relative",padding:4,overflow:"visible"},children:[(0,e.jsx)(Z,{type:"source",position:Q.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)(Z,{type:"target",position:Q.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:()=>E(!0),children:[(0,e.jsx)("div",{style:{width:P,height:P,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)"}}),K&&(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)(ae,{open:G,onCancel:()=>{E(!1),w(!1),r({...i,id:i.name})},footer:null,width:v?1e3:760,destroyOnClose:!0,title:null,styles:{body:{padding:0}},children:Fe})]})},We=Ae;var g=W(j()),De=({onNodeClick:b})=>{let S=H(),[n,o,D]=be([]),[T,O,K]=Te([]),[U,p]=(0,u.useState)(!1),[x,I]=(0,u.useState)([]),[i,F]=(0,u.useState)(!1),[k,M]=(0,u.useState)(null),{token:P}=L.useToken(),{get:V}=q(),C=(0,u.useMemo)(()=>({skill:We}),[]),$=(0,u.useMemo)(()=>k===null?n:n.map(l=>{let r=l.id===k||T.some(y=>y.source===k&&y.target===l.id||y.target===k&&y.source===l.id);return{...l,style:{opacity:r?1:.2,transition:"opacity 0.2s ease"}}}),[n,T,k]),Y=(0,u.useMemo)(()=>k===null?T.map(l=>({...l,style:{stroke:"#1677ff",strokeWidth:1.5,opacity:.25,transition:"opacity 0.2s ease"}})):T.map(l=>{let r=l.source===k||l.target===k;return{...l,style:{stroke:"#1677ff",strokeWidth:r?2.5:1,opacity:r?1:.04,transition:"opacity 0.2s ease"}}}),[T,k]),v=async()=>{F(!0);try{let l=await V("/api/skills");l.success&&l.data&&Array.isArray(l.data.records)&&I(l.data.records)}catch(l){console.error("Failed to fetch skills:",l),I([])}finally{F(!1)}};(0,u.useEffect)(()=>{v()},[]),(0,u.useEffect)(()=>{if(!x||x.length===0){o([]),O([]);return}let l=[],r=new Map,y=[];x.forEach(a=>{r.set(a.name,a),a.subSkills&&a.subSkills.length>0&&a.subSkills.forEach(N=>{x.find(J=>J.name===N)&&y.push({source:a.name,target:N})})});let z=x.map(a=>({id:a.name})),G=y.map(a=>({source:a.source,target:a.target})),E=ke(z).force("link",ue(G).id(a=>a.id).distance(80)).force("charge",he().strength(-300)).force("center",ge(0,0)).force("collide",me(30)).stop();for(let a=0;a<300;a++)E.tick();let X=z.map(a=>({id:a.id,type:"skill",data:{skill:r.get(a.id),onClick:()=>b?.(r.get(a.id)),onDelete:v},position:{x:a.x,y:a.y}}));y.forEach(a=>{r.has(a.source)&&r.has(a.target)&&l.push({id:`e${a.source}-${a.target}`,source:a.source,target:a.target,style:{stroke:"#1677ff",strokeWidth:2},type:"straight"})}),o(X),O(l)},[x,o,O,b]);let w=async()=>{await v()};return i?(0,g.jsx)("div",{style:{width:"100%",height:"100%",display:"flex",justifyContent:"center",alignItems:"center",background:"#fafafa"},children:S("chat.skills.loading")}):(0,g.jsxs)("div",{style:{width:"100%",height:"100%",background:"#fafafa",position:"relative"},children:[(0,g.jsxs)(ve,{nodes:$,edges:Y,onNodesChange:D,onEdgesChange:K,onNodeMouseEnter:(l,r)=>M(r.id),onNodeMouseLeave:()=>M(null),nodeTypes:C,fitView:!0,children:[(0,g.jsx)(Ce,{color:"#eee",gap:20}),(0,g.jsx)(we,{})]}),(0,g.jsx)("div",{style:{position:"absolute",top:20,right:20,zIndex:10},children:(0,g.jsx)(h,{type:"primary",size:"large",icon:(0,g.jsx)(_,{}),onClick:()=>p(!0),style:{height:48,width:48,borderRadius:"50%",boxShadow:P.boxShadowTertiary,display:"flex",alignItems:"center",justifyContent:"center",padding:0}})}),(0,g.jsx)(Ne,{open:U,onCancel:()=>p(!1),onSuccess:w})]})},Oe=b=>(0,g.jsx)(xe,{children:(0,g.jsx)(De,{...b})}),rt=Oe;export{rt as default};
|
package/dist/embed/{embed-page-TasksSideApp-PJ5LIIMG.js → embed-page-TasksSideApp-5JDZKFUH.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as Ze}from"./embed-page-chunk-
|
|
1
|
+
import{a as Ze}from"./embed-page-chunk-XGZYUTPS.js";import{c as qe,d as Ke}from"./embed-page-chunk-I6Q3MSI4.js";import{b as Ne,e as Ie,h as He,i as We}from"./embed-page-chunk-7EEAFSMK.js";import"./embed-page-chunk-S4XZPBRM.js";import{C as Ve,D as Ue,E as ue,F as Re,G as Ye,H as Qe,I as Je,K as Xe,L as et,M as tt,N as ot,r as Ge}from"./embed-page-chunk-HJYCGHWQ.js";import"./embed-page-chunk-A4I7H7RP.js";import{d as q,f as _e}from"./embed-page-chunk-F5RPCW5O.js";import"./embed-page-chunk-FYIVKZA2.js";import"./embed-page-chunk-Q54ZBF3I.js";import{l as Ee,o as Oe}from"./embed-page-chunk-CSRF4YQD.js";import{I as Fe,Qa as me,n as ce,ya as pe}from"./embed-page-chunk-BNA3NXXX.js";import{o as j}from"./embed-page-chunk-36VOH7DG.js";import{a as A}from"./embed-page-chunk-L2PNY33P.js";import"./embed-page-chunk-DLSQ2OWQ.js";import"./embed-page-chunk-F52TPGBP.js";import"./embed-page-chunk-WMHFEZXB.js";import{Ca as De,La as W,Qa as Ce,Ra as J,Ua as ze,_a as le,fa as ae,fb as Me,ha as Be,ia as Le,jb as de,ma as be}from"./embed-page-chunk-QWLZN3EX.js";import{a as se}from"./embed-page-chunk-MPQBYKDM.js";import"./embed-page-chunk-3KBY77YU.js";import"./embed-page-chunk-U2CG7PH5.js";import{e as T}from"./embed-page-chunk-45A47GH2.js";var n=T(se());var it=T(se());var s=T(A()),Tt=[{key:"pending",color:"#7A7A7A"},{key:"in_progress",color:"#3b82f6"},{key:"failed",color:"#ef4444"},{key:"interrupted",color:"#8b5cf6"},{key:"completed",color:"#22c55e"}],rt={high:"#ef4444",medium:"#f59e0b",low:"#22c55e"};function bt(e){return e==="high"||e==="low"?e:"medium"}function Ct(e,i){let f=typeof e=="string"?new Date(e):e,a=new Date().getTime()-f.getTime(),k=Math.floor(a/1e3),o=Math.floor(k/60),r=Math.floor(o/60),l=Math.floor(r/24);return k<60?i("common.time.justNow"):o<60?i("common.time.minutesAgo",{count:o}):r<24?i("common.time.hoursAgo",{count:r}):l<30?i("common.time.daysAgo",{count:l}):f.toLocaleDateString(i.locale)}var Nt=q(({css:e,token:i})=>({container:e`
|
|
2
2
|
display: flex;
|
|
3
3
|
flex-direction: column;
|
|
4
4
|
height: 100%;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as Z}from"./embed-page-chunk-Q54ZBF3I.js";import{o as X}from"./embed-page-chunk-CSRF4YQD.js";import{Aa as ee,Wa as U}from"./embed-page-chunk-BNA3NXXX.js";import{o as M}from"./embed-page-chunk-36VOH7DG.js";import{a as w}from"./embed-page-chunk-L2PNY33P.js";import{Fa as s,Ga as J,Ha as R,Qa as F,ba as _,eb as B,fa as K,fb as O,ga as q,gb as V,jb as $,ma as Y,wa as G,xa as W}from"./embed-page-chunk-QWLZN3EX.js";import{a as Q}from"./embed-page-chunk-MPQBYKDM.js";import{e as c}from"./embed-page-chunk-45A47GH2.js";var E=c(Q());function N(e){if(e==null)return"\u2014";if(e<1e3)return`${e}ms`;if(e<6e4)return`${(e/1e3).toFixed(1)}s`;let p=Math.floor(e/6e4),r=Math.floor(e%6e4/1e3);return`${p}m ${r}s`}function re(e){return N(e)}function j(e){switch(e){case"pending":return"blue";case"running":return"processing";case"success":return"green";case"error":case"timeout":return"red";case"interrupted":return"orange";case"cancelled":return"default";default:return}}function H(e){return`monitor.kind.${e}`}var D=c(w()),{Text:me}=$,ue=[{key:"pending",label:"monitor.overview.pending"},{key:"running",label:"monitor.overview.running"},{key:"stuck",label:"monitor.overview.stuck"},{key:"failed",label:"monitor.overview.failed"},{key:"pendingThreads",label:"monitor.overview.pendingThreads"},{key:"oldest",label:"monitor.overview.oldestPending"}],te=({overview:e,loading:p,error:r})=>{let T=M(),{token:y}=V.useToken();if(r!==null)return(0,D.jsx)(_,{type:"error",showIcon:!0,message:r});if(p&&e===null)return(0,D.jsx)(q,{active:!0,paragraph:{rows:1}});if(e===null)return null;let t={pending:String(e.counts.pending),running:String(e.counts.running),stuck:String(e.stuckRunning),failed:String(e.counts.error),pendingThreads:String(e.pendingThreads),oldest:re(e.oldestPendingAgeMs)};return(0,D.jsx)("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(140px, 1fr))",gap:10},children:ue.map(l=>(0,D.jsxs)(W,{size:"small",styles:{body:{padding:12}},children:[(0,D.jsx)(me,{type:"secondary",style:{fontSize:12},children:T(l.label)}),(0,D.jsx)("div",{style:{fontSize:20,fontWeight:650,color:y.colorText},children:t[l.key]})]},l.key))})};var P=c(Q());var oe=c(U());var h=c(w()),pe=["pending","running","success","error","interrupted","cancelled","timeout"],fe=["run_api","legacy","project_task"],ne=({state:e,loading:p,assistants:r,onQuery:T,onSelect:y})=>{let t=M(),[l,I]=(0,P.useState)(),[f,k]=(0,P.useState)(),[a,x]=(0,P.useState)(),[C,S]=(0,P.useState)(""),o=(0,P.useMemo)(()=>[{title:t("monitor.columns.status"),dataIndex:"status",render:n=>(0,h.jsx)(O,{color:j(n),children:t(`monitor.status.${n}`)})},{title:t("monitor.columns.run"),dataIndex:"runId",ellipsis:!0},{title:t("monitor.columns.agent"),dataIndex:"assistantId",render:n=>r.find(g=>g.id===n)?.name??n},{title:t("monitor.columns.thread"),dataIndex:"threadId",ellipsis:!0},{title:t("monitor.columns.source"),dataIndex:"source"},{title:t("monitor.columns.created"),dataIndex:"createdAt",render:n=>(0,oe.default)(n).format("YYYY-MM-DD HH:mm:ss")},{title:t("monitor.columns.duration"),key:"duration",render:(n,g)=>N(g.startedAt===null?null:(g.finishedAt??Date.now())-g.startedAt)},{title:t("monitor.columns.error"),dataIndex:"error",ellipsis:!0}],[r,t]),b=(n=0)=>{T({limit:e.limit,offset:n,...l?{status:l}:{},...f?{source:f}:{},...a?{assistantId:a}:{},...C?{createdAfter:new Date(C).toISOString()}:{}})};return(0,h.jsxs)(R,{direction:"vertical",size:12,style:{width:"100%"},children:[(0,h.jsxs)(R,{wrap:!0,children:[(0,h.jsx)(Y,{allowClear:!0,placeholder:t("monitor.filters.status"),style:{width:150},value:l,onChange:I,options:pe.map(n=>({value:n,label:t(`monitor.status.${n}`)}))}),(0,h.jsx)(Y,{allowClear:!0,placeholder:t("monitor.filters.source"),style:{width:150},value:f,onChange:k,options:fe.map(n=>({value:n,label:t(`monitor.source.${n}`)}))}),(0,h.jsx)(Y,{allowClear:!0,showSearch:!0,optionFilterProp:"label",placeholder:t("monitor.filters.assistant"),style:{width:200},value:a,onChange:x,options:r.map(n=>({value:n.id,label:n.name}))}),(0,h.jsx)(F,{type:"date",value:C,onChange:n=>S(n.target.value),style:{width:160}}),(0,h.jsx)(K,{onClick:()=>b(0),children:t("common.search")})]}),e.error!==null?(0,h.jsx)(_,{type:"error",showIcon:!0,message:e.error}):null,(0,h.jsx)(B,{rowKey:"runId",size:"small",loading:p,columns:o,dataSource:e.records,onRow:n=>({onClick:()=>y(n)}),pagination:{current:Math.floor(e.offset/e.limit)+1,pageSize:e.limit,total:e.total,onChange:n=>b((n-1)*e.limit),showSizeChanger:!1},locale:{emptyText:t("monitor.empty")}})]})};var L=c(Q());var ie=c(U());var v=c(w()),ge=["conversation","room_presence","task_execution","open_api","web_app","cron","channel"],ae=({state:e,loading:p,assistants:r,onQuery:T,onSelect:y})=>{let t=M(),[l,I]=(0,L.useState)(),[f,k]=(0,L.useState)(),[a,x]=(0,L.useState)(""),C=(0,L.useMemo)(()=>[{title:t("monitor.columns.kind"),dataIndex:"kind",render:o=>(0,v.jsx)(O,{children:t(H(o))})},{title:t("monitor.columns.thread"),dataIndex:"id",ellipsis:!0},{title:t("monitor.columns.agent"),dataIndex:"assistantId",render:o=>r.find(b=>b.id===o)?.name??o},{title:t("monitor.columns.scope"),key:"scope",render:(o,b)=>[b.workspaceId,b.projectId].filter(Boolean).join(" / ")||"\u2014"},{title:t("monitor.columns.created"),dataIndex:"createdAt",render:o=>(0,ie.default)(o).format("YYYY-MM-DD HH:mm:ss")}],[r,t]),S=(o=0)=>{T({limit:e.limit,offset:o,...l?{kind:l}:{},...f?{assistantId:f}:{},...a?{createdAfter:new Date(a).toISOString()}:{}})};return(0,v.jsxs)(R,{direction:"vertical",size:12,style:{width:"100%"},children:[(0,v.jsxs)(R,{wrap:!0,children:[(0,v.jsx)(Y,{allowClear:!0,placeholder:t("monitor.filters.kind"),style:{width:170},value:l,onChange:I,options:ge.map(o=>({value:o,label:t(H(o))}))}),(0,v.jsx)(Y,{allowClear:!0,showSearch:!0,optionFilterProp:"label",placeholder:t("monitor.filters.assistant"),style:{width:200},value:f,onChange:k,options:r.map(o=>({value:o.id,label:o.name}))}),(0,v.jsx)(F,{type:"date",value:a,onChange:o=>x(o.target.value),style:{width:160}}),(0,v.jsx)(K,{onClick:()=>S(0),children:t("common.search")})]}),e.error!==null?(0,v.jsx)(_,{type:"error",showIcon:!0,message:e.error}):null,(0,v.jsx)(B,{rowKey:"id",size:"small",loading:p,columns:C,dataSource:e.records,onRow:o=>({onClick:()=>y(o)}),pagination:{current:Math.floor(e.offset/e.limit)+1,pageSize:e.limit,total:e.total,onChange:o=>S((o-1)*e.limit),showSizeChanger:!1},locale:{emptyText:t("monitor.empty")}})]})};var z=c(U());var i=c(w()),se=({selection:e,onClose:p})=>{let r=M();return(0,i.jsx)(J,{open:e!==null,onClose:p,width:520,title:r("monitor.drawer.title"),children:e?.kind==="run"?(0,i.jsxs)(s,{column:1,size:"small",bordered:!0,children:[(0,i.jsx)(s.Item,{label:r("monitor.columns.run"),children:e.record.runId}),(0,i.jsx)(s.Item,{label:r("monitor.columns.status"),children:(0,i.jsx)(O,{color:j(e.record.status),children:r(`monitor.status.${e.record.status}`)})}),(0,i.jsx)(s.Item,{label:r("monitor.columns.agent"),children:e.record.assistantId}),(0,i.jsx)(s.Item,{label:r("monitor.columns.thread"),children:e.record.threadId}),(0,i.jsx)(s.Item,{label:r("monitor.columns.source"),children:e.record.source}),(0,i.jsx)(s.Item,{label:r("monitor.columns.scope"),children:[e.record.workspaceId,e.record.projectId].filter(Boolean).join(" / ")||"\u2014"}),(0,i.jsx)(s.Item,{label:r("monitor.columns.created"),children:(0,z.default)(e.record.createdAt).format("YYYY-MM-DD HH:mm:ss")}),(0,i.jsx)(s.Item,{label:r("monitor.columns.error"),children:e.record.error??"\u2014"}),(0,i.jsx)(s.Item,{label:r("monitor.drawer.inputPreview"),children:e.record.inputPreview??"\u2014"})]}):e?.kind==="thread"?(0,i.jsxs)(s,{column:1,size:"small",bordered:!0,children:[(0,i.jsx)(s.Item,{label:r("monitor.columns.thread"),children:e.record.id}),(0,i.jsx)(s.Item,{label:r("monitor.columns.kind"),children:(0,i.jsx)(O,{children:r(H(e.record.kind))})}),(0,i.jsx)(s.Item,{label:r("monitor.columns.agent"),children:e.record.assistantId}),(0,i.jsx)(s.Item,{label:r("monitor.columns.scope"),children:[e.record.workspaceId,e.record.projectId].filter(Boolean).join(" / ")||"\u2014"}),(0,i.jsx)(s.Item,{label:r("monitor.drawer.room"),children:e.record.roomId??"\u2014"}),(0,i.jsx)(s.Item,{label:r("monitor.drawer.task"),children:e.record.taskId??"\u2014"}),(0,i.jsx)(s.Item,{label:r("monitor.columns.created"),children:(0,z.default)(e.record.createdAt).format("YYYY-MM-DD HH:mm:ss")}),(0,i.jsx)(s.Item,{label:r("monitor.drawer.updated"),children:(0,z.default)(e.record.updatedAt).format("YYYY-MM-DD HH:mm:ss")}),(0,i.jsx)(s.Item,{label:r("monitor.drawer.expires"),children:e.record.expiresAt?(0,z.default)(e.record.expiresAt).format("YYYY-MM-DD HH:mm:ss"):"\u2014"})]}):null})};var m=c(Q());var le={records:[],total:0,limit:50,offset:0};function de(){let e=X("__GLOBAL__"),[p,r]=(0,m.useState)(null),[T,y]=(0,m.useState)(!0),[t,l]=(0,m.useState)(null),[I,f]=(0,m.useState)({...le,loading:!0,error:null}),[k,a]=(0,m.useState)({...le,loading:!0,error:null}),[x,C]=(0,m.useState)(24),S=(0,m.useRef)(0),o=(0,m.useCallback)(async(g=x)=>{let d=++S.current;y(!0),l(null);try{let A=await e.monitor.overview({sinceHours:g});d===S.current&&r(A)}catch(A){d===S.current&&l(A instanceof Error?A.message:"Failed to load overview")}finally{d===S.current&&y(!1)}},[e,x]),b=(0,m.useCallback)(async(g={})=>{f(d=>({...d,loading:!0,error:null}));try{let d=await e.monitor.threads.list(g);f({...d,loading:!1,error:null})}catch(d){f(A=>({...A,loading:!1,error:d instanceof Error?d.message:"Failed to load threads"}))}},[e]),n=(0,m.useCallback)(async(g={})=>{a(d=>({...d,loading:!0,error:null}));try{let d=await e.monitor.runs.list(g);a({...d,loading:!1,error:null})}catch(d){a(A=>({...A,loading:!1,error:d instanceof Error?d.message:"Failed to load runs"}))}},[e]);return(0,m.useEffect)(()=>{o()},[o]),(0,m.useEffect)(()=>{let g=window.setInterval(()=>{document.visibilityState==="visible"&&o()},15e3);return()=>window.clearInterval(g)},[o]),{sinceHours:x,setSinceHours:C,overview:p,overviewLoading:T,overviewError:t,refreshOverview:o,threads:I,loadThreads:b,runs:k,loadRuns:n}}var u=c(w()),{Title:he,Text:ce}=$,Ge=()=>{let e=M(),{assistants:p}=Z(),r=de(),{loadRuns:T,loadThreads:y}=r,[t,l]=(0,E.useState)(null),[I,f]=(0,E.useState)("runs"),k=p.map(a=>({id:a.id,name:a.name}));return(0,E.useEffect)(()=>{I==="runs"?T():y()},[I,T,y]),(0,u.jsxs)("div",{style:{height:"100%",display:"flex",flexDirection:"column",gap:16,padding:16,overflow:"auto"},children:[(0,u.jsxs)(R,{direction:"vertical",size:2,children:[(0,u.jsx)(he,{level:4,style:{margin:0},children:e("monitor.title")}),(0,u.jsx)(ce,{type:"secondary",children:e("monitor.subtitle")})]}),(0,u.jsxs)(R,{wrap:!0,children:[(0,u.jsx)(K,{icon:(0,u.jsx)(ee,{size:16}),onClick:()=>void r.refreshOverview(),children:e("monitor.refresh")}),(0,u.jsx)(ce,{type:"secondary",children:e("monitor.scope")})]}),(0,u.jsx)(te,{overview:r.overview,loading:r.overviewLoading,error:r.overviewError}),(0,u.jsx)(G,{activeKey:I,onChange:f,items:[{key:"runs",label:e("monitor.tabs.runs"),children:(0,u.jsx)(ne,{state:r.runs,loading:r.runs.loading,assistants:k,onQuery:a=>void r.loadRuns(a),onSelect:a=>l({kind:"run",record:a})})},{key:"threads",label:e("monitor.tabs.threads"),children:(0,u.jsx)(ae,{state:r.threads,loading:r.threads.loading,assistants:k,onQuery:a=>void r.loadThreads(a),onSelect:a=>l({kind:"thread",record:a})})}]}),(0,u.jsx)(se,{selection:t,onClose:()=>l(null)})]})};export{Ge as TenantMonitorPanel};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{h as ue,n as he}from"./embed-page-chunk-F5RPCW5O.js";import"./embed-page-chunk-FYIVKZA2.js";import"./embed-page-chunk-Q54ZBF3I.js";import{o as oe}from"./embed-page-chunk-CSRF4YQD.js";import{Aa as le,L as ce,La as de,O as se,Wa as Ae}from"./embed-page-chunk-BNA3NXXX.js";import{o as re}from"./embed-page-chunk-36VOH7DG.js";import{a as ie}from"./embed-page-chunk-L2PNY33P.js";import"./embed-page-chunk-WMHFEZXB.js";import{Ea as ne,Ha as h,Ua as ae,Wa as C,ba as d,eb as L,fa as u,fb as S,ia as F,jb as c,xa as te}from"./embed-page-chunk-QWLZN3EX.js";import{a as Pe}from"./embed-page-chunk-MPQBYKDM.js";import{e as I}from"./embed-page-chunk-45A47GH2.js";var a=I(Pe());var _=I(Ae());var t=I(ie());function f(r){return typeof r=="object"&&r!==null&&!Array.isArray(r)}function Ee(r){if(!f(r))return;let e=r.checkpoint;if(f(e)&&typeof e.checkpoint_id=="string")return e.checkpoint_id;let o=r.config;if(f(o)&&f(o.configurable)){let s=o.configurable.checkpoint_id;if(typeof s=="string")return s}}function ze(r){if(!f(r))return;if(typeof r.createdAt=="string")return r.createdAt;let e=r.checkpoint;if(f(e)&&typeof e.ts=="string")return e.ts}function He(r){switch(r){case"pending":return"blue";case"running":return"processing";case"success":return"green";case"error":case"failed":case"timeout":return"red";case"interrupted":return"orange";default:return}}function Fe(r){return r==="pending"||r==="running"}function Le(r){return r<1024?`${r} B`:r<1024*1024?`${(r/1024).toFixed(1)} KB`:`${(r/(1024*1024)).toFixed(2)} MB`}var We=({data:r})=>{let e=re(),o=r?.threadId,s=r?.assistantId,l=oe(s||"__no_assistant__"),D=(0,a.useContext)(ue),{closeSideApp:pe}=he(),[m,ge]=(0,a.useState)(null),[T,ye]=(0,a.useState)(null),[fe,me]=(0,a.useState)([]),[Te,Me]=(0,a.useState)([]),[v,R]=(0,a.useState)(!0),[K,M]=(0,a.useState)(null),[Y,O]=(0,a.useState)(null),[p,J]=(0,a.useState)({}),[b,N]=(0,a.useState)(null),[xe,W]=(0,a.useState)(!1),[ke,B]=(0,a.useState)(""),[we,$]=(0,a.useState)(!1),[Ce,G]=(0,a.useState)(!1),[P,Ie]=(0,a.useState)(null),[U,V]=(0,a.useState)(!1),[A,j]=(0,a.useState)(5),E=(0,a.useRef)(0),x=(0,a.useRef)(0),g=(0,a.useCallback)(async()=>{if(!o||!s){R(!1);return}let n=++E.current;R(!0),J({});let[i,k,X,Z]=await Promise.allSettled([l.getThreadStatus(o),l.getThreadStorage(o),l.getThreadHistory(o,{limit:10}),l.runs.list(o,s)]);if(n!==E.current)return;let w={};i.status==="fulfilled"?ge(i.value):w.status=e("chat.threadMaintenance.statusLoadFailed"),k.status==="fulfilled"?ye(k.value):w.storage=e("chat.threadMaintenance.storageLoadFailed"),X.status==="fulfilled"?me(X.value.flatMap(H=>{let ee=Ee(H);return ee===void 0?[]:[{id:ee,createdAt:ze(H),raw:H}]})):w.history=e("chat.threadMaintenance.historyLoadFailed"),Z.status==="fulfilled"?Me(Z.value):w.runs=e("chat.threadMaintenance.runsLoadFailed"),J(w),R(!1)},[s,l,e,o]);(0,a.useEffect)(()=>(g(),()=>{E.current+=1}),[g]);let Se=async n=>{if(!o)return;let i=++x.current;W(!0),$(!0),B("");try{let k=await l.getThreadStateAtCheckpoint(o,n.id);i===x.current&&B(JSON.stringify(k,null,2))}catch{i===x.current&&B(e("chat.threadMaintenance.stateFailed"))}finally{i===x.current&&$(!1)}},ve=()=>{x.current+=1,W(!1)},Re=async()=>{if(o){G(!0),M(null);try{let n=await l.copyThread(o);Ie(n.id)}catch{M(e("chat.threadMaintenance.copyFailed"))}finally{G(!1)}}},q=async n=>{if(!o)return;V(!0),M(null);let i=Math.min(100,Math.max(1,Math.trunc(A)));j(i);try{if(!(await l.pruneThread(o,n==="delete"?{strategy:n}:{strategy:n,keep:i})).pruned){M(e("chat.threadMaintenance.pruneFailed"));return}if(n==="delete"){pe();return}await g()}catch{M(e("chat.threadMaintenance.pruneFailed"))}finally{V(!1)}},z=(0,a.useCallback)(async(n,i)=>{if(!(!o||!s)){N(n),O(null);try{await l.runs.cancel(o,n,{action:i},s),await g()}catch{O(e("chat.threadMaintenance.runCancelFailed"))}finally{N(null)}}},[s,l,g,e,o]),Q=m?.interrupts??[],be=(0,a.useMemo)(()=>[{title:e("chat.threadMaintenance.runStatus"),dataIndex:"status",render:n=>(0,t.jsx)(S,{color:He(n),children:n})},{title:e("chat.threadMaintenance.runId"),dataIndex:"runId",render:n=>(0,t.jsx)(c.Text,{code:!0,ellipsis:{tooltip:n},style:{maxWidth:180},children:n})},{title:e("chat.threadMaintenance.runCreated"),dataIndex:"createdAt",render:n=>(0,_.default)(n).format("YYYY-MM-DD HH:mm:ss")},{title:e("chat.threadMaintenance.runOwner"),key:"owner",render:(n,i)=>(0,t.jsxs)(h,{size:4,children:[(0,t.jsx)(c.Text,{children:i.owner??"\u2014"}),(0,t.jsx)(c.Text,{type:"secondary",children:"/"}),(0,t.jsx)(c.Text,{type:"secondary",children:i.attempts})]})},{key:"actions",render:(n,i)=>Fe(i.status)?(0,t.jsxs)(h,{size:4,children:[(0,t.jsx)(C,{title:e("chat.threadMaintenance.interruptRunConfirm"),okText:e("chat.threadMaintenance.interruptRun"),cancelText:e("common.cancel"),onConfirm:()=>void z(i.runId,"interrupt"),children:(0,t.jsx)(u,{size:"small",type:"link",loading:b===i.runId,children:e("chat.threadMaintenance.interruptRun")})}),(0,t.jsx)(C,{title:e("chat.threadMaintenance.rollbackRunConfirm"),okText:e("chat.threadMaintenance.rollbackRun"),cancelText:e("common.cancel"),onConfirm:()=>void z(i.runId,"rollback"),children:(0,t.jsx)(u,{size:"small",type:"link",danger:!0,loading:b===i.runId,children:e("chat.threadMaintenance.rollbackRun")})})]}):null}],[z,b,e]),Be=(0,a.useMemo)(()=>[{title:e("chat.threadMaintenance.checkpointId"),dataIndex:"id",render:n=>(0,t.jsx)(c.Text,{code:!0,children:n})},{title:e("chat.threadMaintenance.checkpointTime"),dataIndex:"createdAt",render:n=>n?(0,_.default)(n).format("YYYY-MM-DD HH:mm:ss"):e("chat.threadMaintenance.unknown")},{key:"actions",render:(n,i)=>(0,t.jsx)(u,{size:"small",type:"link",onClick:()=>void Se(i),children:e("chat.threadMaintenance.viewState")})}],[e]);return!o||!s?(0,t.jsx)(d,{type:"warning",showIcon:!0,message:e("chat.threadMaintenance.missingContext")}):(0,t.jsxs)(te,{title:(0,t.jsxs)(h,{children:[(0,t.jsx)(se,{size:16}),e("chat.threadMaintenance.title")]}),extra:(0,t.jsxs)(h,{wrap:!0,children:[(0,t.jsx)(u,{icon:(0,t.jsx)(le,{size:14}),onClick:()=>void g(),loading:v,children:e("common.refresh")}),(0,t.jsx)(u,{icon:(0,t.jsx)(ce,{size:14}),loading:Ce,onClick:()=>void Re(),children:e("chat.threadMaintenance.copy")})]}),children:[(0,t.jsxs)(h,{direction:"vertical",size:14,style:{width:"100%"},children:[K?(0,t.jsx)(d,{type:"error",showIcon:!0,message:K}):null,p.status?(0,t.jsx)(d,{type:"error",showIcon:!0,message:p.status}):null,p.storage?(0,t.jsx)(d,{type:"warning",showIcon:!0,message:p.storage}):null,p.history?(0,t.jsx)(d,{type:"warning",showIcon:!0,message:p.history}):null,p.runs?(0,t.jsx)(d,{type:"warning",showIcon:!0,message:p.runs}):null,P?(0,t.jsx)(d,{type:"success",showIcon:!0,message:e("chat.threadMaintenance.copySuccess",{id:P}),action:D?.selectThread?(0,t.jsx)(u,{size:"small",onClick:()=>D.selectThread(P),children:e("chat.threadMaintenance.switchToCopy")}):null}):null,(0,t.jsxs)(h,{wrap:!0,size:16,children:[(0,t.jsx)(y,{label:e("chat.threadMaintenance.status"),children:(0,t.jsx)(S,{color:m?.status==="idle"?"green":m?.status==="error"?"red":"blue",children:m?.status??e("chat.threadMaintenance.unknown")})}),(0,t.jsx)(y,{label:e("chat.threadMaintenance.pendingMessages"),children:m?.pendingMessages??0}),(0,t.jsx)(y,{label:e("chat.threadMaintenance.storage"),children:T?Le(T.totalBytes):e("chat.threadMaintenance.unknown")}),(0,t.jsx)(y,{label:e("chat.threadMaintenance.checkpoints"),children:T?.checkpoints.count??0}),(0,t.jsx)(y,{label:e("chat.threadMaintenance.channelValues"),children:T?.channelValues.count??0}),(0,t.jsx)(y,{label:e("chat.threadMaintenance.pendingWrites"),children:T?.pendingWrites.count??0})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)(c.Text,{strong:!0,children:e("chat.threadMaintenance.interrupts")}),(0,t.jsx)("div",{style:{marginTop:6},children:Q.length===0?(0,t.jsx)(c.Text,{type:"secondary",children:e("chat.threadMaintenance.noInterrupts")}):(0,t.jsx)(h,{wrap:!0,children:Q.map(n=>(0,t.jsxs)(S,{color:"orange",children:[n.type,": ",n.interruptId]},n.interruptId))})})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)(c.Text,{strong:!0,children:e("chat.threadMaintenance.runs")}),Y?(0,t.jsx)(d,{type:"error",showIcon:!0,message:Y,style:{marginTop:6}}):null,(0,t.jsx)(L,{rowKey:"runId",size:"small",columns:be,dataSource:Te,pagination:!1,loading:v,locale:{emptyText:(0,t.jsx)(F,{description:e("chat.threadMaintenance.noRuns")})}})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)(c.Text,{strong:!0,children:e("chat.threadMaintenance.history")}),(0,t.jsx)(L,{rowKey:"id",size:"small",columns:Be,dataSource:fe,pagination:!1,loading:v,locale:{emptyText:(0,t.jsx)(F,{description:e("chat.threadMaintenance.noHistory")})}})]}),(0,t.jsxs)(h,{wrap:!0,children:[(0,t.jsx)(C,{title:e("chat.threadMaintenance.pruneDeleteTitle"),description:e("chat.threadMaintenance.pruneDeleteConfirm"),okText:e("common.delete"),cancelText:e("common.cancel"),okButtonProps:{danger:!0},onConfirm:()=>void q("delete"),children:(0,t.jsx)(u,{danger:!0,icon:(0,t.jsx)(de,{size:14}),loading:U,children:e("chat.threadMaintenance.pruneDelete")})}),(0,t.jsx)(ne,{"aria-label":e("chat.threadMaintenance.keepLabel"),min:1,max:100,precision:0,step:1,value:A,onChange:n=>{j(typeof n=="number"?Math.min(100,Math.max(1,Math.trunc(n))):1)}}),(0,t.jsx)(C,{title:e("chat.threadMaintenance.pruneKeepTitle"),description:e("chat.threadMaintenance.pruneKeepConfirm",{count:A}),okText:e("chat.threadMaintenance.pruneKeepLatest"),cancelText:e("common.cancel"),onConfirm:()=>void q("keep_latest"),children:(0,t.jsx)(u,{loading:U,children:e("chat.threadMaintenance.pruneKeepLatest")})})]})]}),(0,t.jsx)(ae,{open:xe,title:e("chat.threadMaintenance.stateTitle"),footer:null,onCancel:ve,width:720,children:we?(0,t.jsx)(c.Text,{children:e("chat.threadMaintenance.loadingState")}):(0,t.jsx)("pre",{style:{maxHeight:"60vh",overflow:"auto",margin:0},children:ke})})]})},y=({label:r,children:e})=>(0,t.jsxs)("div",{children:[(0,t.jsx)(c.Text,{type:"secondary",style:{display:"block",fontSize:12},children:r}),(0,t.jsx)(c.Text,{strong:!0,children:e})]});export{We as ThreadMaintenancePanel};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as pe,c as ue}from"./embed-page-chunk-
|
|
1
|
+
import{a as pe,c as ue}from"./embed-page-chunk-A4EW4WEZ.js";import{a as ve}from"./embed-page-chunk-I6Q3MSI4.js";import{a as ne,b as O,e as G,f as V,g as ie,h as re,i as se,k as ae,l as le,m as de,n as ce}from"./embed-page-chunk-7EEAFSMK.js";import"./embed-page-chunk-S4XZPBRM.js";import{j}from"./embed-page-chunk-HJYCGHWQ.js";import{a as H}from"./embed-page-chunk-A4I7H7RP.js";import"./embed-page-chunk-F5RPCW5O.js";import"./embed-page-chunk-FYIVKZA2.js";import"./embed-page-chunk-Q54ZBF3I.js";import"./embed-page-chunk-CSRF4YQD.js";import{A as te,E as L,Pa as oe,g as ee,ma as $,y as M}from"./embed-page-chunk-BNA3NXXX.js";import{o as C}from"./embed-page-chunk-36VOH7DG.js";import{a as I}from"./embed-page-chunk-L2PNY33P.js";import"./embed-page-chunk-DLSQ2OWQ.js";import"./embed-page-chunk-F52TPGBP.js";import{G as q,Ma as Q}from"./embed-page-chunk-WMHFEZXB.js";import{Ga as Y,Ha as B,Ra as F,Sa as J,Wa as K,_a as Z,fb as z,ia as E,jb as X,oa as P}from"./embed-page-chunk-QWLZN3EX.js";import{a as _}from"./embed-page-chunk-MPQBYKDM.js";import"./embed-page-chunk-3KBY77YU.js";import"./embed-page-chunk-U2CG7PH5.js";import{e as b}from"./embed-page-chunk-45A47GH2.js";var s=b(_());var U=b(ve());var ge=b(_());var me=b(I()),fe=({steps:t,graphDefinition:o,assistantId:n})=>{let i=(0,ge.useMemo)(()=>ue(o),[o]);return(0,me.jsx)(pe,{dsl:i,steps:t,assistantId:n})};var e=b(I()),ke=`
|
|
2
2
|
@keyframes spin {
|
|
3
3
|
from { transform: rotate(0deg); }
|
|
4
4
|
to { transform: rotate(360deg); }
|