@arcgis/ai-components 5.2.0-next.7 → 5.2.0-next.71
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/README.md +2 -2
- package/dist/agent-utils/FunctionAgent.d.ts +2 -2
- package/dist/agent-utils/LLMAgent.d.ts +2 -2
- package/dist/agent-utils/LLMAgent.js +2 -1
- package/dist/agent-utils/WorkflowAgent.d.ts +2 -2
- package/dist/agent-utils/index.d.ts +177 -0
- package/dist/agent-utils/index.js +167 -0
- package/dist/agent-utils/middlewares/trace.d.ts +2 -0
- package/dist/agent-utils/middlewares/trace.js +25 -33
- package/dist/agent-utils/tools/FunctionTool.d.ts +2 -2
- package/dist/agent-utils/types.d.ts +36 -7
- package/dist/agent-utils/workflows/ConditionalWorkflow.d.ts +2 -2
- package/dist/agent-utils/workflows/LoopWorkflow.d.ts +2 -2
- package/dist/agent-utils/workflows/ParallelWorkflow.d.ts +2 -2
- package/dist/agent-utils/workflows/RouterWorkflow.d.ts +2 -2
- package/dist/agent-utils/workflows/SequentialWorkflow.d.ts +2 -2
- package/dist/agent-utils/workflows/SwitchWorkflow.d.ts +2 -2
- package/dist/cdn/{H7422XUG.js → 2GH3K5JP.js} +1 -1
- package/dist/cdn/2Y4DTOGT.js +2 -0
- package/dist/cdn/3DJDRAGV.js +2 -0
- package/dist/cdn/3S5G5SIX.js +2 -0
- package/dist/cdn/{AMP6IALT.js → 3UEKINYC.js} +1 -1
- package/dist/cdn/3ZPPYCNL.js +2 -0
- package/dist/cdn/434TAA3J.js +2 -0
- package/dist/cdn/4CEMUECT.js +2 -0
- package/dist/cdn/4PCAK3ET.js +2 -0
- package/dist/cdn/57OMVTIU.js +2 -0
- package/dist/cdn/5TI2F5XX.js +2 -0
- package/dist/cdn/6TA5KFAQ.js +4 -0
- package/dist/cdn/6U7TEAAJ.js +2 -0
- package/dist/cdn/{ZS2TZ6BF.js → AOVJ34QE.js} +1 -1
- package/dist/cdn/APFZY4PI.js +2 -0
- package/dist/cdn/B6CJG5UH.js +66 -0
- package/dist/cdn/BE7ZN5FZ.js +2 -0
- package/dist/cdn/{FL4W4VYN.js → BL273EGZ.js} +17 -1
- package/dist/cdn/BNSJO6X2.js +2 -0
- package/dist/cdn/{5ZZGKP7N.js → CEKOEHB3.js} +1 -1
- package/dist/cdn/CMDRED5H.js +2 -0
- package/dist/cdn/CXW5URTF.js +14 -0
- package/dist/cdn/DCSZPL7R.js +2 -0
- package/dist/cdn/DTIVDIDY.js +2 -0
- package/dist/cdn/DUSILSNJ.js +9 -0
- package/dist/cdn/E5ZKBC24.js +36 -0
- package/dist/cdn/FSGIG7UN.js +2 -0
- package/dist/cdn/{ZLXN7NMF.js → FYZATVB3.js} +10 -8
- package/dist/cdn/GLBE7OW2.js +2 -0
- package/dist/cdn/GP6NDTUE.js +18 -0
- package/dist/cdn/HBLRVXEB.js +2 -0
- package/dist/cdn/HJG7QM2R.js +9 -0
- package/dist/cdn/HQXPPYMD.js +2 -0
- package/dist/cdn/{FX7UOGHP.js → ICBIUFK7.js} +1 -1
- package/dist/cdn/ICYUPLZM.js +56 -0
- package/dist/cdn/IEHPNCTL.js +2 -0
- package/dist/cdn/IHP25JWI.js +99 -0
- package/dist/cdn/J6A4AS7E.js +22 -0
- package/dist/cdn/{NE7E52YR.js → JEBRN3EU.js} +9 -3
- package/dist/cdn/KKLAQF3Z.js +2 -0
- package/dist/cdn/KLYNL2ZT.js +2 -0
- package/dist/cdn/KQHLOYKL.js +3 -0
- package/dist/cdn/LHLO6PTD.js +2 -0
- package/dist/cdn/{7RCQFLPP.js → LK7ZIQW6.js} +1 -1
- package/dist/cdn/LUY6V4TP.js +181 -0
- package/dist/cdn/M3MRIGDZ.js +2 -0
- package/dist/cdn/{VOQX4AVB.js → MW5S2XCB.js} +6 -4
- package/dist/cdn/MWYBF3F3.js +66 -0
- package/dist/cdn/NEV6OZN3.js +71 -0
- package/dist/cdn/OKMZQXBQ.js +2 -0
- package/dist/cdn/OKTBWKNG.js +2 -0
- package/dist/cdn/{23EQTPO3.js → OKVLGJAG.js} +1 -1
- package/dist/cdn/OWXCOUIQ.js +2 -0
- package/dist/cdn/OYNIFMCJ.js +2 -0
- package/dist/cdn/{LQ6R5YRN.js → PQ2DPOFM.js} +1 -1
- package/dist/cdn/PUFTYLJ2.js +22 -0
- package/dist/cdn/PVE7Q43N.js +2 -0
- package/dist/cdn/R74ZHFA6.js +2 -0
- package/dist/cdn/RLEHNAIA.js +2 -0
- package/dist/cdn/{X2ZDYHCG.js → SDWWUWAF.js} +10 -5
- package/dist/cdn/ST5FQYT7.js +180 -0
- package/dist/cdn/SXHH575T.js +48 -0
- package/dist/cdn/T4ECSHM7.js +2 -0
- package/dist/cdn/TFT6HK3O.js +208 -0
- package/dist/cdn/TPULIO6I.js +34 -0
- package/dist/cdn/U3XIDLHO.js +3 -0
- package/dist/cdn/{6YMR4QSD.js → UHEYPSOR.js} +1 -1
- package/dist/cdn/UZLQALHY.js +2 -0
- package/dist/cdn/V6HOUZPZ.js +2 -0
- package/dist/cdn/VAXH6RUQ.js +134 -0
- package/dist/cdn/VXFQANGJ.js +2 -0
- package/dist/cdn/WQGJATNJ.js +2 -0
- package/dist/cdn/WSHWQDO2.js +2 -0
- package/dist/cdn/WUNCZOGU.js +2 -0
- package/dist/cdn/WVPU4QOO.js +2 -0
- package/dist/cdn/WXWO5D3W.js +2 -0
- package/dist/cdn/XCRR2EEG.js +6 -0
- package/dist/cdn/XETNZW4D.js +3 -0
- package/dist/cdn/XRE5USHA.js +2 -0
- package/dist/cdn/YHQJ66WJ.js +2 -0
- package/dist/cdn/ZCEMEUP7.js +2 -0
- package/dist/cdn/ZS6SXJP2.js +2 -0
- package/dist/cdn/{ZTBA5PM7.js → ZU2FHVNK.js} +1 -1
- package/dist/cdn/agent-utils/index.js +2 -0
- package/dist/cdn/agent-utils/middlewares/humanInTheLoop.js +3 -0
- package/dist/cdn/agent-utils/middlewares/middleware.js +2 -0
- package/dist/cdn/agent-utils/middlewares/trace.js +2 -0
- package/dist/cdn/index.js +1 -1
- package/dist/chunks/adapter.js +1795 -1598
- package/dist/chunks/arcgisKnowledgeGraph.js +127 -72
- package/dist/chunks/arcgis_knowledge_current_lc_context.js +19 -2
- package/dist/chunks/arcgis_knowledge_current_map_context.js +31 -2
- package/dist/chunks/arcgis_knowledge_cypher_query_prompt.js +102 -0
- package/dist/chunks/arcgis_knowledge_summarize_result_prompt.js +116 -27
- package/dist/chunks/converterUtils.js +39 -32
- package/dist/chunks/dataExplorationGraph.js +140 -114
- package/dist/chunks/data_explore_query_prompt.js +9 -4
- package/dist/chunks/generateLayerDescriptions.js +265 -240
- package/dist/chunks/helpGraph.js +30 -23
- package/dist/chunks/help_prompt.js +34 -17
- package/dist/chunks/index.js +11 -0
- package/dist/chunks/intent_prompt.js +16 -0
- package/dist/chunks/layerStylingGraph.js +25 -21
- package/dist/chunks/navigationGraph.js +79 -70
- package/dist/chunks/navigation_intent_prompt.js +8 -2
- package/dist/chunks/orchestrator.js +205 -175
- package/dist/chunks/slottableRequestUtils.js +3 -7
- package/dist/chunks/state.js +1 -1
- package/dist/chunks/summarize_query_response_prompt.js +9 -7
- package/dist/chunks/toolCallResponse.js +13 -10
- package/dist/chunks/utils2.js +8 -8
- package/dist/components/arcgis-assistant/customElement.d.ts +27 -0
- package/dist/components/arcgis-assistant/customElement.js +386 -152
- package/dist/components/arcgis-assistant/index.js +2 -3
- package/dist/components/arcgis-assistant/types.d.ts +14 -1
- package/dist/components/arcgis-assistant-agent/customElement.js +5 -1
- package/dist/components/arcgis-assistant-chat/customElement.d.ts +2 -1
- package/dist/components/arcgis-assistant-chat/customElement.js +23 -18
- package/dist/components/arcgis-assistant-chat-entry/customElement.d.ts +2 -0
- package/dist/components/arcgis-assistant-chat-entry/customElement.js +25 -18
- package/dist/components/arcgis-assistant-data-exploration-agent/customElement.js +12 -6
- package/dist/components/arcgis-assistant-help-agent/customElement.js +9 -3
- package/dist/components/arcgis-assistant-interrupt/customElement.js +12 -8
- package/dist/components/arcgis-assistant-interrupt-preview/customElement.js +20 -0
- package/dist/components/arcgis-assistant-interrupt-preview/index.js +2 -0
- package/dist/components/arcgis-assistant-knowledge-agent/customElement.d.ts +7 -7
- package/dist/components/arcgis-assistant-knowledge-agent/customElement.js +18 -12
- package/dist/components/arcgis-assistant-layer-styling-agent/customElement.js +11 -5
- package/dist/components/arcgis-assistant-message/customElement.d.ts +2 -0
- package/dist/components/arcgis-assistant-message/customElement.js +28 -26
- package/dist/components/arcgis-assistant-message/index.js +2 -0
- package/dist/components/arcgis-assistant-message-block/customElement.js +18 -11
- package/dist/components/arcgis-assistant-message-block/index.js +1 -0
- package/dist/components/arcgis-assistant-message-loading/customElement.d.ts +4 -0
- package/dist/components/arcgis-assistant-message-loading/customElement.js +10 -10
- package/dist/components/arcgis-assistant-message-loading/index.js +1 -0
- package/dist/components/arcgis-assistant-message-text/customElement.d.ts +1 -0
- package/dist/components/arcgis-assistant-message-text/customElement.js +12 -12
- package/dist/components/arcgis-assistant-navigation-agent/customElement.js +12 -6
- package/dist/components/arcgis-assistant-speech-input/customElement.js +29 -46
- package/dist/components/arcgis-assistant-suggested-prompts/customElement.js +8 -8
- package/dist/components/arcgis-assistant-user-message/customElement.js +10 -8
- package/dist/docs/api.json +1 -1
- package/dist/docs/docs.json +1 -1
- package/dist/docs/vscode.html-custom-data.json +1 -1
- package/dist/docs/web-types.json +1 -1
- package/dist/loader.js +7 -6
- package/dist/oauth-callback.html +1 -1
- package/dist/types/lumina.d.ts +7 -6
- package/dist/types/preact.d.ts +7 -6
- package/dist/types/react.d.ts +7 -6
- package/dist/types/stencil.d.ts +7 -6
- package/dist/utils/index.d.ts +95 -47
- package/dist/utils/index.js +80 -65
- package/package.json +12 -11
- package/dist/cdn/2AXF774U.js +0 -2
- package/dist/cdn/3NI46YCE.js +0 -2
- package/dist/cdn/3PKJWIC3.js +0 -2
- package/dist/cdn/462JBSEV.js +0 -422
- package/dist/cdn/47FWPQ2A.js +0 -16
- package/dist/cdn/5QAHYX7Y.js +0 -5
- package/dist/cdn/7BCR6TUO.js +0 -2
- package/dist/cdn/7GH7VSB2.js +0 -2
- package/dist/cdn/7PLV4QH6.js +0 -2
- package/dist/cdn/AEJHYRGT.js +0 -166
- package/dist/cdn/AO7BQHKC.js +0 -2
- package/dist/cdn/AXDZBBNL.js +0 -45
- package/dist/cdn/BFZJNJL6.js +0 -22
- package/dist/cdn/DDLZOMUY.js +0 -2
- package/dist/cdn/DHOVCT6R.js +0 -2
- package/dist/cdn/F2AHA4GB.js +0 -54
- package/dist/cdn/FX5JFRDL.js +0 -2
- package/dist/cdn/GCQLVNNC.js +0 -14
- package/dist/cdn/HB5A5R2E.js +0 -2
- package/dist/cdn/JV4SI65E.js +0 -108
- package/dist/cdn/KMQ3SP4I.js +0 -5
- package/dist/cdn/MH5RPXHM.js +0 -2
- package/dist/cdn/NAUXSHIE.js +0 -72
- package/dist/cdn/NVI3I46B.js +0 -2
- package/dist/cdn/OAVEHGB6.js +0 -2
- package/dist/cdn/OH64RMOR.js +0 -4
- package/dist/cdn/P6OPJQMC.js +0 -3
- package/dist/cdn/QR54T33D.js +0 -2
- package/dist/cdn/R6HV42YW.js +0 -3
- package/dist/cdn/RVOAPUBN.js +0 -2
- package/dist/cdn/SXDLXCIM.js +0 -2
- package/dist/cdn/USMDJUFS.js +0 -2
- package/dist/cdn/V2P4AIGG.js +0 -2
- package/dist/cdn/V7OJRG26.js +0 -36
- package/dist/cdn/Y333DGV6.js +0 -2
- package/dist/cdn/YIMNOUTF.js +0 -2
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import
|
|
2
|
+
import A from "@arcgis/core/identity/IdentityManager.js";
|
|
3
3
|
import C from "@arcgis/core/portal/Portal.js";
|
|
4
|
-
import {
|
|
5
|
-
import { isGraphInterrupt as
|
|
6
|
-
import {
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
|
|
11
|
-
|
|
4
|
+
import { n as k, o as b, D as M, p as D, q as F, W as $ } from "./generateLayerDescriptions.js";
|
|
5
|
+
import { isGraphInterrupt as L, StateGraph as W, START as q, END as j, MemorySaver as H } from "@langchain/langgraph/web";
|
|
6
|
+
import { generateGuid as P } from "@arcgis/toolkit/string";
|
|
7
|
+
import { HumanMessage as O, AIMessage as T } from "@langchain/core/messages";
|
|
8
|
+
import { s as l } from "./index.js";
|
|
9
|
+
import * as U from "@arcgis/core/core/reactiveUtils.js";
|
|
10
|
+
import N from "@arcgis/core/layers/FeatureLayer.js";
|
|
11
|
+
import G from "@arcgis/core/request.js";
|
|
12
|
+
const _ = async (t) => {
|
|
13
|
+
const e = await V(), n = await k("default"), s = C.getDefault(), a = (await A.getCredential(`${s.url}/sharing`)).token, i = {
|
|
12
14
|
type: "generateEmbeddings",
|
|
13
15
|
webmapEmbeddings: t,
|
|
14
|
-
auth: { apiUrl:
|
|
16
|
+
auth: { apiUrl: n, token: a }
|
|
15
17
|
};
|
|
16
18
|
return e.postMessage(i), await new Promise((c, d) => {
|
|
17
19
|
const o = (u) => {
|
|
@@ -21,59 +23,59 @@ const U = async (t) => {
|
|
|
21
23
|
};
|
|
22
24
|
e.addEventListener("message", o), e.addEventListener("error", g, { once: !0 });
|
|
23
25
|
}), e;
|
|
24
|
-
},
|
|
26
|
+
}, V = async () => {
|
|
25
27
|
{
|
|
26
28
|
const t = (await import("./embeddings.worker.js")).default;
|
|
27
29
|
return new t();
|
|
28
30
|
}
|
|
29
|
-
},
|
|
31
|
+
}, z = (t) => {
|
|
30
32
|
t.currentIntent = "none";
|
|
31
|
-
},
|
|
32
|
-
const
|
|
33
|
+
}, Q = async (t, e) => {
|
|
34
|
+
const n = b(e);
|
|
33
35
|
if (t.agentExecutionContext.userRequest) {
|
|
34
|
-
const
|
|
35
|
-
t.agentExecutionContext.messages = [...t.agentExecutionContext.messages,
|
|
36
|
+
const r = new O(t.agentExecutionContext.userRequest.trim());
|
|
37
|
+
t.agentExecutionContext.messages = [...t.agentExecutionContext.messages, r], z(t);
|
|
36
38
|
}
|
|
37
|
-
const s =
|
|
39
|
+
const s = n?.services.agentRegistry.list().map((r) => r.agent.id) ?? [];
|
|
38
40
|
return await l({ text: `Available agents: ${[...s].join(", ")}` }, e), await l({ text: "Analyzing user input" }, e), t;
|
|
39
|
-
},
|
|
40
|
-
if (!
|
|
41
|
+
}, B = async (t, e) => (await l({ text: "Exiting..." }, e), t), f = (t) => typeof t == "object" && t !== null && !Array.isArray(t), J = (t, e) => {
|
|
42
|
+
if (!f(t)) {
|
|
41
43
|
t !== void 0 && console.warn(`Agent "${e}" returned invalid sharedStatePatch. Ignoring it.`);
|
|
42
44
|
return;
|
|
43
45
|
}
|
|
44
|
-
const
|
|
45
|
-
for (const [s,
|
|
46
|
-
if (!
|
|
46
|
+
const n = {};
|
|
47
|
+
for (const [s, r] of Object.entries(t)) {
|
|
48
|
+
if (!f(r) || !("value" in r)) {
|
|
47
49
|
console.warn(
|
|
48
50
|
`Agent "${e}" returned invalid sharedStatePatch entry for key "${s}". Ignoring that entry.`
|
|
49
51
|
);
|
|
50
52
|
continue;
|
|
51
53
|
}
|
|
52
|
-
|
|
54
|
+
n[s] = { value: r.value };
|
|
53
55
|
}
|
|
54
|
-
return
|
|
55
|
-
},
|
|
56
|
-
const { previousSharedState: e, patch:
|
|
57
|
-
if (!
|
|
56
|
+
return n;
|
|
57
|
+
}, K = (t) => {
|
|
58
|
+
const { previousSharedState: e, patch: n, agentId: s } = t;
|
|
59
|
+
if (!n)
|
|
58
60
|
return e;
|
|
59
|
-
const
|
|
61
|
+
const r = Date.now(), a = {
|
|
60
62
|
...e
|
|
61
63
|
};
|
|
62
|
-
for (const [i, c] of Object.entries(
|
|
64
|
+
for (const [i, c] of Object.entries(n))
|
|
63
65
|
c?.value !== void 0 && (a[i] = {
|
|
64
66
|
value: c.value,
|
|
65
67
|
meta: {
|
|
66
68
|
updatedByAgentId: s,
|
|
67
|
-
updatedAt:
|
|
69
|
+
updatedAt: r
|
|
68
70
|
}
|
|
69
71
|
});
|
|
70
72
|
return a;
|
|
71
|
-
},
|
|
73
|
+
}, E = (t) => {
|
|
72
74
|
if (typeof t != "string")
|
|
73
75
|
return;
|
|
74
76
|
const e = t.trim();
|
|
75
77
|
return e || void 0;
|
|
76
|
-
},
|
|
78
|
+
}, X = (t) => {
|
|
77
79
|
switch (t) {
|
|
78
80
|
case "failed":
|
|
79
81
|
return "Agent failed without a summary.";
|
|
@@ -84,39 +86,39 @@ const U = async (t) => {
|
|
|
84
86
|
default:
|
|
85
87
|
return "Agent completed without a summary.";
|
|
86
88
|
}
|
|
87
|
-
},
|
|
88
|
-
const
|
|
89
|
+
}, Y = (t, e) => {
|
|
90
|
+
const n = E(e?.outputMessage), s = E(e?.summary), r = e?.status, a = r === "success" || r === "failed" ? r : "unknown";
|
|
89
91
|
a === "unknown" && console.warn(`Agent "${t}" returned missing/invalid status. Defaulting to "unknown".`);
|
|
90
|
-
const i =
|
|
92
|
+
const i = J(e?.sharedStatePatch, t);
|
|
91
93
|
return {
|
|
92
|
-
outputMessage:
|
|
93
|
-
summary: s ??
|
|
94
|
+
outputMessage: n,
|
|
95
|
+
summary: s ?? n ?? X(a),
|
|
94
96
|
status: a,
|
|
95
97
|
sharedStatePatch: i
|
|
96
98
|
};
|
|
97
|
-
},
|
|
98
|
-
const
|
|
99
|
-
if (
|
|
99
|
+
}, x = 4e3, Z = async (t, e) => {
|
|
100
|
+
const n = b(e);
|
|
101
|
+
if (e?.signal?.aborted)
|
|
100
102
|
return await l({ text: "Run cancelled; skipping agent execution" }, e), {
|
|
101
103
|
...t,
|
|
102
104
|
currentIntent: "none",
|
|
103
105
|
requiresFollowUp: !1
|
|
104
106
|
};
|
|
105
|
-
const { agentRegistry: s } =
|
|
106
|
-
if (!
|
|
107
|
+
const { agentRegistry: s } = n?.services ?? {}, r = s?.get(t.currentIntent);
|
|
108
|
+
if (!r)
|
|
107
109
|
return console.warn(`No agent found for intent: ${t.currentIntent}`), t;
|
|
108
|
-
await l({ text: `Executing registered agent: ${
|
|
110
|
+
await l({ text: `Executing registered agent: ${r.agent.name}` }, e);
|
|
109
111
|
const a = {
|
|
110
112
|
...e ?? {},
|
|
111
113
|
configurable: {
|
|
112
|
-
...
|
|
113
|
-
agentId:
|
|
114
|
-
context:
|
|
114
|
+
...n ?? {},
|
|
115
|
+
agentId: r.agent.id,
|
|
116
|
+
context: r.getContext ? await r.getContext() : void 0
|
|
115
117
|
}
|
|
116
118
|
};
|
|
117
119
|
let i;
|
|
118
120
|
try {
|
|
119
|
-
const o = await
|
|
121
|
+
const o = await r.agent.createGraph().compile().invoke(
|
|
120
122
|
{
|
|
121
123
|
agentExecutionContext: {
|
|
122
124
|
...t.agentExecutionContext,
|
|
@@ -129,12 +131,12 @@ const U = async (t) => {
|
|
|
129
131
|
},
|
|
130
132
|
a
|
|
131
133
|
);
|
|
132
|
-
i =
|
|
134
|
+
i = Y(r.agent.name, o), await l({ text: `Finished executing registered agent: ${r.agent.name}` }, e);
|
|
133
135
|
} catch (o) {
|
|
134
|
-
if (
|
|
136
|
+
if (L(o) || e?.signal?.aborted || o instanceof Error && o.name === "AbortError")
|
|
135
137
|
throw o;
|
|
136
138
|
const g = o instanceof Error ? o.message : String(o);
|
|
137
|
-
console.error(`Agent "${
|
|
139
|
+
console.error(`Agent "${r.agent.name}" failed:`, o), await l({ text: `Registered agent failed: ${r.agent.name}. ${g}` }, e), i = {
|
|
138
140
|
status: "failed",
|
|
139
141
|
outputMessage: `Agent execution failed: ${g}`,
|
|
140
142
|
summary: `Agent execution failed: ${g}`
|
|
@@ -142,14 +144,14 @@ const U = async (t) => {
|
|
|
142
144
|
}
|
|
143
145
|
const c = i.outputMessage, d = [...t.agentExecutionContext.messages];
|
|
144
146
|
if (c) {
|
|
145
|
-
const o = c.length >
|
|
147
|
+
const o = c.length > x ? `${c.slice(0, x - 14)}
|
|
146
148
|
[truncated]` : c;
|
|
147
|
-
d.push(new
|
|
149
|
+
d.push(new T(o));
|
|
148
150
|
}
|
|
149
151
|
return {
|
|
150
152
|
...t,
|
|
151
153
|
stepCount: t.stepCount + 1,
|
|
152
|
-
lastExecutedAgent:
|
|
154
|
+
lastExecutedAgent: r.agent.id,
|
|
153
155
|
requiresFollowUp: i.status === "failed" ? !0 : t.requiresFollowUp,
|
|
154
156
|
finalOutputMessage: c ?? "",
|
|
155
157
|
agentExecutionContext: {
|
|
@@ -158,32 +160,41 @@ const U = async (t) => {
|
|
|
158
160
|
priorSteps: [
|
|
159
161
|
...t.agentExecutionContext.priorSteps ?? [],
|
|
160
162
|
{
|
|
161
|
-
agentId:
|
|
163
|
+
agentId: r.agent.id,
|
|
162
164
|
assignedTask: t.agentExecutionContext.assignedTask,
|
|
163
165
|
summary: i?.summary || "No summary provided.",
|
|
164
166
|
status: i?.status || "unknown"
|
|
165
167
|
}
|
|
166
168
|
],
|
|
167
|
-
sharedState:
|
|
169
|
+
sharedState: K({
|
|
168
170
|
previousSharedState: t.agentExecutionContext.sharedState,
|
|
169
171
|
patch: i.sharedStatePatch,
|
|
170
|
-
agentId:
|
|
172
|
+
agentId: r.agent.id
|
|
171
173
|
})
|
|
172
174
|
}
|
|
173
175
|
};
|
|
174
|
-
},
|
|
175
|
-
"
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
176
|
+
}, ee = async (t, e) => {
|
|
177
|
+
if (t.routing.mode !== "direct")
|
|
178
|
+
throw new Error("Direct agent assignment requires direct routing.");
|
|
179
|
+
return await l({ text: `Doing a direct route to agent: ${t.routing.agentId}` }, e), {
|
|
180
|
+
...t,
|
|
181
|
+
currentIntent: t.routing.agentId,
|
|
182
|
+
requiresFollowUp: !1,
|
|
183
|
+
agentExecutionContext: {
|
|
184
|
+
...t.agentExecutionContext,
|
|
185
|
+
assignedTask: t.agentExecutionContext.userRequest
|
|
186
|
+
}
|
|
187
|
+
};
|
|
188
|
+
}, te = 3, re = (t) => t.routing.mode === "direct" ? "assignDirectAgent" : "intentLLM", ne = (t) => t.routing.mode === "direct" || t.stepCount >= te || !t.requiresFollowUp ? "exit" : "intentLLM", se = () => new W(M).addNode("ingestInput", Q).addNode("assignDirectAgent", ee).addNode("intentLLM", D).addNode("executeRegisteredAgent", Z).addNode("exit", B).addEdge(q, "ingestInput").addConditionalEdges("ingestInput", re).addEdge("assignDirectAgent", "executeRegisteredAgent").addConditionalEdges("intentLLM", (e) => e.currentIntent === "none" || e.currentIntent === e.lastExecutedAgent ? "exit" : "executeRegisteredAgent").addConditionalEdges("executeRegisteredAgent", ne).addEdge("exit", j);
|
|
189
|
+
class v {
|
|
179
190
|
constructor() {
|
|
180
191
|
this.agentRegistry = /* @__PURE__ */ new Map();
|
|
181
192
|
}
|
|
182
193
|
register(e) {
|
|
183
|
-
const { agent:
|
|
184
|
-
if (this.agentRegistry.has(
|
|
185
|
-
throw new Error(`Duplicate agent id: ${
|
|
186
|
-
this.agentRegistry.set(
|
|
194
|
+
const { agent: n } = e;
|
|
195
|
+
if (this.agentRegistry.has(n.id))
|
|
196
|
+
throw new Error(`Duplicate agent id: ${n.id}`);
|
|
197
|
+
this.agentRegistry.set(n.id, e);
|
|
187
198
|
}
|
|
188
199
|
get(e) {
|
|
189
200
|
return this.agentRegistry.get(e);
|
|
@@ -192,31 +203,31 @@ class Z {
|
|
|
192
203
|
return [...this.agentRegistry.values()];
|
|
193
204
|
}
|
|
194
205
|
}
|
|
195
|
-
class
|
|
206
|
+
class ae {
|
|
196
207
|
/**
|
|
197
208
|
* Create a new InterruptHandler tied to a specific compiled graph and config.
|
|
198
209
|
*/
|
|
199
|
-
constructor(e,
|
|
200
|
-
this.graph = e, this.config = { ...
|
|
210
|
+
constructor(e, n) {
|
|
211
|
+
this.graph = e, this.config = { ...n };
|
|
201
212
|
}
|
|
202
213
|
/**
|
|
203
214
|
* Returns a promise that resolves when the user provides a HITL response.
|
|
204
215
|
*/
|
|
205
216
|
async waitForUser() {
|
|
206
|
-
return await new Promise((e,
|
|
207
|
-
this.resolveWait = e, this.rejectWait =
|
|
217
|
+
return await new Promise((e, n) => {
|
|
218
|
+
this.resolveWait = e, this.rejectWait = n;
|
|
208
219
|
});
|
|
209
220
|
}
|
|
210
221
|
/**
|
|
211
222
|
* Resume graph execution after the UI responds to an interrupt.
|
|
212
223
|
*/
|
|
213
|
-
handle(e,
|
|
224
|
+
handle(e, n) {
|
|
214
225
|
try {
|
|
215
226
|
const s = {
|
|
216
227
|
agentId: e.agentId,
|
|
217
228
|
id: e.id,
|
|
218
|
-
payload:
|
|
219
|
-
},
|
|
229
|
+
payload: n
|
|
230
|
+
}, r = this.graph.streamEvents(null, {
|
|
220
231
|
...this.config,
|
|
221
232
|
configurable: {
|
|
222
233
|
...this.config.configurable,
|
|
@@ -225,7 +236,7 @@ class ee {
|
|
|
225
236
|
subgraphs: !0,
|
|
226
237
|
version: "v2"
|
|
227
238
|
});
|
|
228
|
-
this.resolveWait?.(
|
|
239
|
+
this.resolveWait?.(r);
|
|
229
240
|
} catch (s) {
|
|
230
241
|
this.rejectWait?.(s);
|
|
231
242
|
} finally {
|
|
@@ -239,120 +250,120 @@ class ee {
|
|
|
239
250
|
this.rejectWait && (this.rejectWait(new Error("Request cancelled by user.")), this.resolveWait = void 0, this.rejectWait = void 0);
|
|
240
251
|
}
|
|
241
252
|
}
|
|
242
|
-
const
|
|
253
|
+
const ie = async (t) => {
|
|
243
254
|
try {
|
|
244
|
-
return await (await
|
|
255
|
+
return await (await F()).embedDocuments(t);
|
|
245
256
|
} catch (e) {
|
|
246
257
|
throw console.error("Failed to generate embeddings:", e), e;
|
|
247
258
|
}
|
|
248
|
-
},
|
|
249
|
-
const
|
|
250
|
-
if (
|
|
251
|
-
return
|
|
252
|
-
const s = await
|
|
259
|
+
}, S = async (t, e) => {
|
|
260
|
+
const n = e.get(t);
|
|
261
|
+
if (n)
|
|
262
|
+
return n;
|
|
263
|
+
const s = await ie([t]);
|
|
253
264
|
return e.set(t, s[0]), s[0];
|
|
254
265
|
};
|
|
255
|
-
async function
|
|
256
|
-
const
|
|
266
|
+
async function oe(t, e, n, s) {
|
|
267
|
+
const r = `req-${Date.now()}`, i = {
|
|
257
268
|
type: "layerSearch",
|
|
258
|
-
precomputedEmbedding: s ? await
|
|
259
|
-
requestId:
|
|
260
|
-
minScore:
|
|
269
|
+
precomputedEmbedding: s ? await S(t, s) : void 0,
|
|
270
|
+
requestId: r,
|
|
271
|
+
minScore: n
|
|
261
272
|
};
|
|
262
273
|
return await new Promise((c) => {
|
|
263
274
|
const d = (o) => {
|
|
264
|
-
o.data.requestId ===
|
|
275
|
+
o.data.requestId === r && c(o.data.results);
|
|
265
276
|
};
|
|
266
277
|
e.addEventListener("message", d, { once: !0 }), e.postMessage(i);
|
|
267
278
|
});
|
|
268
279
|
}
|
|
269
|
-
function
|
|
280
|
+
function ce(t) {
|
|
270
281
|
const { worker: e } = t;
|
|
271
282
|
return {
|
|
272
283
|
async searchLayers({
|
|
273
|
-
text:
|
|
284
|
+
text: n,
|
|
274
285
|
minScore: s,
|
|
275
|
-
embeddingCache:
|
|
286
|
+
embeddingCache: r
|
|
276
287
|
}) {
|
|
277
|
-
return await
|
|
288
|
+
return await oe(n, e, s, r);
|
|
278
289
|
}
|
|
279
290
|
};
|
|
280
291
|
}
|
|
281
|
-
const
|
|
292
|
+
const de = async ({
|
|
282
293
|
combinedQuery: t,
|
|
283
294
|
layerIds: e,
|
|
284
|
-
embeddingsWorker:
|
|
295
|
+
embeddingsWorker: n,
|
|
285
296
|
minScore: s,
|
|
286
|
-
topResults:
|
|
297
|
+
topResults: r,
|
|
287
298
|
embeddingCache: a
|
|
288
299
|
}) => {
|
|
289
|
-
const i = `req-${Date.now()}`, c = a ? await
|
|
300
|
+
const i = `req-${Date.now()}`, c = a ? await S(t, a) : void 0, d = {
|
|
290
301
|
type: "fieldSearch",
|
|
291
302
|
layerIdForFieldsSearch: e,
|
|
292
303
|
precomputedEmbedding: c,
|
|
293
304
|
requestId: i,
|
|
294
305
|
minScore: s,
|
|
295
|
-
topResults:
|
|
306
|
+
topResults: r
|
|
296
307
|
};
|
|
297
308
|
return await new Promise((o) => {
|
|
298
309
|
const g = (u) => {
|
|
299
310
|
if (u.data.requestId !== i)
|
|
300
311
|
return;
|
|
301
|
-
const p = u.data.results.map(({ layerId: y, results:
|
|
312
|
+
const p = u.data.results.map(({ layerId: y, results: h }) => ({
|
|
302
313
|
layerId: y,
|
|
303
|
-
results:
|
|
314
|
+
results: h
|
|
304
315
|
}));
|
|
305
316
|
o(p);
|
|
306
317
|
};
|
|
307
|
-
|
|
318
|
+
n.addEventListener("message", g, { once: !0 }), n.postMessage(d);
|
|
308
319
|
});
|
|
309
320
|
};
|
|
310
|
-
function
|
|
321
|
+
function ge(t) {
|
|
311
322
|
const { worker: e } = t;
|
|
312
323
|
return {
|
|
313
|
-
async searchFields({ text:
|
|
314
|
-
return await
|
|
315
|
-
combinedQuery:
|
|
324
|
+
async searchFields({ text: n, layerIds: s, minScore: r, topResults: a, embeddingCache: i }) {
|
|
325
|
+
return await de({
|
|
326
|
+
combinedQuery: n,
|
|
316
327
|
layerIds: s,
|
|
317
328
|
embeddingsWorker: e,
|
|
318
|
-
minScore:
|
|
329
|
+
minScore: r,
|
|
319
330
|
topResults: a,
|
|
320
331
|
embeddingCache: i
|
|
321
332
|
});
|
|
322
333
|
}
|
|
323
334
|
};
|
|
324
335
|
}
|
|
325
|
-
const
|
|
326
|
-
const e =
|
|
336
|
+
const ue = (t) => {
|
|
337
|
+
const e = $.safeParse(t);
|
|
327
338
|
if (!e.success)
|
|
328
339
|
throw new Error("Embeddings response validation failed. Regenerate embeddings.");
|
|
329
340
|
return e.data;
|
|
330
|
-
},
|
|
331
|
-
const
|
|
332
|
-
if (e.allLayers.forEach((
|
|
333
|
-
|
|
341
|
+
}, le = (t, e) => {
|
|
342
|
+
const n = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map();
|
|
343
|
+
if (e.allLayers.forEach((r) => {
|
|
344
|
+
r instanceof N && s.set(r.id, r);
|
|
334
345
|
}), t.length !== s.size)
|
|
335
346
|
throw new Error("Layer count mismatch during registry restoration. Regenerate embeddings.");
|
|
336
|
-
for (const
|
|
337
|
-
const a = s.get(
|
|
347
|
+
for (const r of t) {
|
|
348
|
+
const a = s.get(r.id);
|
|
338
349
|
if (!a)
|
|
339
350
|
throw new Error(
|
|
340
|
-
`Layer with ID ${
|
|
351
|
+
`Layer with ID ${r.id} not found in the original map during registry restoration. Regenerate embeddings.`
|
|
341
352
|
);
|
|
342
|
-
if (
|
|
353
|
+
if (r.fields.length !== a.fields.length)
|
|
343
354
|
throw new Error(
|
|
344
|
-
`Field count mismatch for layer ID ${
|
|
355
|
+
`Field count mismatch for layer ID ${r.id} during registry restoration. Regenerate embeddings.`
|
|
345
356
|
);
|
|
346
357
|
const i = {
|
|
347
|
-
name:
|
|
348
|
-
title:
|
|
349
|
-
description:
|
|
358
|
+
name: r.name,
|
|
359
|
+
title: r.title,
|
|
360
|
+
description: r.description
|
|
350
361
|
}, c = /* @__PURE__ */ new Map();
|
|
351
|
-
for (const d of
|
|
362
|
+
for (const d of r.fields) {
|
|
352
363
|
const o = a.fieldsIndex.get(d.name);
|
|
353
364
|
if (!o)
|
|
354
365
|
throw new Error(
|
|
355
|
-
`Field with name ${d.name} not found in the original layer ${
|
|
366
|
+
`Field with name ${d.name} not found in the original layer ${r.id} during registry restoration. Regenerate embeddings.`
|
|
356
367
|
);
|
|
357
368
|
c.set(d.name, {
|
|
358
369
|
name: d.name,
|
|
@@ -363,33 +374,33 @@ const ie = (t) => {
|
|
|
363
374
|
domain: a.getFieldDomain(d.name) ?? void 0
|
|
364
375
|
});
|
|
365
376
|
}
|
|
366
|
-
|
|
377
|
+
n.set(r.id, {
|
|
367
378
|
layerItem: i,
|
|
368
379
|
fieldRegistry: c
|
|
369
380
|
});
|
|
370
381
|
}
|
|
371
|
-
return
|
|
372
|
-
},
|
|
382
|
+
return n;
|
|
383
|
+
}, he = async (t) => {
|
|
373
384
|
try {
|
|
374
|
-
return (await
|
|
385
|
+
return (await G(t, {
|
|
375
386
|
responseType: "json"
|
|
376
387
|
})).data;
|
|
377
388
|
} catch (e) {
|
|
378
389
|
throw new Error(`Failed to fetch data from ${t}: ${String(e)}`);
|
|
379
390
|
}
|
|
380
|
-
},
|
|
391
|
+
}, me = async (t) => {
|
|
381
392
|
const e = t.map;
|
|
382
393
|
if (!e?.portalItem)
|
|
383
394
|
throw new Error("WebMap portal item is missing.");
|
|
384
|
-
const { resources:
|
|
395
|
+
const { resources: n } = await e.portalItem.fetchResources(), s = n.find((i) => i.resource.path === "embeddings-v01.json");
|
|
385
396
|
if (!s?.resource.url)
|
|
386
397
|
throw new Error("Embeddings resource 'embeddings-v01.json' not found in the webmap portal item.");
|
|
387
|
-
const
|
|
388
|
-
return
|
|
398
|
+
const r = await he(s.resource.url);
|
|
399
|
+
return ue(r);
|
|
389
400
|
};
|
|
390
|
-
class
|
|
401
|
+
class R {
|
|
391
402
|
constructor() {
|
|
392
|
-
this.orchestratorReady = !1, this.chatHistory = [], this.priorSteps = [], this.sharedState = {}, this.agentRegistry = new
|
|
403
|
+
this.orchestratorReady = !1, this.chatHistory = [], this.priorSteps = [], this.sharedState = {}, this.agentRegistry = new v(), this.activeRunId = "", this.cancelledRunIds = /* @__PURE__ */ new Set(), this.streamEpoch = 0;
|
|
393
404
|
}
|
|
394
405
|
/**
|
|
395
406
|
* Creates and returns an AI-ready Orchestrator instance.
|
|
@@ -397,19 +408,19 @@ class x {
|
|
|
397
408
|
* @returns Ready Orchestrator.
|
|
398
409
|
*/
|
|
399
410
|
static async init(e) {
|
|
400
|
-
const
|
|
411
|
+
const n = new R();
|
|
401
412
|
try {
|
|
402
413
|
if (e.view?.map) {
|
|
403
|
-
await
|
|
404
|
-
const s = await
|
|
414
|
+
await U.whenOnce(() => e.view.ready);
|
|
415
|
+
const s = await me(e.view), r = le(
|
|
405
416
|
s.layers,
|
|
406
417
|
e.view.map
|
|
407
418
|
);
|
|
408
|
-
|
|
419
|
+
n.layersAndFieldsRegistry = r, n.embeddingsWorker = await _(s);
|
|
409
420
|
}
|
|
410
421
|
return e.agents?.forEach((s) => {
|
|
411
|
-
|
|
412
|
-
}),
|
|
422
|
+
n.agentRegistry.register(s);
|
|
423
|
+
}), n.orchestratorReady = !0, n;
|
|
413
424
|
} catch (s) {
|
|
414
425
|
throw console.error("Orchestrator initialization failed:", s), s;
|
|
415
426
|
}
|
|
@@ -421,35 +432,41 @@ class x {
|
|
|
421
432
|
* - `interrupt`: HITL required, wait for `resumeInterrupt()`
|
|
422
433
|
* - `completed`: final result with chat history + layer styling
|
|
423
434
|
* - `cancelled`: user aborted the run
|
|
435
|
+
* @param userInput User request to process.
|
|
436
|
+
* @param options Agent selection and routing behavior for this run.
|
|
424
437
|
*/
|
|
425
|
-
async *ask(e) {
|
|
438
|
+
async *ask(e, n = {}) {
|
|
426
439
|
if (!this.orchestratorReady)
|
|
427
440
|
throw new Error("Orchestrator is not ready yet.");
|
|
428
441
|
if (!this.agentRegistry.list().length)
|
|
429
442
|
throw new Error("Orchestrator has no registered agents.");
|
|
443
|
+
const s = this.createRequestAgentRegistry(n);
|
|
444
|
+
if (!s.list().length)
|
|
445
|
+
throw new Error("Orchestrator has no agents selected for this request.");
|
|
430
446
|
if (++this.streamEpoch, !e.trim())
|
|
431
447
|
return;
|
|
432
|
-
const r =
|
|
433
|
-
this.activeRunId = r, this.activeAbortController = new AbortController(), this.graph || (this.graph =
|
|
434
|
-
const
|
|
448
|
+
const r = P();
|
|
449
|
+
this.activeRunId = r, this.activeAbortController = new AbortController(), this.graph || (this.graph = se().compile({ checkpointer: new H() }));
|
|
450
|
+
const a = this.embeddingsWorker ? ce({ worker: this.embeddingsWorker }) : void 0, i = this.embeddingsWorker ? ge({ worker: this.embeddingsWorker }) : void 0, c = /* @__PURE__ */ new Map(), d = n.routing === "direct" ? { mode: "direct", agentId: n.agentId } : { mode: "auto" }, o = {
|
|
451
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
452
|
+
thread_id: r,
|
|
453
|
+
hitlResponse: null,
|
|
454
|
+
services: {
|
|
455
|
+
layerSearch: a,
|
|
456
|
+
fieldSearch: i,
|
|
457
|
+
layersAndFieldsRegistry: this.layersAndFieldsRegistry,
|
|
458
|
+
agentRegistry: s,
|
|
459
|
+
embeddingCache: c
|
|
460
|
+
}
|
|
461
|
+
}, g = {
|
|
435
462
|
version: "v2",
|
|
436
463
|
streamMode: "custom",
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
thread_id: r,
|
|
440
|
-
abortSignal: this.activeAbortController.signal,
|
|
441
|
-
hitlResponse: null,
|
|
442
|
-
services: {
|
|
443
|
-
layerSearch: s,
|
|
444
|
-
fieldSearch: n,
|
|
445
|
-
layersAndFieldsRegistry: this.layersAndFieldsRegistry,
|
|
446
|
-
agentRegistry: this.agentRegistry,
|
|
447
|
-
embeddingCache: a
|
|
448
|
-
}
|
|
449
|
-
},
|
|
464
|
+
signal: this.activeAbortController.signal,
|
|
465
|
+
configurable: o,
|
|
450
466
|
subgraphs: !0
|
|
451
|
-
},
|
|
467
|
+
}, u = this.graph?.streamEvents(
|
|
452
468
|
{
|
|
469
|
+
routing: d,
|
|
453
470
|
agentExecutionContext: {
|
|
454
471
|
userRequest: e,
|
|
455
472
|
messages: this.chatHistory,
|
|
@@ -457,9 +474,9 @@ class x {
|
|
|
457
474
|
sharedState: this.sharedState
|
|
458
475
|
}
|
|
459
476
|
},
|
|
460
|
-
|
|
461
|
-
),
|
|
462
|
-
if (yield* this.pipeStream(
|
|
477
|
+
g
|
|
478
|
+
), p = ++this.streamEpoch;
|
|
479
|
+
if (yield* this.pipeStream(u, p, r), this.isRunCancelled(r)) {
|
|
463
480
|
yield { runId: r, timestamp: Date.now(), type: "cancelled", reason: "user" };
|
|
464
481
|
return;
|
|
465
482
|
}
|
|
@@ -468,24 +485,24 @@ class x {
|
|
|
468
485
|
yield { runId: r, timestamp: Date.now(), type: "cancelled", reason: "user" };
|
|
469
486
|
return;
|
|
470
487
|
}
|
|
471
|
-
const
|
|
472
|
-
if (!
|
|
488
|
+
const w = (await this.graph.getState(g, { subgraphs: !0 })).tasks.find((m) => m.interrupts.length > 0)?.interrupts[0]?.value;
|
|
489
|
+
if (!w)
|
|
473
490
|
break;
|
|
474
|
-
this.currentInterrupt =
|
|
491
|
+
this.currentInterrupt = w, this.interruptHandler = new ae(this.graph, g), yield { runId: r, timestamp: Date.now(), type: "interrupt", interrupt: w };
|
|
475
492
|
try {
|
|
476
|
-
const
|
|
477
|
-
yield* this.pipeStream(
|
|
478
|
-
} catch (
|
|
493
|
+
const m = await this.interruptHandler.waitForUser(), I = ++this.streamEpoch;
|
|
494
|
+
yield* this.pipeStream(m, I, r);
|
|
495
|
+
} catch (m) {
|
|
479
496
|
if (this.isRunCancelled(r)) {
|
|
480
497
|
yield { runId: r, timestamp: Date.now(), type: "cancelled", reason: "user" };
|
|
481
498
|
return;
|
|
482
499
|
}
|
|
483
|
-
if (
|
|
500
|
+
if (m) {
|
|
484
501
|
yield {
|
|
485
502
|
runId: r,
|
|
486
503
|
timestamp: Date.now(),
|
|
487
504
|
type: "error",
|
|
488
|
-
error: { message:
|
|
505
|
+
error: { message: m?.message }
|
|
489
506
|
};
|
|
490
507
|
return;
|
|
491
508
|
}
|
|
@@ -495,16 +512,16 @@ class x {
|
|
|
495
512
|
yield { runId: r, timestamp: Date.now(), type: "cancelled", reason: "user" };
|
|
496
513
|
return;
|
|
497
514
|
}
|
|
498
|
-
const
|
|
515
|
+
const h = (await this.graph.getState(g, { subgraphs: !0 })).values;
|
|
499
516
|
if (this.isRunCancelled(r)) {
|
|
500
517
|
yield { runId: r, timestamp: Date.now(), type: "cancelled", reason: "user" };
|
|
501
518
|
return;
|
|
502
519
|
}
|
|
503
|
-
this.chatHistory =
|
|
520
|
+
this.chatHistory = h.agentExecutionContext.messages.length ? h.agentExecutionContext.messages : this.chatHistory, this.priorSteps = h.agentExecutionContext.priorSteps?.slice(-5) ?? [], this.sharedState = h.agentExecutionContext.sharedState ?? {}, yield {
|
|
504
521
|
runId: r,
|
|
505
522
|
timestamp: Date.now(),
|
|
506
523
|
type: "completed",
|
|
507
|
-
result: { content:
|
|
524
|
+
result: { content: h.finalOutputMessage }
|
|
508
525
|
};
|
|
509
526
|
}
|
|
510
527
|
/**
|
|
@@ -538,21 +555,34 @@ class x {
|
|
|
538
555
|
cancel() {
|
|
539
556
|
this.activeRunId && (this.cancelledRunIds.add(this.activeRunId), this.activeAbortController?.abort(), ++this.streamEpoch, this.interruptHandler?.cancel());
|
|
540
557
|
}
|
|
541
|
-
async *pipeStream(e,
|
|
542
|
-
for await (const
|
|
543
|
-
if (this.isRunCancelled(s) ||
|
|
558
|
+
async *pipeStream(e, n, s) {
|
|
559
|
+
for await (const r of e) {
|
|
560
|
+
if (this.isRunCancelled(s) || n !== this.streamEpoch)
|
|
544
561
|
break;
|
|
545
|
-
|
|
562
|
+
r.event === "on_custom_event" && r.name === "trace_message" ? yield { runId: s, timestamp: Date.now(), type: "trace", data: r.data } : r.name === "graph_ux_suggestion" && (yield {
|
|
546
563
|
runId: s,
|
|
547
564
|
timestamp: Date.now(),
|
|
548
565
|
type: "ux-suggestion",
|
|
549
|
-
suggestion:
|
|
566
|
+
suggestion: r.data
|
|
550
567
|
});
|
|
551
568
|
}
|
|
552
569
|
}
|
|
553
570
|
isRunCancelled(e) {
|
|
554
571
|
return this.cancelledRunIds.has(e);
|
|
555
572
|
}
|
|
573
|
+
/**
|
|
574
|
+
* Creates a request-scoped registry containing all agents by default,
|
|
575
|
+
* or only the explicitly selected agents when filtering is requested.
|
|
576
|
+
*/
|
|
577
|
+
createRequestAgentRegistry(e) {
|
|
578
|
+
const n = e.routing === "direct" ? [e.agentId] : e.agentIds, s = n ? n.map((a) => {
|
|
579
|
+
const i = this.agentRegistry.get(a);
|
|
580
|
+
if (!i)
|
|
581
|
+
throw new Error(`Agent is not registered: ${a}`);
|
|
582
|
+
return i;
|
|
583
|
+
}) : this.agentRegistry.list(), r = new v();
|
|
584
|
+
return s.forEach((a) => r.register(a)), r;
|
|
585
|
+
}
|
|
556
586
|
/**
|
|
557
587
|
* Disposes this instance by terminating the embeddings worker
|
|
558
588
|
* and cleaning up all related resources.
|
|
@@ -562,6 +592,6 @@ class x {
|
|
|
562
592
|
}
|
|
563
593
|
}
|
|
564
594
|
export {
|
|
565
|
-
|
|
566
|
-
|
|
595
|
+
R as O,
|
|
596
|
+
ie as g
|
|
567
597
|
};
|