@arcgis/ai-components 5.2.0-next.71 → 5.2.0-next.73
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/LICENSE.md +4 -2
- package/dist/agent-utils/LLMAgent.d.ts +5 -2
- package/dist/agent-utils/LLMAgent.js +1 -1
- package/dist/agent-utils/types.d.ts +1 -1
- package/dist/agentic-workflow/AgenticWorkflowRuntime.d.ts +24 -0
- package/dist/agentic-workflow/Edge.d.ts +16 -0
- package/dist/agentic-workflow/WebAgent.d.ts +39 -0
- package/dist/agentic-workflow/jsonTypes.d.ts +193 -0
- package/dist/agentic-workflow/nodes/AgentNode.d.ts +28 -0
- package/dist/agentic-workflow/nodes/BaseNode.d.ts +35 -0
- package/dist/agentic-workflow/nodes/EndMessageNode.d.ts +25 -0
- package/dist/agentic-workflow/nodes/StartNode.d.ts +21 -0
- package/dist/agentic-workflow/nodes/support/Prompt.d.ts +20 -0
- package/dist/agentic-workflow/nodes/tools/ArcgisTool.d.ts +21 -0
- package/dist/agentic-workflow/types.d.ts +29 -0
- package/dist/cdn/2EJROB32.js +2 -0
- package/dist/cdn/34O57OGV.js +2 -0
- package/dist/cdn/3LXXSMA5.js +2 -0
- package/dist/cdn/3MJQA533.js +2 -0
- package/dist/cdn/3U476GCP.js +5 -0
- package/dist/cdn/3XXZUQMQ.js +2 -0
- package/dist/cdn/4YDXYW4J.js +2 -0
- package/dist/cdn/4ZUUS4DH.js +2 -0
- package/dist/cdn/527C4GD2.js +36 -0
- package/dist/cdn/5RZGG4F2.js +2 -0
- package/dist/cdn/5SF6DEMO.js +2 -0
- package/dist/cdn/5Y6TQAJN.js +2 -0
- package/dist/cdn/65IWA2PM.js +2 -0
- package/dist/cdn/{MW5S2XCB.js → 67YCNNCN.js} +2 -2
- package/dist/cdn/6FKLWNGA.js +2 -0
- package/dist/cdn/6QJFOL6M.js +2 -0
- package/dist/cdn/6RDKDLSX.js +2 -0
- package/dist/cdn/6SGNSDLY.js +2 -0
- package/dist/cdn/7747YL7V.js +2 -0
- package/dist/cdn/7TO56JHS.js +2 -0
- package/dist/cdn/ABXLPDEK.js +2 -0
- package/dist/cdn/BBJDW6GC.js +2 -0
- package/dist/cdn/{PUFTYLJ2.js → C4FKFOU4.js} +4 -4
- package/dist/cdn/CCC6LBMY.js +2 -0
- package/dist/cdn/CGVVL52C.js +2 -0
- package/dist/cdn/DBHLKLKM.js +2 -0
- package/dist/cdn/DKLK4EUE.js +2 -0
- package/dist/cdn/E25RINU2.js +2 -0
- package/dist/cdn/E62P76TP.js +2 -0
- package/dist/cdn/E7JLG2A2.js +2 -0
- package/dist/cdn/{TFT6HK3O.js → E7KEOJZG.js} +1 -1
- package/dist/cdn/FDOMMK2M.js +2 -0
- package/dist/cdn/FSMHR7GK.js +2 -0
- package/dist/cdn/GG3AESSV.js +2 -0
- package/dist/cdn/H6JSNAT4.js +2 -0
- package/dist/cdn/HNMFFLSY.js +2 -0
- package/dist/cdn/HO2YDJI2.js +6 -0
- package/dist/cdn/{KQHLOYKL.js → I4L45WQS.js} +1 -1
- package/dist/cdn/ITBQGOMF.js +11 -0
- package/dist/cdn/JH6EAWB2.js +2 -0
- package/dist/cdn/JON2JHS2.js +2 -0
- package/dist/cdn/JWPB3XZM.js +2 -0
- package/dist/cdn/JXB4TNSG.js +2 -0
- package/dist/cdn/JYVBCHR6.js +6 -0
- package/dist/cdn/KRN6AFNB.js +18 -0
- package/dist/cdn/KZACIY2W.js +2 -0
- package/dist/cdn/MKJS7QYQ.js +2 -0
- package/dist/cdn/N735LT4S.js +2 -0
- package/dist/cdn/NP7DG7LQ.js +2 -0
- package/dist/cdn/NTZAOJH5.js +2 -0
- package/dist/cdn/{CXW5URTF.js → OHMNQ3RU.js} +5 -5
- package/dist/cdn/ONQ6JSBJ.js +2 -0
- package/dist/cdn/PAUIFUMO.js +2 -0
- package/dist/cdn/QNNGPA3Q.js +2 -0
- package/dist/cdn/RATZTLNX.js +2 -0
- package/dist/cdn/RU5DVLYG.js +156 -0
- package/dist/cdn/{YHQJ66WJ.js → S3XUYAUX.js} +1 -1
- package/dist/cdn/S6ZAQRC6.js +2 -0
- package/dist/cdn/SABZC4D4.js +2 -0
- package/dist/cdn/TYL5G7KR.js +2 -0
- package/dist/cdn/{XETNZW4D.js → UAZLKUFN.js} +1 -1
- package/dist/cdn/UZL6UVE4.js +2 -0
- package/dist/cdn/VBZ5XGAM.js +2 -0
- package/dist/cdn/VXBUMZYR.js +2 -0
- package/dist/cdn/W5FLNFSN.js +2 -0
- package/dist/cdn/W5J4Q3RO.js +14 -0
- package/dist/cdn/WQKNV6KK.js +2 -0
- package/dist/cdn/{ICYUPLZM.js → WZFC5HUX.js} +1 -1
- package/dist/cdn/XGBEHER5.js +2 -0
- package/dist/cdn/XPTCV6YV.js +2 -0
- package/dist/cdn/Y5UFOH54.js +2 -0
- package/dist/cdn/YGCTAIBS.js +2 -0
- package/dist/cdn/{SXHH575T.js → ZJEWP2ND.js} +20 -24
- package/dist/cdn/agent-utils/index.js +1 -1
- package/dist/cdn/agent-utils/middlewares/humanInTheLoop.js +1 -1
- package/dist/cdn/agent-utils/middlewares/middleware.js +1 -1
- package/dist/cdn/agent-utils/middlewares/trace.js +1 -1
- package/dist/cdn/index.js +1 -1
- package/dist/chunks/adapter.js +939 -1950
- package/dist/chunks/adapter10.js +21 -0
- package/dist/chunks/adapter11.js +30 -0
- package/dist/chunks/adapter12.js +22 -0
- package/dist/chunks/adapter13.js +22 -0
- package/dist/chunks/adapter14.js +109 -0
- package/dist/chunks/adapter15.js +40 -0
- package/dist/chunks/adapter16.js +154 -0
- package/dist/chunks/adapter17.js +141 -0
- package/dist/chunks/adapter18.js +127 -0
- package/dist/chunks/adapter2.js +52 -0
- package/dist/chunks/adapter3.js +30 -0
- package/dist/chunks/adapter4.js +50 -0
- package/dist/chunks/adapter5.js +27 -0
- package/dist/chunks/adapter6.js +24 -0
- package/dist/chunks/adapter7.js +26 -0
- package/dist/chunks/adapter8.js +21 -0
- package/dist/chunks/adapter9.js +42 -0
- package/dist/chunks/arcgisKnowledgeGraph.js +5 -5
- package/dist/chunks/baseAgentState.js +56 -0
- package/dist/chunks/dataExplorationGraph.js +34 -31
- package/dist/chunks/fetchAgentContext.js +13 -0
- package/dist/chunks/fetchService.js +10 -0
- package/dist/chunks/formatFeatureAttributes.js +132 -0
- package/dist/chunks/generateLayerDescriptions.js +189 -235
- package/dist/chunks/helpGraph.js +11 -9
- package/dist/chunks/layerStylingGraph.js +22 -21
- package/dist/chunks/mergeWhereClauses.js +15 -0
- package/dist/chunks/navigationGraph.js +81 -70
- package/dist/chunks/orchestrator.js +1 -1
- package/dist/chunks/state.js +20 -26
- package/dist/chunks/types.js +59 -0
- package/dist/chunks/utils2.js +3 -3
- package/dist/components/arcgis-assistant-agent/customElement.d.ts +13 -1
- package/dist/components/arcgis-assistant-agent/customElement.js +636 -10
- package/dist/components/arcgis-assistant-data-exploration-agent/customElement.js +15 -5
- package/dist/components/arcgis-assistant-help-agent/customElement.js +21 -5
- package/dist/components/arcgis-assistant-knowledge-agent/customElement.js +39 -22
- package/dist/components/arcgis-assistant-layer-styling-agent/customElement.js +22 -5
- package/dist/components/arcgis-assistant-navigation-agent/customElement.js +13 -5
- 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 +1 -1
- package/dist/types/lumina.d.ts +1 -1
- package/dist/types/preact.d.ts +1 -1
- package/dist/types/react.d.ts +1 -1
- package/dist/types/stencil.d.ts +1 -1
- package/dist/utils/index.js +26 -25
- package/package.json +4 -4
- package/dist/cdn/3DJDRAGV.js +0 -2
- package/dist/cdn/4CEMUECT.js +0 -2
- package/dist/cdn/4PCAK3ET.js +0 -2
- package/dist/cdn/57OMVTIU.js +0 -2
- package/dist/cdn/6U7TEAAJ.js +0 -2
- package/dist/cdn/BE7ZN5FZ.js +0 -2
- package/dist/cdn/BNSJO6X2.js +0 -2
- package/dist/cdn/CMDRED5H.js +0 -2
- package/dist/cdn/DTIVDIDY.js +0 -2
- package/dist/cdn/E5ZKBC24.js +0 -36
- package/dist/cdn/GP6NDTUE.js +0 -18
- package/dist/cdn/HBLRVXEB.js +0 -2
- package/dist/cdn/HQXPPYMD.js +0 -2
- package/dist/cdn/IEHPNCTL.js +0 -2
- package/dist/cdn/LHLO6PTD.js +0 -2
- package/dist/cdn/OWXCOUIQ.js +0 -2
- package/dist/cdn/PVE7Q43N.js +0 -2
- package/dist/cdn/ST5FQYT7.js +0 -180
- package/dist/cdn/WUNCZOGU.js +0 -2
- package/dist/cdn/WVPU4QOO.js +0 -2
- package/dist/cdn/WXWO5D3W.js +0 -2
- package/dist/cdn/XCRR2EEG.js +0 -6
- package/dist/cdn/ZS6SXJP2.js +0 -2
package/dist/chunks/helpGraph.js
CHANGED
|
@@ -1,22 +1,24 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
2
|
import { StateGraph as d, START as g, END as i } from "@langchain/langgraph/web";
|
|
3
|
-
import {
|
|
3
|
+
import { g as h, r as f, t as x, H as u } from "./adapter.js";
|
|
4
4
|
import "@arcgis/core/identity/IdentityManager.js";
|
|
5
5
|
import "@arcgis/core/portal/Portal.js";
|
|
6
6
|
import "@arcgis/core/request.js";
|
|
7
7
|
import "@arcgis/toolkit/string";
|
|
8
|
-
import { h as
|
|
8
|
+
import { h as y } from "./generateLayerDescriptions.js";
|
|
9
9
|
import "@langchain/core/messages";
|
|
10
10
|
import "@langchain/core/callbacks/dispatch/web";
|
|
11
11
|
import "@langchain/openai";
|
|
12
12
|
import "@arcgis/core/config.js";
|
|
13
13
|
import "@arcgis/core/core/reactiveUtils.js";
|
|
14
14
|
import "@arcgis/core/layers/FeatureLayer.js";
|
|
15
|
+
import { f as p } from "./fetchService.js";
|
|
16
|
+
import { listLayerFieldsTool as S } from "./adapter11.js";
|
|
15
17
|
import { h as E } from "./toolCallResponse.js";
|
|
16
18
|
import { ToolNode as T } from "@langchain/langgraph/prebuilt";
|
|
17
19
|
import { s as m } from "./index.js";
|
|
18
20
|
import "@langchain/core/prompts";
|
|
19
|
-
const c = [
|
|
21
|
+
const c = [S], v = (e) => {
|
|
20
22
|
if (!e || e.size === 0)
|
|
21
23
|
return "No layers available in this map.";
|
|
22
24
|
const t = Array.from(e.values()).map(({ layerItem: r, fieldRegistry: s }, l) => {
|
|
@@ -35,9 +37,9 @@ ${t}`;
|
|
|
35
37
|
`) : "No agents currently available.";
|
|
36
38
|
};
|
|
37
39
|
async function _(e, t) {
|
|
38
|
-
const r = await
|
|
40
|
+
const r = await h("help_prompt"), s = p(t, "layersAndFieldsRegistry"), l = p(t, "agentRegistry");
|
|
39
41
|
try {
|
|
40
|
-
const a = await
|
|
42
|
+
const a = await y({
|
|
41
43
|
promptText: r,
|
|
42
44
|
modelTier: "default",
|
|
43
45
|
config: t,
|
|
@@ -72,7 +74,7 @@ async function _(e, t) {
|
|
|
72
74
|
};
|
|
73
75
|
}
|
|
74
76
|
}
|
|
75
|
-
const H = (e, t) =>
|
|
77
|
+
const H = (e, t) => f(["agentRegistry"], "Help Agent")(e, t);
|
|
76
78
|
async function b(e, t) {
|
|
77
79
|
const r = new T(c, { handleToolErrors: !1 });
|
|
78
80
|
try {
|
|
@@ -85,7 +87,7 @@ async function b(e, t) {
|
|
|
85
87
|
...e,
|
|
86
88
|
outputMessage: a,
|
|
87
89
|
status: "success",
|
|
88
|
-
summary: a ?
|
|
90
|
+
summary: a ? x(a) : "Help executed.",
|
|
89
91
|
helpInternalState: {
|
|
90
92
|
...e.helpInternalState,
|
|
91
93
|
toolCallMessage: void 0
|
|
@@ -118,7 +120,7 @@ const M = () => new d(u).addNode("requireHelpServices", H).addNode("agent", _).a
|
|
|
118
120
|
|
|
119
121
|
IF the user asks map related queries, but those that are not performed by any of the agents, call this agent so we can respond that the requested action is not supported.
|
|
120
122
|
_Example: "Create a chart"_
|
|
121
|
-
_Example: "Create a table"_`,
|
|
123
|
+
_Example: "Create a table"_`, O = {
|
|
122
124
|
id: "help",
|
|
123
125
|
name: "Help Agent",
|
|
124
126
|
description: k,
|
|
@@ -126,5 +128,5 @@ const M = () => new d(u).addNode("requireHelpServices", H).addNode("agent", _).a
|
|
|
126
128
|
workspace: u
|
|
127
129
|
};
|
|
128
130
|
export {
|
|
129
|
-
|
|
131
|
+
O as H
|
|
130
132
|
};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import { NodeInterrupt as
|
|
2
|
+
import { NodeInterrupt as w, StateGraph as L, START as E, END as m } from "@langchain/langgraph/web";
|
|
3
3
|
import "@arcgis/core/identity/IdentityManager.js";
|
|
4
4
|
import "@arcgis/core/portal/Portal.js";
|
|
5
5
|
import "@arcgis/core/request.js";
|
|
6
6
|
import "@arcgis/toolkit/string";
|
|
7
|
-
import { h as
|
|
7
|
+
import { h as v } from "./generateLayerDescriptions.js";
|
|
8
8
|
import "@langchain/core/messages";
|
|
9
9
|
import { s as i } from "./index.js";
|
|
10
10
|
import "@langchain/openai";
|
|
@@ -12,17 +12,18 @@ import "@arcgis/core/config.js";
|
|
|
12
12
|
import "@arcgis/core/core/reactiveUtils.js";
|
|
13
13
|
import "@arcgis/core/layers/FeatureLayer.js";
|
|
14
14
|
import "@langchain/core/prompts";
|
|
15
|
-
import { f as g
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
|
|
15
|
+
import { f as g } from "./fetchService.js";
|
|
16
|
+
import { j as I, k as T, l as R, m as F, n as C, o as $, p as A, u as N, v as b, w as q, x as _, g as M, r as k, L as S } from "./adapter.js";
|
|
17
|
+
import { h as j } from "./toolCallResponse.js";
|
|
18
|
+
import { ToolNode as V } from "@langchain/langgraph/prebuilt";
|
|
19
|
+
const h = 0.7, P = 10, z = async (t, e) => {
|
|
19
20
|
try {
|
|
20
21
|
await i({ text: "Similarity search to find fields" }, e);
|
|
21
22
|
const r = g(e, "fieldSearch"), a = g(e, "layersAndFieldsRegistry"), o = g(e, "embeddingCache"), n = await r.searchFields({
|
|
22
23
|
text: t.agentExecutionContext.assignedTask,
|
|
23
24
|
layerIds: t.vectorSearchLayerIds,
|
|
24
25
|
minScore: h,
|
|
25
|
-
topResults:
|
|
26
|
+
topResults: P,
|
|
26
27
|
embeddingCache: o
|
|
27
28
|
}), c = n.map(({ layerId: d, results: p }) => {
|
|
28
29
|
const y = p.map((s) => ` - ${s.name} (${s.score.toFixed(2)})`).join(`
|
|
@@ -43,7 +44,7 @@ ${c}` : l = `No vector search results found for score over ${h}.`, await i({ tex
|
|
|
43
44
|
e
|
|
44
45
|
), new Error(`Vector search failed: ${r instanceof Error ? r.message : String(r)}`);
|
|
45
46
|
}
|
|
46
|
-
},
|
|
47
|
+
}, D = 0.7, H = async (t, e) => {
|
|
47
48
|
try {
|
|
48
49
|
await i(
|
|
49
50
|
{ text: `Similarity search to find layers: ${t.agentExecutionContext.assignedTask}` },
|
|
@@ -51,7 +52,7 @@ ${c}` : l = `No vector search results found for score over ${h}.`, await i({ tex
|
|
|
51
52
|
);
|
|
52
53
|
const r = g(e, "layerSearch"), a = g(e, "layersAndFieldsRegistry"), o = await r.searchLayers({
|
|
53
54
|
text: t.agentExecutionContext.assignedTask,
|
|
54
|
-
minScore:
|
|
55
|
+
minScore: D
|
|
55
56
|
}), n = o.map((d) => d.id), c = o.map(({ id: d, score: p }) => `${a.get(d)?.layerItem.name ?? d} (${p.toFixed(2)})`).join(`
|
|
56
57
|
`);
|
|
57
58
|
let l;
|
|
@@ -67,17 +68,17 @@ ${c}` : l = "Vector search completed. No matching layers found.", await i({ text
|
|
|
67
68
|
), new Error(`Vector search failed: ${r instanceof Error ? r.message : String(r)}`);
|
|
68
69
|
}
|
|
69
70
|
}, f = [
|
|
70
|
-
|
|
71
|
+
I,
|
|
71
72
|
T,
|
|
72
73
|
R,
|
|
73
74
|
F,
|
|
74
75
|
C,
|
|
75
|
-
A,
|
|
76
76
|
$,
|
|
77
|
+
A,
|
|
77
78
|
N,
|
|
78
79
|
b,
|
|
79
80
|
q,
|
|
80
|
-
|
|
81
|
+
_
|
|
81
82
|
], x = (t, e = 3) => {
|
|
82
83
|
const r = t.map((o, n) => o.type === "human" ? n : -1).filter((o) => o !== -1);
|
|
83
84
|
if (r.length === 0)
|
|
@@ -86,12 +87,12 @@ ${c}` : l = "Vector search completed. No matching layers found.", await i({ text
|
|
|
86
87
|
return t.slice(a);
|
|
87
88
|
}, G = async (t, e) => {
|
|
88
89
|
await i({ text: "Requesting LLM for layer query results" }, e);
|
|
89
|
-
const r = await
|
|
90
|
+
const r = await M("navigation_intent_prompt");
|
|
90
91
|
if (!e?.configurable)
|
|
91
92
|
throw new Error("config.configurable is required for layer query tools");
|
|
92
93
|
const a = {
|
|
93
94
|
layerFieldInfo: t.layerFieldInfo
|
|
94
|
-
}, o = await
|
|
95
|
+
}, o = await v({
|
|
95
96
|
promptText: r,
|
|
96
97
|
modelTier: "advanced",
|
|
97
98
|
config: e,
|
|
@@ -99,7 +100,7 @@ ${c}` : l = "Vector search completed. No matching layers found.", await i({ text
|
|
|
99
100
|
inputVariables: a,
|
|
100
101
|
tools: f
|
|
101
102
|
});
|
|
102
|
-
return await
|
|
103
|
+
return await j(o, e), {
|
|
103
104
|
...t,
|
|
104
105
|
agentExecutionContext: {
|
|
105
106
|
...t.agentExecutionContext,
|
|
@@ -107,8 +108,8 @@ ${c}` : l = "Vector search completed. No matching layers found.", await i({ text
|
|
|
107
108
|
}
|
|
108
109
|
};
|
|
109
110
|
};
|
|
110
|
-
async function
|
|
111
|
-
const a = await new
|
|
111
|
+
async function U(t, e) {
|
|
112
|
+
const a = await new V(f, { handleToolErrors: !1 }).invoke(
|
|
112
113
|
{
|
|
113
114
|
messages: x(t.agentExecutionContext.messages)
|
|
114
115
|
},
|
|
@@ -120,7 +121,7 @@ async function B(t, e) {
|
|
|
120
121
|
`);
|
|
121
122
|
return { ...t, outputMessage: n };
|
|
122
123
|
}
|
|
123
|
-
const
|
|
124
|
+
const B = async (t, e) => (await i({ text: "Exiting Layer Styling agent" }, e), t), O = async (t, e) => {
|
|
124
125
|
try {
|
|
125
126
|
await i({ text: "Populating layer and field info" }, e);
|
|
126
127
|
const r = [];
|
|
@@ -151,7 +152,7 @@ const U = async (t, e) => (await i({ text: "Exiting Layer Styling agent" }, e),
|
|
|
151
152
|
} catch (r) {
|
|
152
153
|
throw await i({ text: "Error populating layerFieldInfo" }, e), new Error(`Error populating layerFieldInfo: ${r instanceof Error ? r.message : String(r)}`);
|
|
153
154
|
}
|
|
154
|
-
},
|
|
155
|
+
}, J = (t, e) => {
|
|
155
156
|
const r = t.vectorSearchLayerIds ?? [];
|
|
156
157
|
if (r.length <= 1)
|
|
157
158
|
return { ...t, selectedLayerId: t.vectorSearchLayerIds[0] };
|
|
@@ -164,14 +165,14 @@ const U = async (t, e) => (await i({ text: "Exiting Layer Styling agent" }, e),
|
|
|
164
165
|
message: "Choose a layer to apply the styles.",
|
|
165
166
|
metadata: [...r]
|
|
166
167
|
};
|
|
167
|
-
throw new
|
|
168
|
+
throw new w(n);
|
|
168
169
|
}
|
|
169
170
|
let o = null;
|
|
170
171
|
return Array.isArray(a.payload) && a.payload.length > 0 && (o = a.payload[0]), {
|
|
171
172
|
...t,
|
|
172
173
|
selectedLayerId: o ?? t.vectorSearchLayerIds[0]
|
|
173
174
|
};
|
|
174
|
-
},
|
|
175
|
+
}, K = (t, e) => k(["layerSearch", "fieldSearch", "layersAndFieldsRegistry"], "Layer Styling Agent")(t, e), Q = () => new L(S).addNode("requireLayerStylingServices", K).addNode("vectorSearchLayers", H).addNode("layerSelectionHITL", J).addNode("vectorSearchFields", z).addNode("populateLayerFieldInfo", O).addNode("agent", G).addNode("tools", U).addNode("earlyExit", B).addEdge(E, "requireLayerStylingServices").addEdge("requireLayerStylingServices", "vectorSearchLayers").addConditionalEdges(
|
|
175
176
|
"layerSelectionHITL",
|
|
176
177
|
(e) => e.vectorSearchLayerIds.length ? "vectorSearchFields" : "earlyExit"
|
|
177
178
|
).addConditionalEdges(
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
+
const r = (e, s, a) => {
|
|
3
|
+
if (!(a ? e.hasAllFeaturesInView : e.hasAllFeatures))
|
|
4
|
+
return !1;
|
|
5
|
+
const n = new Set((e.availableFields ?? []).map((t) => t.toLowerCase()));
|
|
6
|
+
return n.has("*") ? !0 : s.every((t) => n.has(t.toLowerCase()));
|
|
7
|
+
};
|
|
8
|
+
function u(e, s) {
|
|
9
|
+
let a = e ?? "";
|
|
10
|
+
return s != null && s && (a = a ? `(${a}) AND (${s})` : s), a || null;
|
|
11
|
+
}
|
|
12
|
+
export {
|
|
13
|
+
r as c,
|
|
14
|
+
u as m
|
|
15
|
+
};
|
|
@@ -1,56 +1,67 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
2
|
import { StateGraph as E, START as $, END as C } from "@langchain/langgraph/web";
|
|
3
|
-
import {
|
|
3
|
+
import { g as T, t as F, r as R, N as k } from "./adapter.js";
|
|
4
4
|
import "@arcgis/core/identity/IdentityManager.js";
|
|
5
5
|
import "@arcgis/core/portal/Portal.js";
|
|
6
6
|
import "@arcgis/core/request.js";
|
|
7
7
|
import "@arcgis/toolkit/string";
|
|
8
|
-
import { h as
|
|
8
|
+
import { h as L, i as M } from "./generateLayerDescriptions.js";
|
|
9
9
|
import "@langchain/core/messages";
|
|
10
10
|
import "@langchain/core/callbacks/dispatch/web";
|
|
11
11
|
import "@langchain/openai";
|
|
12
12
|
import "@arcgis/core/config.js";
|
|
13
13
|
import "@arcgis/core/core/reactiveUtils.js";
|
|
14
14
|
import "@arcgis/core/layers/FeatureLayer.js";
|
|
15
|
+
import { goToAddressTool as A } from "./adapter2.js";
|
|
16
|
+
import { goToBookmarkTool as _ } from "./adapter3.js";
|
|
17
|
+
import { goToFeaturesTool as I } from "./adapter4.js";
|
|
18
|
+
import { goToFullExtentTool as q } from "./adapter5.js";
|
|
19
|
+
import { goToHomeExtentTool as Z } from "./adapter6.js";
|
|
20
|
+
import { goToLayerTool as V } from "./adapter7.js";
|
|
21
|
+
import { goToScaleTool as j } from "./adapter8.js";
|
|
22
|
+
import { goToViewpointTool as P } from "./adapter9.js";
|
|
23
|
+
import { goToZoomTool as z } from "./adapter10.js";
|
|
24
|
+
import { f as w } from "./fetchAgentContext.js";
|
|
15
25
|
import { h as G } from "./toolCallResponse.js";
|
|
16
|
-
import { s as
|
|
26
|
+
import { s as p } from "./index.js";
|
|
17
27
|
import "@langchain/core/prompts";
|
|
18
28
|
import { ToolNode as O } from "@langchain/langgraph/prebuilt";
|
|
19
|
-
import
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
R,
|
|
23
|
-
L,
|
|
24
|
-
M,
|
|
29
|
+
import S from "zod";
|
|
30
|
+
import { f as u } from "./fetchService.js";
|
|
31
|
+
const f = [
|
|
25
32
|
A,
|
|
26
33
|
_,
|
|
27
34
|
I,
|
|
28
35
|
q,
|
|
29
|
-
Z
|
|
36
|
+
Z,
|
|
37
|
+
V,
|
|
38
|
+
j,
|
|
39
|
+
P,
|
|
40
|
+
z
|
|
30
41
|
];
|
|
31
42
|
async function B(e, t) {
|
|
32
|
-
const o = await T("navigation_tool_prompt"), { mapView:
|
|
33
|
-
(
|
|
43
|
+
const o = await T("navigation_tool_prompt"), { mapView: r } = w(t, ["mapView"]), i = r.map.bookmarks?.map((h) => h.name).filter(Boolean) ?? [], l = e.vectorSearchLayerResults?.length > 0 ? e.vectorSearchLayerResults.map(
|
|
44
|
+
(h, b) => `${b + 1}. layerId=${h.id} | title=${h.title ?? ""} | name=${h.name ?? ""} | score=${h.score.toFixed(2)}`
|
|
34
45
|
).join(`
|
|
35
46
|
`) : "", c = e.vectorSearchFieldResults?.length > 0 ? JSON.stringify(e.vectorSearchFieldResults, null, 2) : "", a = e.intent === "goToBookmark" && i.length ? `Available bookmarks:
|
|
36
|
-
${i.map((
|
|
37
|
-
`)}` : "",
|
|
38
|
-
${l}` : "",
|
|
47
|
+
${i.map((h) => `- ${h}`).join(`
|
|
48
|
+
`)}` : "", s = (e.intent === "goToLayer" || e.intent === "goToFeatures") && e.vectorSearchLayerResults?.length ? `Candidate layers:
|
|
49
|
+
${l}` : "", d = e.intent === "goToFeatures" && e.vectorSearchFieldResults?.length ? `Candidate fields:
|
|
39
50
|
${c}` : "", y = {
|
|
40
51
|
intent: e.intent,
|
|
41
52
|
bookmarksSection: a,
|
|
42
|
-
layersSection:
|
|
43
|
-
fieldsSection:
|
|
44
|
-
currentZoom:
|
|
53
|
+
layersSection: s,
|
|
54
|
+
fieldsSection: d,
|
|
55
|
+
currentZoom: r.zoom,
|
|
45
56
|
assignedTask: e.agentExecutionContext.assignedTask,
|
|
46
57
|
userRequest: e.agentExecutionContext.userRequest,
|
|
47
58
|
priorSteps: e.agentExecutionContext.priorSteps
|
|
48
|
-
}, n = await
|
|
59
|
+
}, n = await L({
|
|
49
60
|
promptText: o,
|
|
50
61
|
modelTier: "fast",
|
|
51
62
|
config: t,
|
|
52
63
|
inputVariables: y,
|
|
53
|
-
tools:
|
|
64
|
+
tools: f
|
|
54
65
|
});
|
|
55
66
|
await G(n, t);
|
|
56
67
|
const g = (n.tool_calls?.length ?? 0) > 0, v = typeof n.text == "string" ? n.text.trim() : "", N = v.length > 0;
|
|
@@ -77,19 +88,19 @@ const D = (e) => {
|
|
|
77
88
|
return { text: t };
|
|
78
89
|
};
|
|
79
90
|
async function J(e, t) {
|
|
80
|
-
const o = new O(
|
|
91
|
+
const o = new O(f, { handleToolErrors: !1 });
|
|
81
92
|
try {
|
|
82
|
-
const
|
|
83
|
-
if (!
|
|
93
|
+
const r = e.navigationInternalState.toolCallMessage;
|
|
94
|
+
if (!r)
|
|
84
95
|
throw new Error("navigationToolCalling: missing navigationInternalState.toolCallMessage");
|
|
85
|
-
const { messages:
|
|
96
|
+
const { messages: m } = await o.invoke(
|
|
86
97
|
{
|
|
87
|
-
messages: [
|
|
98
|
+
messages: [r]
|
|
88
99
|
},
|
|
89
100
|
t
|
|
90
101
|
);
|
|
91
102
|
let i = "", l;
|
|
92
|
-
for (const c of
|
|
103
|
+
for (const c of m) {
|
|
93
104
|
const a = D(c.content);
|
|
94
105
|
a.text && (i += `${a.text}
|
|
95
106
|
`), a.sharedStatePatch && (l = {
|
|
@@ -97,24 +108,24 @@ async function J(e, t) {
|
|
|
97
108
|
...a.sharedStatePatch
|
|
98
109
|
});
|
|
99
110
|
}
|
|
100
|
-
return await
|
|
111
|
+
return await p({ text: `Finished executing navigation tool: ${i}` }, t), {
|
|
101
112
|
...e,
|
|
102
113
|
outputMessage: i,
|
|
103
114
|
sharedStatePatch: l,
|
|
104
115
|
status: "success",
|
|
105
|
-
summary: i ?
|
|
116
|
+
summary: i ? F(i) : "Navigation executed.",
|
|
106
117
|
navigationInternalState: {
|
|
107
118
|
...e.navigationInternalState,
|
|
108
119
|
toolCallMessage: void 0
|
|
109
120
|
}
|
|
110
121
|
};
|
|
111
|
-
} catch (
|
|
112
|
-
const
|
|
113
|
-
return await
|
|
122
|
+
} catch (r) {
|
|
123
|
+
const m = r instanceof Error ? r.message : String(r);
|
|
124
|
+
return await p({ text: `Navigation tool execution failed: ${m}` }, t), {
|
|
114
125
|
...e,
|
|
115
|
-
outputMessage: `Navigation tool execution failed: ${
|
|
126
|
+
outputMessage: `Navigation tool execution failed: ${m}`,
|
|
116
127
|
status: "failed",
|
|
117
|
-
summary: `Navigation tool execution failed: ${
|
|
128
|
+
summary: `Navigation tool execution failed: ${m}`,
|
|
118
129
|
navigationInternalState: {
|
|
119
130
|
...e.navigationInternalState,
|
|
120
131
|
toolCallMessage: void 0
|
|
@@ -123,83 +134,83 @@ async function J(e, t) {
|
|
|
123
134
|
}
|
|
124
135
|
}
|
|
125
136
|
async function H(e, t) {
|
|
126
|
-
const o = await T("navigation_intent_prompt"), { mapView:
|
|
137
|
+
const o = await T("navigation_intent_prompt"), { mapView: r } = w(t, ["mapView"]), m = f.map((n) => ({
|
|
127
138
|
name: n.name,
|
|
128
139
|
description: n.description,
|
|
129
140
|
schema: n.schema
|
|
130
|
-
})), l =
|
|
141
|
+
})), l = r.map.bookmarks?.map((n) => n.name).filter(Boolean) ?? [], c = l.length ? `Available bookmarks:
|
|
131
142
|
${l.map((n) => `- ${n}`).join(`
|
|
132
143
|
`)}` : "No bookmarks are available in this map.", a = {
|
|
133
|
-
tools:
|
|
144
|
+
tools: m.map(({ name: n, description: g, schema: v }) => `${n}: ${g}, ${JSON.stringify(v)}`).join(`
|
|
134
145
|
`),
|
|
135
146
|
bookmarks: c,
|
|
136
147
|
assignedTask: e.agentExecutionContext.assignedTask,
|
|
137
148
|
userRequest: e.agentExecutionContext.userRequest,
|
|
138
149
|
priorSteps: e.agentExecutionContext.priorSteps
|
|
139
|
-
},
|
|
140
|
-
intent:
|
|
141
|
-
}),
|
|
150
|
+
}, s = S.object({
|
|
151
|
+
intent: S.string()
|
|
152
|
+
}), d = await M({
|
|
142
153
|
promptText: o,
|
|
143
154
|
config: t,
|
|
144
155
|
inputVariables: a,
|
|
145
|
-
schema:
|
|
156
|
+
schema: s,
|
|
146
157
|
modelTier: "fast"
|
|
147
|
-
}), y = typeof
|
|
158
|
+
}), y = typeof d.intent == "string" ? d.intent.trim().replace(/^"|"$/gu, "") : "";
|
|
148
159
|
return { ...e, intent: y || "" };
|
|
149
160
|
}
|
|
150
161
|
const U = 0.7, W = async (e, t) => {
|
|
151
162
|
try {
|
|
152
|
-
await
|
|
163
|
+
await p(
|
|
153
164
|
{ text: `Similarity search to find layers: ${e.agentExecutionContext.assignedTask}` },
|
|
154
165
|
t
|
|
155
166
|
);
|
|
156
|
-
const o = u(t, "layerSearch"),
|
|
167
|
+
const o = u(t, "layerSearch"), r = u(t, "layersAndFieldsRegistry"), m = u(t, "embeddingCache"), l = (await o.searchLayers({
|
|
157
168
|
text: e.agentExecutionContext.assignedTask,
|
|
158
169
|
minScore: U,
|
|
159
|
-
embeddingCache:
|
|
160
|
-
})).map(({ id: a, score:
|
|
161
|
-
const
|
|
170
|
+
embeddingCache: m
|
|
171
|
+
})).map(({ id: a, score: s }) => {
|
|
172
|
+
const d = r.get(a)?.layerItem;
|
|
162
173
|
return {
|
|
163
174
|
id: a,
|
|
164
|
-
title:
|
|
165
|
-
name:
|
|
166
|
-
score:
|
|
175
|
+
title: d?.title,
|
|
176
|
+
name: d?.name ?? void 0,
|
|
177
|
+
score: s
|
|
167
178
|
};
|
|
168
179
|
});
|
|
169
180
|
let c;
|
|
170
181
|
return l.length > 0 ? c = `Vector search completed. Matching layers:
|
|
171
182
|
${l.map((a) => `- layerId=${a.id} | title=${a.title ?? ""} | name=${a.name ?? ""} | score=${a.score.toFixed(2)}`).join(`
|
|
172
|
-
`)}` : c = "Vector search completed. No matching layers found.", await
|
|
183
|
+
`)}` : c = "Vector search completed. No matching layers found.", await p({ text: c }, t), {
|
|
173
184
|
...e,
|
|
174
185
|
vectorSearchLayerResults: l
|
|
175
186
|
};
|
|
176
187
|
} catch (o) {
|
|
177
|
-
throw await
|
|
188
|
+
throw await p(
|
|
178
189
|
{ text: `Error during vector search layers: ${o instanceof Error ? o.message : String(o)}` },
|
|
179
190
|
t
|
|
180
191
|
), o;
|
|
181
192
|
}
|
|
182
|
-
},
|
|
193
|
+
}, x = 0.7, K = 10, Q = async (e, t) => {
|
|
183
194
|
try {
|
|
184
|
-
await
|
|
195
|
+
await p(
|
|
185
196
|
{ text: `Similarity search to find fields: ${e.agentExecutionContext.assignedTask}` },
|
|
186
197
|
t
|
|
187
198
|
);
|
|
188
|
-
const o = u(t, "fieldSearch"),
|
|
199
|
+
const o = u(t, "fieldSearch"), r = u(t, "layersAndFieldsRegistry"), m = u(t, "embeddingCache"), i = e.vectorSearchLayerResults?.map((s) => s.id) ?? [];
|
|
189
200
|
if (i.length === 0)
|
|
190
|
-
return await
|
|
201
|
+
return await p({ text: "No candidate layers for field search" }, t), e;
|
|
191
202
|
const c = (await o.searchFields({
|
|
192
203
|
text: e.agentExecutionContext.assignedTask,
|
|
193
204
|
layerIds: i,
|
|
194
|
-
minScore:
|
|
205
|
+
minScore: x,
|
|
195
206
|
topResults: K,
|
|
196
|
-
embeddingCache:
|
|
197
|
-
})).map(({ layerId:
|
|
198
|
-
const y =
|
|
207
|
+
embeddingCache: m
|
|
208
|
+
})).map(({ layerId: s, results: d }) => {
|
|
209
|
+
const y = r.get(s)?.fieldRegistry;
|
|
199
210
|
return {
|
|
200
|
-
layerId:
|
|
201
|
-
layerName:
|
|
202
|
-
results:
|
|
211
|
+
layerId: s,
|
|
212
|
+
layerName: r.get(s)?.layerItem.name,
|
|
213
|
+
results: d.map((n) => {
|
|
203
214
|
const g = y?.get(n.name);
|
|
204
215
|
return {
|
|
205
216
|
name: n.name,
|
|
@@ -216,21 +227,21 @@ ${l.map((a) => `- layerId=${a.id} | title=${a.title ?? ""} | name=${a.name ?? ""
|
|
|
216
227
|
let a;
|
|
217
228
|
return c.length > 0 ? a = `Vector search completed. Matching layers and fields:
|
|
218
229
|
${c.map(
|
|
219
|
-
(
|
|
220
|
-
${
|
|
230
|
+
(s) => `${s.layerName ?? s.layerId}:
|
|
231
|
+
${s.results.map((d) => ` - ${d.name} (${d.score.toFixed(2)})`).join(`
|
|
221
232
|
`)}`
|
|
222
233
|
).join(`
|
|
223
|
-
`)}` : a = `No vector search field results found for score over ${
|
|
234
|
+
`)}` : a = `No vector search field results found for score over ${x}.`, await p({ text: a }, t), {
|
|
224
235
|
...e,
|
|
225
236
|
vectorSearchFieldResults: c
|
|
226
237
|
};
|
|
227
238
|
} catch (o) {
|
|
228
|
-
throw await
|
|
239
|
+
throw await p(
|
|
229
240
|
{ text: `Error during vector search fields: ${o instanceof Error ? o.message : String(o)}` },
|
|
230
241
|
t
|
|
231
242
|
), o;
|
|
232
243
|
}
|
|
233
|
-
}, X = (e, t) =>
|
|
244
|
+
}, X = (e, t) => R(["layerSearch", "layersAndFieldsRegistry"], "Navigation Agent")(e, t), Y = () => new E(k).addNode("requireNavigationServices", X).addNode("intentLLM", H).addNode("vectorSearchLayers", W).addNode("vectorSearchFields", Q).addNode("agent", B).addNode("tools", J).addEdge($, "requireNavigationServices").addEdge("requireNavigationServices", "intentLLM").addConditionalEdges(
|
|
234
245
|
"intentLLM",
|
|
235
246
|
(t) => t.intent === "goToLayer" || t.intent === "goToFeatures" ? "vectorSearchLayers" : "agent",
|
|
236
247
|
{
|
|
@@ -263,13 +274,13 @@ ${r.results.map((m) => ` - ${m.name} (${m.score.toFixed(2)})`).join(`
|
|
|
263
274
|
_Example: “Center the map on San Francisco at scale 50000”_
|
|
264
275
|
_Example: “Zoom to the features in the schools layer where city = 'Austin'”_
|
|
265
276
|
_Example: “Go to the Downtown bookmark”_
|
|
266
|
-
_Example: “Where is Mount Rainier?”_`,
|
|
277
|
+
_Example: “Where is Mount Rainier?”_`, Re = {
|
|
267
278
|
id: "navigation",
|
|
268
279
|
name: "Navigation Agent",
|
|
269
280
|
description: ee,
|
|
270
281
|
createGraph: Y,
|
|
271
|
-
workspace:
|
|
282
|
+
workspace: k
|
|
272
283
|
};
|
|
273
284
|
export {
|
|
274
|
-
|
|
285
|
+
Re as N
|
|
275
286
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
2
|
import A from "@arcgis/core/identity/IdentityManager.js";
|
|
3
3
|
import C from "@arcgis/core/portal/Portal.js";
|
|
4
|
-
import {
|
|
4
|
+
import { j as k, k as b, D as M, n as D, o as F, W as $ } from "./generateLayerDescriptions.js";
|
|
5
5
|
import { isGraphInterrupt as L, StateGraph as W, START as q, END as j, MemorySaver as H } from "@langchain/langgraph/web";
|
|
6
6
|
import { generateGuid as P } from "@arcgis/toolkit/string";
|
|
7
7
|
import { HumanMessage as O, AIMessage as T } from "@langchain/core/messages";
|
package/dist/chunks/state.js
CHANGED
|
@@ -1,17 +1,9 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import { Annotation as
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
messages: [],
|
|
8
|
-
priorSteps: [],
|
|
9
|
-
sharedState: {},
|
|
10
|
-
userRequest: ""
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
|
-
function i(r) {
|
|
14
|
-
const n = [...new Set([...r].filter((t) => c.has(t)))];
|
|
2
|
+
import { Annotation as o } from "@langchain/langgraph/web";
|
|
3
|
+
import { c } from "./baseAgentState.js";
|
|
4
|
+
const i = /* @__PURE__ */ new Set(["agentExecutionContext", "outputMessage", "summary", "status"]);
|
|
5
|
+
function u(r) {
|
|
6
|
+
const n = [...new Set([...r].filter((t) => i.has(t)))];
|
|
15
7
|
if (n.length !== 0)
|
|
16
8
|
throw new Error(`custom state cannot define reserved runtime fields: ${n.join(", ")}.`);
|
|
17
9
|
}
|
|
@@ -20,36 +12,36 @@ function f(r) {
|
|
|
20
12
|
return Object.fromEntries(
|
|
21
13
|
n.map(([t, e]) => [
|
|
22
14
|
t,
|
|
23
|
-
|
|
24
|
-
reducer: (
|
|
15
|
+
o({
|
|
16
|
+
reducer: (s, a) => a,
|
|
25
17
|
default: () => e
|
|
26
18
|
})
|
|
27
19
|
])
|
|
28
20
|
);
|
|
29
21
|
}
|
|
30
22
|
function m(r = {}) {
|
|
31
|
-
|
|
23
|
+
u(Object.keys(r));
|
|
32
24
|
const n = f(r);
|
|
33
|
-
return
|
|
25
|
+
return o.Root({
|
|
34
26
|
...n,
|
|
35
|
-
agentExecutionContext:
|
|
27
|
+
agentExecutionContext: o({
|
|
36
28
|
reducer: (t, e) => ({
|
|
37
29
|
...t,
|
|
38
30
|
...e
|
|
39
31
|
}),
|
|
40
|
-
default:
|
|
32
|
+
default: c
|
|
41
33
|
}),
|
|
42
|
-
outputMessage:
|
|
34
|
+
outputMessage: o({
|
|
43
35
|
// Preserve the last meaningful user-facing message produced by the graph.
|
|
44
36
|
reducer: (t = "", e) => typeof e == "string" && e.trim() ? e : t,
|
|
45
37
|
default: () => ""
|
|
46
38
|
}),
|
|
47
|
-
summary:
|
|
39
|
+
summary: o({
|
|
48
40
|
// Summary is a compact orchestrator-facing outcome, so replacement semantics are enough.
|
|
49
41
|
reducer: (t = "", e) => typeof e == "string" ? e : t,
|
|
50
42
|
default: () => ""
|
|
51
43
|
}),
|
|
52
|
-
status:
|
|
44
|
+
status: o({
|
|
53
45
|
// Keep the first meaningful status until a later node explicitly replaces it.
|
|
54
46
|
reducer: (t, e) => e ?? t,
|
|
55
47
|
default: () => {
|
|
@@ -57,15 +49,17 @@ function m(r = {}) {
|
|
|
57
49
|
})
|
|
58
50
|
});
|
|
59
51
|
}
|
|
60
|
-
function
|
|
52
|
+
function g(r) {
|
|
61
53
|
const n = /* @__PURE__ */ new Set();
|
|
62
54
|
for (const e of r)
|
|
63
|
-
for (const
|
|
64
|
-
n.add(
|
|
55
|
+
for (const s of Object.keys(e.shape ?? {}))
|
|
56
|
+
n.add(s);
|
|
65
57
|
const t = Object.fromEntries([...n].map((e) => [e, void 0]));
|
|
66
58
|
return m(t);
|
|
67
59
|
}
|
|
68
60
|
export {
|
|
69
61
|
m as a,
|
|
70
|
-
|
|
62
|
+
u as b,
|
|
63
|
+
g as c,
|
|
64
|
+
f as d
|
|
71
65
|
};
|