@arcgis/ai-agents 5.1.0-next.69 → 5.1.0-next.70
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/index.js +996 -962
- package/dist/utils/dateTimeUtils.d.ts +31 -0
- package/package.json +2 -2
- package/dist/utils/timeZone.d.ts +0 -8
package/dist/index.js
CHANGED
|
@@ -1,45 +1,46 @@
|
|
|
1
|
-
import { Annotation as w, StateGraph as V, START as W, END as
|
|
2
|
-
import { invokeToolPrompt as
|
|
1
|
+
import { Annotation as w, StateGraph as V, START as W, END as q, NodeInterrupt as He } from "@langchain/langgraph/web";
|
|
2
|
+
import { invokeToolPrompt as D, sendTraceMessage as g, invokeStructuredPrompt as Re, invokeTextPrompt as Ze, sendUXSuggestion as $ } from "@arcgis/ai-orchestrator";
|
|
3
3
|
import { tool as b } from "@langchain/core/tools";
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import { addressToLocations as
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import { AIMessage as
|
|
13
|
-
import { ToolNode as
|
|
14
|
-
import
|
|
15
|
-
import
|
|
16
|
-
import * as
|
|
17
|
-
import
|
|
18
|
-
import
|
|
19
|
-
import
|
|
20
|
-
import
|
|
21
|
-
import
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
26
|
-
import {
|
|
27
|
-
import {
|
|
28
|
-
import {
|
|
29
|
-
import {
|
|
30
|
-
import {
|
|
31
|
-
import {
|
|
32
|
-
import {
|
|
33
|
-
import {
|
|
34
|
-
import {
|
|
35
|
-
import {
|
|
36
|
-
import {
|
|
37
|
-
import {
|
|
38
|
-
import
|
|
39
|
-
import
|
|
40
|
-
import
|
|
41
|
-
import
|
|
42
|
-
import
|
|
4
|
+
import Je from "@arcgis/core/Graphic.js";
|
|
5
|
+
import ie from "@arcgis/core/geometry/Point.js";
|
|
6
|
+
import $e from "@arcgis/core/geometry/Extent.js";
|
|
7
|
+
import Ye from "@arcgis/core/symbols/PictureMarkerSymbol.js";
|
|
8
|
+
import { addressToLocations as Xe } from "@arcgis/core/rest/locator.js";
|
|
9
|
+
import _ from "@arcgis/core/portal/Portal.js";
|
|
10
|
+
import oe from "@arcgis/core/config.js";
|
|
11
|
+
import i, { z as N } from "zod";
|
|
12
|
+
import { AIMessage as ke } from "@langchain/core/messages";
|
|
13
|
+
import { ToolNode as P } from "@langchain/langgraph/prebuilt";
|
|
14
|
+
import et from "@arcgis/core/layers/support/FeatureEffect.js";
|
|
15
|
+
import Fe from "@arcgis/core/layers/support/FeatureFilter.js";
|
|
16
|
+
import * as tt from "@arcgis/core/geometry/operators/unionOperator.js";
|
|
17
|
+
import { formatDateOnly as rt, convertDateFormatToIntlOptions as U, formatTimeOnly as at, formatDate as fe } from "@arcgis/core/intl.js";
|
|
18
|
+
import qe from "@arcgis/core/smartMapping/statistics/summaryStatistics.js";
|
|
19
|
+
import Le from "@arcgis/core/smartMapping/statistics/uniqueValues.js";
|
|
20
|
+
import ot from "@arcgis/core/rest/support/TopFeaturesQuery.js";
|
|
21
|
+
import nt from "@arcgis/core/rest/support/TopFilter.js";
|
|
22
|
+
import { createRenderer as st } from "@arcgis/core/smartMapping/renderers/pieChart.js";
|
|
23
|
+
import { getSchemesByTag as it, getSchemes as ct } from "@arcgis/core/smartMapping/symbology/pieChart.js";
|
|
24
|
+
import { getBackgroundColorTheme as we } from "@arcgis/core/views/support/colorUtils.js";
|
|
25
|
+
import { createAgeRenderer as lt, createContinuousRenderer as dt } from "@arcgis/core/smartMapping/renderers/color.js";
|
|
26
|
+
import { getSchemesByTag as ce } from "@arcgis/core/smartMapping/symbology/color.js";
|
|
27
|
+
import { createContinuousRenderer as ut } from "@arcgis/core/smartMapping/renderers/univariateColorSize.js";
|
|
28
|
+
import { createRenderer as pt } from "@arcgis/core/smartMapping/renderers/dotDensity.js";
|
|
29
|
+
import { getSchemesByTag as mt } from "@arcgis/core/smartMapping/symbology/dotDensity.js";
|
|
30
|
+
import { createRenderer as ht } from "@arcgis/core/smartMapping/renderers/heatmap.js";
|
|
31
|
+
import { getSchemesByTag as gt } from "@arcgis/core/smartMapping/symbology/heatmap.js";
|
|
32
|
+
import { createRenderer as yt } from "@arcgis/core/smartMapping/renderers/predominance.js";
|
|
33
|
+
import { getSchemesByTag as ft } from "@arcgis/core/smartMapping/symbology/predominance.js";
|
|
34
|
+
import { createRenderer as wt } from "@arcgis/core/smartMapping/renderers/relationship.js";
|
|
35
|
+
import { getSchemesByTag as bt } from "@arcgis/core/smartMapping/symbology/relationship.js";
|
|
36
|
+
import { createAgeRenderer as xt, createContinuousRenderer as St } from "@arcgis/core/smartMapping/renderers/size.js";
|
|
37
|
+
import { createRenderer as vt } from "@arcgis/core/smartMapping/renderers/type.js";
|
|
38
|
+
import { getSchemesByTag as Tt } from "@arcgis/core/smartMapping/symbology/type.js";
|
|
39
|
+
import Ie from "@arcgis/core/rest/knowledgeGraph/GraphQueryStreaming.js";
|
|
40
|
+
import be from "@arcgis/core/request.js";
|
|
41
|
+
import xe from "@arcgis/core/identity/IdentityManager.js";
|
|
42
|
+
import { executeQueryStreaming as Et } from "@arcgis/core/rest/knowledgeGraphService.js";
|
|
43
|
+
import Ct from "@arcgis/core/WebLinkChart.js";
|
|
43
44
|
const K = (e, t) => ({
|
|
44
45
|
...e,
|
|
45
46
|
...t
|
|
@@ -58,7 +59,7 @@ const K = (e, t) => ({
|
|
|
58
59
|
return o[o.length - 1]?.trim() === r ? e : `${e}
|
|
59
60
|
|
|
60
61
|
${r}`;
|
|
61
|
-
},
|
|
62
|
+
}, j = (e, t) => t ?? e, Ne = w.Root({
|
|
62
63
|
// Execution context provided by the orchestrator for this agent invocation.
|
|
63
64
|
agentExecutionContext: w({
|
|
64
65
|
reducer: K,
|
|
@@ -75,11 +76,11 @@ ${r}`;
|
|
|
75
76
|
default: () => ""
|
|
76
77
|
}),
|
|
77
78
|
summary: w({
|
|
78
|
-
reducer:
|
|
79
|
+
reducer: j,
|
|
79
80
|
default: () => ""
|
|
80
81
|
}),
|
|
81
82
|
status: w({
|
|
82
|
-
reducer:
|
|
83
|
+
reducer: j,
|
|
83
84
|
default: () => "success"
|
|
84
85
|
}),
|
|
85
86
|
intent: w({
|
|
@@ -93,58 +94,58 @@ ${r}`;
|
|
|
93
94
|
reducer: (e, t) => t
|
|
94
95
|
})
|
|
95
96
|
});
|
|
96
|
-
async function
|
|
97
|
-
const a =
|
|
97
|
+
async function Rt(e, t) {
|
|
98
|
+
const a = _.getDefault().helperServices, o = a.geocode.find((R) => R.name === "ArcGIS World Geocoding Service") ?? a.geocode[0];
|
|
98
99
|
if (!o)
|
|
99
100
|
throw new Error("No geocoding service found in helperServices.");
|
|
100
|
-
const n = o.url, c = `${
|
|
101
|
+
const n = o.url, c = `${oe.assetsPath?.endsWith("/") ? oe.assetsPath : `${oe.assetsPath}/`}esri/images/search/search-symbol-32.png`, l = (await Xe(n, {
|
|
101
102
|
address: { SingleLine: e },
|
|
102
103
|
outFields: ["Match_addr"]
|
|
103
104
|
}))?.[0];
|
|
104
105
|
if (!l?.extent)
|
|
105
106
|
throw new Error(`Could not find location for: ${e}`);
|
|
106
|
-
const { xmin: d, ymin: u, xmax: p, ymax:
|
|
107
|
+
const { xmin: d, ymin: u, xmax: p, ymax: m, spatialReference: y } = l.extent, E = new $e({
|
|
107
108
|
xmin: d,
|
|
108
109
|
ymin: u,
|
|
109
110
|
xmax: p,
|
|
110
|
-
ymax:
|
|
111
|
+
ymax: m,
|
|
111
112
|
spatialReference: y
|
|
112
|
-
}),
|
|
113
|
-
x:
|
|
113
|
+
}), h = (d + p) / 2, f = (u + m) / 2, S = new ie({
|
|
114
|
+
x: h,
|
|
114
115
|
y: f,
|
|
115
116
|
spatialReference: y
|
|
116
|
-
}),
|
|
117
|
+
}), v = new Ye({
|
|
117
118
|
url: c,
|
|
118
119
|
width: 24,
|
|
119
120
|
height: 24
|
|
120
|
-
}),
|
|
121
|
-
geometry:
|
|
122
|
-
symbol:
|
|
121
|
+
}), T = new Je({
|
|
122
|
+
geometry: S,
|
|
123
|
+
symbol: v
|
|
123
124
|
});
|
|
124
|
-
return t.graphics.removeAll(), t.graphics.add(
|
|
125
|
+
return t.graphics.removeAll(), t.graphics.add(T), await t.goTo(E), `Successfully zoomed to: ${e}. Location coordinates: x=${h}, y=${f}, wkid=${y.wkid}`;
|
|
125
126
|
}
|
|
126
|
-
const
|
|
127
|
-
function
|
|
127
|
+
const $t = ["mapView"];
|
|
128
|
+
function k(e) {
|
|
128
129
|
const r = e?.configurable?.context;
|
|
129
130
|
if (!r || typeof r != "object")
|
|
130
131
|
throw new Error("NavigationAgent context missing");
|
|
131
|
-
const a =
|
|
132
|
+
const a = $t.filter((o) => !(o in r));
|
|
132
133
|
if (a.length)
|
|
133
134
|
throw new Error(`NavigationAgent context missing: ${a.join(", ")}`);
|
|
134
135
|
return r;
|
|
135
136
|
}
|
|
136
|
-
async function
|
|
137
|
-
const { mapView: r } =
|
|
138
|
-
return await
|
|
137
|
+
async function kt({ address: e }, t) {
|
|
138
|
+
const { mapView: r } = k(t);
|
|
139
|
+
return await Rt(e, r);
|
|
139
140
|
}
|
|
140
|
-
const
|
|
141
|
-
address:
|
|
142
|
-
}),
|
|
141
|
+
const Ft = i.object({
|
|
142
|
+
address: i.string().describe("The full address or place name to locate.")
|
|
143
|
+
}), qt = b(kt, {
|
|
143
144
|
name: "goToAddress",
|
|
144
145
|
description: "Geocodes an address using Esri's World Geocoding Service and zooms the map to that location.",
|
|
145
|
-
schema:
|
|
146
|
+
schema: Ft
|
|
146
147
|
});
|
|
147
|
-
async function
|
|
148
|
+
async function Lt(e, t) {
|
|
148
149
|
const a = t.map.bookmarks;
|
|
149
150
|
if (!a || a.length === 0)
|
|
150
151
|
throw new Error("No bookmarks found in the map.");
|
|
@@ -156,18 +157,18 @@ async function Et(e, t) {
|
|
|
156
157
|
throw new Error(`Bookmark with name "${e}" does not have a valid viewpoint.`);
|
|
157
158
|
return await t.goTo(n), `Navigated to bookmark: ${e}`;
|
|
158
159
|
}
|
|
159
|
-
async function
|
|
160
|
-
const { mapView: r } =
|
|
161
|
-
return await Promise.resolve(
|
|
160
|
+
async function It({ bookmarkName: e }, t) {
|
|
161
|
+
const { mapView: r } = k(t);
|
|
162
|
+
return await Promise.resolve(Lt(e, r));
|
|
162
163
|
}
|
|
163
|
-
const
|
|
164
|
-
bookmarkName:
|
|
165
|
-
}),
|
|
164
|
+
const Nt = N.object({
|
|
165
|
+
bookmarkName: N.string().describe("The name of the bookmark to navigate to.")
|
|
166
|
+
}), At = b(It, {
|
|
166
167
|
name: "goToBookmark",
|
|
167
168
|
description: "Go to the extent of the bookmark with the given name.",
|
|
168
|
-
schema:
|
|
169
|
+
schema: Nt
|
|
169
170
|
});
|
|
170
|
-
async function
|
|
171
|
+
async function zt(e, t, r) {
|
|
171
172
|
const a = r.map?.allLayers.find((n) => n.id === e);
|
|
172
173
|
if (!a)
|
|
173
174
|
return `Error: Layer with id ${e} not found`;
|
|
@@ -186,20 +187,20 @@ async function kt(e, t, r) {
|
|
|
186
187
|
return console.error("Error in goToFeatures:", n), `Error: ${n instanceof Error ? n.message : "Unknown error"}`;
|
|
187
188
|
}
|
|
188
189
|
}
|
|
189
|
-
async function
|
|
190
|
-
const { mapView: a } =
|
|
191
|
-
return await
|
|
190
|
+
async function _t({ layerId: e, where: t }, r) {
|
|
191
|
+
const { mapView: a } = k(r);
|
|
192
|
+
return await zt(e, t, a);
|
|
192
193
|
}
|
|
193
|
-
const
|
|
194
|
-
layerId:
|
|
195
|
-
where:
|
|
196
|
-
}),
|
|
194
|
+
const jt = N.object({
|
|
195
|
+
layerId: N.string().describe("The layerId of the layer to zoom to."),
|
|
196
|
+
where: N.string().describe("The sql-92 where clause used to query features to zoom to")
|
|
197
|
+
}), Dt = b(_t, {
|
|
197
198
|
name: "goToFeatures",
|
|
198
199
|
description: "Go to the features that match the given filter related to the given layerId.",
|
|
199
|
-
schema:
|
|
200
|
+
schema: jt
|
|
200
201
|
});
|
|
201
|
-
async function
|
|
202
|
-
const r = new
|
|
202
|
+
async function Pt(e) {
|
|
203
|
+
const r = new $e({
|
|
203
204
|
xmin: -180,
|
|
204
205
|
ymin: -90,
|
|
205
206
|
xmax: 180,
|
|
@@ -208,16 +209,16 @@ async function It(e) {
|
|
|
208
209
|
}).expand(0.7);
|
|
209
210
|
return await e.goTo(r), "Successfully zoomed to world extent";
|
|
210
211
|
}
|
|
211
|
-
async function
|
|
212
|
-
const { mapView: r } =
|
|
213
|
-
return await
|
|
212
|
+
async function Mt(e, t) {
|
|
213
|
+
const { mapView: r } = k(t);
|
|
214
|
+
return await Pt(r);
|
|
214
215
|
}
|
|
215
|
-
const
|
|
216
|
+
const Ot = N.object({}), Gt = b(Mt, {
|
|
216
217
|
name: "goToFullExtent",
|
|
217
218
|
description: "Zooms the map to the full world extent using Esri's Geocoding Service.",
|
|
218
|
-
schema:
|
|
219
|
+
schema: Ot
|
|
219
220
|
});
|
|
220
|
-
async function
|
|
221
|
+
async function Vt(e) {
|
|
221
222
|
const r = e.map.initialViewProperties?.viewpoint?.targetGeometry;
|
|
222
223
|
if (r)
|
|
223
224
|
await e.goTo(r);
|
|
@@ -225,16 +226,16 @@ async function _t(e) {
|
|
|
225
226
|
throw new Error("Initial extent is undefined");
|
|
226
227
|
return "Successfully zoomed to home extent";
|
|
227
228
|
}
|
|
228
|
-
async function
|
|
229
|
-
const { mapView: r } =
|
|
230
|
-
return await
|
|
229
|
+
async function Wt(e, t) {
|
|
230
|
+
const { mapView: r } = k(t);
|
|
231
|
+
return await Vt(r);
|
|
231
232
|
}
|
|
232
|
-
const
|
|
233
|
+
const Kt = i.object({}), Bt = b(Wt, {
|
|
233
234
|
name: "goToHomeExtent",
|
|
234
235
|
description: "Go to the initial web map view extent",
|
|
235
|
-
schema:
|
|
236
|
+
schema: Kt
|
|
236
237
|
});
|
|
237
|
-
async function
|
|
238
|
+
async function Qt(e, t) {
|
|
238
239
|
await t.when();
|
|
239
240
|
const r = t.map?.allLayers.find((o) => o.id === e);
|
|
240
241
|
if (!r)
|
|
@@ -242,34 +243,34 @@ async function Dt(e, t) {
|
|
|
242
243
|
let a;
|
|
243
244
|
return (r.type === "link-chart" || r.type === "knowledge-graph-sublayer") && t.map?.activeLinkChartLayer ? a = t.map.diagramNodesExtent : a = r.fullExtent, a ? (await t.goTo(a), r.visible = !0, `Successfully zoomed to: ${r.title ?? ""}`) : "Layer has no defined extent. Cannot zoom to layer.";
|
|
244
245
|
}
|
|
245
|
-
async function
|
|
246
|
-
const { mapView: r } =
|
|
247
|
-
return await
|
|
246
|
+
async function Ut({ layerId: e }, t) {
|
|
247
|
+
const { mapView: r } = k(t);
|
|
248
|
+
return await Qt(e, r);
|
|
248
249
|
}
|
|
249
|
-
const
|
|
250
|
-
layerId:
|
|
251
|
-
}),
|
|
250
|
+
const Ht = N.object({
|
|
251
|
+
layerId: N.string().describe("The id of the layer to navigate to")
|
|
252
|
+
}), Zt = b(Ut, {
|
|
252
253
|
name: "goToLayer",
|
|
253
254
|
description: "Zooms the map view to the full extent of the top matching layer.",
|
|
254
|
-
schema:
|
|
255
|
+
schema: Ht
|
|
255
256
|
});
|
|
256
|
-
async function
|
|
257
|
+
async function Jt(e, t) {
|
|
257
258
|
return await t.goTo({ scale: e }), `Successfully zoomed to: ${e}`;
|
|
258
259
|
}
|
|
259
|
-
async function
|
|
260
|
-
const { mapView: r } =
|
|
261
|
-
return await
|
|
260
|
+
async function Yt({ scale: e }, t) {
|
|
261
|
+
const { mapView: r } = k(t);
|
|
262
|
+
return await Jt(e, r);
|
|
262
263
|
}
|
|
263
|
-
const
|
|
264
|
-
scale:
|
|
265
|
-
}),
|
|
264
|
+
const Xt = i.object({
|
|
265
|
+
scale: i.number().describe("The map scale of the view to go to.")
|
|
266
|
+
}), er = b(Yt, {
|
|
266
267
|
name: "goToScale",
|
|
267
268
|
description: "Go to the specified view scale.",
|
|
268
|
-
schema:
|
|
269
|
+
schema: Xt
|
|
269
270
|
});
|
|
270
|
-
async function
|
|
271
|
+
async function tr(e, t, r) {
|
|
271
272
|
const o = {
|
|
272
|
-
target: new
|
|
273
|
+
target: new ie({
|
|
273
274
|
longitude: e.longitude,
|
|
274
275
|
latitude: e.latitude,
|
|
275
276
|
spatialReference: { wkid: 4326 }
|
|
@@ -281,50 +282,50 @@ async function Ut(e, t, r) {
|
|
|
281
282
|
r?.scale !== void 0 ? `scale 1:${r.scale}` : ""
|
|
282
283
|
].filter(Boolean).join(", ")}`;
|
|
283
284
|
}
|
|
284
|
-
async function
|
|
285
|
+
async function rr({
|
|
285
286
|
center: e,
|
|
286
287
|
zoom: t,
|
|
287
288
|
scale: r
|
|
288
289
|
}, a) {
|
|
289
|
-
const { mapView: o } =
|
|
290
|
-
return await
|
|
290
|
+
const { mapView: o } = k(a);
|
|
291
|
+
return await tr(e, o, { zoom: t, scale: r });
|
|
291
292
|
}
|
|
292
|
-
const
|
|
293
|
-
center:
|
|
294
|
-
longitude:
|
|
295
|
-
latitude:
|
|
293
|
+
const ar = i.object({
|
|
294
|
+
center: i.object({
|
|
295
|
+
longitude: i.number().describe("The longitude (x-coordinate) of the point to navigate to."),
|
|
296
|
+
latitude: i.number().describe("The latitude (y-coordinate) of the point to navigate to.")
|
|
296
297
|
}),
|
|
297
|
-
zoom:
|
|
298
|
-
scale:
|
|
299
|
-
}),
|
|
298
|
+
zoom: i.number().optional().describe("The zoom level. Higher values = more zoomed in."),
|
|
299
|
+
scale: i.number().optional().describe("The map scale. Alternative to zoom. Smaller numbers = more zoomed in.")
|
|
300
|
+
}), or = b(rr, {
|
|
300
301
|
name: "goToViewpoint",
|
|
301
302
|
description: "Go to the specified viewpoint. This can contain a combination of scale, center, zoom, etc.",
|
|
302
|
-
schema:
|
|
303
|
+
schema: ar
|
|
303
304
|
});
|
|
304
|
-
async function
|
|
305
|
+
async function nr(e, t) {
|
|
305
306
|
return await t.goTo({ zoom: e }), `Successfully zoomed to: ${e}`;
|
|
306
307
|
}
|
|
307
|
-
async function
|
|
308
|
-
const { mapView: r } =
|
|
309
|
-
return await
|
|
308
|
+
async function sr({ zoom: e }, t) {
|
|
309
|
+
const { mapView: r } = k(t);
|
|
310
|
+
return await nr(e, r);
|
|
310
311
|
}
|
|
311
|
-
const
|
|
312
|
-
zoom:
|
|
313
|
-
}),
|
|
312
|
+
const ir = i.object({
|
|
313
|
+
zoom: i.number().min(1).max(20).describe("The zoom level of the view to go to.")
|
|
314
|
+
}), cr = b(sr, {
|
|
314
315
|
name: "goToZoom",
|
|
315
316
|
description: 'Go to the specified zoom level. If input is generic (e.g. "zoom in", then only zoom to the next appropriate level - increase level for zooming in and decrease for zooming out.).',
|
|
316
|
-
schema:
|
|
317
|
-
}),
|
|
318
|
-
Tt,
|
|
319
|
-
$t,
|
|
317
|
+
schema: ir
|
|
318
|
+
}), le = [
|
|
320
319
|
qt,
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
320
|
+
At,
|
|
321
|
+
Dt,
|
|
322
|
+
Gt,
|
|
323
|
+
Bt,
|
|
324
|
+
Zt,
|
|
325
|
+
er,
|
|
326
|
+
or,
|
|
327
|
+
cr
|
|
328
|
+
], Se = /* @__PURE__ */ Object.assign({
|
|
328
329
|
"../agents/arcgisKnowledge/prompts/arcgis_knowledge_current_lc_context.md": () => import("./arcgis_knowledge_current_lc_context-BIA49RO2.js").then((e) => e.default),
|
|
329
330
|
"../agents/arcgisKnowledge/prompts/arcgis_knowledge_intent_prompt.md": () => import("./arcgis_knowledge_intent_prompt-AaXBzNVW.js").then((e) => e.default),
|
|
330
331
|
"../agents/arcgisKnowledge/prompts/arcgis_knowledge_tool_prompt.md": () => import("./arcgis_knowledge_tool_prompt-459P6qrK.js").then((e) => e.default),
|
|
@@ -337,11 +338,11 @@ const er = s.object({
|
|
|
337
338
|
"../agents/navigation/prompts/navigation_tool_prompt.md": () => import("./navigation_tool_prompt-B-SYvVbG.js").then((e) => e.default)
|
|
338
339
|
});
|
|
339
340
|
async function L(e) {
|
|
340
|
-
const t = Object.entries(
|
|
341
|
+
const t = Object.entries(Se).find(([r]) => r.endsWith(`/${e}.md`));
|
|
341
342
|
if (!t)
|
|
342
343
|
throw new Error(`Prompt not found: ${e}
|
|
343
344
|
Available prompts:
|
|
344
|
-
${Object.keys(
|
|
345
|
+
${Object.keys(Se).join(`
|
|
345
346
|
`)}`);
|
|
346
347
|
return await t[1]();
|
|
347
348
|
}
|
|
@@ -352,63 +353,63 @@ const C = (e, t = 3) => {
|
|
|
352
353
|
const a = r.length > t ? r[r.length - t] : r[0];
|
|
353
354
|
return e.slice(a);
|
|
354
355
|
};
|
|
355
|
-
async function
|
|
356
|
-
const r = await L("navigation_tool_prompt"), { mapView: a } =
|
|
357
|
-
(
|
|
356
|
+
async function lr(e, t) {
|
|
357
|
+
const r = await L("navigation_tool_prompt"), { mapView: a } = k(t), o = a.map, n = e.vectorSearchLayerResults?.length > 0 ? e.vectorSearchLayerResults.map(
|
|
358
|
+
(h, f) => `${f + 1}. layerId=${h.id} | title=${h.title ?? ""} | name=${h.name ?? ""} | score=${h.score.toFixed(2)}`
|
|
358
359
|
).join(`
|
|
359
|
-
`) : "", c = e.vectorSearchFieldResults?.length > 0 ? JSON.stringify(e.vectorSearchFieldResults, null, 2) : "",
|
|
360
|
+
`) : "", c = e.vectorSearchFieldResults?.length > 0 ? JSON.stringify(e.vectorSearchFieldResults, null, 2) : "", s = e.intent === "goToBookmark" && o.bookmarks?.length ? `Available bookmarks:
|
|
360
361
|
${JSON.stringify(o.bookmarks, null, 2)}` : "", l = (e.intent === "goToLayer" || e.intent === "goToFeatures") && e.vectorSearchLayerResults?.length ? `Candidate layers:
|
|
361
362
|
${n}` : "", d = e.intent === "goToFeatures" && e.vectorSearchFieldResults?.length ? `Candidate fields:
|
|
362
363
|
${c}` : "", u = {
|
|
363
364
|
intent: e.intent,
|
|
364
|
-
bookmarksSection:
|
|
365
|
+
bookmarksSection: s,
|
|
365
366
|
layersSection: l,
|
|
366
367
|
fieldsSection: d,
|
|
367
368
|
currentZoom: a.zoom,
|
|
368
369
|
assignedTask: e.agentExecutionContext.assignedTask,
|
|
369
370
|
userRequest: e.agentExecutionContext.userRequest,
|
|
370
371
|
priorSteps: e.agentExecutionContext.priorSteps
|
|
371
|
-
}, p = await
|
|
372
|
+
}, p = await D({
|
|
372
373
|
promptText: r,
|
|
373
374
|
modelTier: "advanced",
|
|
374
375
|
messages: C(e.agentExecutionContext.messages),
|
|
375
376
|
inputVariables: u,
|
|
376
|
-
tools:
|
|
377
|
-
}),
|
|
378
|
-
return { ...e, agentExecutionContext: { ...e.agentExecutionContext, messages:
|
|
377
|
+
tools: le
|
|
378
|
+
}), m = [...e.agentExecutionContext.messages, p], E = (p.tool_calls?.length ?? 0) > 0 ? [...m] : [...m, p];
|
|
379
|
+
return { ...e, agentExecutionContext: { ...e.agentExecutionContext, messages: E } };
|
|
379
380
|
}
|
|
380
|
-
async function
|
|
381
|
-
const a = await new
|
|
381
|
+
async function dr(e, t) {
|
|
382
|
+
const a = await new P(le).invoke(
|
|
382
383
|
{
|
|
383
384
|
messages: C(e.agentExecutionContext.messages)
|
|
384
385
|
},
|
|
385
386
|
t
|
|
386
|
-
), o = a.messages.map((
|
|
387
|
+
), o = a.messages.map((s) => s.text).join(`
|
|
387
388
|
`);
|
|
388
389
|
await g({ text: `Finished executing navigation tool: ${o}` }, t);
|
|
389
|
-
const n = [...e.agentExecutionContext.messages, ...a.messages], c = a.messages.map((
|
|
390
|
+
const n = [...e.agentExecutionContext.messages, ...a.messages], c = a.messages.map((s) => s.text).join(`
|
|
390
391
|
`);
|
|
391
392
|
return { ...e, agentExecutionContext: { ...e.agentExecutionContext, messages: n }, outputMessage: c };
|
|
392
393
|
}
|
|
393
|
-
async function
|
|
394
|
-
const r = await L("navigation_intent_prompt"), { mapView: a } =
|
|
394
|
+
async function ur(e, t) {
|
|
395
|
+
const r = await L("navigation_intent_prompt"), { mapView: a } = k(t), o = le.map((p) => ({
|
|
395
396
|
name: p.name,
|
|
396
397
|
description: p.description,
|
|
397
398
|
schema: p.schema
|
|
398
399
|
})), n = a.map, c = n.bookmarks?.length ? `Available bookmarks:
|
|
399
|
-
${JSON.stringify(n.bookmarks, null, 2)}` : "",
|
|
400
|
-
tools: o.map(({ name: p, description:
|
|
400
|
+
${JSON.stringify(n.bookmarks, null, 2)}` : "", s = {
|
|
401
|
+
tools: o.map(({ name: p, description: m, schema: y }) => `${p}: ${m}, ${JSON.stringify(y)}`).join(`
|
|
401
402
|
`),
|
|
402
403
|
bookmarks: c,
|
|
403
404
|
assignedTask: e.agentExecutionContext.assignedTask,
|
|
404
405
|
userRequest: e.agentExecutionContext.userRequest,
|
|
405
406
|
priorSteps: e.agentExecutionContext.priorSteps
|
|
406
|
-
}, l =
|
|
407
|
-
intent:
|
|
408
|
-
}), d = await
|
|
407
|
+
}, l = i.object({
|
|
408
|
+
intent: i.string()
|
|
409
|
+
}), d = await Re({
|
|
409
410
|
promptText: r,
|
|
410
411
|
messages: C(e.agentExecutionContext.messages),
|
|
411
|
-
inputVariables:
|
|
412
|
+
inputVariables: s,
|
|
412
413
|
schema: l
|
|
413
414
|
}), u = typeof d.intent == "string" ? d.intent.trim().replace(/^"|"$/gu, "") : "";
|
|
414
415
|
return { ...e, intent: u || "" };
|
|
@@ -418,7 +419,7 @@ const x = (e, t) => {
|
|
|
418
419
|
if (a == null)
|
|
419
420
|
throw new Error(`${t} missing in config.configurable.services`);
|
|
420
421
|
return a;
|
|
421
|
-
},
|
|
422
|
+
}, pr = 0.7, mr = async (e, t) => {
|
|
422
423
|
try {
|
|
423
424
|
await g(
|
|
424
425
|
{ text: `Similarity search to find layers: ${e.agentExecutionContext.assignedTask}` },
|
|
@@ -426,7 +427,7 @@ const x = (e, t) => {
|
|
|
426
427
|
);
|
|
427
428
|
const r = x(t, "layerSearch"), a = x(t, "layersAndFieldsRegistry"), o = x(t, "embeddingCache"), c = (await r.searchLayers({
|
|
428
429
|
text: e.agentExecutionContext.assignedTask,
|
|
429
|
-
minScore:
|
|
430
|
+
minScore: pr,
|
|
430
431
|
embeddingCache: o
|
|
431
432
|
})).map(({ id: l, score: d }) => {
|
|
432
433
|
const u = a.get(l)?.layerItem;
|
|
@@ -437,10 +438,10 @@ const x = (e, t) => {
|
|
|
437
438
|
score: d
|
|
438
439
|
};
|
|
439
440
|
});
|
|
440
|
-
let
|
|
441
|
-
return c.length > 0 ?
|
|
441
|
+
let s;
|
|
442
|
+
return c.length > 0 ? s = `Vector search completed. Matching layers:
|
|
442
443
|
${c.map((l) => `- layerId=${l.id} | title=${l.title ?? ""} | name=${l.name ?? ""} | score=${l.score.toFixed(2)}`).join(`
|
|
443
|
-
`)}` :
|
|
444
|
+
`)}` : s = "Vector search completed. No matching layers found.", await g({ text: s }, t), {
|
|
444
445
|
...e,
|
|
445
446
|
vectorSearchLayerResults: c
|
|
446
447
|
};
|
|
@@ -450,7 +451,7 @@ ${c.map((l) => `- layerId=${l.id} | title=${l.title ?? ""} | name=${l.name ?? ""
|
|
|
450
451
|
t
|
|
451
452
|
), r;
|
|
452
453
|
}
|
|
453
|
-
},
|
|
454
|
+
}, ve = 0.7, hr = 10, gr = async (e, t) => {
|
|
454
455
|
try {
|
|
455
456
|
await g(
|
|
456
457
|
{ text: `Similarity search to find fields: ${e.agentExecutionContext.assignedTask}` },
|
|
@@ -459,22 +460,22 @@ ${c.map((l) => `- layerId=${l.id} | title=${l.title ?? ""} | name=${l.name ?? ""
|
|
|
459
460
|
const r = x(t, "fieldSearch"), a = x(t, "layersAndFieldsRegistry"), o = x(t, "embeddingCache"), n = e.vectorSearchLayerResults?.map((d) => d.id) ?? [];
|
|
460
461
|
if (n.length === 0)
|
|
461
462
|
return await g({ text: "No candidate layers for field search" }, t), e;
|
|
462
|
-
const
|
|
463
|
+
const s = (await r.searchFields({
|
|
463
464
|
text: e.agentExecutionContext.assignedTask,
|
|
464
465
|
layerIds: n,
|
|
465
|
-
minScore:
|
|
466
|
-
topResults:
|
|
466
|
+
minScore: ve,
|
|
467
|
+
topResults: hr,
|
|
467
468
|
embeddingCache: o
|
|
468
469
|
})).map(({ layerId: d, results: u }) => {
|
|
469
470
|
const p = a.get(d)?.fieldRegistry;
|
|
470
471
|
return {
|
|
471
472
|
layerId: d,
|
|
472
473
|
layerName: a.get(d)?.layerItem.name,
|
|
473
|
-
results: u.map((
|
|
474
|
-
const y = p?.get(
|
|
474
|
+
results: u.map((m) => {
|
|
475
|
+
const y = p?.get(m.name);
|
|
475
476
|
return {
|
|
476
|
-
name:
|
|
477
|
-
score:
|
|
477
|
+
name: m.name,
|
|
478
|
+
score: m.score,
|
|
478
479
|
type: y?.type,
|
|
479
480
|
alias: y?.alias,
|
|
480
481
|
description: y?.description,
|
|
@@ -484,15 +485,15 @@ ${c.map((l) => `- layerId=${l.id} | title=${l.title ?? ""} | name=${l.name ?? ""
|
|
|
484
485
|
};
|
|
485
486
|
});
|
|
486
487
|
let l;
|
|
487
|
-
return
|
|
488
|
-
${
|
|
488
|
+
return s.length > 0 ? l = `Vector search completed. Matching layers and fields:
|
|
489
|
+
${s.map(
|
|
489
490
|
(d) => `${d.layerName ?? d.layerId}:
|
|
490
491
|
${d.results.map((u) => ` - ${u.name} (${u.score.toFixed(2)})`).join(`
|
|
491
492
|
`)}`
|
|
492
493
|
).join(`
|
|
493
|
-
`)}` : l = `No vector search field results found for score over ${
|
|
494
|
+
`)}` : l = `No vector search field results found for score over ${ve}.`, await g({ text: l }, t), {
|
|
494
495
|
...e,
|
|
495
|
-
vectorSearchFieldResults:
|
|
496
|
+
vectorSearchFieldResults: s
|
|
496
497
|
};
|
|
497
498
|
} catch (r) {
|
|
498
499
|
throw await g(
|
|
@@ -506,7 +507,7 @@ ${d.results.map((u) => ` - ${u.name} (${u.score.toFixed(2)})`).join(`
|
|
|
506
507
|
if (!o?.[n])
|
|
507
508
|
throw new Error(`${t} requires services.${n} to be available.`);
|
|
508
509
|
return r;
|
|
509
|
-
},
|
|
510
|
+
}, yr = (e, t) => Q(["layerSearch", "layersAndFieldsRegistry"], "Navigation Agent")(e, t), fr = () => new V(Ne).addNode("requireNavigationServices", yr).addNode("intentLLM", ur).addNode("vectorSearchLayers", mr).addNode("vectorSearchFields", gr).addNode("agent", lr).addNode("tools", dr).addEdge(W, "requireNavigationServices").addEdge("requireNavigationServices", "intentLLM").addConditionalEdges(
|
|
510
511
|
"intentLLM",
|
|
511
512
|
(t) => t.intent === "goToLayer" || t.intent === "goToFeatures" ? "vectorSearchLayers" : "agent",
|
|
512
513
|
{
|
|
@@ -520,7 +521,7 @@ ${d.results.map((u) => ` - ${u.name} (${u.score.toFixed(2)})`).join(`
|
|
|
520
521
|
vectorSearchFields: "vectorSearchFields",
|
|
521
522
|
agent: "agent"
|
|
522
523
|
}
|
|
523
|
-
).addEdge("vectorSearchFields", "agent").addEdge("agent", "tools").addEdge("tools",
|
|
524
|
+
).addEdge("vectorSearchFields", "agent").addEdge("agent", "tools").addEdge("tools", q), wr = String.raw`- **navigation** — Enables users to interact with the map by navigating to specific locations, layers, features, or extents.
|
|
524
525
|
This includes zooming, panning, centering, or geocoding based on user input. The agent is designed to handle explicit map movement requests. NOTE: DO NOT call this agent if the user asks "show me...", that is meant to be handled by another agent. If the query is about where a certain address is, call this agent.
|
|
525
526
|
|
|
526
527
|
Supported actions:
|
|
@@ -539,13 +540,13 @@ ${d.results.map((u) => ` - ${u.name} (${u.score.toFixed(2)})`).join(`
|
|
|
539
540
|
_Example: “Center the map on San Francisco at scale 50000”_
|
|
540
541
|
_Example: “Zoom to the features in the schools layer where city = 'Austin'”_
|
|
541
542
|
_Example: “Go to the Downtown bookmark”_
|
|
542
|
-
_Example: “Where is Mount Rainier?”_`,
|
|
543
|
+
_Example: “Where is Mount Rainier?”_`, qs = {
|
|
543
544
|
id: "navigation",
|
|
544
545
|
name: "Navigation Agent",
|
|
545
|
-
description:
|
|
546
|
-
createGraph:
|
|
547
|
-
workspace:
|
|
548
|
-
},
|
|
546
|
+
description: wr,
|
|
547
|
+
createGraph: fr,
|
|
548
|
+
workspace: Ne
|
|
549
|
+
}, Ae = w.Root({
|
|
549
550
|
// Execution context provided by the orchestrator for this agent invocation.
|
|
550
551
|
agentExecutionContext: w({
|
|
551
552
|
reducer: K,
|
|
@@ -562,18 +563,18 @@ ${d.results.map((u) => ` - ${u.name} (${u.score.toFixed(2)})`).join(`
|
|
|
562
563
|
default: () => ""
|
|
563
564
|
}),
|
|
564
565
|
summary: w({
|
|
565
|
-
reducer:
|
|
566
|
+
reducer: j,
|
|
566
567
|
default: () => ""
|
|
567
568
|
}),
|
|
568
569
|
status: w({
|
|
569
|
-
reducer:
|
|
570
|
+
reducer: j,
|
|
570
571
|
default: () => "success"
|
|
571
572
|
}),
|
|
572
573
|
vectorSearchLayerIds: w(),
|
|
573
574
|
vectorSearchFieldResults: w(),
|
|
574
575
|
layerFieldInfo: w(),
|
|
575
576
|
queryResponse: w()
|
|
576
|
-
}),
|
|
577
|
+
}), br = async (e, t) => (await g({ text: "Exiting Data Exploration agent" }, t), e), de = async (e, t) => {
|
|
577
578
|
const r = e.tool_calls ?? [];
|
|
578
579
|
if (r.length === 0) {
|
|
579
580
|
await g({ text: `LLM did not request any tool calls: ${String(e?.content)}` }, t);
|
|
@@ -587,55 +588,55 @@ ${d.results.map((u) => ` - ${u.name} (${u.score.toFixed(2)})`).join(`
|
|
|
587
588
|
)
|
|
588
589
|
)
|
|
589
590
|
);
|
|
590
|
-
},
|
|
591
|
-
function
|
|
591
|
+
}, xr = ["mapView"];
|
|
592
|
+
function A(e) {
|
|
592
593
|
const r = e?.configurable?.context;
|
|
593
594
|
if (!r || typeof r != "object")
|
|
594
595
|
throw new Error("DataExplorationAgent context missing");
|
|
595
|
-
const a =
|
|
596
|
+
const a = xr.filter((o) => !(o in r));
|
|
596
597
|
if (a.length)
|
|
597
598
|
throw new Error(`DataExplorationAgent context missing: ${a.join(", ")}`);
|
|
598
599
|
return r;
|
|
599
600
|
}
|
|
600
|
-
const
|
|
601
|
+
const Sr = (e) => {
|
|
601
602
|
const t = e.map?.allLayers.filter((a) => a.type === "feature");
|
|
602
603
|
let r = 0;
|
|
603
604
|
return t?.forEach((a) => {
|
|
604
605
|
const o = a;
|
|
605
606
|
o.featureEffect && (o.featureEffect = null, r++);
|
|
606
607
|
}), r > 0 ? `Cleared filters from ${r} layer(s). View unchanged.` : "No active filters to clear. View unchanged.";
|
|
607
|
-
},
|
|
608
|
-
const { mapView: r } =
|
|
609
|
-
return
|
|
610
|
-
},
|
|
608
|
+
}, vr = async (e, t) => {
|
|
609
|
+
const { mapView: r } = A(t);
|
|
610
|
+
return Sr(r);
|
|
611
|
+
}, Tr = b(vr, {
|
|
611
612
|
name: "clearFilters",
|
|
612
613
|
description: "Clears all feature effects/filters from the map but does NOT change the current view. Use when user says 'clear filters', 'reset filters', 'remove filters', 'show all features', or wants to remove emphasis without navigating anywhere.",
|
|
613
|
-
schema:
|
|
614
|
-
}),
|
|
614
|
+
schema: i.object({})
|
|
615
|
+
}), Er = async (e) => {
|
|
615
616
|
e.map?.allLayers.filter((o) => o.type === "feature")?.forEach((o) => {
|
|
616
617
|
const n = o;
|
|
617
618
|
n.featureEffect && (n.featureEffect = null);
|
|
618
619
|
});
|
|
619
620
|
const a = e.map.initialViewProperties?.viewpoint?.targetGeometry;
|
|
620
621
|
return a ? (await e.goTo(a), "Cleared all filters and returned to home extent.") : "Cleared all filters. Could not determine home extent.";
|
|
621
|
-
},
|
|
622
|
-
const { mapView: r } =
|
|
623
|
-
return await
|
|
624
|
-
},
|
|
622
|
+
}, Cr = async (e, t) => {
|
|
623
|
+
const { mapView: r } = A(t);
|
|
624
|
+
return await Er(r);
|
|
625
|
+
}, Rr = b(Cr, {
|
|
625
626
|
name: "resetMap",
|
|
626
627
|
description: "Clears all feature effects/filters from the map AND zooms to the home extent (initial map view). Use when user says 'reset map', 'reset the map', 'start over', or wants to both clear filters and return to the initial view.",
|
|
627
|
-
schema:
|
|
628
|
+
schema: i.object({})
|
|
628
629
|
});
|
|
629
|
-
function
|
|
630
|
+
function J(e) {
|
|
630
631
|
return "point" in e && e.point !== void 0;
|
|
631
632
|
}
|
|
632
633
|
function O(e) {
|
|
633
634
|
return "layerId" in e && e.layerId !== void 0;
|
|
634
635
|
}
|
|
635
|
-
const
|
|
636
|
-
if (
|
|
636
|
+
const re = async (e, t) => {
|
|
637
|
+
if (J(e)) {
|
|
637
638
|
const { point: r } = e;
|
|
638
|
-
return { geometry: new
|
|
639
|
+
return { geometry: new ie({
|
|
639
640
|
x: r.x,
|
|
640
641
|
y: r.y,
|
|
641
642
|
spatialReference: r.spatialReference ? { wkid: r.spatialReference.wkid } : t.spatialReference
|
|
@@ -664,7 +665,7 @@ const X = async (e, t) => {
|
|
|
664
665
|
return { error: "The geometry of the first feature is undefined or null." };
|
|
665
666
|
o = n;
|
|
666
667
|
} else {
|
|
667
|
-
const n = a.features.map((
|
|
668
|
+
const n = a.features.map((s) => s.geometry), c = tt.executeMany(n);
|
|
668
669
|
if (!c)
|
|
669
670
|
return { error: "Failed to create a combined geometry." };
|
|
670
671
|
o = c;
|
|
@@ -675,17 +676,17 @@ const X = async (e, t) => {
|
|
|
675
676
|
}
|
|
676
677
|
}
|
|
677
678
|
return { error: "Invalid geometry configuration provided" };
|
|
678
|
-
},
|
|
679
|
+
}, $r = async (e, t, r, a, o, n) => {
|
|
679
680
|
const c = e.map?.allLayers.find((l) => l.id === t);
|
|
680
681
|
if (!c)
|
|
681
682
|
return { success: !1, error: `Layer '${t}' not found.` };
|
|
682
|
-
const
|
|
683
|
-
|
|
683
|
+
const s = c.createQuery();
|
|
684
|
+
s.where = r ?? "1=1", a && (s.geometry = a, s.spatialRelationship = "intersects", o && (s.distance = o), n && (s.units = n));
|
|
684
685
|
try {
|
|
685
|
-
const { extent: l, count: d } = await c.queryExtent(
|
|
686
|
+
const { extent: l, count: d } = await c.queryExtent(s);
|
|
686
687
|
return !l || d === 0 ? {
|
|
687
688
|
success: !1,
|
|
688
|
-
error: `No features found for filter (where: ${
|
|
689
|
+
error: `No features found for filter (where: ${s.where}${a ? ", spatial filter used" : ""})`
|
|
689
690
|
} : (await e.goTo(l), { success: !0 });
|
|
690
691
|
} catch (l) {
|
|
691
692
|
return {
|
|
@@ -693,23 +694,23 @@ const X = async (e, t) => {
|
|
|
693
694
|
error: l instanceof Error ? l.message : String(l)
|
|
694
695
|
};
|
|
695
696
|
}
|
|
696
|
-
},
|
|
697
|
+
}, kr = async (e, t, r, a, o, n) => {
|
|
697
698
|
const c = t.map?.allLayers.find(
|
|
698
699
|
(p) => p.id === e.layerId
|
|
699
700
|
);
|
|
700
701
|
if (!c)
|
|
701
702
|
return `Could not find target layer with ID: ${e.layerId}`;
|
|
702
|
-
let
|
|
703
|
+
let s;
|
|
703
704
|
if (o) {
|
|
704
|
-
const p = await
|
|
705
|
+
const p = await re(o, t);
|
|
705
706
|
if ("error" in p)
|
|
706
707
|
return p.error;
|
|
707
|
-
|
|
708
|
+
s = p.geometry;
|
|
708
709
|
}
|
|
709
|
-
if (c.featureEffect = null, c.featureEffect = new
|
|
710
|
-
filter: new
|
|
710
|
+
if (c.featureEffect = null, c.featureEffect = new et({
|
|
711
|
+
filter: new Fe({
|
|
711
712
|
...e.objectIds?.length ? { objectIds: e.objectIds } : { where: e.where },
|
|
712
|
-
geometry:
|
|
713
|
+
geometry: s,
|
|
713
714
|
spatialRelationship: "intersects",
|
|
714
715
|
distance: o?.distance,
|
|
715
716
|
units: o?.units
|
|
@@ -718,190 +719,226 @@ const X = async (e, t) => {
|
|
|
718
719
|
excludedEffect: a
|
|
719
720
|
}), c.visible = !0, n)
|
|
720
721
|
return `Applied feature effects to "${c.title ?? e.layerId}" within current map extent.`;
|
|
721
|
-
const l = e.objectIds?.length ? `${c.objectIdField} IN (${e.objectIds.join(",")})` : e.where, d = await
|
|
722
|
+
const l = e.objectIds?.length ? `${c.objectIdField} IN (${e.objectIds.join(",")})` : e.where, d = await $r(
|
|
722
723
|
t,
|
|
723
724
|
e.layerId,
|
|
724
725
|
l,
|
|
725
|
-
|
|
726
|
+
s,
|
|
726
727
|
o?.distance,
|
|
727
728
|
o?.units
|
|
728
729
|
), u = c.title ?? e.layerId;
|
|
729
730
|
return d.success ? `Applied feature effects to target layer "${c.title ?? e.layerId}"${o && "layerId" in o ? ` using geometry from layer "${o.layerId}"` : ""}.` : `Applied filter to "${u}" but no features matched. ${d.error}`;
|
|
730
|
-
},
|
|
731
|
+
}, Fr = ["feet", "kilometers", "meters", "miles", "nautical-miles", "us-nautical-miles"], z = i.enum(Fr), qr = async ({
|
|
731
732
|
targetLayer: e,
|
|
732
733
|
geometryFilter: t,
|
|
733
734
|
useCurrentExtent: r,
|
|
734
735
|
includedEffect: a = "drop-shadow(2px, 2px, 2px, gray)",
|
|
735
736
|
excludedEffect: o = "grayscale(100%) opacity(60%) blur(2px)"
|
|
736
737
|
}, n) => {
|
|
737
|
-
const { mapView: c } =
|
|
738
|
-
return await
|
|
739
|
-
},
|
|
740
|
-
layerId:
|
|
741
|
-
where:
|
|
742
|
-
distance:
|
|
743
|
-
units:
|
|
744
|
-
}),
|
|
745
|
-
point:
|
|
746
|
-
x:
|
|
747
|
-
y:
|
|
748
|
-
spatialReference:
|
|
749
|
-
wkid:
|
|
738
|
+
const { mapView: c } = A(n);
|
|
739
|
+
return await kr(e, c, a, o, t, r);
|
|
740
|
+
}, Lr = i.object({
|
|
741
|
+
layerId: i.string().describe("The layerId of the layer containing the geometry by which to filter."),
|
|
742
|
+
where: i.string().describe("The SQL-92 where clause representing the features from which to filter."),
|
|
743
|
+
distance: i.number().optional().describe("The buffer distance around the geometry."),
|
|
744
|
+
units: z.optional().describe("The units for the distance buffer.")
|
|
745
|
+
}), Ir = i.object({
|
|
746
|
+
point: i.object({
|
|
747
|
+
x: i.number().describe("X coordinate (longitude) from navigation result"),
|
|
748
|
+
y: i.number().describe("Y coordinate (latitude) from navigation result"),
|
|
749
|
+
spatialReference: i.object({
|
|
750
|
+
wkid: i.number().describe("Spatial reference WKID (e.g., 4326 for WGS84)")
|
|
750
751
|
}).optional().describe("Spatial reference. Defaults to map's spatial reference if not provided.")
|
|
751
752
|
}).describe("Point coordinates from a previous navigation/geocoding result"),
|
|
752
|
-
distance:
|
|
753
|
-
units:
|
|
754
|
-
}),
|
|
755
|
-
targetLayer:
|
|
756
|
-
layerId:
|
|
757
|
-
where:
|
|
758
|
-
objectIds:
|
|
753
|
+
distance: i.number().optional().describe("Optional buffer distance around the point."),
|
|
754
|
+
units: z.optional().describe("The units for the distance buffer.")
|
|
755
|
+
}), Nr = i.object({
|
|
756
|
+
targetLayer: i.object({
|
|
757
|
+
layerId: i.string().describe("The layerId of the layer on which to set a feature effect."),
|
|
758
|
+
where: i.string().describe("The SQL-92 where clause representing the features to emphasize."),
|
|
759
|
+
objectIds: i.array(i.number()).optional().describe(
|
|
759
760
|
"Array of objectIds from a previous query result. Use this instead of a where clause when the query returned objectIds (e.g. top N results). If provided, takes precedence over where clause."
|
|
760
761
|
)
|
|
761
762
|
}),
|
|
762
|
-
geometryFilter:
|
|
763
|
-
useCurrentExtent:
|
|
763
|
+
geometryFilter: i.union([Lr, Ir]).optional().describe("Optional geometry-based filtering parameters for spatial queries."),
|
|
764
|
+
useCurrentExtent: i.boolean().optional().describe(
|
|
764
765
|
"Set to true when the previous query used the current map extent as a spatial filter. This ensures the feature effect applies only to features visible in the current view. Default is false."
|
|
765
766
|
),
|
|
766
|
-
includedEffect:
|
|
767
|
+
includedEffect: i.string().default("drop-shadow(2px, 2px, 2px, gray)").describe(
|
|
767
768
|
"The effect applied to features that meet the filter requirements. Valid effects include: bloom, blur, brightness, contrast, drop-shadow, grayscale, hue-rotate, invert, opacity, saturate, and sepia. Prefer default unless specified."
|
|
768
769
|
),
|
|
769
|
-
excludedEffect:
|
|
770
|
+
excludedEffect: i.string().default("grayscale(100%) opacity(60%) blur(2px)").describe(
|
|
770
771
|
"The effect applied to features that do not meet the filter requirements. Valid effects include: bloom, blur, brightness, contrast, drop-shadow, grayscale, hue-rotate, invert, opacity, saturate, and sepia. Prefer default unless specified."
|
|
771
772
|
)
|
|
772
|
-
}),
|
|
773
|
+
}), Ar = b(qr, {
|
|
773
774
|
name: "setFeatureEffect",
|
|
774
775
|
description: "Sets a feature effect on a given layer with given filter parameters and feature effects to emphasize certain features that meet a filter requirement. If no feature effect information is provided, then use the default effect provided.",
|
|
775
|
-
schema:
|
|
776
|
-
}),
|
|
776
|
+
schema: Nr
|
|
777
|
+
}), Y = (e, t, r) => {
|
|
777
778
|
if (e && typeof e != "function") {
|
|
778
779
|
const a = "getField" in r && r.getField?.(e), o = a && "getFieldDomain" in r && r.getFieldDomain ? r.getFieldDomain(a.name) : null;
|
|
779
780
|
if (o?.type === "coded-value") {
|
|
780
|
-
const c = o.codedValues.find((
|
|
781
|
+
const c = o.codedValues.find((s) => s.code === t);
|
|
781
782
|
return c ? c.name : null;
|
|
782
783
|
}
|
|
783
784
|
}
|
|
784
785
|
return null;
|
|
785
|
-
},
|
|
786
|
+
}, zr = /* @__PURE__ */ new Set(["date", "date-only", "time-only", "timestamp-offset"]), se = (e) => {
|
|
787
|
+
if (e instanceof Date)
|
|
788
|
+
return Number.isNaN(e.getTime()) ? null : e;
|
|
789
|
+
if (typeof e == "number" && Number.isFinite(e)) {
|
|
790
|
+
const t = new Date(e);
|
|
791
|
+
return Number.isNaN(t.getTime()) ? null : t;
|
|
792
|
+
}
|
|
793
|
+
return null;
|
|
794
|
+
}, _r = (e) => !e || e === "system" ? Intl.DateTimeFormat().resolvedOptions().timeZone : e === "unknown" ? "UTC" : e, jr = (e) => {
|
|
795
|
+
if (typeof e == "string" && e)
|
|
796
|
+
return e;
|
|
797
|
+
const t = se(e);
|
|
798
|
+
return t ? t.toISOString().slice(0, 10) : null;
|
|
799
|
+
}, ze = () => {
|
|
800
|
+
const e = (/* @__PURE__ */ new Date()).getTimezoneOffset(), t = e <= 0 ? "+" : "-", r = Math.floor(Math.abs(e) / 60).toString().padStart(2, "0"), a = (Math.abs(e) % 60).toString().padStart(2, "0"), o = `${t}${r}:${a}`;
|
|
801
|
+
return { userTimezone: Intl.DateTimeFormat().resolvedOptions().timeZone, userTimezoneOffset: o };
|
|
802
|
+
}, X = (e) => e ? zr.has(e.toLowerCase()) : !1, ee = (e, t, r) => {
|
|
803
|
+
const a = t?.toLowerCase();
|
|
804
|
+
if (a === "date-only") {
|
|
805
|
+
const n = jr(e);
|
|
806
|
+
return n ? rt(n, U("short-date")) : e;
|
|
807
|
+
}
|
|
808
|
+
if (a === "time-only") {
|
|
809
|
+
if (typeof e == "string" && e)
|
|
810
|
+
return at(e, U("long-time"));
|
|
811
|
+
const n = se(e);
|
|
812
|
+
return n ? fe(n, {
|
|
813
|
+
...U("long-time"),
|
|
814
|
+
timeZone: "UTC"
|
|
815
|
+
}) : e;
|
|
816
|
+
}
|
|
817
|
+
const o = se(e);
|
|
818
|
+
return o ? fe(o, {
|
|
819
|
+
...U("short-date-short-time"),
|
|
820
|
+
timeZone: _r(r)
|
|
821
|
+
}) : e;
|
|
822
|
+
}, Dr = (e, t, r) => {
|
|
786
823
|
const a = e.createQuery();
|
|
787
824
|
return a.outFields = [t], a.where = r || "1=1", a.num = 1, a;
|
|
788
|
-
},
|
|
789
|
-
const o = a.map?.allLayers.find((
|
|
825
|
+
}, Pr = async (e, t, r, a) => {
|
|
826
|
+
const o = a.map?.allLayers.find((y) => y.id === e), n = Dr(o, t, r.where), s = (await o.queryFeatures(n)).features[0], l = s ? s.attributes[t] : null, d = o.fields.find((y) => y.name === t), u = Y(t, l, o) || l, p = d && X(d.type) ? ee(u, d.type, a.timeZone) : u;
|
|
790
827
|
return {
|
|
791
828
|
tool: "getAttribute",
|
|
792
829
|
layerName: o.title ?? e,
|
|
793
|
-
summary: `${t} = ${
|
|
830
|
+
summary: `${t} = ${p}`,
|
|
794
831
|
details: {
|
|
795
832
|
fieldName: t,
|
|
796
|
-
value:
|
|
833
|
+
value: p,
|
|
797
834
|
where: r.where
|
|
798
835
|
}
|
|
799
836
|
};
|
|
800
837
|
};
|
|
801
|
-
async function
|
|
802
|
-
const { mapView: o } =
|
|
838
|
+
async function Mr({ layerId: e, fieldName: t, query: r }, a) {
|
|
839
|
+
const { mapView: o } = A(a), n = await Pr(e, t, r, o);
|
|
803
840
|
return JSON.stringify(n, null, 2);
|
|
804
841
|
}
|
|
805
|
-
const
|
|
806
|
-
layerId:
|
|
807
|
-
fieldName:
|
|
808
|
-
query:
|
|
809
|
-
where:
|
|
842
|
+
const Or = i.object({
|
|
843
|
+
layerId: i.string().describe("The layerId of the layer containing the field from which to get a value."),
|
|
844
|
+
fieldName: i.string().describe("The name of the field/attribute from which to get a field value."),
|
|
845
|
+
query: i.object({
|
|
846
|
+
where: i.string().describe("The SQL-92 where clause representing the feature from which to get an attribute value.")
|
|
810
847
|
})
|
|
811
|
-
}),
|
|
848
|
+
}), Gr = b(Mr, {
|
|
812
849
|
name: "getAttribute",
|
|
813
850
|
description: "Returns an attribute value for a given feature.",
|
|
814
|
-
schema:
|
|
815
|
-
}),
|
|
816
|
-
function
|
|
851
|
+
schema: Or
|
|
852
|
+
}), ue = (e, t, r) => r ? e.hasAllFeaturesInView && e.availableFields === t : e.hasAllFeatures && e.availableFields === t;
|
|
853
|
+
function te(e, t) {
|
|
817
854
|
let r = e ?? "";
|
|
818
855
|
return t != null && t && (r = r ? `(${r}) AND (${t})` : t), r || null;
|
|
819
856
|
}
|
|
820
|
-
const
|
|
821
|
-
const { targetLayer: t, fieldName: r, statisticType: a, mapView: o, layersAndFieldsRegistry: n, geometryFilter: c } = e,
|
|
822
|
-
if (!
|
|
857
|
+
const Vr = async (e) => {
|
|
858
|
+
const { targetLayer: t, fieldName: r, statisticType: a, mapView: o, layersAndFieldsRegistry: n, geometryFilter: c } = e, s = o.map?.allLayers.find((T) => T.id === t.layerId);
|
|
859
|
+
if (!s)
|
|
823
860
|
throw new Error(`Layer '${t.layerId}' not found.`);
|
|
824
|
-
const l = await o.whenLayerView(
|
|
861
|
+
const l = await o.whenLayerView(s), u = n.get(t.layerId)?.fieldRegistry.get(r), p = u?.alias;
|
|
825
862
|
if (!u)
|
|
826
863
|
throw new Error(`Field '${r}' not found.`);
|
|
827
|
-
let
|
|
864
|
+
let m, y;
|
|
828
865
|
if (c) {
|
|
829
|
-
const
|
|
830
|
-
if ("error" in
|
|
831
|
-
throw new Error(
|
|
832
|
-
if (!
|
|
866
|
+
const T = await re(c, o);
|
|
867
|
+
if ("error" in T)
|
|
868
|
+
throw new Error(T.error);
|
|
869
|
+
if (!T.geometry)
|
|
833
870
|
throw O(c) ? new Error(`No features found matching: ${c.where}`) : new Error("Failed to create geometry");
|
|
834
|
-
O(c) ?
|
|
871
|
+
O(c) ? m = {
|
|
835
872
|
geometryLayerId: c.layerId,
|
|
836
873
|
geometryWhere: c.where,
|
|
837
874
|
distance: c.distance,
|
|
838
875
|
units: c.units,
|
|
839
876
|
applied: !0
|
|
840
|
-
} :
|
|
877
|
+
} : J(c) && (m = {
|
|
841
878
|
point: c.point,
|
|
842
879
|
distance: c.distance,
|
|
843
880
|
units: c.units,
|
|
844
881
|
applied: !0
|
|
845
|
-
}), y = new
|
|
846
|
-
geometry:
|
|
882
|
+
}), y = new Fe({
|
|
883
|
+
geometry: T.geometry,
|
|
847
884
|
distance: c.distance,
|
|
848
885
|
units: c.units,
|
|
849
886
|
spatialRelationship: "intersects"
|
|
850
887
|
});
|
|
851
888
|
}
|
|
852
|
-
const
|
|
853
|
-
let
|
|
854
|
-
const
|
|
889
|
+
const E = ue(l, [r], !1);
|
|
890
|
+
let h = null, f = null;
|
|
891
|
+
const S = 10;
|
|
855
892
|
if (u.type !== "geometry" && u.type !== "oid" && u.type !== "global-id")
|
|
856
893
|
try {
|
|
857
|
-
const
|
|
858
|
-
layer:
|
|
859
|
-
useFeaturesInView:
|
|
860
|
-
view:
|
|
894
|
+
const T = {
|
|
895
|
+
layer: s,
|
|
896
|
+
useFeaturesInView: E,
|
|
897
|
+
view: E ? o : void 0,
|
|
861
898
|
field: r,
|
|
862
|
-
sqlWhere:
|
|
899
|
+
sqlWhere: te(s.definitionExpression, t.where),
|
|
863
900
|
...y && { filter: y },
|
|
864
901
|
outStatisticTypes: { include: [a] }
|
|
865
902
|
};
|
|
866
|
-
|
|
867
|
-
const
|
|
868
|
-
(
|
|
869
|
-
layer:
|
|
870
|
-
useFeaturesInView:
|
|
871
|
-
view:
|
|
903
|
+
h = await qe(T);
|
|
904
|
+
const R = ["string", "small-integer", "integer"], M = u.domain?.type === "coded-value" ? u.domain : null;
|
|
905
|
+
(R.includes(u.type) || M) && (f = (await Le({
|
|
906
|
+
layer: s,
|
|
907
|
+
useFeaturesInView: E,
|
|
908
|
+
view: E ? o : void 0,
|
|
872
909
|
field: r,
|
|
873
|
-
sqlWhere:
|
|
910
|
+
sqlWhere: te(s.definitionExpression, t.where),
|
|
874
911
|
...y && { filter: y }
|
|
875
|
-
})).uniqueValueInfos.sort((
|
|
876
|
-
...
|
|
877
|
-
value:
|
|
912
|
+
})).uniqueValueInfos.sort((I, Ue) => Ue.count - I.count).slice(0, S)), f && u.domain?.type === "coded-value" && (f = f.map((I) => ({
|
|
913
|
+
...I,
|
|
914
|
+
value: M ? M.getName(I.value) ?? I.value : I.value
|
|
878
915
|
})));
|
|
879
|
-
} catch (
|
|
880
|
-
console.error("Statistics error:",
|
|
916
|
+
} catch (T) {
|
|
917
|
+
console.error("Statistics error:", T);
|
|
881
918
|
}
|
|
882
919
|
return {
|
|
883
920
|
tool: "getStatistics",
|
|
884
|
-
layerName:
|
|
885
|
-
summary: `${a} = ${typeof
|
|
921
|
+
layerName: s.title ?? t.layerId,
|
|
922
|
+
summary: `${a} = ${typeof h?.[a] == "number" ? h[a] : "N/A"}`,
|
|
886
923
|
details: {
|
|
887
924
|
fieldName: r,
|
|
888
925
|
fieldAlias: p,
|
|
889
926
|
statisticType: a,
|
|
890
|
-
statistic:
|
|
891
|
-
summaryStatistics:
|
|
927
|
+
statistic: h?.[a] ?? null,
|
|
928
|
+
summaryStatistics: h,
|
|
892
929
|
uniqueValues: f,
|
|
893
930
|
where: t.where,
|
|
894
|
-
spatialFilterInfo:
|
|
931
|
+
spatialFilterInfo: m
|
|
895
932
|
}
|
|
896
933
|
};
|
|
897
934
|
};
|
|
898
|
-
async function
|
|
935
|
+
async function Wr({
|
|
899
936
|
targetLayer: e,
|
|
900
937
|
fieldName: t,
|
|
901
938
|
statisticType: r,
|
|
902
939
|
geometryFilter: a
|
|
903
940
|
}, o) {
|
|
904
|
-
const n = x(o, "layersAndFieldsRegistry"), { mapView: c } =
|
|
941
|
+
const n = x(o, "layersAndFieldsRegistry"), { mapView: c } = A(o), s = await Vr({
|
|
905
942
|
targetLayer: e,
|
|
906
943
|
fieldName: t,
|
|
907
944
|
statisticType: r,
|
|
@@ -909,34 +946,34 @@ async function Nr({
|
|
|
909
946
|
layersAndFieldsRegistry: n,
|
|
910
947
|
geometryFilter: a
|
|
911
948
|
});
|
|
912
|
-
return JSON.stringify(
|
|
913
|
-
}
|
|
914
|
-
const
|
|
915
|
-
layerId:
|
|
916
|
-
where:
|
|
917
|
-
distance:
|
|
918
|
-
units:
|
|
919
|
-
}),
|
|
920
|
-
point:
|
|
921
|
-
x:
|
|
922
|
-
y:
|
|
923
|
-
spatialReference:
|
|
924
|
-
wkid:
|
|
949
|
+
return JSON.stringify(s, null, 2);
|
|
950
|
+
}
|
|
951
|
+
const Kr = i.object({
|
|
952
|
+
layerId: i.string().describe("The layerId of the layer containing the geometry by which to filter."),
|
|
953
|
+
where: i.string().describe("The SQL-92 where clause representing the features from which to filter."),
|
|
954
|
+
distance: i.number().optional().describe("The buffer distance around the geometry."),
|
|
955
|
+
units: z.optional().describe("The units for the distance buffer.")
|
|
956
|
+
}), Br = i.object({
|
|
957
|
+
point: i.object({
|
|
958
|
+
x: i.number().describe("X coordinate (longitude) from navigation result"),
|
|
959
|
+
y: i.number().describe("Y coordinate (latitude) from navigation result"),
|
|
960
|
+
spatialReference: i.object({
|
|
961
|
+
wkid: i.number().describe("Spatial reference WKID (e.g., 4326 for WGS84)")
|
|
925
962
|
}).optional().describe("Spatial reference. Defaults to map's spatial reference if not provided.")
|
|
926
963
|
}).describe("Point coordinates from a previous navigation/geocoding result"),
|
|
927
|
-
distance:
|
|
928
|
-
units:
|
|
929
|
-
}),
|
|
930
|
-
targetLayer:
|
|
931
|
-
layerId:
|
|
932
|
-
where:
|
|
964
|
+
distance: i.number().optional().describe("Optional buffer distance around the point."),
|
|
965
|
+
units: z.optional().describe("The units for the distance buffer.")
|
|
966
|
+
}), Qr = i.object({
|
|
967
|
+
targetLayer: i.object({
|
|
968
|
+
layerId: i.string().describe("The layerId of the layer containing the field from which to get a value."),
|
|
969
|
+
where: i.string().describe("The SQL-92 where clause representing the feature from which to get an attribute value.")
|
|
933
970
|
}),
|
|
934
|
-
geometryFilter:
|
|
971
|
+
geometryFilter: i.union([Kr, Br]).optional().describe(
|
|
935
972
|
"Geometry filter for spatial queries. Use 'point' option with x/y coordinates from navigation results to find features at that location (point-in-polygon). Use 'layerId/where' option to filter by features from another layer."
|
|
936
973
|
),
|
|
937
|
-
fieldName:
|
|
938
|
-
statisticType:
|
|
939
|
-
}),
|
|
974
|
+
fieldName: i.string().describe("The name of the field for which to get statistics. STRICTLY DO NOT use OBJECTID. Use any other field"),
|
|
975
|
+
statisticType: i.enum(["avg", "max", "median", "min", "stddev", "sum", "variance", "nullcount", "count"]).describe("The statistic type to calculate.")
|
|
976
|
+
}), Ur = b(Wr, {
|
|
940
977
|
name: "getStatistics",
|
|
941
978
|
description: `Computes a single aggregate statistic (max, min, avg, sum, median, stddev, variance) for a numeric field across matching features. Also returns frequency analysis for categorical fields.
|
|
942
979
|
|
|
@@ -951,35 +988,35 @@ DO NOT USE FOR:
|
|
|
951
988
|
- Simple counts of features matching a condition — use queryFeatures instead
|
|
952
989
|
|
|
953
990
|
Only call this tool when the answer requires computing an aggregate (avg, max, min, sum, median, stddev) over a field's values, not just counting or listing features.`,
|
|
954
|
-
schema:
|
|
955
|
-
}),
|
|
956
|
-
const n = r.map?.allLayers.find((
|
|
991
|
+
schema: Qr
|
|
992
|
+
}), Hr = async (e, t, r, a, o) => {
|
|
993
|
+
const n = r.map?.allLayers.find((m) => m.id === e.layerId), c = await r.whenLayerView(n), s = n.title ?? e.layerId;
|
|
957
994
|
let l;
|
|
958
995
|
if (a) {
|
|
959
|
-
const
|
|
960
|
-
if ("error" in
|
|
996
|
+
const m = await re(a, r);
|
|
997
|
+
if ("error" in m)
|
|
961
998
|
return {
|
|
962
999
|
tool: "getTopFeatures",
|
|
963
|
-
layerName:
|
|
1000
|
+
layerName: s,
|
|
964
1001
|
summary: "Geometry lookup failed",
|
|
965
|
-
details: { error:
|
|
1002
|
+
details: { error: m.error }
|
|
966
1003
|
};
|
|
967
|
-
if (!
|
|
1004
|
+
if (!m.geometry)
|
|
968
1005
|
return {
|
|
969
1006
|
tool: "getTopFeatures",
|
|
970
|
-
layerName:
|
|
1007
|
+
layerName: s,
|
|
971
1008
|
summary: "No features found for geometry filter",
|
|
972
1009
|
details: {
|
|
973
1010
|
error: `No features found matching: ${"where" in a ? a.where : "unknown criteria"}`
|
|
974
1011
|
}
|
|
975
1012
|
};
|
|
976
|
-
l =
|
|
1013
|
+
l = m.geometry;
|
|
977
1014
|
} else o && (l = r.extent.clone());
|
|
978
1015
|
const d = t.groupByFields && t.groupByFields.length > 0, u = n.objectIdField, p = e.outFields.includes("*") ? ["*"] : [.../* @__PURE__ */ new Set([...e.outFields, u])];
|
|
979
1016
|
try {
|
|
980
|
-
let
|
|
1017
|
+
let m;
|
|
981
1018
|
if (d) {
|
|
982
|
-
const
|
|
1019
|
+
const h = new ot({
|
|
983
1020
|
where: e.where || "1=1",
|
|
984
1021
|
outFields: p,
|
|
985
1022
|
orderByFields: e.orderByFields,
|
|
@@ -987,41 +1024,41 @@ Only call this tool when the answer requires computing an aggregate (avg, max, m
|
|
|
987
1024
|
spatialRelationship: l ? "intersects" : void 0,
|
|
988
1025
|
distance: a?.distance,
|
|
989
1026
|
units: a?.units,
|
|
990
|
-
topFilter: new
|
|
1027
|
+
topFilter: new nt({
|
|
991
1028
|
topCount: t.topCount,
|
|
992
1029
|
groupByFields: t.groupByFields,
|
|
993
1030
|
orderByFields: t.orderByFields
|
|
994
1031
|
})
|
|
995
1032
|
});
|
|
996
|
-
|
|
1033
|
+
m = await n.queryTopFeatures(h);
|
|
997
1034
|
} else {
|
|
998
|
-
const
|
|
999
|
-
|
|
1000
|
-
const f =
|
|
1035
|
+
const h = n.createQuery();
|
|
1036
|
+
h.where = te(n.definitionExpression, e.where || "1=1"), h.outFields = p.length ? p : ["*"], h.orderByFields = t.orderByFields, h.num = t.topCount, l && (h.geometry = l, h.spatialRelationship = "intersects"), a?.distance && (h.distance = a.distance), a?.units && (h.units = a.units), h.outSpatialReference = r.spatialReference;
|
|
1037
|
+
const f = ue(c, e.outFields, o ?? !1);
|
|
1001
1038
|
try {
|
|
1002
|
-
|
|
1003
|
-
} catch (
|
|
1004
|
-
console.warn("Client-side query failed, falling back to server:",
|
|
1039
|
+
m = f ? await c.queryFeatures(h) : await n.queryFeatures(h);
|
|
1040
|
+
} catch (S) {
|
|
1041
|
+
console.warn("Client-side query failed, falling back to server:", S), m = await n.queryFeatures(h);
|
|
1005
1042
|
}
|
|
1006
1043
|
}
|
|
1007
|
-
const y =
|
|
1008
|
-
const f =
|
|
1009
|
-
return n.fields.forEach((
|
|
1010
|
-
if (
|
|
1011
|
-
v
|
|
1044
|
+
const y = m.features.map((h) => h.attributes[u]), E = m.features.map((h) => {
|
|
1045
|
+
const f = h.attributes, S = {};
|
|
1046
|
+
return n.fields.forEach((v) => {
|
|
1047
|
+
if (v.name === n.objectIdField) {
|
|
1048
|
+
S[v.name] = f[v.name];
|
|
1012
1049
|
return;
|
|
1013
1050
|
}
|
|
1014
|
-
const
|
|
1015
|
-
|
|
1016
|
-
}),
|
|
1051
|
+
const T = f[v.name], R = Y(v.name, T, n), M = v.alias || v.name, I = R ?? T;
|
|
1052
|
+
S[M] = X(v.type) ? ee(I, v.type, r.timeZone) : I;
|
|
1053
|
+
}), S;
|
|
1017
1054
|
});
|
|
1018
1055
|
return {
|
|
1019
1056
|
tool: "getTopFeatures",
|
|
1020
|
-
layerName:
|
|
1057
|
+
layerName: s,
|
|
1021
1058
|
summary: `Top ${t.topCount} features extracted`,
|
|
1022
1059
|
details: {
|
|
1023
1060
|
topCount: t.topCount,
|
|
1024
|
-
attributes:
|
|
1061
|
+
attributes: E,
|
|
1025
1062
|
objectIds: y,
|
|
1026
1063
|
objectIdField: u,
|
|
1027
1064
|
where: e.where,
|
|
@@ -1029,110 +1066,110 @@ Only call this tool when the answer requires computing an aggregate (avg, max, m
|
|
|
1029
1066
|
...d && { groupByFields: t.groupByFields }
|
|
1030
1067
|
}
|
|
1031
1068
|
};
|
|
1032
|
-
} catch (
|
|
1069
|
+
} catch (m) {
|
|
1033
1070
|
return {
|
|
1034
1071
|
tool: "getTopFeatures",
|
|
1035
|
-
layerName:
|
|
1072
|
+
layerName: s,
|
|
1036
1073
|
summary: "Query failed",
|
|
1037
|
-
details: { error:
|
|
1074
|
+
details: { error: m instanceof Error ? m.message : String(m) }
|
|
1038
1075
|
};
|
|
1039
1076
|
}
|
|
1040
|
-
},
|
|
1077
|
+
}, Zr = async ({
|
|
1041
1078
|
targetLayer: e,
|
|
1042
1079
|
topFilter: t,
|
|
1043
1080
|
geometryFilter: r,
|
|
1044
1081
|
useCurrentExtent: a
|
|
1045
1082
|
}, o) => {
|
|
1046
|
-
const { mapView: n } =
|
|
1083
|
+
const { mapView: n } = A(o), c = await Hr(e, t, n, r, a);
|
|
1047
1084
|
return JSON.stringify(c, null, 2);
|
|
1048
|
-
},
|
|
1049
|
-
layerId:
|
|
1050
|
-
where:
|
|
1051
|
-
distance:
|
|
1052
|
-
units:
|
|
1053
|
-
}),
|
|
1054
|
-
point:
|
|
1055
|
-
x:
|
|
1056
|
-
y:
|
|
1057
|
-
spatialReference:
|
|
1058
|
-
wkid:
|
|
1085
|
+
}, Jr = i.object({
|
|
1086
|
+
layerId: i.string().describe("The layerId of the layer containing the geometry by which to filter."),
|
|
1087
|
+
where: i.string().describe("The SQL-92 where clause representing the features from which to filter."),
|
|
1088
|
+
distance: i.number().optional().describe("The buffer distance around the geometry."),
|
|
1089
|
+
units: z.optional().describe("The units for the distance buffer.")
|
|
1090
|
+
}), Yr = i.object({
|
|
1091
|
+
point: i.object({
|
|
1092
|
+
x: i.number().describe("X coordinate (longitude) from navigation result"),
|
|
1093
|
+
y: i.number().describe("Y coordinate (latitude) from navigation result"),
|
|
1094
|
+
spatialReference: i.object({
|
|
1095
|
+
wkid: i.number().describe("Spatial reference WKID (e.g., 4326 for WGS84)")
|
|
1059
1096
|
}).optional().describe("Spatial reference. Defaults to map's spatial reference if not provided.")
|
|
1060
1097
|
}).describe("Point coordinates from a previous navigation/geocoding result"),
|
|
1061
|
-
distance:
|
|
1062
|
-
units:
|
|
1063
|
-
}),
|
|
1064
|
-
targetLayer:
|
|
1065
|
-
layerId:
|
|
1066
|
-
where:
|
|
1067
|
-
orderByFields:
|
|
1068
|
-
outFields:
|
|
1069
|
-
|
|
1098
|
+
distance: i.number().optional().describe("Optional buffer distance around the point."),
|
|
1099
|
+
units: z.optional().describe("The units for the distance buffer.")
|
|
1100
|
+
}), Xr = i.object({
|
|
1101
|
+
targetLayer: i.object({
|
|
1102
|
+
layerId: i.string().describe("The layerId of the layer containing the field from which to get a value."),
|
|
1103
|
+
where: i.string().describe("The SQL-92 where clause representing the feature from which to get an attribute value."),
|
|
1104
|
+
orderByFields: i.array(i.string().describe("The field(s) and order for which to sort the resulting features.")),
|
|
1105
|
+
outFields: i.array(
|
|
1106
|
+
i.string().describe(
|
|
1070
1107
|
'The fields to include in the output that will be presented to the user. This should include identifying information about the resulting features, like a name or id, along with the values desired in the output. If unsure, choose all fields ("*").'
|
|
1071
1108
|
).default("*")
|
|
1072
1109
|
)
|
|
1073
1110
|
}),
|
|
1074
|
-
geometryFilter:
|
|
1111
|
+
geometryFilter: i.union([Jr, Yr]).optional().describe(
|
|
1075
1112
|
"Geometry filter for spatial queries. Use 'point' option with x/y coordinates from navigation results to find features at that location (point-in-polygon). Use 'layerId/where' option to filter by features from another layer."
|
|
1076
1113
|
),
|
|
1077
|
-
topFilter:
|
|
1078
|
-
topCount:
|
|
1079
|
-
orderByFields:
|
|
1080
|
-
|
|
1114
|
+
topFilter: i.object({
|
|
1115
|
+
topCount: i.number().describe("Number of top features to return per group."),
|
|
1116
|
+
orderByFields: i.array(
|
|
1117
|
+
i.string().describe("Field(s) to rank by with ASC/DESC. Must be existing field names, not aggregate functions.")
|
|
1081
1118
|
),
|
|
1082
|
-
groupByFields:
|
|
1119
|
+
groupByFields: i.array(i.string().describe("Field(s) to group results by. Returns top N per group."))
|
|
1083
1120
|
}),
|
|
1084
|
-
useCurrentExtent:
|
|
1121
|
+
useCurrentExtent: i.boolean().optional().describe(
|
|
1085
1122
|
"Set to true ONLY when user explicitly asks about features 'in my view', 'on my map', 'I am looking at'. Default is false (queries entire layer)."
|
|
1086
1123
|
)
|
|
1087
|
-
}),
|
|
1124
|
+
}), ea = b(Zr, {
|
|
1088
1125
|
name: "getTopFeatures",
|
|
1089
1126
|
description: 'Returns top N features ranked by an existing field value. Use for "highest", "lowest", "top N" questions where ranking is based on a field that already exists in the data (e.g., population, value, date, depth). orderByFields must be actual field names with ASC/DESC. Do NOT use aggregate functions like COUNT(), SUM(), AVG() - those require getStatistics.',
|
|
1090
|
-
schema:
|
|
1091
|
-
}),
|
|
1092
|
-
const o = t.map?.allLayers.find((
|
|
1093
|
-
let
|
|
1127
|
+
schema: Xr
|
|
1128
|
+
}), ne = 25, ta = async (e, t, r, a) => {
|
|
1129
|
+
const o = t.map?.allLayers.find((h) => h.id === e.layerId), n = await t.whenLayerView(o), c = o.title ?? e.layerId;
|
|
1130
|
+
let s;
|
|
1094
1131
|
if (r) {
|
|
1095
|
-
const
|
|
1096
|
-
if ("error" in
|
|
1097
|
-
const f = { error:
|
|
1098
|
-
return O(r) ? (f.geometryLayerId = r.layerId, f.geometryWhere = r.where) :
|
|
1132
|
+
const h = await re(r, t);
|
|
1133
|
+
if ("error" in h) {
|
|
1134
|
+
const f = { error: h.error };
|
|
1135
|
+
return O(r) ? (f.geometryLayerId = r.layerId, f.geometryWhere = r.where) : J(r) && (f.point = r.point), {
|
|
1099
1136
|
tool: "queryFeatures",
|
|
1100
1137
|
layerName: c,
|
|
1101
1138
|
summary: "Geometry lookup failed",
|
|
1102
1139
|
details: f
|
|
1103
1140
|
};
|
|
1104
1141
|
}
|
|
1105
|
-
if (!
|
|
1142
|
+
if (!h.geometry) {
|
|
1106
1143
|
const f = {};
|
|
1107
|
-
return O(r) ? (f.error = `No features found matching: ${r.where}`, f.geometryLayerId = r.layerId, f.geometryWhere = r.where) :
|
|
1144
|
+
return O(r) ? (f.error = `No features found matching: ${r.where}`, f.geometryLayerId = r.layerId, f.geometryWhere = r.where) : J(r) && (f.error = "Failed to create point geometry", f.point = r.point), {
|
|
1108
1145
|
tool: "queryFeatures",
|
|
1109
1146
|
layerName: c,
|
|
1110
1147
|
summary: "No features found for geometry filter",
|
|
1111
1148
|
details: f
|
|
1112
1149
|
};
|
|
1113
1150
|
}
|
|
1114
|
-
|
|
1115
|
-
} else a && (
|
|
1116
|
-
const l =
|
|
1117
|
-
u.where =
|
|
1118
|
-
let p,
|
|
1151
|
+
s = h.geometry;
|
|
1152
|
+
} else a && (s = t.extent.clone());
|
|
1153
|
+
const l = ue(n, e.outFields, a ?? !1), d = o.objectIdField, u = o.createQuery();
|
|
1154
|
+
u.where = te(o.definitionExpression, e.where || "1=1"), u.outFields = e.outFields.includes("*") ? ["*"] : [.../* @__PURE__ */ new Set([...e.outFields, d])], u.orderByFields = e.orderByFields, s && (u.geometry = s, u.spatialRelationship = "intersects"), r?.distance && (u.distance = r.distance), r?.units && (u.units = r.units), u.outSpatialReference = t.spatialReference;
|
|
1155
|
+
let p, m;
|
|
1119
1156
|
try {
|
|
1120
|
-
p = l ? await n.queryFeatureCount(u) : await o.queryFeatureCount(u), p > 0 && p <=
|
|
1121
|
-
const f =
|
|
1122
|
-
o.fields.forEach((
|
|
1123
|
-
const
|
|
1124
|
-
|
|
1157
|
+
p = l ? await n.queryFeatureCount(u) : await o.queryFeatureCount(u), p > 0 && p <= ne && (m = l ? await n.queryFeatures(u) : await o.queryFeatures(u), m && m.features.forEach((h) => {
|
|
1158
|
+
const f = h.attributes;
|
|
1159
|
+
o.fields.forEach((S) => {
|
|
1160
|
+
const v = f[S.name], R = Y(S.name, v, o) ?? v;
|
|
1161
|
+
f[S.name] = X(S.type) ? ee(R, S.type, t.timeZone) : R;
|
|
1125
1162
|
});
|
|
1126
1163
|
}));
|
|
1127
|
-
} catch (
|
|
1128
|
-
console.warn("Client-side query failed, falling back to server:",
|
|
1129
|
-
o.fields.forEach((
|
|
1130
|
-
const
|
|
1131
|
-
|
|
1164
|
+
} catch (h) {
|
|
1165
|
+
console.warn("Client-side query failed, falling back to server:", h), p = await o.queryFeatureCount(u), p > 0 && p <= ne && (m = await o.queryFeatures(u), m && m.features.forEach((f) => {
|
|
1166
|
+
o.fields.forEach((S) => {
|
|
1167
|
+
const v = f.attributes[S.name], R = Y(S.name, v, o) ?? v;
|
|
1168
|
+
f.attributes[S.name] = X(S.type) ? ee(R, S.type, t.timeZone) : R;
|
|
1132
1169
|
});
|
|
1133
1170
|
}));
|
|
1134
1171
|
}
|
|
1135
|
-
const y =
|
|
1172
|
+
const y = m?.features.map((h) => h.attributes[d]), E = m?.features.map((h) => h.attributes);
|
|
1136
1173
|
return {
|
|
1137
1174
|
tool: "queryFeatures",
|
|
1138
1175
|
layerName: c,
|
|
@@ -1143,56 +1180,56 @@ Only call this tool when the answer requires computing an aggregate (avg, max, m
|
|
|
1143
1180
|
orderByFields: e.orderByFields,
|
|
1144
1181
|
outFields: e.outFields,
|
|
1145
1182
|
...y && { objectIds: y, objectIdField: d },
|
|
1146
|
-
...
|
|
1147
|
-
...p >
|
|
1183
|
+
...E && { attributes: E },
|
|
1184
|
+
...p > ne && {
|
|
1148
1185
|
note: `${p} features found.`
|
|
1149
1186
|
}
|
|
1150
1187
|
}
|
|
1151
1188
|
};
|
|
1152
1189
|
};
|
|
1153
|
-
async function
|
|
1190
|
+
async function ra({
|
|
1154
1191
|
targetLayer: e,
|
|
1155
1192
|
geometryFilter: t,
|
|
1156
1193
|
useCurrentExtent: r
|
|
1157
1194
|
}, a) {
|
|
1158
|
-
const { mapView: o } =
|
|
1195
|
+
const { mapView: o } = A(a), n = await ta(e, o, t, r);
|
|
1159
1196
|
return JSON.stringify(n, null, 2);
|
|
1160
1197
|
}
|
|
1161
|
-
const
|
|
1162
|
-
layerId:
|
|
1163
|
-
where:
|
|
1164
|
-
distance:
|
|
1165
|
-
units:
|
|
1166
|
-
}),
|
|
1167
|
-
point:
|
|
1168
|
-
x:
|
|
1169
|
-
y:
|
|
1170
|
-
spatialReference:
|
|
1171
|
-
wkid:
|
|
1198
|
+
const aa = i.object({
|
|
1199
|
+
layerId: i.string().describe("The layerId of the layer containing the geometry by which to filter."),
|
|
1200
|
+
where: i.string().describe("The SQL-92 where clause representing the features from which to filter."),
|
|
1201
|
+
distance: i.number().optional().describe("The buffer distance around the geometry."),
|
|
1202
|
+
units: z.optional().describe("The units for the distance buffer.")
|
|
1203
|
+
}), oa = i.object({
|
|
1204
|
+
point: i.object({
|
|
1205
|
+
x: i.number().describe("X coordinate (longitude) from navigation result"),
|
|
1206
|
+
y: i.number().describe("Y coordinate (latitude) from navigation result"),
|
|
1207
|
+
spatialReference: i.object({
|
|
1208
|
+
wkid: i.number().describe("Spatial reference WKID (e.g., 4326 for WGS84)")
|
|
1172
1209
|
}).optional().describe("Spatial reference. Defaults to map's spatial reference if not provided.")
|
|
1173
1210
|
}).describe("Point coordinates from a previous navigation/geocoding result"),
|
|
1174
|
-
distance:
|
|
1175
|
-
units:
|
|
1176
|
-
}),
|
|
1177
|
-
targetLayer:
|
|
1178
|
-
layerId:
|
|
1179
|
-
where:
|
|
1211
|
+
distance: i.number().optional().describe("Optional buffer distance around the point."),
|
|
1212
|
+
units: z.optional().describe("The units for the distance buffer.")
|
|
1213
|
+
}), na = i.object({
|
|
1214
|
+
targetLayer: i.object({
|
|
1215
|
+
layerId: i.string().describe("The layerId of the layer containing the field from which to get a value."),
|
|
1216
|
+
where: i.string().describe(
|
|
1180
1217
|
"SQL-92 where clause. IMPORTANT: When using geometryFilter.point for point-in-polygon queries, set this to '1=1' to return all features that intersect the point. Only add attribute filters if the user specifically requests them in addition to the spatial query."
|
|
1181
1218
|
),
|
|
1182
|
-
orderByFields:
|
|
1183
|
-
outFields:
|
|
1184
|
-
|
|
1219
|
+
orderByFields: i.array(i.string().describe("The field(s) and order for which to sort the resulting features.")),
|
|
1220
|
+
outFields: i.array(
|
|
1221
|
+
i.string().describe(
|
|
1185
1222
|
'The fields to include in the output that will be presented to the user. This should include identifying information about the resulting features, like a name or id, along with the values desired in the output. If unsure, choose all fields ("*").'
|
|
1186
1223
|
).default("*")
|
|
1187
1224
|
)
|
|
1188
1225
|
}),
|
|
1189
|
-
geometryFilter:
|
|
1226
|
+
geometryFilter: i.union([aa, oa]).optional().describe(
|
|
1190
1227
|
"Geometry filter for spatial queries. Use 'point' option with x/y coordinates from navigation results to find features at that location (point-in-polygon). Use 'layerId/where' option to filter by features from another layer."
|
|
1191
1228
|
),
|
|
1192
|
-
useCurrentExtent:
|
|
1229
|
+
useCurrentExtent: i.boolean().optional().describe(
|
|
1193
1230
|
"Set to true ONLY when user explicitly asks about features 'in my view', 'on my map', 'I am looking at', OR when the user refers back to features previously identified using the current extent (e.g. 'these', 'those', 'them', 'the same ones'). Default is false (queries entire layer)."
|
|
1194
1231
|
)
|
|
1195
|
-
}),
|
|
1232
|
+
}), sa = b(ra, {
|
|
1196
1233
|
name: "queryFeatures",
|
|
1197
1234
|
description: `Queries features from a layer. Returns the total count of matching features, plus individual feature attributes if ≤25 features match.
|
|
1198
1235
|
|
|
@@ -1204,16 +1241,13 @@ USE THIS TOOL FOR:
|
|
|
1204
1241
|
- Any question where the user wants to SEE or COUNT matching features
|
|
1205
1242
|
|
|
1206
1243
|
This is the DEFAULT tool for most queries. When in doubt, use this tool.`,
|
|
1207
|
-
schema:
|
|
1208
|
-
}),
|
|
1209
|
-
const e = (/* @__PURE__ */ new Date()).getTimezoneOffset(), t = e <= 0 ? "+" : "-", r = Math.floor(Math.abs(e) / 60).toString().padStart(2, "0"), a = (Math.abs(e) % 60).toString().padStart(2, "0"), o = `${t}${r}:${a}`;
|
|
1210
|
-
return { userTimezone: Intl.DateTimeFormat().resolvedOptions().timeZone, userTimezoneOffset: o };
|
|
1211
|
-
}, Jr = async (e, t) => {
|
|
1244
|
+
schema: na
|
|
1245
|
+
}), _e = [Gr, Ur, ea, sa], je = [Ar, Rr, Tr], ia = async (e, t) => {
|
|
1212
1246
|
await g({ text: "Requesting LLM for layer filter results" }, t);
|
|
1213
1247
|
const a = await L("data_explore_filter_prompt");
|
|
1214
1248
|
if (!t?.configurable)
|
|
1215
1249
|
throw new Error("config.configurable is required for layer filter tools");
|
|
1216
|
-
const { userTimezone: o, userTimezoneOffset: n } =
|
|
1250
|
+
const { userTimezone: o, userTimezoneOffset: n } = ze(), c = {
|
|
1217
1251
|
layerFieldInfo: e.layerFieldInfo,
|
|
1218
1252
|
userTimezone: o,
|
|
1219
1253
|
userTimezoneOffset: n,
|
|
@@ -1221,42 +1255,42 @@ This is the DEFAULT tool for most queries. When in doubt, use this tool.`,
|
|
|
1221
1255
|
assignedTask: e.agentExecutionContext.assignedTask,
|
|
1222
1256
|
userRequest: e.agentExecutionContext.userRequest,
|
|
1223
1257
|
priorSteps: e.agentExecutionContext.priorSteps
|
|
1224
|
-
},
|
|
1258
|
+
}, s = await D({
|
|
1225
1259
|
promptText: a,
|
|
1226
1260
|
modelTier: "advanced",
|
|
1227
1261
|
messages: C(e.agentExecutionContext.messages),
|
|
1228
1262
|
inputVariables: c,
|
|
1229
|
-
tools:
|
|
1230
|
-
}), l = [...e.agentExecutionContext.messages,
|
|
1231
|
-
if (!((
|
|
1263
|
+
tools: je
|
|
1264
|
+
}), l = [...e.agentExecutionContext.messages, s];
|
|
1265
|
+
if (!((s.tool_calls?.length ?? 0) > 0))
|
|
1232
1266
|
return await g({ text: "LLM determined no filter changes needed" }, t), {
|
|
1233
1267
|
...e,
|
|
1234
1268
|
agentExecutionContext: { ...e.agentExecutionContext, messages: l }
|
|
1235
1269
|
// Don't overwrite outputMessage if query already set it
|
|
1236
1270
|
};
|
|
1237
|
-
const u = [...l,
|
|
1238
|
-
return await
|
|
1239
|
-
},
|
|
1271
|
+
const u = [...l, s], p = s.content.toString();
|
|
1272
|
+
return await de(s, t), { ...e, agentExecutionContext: { ...e.agentExecutionContext, messages: u }, outputMessage: p };
|
|
1273
|
+
}, ca = async (e, t) => {
|
|
1240
1274
|
await g({ text: "Requesting LLM for layer query results" }, t);
|
|
1241
1275
|
const a = await L("data_explore_query_prompt");
|
|
1242
1276
|
if (!t?.configurable)
|
|
1243
1277
|
throw new Error("config.configurable is required for layer query tools");
|
|
1244
|
-
const { userTimezone: o, userTimezoneOffset: n } =
|
|
1278
|
+
const { userTimezone: o, userTimezoneOffset: n } = ze(), c = {
|
|
1245
1279
|
layerFieldInfo: e.layerFieldInfo,
|
|
1246
1280
|
userTimezone: o,
|
|
1247
1281
|
userTimezoneOffset: n,
|
|
1248
1282
|
assignedTask: e.agentExecutionContext.assignedTask,
|
|
1249
1283
|
userRequest: e.agentExecutionContext.userRequest,
|
|
1250
1284
|
priorSteps: e.agentExecutionContext.priorSteps
|
|
1251
|
-
},
|
|
1285
|
+
}, s = await D({
|
|
1252
1286
|
promptText: a,
|
|
1253
1287
|
modelTier: "advanced",
|
|
1254
1288
|
messages: C(e.agentExecutionContext.messages),
|
|
1255
1289
|
inputVariables: c,
|
|
1256
|
-
tools:
|
|
1257
|
-
}), l = [...e.agentExecutionContext.messages,
|
|
1258
|
-
return await
|
|
1259
|
-
},
|
|
1290
|
+
tools: _e
|
|
1291
|
+
}), l = [...e.agentExecutionContext.messages, s], d = s.content.toString();
|
|
1292
|
+
return await de(s, t), { ...e, agentExecutionContext: { ...e.agentExecutionContext, messages: l }, outputMessage: d };
|
|
1293
|
+
}, la = async (e, t) => {
|
|
1260
1294
|
try {
|
|
1261
1295
|
await g({ text: "Requesting LLM for summary on query results" }, t);
|
|
1262
1296
|
const a = await L("summarize_query_response_prompt"), o = {
|
|
@@ -1264,72 +1298,72 @@ This is the DEFAULT tool for most queries. When in doubt, use this tool.`,
|
|
|
1264
1298
|
assignedTask: e.agentExecutionContext.assignedTask,
|
|
1265
1299
|
userRequest: e.agentExecutionContext.userRequest,
|
|
1266
1300
|
priorSteps: e.agentExecutionContext.priorSteps
|
|
1267
|
-
}, n = await
|
|
1301
|
+
}, n = await Ze({
|
|
1268
1302
|
promptText: a,
|
|
1269
1303
|
modelTier: "fast",
|
|
1270
1304
|
messages: C(e.agentExecutionContext.messages),
|
|
1271
1305
|
inputVariables: o
|
|
1272
|
-
}), c = typeof n == "string" ? n : n.content,
|
|
1306
|
+
}), c = typeof n == "string" ? n : n.content, s = new ke(c);
|
|
1273
1307
|
return await g({ text: `Received response from LLM: ${c}` }, t), {
|
|
1274
1308
|
...e,
|
|
1275
1309
|
outputMessage: c,
|
|
1276
1310
|
agentExecutionContext: {
|
|
1277
1311
|
...e.agentExecutionContext,
|
|
1278
|
-
messages: [...e.agentExecutionContext.messages,
|
|
1312
|
+
messages: [...e.agentExecutionContext.messages, s]
|
|
1279
1313
|
}
|
|
1280
1314
|
};
|
|
1281
1315
|
} catch (r) {
|
|
1282
1316
|
throw await g({ text: "Error during filter LLM request" }, t), new Error(`Error during filter LLM request: ${r instanceof Error ? r.message : String(r)}`);
|
|
1283
1317
|
}
|
|
1284
1318
|
};
|
|
1285
|
-
async function
|
|
1286
|
-
const a = await new
|
|
1319
|
+
async function da(e, t) {
|
|
1320
|
+
const a = await new P(je).invoke(
|
|
1287
1321
|
{
|
|
1288
1322
|
messages: C(e.agentExecutionContext.messages)
|
|
1289
1323
|
},
|
|
1290
1324
|
t
|
|
1291
1325
|
), o = [...e.agentExecutionContext.messages, ...a.messages], n = a.messages.map(
|
|
1292
|
-
(
|
|
1293
|
-
content:
|
|
1326
|
+
(s) => new ke({
|
|
1327
|
+
content: s.content,
|
|
1294
1328
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
1295
|
-
additional_kwargs:
|
|
1329
|
+
additional_kwargs: s.additional_kwargs
|
|
1296
1330
|
})
|
|
1297
1331
|
);
|
|
1298
1332
|
await g(
|
|
1299
|
-
{ text: `Finished executing layer filter tool: ${a.messages.map((
|
|
1333
|
+
{ text: `Finished executing layer filter tool: ${a.messages.map((s) => s.content).join(", ")}` },
|
|
1300
1334
|
t
|
|
1301
1335
|
);
|
|
1302
1336
|
const c = [...o, ...n];
|
|
1303
1337
|
return { ...e, agentExecutionContext: { ...e.agentExecutionContext, messages: c } };
|
|
1304
1338
|
}
|
|
1305
|
-
const
|
|
1306
|
-
async function
|
|
1307
|
-
const { messages: r } = await
|
|
1339
|
+
const ua = new P(_e);
|
|
1340
|
+
async function pa(e, t) {
|
|
1341
|
+
const { messages: r } = await ua.invoke(
|
|
1308
1342
|
{ messages: C(e.agentExecutionContext.messages) },
|
|
1309
1343
|
t
|
|
1310
1344
|
), a = [], o = [];
|
|
1311
1345
|
for (const c of r) {
|
|
1312
|
-
const
|
|
1346
|
+
const s = c.content;
|
|
1313
1347
|
let l;
|
|
1314
|
-
typeof
|
|
1348
|
+
typeof s != "string" && (l = {
|
|
1315
1349
|
tool: c.name ?? "unknown",
|
|
1316
1350
|
layerName: "unknown",
|
|
1317
1351
|
summary: "Query failed",
|
|
1318
|
-
details: { error: "Skipping non-string tool output:", raw:
|
|
1352
|
+
details: { error: "Skipping non-string tool output:", raw: s }
|
|
1319
1353
|
});
|
|
1320
1354
|
try {
|
|
1321
|
-
typeof
|
|
1355
|
+
typeof s == "string" ? l = JSON.parse(s) : l = {
|
|
1322
1356
|
tool: c.name ?? "unknown",
|
|
1323
1357
|
layerName: "unknown",
|
|
1324
1358
|
summary: "Query failed",
|
|
1325
|
-
details: { error: "Invalid tool output type", raw:
|
|
1359
|
+
details: { error: "Invalid tool output type", raw: s }
|
|
1326
1360
|
};
|
|
1327
1361
|
} catch {
|
|
1328
1362
|
l = {
|
|
1329
1363
|
tool: c.name ?? "unknown",
|
|
1330
1364
|
layerName: "unknown",
|
|
1331
1365
|
summary: "Query failed",
|
|
1332
|
-
details: { error:
|
|
1366
|
+
details: { error: s }
|
|
1333
1367
|
};
|
|
1334
1368
|
}
|
|
1335
1369
|
a.push(l), l.details && typeof l.details == "object" && "error" in l.details ? o.push(`- ${l.tool}: Error - ${String(l.details.error)}`) : o.push(`- ${l.layerName}: ${l.summary}`);
|
|
@@ -1341,13 +1375,13 @@ async function ra(e, t) {
|
|
|
1341
1375
|
queryResponse: a
|
|
1342
1376
|
};
|
|
1343
1377
|
}
|
|
1344
|
-
const
|
|
1378
|
+
const ma = 10, ha = ["string", "small-integer", "integer"], ga = async (e, t) => {
|
|
1345
1379
|
let r = null, a = null;
|
|
1346
1380
|
try {
|
|
1347
1381
|
if (t.type !== "geometry" && t.type !== "oid" && t.type !== "global-id") {
|
|
1348
|
-
r = await
|
|
1382
|
+
r = await qe({ layer: e, field: t.name });
|
|
1349
1383
|
const o = t.domain?.type === "coded-value" ? t.domain : null;
|
|
1350
|
-
(
|
|
1384
|
+
(ha.includes(t.type) || o) && (a = (await Le({ layer: e, field: t.name })).uniqueValueInfos.sort((n, c) => c.count - n.count).slice(0, ma), o && (a = a.map((n) => ({
|
|
1351
1385
|
...n,
|
|
1352
1386
|
value: o.getName(n.value) ?? n.value
|
|
1353
1387
|
}))));
|
|
@@ -1360,57 +1394,57 @@ const aa = 10, oa = ["string", "small-integer", "integer"], na = async (e, t) =>
|
|
|
1360
1394
|
uniqueValues: a
|
|
1361
1395
|
};
|
|
1362
1396
|
};
|
|
1363
|
-
async function
|
|
1397
|
+
async function ya(e, t, r) {
|
|
1364
1398
|
const a = [], o = [];
|
|
1365
1399
|
for (const n of e) {
|
|
1366
|
-
let c = function(
|
|
1367
|
-
const y = t.get(
|
|
1400
|
+
let c = function(m) {
|
|
1401
|
+
const y = t.get(m)?.layerItem;
|
|
1368
1402
|
return y ? [
|
|
1369
1403
|
y.name && `Name: ${y.name}`,
|
|
1370
1404
|
y.title && `Title: ${y.title}`,
|
|
1371
1405
|
y.description && `Description: ${y.description}`
|
|
1372
|
-
].filter(Boolean).join(" | ") :
|
|
1406
|
+
].filter(Boolean).join(" | ") : m;
|
|
1373
1407
|
};
|
|
1374
|
-
const { layerId:
|
|
1408
|
+
const { layerId: s, results: l } = n, d = r.map?.allLayers.find((m) => m.id === s), u = t.get(s)?.fieldRegistry;
|
|
1375
1409
|
if (!u)
|
|
1376
1410
|
continue;
|
|
1377
|
-
let p = a.find((
|
|
1411
|
+
let p = a.find((m) => m.layerId === s);
|
|
1378
1412
|
p || (p = {
|
|
1379
|
-
layerId:
|
|
1380
|
-
layerSummary: c(
|
|
1413
|
+
layerId: s,
|
|
1414
|
+
layerSummary: c(s),
|
|
1381
1415
|
fieldInfos: []
|
|
1382
1416
|
}, a.push(p));
|
|
1383
|
-
for (const
|
|
1384
|
-
const y = u.get(
|
|
1417
|
+
for (const m of l) {
|
|
1418
|
+
const y = u.get(m.name);
|
|
1385
1419
|
if (!y)
|
|
1386
1420
|
continue;
|
|
1387
1421
|
if (!y.statistics) {
|
|
1388
|
-
const
|
|
1422
|
+
const h = ga(d, y).then((f) => {
|
|
1389
1423
|
u.set(y.name, { ...y, statistics: f }), y.statistics = f;
|
|
1390
1424
|
});
|
|
1391
|
-
o.push(
|
|
1425
|
+
o.push(h);
|
|
1392
1426
|
}
|
|
1393
1427
|
p.fieldInfos.push(y);
|
|
1394
1428
|
}
|
|
1395
1429
|
}
|
|
1396
1430
|
return await Promise.all(o), a;
|
|
1397
1431
|
}
|
|
1398
|
-
const
|
|
1432
|
+
const fa = async (e, t) => {
|
|
1399
1433
|
try {
|
|
1400
1434
|
await g({ text: "Getting statistics for vector search results" }, t);
|
|
1401
|
-
const r = x(t, "layersAndFieldsRegistry"), { mapView: a } =
|
|
1435
|
+
const r = x(t, "layersAndFieldsRegistry"), { mapView: a } = A(t), o = await ya(e.vectorSearchFieldResults, r, a);
|
|
1402
1436
|
return await g({ text: "Statistics retrieved" }, t), { ...e, layerFieldInfo: o };
|
|
1403
1437
|
} catch (r) {
|
|
1404
1438
|
throw await g({ text: "Error during fetching statistics" }, t), new Error(`Error during fetching statistics: ${r instanceof Error ? r.message : String(r)}`);
|
|
1405
1439
|
}
|
|
1406
|
-
},
|
|
1440
|
+
}, Te = 0.7, wa = 10, ba = async (e, t) => {
|
|
1407
1441
|
try {
|
|
1408
1442
|
await g({ text: "Similarity search to find fields" }, t);
|
|
1409
1443
|
const r = x(t, "fieldSearch"), a = x(t, "layersAndFieldsRegistry"), o = x(t, "embeddingCache"), n = await r.searchFields({
|
|
1410
1444
|
text: e.agentExecutionContext.assignedTask,
|
|
1411
1445
|
layerIds: e.vectorSearchLayerIds,
|
|
1412
|
-
minScore:
|
|
1413
|
-
topResults:
|
|
1446
|
+
minScore: Te,
|
|
1447
|
+
topResults: wa,
|
|
1414
1448
|
embeddingCache: o
|
|
1415
1449
|
}), c = n.map(({ layerId: l, results: d }) => {
|
|
1416
1450
|
const u = d.map((p) => ` - ${p.name} (${p.score.toFixed(2)})`).join(`
|
|
@@ -1419,9 +1453,9 @@ const sa = async (e, t) => {
|
|
|
1419
1453
|
${u}`;
|
|
1420
1454
|
}).join(`
|
|
1421
1455
|
`);
|
|
1422
|
-
let
|
|
1423
|
-
return n.length > 0 ?
|
|
1424
|
-
${c}` :
|
|
1456
|
+
let s;
|
|
1457
|
+
return n.length > 0 ? s = `Vector search completed. Matching layers and fields with scores:
|
|
1458
|
+
${c}` : s = `No vector search results found for score over ${Te}.`, await g({ text: s }, t), {
|
|
1425
1459
|
...e,
|
|
1426
1460
|
vectorSearchFieldResults: n
|
|
1427
1461
|
};
|
|
@@ -1431,7 +1465,7 @@ ${c}` : i = `No vector search results found for score over ${we}.`, await g({ te
|
|
|
1431
1465
|
t
|
|
1432
1466
|
), new Error(`Vector search failed: ${r instanceof Error ? r.message : String(r)}`);
|
|
1433
1467
|
}
|
|
1434
|
-
},
|
|
1468
|
+
}, xa = 0.7, Sa = async (e, t) => {
|
|
1435
1469
|
try {
|
|
1436
1470
|
await g(
|
|
1437
1471
|
{ text: `Similarity search to find layers: ${e.agentExecutionContext.assignedTask}` },
|
|
@@ -1439,13 +1473,13 @@ ${c}` : i = `No vector search results found for score over ${we}.`, await g({ te
|
|
|
1439
1473
|
);
|
|
1440
1474
|
const r = x(t, "layerSearch"), a = x(t, "layersAndFieldsRegistry"), o = x(t, "embeddingCache"), n = await r.searchLayers({
|
|
1441
1475
|
text: e.agentExecutionContext.assignedTask,
|
|
1442
|
-
minScore:
|
|
1476
|
+
minScore: xa,
|
|
1443
1477
|
embeddingCache: o
|
|
1444
|
-
}), c = n.map((d) => d.id),
|
|
1478
|
+
}), c = n.map((d) => d.id), s = n.map(({ id: d, score: u }) => `${a.get(d)?.layerItem.name ?? d} (${u.toFixed(2)})`).join(`
|
|
1445
1479
|
`);
|
|
1446
1480
|
let l;
|
|
1447
1481
|
return c.length > 0 ? l = `Vector search completed. Matching layers with scores:
|
|
1448
|
-
${
|
|
1482
|
+
${s}` : l = "Vector search completed. No matching layers found.", await g({ text: l }, t), {
|
|
1449
1483
|
...e,
|
|
1450
1484
|
vectorSearchLayerIds: c
|
|
1451
1485
|
};
|
|
@@ -1455,10 +1489,10 @@ ${i}` : l = "Vector search completed. No matching layers found.", await g({ text
|
|
|
1455
1489
|
t
|
|
1456
1490
|
), new Error(`Vector search failed: ${r instanceof Error ? r.message : String(r)}`);
|
|
1457
1491
|
}
|
|
1458
|
-
},
|
|
1492
|
+
}, va = (e, t) => Q(["layerSearch", "fieldSearch", "layersAndFieldsRegistry"], "Data Exploration Agent")(
|
|
1459
1493
|
e,
|
|
1460
1494
|
t
|
|
1461
|
-
),
|
|
1495
|
+
), Ta = () => new V(Ae).addNode("requireDataExplorationServices", va).addNode("vectorSearchLayers", Sa).addNode("vectorSearchFields", ba).addNode("fieldStatistics", fa).addNode("queryAgent", ca).addNode("queryTools", pa).addNode("summarizeQueryResponseLLM", la).addNode("filterAgent", ia).addNode("filterTools", da).addNode("earlyExit", br).addEdge(W, "requireDataExplorationServices").addEdge("requireDataExplorationServices", "vectorSearchLayers").addConditionalEdges(
|
|
1462
1496
|
"vectorSearchLayers",
|
|
1463
1497
|
(t) => t.vectorSearchLayerIds.length ? "vectorSearchFields" : "earlyExit"
|
|
1464
1498
|
).addConditionalEdges(
|
|
@@ -1467,7 +1501,7 @@ ${i}` : l = "Vector search completed. No matching layers found.", await g({ text
|
|
|
1467
1501
|
).addEdge("fieldStatistics", "queryAgent").addConditionalEdges("queryAgent", (t) => (t.agentExecutionContext.messages[t.agentExecutionContext.messages.length - 1]?.tool_calls?.length ?? 0) > 0 ? "queryTools" : "filterAgent").addConditionalEdges(
|
|
1468
1502
|
"queryTools",
|
|
1469
1503
|
(t) => t.queryResponse.length ? "summarizeQueryResponseLLM" : "filterAgent"
|
|
1470
|
-
).addEdge("summarizeQueryResponseLLM", "filterAgent").addConditionalEdges("filterAgent", (t) => (t.agentExecutionContext.messages[t.agentExecutionContext.messages.length - 1]?.tool_calls?.length ?? 0) > 0 ? "filterTools" :
|
|
1504
|
+
).addEdge("summarizeQueryResponseLLM", "filterAgent").addConditionalEdges("filterAgent", (t) => (t.agentExecutionContext.messages[t.agentExecutionContext.messages.length - 1]?.tool_calls?.length ?? 0) > 0 ? "filterTools" : q).addEdge("filterTools", q).addEdge("earlyExit", q), Ea = String.raw`- **data exploration** — User is asking about the feature layer’s data (e.g. counts, summaries, statistics, field values), either for all features, a subset based on a condition, or for a subset based on the current view. And/Or user wants to include or exclude features based on field values, or visually style features differently (e.g., highlight or deemphasize them).
|
|
1471
1505
|
The Data Exploration Agent will automatically zoom to the affected features for action taken by this agent. In this case, no need to call navigation tool separately.
|
|
1472
1506
|
_Example: “Only show stations where Brand is Shell”_
|
|
1473
1507
|
_Example: “Make Shell stations stand out on the map”_
|
|
@@ -1475,20 +1509,20 @@ ${i}` : l = "Vector search completed. No matching layers found.", await g({ text
|
|
|
1475
1509
|
This also includes questions that ask which feature meets a given condition or where a particular feature in the data is located (e.g., “Where is the spring with the highest elevation?”). However, this agent does not handle addresses.
|
|
1476
1510
|
_Example: “How many features are there?”_
|
|
1477
1511
|
_Example: “What’s the average population?”_
|
|
1478
|
-
_Example: “Which values are in the status field?”_`,
|
|
1512
|
+
_Example: “Which values are in the status field?”_`, Ls = {
|
|
1479
1513
|
id: "dataExploration",
|
|
1480
1514
|
name: "Data Exploration Agent",
|
|
1481
|
-
description:
|
|
1482
|
-
createGraph:
|
|
1483
|
-
workspace:
|
|
1484
|
-
},
|
|
1515
|
+
description: Ea,
|
|
1516
|
+
createGraph: Ta,
|
|
1517
|
+
workspace: Ae
|
|
1518
|
+
}, Ee = 0.7, Ca = 10, Ra = async (e, t) => {
|
|
1485
1519
|
try {
|
|
1486
1520
|
await g({ text: "Similarity search to find fields" }, t);
|
|
1487
1521
|
const r = x(t, "fieldSearch"), a = x(t, "layersAndFieldsRegistry"), o = x(t, "embeddingCache"), n = await r.searchFields({
|
|
1488
1522
|
text: e.agentExecutionContext.assignedTask,
|
|
1489
1523
|
layerIds: e.vectorSearchLayerIds,
|
|
1490
|
-
minScore:
|
|
1491
|
-
topResults:
|
|
1524
|
+
minScore: Ee,
|
|
1525
|
+
topResults: Ca,
|
|
1492
1526
|
embeddingCache: o
|
|
1493
1527
|
}), c = n.map(({ layerId: l, results: d }) => {
|
|
1494
1528
|
const u = d.map((p) => ` - ${p.name} (${p.score.toFixed(2)})`).join(`
|
|
@@ -1497,9 +1531,9 @@ ${i}` : l = "Vector search completed. No matching layers found.", await g({ text
|
|
|
1497
1531
|
${u}`;
|
|
1498
1532
|
}).join(`
|
|
1499
1533
|
`);
|
|
1500
|
-
let
|
|
1501
|
-
return n.length > 0 ?
|
|
1502
|
-
${c}` :
|
|
1534
|
+
let s;
|
|
1535
|
+
return n.length > 0 ? s = `Vector search completed. Matching layers and fields with scores:
|
|
1536
|
+
${c}` : s = `No vector search results found for score over ${Ee}.`, await g({ text: s }, t), {
|
|
1503
1537
|
...e,
|
|
1504
1538
|
vectorSearchFieldResults: n
|
|
1505
1539
|
};
|
|
@@ -1509,7 +1543,7 @@ ${c}` : i = `No vector search results found for score over ${be}.`, await g({ te
|
|
|
1509
1543
|
t
|
|
1510
1544
|
), new Error(`Vector search failed: ${r instanceof Error ? r.message : String(r)}`);
|
|
1511
1545
|
}
|
|
1512
|
-
},
|
|
1546
|
+
}, $a = 0.7, ka = async (e, t) => {
|
|
1513
1547
|
try {
|
|
1514
1548
|
await g(
|
|
1515
1549
|
{ text: `Similarity search to find layers: ${e.agentExecutionContext.assignedTask}` },
|
|
@@ -1517,12 +1551,12 @@ ${c}` : i = `No vector search results found for score over ${be}.`, await g({ te
|
|
|
1517
1551
|
);
|
|
1518
1552
|
const r = x(t, "layerSearch"), a = x(t, "layersAndFieldsRegistry"), o = await r.searchLayers({
|
|
1519
1553
|
text: e.agentExecutionContext.assignedTask,
|
|
1520
|
-
minScore:
|
|
1554
|
+
minScore: $a
|
|
1521
1555
|
}), n = o.map((l) => l.id), c = o.map(({ id: l, score: d }) => `${a.get(l)?.layerItem.name ?? l} (${d.toFixed(2)})`).join(`
|
|
1522
1556
|
`);
|
|
1523
|
-
let
|
|
1524
|
-
return n.length > 0 ?
|
|
1525
|
-
${c}` :
|
|
1557
|
+
let s;
|
|
1558
|
+
return n.length > 0 ? s = `Vector search completed. Matching layers with scores:
|
|
1559
|
+
${c}` : s = "Vector search completed. No matching layers found.", await g({ text: s }, t), {
|
|
1526
1560
|
...e,
|
|
1527
1561
|
vectorSearchLayerIds: n
|
|
1528
1562
|
};
|
|
@@ -1533,24 +1567,24 @@ ${c}` : i = "Vector search completed. No matching layers found.", await g({ text
|
|
|
1533
1567
|
), new Error(`Vector search failed: ${r instanceof Error ? r.message : String(r)}`);
|
|
1534
1568
|
}
|
|
1535
1569
|
};
|
|
1536
|
-
async function
|
|
1570
|
+
async function Fa(e) {
|
|
1537
1571
|
const { fields: t, layer: r, view: a, styleName: o, colorSchemeTags: n } = e;
|
|
1538
1572
|
let c;
|
|
1539
|
-
return n ? c =
|
|
1540
|
-
basemapTheme: await
|
|
1573
|
+
return n ? c = it({
|
|
1574
|
+
basemapTheme: await we(a),
|
|
1541
1575
|
geometryType: r.geometryType,
|
|
1542
1576
|
includedTags: n,
|
|
1543
1577
|
numColors: Math.min(t.length, 8)
|
|
1544
|
-
})[0] : c =
|
|
1545
|
-
basemapTheme: await
|
|
1578
|
+
})[0] : c = ct({
|
|
1579
|
+
basemapTheme: await we(a),
|
|
1546
1580
|
geometryType: r.geometryType,
|
|
1547
1581
|
numColors: Math.min(t.length, 8)
|
|
1548
1582
|
}).primaryScheme, {
|
|
1549
1583
|
layer: r,
|
|
1550
1584
|
view: a,
|
|
1551
|
-
attributes: t.map((
|
|
1552
|
-
field:
|
|
1553
|
-
label: r.fields.find((l) => l.name ===
|
|
1585
|
+
attributes: t.map((s) => ({
|
|
1586
|
+
field: s,
|
|
1587
|
+
label: r.fields.find((l) => l.name === s)?.alias ?? ""
|
|
1554
1588
|
})).slice(0, 8),
|
|
1555
1589
|
outlineOptimizationEnabled: !0,
|
|
1556
1590
|
sizeOptimizationEnabled: !0,
|
|
@@ -1558,10 +1592,10 @@ async function ba(e) {
|
|
|
1558
1592
|
pieChartScheme: c
|
|
1559
1593
|
};
|
|
1560
1594
|
}
|
|
1561
|
-
async function
|
|
1562
|
-
return await
|
|
1595
|
+
async function qa(e) {
|
|
1596
|
+
return await st(e);
|
|
1563
1597
|
}
|
|
1564
|
-
async function
|
|
1598
|
+
async function La({
|
|
1565
1599
|
arcgisMap: e,
|
|
1566
1600
|
arcgisMapView: t,
|
|
1567
1601
|
layerId: r,
|
|
@@ -1569,41 +1603,41 @@ async function Sa({
|
|
|
1569
1603
|
colorSchemes: o,
|
|
1570
1604
|
includeSize: n
|
|
1571
1605
|
}) {
|
|
1572
|
-
const c = t,
|
|
1573
|
-
if (!
|
|
1606
|
+
const c = t, s = e?.allLayers.find((u) => u.id === r);
|
|
1607
|
+
if (!s)
|
|
1574
1608
|
return `Could not find layer for id: ${r}`;
|
|
1575
1609
|
const d = {
|
|
1576
1610
|
styleName: n ? "chart-size" : "chart",
|
|
1577
1611
|
fields: a,
|
|
1578
|
-
layer:
|
|
1612
|
+
layer: s,
|
|
1579
1613
|
view: c,
|
|
1580
1614
|
colorSchemeTags: o
|
|
1581
1615
|
};
|
|
1582
1616
|
try {
|
|
1583
|
-
const u = await
|
|
1584
|
-
return
|
|
1617
|
+
const u = await Fa(d), p = await qa(u);
|
|
1618
|
+
return s.renderer = p.renderer, s.visible = !0, `Chart renderer applied to layer: ${s.title ?? s.id} using fields ${a.join(", ")}`;
|
|
1585
1619
|
} catch (u) {
|
|
1586
1620
|
return `Error applying chart renderer: ${u instanceof Error ? u.message : String(u)}`;
|
|
1587
1621
|
}
|
|
1588
1622
|
}
|
|
1589
|
-
const
|
|
1590
|
-
function
|
|
1623
|
+
const Ia = ["mapView"];
|
|
1624
|
+
function F(e) {
|
|
1591
1625
|
const r = e?.configurable?.context;
|
|
1592
1626
|
if (!r || typeof r != "object")
|
|
1593
1627
|
throw new Error("LayerStylingAgent context missing");
|
|
1594
|
-
const a =
|
|
1628
|
+
const a = Ia.filter((o) => !(o in r));
|
|
1595
1629
|
if (a.length)
|
|
1596
1630
|
throw new Error(`LayerStylingAgent context missing: ${a.join(", ")}`);
|
|
1597
1631
|
return r;
|
|
1598
1632
|
}
|
|
1599
|
-
async function
|
|
1633
|
+
async function Na({
|
|
1600
1634
|
layerId: e,
|
|
1601
1635
|
fields: t,
|
|
1602
1636
|
colorSchemes: r,
|
|
1603
1637
|
includeSize: a
|
|
1604
1638
|
}, o) {
|
|
1605
|
-
const { mapView: n } =
|
|
1606
|
-
return await
|
|
1639
|
+
const { mapView: n } = F(o);
|
|
1640
|
+
return await $({ type: "show-legend", data: { layerIds: [e] } }, o), await La({
|
|
1607
1641
|
arcgisMap: n.map,
|
|
1608
1642
|
arcgisMapView: n,
|
|
1609
1643
|
layerId: e,
|
|
@@ -1612,12 +1646,12 @@ async function Ta({
|
|
|
1612
1646
|
includeSize: a
|
|
1613
1647
|
});
|
|
1614
1648
|
}
|
|
1615
|
-
const
|
|
1616
|
-
layerId:
|
|
1617
|
-
fields:
|
|
1618
|
-
colorSchemes:
|
|
1619
|
-
includeSize:
|
|
1620
|
-
}),
|
|
1649
|
+
const Aa = i.object({
|
|
1650
|
+
layerId: i.string().describe("The id of the layer to apply the chart renderer to"),
|
|
1651
|
+
fields: i.array(i.string()).describe("The fields to use for the chart renderer (multiple numeric fields)"),
|
|
1652
|
+
colorSchemes: i.array(i.string()).optional().describe("Optional color scheme tags to use"),
|
|
1653
|
+
includeSize: i.boolean().optional().describe("Whether to vary the chart size (chart-size)")
|
|
1654
|
+
}), za = b(Na, {
|
|
1621
1655
|
name: "chart",
|
|
1622
1656
|
description: `Label: Charts
|
|
1623
1657
|
Description: Show the values of two or more categories as a proportion of the total using a pie chart.
|
|
@@ -1630,12 +1664,12 @@ const Ea = s.object({
|
|
|
1630
1664
|
Keywords: pie, chart, all categories, breakdown, proportion, total, amount, how much, sum, graduated size, proportional size
|
|
1631
1665
|
Example: Show the total number of homes built in each decade using a pie chart for each feature and vary the size of each chart based on the total of all categories.
|
|
1632
1666
|
Fields: This style requires 2-8 number fields.`,
|
|
1633
|
-
schema:
|
|
1667
|
+
schema: Aa
|
|
1634
1668
|
});
|
|
1635
|
-
function
|
|
1669
|
+
function _a(e) {
|
|
1636
1670
|
const { fields: t, layer: r, view: a, theme: o, colorSchemeTags: n } = e, c = t[0];
|
|
1637
|
-
let
|
|
1638
|
-
return n && (
|
|
1671
|
+
let s;
|
|
1672
|
+
return n && (s = ce({
|
|
1639
1673
|
geometryType: r.geometryType,
|
|
1640
1674
|
includedTags: n,
|
|
1641
1675
|
theme: o || "high-to-low"
|
|
@@ -1647,13 +1681,13 @@ function Ra(e) {
|
|
|
1647
1681
|
theme: o,
|
|
1648
1682
|
sizeOptimizationEnabled: !0,
|
|
1649
1683
|
outlineOptimizationEnabled: !0,
|
|
1650
|
-
colorScheme:
|
|
1684
|
+
colorScheme: s
|
|
1651
1685
|
};
|
|
1652
1686
|
}
|
|
1653
|
-
async function
|
|
1654
|
-
return await
|
|
1687
|
+
async function ja(e) {
|
|
1688
|
+
return await lt(e);
|
|
1655
1689
|
}
|
|
1656
|
-
async function
|
|
1690
|
+
async function Da({
|
|
1657
1691
|
arcgisMap: e,
|
|
1658
1692
|
arcgisMapView: t,
|
|
1659
1693
|
layerId: r,
|
|
@@ -1661,32 +1695,32 @@ async function ka({
|
|
|
1661
1695
|
colorSchemes: o,
|
|
1662
1696
|
theme: n
|
|
1663
1697
|
}) {
|
|
1664
|
-
const c = t,
|
|
1665
|
-
if (!
|
|
1698
|
+
const c = t, s = e?.allLayers.find((d) => d.id === r);
|
|
1699
|
+
if (!s)
|
|
1666
1700
|
return `Could not find layer for id: ${r}`;
|
|
1667
1701
|
const l = {
|
|
1668
1702
|
styleName: "color-age",
|
|
1669
1703
|
fields: a,
|
|
1670
|
-
layer:
|
|
1704
|
+
layer: s,
|
|
1671
1705
|
view: c,
|
|
1672
1706
|
colorSchemeTags: o,
|
|
1673
1707
|
theme: n
|
|
1674
1708
|
};
|
|
1675
1709
|
try {
|
|
1676
|
-
const d =
|
|
1677
|
-
return
|
|
1710
|
+
const d = _a(l), u = await ja(d);
|
|
1711
|
+
return s.renderer = u.renderer, s.visible = !0, `Color-age renderer applied to layer: ${s.title ?? s.id} using fields ${a.join(", ")}`;
|
|
1678
1712
|
} catch (d) {
|
|
1679
1713
|
return `Error applying color-age renderer: ${d instanceof Error ? d.message : String(d)}`;
|
|
1680
1714
|
}
|
|
1681
1715
|
}
|
|
1682
|
-
async function
|
|
1716
|
+
async function Pa({
|
|
1683
1717
|
layerId: e,
|
|
1684
1718
|
fields: t,
|
|
1685
1719
|
colorSchemes: r,
|
|
1686
1720
|
theme: a
|
|
1687
1721
|
}, o) {
|
|
1688
|
-
const { mapView: n } =
|
|
1689
|
-
return await
|
|
1722
|
+
const { mapView: n } = F(o);
|
|
1723
|
+
return await $({ type: "show-legend", data: { layerIds: [e] } }, o), await Da({
|
|
1690
1724
|
arcgisMap: n.map,
|
|
1691
1725
|
arcgisMapView: n,
|
|
1692
1726
|
layerId: e,
|
|
@@ -1695,33 +1729,33 @@ async function Fa({
|
|
|
1695
1729
|
theme: a
|
|
1696
1730
|
});
|
|
1697
1731
|
}
|
|
1698
|
-
const
|
|
1699
|
-
layerId:
|
|
1700
|
-
fields:
|
|
1701
|
-
colorSchemes:
|
|
1702
|
-
theme:
|
|
1703
|
-
}),
|
|
1732
|
+
const Ma = i.object({
|
|
1733
|
+
layerId: i.string().describe("The id of the layer to apply the color-age renderer to"),
|
|
1734
|
+
fields: i.array(i.string()).describe("The field(s) to use for the color-age renderer (temporal/date data)"),
|
|
1735
|
+
colorSchemes: i.array(i.string()).optional().describe("Optional color scheme tags to use"),
|
|
1736
|
+
theme: i.enum(["above-and-below", "above", "below", "centered-on", "extremes", "high-to-low"]).optional().describe("Optional theme for the color ramp")
|
|
1737
|
+
}), Oa = b(Pa, {
|
|
1704
1738
|
name: "color-age",
|
|
1705
1739
|
description: `Label: Age (color)
|
|
1706
1740
|
Description: Use colors along a continuous color ramp to represent the age of features. Age reflects the length of time from a start date to an end date.
|
|
1707
1741
|
Keywords: since, age, how old, how long
|
|
1708
1742
|
Example: Show the age of each feature based on its reported date.
|
|
1709
1743
|
Fields: This style requires at least one field with a date type.`,
|
|
1710
|
-
schema:
|
|
1744
|
+
schema: Ma
|
|
1711
1745
|
});
|
|
1712
|
-
function
|
|
1746
|
+
function Ga(e) {
|
|
1713
1747
|
const { fields: t, layer: r, view: a, colorSchemeTags: o } = e;
|
|
1714
1748
|
let { theme: n } = e, c = t[1];
|
|
1715
|
-
const
|
|
1749
|
+
const s = t[0];
|
|
1716
1750
|
let l;
|
|
1717
|
-
return o && (l =
|
|
1751
|
+
return o && (l = ce({
|
|
1718
1752
|
geometryType: r.geometryType,
|
|
1719
1753
|
includedTags: o,
|
|
1720
1754
|
theme: n || "high-to-low"
|
|
1721
1755
|
})[0]), {
|
|
1722
1756
|
layer: r,
|
|
1723
1757
|
view: a,
|
|
1724
|
-
field:
|
|
1758
|
+
field: s,
|
|
1725
1759
|
normalizationField: c,
|
|
1726
1760
|
theme: n,
|
|
1727
1761
|
sizeOptimizationEnabled: !0,
|
|
@@ -1729,10 +1763,10 @@ function Ia(e) {
|
|
|
1729
1763
|
colorScheme: l
|
|
1730
1764
|
};
|
|
1731
1765
|
}
|
|
1732
|
-
async function
|
|
1733
|
-
return await
|
|
1766
|
+
async function Va(e) {
|
|
1767
|
+
return await dt(e);
|
|
1734
1768
|
}
|
|
1735
|
-
async function
|
|
1769
|
+
async function Wa({
|
|
1736
1770
|
arcgisMap: e,
|
|
1737
1771
|
arcgisMapView: t,
|
|
1738
1772
|
layerId: r,
|
|
@@ -1740,32 +1774,32 @@ async function Na({
|
|
|
1740
1774
|
colorSchemes: o,
|
|
1741
1775
|
theme: n
|
|
1742
1776
|
}) {
|
|
1743
|
-
const c = t,
|
|
1744
|
-
if (!
|
|
1777
|
+
const c = t, s = e?.allLayers.find((d) => d.id === r);
|
|
1778
|
+
if (!s)
|
|
1745
1779
|
return `Could not find layer for id: ${r}`;
|
|
1746
1780
|
const l = {
|
|
1747
1781
|
styleName: "color",
|
|
1748
1782
|
fields: a,
|
|
1749
|
-
layer:
|
|
1783
|
+
layer: s,
|
|
1750
1784
|
view: c,
|
|
1751
1785
|
colorSchemeTags: o,
|
|
1752
1786
|
theme: n
|
|
1753
1787
|
};
|
|
1754
1788
|
try {
|
|
1755
|
-
const d =
|
|
1756
|
-
return
|
|
1789
|
+
const d = Ga(l), u = await Va(d);
|
|
1790
|
+
return s.renderer = u.renderer, s.visible = !0, `Color renderer applied to layer: ${s.title ?? s.id} using fields ${a.join(", ")}`;
|
|
1757
1791
|
} catch (d) {
|
|
1758
1792
|
return `Error applying color renderer: ${d instanceof Error ? d.message : String(d)}`;
|
|
1759
1793
|
}
|
|
1760
1794
|
}
|
|
1761
|
-
async function
|
|
1795
|
+
async function Ka({
|
|
1762
1796
|
layerId: e,
|
|
1763
1797
|
fields: t,
|
|
1764
1798
|
colorSchemes: r,
|
|
1765
1799
|
theme: a
|
|
1766
1800
|
}, o) {
|
|
1767
|
-
const { mapView: n } =
|
|
1768
|
-
return await
|
|
1801
|
+
const { mapView: n } = F(o);
|
|
1802
|
+
return await $({ type: "show-legend", data: { layerIds: [e] } }, o), await Wa({
|
|
1769
1803
|
arcgisMap: n.map,
|
|
1770
1804
|
arcgisMapView: n,
|
|
1771
1805
|
layerId: e,
|
|
@@ -1774,25 +1808,25 @@ async function za({
|
|
|
1774
1808
|
theme: a
|
|
1775
1809
|
});
|
|
1776
1810
|
}
|
|
1777
|
-
const
|
|
1778
|
-
layerId:
|
|
1779
|
-
fields:
|
|
1780
|
-
colorSchemes:
|
|
1781
|
-
theme:
|
|
1782
|
-
}),
|
|
1811
|
+
const Ba = i.object({
|
|
1812
|
+
layerId: i.string().describe("The id of the layer to apply the color renderer to"),
|
|
1813
|
+
fields: i.array(i.string()).describe("The field(s) to use for the color renderer"),
|
|
1814
|
+
colorSchemes: i.array(i.string()).optional().describe("Optional color scheme tags to use"),
|
|
1815
|
+
theme: i.enum(["above-and-below", "above", "below", "centered-on", "extremes", "high-to-low"]).optional().describe("Optional theme for the color ramp")
|
|
1816
|
+
}), Qa = b(Ka, {
|
|
1783
1817
|
name: "color",
|
|
1784
1818
|
description: `Label: Counts and Amounts (color)
|
|
1785
1819
|
Description: Vary color along a continuous color ramp to represent numeric or ranked data.
|
|
1786
1820
|
Keywords: graduated color, choropleth, continuous color, hue, color, gradation, saturation, lightness, percent, rate, ratio, index, how much, increase, decrease
|
|
1787
1821
|
Example: Color each feature based on the population density.
|
|
1788
1822
|
Fields: This style requires a single field with a number type. A second number field may be specified for normalizing the value of the first field.`,
|
|
1789
|
-
schema:
|
|
1823
|
+
schema: Ba
|
|
1790
1824
|
});
|
|
1791
|
-
function
|
|
1825
|
+
function Ua(e) {
|
|
1792
1826
|
const { fields: t, layer: r, view: a, colorSchemeTags: o, theme: n } = e;
|
|
1793
|
-
let c,
|
|
1827
|
+
let c, s;
|
|
1794
1828
|
const l = t[0];
|
|
1795
|
-
return o && (
|
|
1829
|
+
return o && (s = ce({
|
|
1796
1830
|
geometryType: r.geometryType,
|
|
1797
1831
|
includedTags: o,
|
|
1798
1832
|
theme: n || "high-to-low"
|
|
@@ -1803,14 +1837,14 @@ function Ma(e) {
|
|
|
1803
1837
|
normalizationField: c,
|
|
1804
1838
|
theme: n,
|
|
1805
1839
|
colorOptions: {
|
|
1806
|
-
colorScheme:
|
|
1840
|
+
colorScheme: s
|
|
1807
1841
|
}
|
|
1808
1842
|
};
|
|
1809
1843
|
}
|
|
1810
|
-
async function
|
|
1811
|
-
return await
|
|
1844
|
+
async function Ha(e) {
|
|
1845
|
+
return await ut(e);
|
|
1812
1846
|
}
|
|
1813
|
-
async function
|
|
1847
|
+
async function Za({
|
|
1814
1848
|
arcgisMap: e,
|
|
1815
1849
|
arcgisMapView: t,
|
|
1816
1850
|
layerId: r,
|
|
@@ -1818,32 +1852,32 @@ async function Da({
|
|
|
1818
1852
|
colorSchemes: o,
|
|
1819
1853
|
theme: n
|
|
1820
1854
|
}) {
|
|
1821
|
-
const c = t,
|
|
1822
|
-
if (!
|
|
1855
|
+
const c = t, s = e?.allLayers.find((d) => d.id === r);
|
|
1856
|
+
if (!s)
|
|
1823
1857
|
return `Could not find layer for id: ${r}`;
|
|
1824
1858
|
const l = {
|
|
1825
1859
|
styleName: "color-size-univariate",
|
|
1826
1860
|
fields: a,
|
|
1827
|
-
layer:
|
|
1861
|
+
layer: s,
|
|
1828
1862
|
view: c,
|
|
1829
1863
|
colorSchemeTags: o,
|
|
1830
1864
|
theme: n
|
|
1831
1865
|
};
|
|
1832
1866
|
try {
|
|
1833
|
-
const d =
|
|
1834
|
-
return
|
|
1867
|
+
const d = Ua(l), u = await Ha(d);
|
|
1868
|
+
return s.renderer = u.renderer, s.visible = !0, `Color-size-univariate renderer applied to layer: ${s.title ?? s.id} using fields ${a.join(", ")}`;
|
|
1835
1869
|
} catch (d) {
|
|
1836
1870
|
return `Error applying color-size-univariate renderer: ${d instanceof Error ? d.message : String(d)}`;
|
|
1837
1871
|
}
|
|
1838
1872
|
}
|
|
1839
|
-
async function
|
|
1873
|
+
async function Ja({
|
|
1840
1874
|
layerId: e,
|
|
1841
1875
|
fields: t,
|
|
1842
1876
|
colorSchemes: r,
|
|
1843
1877
|
theme: a
|
|
1844
1878
|
}, o) {
|
|
1845
|
-
const { mapView: n } =
|
|
1846
|
-
return await
|
|
1879
|
+
const { mapView: n } = F(o);
|
|
1880
|
+
return await $({ type: "show-legend", data: { layerIds: [e] } }, o), await Za({
|
|
1847
1881
|
arcgisMap: n.map,
|
|
1848
1882
|
arcgisMapView: n,
|
|
1849
1883
|
layerId: e,
|
|
@@ -1852,24 +1886,24 @@ async function Oa({
|
|
|
1852
1886
|
theme: a
|
|
1853
1887
|
});
|
|
1854
1888
|
}
|
|
1855
|
-
const
|
|
1856
|
-
layerId:
|
|
1857
|
-
fields:
|
|
1858
|
-
colorSchemes:
|
|
1859
|
-
theme:
|
|
1860
|
-
}),
|
|
1889
|
+
const Ya = i.object({
|
|
1890
|
+
layerId: i.string().describe("The id of the layer to apply the color-size univariate renderer to"),
|
|
1891
|
+
fields: i.array(i.string()).describe("The fields to use for the color-size univariate renderer"),
|
|
1892
|
+
colorSchemes: i.array(i.string()).optional().describe("Optional color scheme tags to use"),
|
|
1893
|
+
theme: i.enum(["above-and-below", "above", "below", "centered-on", "extremes", "high-to-low"]).optional().describe("Optional theme for the color and size ramps")
|
|
1894
|
+
}), Xa = b(Ja, {
|
|
1861
1895
|
name: "color-size-univariate",
|
|
1862
1896
|
description: `Label: Color and Size (univariate)
|
|
1863
1897
|
Description: Vary symbol size and color based on the values of two numeric attributes.
|
|
1864
1898
|
Keywords: continuous color, hue, color, size, gradation, saturation, lightness, percent, rate, ratio, index, how much, increase, decrease, amount
|
|
1865
1899
|
Example: Color each feature based on the percentage of the population that owns a home and vary the size of each point based on total population.
|
|
1866
1900
|
Fields: This style requires at least two fields: one determining the color of each feature, the other determining the size of each feature. Each field may be normalized by an additional normalization field.`,
|
|
1867
|
-
schema:
|
|
1901
|
+
schema: Ya
|
|
1868
1902
|
});
|
|
1869
|
-
function
|
|
1903
|
+
function eo(e) {
|
|
1870
1904
|
const { fields: t, layer: r, view: a, colorSchemeTags: o } = e;
|
|
1871
1905
|
let n;
|
|
1872
|
-
return o && (n =
|
|
1906
|
+
return o && (n = mt({
|
|
1873
1907
|
includedTags: o,
|
|
1874
1908
|
numColors: Math.min(t.length, 8)
|
|
1875
1909
|
})[0]), {
|
|
@@ -1880,16 +1914,16 @@ function Wa(e) {
|
|
|
1880
1914
|
},
|
|
1881
1915
|
attributes: t.map((c) => ({
|
|
1882
1916
|
field: c,
|
|
1883
|
-
label: r.fields.find((
|
|
1917
|
+
label: r.fields.find((s) => s.name === c)?.alias ?? ""
|
|
1884
1918
|
})).slice(0, 8),
|
|
1885
1919
|
outlineOptimizationEnabled: !0,
|
|
1886
1920
|
dotDensityScheme: n
|
|
1887
1921
|
};
|
|
1888
1922
|
}
|
|
1889
|
-
async function
|
|
1890
|
-
return await
|
|
1923
|
+
async function to(e) {
|
|
1924
|
+
return await pt(e);
|
|
1891
1925
|
}
|
|
1892
|
-
async function
|
|
1926
|
+
async function ro({
|
|
1893
1927
|
arcgisMap: e,
|
|
1894
1928
|
arcgisMapView: t,
|
|
1895
1929
|
layerId: r,
|
|
@@ -1899,7 +1933,7 @@ async function Ba({
|
|
|
1899
1933
|
const n = t, c = e?.allLayers.find((l) => l.id === r);
|
|
1900
1934
|
if (!c)
|
|
1901
1935
|
return `Could not find layer for id: ${r}`;
|
|
1902
|
-
const
|
|
1936
|
+
const s = {
|
|
1903
1937
|
styleName: "dot-density",
|
|
1904
1938
|
fields: a,
|
|
1905
1939
|
layer: c,
|
|
@@ -1907,19 +1941,19 @@ async function Ba({
|
|
|
1907
1941
|
colorSchemeTags: o
|
|
1908
1942
|
};
|
|
1909
1943
|
try {
|
|
1910
|
-
const l =
|
|
1944
|
+
const l = eo(s), d = await to(l);
|
|
1911
1945
|
return c.renderer = d.renderer, c.visible = !0, `Dot Density renderer applied to layer: ${c.title ?? c.id} using fields ${a.join(", ")}`;
|
|
1912
1946
|
} catch (l) {
|
|
1913
1947
|
return `Error applying dot density renderer: ${l instanceof Error ? l.message : String(l)}`;
|
|
1914
1948
|
}
|
|
1915
1949
|
}
|
|
1916
|
-
async function
|
|
1950
|
+
async function ao({
|
|
1917
1951
|
layerId: e,
|
|
1918
1952
|
fields: t,
|
|
1919
1953
|
colorSchemes: r
|
|
1920
1954
|
}, a) {
|
|
1921
|
-
const { mapView: o } =
|
|
1922
|
-
return await
|
|
1955
|
+
const { mapView: o } = F(a);
|
|
1956
|
+
return await $({ type: "show-legend", data: { layerIds: [e] } }, a), await ro({
|
|
1923
1957
|
arcgisMap: o.map,
|
|
1924
1958
|
arcgisMapView: o,
|
|
1925
1959
|
layerId: e,
|
|
@@ -1927,11 +1961,11 @@ async function Qa({
|
|
|
1927
1961
|
colorSchemes: r
|
|
1928
1962
|
});
|
|
1929
1963
|
}
|
|
1930
|
-
const
|
|
1931
|
-
layerId:
|
|
1932
|
-
fields:
|
|
1933
|
-
colorSchemes:
|
|
1934
|
-
}),
|
|
1964
|
+
const oo = i.object({
|
|
1965
|
+
layerId: i.string().describe("The id of the layer to apply the dot density renderer to"),
|
|
1966
|
+
fields: i.array(i.string()).describe("The field(s) to use for the dot density renderer (population or count data)"),
|
|
1967
|
+
colorSchemes: i.array(i.string()).optional().describe("Optional color scheme tags to use")
|
|
1968
|
+
}), no = b(ao, {
|
|
1935
1969
|
name: "dot-density",
|
|
1936
1970
|
description: `Dot Density
|
|
1937
1971
|
Use dot density to visualize the distribution of one attribute or compare the density of multiple attributes. This is only valid for polygon layers.
|
|
@@ -1945,13 +1979,13 @@ const Ua = s.object({
|
|
|
1945
1979
|
- Display demographic patterns within census tracts
|
|
1946
1980
|
**Fields:** Requires 2-8 number fields.
|
|
1947
1981
|
**Keywords:** density, how much, how many, total, number, amount`,
|
|
1948
|
-
schema:
|
|
1982
|
+
schema: oo
|
|
1949
1983
|
});
|
|
1950
|
-
function
|
|
1984
|
+
function so(e) {
|
|
1951
1985
|
const { fields: t, layer: r, view: a, colorSchemeTags: o } = e;
|
|
1952
1986
|
let n;
|
|
1953
1987
|
const c = t[0];
|
|
1954
|
-
return o && (n =
|
|
1988
|
+
return o && (n = gt({
|
|
1955
1989
|
includedTags: o,
|
|
1956
1990
|
basemap: a.map?.basemap || "topo"
|
|
1957
1991
|
})[0]), {
|
|
@@ -1961,10 +1995,10 @@ function Za(e) {
|
|
|
1961
1995
|
heatmapScheme: n
|
|
1962
1996
|
};
|
|
1963
1997
|
}
|
|
1964
|
-
async function
|
|
1965
|
-
return await
|
|
1998
|
+
async function io(e) {
|
|
1999
|
+
return await ht(e);
|
|
1966
2000
|
}
|
|
1967
|
-
async function
|
|
2001
|
+
async function co({
|
|
1968
2002
|
arcgisMap: e,
|
|
1969
2003
|
arcgisMapView: t,
|
|
1970
2004
|
layerId: r,
|
|
@@ -1974,7 +2008,7 @@ async function Ya({
|
|
|
1974
2008
|
const n = t, c = e?.allLayers.find((l) => l.id === r);
|
|
1975
2009
|
if (!c)
|
|
1976
2010
|
return `Could not find layer for id: ${r}`;
|
|
1977
|
-
const
|
|
2011
|
+
const s = {
|
|
1978
2012
|
styleName: "heatmap",
|
|
1979
2013
|
fields: a,
|
|
1980
2014
|
layer: c,
|
|
@@ -1982,19 +2016,19 @@ async function Ya({
|
|
|
1982
2016
|
colorSchemeTags: o
|
|
1983
2017
|
};
|
|
1984
2018
|
try {
|
|
1985
|
-
const l =
|
|
2019
|
+
const l = so(s), d = await io(l);
|
|
1986
2020
|
return c.renderer = d.renderer, c.visible = !0, `Heatmap renderer applied to layer: ${c.title ?? c.id} using fields ${a.join(", ")}`;
|
|
1987
2021
|
} catch (l) {
|
|
1988
2022
|
return `Error applying heatmap renderer: ${l instanceof Error ? l.message : String(l)}`;
|
|
1989
2023
|
}
|
|
1990
2024
|
}
|
|
1991
|
-
async function
|
|
2025
|
+
async function lo({
|
|
1992
2026
|
layerId: e,
|
|
1993
2027
|
fields: t,
|
|
1994
2028
|
colorSchemes: r
|
|
1995
2029
|
}, a) {
|
|
1996
|
-
const { mapView: o } =
|
|
1997
|
-
return await
|
|
2030
|
+
const { mapView: o } = F(a);
|
|
2031
|
+
return await $({ type: "show-legend", data: { layerIds: [e] } }, a), await co({
|
|
1998
2032
|
arcgisMap: o.map,
|
|
1999
2033
|
arcgisMapView: o,
|
|
2000
2034
|
layerId: e,
|
|
@@ -2002,40 +2036,40 @@ async function Xa({
|
|
|
2002
2036
|
colorSchemes: r
|
|
2003
2037
|
});
|
|
2004
2038
|
}
|
|
2005
|
-
const
|
|
2006
|
-
layerId:
|
|
2007
|
-
fields:
|
|
2008
|
-
colorSchemes:
|
|
2009
|
-
}),
|
|
2039
|
+
const uo = i.object({
|
|
2040
|
+
layerId: i.string().describe("The id of the layer to apply the heatmap renderer to"),
|
|
2041
|
+
fields: i.array(i.string()).describe("The field(s) to use for the heatmap renderer (typically point density)"),
|
|
2042
|
+
colorSchemes: i.array(i.string()).optional().describe("Optional color scheme tags to use")
|
|
2043
|
+
}), po = b(lo, {
|
|
2010
2044
|
name: "heatmap",
|
|
2011
2045
|
description: `Label: Heat Map
|
|
2012
2046
|
Description: Show areas of high density with colors that appear to glow hotter. This is only valid for point layers.
|
|
2013
2047
|
Keywords: density, heatmap, hot spots, pattern, cluster
|
|
2014
2048
|
Example: Create a heatmap
|
|
2015
2049
|
Fields: This typically requires zero or one field of type number.`,
|
|
2016
|
-
schema:
|
|
2050
|
+
schema: uo
|
|
2017
2051
|
});
|
|
2018
|
-
function
|
|
2052
|
+
function mo(e) {
|
|
2019
2053
|
const { fields: t, layer: r, view: a, styleName: o, colorSchemeTags: n } = e;
|
|
2020
2054
|
let c;
|
|
2021
|
-
return n && (c =
|
|
2055
|
+
return n && (c = ft({
|
|
2022
2056
|
geometryType: r.geometryType,
|
|
2023
2057
|
includedTags: n,
|
|
2024
2058
|
numColors: Math.min(t.length, 10)
|
|
2025
2059
|
})[0]), {
|
|
2026
2060
|
layer: r,
|
|
2027
2061
|
view: a,
|
|
2028
|
-
fields: t.map((
|
|
2062
|
+
fields: t.map((s) => ({ name: s })).slice(0, 9),
|
|
2029
2063
|
outlineOptimizationEnabled: !0,
|
|
2030
2064
|
sizeOptimizationEnabled: !0,
|
|
2031
2065
|
includeSizeVariable: o.includes("Size"),
|
|
2032
2066
|
predominanceScheme: c
|
|
2033
2067
|
};
|
|
2034
2068
|
}
|
|
2035
|
-
async function
|
|
2036
|
-
return await
|
|
2069
|
+
async function ho(e) {
|
|
2070
|
+
return await yt(e);
|
|
2037
2071
|
}
|
|
2038
|
-
async function
|
|
2072
|
+
async function go({
|
|
2039
2073
|
arcgisMap: e,
|
|
2040
2074
|
arcgisMapView: t,
|
|
2041
2075
|
layerId: r,
|
|
@@ -2043,31 +2077,31 @@ async function oo({
|
|
|
2043
2077
|
colorSchemes: o,
|
|
2044
2078
|
includeSize: n
|
|
2045
2079
|
}) {
|
|
2046
|
-
const c = t,
|
|
2047
|
-
if (!
|
|
2080
|
+
const c = t, s = e?.allLayers.find((u) => u.id === r);
|
|
2081
|
+
if (!s)
|
|
2048
2082
|
return `Could not find layer for id: ${r}`;
|
|
2049
2083
|
const d = {
|
|
2050
2084
|
styleName: n ? "predominance-size" : "predominance",
|
|
2051
2085
|
fields: a,
|
|
2052
|
-
layer:
|
|
2086
|
+
layer: s,
|
|
2053
2087
|
view: c,
|
|
2054
2088
|
colorSchemeTags: o
|
|
2055
2089
|
};
|
|
2056
2090
|
try {
|
|
2057
|
-
const u =
|
|
2058
|
-
return
|
|
2091
|
+
const u = mo(d), p = await ho(u);
|
|
2092
|
+
return s.renderer = p.renderer, s.visible = !0, `Predominance renderer applied to layer: ${s.title ?? s.id} using fields ${a.join(", ")}`;
|
|
2059
2093
|
} catch (u) {
|
|
2060
2094
|
return `Error applying predominance renderer: ${u instanceof Error ? u.message : String(u)}`;
|
|
2061
2095
|
}
|
|
2062
2096
|
}
|
|
2063
|
-
async function
|
|
2097
|
+
async function yo({
|
|
2064
2098
|
layerId: e,
|
|
2065
2099
|
fields: t,
|
|
2066
2100
|
colorSchemes: r,
|
|
2067
2101
|
includeSize: a
|
|
2068
2102
|
}, o) {
|
|
2069
|
-
const { mapView: n } =
|
|
2070
|
-
return await
|
|
2103
|
+
const { mapView: n } = F(o);
|
|
2104
|
+
return await $({ type: "show-legend", data: { layerIds: [e] } }, o), await go({
|
|
2071
2105
|
arcgisMap: n.map,
|
|
2072
2106
|
arcgisMapView: n,
|
|
2073
2107
|
layerId: e,
|
|
@@ -2076,12 +2110,12 @@ async function no({
|
|
|
2076
2110
|
includeSize: a
|
|
2077
2111
|
});
|
|
2078
2112
|
}
|
|
2079
|
-
const
|
|
2080
|
-
layerId:
|
|
2081
|
-
fields:
|
|
2082
|
-
colorSchemes:
|
|
2083
|
-
includeSize:
|
|
2084
|
-
}),
|
|
2113
|
+
const fo = i.object({
|
|
2114
|
+
layerId: i.string().describe("The id of the layer to apply the predominance renderer to"),
|
|
2115
|
+
fields: i.array(i.string()).describe("The fields to use for the predominance renderer (competing categories)"),
|
|
2116
|
+
colorSchemes: i.array(i.string()).optional().describe("Optional color scheme tags to use"),
|
|
2117
|
+
includeSize: i.boolean().optional().describe("Whether to include size visualization (predominance-size)")
|
|
2118
|
+
}), wo = b(yo, {
|
|
2085
2119
|
name: "predominance",
|
|
2086
2120
|
description: `Label: Predominant category
|
|
2087
2121
|
Description: Compare attributes that share a common subject and unit of measurement to see which has the highest value.
|
|
@@ -2094,33 +2128,33 @@ const io = s.object({
|
|
|
2094
2128
|
Keywords: predominant, winner, won, competing, most, most common, most frequent, dominant, prevalent, top, amount, total, how much, proportional size, graduated size, sum
|
|
2095
2129
|
Example: Show the predominant crop in each area and vary the size of each symbol based on the total of all categories.
|
|
2096
2130
|
Fields: This style relies on 2-10 number fields.`,
|
|
2097
|
-
schema:
|
|
2131
|
+
schema: fo
|
|
2098
2132
|
});
|
|
2099
|
-
function
|
|
2133
|
+
function bo(e) {
|
|
2100
2134
|
const { fields: t, layer: r, view: a, colorSchemeTags: o } = e;
|
|
2101
2135
|
let n;
|
|
2102
2136
|
const c = {
|
|
2103
2137
|
field: t[0]
|
|
2104
|
-
},
|
|
2138
|
+
}, s = {
|
|
2105
2139
|
field: t[1]
|
|
2106
2140
|
};
|
|
2107
|
-
return o && (n =
|
|
2141
|
+
return o && (n = bt({
|
|
2108
2142
|
geometryType: r.geometryType,
|
|
2109
2143
|
includedTags: o
|
|
2110
2144
|
})[0]), {
|
|
2111
2145
|
layer: r,
|
|
2112
2146
|
view: a,
|
|
2113
2147
|
field1: c,
|
|
2114
|
-
field2:
|
|
2148
|
+
field2: s,
|
|
2115
2149
|
outlineOptimizationEnabled: !0,
|
|
2116
2150
|
sizeOptimizationEnabled: !0,
|
|
2117
2151
|
relationshipScheme: n
|
|
2118
2152
|
};
|
|
2119
2153
|
}
|
|
2120
|
-
async function
|
|
2121
|
-
return await
|
|
2154
|
+
async function xo(e) {
|
|
2155
|
+
return await wt(e);
|
|
2122
2156
|
}
|
|
2123
|
-
async function
|
|
2157
|
+
async function So({
|
|
2124
2158
|
arcgisMap: e,
|
|
2125
2159
|
arcgisMapView: t,
|
|
2126
2160
|
layerId: r,
|
|
@@ -2130,7 +2164,7 @@ async function uo({
|
|
|
2130
2164
|
const n = t, c = e?.allLayers.find((l) => l.id === r);
|
|
2131
2165
|
if (!c)
|
|
2132
2166
|
return `Could not find layer for id: ${r}`;
|
|
2133
|
-
const
|
|
2167
|
+
const s = {
|
|
2134
2168
|
styleName: "relationship",
|
|
2135
2169
|
fields: a,
|
|
2136
2170
|
layer: c,
|
|
@@ -2138,19 +2172,19 @@ async function uo({
|
|
|
2138
2172
|
colorSchemeTags: o
|
|
2139
2173
|
};
|
|
2140
2174
|
try {
|
|
2141
|
-
const l =
|
|
2175
|
+
const l = bo(s), d = await xo(l);
|
|
2142
2176
|
return c.renderer = d.renderer, c.visible = !0, `Relationship renderer applied to layer: ${c.title ?? c.id} using fields ${a.join(", ")}`;
|
|
2143
2177
|
} catch (l) {
|
|
2144
2178
|
return `Error applying relationship renderer: ${l instanceof Error ? l.message : String(l)}`;
|
|
2145
2179
|
}
|
|
2146
2180
|
}
|
|
2147
|
-
async function
|
|
2181
|
+
async function vo({
|
|
2148
2182
|
layerId: e,
|
|
2149
2183
|
fields: t,
|
|
2150
2184
|
colorSchemes: r
|
|
2151
2185
|
}, a) {
|
|
2152
|
-
const { mapView: o } =
|
|
2153
|
-
return await
|
|
2186
|
+
const { mapView: o } = F(a);
|
|
2187
|
+
return await $({ type: "show-legend", data: { layerIds: [e] } }, a), await So({
|
|
2154
2188
|
arcgisMap: o.map,
|
|
2155
2189
|
arcgisMapView: o,
|
|
2156
2190
|
layerId: e,
|
|
@@ -2158,20 +2192,20 @@ async function po({
|
|
|
2158
2192
|
colorSchemes: r
|
|
2159
2193
|
});
|
|
2160
2194
|
}
|
|
2161
|
-
const
|
|
2162
|
-
layerId:
|
|
2163
|
-
fields:
|
|
2164
|
-
colorSchemes:
|
|
2165
|
-
}),
|
|
2195
|
+
const To = i.object({
|
|
2196
|
+
layerId: i.string().describe("The id of the layer to apply the relationship renderer to"),
|
|
2197
|
+
fields: i.array(i.string()).describe("The two fields to use for the relationship renderer (bivariate visualization)"),
|
|
2198
|
+
colorSchemes: i.array(i.string()).optional().describe("Optional color scheme tags to use")
|
|
2199
|
+
}), Eo = b(vo, {
|
|
2166
2200
|
name: "relationship",
|
|
2167
2201
|
description: `Label: Relationship
|
|
2168
2202
|
Description: Overlays two color ramps to represent the relationship between two numeric attributes.
|
|
2169
2203
|
Keywords: relationship, correlation, compare, related, bivariate choropleth, bivariate color
|
|
2170
2204
|
Example: Show the relationship between tree height and carbon storage
|
|
2171
2205
|
Fields: This style requires two number fields.`,
|
|
2172
|
-
schema:
|
|
2206
|
+
schema: To
|
|
2173
2207
|
});
|
|
2174
|
-
function
|
|
2208
|
+
function Co(e) {
|
|
2175
2209
|
const { fields: t, layer: r, view: a, theme: o } = e, n = t[0];
|
|
2176
2210
|
return {
|
|
2177
2211
|
layer: r,
|
|
@@ -2183,10 +2217,10 @@ function go(e) {
|
|
|
2183
2217
|
outlineOptimizationEnabled: !0
|
|
2184
2218
|
};
|
|
2185
2219
|
}
|
|
2186
|
-
async function
|
|
2187
|
-
return await
|
|
2220
|
+
async function Ro(e) {
|
|
2221
|
+
return await xt(e);
|
|
2188
2222
|
}
|
|
2189
|
-
async function
|
|
2223
|
+
async function $o({
|
|
2190
2224
|
arcgisMap: e,
|
|
2191
2225
|
arcgisMapView: t,
|
|
2192
2226
|
layerId: r,
|
|
@@ -2194,32 +2228,32 @@ async function fo({
|
|
|
2194
2228
|
colorSchemes: o,
|
|
2195
2229
|
theme: n
|
|
2196
2230
|
}) {
|
|
2197
|
-
const c = t,
|
|
2198
|
-
if (!
|
|
2231
|
+
const c = t, s = e?.allLayers.find((d) => d.id === r);
|
|
2232
|
+
if (!s)
|
|
2199
2233
|
return `Could not find layer for id: ${r}`;
|
|
2200
2234
|
const l = {
|
|
2201
2235
|
styleName: "size-age",
|
|
2202
2236
|
fields: a,
|
|
2203
|
-
layer:
|
|
2237
|
+
layer: s,
|
|
2204
2238
|
view: c,
|
|
2205
2239
|
colorSchemeTags: o,
|
|
2206
2240
|
theme: n
|
|
2207
2241
|
};
|
|
2208
2242
|
try {
|
|
2209
|
-
const d =
|
|
2210
|
-
return
|
|
2243
|
+
const d = Co(l), u = await Ro(d);
|
|
2244
|
+
return s.renderer = u.renderer, s.visible = !0, `Size-age renderer applied to layer: ${s.title ?? s.id} using fields ${a.join(", ")}`;
|
|
2211
2245
|
} catch (d) {
|
|
2212
2246
|
return `Error applying size-age renderer: ${d instanceof Error ? d.message : String(d)}`;
|
|
2213
2247
|
}
|
|
2214
2248
|
}
|
|
2215
|
-
async function
|
|
2249
|
+
async function ko({
|
|
2216
2250
|
layerId: e,
|
|
2217
2251
|
fields: t,
|
|
2218
2252
|
colorSchemes: r,
|
|
2219
2253
|
theme: a
|
|
2220
2254
|
}, o) {
|
|
2221
|
-
const { mapView: n } =
|
|
2222
|
-
return await
|
|
2255
|
+
const { mapView: n } = F(o);
|
|
2256
|
+
return await $({ type: "show-legend", data: { layerIds: [e] } }, o), await $o({
|
|
2223
2257
|
arcgisMap: n.map,
|
|
2224
2258
|
arcgisMapView: n,
|
|
2225
2259
|
layerId: e,
|
|
@@ -2228,21 +2262,21 @@ async function wo({
|
|
|
2228
2262
|
theme: a
|
|
2229
2263
|
});
|
|
2230
2264
|
}
|
|
2231
|
-
const
|
|
2232
|
-
layerId:
|
|
2233
|
-
fields:
|
|
2234
|
-
colorSchemes:
|
|
2235
|
-
theme:
|
|
2236
|
-
}),
|
|
2265
|
+
const Fo = i.object({
|
|
2266
|
+
layerId: i.string().describe("The id of the layer to apply the size-age renderer to"),
|
|
2267
|
+
fields: i.array(i.string()).describe("The field(s) to use for the size-age renderer (temporal data with size)"),
|
|
2268
|
+
colorSchemes: i.array(i.string()).optional().describe("Optional color scheme tags to use"),
|
|
2269
|
+
theme: i.enum(["above-and-below", "above", "below", "centered-on", "extremes", "high-to-low"]).optional().describe("Optional theme for the size ramp")
|
|
2270
|
+
}), qo = b(ko, {
|
|
2237
2271
|
name: "size-age",
|
|
2238
2272
|
description: `Label: Age (size)
|
|
2239
2273
|
Description: Vary symbol sizes along a continuous ramp to represent the age of features. Age reflects the length of time from a start date to an end date.
|
|
2240
2274
|
Keywords: since, age, how old, how long
|
|
2241
2275
|
Example: Change the size of features so older features are larger than new features.
|
|
2242
2276
|
Fields: This style requires at least one field with a date type.`,
|
|
2243
|
-
schema:
|
|
2277
|
+
schema: Fo
|
|
2244
2278
|
});
|
|
2245
|
-
function
|
|
2279
|
+
function Lo(e) {
|
|
2246
2280
|
const { fields: t, layer: r, view: a } = e;
|
|
2247
2281
|
let { theme: o } = e, n = t[1];
|
|
2248
2282
|
const c = t[0];
|
|
@@ -2256,10 +2290,10 @@ function So(e) {
|
|
|
2256
2290
|
outlineOptimizationEnabled: !0
|
|
2257
2291
|
};
|
|
2258
2292
|
}
|
|
2259
|
-
async function
|
|
2260
|
-
return await
|
|
2293
|
+
async function Io(e) {
|
|
2294
|
+
return await St(e);
|
|
2261
2295
|
}
|
|
2262
|
-
async function
|
|
2296
|
+
async function No({
|
|
2263
2297
|
arcgisMap: e,
|
|
2264
2298
|
arcgisMapView: t,
|
|
2265
2299
|
layerId: r,
|
|
@@ -2267,32 +2301,32 @@ async function To({
|
|
|
2267
2301
|
colorSchemes: o,
|
|
2268
2302
|
theme: n
|
|
2269
2303
|
}) {
|
|
2270
|
-
const c = t,
|
|
2271
|
-
if (!
|
|
2304
|
+
const c = t, s = e?.allLayers.find((d) => d.id === r);
|
|
2305
|
+
if (!s)
|
|
2272
2306
|
return `Could not find layer for id: ${r}`;
|
|
2273
2307
|
const l = {
|
|
2274
2308
|
styleName: "size",
|
|
2275
2309
|
fields: a,
|
|
2276
|
-
layer:
|
|
2310
|
+
layer: s,
|
|
2277
2311
|
view: c,
|
|
2278
2312
|
colorSchemeTags: o,
|
|
2279
2313
|
theme: n
|
|
2280
2314
|
};
|
|
2281
2315
|
try {
|
|
2282
|
-
const d =
|
|
2283
|
-
return
|
|
2316
|
+
const d = Lo(l), u = await Io(d);
|
|
2317
|
+
return s.renderer = u.renderer, s.visible = !0, `Size renderer applied to layer: ${s.title ?? s.id} using fields ${a.join(", ")}`;
|
|
2284
2318
|
} catch (d) {
|
|
2285
2319
|
return `Error applying size renderer: ${d instanceof Error ? d.message : String(d)}`;
|
|
2286
2320
|
}
|
|
2287
2321
|
}
|
|
2288
|
-
async function
|
|
2322
|
+
async function Ao({
|
|
2289
2323
|
layerId: e,
|
|
2290
2324
|
fields: t,
|
|
2291
2325
|
colorSchemes: r,
|
|
2292
2326
|
theme: a
|
|
2293
2327
|
}, o) {
|
|
2294
|
-
const { mapView: n } =
|
|
2295
|
-
return await
|
|
2328
|
+
const { mapView: n } = F(o);
|
|
2329
|
+
return await $({ type: "show-legend", data: { layerIds: [e] } }, o), await No({
|
|
2296
2330
|
arcgisMap: n.map,
|
|
2297
2331
|
arcgisMapView: n,
|
|
2298
2332
|
layerId: e,
|
|
@@ -2301,12 +2335,12 @@ async function Eo({
|
|
|
2301
2335
|
theme: a
|
|
2302
2336
|
});
|
|
2303
2337
|
}
|
|
2304
|
-
const
|
|
2305
|
-
layerId:
|
|
2306
|
-
fields:
|
|
2307
|
-
colorSchemes:
|
|
2308
|
-
theme:
|
|
2309
|
-
}),
|
|
2338
|
+
const zo = i.object({
|
|
2339
|
+
layerId: i.string().describe("The id of the layer to apply the size renderer to"),
|
|
2340
|
+
fields: i.array(i.string()).describe("The field(s) to use for the size renderer (numeric data)"),
|
|
2341
|
+
colorSchemes: i.array(i.string()).optional().describe("Optional color scheme tags to use"),
|
|
2342
|
+
theme: i.enum(["above-and-below", "above", "below", "centered-on", "extremes", "high-to-low"]).optional().describe("Optional theme for the size ramp")
|
|
2343
|
+
}), _o = b(Ao, {
|
|
2310
2344
|
name: "size",
|
|
2311
2345
|
description: `Label: Counts and Amounts (size)
|
|
2312
2346
|
Description: Vary symbol sizes along a continuous ramp to represent numeric or ranked data.
|
|
@@ -2319,12 +2353,12 @@ const Co = s.object({
|
|
|
2319
2353
|
Keywords: graduated size, proportional size, classed size, how much, total, number, when
|
|
2320
2354
|
Example: Vary the size of each feature based on the date a ticket was completed.
|
|
2321
2355
|
Fields: This style requires a single field with a date type.`,
|
|
2322
|
-
schema:
|
|
2356
|
+
schema: zo
|
|
2323
2357
|
});
|
|
2324
|
-
function
|
|
2325
|
-
const { fields: t, layer: r, view: a, colorSchemeTags: o } = e, n = t[0], c = t[1],
|
|
2358
|
+
function jo(e) {
|
|
2359
|
+
const { fields: t, layer: r, view: a, colorSchemeTags: o } = e, n = t[0], c = t[1], s = t[2];
|
|
2326
2360
|
let l;
|
|
2327
|
-
return o && (l =
|
|
2361
|
+
return o && (l = Tt({
|
|
2328
2362
|
geometryType: r.geometryType,
|
|
2329
2363
|
includedTags: o
|
|
2330
2364
|
})[0]), {
|
|
@@ -2332,16 +2366,16 @@ function $o(e) {
|
|
|
2332
2366
|
view: a,
|
|
2333
2367
|
field: n,
|
|
2334
2368
|
field2: c,
|
|
2335
|
-
field3:
|
|
2369
|
+
field3: s,
|
|
2336
2370
|
outlineOptimizationEnabled: !0,
|
|
2337
2371
|
sizeOptimizationEnabled: !0,
|
|
2338
2372
|
typeScheme: l
|
|
2339
2373
|
};
|
|
2340
2374
|
}
|
|
2341
|
-
async function
|
|
2342
|
-
return await
|
|
2375
|
+
async function Do(e) {
|
|
2376
|
+
return await vt(e);
|
|
2343
2377
|
}
|
|
2344
|
-
async function
|
|
2378
|
+
async function Po({
|
|
2345
2379
|
arcgisMap: e,
|
|
2346
2380
|
arcgisMapView: t,
|
|
2347
2381
|
layerId: r,
|
|
@@ -2349,32 +2383,32 @@ async function Fo({
|
|
|
2349
2383
|
colorSchemes: o,
|
|
2350
2384
|
theme: n
|
|
2351
2385
|
}) {
|
|
2352
|
-
const c = t,
|
|
2353
|
-
if (!
|
|
2386
|
+
const c = t, s = e?.allLayers.find((d) => d.id === r);
|
|
2387
|
+
if (!s)
|
|
2354
2388
|
return `Could not find layer for id: ${r}`;
|
|
2355
2389
|
const l = {
|
|
2356
2390
|
styleName: "type",
|
|
2357
2391
|
fields: a,
|
|
2358
|
-
layer:
|
|
2392
|
+
layer: s,
|
|
2359
2393
|
view: c,
|
|
2360
2394
|
colorSchemeTags: o,
|
|
2361
2395
|
theme: n
|
|
2362
2396
|
};
|
|
2363
2397
|
try {
|
|
2364
|
-
const d =
|
|
2365
|
-
return
|
|
2398
|
+
const d = jo(l), u = await Do(d);
|
|
2399
|
+
return s.renderer = u.renderer, s.visible = !0, `Type renderer applied to layer: ${s.title ?? s.id} using fields ${a.join(", ")}`;
|
|
2366
2400
|
} catch (d) {
|
|
2367
2401
|
return `Error applying type renderer: ${d instanceof Error ? d.message : String(d)}`;
|
|
2368
2402
|
}
|
|
2369
2403
|
}
|
|
2370
|
-
async function
|
|
2404
|
+
async function Mo({
|
|
2371
2405
|
layerId: e,
|
|
2372
2406
|
fields: t,
|
|
2373
2407
|
colorSchemes: r,
|
|
2374
2408
|
theme: a
|
|
2375
2409
|
}, o) {
|
|
2376
|
-
const { mapView: n } =
|
|
2377
|
-
return await
|
|
2410
|
+
const { mapView: n } = F(o);
|
|
2411
|
+
return await $({ type: "show-legend", data: { layerIds: [e] } }, o), await Po({
|
|
2378
2412
|
arcgisMap: n.map,
|
|
2379
2413
|
arcgisMapView: n,
|
|
2380
2414
|
layerId: e,
|
|
@@ -2383,46 +2417,46 @@ async function Lo({
|
|
|
2383
2417
|
theme: a
|
|
2384
2418
|
});
|
|
2385
2419
|
}
|
|
2386
|
-
const
|
|
2387
|
-
layerId:
|
|
2388
|
-
fields:
|
|
2389
|
-
colorSchemes:
|
|
2390
|
-
theme:
|
|
2391
|
-
}),
|
|
2420
|
+
const Oo = i.object({
|
|
2421
|
+
layerId: i.string().describe("The id of the layer to apply the type renderer to"),
|
|
2422
|
+
fields: i.array(i.string()).describe("The field(s) to use for the type renderer (categorical data)"),
|
|
2423
|
+
colorSchemes: i.array(i.string()).optional().describe("Optional color scheme tags to use"),
|
|
2424
|
+
theme: i.enum(["above-and-below", "above", "below", "centered-on", "extremes", "high-to-low"]).optional().describe("Optional theme for the color scheme")
|
|
2425
|
+
}), Go = b(Mo, {
|
|
2392
2426
|
name: "type",
|
|
2393
2427
|
description: `Label: Types (unique symbols)
|
|
2394
2428
|
Description: Represent features as categories with different symbol colors or shapes. Examples include type of tree, road class, or province name.
|
|
2395
2429
|
Keywords: categorical, category, type, unique, discrete, point of interest, region, group
|
|
2396
2430
|
Example: Color each feature based on the region it belongs to
|
|
2397
2431
|
Fields: This style requires a single field which may be a string, number, or date type. It is usually a string.`,
|
|
2398
|
-
schema:
|
|
2399
|
-
}),
|
|
2400
|
-
|
|
2401
|
-
|
|
2402
|
-
|
|
2403
|
-
|
|
2404
|
-
|
|
2405
|
-
|
|
2406
|
-
|
|
2407
|
-
|
|
2408
|
-
|
|
2409
|
-
|
|
2410
|
-
|
|
2411
|
-
],
|
|
2432
|
+
schema: Oo
|
|
2433
|
+
}), De = [
|
|
2434
|
+
za,
|
|
2435
|
+
Oa,
|
|
2436
|
+
Qa,
|
|
2437
|
+
Xa,
|
|
2438
|
+
no,
|
|
2439
|
+
po,
|
|
2440
|
+
wo,
|
|
2441
|
+
Eo,
|
|
2442
|
+
qo,
|
|
2443
|
+
_o,
|
|
2444
|
+
Go
|
|
2445
|
+
], Vo = async (e, t) => {
|
|
2412
2446
|
await g({ text: "Requesting LLM for layer query results" }, t);
|
|
2413
2447
|
const r = await L("navigation_intent_prompt");
|
|
2414
2448
|
if (!t?.configurable)
|
|
2415
2449
|
throw new Error("config.configurable is required for layer query tools");
|
|
2416
2450
|
const a = {
|
|
2417
2451
|
layerFieldInfo: e.layerFieldInfo
|
|
2418
|
-
}, o = await
|
|
2452
|
+
}, o = await D({
|
|
2419
2453
|
promptText: r,
|
|
2420
2454
|
modelTier: "advanced",
|
|
2421
2455
|
messages: C(e.agentExecutionContext.messages),
|
|
2422
2456
|
inputVariables: a,
|
|
2423
|
-
tools:
|
|
2457
|
+
tools: De
|
|
2424
2458
|
});
|
|
2425
|
-
return await
|
|
2459
|
+
return await de(o, t), {
|
|
2426
2460
|
...e,
|
|
2427
2461
|
agentExecutionContext: {
|
|
2428
2462
|
...e.agentExecutionContext,
|
|
@@ -2430,8 +2464,8 @@ Fields: This style requires a single field which may be a string, number, or dat
|
|
|
2430
2464
|
}
|
|
2431
2465
|
};
|
|
2432
2466
|
};
|
|
2433
|
-
async function
|
|
2434
|
-
const a = await new
|
|
2467
|
+
async function Wo(e, t) {
|
|
2468
|
+
const a = await new P(De).invoke(
|
|
2435
2469
|
{
|
|
2436
2470
|
messages: C(e.agentExecutionContext.messages)
|
|
2437
2471
|
},
|
|
@@ -2443,7 +2477,7 @@ async function No(e, t) {
|
|
|
2443
2477
|
`);
|
|
2444
2478
|
return { ...e, outputMessage: n };
|
|
2445
2479
|
}
|
|
2446
|
-
const
|
|
2480
|
+
const Pe = w.Root({
|
|
2447
2481
|
// Execution context provided by the orchestrator for this agent invocation.
|
|
2448
2482
|
agentExecutionContext: w({
|
|
2449
2483
|
reducer: K,
|
|
@@ -2463,20 +2497,20 @@ const Ne = w.Root({
|
|
|
2463
2497
|
vectorSearchFieldResults: w(),
|
|
2464
2498
|
layerFieldInfo: w(),
|
|
2465
2499
|
selectedLayerId: w()
|
|
2466
|
-
}),
|
|
2500
|
+
}), Ko = async (e, t) => (await g({ text: "Exiting Layer Styling agent" }, t), e), Bo = async (e, t) => {
|
|
2467
2501
|
try {
|
|
2468
2502
|
await g({ text: "Populating layer and field info" }, t);
|
|
2469
2503
|
const r = [];
|
|
2470
2504
|
for (const a of e.vectorSearchFieldResults) {
|
|
2471
2505
|
let o = function(u) {
|
|
2472
|
-
const p =
|
|
2506
|
+
const p = s.get(u)?.layerItem;
|
|
2473
2507
|
return p ? [
|
|
2474
2508
|
p.name && `Name: ${p.name}`,
|
|
2475
2509
|
p.title && `Title: ${p.title}`,
|
|
2476
2510
|
p.description && `Description: ${p.description}`
|
|
2477
2511
|
].filter(Boolean).join(" | ") : u;
|
|
2478
2512
|
};
|
|
2479
|
-
const { layerId: n, results: c } = a,
|
|
2513
|
+
const { layerId: n, results: c } = a, s = x(t, "layersAndFieldsRegistry"), l = s.get(n)?.fieldRegistry;
|
|
2480
2514
|
if (!l)
|
|
2481
2515
|
continue;
|
|
2482
2516
|
let d = r.find((u) => u.layerId === n);
|
|
@@ -2494,43 +2528,43 @@ const Ne = w.Root({
|
|
|
2494
2528
|
} catch (r) {
|
|
2495
2529
|
throw await g({ text: "Error populating layerFieldInfo" }, t), new Error(`Error populating layerFieldInfo: ${r instanceof Error ? r.message : String(r)}`);
|
|
2496
2530
|
}
|
|
2497
|
-
},
|
|
2531
|
+
}, Qo = (e, t) => {
|
|
2498
2532
|
const r = e.vectorSearchLayerIds ?? [];
|
|
2499
2533
|
if (r.length <= 1)
|
|
2500
2534
|
return { ...e, selectedLayerId: e.vectorSearchLayerIds[0] };
|
|
2501
2535
|
const { hitlResponse: a } = t.configurable;
|
|
2502
|
-
if (!a || a.agentId !==
|
|
2536
|
+
if (!a || a.agentId !== Ce.id || a.id !== "reviewLayerSelection") {
|
|
2503
2537
|
const n = {
|
|
2504
|
-
agentId:
|
|
2538
|
+
agentId: Ce.id,
|
|
2505
2539
|
id: "reviewLayerSelection",
|
|
2506
2540
|
kind: "singleSelection",
|
|
2507
2541
|
message: "Choose a layer to apply the styles.",
|
|
2508
2542
|
metadata: [...r]
|
|
2509
2543
|
};
|
|
2510
|
-
throw new
|
|
2544
|
+
throw new He(n);
|
|
2511
2545
|
}
|
|
2512
2546
|
let o = null;
|
|
2513
2547
|
return Array.isArray(a.payload) && a.payload.length > 0 && (o = a.payload[0]), {
|
|
2514
2548
|
...e,
|
|
2515
2549
|
selectedLayerId: o ?? e.vectorSearchLayerIds[0]
|
|
2516
2550
|
};
|
|
2517
|
-
},
|
|
2551
|
+
}, Uo = (e, t) => Q(["layerSearch", "fieldSearch", "layersAndFieldsRegistry"], "Layer Styling Agent")(e, t), Ho = () => new V(Pe).addNode("requireLayerStylingServices", Uo).addNode("vectorSearchLayers", ka).addNode("layerSelectionHITL", Qo).addNode("vectorSearchFields", Ra).addNode("populateLayerFieldInfo", Bo).addNode("agent", Vo).addNode("tools", Wo).addNode("earlyExit", Ko).addEdge(W, "requireLayerStylingServices").addEdge("requireLayerStylingServices", "vectorSearchLayers").addConditionalEdges(
|
|
2518
2552
|
"layerSelectionHITL",
|
|
2519
2553
|
(t) => t.vectorSearchLayerIds.length ? "vectorSearchFields" : "earlyExit"
|
|
2520
2554
|
).addConditionalEdges(
|
|
2521
2555
|
"vectorSearchFields",
|
|
2522
2556
|
(t) => t.vectorSearchFieldResults.length ? "populateLayerFieldInfo" : "earlyExit"
|
|
2523
|
-
).addEdge("populateLayerFieldInfo", "agent").addEdge("agent", "tools").addEdge("tools",
|
|
2557
|
+
).addEdge("populateLayerFieldInfo", "agent").addEdge("agent", "tools").addEdge("tools", q).addEdge("earlyExit", q), Zo = String.raw`- **layerStyling** — User wants to change how features are drawn or styled on the map based on their data, such as applying color, size, transparency, symbols, or charts according to field values.
|
|
2524
2558
|
_Example: “Color points by sales amount”_
|
|
2525
2559
|
_Example: “Show population density with a color gradient”_
|
|
2526
2560
|
_Example: “Create a relationship map between height and depth”_
|
|
2527
|
-
_Example: “Vary circle sizes according to population”_`,
|
|
2561
|
+
_Example: “Vary circle sizes according to population”_`, Ce = {
|
|
2528
2562
|
id: "layerStyling",
|
|
2529
2563
|
name: "Layer Styling Agent",
|
|
2530
|
-
description:
|
|
2531
|
-
createGraph:
|
|
2532
|
-
workspace:
|
|
2533
|
-
},
|
|
2564
|
+
description: Zo,
|
|
2565
|
+
createGraph: Ho,
|
|
2566
|
+
workspace: Pe
|
|
2567
|
+
}, Me = w.Root({
|
|
2534
2568
|
// Execution context provided by the orchestrator for this agent invocation.
|
|
2535
2569
|
agentExecutionContext: w({
|
|
2536
2570
|
reducer: K,
|
|
@@ -2547,14 +2581,14 @@ const Ne = w.Root({
|
|
|
2547
2581
|
default: () => ""
|
|
2548
2582
|
}),
|
|
2549
2583
|
summary: w({
|
|
2550
|
-
reducer:
|
|
2584
|
+
reducer: j,
|
|
2551
2585
|
default: () => ""
|
|
2552
2586
|
}),
|
|
2553
2587
|
status: w({
|
|
2554
|
-
reducer:
|
|
2588
|
+
reducer: j,
|
|
2555
2589
|
default: () => "success"
|
|
2556
2590
|
})
|
|
2557
|
-
}),
|
|
2591
|
+
}), Jo = (e, t) => {
|
|
2558
2592
|
const r = Array.from(e.values()).find(
|
|
2559
2593
|
({ layerItem: n }) => n.title?.toLowerCase().includes(t.toLowerCase())
|
|
2560
2594
|
);
|
|
@@ -2567,20 +2601,20 @@ const Ne = w.Root({
|
|
|
2567
2601
|
return `**${r.layerItem.title}** has ${a.length} field(s):
|
|
2568
2602
|
|
|
2569
2603
|
${o}`;
|
|
2570
|
-
},
|
|
2604
|
+
}, Yo = async ({ layerTitle: e }, t) => {
|
|
2571
2605
|
const r = x(t, "layersAndFieldsRegistry");
|
|
2572
|
-
return
|
|
2573
|
-
},
|
|
2606
|
+
return Jo(r, e);
|
|
2607
|
+
}, Xo = b(Yo, {
|
|
2574
2608
|
name: "listLayerFields",
|
|
2575
2609
|
description: "Lists all fields for a given layer by title. Use when the user asks to see fields, columns, or attributes of a specific layer.",
|
|
2576
|
-
schema:
|
|
2577
|
-
layerTitle:
|
|
2610
|
+
schema: i.object({
|
|
2611
|
+
layerTitle: i.string().describe("The title or partial title of the layer to list fields for.")
|
|
2578
2612
|
})
|
|
2579
|
-
}),
|
|
2613
|
+
}), Oe = [Xo], en = (e) => {
|
|
2580
2614
|
if (!e || e.size === 0)
|
|
2581
2615
|
return "No layers available in this map.";
|
|
2582
2616
|
const t = Array.from(e.values()).map(({ layerItem: r, fieldRegistry: a }, o) => {
|
|
2583
|
-
const n = Array.from(a.values()).map((
|
|
2617
|
+
const n = Array.from(a.values()).map((s) => s.name).slice(0, 10).join(", "), c = a.size > 10 ? ` (and ${a.size - 10} more)` : "";
|
|
2584
2618
|
return `${o + 1}. "${r.title}". Description: ${r.description}
|
|
2585
2619
|
Fields: ${n}${c}`;
|
|
2586
2620
|
}).join(`
|
|
@@ -2589,29 +2623,29 @@ ${o}`;
|
|
|
2589
2623
|
return `This map contains ${e.size} layer(s):
|
|
2590
2624
|
|
|
2591
2625
|
${t}`;
|
|
2592
|
-
},
|
|
2626
|
+
}, tn = (e) => {
|
|
2593
2627
|
const t = e?.list() ?? [];
|
|
2594
2628
|
return t.length ? t.map((r) => `- ${r.agent.name}: ${r.agent.description}`).join(`
|
|
2595
2629
|
`) : "No agents currently available.";
|
|
2596
2630
|
};
|
|
2597
|
-
async function
|
|
2631
|
+
async function rn(e, t) {
|
|
2598
2632
|
const r = await L("help_prompt"), a = x(t, "layersAndFieldsRegistry"), o = x(t, "agentRegistry");
|
|
2599
2633
|
try {
|
|
2600
|
-
const n = await
|
|
2634
|
+
const n = await D({
|
|
2601
2635
|
promptText: r,
|
|
2602
2636
|
modelTier: "fast",
|
|
2603
|
-
tools:
|
|
2637
|
+
tools: Oe,
|
|
2604
2638
|
inputVariables: {
|
|
2605
|
-
layerSummary:
|
|
2606
|
-
agents:
|
|
2639
|
+
layerSummary: en(a),
|
|
2640
|
+
agents: tn(o),
|
|
2607
2641
|
assignedTask: e.agentExecutionContext.assignedTask,
|
|
2608
2642
|
userRequest: e.agentExecutionContext.userRequest,
|
|
2609
2643
|
priorSteps: e.agentExecutionContext.priorSteps
|
|
2610
2644
|
}
|
|
2611
|
-
}), c = n.content.toString(),
|
|
2645
|
+
}), c = n.content.toString(), s = [...e.agentExecutionContext.messages, n];
|
|
2612
2646
|
return {
|
|
2613
2647
|
...e,
|
|
2614
|
-
agentExecutionContext: { ...e.agentExecutionContext, messages:
|
|
2648
|
+
agentExecutionContext: { ...e.agentExecutionContext, messages: s },
|
|
2615
2649
|
outputMessage: c,
|
|
2616
2650
|
summary: "Provided map-related help based on the assigned task.",
|
|
2617
2651
|
status: "success"
|
|
@@ -2626,13 +2660,13 @@ async function Bo(e, t) {
|
|
|
2626
2660
|
};
|
|
2627
2661
|
}
|
|
2628
2662
|
}
|
|
2629
|
-
const
|
|
2630
|
-
async function
|
|
2631
|
-
const a = await new
|
|
2663
|
+
const an = (e, t) => Q(["agentRegistry"], "Help Agent")(e, t);
|
|
2664
|
+
async function on(e, t) {
|
|
2665
|
+
const a = await new P(Oe).invoke({ messages: e.agentExecutionContext.messages }, t), o = [...e.agentExecutionContext.messages, ...a.messages], n = a.messages.map((c) => c.text).join(`
|
|
2632
2666
|
`);
|
|
2633
2667
|
return { ...e, agentExecutionContext: { ...e.agentExecutionContext, messages: o }, outputMessage: n };
|
|
2634
2668
|
}
|
|
2635
|
-
const
|
|
2669
|
+
const nn = () => new V(Me).addNode("requireHelpServices", an).addNode("agent", rn).addNode("tools", on).addEdge(W, "requireHelpServices").addEdge("requireHelpServices", "agent").addConditionalEdges("agent", (t) => (t.agentExecutionContext.messages[t.agentExecutionContext.messages.length - 1]?.tool_calls?.length ?? 0) > 0 ? "tools" : q).addEdge("tools", q), sn = String.raw`- **help** — Enables users to ask questions about the map, layers, fields, and it's capabilities.
|
|
2636
2670
|
|
|
2637
2671
|
_Example: “Tell me about this map”_
|
|
2638
2672
|
_Example: “List all layers in this map”_
|
|
@@ -2645,13 +2679,13 @@ const Ho = () => new V(ze).addNode("requireHelpServices", Qo).addNode("agent", B
|
|
|
2645
2679
|
|
|
2646
2680
|
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 accordingly.
|
|
2647
2681
|
_Example: "Create a chart"_
|
|
2648
|
-
_Example: "Create a table"_`,
|
|
2682
|
+
_Example: "Create a table"_`, Is = {
|
|
2649
2683
|
id: "help",
|
|
2650
2684
|
name: "Help Agent",
|
|
2651
|
-
description:
|
|
2652
|
-
createGraph:
|
|
2653
|
-
workspace:
|
|
2654
|
-
},
|
|
2685
|
+
description: sn,
|
|
2686
|
+
createGraph: nn,
|
|
2687
|
+
workspace: Me
|
|
2688
|
+
}, Ge = w.Root({
|
|
2655
2689
|
// Execution context provided by the orchestrator for this agent invocation.
|
|
2656
2690
|
agentExecutionContext: w({
|
|
2657
2691
|
reducer: K,
|
|
@@ -2670,33 +2704,33 @@ const Ho = () => new V(ze).addNode("requireHelpServices", Qo).addNode("agent", B
|
|
|
2670
2704
|
intent: w({
|
|
2671
2705
|
reducer: (e, t) => t
|
|
2672
2706
|
})
|
|
2673
|
-
}),
|
|
2707
|
+
}), H = {
|
|
2674
2708
|
conversationId: ""
|
|
2675
|
-
},
|
|
2676
|
-
function
|
|
2709
|
+
}, cn = ["linkChartView"], ln = ["knowledgeGraph"];
|
|
2710
|
+
function ae(e) {
|
|
2677
2711
|
const r = e?.configurable?.context;
|
|
2678
2712
|
if (!r || typeof r != "object")
|
|
2679
2713
|
throw new Error("ArcgisKnowledgeAgent context missing");
|
|
2680
|
-
const a =
|
|
2714
|
+
const a = cn.filter((o) => !(o in r));
|
|
2681
2715
|
if (a.length)
|
|
2682
2716
|
throw new Error(`Link Chart context missing: ${a.join(", ")}`);
|
|
2683
2717
|
return r;
|
|
2684
2718
|
}
|
|
2685
|
-
function
|
|
2719
|
+
function pe(e) {
|
|
2686
2720
|
const r = e?.configurable?.context;
|
|
2687
2721
|
if (!r || typeof r != "object")
|
|
2688
2722
|
throw new Error("ArcgisKnowledgeAgent context missing");
|
|
2689
|
-
const a =
|
|
2723
|
+
const a = ln.filter((o) => !(o in r));
|
|
2690
2724
|
if (a.length)
|
|
2691
2725
|
throw new Error(`Knowledge Graph context missing: ${a.join(", ")}`);
|
|
2692
2726
|
return r;
|
|
2693
2727
|
}
|
|
2694
|
-
class
|
|
2728
|
+
class dn {
|
|
2695
2729
|
constructor(t) {
|
|
2696
|
-
this.dataModel = t, this.kind = "GraphQueryGenerationRequest", this.explainQuery = !0, this.schemaInformation =
|
|
2730
|
+
this.dataModel = t, this.kind = "GraphQueryGenerationRequest", this.explainQuery = !0, this.schemaInformation = me.fromDataModel(t);
|
|
2697
2731
|
}
|
|
2698
2732
|
}
|
|
2699
|
-
class
|
|
2733
|
+
class me {
|
|
2700
2734
|
constructor() {
|
|
2701
2735
|
this.schemaType = "ArcgisGraphSchema", this.entityTypes = [], this.relationshipTypes = [], this.identifierInfo = {
|
|
2702
2736
|
mappingInfo: {
|
|
@@ -2706,14 +2740,14 @@ class le {
|
|
|
2706
2740
|
};
|
|
2707
2741
|
}
|
|
2708
2742
|
static fromDataModel(t) {
|
|
2709
|
-
const r = new
|
|
2743
|
+
const r = new me();
|
|
2710
2744
|
for (const a of t.entityTypes)
|
|
2711
2745
|
r.entityTypes.push(G.fromEntityType(a));
|
|
2712
2746
|
for (const a of t.relationshipTypes)
|
|
2713
|
-
r.relationshipTypes.push(
|
|
2747
|
+
r.relationshipTypes.push(un.fromRelationshipType(a));
|
|
2714
2748
|
return r.identifierInfo = {
|
|
2715
2749
|
mappingInfo: {
|
|
2716
|
-
identifierMapsTo:
|
|
2750
|
+
identifierMapsTo: pn(
|
|
2717
2751
|
t.identifierInfo.identifierMappingInfo.identifierInfoType
|
|
2718
2752
|
),
|
|
2719
2753
|
identifierPropertyName: t.identifierInfo.identifierMappingInfo.uniformPropertyIdentifier.identifierPropertyName
|
|
@@ -2727,13 +2761,13 @@ class G {
|
|
|
2727
2761
|
}
|
|
2728
2762
|
static fromEntityType(t) {
|
|
2729
2763
|
const r = new G();
|
|
2730
|
-
r.name = t.name, r.alias = t.alias ? t.alias : void 0, r.role =
|
|
2764
|
+
r.name = t.name, r.alias = t.alias ? t.alias : void 0, r.role = mn(t.role);
|
|
2731
2765
|
for (const a of t.properties) {
|
|
2732
2766
|
const o = {
|
|
2733
2767
|
name: a.name,
|
|
2734
2768
|
alias: a.alias ? a.alias : void 0,
|
|
2735
2769
|
fieldType: a.fieldType,
|
|
2736
|
-
role:
|
|
2770
|
+
role: hn(a.role),
|
|
2737
2771
|
geometryDef: a.fieldType === "esriFieldTypeGeometry" ? {
|
|
2738
2772
|
geometryType: a.geometryType ?? "esriGeometryAny",
|
|
2739
2773
|
hasM: a.hasM ? a.hasM : void 0,
|
|
@@ -2745,7 +2779,7 @@ class G {
|
|
|
2745
2779
|
return r;
|
|
2746
2780
|
}
|
|
2747
2781
|
}
|
|
2748
|
-
class
|
|
2782
|
+
class un extends G {
|
|
2749
2783
|
constructor() {
|
|
2750
2784
|
super(...arguments), this.observedEndPoints = [];
|
|
2751
2785
|
}
|
|
@@ -2760,7 +2794,7 @@ class en extends G {
|
|
|
2760
2794
|
return r;
|
|
2761
2795
|
}
|
|
2762
2796
|
}
|
|
2763
|
-
const
|
|
2797
|
+
const pn = (e) => {
|
|
2764
2798
|
switch (e) {
|
|
2765
2799
|
case "esriIdentifierInfoTypeUNSPECIFIED":
|
|
2766
2800
|
return "UNSPECIFIED";
|
|
@@ -2771,7 +2805,7 @@ const tn = (e) => {
|
|
|
2771
2805
|
default:
|
|
2772
2806
|
return e;
|
|
2773
2807
|
}
|
|
2774
|
-
},
|
|
2808
|
+
}, mn = (e) => {
|
|
2775
2809
|
switch (e) {
|
|
2776
2810
|
case "Regular":
|
|
2777
2811
|
return "esriGraphNamedObjectRegular";
|
|
@@ -2783,7 +2817,7 @@ const tn = (e) => {
|
|
|
2783
2817
|
return e;
|
|
2784
2818
|
}
|
|
2785
2819
|
};
|
|
2786
|
-
function
|
|
2820
|
+
function hn(e) {
|
|
2787
2821
|
switch (e) {
|
|
2788
2822
|
case "esriGraphPropertyRegular":
|
|
2789
2823
|
return "Regular";
|
|
@@ -2821,41 +2855,41 @@ function an(e) {
|
|
|
2821
2855
|
return "Regular";
|
|
2822
2856
|
}
|
|
2823
2857
|
}
|
|
2824
|
-
async function
|
|
2825
|
-
const { graphQuery: o, explanation: n } = await
|
|
2858
|
+
async function gn(e, t, r, a) {
|
|
2859
|
+
const { graphQuery: o, explanation: n } = await he(e, t, r, a);
|
|
2826
2860
|
return `Generated Graph Query:
|
|
2827
2861
|
${o}
|
|
2828
2862
|
|
|
2829
2863
|
Explanation: ${n}`;
|
|
2830
2864
|
}
|
|
2831
|
-
async function
|
|
2865
|
+
async function he(e, t, r, a) {
|
|
2832
2866
|
const o = {
|
|
2833
2867
|
message: e,
|
|
2834
|
-
context: new
|
|
2868
|
+
context: new dn(t)
|
|
2835
2869
|
};
|
|
2836
|
-
|
|
2837
|
-
const n = await
|
|
2870
|
+
H.conversationId && (o.conversationId = H.conversationId), await g({ text: "Attempting to generate a cypher query from your prompt..." }, a);
|
|
2871
|
+
const n = await be(`${r}/chat`, {
|
|
2838
2872
|
method: "post",
|
|
2839
2873
|
body: JSON.stringify(o),
|
|
2840
2874
|
headers: {
|
|
2841
2875
|
"Content-Type": "application/json",
|
|
2842
|
-
token:
|
|
2876
|
+
token: xe.findCredential(_.getDefault().url)?.token ?? ""
|
|
2843
2877
|
}
|
|
2844
2878
|
});
|
|
2845
2879
|
if (n.httpStatus !== 200)
|
|
2846
2880
|
throw new Error(`Graph query service returned an error: ${n.httpStatus}`, {
|
|
2847
2881
|
cause: n.data
|
|
2848
2882
|
});
|
|
2849
|
-
|
|
2883
|
+
H.conversationId || (H.conversationId = n.data.conversationId);
|
|
2850
2884
|
let c = !1;
|
|
2851
|
-
const
|
|
2885
|
+
const s = Date.now();
|
|
2852
2886
|
let l = n.data.sequenceNumber, d = "", u = "", p = 1;
|
|
2853
2887
|
for (; !c; ) {
|
|
2854
2888
|
await new Promise((y) => setTimeout(y, 1e3)), await g(
|
|
2855
2889
|
{ text: `Periodically requesting status of job from ArcGIS AI Services${"...".substring(0, p)}` },
|
|
2856
2890
|
a
|
|
2857
2891
|
), p = p % 3 + 1;
|
|
2858
|
-
const
|
|
2892
|
+
const m = await be(`${r}/chat`, {
|
|
2859
2893
|
method: "post",
|
|
2860
2894
|
body: JSON.stringify({
|
|
2861
2895
|
conversationId: n.data.conversationId,
|
|
@@ -2864,48 +2898,48 @@ async function de(e, t, r, a) {
|
|
|
2864
2898
|
}),
|
|
2865
2899
|
headers: {
|
|
2866
2900
|
"Content-Type": "application/json",
|
|
2867
|
-
token:
|
|
2901
|
+
token: xe.findCredential(_.getDefault().url)?.token ?? ""
|
|
2868
2902
|
}
|
|
2869
2903
|
});
|
|
2870
|
-
if (
|
|
2871
|
-
throw new Error(`Graph query service polling returned an error: ${
|
|
2872
|
-
cause:
|
|
2904
|
+
if (m.httpStatus !== 200)
|
|
2905
|
+
throw new Error(`Graph query service polling returned an error: ${m.httpStatus}`, {
|
|
2906
|
+
cause: m.data
|
|
2873
2907
|
});
|
|
2874
|
-
if (
|
|
2875
|
-
d =
|
|
2876
|
-
else if (!
|
|
2908
|
+
if (m.data.context)
|
|
2909
|
+
d = m.data.context.graphQuery, u = m.data.message || "";
|
|
2910
|
+
else if (!m.data.hasMore)
|
|
2877
2911
|
c = !0;
|
|
2878
|
-
else if (Date.now() -
|
|
2912
|
+
else if (Date.now() - s > 6e4)
|
|
2879
2913
|
throw new Error("Graph query service polling timed out after 1 minute.");
|
|
2880
|
-
l =
|
|
2914
|
+
l = m.data.sequenceNumber;
|
|
2881
2915
|
}
|
|
2882
2916
|
return { graphQuery: d, explanation: u };
|
|
2883
2917
|
}
|
|
2884
|
-
function
|
|
2918
|
+
function Z(e, t) {
|
|
2885
2919
|
if (!(!e || typeof e != "object")) {
|
|
2886
|
-
if (
|
|
2920
|
+
if (fn(e))
|
|
2887
2921
|
for (const r of e.path)
|
|
2888
|
-
|
|
2889
|
-
else if (
|
|
2922
|
+
Z(r, t);
|
|
2923
|
+
else if (yn(e))
|
|
2890
2924
|
t.set(`${e.typeName}__${e.id}`, { id: e.id, typeName: e.typeName });
|
|
2891
2925
|
else if (Array.isArray(e))
|
|
2892
2926
|
for (const r of e)
|
|
2893
|
-
|
|
2894
|
-
else if (
|
|
2927
|
+
Z(r, t);
|
|
2928
|
+
else if (wn(e))
|
|
2895
2929
|
for (const r of Object.values(e.properties ?? {}))
|
|
2896
|
-
|
|
2930
|
+
Z(r, t);
|
|
2897
2931
|
}
|
|
2898
2932
|
}
|
|
2899
|
-
function
|
|
2933
|
+
function yn(e) {
|
|
2900
2934
|
return !e || typeof e != "object" || Array.isArray(e) ? !1 : "id" in e && "typeName" in e;
|
|
2901
2935
|
}
|
|
2902
|
-
function
|
|
2936
|
+
function fn(e) {
|
|
2903
2937
|
return !e || typeof e != "object" || Array.isArray(e) ? !1 : e && "path" in e && Array.isArray(e.path);
|
|
2904
2938
|
}
|
|
2905
|
-
function
|
|
2939
|
+
function wn(e) {
|
|
2906
2940
|
return !e || typeof e != "object" || Array.isArray(e) || "id" in e ? !1 : "properties" in e && typeof e.properties == "object";
|
|
2907
2941
|
}
|
|
2908
|
-
function
|
|
2942
|
+
function bn(e, t) {
|
|
2909
2943
|
const r = [];
|
|
2910
2944
|
for (const a of [...t.dataModel.entityTypes, ...t.dataModel.relationshipTypes]) {
|
|
2911
2945
|
const o = e.getMemberIdsByType(a.name);
|
|
@@ -2914,7 +2948,7 @@ function ln(e, t) {
|
|
|
2914
2948
|
}
|
|
2915
2949
|
return r;
|
|
2916
2950
|
}
|
|
2917
|
-
const
|
|
2951
|
+
const xn = async (e) => {
|
|
2918
2952
|
const t = /* @__PURE__ */ new Map(), r = e.resultRowsStream.getReader();
|
|
2919
2953
|
for (; ; ) {
|
|
2920
2954
|
const { done: a, value: o } = await r.read();
|
|
@@ -2922,12 +2956,12 @@ const dn = async (e) => {
|
|
|
2922
2956
|
break;
|
|
2923
2957
|
for (const n of o)
|
|
2924
2958
|
for (const c of n)
|
|
2925
|
-
|
|
2959
|
+
Z(c, t);
|
|
2926
2960
|
}
|
|
2927
2961
|
return Array.from(t.values());
|
|
2928
2962
|
};
|
|
2929
|
-
async function
|
|
2930
|
-
const { graphQuery: n, explanation: c } = await
|
|
2963
|
+
async function Sn(e, t, r, a, o) {
|
|
2964
|
+
const { graphQuery: n, explanation: c } = await he(
|
|
2931
2965
|
e,
|
|
2932
2966
|
t.dataModel,
|
|
2933
2967
|
r,
|
|
@@ -2937,16 +2971,16 @@ async function un(e, t, r, a, o) {
|
|
|
2937
2971
|
{ text: `Attempting to execute query: ${n.substring(0, 500)}${n.length > 500 ? "..." : ""}` },
|
|
2938
2972
|
o
|
|
2939
2973
|
);
|
|
2940
|
-
const
|
|
2974
|
+
const s = await Et(
|
|
2941
2975
|
t,
|
|
2942
|
-
new
|
|
2976
|
+
new Ie({
|
|
2943
2977
|
openCypherQuery: n
|
|
2944
2978
|
}),
|
|
2945
2979
|
{
|
|
2946
2980
|
signal: o?.signal,
|
|
2947
2981
|
timeout: o?.timeout
|
|
2948
2982
|
}
|
|
2949
|
-
), l = await
|
|
2983
|
+
), l = await xn(s);
|
|
2950
2984
|
return await g(
|
|
2951
2985
|
{
|
|
2952
2986
|
text: `Query Results parsed into ${l.length} unique relationships and entities. Atempting to add to link chart...`
|
|
@@ -2957,11 +2991,11 @@ ${n}
|
|
|
2957
2991
|
|
|
2958
2992
|
Explanation: ${c}`;
|
|
2959
2993
|
}
|
|
2960
|
-
async function
|
|
2961
|
-
const { knowledgeGraph: r } =
|
|
2994
|
+
async function Ve({ prompt: e }, t) {
|
|
2995
|
+
const { knowledgeGraph: r } = pe(t), { linkChartView: a } = ae(t), n = _.getDefault().helperServices, c = await L("arcgis_knowledge_current_lc_context"), s = bn(a.map, r), l = `${e}
|
|
2962
2996
|
|
|
2963
|
-
${c}${JSON.stringify(
|
|
2964
|
-
return await
|
|
2997
|
+
${c}${JSON.stringify(s)}`;
|
|
2998
|
+
return await Sn(
|
|
2965
2999
|
l,
|
|
2966
3000
|
r,
|
|
2967
3001
|
`${n.aiAssistantServices.url}${n.aiAssistantServices.graphQueryAssistant}`,
|
|
@@ -2969,22 +3003,22 @@ ${c}${JSON.stringify(i)}`;
|
|
|
2969
3003
|
t
|
|
2970
3004
|
);
|
|
2971
3005
|
}
|
|
2972
|
-
const
|
|
2973
|
-
prompt:
|
|
2974
|
-
}),
|
|
3006
|
+
const vn = i.object({
|
|
3007
|
+
prompt: i.string().describe("The user's inquiry into the knowledge graph that needs to be run.")
|
|
3008
|
+
}), We = b(Ve, {
|
|
2975
3009
|
name: "addRecords",
|
|
2976
3010
|
description: "Adds records (entities or relationships) to the current link chart visualization from an inquiry into the knowledge graph data. The inquiry will retrieve data from the graph database that will serve as the basis for the records to be added to the link chart. The user should have explicitly requested to add records to the current link chart from their prompt.",
|
|
2977
|
-
schema:
|
|
3011
|
+
schema: vn
|
|
2978
3012
|
});
|
|
2979
|
-
async function
|
|
3013
|
+
async function Tn(e, t) {
|
|
2980
3014
|
return await t.map.applyLayout(e), `Successfully applied layout: ${e}.`;
|
|
2981
3015
|
}
|
|
2982
|
-
async function
|
|
2983
|
-
const { linkChartView: r } =
|
|
2984
|
-
return await
|
|
3016
|
+
async function En({ layout: e }, t) {
|
|
3017
|
+
const { linkChartView: r } = ae(t);
|
|
3018
|
+
return await Tn(e, r);
|
|
2985
3019
|
}
|
|
2986
|
-
const
|
|
2987
|
-
layout:
|
|
3020
|
+
const Cn = i.object({
|
|
3021
|
+
layout: i.enum([
|
|
2988
3022
|
"organic-standard",
|
|
2989
3023
|
"organic-community",
|
|
2990
3024
|
"basic-grid",
|
|
@@ -2997,47 +3031,47 @@ const gn = s.object({
|
|
|
2997
3031
|
]).describe(
|
|
2998
3032
|
"The layout mode to apply to the link chart. The value must be one of the following: organic-standard, organic-community, basic-grid, hierarchical-bottom-to-top, radial-root-centric, tree-left-to-right, geographic-organic-standard, chronological-mono-timeline, chronological-multi-timeline"
|
|
2999
3033
|
)
|
|
3000
|
-
}),
|
|
3034
|
+
}), Rn = b(En, {
|
|
3001
3035
|
name: "applyLayout",
|
|
3002
3036
|
description: "Apply a diagram layout to the link chart",
|
|
3003
|
-
schema:
|
|
3037
|
+
schema: Cn
|
|
3004
3038
|
});
|
|
3005
|
-
function
|
|
3039
|
+
function $n(e, t) {
|
|
3006
3040
|
return t.map.changeNonspatialDataDisplay(e), `Successfully applied nonspatial visibility setting: ${e}.`;
|
|
3007
3041
|
}
|
|
3008
|
-
function
|
|
3009
|
-
const { linkChartView: r } =
|
|
3010
|
-
return
|
|
3042
|
+
function kn({ setting: e }, t) {
|
|
3043
|
+
const { linkChartView: r } = ae(t);
|
|
3044
|
+
return $n(e, r);
|
|
3011
3045
|
}
|
|
3012
|
-
const
|
|
3013
|
-
setting:
|
|
3014
|
-
}),
|
|
3046
|
+
const Fn = i.object({
|
|
3047
|
+
setting: i.enum(["hidden", "visible"]).describe("The setting of nonspatial visibility")
|
|
3048
|
+
}), qn = b(kn, {
|
|
3015
3049
|
name: "changeNonspatialVisibility",
|
|
3016
3050
|
description: "Change whether or not nonspatial data is visible in the link chart. The value must be either 'hidden' or 'visible'.",
|
|
3017
|
-
schema:
|
|
3051
|
+
schema: Fn
|
|
3018
3052
|
});
|
|
3019
|
-
async function
|
|
3020
|
-
const { graphQuery: n, explanation: c } = await
|
|
3053
|
+
async function Ln(e, t, r, a, o) {
|
|
3054
|
+
const { graphQuery: n, explanation: c } = await he(
|
|
3021
3055
|
e,
|
|
3022
3056
|
t.dataModel,
|
|
3023
3057
|
r,
|
|
3024
3058
|
o
|
|
3025
3059
|
);
|
|
3026
3060
|
await g({ text: `Attempting to create link chart from derived query: ${n}` }, o);
|
|
3027
|
-
const
|
|
3061
|
+
const s = await Ct.fromCypherQuery(
|
|
3028
3062
|
t,
|
|
3029
|
-
new
|
|
3063
|
+
new Ie({
|
|
3030
3064
|
openCypherQuery: n
|
|
3031
3065
|
})
|
|
3032
3066
|
);
|
|
3033
|
-
return await g({ text: "Link chart created successfully, loading..." }, o), a.map =
|
|
3067
|
+
return await g({ text: "Link chart created successfully, loading..." }, o), a.map = s, await s.load(), await a.when(), `Link chart created successfully. Cypher Query used to create the link chart:
|
|
3034
3068
|
${n}
|
|
3035
3069
|
|
|
3036
3070
|
Explanation: ${c}`;
|
|
3037
3071
|
}
|
|
3038
|
-
async function
|
|
3039
|
-
const { knowledgeGraph: r } =
|
|
3040
|
-
return await
|
|
3072
|
+
async function Ke({ prompt: e }, t) {
|
|
3073
|
+
const { knowledgeGraph: r } = pe(t), { linkChartView: a } = ae(t), n = _.getDefault().helperServices;
|
|
3074
|
+
return await Ln(
|
|
3041
3075
|
e,
|
|
3042
3076
|
r,
|
|
3043
3077
|
`${n.aiAssistantServices.url}${n.aiAssistantServices.graphQueryAssistant}`,
|
|
@@ -3045,72 +3079,72 @@ async function De({ prompt: e }, t) {
|
|
|
3045
3079
|
t
|
|
3046
3080
|
);
|
|
3047
3081
|
}
|
|
3048
|
-
const
|
|
3049
|
-
prompt:
|
|
3082
|
+
const In = i.object({
|
|
3083
|
+
prompt: i.string().describe(
|
|
3050
3084
|
"The user's inquiry into the knowledge graph that needs to be transformed into a link chart visualization."
|
|
3051
3085
|
)
|
|
3052
|
-
}),
|
|
3086
|
+
}), Be = b(Ke, {
|
|
3053
3087
|
name: "createLinkChart",
|
|
3054
3088
|
description: "Creates a new link chart visualization from an inquiry into the knowledge graph data. The inquiry will retrieve data from the graph database that will serve as the basis for the new link chart. The user should have explicitly requested the creation of a new link chart from their prompt.",
|
|
3055
|
-
schema:
|
|
3089
|
+
schema: In
|
|
3056
3090
|
});
|
|
3057
|
-
async function
|
|
3058
|
-
const { knowledgeGraph: r } =
|
|
3059
|
-
return await
|
|
3091
|
+
async function Qe({ prompt: e }, t) {
|
|
3092
|
+
const { knowledgeGraph: r } = pe(t), o = _.getDefault().helperServices;
|
|
3093
|
+
return await gn(
|
|
3060
3094
|
e,
|
|
3061
3095
|
r.dataModel,
|
|
3062
3096
|
`${o.aiAssistantServices.url}${o.aiAssistantServices.graphQueryAssistant}`,
|
|
3063
3097
|
t
|
|
3064
3098
|
);
|
|
3065
3099
|
}
|
|
3066
|
-
const
|
|
3067
|
-
prompt:
|
|
3068
|
-
}),
|
|
3100
|
+
const Nn = i.object({
|
|
3101
|
+
prompt: i.string().describe("The user's inquiry into the knowledge graph that needs to be translated into a cypher query.")
|
|
3102
|
+
}), ge = b(Qe, {
|
|
3069
3103
|
name: "generateCypher",
|
|
3070
3104
|
description: "Generates an Open Cypher query based on the user's prompt which represents an inquiry into the data of the knowledge service and its graph database, attempting to filter based on certain conditions and traverse specified relationships. The generated query should be syntactically correct and optimized for performance.",
|
|
3071
|
-
schema:
|
|
3072
|
-
}),
|
|
3073
|
-
|
|
3074
|
-
|
|
3075
|
-
|
|
3076
|
-
|
|
3077
|
-
|
|
3078
|
-
],
|
|
3079
|
-
async function
|
|
3105
|
+
schema: Nn
|
|
3106
|
+
}), ye = [
|
|
3107
|
+
Rn,
|
|
3108
|
+
qn,
|
|
3109
|
+
ge,
|
|
3110
|
+
Be,
|
|
3111
|
+
We
|
|
3112
|
+
], An = [ge, Be, We];
|
|
3113
|
+
async function zn(e, t) {
|
|
3080
3114
|
const r = await L("arcgis_knowledge_tool_prompt"), a = {
|
|
3081
3115
|
intent: e.intent
|
|
3082
|
-
}, o = await
|
|
3116
|
+
}, o = await D({
|
|
3083
3117
|
promptText: r,
|
|
3084
3118
|
messages: C(e.agentExecutionContext.messages),
|
|
3085
3119
|
inputVariables: a,
|
|
3086
|
-
tools:
|
|
3087
|
-
}), n = [...e.agentExecutionContext.messages, o],
|
|
3088
|
-
return { ...e, agentExecutionContext: { ...e.agentExecutionContext, messages:
|
|
3120
|
+
tools: ye
|
|
3121
|
+
}), n = [...e.agentExecutionContext.messages, o], s = (o.tool_calls?.length ?? 0) > 0 ? [...n] : [...n, o];
|
|
3122
|
+
return { ...e, agentExecutionContext: { ...e.agentExecutionContext, messages: s } };
|
|
3089
3123
|
}
|
|
3090
|
-
async function
|
|
3091
|
-
const a = await new
|
|
3124
|
+
async function _n(e, t) {
|
|
3125
|
+
const a = await new P(ye).invoke(
|
|
3092
3126
|
{
|
|
3093
3127
|
messages: C(e.agentExecutionContext.messages)
|
|
3094
3128
|
},
|
|
3095
3129
|
t
|
|
3096
|
-
), o = a.messages.map((
|
|
3130
|
+
), o = a.messages.map((s) => s.text).join(`
|
|
3097
3131
|
`);
|
|
3098
3132
|
await g({ text: `Finished executing arcgisKnowledge tool: ${o}` }, t);
|
|
3099
|
-
const n = [...e.agentExecutionContext.messages, ...a.messages], c = a.messages.map((
|
|
3133
|
+
const n = [...e.agentExecutionContext.messages, ...a.messages], c = a.messages.map((s) => s.text).join(`
|
|
3100
3134
|
`);
|
|
3101
3135
|
return { ...e, agentExecutionContext: { ...e.agentExecutionContext, messages: n }, outputMessage: c };
|
|
3102
3136
|
}
|
|
3103
|
-
async function
|
|
3137
|
+
async function jn(e) {
|
|
3104
3138
|
const t = await L("arcgis_knowledge_intent_prompt"), a = {
|
|
3105
|
-
tools:
|
|
3106
|
-
name:
|
|
3107
|
-
description:
|
|
3108
|
-
schema:
|
|
3109
|
-
})).map(({ name:
|
|
3139
|
+
tools: ye.map((s) => ({
|
|
3140
|
+
name: s.name,
|
|
3141
|
+
description: s.description,
|
|
3142
|
+
schema: s.schema
|
|
3143
|
+
})).map(({ name: s, description: l, schema: d }) => `${s}: ${l}, ${JSON.stringify(d)}`).join(`
|
|
3110
3144
|
`)
|
|
3111
|
-
}, o =
|
|
3112
|
-
intent:
|
|
3113
|
-
}), n = await
|
|
3145
|
+
}, o = i.object({
|
|
3146
|
+
intent: i.string()
|
|
3147
|
+
}), n = await Re({
|
|
3114
3148
|
promptText: t,
|
|
3115
3149
|
messages: C(e.agentExecutionContext.messages),
|
|
3116
3150
|
inputVariables: a,
|
|
@@ -3118,35 +3152,35 @@ async function $n(e) {
|
|
|
3118
3152
|
}), c = typeof n.intent == "string" ? n.intent.trim().replace(/^"|"$/gu, "") : "";
|
|
3119
3153
|
return { ...e, intent: c || "" };
|
|
3120
3154
|
}
|
|
3121
|
-
const
|
|
3155
|
+
const Dn = (e, t) => (
|
|
3122
3156
|
//agent services (ex: embeddingsWorker) would go in the array below, if required.
|
|
3123
3157
|
Q([], "ArcgisKnowledge Agent")(e, t)
|
|
3124
3158
|
);
|
|
3125
|
-
async function
|
|
3159
|
+
async function Pn(e, t) {
|
|
3126
3160
|
const r = e.agentExecutionContext.messages[e.agentExecutionContext.messages.length - 1].content;
|
|
3127
3161
|
let a;
|
|
3128
3162
|
if (typeof r != "string")
|
|
3129
3163
|
throw new Error("The original message content must be a string to process server skills.");
|
|
3130
|
-
if (e.intent ===
|
|
3131
|
-
a = await
|
|
3164
|
+
if (e.intent === ge.name)
|
|
3165
|
+
a = await Qe({ prompt: r }, t);
|
|
3132
3166
|
else if (e.intent === "createLinkChart")
|
|
3133
|
-
a = await
|
|
3167
|
+
a = await Ke({ prompt: r }, t);
|
|
3134
3168
|
else if (e.intent === "addRecords")
|
|
3135
|
-
a = await
|
|
3169
|
+
a = await Ve({ prompt: r }, t);
|
|
3136
3170
|
else
|
|
3137
3171
|
throw new Error(`No server skills were successfully invoked matching the name: ${e.intent}`);
|
|
3138
3172
|
return { ...e, outputMessage: a };
|
|
3139
3173
|
}
|
|
3140
|
-
const
|
|
3174
|
+
const Mn = () => new V(Ge).addNode("requireArcgisKnowledgeServices", Dn).addNode("intentLLM", jn).addNode("agent", zn).addNode("serverSkill", Pn).addNode("tools", _n).addEdge(W, "requireArcgisKnowledgeServices").addEdge("requireArcgisKnowledgeServices", "intentLLM").addConditionalEdges(
|
|
3141
3175
|
"intentLLM",
|
|
3142
3176
|
(t) => (
|
|
3143
3177
|
// ts/lint are getting confused here about the type, and the cast resolves it. Without it, there is a ts error
|
|
3144
|
-
|
|
3178
|
+
An.map((r) => r.name).includes(t.intent) ? "serverSkill" : "agent"
|
|
3145
3179
|
)
|
|
3146
3180
|
).addConditionalEdges("agent", (t) => {
|
|
3147
3181
|
const r = t.agentExecutionContext.messages[t.agentExecutionContext.messages.length - 1];
|
|
3148
|
-
return r?.getType() === "ai" && "tool_calls" in r && Array.isArray(r.tool_calls) && r.tool_calls.length > 0 ? "tools" :
|
|
3149
|
-
}).addEdge("tools",
|
|
3182
|
+
return r?.getType() === "ai" && "tool_calls" in r && Array.isArray(r.tool_calls) && r.tool_calls.length > 0 ? "tools" : q;
|
|
3183
|
+
}).addEdge("tools", q), On = String.raw`The purpose of this agent is to work with Knowledge Graph data, a graph database technology that represents and stores data as interconnected entities (nodes) and relationships (edges).
|
|
3150
3184
|
This agent has two categories of skills: those that work with an active link chart visualization of a subset of the data in the knowledge graph, and those that work with the knowledge graph data more generally against the entire dataset in the service and database.
|
|
3151
3185
|
For link charts, the agent enables users to interact with a link chart by adding new entities (also called nodes) or relationships (also called edges), removing existing entities or relationships,
|
|
3152
3186
|
expanding the graph from particular entities, finding relationships between specified entities on the link chart and adding them to the link chart, finding all relationships
|
|
@@ -3178,17 +3212,17 @@ _example: "Find all the products supplied by Supplier X and add them to my visua
|
|
|
3178
3212
|
_example: "Expand the link chart from 'Entity D' to show its direct connections"_
|
|
3179
3213
|
_example: "Find all the cars and then add everything up to two hops away from them on the link chart"_
|
|
3180
3214
|
_example: "Connect Emma and Rob on the link chart if there is a relationship between them"
|
|
3181
|
-
_example: "Discover and add all the relationships originating at 'Entity E' to the link chart"_`,
|
|
3215
|
+
_example: "Discover and add all the relationships originating at 'Entity E' to the link chart"_`, Ns = {
|
|
3182
3216
|
id: "arcgisKnowledge",
|
|
3183
3217
|
name: "ArcgisKnowledge Agent",
|
|
3184
|
-
description:
|
|
3185
|
-
createGraph:
|
|
3186
|
-
workspace:
|
|
3218
|
+
description: On,
|
|
3219
|
+
createGraph: Mn,
|
|
3220
|
+
workspace: Ge
|
|
3187
3221
|
};
|
|
3188
3222
|
export {
|
|
3189
|
-
|
|
3190
|
-
|
|
3191
|
-
|
|
3192
|
-
|
|
3193
|
-
|
|
3223
|
+
Ns as ArcgisKnowledgeAgent,
|
|
3224
|
+
Ls as DataExplorationAgent,
|
|
3225
|
+
Is as HelpAgent,
|
|
3226
|
+
Ce as LayerStylingAgent,
|
|
3227
|
+
qs as NavigationAgent
|
|
3194
3228
|
};
|