@arcgis/ai-components 5.2.0-next.12 → 5.2.0-next.14
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/LLMAgent.js +1 -0
- package/dist/cdn/{5CV7R5IS.js → 22IT5TDB.js} +2 -2
- package/dist/cdn/{EBISDZ5H.js → 4UDYY3HL.js} +1 -1
- package/dist/cdn/7PANDHIL.js +16 -0
- package/dist/cdn/ADYIXCSG.js +2 -0
- package/dist/cdn/CAECQD75.js +2 -0
- package/dist/cdn/{34SG44C3.js → CE6VDP2D.js} +1 -1
- package/dist/cdn/CI3QSFPS.js +2 -0
- package/dist/cdn/DEAYZ3MK.js +2 -0
- package/dist/cdn/{YLN2BZ5J.js → E2HENO3T.js} +1 -1
- package/dist/cdn/FWU6DFIB.js +2 -0
- package/dist/cdn/GBYLKQIL.js +2 -0
- package/dist/cdn/GPYYAQVI.js +2 -0
- package/dist/cdn/{ERL2CB2Y.js → I2Y67HBL.js} +5 -5
- package/dist/cdn/JG2BIENI.js +3 -0
- package/dist/cdn/JN744CAW.js +2 -0
- package/dist/cdn/K475UT3E.js +2 -0
- package/dist/cdn/{JLKGS6Y5.js → L4XF4H6V.js} +1 -1
- package/dist/cdn/M3SWPT3M.js +2 -0
- package/dist/cdn/MAV3DW27.js +4 -0
- package/dist/cdn/PB2ODJC7.js +2 -0
- package/dist/cdn/{QCSN44H4.js → QSA4T3BU.js} +1 -1
- package/dist/cdn/{R56X6ZKR.js → QYR3NSF2.js} +3 -3
- package/dist/cdn/RMLXVQZ5.js +2 -0
- package/dist/cdn/{T43LEBBE.js → S75VFYR4.js} +18 -18
- package/dist/cdn/SBHLUL3Q.js +2 -0
- package/dist/cdn/{X2ZDYHCG.js → TNMXWUXU.js} +9 -4
- package/dist/cdn/WH6QQK6N.js +2 -0
- package/dist/cdn/XBW4MWQR.js +2 -0
- package/dist/cdn/{Z2G7MP5L.js → XU6NCSE2.js} +1 -1
- package/dist/cdn/Z7UWJ4AI.js +3 -0
- package/dist/cdn/ZOSUDIJH.js +2 -0
- package/dist/cdn/ZPLFFLPF.js +2 -0
- package/dist/cdn/agent-utils/index.js +1 -1
- package/dist/cdn/index.js +1 -1
- package/dist/chunks/adapter.js +170 -169
- package/dist/chunks/arcgisKnowledgeGraph.js +8 -7
- package/dist/chunks/dataExplorationGraph.js +88 -76
- package/dist/chunks/data_explore_query_prompt.js +9 -4
- package/dist/chunks/generateLayerDescriptions.js +161 -159
- package/dist/chunks/helpGraph.js +3 -2
- package/dist/chunks/layerStylingGraph.js +1 -0
- package/dist/chunks/navigationGraph.js +3 -2
- package/dist/chunks/orchestrator.js +108 -107
- package/dist/chunks/toolCallResponse.js +10 -9
- package/dist/components/arcgis-assistant/customElement.js +136 -124
- package/dist/components/arcgis-assistant-data-exploration-agent/customElement.js +3 -2
- package/dist/components/arcgis-assistant-help-agent/customElement.js +1 -0
- package/dist/components/arcgis-assistant-knowledge-agent/customElement.js +4 -3
- package/dist/components/arcgis-assistant-layer-styling-agent/customElement.js +1 -0
- package/dist/components/arcgis-assistant-navigation-agent/customElement.js +1 -0
- package/dist/docs/api.json +1 -1
- package/dist/docs/docs.json +1 -1
- package/dist/docs/web-types.json +1 -1
- package/package.json +5 -5
- package/dist/cdn/24QNMEFG.js +0 -2
- package/dist/cdn/3NBDVZ2I.js +0 -2
- package/dist/cdn/53NTYC4I.js +0 -2
- package/dist/cdn/AZGGTNA3.js +0 -2
- package/dist/cdn/B7WJFBOZ.js +0 -2
- package/dist/cdn/DZ2QWNUA.js +0 -3
- package/dist/cdn/F6QHMKF5.js +0 -2
- package/dist/cdn/H2CHHGGH.js +0 -2
- package/dist/cdn/HWKDNS4K.js +0 -4
- package/dist/cdn/IMQ4TVHF.js +0 -16
- package/dist/cdn/IRZDTYO2.js +0 -2
- package/dist/cdn/KHXUWZHB.js +0 -2
- package/dist/cdn/LIFK3QSD.js +0 -2
- package/dist/cdn/O3EN27N5.js +0 -2
- package/dist/cdn/PBO6FZN6.js +0 -2
- package/dist/cdn/Q3ZW4FYA.js +0 -3
- package/dist/cdn/UPEEHMSY.js +0 -2
- package/dist/cdn/WAIFKDR3.js +0 -2
- package/dist/cdn/XON27U6U.js +0 -2
- package/dist/cdn/YUKR4AZW.js +0 -2
|
@@ -3,41 +3,42 @@ import R from "@arcgis/core/identity/IdentityManager.js";
|
|
|
3
3
|
import C from "@arcgis/core/portal/Portal.js";
|
|
4
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 {
|
|
6
|
+
import { generateGuid as q } from "@arcgis/toolkit/string";
|
|
7
|
+
import { HumanMessage as H, AIMessage as P } from "@langchain/core/messages";
|
|
7
8
|
import { s as l } from "./index.js";
|
|
8
|
-
import * as
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
const
|
|
12
|
-
const e = await N(), r = await I("default"), s = C.getDefault(),
|
|
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 = {
|
|
13
14
|
type: "generateEmbeddings",
|
|
14
15
|
webmapEmbeddings: t,
|
|
15
|
-
auth: { apiUrl: r, token:
|
|
16
|
+
auth: { apiUrl: r, token: o }
|
|
16
17
|
};
|
|
17
18
|
return e.postMessage(i), await new Promise((c, d) => {
|
|
18
|
-
const
|
|
19
|
-
u.data === "completed" && (e.removeEventListener("message",
|
|
19
|
+
const a = (u) => {
|
|
20
|
+
u.data === "completed" && (e.removeEventListener("message", a), c());
|
|
20
21
|
}, g = (u) => {
|
|
21
|
-
e.removeEventListener("message",
|
|
22
|
+
e.removeEventListener("message", a), d(u instanceof Error ? u : new Error("Embeddings worker error"));
|
|
22
23
|
};
|
|
23
|
-
e.addEventListener("message",
|
|
24
|
+
e.addEventListener("message", a), e.addEventListener("error", g, { once: !0 });
|
|
24
25
|
}), e;
|
|
25
26
|
}, N = async () => {
|
|
26
27
|
{
|
|
27
28
|
const t = (await import("./embeddings.worker.js")).default;
|
|
28
29
|
return new t();
|
|
29
30
|
}
|
|
30
|
-
},
|
|
31
|
+
}, _ = (t) => {
|
|
31
32
|
t.currentIntent = "none";
|
|
32
|
-
},
|
|
33
|
+
}, V = async (t, e) => {
|
|
33
34
|
const r = v(e);
|
|
34
35
|
if (t.agentExecutionContext.userRequest) {
|
|
35
|
-
const n = new
|
|
36
|
-
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);
|
|
37
38
|
}
|
|
38
39
|
const s = r?.services.agentRegistry.list().map((n) => n.agent.id) ?? [];
|
|
39
40
|
return await l({ text: `Available agents: ${[...s].join(", ")}` }, e), await l({ text: "Analyzing user input" }, e), t;
|
|
40
|
-
},
|
|
41
|
+
}, z = async (t, e) => (await l({ text: "Exiting..." }, e), t), w = (t) => typeof t == "object" && t !== null && !Array.isArray(t), Q = (t, e) => {
|
|
41
42
|
if (!w(t)) {
|
|
42
43
|
t !== void 0 && console.warn(`Agent "${e}" returned invalid sharedStatePatch. Ignoring it.`);
|
|
43
44
|
return;
|
|
@@ -53,28 +54,28 @@ const T = async (t) => {
|
|
|
53
54
|
r[s] = { value: n.value };
|
|
54
55
|
}
|
|
55
56
|
return r;
|
|
56
|
-
},
|
|
57
|
+
}, B = (t) => {
|
|
57
58
|
const { previousSharedState: e, patch: r, agentId: s } = t;
|
|
58
59
|
if (!r)
|
|
59
60
|
return e;
|
|
60
|
-
const n = Date.now(),
|
|
61
|
+
const n = Date.now(), o = {
|
|
61
62
|
...e
|
|
62
63
|
};
|
|
63
64
|
for (const [i, c] of Object.entries(r))
|
|
64
|
-
c?.value !== void 0 && (
|
|
65
|
+
c?.value !== void 0 && (o[i] = {
|
|
65
66
|
value: c.value,
|
|
66
67
|
meta: {
|
|
67
68
|
updatedByAgentId: s,
|
|
68
69
|
updatedAt: n
|
|
69
70
|
}
|
|
70
71
|
});
|
|
71
|
-
return
|
|
72
|
+
return o;
|
|
72
73
|
}, f = (t) => {
|
|
73
74
|
if (typeof t != "string")
|
|
74
75
|
return;
|
|
75
76
|
const e = t.trim();
|
|
76
77
|
return e || void 0;
|
|
77
|
-
},
|
|
78
|
+
}, J = (t) => {
|
|
78
79
|
switch (t) {
|
|
79
80
|
case "failed":
|
|
80
81
|
return "Agent failed without a summary.";
|
|
@@ -85,19 +86,19 @@ const T = async (t) => {
|
|
|
85
86
|
default:
|
|
86
87
|
return "Agent completed without a summary.";
|
|
87
88
|
}
|
|
88
|
-
},
|
|
89
|
-
const r = f(e?.outputMessage), s = f(e?.summary), n = e?.status,
|
|
90
|
-
|
|
91
|
-
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);
|
|
92
93
|
return {
|
|
93
94
|
outputMessage: r,
|
|
94
|
-
summary: s ?? r ??
|
|
95
|
-
status:
|
|
95
|
+
summary: s ?? r ?? J(o),
|
|
96
|
+
status: o,
|
|
96
97
|
sharedStatePatch: i
|
|
97
98
|
};
|
|
98
|
-
}, E = 4e3,
|
|
99
|
+
}, E = 4e3, X = async (t, e) => {
|
|
99
100
|
const r = v(e);
|
|
100
|
-
if (
|
|
101
|
+
if (e?.signal?.aborted)
|
|
101
102
|
return await l({ text: "Run cancelled; skipping agent execution" }, e), {
|
|
102
103
|
...t,
|
|
103
104
|
currentIntent: "none",
|
|
@@ -107,7 +108,7 @@ const T = async (t) => {
|
|
|
107
108
|
if (!n)
|
|
108
109
|
return console.warn(`No agent found for intent: ${t.currentIntent}`), t;
|
|
109
110
|
await l({ text: `Executing registered agent: ${n.agent.name}` }, e);
|
|
110
|
-
const
|
|
111
|
+
const o = {
|
|
111
112
|
...e ?? {},
|
|
112
113
|
configurable: {
|
|
113
114
|
...r ?? {},
|
|
@@ -117,7 +118,7 @@ const T = async (t) => {
|
|
|
117
118
|
};
|
|
118
119
|
let i;
|
|
119
120
|
try {
|
|
120
|
-
const
|
|
121
|
+
const a = await n.agent.createGraph().compile().invoke(
|
|
121
122
|
{
|
|
122
123
|
agentExecutionContext: {
|
|
123
124
|
...t.agentExecutionContext,
|
|
@@ -128,14 +129,14 @@ const T = async (t) => {
|
|
|
128
129
|
sharedState: structuredClone(t.agentExecutionContext.sharedState ?? {})
|
|
129
130
|
}
|
|
130
131
|
},
|
|
131
|
-
|
|
132
|
+
o
|
|
132
133
|
);
|
|
133
|
-
i =
|
|
134
|
-
} catch (
|
|
135
|
-
if (D(
|
|
136
|
-
throw
|
|
137
|
-
const g =
|
|
138
|
-
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 = {
|
|
139
140
|
status: "failed",
|
|
140
141
|
outputMessage: `Agent execution failed: ${g}`,
|
|
141
142
|
summary: `Agent execution failed: ${g}`
|
|
@@ -143,9 +144,9 @@ const T = async (t) => {
|
|
|
143
144
|
}
|
|
144
145
|
const c = i.outputMessage, d = [...t.agentExecutionContext.messages];
|
|
145
146
|
if (c) {
|
|
146
|
-
const
|
|
147
|
+
const a = c.length > E ? `${c.slice(0, E - 14)}
|
|
147
148
|
[truncated]` : c;
|
|
148
|
-
d.push(new
|
|
149
|
+
d.push(new P(a));
|
|
149
150
|
}
|
|
150
151
|
return {
|
|
151
152
|
...t,
|
|
@@ -165,18 +166,18 @@ const T = async (t) => {
|
|
|
165
166
|
status: i?.status || "unknown"
|
|
166
167
|
}
|
|
167
168
|
],
|
|
168
|
-
sharedState:
|
|
169
|
+
sharedState: B({
|
|
169
170
|
previousSharedState: t.agentExecutionContext.sharedState,
|
|
170
171
|
patch: i.sharedStatePatch,
|
|
171
172
|
agentId: n.agent.id
|
|
172
173
|
})
|
|
173
174
|
}
|
|
174
175
|
};
|
|
175
|
-
},
|
|
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(
|
|
176
177
|
"executeRegisteredAgent",
|
|
177
|
-
(e) => e.stepCount >=
|
|
178
|
+
(e) => e.stepCount >= Y || !e.requiresFollowUp ? "exit" : "intentLLM"
|
|
178
179
|
).addEdge("exit", $);
|
|
179
|
-
class
|
|
180
|
+
class ee {
|
|
180
181
|
constructor() {
|
|
181
182
|
this.agentRegistry = /* @__PURE__ */ new Map();
|
|
182
183
|
}
|
|
@@ -193,7 +194,7 @@ class Z {
|
|
|
193
194
|
return [...this.agentRegistry.values()];
|
|
194
195
|
}
|
|
195
196
|
}
|
|
196
|
-
class
|
|
197
|
+
class te {
|
|
197
198
|
/**
|
|
198
199
|
* Create a new InterruptHandler tied to a specific compiled graph and config.
|
|
199
200
|
*/
|
|
@@ -240,34 +241,34 @@ class ee {
|
|
|
240
241
|
this.rejectWait && (this.rejectWait(new Error("Request cancelled by user.")), this.resolveWait = void 0, this.rejectWait = void 0);
|
|
241
242
|
}
|
|
242
243
|
}
|
|
243
|
-
const
|
|
244
|
+
const re = async (t) => {
|
|
244
245
|
try {
|
|
245
246
|
return await (await M()).embedDocuments(t);
|
|
246
247
|
} catch (e) {
|
|
247
248
|
throw console.error("Failed to generate embeddings:", e), e;
|
|
248
249
|
}
|
|
249
|
-
},
|
|
250
|
+
}, x = async (t, e) => {
|
|
250
251
|
const r = e.get(t);
|
|
251
252
|
if (r)
|
|
252
253
|
return r;
|
|
253
|
-
const s = await
|
|
254
|
+
const s = await re([t]);
|
|
254
255
|
return e.set(t, s[0]), s[0];
|
|
255
256
|
};
|
|
256
|
-
async function
|
|
257
|
+
async function ne(t, e, r, s) {
|
|
257
258
|
const n = `req-${Date.now()}`, i = {
|
|
258
259
|
type: "layerSearch",
|
|
259
|
-
precomputedEmbedding: s ? await
|
|
260
|
+
precomputedEmbedding: s ? await x(t, s) : void 0,
|
|
260
261
|
requestId: n,
|
|
261
262
|
minScore: r
|
|
262
263
|
};
|
|
263
264
|
return await new Promise((c) => {
|
|
264
|
-
const d = (
|
|
265
|
-
|
|
265
|
+
const d = (a) => {
|
|
266
|
+
a.data.requestId === n && c(a.data.results);
|
|
266
267
|
};
|
|
267
268
|
e.addEventListener("message", d, { once: !0 }), e.postMessage(i);
|
|
268
269
|
});
|
|
269
270
|
}
|
|
270
|
-
function
|
|
271
|
+
function se(t) {
|
|
271
272
|
const { worker: e } = t;
|
|
272
273
|
return {
|
|
273
274
|
async searchLayers({
|
|
@@ -275,19 +276,19 @@ function ne(t) {
|
|
|
275
276
|
minScore: s,
|
|
276
277
|
embeddingCache: n
|
|
277
278
|
}) {
|
|
278
|
-
return await
|
|
279
|
+
return await ne(r, e, s, n);
|
|
279
280
|
}
|
|
280
281
|
};
|
|
281
282
|
}
|
|
282
|
-
const
|
|
283
|
+
const ae = async ({
|
|
283
284
|
combinedQuery: t,
|
|
284
285
|
layerIds: e,
|
|
285
286
|
embeddingsWorker: r,
|
|
286
287
|
minScore: s,
|
|
287
288
|
topResults: n,
|
|
288
|
-
embeddingCache:
|
|
289
|
+
embeddingCache: o
|
|
289
290
|
}) => {
|
|
290
|
-
const i = `req-${Date.now()}`, c =
|
|
291
|
+
const i = `req-${Date.now()}`, c = o ? await x(t, o) : void 0, d = {
|
|
291
292
|
type: "fieldSearch",
|
|
292
293
|
layerIdForFieldsSearch: e,
|
|
293
294
|
precomputedEmbedding: c,
|
|
@@ -295,7 +296,7 @@ const se = async ({
|
|
|
295
296
|
minScore: s,
|
|
296
297
|
topResults: n
|
|
297
298
|
};
|
|
298
|
-
return await new Promise((
|
|
299
|
+
return await new Promise((a) => {
|
|
299
300
|
const g = (u) => {
|
|
300
301
|
if (u.data.requestId !== i)
|
|
301
302
|
return;
|
|
@@ -303,44 +304,44 @@ const se = async ({
|
|
|
303
304
|
layerId: y,
|
|
304
305
|
results: m
|
|
305
306
|
}));
|
|
306
|
-
|
|
307
|
+
a(p);
|
|
307
308
|
};
|
|
308
309
|
r.addEventListener("message", g, { once: !0 }), r.postMessage(d);
|
|
309
310
|
});
|
|
310
311
|
};
|
|
311
|
-
function
|
|
312
|
+
function ie(t) {
|
|
312
313
|
const { worker: e } = t;
|
|
313
314
|
return {
|
|
314
|
-
async searchFields({ text: r, layerIds: s, minScore: n, topResults:
|
|
315
|
-
return await
|
|
315
|
+
async searchFields({ text: r, layerIds: s, minScore: n, topResults: o, embeddingCache: i }) {
|
|
316
|
+
return await ae({
|
|
316
317
|
combinedQuery: r,
|
|
317
318
|
layerIds: s,
|
|
318
319
|
embeddingsWorker: e,
|
|
319
320
|
minScore: n,
|
|
320
|
-
topResults:
|
|
321
|
+
topResults: o,
|
|
321
322
|
embeddingCache: i
|
|
322
323
|
});
|
|
323
324
|
}
|
|
324
325
|
};
|
|
325
326
|
}
|
|
326
|
-
const
|
|
327
|
+
const oe = (t) => {
|
|
327
328
|
const e = F.safeParse(t);
|
|
328
329
|
if (!e.success)
|
|
329
330
|
throw new Error("Embeddings response validation failed. Regenerate embeddings.");
|
|
330
331
|
return e.data;
|
|
331
|
-
},
|
|
332
|
+
}, ce = (t, e) => {
|
|
332
333
|
const r = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map();
|
|
333
334
|
if (e.allLayers.forEach((n) => {
|
|
334
|
-
n instanceof
|
|
335
|
+
n instanceof T && s.set(n.id, n);
|
|
335
336
|
}), t.length !== s.size)
|
|
336
337
|
throw new Error("Layer count mismatch during registry restoration. Regenerate embeddings.");
|
|
337
338
|
for (const n of t) {
|
|
338
|
-
const
|
|
339
|
-
if (!
|
|
339
|
+
const o = s.get(n.id);
|
|
340
|
+
if (!o)
|
|
340
341
|
throw new Error(
|
|
341
342
|
`Layer with ID ${n.id} not found in the original map during registry restoration. Regenerate embeddings.`
|
|
342
343
|
);
|
|
343
|
-
if (n.fields.length !==
|
|
344
|
+
if (n.fields.length !== o.fields.length)
|
|
344
345
|
throw new Error(
|
|
345
346
|
`Field count mismatch for layer ID ${n.id} during registry restoration. Regenerate embeddings.`
|
|
346
347
|
);
|
|
@@ -350,18 +351,18 @@ const ie = (t) => {
|
|
|
350
351
|
description: n.description
|
|
351
352
|
}, c = /* @__PURE__ */ new Map();
|
|
352
353
|
for (const d of n.fields) {
|
|
353
|
-
const
|
|
354
|
-
if (!
|
|
354
|
+
const a = o.fieldsIndex.get(d.name);
|
|
355
|
+
if (!a)
|
|
355
356
|
throw new Error(
|
|
356
357
|
`Field with name ${d.name} not found in the original layer ${n.id} during registry restoration. Regenerate embeddings.`
|
|
357
358
|
);
|
|
358
359
|
c.set(d.name, {
|
|
359
360
|
name: d.name,
|
|
360
|
-
alias:
|
|
361
|
+
alias: o.getFieldAlias(d.name) ?? d.alias,
|
|
361
362
|
description: d.description,
|
|
362
|
-
type:
|
|
363
|
-
valueType:
|
|
364
|
-
domain:
|
|
363
|
+
type: a.type || "unknown",
|
|
364
|
+
valueType: a.valueType || "unknown",
|
|
365
|
+
domain: o.getFieldDomain(d.name) ?? void 0
|
|
365
366
|
});
|
|
366
367
|
}
|
|
367
368
|
r.set(n.id, {
|
|
@@ -370,27 +371,27 @@ const ie = (t) => {
|
|
|
370
371
|
});
|
|
371
372
|
}
|
|
372
373
|
return r;
|
|
373
|
-
},
|
|
374
|
+
}, de = async (t) => {
|
|
374
375
|
try {
|
|
375
|
-
return (await
|
|
376
|
+
return (await U(t, {
|
|
376
377
|
responseType: "json"
|
|
377
378
|
})).data;
|
|
378
379
|
} catch (e) {
|
|
379
380
|
throw new Error(`Failed to fetch data from ${t}: ${String(e)}`);
|
|
380
381
|
}
|
|
381
|
-
},
|
|
382
|
+
}, ue = async (t) => {
|
|
382
383
|
const e = t.map;
|
|
383
384
|
if (!e?.portalItem)
|
|
384
385
|
throw new Error("WebMap portal item is missing.");
|
|
385
386
|
const { resources: r } = await e.portalItem.fetchResources(), s = r.find((i) => i.resource.path === "embeddings-v01.json");
|
|
386
387
|
if (!s?.resource.url)
|
|
387
388
|
throw new Error("Embeddings resource 'embeddings-v01.json' not found in the webmap portal item.");
|
|
388
|
-
const n = await
|
|
389
|
-
return
|
|
389
|
+
const n = await de(s.resource.url);
|
|
390
|
+
return oe(n);
|
|
390
391
|
};
|
|
391
|
-
class
|
|
392
|
+
class b {
|
|
392
393
|
constructor() {
|
|
393
|
-
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;
|
|
394
395
|
}
|
|
395
396
|
/**
|
|
396
397
|
* Creates and returns an AI-ready Orchestrator instance.
|
|
@@ -398,15 +399,15 @@ class x {
|
|
|
398
399
|
* @returns Ready Orchestrator.
|
|
399
400
|
*/
|
|
400
401
|
static async init(e) {
|
|
401
|
-
const r = new
|
|
402
|
+
const r = new b();
|
|
402
403
|
try {
|
|
403
404
|
if (e.view?.map) {
|
|
404
|
-
await
|
|
405
|
-
const s = await
|
|
405
|
+
await O.whenOnce(() => e.view.ready);
|
|
406
|
+
const s = await ue(e.view), n = ce(
|
|
406
407
|
s.layers,
|
|
407
408
|
e.view.map
|
|
408
409
|
);
|
|
409
|
-
r.layersAndFieldsRegistry = n, r.embeddingsWorker = await
|
|
410
|
+
r.layersAndFieldsRegistry = n, r.embeddingsWorker = await G(s);
|
|
410
411
|
}
|
|
411
412
|
return e.agents?.forEach((s) => {
|
|
412
413
|
r.agentRegistry.register(s);
|
|
@@ -430,24 +431,24 @@ class x {
|
|
|
430
431
|
throw new Error("Orchestrator has no registered agents.");
|
|
431
432
|
if (++this.streamEpoch, !e.trim())
|
|
432
433
|
return;
|
|
433
|
-
const r =
|
|
434
|
-
this.activeRunId = r, this.activeAbortController = new AbortController(), this.graph || (this.graph =
|
|
435
|
-
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 = {
|
|
436
448
|
version: "v2",
|
|
437
449
|
streamMode: "custom",
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
thread_id: r,
|
|
441
|
-
abortSignal: this.activeAbortController.signal,
|
|
442
|
-
hitlResponse: null,
|
|
443
|
-
services: {
|
|
444
|
-
layerSearch: s,
|
|
445
|
-
fieldSearch: n,
|
|
446
|
-
layersAndFieldsRegistry: this.layersAndFieldsRegistry,
|
|
447
|
-
agentRegistry: this.agentRegistry,
|
|
448
|
-
embeddingCache: a
|
|
449
|
-
}
|
|
450
|
-
},
|
|
450
|
+
signal: this.activeAbortController.signal,
|
|
451
|
+
configurable: i,
|
|
451
452
|
subgraphs: !0
|
|
452
453
|
}, d = this.graph?.streamEvents(
|
|
453
454
|
{
|
|
@@ -459,8 +460,8 @@ class x {
|
|
|
459
460
|
}
|
|
460
461
|
},
|
|
461
462
|
c
|
|
462
|
-
),
|
|
463
|
-
if (yield* this.pipeStream(d,
|
|
463
|
+
), a = ++this.streamEpoch;
|
|
464
|
+
if (yield* this.pipeStream(d, a, r), this.isRunCancelled(r)) {
|
|
464
465
|
yield { runId: r, timestamp: Date.now(), type: "cancelled", reason: "user" };
|
|
465
466
|
return;
|
|
466
467
|
}
|
|
@@ -472,7 +473,7 @@ class x {
|
|
|
472
473
|
const m = (await this.graph.getState(c, { subgraphs: !0 })).tasks.find((h) => h.interrupts.length > 0)?.interrupts[0]?.value;
|
|
473
474
|
if (!m)
|
|
474
475
|
break;
|
|
475
|
-
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 };
|
|
476
477
|
try {
|
|
477
478
|
const h = await this.interruptHandler.waitForUser(), S = ++this.streamEpoch;
|
|
478
479
|
yield* this.pipeStream(h, S, r);
|
|
@@ -563,6 +564,6 @@ class x {
|
|
|
563
564
|
}
|
|
564
565
|
}
|
|
565
566
|
export {
|
|
566
|
-
|
|
567
|
-
|
|
567
|
+
b as O,
|
|
568
|
+
re as g
|
|
568
569
|
};
|
|
@@ -2,30 +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 "@arcgis/toolkit/string";
|
|
5
6
|
import "./generateLayerDescriptions.js";
|
|
6
7
|
import "@langchain/core/messages";
|
|
7
|
-
import { s as
|
|
8
|
+
import { s as a } from "./index.js";
|
|
8
9
|
import "@langchain/openai";
|
|
9
10
|
import "@arcgis/core/config.js";
|
|
10
11
|
import "@arcgis/core/core/reactiveUtils.js";
|
|
11
12
|
import "@arcgis/core/layers/FeatureLayer.js";
|
|
12
13
|
import "@arcgis/core/request.js";
|
|
13
14
|
import "@langchain/core/prompts";
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
if (
|
|
17
|
-
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);
|
|
18
19
|
return;
|
|
19
20
|
}
|
|
20
21
|
await Promise.all(
|
|
21
|
-
|
|
22
|
-
async (
|
|
23
|
-
{ 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)}` },
|
|
24
25
|
o
|
|
25
26
|
)
|
|
26
27
|
)
|
|
27
28
|
);
|
|
28
29
|
};
|
|
29
30
|
export {
|
|
30
|
-
|
|
31
|
+
L as h
|
|
31
32
|
};
|