@arcgis/ai-components 5.2.0-next.72 → 5.2.0-next.74
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.d.ts +5 -2
- package/dist/agent-utils/LLMAgent.js +1 -1
- package/dist/agentic-workflow/jsonTypes.d.ts +8 -1
- package/dist/agentic-workflow/nodes/AgentNode.d.ts +2 -0
- package/dist/agentic-workflow/nodes/tools/ArcgisTool.d.ts +21 -0
- package/dist/cdn/253R5CBD.js +2 -0
- package/dist/cdn/2VBPA27M.js +18 -0
- package/dist/cdn/{DWYODVWW.js → 323DHVYA.js} +5 -5
- package/dist/cdn/34O57OGV.js +2 -0
- package/dist/cdn/{FSMHR7GK.js → 4HDDRBIY.js} +1 -1
- package/dist/cdn/4MFEKBKL.js +11 -0
- package/dist/cdn/{Y5UFOH54.js → 4NJ2FF7H.js} +1 -1
- package/dist/cdn/4YXYLX4H.js +2 -0
- package/dist/cdn/5DVRVY4L.js +2 -0
- package/dist/cdn/5PJXNTLZ.js +2 -0
- package/dist/cdn/5R6QUF5B.js +2 -0
- package/dist/cdn/5RVELJU4.js +36 -0
- package/dist/cdn/5WLNL4HZ.js +2 -0
- package/dist/cdn/66SKMECC.js +2 -0
- package/dist/cdn/6CLF7KIK.js +2 -0
- package/dist/cdn/{S6ZAQRC6.js → 6KFMRBAA.js} +1 -1
- package/dist/cdn/77QFSIWW.js +5 -0
- package/dist/cdn/7E2QMWK6.js +2 -0
- package/dist/cdn/{HO2YDJI2.js → 7M6VKBTK.js} +1 -1
- package/dist/cdn/{HJG7QM2R.js → 7VAQUCBU.js} +1 -1
- package/dist/cdn/ACJTJLZN.js +2 -0
- package/dist/cdn/AI6DYOKR.js +181 -0
- package/dist/cdn/AT4XVTJR.js +44 -0
- package/dist/cdn/BS2PFNU4.js +2 -0
- package/dist/cdn/CCC6LBMY.js +2 -0
- package/dist/cdn/CGXQAB3A.js +2 -0
- package/dist/cdn/{M3MRIGDZ.js → CP5BVGJU.js} +1 -1
- package/dist/cdn/CWD37QFT.js +2 -0
- package/dist/cdn/DY36ATOA.js +2 -0
- package/dist/cdn/DYASSC7Z.js +2 -0
- package/dist/cdn/EAEQONP7.js +2 -0
- package/dist/cdn/EMLOVMD4.js +2 -0
- package/dist/cdn/EWLXNGKH.js +208 -0
- package/dist/cdn/FAR3DFFK.js +2 -0
- package/dist/cdn/FDOMMK2M.js +2 -0
- package/dist/cdn/GRHIFCQX.js +2 -0
- package/dist/cdn/{S3XUYAUX.js → HHFNQR6Z.js} +1 -1
- package/dist/cdn/{WQKNV6KK.js → HMUWQCXU.js} +1 -1
- package/dist/cdn/HZ5ARNAM.js +2 -0
- package/dist/cdn/I6PD2HSL.js +2 -0
- package/dist/cdn/IDUC4CPV.js +2 -0
- package/dist/cdn/IRNSIUBT.js +2 -0
- package/dist/cdn/{OYNIFMCJ.js → J6SZIQJA.js} +1 -1
- package/dist/cdn/K335IAIE.js +2 -0
- package/dist/cdn/K33MZ726.js +2 -0
- package/dist/cdn/KA3FF3ZO.js +2 -0
- package/dist/cdn/{DBHLKLKM.js → KPO4XX6J.js} +1 -1
- package/dist/cdn/{I4L45WQS.js → L7XTRDFM.js} +1 -1
- package/dist/cdn/LCFIADOZ.js +2 -0
- package/dist/cdn/MDM2K3U7.js +2 -0
- package/dist/cdn/MM33KJPF.js +2 -0
- package/dist/cdn/NIY32GK2.js +2 -0
- package/dist/cdn/{3ZPPYCNL.js → ONMNQBPO.js} +1 -1
- package/dist/cdn/ONQ6JSBJ.js +2 -0
- package/dist/cdn/{6QJFOL6M.js → OWTGH34K.js} +1 -1
- package/dist/cdn/{XPTCV6YV.js → PSYRZMX2.js} +1 -1
- package/dist/cdn/Q4IQUEZN.js +14 -0
- package/dist/cdn/QNNGPA3Q.js +2 -0
- package/dist/cdn/QRHZXLZN.js +2 -0
- package/dist/cdn/QVOMX3R6.js +2 -0
- package/dist/cdn/QZ3NQTNQ.js +2 -0
- package/dist/cdn/RADWN4ZP.js +2 -0
- package/dist/cdn/RU2T7GUX.js +2 -0
- package/dist/cdn/S6OYR4VI.js +156 -0
- package/dist/cdn/T2GJLEYV.js +2 -0
- package/dist/cdn/TKYI5QRL.js +2 -0
- package/dist/cdn/{5SFZS2RD.js → TQXLSW4A.js} +2 -2
- package/dist/cdn/{NJJYZP3R.js → U6FBRUM4.js} +1 -1
- package/dist/cdn/UIXX3XEN.js +2 -0
- package/dist/cdn/UPWAOZXQ.js +2 -0
- package/dist/cdn/{5SF6DEMO.js → VNJMTA6O.js} +1 -1
- package/dist/cdn/VOKXKU7M.js +56 -0
- package/dist/cdn/{33BF35AO.js → VYTYVWR6.js} +4 -4
- package/dist/cdn/WMZ24LWS.js +2 -0
- package/dist/cdn/{JYVBCHR6.js → WP7ORLSB.js} +1 -1
- package/dist/cdn/WS3T73IY.js +2 -0
- package/dist/cdn/{UZL6UVE4.js → ZLWWWTH4.js} +1 -1
- package/dist/cdn/{PAUIFUMO.js → ZQMBJ6MI.js} +1 -1
- 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 +938 -1938
- 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/dataExplorationGraph.js +30 -27
- 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 +145 -148
- 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 +68 -57
- package/dist/chunks/types.js +59 -0
- package/dist/components/arcgis-assistant-agent/customElement.js +404 -279
- 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/web-types.json +1 -1
- package/dist/types/stencil.d.ts +2 -2
- package/dist/utils/index.d.ts +4 -5
- package/dist/utils/index.js +19 -20
- package/package.json +8 -8
- package/dist/cdn/55M2HE4U.js +0 -2
- package/dist/cdn/5RZGG4F2.js +0 -2
- package/dist/cdn/BAB3MK4Y.js +0 -2
- package/dist/cdn/BMBV6Y2A.js +0 -2
- package/dist/cdn/D3RKQSWS.js +0 -2
- package/dist/cdn/E7KEOJZG.js +0 -208
- package/dist/cdn/IGQFAL3H.js +0 -2
- package/dist/cdn/LUY6V4TP.js +0 -181
- package/dist/cdn/NSXX2KYS.js +0 -2
- package/dist/cdn/OFRFP4BX.js +0 -2
- package/dist/cdn/OUFGJV3R.js +0 -2
- package/dist/cdn/RWM5T4XB.js +0 -180
- package/dist/cdn/SRFLL6ET.js +0 -2
- package/dist/cdn/WDOM6Z5O.js +0 -18
- package/dist/cdn/WZFC5HUX.js +0 -56
- package/dist/cdn/Z4XUJQ2I.js +0 -36
- package/dist/cdn/ZJEWP2ND.js +0 -44
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
|
-
`)}` : "",
|
|
47
|
+
${i.map((h) => `- ${h}`).join(`
|
|
48
|
+
`)}` : "", s = (e.intent === "goToLayer" || e.intent === "goToFeatures") && e.vectorSearchLayerResults?.length ? `Candidate layers:
|
|
38
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:
|
|
53
|
+
layersSection: s,
|
|
43
54
|
fieldsSection: d,
|
|
44
|
-
currentZoom:
|
|
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,14 +88,14 @@ 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
96
|
const { messages: m } = await o.invoke(
|
|
86
97
|
{
|
|
87
|
-
messages: [
|
|
98
|
+
messages: [r]
|
|
88
99
|
},
|
|
89
100
|
t
|
|
90
101
|
);
|
|
@@ -97,20 +108,20 @@ 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 m =
|
|
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
126
|
outputMessage: `Navigation tool execution failed: ${m}`,
|
|
116
127
|
status: "failed",
|
|
@@ -123,11 +134,11 @@ 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
144
|
tools: m.map(({ name: n, description: g, schema: v }) => `${n}: ${g}, ${JSON.stringify(v)}`).join(`
|
|
@@ -136,69 +147,69 @@ ${l.map((n) => `- ${n}`).join(`
|
|
|
136
147
|
assignedTask: e.agentExecutionContext.assignedTask,
|
|
137
148
|
userRequest: e.agentExecutionContext.userRequest,
|
|
138
149
|
priorSteps: e.agentExecutionContext.priorSteps
|
|
139
|
-
},
|
|
140
|
-
intent:
|
|
141
|
-
}), d = await
|
|
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
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
170
|
embeddingCache: m
|
|
160
|
-
})).map(({ id: a, score:
|
|
161
|
-
const d =
|
|
171
|
+
})).map(({ id: a, score: s }) => {
|
|
172
|
+
const d = r.get(a)?.layerItem;
|
|
162
173
|
return {
|
|
163
174
|
id: a,
|
|
164
175
|
title: d?.title,
|
|
165
176
|
name: d?.name ?? void 0,
|
|
166
|
-
score:
|
|
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
207
|
embeddingCache: m
|
|
197
|
-
})).map(({ layerId:
|
|
198
|
-
const y =
|
|
208
|
+
})).map(({ layerId: s, results: d }) => {
|
|
209
|
+
const y = r.get(s)?.fieldRegistry;
|
|
199
210
|
return {
|
|
200
|
-
layerId:
|
|
201
|
-
layerName:
|
|
211
|
+
layerId: s,
|
|
212
|
+
layerName: r.get(s)?.layerItem.name,
|
|
202
213
|
results: d.map((n) => {
|
|
203
214
|
const g = y?.get(n.name);
|
|
204
215
|
return {
|
|
@@ -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((d) => ` - ${d.name} (${d.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
|
};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
+
import m from "@arcgis/core/geometry/Point.js";
|
|
3
|
+
import * as y from "@arcgis/core/geometry/operators/unionOperator.js";
|
|
4
|
+
import f from "zod";
|
|
5
|
+
const u = 750;
|
|
6
|
+
function c(e) {
|
|
7
|
+
return "point" in e && e.point !== void 0;
|
|
8
|
+
}
|
|
9
|
+
function d(e) {
|
|
10
|
+
return "layerId" in e && e.layerId !== void 0;
|
|
11
|
+
}
|
|
12
|
+
const R = async (e, o) => {
|
|
13
|
+
if (c(e)) {
|
|
14
|
+
const { point: r } = e;
|
|
15
|
+
return { geometry: new m({
|
|
16
|
+
x: r.x,
|
|
17
|
+
y: r.y,
|
|
18
|
+
spatialReference: r.spatialReference ? { wkid: r.spatialReference.wkid } : o.spatialReference
|
|
19
|
+
}) };
|
|
20
|
+
}
|
|
21
|
+
if (d(e)) {
|
|
22
|
+
const r = o.map?.allLayers.find(
|
|
23
|
+
(t) => t.id === e.layerId
|
|
24
|
+
);
|
|
25
|
+
if (!r)
|
|
26
|
+
return { error: `Could not find geometry layer with ID: ${e.layerId}` };
|
|
27
|
+
const i = r.title ?? r.id, l = e.where?.trim() || "1=1";
|
|
28
|
+
try {
|
|
29
|
+
const t = await r.queryFeatures({
|
|
30
|
+
where: l,
|
|
31
|
+
returnGeometry: !0,
|
|
32
|
+
outSpatialReference: o.spatialReference,
|
|
33
|
+
num: u + 1
|
|
34
|
+
});
|
|
35
|
+
if (!t.features.length)
|
|
36
|
+
return {
|
|
37
|
+
error: `No features found in geometry layer "${i}" with the specified where clause: ${l}`
|
|
38
|
+
};
|
|
39
|
+
if (t.features.length > u)
|
|
40
|
+
return {
|
|
41
|
+
error: `Geometry filter for layer "${i}" matched too many features (${t.features.length}+). Please narrow the geometry layer filter.`
|
|
42
|
+
};
|
|
43
|
+
const a = t.features.map((s) => s.geometry).filter((s) => !!s);
|
|
44
|
+
if (!a.length)
|
|
45
|
+
return { error: "No valid geometries found for the matched geometry layer features." };
|
|
46
|
+
const n = a.length === 1 ? a[0] : y.executeMany(a);
|
|
47
|
+
return n ? (n.spatialReference || (n.spatialReference = o.spatialReference), { geometry: n }) : { error: "Failed to combine geometries from geometry layer." };
|
|
48
|
+
} catch (t) {
|
|
49
|
+
return { error: `Failed to query geometry: ${String(t)}` };
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return { error: "Invalid geometry configuration provided" };
|
|
53
|
+
}, h = ["feet", "kilometers", "meters", "miles", "nautical-miles", "us-nautical-miles"], w = f.enum(h);
|
|
54
|
+
export {
|
|
55
|
+
c as a,
|
|
56
|
+
w as d,
|
|
57
|
+
R as g,
|
|
58
|
+
d as i
|
|
59
|
+
};
|