@arcgis/ai-components 5.2.0-next.97 → 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.
- package/dist/agents/tools/filter/setFeatureEffect/adapter.js +52 -40
- package/dist/agents/tools/navigation/goToAddress/adapter.js +39 -31
- package/dist/agents/tools/query/getStatistics/adapter.js +59 -56
- package/dist/agents/tools/query/getTopFeatures/adapter.js +51 -48
- package/dist/agents/tools/query/queryFeatures/adapter.js +46 -43
- package/dist/cdn/22KHSDJI.js +2 -0
- package/dist/cdn/5K5ZY267.js +2 -0
- package/dist/cdn/{NSHLOFIY.js → 5XZLS7UO.js} +1 -1
- package/dist/cdn/655YIKL3.js +11 -0
- package/dist/cdn/AKD5UOVX.js +2 -0
- package/dist/cdn/{NEZXHUAL.js → BE7BRJZD.js} +1 -1
- package/dist/cdn/C4JT4S5E.js +2 -0
- package/dist/cdn/{UHZG7SKO.js → FJO4KNOZ.js} +1 -1
- package/dist/cdn/{MX7OEO5Z.js → FXP5UIQU.js} +1 -1
- package/dist/cdn/{CZM4URK7.js → G3SF6U2U.js} +1 -1
- package/dist/cdn/{HNADFHYH.js → ICQCK5D3.js} +1 -1
- package/dist/cdn/{ASR3I43T.js → IJVMUS2L.js} +1 -1
- package/dist/cdn/{UAANWCMU.js → LAYVGCPL.js} +1 -1
- package/dist/cdn/NNXISHCA.js +14 -0
- package/dist/cdn/{LNCT4S4I.js → OX64WOEL.js} +1 -1
- package/dist/cdn/{7ZFAFKJT.js → QUKNPVAF.js} +1 -1
- package/dist/cdn/{YWN57GH4.js → RVSTAUQS.js} +1 -1
- package/dist/cdn/{EKWM5K4K.js → TCH5I5LS.js} +1 -1
- package/dist/cdn/{B2T7D57Y.js → TEPP7YPR.js} +1 -1
- package/dist/cdn/{6KN5LUAV.js → TMVF2W5N.js} +15 -15
- package/dist/cdn/{IC3LG6TH.js → UHNVDALX.js} +1 -1
- package/dist/cdn/{4WIDLQUH.js → XX6GHMNR.js} +1 -1
- package/dist/cdn/{AA4FBYKK.js → Z5HWPSZN.js} +1 -1
- package/dist/cdn/{GFEOVHJK.js → ZRVZMPFN.js} +1 -1
- package/dist/cdn/agent-utils/index.js +1 -1
- package/dist/cdn/index.js +1 -1
- package/dist/chunks/navigationGraph.js +84 -81
- package/dist/chunks/resolvePointGeometryFilter.js +92 -0
- package/dist/docs/api.json +1 -1
- package/dist/docs/docs.json +1 -1
- package/dist/docs/web-types.json +1 -1
- package/package.json +5 -5
- package/dist/cdn/6HF36IKA.js +0 -2
- package/dist/cdn/JKIESH74.js +0 -2
- package/dist/cdn/OAKRPM7D.js +0 -2
- package/dist/cdn/QNNGPA3Q.js +0 -2
- package/dist/cdn/U2D53TAX.js +0 -14
- package/dist/cdn/V52XWEGV.js +0 -11
- 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/
|
|
7
|
-
import { f as
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
if (!
|
|
11
|
-
return { success: !1, error: `Layer '${
|
|
12
|
-
const
|
|
13
|
-
|
|
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:
|
|
16
|
-
return !
|
|
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: ${
|
|
19
|
-
} : (await t.goTo(
|
|
20
|
-
} catch (
|
|
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:
|
|
23
|
+
error: o instanceof Error ? o.message : String(o)
|
|
24
24
|
};
|
|
25
25
|
}
|
|
26
|
-
},
|
|
27
|
-
const
|
|
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 (!
|
|
30
|
+
if (!s)
|
|
31
31
|
return `Could not find target layer with ID: ${t.layerId}`;
|
|
32
|
-
let
|
|
32
|
+
let a;
|
|
33
33
|
if (r) {
|
|
34
|
-
const f = await y(r,
|
|
34
|
+
const f = await y(r, i);
|
|
35
35
|
if ("error" in f)
|
|
36
36
|
return f.error;
|
|
37
|
-
|
|
37
|
+
a = f.geometry;
|
|
38
38
|
}
|
|
39
|
-
if (
|
|
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:
|
|
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
|
-
}),
|
|
50
|
-
return `Applied feature effects to "${
|
|
51
|
-
const
|
|
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
|
-
|
|
53
|
+
t.layerId,
|
|
54
|
+
o,
|
|
55
|
+
a,
|
|
56
56
|
r?.distance,
|
|
57
57
|
r?.units
|
|
58
|
-
), p =
|
|
59
|
-
return l.success ? `Applied feature effects to target layer "${
|
|
60
|
-
},
|
|
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:
|
|
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:
|
|
68
|
-
|
|
69
|
-
|
|
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
|
-
}),
|
|
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
|
-
}),
|
|
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([
|
|
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(
|
|
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:
|
|
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
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import { addressToLocations as
|
|
7
|
-
import
|
|
8
|
-
import { f as
|
|
9
|
-
import
|
|
10
|
-
async function
|
|
11
|
-
const
|
|
12
|
-
if (!
|
|
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
|
|
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
|
|
21
|
-
url:
|
|
20
|
+
const m = new w({
|
|
21
|
+
url: l,
|
|
22
22
|
width: 24,
|
|
23
23
|
height: 24
|
|
24
|
-
}),
|
|
24
|
+
}), h = new u({
|
|
25
25
|
geometry: o.location,
|
|
26
|
-
symbol:
|
|
26
|
+
symbol: m
|
|
27
27
|
});
|
|
28
|
-
t.graphics.removeAll(), t.graphics.add(
|
|
29
|
-
const
|
|
30
|
-
address: o.address ??
|
|
31
|
-
location: o.location
|
|
32
|
-
extent: o.extent
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
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:
|
|
41
|
-
return await
|
|
47
|
+
const { mapView: a } = y(t, ["mapView"]);
|
|
48
|
+
return await A(e, a);
|
|
42
49
|
}
|
|
43
|
-
const
|
|
44
|
-
address:
|
|
45
|
-
}), E =
|
|
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:
|
|
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
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import { c as x, m as
|
|
8
|
-
import { g as
|
|
9
|
-
import { f as
|
|
10
|
-
import { f as
|
|
11
|
-
const
|
|
12
|
-
const { targetLayer:
|
|
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 '${
|
|
15
|
-
const
|
|
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
|
|
18
|
+
let b, u;
|
|
19
19
|
if (e) {
|
|
20
|
-
const
|
|
21
|
-
if ("error" in
|
|
22
|
-
throw new Error(
|
|
23
|
-
if (!
|
|
24
|
-
throw
|
|
25
|
-
if (
|
|
26
|
-
const g =
|
|
27
|
-
|
|
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) && (
|
|
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
|
|
42
|
-
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(
|
|
48
|
+
const y = x(w, [n], !1);
|
|
49
49
|
let d = null, m = null;
|
|
50
|
-
const
|
|
50
|
+
const T = 10;
|
|
51
51
|
if (o.type !== "geometry" && o.type !== "oid" && o.type !== "global-id")
|
|
52
52
|
try {
|
|
53
|
-
const
|
|
53
|
+
const r = {
|
|
54
54
|
layer: s,
|
|
55
55
|
useFeaturesInView: y,
|
|
56
|
-
view: y ?
|
|
56
|
+
view: y ? i : void 0,
|
|
57
57
|
field: n,
|
|
58
|
-
sqlWhere:
|
|
58
|
+
sqlWhere: v(s.definitionExpression, a.where),
|
|
59
59
|
...u && { filter: u },
|
|
60
60
|
outStatisticTypes: { include: [l] }
|
|
61
61
|
};
|
|
62
|
-
d = await
|
|
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
|
|
64
|
+
(g.includes(o.type) || f) && (m = (await R({
|
|
65
65
|
layer: s,
|
|
66
66
|
useFeaturesInView: y,
|
|
67
|
-
view: y ?
|
|
67
|
+
view: y ? i : void 0,
|
|
68
68
|
field: n,
|
|
69
|
-
sqlWhere:
|
|
69
|
+
sqlWhere: v(s.definitionExpression, a.where),
|
|
70
70
|
...u && { filter: u }
|
|
71
|
-
})).uniqueValueInfos.sort((c, q) => q.count - c.count).slice(0,
|
|
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 (
|
|
76
|
-
console.error("Statistics error:",
|
|
75
|
+
} catch (r) {
|
|
76
|
+
console.error("Statistics error:", r);
|
|
77
77
|
}
|
|
78
78
|
return {
|
|
79
79
|
tool: "getStatistics",
|
|
80
|
-
layerName: s.title ??
|
|
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:
|
|
84
|
+
fieldAlias: F,
|
|
85
85
|
statisticType: l,
|
|
86
86
|
statistic: d?.[l] ?? null,
|
|
87
87
|
summaryStatistics: d,
|
|
88
88
|
uniqueValues: m,
|
|
89
|
-
where:
|
|
90
|
-
spatialFilterInfo:
|
|
89
|
+
where: a.where,
|
|
90
|
+
spatialFilterInfo: b
|
|
91
91
|
}
|
|
92
92
|
};
|
|
93
93
|
};
|
|
94
|
-
async function
|
|
94
|
+
async function A({
|
|
95
95
|
targetLayer: h,
|
|
96
|
-
fieldName:
|
|
96
|
+
fieldName: a,
|
|
97
97
|
statisticType: n,
|
|
98
98
|
geometryFilter: l
|
|
99
|
-
},
|
|
100
|
-
const p =
|
|
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:
|
|
105
|
+
fieldName: a,
|
|
103
106
|
statisticType: n,
|
|
104
107
|
mapView: e,
|
|
105
108
|
layersAndFieldsRegistry: p,
|
|
106
|
-
geometryFilter:
|
|
109
|
+
geometryFilter: s
|
|
107
110
|
});
|
|
108
|
-
return JSON.stringify(
|
|
111
|
+
return JSON.stringify(w, null, 2);
|
|
109
112
|
}
|
|
110
|
-
const
|
|
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:
|
|
115
|
-
}),
|
|
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:
|
|
125
|
-
}),
|
|
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([
|
|
131
|
-
"Geometry filter for spatial queries. Use '
|
|
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
|
-
}),
|
|
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:
|
|
153
|
+
schema: $
|
|
151
154
|
});
|
|
152
155
|
export {
|
|
153
|
-
|
|
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
|
|
2
|
+
import { tool as S } from "@langchain/core/tools";
|
|
3
3
|
import e from "zod";
|
|
4
|
-
import
|
|
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/
|
|
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 = (
|
|
11
|
-
const
|
|
12
|
-
let
|
|
13
|
-
if (
|
|
14
|
-
const o = await q(
|
|
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:
|
|
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:
|
|
25
|
+
layerName: u,
|
|
26
26
|
summary: "No features found for geometry filter",
|
|
27
27
|
details: {
|
|
28
|
-
error: `No features found matching: ${"where" in
|
|
28
|
+
error: `No features found matching: ${"where" in i ? i.where : "unknown criteria"}`
|
|
29
29
|
}
|
|
30
30
|
};
|
|
31
|
-
|
|
32
|
-
} else l && (
|
|
33
|
-
const
|
|
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 (
|
|
37
|
-
const r = new
|
|
38
|
-
where:
|
|
39
|
-
outFields:
|
|
40
|
-
orderByFields:
|
|
41
|
-
geometry:
|
|
42
|
-
spatialRelationship:
|
|
43
|
-
distance:
|
|
44
|
-
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
|
|
51
|
+
o = await a.queryTopFeatures(r);
|
|
52
52
|
} else {
|
|
53
|
-
const r =
|
|
54
|
-
r.where = C(
|
|
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([...
|
|
57
|
-
], w = v(
|
|
56
|
+
.../* @__PURE__ */ new Set([...s.outFields, ...k(t.orderByFields)])
|
|
57
|
+
], w = v(c, m, l ?? !1);
|
|
58
58
|
try {
|
|
59
|
-
o = w ? await
|
|
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
|
|
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(
|
|
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:
|
|
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:
|
|
74
|
+
where: s.where,
|
|
75
75
|
orderByFields: t.orderByFields,
|
|
76
|
-
...
|
|
76
|
+
...p && { groupByFields: t.groupByFields }
|
|
77
77
|
}
|
|
78
78
|
};
|
|
79
79
|
} catch (o) {
|
|
80
80
|
return {
|
|
81
81
|
tool: "getTopFeatures",
|
|
82
|
-
layerName:
|
|
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:
|
|
88
|
+
targetLayer: s,
|
|
89
89
|
topFilter: t,
|
|
90
|
-
geometryFilter:
|
|
91
|
-
useCurrentExtent:
|
|
90
|
+
geometryFilter: n,
|
|
91
|
+
useCurrentExtent: i
|
|
92
92
|
}, l) => {
|
|
93
|
-
const { mapView:
|
|
94
|
-
|
|
95
|
-
|
|
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
|
-
}),
|
|
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
|
-
}),
|
|
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([
|
|
122
|
-
"Geometry filter for spatial queries. Use '
|
|
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
|
-
}),
|
|
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:
|
|
140
|
+
schema: U
|
|
138
141
|
});
|
|
139
142
|
export {
|
|
140
|
-
|
|
143
|
+
J as getTopFeaturesTool
|
|
141
144
|
};
|