@arcgis/ai-components 5.2.0-next.98 → 5.2.0-next.99

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 (44) hide show
  1. package/dist/agents/tools/filter/setFeatureEffect/adapter.js +52 -40
  2. package/dist/agents/tools/navigation/goToAddress/adapter.js +39 -31
  3. package/dist/agents/tools/query/getStatistics/adapter.js +59 -56
  4. package/dist/agents/tools/query/getTopFeatures/adapter.js +51 -48
  5. package/dist/agents/tools/query/queryFeatures/adapter.js +46 -43
  6. package/dist/cdn/22KHSDJI.js +2 -0
  7. package/dist/cdn/5K5ZY267.js +2 -0
  8. package/dist/cdn/{NSHLOFIY.js → 5XZLS7UO.js} +1 -1
  9. package/dist/cdn/655YIKL3.js +11 -0
  10. package/dist/cdn/AKD5UOVX.js +2 -0
  11. package/dist/cdn/{NEZXHUAL.js → BE7BRJZD.js} +1 -1
  12. package/dist/cdn/C4JT4S5E.js +2 -0
  13. package/dist/cdn/{UHZG7SKO.js → FJO4KNOZ.js} +1 -1
  14. package/dist/cdn/{MX7OEO5Z.js → FXP5UIQU.js} +1 -1
  15. package/dist/cdn/{CZM4URK7.js → G3SF6U2U.js} +1 -1
  16. package/dist/cdn/{HNADFHYH.js → ICQCK5D3.js} +1 -1
  17. package/dist/cdn/{ASR3I43T.js → IJVMUS2L.js} +1 -1
  18. package/dist/cdn/{UAANWCMU.js → LAYVGCPL.js} +1 -1
  19. package/dist/cdn/NNXISHCA.js +14 -0
  20. package/dist/cdn/{LNCT4S4I.js → OX64WOEL.js} +1 -1
  21. package/dist/cdn/{7ZFAFKJT.js → QUKNPVAF.js} +1 -1
  22. package/dist/cdn/{YWN57GH4.js → RVSTAUQS.js} +1 -1
  23. package/dist/cdn/{EKWM5K4K.js → TCH5I5LS.js} +1 -1
  24. package/dist/cdn/{B2T7D57Y.js → TEPP7YPR.js} +1 -1
  25. package/dist/cdn/{6KN5LUAV.js → TMVF2W5N.js} +15 -15
  26. package/dist/cdn/{IC3LG6TH.js → UHNVDALX.js} +1 -1
  27. package/dist/cdn/{4WIDLQUH.js → XX6GHMNR.js} +1 -1
  28. package/dist/cdn/{AA4FBYKK.js → Z5HWPSZN.js} +1 -1
  29. package/dist/cdn/{GFEOVHJK.js → ZRVZMPFN.js} +1 -1
  30. package/dist/cdn/agent-utils/index.js +1 -1
  31. package/dist/cdn/index.js +1 -1
  32. package/dist/chunks/navigationGraph.js +84 -81
  33. package/dist/chunks/resolvePointGeometryFilter.js +92 -0
  34. package/dist/docs/api.json +1 -1
  35. package/dist/docs/docs.json +1 -1
  36. package/dist/docs/web-types.json +1 -1
  37. package/package.json +5 -5
  38. package/dist/cdn/6HF36IKA.js +0 -2
  39. package/dist/cdn/JKIESH74.js +0 -2
  40. package/dist/cdn/OAKRPM7D.js +0 -2
  41. package/dist/cdn/QNNGPA3Q.js +0 -2
  42. package/dist/cdn/U2D53TAX.js +0 -14
  43. package/dist/cdn/V52XWEGV.js +0 -11
  44. package/dist/chunks/types.js +0 -59
@@ -3,75 +3,85 @@ import e from "zod";
3
3
  import { tool as h } from "@langchain/core/tools";
4
4
  import m from "@arcgis/core/layers/support/FeatureEffect.js";
5
5
  import b from "@arcgis/core/layers/support/FeatureFilter.js";
6
- import { g as y, d } from "../../../../chunks/types.js";
7
- import { f as w } from "../../../../chunks/fetchAgentContext.js";
8
- const g = async (t, o, u, n, r, c) => {
9
- const a = t.map?.allLayers.find((i) => i.id === o);
10
- if (!a)
11
- return { success: !1, error: `Layer '${o}' not found.` };
12
- const s = a.createQuery();
13
- s.where = u ?? "1=1", n && (s.geometry = n, s.spatialRelationship = "intersects", r && (s.distance = r), c && (s.units = c));
6
+ import { g as y, d, s as w, r as I } from "../../../../chunks/resolvePointGeometryFilter.js";
7
+ import { f as g } from "../../../../chunks/fetchAgentContext.js";
8
+ const v = async (t, i, u, n, r, c) => {
9
+ const s = t.map?.allLayers.find((o) => o.id === i);
10
+ if (!s)
11
+ return { success: !1, error: `Layer '${i}' not found.` };
12
+ const a = s.createQuery();
13
+ a.where = u ?? "1=1", n && (a.geometry = n, a.spatialRelationship = "intersects", r && (a.distance = r), c && (a.units = c));
14
14
  try {
15
- const { extent: i, count: l } = await a.queryExtent(s);
16
- return !i || l === 0 ? {
15
+ const { extent: o, count: l } = await s.queryExtent(a);
16
+ return !o || l === 0 ? {
17
17
  success: !1,
18
- error: `No features found for filter (where: ${s.where}${n ? ", spatial filter used" : ""})`
19
- } : (await t.goTo(i), { success: !0 });
20
- } catch (i) {
18
+ error: `No features found for filter (where: ${a.where}${n ? ", spatial filter used" : ""})`
19
+ } : (await t.goTo(o), { success: !0 });
20
+ } catch (o) {
21
21
  return {
22
22
  success: !1,
23
- error: i instanceof Error ? i.message : String(i)
23
+ error: o instanceof Error ? o.message : String(o)
24
24
  };
25
25
  }
26
- }, I = async (t, o, u, n, r, c) => {
27
- const a = o.map?.allLayers.find(
26
+ }, x = async (t, i, u, n, r, c) => {
27
+ const s = i.map?.allLayers.find(
28
28
  (f) => f.id === t.layerId
29
29
  );
30
- if (!a)
30
+ if (!s)
31
31
  return `Could not find target layer with ID: ${t.layerId}`;
32
- let s;
32
+ let a;
33
33
  if (r) {
34
- const f = await y(r, o);
34
+ const f = await y(r, i);
35
35
  if ("error" in f)
36
36
  return f.error;
37
- s = f.geometry;
37
+ a = f.geometry;
38
38
  }
39
- if (a.featureEffect = null, a.featureEffect = new m({
39
+ if (s.featureEffect = null, s.featureEffect = new m({
40
40
  filter: new b({
41
41
  ...t.objectIds?.length ? { objectIds: t.objectIds } : { where: t.where },
42
- geometry: s,
42
+ geometry: a,
43
43
  spatialRelationship: "intersects",
44
44
  distance: r?.distance,
45
45
  units: r?.units
46
46
  }),
47
47
  includedEffect: u,
48
48
  excludedEffect: n
49
- }), a.visible = !0, c)
50
- return `Applied feature effects to "${a.title ?? t.layerId}" within current map extent.`;
51
- const i = t.objectIds?.length ? `${a.objectIdField} IN (${t.objectIds.join(",")})` : t.where, l = await g(
52
- o,
53
- t.layerId,
49
+ }), s.visible = !0, c)
50
+ return `Applied feature effects to "${s.title ?? t.layerId}" within current map extent.`;
51
+ const o = t.objectIds?.length ? `${s.objectIdField} IN (${t.objectIds.join(",")})` : t.where, l = await v(
54
52
  i,
55
- s,
53
+ t.layerId,
54
+ o,
55
+ a,
56
56
  r?.distance,
57
57
  r?.units
58
- ), p = a.title ?? t.layerId;
59
- return l.success ? `Applied feature effects to target layer "${a.title ?? t.layerId}"${r && "layerId" in r ? ` using geometry from layer "${r.layerId}"` : ""}.` : `Applied filter to "${p}" but no features matched. ${l.error}`;
60
- }, v = async ({
58
+ ), p = s.title ?? t.layerId;
59
+ return l.success ? `Applied feature effects to target layer "${s.title ?? t.layerId}"${r && "layerId" in r ? ` using geometry from layer "${r.layerId}"` : ""}.` : `Applied filter to "${p}" but no features matched. ${l.error}`;
60
+ }, j = async ({
61
61
  targetLayer: t,
62
- geometryFilter: o,
62
+ geometryFilter: i,
63
63
  useCurrentExtent: u,
64
64
  includedEffect: n = "drop-shadow(2px, 2px, 2px, gray)",
65
65
  excludedEffect: r = "grayscale(100%) opacity(60%) blur(2px)"
66
66
  }, c) => {
67
- const { mapView: a } = w(c, ["mapView"]);
68
- return await I(t, a, n, r, o, u);
69
- }, x = e.object({
67
+ const { mapView: s } = g(c, ["mapView"]), a = I(
68
+ i,
69
+ c.state?.agentExecutionContext?.sharedResources
70
+ );
71
+ return await x(
72
+ t,
73
+ s,
74
+ n,
75
+ r,
76
+ a,
77
+ u
78
+ );
79
+ }, E = e.object({
70
80
  layerId: e.string().describe("The layerId of the layer containing the geometry by which to filter."),
71
81
  where: e.string().describe("The SQL-92 where clause representing the features from which to filter."),
72
82
  distance: e.number().optional().describe("The buffer distance around the geometry."),
73
83
  units: d.optional().describe("The units for the distance buffer.")
74
- }), j = e.object({
84
+ }), S = e.object({
75
85
  point: e.object({
76
86
  x: e.number().describe("X coordinate (longitude) from navigation result"),
77
87
  y: e.number().describe("Y coordinate (latitude) from navigation result"),
@@ -81,7 +91,7 @@ const g = async (t, o, u, n, r, c) => {
81
91
  }).describe("Point coordinates from a previous navigation/geocoding result"),
82
92
  distance: e.number().optional().describe("Optional buffer distance around the point."),
83
93
  units: d.optional().describe("The units for the distance buffer.")
84
- }), E = e.object({
94
+ }), T = e.object({
85
95
  targetLayer: e.object({
86
96
  layerId: e.string().describe("The layerId of the layer on which to set a feature effect."),
87
97
  where: e.string().describe("The SQL-92 where clause representing the features to emphasize."),
@@ -89,7 +99,9 @@ const g = async (t, o, u, n, r, c) => {
89
99
  "Array of objectIds from a previous query result. Use this instead of a where clause when the query returned objectIds (e.g. top N results). If provided, takes precedence over where clause."
90
100
  )
91
101
  }),
92
- geometryFilter: e.union([x, j]).optional().describe("Optional geometry-based filtering parameters for spatial queries."),
102
+ geometryFilter: e.union([E, S, w]).optional().describe(
103
+ "Optional spatial filter. Use 'sharedResourceId' with an ID from listSharedResources for a previously geocoded location."
104
+ ),
93
105
  useCurrentExtent: e.boolean().optional().describe(
94
106
  "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."
95
107
  ),
@@ -99,10 +111,10 @@ const g = async (t, o, u, n, r, c) => {
99
111
  excludedEffect: e.string().default("grayscale(100%) opacity(60%) blur(2px)").describe(
100
112
  "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."
101
113
  )
102
- }), A = h(v, {
114
+ }), A = h(j, {
103
115
  name: "setFeatureEffect",
104
116
  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.",
105
- schema: E
117
+ schema: T
106
118
  });
107
119
  export {
108
120
  A as setFeatureEffectTool
@@ -1,51 +1,59 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import { tool as p } from "@langchain/core/tools";
3
- import r from "@arcgis/core/config.js";
4
- import f from "@arcgis/core/Graphic.js";
5
- import u from "@arcgis/core/portal/Portal.js";
6
- import { addressToLocations as S } from "@arcgis/core/rest/locator.js";
7
- import v from "@arcgis/core/symbols/PictureMarkerSymbol.js";
8
- import { f as w } from "../../../../chunks/fetchAgentContext.js";
9
- import c from "zod";
10
- async function y(e, t) {
11
- const a = u.getDefault().helperServices, n = a.geocode.find((h) => h.name === "ArcGIS World Geocoding Service") ?? a.geocode[0];
12
- if (!n)
2
+ import { tool as f } from "@langchain/core/tools";
3
+ import s from "@arcgis/core/config.js";
4
+ import u from "@arcgis/core/Graphic.js";
5
+ import S from "@arcgis/core/portal/Portal.js";
6
+ import { addressToLocations as v } from "@arcgis/core/rest/locator.js";
7
+ import w from "@arcgis/core/symbols/PictureMarkerSymbol.js";
8
+ import { f as y } from "../../../../chunks/fetchAgentContext.js";
9
+ import i from "zod";
10
+ async function A(e, t) {
11
+ const n = S.getDefault().helperServices, c = n.geocode.find((g) => g.name === "ArcGIS World Geocoding Service") ?? n.geocode[0];
12
+ if (!c)
13
13
  throw new Error("No geocoding service found in helperServices.");
14
- const i = n.url, d = `${r.assetsPath?.endsWith("/") ? r.assetsPath : `${r.assetsPath}/`}esri/images/search/search-symbol-32.png`, o = (await S(i, {
14
+ const d = c.url, l = `${s.assetsPath?.endsWith("/") ? s.assetsPath : `${s.assetsPath}/`}esri/images/search/search-symbol-32.png`, o = (await v(d, {
15
15
  address: { SingleLine: e },
16
16
  outFields: ["Match_addr"]
17
17
  }))?.[0];
18
18
  if (!o?.extent || !o.location)
19
19
  throw new Error(`Could not find location for: ${e}`);
20
- const l = new v({
21
- url: d,
20
+ const m = new w({
21
+ url: l,
22
22
  width: 24,
23
23
  height: 24
24
- }), m = new f({
24
+ }), h = new u({
25
25
  geometry: o.location,
26
- symbol: l
26
+ symbol: m
27
27
  });
28
- t.graphics.removeAll(), t.graphics.add(m), await t.goTo(o.extent);
29
- const g = {
30
- address: o.address ?? "",
31
- location: o.location ? o.location.toJSON() : null,
32
- extent: o.extent ? o.extent.toJSON() : null
33
- };
34
- return {
35
- text: `Successfully zoomed to ${e}.`,
36
- sharedStatePatch: { lastResolvedLocation: { value: g } }
28
+ t.graphics.removeAll(), t.graphics.add(h), await t.goTo(o.extent);
29
+ const r = {
30
+ address: o.address ?? e,
31
+ location: o.location.toJSON(),
32
+ extent: o.extent.toJSON()
33
+ }, p = {
34
+ value: r,
35
+ sharedStatePatch: { lastResolvedLocation: { value: r } },
36
+ sharedResourceAdditions: [
37
+ {
38
+ kind: "point",
39
+ description: r.address,
40
+ payload: r.location
41
+ }
42
+ ]
37
43
  };
44
+ return [`Successfully zoomed to ${r.address}.`, p];
38
45
  }
39
46
  async function T({ address: e }, t) {
40
- const { mapView: s } = w(t, ["mapView"]);
41
- return await y(e, s);
47
+ const { mapView: a } = y(t, ["mapView"]);
48
+ return await A(e, a);
42
49
  }
43
- const x = c.object({
44
- address: c.string().describe("The full address or place name to locate.")
45
- }), E = p(T, {
50
+ const b = i.object({
51
+ address: i.string().describe("The full address or place name to locate.")
52
+ }), E = f(T, {
46
53
  name: "goToAddress",
47
54
  description: "Geocodes an address using Esri's World Geocoding Service and zooms the map to that location.",
48
- schema: x
55
+ schema: b,
56
+ responseFormat: "content_and_artifact"
49
57
  });
50
58
  export {
51
59
  E as goToAddressTool
@@ -1,30 +1,30 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
2
  import { tool as L } from "@langchain/core/tools";
3
3
  import t from "zod";
4
- import V from "@arcgis/core/smartMapping/statistics/summaryStatistics.js";
5
- import E from "@arcgis/core/smartMapping/statistics/uniqueValues.js";
6
- import O from "@arcgis/core/layers/support/FeatureFilter.js";
7
- import { c as x, m as b } from "../../../../chunks/mergeWhereClauses.js";
8
- import { g as N, i as v, a as C, d as S } from "../../../../chunks/types.js";
9
- import { f as R } from "../../../../chunks/fetchAgentContext.js";
10
- import { f as U } from "../../../../chunks/fetchService.js";
11
- const W = async (h) => {
12
- const { targetLayer: r, fieldName: n, statisticType: l, mapView: a, layersAndFieldsRegistry: p, geometryFilter: e } = h, s = a.map?.allLayers.find((i) => i.id === r.layerId);
4
+ import E from "@arcgis/core/smartMapping/statistics/summaryStatistics.js";
5
+ import R from "@arcgis/core/smartMapping/statistics/uniqueValues.js";
6
+ import V from "@arcgis/core/layers/support/FeatureFilter.js";
7
+ import { c as x, m as v } from "../../../../chunks/mergeWhereClauses.js";
8
+ import { g as O, i as S, a as C, d as I, s as N, r as G } from "../../../../chunks/resolvePointGeometryFilter.js";
9
+ import { f as U } from "../../../../chunks/fetchAgentContext.js";
10
+ import { f as W } from "../../../../chunks/fetchService.js";
11
+ const j = async (h) => {
12
+ const { targetLayer: a, fieldName: n, statisticType: l, mapView: i, layersAndFieldsRegistry: p, geometryFilter: e } = h, s = i.map?.allLayers.find((r) => r.id === a.layerId);
13
13
  if (!s)
14
- throw new Error(`Layer '${r.layerId}' not found.`);
15
- const T = await a.whenLayerView(s), o = p.get(r.layerId)?.fieldRegistry.get(n), I = o?.alias;
14
+ throw new Error(`Layer '${a.layerId}' not found.`);
15
+ const w = await i.whenLayerView(s), o = p.get(a.layerId)?.fieldRegistry.get(n), F = o?.alias;
16
16
  if (!o)
17
17
  throw new Error(`Field '${n}' not found.`);
18
- let w, u;
18
+ let b, u;
19
19
  if (e) {
20
- const i = await N(e, a);
21
- if ("error" in i)
22
- throw new Error(i.error);
23
- if (!i.geometry)
24
- throw v(e) ? new Error(`No features found matching: ${e.where}`) : new Error("Failed to create geometry");
25
- if (v(e)) {
26
- const g = a.map?.allLayers.find((f) => f.id === e.layerId);
27
- w = {
20
+ const r = await O(e, i);
21
+ if ("error" in r)
22
+ throw new Error(r.error);
23
+ if (!r.geometry)
24
+ throw S(e) ? new Error(`No features found matching: ${e.where}`) : new Error("Failed to create geometry");
25
+ if (S(e)) {
26
+ const g = i.map?.allLayers.find((f) => f.id === e.layerId);
27
+ b = {
28
28
  geometryLayerName: g?.title ?? g?.id,
29
29
  geometryLayerId: e.layerId,
30
30
  geometryWhere: e.where,
@@ -32,87 +32,90 @@ const W = async (h) => {
32
32
  units: e.units,
33
33
  applied: !0
34
34
  };
35
- } else C(e) && (w = {
35
+ } else C(e) && (b = {
36
36
  point: e.point,
37
37
  distance: e.distance,
38
38
  units: e.units,
39
39
  applied: !0
40
40
  });
41
- u = new O({
42
- geometry: i.geometry,
41
+ u = new V({
42
+ geometry: r.geometry,
43
43
  distance: e.distance,
44
44
  units: e.units,
45
45
  spatialRelationship: "intersects"
46
46
  });
47
47
  }
48
- const y = x(T, [n], !1);
48
+ const y = x(w, [n], !1);
49
49
  let d = null, m = null;
50
- const F = 10;
50
+ const T = 10;
51
51
  if (o.type !== "geometry" && o.type !== "oid" && o.type !== "global-id")
52
52
  try {
53
- const i = {
53
+ const r = {
54
54
  layer: s,
55
55
  useFeaturesInView: y,
56
- view: y ? a : void 0,
56
+ view: y ? i : void 0,
57
57
  field: n,
58
- sqlWhere: b(s.definitionExpression, r.where),
58
+ sqlWhere: v(s.definitionExpression, a.where),
59
59
  ...u && { filter: u },
60
60
  outStatisticTypes: { include: [l] }
61
61
  };
62
- d = await V(i);
62
+ d = await E(r);
63
63
  const g = ["string", "small-integer", "integer"], f = o.domain?.type === "coded-value" ? o.domain : null;
64
- (g.includes(o.type) || f) && (m = (await E({
64
+ (g.includes(o.type) || f) && (m = (await R({
65
65
  layer: s,
66
66
  useFeaturesInView: y,
67
- view: y ? a : void 0,
67
+ view: y ? i : void 0,
68
68
  field: n,
69
- sqlWhere: b(s.definitionExpression, r.where),
69
+ sqlWhere: v(s.definitionExpression, a.where),
70
70
  ...u && { filter: u }
71
- })).uniqueValueInfos.sort((c, q) => q.count - c.count).slice(0, F)), m && o.domain?.type === "coded-value" && (m = m.map((c) => ({
71
+ })).uniqueValueInfos.sort((c, q) => q.count - c.count).slice(0, T)), m && o.domain?.type === "coded-value" && (m = m.map((c) => ({
72
72
  ...c,
73
73
  value: f ? f.getName(c.value) ?? c.value : c.value
74
74
  })));
75
- } catch (i) {
76
- console.error("Statistics error:", i);
75
+ } catch (r) {
76
+ console.error("Statistics error:", r);
77
77
  }
78
78
  return {
79
79
  tool: "getStatistics",
80
- layerName: s.title ?? r.layerId,
80
+ layerName: s.title ?? a.layerId,
81
81
  summary: `${l} = ${typeof d?.[l] == "number" ? d[l] : "N/A"}`,
82
82
  details: {
83
83
  fieldName: n,
84
- fieldAlias: I,
84
+ fieldAlias: F,
85
85
  statisticType: l,
86
86
  statistic: d?.[l] ?? null,
87
87
  summaryStatistics: d,
88
88
  uniqueValues: m,
89
- where: r.where,
90
- spatialFilterInfo: w
89
+ where: a.where,
90
+ spatialFilterInfo: b
91
91
  }
92
92
  };
93
93
  };
94
- async function j({
94
+ async function A({
95
95
  targetLayer: h,
96
- fieldName: r,
96
+ fieldName: a,
97
97
  statisticType: n,
98
98
  geometryFilter: l
99
- }, a) {
100
- const p = U(a, "layersAndFieldsRegistry"), { mapView: e } = R(a, ["mapView"]), s = await W({
99
+ }, i) {
100
+ const p = W(i, "layersAndFieldsRegistry"), { mapView: e } = U(i, ["mapView"]), s = G(
101
+ l,
102
+ i.state?.agentExecutionContext?.sharedResources
103
+ ), w = await j({
101
104
  targetLayer: h,
102
- fieldName: r,
105
+ fieldName: a,
103
106
  statisticType: n,
104
107
  mapView: e,
105
108
  layersAndFieldsRegistry: p,
106
- geometryFilter: l
109
+ geometryFilter: s
107
110
  });
108
- return JSON.stringify(s, null, 2);
111
+ return JSON.stringify(w, null, 2);
109
112
  }
110
- const A = t.object({
113
+ const D = t.object({
111
114
  layerId: t.string().describe("The layerId of the layer containing the geometry by which to filter."),
112
115
  where: t.string().describe("The SQL-92 where clause representing the features from which to filter."),
113
116
  distance: t.number().optional().describe("The buffer distance around the geometry."),
114
- units: S.optional().describe("The units for the distance buffer.")
115
- }), G = t.object({
117
+ units: I.optional().describe("The units for the distance buffer.")
118
+ }), P = t.object({
116
119
  point: t.object({
117
120
  x: t.number().describe("X coordinate (longitude) from navigation result"),
118
121
  y: t.number().describe("Y coordinate (latitude) from navigation result"),
@@ -121,18 +124,18 @@ const A = t.object({
121
124
  }).optional().describe("Spatial reference. Defaults to map's spatial reference if not provided.")
122
125
  }).describe("Point coordinates from a previous navigation/geocoding result"),
123
126
  distance: t.number().optional().describe("Optional buffer distance around the point."),
124
- units: S.optional().describe("The units for the distance buffer.")
125
- }), D = t.object({
127
+ units: I.optional().describe("The units for the distance buffer.")
128
+ }), $ = t.object({
126
129
  targetLayer: t.object({
127
130
  layerId: t.string().describe("The layerId of the layer containing the field from which to get a value."),
128
131
  where: t.string().describe("The SQL-92 where clause representing the feature from which to get an attribute value.")
129
132
  }),
130
- geometryFilter: t.union([A, G]).optional().describe(
131
- "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."
133
+ geometryFilter: t.union([D, P, N]).optional().describe(
134
+ "Geometry filter for spatial queries. Use 'sharedResourceId' with an ID from listSharedResources for a previously geocoded location. Use 'point' for inline coordinates or 'layerId/where' for features from another layer."
132
135
  ),
133
136
  fieldName: t.string().describe("The name of the field for which to get statistics. STRICTLY DO NOT use OBJECTID. Use any other field"),
134
137
  statisticType: t.enum(["avg", "max", "median", "min", "stddev", "sum", "variance", "nullcount", "count"]).describe("The statistic type to calculate.")
135
- }), M = L(j, {
138
+ }), _ = L(A, {
136
139
  name: "getStatistics",
137
140
  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.
138
141
 
@@ -147,8 +150,8 @@ DO NOT USE FOR:
147
150
  - Simple counts of features matching a condition — use queryFeatures instead
148
151
 
149
152
  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.`,
150
- schema: D
153
+ schema: $
151
154
  });
152
155
  export {
153
- M as getStatisticsTool
156
+ _ as getStatisticsTool
154
157
  };
@@ -1,103 +1,106 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import { tool as T } from "@langchain/core/tools";
2
+ import { tool as S } from "@langchain/core/tools";
3
3
  import e from "zod";
4
- import S from "@arcgis/core/rest/support/TopFeaturesQuery.js";
4
+ import T from "@arcgis/core/rest/support/TopFeaturesQuery.js";
5
5
  import B from "@arcgis/core/rest/support/TopFilter.js";
6
6
  import { m as C, c as v } from "../../../../chunks/mergeWhereClauses.js";
7
7
  import { a as I } from "../../../../chunks/formatFeatureAttributes.js";
8
- import { g as q, d as y } from "../../../../chunks/types.js";
8
+ import { g as q, d as y, s as x, r as G } from "../../../../chunks/resolvePointGeometryFilter.js";
9
9
  import { f as N } from "../../../../chunks/fetchAgentContext.js";
10
- const k = (i) => i.flatMap((t) => t.split(",")).map((t) => t.trim()).map((t) => t.split(/\s+/u)[0]?.replace(/^"|"$/gu, "")).filter((t) => !!t), x = async (i, t, a, s, l) => {
11
- const n = a.map?.allLayers.find((o) => o.id === i.layerId), d = await a.whenLayerView(n), c = n.title ?? i.layerId;
12
- let u;
13
- if (s) {
14
- const o = await q(s, a);
10
+ const k = (s) => s.flatMap((t) => t.split(",")).map((t) => t.trim()).map((t) => t.split(/\s+/u)[0]?.replace(/^"|"$/gu, "")).filter((t) => !!t), R = async (s, t, n, i, l) => {
11
+ const a = n.map?.allLayers.find((o) => o.id === s.layerId), c = await n.whenLayerView(a), u = a.title ?? s.layerId;
12
+ let d;
13
+ if (i) {
14
+ const o = await q(i, n);
15
15
  if ("error" in o)
16
16
  return {
17
17
  tool: "getTopFeatures",
18
- layerName: c,
18
+ layerName: u,
19
19
  summary: "Geometry lookup failed",
20
20
  details: { error: o.error }
21
21
  };
22
22
  if (!o.geometry)
23
23
  return {
24
24
  tool: "getTopFeatures",
25
- layerName: c,
25
+ layerName: u,
26
26
  summary: "No features found for geometry filter",
27
27
  details: {
28
- error: `No features found matching: ${"where" in s ? s.where : "unknown criteria"}`
28
+ error: `No features found matching: ${"where" in i ? i.where : "unknown criteria"}`
29
29
  }
30
30
  };
31
- u = o.geometry;
32
- } else l && (u = a.extent.clone());
33
- const h = t.groupByFields && t.groupByFields.length > 0, f = n.objectIdField, p = i.outFields.includes("*") ? ["*"] : [.../* @__PURE__ */ new Set([...i.outFields, f])];
31
+ d = o.geometry;
32
+ } else l && (d = n.extent.clone());
33
+ const p = t.groupByFields && t.groupByFields.length > 0, f = a.objectIdField, h = s.outFields.includes("*") ? ["*"] : [.../* @__PURE__ */ new Set([...s.outFields, f])];
34
34
  try {
35
35
  let o;
36
- if (h) {
37
- const r = new S({
38
- where: i.where || "1=1",
39
- outFields: p,
40
- orderByFields: i.orderByFields,
41
- geometry: u,
42
- spatialRelationship: u ? "intersects" : void 0,
43
- distance: s?.distance,
44
- units: s?.units,
36
+ if (p) {
37
+ const r = new T({
38
+ where: s.where || "1=1",
39
+ outFields: h,
40
+ orderByFields: s.orderByFields,
41
+ geometry: d,
42
+ spatialRelationship: d ? "intersects" : void 0,
43
+ distance: i?.distance,
44
+ units: i?.units,
45
45
  topFilter: new B({
46
46
  topCount: t.topCount,
47
47
  groupByFields: t.groupByFields,
48
48
  orderByFields: t.orderByFields
49
49
  })
50
50
  });
51
- o = await n.queryTopFeatures(r);
51
+ o = await a.queryTopFeatures(r);
52
52
  } else {
53
- const r = n.createQuery();
54
- r.where = C(n.definitionExpression, i.where || "1=1"), r.outFields = p.length ? p : ["*"], r.orderByFields = t.orderByFields, r.returnGeometry = !1, r.num = t.topCount, u && (r.geometry = u, r.spatialRelationship = "intersects"), s?.distance && (r.distance = s.distance), s?.units && (r.units = s.units), r.outSpatialReference = a.spatialReference;
53
+ const r = a.createQuery();
54
+ r.where = C(a.definitionExpression, s.where || "1=1"), r.outFields = h.length ? h : ["*"], r.orderByFields = t.orderByFields, r.returnGeometry = !1, r.num = t.topCount, d && (r.geometry = d, r.spatialRelationship = "intersects"), i?.distance && (r.distance = i.distance), i?.units && (r.units = i.units), r.outSpatialReference = n.spatialReference;
55
55
  const m = [
56
- .../* @__PURE__ */ new Set([...i.outFields, ...k(t.orderByFields)])
57
- ], w = v(d, m, l ?? !1);
56
+ .../* @__PURE__ */ new Set([...s.outFields, ...k(t.orderByFields)])
57
+ ], w = v(c, m, l ?? !1);
58
58
  try {
59
- o = w ? await d.queryFeatures(r) : await n.queryFeatures(r);
59
+ o = w ? await c.queryFeatures(r) : await a.queryFeatures(r);
60
60
  } catch (F) {
61
- console.warn("Client-side query failed, falling back to server:", F), o = await n.queryFeatures(r);
61
+ console.warn("Client-side query failed, falling back to server:", F), o = await a.queryFeatures(r);
62
62
  }
63
63
  }
64
- const g = o.features.map((r) => r.attributes[f]), { attributes: b } = I(n, o, a.timeZone);
64
+ const g = o.features.map((r) => r.attributes[f]), { attributes: b } = I(a, o, n.timeZone);
65
65
  return {
66
66
  tool: "getTopFeatures",
67
- layerName: c,
67
+ layerName: u,
68
68
  summary: `Top ${t.topCount} features extracted`,
69
69
  details: {
70
70
  topCount: t.topCount,
71
71
  attributes: b,
72
72
  objectIds: g,
73
73
  objectIdField: f,
74
- where: i.where,
74
+ where: s.where,
75
75
  orderByFields: t.orderByFields,
76
- ...h && { groupByFields: t.groupByFields }
76
+ ...p && { groupByFields: t.groupByFields }
77
77
  }
78
78
  };
79
79
  } catch (o) {
80
80
  return {
81
81
  tool: "getTopFeatures",
82
- layerName: c,
82
+ layerName: u,
83
83
  summary: "Query failed",
84
84
  details: { error: o instanceof Error ? o.message : String(o) }
85
85
  };
86
86
  }
87
87
  }, j = async ({
88
- targetLayer: i,
88
+ targetLayer: s,
89
89
  topFilter: t,
90
- geometryFilter: a,
91
- useCurrentExtent: s
90
+ geometryFilter: n,
91
+ useCurrentExtent: i
92
92
  }, l) => {
93
- const { mapView: n } = N(l, ["mapView"]), d = await x(i, t, n, a, s);
94
- return JSON.stringify(d, null, 2);
95
- }, G = e.object({
93
+ const { mapView: a } = N(l, ["mapView"]), c = G(
94
+ n,
95
+ l.state?.agentExecutionContext?.sharedResources
96
+ ), u = await R(s, t, a, c, i);
97
+ return JSON.stringify(u, null, 2);
98
+ }, D = e.object({
96
99
  layerId: e.string().describe("The layerId of the layer containing the geometry by which to filter."),
97
100
  where: e.string().describe("The SQL-92 where clause representing the features from which to filter."),
98
101
  distance: e.number().optional().describe("The buffer distance around the geometry."),
99
102
  units: y.optional().describe("The units for the distance buffer.")
100
- }), R = e.object({
103
+ }), Q = e.object({
101
104
  point: e.object({
102
105
  x: e.number().describe("X coordinate (longitude) from navigation result"),
103
106
  y: e.number().describe("Y coordinate (latitude) from navigation result"),
@@ -107,7 +110,7 @@ const k = (i) => i.flatMap((t) => t.split(",")).map((t) => t.trim()).map((t) =>
107
110
  }).describe("Point coordinates from a previous navigation/geocoding result"),
108
111
  distance: e.number().optional().describe("Optional buffer distance around the point."),
109
112
  units: y.optional().describe("The units for the distance buffer.")
110
- }), Q = e.object({
113
+ }), U = e.object({
111
114
  targetLayer: e.object({
112
115
  layerId: e.string().describe("The layerId of the layer containing the field from which to get a value."),
113
116
  where: e.string().describe("The SQL-92 where clause representing the feature from which to get an attribute value."),
@@ -118,8 +121,8 @@ const k = (i) => i.flatMap((t) => t.split(",")).map((t) => t.trim()).map((t) =>
118
121
  ).default("*")
119
122
  )
120
123
  }),
121
- geometryFilter: e.union([G, R]).optional().describe(
122
- "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."
124
+ geometryFilter: e.union([D, Q, x]).optional().describe(
125
+ "Geometry filter for spatial queries. Use 'sharedResourceId' with an ID from listSharedResources for a previously geocoded location. Use 'point' for inline coordinates or 'layerId/where' for features from another layer."
123
126
  ),
124
127
  topFilter: e.object({
125
128
  topCount: e.number().describe("Number of top features to return per group."),
@@ -131,11 +134,11 @@ const k = (i) => i.flatMap((t) => t.split(",")).map((t) => t.trim()).map((t) =>
131
134
  useCurrentExtent: e.boolean().optional().describe(
132
135
  "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)."
133
136
  )
134
- }), z = T(j, {
137
+ }), J = S(j, {
135
138
  name: "getTopFeatures",
136
139
  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.',
137
- schema: Q
140
+ schema: U
138
141
  });
139
142
  export {
140
- z as getTopFeaturesTool
143
+ J as getTopFeaturesTool
141
144
  };