@arcgis/ai-components 5.2.0-next.5 → 5.2.0-next.51
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/agent-utils/FunctionAgent.d.ts +2 -2
- package/dist/agent-utils/LLMAgent.d.ts +2 -2
- package/dist/agent-utils/LLMAgent.js +1 -0
- 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/2ER3LN6U.js +2 -0
- package/dist/cdn/2W6XPTA6.js +9 -0
- package/dist/cdn/3DJDRAGV.js +2 -0
- package/dist/cdn/3LCF5HIE.js +3 -0
- package/dist/cdn/{AMP6IALT.js → 3UEKINYC.js} +1 -1
- package/dist/cdn/434TAA3J.js +2 -0
- package/dist/cdn/4CEMUECT.js +2 -0
- package/dist/cdn/4G5XCUE5.js +2 -0
- package/dist/cdn/57OMVTIU.js +2 -0
- package/dist/cdn/5I35MJXT.js +48 -0
- package/dist/cdn/6O6KMX3M.js +2 -0
- package/dist/cdn/6U7TEAAJ.js +2 -0
- package/dist/cdn/7FY4G4K2.js +2 -0
- package/dist/cdn/7YIRK2E3.js +2 -0
- package/dist/cdn/A4JLOAOH.js +2 -0
- package/dist/cdn/{ZS2TZ6BF.js → AOVJ34QE.js} +1 -1
- package/dist/cdn/APFZY4PI.js +2 -0
- package/dist/cdn/BE7ZN5FZ.js +2 -0
- package/dist/cdn/{FL4W4VYN.js → BL273EGZ.js} +17 -1
- package/dist/cdn/BMGQJYTE.js +2 -0
- package/dist/cdn/{5ZZGKP7N.js → CEKOEHB3.js} +1 -1
- package/dist/cdn/CMG2NY3K.js +2 -0
- package/dist/cdn/DMLRWHBA.js +2 -0
- package/dist/cdn/EQLRFZVU.js +18 -0
- package/dist/cdn/EW6AYEUX.js +36 -0
- package/dist/cdn/F5SUU35Z.js +2 -0
- package/dist/cdn/FYW633VX.js +2 -0
- package/dist/cdn/{ZLXN7NMF.js → FYZATVB3.js} +10 -8
- package/dist/cdn/{H7422XUG.js → GYVSHAUI.js} +1 -1
- 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/JEL5M7FA.js +2 -0
- package/dist/cdn/{CXWBEDXN.js → JSIGEUX7.js} +6 -4
- package/dist/cdn/JSJ4RMOE.js +2 -0
- package/dist/cdn/JVYPIWEU.js +2 -0
- package/dist/cdn/KJJAXCP4.js +2 -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/MS5EA2KY.js +2 -0
- package/dist/cdn/MWYBF3F3.js +66 -0
- package/dist/cdn/NAKAZDJ7.js +4 -0
- package/dist/cdn/NEV6OZN3.js +71 -0
- package/dist/cdn/O5TONDCH.js +2 -0
- package/dist/cdn/OC5GA5ZQ.js +3 -0
- package/dist/cdn/OGMMYFHR.js +2 -0
- package/dist/cdn/{23EQTPO3.js → OKVLGJAG.js} +1 -1
- package/dist/cdn/OYNIFMCJ.js +2 -0
- package/dist/cdn/PNFBQ6JV.js +180 -0
- package/dist/cdn/{LQ6R5YRN.js → PQ2DPOFM.js} +1 -1
- 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/SJR4IR57.js +2 -0
- package/dist/cdn/SPVOBZAL.js +2 -0
- package/dist/cdn/SUA3YJTU.js +22 -0
- package/dist/cdn/T7DYMSJV.js +65 -0
- package/dist/cdn/TFT6HK3O.js +208 -0
- package/dist/cdn/THR22OXW.js +2 -0
- package/dist/cdn/TPULIO6I.js +34 -0
- package/dist/cdn/{6YMR4QSD.js → UHEYPSOR.js} +1 -1
- package/dist/cdn/UK7PR2FE.js +2 -0
- package/dist/cdn/UZLQALHY.js +2 -0
- package/dist/cdn/V6HOUZPZ.js +2 -0
- package/dist/cdn/VAXH6RUQ.js +134 -0
- package/dist/cdn/VPFIUEKT.js +14 -0
- package/dist/cdn/VXFQANGJ.js +2 -0
- package/dist/cdn/XCRR2EEG.js +6 -0
- package/dist/cdn/YHQJ66WJ.js +2 -0
- package/dist/cdn/YYSMCB4A.js +2 -0
- package/dist/cdn/Z6I6JACX.js +3 -0
- package/dist/cdn/ZB57WYHC.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/cdn/main.css +1 -1
- package/dist/chunks/adapter.js +1794 -1597
- package/dist/chunks/arcgisKnowledgeGraph.js +126 -71
- 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 +139 -113
- package/dist/chunks/data_explore_query_prompt.js +9 -4
- package/dist/chunks/generateLayerDescriptions.js +248 -228
- package/dist/chunks/helpGraph.js +17 -13
- 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 +24 -20
- package/dist/chunks/navigationGraph.js +33 -28
- package/dist/chunks/navigation_intent_prompt.js +8 -2
- package/dist/chunks/orchestrator.js +110 -108
- 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 +12 -9
- package/dist/chunks/utils2.js +8 -8
- package/dist/components/arcgis-assistant/customElement.d.ts +27 -0
- package/dist/components/arcgis-assistant/customElement.js +385 -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 +8 -2
- package/dist/components/arcgis-assistant-chat/customElement.js +23 -18
- package/dist/components/arcgis-assistant-chat-entry/customElement.d.ts +4 -1
- package/dist/components/arcgis-assistant-chat-entry/customElement.js +25 -18
- package/dist/components/arcgis-assistant-data-exploration-agent/customElement.js +11 -5
- package/dist/components/arcgis-assistant-help-agent/customElement.js +8 -2
- package/dist/components/arcgis-assistant-interrupt/customElement.d.ts +4 -1
- 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 +17 -11
- package/dist/components/arcgis-assistant-layer-styling-agent/customElement.js +10 -4
- package/dist/components/arcgis-assistant-message/customElement.d.ts +23 -0
- package/dist/components/arcgis-assistant-message/customElement.js +28 -26
- package/dist/components/arcgis-assistant-message/index.d.ts +1 -0
- package/dist/components/arcgis-assistant-message/index.js +2 -0
- package/dist/components/arcgis-assistant-message-block/customElement.d.ts +1 -1
- 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-feedback/customElement.d.ts +4 -1
- package/dist/components/arcgis-assistant-message-footer/customElement.d.ts +4 -1
- package/dist/components/arcgis-assistant-message-loading/customElement.d.ts +8 -1
- package/dist/components/arcgis-assistant-message-loading/customElement.js +8 -8
- package/dist/components/arcgis-assistant-message-loading/index.js +1 -0
- package/dist/components/arcgis-assistant-message-log/customElement.d.ts +4 -1
- package/dist/components/arcgis-assistant-message-read-aloud/customElement.d.ts +4 -1
- package/dist/components/arcgis-assistant-message-text/customElement.d.ts +5 -1
- package/dist/components/arcgis-assistant-message-text/customElement.js +12 -12
- package/dist/components/arcgis-assistant-navigation-agent/customElement.js +11 -5
- package/dist/components/arcgis-assistant-speech-input/customElement.d.ts +6 -1
- package/dist/components/arcgis-assistant-suggested-prompts/customElement.d.ts +4 -1
- package/dist/components/arcgis-assistant-suggested-prompts/customElement.js +8 -8
- package/dist/components/arcgis-assistant-user-message/customElement.d.ts +4 -1
- 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/index.d.ts +4 -0
- package/dist/loader.js +7 -6
- package/dist/oauth-callback.html +1 -1
- package/dist/types/lumina.d.ts +11 -5
- package/dist/types/preact.d.ts +12 -5
- package/dist/types/react.d.ts +13 -5
- package/dist/types/stencil.d.ts +11 -5
- package/dist/utils/index.d.ts +85 -47
- package/dist/utils/index.js +48 -47
- package/package.json +13 -12
- package/dist/cdn/2AXF774U.js +0 -2
- package/dist/cdn/3BKUCFKS.js +0 -36
- package/dist/cdn/3PKJWIC3.js +0 -2
- package/dist/cdn/3WINIQWY.js +0 -2
- package/dist/cdn/462JBSEV.js +0 -422
- 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/AO7BQHKC.js +0 -2
- package/dist/cdn/AXDZBBNL.js +0 -45
- package/dist/cdn/DDLZOMUY.js +0 -2
- package/dist/cdn/DHOVCT6R.js +0 -2
- package/dist/cdn/DO2P3PWF.js +0 -106
- package/dist/cdn/ERBQSEPQ.js +0 -22
- package/dist/cdn/F2AHA4GB.js +0 -54
- package/dist/cdn/FX5JFRDL.js +0 -2
- package/dist/cdn/GBNUMN4J.js +0 -16
- package/dist/cdn/GJUXVEOF.js +0 -166
- package/dist/cdn/HB5A5R2E.js +0 -2
- package/dist/cdn/J5CMRCPS.js +0 -3
- package/dist/cdn/KMQ3SP4I.js +0 -5
- package/dist/cdn/M6F4MXDK.js +0 -14
- 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/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/Y333DGV6.js +0 -2
- package/dist/cdn/YIMNOUTF.js +0 -2
|
@@ -1,42 +1,44 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
2
|
import R from "@arcgis/core/identity/IdentityManager.js";
|
|
3
3
|
import C from "@arcgis/core/portal/Portal.js";
|
|
4
|
-
import {
|
|
4
|
+
import { n as I, o as v, D as k, p as A, q as M, W as F } from "./generateLayerDescriptions.js";
|
|
5
5
|
import { isGraphInterrupt as D, StateGraph as L, START as W, END as $, MemorySaver as j } from "@langchain/langgraph/web";
|
|
6
|
-
import {
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
|
|
11
|
-
|
|
6
|
+
import { generateGuid as q } from "@arcgis/toolkit/string";
|
|
7
|
+
import { HumanMessage as H, AIMessage as P } from "@langchain/core/messages";
|
|
8
|
+
import { s as l } from "./index.js";
|
|
9
|
+
import * as O from "@arcgis/core/core/reactiveUtils.js";
|
|
10
|
+
import T from "@arcgis/core/layers/FeatureLayer.js";
|
|
11
|
+
import U from "@arcgis/core/request.js";
|
|
12
|
+
const G = async (t) => {
|
|
13
|
+
const e = await N(), r = await I("default"), s = C.getDefault(), o = (await R.getCredential(`${s.url}/sharing`)).token, i = {
|
|
12
14
|
type: "generateEmbeddings",
|
|
13
15
|
webmapEmbeddings: t,
|
|
14
|
-
auth: { apiUrl: r, token:
|
|
16
|
+
auth: { apiUrl: r, token: o }
|
|
15
17
|
};
|
|
16
18
|
return e.postMessage(i), await new Promise((c, d) => {
|
|
17
|
-
const
|
|
18
|
-
u.data === "completed" && (e.removeEventListener("message",
|
|
19
|
+
const a = (u) => {
|
|
20
|
+
u.data === "completed" && (e.removeEventListener("message", a), c());
|
|
19
21
|
}, g = (u) => {
|
|
20
|
-
e.removeEventListener("message",
|
|
22
|
+
e.removeEventListener("message", a), d(u instanceof Error ? u : new Error("Embeddings worker error"));
|
|
21
23
|
};
|
|
22
|
-
e.addEventListener("message",
|
|
24
|
+
e.addEventListener("message", a), e.addEventListener("error", g, { once: !0 });
|
|
23
25
|
}), e;
|
|
24
26
|
}, N = async () => {
|
|
25
27
|
{
|
|
26
28
|
const t = (await import("./embeddings.worker.js")).default;
|
|
27
29
|
return new t();
|
|
28
30
|
}
|
|
29
|
-
},
|
|
31
|
+
}, _ = (t) => {
|
|
30
32
|
t.currentIntent = "none";
|
|
31
|
-
},
|
|
33
|
+
}, V = async (t, e) => {
|
|
32
34
|
const r = v(e);
|
|
33
35
|
if (t.agentExecutionContext.userRequest) {
|
|
34
|
-
const n = new
|
|
35
|
-
t.agentExecutionContext.messages = [...t.agentExecutionContext.messages, n],
|
|
36
|
+
const n = new H(t.agentExecutionContext.userRequest.trim());
|
|
37
|
+
t.agentExecutionContext.messages = [...t.agentExecutionContext.messages, n], _(t);
|
|
36
38
|
}
|
|
37
39
|
const s = r?.services.agentRegistry.list().map((n) => n.agent.id) ?? [];
|
|
38
40
|
return await l({ text: `Available agents: ${[...s].join(", ")}` }, e), await l({ text: "Analyzing user input" }, e), t;
|
|
39
|
-
},
|
|
41
|
+
}, z = async (t, e) => (await l({ text: "Exiting..." }, e), t), w = (t) => typeof t == "object" && t !== null && !Array.isArray(t), Q = (t, e) => {
|
|
40
42
|
if (!w(t)) {
|
|
41
43
|
t !== void 0 && console.warn(`Agent "${e}" returned invalid sharedStatePatch. Ignoring it.`);
|
|
42
44
|
return;
|
|
@@ -52,28 +54,28 @@ const U = async (t) => {
|
|
|
52
54
|
r[s] = { value: n.value };
|
|
53
55
|
}
|
|
54
56
|
return r;
|
|
55
|
-
},
|
|
57
|
+
}, B = (t) => {
|
|
56
58
|
const { previousSharedState: e, patch: r, agentId: s } = t;
|
|
57
59
|
if (!r)
|
|
58
60
|
return e;
|
|
59
|
-
const n = Date.now(),
|
|
61
|
+
const n = Date.now(), o = {
|
|
60
62
|
...e
|
|
61
63
|
};
|
|
62
64
|
for (const [i, c] of Object.entries(r))
|
|
63
|
-
c?.value !== void 0 && (
|
|
65
|
+
c?.value !== void 0 && (o[i] = {
|
|
64
66
|
value: c.value,
|
|
65
67
|
meta: {
|
|
66
68
|
updatedByAgentId: s,
|
|
67
69
|
updatedAt: n
|
|
68
70
|
}
|
|
69
71
|
});
|
|
70
|
-
return
|
|
72
|
+
return o;
|
|
71
73
|
}, f = (t) => {
|
|
72
74
|
if (typeof t != "string")
|
|
73
75
|
return;
|
|
74
76
|
const e = t.trim();
|
|
75
77
|
return e || void 0;
|
|
76
|
-
},
|
|
78
|
+
}, J = (t) => {
|
|
77
79
|
switch (t) {
|
|
78
80
|
case "failed":
|
|
79
81
|
return "Agent failed without a summary.";
|
|
@@ -84,19 +86,19 @@ const U = async (t) => {
|
|
|
84
86
|
default:
|
|
85
87
|
return "Agent completed without a summary.";
|
|
86
88
|
}
|
|
87
|
-
},
|
|
88
|
-
const r = f(e?.outputMessage), s = f(e?.summary), n = e?.status,
|
|
89
|
-
|
|
90
|
-
const i =
|
|
89
|
+
}, K = (t, e) => {
|
|
90
|
+
const r = f(e?.outputMessage), s = f(e?.summary), n = e?.status, o = n === "success" || n === "failed" ? n : "unknown";
|
|
91
|
+
o === "unknown" && console.warn(`Agent "${t}" returned missing/invalid status. Defaulting to "unknown".`);
|
|
92
|
+
const i = Q(e?.sharedStatePatch, t);
|
|
91
93
|
return {
|
|
92
94
|
outputMessage: r,
|
|
93
|
-
summary: s ?? r ??
|
|
94
|
-
status:
|
|
95
|
+
summary: s ?? r ?? J(o),
|
|
96
|
+
status: o,
|
|
95
97
|
sharedStatePatch: i
|
|
96
98
|
};
|
|
97
|
-
}, E = 4e3,
|
|
99
|
+
}, E = 4e3, X = async (t, e) => {
|
|
98
100
|
const r = v(e);
|
|
99
|
-
if (
|
|
101
|
+
if (e?.signal?.aborted)
|
|
100
102
|
return await l({ text: "Run cancelled; skipping agent execution" }, e), {
|
|
101
103
|
...t,
|
|
102
104
|
currentIntent: "none",
|
|
@@ -106,7 +108,7 @@ const U = async (t) => {
|
|
|
106
108
|
if (!n)
|
|
107
109
|
return console.warn(`No agent found for intent: ${t.currentIntent}`), t;
|
|
108
110
|
await l({ text: `Executing registered agent: ${n.agent.name}` }, e);
|
|
109
|
-
const
|
|
111
|
+
const o = {
|
|
110
112
|
...e ?? {},
|
|
111
113
|
configurable: {
|
|
112
114
|
...r ?? {},
|
|
@@ -116,7 +118,7 @@ const U = async (t) => {
|
|
|
116
118
|
};
|
|
117
119
|
let i;
|
|
118
120
|
try {
|
|
119
|
-
const
|
|
121
|
+
const a = await n.agent.createGraph().compile().invoke(
|
|
120
122
|
{
|
|
121
123
|
agentExecutionContext: {
|
|
122
124
|
...t.agentExecutionContext,
|
|
@@ -127,14 +129,14 @@ const U = async (t) => {
|
|
|
127
129
|
sharedState: structuredClone(t.agentExecutionContext.sharedState ?? {})
|
|
128
130
|
}
|
|
129
131
|
},
|
|
130
|
-
|
|
132
|
+
o
|
|
131
133
|
);
|
|
132
|
-
i =
|
|
133
|
-
} catch (
|
|
134
|
-
if (D(
|
|
135
|
-
throw
|
|
136
|
-
const g =
|
|
137
|
-
console.error(`Agent "${n.agent.name}" failed:`,
|
|
134
|
+
i = K(n.agent.name, a), await l({ text: `Finished executing registered agent: ${n.agent.name}` }, e);
|
|
135
|
+
} catch (a) {
|
|
136
|
+
if (D(a) || e?.signal?.aborted || a instanceof Error && a.name === "AbortError")
|
|
137
|
+
throw a;
|
|
138
|
+
const g = a instanceof Error ? a.message : String(a);
|
|
139
|
+
console.error(`Agent "${n.agent.name}" failed:`, a), await l({ text: `Registered agent failed: ${n.agent.name}. ${g}` }, e), i = {
|
|
138
140
|
status: "failed",
|
|
139
141
|
outputMessage: `Agent execution failed: ${g}`,
|
|
140
142
|
summary: `Agent execution failed: ${g}`
|
|
@@ -142,9 +144,9 @@ const U = async (t) => {
|
|
|
142
144
|
}
|
|
143
145
|
const c = i.outputMessage, d = [...t.agentExecutionContext.messages];
|
|
144
146
|
if (c) {
|
|
145
|
-
const
|
|
147
|
+
const a = c.length > E ? `${c.slice(0, E - 14)}
|
|
146
148
|
[truncated]` : c;
|
|
147
|
-
d.push(new
|
|
149
|
+
d.push(new P(a));
|
|
148
150
|
}
|
|
149
151
|
return {
|
|
150
152
|
...t,
|
|
@@ -164,18 +166,18 @@ const U = async (t) => {
|
|
|
164
166
|
status: i?.status || "unknown"
|
|
165
167
|
}
|
|
166
168
|
],
|
|
167
|
-
sharedState:
|
|
169
|
+
sharedState: B({
|
|
168
170
|
previousSharedState: t.agentExecutionContext.sharedState,
|
|
169
171
|
patch: i.sharedStatePatch,
|
|
170
172
|
agentId: n.agent.id
|
|
171
173
|
})
|
|
172
174
|
}
|
|
173
175
|
};
|
|
174
|
-
},
|
|
176
|
+
}, Y = 3, Z = () => new L(k).addNode("ingestInput", V).addNode("intentLLM", A).addNode("executeRegisteredAgent", X).addNode("exit", z).addEdge(W, "ingestInput").addEdge("ingestInput", "intentLLM").addConditionalEdges("intentLLM", (e) => e.currentIntent === "none" || e.currentIntent === e.lastExecutedAgent ? "exit" : "executeRegisteredAgent").addConditionalEdges(
|
|
175
177
|
"executeRegisteredAgent",
|
|
176
|
-
(e) => e.stepCount >=
|
|
178
|
+
(e) => e.stepCount >= Y || !e.requiresFollowUp ? "exit" : "intentLLM"
|
|
177
179
|
).addEdge("exit", $);
|
|
178
|
-
class
|
|
180
|
+
class ee {
|
|
179
181
|
constructor() {
|
|
180
182
|
this.agentRegistry = /* @__PURE__ */ new Map();
|
|
181
183
|
}
|
|
@@ -192,7 +194,7 @@ class Z {
|
|
|
192
194
|
return [...this.agentRegistry.values()];
|
|
193
195
|
}
|
|
194
196
|
}
|
|
195
|
-
class
|
|
197
|
+
class te {
|
|
196
198
|
/**
|
|
197
199
|
* Create a new InterruptHandler tied to a specific compiled graph and config.
|
|
198
200
|
*/
|
|
@@ -239,34 +241,34 @@ class ee {
|
|
|
239
241
|
this.rejectWait && (this.rejectWait(new Error("Request cancelled by user.")), this.resolveWait = void 0, this.rejectWait = void 0);
|
|
240
242
|
}
|
|
241
243
|
}
|
|
242
|
-
const
|
|
244
|
+
const re = async (t) => {
|
|
243
245
|
try {
|
|
244
246
|
return await (await M()).embedDocuments(t);
|
|
245
247
|
} catch (e) {
|
|
246
248
|
throw console.error("Failed to generate embeddings:", e), e;
|
|
247
249
|
}
|
|
248
|
-
},
|
|
250
|
+
}, x = async (t, e) => {
|
|
249
251
|
const r = e.get(t);
|
|
250
252
|
if (r)
|
|
251
253
|
return r;
|
|
252
|
-
const s = await
|
|
254
|
+
const s = await re([t]);
|
|
253
255
|
return e.set(t, s[0]), s[0];
|
|
254
256
|
};
|
|
255
|
-
async function
|
|
257
|
+
async function ne(t, e, r, s) {
|
|
256
258
|
const n = `req-${Date.now()}`, i = {
|
|
257
259
|
type: "layerSearch",
|
|
258
|
-
precomputedEmbedding: s ? await
|
|
260
|
+
precomputedEmbedding: s ? await x(t, s) : void 0,
|
|
259
261
|
requestId: n,
|
|
260
262
|
minScore: r
|
|
261
263
|
};
|
|
262
264
|
return await new Promise((c) => {
|
|
263
|
-
const d = (
|
|
264
|
-
|
|
265
|
+
const d = (a) => {
|
|
266
|
+
a.data.requestId === n && c(a.data.results);
|
|
265
267
|
};
|
|
266
268
|
e.addEventListener("message", d, { once: !0 }), e.postMessage(i);
|
|
267
269
|
});
|
|
268
270
|
}
|
|
269
|
-
function
|
|
271
|
+
function se(t) {
|
|
270
272
|
const { worker: e } = t;
|
|
271
273
|
return {
|
|
272
274
|
async searchLayers({
|
|
@@ -274,19 +276,19 @@ function ne(t) {
|
|
|
274
276
|
minScore: s,
|
|
275
277
|
embeddingCache: n
|
|
276
278
|
}) {
|
|
277
|
-
return await
|
|
279
|
+
return await ne(r, e, s, n);
|
|
278
280
|
}
|
|
279
281
|
};
|
|
280
282
|
}
|
|
281
|
-
const
|
|
283
|
+
const ae = async ({
|
|
282
284
|
combinedQuery: t,
|
|
283
285
|
layerIds: e,
|
|
284
286
|
embeddingsWorker: r,
|
|
285
287
|
minScore: s,
|
|
286
288
|
topResults: n,
|
|
287
|
-
embeddingCache:
|
|
289
|
+
embeddingCache: o
|
|
288
290
|
}) => {
|
|
289
|
-
const i = `req-${Date.now()}`, c =
|
|
291
|
+
const i = `req-${Date.now()}`, c = o ? await x(t, o) : void 0, d = {
|
|
290
292
|
type: "fieldSearch",
|
|
291
293
|
layerIdForFieldsSearch: e,
|
|
292
294
|
precomputedEmbedding: c,
|
|
@@ -294,7 +296,7 @@ const se = async ({
|
|
|
294
296
|
minScore: s,
|
|
295
297
|
topResults: n
|
|
296
298
|
};
|
|
297
|
-
return await new Promise((
|
|
299
|
+
return await new Promise((a) => {
|
|
298
300
|
const g = (u) => {
|
|
299
301
|
if (u.data.requestId !== i)
|
|
300
302
|
return;
|
|
@@ -302,44 +304,44 @@ const se = async ({
|
|
|
302
304
|
layerId: y,
|
|
303
305
|
results: m
|
|
304
306
|
}));
|
|
305
|
-
|
|
307
|
+
a(p);
|
|
306
308
|
};
|
|
307
309
|
r.addEventListener("message", g, { once: !0 }), r.postMessage(d);
|
|
308
310
|
});
|
|
309
311
|
};
|
|
310
|
-
function
|
|
312
|
+
function ie(t) {
|
|
311
313
|
const { worker: e } = t;
|
|
312
314
|
return {
|
|
313
|
-
async searchFields({ text: r, layerIds: s, minScore: n, topResults:
|
|
314
|
-
return await
|
|
315
|
+
async searchFields({ text: r, layerIds: s, minScore: n, topResults: o, embeddingCache: i }) {
|
|
316
|
+
return await ae({
|
|
315
317
|
combinedQuery: r,
|
|
316
318
|
layerIds: s,
|
|
317
319
|
embeddingsWorker: e,
|
|
318
320
|
minScore: n,
|
|
319
|
-
topResults:
|
|
321
|
+
topResults: o,
|
|
320
322
|
embeddingCache: i
|
|
321
323
|
});
|
|
322
324
|
}
|
|
323
325
|
};
|
|
324
326
|
}
|
|
325
|
-
const
|
|
327
|
+
const oe = (t) => {
|
|
326
328
|
const e = F.safeParse(t);
|
|
327
329
|
if (!e.success)
|
|
328
330
|
throw new Error("Embeddings response validation failed. Regenerate embeddings.");
|
|
329
331
|
return e.data;
|
|
330
|
-
},
|
|
332
|
+
}, ce = (t, e) => {
|
|
331
333
|
const r = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map();
|
|
332
334
|
if (e.allLayers.forEach((n) => {
|
|
333
|
-
n instanceof
|
|
335
|
+
n instanceof T && s.set(n.id, n);
|
|
334
336
|
}), t.length !== s.size)
|
|
335
337
|
throw new Error("Layer count mismatch during registry restoration. Regenerate embeddings.");
|
|
336
338
|
for (const n of t) {
|
|
337
|
-
const
|
|
338
|
-
if (!
|
|
339
|
+
const o = s.get(n.id);
|
|
340
|
+
if (!o)
|
|
339
341
|
throw new Error(
|
|
340
342
|
`Layer with ID ${n.id} not found in the original map during registry restoration. Regenerate embeddings.`
|
|
341
343
|
);
|
|
342
|
-
if (n.fields.length !==
|
|
344
|
+
if (n.fields.length !== o.fields.length)
|
|
343
345
|
throw new Error(
|
|
344
346
|
`Field count mismatch for layer ID ${n.id} during registry restoration. Regenerate embeddings.`
|
|
345
347
|
);
|
|
@@ -349,18 +351,18 @@ const ie = (t) => {
|
|
|
349
351
|
description: n.description
|
|
350
352
|
}, c = /* @__PURE__ */ new Map();
|
|
351
353
|
for (const d of n.fields) {
|
|
352
|
-
const
|
|
353
|
-
if (!
|
|
354
|
+
const a = o.fieldsIndex.get(d.name);
|
|
355
|
+
if (!a)
|
|
354
356
|
throw new Error(
|
|
355
357
|
`Field with name ${d.name} not found in the original layer ${n.id} during registry restoration. Regenerate embeddings.`
|
|
356
358
|
);
|
|
357
359
|
c.set(d.name, {
|
|
358
360
|
name: d.name,
|
|
359
|
-
alias:
|
|
361
|
+
alias: o.getFieldAlias(d.name) ?? d.alias,
|
|
360
362
|
description: d.description,
|
|
361
|
-
type:
|
|
362
|
-
valueType:
|
|
363
|
-
domain:
|
|
363
|
+
type: a.type || "unknown",
|
|
364
|
+
valueType: a.valueType || "unknown",
|
|
365
|
+
domain: o.getFieldDomain(d.name) ?? void 0
|
|
364
366
|
});
|
|
365
367
|
}
|
|
366
368
|
r.set(n.id, {
|
|
@@ -369,27 +371,27 @@ const ie = (t) => {
|
|
|
369
371
|
});
|
|
370
372
|
}
|
|
371
373
|
return r;
|
|
372
|
-
},
|
|
374
|
+
}, de = async (t) => {
|
|
373
375
|
try {
|
|
374
|
-
return (await
|
|
376
|
+
return (await U(t, {
|
|
375
377
|
responseType: "json"
|
|
376
378
|
})).data;
|
|
377
379
|
} catch (e) {
|
|
378
380
|
throw new Error(`Failed to fetch data from ${t}: ${String(e)}`);
|
|
379
381
|
}
|
|
380
|
-
},
|
|
382
|
+
}, ue = async (t) => {
|
|
381
383
|
const e = t.map;
|
|
382
384
|
if (!e?.portalItem)
|
|
383
385
|
throw new Error("WebMap portal item is missing.");
|
|
384
386
|
const { resources: r } = await e.portalItem.fetchResources(), s = r.find((i) => i.resource.path === "embeddings-v01.json");
|
|
385
387
|
if (!s?.resource.url)
|
|
386
388
|
throw new Error("Embeddings resource 'embeddings-v01.json' not found in the webmap portal item.");
|
|
387
|
-
const n = await
|
|
388
|
-
return
|
|
389
|
+
const n = await de(s.resource.url);
|
|
390
|
+
return oe(n);
|
|
389
391
|
};
|
|
390
|
-
class
|
|
392
|
+
class b {
|
|
391
393
|
constructor() {
|
|
392
|
-
this.orchestratorReady = !1, this.chatHistory = [], this.priorSteps = [], this.sharedState = {}, this.agentRegistry = new
|
|
394
|
+
this.orchestratorReady = !1, this.chatHistory = [], this.priorSteps = [], this.sharedState = {}, this.agentRegistry = new ee(), this.activeRunId = "", this.cancelledRunIds = /* @__PURE__ */ new Set(), this.streamEpoch = 0;
|
|
393
395
|
}
|
|
394
396
|
/**
|
|
395
397
|
* Creates and returns an AI-ready Orchestrator instance.
|
|
@@ -397,15 +399,15 @@ class x {
|
|
|
397
399
|
* @returns Ready Orchestrator.
|
|
398
400
|
*/
|
|
399
401
|
static async init(e) {
|
|
400
|
-
const r = new
|
|
402
|
+
const r = new b();
|
|
401
403
|
try {
|
|
402
404
|
if (e.view?.map) {
|
|
403
|
-
await
|
|
404
|
-
const s = await
|
|
405
|
+
await O.whenOnce(() => e.view.ready);
|
|
406
|
+
const s = await ue(e.view), n = ce(
|
|
405
407
|
s.layers,
|
|
406
408
|
e.view.map
|
|
407
409
|
);
|
|
408
|
-
r.layersAndFieldsRegistry = n, r.embeddingsWorker = await
|
|
410
|
+
r.layersAndFieldsRegistry = n, r.embeddingsWorker = await G(s);
|
|
409
411
|
}
|
|
410
412
|
return e.agents?.forEach((s) => {
|
|
411
413
|
r.agentRegistry.register(s);
|
|
@@ -429,24 +431,24 @@ class x {
|
|
|
429
431
|
throw new Error("Orchestrator has no registered agents.");
|
|
430
432
|
if (++this.streamEpoch, !e.trim())
|
|
431
433
|
return;
|
|
432
|
-
const r =
|
|
433
|
-
this.activeRunId = r, this.activeAbortController = new AbortController(), this.graph || (this.graph =
|
|
434
|
-
const s = this.embeddingsWorker ?
|
|
434
|
+
const r = q();
|
|
435
|
+
this.activeRunId = r, this.activeAbortController = new AbortController(), this.graph || (this.graph = Z().compile({ checkpointer: new j() }));
|
|
436
|
+
const s = this.embeddingsWorker ? se({ worker: this.embeddingsWorker }) : void 0, n = this.embeddingsWorker ? ie({ worker: this.embeddingsWorker }) : void 0, o = /* @__PURE__ */ new Map(), i = {
|
|
437
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
438
|
+
thread_id: r,
|
|
439
|
+
hitlResponse: null,
|
|
440
|
+
services: {
|
|
441
|
+
layerSearch: s,
|
|
442
|
+
fieldSearch: n,
|
|
443
|
+
layersAndFieldsRegistry: this.layersAndFieldsRegistry,
|
|
444
|
+
agentRegistry: this.agentRegistry,
|
|
445
|
+
embeddingCache: o
|
|
446
|
+
}
|
|
447
|
+
}, c = {
|
|
435
448
|
version: "v2",
|
|
436
449
|
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
|
-
},
|
|
450
|
+
signal: this.activeAbortController.signal,
|
|
451
|
+
configurable: i,
|
|
450
452
|
subgraphs: !0
|
|
451
453
|
}, d = this.graph?.streamEvents(
|
|
452
454
|
{
|
|
@@ -458,8 +460,8 @@ class x {
|
|
|
458
460
|
}
|
|
459
461
|
},
|
|
460
462
|
c
|
|
461
|
-
),
|
|
462
|
-
if (yield* this.pipeStream(d,
|
|
463
|
+
), a = ++this.streamEpoch;
|
|
464
|
+
if (yield* this.pipeStream(d, a, r), this.isRunCancelled(r)) {
|
|
463
465
|
yield { runId: r, timestamp: Date.now(), type: "cancelled", reason: "user" };
|
|
464
466
|
return;
|
|
465
467
|
}
|
|
@@ -471,7 +473,7 @@ class x {
|
|
|
471
473
|
const m = (await this.graph.getState(c, { subgraphs: !0 })).tasks.find((h) => h.interrupts.length > 0)?.interrupts[0]?.value;
|
|
472
474
|
if (!m)
|
|
473
475
|
break;
|
|
474
|
-
this.currentInterrupt = m, this.interruptHandler = new
|
|
476
|
+
this.currentInterrupt = m, this.interruptHandler = new te(this.graph, c), yield { runId: r, timestamp: Date.now(), type: "interrupt", interrupt: m };
|
|
475
477
|
try {
|
|
476
478
|
const h = await this.interruptHandler.waitForUser(), S = ++this.streamEpoch;
|
|
477
479
|
yield* this.pipeStream(h, S, r);
|
|
@@ -562,6 +564,6 @@ class x {
|
|
|
562
564
|
}
|
|
563
565
|
}
|
|
564
566
|
export {
|
|
565
|
-
|
|
566
|
-
|
|
567
|
+
b as O,
|
|
568
|
+
re as g
|
|
567
569
|
};
|
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
function
|
|
3
|
-
return `
|
|
4
|
-
}
|
|
5
|
-
function o(e, t) {
|
|
6
|
-
return `block-${e}-${t}`;
|
|
2
|
+
function e(o, t) {
|
|
3
|
+
return `block-${o}-${t}`;
|
|
7
4
|
}
|
|
8
5
|
export {
|
|
9
|
-
|
|
10
|
-
a as g
|
|
6
|
+
e as g
|
|
11
7
|
};
|
package/dist/chunks/state.js
CHANGED
|
@@ -13,7 +13,7 @@ function u() {
|
|
|
13
13
|
function i(r) {
|
|
14
14
|
const n = [...new Set([...r].filter((t) => c.has(t)))];
|
|
15
15
|
if (n.length !== 0)
|
|
16
|
-
throw new Error(`
|
|
16
|
+
throw new Error(`custom state cannot define reserved runtime fields: ${n.join(", ")}.`);
|
|
17
17
|
}
|
|
18
18
|
function f(r) {
|
|
19
19
|
const n = Object.entries(r);
|
|
@@ -22,13 +22,15 @@ Use chat history only when necessary to understand conversational references, an
|
|
|
22
22
|
|
|
23
23
|
### Your goal:
|
|
24
24
|
|
|
25
|
-
1. If the assigned task is about a **specific calculation** (e.g., average, total, count, min, max), return
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
25
|
+
1. If the assigned task is about a **specific calculation** (e.g., average, total, count, min, max), return a **single concise sentence** that includes the numeric result.
|
|
26
|
+
|
|
27
|
+
- Example: “The average price is $4.00.”
|
|
28
|
+
- Never return a bare number by itself (for example: \`4\`).
|
|
29
|
+
- When a value is already present in \`queryResponse\` (for example in \`details.value\` or \`summary\`), copy that value **verbatim**.
|
|
30
|
+
- Do NOT reformat values (including numbers, dates, and times):
|
|
31
|
+
- Do not add/remove grouping commas.
|
|
32
|
+
- Do not change decimals, round values, or change numeric type/text.
|
|
33
|
+
- Do not change date/time format, timezone notation, separators, or precision.
|
|
32
34
|
|
|
33
35
|
2. If the question is more general or there are **multiple features with varying attributes**, write a **brief summary** (2–3 sentences max) that highlights key patterns or insights.
|
|
34
36
|
|
|
@@ -2,28 +2,31 @@
|
|
|
2
2
|
import "@arcgis/core/identity/IdentityManager.js";
|
|
3
3
|
import "@arcgis/core/portal/Portal.js";
|
|
4
4
|
import "@langchain/langgraph/web";
|
|
5
|
-
import
|
|
5
|
+
import "@arcgis/toolkit/string";
|
|
6
|
+
import "./generateLayerDescriptions.js";
|
|
6
7
|
import "@langchain/core/messages";
|
|
8
|
+
import { s as a } from "./index.js";
|
|
7
9
|
import "@langchain/openai";
|
|
10
|
+
import "@arcgis/core/config.js";
|
|
8
11
|
import "@arcgis/core/core/reactiveUtils.js";
|
|
9
12
|
import "@arcgis/core/layers/FeatureLayer.js";
|
|
10
13
|
import "@arcgis/core/request.js";
|
|
11
14
|
import "@langchain/core/prompts";
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
if (
|
|
15
|
-
await
|
|
15
|
+
const L = async (t, o) => {
|
|
16
|
+
const i = t.tool_calls ?? [];
|
|
17
|
+
if (i.length === 0) {
|
|
18
|
+
await a({ text: `LLM did not request any tool calls: ${String(t?.content)}` }, o);
|
|
16
19
|
return;
|
|
17
20
|
}
|
|
18
21
|
await Promise.all(
|
|
19
|
-
|
|
20
|
-
async (
|
|
21
|
-
{ text: `LLM invoked ${
|
|
22
|
+
i.map(
|
|
23
|
+
async (r) => await a(
|
|
24
|
+
{ text: `LLM invoked ${r.name} tool with arguments: ${JSON.stringify(r.args, null, 2)}` },
|
|
22
25
|
o
|
|
23
26
|
)
|
|
24
27
|
)
|
|
25
28
|
);
|
|
26
29
|
};
|
|
27
30
|
export {
|
|
28
|
-
|
|
31
|
+
L as h
|
|
29
32
|
};
|
package/dist/chunks/utils2.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
2
|
import { getClosestElement as i } from "@arcgis/toolkit/dom";
|
|
3
|
-
import { g as
|
|
3
|
+
import { g as s, a as o } from "./utils3.js";
|
|
4
4
|
function c(e, t) {
|
|
5
|
-
const
|
|
6
|
-
if (
|
|
7
|
-
return
|
|
8
|
-
const n = i(e.el, "arcgis-assistant"), a =
|
|
5
|
+
const r = s(e.el, e.referenceElement);
|
|
6
|
+
if (r)
|
|
7
|
+
return r;
|
|
8
|
+
const n = i(e.el, "arcgis-assistant"), a = s(e.el, n?.referenceElement);
|
|
9
9
|
if (a)
|
|
10
10
|
return a;
|
|
11
11
|
throw new Error(`${t}: Reference element not found`);
|
|
@@ -23,16 +23,16 @@ function g(e) {
|
|
|
23
23
|
const t = i(e.el, "arcgis-assistant");
|
|
24
24
|
if (t === void 0)
|
|
25
25
|
throw new Error("arcgis-assistant-agent must be used within an arcgis-assistant element");
|
|
26
|
-
t.register({
|
|
26
|
+
return t.register({
|
|
27
27
|
agent: e.agent,
|
|
28
28
|
getContext: async () => await e.getContext?.() ?? e.context ?? {}
|
|
29
|
-
});
|
|
29
|
+
}), t;
|
|
30
30
|
}
|
|
31
31
|
function l(e) {
|
|
32
32
|
const t = o(e.el, e.referenceElement);
|
|
33
33
|
if (t)
|
|
34
34
|
return t;
|
|
35
|
-
const
|
|
35
|
+
const r = i(e.el, "arcgis-assistant"), n = s(e.el, r?.referenceElement);
|
|
36
36
|
return n || null;
|
|
37
37
|
}
|
|
38
38
|
function v(e) {
|