@arcgis/ai-agents 5.1.0-next.59 → 5.1.0-next.60

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.
Files changed (2) hide show
  1. package/dist/index.js +541 -541
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -1,48 +1,48 @@
1
- import { Annotation as f, messagesStateReducer as j, StateGraph as M, START as P, END as F, NodeInterrupt as ct } from "@langchain/langgraph/web";
1
+ import { Annotation as f, messagesStateReducer as j, StateGraph as M, START as P, END as F, NodeInterrupt as lt } from "@langchain/langgraph/web";
2
2
  import { invokeToolPrompt as k, sendTraceMessage as m, invokeStructuredPrompt as Ae, invokeTextPrompt as Ne, sendUXSuggestion as L } from "@arcgis/ai-orchestrator";
3
3
  import { tool as b } from "@langchain/core/tools";
4
- import dt from "@arcgis/core/Graphic.js";
4
+ import ct from "@arcgis/core/Graphic.js";
5
5
  import ie from "@arcgis/core/geometry/Point.js";
6
6
  import ke from "@arcgis/core/geometry/Extent.js";
7
- import ut from "@arcgis/core/symbols/PictureMarkerSymbol.js";
8
- import { addressToLocations as ht } from "@arcgis/core/rest/locator.js";
7
+ import dt from "@arcgis/core/symbols/PictureMarkerSymbol.js";
8
+ import { addressToLocations as ut } from "@arcgis/core/rest/locator.js";
9
9
  import O from "@arcgis/core/portal/Portal.js";
10
10
  import se from "@arcgis/core/config.js";
11
11
  import n, { z as N } from "zod";
12
- import { HumanMessage as ze, AIMessage as te } from "@langchain/core/messages";
12
+ import { AIMessage as te } from "@langchain/core/messages";
13
13
  import { ToolNode as z } from "@langchain/langgraph/prebuilt";
14
- import _e from "@arcgis/core/layers/support/FeatureEffect.js";
14
+ import ze from "@arcgis/core/layers/support/FeatureEffect.js";
15
15
  import K from "@arcgis/core/layers/support/FeatureFilter.js";
16
16
  import * as le from "@arcgis/core/geometry/operators/unionOperator.js";
17
17
  import ce from "@arcgis/core/smartMapping/statistics/summaryStatistics.js";
18
18
  import de from "@arcgis/core/smartMapping/statistics/uniqueValues.js";
19
- import je from "@arcgis/core/rest/support/TopFeaturesQuery.js";
20
- import Me from "@arcgis/core/rest/support/TopFilter.js";
21
- import * as mt from "@arcgis/core/geometry/operators/bufferOperator.js";
22
- import pt from "@arcgis/core/rest/support/Query.js";
23
- import { createRenderer as yt } from "@arcgis/core/smartMapping/renderers/pieChart.js";
24
- import { getSchemesByTag as gt, getSchemes as ft } from "@arcgis/core/smartMapping/symbology/pieChart.js";
19
+ import _e from "@arcgis/core/rest/support/TopFeaturesQuery.js";
20
+ import je from "@arcgis/core/rest/support/TopFilter.js";
21
+ import * as ht from "@arcgis/core/geometry/operators/bufferOperator.js";
22
+ import mt from "@arcgis/core/rest/support/Query.js";
23
+ import { createRenderer as pt } from "@arcgis/core/smartMapping/renderers/pieChart.js";
24
+ import { getSchemesByTag as yt, getSchemes as gt } from "@arcgis/core/smartMapping/symbology/pieChart.js";
25
25
  import { getBackgroundColorTheme as Te } from "@arcgis/core/views/support/colorUtils.js";
26
- import { createAgeRenderer as wt, createContinuousRenderer as bt } from "@arcgis/core/smartMapping/renderers/color.js";
26
+ import { createAgeRenderer as ft, createContinuousRenderer as wt } from "@arcgis/core/smartMapping/renderers/color.js";
27
27
  import { getSchemesByTag as ue } from "@arcgis/core/smartMapping/symbology/color.js";
28
- import { createContinuousRenderer as St } from "@arcgis/core/smartMapping/renderers/univariateColorSize.js";
29
- import { createRenderer as vt } from "@arcgis/core/smartMapping/renderers/dotDensity.js";
30
- import { getSchemesByTag as Tt } from "@arcgis/core/smartMapping/symbology/dotDensity.js";
31
- import { createRenderer as xt } from "@arcgis/core/smartMapping/renderers/heatmap.js";
32
- import { getSchemesByTag as Et } from "@arcgis/core/smartMapping/symbology/heatmap.js";
33
- import { createRenderer as $t } from "@arcgis/core/smartMapping/renderers/predominance.js";
34
- import { getSchemesByTag as Ft } from "@arcgis/core/smartMapping/symbology/predominance.js";
35
- import { createRenderer as Rt } from "@arcgis/core/smartMapping/renderers/relationship.js";
36
- import { getSchemesByTag as Lt } from "@arcgis/core/smartMapping/symbology/relationship.js";
37
- import { createAgeRenderer as It, createContinuousRenderer as qt } from "@arcgis/core/smartMapping/renderers/size.js";
38
- import { createRenderer as Ct } from "@arcgis/core/smartMapping/renderers/type.js";
39
- import { getSchemesByTag as At } from "@arcgis/core/smartMapping/symbology/type.js";
40
- import Pe from "@arcgis/core/rest/knowledgeGraph/GraphQueryStreaming.js";
28
+ import { createContinuousRenderer as bt } from "@arcgis/core/smartMapping/renderers/univariateColorSize.js";
29
+ import { createRenderer as St } from "@arcgis/core/smartMapping/renderers/dotDensity.js";
30
+ import { getSchemesByTag as vt } from "@arcgis/core/smartMapping/symbology/dotDensity.js";
31
+ import { createRenderer as Tt } from "@arcgis/core/smartMapping/renderers/heatmap.js";
32
+ import { getSchemesByTag as xt } from "@arcgis/core/smartMapping/symbology/heatmap.js";
33
+ import { createRenderer as Et } from "@arcgis/core/smartMapping/renderers/predominance.js";
34
+ import { getSchemesByTag as $t } from "@arcgis/core/smartMapping/symbology/predominance.js";
35
+ import { createRenderer as Ft } from "@arcgis/core/smartMapping/renderers/relationship.js";
36
+ import { getSchemesByTag as Rt } from "@arcgis/core/smartMapping/symbology/relationship.js";
37
+ import { createAgeRenderer as Lt, createContinuousRenderer as It } from "@arcgis/core/smartMapping/renderers/size.js";
38
+ import { createRenderer as qt } from "@arcgis/core/smartMapping/renderers/type.js";
39
+ import { getSchemesByTag as Ct } from "@arcgis/core/smartMapping/symbology/type.js";
40
+ import Me from "@arcgis/core/rest/knowledgeGraph/GraphQueryStreaming.js";
41
41
  import xe from "@arcgis/core/request.js";
42
42
  import Ee from "@arcgis/core/identity/IdentityManager.js";
43
- import { executeQueryStreaming as Nt } from "@arcgis/core/rest/knowledgeGraphService.js";
44
- import kt from "@arcgis/core/WebLinkChart.js";
45
- const De = f.Root({
43
+ import { executeQueryStreaming as At } from "@arcgis/core/rest/knowledgeGraphService.js";
44
+ import Nt from "@arcgis/core/WebLinkChart.js";
45
+ const Pe = f.Root({
46
46
  // messages: comes from global chat history.
47
47
  // It is safe to append new messages locally, but existing message objects
48
48
  // must be treated as read-only and never mutated.
@@ -84,11 +84,11 @@ ${r}`;
84
84
  reducer: (e, t) => t
85
85
  })
86
86
  });
87
- async function zt(e, t) {
87
+ async function kt(e, t) {
88
88
  const a = O.getDefault().helperServices, o = a.geocode.find((Q) => Q.name === "ArcGIS World Geocoding Service") ?? a.geocode[0];
89
89
  if (!o)
90
90
  throw new Error("No geocoding service found in helperServices.");
91
- const s = o.url, i = `${se.assetsPath?.endsWith("/") ? se.assetsPath : `${se.assetsPath}/`}esri/images/search/search-symbol-32.png`, c = (await ht(s, {
91
+ const s = o.url, i = `${se.assetsPath?.endsWith("/") ? se.assetsPath : `${se.assetsPath}/`}esri/images/search/search-symbol-32.png`, c = (await ut(s, {
92
92
  address: { SingleLine: e },
93
93
  outFields: ["Match_addr"]
94
94
  }))?.[0];
@@ -104,38 +104,38 @@ async function zt(e, t) {
104
104
  x: y,
105
105
  y: w,
106
106
  spatialReference: g
107
- }), $ = new ut({
107
+ }), $ = new dt({
108
108
  url: i,
109
109
  width: 24,
110
110
  height: 24
111
- }), v = new dt({
111
+ }), v = new ct({
112
112
  geometry: E,
113
113
  symbol: $
114
114
  });
115
115
  return t.graphics.removeAll(), t.graphics.add(v), await t.goTo(T), `Successfully zoomed to: ${e}. Location coordinates: x=${y}, y=${w}, wkid=${g.wkid}`;
116
116
  }
117
- const _t = ["mapView"];
117
+ const zt = ["mapView"];
118
118
  function I(e) {
119
119
  const r = e?.configurable?.context;
120
120
  if (!r || typeof r != "object")
121
121
  throw new Error("NavigationAgent context missing");
122
- const a = _t.filter((o) => !(o in r));
122
+ const a = zt.filter((o) => !(o in r));
123
123
  if (a.length)
124
124
  throw new Error(`NavigationAgent context missing: ${a.join(", ")}`);
125
125
  return r;
126
126
  }
127
- async function jt({ address: e }, t) {
127
+ async function _t({ address: e }, t) {
128
128
  const { mapView: r } = I(t);
129
- return await zt(e, r);
129
+ return await kt(e, r);
130
130
  }
131
- const Mt = n.object({
131
+ const jt = n.object({
132
132
  address: n.string().describe("The full address or place name to locate.")
133
- }), Pt = b(jt, {
133
+ }), Mt = b(_t, {
134
134
  name: "goToAddress",
135
135
  description: "Geocodes an address using Esri's World Geocoding Service and zooms the map to that location.",
136
- schema: Mt
136
+ schema: jt
137
137
  });
138
- async function Dt(e, t) {
138
+ async function Pt(e, t) {
139
139
  const a = t.map.bookmarks;
140
140
  if (!a || a.length === 0)
141
141
  throw new Error("No bookmarks found in the map.");
@@ -147,18 +147,18 @@ async function Dt(e, t) {
147
147
  throw new Error(`Bookmark with name "${e}" does not have a valid viewpoint.`);
148
148
  return await t.goTo(s), `Navigated to bookmark: ${e}`;
149
149
  }
150
- async function Gt({ bookmarkName: e }, t) {
150
+ async function Dt({ bookmarkName: e }, t) {
151
151
  const { mapView: r } = I(t);
152
- return await Promise.resolve(Dt(e, r));
152
+ return await Promise.resolve(Pt(e, r));
153
153
  }
154
- const Ot = N.object({
154
+ const Gt = N.object({
155
155
  bookmarkName: N.string().describe("The name of the bookmark to navigate to.")
156
- }), Qt = b(Gt, {
156
+ }), Ot = b(Dt, {
157
157
  name: "goToBookmark",
158
158
  description: "Go to the extent of the bookmark with the given name.",
159
- schema: Ot
159
+ schema: Gt
160
160
  });
161
- async function Vt(e, t, r) {
161
+ async function Qt(e, t, r) {
162
162
  const a = r.map?.allLayers.find((s) => s.id === e);
163
163
  if (!a)
164
164
  return `Error: Layer with id ${e} not found`;
@@ -177,19 +177,19 @@ async function Vt(e, t, r) {
177
177
  return console.error("Error in goToFeatures:", s), `Error: ${s instanceof Error ? s.message : "Unknown error"}`;
178
178
  }
179
179
  }
180
- async function Wt({ layerId: e, where: t }, r) {
180
+ async function Vt({ layerId: e, where: t }, r) {
181
181
  const { mapView: a } = I(r);
182
- return await Vt(e, t, a);
182
+ return await Qt(e, t, a);
183
183
  }
184
- const Bt = N.object({
184
+ const Wt = N.object({
185
185
  layerId: N.string().describe("The layerId of the layer to zoom to."),
186
186
  where: N.string().describe("The sql-92 where clause used to query features to zoom to")
187
- }), Kt = b(Wt, {
187
+ }), Bt = b(Vt, {
188
188
  name: "goToFeatures",
189
189
  description: "Go to the features that match the given filter related to the given layerId.",
190
- schema: Bt
190
+ schema: Wt
191
191
  });
192
- async function Ut(e) {
192
+ async function Kt(e) {
193
193
  const r = new ke({
194
194
  xmin: -180,
195
195
  ymin: -90,
@@ -199,16 +199,16 @@ async function Ut(e) {
199
199
  }).expand(0.7);
200
200
  return await e.goTo(r), "Successfully zoomed to world extent";
201
201
  }
202
- async function Ht(e, t) {
202
+ async function Ut(e, t) {
203
203
  const { mapView: r } = I(t);
204
- return await Ut(r);
204
+ return await Kt(r);
205
205
  }
206
- const Zt = N.object({}), Jt = b(Ht, {
206
+ const Ht = N.object({}), Zt = b(Ut, {
207
207
  name: "goToFullExtent",
208
208
  description: "Zooms the map to the full world extent using Esri's Geocoding Service.",
209
- schema: Zt
209
+ schema: Ht
210
210
  });
211
- async function Yt(e) {
211
+ async function Jt(e) {
212
212
  const r = e.map.initialViewProperties?.viewpoint?.targetGeometry;
213
213
  if (r)
214
214
  await e.goTo(r);
@@ -216,16 +216,16 @@ async function Yt(e) {
216
216
  throw new Error("Initial extent is undefined");
217
217
  return "Successfully zoomed to home extent";
218
218
  }
219
- async function Xt(e, t) {
219
+ async function Yt(e, t) {
220
220
  const { mapView: r } = I(t);
221
- return await Yt(r);
221
+ return await Jt(r);
222
222
  }
223
- const er = n.object({}), tr = b(Xt, {
223
+ const Xt = n.object({}), er = b(Yt, {
224
224
  name: "goToHomeExtent",
225
225
  description: "Go to the initial web map view extent",
226
- schema: er
226
+ schema: Xt
227
227
  });
228
- async function rr(e, t) {
228
+ async function tr(e, t) {
229
229
  await t.when();
230
230
  const r = t.map?.allLayers.find((o) => o.id === e);
231
231
  if (!r)
@@ -233,32 +233,32 @@ async function rr(e, t) {
233
233
  let a;
234
234
  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.";
235
235
  }
236
- async function ar({ layerId: e }, t) {
236
+ async function rr({ layerId: e }, t) {
237
237
  const { mapView: r } = I(t);
238
- return await rr(e, r);
238
+ return await tr(e, r);
239
239
  }
240
- const or = N.object({
240
+ const ar = N.object({
241
241
  layerId: N.string().describe("The id of the layer to navigate to")
242
- }), sr = b(ar, {
242
+ }), or = b(rr, {
243
243
  name: "goToLayer",
244
244
  description: "Zooms the map view to the full extent of the top matching layer.",
245
- schema: or
245
+ schema: ar
246
246
  });
247
- async function nr(e, t) {
247
+ async function sr(e, t) {
248
248
  return await t.goTo({ scale: e }), `Successfully zoomed to: ${e}`;
249
249
  }
250
- async function ir({ scale: e }, t) {
250
+ async function nr({ scale: e }, t) {
251
251
  const { mapView: r } = I(t);
252
- return await nr(e, r);
252
+ return await sr(e, r);
253
253
  }
254
- const lr = n.object({
254
+ const ir = n.object({
255
255
  scale: n.number().describe("The map scale of the view to go to.")
256
- }), cr = b(ir, {
256
+ }), lr = b(nr, {
257
257
  name: "goToScale",
258
258
  description: "Go to the specified view scale.",
259
- schema: lr
259
+ schema: ir
260
260
  });
261
- async function dr(e, t, r) {
261
+ async function cr(e, t, r) {
262
262
  const o = {
263
263
  target: new ie({
264
264
  longitude: e.longitude,
@@ -272,49 +272,49 @@ async function dr(e, t, r) {
272
272
  r?.scale !== void 0 ? `scale 1:${r.scale}` : ""
273
273
  ].filter(Boolean).join(", ")}`;
274
274
  }
275
- async function ur({
275
+ async function dr({
276
276
  center: e,
277
277
  zoom: t,
278
278
  scale: r
279
279
  }, a) {
280
280
  const { mapView: o } = I(a);
281
- return await dr(e, o, { zoom: t, scale: r });
281
+ return await cr(e, o, { zoom: t, scale: r });
282
282
  }
283
- const hr = n.object({
283
+ const ur = n.object({
284
284
  center: n.object({
285
285
  longitude: n.number().describe("The longitude (x-coordinate) of the point to navigate to."),
286
286
  latitude: n.number().describe("The latitude (y-coordinate) of the point to navigate to.")
287
287
  }),
288
288
  zoom: n.number().optional().describe("The zoom level. Higher values = more zoomed in."),
289
289
  scale: n.number().optional().describe("The map scale. Alternative to zoom. Smaller numbers = more zoomed in.")
290
- }), mr = b(ur, {
290
+ }), hr = b(dr, {
291
291
  name: "goToViewpoint",
292
292
  description: "Go to the specified viewpoint. This can contain a combination of scale, center, zoom, etc.",
293
- schema: hr
293
+ schema: ur
294
294
  });
295
- async function pr(e, t) {
295
+ async function mr(e, t) {
296
296
  return await t.goTo({ zoom: e }), `Successfully zoomed to: ${e}`;
297
297
  }
298
- async function yr({ zoom: e }, t) {
298
+ async function pr({ zoom: e }, t) {
299
299
  const { mapView: r } = I(t);
300
- return await pr(e, r);
300
+ return await mr(e, r);
301
301
  }
302
- const gr = n.object({
302
+ const yr = n.object({
303
303
  zoom: n.number().min(1).max(20).describe("The zoom level of the view to go to.")
304
- }), fr = b(yr, {
304
+ }), gr = b(pr, {
305
305
  name: "goToZoom",
306
306
  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.).',
307
- schema: gr
307
+ schema: yr
308
308
  }), he = [
309
- Pt,
310
- Qt,
311
- Kt,
312
- Jt,
313
- tr,
314
- sr,
315
- cr,
316
- mr,
317
- fr
309
+ Mt,
310
+ Ot,
311
+ Bt,
312
+ Zt,
313
+ er,
314
+ or,
315
+ lr,
316
+ hr,
317
+ gr
318
318
  ], $e = /* @__PURE__ */ Object.assign({
319
319
  "../agents/arcgisKnowledge/prompts/arcgis_knowledge_current_lc_context.md": () => import("./arcgis_knowledge_current_lc_context-BIA49RO2.js").then((e) => e.default),
320
320
  "../agents/arcgisKnowledge/prompts/arcgis_knowledge_intent_prompt.md": () => import("./arcgis_knowledge_intent_prompt-AaXBzNVW.js").then((e) => e.default),
@@ -339,14 +339,14 @@ ${Object.keys($e).join(`
339
339
  `)}`);
340
340
  return await t[1]();
341
341
  }
342
- const wr = (e, t = 3) => e.filter((r) => r instanceof ze).slice(-t), x = (e, t = 3) => {
343
- const r = e.map((o, s) => o instanceof ze ? s : -1).filter((o) => o !== -1);
342
+ const fr = (e, t = 3) => e.filter((r) => r.type === "human").slice(-t), x = (e, t = 3) => {
343
+ const r = e.map((o, s) => o.type === "human" ? s : -1).filter((o) => o !== -1);
344
344
  if (r.length === 0)
345
345
  return [];
346
346
  const a = r.length > t ? r[r.length - t] : r[0];
347
347
  return e.slice(a);
348
- }, C = (e, t = " ") => wr(e).map((o) => o.content).join(t).trim();
349
- async function br(e, t) {
348
+ }, C = (e, t = " ") => fr(e).map((o) => o.content).join(t).trim();
349
+ async function wr(e, t) {
350
350
  const r = await R("navigation_tool_prompt"), { mapView: a } = I(t), o = a.map, s = e.vectorSearchLayerResults?.length > 0 ? e.vectorSearchLayerResults.map(
351
351
  (y, w) => `${w + 1}. layerId=${y.id} | title=${y.title ?? ""} | name=${y.name ?? ""} | score=${y.score.toFixed(2)}`
352
352
  ).join(`
@@ -368,7 +368,7 @@ ${i}` : "", u = {
368
368
  }), p = [...e.messages, h], T = (h.tool_calls?.length ?? 0) > 0 ? [...p] : [...p, h];
369
369
  return { ...e, messages: T };
370
370
  }
371
- async function Sr(e, t) {
371
+ async function br(e, t) {
372
372
  const a = await new z(he).invoke(
373
373
  {
374
374
  messages: x(e.messages)
@@ -381,7 +381,7 @@ async function Sr(e, t) {
381
381
  `);
382
382
  return { ...e, messages: s, outputMessage: i };
383
383
  }
384
- async function vr(e, t) {
384
+ async function Sr(e, t) {
385
385
  const r = await R("navigation_intent_prompt"), { mapView: a } = I(t), o = he.map((h) => ({
386
386
  name: h.name,
387
387
  description: h.description,
@@ -406,13 +406,13 @@ const S = (e, t) => {
406
406
  if (a == null)
407
407
  throw new Error(`${t} missing in config.configurable.services`);
408
408
  return a;
409
- }, Tr = 0.7, xr = async (e, t) => {
409
+ }, vr = 0.7, Tr = async (e, t) => {
410
410
  try {
411
411
  const r = C(e.messages);
412
412
  await m({ text: `Similarity search to find layers: ${r}` }, t);
413
413
  const a = S(t, "layerSearch"), o = S(t, "layersAndFieldsRegistry"), s = S(t, "embeddingCache"), l = (await a.searchLayers({
414
414
  text: r,
415
- minScore: Tr,
415
+ minScore: vr,
416
416
  embeddingCache: s
417
417
  })).map(({ id: d, score: u }) => {
418
418
  const h = o.get(d)?.layerItem;
@@ -436,7 +436,7 @@ ${l.map((d) => `- layerId=${d.id} | title=${d.title ?? ""} | name=${d.name ?? ""
436
436
  t
437
437
  ), r;
438
438
  }
439
- }, Fe = 0.7, Er = 10, $r = async (e, t) => {
439
+ }, Fe = 0.7, xr = 10, Er = async (e, t) => {
440
440
  try {
441
441
  const r = C(e.messages);
442
442
  await m({ text: "Similarity search to find fields" }, t);
@@ -447,7 +447,7 @@ ${l.map((d) => `- layerId=${d.id} | title=${d.title ?? ""} | name=${d.name ?? ""
447
447
  text: r,
448
448
  layerIds: i,
449
449
  minScore: Fe,
450
- topResults: Er,
450
+ topResults: xr,
451
451
  embeddingCache: s
452
452
  })).map(({ layerId: u, results: h }) => {
453
453
  const p = o.get(u)?.fieldRegistry;
@@ -490,7 +490,7 @@ ${u.results.map((h) => ` - ${h.name} (${h.score.toFixed(2)})`).join(`
490
490
  if (!o?.[s])
491
491
  throw new Error(`${t} requires services.${s} to be available.`);
492
492
  return r;
493
- }, Fr = (e, t) => D(["layerSearch", "layersAndFieldsRegistry"], "Navigation Agent")(e, t), Rr = () => new M(De).addNode("requireNavigationServices", Fr).addNode("intentLLM", vr).addNode("vectorSearchLayers", xr).addNode("vectorSearchFields", $r).addNode("agent", br).addNode("tools", Sr).addEdge(P, "requireNavigationServices").addEdge("requireNavigationServices", "intentLLM").addConditionalEdges(
493
+ }, $r = (e, t) => D(["layerSearch", "layersAndFieldsRegistry"], "Navigation Agent")(e, t), Fr = () => new M(Pe).addNode("requireNavigationServices", $r).addNode("intentLLM", Sr).addNode("vectorSearchLayers", Tr).addNode("vectorSearchFields", Er).addNode("agent", wr).addNode("tools", br).addEdge(P, "requireNavigationServices").addEdge("requireNavigationServices", "intentLLM").addConditionalEdges(
494
494
  "intentLLM",
495
495
  (t) => t.intent === "goToLayer" || t.intent === "goToFeatures" ? "vectorSearchLayers" : "agent",
496
496
  {
@@ -504,7 +504,7 @@ ${u.results.map((h) => ` - ${h.name} (${h.score.toFixed(2)})`).join(`
504
504
  vectorSearchFields: "vectorSearchFields",
505
505
  agent: "agent"
506
506
  }
507
- ).addEdge("vectorSearchFields", "agent").addEdge("agent", "tools").addEdge("tools", F), Lr = String.raw`- **navigation** — Enables users to interact with the map by navigating to specific locations, layers, features, or extents.
507
+ ).addEdge("vectorSearchFields", "agent").addEdge("agent", "tools").addEdge("tools", F), Rr = String.raw`- **navigation** — Enables users to interact with the map by navigating to specific locations, layers, features, or extents.
508
508
  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.
509
509
 
510
510
  Supported actions:
@@ -523,13 +523,13 @@ ${u.results.map((h) => ` - ${h.name} (${h.score.toFixed(2)})`).join(`
523
523
  _Example: “Center the map on San Francisco at scale 50000”_
524
524
  _Example: “Zoom to the features in the schools layer where city = 'Austin'”_
525
525
  _Example: “Go to the Downtown bookmark”_
526
- _Example: “Where is Mount Rainier?”_`, ki = {
526
+ _Example: “Where is Mount Rainier?”_`, Ni = {
527
527
  id: "navigation",
528
528
  name: "Navigation Agent",
529
- description: Lr,
530
- createGraph: Rr,
531
- workspace: De
532
- }, Ge = f.Root({
529
+ description: Rr,
530
+ createGraph: Fr,
531
+ workspace: Pe
532
+ }, De = f.Root({
533
533
  // Inputs coming from global context
534
534
  messages: f({
535
535
  reducer: j,
@@ -562,7 +562,7 @@ ${r}`;
562
562
  vectorSearchFieldResults: f(),
563
563
  layerFieldInfo: f(),
564
564
  queryResponse: f()
565
- }), Ir = async (e, t) => (await m({ text: "Exiting Data Exploration agent" }, t), e), U = async (e, t) => {
565
+ }), Lr = async (e, t) => (await m({ text: "Exiting Data Exploration agent" }, t), e), U = async (e, t) => {
566
566
  const r = e.tool_calls ?? [];
567
567
  if (r.length === 0) {
568
568
  await m({ text: `LLM did not request any tool calls: ${String(e?.content)}` }, t);
@@ -576,41 +576,41 @@ ${r}`;
576
576
  )
577
577
  )
578
578
  );
579
- }, qr = ["mapView"];
579
+ }, Ir = ["mapView"];
580
580
  function _(e) {
581
581
  const r = e?.configurable?.context;
582
582
  if (!r || typeof r != "object")
583
583
  throw new Error("DataExplorationAgent context missing");
584
- const a = qr.filter((o) => !(o in r));
584
+ const a = Ir.filter((o) => !(o in r));
585
585
  if (a.length)
586
586
  throw new Error(`DataExplorationAgent context missing: ${a.join(", ")}`);
587
587
  return r;
588
588
  }
589
- const Cr = (e) => {
589
+ const qr = (e) => {
590
590
  const t = e.map?.allLayers.filter((a) => a.type === "feature");
591
591
  let r = 0;
592
592
  return t?.forEach((a) => {
593
593
  const o = a;
594
594
  o.featureEffect && (o.featureEffect = null, r++);
595
595
  }), r > 0 ? `Cleared filters from ${r} layer(s). View unchanged.` : "No active filters to clear. View unchanged.";
596
- }, Ar = async (e, t) => {
596
+ }, Cr = async (e, t) => {
597
597
  const { mapView: r } = _(t);
598
- return Cr(r);
599
- }, Nr = b(Ar, {
598
+ return qr(r);
599
+ }, Ar = b(Cr, {
600
600
  name: "clearFilters",
601
601
  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.",
602
602
  schema: n.object({})
603
- }), kr = async (e) => {
603
+ }), Nr = async (e) => {
604
604
  e.map?.allLayers.filter((o) => o.type === "feature")?.forEach((o) => {
605
605
  const s = o;
606
606
  s.featureEffect && (s.featureEffect = null);
607
607
  });
608
608
  const a = e.map.initialViewProperties?.viewpoint?.targetGeometry;
609
609
  return a ? (await e.goTo(a), "Cleared all filters and returned to home extent.") : "Cleared all filters. Could not determine home extent.";
610
- }, zr = async (e, t) => {
610
+ }, kr = async (e, t) => {
611
611
  const { mapView: r } = _(t);
612
- return await kr(r);
613
- }, _r = b(zr, {
612
+ return await Nr(r);
613
+ }, zr = b(kr, {
614
614
  name: "resetMap",
615
615
  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.",
616
616
  schema: n.object({})
@@ -664,7 +664,7 @@ const re = async (e, t) => {
664
664
  }
665
665
  }
666
666
  return { error: "Invalid geometry configuration provided" };
667
- }, jr = async (e, t, r, a, o, s) => {
667
+ }, _r = async (e, t, r, a, o, s) => {
668
668
  const i = e.map?.allLayers.find((c) => c.id === t);
669
669
  if (!i)
670
670
  return { success: !1, error: `Layer '${t}' not found.` };
@@ -682,7 +682,7 @@ const re = async (e, t) => {
682
682
  error: c instanceof Error ? c.message : String(c)
683
683
  };
684
684
  }
685
- }, Mr = async (e, t, r, a, o, s) => {
685
+ }, jr = async (e, t, r, a, o, s) => {
686
686
  const i = t.map?.allLayers.find(
687
687
  (u) => u.id === e.layerId
688
688
  );
@@ -695,7 +695,7 @@ const re = async (e, t) => {
695
695
  return u.error;
696
696
  l = u.geometry;
697
697
  }
698
- if (i.featureEffect = null, i.featureEffect = new _e({
698
+ if (i.featureEffect = null, i.featureEffect = new ze({
699
699
  filter: new K({
700
700
  where: e.where,
701
701
  geometry: l,
@@ -707,7 +707,7 @@ const re = async (e, t) => {
707
707
  excludedEffect: a
708
708
  }), i.visible = !0, s)
709
709
  return `Applied feature effects to "${i.title ?? e.layerId}" within current map extent.`;
710
- const c = await jr(
710
+ const c = await _r(
711
711
  t,
712
712
  e.layerId,
713
713
  e.where,
@@ -716,7 +716,7 @@ const re = async (e, t) => {
716
716
  o?.units
717
717
  ), d = i.title ?? e.layerId;
718
718
  return c.success ? `Applied feature effects to target layer "${i.title ?? e.layerId}"${o && "layerId" in o ? ` using geometry from layer "${o.layerId}"` : ""}.` : `Applied filter to "${d}" but no features matched. ${c.error}`;
719
- }, Pr = ["feet", "kilometers", "meters", "miles", "nautical-miles", "us-nautical-miles"], A = n.enum(Pr), Dr = async ({
719
+ }, Mr = ["feet", "kilometers", "meters", "miles", "nautical-miles", "us-nautical-miles"], A = n.enum(Mr), Pr = async ({
720
720
  targetLayer: e,
721
721
  geometryFilter: t,
722
722
  useCurrentExtent: r,
@@ -724,13 +724,13 @@ const re = async (e, t) => {
724
724
  excludedEffect: o = "grayscale(100%) opacity(60%) blur(2px)"
725
725
  }, s) => {
726
726
  const { mapView: i } = _(s);
727
- return await Mr(e, i, a, o, t, r);
728
- }, Gr = n.object({
727
+ return await jr(e, i, a, o, t, r);
728
+ }, Dr = n.object({
729
729
  layerId: n.string().describe("The layerId of the layer containing the geometry by which to filter."),
730
730
  where: n.string().describe("The SQL-92 where clause representing the features from which to filter."),
731
731
  distance: n.number().optional().describe("The buffer distance around the geometry."),
732
732
  units: A.optional().describe("The units for the distance buffer.")
733
- }), Or = n.object({
733
+ }), Gr = n.object({
734
734
  point: n.object({
735
735
  x: n.number().describe("X coordinate (longitude) from navigation result"),
736
736
  y: n.number().describe("Y coordinate (latitude) from navigation result"),
@@ -740,12 +740,12 @@ const re = async (e, t) => {
740
740
  }).describe("Point coordinates from a previous navigation/geocoding result"),
741
741
  distance: n.number().optional().describe("Optional buffer distance around the point."),
742
742
  units: A.optional().describe("The units for the distance buffer.")
743
- }), Qr = n.object({
743
+ }), Or = n.object({
744
744
  targetLayer: n.object({
745
745
  layerId: n.string().describe("The layerId of the layer on which to set a feature effect."),
746
746
  where: n.string().describe("The SQL-92 where clause representing the features to emphasize.")
747
747
  }),
748
- geometryFilter: n.union([Gr, Or]).optional().describe("Optional geometry-based filtering parameters for spatial queries."),
748
+ geometryFilter: n.union([Dr, Gr]).optional().describe("Optional geometry-based filtering parameters for spatial queries."),
749
749
  useCurrentExtent: n.boolean().optional().describe(
750
750
  "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."
751
751
  ),
@@ -755,10 +755,10 @@ const re = async (e, t) => {
755
755
  excludedEffect: n.string().default("grayscale(100%) opacity(60%) blur(2px)").describe(
756
756
  "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."
757
757
  )
758
- }), Vr = b(Dr, {
758
+ }), Qr = b(Pr, {
759
759
  name: "setFeatureEffect",
760
760
  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.",
761
- schema: Qr
761
+ schema: Or
762
762
  }), X = (e, t, r) => {
763
763
  if (e && typeof e != "function") {
764
764
  const a = "getField" in r && r.getField?.(e), o = a && "getFieldDomain" in r && r.getFieldDomain ? r.getFieldDomain(a.name) : null;
@@ -768,11 +768,11 @@ const re = async (e, t) => {
768
768
  }
769
769
  }
770
770
  return null;
771
- }, Wr = (e, t, r) => {
771
+ }, Vr = (e, t, r) => {
772
772
  const a = e.createQuery();
773
773
  return a.outFields = [t], a.where = r || "1=1", a.num = 1, a;
774
- }, Br = async (e, t, r, a) => {
775
- const o = a.map?.allLayers.find((h) => h.id === e), s = Wr(o, t, r.where), l = (await o.queryFeatures(s)).features[0], c = l ? l.attributes[t] : null, d = X(t, c, o) || c;
774
+ }, Wr = async (e, t, r, a) => {
775
+ const o = a.map?.allLayers.find((h) => h.id === e), s = Vr(o, t, r.where), l = (await o.queryFeatures(s)).features[0], c = l ? l.attributes[t] : null, d = X(t, c, o) || c;
776
776
  return {
777
777
  tool: "getAttribute",
778
778
  layerName: o.title ?? e,
@@ -784,26 +784,26 @@ const re = async (e, t) => {
784
784
  }
785
785
  };
786
786
  };
787
- async function Kr({ layerId: e, fieldName: t, query: r }, a) {
788
- const { mapView: o } = _(a), s = await Br(e, t, r, o);
787
+ async function Br({ layerId: e, fieldName: t, query: r }, a) {
788
+ const { mapView: o } = _(a), s = await Wr(e, t, r, o);
789
789
  return JSON.stringify(s, null, 2);
790
790
  }
791
- const Ur = n.object({
791
+ const Kr = n.object({
792
792
  layerId: n.string().describe("The layerId of the layer containing the field from which to get a value."),
793
793
  fieldName: n.string().describe("The name of the field/attribute from which to get a field value."),
794
794
  query: n.object({
795
795
  where: n.string().describe("The SQL-92 where clause representing the feature from which to get an attribute value.")
796
796
  })
797
- }), Hr = b(Kr, {
797
+ }), Ur = b(Br, {
798
798
  name: "getAttribute",
799
799
  description: "Returns an attribute value for a given feature.",
800
- schema: Ur
800
+ schema: Kr
801
801
  }), me = (e, t, r) => r ? e.hasAllFeaturesInView && e.availableFields === t : e.hasAllFeatures && e.availableFields === t;
802
802
  function ee(e, t) {
803
803
  let r = e ?? "";
804
804
  return t != null && t && (r = r ? `(${r}) AND (${t})` : t), r || null;
805
805
  }
806
- const Zr = async (e) => {
806
+ const Hr = async (e) => {
807
807
  const { targetLayer: t, fieldName: r, statisticType: a, mapView: o, layersAndFieldsRegistry: s, geometryFilter: i } = e, l = o.map?.allLayers.find((v) => v.id === t.layerId);
808
808
  if (!l)
809
809
  throw new Error(`Layer '${t.layerId}' not found.`);
@@ -858,7 +858,7 @@ const Zr = async (e) => {
858
858
  field: r,
859
859
  sqlWhere: ee(l.definitionExpression, t.where),
860
860
  ...g && { filter: g }
861
- })).uniqueValueInfos.sort((G, lt) => lt.count - G.count).slice(0, E)), w && u.domain?.type === "coded-value" && (w = w.map((G) => ({
861
+ })).uniqueValueInfos.sort((G, it) => it.count - G.count).slice(0, E)), w && u.domain?.type === "coded-value" && (w = w.map((G) => ({
862
862
  ...G,
863
863
  value: V ? V.getName(G.value) ?? G.value : G.value
864
864
  })));
@@ -881,13 +881,13 @@ const Zr = async (e) => {
881
881
  }
882
882
  };
883
883
  };
884
- async function Jr({
884
+ async function Zr({
885
885
  targetLayer: e,
886
886
  fieldName: t,
887
887
  statisticType: r,
888
888
  geometryFilter: a
889
889
  }, o) {
890
- const s = S(o, "layersAndFieldsRegistry"), { mapView: i } = _(o), l = await Zr({
890
+ const s = S(o, "layersAndFieldsRegistry"), { mapView: i } = _(o), l = await Hr({
891
891
  targetLayer: e,
892
892
  fieldName: t,
893
893
  statisticType: r,
@@ -897,12 +897,12 @@ async function Jr({
897
897
  });
898
898
  return JSON.stringify(l, null, 2);
899
899
  }
900
- const Yr = n.object({
900
+ const Jr = n.object({
901
901
  layerId: n.string().describe("The layerId of the layer containing the geometry by which to filter."),
902
902
  where: n.string().describe("The SQL-92 where clause representing the features from which to filter."),
903
903
  distance: n.number().optional().describe("The buffer distance around the geometry."),
904
904
  units: A.optional().describe("The units for the distance buffer.")
905
- }), Xr = n.object({
905
+ }), Yr = n.object({
906
906
  point: n.object({
907
907
  x: n.number().describe("X coordinate (longitude) from navigation result"),
908
908
  y: n.number().describe("Y coordinate (latitude) from navigation result"),
@@ -912,17 +912,17 @@ const Yr = n.object({
912
912
  }).describe("Point coordinates from a previous navigation/geocoding result"),
913
913
  distance: n.number().optional().describe("Optional buffer distance around the point."),
914
914
  units: A.optional().describe("The units for the distance buffer.")
915
- }), ea = n.object({
915
+ }), Xr = n.object({
916
916
  targetLayer: n.object({
917
917
  layerId: n.string().describe("The layerId of the layer containing the field from which to get a value."),
918
918
  where: n.string().describe("The SQL-92 where clause representing the feature from which to get an attribute value.")
919
919
  }),
920
- geometryFilter: n.union([Yr, Xr]).optional().describe(
920
+ geometryFilter: n.union([Jr, Yr]).optional().describe(
921
921
  "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."
922
922
  ),
923
923
  fieldName: n.string().describe("The name of the field for which to get statistics. STRICTLY DO NOT use OBJECTID. Use any other field"),
924
924
  statisticType: n.enum(["avg", "max", "median", "min", "stddev", "sum", "variance", "nullcount", "count"]).describe("The statistic type to calculate.")
925
- }), ta = b(Jr, {
925
+ }), ea = b(Zr, {
926
926
  name: "getStatistics",
927
927
  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.
928
928
 
@@ -937,8 +937,8 @@ DO NOT USE FOR:
937
937
  - Simple counts of features matching a condition — use queryFeatures instead
938
938
 
939
939
  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.`,
940
- schema: ea
941
- }), ra = async (e, t, r, a, o) => {
940
+ schema: Xr
941
+ }), ta = async (e, t, r, a, o) => {
942
942
  const s = r.map?.allLayers.find((p) => p.id === e.layerId), i = await r.whenLayerView(s), l = s.title ?? e.layerId;
943
943
  let c;
944
944
  if (a) {
@@ -966,7 +966,7 @@ Only call this tool when the answer requires computing an aggregate (avg, max, m
966
966
  try {
967
967
  let p;
968
968
  if (d) {
969
- const y = new je({
969
+ const y = new _e({
970
970
  where: e.where || "1=1",
971
971
  outFields: h,
972
972
  orderByFields: e.orderByFields,
@@ -974,7 +974,7 @@ Only call this tool when the answer requires computing an aggregate (avg, max, m
974
974
  spatialRelationship: c ? "intersects" : void 0,
975
975
  distance: a?.distance,
976
976
  units: a?.units,
977
- topFilter: new Me({
977
+ topFilter: new je({
978
978
  topCount: t.topCount,
979
979
  groupByFields: t.groupByFields,
980
980
  orderByFields: t.orderByFields
@@ -1024,20 +1024,20 @@ Only call this tool when the answer requires computing an aggregate (avg, max, m
1024
1024
  details: { error: p instanceof Error ? p.message : String(p) }
1025
1025
  };
1026
1026
  }
1027
- }, aa = async ({
1027
+ }, ra = async ({
1028
1028
  targetLayer: e,
1029
1029
  topFilter: t,
1030
1030
  geometryFilter: r,
1031
1031
  useCurrentExtent: a
1032
1032
  }, o) => {
1033
- const { mapView: s } = _(o), i = await ra(e, t, s, r, a);
1033
+ const { mapView: s } = _(o), i = await ta(e, t, s, r, a);
1034
1034
  return JSON.stringify(i, null, 2);
1035
- }, oa = n.object({
1035
+ }, aa = n.object({
1036
1036
  layerId: n.string().describe("The layerId of the layer containing the geometry by which to filter."),
1037
1037
  where: n.string().describe("The SQL-92 where clause representing the features from which to filter."),
1038
1038
  distance: n.number().optional().describe("The buffer distance around the geometry."),
1039
1039
  units: A.optional().describe("The units for the distance buffer.")
1040
- }), sa = n.object({
1040
+ }), oa = n.object({
1041
1041
  point: n.object({
1042
1042
  x: n.number().describe("X coordinate (longitude) from navigation result"),
1043
1043
  y: n.number().describe("Y coordinate (latitude) from navigation result"),
@@ -1047,7 +1047,7 @@ Only call this tool when the answer requires computing an aggregate (avg, max, m
1047
1047
  }).describe("Point coordinates from a previous navigation/geocoding result"),
1048
1048
  distance: n.number().optional().describe("Optional buffer distance around the point."),
1049
1049
  units: A.optional().describe("The units for the distance buffer.")
1050
- }), na = n.object({
1050
+ }), sa = n.object({
1051
1051
  targetLayer: n.object({
1052
1052
  layerId: n.string().describe("The layerId of the layer containing the field from which to get a value."),
1053
1053
  where: n.string().describe("The SQL-92 where clause representing the feature from which to get an attribute value."),
@@ -1058,7 +1058,7 @@ Only call this tool when the answer requires computing an aggregate (avg, max, m
1058
1058
  ).default("*")
1059
1059
  )
1060
1060
  }),
1061
- geometryFilter: n.union([oa, sa]).optional().describe(
1061
+ geometryFilter: n.union([aa, oa]).optional().describe(
1062
1062
  "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."
1063
1063
  ),
1064
1064
  topFilter: n.object({
@@ -1071,11 +1071,11 @@ Only call this tool when the answer requires computing an aggregate (avg, max, m
1071
1071
  useCurrentExtent: n.boolean().optional().describe(
1072
1072
  "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)."
1073
1073
  )
1074
- }), ia = b(aa, {
1074
+ }), na = b(ra, {
1075
1075
  name: "getTopFeatures",
1076
1076
  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.',
1077
- schema: na
1078
- }), ne = 25, la = async (e, t, r, a) => {
1077
+ schema: sa
1078
+ }), ne = 25, ia = async (e, t, r, a) => {
1079
1079
  const o = t.map?.allLayers.find((y) => y.id === e.layerId), s = await t.whenLayerView(o), i = o.title ?? e.layerId;
1080
1080
  let l;
1081
1081
  if (r) {
@@ -1137,20 +1137,20 @@ Only call this tool when the answer requires computing an aggregate (avg, max, m
1137
1137
  }
1138
1138
  };
1139
1139
  };
1140
- async function ca({
1140
+ async function la({
1141
1141
  targetLayer: e,
1142
1142
  geometryFilter: t,
1143
1143
  useCurrentExtent: r
1144
1144
  }, a) {
1145
- const { mapView: o } = _(a), s = await la(e, o, t, r);
1145
+ const { mapView: o } = _(a), s = await ia(e, o, t, r);
1146
1146
  return JSON.stringify(s, null, 2);
1147
1147
  }
1148
- const da = n.object({
1148
+ const ca = n.object({
1149
1149
  layerId: n.string().describe("The layerId of the layer containing the geometry by which to filter."),
1150
1150
  where: n.string().describe("The SQL-92 where clause representing the features from which to filter."),
1151
1151
  distance: n.number().optional().describe("The buffer distance around the geometry."),
1152
1152
  units: A.optional().describe("The units for the distance buffer.")
1153
- }), ua = n.object({
1153
+ }), da = n.object({
1154
1154
  point: n.object({
1155
1155
  x: n.number().describe("X coordinate (longitude) from navigation result"),
1156
1156
  y: n.number().describe("Y coordinate (latitude) from navigation result"),
@@ -1160,7 +1160,7 @@ const da = n.object({
1160
1160
  }).describe("Point coordinates from a previous navigation/geocoding result"),
1161
1161
  distance: n.number().optional().describe("Optional buffer distance around the point."),
1162
1162
  units: A.optional().describe("The units for the distance buffer.")
1163
- }), ha = n.object({
1163
+ }), ua = n.object({
1164
1164
  targetLayer: n.object({
1165
1165
  layerId: n.string().describe("The layerId of the layer containing the field from which to get a value."),
1166
1166
  where: n.string().describe(
@@ -1173,13 +1173,13 @@ const da = n.object({
1173
1173
  ).default("*")
1174
1174
  )
1175
1175
  }),
1176
- geometryFilter: n.union([da, ua]).optional().describe(
1176
+ geometryFilter: n.union([ca, da]).optional().describe(
1177
1177
  "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."
1178
1178
  ),
1179
1179
  useCurrentExtent: n.boolean().optional().describe(
1180
1180
  "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)."
1181
1181
  )
1182
- }), ma = b(ca, {
1182
+ }), ha = b(la, {
1183
1183
  name: "queryFeatures",
1184
1184
  description: `Queries features from a layer. Returns the total count of matching features, plus individual feature attributes if ≤25 features match.
1185
1185
 
@@ -1191,11 +1191,11 @@ USE THIS TOOL FOR:
1191
1191
  - Any question where the user wants to SEE or COUNT matching features
1192
1192
 
1193
1193
  This is the DEFAULT tool for most queries. When in doubt, use this tool.`,
1194
- schema: ha
1195
- }), Oe = [Hr, ta, ia, ma], Qe = [Vr, _r, Nr], ae = () => {
1194
+ schema: ua
1195
+ }), Ge = [Ur, ea, na, ha], Oe = [Qr, zr, Ar], ae = () => {
1196
1196
  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}`;
1197
1197
  return { userTimezone: Intl.DateTimeFormat().resolvedOptions().timeZone, userTimezoneOffset: o };
1198
- }, pa = async (e, t) => {
1198
+ }, ma = async (e, t) => {
1199
1199
  await m({ text: "Requesting LLM for layer filter results" }, t);
1200
1200
  const a = await R("data_explore_filter_prompt");
1201
1201
  if (!t?.configurable)
@@ -1210,7 +1210,7 @@ This is the DEFAULT tool for most queries. When in doubt, use this tool.`,
1210
1210
  modelTier: "advanced",
1211
1211
  messages: x(e.messages),
1212
1212
  inputVariables: i,
1213
- tools: Qe
1213
+ tools: Oe
1214
1214
  }), c = [...e.messages, l];
1215
1215
  if (!((l.tool_calls?.length ?? 0) > 0))
1216
1216
  return await m({ text: "LLM determined no filter changes needed" }, t), {
@@ -1220,7 +1220,7 @@ This is the DEFAULT tool for most queries. When in doubt, use this tool.`,
1220
1220
  };
1221
1221
  const u = [...c, l], h = l.content.toString();
1222
1222
  return await U(l, t), { ...e, messages: u, outputMessage: h };
1223
- }, ya = async (e, t) => {
1223
+ }, pa = async (e, t) => {
1224
1224
  await m({ text: "Requesting LLM for layer query results" }, t);
1225
1225
  const a = await R("data_explore_query_prompt");
1226
1226
  if (!t?.configurable)
@@ -1234,10 +1234,10 @@ This is the DEFAULT tool for most queries. When in doubt, use this tool.`,
1234
1234
  modelTier: "advanced",
1235
1235
  messages: x(e.messages),
1236
1236
  inputVariables: i,
1237
- tools: Oe
1237
+ tools: Ge
1238
1238
  }), c = [...e.messages, l], d = l.content.toString();
1239
1239
  return await U(l, t), { ...e, messages: c, outputMessage: d };
1240
- }, ga = async (e, t) => {
1240
+ }, ya = async (e, t) => {
1241
1241
  try {
1242
1242
  await m({ text: "Requesting LLM for summary on query results" }, t);
1243
1243
  const a = await R("summarize_query_response_prompt"), o = {
@@ -1256,8 +1256,8 @@ This is the DEFAULT tool for most queries. When in doubt, use this tool.`,
1256
1256
  throw await m({ text: "Error during filter LLM request" }, t), new Error(`Error during filter LLM request: ${r instanceof Error ? r.message : String(r)}`);
1257
1257
  }
1258
1258
  };
1259
- async function fa(e, t) {
1260
- const a = await new z(Qe).invoke(
1259
+ async function ga(e, t) {
1260
+ const a = await new z(Oe).invoke(
1261
1261
  {
1262
1262
  messages: x(e.messages)
1263
1263
  },
@@ -1276,9 +1276,9 @@ async function fa(e, t) {
1276
1276
  const i = [...o, ...s];
1277
1277
  return { ...e, messages: i };
1278
1278
  }
1279
- const wa = new z(Oe);
1280
- async function ba(e, t) {
1281
- const { messages: r } = await wa.invoke({ messages: x(e.messages) }, t), a = [], o = [];
1279
+ const fa = new z(Ge);
1280
+ async function wa(e, t) {
1281
+ const { messages: r } = await fa.invoke({ messages: x(e.messages) }, t), a = [], o = [];
1282
1282
  for (const i of r) {
1283
1283
  const l = i.content;
1284
1284
  let c;
@@ -1312,13 +1312,13 @@ async function ba(e, t) {
1312
1312
  queryResponse: a
1313
1313
  };
1314
1314
  }
1315
- const Sa = 10, va = ["string", "small-integer", "integer"], Ta = async (e, t) => {
1315
+ const ba = 10, Sa = ["string", "small-integer", "integer"], va = async (e, t) => {
1316
1316
  let r = null, a = null;
1317
1317
  try {
1318
1318
  if (t.type !== "geometry" && t.type !== "oid" && t.type !== "global-id") {
1319
1319
  r = await ce({ layer: e, field: t.name });
1320
1320
  const o = t.domain?.type === "coded-value" ? t.domain : null;
1321
- (va.includes(t.type) || o) && (a = (await de({ layer: e, field: t.name })).uniqueValueInfos.sort((s, i) => i.count - s.count).slice(0, Sa), o && (a = a.map((s) => ({
1321
+ (Sa.includes(t.type) || o) && (a = (await de({ layer: e, field: t.name })).uniqueValueInfos.sort((s, i) => i.count - s.count).slice(0, ba), o && (a = a.map((s) => ({
1322
1322
  ...s,
1323
1323
  value: o.getName(s.value) ?? s.value
1324
1324
  }))));
@@ -1356,7 +1356,7 @@ async function pe(e, t, r) {
1356
1356
  if (!g)
1357
1357
  continue;
1358
1358
  if (!g.statistics) {
1359
- const y = Ta(d, g).then((w) => {
1359
+ const y = va(d, g).then((w) => {
1360
1360
  u.set(g.name, { ...g, statistics: w }), g.statistics = w;
1361
1361
  });
1362
1362
  o.push(y);
@@ -1366,7 +1366,7 @@ async function pe(e, t, r) {
1366
1366
  }
1367
1367
  return await Promise.all(o), a;
1368
1368
  }
1369
- const xa = async (e, t) => {
1369
+ const Ta = async (e, t) => {
1370
1370
  try {
1371
1371
  await m({ text: "Getting statistics for vector search results" }, t);
1372
1372
  const r = S(t, "layersAndFieldsRegistry"), { mapView: a } = _(t), o = await pe(e.vectorSearchFieldResults, r, a);
@@ -1374,7 +1374,7 @@ const xa = async (e, t) => {
1374
1374
  } catch (r) {
1375
1375
  throw await m({ text: "Error during fetching statistics" }, t), new Error(`Error during fetching statistics: ${r instanceof Error ? r.message : String(r)}`);
1376
1376
  }
1377
- }, Re = 0.7, Ea = 10, $a = async (e, t) => {
1377
+ }, Re = 0.7, xa = 10, Ea = async (e, t) => {
1378
1378
  try {
1379
1379
  const r = C(e.messages);
1380
1380
  await m({ text: "Similarity search to find fields" }, t);
@@ -1382,7 +1382,7 @@ const xa = async (e, t) => {
1382
1382
  text: r,
1383
1383
  layerIds: e.vectorSearchLayerIds,
1384
1384
  minScore: Re,
1385
- topResults: Ea,
1385
+ topResults: xa,
1386
1386
  embeddingCache: s
1387
1387
  }), l = i.map(({ layerId: d, results: u }) => {
1388
1388
  const h = u.map((p) => ` - ${p.name} (${p.score.toFixed(2)})`).join(`
@@ -1403,13 +1403,13 @@ ${l}` : c = `No vector search results found for score over ${Re}.`, await m({ te
1403
1403
  t
1404
1404
  ), new Error(`Vector search failed: ${r instanceof Error ? r.message : String(r)}`);
1405
1405
  }
1406
- }, Fa = 0.7, Ra = async (e, t) => {
1406
+ }, $a = 0.7, Fa = async (e, t) => {
1407
1407
  try {
1408
1408
  const r = C(e.messages);
1409
1409
  await m({ text: `Similarity search to find layers: ${r}` }, t);
1410
1410
  const a = S(t, "layerSearch"), o = S(t, "layersAndFieldsRegistry"), s = S(t, "embeddingCache"), i = await a.searchLayers({
1411
1411
  text: r,
1412
- minScore: Fa,
1412
+ minScore: $a,
1413
1413
  embeddingCache: s
1414
1414
  }), l = i.map((u) => u.id), c = i.map(({ id: u, score: h }) => `${o.get(u)?.layerItem.name ?? u} (${h.toFixed(2)})`).join(`
1415
1415
  `);
@@ -1425,10 +1425,10 @@ ${c}` : d = "Vector search completed. No matching layers found.", await m({ text
1425
1425
  t
1426
1426
  ), new Error(`Vector search failed: ${r instanceof Error ? r.message : String(r)}`);
1427
1427
  }
1428
- }, La = (e, t) => D(["layerSearch", "fieldSearch", "layersAndFieldsRegistry"], "Data Exploration Agent")(
1428
+ }, Ra = (e, t) => D(["layerSearch", "fieldSearch", "layersAndFieldsRegistry"], "Data Exploration Agent")(
1429
1429
  e,
1430
1430
  t
1431
- ), Ia = () => new M(Ge).addNode("requireDataExplorationServices", La).addNode("vectorSearchLayers", Ra).addNode("vectorSearchFields", $a).addNode("fieldStatistics", xa).addNode("queryAgent", ya).addNode("queryTools", ba).addNode("summarizeQueryResponseLLM", ga).addNode("filterAgent", pa).addNode("filterTools", fa).addNode("earlyExit", Ir).addEdge(P, "requireDataExplorationServices").addEdge("requireDataExplorationServices", "vectorSearchLayers").addConditionalEdges(
1431
+ ), La = () => new M(De).addNode("requireDataExplorationServices", Ra).addNode("vectorSearchLayers", Fa).addNode("vectorSearchFields", Ea).addNode("fieldStatistics", Ta).addNode("queryAgent", pa).addNode("queryTools", wa).addNode("summarizeQueryResponseLLM", ya).addNode("filterAgent", ma).addNode("filterTools", ga).addNode("earlyExit", Lr).addEdge(P, "requireDataExplorationServices").addEdge("requireDataExplorationServices", "vectorSearchLayers").addConditionalEdges(
1432
1432
  "vectorSearchLayers",
1433
1433
  (t) => t.vectorSearchLayerIds.length ? "vectorSearchFields" : "earlyExit"
1434
1434
  ).addConditionalEdges(
@@ -1437,7 +1437,7 @@ ${c}` : d = "Vector search completed. No matching layers found.", await m({ text
1437
1437
  ).addEdge("fieldStatistics", "queryAgent").addConditionalEdges("queryAgent", (t) => (t.messages[t.messages.length - 1]?.tool_calls?.length ?? 0) > 0 ? "queryTools" : "filterAgent").addConditionalEdges(
1438
1438
  "queryTools",
1439
1439
  (t) => t.queryResponse.length ? "summarizeQueryResponseLLM" : "filterAgent"
1440
- ).addEdge("summarizeQueryResponseLLM", "filterAgent").addConditionalEdges("filterAgent", (t) => (t.messages[t.messages.length - 1]?.tool_calls?.length ?? 0) > 0 ? "filterTools" : F).addEdge("filterTools", F).addEdge("earlyExit", F), qa = 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).
1440
+ ).addEdge("summarizeQueryResponseLLM", "filterAgent").addConditionalEdges("filterAgent", (t) => (t.messages[t.messages.length - 1]?.tool_calls?.length ?? 0) > 0 ? "filterTools" : F).addEdge("filterTools", F).addEdge("earlyExit", F), Ia = 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).
1441
1441
  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.
1442
1442
  _Example: “Only show stations where Brand is Shell”_
1443
1443
  _Example: “Make Shell stations stand out on the map”_
@@ -1445,13 +1445,13 @@ ${c}` : d = "Vector search completed. No matching layers found.", await m({ text
1445
1445
  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.
1446
1446
  _Example: “How many features are there?”_
1447
1447
  _Example: “What’s the average population?”_
1448
- _Example: “Which values are in the status field?”_`, zi = {
1448
+ _Example: “Which values are in the status field?”_`, ki = {
1449
1449
  id: "dataExploration",
1450
1450
  name: "Data Exploration Agent",
1451
- description: qa,
1452
- createGraph: Ia,
1453
- workspace: Ge
1454
- }, Le = 0.7, Ca = 10, Aa = async (e, t) => {
1451
+ description: Ia,
1452
+ createGraph: La,
1453
+ workspace: De
1454
+ }, Le = 0.7, qa = 10, Ca = async (e, t) => {
1455
1455
  try {
1456
1456
  const r = C(e.messages);
1457
1457
  await m({ text: "Similarity search to find fields" }, t);
@@ -1459,7 +1459,7 @@ ${c}` : d = "Vector search completed. No matching layers found.", await m({ text
1459
1459
  text: r,
1460
1460
  layerIds: e.vectorSearchLayerIds,
1461
1461
  minScore: Le,
1462
- topResults: Ca,
1462
+ topResults: qa,
1463
1463
  embeddingCache: s
1464
1464
  }), l = i.map(({ layerId: d, results: u }) => {
1465
1465
  const h = u.map((p) => ` - ${p.name} (${p.score.toFixed(2)})`).join(`
@@ -1480,11 +1480,11 @@ ${l}` : c = `No vector search results found for score over ${Le}.`, await m({ te
1480
1480
  t
1481
1481
  ), new Error(`Vector search failed: ${r instanceof Error ? r.message : String(r)}`);
1482
1482
  }
1483
- }, Na = 0.7, ka = async (e, t) => {
1483
+ }, Aa = 0.7, Na = async (e, t) => {
1484
1484
  try {
1485
1485
  const r = C(e.messages);
1486
1486
  await m({ text: `Similarity search to find layers: ${r}` }, t);
1487
- const a = S(t, "layerSearch"), o = S(t, "layersAndFieldsRegistry"), s = await a.searchLayers({ text: r, minScore: Na }), i = s.map((d) => d.id), l = s.map(({ id: d, score: u }) => `${o.get(d)?.layerItem.name ?? d} (${u.toFixed(2)})`).join(`
1487
+ const a = S(t, "layerSearch"), o = S(t, "layersAndFieldsRegistry"), s = await a.searchLayers({ text: r, minScore: Aa }), i = s.map((d) => d.id), l = s.map(({ id: d, score: u }) => `${o.get(d)?.layerItem.name ?? d} (${u.toFixed(2)})`).join(`
1488
1488
  `);
1489
1489
  let c;
1490
1490
  return i.length > 0 ? c = `Vector search completed. Matching layers with scores:
@@ -1498,17 +1498,17 @@ ${l}` : c = "Vector search completed. No matching layers found.", await m({ text
1498
1498
  t
1499
1499
  ), new Error(`Vector search failed: ${r instanceof Error ? r.message : String(r)}`);
1500
1500
  }
1501
- }, Ve = ["mapView"];
1501
+ }, Qe = ["mapView"];
1502
1502
  function ye(e) {
1503
1503
  const r = e?.configurable?.context;
1504
1504
  if (!r || typeof r != "object")
1505
1505
  throw new Error("LayerFilterAgent context missing");
1506
- const a = Ve.filter((o) => !(o in r));
1506
+ const a = Qe.filter((o) => !(o in r));
1507
1507
  if (a.length)
1508
1508
  throw new Error(`LayerFilterAgent context missing: ${a.join(", ")}`);
1509
1509
  return r;
1510
1510
  }
1511
- const za = async (e, t) => {
1511
+ const ka = async (e, t) => {
1512
1512
  try {
1513
1513
  await m({ text: "Getting statistics for vector search results" }, t);
1514
1514
  const r = S(t, "layersAndFieldsRegistry"), { mapView: a } = ye(t), o = await pe(e.vectorSearchFieldResults, r, a);
@@ -1516,12 +1516,12 @@ const za = async (e, t) => {
1516
1516
  } catch (r) {
1517
1517
  throw await m({ text: "Error during fetching statistics" }, t), new Error(`Error during fetching statistics: ${r instanceof Error ? r.message : String(r)}`);
1518
1518
  }
1519
- }, We = async (e, t, r) => {
1519
+ }, Ve = async (e, t, r) => {
1520
1520
  const a = e.map?.allLayers.find((i) => i.id === t), o = a.createQuery();
1521
1521
  o.where = r ?? "1=1";
1522
1522
  const { features: s } = await a.queryFeatures(o);
1523
1523
  e.goTo(s);
1524
- }, Be = async (e, t) => {
1524
+ }, We = async (e, t) => {
1525
1525
  const r = t.map?.allLayers.find(
1526
1526
  (s) => s.id === e.layerId
1527
1527
  );
@@ -1546,7 +1546,7 @@ const za = async (e, t) => {
1546
1546
  o = i;
1547
1547
  }
1548
1548
  return { geometry: o };
1549
- }, _a = async (e, t, r, a, o) => {
1549
+ }, za = async (e, t, r, a, o) => {
1550
1550
  const s = t.map?.allLayers.find(
1551
1551
  (l) => l.id === e.layerId
1552
1552
  );
@@ -1554,12 +1554,12 @@ const za = async (e, t) => {
1554
1554
  return `Could not find target layer with ID: ${e.layerId}`;
1555
1555
  let i;
1556
1556
  if (o) {
1557
- const l = await Be(o, t);
1557
+ const l = await We(o, t);
1558
1558
  if ("error" in l)
1559
1559
  return l.error;
1560
1560
  i = l.geometry;
1561
1561
  }
1562
- return s.featureEffect = new _e({
1562
+ return s.featureEffect = new ze({
1563
1563
  filter: new K({
1564
1564
  where: e.where,
1565
1565
  geometry: i,
@@ -1569,20 +1569,20 @@ const za = async (e, t) => {
1569
1569
  }),
1570
1570
  includedEffect: r,
1571
1571
  excludedEffect: a
1572
- }), s.visible = !0, s.refresh(), We(
1572
+ }), s.visible = !0, s.refresh(), Ve(
1573
1573
  t,
1574
1574
  o ? o.layerId : e.layerId,
1575
1575
  o ? o.where : e.where
1576
1576
  ), `Applied feature effects to target layer "${s.title ?? e.layerId}"${o ? ` using geometry from layer "${o.layerId}"` : ""}.`;
1577
- }, ja = ["feet", "kilometers", "meters", "miles", "nautical-miles", "us-nautical-miles"], Ke = n.enum(ja), Ma = async ({
1577
+ }, _a = ["feet", "kilometers", "meters", "miles", "nautical-miles", "us-nautical-miles"], Be = n.enum(_a), ja = async ({
1578
1578
  targetLayer: e,
1579
1579
  geometryLayer: t,
1580
1580
  includedEffect: r = "drop-shadow(2px, 2px, 2px, gray)",
1581
1581
  excludedEffect: a = "grayscale(100%) opacity(60%) blur(2px)"
1582
1582
  }, o) => {
1583
1583
  const { mapView: s } = ye(o);
1584
- return await _a(e, s, r, a, t);
1585
- }, Pa = n.object({
1584
+ return await za(e, s, r, a, t);
1585
+ }, Ma = n.object({
1586
1586
  targetLayer: n.object({
1587
1587
  layerId: n.string().describe("The layerId of the layer on which to set a feature effect."),
1588
1588
  where: n.string().describe("The SQL-92 where clause representing the features to emphasize.")
@@ -1593,7 +1593,7 @@ const za = async (e, t) => {
1593
1593
  "The SQL-92 where clause representing the features from which to filter features from the targetLayer by geometry."
1594
1594
  ),
1595
1595
  distance: n.number().describe("The distance by which to filter the input geometry."),
1596
- units: Ke.describe("The units used to filter by geometry and distance.")
1596
+ units: Be.describe("The units used to filter by geometry and distance.")
1597
1597
  }).optional().describe("Optional geometry-based filtering parameters for spatial queries."),
1598
1598
  includedEffect: n.string().optional().default("drop-shadow(2px, 2px, 2px, gray)").describe(
1599
1599
  "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."
@@ -1601,11 +1601,11 @@ const za = async (e, t) => {
1601
1601
  excludedEffect: n.string().optional().default("grayscale(100%) opacity(60%) blur(2px)").describe(
1602
1602
  "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."
1603
1603
  )
1604
- }), Da = b(Ma, {
1604
+ }), Pa = b(ja, {
1605
1605
  name: "setFeatureEffect",
1606
1606
  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.",
1607
- schema: Pa
1608
- }), Ga = async (e, t, r) => {
1607
+ schema: Ma
1608
+ }), Da = async (e, t, r) => {
1609
1609
  const a = t.map?.allLayers.find(
1610
1610
  (i) => i.id === e.layerId
1611
1611
  );
@@ -1613,7 +1613,7 @@ const za = async (e, t) => {
1613
1613
  return `Could not find target layer with ID: ${e.layerId}`;
1614
1614
  let o;
1615
1615
  if (r) {
1616
- const i = await Be(r, t);
1616
+ const i = await We(r, t);
1617
1617
  if ("error" in i)
1618
1618
  return i.error;
1619
1619
  o = i.geometry;
@@ -1625,18 +1625,18 @@ const za = async (e, t) => {
1625
1625
  spatialRelationship: "intersects",
1626
1626
  distance: r?.distance,
1627
1627
  units: r?.units
1628
- }), a.visible = !0, We(
1628
+ }), a.visible = !0, Ve(
1629
1629
  t,
1630
1630
  r ? r.layerId : e.layerId,
1631
1631
  r ? r.where : e.where
1632
1632
  ), `Applied feature filter to layer "${a.title ?? e.layerId}"${r ? ` using geometry from layer "${r.layerId}"` : ""}.`;
1633
- }, Oa = async ({
1633
+ }, Ga = async ({
1634
1634
  targetLayer: e,
1635
1635
  geometryLayer: t
1636
1636
  }, r) => {
1637
1637
  const { mapView: a } = ye(r);
1638
- return await Ga(e, a, t);
1639
- }, Qa = n.object({
1638
+ return await Da(e, a, t);
1639
+ }, Oa = n.object({
1640
1640
  targetLayer: n.object({
1641
1641
  layerId: n.string().describe("The layerId of the layer on which to set a filter."),
1642
1642
  where: n.string().describe("The SQL-92 where clause representing the features to display.")
@@ -1647,13 +1647,13 @@ const za = async (e, t) => {
1647
1647
  "The SQL-92 where clause representing the features from which to filter features from the targetLayer by geometry."
1648
1648
  ),
1649
1649
  distance: n.number().describe("The distance by which to filter the input geometry."),
1650
- units: Ke.describe("The units used to filter by geometry and distance.")
1650
+ units: Be.describe("The units used to filter by geometry and distance.")
1651
1651
  }).optional().describe("Optional geometry-based filtering parameters for spatial queries.")
1652
- }), Va = b(Oa, {
1652
+ }), Qa = b(Ga, {
1653
1653
  name: "setFeatureFilter",
1654
1654
  description: "Sets a client-side filter using a where clause, geometry filter, or both on a target layer. This filters features at the client level in the view.",
1655
- schema: Qa
1656
- }), Ue = [Da, Va], Wa = async (e, t) => {
1655
+ schema: Oa
1656
+ }), Ke = [Pa, Qa], Va = async (e, t) => {
1657
1657
  await m({ text: "Requesting LLM for layer filter results" }, t);
1658
1658
  const a = await R("layer_filter_prompt");
1659
1659
  if (!t?.configurable)
@@ -1667,12 +1667,12 @@ const za = async (e, t) => {
1667
1667
  modelTier: "advanced",
1668
1668
  messages: x(e.messages),
1669
1669
  inputVariables: i,
1670
- tools: Ue
1670
+ tools: Ke
1671
1671
  }), c = l.content.toString();
1672
1672
  return await U(l, t), { ...e, messages: [...e.messages, l], outputMessage: c };
1673
1673
  };
1674
- async function Ba(e, t) {
1675
- const a = await new z(Ue).invoke(
1674
+ async function Wa(e, t) {
1675
+ const a = await new z(Ke).invoke(
1676
1676
  {
1677
1677
  messages: x(e.messages)
1678
1678
  },
@@ -1684,7 +1684,7 @@ async function Ba(e, t) {
1684
1684
  `);
1685
1685
  return { ...e, outputMessage: i, messages: s };
1686
1686
  }
1687
- const He = f.Root({
1687
+ const Ue = f.Root({
1688
1688
  // Inputs coming from global context
1689
1689
  messages: f({
1690
1690
  reducer: j,
@@ -1716,23 +1716,23 @@ ${r}`;
1716
1716
  vectorSearchLayerIds: f(),
1717
1717
  vectorSearchFieldResults: f(),
1718
1718
  layerFieldInfo: f()
1719
- }), Ka = async (e, t) => (await m({ text: "Exiting Layer Filter agent" }, t), e), Ua = (e, t) => D(["layerSearch", "fieldSearch", "layersAndFieldsRegistry"], "Layer Filter Agent")(e, t), Ha = () => new M(He).addNode("requireLayerFilterServices", Ua).addNode("vectorSearchLayers", ka).addNode("vectorSearchFields", Aa).addNode("fieldStatistics", za).addNode("agent", Wa).addNode("tools", Ba).addNode("earlyExit", Ka).addEdge(P, "requireLayerFilterServices").addEdge("requireLayerFilterServices", "vectorSearchLayers").addConditionalEdges(
1719
+ }), Ba = async (e, t) => (await m({ text: "Exiting Layer Filter agent" }, t), e), Ka = (e, t) => D(["layerSearch", "fieldSearch", "layersAndFieldsRegistry"], "Layer Filter Agent")(e, t), Ua = () => new M(Ue).addNode("requireLayerFilterServices", Ka).addNode("vectorSearchLayers", Na).addNode("vectorSearchFields", Ca).addNode("fieldStatistics", ka).addNode("agent", Va).addNode("tools", Wa).addNode("earlyExit", Ba).addEdge(P, "requireLayerFilterServices").addEdge("requireLayerFilterServices", "vectorSearchLayers").addConditionalEdges(
1720
1720
  "vectorSearchLayers",
1721
1721
  (t) => t.vectorSearchLayerIds.length ? "vectorSearchFields" : "earlyExit"
1722
1722
  ).addConditionalEdges(
1723
1723
  "vectorSearchFields",
1724
1724
  (t) => t.vectorSearchFieldResults.length ? "fieldStatistics" : "earlyExit"
1725
- ).addEdge("fieldStatistics", "agent").addConditionalEdges("agent", (t) => (t.messages[t.messages.length - 1]?.tool_calls?.length ?? 0) > 0 ? "tools" : "earlyExit").addEdge("tools", "earlyExit").addEdge("earlyExit", F), Za = String.raw`- **layer filter** — User wants to include or exclude features based on field values, or visually style features differently (e.g., highlight or deemphasize them).
1725
+ ).addEdge("fieldStatistics", "agent").addConditionalEdges("agent", (t) => (t.messages[t.messages.length - 1]?.tool_calls?.length ?? 0) > 0 ? "tools" : "earlyExit").addEdge("tools", "earlyExit").addEdge("earlyExit", F), Ha = String.raw`- **layer filter** — User wants to include or exclude features based on field values, or visually style features differently (e.g., highlight or deemphasize them).
1726
1726
  The Layer Filter Agent will automatically zoom to the affected features for action taken by this agent. In this case, no need to call navigation tool separately.
1727
1727
  _Example: “Only show stations where Brand is Shell”_
1728
1728
  _Example: “Make Shell stations stand out on the map”_
1729
- _Example: “Gray out all stations that aren’t Shell”_`, _i = {
1729
+ _Example: “Gray out all stations that aren’t Shell”_`, zi = {
1730
1730
  id: "layerFilter",
1731
1731
  name: "Layer Filter Agent",
1732
- description: Za,
1733
- createGraph: Ha,
1734
- workspace: He
1735
- }, Ze = f.Root({
1732
+ description: Ha,
1733
+ createGraph: Ua,
1734
+ workspace: Ue
1735
+ }, He = f.Root({
1736
1736
  // Inputs coming from global context
1737
1737
  messages: f({
1738
1738
  reducer: j,
@@ -1765,17 +1765,17 @@ ${r}`;
1765
1765
  vectorSearchFieldResults: f(),
1766
1766
  layerFieldInfo: f(),
1767
1767
  queryResponses: f()
1768
- }), Ja = async (e, t) => (await m({ text: "Exiting Layer Query agent" }, t), e);
1768
+ }), Za = async (e, t) => (await m({ text: "Exiting Layer Query agent" }, t), e);
1769
1769
  function H(e) {
1770
1770
  const r = e?.configurable?.context;
1771
1771
  if (!r || typeof r != "object")
1772
1772
  throw new Error("LayerQueryAgent context missing");
1773
- const a = Ve.filter((o) => !(o in r));
1773
+ const a = Qe.filter((o) => !(o in r));
1774
1774
  if (a.length)
1775
1775
  throw new Error(`LayerQueryAgent context missing: ${a.join(", ")}`);
1776
1776
  return r;
1777
1777
  }
1778
- const Ya = async (e, t) => {
1778
+ const Ja = async (e, t) => {
1779
1779
  try {
1780
1780
  await m({ text: "Getting statistics for vector search results" }, t);
1781
1781
  const r = S(t, "layersAndFieldsRegistry"), { mapView: a } = H(t), o = await pe(e.vectorSearchFieldResults, r, a);
@@ -1783,7 +1783,7 @@ const Ya = async (e, t) => {
1783
1783
  } catch (r) {
1784
1784
  throw await m({ text: "Error during fetching statistics" }, t), new Error(`Error during fetching statistics: ${r instanceof Error ? r.message : String(r)}`);
1785
1785
  }
1786
- }, Ie = 0.7, Xa = 10, eo = async (e, t) => {
1786
+ }, Ie = 0.7, Ya = 10, Xa = async (e, t) => {
1787
1787
  try {
1788
1788
  const r = C(e.messages);
1789
1789
  await m({ text: "Similarity search to find fields" }, t);
@@ -1791,7 +1791,7 @@ const Ya = async (e, t) => {
1791
1791
  text: r,
1792
1792
  layerIds: e.vectorSearchLayerIds,
1793
1793
  minScore: Ie,
1794
- topResults: Xa,
1794
+ topResults: Ya,
1795
1795
  embeddingCache: s
1796
1796
  }), l = i.map(({ layerId: d, results: u }) => {
1797
1797
  const h = u.map((p) => ` - ${p.name} (${p.score.toFixed(2)})`).join(`
@@ -1812,13 +1812,13 @@ ${l}` : c = `No vector search results found for score over ${Ie}.`, await m({ te
1812
1812
  t
1813
1813
  ), new Error(`Vector search failed: ${r instanceof Error ? r.message : String(r)}`);
1814
1814
  }
1815
- }, to = 0.7, ro = async (e, t) => {
1815
+ }, eo = 0.7, to = async (e, t) => {
1816
1816
  try {
1817
1817
  const r = C(e.messages);
1818
1818
  await m({ text: `Similarity search to find layers: ${r}` }, t);
1819
1819
  const a = S(t, "layerSearch"), o = S(t, "layersAndFieldsRegistry"), s = await a.searchLayers({
1820
1820
  text: r,
1821
- minScore: to
1821
+ minScore: eo
1822
1822
  }), i = s.map((d) => d.id), l = s.map(({ id: d, score: u }) => `${o.get(d)?.layerItem.name ?? d} (${u.toFixed(2)})`).join(`
1823
1823
  `);
1824
1824
  let c;
@@ -1833,11 +1833,11 @@ ${l}` : c = "Vector search completed. No matching layers found.", await m({ text
1833
1833
  t
1834
1834
  ), new Error(`Vector search failed: ${r instanceof Error ? r.message : String(r)}`);
1835
1835
  }
1836
- }, ao = (e, t, r) => {
1836
+ }, ro = (e, t, r) => {
1837
1837
  const a = e.createQuery();
1838
1838
  return a.outFields = [t], a.where = r || "1=1", a.num = 1, a;
1839
- }, oo = async (e, t, r, a) => {
1840
- const o = a.map?.allLayers.find((u) => u.id === e), s = ao(o, t, r.where), l = (await o.queryFeatures(s)).features[0], c = l ? l.attributes[t] : null;
1839
+ }, ao = async (e, t, r, a) => {
1840
+ const o = a.map?.allLayers.find((u) => u.id === e), s = ro(o, t, r.where), l = (await o.queryFeatures(s)).features[0], c = l ? l.attributes[t] : null;
1841
1841
  return {
1842
1842
  tool: "getAttribute",
1843
1843
  layerName: o.title ?? e,
@@ -1849,20 +1849,20 @@ ${l}` : c = "Vector search completed. No matching layers found.", await m({ text
1849
1849
  }
1850
1850
  };
1851
1851
  };
1852
- async function so({ layerId: e, fieldName: t, query: r }, a) {
1853
- const { mapView: o } = H(a), s = await oo(e, t, r, o);
1852
+ async function oo({ layerId: e, fieldName: t, query: r }, a) {
1853
+ const { mapView: o } = H(a), s = await ao(e, t, r, o);
1854
1854
  return JSON.stringify(s, null, 2);
1855
1855
  }
1856
- const no = n.object({
1856
+ const so = n.object({
1857
1857
  layerId: n.string().describe("The layerId of the layer containing the field from which to get a value."),
1858
1858
  fieldName: n.string().describe("The name of the field/attribute from which to get a field value."),
1859
1859
  query: n.object({
1860
1860
  where: n.string().describe("The SQL-92 where clause representing the feature from which to get an attribute value.")
1861
1861
  })
1862
- }), io = b(so, {
1862
+ }), no = b(oo, {
1863
1863
  name: "getAttribute",
1864
1864
  description: "Returns an attribute value for a given feature.",
1865
- schema: no
1865
+ schema: so
1866
1866
  }), ge = async (e, t) => {
1867
1867
  const r = t.map?.allLayers.find(
1868
1868
  (s) => s.id === e.layerId
@@ -1888,7 +1888,7 @@ const no = n.object({
1888
1888
  o = i;
1889
1889
  }
1890
1890
  return { geometry: o };
1891
- }, lo = async (e) => {
1891
+ }, io = async (e) => {
1892
1892
  const { targetLayer: t, fieldName: r, statisticType: a, mapView: o, layersAndFieldsRegistry: s, geometryLayer: i } = e, l = o.map?.allLayers.find((y) => y.id === t.layerId);
1893
1893
  if (!l)
1894
1894
  throw new Error(`Layer '${t.layerId}' not found.`);
@@ -1901,7 +1901,7 @@ const no = n.object({
1901
1901
  if ("error" in y)
1902
1902
  throw new Error(y.error);
1903
1903
  if (u = y.geometry, i.distance && i.units) {
1904
- const w = mt.execute(u, i.distance, {
1904
+ const w = ht.execute(u, i.distance, {
1905
1905
  unit: i.units === "us-nautical-miles" ? "nautical-miles" : i.units
1906
1906
  });
1907
1907
  w && (u = w);
@@ -1942,14 +1942,14 @@ const no = n.object({
1942
1942
  where: t.where
1943
1943
  }
1944
1944
  };
1945
- }, co = ["feet", "kilometers", "meters", "miles", "nautical-miles", "us-nautical-miles"], uo = n.enum(co);
1946
- async function ho({
1945
+ }, lo = ["feet", "kilometers", "meters", "miles", "nautical-miles", "us-nautical-miles"], co = n.enum(lo);
1946
+ async function uo({
1947
1947
  targetLayer: e,
1948
1948
  fieldName: t,
1949
1949
  statisticType: r,
1950
1950
  geometryLayer: a
1951
1951
  }, o) {
1952
- const s = S(o, "layersAndFieldsRegistry"), { mapView: i } = H(o), l = await lo({
1952
+ const s = S(o, "layersAndFieldsRegistry"), { mapView: i } = H(o), l = await io({
1953
1953
  targetLayer: e,
1954
1954
  fieldName: t,
1955
1955
  statisticType: r,
@@ -1959,7 +1959,7 @@ async function ho({
1959
1959
  });
1960
1960
  return JSON.stringify(l, null, 2);
1961
1961
  }
1962
- const mo = n.object({
1962
+ const ho = n.object({
1963
1963
  targetLayer: n.object({
1964
1964
  layerId: n.string().describe("The layerId of the layer containing the field from which to get a value."),
1965
1965
  where: n.string().describe("The SQL-92 where clause representing the feature from which to get an attribute value.")
@@ -1971,19 +1971,19 @@ const mo = n.object({
1971
1971
  "The SQL-92 where clause representing the features from which to filter features from the targetLayer by geometry."
1972
1972
  ),
1973
1973
  distance: n.number().optional().describe("The distance by which to query from the input geometry."),
1974
- units: uo.optional().describe("The units used to query by geometry and distance.")
1974
+ units: co.optional().describe("The units used to query by geometry and distance.")
1975
1975
  }),
1976
1976
  n.object({}).strict()
1977
1977
  // <-- Allows `{}` without throwing
1978
1978
  ]).optional().describe("Optional geometry-based filtering parameters for spatial queries."),
1979
1979
  fieldName: n.string().describe("The name of the field for which to get statistics."),
1980
1980
  statisticType: n.enum(["avg", "max", "median", "min", "stddev", "sum", "variance", "nullcount", "count"]).describe("The statistic type to calculate.")
1981
- }), po = b(ho, {
1981
+ }), mo = b(uo, {
1982
1982
  name: "getStatistics",
1983
1983
  description: "Returns one or more summary statistics for the given field. Statistic types include: count, maximum, minimum, average, median, standard deviation, variance, mode, sum, nullcount (number of features without a value for a given field), unique values. Statistics can be returned for number, date, and string fields. Only call this tool when the question requires filtering (e.g. a WHERE clause or spatial constraint) that cannot be satisfied by precomputed stats.",
1984
- schema: mo
1985
- }), yo = async (e, t, r, a) => {
1986
- const o = r.map?.allLayers.find((u) => u.id === e.layerId), s = a ? await ge(a, r) : { geometry: void 0 }, i = "geometry" in s ? s.geometry : void 0, l = new je({
1984
+ schema: ho
1985
+ }), po = async (e, t, r, a) => {
1986
+ const o = r.map?.allLayers.find((u) => u.id === e.layerId), s = a ? await ge(a, r) : { geometry: void 0 }, i = "geometry" in s ? s.geometry : void 0, l = new _e({
1987
1987
  where: e.where || "1=1",
1988
1988
  outFields: e.outFields.length ? e.outFields : ["*"],
1989
1989
  orderByFields: e.orderByFields,
@@ -1991,7 +1991,7 @@ const mo = n.object({
1991
1991
  spatialRelationship: i ? "intersects" : void 0,
1992
1992
  distance: a?.distance,
1993
1993
  units: a?.units,
1994
- topFilter: new Me({
1994
+ topFilter: new je({
1995
1995
  topCount: t.topCount,
1996
1996
  groupByFields: t.groupByFields,
1997
1997
  orderByFields: t.orderByFields
@@ -2007,14 +2007,14 @@ const mo = n.object({
2007
2007
  where: e.where
2008
2008
  }
2009
2009
  };
2010
- }, go = async ({
2010
+ }, yo = async ({
2011
2011
  targetLayer: e,
2012
2012
  topFilter: t,
2013
2013
  geometryLayer: r
2014
2014
  }, a) => {
2015
- const { mapView: o } = H(a), s = await yo(e, t, o, r);
2015
+ const { mapView: o } = H(a), s = await po(e, t, o, r);
2016
2016
  return JSON.stringify(s, null, 2);
2017
- }, fo = n.object({
2017
+ }, go = n.object({
2018
2018
  targetLayer: n.object({
2019
2019
  layerId: n.string().describe("The layerId of the layer containing the field from which to get a value."),
2020
2020
  where: n.string().describe("The SQL-92 where clause representing the feature from which to get an attribute value."),
@@ -2038,12 +2038,12 @@ const mo = n.object({
2038
2038
  orderByFields: n.array(n.string().describe("The field(s) and order for which to sort the resulting features.")),
2039
2039
  groupByFields: n.array(n.string().describe("The field(s) for which to group by the top features."))
2040
2040
  })
2041
- }), wo = b(go, {
2041
+ }), fo = b(yo, {
2042
2042
  name: "getTopFeatures",
2043
2043
  description: "Returns the top n features from a layer",
2044
- schema: fo
2045
- }), bo = async (e, t, r) => {
2046
- const a = t.map?.allLayers.find((d) => d.id === e.layerId), o = r ? await ge(r, t) : { geometry: void 0 }, s = "geometry" in o ? o.geometry : void 0, i = new pt({
2044
+ schema: go
2045
+ }), wo = async (e, t, r) => {
2046
+ const a = t.map?.allLayers.find((d) => d.id === e.layerId), o = r ? await ge(r, t) : { geometry: void 0 }, s = "geometry" in o ? o.geometry : void 0, i = new mt({
2047
2047
  where: e.where || "1=1",
2048
2048
  outFields: e.outFields.length ? e.outFields : ["*"],
2049
2049
  orderByFields: e.orderByFields,
@@ -2063,14 +2063,14 @@ const mo = n.object({
2063
2063
  }
2064
2064
  };
2065
2065
  };
2066
- async function So({
2066
+ async function bo({
2067
2067
  targetLayer: e,
2068
2068
  geometryLayer: t
2069
2069
  }, r) {
2070
- const { mapView: a } = H(r), o = await bo(e, a, t);
2070
+ const { mapView: a } = H(r), o = await wo(e, a, t);
2071
2071
  return JSON.stringify(o, null, 2);
2072
2072
  }
2073
- const vo = n.object({
2073
+ const So = n.object({
2074
2074
  targetLayer: n.object({
2075
2075
  layerId: n.string().describe("The layerId of the layer containing the field from which to get a value."),
2076
2076
  where: n.string().describe("The SQL-92 where clause representing the feature from which to get an attribute value."),
@@ -2089,11 +2089,11 @@ const vo = n.object({
2089
2089
  distance: n.number().describe("The distance by which to query from the input geometry."),
2090
2090
  units: A.describe("The units used to query by geometry and distance.")
2091
2091
  }).optional().describe("Optional geometry-based filtering parameters for spatial queries.")
2092
- }), To = b(So, {
2092
+ }), vo = b(bo, {
2093
2093
  name: "queryFeatures",
2094
2094
  description: "Queries for one or more features from a given layer.",
2095
- schema: vo
2096
- }), Je = [To, po, io, wo], xo = async (e, t) => {
2095
+ schema: So
2096
+ }), Ze = [vo, mo, no, fo], To = async (e, t) => {
2097
2097
  await m({ text: "Requesting LLM for layer query results" }, t);
2098
2098
  const r = await R("data_query_prompt");
2099
2099
  if (!t?.configurable)
@@ -2107,7 +2107,7 @@ const vo = n.object({
2107
2107
  modelTier: "advanced",
2108
2108
  messages: x(e.messages),
2109
2109
  inputVariables: s,
2110
- tools: Je
2110
+ tools: Ze
2111
2111
  });
2112
2112
  if (!(i.tool_calls && Array.isArray(i.tool_calls) && i.tool_calls.length > 0))
2113
2113
  return {
@@ -2116,9 +2116,9 @@ const vo = n.object({
2116
2116
  };
2117
2117
  const c = i.content.toString() || "LLM requested tool calls.";
2118
2118
  return await U(i, t), { ...e, outputMessage: c, messages: [...e.messages, i] };
2119
- }, Eo = new z(Je);
2120
- async function $o(e, t) {
2121
- const { messages: r } = await Eo.invoke(
2119
+ }, xo = new z(Ze);
2120
+ async function Eo(e, t) {
2121
+ const { messages: r } = await xo.invoke(
2122
2122
  { messages: x(e.messages) },
2123
2123
  t
2124
2124
  ), a = [], o = [];
@@ -2153,7 +2153,7 @@ ${o.join(`
2153
2153
  queryResponses: a
2154
2154
  };
2155
2155
  }
2156
- const Fo = async (e, t) => {
2156
+ const $o = async (e, t) => {
2157
2157
  try {
2158
2158
  await m({ text: "Requesting LLM for summary on query results" }, t);
2159
2159
  const a = await R("summarize_query_response_prompt"), o = {
@@ -2167,23 +2167,23 @@ const Fo = async (e, t) => {
2167
2167
  } catch (r) {
2168
2168
  throw await m({ text: "Error during filter LLM request" }, t), new Error(`Error during filter LLM request: ${r instanceof Error ? r.message : String(r)}`);
2169
2169
  }
2170
- }, Ro = (e, t) => D(["layerSearch", "fieldSearch", "layersAndFieldsRegistry"], "Layer Query Agent")(e, t), Lo = () => new M(Ze).addNode("requireLayerQueryServices", Ro).addNode("vectorSearchLayers", ro).addNode("vectorSearchFields", eo).addNode("fieldStatistics", Ya).addNode("agent", xo).addNode("tools", $o).addNode("summarizeQueryResponseLLM", Fo).addNode("earlyExit", Ja).addEdge(P, "requireLayerQueryServices").addEdge("requireLayerQueryServices", "vectorSearchLayers").addConditionalEdges(
2170
+ }, Fo = (e, t) => D(["layerSearch", "fieldSearch", "layersAndFieldsRegistry"], "Layer Query Agent")(e, t), Ro = () => new M(He).addNode("requireLayerQueryServices", Fo).addNode("vectorSearchLayers", to).addNode("vectorSearchFields", Xa).addNode("fieldStatistics", Ja).addNode("agent", To).addNode("tools", Eo).addNode("summarizeQueryResponseLLM", $o).addNode("earlyExit", Za).addEdge(P, "requireLayerQueryServices").addEdge("requireLayerQueryServices", "vectorSearchLayers").addConditionalEdges(
2171
2171
  "vectorSearchLayers",
2172
2172
  (t) => t.vectorSearchLayerIds.length ? "vectorSearchFields" : "earlyExit"
2173
2173
  ).addConditionalEdges(
2174
2174
  "vectorSearchFields",
2175
2175
  (t) => t.vectorSearchFieldResults.length ? "fieldStatistics" : "earlyExit"
2176
- ).addEdge("fieldStatistics", "agent").addEdge("agent", "tools").addConditionalEdges("tools", (t) => t.queryResponses.length ? "summarizeQueryResponseLLM" : "earlyExit").addEdge("summarizeQueryResponseLLM", F).addEdge("earlyExit", F), Io = String.raw`- **layerQuery** — 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. CRITICAL: Always call the Layer Filter Agent after this agent.
2176
+ ).addEdge("fieldStatistics", "agent").addEdge("agent", "tools").addConditionalEdges("tools", (t) => t.queryResponses.length ? "summarizeQueryResponseLLM" : "earlyExit").addEdge("summarizeQueryResponseLLM", F).addEdge("earlyExit", F), Lo = String.raw`- **layerQuery** — 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. CRITICAL: Always call the Layer Filter Agent after this agent.
2177
2177
  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?”).
2178
2178
  _Example: “How many features are there?”_
2179
2179
  _Example: “What’s the average population?”_
2180
- _Example: “Which values are in the status field?”_`, ji = {
2180
+ _Example: “Which values are in the status field?”_`, _i = {
2181
2181
  id: "layerQuery",
2182
2182
  name: "Layer Query Agent",
2183
- description: Io,
2184
- createGraph: Lo,
2185
- workspace: Ze
2186
- }, qe = 0.7, qo = 10, Co = async (e, t) => {
2183
+ description: Lo,
2184
+ createGraph: Ro,
2185
+ workspace: He
2186
+ }, qe = 0.7, Io = 10, qo = async (e, t) => {
2187
2187
  try {
2188
2188
  const r = C(e.messages);
2189
2189
  await m({ text: "Similarity search to find fields" }, t);
@@ -2191,7 +2191,7 @@ const Fo = async (e, t) => {
2191
2191
  text: r,
2192
2192
  layerIds: e.vectorSearchLayerIds,
2193
2193
  minScore: qe,
2194
- topResults: qo,
2194
+ topResults: Io,
2195
2195
  embeddingCache: s
2196
2196
  }), l = i.map(({ layerId: d, results: u }) => {
2197
2197
  const h = u.map((p) => ` - ${p.name} (${p.score.toFixed(2)})`).join(`
@@ -2212,13 +2212,13 @@ ${l}` : c = `No vector search results found for score over ${qe}.`, await m({ te
2212
2212
  t
2213
2213
  ), new Error(`Vector search failed: ${r instanceof Error ? r.message : String(r)}`);
2214
2214
  }
2215
- }, Ao = 0.7, No = async (e, t) => {
2215
+ }, Co = 0.7, Ao = async (e, t) => {
2216
2216
  try {
2217
2217
  const r = C(e.messages);
2218
2218
  await m({ text: `Similarity search to find layers: ${r}` }, t);
2219
2219
  const a = S(t, "layerSearch"), o = S(t, "layersAndFieldsRegistry"), s = await a.searchLayers({
2220
2220
  text: r,
2221
- minScore: Ao
2221
+ minScore: Co
2222
2222
  }), i = s.map((d) => d.id), l = s.map(({ id: d, score: u }) => `${o.get(d)?.layerItem.name ?? d} (${u.toFixed(2)})`).join(`
2223
2223
  `);
2224
2224
  let c;
@@ -2234,15 +2234,15 @@ ${l}` : c = "Vector search completed. No matching layers found.", await m({ text
2234
2234
  ), new Error(`Vector search failed: ${r instanceof Error ? r.message : String(r)}`);
2235
2235
  }
2236
2236
  };
2237
- async function ko(e) {
2237
+ async function No(e) {
2238
2238
  const { fields: t, layer: r, view: a, styleName: o, colorSchemeTags: s } = e;
2239
2239
  let i;
2240
- return s ? i = gt({
2240
+ return s ? i = yt({
2241
2241
  basemapTheme: await Te(a),
2242
2242
  geometryType: r.geometryType,
2243
2243
  includedTags: s,
2244
2244
  numColors: Math.min(t.length, 8)
2245
- })[0] : i = ft({
2245
+ })[0] : i = gt({
2246
2246
  basemapTheme: await Te(a),
2247
2247
  geometryType: r.geometryType,
2248
2248
  numColors: Math.min(t.length, 8)
@@ -2259,10 +2259,10 @@ async function ko(e) {
2259
2259
  pieChartScheme: i
2260
2260
  };
2261
2261
  }
2262
- async function zo(e) {
2263
- return await yt(e);
2262
+ async function ko(e) {
2263
+ return await pt(e);
2264
2264
  }
2265
- async function _o({
2265
+ async function zo({
2266
2266
  arcgisMap: e,
2267
2267
  arcgisMapView: t,
2268
2268
  layerId: r,
@@ -2281,30 +2281,30 @@ async function _o({
2281
2281
  colorSchemeTags: o
2282
2282
  };
2283
2283
  try {
2284
- const u = await ko(d), h = await zo(u);
2284
+ const u = await No(d), h = await ko(u);
2285
2285
  return l.renderer = h.renderer, l.visible = !0, `Chart renderer applied to layer: ${l.title ?? l.id} using fields ${a.join(", ")}`;
2286
2286
  } catch (u) {
2287
2287
  return `Error applying chart renderer: ${u instanceof Error ? u.message : String(u)}`;
2288
2288
  }
2289
2289
  }
2290
- const jo = ["mapView"];
2290
+ const _o = ["mapView"];
2291
2291
  function q(e) {
2292
2292
  const r = e?.configurable?.context;
2293
2293
  if (!r || typeof r != "object")
2294
2294
  throw new Error("LayerStylingAgent context missing");
2295
- const a = jo.filter((o) => !(o in r));
2295
+ const a = _o.filter((o) => !(o in r));
2296
2296
  if (a.length)
2297
2297
  throw new Error(`LayerStylingAgent context missing: ${a.join(", ")}`);
2298
2298
  return r;
2299
2299
  }
2300
- async function Mo({
2300
+ async function jo({
2301
2301
  layerId: e,
2302
2302
  fields: t,
2303
2303
  colorSchemes: r,
2304
2304
  includeSize: a
2305
2305
  }, o) {
2306
2306
  const { mapView: s } = q(o);
2307
- return await L({ id: "show-legend", description: "Show Legend", payload: { layerIds: [e] } }, o), await _o({
2307
+ return await L({ id: "show-legend", description: "Show Legend", payload: { layerIds: [e] } }, o), await zo({
2308
2308
  arcgisMap: s.map,
2309
2309
  arcgisMapView: s,
2310
2310
  layerId: e,
@@ -2313,12 +2313,12 @@ async function Mo({
2313
2313
  includeSize: a
2314
2314
  });
2315
2315
  }
2316
- const Po = n.object({
2316
+ const Mo = n.object({
2317
2317
  layerId: n.string().describe("The id of the layer to apply the chart renderer to"),
2318
2318
  fields: n.array(n.string()).describe("The fields to use for the chart renderer (multiple numeric fields)"),
2319
2319
  colorSchemes: n.array(n.string()).optional().describe("Optional color scheme tags to use"),
2320
2320
  includeSize: n.boolean().optional().describe("Whether to vary the chart size (chart-size)")
2321
- }), Do = b(Mo, {
2321
+ }), Po = b(jo, {
2322
2322
  name: "chart",
2323
2323
  description: `Label: Charts
2324
2324
  Description: Show the values of two or more categories as a proportion of the total using a pie chart.
@@ -2331,9 +2331,9 @@ const Po = n.object({
2331
2331
  Keywords: pie, chart, all categories, breakdown, proportion, total, amount, how much, sum, graduated size, proportional size
2332
2332
  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.
2333
2333
  Fields: This style requires 2-8 number fields.`,
2334
- schema: Po
2334
+ schema: Mo
2335
2335
  });
2336
- function Go(e) {
2336
+ function Do(e) {
2337
2337
  const { fields: t, layer: r, view: a, theme: o, colorSchemeTags: s } = e, i = t[0];
2338
2338
  let l;
2339
2339
  return s && (l = ue({
@@ -2351,10 +2351,10 @@ function Go(e) {
2351
2351
  colorScheme: l
2352
2352
  };
2353
2353
  }
2354
- async function Oo(e) {
2355
- return await wt(e);
2354
+ async function Go(e) {
2355
+ return await ft(e);
2356
2356
  }
2357
- async function Qo({
2357
+ async function Oo({
2358
2358
  arcgisMap: e,
2359
2359
  arcgisMapView: t,
2360
2360
  layerId: r,
@@ -2374,20 +2374,20 @@ async function Qo({
2374
2374
  theme: s
2375
2375
  };
2376
2376
  try {
2377
- const d = Go(c), u = await Oo(d);
2377
+ const d = Do(c), u = await Go(d);
2378
2378
  return l.renderer = u.renderer, l.visible = !0, `Color-age renderer applied to layer: ${l.title ?? l.id} using fields ${a.join(", ")}`;
2379
2379
  } catch (d) {
2380
2380
  return `Error applying color-age renderer: ${d instanceof Error ? d.message : String(d)}`;
2381
2381
  }
2382
2382
  }
2383
- async function Vo({
2383
+ async function Qo({
2384
2384
  layerId: e,
2385
2385
  fields: t,
2386
2386
  colorSchemes: r,
2387
2387
  theme: a
2388
2388
  }, o) {
2389
2389
  const { mapView: s } = q(o);
2390
- return await L({ id: "show-legend", description: "Show Legend", payload: { layerIds: [e] } }, o), await Qo({
2390
+ return await L({ id: "show-legend", description: "Show Legend", payload: { layerIds: [e] } }, o), await Oo({
2391
2391
  arcgisMap: s.map,
2392
2392
  arcgisMapView: s,
2393
2393
  layerId: e,
@@ -2396,21 +2396,21 @@ async function Vo({
2396
2396
  theme: a
2397
2397
  });
2398
2398
  }
2399
- const Wo = n.object({
2399
+ const Vo = n.object({
2400
2400
  layerId: n.string().describe("The id of the layer to apply the color-age renderer to"),
2401
2401
  fields: n.array(n.string()).describe("The field(s) to use for the color-age renderer (temporal/date data)"),
2402
2402
  colorSchemes: n.array(n.string()).optional().describe("Optional color scheme tags to use"),
2403
2403
  theme: n.enum(["above-and-below", "above", "below", "centered-on", "extremes", "high-to-low"]).optional().describe("Optional theme for the color ramp")
2404
- }), Bo = b(Vo, {
2404
+ }), Wo = b(Qo, {
2405
2405
  name: "color-age",
2406
2406
  description: `Label: Age (color)
2407
2407
  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.
2408
2408
  Keywords: since, age, how old, how long
2409
2409
  Example: Show the age of each feature based on its reported date.
2410
2410
  Fields: This style requires at least one field with a date type.`,
2411
- schema: Wo
2411
+ schema: Vo
2412
2412
  });
2413
- function Ko(e) {
2413
+ function Bo(e) {
2414
2414
  const { fields: t, layer: r, view: a, colorSchemeTags: o } = e;
2415
2415
  let { theme: s } = e, i = t[1];
2416
2416
  const l = t[0];
@@ -2430,10 +2430,10 @@ function Ko(e) {
2430
2430
  colorScheme: c
2431
2431
  };
2432
2432
  }
2433
- async function Uo(e) {
2434
- return await bt(e);
2433
+ async function Ko(e) {
2434
+ return await wt(e);
2435
2435
  }
2436
- async function Ho({
2436
+ async function Uo({
2437
2437
  arcgisMap: e,
2438
2438
  arcgisMapView: t,
2439
2439
  layerId: r,
@@ -2453,20 +2453,20 @@ async function Ho({
2453
2453
  theme: s
2454
2454
  };
2455
2455
  try {
2456
- const d = Ko(c), u = await Uo(d);
2456
+ const d = Bo(c), u = await Ko(d);
2457
2457
  return l.renderer = u.renderer, l.visible = !0, `Color renderer applied to layer: ${l.title ?? l.id} using fields ${a.join(", ")}`;
2458
2458
  } catch (d) {
2459
2459
  return `Error applying color renderer: ${d instanceof Error ? d.message : String(d)}`;
2460
2460
  }
2461
2461
  }
2462
- async function Zo({
2462
+ async function Ho({
2463
2463
  layerId: e,
2464
2464
  fields: t,
2465
2465
  colorSchemes: r,
2466
2466
  theme: a
2467
2467
  }, o) {
2468
2468
  const { mapView: s } = q(o);
2469
- return await L({ id: "show-legend", description: "Show Legend", payload: { layerIds: [e] } }, o), await Ho({
2469
+ return await L({ id: "show-legend", description: "Show Legend", payload: { layerIds: [e] } }, o), await Uo({
2470
2470
  arcgisMap: s.map,
2471
2471
  arcgisMapView: s,
2472
2472
  layerId: e,
@@ -2475,21 +2475,21 @@ async function Zo({
2475
2475
  theme: a
2476
2476
  });
2477
2477
  }
2478
- const Jo = n.object({
2478
+ const Zo = n.object({
2479
2479
  layerId: n.string().describe("The id of the layer to apply the color renderer to"),
2480
2480
  fields: n.array(n.string()).describe("The field(s) to use for the color renderer"),
2481
2481
  colorSchemes: n.array(n.string()).optional().describe("Optional color scheme tags to use"),
2482
2482
  theme: n.enum(["above-and-below", "above", "below", "centered-on", "extremes", "high-to-low"]).optional().describe("Optional theme for the color ramp")
2483
- }), Yo = b(Zo, {
2483
+ }), Jo = b(Ho, {
2484
2484
  name: "color",
2485
2485
  description: `Label: Counts and Amounts (color)
2486
2486
  Description: Vary color along a continuous color ramp to represent numeric or ranked data.
2487
2487
  Keywords: graduated color, choropleth, continuous color, hue, color, gradation, saturation, lightness, percent, rate, ratio, index, how much, increase, decrease
2488
2488
  Example: Color each feature based on the population density.
2489
2489
  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.`,
2490
- schema: Jo
2490
+ schema: Zo
2491
2491
  });
2492
- function Xo(e) {
2492
+ function Yo(e) {
2493
2493
  const { fields: t, layer: r, view: a, colorSchemeTags: o, theme: s } = e;
2494
2494
  let i, l;
2495
2495
  const c = t[0];
@@ -2508,10 +2508,10 @@ function Xo(e) {
2508
2508
  }
2509
2509
  };
2510
2510
  }
2511
- async function es(e) {
2512
- return await St(e);
2511
+ async function Xo(e) {
2512
+ return await bt(e);
2513
2513
  }
2514
- async function ts({
2514
+ async function es({
2515
2515
  arcgisMap: e,
2516
2516
  arcgisMapView: t,
2517
2517
  layerId: r,
@@ -2531,20 +2531,20 @@ async function ts({
2531
2531
  theme: s
2532
2532
  };
2533
2533
  try {
2534
- const d = Xo(c), u = await es(d);
2534
+ const d = Yo(c), u = await Xo(d);
2535
2535
  return l.renderer = u.renderer, l.visible = !0, `Color-size-univariate renderer applied to layer: ${l.title ?? l.id} using fields ${a.join(", ")}`;
2536
2536
  } catch (d) {
2537
2537
  return `Error applying color-size-univariate renderer: ${d instanceof Error ? d.message : String(d)}`;
2538
2538
  }
2539
2539
  }
2540
- async function rs({
2540
+ async function ts({
2541
2541
  layerId: e,
2542
2542
  fields: t,
2543
2543
  colorSchemes: r,
2544
2544
  theme: a
2545
2545
  }, o) {
2546
2546
  const { mapView: s } = q(o);
2547
- return await L({ id: "show-legend", description: "Show Legend", payload: { layerIds: [e] } }, o), await ts({
2547
+ return await L({ id: "show-legend", description: "Show Legend", payload: { layerIds: [e] } }, o), await es({
2548
2548
  arcgisMap: s.map,
2549
2549
  arcgisMapView: s,
2550
2550
  layerId: e,
@@ -2553,24 +2553,24 @@ async function rs({
2553
2553
  theme: a
2554
2554
  });
2555
2555
  }
2556
- const as = n.object({
2556
+ const rs = n.object({
2557
2557
  layerId: n.string().describe("The id of the layer to apply the color-size univariate renderer to"),
2558
2558
  fields: n.array(n.string()).describe("The fields to use for the color-size univariate renderer"),
2559
2559
  colorSchemes: n.array(n.string()).optional().describe("Optional color scheme tags to use"),
2560
2560
  theme: n.enum(["above-and-below", "above", "below", "centered-on", "extremes", "high-to-low"]).optional().describe("Optional theme for the color and size ramps")
2561
- }), os = b(rs, {
2561
+ }), as = b(ts, {
2562
2562
  name: "color-size-univariate",
2563
2563
  description: `Label: Color and Size (univariate)
2564
2564
  Description: Vary symbol size and color based on the values of two numeric attributes.
2565
2565
  Keywords: continuous color, hue, color, size, gradation, saturation, lightness, percent, rate, ratio, index, how much, increase, decrease, amount
2566
2566
  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.
2567
2567
  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.`,
2568
- schema: as
2568
+ schema: rs
2569
2569
  });
2570
- function ss(e) {
2570
+ function os(e) {
2571
2571
  const { fields: t, layer: r, view: a, colorSchemeTags: o } = e;
2572
2572
  let s;
2573
- return o && (s = Tt({
2573
+ return o && (s = vt({
2574
2574
  includedTags: o,
2575
2575
  numColors: Math.min(t.length, 8)
2576
2576
  })[0]), {
@@ -2587,10 +2587,10 @@ function ss(e) {
2587
2587
  dotDensityScheme: s
2588
2588
  };
2589
2589
  }
2590
- async function ns(e) {
2591
- return await vt(e);
2590
+ async function ss(e) {
2591
+ return await St(e);
2592
2592
  }
2593
- async function is({
2593
+ async function ns({
2594
2594
  arcgisMap: e,
2595
2595
  arcgisMapView: t,
2596
2596
  layerId: r,
@@ -2608,19 +2608,19 @@ async function is({
2608
2608
  colorSchemeTags: o
2609
2609
  };
2610
2610
  try {
2611
- const c = ss(l), d = await ns(c);
2611
+ const c = os(l), d = await ss(c);
2612
2612
  return i.renderer = d.renderer, i.visible = !0, `Dot Density renderer applied to layer: ${i.title ?? i.id} using fields ${a.join(", ")}`;
2613
2613
  } catch (c) {
2614
2614
  return `Error applying dot density renderer: ${c instanceof Error ? c.message : String(c)}`;
2615
2615
  }
2616
2616
  }
2617
- async function ls({
2617
+ async function is({
2618
2618
  layerId: e,
2619
2619
  fields: t,
2620
2620
  colorSchemes: r
2621
2621
  }, a) {
2622
2622
  const { mapView: o } = q(a);
2623
- return await L({ id: "show-legend", description: "Show Legend", payload: { layerIds: [e] } }, a), await is({
2623
+ return await L({ id: "show-legend", description: "Show Legend", payload: { layerIds: [e] } }, a), await ns({
2624
2624
  arcgisMap: o.map,
2625
2625
  arcgisMapView: o,
2626
2626
  layerId: e,
@@ -2628,11 +2628,11 @@ async function ls({
2628
2628
  colorSchemes: r
2629
2629
  });
2630
2630
  }
2631
- const cs = n.object({
2631
+ const ls = n.object({
2632
2632
  layerId: n.string().describe("The id of the layer to apply the dot density renderer to"),
2633
2633
  fields: n.array(n.string()).describe("The field(s) to use for the dot density renderer (population or count data)"),
2634
2634
  colorSchemes: n.array(n.string()).optional().describe("Optional color scheme tags to use")
2635
- }), ds = b(ls, {
2635
+ }), cs = b(is, {
2636
2636
  name: "dot-density",
2637
2637
  description: `Dot Density
2638
2638
  Use dot density to visualize the distribution of one attribute or compare the density of multiple attributes. This is only valid for polygon layers.
@@ -2646,13 +2646,13 @@ const cs = n.object({
2646
2646
  - Display demographic patterns within census tracts
2647
2647
  **Fields:** Requires 2-8 number fields.
2648
2648
  **Keywords:** density, how much, how many, total, number, amount`,
2649
- schema: cs
2649
+ schema: ls
2650
2650
  });
2651
- function us(e) {
2651
+ function ds(e) {
2652
2652
  const { fields: t, layer: r, view: a, colorSchemeTags: o } = e;
2653
2653
  let s;
2654
2654
  const i = t[0];
2655
- return o && (s = Et({
2655
+ return o && (s = xt({
2656
2656
  includedTags: o,
2657
2657
  basemap: a.map?.basemap || "topo"
2658
2658
  })[0]), {
@@ -2662,10 +2662,10 @@ function us(e) {
2662
2662
  heatmapScheme: s
2663
2663
  };
2664
2664
  }
2665
- async function hs(e) {
2666
- return await xt(e);
2665
+ async function us(e) {
2666
+ return await Tt(e);
2667
2667
  }
2668
- async function ms({
2668
+ async function hs({
2669
2669
  arcgisMap: e,
2670
2670
  arcgisMapView: t,
2671
2671
  layerId: r,
@@ -2683,19 +2683,19 @@ async function ms({
2683
2683
  colorSchemeTags: o
2684
2684
  };
2685
2685
  try {
2686
- const c = us(l), d = await hs(c);
2686
+ const c = ds(l), d = await us(c);
2687
2687
  return i.renderer = d.renderer, i.visible = !0, `Heatmap renderer applied to layer: ${i.title ?? i.id} using fields ${a.join(", ")}`;
2688
2688
  } catch (c) {
2689
2689
  return `Error applying heatmap renderer: ${c instanceof Error ? c.message : String(c)}`;
2690
2690
  }
2691
2691
  }
2692
- async function ps({
2692
+ async function ms({
2693
2693
  layerId: e,
2694
2694
  fields: t,
2695
2695
  colorSchemes: r
2696
2696
  }, a) {
2697
2697
  const { mapView: o } = q(a);
2698
- return await L({ id: "show-legend", description: "Show Legend", payload: { layerIds: [e] } }, a), await ms({
2698
+ return await L({ id: "show-legend", description: "Show Legend", payload: { layerIds: [e] } }, a), await hs({
2699
2699
  arcgisMap: o.map,
2700
2700
  arcgisMapView: o,
2701
2701
  layerId: e,
@@ -2703,23 +2703,23 @@ async function ps({
2703
2703
  colorSchemes: r
2704
2704
  });
2705
2705
  }
2706
- const ys = n.object({
2706
+ const ps = n.object({
2707
2707
  layerId: n.string().describe("The id of the layer to apply the heatmap renderer to"),
2708
2708
  fields: n.array(n.string()).describe("The field(s) to use for the heatmap renderer (typically point density)"),
2709
2709
  colorSchemes: n.array(n.string()).optional().describe("Optional color scheme tags to use")
2710
- }), gs = b(ps, {
2710
+ }), ys = b(ms, {
2711
2711
  name: "heatmap",
2712
2712
  description: `Label: Heat Map
2713
2713
  Description: Show areas of high density with colors that appear to glow hotter. This is only valid for point layers.
2714
2714
  Keywords: density, heatmap, hot spots, pattern, cluster
2715
2715
  Example: Create a heatmap
2716
2716
  Fields: This typically requires zero or one field of type number.`,
2717
- schema: ys
2717
+ schema: ps
2718
2718
  });
2719
- function fs(e) {
2719
+ function gs(e) {
2720
2720
  const { fields: t, layer: r, view: a, styleName: o, colorSchemeTags: s } = e;
2721
2721
  let i;
2722
- return s && (i = Ft({
2722
+ return s && (i = $t({
2723
2723
  geometryType: r.geometryType,
2724
2724
  includedTags: s,
2725
2725
  numColors: Math.min(t.length, 10)
@@ -2733,10 +2733,10 @@ function fs(e) {
2733
2733
  predominanceScheme: i
2734
2734
  };
2735
2735
  }
2736
- async function ws(e) {
2737
- return await $t(e);
2736
+ async function fs(e) {
2737
+ return await Et(e);
2738
2738
  }
2739
- async function bs({
2739
+ async function ws({
2740
2740
  arcgisMap: e,
2741
2741
  arcgisMapView: t,
2742
2742
  layerId: r,
@@ -2755,20 +2755,20 @@ async function bs({
2755
2755
  colorSchemeTags: o
2756
2756
  };
2757
2757
  try {
2758
- const u = fs(d), h = await ws(u);
2758
+ const u = gs(d), h = await fs(u);
2759
2759
  return l.renderer = h.renderer, l.visible = !0, `Predominance renderer applied to layer: ${l.title ?? l.id} using fields ${a.join(", ")}`;
2760
2760
  } catch (u) {
2761
2761
  return `Error applying predominance renderer: ${u instanceof Error ? u.message : String(u)}`;
2762
2762
  }
2763
2763
  }
2764
- async function Ss({
2764
+ async function bs({
2765
2765
  layerId: e,
2766
2766
  fields: t,
2767
2767
  colorSchemes: r,
2768
2768
  includeSize: a
2769
2769
  }, o) {
2770
2770
  const { mapView: s } = q(o);
2771
- return await L({ id: "show-legend", description: "Show Legend", payload: { layerIds: [e] } }, o), await bs({
2771
+ return await L({ id: "show-legend", description: "Show Legend", payload: { layerIds: [e] } }, o), await ws({
2772
2772
  arcgisMap: s.map,
2773
2773
  arcgisMapView: s,
2774
2774
  layerId: e,
@@ -2777,12 +2777,12 @@ async function Ss({
2777
2777
  includeSize: a
2778
2778
  });
2779
2779
  }
2780
- const vs = n.object({
2780
+ const Ss = n.object({
2781
2781
  layerId: n.string().describe("The id of the layer to apply the predominance renderer to"),
2782
2782
  fields: n.array(n.string()).describe("The fields to use for the predominance renderer (competing categories)"),
2783
2783
  colorSchemes: n.array(n.string()).optional().describe("Optional color scheme tags to use"),
2784
2784
  includeSize: n.boolean().optional().describe("Whether to include size visualization (predominance-size)")
2785
- }), Ts = b(Ss, {
2785
+ }), vs = b(bs, {
2786
2786
  name: "predominance",
2787
2787
  description: `Label: Predominant category
2788
2788
  Description: Compare attributes that share a common subject and unit of measurement to see which has the highest value.
@@ -2795,9 +2795,9 @@ const vs = n.object({
2795
2795
  Keywords: predominant, winner, won, competing, most, most common, most frequent, dominant, prevalent, top, amount, total, how much, proportional size, graduated size, sum
2796
2796
  Example: Show the predominant crop in each area and vary the size of each symbol based on the total of all categories.
2797
2797
  Fields: This style relies on 2-10 number fields.`,
2798
- schema: vs
2798
+ schema: Ss
2799
2799
  });
2800
- function xs(e) {
2800
+ function Ts(e) {
2801
2801
  const { fields: t, layer: r, view: a, colorSchemeTags: o } = e;
2802
2802
  let s;
2803
2803
  const i = {
@@ -2805,7 +2805,7 @@ function xs(e) {
2805
2805
  }, l = {
2806
2806
  field: t[1]
2807
2807
  };
2808
- return o && (s = Lt({
2808
+ return o && (s = Rt({
2809
2809
  geometryType: r.geometryType,
2810
2810
  includedTags: o
2811
2811
  })[0]), {
@@ -2818,10 +2818,10 @@ function xs(e) {
2818
2818
  relationshipScheme: s
2819
2819
  };
2820
2820
  }
2821
- async function Es(e) {
2822
- return await Rt(e);
2821
+ async function xs(e) {
2822
+ return await Ft(e);
2823
2823
  }
2824
- async function $s({
2824
+ async function Es({
2825
2825
  arcgisMap: e,
2826
2826
  arcgisMapView: t,
2827
2827
  layerId: r,
@@ -2839,19 +2839,19 @@ async function $s({
2839
2839
  colorSchemeTags: o
2840
2840
  };
2841
2841
  try {
2842
- const c = xs(l), d = await Es(c);
2842
+ const c = Ts(l), d = await xs(c);
2843
2843
  return i.renderer = d.renderer, i.visible = !0, `Relationship renderer applied to layer: ${i.title ?? i.id} using fields ${a.join(", ")}`;
2844
2844
  } catch (c) {
2845
2845
  return `Error applying relationship renderer: ${c instanceof Error ? c.message : String(c)}`;
2846
2846
  }
2847
2847
  }
2848
- async function Fs({
2848
+ async function $s({
2849
2849
  layerId: e,
2850
2850
  fields: t,
2851
2851
  colorSchemes: r
2852
2852
  }, a) {
2853
2853
  const { mapView: o } = q(a);
2854
- return await L({ id: "show-legend", description: "Show Legend", payload: { layerIds: [e] } }, a), await $s({
2854
+ return await L({ id: "show-legend", description: "Show Legend", payload: { layerIds: [e] } }, a), await Es({
2855
2855
  arcgisMap: o.map,
2856
2856
  arcgisMapView: o,
2857
2857
  layerId: e,
@@ -2859,20 +2859,20 @@ async function Fs({
2859
2859
  colorSchemes: r
2860
2860
  });
2861
2861
  }
2862
- const Rs = n.object({
2862
+ const Fs = n.object({
2863
2863
  layerId: n.string().describe("The id of the layer to apply the relationship renderer to"),
2864
2864
  fields: n.array(n.string()).describe("The two fields to use for the relationship renderer (bivariate visualization)"),
2865
2865
  colorSchemes: n.array(n.string()).optional().describe("Optional color scheme tags to use")
2866
- }), Ls = b(Fs, {
2866
+ }), Rs = b($s, {
2867
2867
  name: "relationship",
2868
2868
  description: `Label: Relationship
2869
2869
  Description: Overlays two color ramps to represent the relationship between two numeric attributes.
2870
2870
  Keywords: relationship, correlation, compare, related, bivariate choropleth, bivariate color
2871
2871
  Example: Show the relationship between tree height and carbon storage
2872
2872
  Fields: This style requires two number fields.`,
2873
- schema: Rs
2873
+ schema: Fs
2874
2874
  });
2875
- function Is(e) {
2875
+ function Ls(e) {
2876
2876
  const { fields: t, layer: r, view: a, theme: o } = e, s = t[0];
2877
2877
  return {
2878
2878
  layer: r,
@@ -2884,10 +2884,10 @@ function Is(e) {
2884
2884
  outlineOptimizationEnabled: !0
2885
2885
  };
2886
2886
  }
2887
- async function qs(e) {
2888
- return await It(e);
2887
+ async function Is(e) {
2888
+ return await Lt(e);
2889
2889
  }
2890
- async function Cs({
2890
+ async function qs({
2891
2891
  arcgisMap: e,
2892
2892
  arcgisMapView: t,
2893
2893
  layerId: r,
@@ -2907,20 +2907,20 @@ async function Cs({
2907
2907
  theme: s
2908
2908
  };
2909
2909
  try {
2910
- const d = Is(c), u = await qs(d);
2910
+ const d = Ls(c), u = await Is(d);
2911
2911
  return l.renderer = u.renderer, l.visible = !0, `Size-age renderer applied to layer: ${l.title ?? l.id} using fields ${a.join(", ")}`;
2912
2912
  } catch (d) {
2913
2913
  return `Error applying size-age renderer: ${d instanceof Error ? d.message : String(d)}`;
2914
2914
  }
2915
2915
  }
2916
- async function As({
2916
+ async function Cs({
2917
2917
  layerId: e,
2918
2918
  fields: t,
2919
2919
  colorSchemes: r,
2920
2920
  theme: a
2921
2921
  }, o) {
2922
2922
  const { mapView: s } = q(o);
2923
- return await L({ id: "show-legend", description: "Show Legend", payload: { layerIds: [e] } }, o), await Cs({
2923
+ return await L({ id: "show-legend", description: "Show Legend", payload: { layerIds: [e] } }, o), await qs({
2924
2924
  arcgisMap: s.map,
2925
2925
  arcgisMapView: s,
2926
2926
  layerId: e,
@@ -2929,21 +2929,21 @@ async function As({
2929
2929
  theme: a
2930
2930
  });
2931
2931
  }
2932
- const Ns = n.object({
2932
+ const As = n.object({
2933
2933
  layerId: n.string().describe("The id of the layer to apply the size-age renderer to"),
2934
2934
  fields: n.array(n.string()).describe("The field(s) to use for the size-age renderer (temporal data with size)"),
2935
2935
  colorSchemes: n.array(n.string()).optional().describe("Optional color scheme tags to use"),
2936
2936
  theme: n.enum(["above-and-below", "above", "below", "centered-on", "extremes", "high-to-low"]).optional().describe("Optional theme for the size ramp")
2937
- }), ks = b(As, {
2937
+ }), Ns = b(Cs, {
2938
2938
  name: "size-age",
2939
2939
  description: `Label: Age (size)
2940
2940
  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.
2941
2941
  Keywords: since, age, how old, how long
2942
2942
  Example: Change the size of features so older features are larger than new features.
2943
2943
  Fields: This style requires at least one field with a date type.`,
2944
- schema: Ns
2944
+ schema: As
2945
2945
  });
2946
- function zs(e) {
2946
+ function ks(e) {
2947
2947
  const { fields: t, layer: r, view: a } = e;
2948
2948
  let { theme: o } = e, s = t[1];
2949
2949
  const i = t[0];
@@ -2957,10 +2957,10 @@ function zs(e) {
2957
2957
  outlineOptimizationEnabled: !0
2958
2958
  };
2959
2959
  }
2960
- async function _s(e) {
2961
- return await qt(e);
2960
+ async function zs(e) {
2961
+ return await It(e);
2962
2962
  }
2963
- async function js({
2963
+ async function _s({
2964
2964
  arcgisMap: e,
2965
2965
  arcgisMapView: t,
2966
2966
  layerId: r,
@@ -2980,20 +2980,20 @@ async function js({
2980
2980
  theme: s
2981
2981
  };
2982
2982
  try {
2983
- const d = zs(c), u = await _s(d);
2983
+ const d = ks(c), u = await zs(d);
2984
2984
  return l.renderer = u.renderer, l.visible = !0, `Size renderer applied to layer: ${l.title ?? l.id} using fields ${a.join(", ")}`;
2985
2985
  } catch (d) {
2986
2986
  return `Error applying size renderer: ${d instanceof Error ? d.message : String(d)}`;
2987
2987
  }
2988
2988
  }
2989
- async function Ms({
2989
+ async function js({
2990
2990
  layerId: e,
2991
2991
  fields: t,
2992
2992
  colorSchemes: r,
2993
2993
  theme: a
2994
2994
  }, o) {
2995
2995
  const { mapView: s } = q(o);
2996
- return await L({ id: "show-legend", description: "Show Legend", payload: { layerIds: [e] } }, o), await js({
2996
+ return await L({ id: "show-legend", description: "Show Legend", payload: { layerIds: [e] } }, o), await _s({
2997
2997
  arcgisMap: s.map,
2998
2998
  arcgisMapView: s,
2999
2999
  layerId: e,
@@ -3002,12 +3002,12 @@ async function Ms({
3002
3002
  theme: a
3003
3003
  });
3004
3004
  }
3005
- const Ps = n.object({
3005
+ const Ms = n.object({
3006
3006
  layerId: n.string().describe("The id of the layer to apply the size renderer to"),
3007
3007
  fields: n.array(n.string()).describe("The field(s) to use for the size renderer (numeric data)"),
3008
3008
  colorSchemes: n.array(n.string()).optional().describe("Optional color scheme tags to use"),
3009
3009
  theme: n.enum(["above-and-below", "above", "below", "centered-on", "extremes", "high-to-low"]).optional().describe("Optional theme for the size ramp")
3010
- }), Ds = b(Ms, {
3010
+ }), Ps = b(js, {
3011
3011
  name: "size",
3012
3012
  description: `Label: Counts and Amounts (size)
3013
3013
  Description: Vary symbol sizes along a continuous ramp to represent numeric or ranked data.
@@ -3020,12 +3020,12 @@ const Ps = n.object({
3020
3020
  Keywords: graduated size, proportional size, classed size, how much, total, number, when
3021
3021
  Example: Vary the size of each feature based on the date a ticket was completed.
3022
3022
  Fields: This style requires a single field with a date type.`,
3023
- schema: Ps
3023
+ schema: Ms
3024
3024
  });
3025
- function Gs(e) {
3025
+ function Ds(e) {
3026
3026
  const { fields: t, layer: r, view: a, colorSchemeTags: o } = e, s = t[0], i = t[1], l = t[2];
3027
3027
  let c;
3028
- return o && (c = At({
3028
+ return o && (c = Ct({
3029
3029
  geometryType: r.geometryType,
3030
3030
  includedTags: o
3031
3031
  })[0]), {
@@ -3039,10 +3039,10 @@ function Gs(e) {
3039
3039
  typeScheme: c
3040
3040
  };
3041
3041
  }
3042
- async function Os(e) {
3043
- return await Ct(e);
3042
+ async function Gs(e) {
3043
+ return await qt(e);
3044
3044
  }
3045
- async function Qs({
3045
+ async function Os({
3046
3046
  arcgisMap: e,
3047
3047
  arcgisMapView: t,
3048
3048
  layerId: r,
@@ -3062,20 +3062,20 @@ async function Qs({
3062
3062
  theme: s
3063
3063
  };
3064
3064
  try {
3065
- const d = Gs(c), u = await Os(d);
3065
+ const d = Ds(c), u = await Gs(d);
3066
3066
  return l.renderer = u.renderer, l.visible = !0, `Type renderer applied to layer: ${l.title ?? l.id} using fields ${a.join(", ")}`;
3067
3067
  } catch (d) {
3068
3068
  return `Error applying type renderer: ${d instanceof Error ? d.message : String(d)}`;
3069
3069
  }
3070
3070
  }
3071
- async function Vs({
3071
+ async function Qs({
3072
3072
  layerId: e,
3073
3073
  fields: t,
3074
3074
  colorSchemes: r,
3075
3075
  theme: a
3076
3076
  }, o) {
3077
3077
  const { mapView: s } = q(o);
3078
- return await L({ id: "show-legend", description: "Show Legend", payload: { layerIds: [e] } }, o), await Qs({
3078
+ return await L({ id: "show-legend", description: "Show Legend", payload: { layerIds: [e] } }, o), await Os({
3079
3079
  arcgisMap: s.map,
3080
3080
  arcgisMapView: s,
3081
3081
  layerId: e,
@@ -3084,32 +3084,32 @@ async function Vs({
3084
3084
  theme: a
3085
3085
  });
3086
3086
  }
3087
- const Ws = n.object({
3087
+ const Vs = n.object({
3088
3088
  layerId: n.string().describe("The id of the layer to apply the type renderer to"),
3089
3089
  fields: n.array(n.string()).describe("The field(s) to use for the type renderer (categorical data)"),
3090
3090
  colorSchemes: n.array(n.string()).optional().describe("Optional color scheme tags to use"),
3091
3091
  theme: n.enum(["above-and-below", "above", "below", "centered-on", "extremes", "high-to-low"]).optional().describe("Optional theme for the color scheme")
3092
- }), Bs = b(Vs, {
3092
+ }), Ws = b(Qs, {
3093
3093
  name: "type",
3094
3094
  description: `Label: Types (unique symbols)
3095
3095
  Description: Represent features as categories with different symbol colors or shapes. Examples include type of tree, road class, or province name.
3096
3096
  Keywords: categorical, category, type, unique, discrete, point of interest, region, group
3097
3097
  Example: Color each feature based on the region it belongs to
3098
3098
  Fields: This style requires a single field which may be a string, number, or date type. It is usually a string.`,
3099
- schema: Ws
3100
- }), Ye = [
3101
- Do,
3102
- Bo,
3103
- Yo,
3104
- os,
3105
- ds,
3106
- gs,
3107
- Ts,
3108
- Ls,
3109
- ks,
3110
- Ds,
3111
- Bs
3112
- ], Ks = async (e, t) => {
3099
+ schema: Vs
3100
+ }), Je = [
3101
+ Po,
3102
+ Wo,
3103
+ Jo,
3104
+ as,
3105
+ cs,
3106
+ ys,
3107
+ vs,
3108
+ Rs,
3109
+ Ns,
3110
+ Ps,
3111
+ Ws
3112
+ ], Bs = async (e, t) => {
3113
3113
  await m({ text: "Requesting LLM for layer query results" }, t);
3114
3114
  const r = await R("navigation_intent_prompt");
3115
3115
  if (!t?.configurable)
@@ -3121,12 +3121,12 @@ Fields: This style requires a single field which may be a string, number, or dat
3121
3121
  modelTier: "advanced",
3122
3122
  messages: x(e.messages),
3123
3123
  inputVariables: a,
3124
- tools: Ye
3124
+ tools: Je
3125
3125
  });
3126
3126
  return await U(o, t), { ...e, messages: [...e.messages, o] };
3127
3127
  };
3128
- async function Us(e, t) {
3129
- const a = await new z(Ye).invoke(
3128
+ async function Ks(e, t) {
3129
+ const a = await new z(Je).invoke(
3130
3130
  {
3131
3131
  messages: x(e.messages)
3132
3132
  },
@@ -3138,7 +3138,7 @@ async function Us(e, t) {
3138
3138
  `);
3139
3139
  return { ...e, outputMessage: s };
3140
3140
  }
3141
- const Xe = f.Root({
3141
+ const Ye = f.Root({
3142
3142
  // Inputs coming from global context
3143
3143
  messages: f({
3144
3144
  reducer: j,
@@ -3171,7 +3171,7 @@ ${r}`;
3171
3171
  vectorSearchFieldResults: f(),
3172
3172
  layerFieldInfo: f(),
3173
3173
  selectedLayerId: f()
3174
- }), Hs = async (e, t) => (await m({ text: "Exiting Layer Styling agent" }, t), e), Zs = async (e, t) => {
3174
+ }), Us = async (e, t) => (await m({ text: "Exiting Layer Styling agent" }, t), e), Hs = async (e, t) => {
3175
3175
  try {
3176
3176
  await m({ text: "Populating layer and field info" }, t);
3177
3177
  const r = [];
@@ -3202,7 +3202,7 @@ ${r}`;
3202
3202
  } catch (r) {
3203
3203
  throw await m({ text: "Error populating layerFieldInfo" }, t), new Error(`Error populating layerFieldInfo: ${r instanceof Error ? r.message : String(r)}`);
3204
3204
  }
3205
- }, Js = (e, t) => {
3205
+ }, Zs = (e, t) => {
3206
3206
  const r = e.vectorSearchLayerIds ?? [];
3207
3207
  if (r.length <= 1)
3208
3208
  return { ...e, selectedLayerId: e.vectorSearchLayerIds[0] };
@@ -3215,30 +3215,30 @@ ${r}`;
3215
3215
  message: "Choose a layer to apply the styles.",
3216
3216
  metadata: [...r]
3217
3217
  };
3218
- throw new ct(s);
3218
+ throw new lt(s);
3219
3219
  }
3220
3220
  let o = null;
3221
3221
  return Array.isArray(a.payload) && a.payload.length > 0 && (o = a.payload[0]), {
3222
3222
  ...e,
3223
3223
  selectedLayerId: o ?? e.vectorSearchLayerIds[0]
3224
3224
  };
3225
- }, Ys = (e, t) => D(["layerSearch", "fieldSearch", "layersAndFieldsRegistry"], "Layer Styling Agent")(e, t), Xs = () => new M(Xe).addNode("requireLayerStylingServices", Ys).addNode("vectorSearchLayers", No).addNode("layerSelectionHITL", Js).addNode("vectorSearchFields", Co).addNode("populateLayerFieldInfo", Zs).addNode("agent", Ks).addNode("tools", Us).addNode("earlyExit", Hs).addEdge(P, "requireLayerStylingServices").addEdge("requireLayerStylingServices", "vectorSearchLayers").addConditionalEdges(
3225
+ }, Js = (e, t) => D(["layerSearch", "fieldSearch", "layersAndFieldsRegistry"], "Layer Styling Agent")(e, t), Ys = () => new M(Ye).addNode("requireLayerStylingServices", Js).addNode("vectorSearchLayers", Ao).addNode("layerSelectionHITL", Zs).addNode("vectorSearchFields", qo).addNode("populateLayerFieldInfo", Hs).addNode("agent", Bs).addNode("tools", Ks).addNode("earlyExit", Us).addEdge(P, "requireLayerStylingServices").addEdge("requireLayerStylingServices", "vectorSearchLayers").addConditionalEdges(
3226
3226
  "layerSelectionHITL",
3227
3227
  (t) => t.vectorSearchLayerIds.length ? "vectorSearchFields" : "earlyExit"
3228
3228
  ).addConditionalEdges(
3229
3229
  "vectorSearchFields",
3230
3230
  (t) => t.vectorSearchFieldResults.length ? "populateLayerFieldInfo" : "earlyExit"
3231
- ).addEdge("populateLayerFieldInfo", "agent").addEdge("agent", "tools").addEdge("tools", F).addEdge("earlyExit", F), en = 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.
3231
+ ).addEdge("populateLayerFieldInfo", "agent").addEdge("agent", "tools").addEdge("tools", F).addEdge("earlyExit", F), Xs = 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.
3232
3232
  _Example: “Color points by sales amount”_
3233
3233
  _Example: “Show population density with a color gradient”_
3234
3234
  _Example: “Create a relationship map between height and depth”_
3235
3235
  _Example: “Vary circle sizes according to population”_`, Ce = {
3236
3236
  id: "layerStyling",
3237
3237
  name: "Layer Styling Agent",
3238
- description: en,
3239
- createGraph: Xs,
3240
- workspace: Xe
3241
- }, et = f.Root({
3238
+ description: Xs,
3239
+ createGraph: Ys,
3240
+ workspace: Ye
3241
+ }, Xe = f.Root({
3242
3242
  // messages: comes from global chat history.
3243
3243
  // It is safe to append new messages locally, but existing message objects
3244
3244
  // must be treated as read-only and never mutated.
@@ -3269,7 +3269,7 @@ ${r}`;
3269
3269
  },
3270
3270
  default: () => ""
3271
3271
  })
3272
- }), tn = (e, t) => {
3272
+ }), en = (e, t) => {
3273
3273
  const r = Array.from(e.values()).find(
3274
3274
  ({ layerItem: s }) => s.title?.toLowerCase().includes(t.toLowerCase())
3275
3275
  );
@@ -3282,16 +3282,16 @@ ${r}`;
3282
3282
  return `**${r.layerItem.title}** has ${a.length} field(s):
3283
3283
 
3284
3284
  ${o}`;
3285
- }, rn = async ({ layerTitle: e }, t) => {
3285
+ }, tn = async ({ layerTitle: e }, t) => {
3286
3286
  const r = S(t, "layersAndFieldsRegistry");
3287
- return tn(r, e);
3288
- }, an = b(rn, {
3287
+ return en(r, e);
3288
+ }, rn = b(tn, {
3289
3289
  name: "listLayerFields",
3290
3290
  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.",
3291
3291
  schema: n.object({
3292
3292
  layerTitle: n.string().describe("The title or partial title of the layer to list fields for.")
3293
3293
  })
3294
- }), tt = [an], on = (e) => {
3294
+ }), et = [rn], an = (e) => {
3295
3295
  if (!e || e.size === 0)
3296
3296
  return "No layers available in this map.";
3297
3297
  const t = Array.from(e.values()).map(({ layerItem: r, fieldRegistry: a }, o) => {
@@ -3304,30 +3304,30 @@ ${o}`;
3304
3304
  return `This map contains ${e.size} layer(s):
3305
3305
 
3306
3306
  ${t}`;
3307
- }, sn = (e) => {
3307
+ }, on = (e) => {
3308
3308
  const t = e?.list() ?? [];
3309
3309
  return t.length ? t.map((r) => `- ${r.agent.name}: ${r.agent.description}`).join(`
3310
3310
  `) : "No agents currently available.";
3311
3311
  };
3312
- async function nn(e, t) {
3312
+ async function sn(e, t) {
3313
3313
  const r = await R("help_prompt"), a = S(t, "layersAndFieldsRegistry"), o = S(t, "agentRegistry"), s = await k({
3314
3314
  promptText: r,
3315
3315
  messages: x(e.messages),
3316
- tools: tt,
3316
+ tools: et,
3317
3317
  inputVariables: {
3318
- layerSummary: on(a),
3319
- agents: sn(o)
3318
+ layerSummary: an(a),
3319
+ agents: on(o)
3320
3320
  }
3321
3321
  }), i = s.content.toString(), l = [...e.messages, s];
3322
3322
  return { ...e, messages: l, outputMessage: i };
3323
3323
  }
3324
- const ln = (e, t) => D(["agentRegistry"], "Help Agent")(e, t);
3325
- async function cn(e, t) {
3326
- const a = await new z(tt).invoke({ messages: e.messages }, t), o = [...e.messages, ...a.messages], s = a.messages.map((i) => i.text).join(`
3324
+ const nn = (e, t) => D(["agentRegistry"], "Help Agent")(e, t);
3325
+ async function ln(e, t) {
3326
+ const a = await new z(et).invoke({ messages: e.messages }, t), o = [...e.messages, ...a.messages], s = a.messages.map((i) => i.text).join(`
3327
3327
  `);
3328
3328
  return { ...e, messages: o, outputMessage: s };
3329
3329
  }
3330
- const dn = () => new M(et).addNode("requireHelpServices", ln).addNode("agent", nn).addNode("tools", cn).addEdge(P, "requireHelpServices").addEdge("requireHelpServices", "agent").addConditionalEdges("agent", (t) => (t.messages[t.messages.length - 1]?.tool_calls?.length ?? 0) > 0 ? "tools" : F).addEdge("tools", F), un = String.raw`- **help** — Enables users to ask questions about the map, layers, fields, and it's capabilities.
3330
+ const cn = () => new M(Xe).addNode("requireHelpServices", nn).addNode("agent", sn).addNode("tools", ln).addEdge(P, "requireHelpServices").addEdge("requireHelpServices", "agent").addConditionalEdges("agent", (t) => (t.messages[t.messages.length - 1]?.tool_calls?.length ?? 0) > 0 ? "tools" : F).addEdge("tools", F), dn = String.raw`- **help** — Enables users to ask questions about the map, layers, fields, and it's capabilities.
3331
3331
 
3332
3332
  _Example: “Tell me about this map”_
3333
3333
  _Example: “List all layers in this map”_
@@ -3340,13 +3340,13 @@ const dn = () => new M(et).addNode("requireHelpServices", ln).addNode("agent", n
3340
3340
 
3341
3341
  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.
3342
3342
  _Example: "Create a chart"_
3343
- _Example: "Create a table"_`, Mi = {
3343
+ _Example: "Create a table"_`, ji = {
3344
3344
  id: "help",
3345
3345
  name: "Help Agent",
3346
- description: un,
3347
- createGraph: dn,
3348
- workspace: et
3349
- }, rt = f.Root({
3346
+ description: dn,
3347
+ createGraph: cn,
3348
+ workspace: Xe
3349
+ }, tt = f.Root({
3350
3350
  // messages: comes from global chat history.
3351
3351
  // It is safe to append new messages locally, but existing message objects
3352
3352
  // must be treated as read-only and never mutated.
@@ -3382,12 +3382,12 @@ ${r}`;
3382
3382
  })
3383
3383
  }), Z = {
3384
3384
  conversationId: ""
3385
- }, hn = ["linkChartView"], mn = ["knowledgeGraph"];
3385
+ }, un = ["linkChartView"], hn = ["knowledgeGraph"];
3386
3386
  function oe(e) {
3387
3387
  const r = e?.configurable?.context;
3388
3388
  if (!r || typeof r != "object")
3389
3389
  throw new Error("ArcgisKnowledgeAgent context missing");
3390
- const a = hn.filter((o) => !(o in r));
3390
+ const a = un.filter((o) => !(o in r));
3391
3391
  if (a.length)
3392
3392
  throw new Error(`Link Chart context missing: ${a.join(", ")}`);
3393
3393
  return r;
@@ -3396,12 +3396,12 @@ function fe(e) {
3396
3396
  const r = e?.configurable?.context;
3397
3397
  if (!r || typeof r != "object")
3398
3398
  throw new Error("ArcgisKnowledgeAgent context missing");
3399
- const a = mn.filter((o) => !(o in r));
3399
+ const a = hn.filter((o) => !(o in r));
3400
3400
  if (a.length)
3401
3401
  throw new Error(`Knowledge Graph context missing: ${a.join(", ")}`);
3402
3402
  return r;
3403
3403
  }
3404
- class pn {
3404
+ class mn {
3405
3405
  constructor(t) {
3406
3406
  this.dataModel = t, this.kind = "GraphQueryGenerationRequest", this.explainQuery = !0, this.schemaInformation = we.fromDataModel(t);
3407
3407
  }
@@ -3420,10 +3420,10 @@ class we {
3420
3420
  for (const a of t.entityTypes)
3421
3421
  r.entityTypes.push(B.fromEntityType(a));
3422
3422
  for (const a of t.relationshipTypes)
3423
- r.relationshipTypes.push(yn.fromRelationshipType(a));
3423
+ r.relationshipTypes.push(pn.fromRelationshipType(a));
3424
3424
  return r.identifierInfo = {
3425
3425
  mappingInfo: {
3426
- identifierMapsTo: gn(
3426
+ identifierMapsTo: yn(
3427
3427
  t.identifierInfo.identifierMappingInfo.identifierInfoType
3428
3428
  ),
3429
3429
  identifierPropertyName: t.identifierInfo.identifierMappingInfo.uniformPropertyIdentifier.identifierPropertyName
@@ -3437,13 +3437,13 @@ class B {
3437
3437
  }
3438
3438
  static fromEntityType(t) {
3439
3439
  const r = new B();
3440
- r.name = t.name, r.alias = t.alias ? t.alias : void 0, r.role = fn(t.role);
3440
+ r.name = t.name, r.alias = t.alias ? t.alias : void 0, r.role = gn(t.role);
3441
3441
  for (const a of t.properties) {
3442
3442
  const o = {
3443
3443
  name: a.name,
3444
3444
  alias: a.alias ? a.alias : void 0,
3445
3445
  fieldType: a.fieldType,
3446
- role: wn(a.role),
3446
+ role: fn(a.role),
3447
3447
  geometryDef: a.fieldType === "esriFieldTypeGeometry" ? {
3448
3448
  geometryType: a.geometryType ?? "esriGeometryAny",
3449
3449
  hasM: a.hasM ? a.hasM : void 0,
@@ -3455,7 +3455,7 @@ class B {
3455
3455
  return r;
3456
3456
  }
3457
3457
  }
3458
- class yn extends B {
3458
+ class pn extends B {
3459
3459
  constructor() {
3460
3460
  super(...arguments), this.observedEndPoints = [];
3461
3461
  }
@@ -3470,7 +3470,7 @@ class yn extends B {
3470
3470
  return r;
3471
3471
  }
3472
3472
  }
3473
- const gn = (e) => {
3473
+ const yn = (e) => {
3474
3474
  switch (e) {
3475
3475
  case "esriIdentifierInfoTypeUNSPECIFIED":
3476
3476
  return "UNSPECIFIED";
@@ -3481,7 +3481,7 @@ const gn = (e) => {
3481
3481
  default:
3482
3482
  return e;
3483
3483
  }
3484
- }, fn = (e) => {
3484
+ }, gn = (e) => {
3485
3485
  switch (e) {
3486
3486
  case "Regular":
3487
3487
  return "esriGraphNamedObjectRegular";
@@ -3493,7 +3493,7 @@ const gn = (e) => {
3493
3493
  return e;
3494
3494
  }
3495
3495
  };
3496
- function wn(e) {
3496
+ function fn(e) {
3497
3497
  switch (e) {
3498
3498
  case "esriGraphPropertyRegular":
3499
3499
  return "Regular";
@@ -3531,7 +3531,7 @@ function wn(e) {
3531
3531
  return "Regular";
3532
3532
  }
3533
3533
  }
3534
- async function bn(e, t, r, a) {
3534
+ async function wn(e, t, r, a) {
3535
3535
  const { graphQuery: o, explanation: s } = await be(e, t, r, a);
3536
3536
  return `Generated Graph Query:
3537
3537
  ${o}
@@ -3541,7 +3541,7 @@ Explanation: ${s}`;
3541
3541
  async function be(e, t, r, a) {
3542
3542
  const o = {
3543
3543
  message: e,
3544
- context: new pn(t)
3544
+ context: new mn(t)
3545
3545
  };
3546
3546
  Z.conversationId && (o.conversationId = Z.conversationId), await m({ text: "Attempting to generate a cypher query from your prompt..." }, a);
3547
3547
  const s = await xe(`${r}/chat`, {
@@ -3593,29 +3593,29 @@ async function be(e, t, r, a) {
3593
3593
  }
3594
3594
  function J(e, t) {
3595
3595
  if (!(!e || typeof e != "object")) {
3596
- if (vn(e))
3596
+ if (Sn(e))
3597
3597
  for (const r of e.path)
3598
3598
  J(r, t);
3599
- else if (Sn(e))
3599
+ else if (bn(e))
3600
3600
  t.set(`${e.typeName}__${e.id}`, { id: e.id, typeName: e.typeName });
3601
3601
  else if (Array.isArray(e))
3602
3602
  for (const r of e)
3603
3603
  J(r, t);
3604
- else if (Tn(e))
3604
+ else if (vn(e))
3605
3605
  for (const r of Object.values(e.properties ?? {}))
3606
3606
  J(r, t);
3607
3607
  }
3608
3608
  }
3609
- function Sn(e) {
3609
+ function bn(e) {
3610
3610
  return !e || typeof e != "object" || Array.isArray(e) ? !1 : "id" in e && "typeName" in e;
3611
3611
  }
3612
- function vn(e) {
3612
+ function Sn(e) {
3613
3613
  return !e || typeof e != "object" || Array.isArray(e) ? !1 : e && "path" in e && Array.isArray(e.path);
3614
3614
  }
3615
- function Tn(e) {
3615
+ function vn(e) {
3616
3616
  return !e || typeof e != "object" || Array.isArray(e) || "id" in e ? !1 : "properties" in e && typeof e.properties == "object";
3617
3617
  }
3618
- function xn(e, t) {
3618
+ function Tn(e, t) {
3619
3619
  const r = [];
3620
3620
  for (const a of [...t.dataModel.entityTypes, ...t.dataModel.relationshipTypes]) {
3621
3621
  const o = e.getMemberIdsByType(a.name);
@@ -3624,7 +3624,7 @@ function xn(e, t) {
3624
3624
  }
3625
3625
  return r;
3626
3626
  }
3627
- const En = async (e) => {
3627
+ const xn = async (e) => {
3628
3628
  const t = /* @__PURE__ */ new Map(), r = e.resultRowsStream.getReader();
3629
3629
  for (; ; ) {
3630
3630
  const { done: a, value: o } = await r.read();
@@ -3636,7 +3636,7 @@ const En = async (e) => {
3636
3636
  }
3637
3637
  return Array.from(t.values());
3638
3638
  };
3639
- async function $n(e, t, r, a, o) {
3639
+ async function En(e, t, r, a, o) {
3640
3640
  const { graphQuery: s, explanation: i } = await be(
3641
3641
  e,
3642
3642
  t.dataModel,
@@ -3647,16 +3647,16 @@ async function $n(e, t, r, a, o) {
3647
3647
  { text: `Attempting to execute query: ${s.substring(0, 500)}${s.length > 500 ? "..." : ""}` },
3648
3648
  o
3649
3649
  );
3650
- const l = await Nt(
3650
+ const l = await At(
3651
3651
  t,
3652
- new Pe({
3652
+ new Me({
3653
3653
  openCypherQuery: s
3654
3654
  }),
3655
3655
  {
3656
3656
  signal: o?.signal,
3657
3657
  timeout: o?.timeout
3658
3658
  }
3659
- ), c = await En(l);
3659
+ ), c = await xn(l);
3660
3660
  return await m(
3661
3661
  {
3662
3662
  text: `Query Results parsed into ${c.length} unique relationships and entities. Atempting to add to link chart...`
@@ -3667,11 +3667,11 @@ ${s}
3667
3667
 
3668
3668
  Explanation: ${i}`;
3669
3669
  }
3670
- async function at({ prompt: e }, t) {
3671
- const { knowledgeGraph: r } = fe(t), { linkChartView: a } = oe(t), s = O.getDefault().helperServices, i = await R("arcgis_knowledge_current_lc_context"), l = xn(a.map, r), c = `${e}
3670
+ async function rt({ prompt: e }, t) {
3671
+ const { knowledgeGraph: r } = fe(t), { linkChartView: a } = oe(t), s = O.getDefault().helperServices, i = await R("arcgis_knowledge_current_lc_context"), l = Tn(a.map, r), c = `${e}
3672
3672
 
3673
3673
  ${i}${JSON.stringify(l)}`;
3674
- return await $n(
3674
+ return await En(
3675
3675
  c,
3676
3676
  r,
3677
3677
  `${s.aiAssistantServices.url}${s.aiAssistantServices.graphQueryAssistant}`,
@@ -3679,21 +3679,21 @@ ${i}${JSON.stringify(l)}`;
3679
3679
  t
3680
3680
  );
3681
3681
  }
3682
- const Fn = n.object({
3682
+ const $n = n.object({
3683
3683
  prompt: n.string().describe("The user's inquiry into the knowledge graph that needs to be run.")
3684
- }), ot = b(at, {
3684
+ }), at = b(rt, {
3685
3685
  name: "addRecords",
3686
3686
  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.",
3687
- schema: Fn
3687
+ schema: $n
3688
3688
  });
3689
- async function Rn(e, t) {
3689
+ async function Fn(e, t) {
3690
3690
  return await t.map.applyLayout(e), `Successfully applied layout: ${e}.`;
3691
3691
  }
3692
- async function Ln({ layout: e }, t) {
3692
+ async function Rn({ layout: e }, t) {
3693
3693
  const { linkChartView: r } = oe(t);
3694
- return await Rn(e, r);
3694
+ return await Fn(e, r);
3695
3695
  }
3696
- const In = n.object({
3696
+ const Ln = n.object({
3697
3697
  layout: n.enum([
3698
3698
  "organic-standard",
3699
3699
  "organic-community",
@@ -3707,26 +3707,26 @@ const In = n.object({
3707
3707
  ]).describe(
3708
3708
  "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"
3709
3709
  )
3710
- }), qn = b(Ln, {
3710
+ }), In = b(Rn, {
3711
3711
  name: "applyLayout",
3712
3712
  description: "Apply a diagram layout to the link chart",
3713
- schema: In
3713
+ schema: Ln
3714
3714
  });
3715
- function Cn(e, t) {
3715
+ function qn(e, t) {
3716
3716
  return t.map.changeNonspatialDataDisplay(e), `Successfully applied nonspatial visibility setting: ${e}.`;
3717
3717
  }
3718
- function An({ setting: e }, t) {
3718
+ function Cn({ setting: e }, t) {
3719
3719
  const { linkChartView: r } = oe(t);
3720
- return Cn(e, r);
3720
+ return qn(e, r);
3721
3721
  }
3722
- const Nn = n.object({
3722
+ const An = n.object({
3723
3723
  setting: n.enum(["hidden", "visible"]).describe("The setting of nonspatial visibility")
3724
- }), kn = b(An, {
3724
+ }), Nn = b(Cn, {
3725
3725
  name: "changeNonspatialVisibility",
3726
3726
  description: "Change whether or not nonspatial data is visible in the link chart. The value must be either 'hidden' or 'visible'.",
3727
- schema: Nn
3727
+ schema: An
3728
3728
  });
3729
- async function zn(e, t, r, a, o) {
3729
+ async function kn(e, t, r, a, o) {
3730
3730
  const { graphQuery: s, explanation: i } = await be(
3731
3731
  e,
3732
3732
  t.dataModel,
@@ -3734,9 +3734,9 @@ async function zn(e, t, r, a, o) {
3734
3734
  o
3735
3735
  );
3736
3736
  await m({ text: `Attempting to create link chart from derived query: ${s}` }, o);
3737
- const l = await kt.fromCypherQuery(
3737
+ const l = await Nt.fromCypherQuery(
3738
3738
  t,
3739
- new Pe({
3739
+ new Me({
3740
3740
  openCypherQuery: s
3741
3741
  })
3742
3742
  );
@@ -3745,9 +3745,9 @@ ${s}
3745
3745
 
3746
3746
  Explanation: ${i}`;
3747
3747
  }
3748
- async function st({ prompt: e }, t) {
3748
+ async function ot({ prompt: e }, t) {
3749
3749
  const { knowledgeGraph: r } = fe(t), { linkChartView: a } = oe(t), s = O.getDefault().helperServices;
3750
- return await zn(
3750
+ return await kn(
3751
3751
  e,
3752
3752
  r,
3753
3753
  `${s.aiAssistantServices.url}${s.aiAssistantServices.graphQueryAssistant}`,
@@ -3755,38 +3755,38 @@ async function st({ prompt: e }, t) {
3755
3755
  t
3756
3756
  );
3757
3757
  }
3758
- const _n = n.object({
3758
+ const zn = n.object({
3759
3759
  prompt: n.string().describe(
3760
3760
  "The user's inquiry into the knowledge graph that needs to be transformed into a link chart visualization."
3761
3761
  )
3762
- }), nt = b(st, {
3762
+ }), st = b(ot, {
3763
3763
  name: "createLinkChart",
3764
3764
  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.",
3765
- schema: _n
3765
+ schema: zn
3766
3766
  });
3767
- async function it({ prompt: e }, t) {
3767
+ async function nt({ prompt: e }, t) {
3768
3768
  const { knowledgeGraph: r } = fe(t), o = O.getDefault().helperServices;
3769
- return await bn(
3769
+ return await wn(
3770
3770
  e,
3771
3771
  r.dataModel,
3772
3772
  `${o.aiAssistantServices.url}${o.aiAssistantServices.graphQueryAssistant}`,
3773
3773
  t
3774
3774
  );
3775
3775
  }
3776
- const jn = n.object({
3776
+ const _n = n.object({
3777
3777
  prompt: n.string().describe("The user's inquiry into the knowledge graph that needs to be translated into a cypher query.")
3778
- }), Se = b(it, {
3778
+ }), Se = b(nt, {
3779
3779
  name: "generateCypher",
3780
3780
  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.",
3781
- schema: jn
3781
+ schema: _n
3782
3782
  }), ve = [
3783
- qn,
3784
- kn,
3783
+ In,
3784
+ Nn,
3785
3785
  Se,
3786
- nt,
3787
- ot
3788
- ], Mn = [Se, nt, ot];
3789
- async function Pn(e, t) {
3786
+ st,
3787
+ at
3788
+ ], jn = [Se, st, at];
3789
+ async function Mn(e, t) {
3790
3790
  const r = await R("arcgis_knowledge_tool_prompt"), a = {
3791
3791
  intent: e.intent
3792
3792
  }, o = await k({
@@ -3797,7 +3797,7 @@ async function Pn(e, t) {
3797
3797
  }), s = [...e.messages, o], l = (o.tool_calls?.length ?? 0) > 0 ? [...s] : [...s, o];
3798
3798
  return { ...e, messages: l };
3799
3799
  }
3800
- async function Dn(e, t) {
3800
+ async function Pn(e, t) {
3801
3801
  const a = await new z(ve).invoke(
3802
3802
  {
3803
3803
  messages: x(e.messages)
@@ -3810,7 +3810,7 @@ async function Dn(e, t) {
3810
3810
  `);
3811
3811
  return { ...e, messages: s, outputMessage: i };
3812
3812
  }
3813
- async function Gn(e) {
3813
+ async function Dn(e) {
3814
3814
  const t = await R("arcgis_knowledge_intent_prompt"), a = {
3815
3815
  tools: ve.map((l) => ({
3816
3816
  name: l.name,
@@ -3828,35 +3828,35 @@ async function Gn(e) {
3828
3828
  }), i = typeof s.intent == "string" ? s.intent.trim().replace(/^"|"$/gu, "") : "";
3829
3829
  return { ...e, intent: i || "" };
3830
3830
  }
3831
- const On = (e, t) => (
3831
+ const Gn = (e, t) => (
3832
3832
  //agent services (ex: embeddingsWorker) would go in the array below, if required.
3833
3833
  D([], "ArcgisKnowledge Agent")(e, t)
3834
3834
  );
3835
- async function Qn(e, t) {
3835
+ async function On(e, t) {
3836
3836
  const r = e.messages[e.messages.length - 1].content;
3837
3837
  let a;
3838
3838
  if (typeof r != "string")
3839
3839
  throw new Error("The original message content must be a string to process server skills.");
3840
3840
  if (e.intent === Se.name)
3841
- a = await it({ prompt: r }, t);
3841
+ a = await nt({ prompt: r }, t);
3842
3842
  else if (e.intent === "createLinkChart")
3843
- a = await st({ prompt: r }, t);
3843
+ a = await ot({ prompt: r }, t);
3844
3844
  else if (e.intent === "addRecords")
3845
- a = await at({ prompt: r }, t);
3845
+ a = await rt({ prompt: r }, t);
3846
3846
  else
3847
3847
  throw new Error(`No server skills were successfully invoked matching the name: ${e.intent}`);
3848
3848
  return { ...e, messages: [...e.messages], outputMessage: a };
3849
3849
  }
3850
- const Vn = () => new M(rt).addNode("requireArcgisKnowledgeServices", On).addNode("intentLLM", Gn).addNode("agent", Pn).addNode("serverSkill", Qn).addNode("tools", Dn).addEdge(P, "requireArcgisKnowledgeServices").addEdge("requireArcgisKnowledgeServices", "intentLLM").addConditionalEdges(
3850
+ const Qn = () => new M(tt).addNode("requireArcgisKnowledgeServices", Gn).addNode("intentLLM", Dn).addNode("agent", Mn).addNode("serverSkill", On).addNode("tools", Pn).addEdge(P, "requireArcgisKnowledgeServices").addEdge("requireArcgisKnowledgeServices", "intentLLM").addConditionalEdges(
3851
3851
  "intentLLM",
3852
3852
  (t) => (
3853
3853
  // ts/lint are getting confused here about the type, and the cast resolves it. Without it, there is a ts error
3854
- Mn.map((r) => r.name).includes(t.intent) ? "serverSkill" : "agent"
3854
+ jn.map((r) => r.name).includes(t.intent) ? "serverSkill" : "agent"
3855
3855
  )
3856
3856
  ).addConditionalEdges("agent", (t) => {
3857
3857
  const r = t.messages[t.messages.length - 1];
3858
3858
  return r?.getType() === "ai" && "tool_calls" in r && Array.isArray(r.tool_calls) && r.tool_calls.length > 0 ? "tools" : F;
3859
- }).addEdge("tools", F), Wn = 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).
3859
+ }).addEdge("tools", F), Vn = 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).
3860
3860
  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.
3861
3861
  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,
3862
3862
  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
@@ -3888,19 +3888,19 @@ _example: "Find all the products supplied by Supplier X and add them to my visua
3888
3888
  _example: "Expand the link chart from 'Entity D' to show its direct connections"_
3889
3889
  _example: "Find all the cars and then add everything up to two hops away from them on the link chart"_
3890
3890
  _example: "Connect Emma and Rob on the link chart if there is a relationship between them"
3891
- _example: "Discover and add all the relationships originating at 'Entity E' to the link chart"_`, Pi = {
3891
+ _example: "Discover and add all the relationships originating at 'Entity E' to the link chart"_`, Mi = {
3892
3892
  id: "arcgisKnowledge",
3893
3893
  name: "ArcgisKnowledge Agent",
3894
- description: Wn,
3895
- createGraph: Vn,
3896
- workspace: rt
3894
+ description: Vn,
3895
+ createGraph: Qn,
3896
+ workspace: tt
3897
3897
  };
3898
3898
  export {
3899
- Pi as ArcgisKnowledgeAgent,
3900
- zi as DataExplorationAgent,
3901
- Mi as HelpAgent,
3902
- _i as LayerFilterAgent,
3903
- ji as LayerQueryAgent,
3899
+ Mi as ArcgisKnowledgeAgent,
3900
+ ki as DataExplorationAgent,
3901
+ ji as HelpAgent,
3902
+ zi as LayerFilterAgent,
3903
+ _i as LayerQueryAgent,
3904
3904
  Ce as LayerStylingAgent,
3905
- ki as NavigationAgent
3905
+ Ni as NavigationAgent
3906
3906
  };