@arcgis/ai-components 5.1.0-next.138 → 5.1.0-next.139
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agent-utils/middlewares/trace.d.ts +2 -0
- package/dist/cdn/{U2CX3WH3.js → 3J5RM5OR.js} +1 -1
- package/dist/cdn/4BA4OUWC.js +134 -0
- package/dist/cdn/{YRJK6X3B.js → 5PCM536R.js} +1 -1
- package/dist/cdn/{DN7TVQ4I.js → 7UZXJ2NV.js} +1 -1
- package/dist/cdn/{6TEXUJFZ.js → BP3VTREO.js} +1 -1
- package/dist/cdn/BUTKUPXN.js +34 -0
- package/dist/cdn/CU2TRUZQ.js +99 -0
- package/dist/cdn/{5JNQ6ZXX.js → CY6TQNPZ.js} +1 -1
- package/dist/cdn/{AEJQUURR.js → DB2C7FK7.js} +1 -1
- package/dist/cdn/{RERLJUOH.js → ECRIHA3B.js} +1 -1
- package/dist/cdn/{6NSZUDHP.js → FDBWYCAB.js} +1 -1
- package/dist/cdn/{4NK7OFUN.js → MJM2MHJW.js} +5 -5
- package/dist/cdn/OP6ENMCN.js +180 -0
- package/dist/cdn/VDAF255D.js +22 -0
- package/dist/cdn/{TU2UCPP6.js → W2CWLWUT.js} +1 -1
- package/dist/cdn/{KV3KZOQY.js → W6HO4D6J.js} +1 -1
- package/dist/cdn/{XR2ONH3R.js → ZGQAMC2Z.js} +1 -1
- package/dist/cdn/agent-utils/index.js +1 -1
- package/dist/cdn/index.js +1 -1
- package/dist/chunks/adapter.js +1464 -1376
- package/dist/chunks/arcgisKnowledgeGraph.js +91 -74
- package/dist/chunks/arcgis_knowledge_current_lc_context.js +19 -2
- package/dist/chunks/arcgis_knowledge_current_map_context.js +31 -2
- package/dist/chunks/arcgis_knowledge_cypher_query_prompt.js +102 -0
- package/dist/chunks/arcgis_knowledge_summarize_result_prompt.js +116 -27
- 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 +4 -4
- package/dist/cdn/GH7EROHP.js +0 -5
- package/dist/cdn/KDLJHH5V.js +0 -161
- package/dist/cdn/KWORBODI.js +0 -5
- package/dist/cdn/MFEAOGTZ.js +0 -45
package/dist/chunks/adapter.js
CHANGED
|
@@ -1,78 +1,78 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import { Annotation as b, messagesStateReducer as
|
|
2
|
+
import pe from "@arcgis/core/identity/IdentityManager.js";
|
|
3
|
+
import k from "@arcgis/core/portal/Portal.js";
|
|
4
|
+
import { Annotation as b, messagesStateReducer as be } from "@langchain/langgraph/web";
|
|
5
5
|
import "@arcgis/toolkit/string";
|
|
6
|
-
import { k as
|
|
6
|
+
import { k as De, j as H, i as Pe } from "./generateLayerDescriptions.js";
|
|
7
7
|
import "@langchain/core/messages";
|
|
8
8
|
import "@langchain/core/callbacks/dispatch/web";
|
|
9
9
|
import "@langchain/openai";
|
|
10
10
|
import X from "@arcgis/core/config.js";
|
|
11
11
|
import * as Ae from "@arcgis/core/core/reactiveUtils.js";
|
|
12
12
|
import "@arcgis/core/layers/FeatureLayer.js";
|
|
13
|
-
import
|
|
13
|
+
import he from "@arcgis/core/request.js";
|
|
14
14
|
import "@langchain/core/prompts";
|
|
15
|
-
import { tool as
|
|
16
|
-
import
|
|
15
|
+
import { tool as w } from "@langchain/core/tools";
|
|
16
|
+
import je from "@arcgis/core/Graphic.js";
|
|
17
17
|
import { addressToLocations as Le } from "@arcgis/core/rest/locator.js";
|
|
18
|
-
import
|
|
19
|
-
import
|
|
20
|
-
import
|
|
21
|
-
import
|
|
22
|
-
import { createRenderer as
|
|
23
|
-
import { getSchemesByTag as
|
|
24
|
-
import { getBackgroundColorTheme as
|
|
18
|
+
import Ge from "@arcgis/core/symbols/PictureMarkerSymbol.js";
|
|
19
|
+
import s, { z as E } from "zod";
|
|
20
|
+
import Oe from "@arcgis/core/geometry/Extent.js";
|
|
21
|
+
import Te from "@arcgis/core/geometry/Point.js";
|
|
22
|
+
import { createRenderer as Me } from "@arcgis/core/smartMapping/renderers/pieChart.js";
|
|
23
|
+
import { getSchemesByTag as Qe, getSchemes as _e } from "@arcgis/core/smartMapping/symbology/pieChart.js";
|
|
24
|
+
import { getBackgroundColorTheme as me } from "@arcgis/core/views/support/colorUtils.js";
|
|
25
25
|
import { a as x, s as S } from "./index.js";
|
|
26
|
-
import { createAgeRenderer as
|
|
27
|
-
import { getSchemesByTag as
|
|
28
|
-
import { createContinuousRenderer as
|
|
29
|
-
import { createRenderer as
|
|
26
|
+
import { createAgeRenderer as We, createContinuousRenderer as Ve } from "@arcgis/core/smartMapping/renderers/color.js";
|
|
27
|
+
import { getSchemesByTag as se } from "@arcgis/core/smartMapping/symbology/color.js";
|
|
28
|
+
import { createContinuousRenderer as Ue } from "@arcgis/core/smartMapping/renderers/univariateColorSize.js";
|
|
29
|
+
import { createRenderer as Be } from "@arcgis/core/smartMapping/renderers/dotDensity.js";
|
|
30
30
|
import { getSchemesByTag as Ke } from "@arcgis/core/smartMapping/symbology/dotDensity.js";
|
|
31
|
-
import { createRenderer as
|
|
32
|
-
import { getSchemesByTag as
|
|
33
|
-
import { createRenderer as
|
|
34
|
-
import { getSchemesByTag as
|
|
35
|
-
import { createRenderer as
|
|
36
|
-
import { getSchemesByTag as
|
|
37
|
-
import { createAgeRenderer as
|
|
38
|
-
import { createRenderer as
|
|
39
|
-
import { getSchemesByTag as
|
|
40
|
-
import { ToolNode as
|
|
41
|
-
import
|
|
42
|
-
import
|
|
43
|
-
import * as
|
|
44
|
-
import { formatDateOnly as
|
|
45
|
-
import
|
|
46
|
-
import
|
|
47
|
-
import
|
|
48
|
-
import
|
|
49
|
-
import
|
|
50
|
-
import
|
|
31
|
+
import { createRenderer as He } from "@arcgis/core/smartMapping/renderers/heatmap.js";
|
|
32
|
+
import { getSchemesByTag as Je } from "@arcgis/core/smartMapping/symbology/heatmap.js";
|
|
33
|
+
import { createRenderer as Ze } from "@arcgis/core/smartMapping/renderers/predominance.js";
|
|
34
|
+
import { getSchemesByTag as Ye } from "@arcgis/core/smartMapping/symbology/predominance.js";
|
|
35
|
+
import { createRenderer as Xe } from "@arcgis/core/smartMapping/renderers/relationship.js";
|
|
36
|
+
import { getSchemesByTag as et } from "@arcgis/core/smartMapping/symbology/relationship.js";
|
|
37
|
+
import { createAgeRenderer as tt, createContinuousRenderer as rt } from "@arcgis/core/smartMapping/renderers/size.js";
|
|
38
|
+
import { createRenderer as at } from "@arcgis/core/smartMapping/renderers/type.js";
|
|
39
|
+
import { getSchemesByTag as ot } from "@arcgis/core/smartMapping/symbology/type.js";
|
|
40
|
+
import { ToolNode as nt } from "@langchain/langgraph/prebuilt";
|
|
41
|
+
import it from "@arcgis/core/layers/support/FeatureEffect.js";
|
|
42
|
+
import ve from "@arcgis/core/layers/support/FeatureFilter.js";
|
|
43
|
+
import * as st from "@arcgis/core/geometry/operators/unionOperator.js";
|
|
44
|
+
import { formatDateOnly as lt, convertDateFormatToIntlOptions as _, formatTimeOnly as ct, formatDate as ye } from "@arcgis/core/intl.js";
|
|
45
|
+
import ut from "@arcgis/core/smartMapping/statistics/summaryStatistics.js";
|
|
46
|
+
import dt from "@arcgis/core/smartMapping/statistics/uniqueValues.js";
|
|
47
|
+
import pt from "@arcgis/core/rest/support/TopFeaturesQuery.js";
|
|
48
|
+
import ht from "@arcgis/core/rest/support/TopFilter.js";
|
|
49
|
+
import mt from "@arcgis/core/WebLinkChart.js";
|
|
50
|
+
import Se from "@arcgis/core/rest/knowledgeGraph/GraphQueryStreaming.js";
|
|
51
51
|
import "@arcgis/core/views/LinkChartView.js";
|
|
52
|
-
import { fetchKnowledgeGraph as
|
|
53
|
-
import
|
|
54
|
-
const
|
|
55
|
-
...
|
|
52
|
+
import { fetchKnowledgeGraph as fe, executeQueryStreaming as yt, executeSearchStreaming as ft } from "@arcgis/core/rest/knowledgeGraphService.js";
|
|
53
|
+
import gt from "@arcgis/core/rest/knowledgeGraph/GraphSearchStreaming.js";
|
|
54
|
+
const j = (e, r) => r ?? e, $n = b.Root({
|
|
55
|
+
...De(),
|
|
56
56
|
// internal to the navigation agent
|
|
57
57
|
intent: b({
|
|
58
|
-
reducer:
|
|
58
|
+
reducer: j
|
|
59
59
|
}),
|
|
60
60
|
vectorSearchLayerResults: b({
|
|
61
|
-
reducer:
|
|
61
|
+
reducer: j,
|
|
62
62
|
default: () => []
|
|
63
63
|
}),
|
|
64
64
|
vectorSearchFieldResults: b({
|
|
65
|
-
reducer:
|
|
65
|
+
reducer: j
|
|
66
66
|
}),
|
|
67
67
|
navigationInternalState: b({
|
|
68
|
-
reducer:
|
|
68
|
+
reducer: j,
|
|
69
69
|
default: () => ({
|
|
70
70
|
toolCallMessage: void 0
|
|
71
71
|
})
|
|
72
72
|
})
|
|
73
73
|
});
|
|
74
|
-
async function
|
|
75
|
-
const a =
|
|
74
|
+
async function wt(e, r) {
|
|
75
|
+
const a = k.getDefault().helperServices, o = a.geocode.find((h) => h.name === "ArcGIS World Geocoding Service") ?? a.geocode[0];
|
|
76
76
|
if (!o)
|
|
77
77
|
throw new Error("No geocoding service found in helperServices.");
|
|
78
78
|
const n = o.url, l = `${X.assetsPath?.endsWith("/") ? X.assetsPath : `${X.assetsPath}/`}esri/images/search/search-symbol-32.png`, c = (await Le(n, {
|
|
@@ -81,15 +81,15 @@ async function gt(e, t) {
|
|
|
81
81
|
}))?.[0];
|
|
82
82
|
if (!c?.extent || !c.location)
|
|
83
83
|
throw new Error(`Could not find location for: ${e}`);
|
|
84
|
-
const u = new
|
|
84
|
+
const u = new Ge({
|
|
85
85
|
url: l,
|
|
86
86
|
width: 24,
|
|
87
87
|
height: 24
|
|
88
|
-
}), d = new
|
|
88
|
+
}), d = new je({
|
|
89
89
|
geometry: c.location,
|
|
90
90
|
symbol: u
|
|
91
91
|
});
|
|
92
|
-
|
|
92
|
+
r.graphics.removeAll(), r.graphics.add(d), await r.goTo(c.extent);
|
|
93
93
|
const p = {
|
|
94
94
|
address: c.address ?? "",
|
|
95
95
|
location: c.location ? c.location.toJSON() : null,
|
|
@@ -100,29 +100,29 @@ async function gt(e, t) {
|
|
|
100
100
|
sharedStatePatch: { lastResolvedLocation: { value: p } }
|
|
101
101
|
};
|
|
102
102
|
}
|
|
103
|
-
const
|
|
104
|
-
function
|
|
105
|
-
const
|
|
106
|
-
if (!
|
|
103
|
+
const bt = ["mapView"];
|
|
104
|
+
function C(e) {
|
|
105
|
+
const t = e?.configurable?.context;
|
|
106
|
+
if (!t || typeof t != "object")
|
|
107
107
|
throw new Error("NavigationAgent context missing");
|
|
108
|
-
const a =
|
|
108
|
+
const a = bt.filter((o) => !(o in t));
|
|
109
109
|
if (a.length)
|
|
110
110
|
throw new Error(`NavigationAgent context missing: ${a.join(", ")}`);
|
|
111
|
-
return
|
|
111
|
+
return t;
|
|
112
112
|
}
|
|
113
|
-
async function
|
|
114
|
-
const { mapView:
|
|
115
|
-
return await
|
|
113
|
+
async function Tt({ address: e }, r) {
|
|
114
|
+
const { mapView: t } = C(r);
|
|
115
|
+
return await wt(e, t);
|
|
116
116
|
}
|
|
117
|
-
const
|
|
118
|
-
address:
|
|
119
|
-
}),
|
|
117
|
+
const vt = s.object({
|
|
118
|
+
address: s.string().describe("The full address or place name to locate.")
|
|
119
|
+
}), Cn = w(Tt, {
|
|
120
120
|
name: "goToAddress",
|
|
121
121
|
description: "Geocodes an address using Esri's World Geocoding Service and zooms the map to that location.",
|
|
122
|
-
schema:
|
|
122
|
+
schema: vt
|
|
123
123
|
});
|
|
124
|
-
async function
|
|
125
|
-
const a =
|
|
124
|
+
async function St(e, r) {
|
|
125
|
+
const a = r.map.bookmarks;
|
|
126
126
|
if (!a || a.length === 0)
|
|
127
127
|
throw new Error("No bookmarks found in the map.");
|
|
128
128
|
const o = a.find((l) => l.name === e);
|
|
@@ -131,41 +131,41 @@ async function vt(e, t) {
|
|
|
131
131
|
const n = o.viewpoint;
|
|
132
132
|
if (!n)
|
|
133
133
|
throw new Error(`Bookmark with name "${e}" does not have a valid viewpoint.`);
|
|
134
|
-
return await
|
|
134
|
+
return await r.goTo(n), { text: `Navigated to bookmark: ${e}` };
|
|
135
135
|
}
|
|
136
|
-
async function
|
|
137
|
-
const { mapView:
|
|
138
|
-
return await Promise.resolve(
|
|
136
|
+
async function xt({ bookmarkName: e }, r) {
|
|
137
|
+
const { mapView: t } = C(r);
|
|
138
|
+
return await Promise.resolve(St(e, t));
|
|
139
139
|
}
|
|
140
|
-
const
|
|
140
|
+
const Rt = E.object({
|
|
141
141
|
bookmarkName: E.string().describe("The name of the bookmark to navigate to.")
|
|
142
|
-
}),
|
|
142
|
+
}), En = w(xt, {
|
|
143
143
|
name: "goToBookmark",
|
|
144
144
|
description: "Go to the extent of the bookmark with the given name.",
|
|
145
|
-
schema:
|
|
145
|
+
schema: Rt
|
|
146
146
|
});
|
|
147
|
-
async function
|
|
148
|
-
const a =
|
|
147
|
+
async function $t(e, r, t) {
|
|
148
|
+
const a = t.map?.allLayers.find((l) => l.id === e);
|
|
149
149
|
if (!a)
|
|
150
150
|
return { text: `Error: Layer with id ${e} not found` };
|
|
151
|
-
const o =
|
|
151
|
+
const o = r?.trim() ? r : "1=1", n = a.createQuery();
|
|
152
152
|
n.where = o;
|
|
153
153
|
try {
|
|
154
|
-
const { extent: l, count:
|
|
155
|
-
if (
|
|
154
|
+
const { extent: l, count: i } = await a.queryExtent(n);
|
|
155
|
+
if (i === 0)
|
|
156
156
|
return { text: `No features found in ${a.title} matching: ${o}`, where: o };
|
|
157
157
|
if (l)
|
|
158
|
-
await
|
|
158
|
+
await t.goTo(l);
|
|
159
159
|
else
|
|
160
160
|
return { text: `Error: Unable to determine extent for ${a.title}`, where: o };
|
|
161
161
|
const c = {
|
|
162
162
|
layerId: e,
|
|
163
163
|
layerTitle: a.title ?? e,
|
|
164
164
|
where: o,
|
|
165
|
-
count:
|
|
165
|
+
count: i
|
|
166
166
|
};
|
|
167
167
|
return {
|
|
168
|
-
text: `Successfully zoomed to ${
|
|
168
|
+
text: `Successfully zoomed to ${i} feature(s) in ${a.title} matching: ${o}`,
|
|
169
169
|
where: o,
|
|
170
170
|
sharedStatePatch: { lastNavigatedFeatures: { value: c } }
|
|
171
171
|
};
|
|
@@ -173,137 +173,138 @@ async function Rt(e, t, r) {
|
|
|
173
173
|
return console.error("Error in goToFeatures:", l), { text: `Error: ${l instanceof Error ? l.message : "Unknown error"}`, where: o };
|
|
174
174
|
}
|
|
175
175
|
}
|
|
176
|
-
async function
|
|
177
|
-
const { mapView: a } =
|
|
178
|
-
return await
|
|
176
|
+
async function Ct({ layerId: e, where: r }, t) {
|
|
177
|
+
const { mapView: a } = C(t);
|
|
178
|
+
return await $t(e, r, a);
|
|
179
179
|
}
|
|
180
|
-
const
|
|
180
|
+
const Et = E.object({
|
|
181
181
|
layerId: E.string().describe("The layerId of the layer to zoom to."),
|
|
182
182
|
where: E.string().describe("The sql-92 where clause used to query features to zoom to")
|
|
183
|
-
}),
|
|
183
|
+
}), Fn = w(Ct, {
|
|
184
184
|
name: "goToFeatures",
|
|
185
185
|
description: "Go to the features that match the given filter related to the given layerId.",
|
|
186
|
-
schema:
|
|
186
|
+
schema: Et
|
|
187
187
|
});
|
|
188
|
-
async function
|
|
189
|
-
const
|
|
188
|
+
async function Ft(e) {
|
|
189
|
+
const t = new Oe({
|
|
190
190
|
xmin: -180,
|
|
191
191
|
ymin: -90,
|
|
192
192
|
xmax: 180,
|
|
193
193
|
ymax: 90,
|
|
194
194
|
spatialReference: { wkid: 4326 }
|
|
195
195
|
}).expand(0.7);
|
|
196
|
-
return await e.goTo(
|
|
196
|
+
return await e.goTo(t), { text: "Successfully zoomed to world extent" };
|
|
197
197
|
}
|
|
198
|
-
async function
|
|
199
|
-
const { mapView:
|
|
200
|
-
return await
|
|
198
|
+
async function kt(e, r) {
|
|
199
|
+
const { mapView: t } = C(r);
|
|
200
|
+
return await Ft(t);
|
|
201
201
|
}
|
|
202
|
-
const
|
|
202
|
+
const Nt = E.object({}), kn = w(kt, {
|
|
203
203
|
name: "goToFullExtent",
|
|
204
204
|
description: "Zooms the map to the full world extent using Esri's Geocoding Service.",
|
|
205
|
-
schema:
|
|
205
|
+
schema: Nt
|
|
206
206
|
});
|
|
207
|
-
async function
|
|
208
|
-
const
|
|
209
|
-
if (
|
|
210
|
-
await e.goTo(
|
|
207
|
+
async function qt(e) {
|
|
208
|
+
const t = e.map.initialViewProperties?.viewpoint?.targetGeometry;
|
|
209
|
+
if (t)
|
|
210
|
+
await e.goTo(t);
|
|
211
211
|
else
|
|
212
212
|
throw new Error("Initial extent is undefined");
|
|
213
213
|
return { text: "Successfully zoomed to home extent" };
|
|
214
214
|
}
|
|
215
|
-
async function
|
|
216
|
-
const { mapView:
|
|
217
|
-
return await
|
|
215
|
+
async function It(e, r) {
|
|
216
|
+
const { mapView: t } = C(r);
|
|
217
|
+
return await qt(t);
|
|
218
218
|
}
|
|
219
|
-
const zt =
|
|
219
|
+
const zt = s.object({}), Nn = w(It, {
|
|
220
220
|
name: "goToHomeExtent",
|
|
221
221
|
description: "Go to the initial web map view extent",
|
|
222
222
|
schema: zt
|
|
223
223
|
});
|
|
224
|
-
async function
|
|
225
|
-
await
|
|
226
|
-
const
|
|
227
|
-
if (!
|
|
224
|
+
async function Dt(e, r) {
|
|
225
|
+
await r.when();
|
|
226
|
+
const t = r.map?.allLayers.find((o) => o.id === e);
|
|
227
|
+
if (!t)
|
|
228
228
|
return console.warn(`[goToLayer] No matching FeatureLayer found for: ${e}`), { text: `Could not find layer for: ${e}` };
|
|
229
229
|
let a;
|
|
230
|
-
return (
|
|
230
|
+
return (t.type === "link-chart" || t.type === "knowledge-graph-sublayer") && r.map?.activeLinkChartLayer ? a = r.map.diagramNodesExtent : a = t.fullExtent, a ? (await r.goTo(a), t.visible = !0, { text: `Successfully zoomed to: ${t.title ?? ""}` }) : { text: "Layer has no defined extent. Cannot zoom to layer." };
|
|
231
231
|
}
|
|
232
|
-
async function
|
|
233
|
-
const { mapView:
|
|
234
|
-
return await
|
|
232
|
+
async function Pt({ layerId: e }, r) {
|
|
233
|
+
const { mapView: t } = C(r);
|
|
234
|
+
return await Dt(e, t);
|
|
235
235
|
}
|
|
236
236
|
const At = E.object({
|
|
237
237
|
layerId: E.string().describe("The id of the layer to navigate to")
|
|
238
|
-
}),
|
|
238
|
+
}), qn = w(Pt, {
|
|
239
239
|
name: "goToLayer",
|
|
240
240
|
description: "Zooms the map view to the full extent of the top matching layer.",
|
|
241
241
|
schema: At
|
|
242
242
|
});
|
|
243
|
-
async function
|
|
244
|
-
return await
|
|
243
|
+
async function jt(e, r) {
|
|
244
|
+
return await r.goTo({ scale: e }), { text: `Successfully zoomed to: ${e}` };
|
|
245
245
|
}
|
|
246
|
-
async function Lt({ scale: e },
|
|
247
|
-
const { mapView:
|
|
248
|
-
return await
|
|
246
|
+
async function Lt({ scale: e }, r) {
|
|
247
|
+
const { mapView: t } = C(r);
|
|
248
|
+
return await jt(e, t);
|
|
249
249
|
}
|
|
250
|
-
const
|
|
251
|
-
scale:
|
|
252
|
-
}),
|
|
250
|
+
const Gt = s.object({
|
|
251
|
+
scale: s.number().describe("The map scale of the view to go to.")
|
|
252
|
+
}), In = w(Lt, {
|
|
253
253
|
name: "goToScale",
|
|
254
254
|
description: "Go to the specified view scale.",
|
|
255
|
-
schema:
|
|
255
|
+
schema: Gt
|
|
256
256
|
});
|
|
257
|
-
async function
|
|
257
|
+
async function Ot(e, r, t) {
|
|
258
258
|
const o = {
|
|
259
|
-
target: new
|
|
259
|
+
target: new Te({
|
|
260
260
|
longitude: e.longitude,
|
|
261
261
|
latitude: e.latitude,
|
|
262
262
|
spatialReference: { wkid: 4326 }
|
|
263
263
|
})
|
|
264
264
|
};
|
|
265
|
-
return
|
|
265
|
+
return t?.zoom !== void 0 && (o.zoom = t.zoom), t?.scale !== void 0 && (o.scale = t.scale), await r.goTo(o), { text: `Successfully navigated to: ${[
|
|
266
266
|
`(${e.latitude}°, ${e.longitude}°)`,
|
|
267
|
-
|
|
268
|
-
|
|
267
|
+
t?.zoom !== void 0 ? `zoom ${t.zoom}` : "",
|
|
268
|
+
t?.scale !== void 0 ? `scale 1:${t.scale}` : ""
|
|
269
269
|
].filter(Boolean).join(", ")}` };
|
|
270
270
|
}
|
|
271
|
-
async function
|
|
271
|
+
async function Mt({
|
|
272
272
|
center: e,
|
|
273
|
-
zoom:
|
|
274
|
-
scale:
|
|
273
|
+
zoom: r,
|
|
274
|
+
scale: t
|
|
275
275
|
}, a) {
|
|
276
|
-
const { mapView: o } =
|
|
277
|
-
return await
|
|
276
|
+
const { mapView: o } = C(a);
|
|
277
|
+
return await Ot(e, o, { zoom: r, scale: t });
|
|
278
278
|
}
|
|
279
|
-
const
|
|
280
|
-
center:
|
|
281
|
-
longitude:
|
|
282
|
-
latitude:
|
|
279
|
+
const Qt = s.object({
|
|
280
|
+
center: s.object({
|
|
281
|
+
longitude: s.number().describe("The longitude (x-coordinate) of the point to navigate to."),
|
|
282
|
+
latitude: s.number().describe("The latitude (y-coordinate) of the point to navigate to.")
|
|
283
283
|
}),
|
|
284
|
-
zoom:
|
|
285
|
-
scale:
|
|
286
|
-
}), zn =
|
|
284
|
+
zoom: s.number().optional().describe("The zoom level. Higher values = more zoomed in."),
|
|
285
|
+
scale: s.number().optional().describe("The map scale. Alternative to zoom. Smaller numbers = more zoomed in.")
|
|
286
|
+
}), zn = w(Mt, {
|
|
287
287
|
name: "goToViewpoint",
|
|
288
288
|
description: "Go to the specified viewpoint. This can contain a combination of scale, center, zoom, etc.",
|
|
289
|
-
schema:
|
|
289
|
+
schema: Qt
|
|
290
290
|
});
|
|
291
|
-
async function
|
|
292
|
-
return await
|
|
291
|
+
async function _t(e, r) {
|
|
292
|
+
return await r.goTo({ zoom: e }), { text: `Successfully zoomed to: ${e}` };
|
|
293
293
|
}
|
|
294
|
-
async function
|
|
295
|
-
const { mapView:
|
|
296
|
-
return await
|
|
294
|
+
async function Wt({ zoom: e }, r) {
|
|
295
|
+
const { mapView: t } = C(r);
|
|
296
|
+
return await _t(e, t);
|
|
297
297
|
}
|
|
298
|
-
const
|
|
299
|
-
zoom:
|
|
300
|
-
}),
|
|
298
|
+
const Vt = s.object({
|
|
299
|
+
zoom: s.number().min(1).max(20).describe("The zoom level of the view to go to.")
|
|
300
|
+
}), Dn = w(Wt, {
|
|
301
301
|
name: "goToZoom",
|
|
302
302
|
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.).',
|
|
303
|
-
schema:
|
|
304
|
-
}),
|
|
303
|
+
schema: Vt
|
|
304
|
+
}), ge = /* @__PURE__ */ Object.assign({
|
|
305
305
|
"../agents/arcgisKnowledge/prompts/arcgis_knowledge_current_lc_context.md": () => import("./arcgis_knowledge_current_lc_context.js").then((e) => e.default),
|
|
306
306
|
"../agents/arcgisKnowledge/prompts/arcgis_knowledge_current_map_context.md": () => import("./arcgis_knowledge_current_map_context.js").then((e) => e.default),
|
|
307
|
+
"../agents/arcgisKnowledge/prompts/arcgis_knowledge_cypher_query_prompt.md": () => import("./arcgis_knowledge_cypher_query_prompt.js").then((e) => e.default),
|
|
307
308
|
"../agents/arcgisKnowledge/prompts/arcgis_knowledge_lucene_generation_prompt.md": () => import("./arcgis_knowledge_lucene_generation_prompt.js").then((e) => e.default),
|
|
308
309
|
"../agents/arcgisKnowledge/prompts/arcgis_knowledge_summarize_result_prompt.md": () => import("./arcgis_knowledge_summarize_result_prompt.js").then((e) => e.default),
|
|
309
310
|
"../agents/arcgisKnowledge/prompts/arcgis_knowledge_tool_prompt.md": () => import("./arcgis_knowledge_tool_prompt.js").then((e) => e.default),
|
|
@@ -315,48 +316,48 @@ const Wt = i.object({
|
|
|
315
316
|
"../agents/navigation/prompts/navigation_intent_prompt.md": () => import("./navigation_intent_prompt.js").then((e) => e.default),
|
|
316
317
|
"../agents/navigation/prompts/navigation_tool_prompt.md": () => import("./navigation_tool_prompt.js").then((e) => e.default)
|
|
317
318
|
});
|
|
318
|
-
async function
|
|
319
|
-
const
|
|
320
|
-
if (!
|
|
319
|
+
async function U(e) {
|
|
320
|
+
const r = Object.entries(ge).find(([t]) => t.endsWith(`/${e}.md`));
|
|
321
|
+
if (!r)
|
|
321
322
|
throw new Error(`Prompt not found: ${e}
|
|
322
323
|
Available prompts:
|
|
323
|
-
${Object.keys(
|
|
324
|
+
${Object.keys(ge).join(`
|
|
324
325
|
`)}`);
|
|
325
|
-
return await
|
|
326
|
+
return await r[1]();
|
|
326
327
|
}
|
|
327
|
-
const
|
|
328
|
-
const
|
|
329
|
-
return
|
|
330
|
-
},
|
|
331
|
-
const a = e?.configurable?.services?.[
|
|
328
|
+
const Ut = (e, r = 300) => {
|
|
329
|
+
const t = e.replace(/\s+/gu, " ").replace(/[*_`#>\-]/gu, "").trim();
|
|
330
|
+
return t.length > r ? `${t.slice(0, r)}...` : t;
|
|
331
|
+
}, xe = (e, r) => {
|
|
332
|
+
const a = e?.configurable?.services?.[r];
|
|
332
333
|
if (a == null)
|
|
333
|
-
throw new Error(`${
|
|
334
|
+
throw new Error(`${r} missing in config.configurable.services`);
|
|
334
335
|
return a;
|
|
335
|
-
},
|
|
336
|
+
}, Pn = (e, r) => (t, a) => {
|
|
336
337
|
const o = a?.configurable?.services;
|
|
337
338
|
for (const n of e)
|
|
338
339
|
if (!o?.[n])
|
|
339
|
-
throw new Error(`${
|
|
340
|
-
return
|
|
340
|
+
throw new Error(`${r} requires services.${n} to be available.`);
|
|
341
|
+
return t;
|
|
341
342
|
};
|
|
342
|
-
async function
|
|
343
|
-
const { fields:
|
|
343
|
+
async function Bt(e) {
|
|
344
|
+
const { fields: r, layer: t, view: a, styleName: o, colorSchemeTags: n } = e;
|
|
344
345
|
let l;
|
|
345
|
-
return n ? l =
|
|
346
|
-
basemapTheme: await
|
|
347
|
-
geometryType:
|
|
346
|
+
return n ? l = Qe({
|
|
347
|
+
basemapTheme: await me(a),
|
|
348
|
+
geometryType: t.geometryType,
|
|
348
349
|
includedTags: n,
|
|
349
|
-
numColors: Math.min(
|
|
350
|
-
})[0] : l =
|
|
351
|
-
basemapTheme: await
|
|
352
|
-
geometryType:
|
|
353
|
-
numColors: Math.min(
|
|
350
|
+
numColors: Math.min(r.length, 8)
|
|
351
|
+
})[0] : l = _e({
|
|
352
|
+
basemapTheme: await me(a),
|
|
353
|
+
geometryType: t.geometryType,
|
|
354
|
+
numColors: Math.min(r.length, 8)
|
|
354
355
|
}).primaryScheme, {
|
|
355
|
-
layer:
|
|
356
|
+
layer: t,
|
|
356
357
|
view: a,
|
|
357
|
-
attributes:
|
|
358
|
-
field:
|
|
359
|
-
label:
|
|
358
|
+
attributes: r.map((i) => ({
|
|
359
|
+
field: i,
|
|
360
|
+
label: t.fields.find((c) => c.name === i)?.alias ?? ""
|
|
360
361
|
})).slice(0, 8),
|
|
361
362
|
outlineOptimizationEnabled: !0,
|
|
362
363
|
sizeOptimizationEnabled: !0,
|
|
@@ -365,65 +366,65 @@ async function Ut(e) {
|
|
|
365
366
|
};
|
|
366
367
|
}
|
|
367
368
|
async function Kt(e) {
|
|
368
|
-
return await
|
|
369
|
+
return await Me(e);
|
|
369
370
|
}
|
|
370
|
-
async function
|
|
371
|
+
async function Ht({
|
|
371
372
|
arcgisMap: e,
|
|
372
|
-
arcgisMapView:
|
|
373
|
-
layerId:
|
|
373
|
+
arcgisMapView: r,
|
|
374
|
+
layerId: t,
|
|
374
375
|
fields: a,
|
|
375
376
|
colorSchemes: o,
|
|
376
377
|
includeSize: n
|
|
377
378
|
}) {
|
|
378
|
-
const l =
|
|
379
|
-
if (!
|
|
380
|
-
return `Could not find layer for id: ${
|
|
379
|
+
const l = r, i = e?.allLayers.find((d) => d.id === t);
|
|
380
|
+
if (!i)
|
|
381
|
+
return `Could not find layer for id: ${t}`;
|
|
381
382
|
const u = {
|
|
382
383
|
styleName: n ? "chart-size" : "chart",
|
|
383
384
|
fields: a,
|
|
384
|
-
layer:
|
|
385
|
+
layer: i,
|
|
385
386
|
view: l,
|
|
386
387
|
colorSchemeTags: o
|
|
387
388
|
};
|
|
388
389
|
try {
|
|
389
|
-
const d = await
|
|
390
|
-
return
|
|
390
|
+
const d = await Bt(u), p = await Kt(d);
|
|
391
|
+
return i.renderer = p.renderer, i.visible = !0, `Chart renderer applied to layer: ${i.title ?? i.id} using fields ${a.join(", ")}`;
|
|
391
392
|
} catch (d) {
|
|
392
393
|
return `Error applying chart renderer: ${d instanceof Error ? d.message : String(d)}`;
|
|
393
394
|
}
|
|
394
395
|
}
|
|
395
|
-
const
|
|
396
|
+
const Jt = ["mapView"];
|
|
396
397
|
function R(e) {
|
|
397
|
-
const
|
|
398
|
-
if (!
|
|
398
|
+
const t = e?.configurable?.context;
|
|
399
|
+
if (!t || typeof t != "object")
|
|
399
400
|
throw new Error("LayerStylingAgent context missing");
|
|
400
|
-
const a =
|
|
401
|
+
const a = Jt.filter((o) => !(o in t));
|
|
401
402
|
if (a.length)
|
|
402
403
|
throw new Error(`LayerStylingAgent context missing: ${a.join(", ")}`);
|
|
403
|
-
return
|
|
404
|
+
return t;
|
|
404
405
|
}
|
|
405
|
-
async function
|
|
406
|
+
async function Zt({
|
|
406
407
|
layerId: e,
|
|
407
|
-
fields:
|
|
408
|
-
colorSchemes:
|
|
408
|
+
fields: r,
|
|
409
|
+
colorSchemes: t,
|
|
409
410
|
includeSize: a
|
|
410
411
|
}, o) {
|
|
411
412
|
const { mapView: n } = R(o);
|
|
412
|
-
return await x({ type: "show-legend", data: { layerIds: [e] } }, o), await
|
|
413
|
+
return await x({ type: "show-legend", data: { layerIds: [e] } }, o), await Ht({
|
|
413
414
|
arcgisMap: n.map,
|
|
414
415
|
arcgisMapView: n,
|
|
415
416
|
layerId: e,
|
|
416
|
-
fields:
|
|
417
|
-
colorSchemes:
|
|
417
|
+
fields: r,
|
|
418
|
+
colorSchemes: t,
|
|
418
419
|
includeSize: a
|
|
419
420
|
});
|
|
420
421
|
}
|
|
421
|
-
const
|
|
422
|
-
layerId:
|
|
423
|
-
fields:
|
|
424
|
-
colorSchemes:
|
|
425
|
-
includeSize:
|
|
426
|
-
}), An =
|
|
422
|
+
const Yt = s.object({
|
|
423
|
+
layerId: s.string().describe("The id of the layer to apply the chart renderer to"),
|
|
424
|
+
fields: s.array(s.string()).describe("The fields to use for the chart renderer (multiple numeric fields)"),
|
|
425
|
+
colorSchemes: s.array(s.string()).optional().describe("Optional color scheme tags to use"),
|
|
426
|
+
includeSize: s.boolean().optional().describe("Whether to vary the chart size (chart-size)")
|
|
427
|
+
}), An = w(Zt, {
|
|
427
428
|
name: "chart",
|
|
428
429
|
description: `Label: Charts
|
|
429
430
|
Description: Show the values of two or more categories as a proportion of the total using a pie chart.
|
|
@@ -436,98 +437,98 @@ const Zt = i.object({
|
|
|
436
437
|
Keywords: pie, chart, all categories, breakdown, proportion, total, amount, how much, sum, graduated size, proportional size
|
|
437
438
|
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.
|
|
438
439
|
Fields: This style requires 2-8 number fields.`,
|
|
439
|
-
schema:
|
|
440
|
+
schema: Yt
|
|
440
441
|
});
|
|
441
|
-
function
|
|
442
|
-
const { fields:
|
|
443
|
-
let
|
|
444
|
-
return n && (
|
|
445
|
-
geometryType:
|
|
442
|
+
function Xt(e) {
|
|
443
|
+
const { fields: r, layer: t, view: a, theme: o, colorSchemeTags: n } = e, l = r[0];
|
|
444
|
+
let i;
|
|
445
|
+
return n && (i = se({
|
|
446
|
+
geometryType: t.geometryType,
|
|
446
447
|
includedTags: n,
|
|
447
448
|
theme: o || "high-to-low"
|
|
448
449
|
})[0]), {
|
|
449
|
-
layer:
|
|
450
|
+
layer: t,
|
|
450
451
|
view: a,
|
|
451
452
|
startTime: l,
|
|
452
453
|
endTime: /* @__PURE__ */ new Date(),
|
|
453
454
|
theme: o,
|
|
454
455
|
sizeOptimizationEnabled: !0,
|
|
455
456
|
outlineOptimizationEnabled: !0,
|
|
456
|
-
colorScheme:
|
|
457
|
+
colorScheme: i
|
|
457
458
|
};
|
|
458
459
|
}
|
|
459
|
-
async function
|
|
460
|
-
return await
|
|
460
|
+
async function er(e) {
|
|
461
|
+
return await We(e);
|
|
461
462
|
}
|
|
462
|
-
async function
|
|
463
|
+
async function tr({
|
|
463
464
|
arcgisMap: e,
|
|
464
|
-
arcgisMapView:
|
|
465
|
-
layerId:
|
|
465
|
+
arcgisMapView: r,
|
|
466
|
+
layerId: t,
|
|
466
467
|
fields: a,
|
|
467
468
|
colorSchemes: o,
|
|
468
469
|
theme: n
|
|
469
470
|
}) {
|
|
470
|
-
const l =
|
|
471
|
-
if (!
|
|
472
|
-
return `Could not find layer for id: ${
|
|
471
|
+
const l = r, i = e?.allLayers.find((u) => u.id === t);
|
|
472
|
+
if (!i)
|
|
473
|
+
return `Could not find layer for id: ${t}`;
|
|
473
474
|
const c = {
|
|
474
475
|
styleName: "color-age",
|
|
475
476
|
fields: a,
|
|
476
|
-
layer:
|
|
477
|
+
layer: i,
|
|
477
478
|
view: l,
|
|
478
479
|
colorSchemeTags: o,
|
|
479
480
|
theme: n
|
|
480
481
|
};
|
|
481
482
|
try {
|
|
482
|
-
const u =
|
|
483
|
-
return
|
|
483
|
+
const u = Xt(c), d = await er(u);
|
|
484
|
+
return i.renderer = d.renderer, i.visible = !0, `Color-age renderer applied to layer: ${i.title ?? i.id} using fields ${a.join(", ")}`;
|
|
484
485
|
} catch (u) {
|
|
485
486
|
return `Error applying color-age renderer: ${u instanceof Error ? u.message : String(u)}`;
|
|
486
487
|
}
|
|
487
488
|
}
|
|
488
|
-
async function
|
|
489
|
+
async function rr({
|
|
489
490
|
layerId: e,
|
|
490
|
-
fields:
|
|
491
|
-
colorSchemes:
|
|
491
|
+
fields: r,
|
|
492
|
+
colorSchemes: t,
|
|
492
493
|
theme: a
|
|
493
494
|
}, o) {
|
|
494
495
|
const { mapView: n } = R(o);
|
|
495
|
-
return await x({ type: "show-legend", data: { layerIds: [e] } }, o), await
|
|
496
|
+
return await x({ type: "show-legend", data: { layerIds: [e] } }, o), await tr({
|
|
496
497
|
arcgisMap: n.map,
|
|
497
498
|
arcgisMapView: n,
|
|
498
499
|
layerId: e,
|
|
499
|
-
fields:
|
|
500
|
-
colorSchemes:
|
|
500
|
+
fields: r,
|
|
501
|
+
colorSchemes: t,
|
|
501
502
|
theme: a
|
|
502
503
|
});
|
|
503
504
|
}
|
|
504
|
-
const
|
|
505
|
-
layerId:
|
|
506
|
-
fields:
|
|
507
|
-
colorSchemes:
|
|
508
|
-
theme:
|
|
509
|
-
}),
|
|
505
|
+
const ar = s.object({
|
|
506
|
+
layerId: s.string().describe("The id of the layer to apply the color-age renderer to"),
|
|
507
|
+
fields: s.array(s.string()).describe("The field(s) to use for the color-age renderer (temporal/date data)"),
|
|
508
|
+
colorSchemes: s.array(s.string()).optional().describe("Optional color scheme tags to use"),
|
|
509
|
+
theme: s.enum(["above-and-below", "above", "below", "centered-on", "extremes", "high-to-low"]).optional().describe("Optional theme for the color ramp")
|
|
510
|
+
}), jn = w(rr, {
|
|
510
511
|
name: "color-age",
|
|
511
512
|
description: `Label: Age (color)
|
|
512
513
|
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.
|
|
513
514
|
Keywords: since, age, how old, how long
|
|
514
515
|
Example: Show the age of each feature based on its reported date.
|
|
515
516
|
Fields: This style requires at least one field with a date type.`,
|
|
516
|
-
schema:
|
|
517
|
+
schema: ar
|
|
517
518
|
});
|
|
518
|
-
function
|
|
519
|
-
const { fields:
|
|
520
|
-
let { theme: n } = e, l =
|
|
521
|
-
const
|
|
519
|
+
function or(e) {
|
|
520
|
+
const { fields: r, layer: t, view: a, colorSchemeTags: o } = e;
|
|
521
|
+
let { theme: n } = e, l = r[1];
|
|
522
|
+
const i = r[0];
|
|
522
523
|
let c;
|
|
523
|
-
return o && (c =
|
|
524
|
-
geometryType:
|
|
524
|
+
return o && (c = se({
|
|
525
|
+
geometryType: t.geometryType,
|
|
525
526
|
includedTags: o,
|
|
526
527
|
theme: n || "high-to-low"
|
|
527
528
|
})[0]), {
|
|
528
|
-
layer:
|
|
529
|
+
layer: t,
|
|
529
530
|
view: a,
|
|
530
|
-
field:
|
|
531
|
+
field: i,
|
|
531
532
|
normalizationField: l,
|
|
532
533
|
theme: n,
|
|
533
534
|
sizeOptimizationEnabled: !0,
|
|
@@ -535,177 +536,177 @@ function ar(e) {
|
|
|
535
536
|
colorScheme: c
|
|
536
537
|
};
|
|
537
538
|
}
|
|
538
|
-
async function
|
|
539
|
-
return await
|
|
539
|
+
async function nr(e) {
|
|
540
|
+
return await Ve(e);
|
|
540
541
|
}
|
|
541
|
-
async function
|
|
542
|
+
async function ir({
|
|
542
543
|
arcgisMap: e,
|
|
543
|
-
arcgisMapView:
|
|
544
|
-
layerId:
|
|
544
|
+
arcgisMapView: r,
|
|
545
|
+
layerId: t,
|
|
545
546
|
fields: a,
|
|
546
547
|
colorSchemes: o,
|
|
547
548
|
theme: n
|
|
548
549
|
}) {
|
|
549
|
-
const l =
|
|
550
|
-
if (!
|
|
551
|
-
return `Could not find layer for id: ${
|
|
550
|
+
const l = r, i = e?.allLayers.find((u) => u.id === t);
|
|
551
|
+
if (!i)
|
|
552
|
+
return `Could not find layer for id: ${t}`;
|
|
552
553
|
const c = {
|
|
553
554
|
styleName: "color",
|
|
554
555
|
fields: a,
|
|
555
|
-
layer:
|
|
556
|
+
layer: i,
|
|
556
557
|
view: l,
|
|
557
558
|
colorSchemeTags: o,
|
|
558
559
|
theme: n
|
|
559
560
|
};
|
|
560
561
|
try {
|
|
561
|
-
const u =
|
|
562
|
-
return
|
|
562
|
+
const u = or(c), d = await nr(u);
|
|
563
|
+
return i.renderer = d.renderer, i.visible = !0, `Color renderer applied to layer: ${i.title ?? i.id} using fields ${a.join(", ")}`;
|
|
563
564
|
} catch (u) {
|
|
564
565
|
return `Error applying color renderer: ${u instanceof Error ? u.message : String(u)}`;
|
|
565
566
|
}
|
|
566
567
|
}
|
|
567
|
-
async function
|
|
568
|
+
async function sr({
|
|
568
569
|
layerId: e,
|
|
569
|
-
fields:
|
|
570
|
-
colorSchemes:
|
|
570
|
+
fields: r,
|
|
571
|
+
colorSchemes: t,
|
|
571
572
|
theme: a
|
|
572
573
|
}, o) {
|
|
573
574
|
const { mapView: n } = R(o);
|
|
574
|
-
return await x({ type: "show-legend", data: { layerIds: [e] } }, o), await
|
|
575
|
+
return await x({ type: "show-legend", data: { layerIds: [e] } }, o), await ir({
|
|
575
576
|
arcgisMap: n.map,
|
|
576
577
|
arcgisMapView: n,
|
|
577
578
|
layerId: e,
|
|
578
|
-
fields:
|
|
579
|
-
colorSchemes:
|
|
579
|
+
fields: r,
|
|
580
|
+
colorSchemes: t,
|
|
580
581
|
theme: a
|
|
581
582
|
});
|
|
582
583
|
}
|
|
583
|
-
const
|
|
584
|
-
layerId:
|
|
585
|
-
fields:
|
|
586
|
-
colorSchemes:
|
|
587
|
-
theme:
|
|
588
|
-
}), Ln =
|
|
584
|
+
const lr = s.object({
|
|
585
|
+
layerId: s.string().describe("The id of the layer to apply the color renderer to"),
|
|
586
|
+
fields: s.array(s.string()).describe("The field(s) to use for the color renderer"),
|
|
587
|
+
colorSchemes: s.array(s.string()).optional().describe("Optional color scheme tags to use"),
|
|
588
|
+
theme: s.enum(["above-and-below", "above", "below", "centered-on", "extremes", "high-to-low"]).optional().describe("Optional theme for the color ramp")
|
|
589
|
+
}), Ln = w(sr, {
|
|
589
590
|
name: "color",
|
|
590
591
|
description: `Label: Counts and Amounts (color)
|
|
591
592
|
Description: Vary color along a continuous color ramp to represent numeric or ranked data.
|
|
592
593
|
Keywords: graduated color, choropleth, continuous color, hue, color, gradation, saturation, lightness, percent, rate, ratio, index, how much, increase, decrease
|
|
593
594
|
Example: Color each feature based on the population density.
|
|
594
595
|
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.`,
|
|
595
|
-
schema:
|
|
596
|
+
schema: lr
|
|
596
597
|
});
|
|
597
|
-
function
|
|
598
|
-
const { fields:
|
|
599
|
-
let l,
|
|
600
|
-
const c =
|
|
601
|
-
return o && (
|
|
602
|
-
geometryType:
|
|
598
|
+
function cr(e) {
|
|
599
|
+
const { fields: r, layer: t, view: a, colorSchemeTags: o, theme: n } = e;
|
|
600
|
+
let l, i;
|
|
601
|
+
const c = r[0];
|
|
602
|
+
return o && (i = se({
|
|
603
|
+
geometryType: t.geometryType,
|
|
603
604
|
includedTags: o,
|
|
604
605
|
theme: n || "high-to-low"
|
|
605
606
|
})[0]), {
|
|
606
|
-
layer:
|
|
607
|
+
layer: t,
|
|
607
608
|
view: a,
|
|
608
609
|
field: c,
|
|
609
610
|
normalizationField: l,
|
|
610
611
|
theme: n,
|
|
611
612
|
colorOptions: {
|
|
612
|
-
colorScheme:
|
|
613
|
+
colorScheme: i
|
|
613
614
|
}
|
|
614
615
|
};
|
|
615
616
|
}
|
|
616
|
-
async function
|
|
617
|
-
return await
|
|
617
|
+
async function ur(e) {
|
|
618
|
+
return await Ue(e);
|
|
618
619
|
}
|
|
619
|
-
async function
|
|
620
|
+
async function dr({
|
|
620
621
|
arcgisMap: e,
|
|
621
|
-
arcgisMapView:
|
|
622
|
-
layerId:
|
|
622
|
+
arcgisMapView: r,
|
|
623
|
+
layerId: t,
|
|
623
624
|
fields: a,
|
|
624
625
|
colorSchemes: o,
|
|
625
626
|
theme: n
|
|
626
627
|
}) {
|
|
627
|
-
const l =
|
|
628
|
-
if (!
|
|
629
|
-
return `Could not find layer for id: ${
|
|
628
|
+
const l = r, i = e?.allLayers.find((u) => u.id === t);
|
|
629
|
+
if (!i)
|
|
630
|
+
return `Could not find layer for id: ${t}`;
|
|
630
631
|
const c = {
|
|
631
632
|
styleName: "color-size-univariate",
|
|
632
633
|
fields: a,
|
|
633
|
-
layer:
|
|
634
|
+
layer: i,
|
|
634
635
|
view: l,
|
|
635
636
|
colorSchemeTags: o,
|
|
636
637
|
theme: n
|
|
637
638
|
};
|
|
638
639
|
try {
|
|
639
|
-
const u =
|
|
640
|
-
return
|
|
640
|
+
const u = cr(c), d = await ur(u);
|
|
641
|
+
return i.renderer = d.renderer, i.visible = !0, `Color-size-univariate renderer applied to layer: ${i.title ?? i.id} using fields ${a.join(", ")}`;
|
|
641
642
|
} catch (u) {
|
|
642
643
|
return `Error applying color-size-univariate renderer: ${u instanceof Error ? u.message : String(u)}`;
|
|
643
644
|
}
|
|
644
645
|
}
|
|
645
|
-
async function
|
|
646
|
+
async function pr({
|
|
646
647
|
layerId: e,
|
|
647
|
-
fields:
|
|
648
|
-
colorSchemes:
|
|
648
|
+
fields: r,
|
|
649
|
+
colorSchemes: t,
|
|
649
650
|
theme: a
|
|
650
651
|
}, o) {
|
|
651
652
|
const { mapView: n } = R(o);
|
|
652
|
-
return await x({ type: "show-legend", data: { layerIds: [e] } }, o), await
|
|
653
|
+
return await x({ type: "show-legend", data: { layerIds: [e] } }, o), await dr({
|
|
653
654
|
arcgisMap: n.map,
|
|
654
655
|
arcgisMapView: n,
|
|
655
656
|
layerId: e,
|
|
656
|
-
fields:
|
|
657
|
-
colorSchemes:
|
|
657
|
+
fields: r,
|
|
658
|
+
colorSchemes: t,
|
|
658
659
|
theme: a
|
|
659
660
|
});
|
|
660
661
|
}
|
|
661
|
-
const
|
|
662
|
-
layerId:
|
|
663
|
-
fields:
|
|
664
|
-
colorSchemes:
|
|
665
|
-
theme:
|
|
666
|
-
}),
|
|
662
|
+
const hr = s.object({
|
|
663
|
+
layerId: s.string().describe("The id of the layer to apply the color-size univariate renderer to"),
|
|
664
|
+
fields: s.array(s.string()).describe("The fields to use for the color-size univariate renderer"),
|
|
665
|
+
colorSchemes: s.array(s.string()).optional().describe("Optional color scheme tags to use"),
|
|
666
|
+
theme: s.enum(["above-and-below", "above", "below", "centered-on", "extremes", "high-to-low"]).optional().describe("Optional theme for the color and size ramps")
|
|
667
|
+
}), Gn = w(pr, {
|
|
667
668
|
name: "color-size-univariate",
|
|
668
669
|
description: `Label: Color and Size (univariate)
|
|
669
670
|
Description: Vary symbol size and color based on the values of two numeric attributes.
|
|
670
671
|
Keywords: continuous color, hue, color, size, gradation, saturation, lightness, percent, rate, ratio, index, how much, increase, decrease, amount
|
|
671
672
|
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.
|
|
672
673
|
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.`,
|
|
673
|
-
schema:
|
|
674
|
+
schema: hr
|
|
674
675
|
});
|
|
675
|
-
function
|
|
676
|
-
const { fields:
|
|
676
|
+
function mr(e) {
|
|
677
|
+
const { fields: r, layer: t, view: a, colorSchemeTags: o } = e;
|
|
677
678
|
let n;
|
|
678
679
|
return o && (n = Ke({
|
|
679
680
|
includedTags: o,
|
|
680
|
-
numColors: Math.min(
|
|
681
|
+
numColors: Math.min(r.length, 8)
|
|
681
682
|
})[0]), {
|
|
682
|
-
layer:
|
|
683
|
+
layer: t,
|
|
683
684
|
view: a,
|
|
684
685
|
legendOptions: {
|
|
685
686
|
unit: "units"
|
|
686
687
|
},
|
|
687
|
-
attributes:
|
|
688
|
+
attributes: r.map((l) => ({
|
|
688
689
|
field: l,
|
|
689
|
-
label:
|
|
690
|
+
label: t.fields.find((i) => i.name === l)?.alias ?? ""
|
|
690
691
|
})).slice(0, 8),
|
|
691
692
|
outlineOptimizationEnabled: !0,
|
|
692
693
|
dotDensityScheme: n
|
|
693
694
|
};
|
|
694
695
|
}
|
|
695
|
-
async function
|
|
696
|
-
return await
|
|
696
|
+
async function yr(e) {
|
|
697
|
+
return await Be(e);
|
|
697
698
|
}
|
|
698
|
-
async function
|
|
699
|
+
async function fr({
|
|
699
700
|
arcgisMap: e,
|
|
700
|
-
arcgisMapView:
|
|
701
|
-
layerId:
|
|
701
|
+
arcgisMapView: r,
|
|
702
|
+
layerId: t,
|
|
702
703
|
fields: a,
|
|
703
704
|
colorSchemes: o
|
|
704
705
|
}) {
|
|
705
|
-
const n =
|
|
706
|
+
const n = r, l = e?.allLayers.find((c) => c.id === t);
|
|
706
707
|
if (!l)
|
|
707
|
-
return `Could not find layer for id: ${
|
|
708
|
-
const
|
|
708
|
+
return `Could not find layer for id: ${t}`;
|
|
709
|
+
const i = {
|
|
709
710
|
styleName: "dot-density",
|
|
710
711
|
fields: a,
|
|
711
712
|
layer: l,
|
|
@@ -713,31 +714,31 @@ async function yr({
|
|
|
713
714
|
colorSchemeTags: o
|
|
714
715
|
};
|
|
715
716
|
try {
|
|
716
|
-
const c =
|
|
717
|
+
const c = mr(i), u = await yr(c);
|
|
717
718
|
return l.renderer = u.renderer, l.visible = !0, `Dot Density renderer applied to layer: ${l.title ?? l.id} using fields ${a.join(", ")}`;
|
|
718
719
|
} catch (c) {
|
|
719
720
|
return `Error applying dot density renderer: ${c instanceof Error ? c.message : String(c)}`;
|
|
720
721
|
}
|
|
721
722
|
}
|
|
722
|
-
async function
|
|
723
|
+
async function gr({
|
|
723
724
|
layerId: e,
|
|
724
|
-
fields:
|
|
725
|
-
colorSchemes:
|
|
725
|
+
fields: r,
|
|
726
|
+
colorSchemes: t
|
|
726
727
|
}, a) {
|
|
727
728
|
const { mapView: o } = R(a);
|
|
728
|
-
return await x({ type: "show-legend", data: { layerIds: [e] } }, a), await
|
|
729
|
+
return await x({ type: "show-legend", data: { layerIds: [e] } }, a), await fr({
|
|
729
730
|
arcgisMap: o.map,
|
|
730
731
|
arcgisMapView: o,
|
|
731
732
|
layerId: e,
|
|
732
|
-
fields:
|
|
733
|
-
colorSchemes:
|
|
733
|
+
fields: r,
|
|
734
|
+
colorSchemes: t
|
|
734
735
|
});
|
|
735
736
|
}
|
|
736
|
-
const
|
|
737
|
-
layerId:
|
|
738
|
-
fields:
|
|
739
|
-
colorSchemes:
|
|
740
|
-
}),
|
|
737
|
+
const wr = s.object({
|
|
738
|
+
layerId: s.string().describe("The id of the layer to apply the dot density renderer to"),
|
|
739
|
+
fields: s.array(s.string()).describe("The field(s) to use for the dot density renderer (population or count data)"),
|
|
740
|
+
colorSchemes: s.array(s.string()).optional().describe("Optional color scheme tags to use")
|
|
741
|
+
}), On = w(gr, {
|
|
741
742
|
name: "dot-density",
|
|
742
743
|
description: `Dot Density
|
|
743
744
|
Use dot density to visualize the distribution of one attribute or compare the density of multiple attributes. This is only valid for polygon layers.
|
|
@@ -751,36 +752,36 @@ const gr = i.object({
|
|
|
751
752
|
- Display demographic patterns within census tracts
|
|
752
753
|
**Fields:** Requires 2-8 number fields.
|
|
753
754
|
**Keywords:** density, how much, how many, total, number, amount`,
|
|
754
|
-
schema:
|
|
755
|
+
schema: wr
|
|
755
756
|
});
|
|
756
|
-
function
|
|
757
|
-
const { fields:
|
|
757
|
+
function br(e) {
|
|
758
|
+
const { fields: r, layer: t, view: a, colorSchemeTags: o } = e;
|
|
758
759
|
let n;
|
|
759
|
-
const l =
|
|
760
|
-
return o && (n =
|
|
760
|
+
const l = r[0];
|
|
761
|
+
return o && (n = Je({
|
|
761
762
|
includedTags: o,
|
|
762
763
|
basemap: a.map?.basemap || "topo"
|
|
763
764
|
})[0]), {
|
|
764
|
-
layer:
|
|
765
|
+
layer: t,
|
|
765
766
|
view: a,
|
|
766
767
|
field: l,
|
|
767
768
|
heatmapScheme: n
|
|
768
769
|
};
|
|
769
770
|
}
|
|
770
|
-
async function
|
|
771
|
-
return await
|
|
771
|
+
async function Tr(e) {
|
|
772
|
+
return await He(e);
|
|
772
773
|
}
|
|
773
|
-
async function
|
|
774
|
+
async function vr({
|
|
774
775
|
arcgisMap: e,
|
|
775
|
-
arcgisMapView:
|
|
776
|
-
layerId:
|
|
776
|
+
arcgisMapView: r,
|
|
777
|
+
layerId: t,
|
|
777
778
|
fields: a,
|
|
778
779
|
colorSchemes: o
|
|
779
780
|
}) {
|
|
780
|
-
const n =
|
|
781
|
+
const n = r, l = e?.allLayers.find((c) => c.id === t);
|
|
781
782
|
if (!l)
|
|
782
|
-
return `Could not find layer for id: ${
|
|
783
|
-
const
|
|
783
|
+
return `Could not find layer for id: ${t}`;
|
|
784
|
+
const i = {
|
|
784
785
|
styleName: "heatmap",
|
|
785
786
|
fields: a,
|
|
786
787
|
layer: l,
|
|
@@ -788,106 +789,106 @@ async function Tr({
|
|
|
788
789
|
colorSchemeTags: o
|
|
789
790
|
};
|
|
790
791
|
try {
|
|
791
|
-
const c =
|
|
792
|
+
const c = br(i), u = await Tr(c);
|
|
792
793
|
return l.renderer = u.renderer, l.visible = !0, `Heatmap renderer applied to layer: ${l.title ?? l.id} using fields ${a.join(", ")}`;
|
|
793
794
|
} catch (c) {
|
|
794
795
|
return `Error applying heatmap renderer: ${c instanceof Error ? c.message : String(c)}`;
|
|
795
796
|
}
|
|
796
797
|
}
|
|
797
|
-
async function
|
|
798
|
+
async function Sr({
|
|
798
799
|
layerId: e,
|
|
799
|
-
fields:
|
|
800
|
-
colorSchemes:
|
|
800
|
+
fields: r,
|
|
801
|
+
colorSchemes: t
|
|
801
802
|
}, a) {
|
|
802
803
|
const { mapView: o } = R(a);
|
|
803
|
-
return await x({ type: "show-legend", data: { layerIds: [e] } }, a), await
|
|
804
|
+
return await x({ type: "show-legend", data: { layerIds: [e] } }, a), await vr({
|
|
804
805
|
arcgisMap: o.map,
|
|
805
806
|
arcgisMapView: o,
|
|
806
807
|
layerId: e,
|
|
807
|
-
fields:
|
|
808
|
-
colorSchemes:
|
|
808
|
+
fields: r,
|
|
809
|
+
colorSchemes: t
|
|
809
810
|
});
|
|
810
811
|
}
|
|
811
|
-
const
|
|
812
|
-
layerId:
|
|
813
|
-
fields:
|
|
814
|
-
colorSchemes:
|
|
815
|
-
}),
|
|
812
|
+
const xr = s.object({
|
|
813
|
+
layerId: s.string().describe("The id of the layer to apply the heatmap renderer to"),
|
|
814
|
+
fields: s.array(s.string()).describe("The field(s) to use for the heatmap renderer (typically point density)"),
|
|
815
|
+
colorSchemes: s.array(s.string()).optional().describe("Optional color scheme tags to use")
|
|
816
|
+
}), Mn = w(Sr, {
|
|
816
817
|
name: "heatmap",
|
|
817
818
|
description: `Label: Heat Map
|
|
818
819
|
Description: Show areas of high density with colors that appear to glow hotter. This is only valid for point layers.
|
|
819
820
|
Keywords: density, heatmap, hot spots, pattern, cluster
|
|
820
821
|
Example: Create a heatmap
|
|
821
822
|
Fields: This typically requires zero or one field of type number.`,
|
|
822
|
-
schema:
|
|
823
|
+
schema: xr
|
|
823
824
|
});
|
|
824
|
-
function
|
|
825
|
-
const { fields:
|
|
825
|
+
function Rr(e) {
|
|
826
|
+
const { fields: r, layer: t, view: a, styleName: o, colorSchemeTags: n } = e;
|
|
826
827
|
let l;
|
|
827
|
-
return n && (l =
|
|
828
|
-
geometryType:
|
|
828
|
+
return n && (l = Ye({
|
|
829
|
+
geometryType: t.geometryType,
|
|
829
830
|
includedTags: n,
|
|
830
|
-
numColors: Math.min(
|
|
831
|
+
numColors: Math.min(r.length, 10)
|
|
831
832
|
})[0]), {
|
|
832
|
-
layer:
|
|
833
|
+
layer: t,
|
|
833
834
|
view: a,
|
|
834
|
-
fields:
|
|
835
|
+
fields: r.map((i) => ({ name: i })).slice(0, 9),
|
|
835
836
|
outlineOptimizationEnabled: !0,
|
|
836
837
|
sizeOptimizationEnabled: !0,
|
|
837
838
|
includeSizeVariable: o.includes("Size"),
|
|
838
839
|
predominanceScheme: l
|
|
839
840
|
};
|
|
840
841
|
}
|
|
841
|
-
async function
|
|
842
|
-
return await
|
|
842
|
+
async function $r(e) {
|
|
843
|
+
return await Ze(e);
|
|
843
844
|
}
|
|
844
|
-
async function
|
|
845
|
+
async function Cr({
|
|
845
846
|
arcgisMap: e,
|
|
846
|
-
arcgisMapView:
|
|
847
|
-
layerId:
|
|
847
|
+
arcgisMapView: r,
|
|
848
|
+
layerId: t,
|
|
848
849
|
fields: a,
|
|
849
850
|
colorSchemes: o,
|
|
850
851
|
includeSize: n
|
|
851
852
|
}) {
|
|
852
|
-
const l =
|
|
853
|
-
if (!
|
|
854
|
-
return `Could not find layer for id: ${
|
|
853
|
+
const l = r, i = e?.allLayers.find((d) => d.id === t);
|
|
854
|
+
if (!i)
|
|
855
|
+
return `Could not find layer for id: ${t}`;
|
|
855
856
|
const u = {
|
|
856
857
|
styleName: n ? "predominance-size" : "predominance",
|
|
857
858
|
fields: a,
|
|
858
|
-
layer:
|
|
859
|
+
layer: i,
|
|
859
860
|
view: l,
|
|
860
861
|
colorSchemeTags: o
|
|
861
862
|
};
|
|
862
863
|
try {
|
|
863
|
-
const d =
|
|
864
|
-
return
|
|
864
|
+
const d = Rr(u), p = await $r(d);
|
|
865
|
+
return i.renderer = p.renderer, i.visible = !0, `Predominance renderer applied to layer: ${i.title ?? i.id} using fields ${a.join(", ")}`;
|
|
865
866
|
} catch (d) {
|
|
866
867
|
return `Error applying predominance renderer: ${d instanceof Error ? d.message : String(d)}`;
|
|
867
868
|
}
|
|
868
869
|
}
|
|
869
|
-
async function
|
|
870
|
+
async function Er({
|
|
870
871
|
layerId: e,
|
|
871
|
-
fields:
|
|
872
|
-
colorSchemes:
|
|
872
|
+
fields: r,
|
|
873
|
+
colorSchemes: t,
|
|
873
874
|
includeSize: a
|
|
874
875
|
}, o) {
|
|
875
876
|
const { mapView: n } = R(o);
|
|
876
|
-
return await x({ type: "show-legend", data: { layerIds: [e] } }, o), await
|
|
877
|
+
return await x({ type: "show-legend", data: { layerIds: [e] } }, o), await Cr({
|
|
877
878
|
arcgisMap: n.map,
|
|
878
879
|
arcgisMapView: n,
|
|
879
880
|
layerId: e,
|
|
880
|
-
fields:
|
|
881
|
-
colorSchemes:
|
|
881
|
+
fields: r,
|
|
882
|
+
colorSchemes: t,
|
|
882
883
|
includeSize: a
|
|
883
884
|
});
|
|
884
885
|
}
|
|
885
|
-
const
|
|
886
|
-
layerId:
|
|
887
|
-
fields:
|
|
888
|
-
colorSchemes:
|
|
889
|
-
includeSize:
|
|
890
|
-
}),
|
|
886
|
+
const Fr = s.object({
|
|
887
|
+
layerId: s.string().describe("The id of the layer to apply the predominance renderer to"),
|
|
888
|
+
fields: s.array(s.string()).describe("The fields to use for the predominance renderer (competing categories)"),
|
|
889
|
+
colorSchemes: s.array(s.string()).optional().describe("Optional color scheme tags to use"),
|
|
890
|
+
includeSize: s.boolean().optional().describe("Whether to include size visualization (predominance-size)")
|
|
891
|
+
}), Qn = w(Er, {
|
|
891
892
|
name: "predominance",
|
|
892
893
|
description: `Label: Predominant category
|
|
893
894
|
Description: Compare attributes that share a common subject and unit of measurement to see which has the highest value.
|
|
@@ -900,43 +901,43 @@ const Er = i.object({
|
|
|
900
901
|
Keywords: predominant, winner, won, competing, most, most common, most frequent, dominant, prevalent, top, amount, total, how much, proportional size, graduated size, sum
|
|
901
902
|
Example: Show the predominant crop in each area and vary the size of each symbol based on the total of all categories.
|
|
902
903
|
Fields: This style relies on 2-10 number fields.`,
|
|
903
|
-
schema:
|
|
904
|
+
schema: Fr
|
|
904
905
|
});
|
|
905
|
-
function
|
|
906
|
-
const { fields:
|
|
906
|
+
function kr(e) {
|
|
907
|
+
const { fields: r, layer: t, view: a, colorSchemeTags: o } = e;
|
|
907
908
|
let n;
|
|
908
909
|
const l = {
|
|
909
|
-
field:
|
|
910
|
-
},
|
|
911
|
-
field:
|
|
910
|
+
field: r[0]
|
|
911
|
+
}, i = {
|
|
912
|
+
field: r[1]
|
|
912
913
|
};
|
|
913
|
-
return o && (n =
|
|
914
|
-
geometryType:
|
|
914
|
+
return o && (n = et({
|
|
915
|
+
geometryType: t.geometryType,
|
|
915
916
|
includedTags: o
|
|
916
917
|
})[0]), {
|
|
917
|
-
layer:
|
|
918
|
+
layer: t,
|
|
918
919
|
view: a,
|
|
919
920
|
field1: l,
|
|
920
|
-
field2:
|
|
921
|
+
field2: i,
|
|
921
922
|
outlineOptimizationEnabled: !0,
|
|
922
923
|
sizeOptimizationEnabled: !0,
|
|
923
924
|
relationshipScheme: n
|
|
924
925
|
};
|
|
925
926
|
}
|
|
926
|
-
async function
|
|
927
|
-
return await
|
|
927
|
+
async function Nr(e) {
|
|
928
|
+
return await Xe(e);
|
|
928
929
|
}
|
|
929
|
-
async function
|
|
930
|
+
async function qr({
|
|
930
931
|
arcgisMap: e,
|
|
931
|
-
arcgisMapView:
|
|
932
|
-
layerId:
|
|
932
|
+
arcgisMapView: r,
|
|
933
|
+
layerId: t,
|
|
933
934
|
fields: a,
|
|
934
935
|
colorSchemes: o
|
|
935
936
|
}) {
|
|
936
|
-
const n =
|
|
937
|
+
const n = r, l = e?.allLayers.find((c) => c.id === t);
|
|
937
938
|
if (!l)
|
|
938
|
-
return `Could not find layer for id: ${
|
|
939
|
-
const
|
|
939
|
+
return `Could not find layer for id: ${t}`;
|
|
940
|
+
const i = {
|
|
940
941
|
styleName: "relationship",
|
|
941
942
|
fields: a,
|
|
942
943
|
layer: l,
|
|
@@ -944,31 +945,31 @@ async function kr({
|
|
|
944
945
|
colorSchemeTags: o
|
|
945
946
|
};
|
|
946
947
|
try {
|
|
947
|
-
const c =
|
|
948
|
+
const c = kr(i), u = await Nr(c);
|
|
948
949
|
return l.renderer = u.renderer, l.visible = !0, `Relationship renderer applied to layer: ${l.title ?? l.id} using fields ${a.join(", ")}`;
|
|
949
950
|
} catch (c) {
|
|
950
951
|
return `Error applying relationship renderer: ${c instanceof Error ? c.message : String(c)}`;
|
|
951
952
|
}
|
|
952
953
|
}
|
|
953
|
-
async function
|
|
954
|
+
async function Ir({
|
|
954
955
|
layerId: e,
|
|
955
|
-
fields:
|
|
956
|
-
colorSchemes:
|
|
956
|
+
fields: r,
|
|
957
|
+
colorSchemes: t
|
|
957
958
|
}, a) {
|
|
958
959
|
const { mapView: o } = R(a);
|
|
959
|
-
return await x({ type: "show-legend", data: { layerIds: [e] } }, a), await
|
|
960
|
+
return await x({ type: "show-legend", data: { layerIds: [e] } }, a), await qr({
|
|
960
961
|
arcgisMap: o.map,
|
|
961
962
|
arcgisMapView: o,
|
|
962
963
|
layerId: e,
|
|
963
|
-
fields:
|
|
964
|
-
colorSchemes:
|
|
964
|
+
fields: r,
|
|
965
|
+
colorSchemes: t
|
|
965
966
|
});
|
|
966
967
|
}
|
|
967
|
-
const zr =
|
|
968
|
-
layerId:
|
|
969
|
-
fields:
|
|
970
|
-
colorSchemes:
|
|
971
|
-
}),
|
|
968
|
+
const zr = s.object({
|
|
969
|
+
layerId: s.string().describe("The id of the layer to apply the relationship renderer to"),
|
|
970
|
+
fields: s.array(s.string()).describe("The two fields to use for the relationship renderer (bivariate visualization)"),
|
|
971
|
+
colorSchemes: s.array(s.string()).optional().describe("Optional color scheme tags to use")
|
|
972
|
+
}), _n = w(Ir, {
|
|
972
973
|
name: "relationship",
|
|
973
974
|
description: `Label: Relationship
|
|
974
975
|
Description: Overlays two color ramps to represent the relationship between two numeric attributes.
|
|
@@ -977,10 +978,10 @@ const zr = i.object({
|
|
|
977
978
|
Fields: This style requires two number fields.`,
|
|
978
979
|
schema: zr
|
|
979
980
|
});
|
|
980
|
-
function
|
|
981
|
-
const { fields:
|
|
981
|
+
function Dr(e) {
|
|
982
|
+
const { fields: r, layer: t, view: a, theme: o } = e, n = r[0];
|
|
982
983
|
return {
|
|
983
|
-
layer:
|
|
984
|
+
layer: t,
|
|
984
985
|
view: a,
|
|
985
986
|
startTime: n,
|
|
986
987
|
endTime: /* @__PURE__ */ new Date(),
|
|
@@ -989,39 +990,39 @@ function qr(e) {
|
|
|
989
990
|
outlineOptimizationEnabled: !0
|
|
990
991
|
};
|
|
991
992
|
}
|
|
992
|
-
async function
|
|
993
|
-
return await
|
|
993
|
+
async function Pr(e) {
|
|
994
|
+
return await tt(e);
|
|
994
995
|
}
|
|
995
996
|
async function Ar({
|
|
996
997
|
arcgisMap: e,
|
|
997
|
-
arcgisMapView:
|
|
998
|
-
layerId:
|
|
998
|
+
arcgisMapView: r,
|
|
999
|
+
layerId: t,
|
|
999
1000
|
fields: a,
|
|
1000
1001
|
colorSchemes: o,
|
|
1001
1002
|
theme: n
|
|
1002
1003
|
}) {
|
|
1003
|
-
const l =
|
|
1004
|
-
if (!
|
|
1005
|
-
return `Could not find layer for id: ${
|
|
1004
|
+
const l = r, i = e?.allLayers.find((u) => u.id === t);
|
|
1005
|
+
if (!i)
|
|
1006
|
+
return `Could not find layer for id: ${t}`;
|
|
1006
1007
|
const c = {
|
|
1007
1008
|
styleName: "size-age",
|
|
1008
1009
|
fields: a,
|
|
1009
|
-
layer:
|
|
1010
|
+
layer: i,
|
|
1010
1011
|
view: l,
|
|
1011
1012
|
colorSchemeTags: o,
|
|
1012
1013
|
theme: n
|
|
1013
1014
|
};
|
|
1014
1015
|
try {
|
|
1015
|
-
const u =
|
|
1016
|
-
return
|
|
1016
|
+
const u = Dr(c), d = await Pr(u);
|
|
1017
|
+
return i.renderer = d.renderer, i.visible = !0, `Size-age renderer applied to layer: ${i.title ?? i.id} using fields ${a.join(", ")}`;
|
|
1017
1018
|
} catch (u) {
|
|
1018
1019
|
return `Error applying size-age renderer: ${u instanceof Error ? u.message : String(u)}`;
|
|
1019
1020
|
}
|
|
1020
1021
|
}
|
|
1021
|
-
async function
|
|
1022
|
+
async function jr({
|
|
1022
1023
|
layerId: e,
|
|
1023
|
-
fields:
|
|
1024
|
-
colorSchemes:
|
|
1024
|
+
fields: r,
|
|
1025
|
+
colorSchemes: t,
|
|
1025
1026
|
theme: a
|
|
1026
1027
|
}, o) {
|
|
1027
1028
|
const { mapView: n } = R(o);
|
|
@@ -1029,17 +1030,17 @@ async function Pr({
|
|
|
1029
1030
|
arcgisMap: n.map,
|
|
1030
1031
|
arcgisMapView: n,
|
|
1031
1032
|
layerId: e,
|
|
1032
|
-
fields:
|
|
1033
|
-
colorSchemes:
|
|
1033
|
+
fields: r,
|
|
1034
|
+
colorSchemes: t,
|
|
1034
1035
|
theme: a
|
|
1035
1036
|
});
|
|
1036
1037
|
}
|
|
1037
|
-
const Lr =
|
|
1038
|
-
layerId:
|
|
1039
|
-
fields:
|
|
1040
|
-
colorSchemes:
|
|
1041
|
-
theme:
|
|
1042
|
-
}),
|
|
1038
|
+
const Lr = s.object({
|
|
1039
|
+
layerId: s.string().describe("The id of the layer to apply the size-age renderer to"),
|
|
1040
|
+
fields: s.array(s.string()).describe("The field(s) to use for the size-age renderer (temporal data with size)"),
|
|
1041
|
+
colorSchemes: s.array(s.string()).optional().describe("Optional color scheme tags to use"),
|
|
1042
|
+
theme: s.enum(["above-and-below", "above", "below", "centered-on", "extremes", "high-to-low"]).optional().describe("Optional theme for the size ramp")
|
|
1043
|
+
}), Wn = w(jr, {
|
|
1043
1044
|
name: "size-age",
|
|
1044
1045
|
description: `Label: Age (size)
|
|
1045
1046
|
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.
|
|
@@ -1048,12 +1049,12 @@ const Lr = i.object({
|
|
|
1048
1049
|
Fields: This style requires at least one field with a date type.`,
|
|
1049
1050
|
schema: Lr
|
|
1050
1051
|
});
|
|
1051
|
-
function
|
|
1052
|
-
const { fields:
|
|
1053
|
-
let { theme: o } = e, n =
|
|
1054
|
-
const l =
|
|
1052
|
+
function Gr(e) {
|
|
1053
|
+
const { fields: r, layer: t, view: a } = e;
|
|
1054
|
+
let { theme: o } = e, n = r[1];
|
|
1055
|
+
const l = r[0];
|
|
1055
1056
|
return {
|
|
1056
|
-
layer:
|
|
1057
|
+
layer: t,
|
|
1057
1058
|
view: a,
|
|
1058
1059
|
field: l,
|
|
1059
1060
|
normalizationField: n,
|
|
@@ -1062,57 +1063,57 @@ function jr(e) {
|
|
|
1062
1063
|
outlineOptimizationEnabled: !0
|
|
1063
1064
|
};
|
|
1064
1065
|
}
|
|
1065
|
-
async function
|
|
1066
|
-
return await
|
|
1066
|
+
async function Or(e) {
|
|
1067
|
+
return await rt(e);
|
|
1067
1068
|
}
|
|
1068
|
-
async function
|
|
1069
|
+
async function Mr({
|
|
1069
1070
|
arcgisMap: e,
|
|
1070
|
-
arcgisMapView:
|
|
1071
|
-
layerId:
|
|
1071
|
+
arcgisMapView: r,
|
|
1072
|
+
layerId: t,
|
|
1072
1073
|
fields: a,
|
|
1073
1074
|
colorSchemes: o,
|
|
1074
1075
|
theme: n
|
|
1075
1076
|
}) {
|
|
1076
|
-
const l =
|
|
1077
|
-
if (!
|
|
1078
|
-
return `Could not find layer for id: ${
|
|
1077
|
+
const l = r, i = e?.allLayers.find((u) => u.id === t);
|
|
1078
|
+
if (!i)
|
|
1079
|
+
return `Could not find layer for id: ${t}`;
|
|
1079
1080
|
const c = {
|
|
1080
1081
|
styleName: "size",
|
|
1081
1082
|
fields: a,
|
|
1082
|
-
layer:
|
|
1083
|
+
layer: i,
|
|
1083
1084
|
view: l,
|
|
1084
1085
|
colorSchemeTags: o,
|
|
1085
1086
|
theme: n
|
|
1086
1087
|
};
|
|
1087
1088
|
try {
|
|
1088
|
-
const u =
|
|
1089
|
-
return
|
|
1089
|
+
const u = Gr(c), d = await Or(u);
|
|
1090
|
+
return i.renderer = d.renderer, i.visible = !0, `Size renderer applied to layer: ${i.title ?? i.id} using fields ${a.join(", ")}`;
|
|
1090
1091
|
} catch (u) {
|
|
1091
1092
|
return `Error applying size renderer: ${u instanceof Error ? u.message : String(u)}`;
|
|
1092
1093
|
}
|
|
1093
1094
|
}
|
|
1094
|
-
async function
|
|
1095
|
+
async function Qr({
|
|
1095
1096
|
layerId: e,
|
|
1096
|
-
fields:
|
|
1097
|
-
colorSchemes:
|
|
1097
|
+
fields: r,
|
|
1098
|
+
colorSchemes: t,
|
|
1098
1099
|
theme: a
|
|
1099
1100
|
}, o) {
|
|
1100
1101
|
const { mapView: n } = R(o);
|
|
1101
|
-
return await x({ type: "show-legend", data: { layerIds: [e] } }, o), await
|
|
1102
|
+
return await x({ type: "show-legend", data: { layerIds: [e] } }, o), await Mr({
|
|
1102
1103
|
arcgisMap: n.map,
|
|
1103
1104
|
arcgisMapView: n,
|
|
1104
1105
|
layerId: e,
|
|
1105
|
-
fields:
|
|
1106
|
-
colorSchemes:
|
|
1106
|
+
fields: r,
|
|
1107
|
+
colorSchemes: t,
|
|
1107
1108
|
theme: a
|
|
1108
1109
|
});
|
|
1109
1110
|
}
|
|
1110
|
-
const
|
|
1111
|
-
layerId:
|
|
1112
|
-
fields:
|
|
1113
|
-
colorSchemes:
|
|
1114
|
-
theme:
|
|
1115
|
-
}),
|
|
1111
|
+
const _r = s.object({
|
|
1112
|
+
layerId: s.string().describe("The id of the layer to apply the size renderer to"),
|
|
1113
|
+
fields: s.array(s.string()).describe("The field(s) to use for the size renderer (numeric data)"),
|
|
1114
|
+
colorSchemes: s.array(s.string()).optional().describe("Optional color scheme tags to use"),
|
|
1115
|
+
theme: s.enum(["above-and-below", "above", "below", "centered-on", "extremes", "high-to-low"]).optional().describe("Optional theme for the size ramp")
|
|
1116
|
+
}), Vn = w(Qr, {
|
|
1116
1117
|
name: "size",
|
|
1117
1118
|
description: `Label: Counts and Amounts (size)
|
|
1118
1119
|
Description: Vary symbol sizes along a continuous ramp to represent numeric or ranked data.
|
|
@@ -1125,76 +1126,76 @@ const Qr = i.object({
|
|
|
1125
1126
|
Keywords: graduated size, proportional size, classed size, how much, total, number, when
|
|
1126
1127
|
Example: Vary the size of each feature based on the date a ticket was completed.
|
|
1127
1128
|
Fields: This style requires a single field with a date type.`,
|
|
1128
|
-
schema:
|
|
1129
|
+
schema: _r
|
|
1129
1130
|
});
|
|
1130
|
-
function
|
|
1131
|
-
const { fields:
|
|
1131
|
+
function Wr(e) {
|
|
1132
|
+
const { fields: r, layer: t, view: a, colorSchemeTags: o } = e, n = r[0], l = r[1], i = r[2];
|
|
1132
1133
|
let c;
|
|
1133
|
-
return o && (c =
|
|
1134
|
-
geometryType:
|
|
1134
|
+
return o && (c = ot({
|
|
1135
|
+
geometryType: t.geometryType,
|
|
1135
1136
|
includedTags: o
|
|
1136
1137
|
})[0]), {
|
|
1137
|
-
layer:
|
|
1138
|
+
layer: t,
|
|
1138
1139
|
view: a,
|
|
1139
1140
|
field: n,
|
|
1140
1141
|
field2: l,
|
|
1141
|
-
field3:
|
|
1142
|
+
field3: i,
|
|
1142
1143
|
outlineOptimizationEnabled: !0,
|
|
1143
1144
|
sizeOptimizationEnabled: !0,
|
|
1144
1145
|
typeScheme: c
|
|
1145
1146
|
};
|
|
1146
1147
|
}
|
|
1147
|
-
async function
|
|
1148
|
-
return await
|
|
1148
|
+
async function Vr(e) {
|
|
1149
|
+
return await at(e);
|
|
1149
1150
|
}
|
|
1150
|
-
async function
|
|
1151
|
+
async function Ur({
|
|
1151
1152
|
arcgisMap: e,
|
|
1152
|
-
arcgisMapView:
|
|
1153
|
-
layerId:
|
|
1153
|
+
arcgisMapView: r,
|
|
1154
|
+
layerId: t,
|
|
1154
1155
|
fields: a,
|
|
1155
1156
|
colorSchemes: o,
|
|
1156
1157
|
theme: n
|
|
1157
1158
|
}) {
|
|
1158
|
-
const l =
|
|
1159
|
-
if (!
|
|
1160
|
-
return `Could not find layer for id: ${
|
|
1159
|
+
const l = r, i = e?.allLayers.find((u) => u.id === t);
|
|
1160
|
+
if (!i)
|
|
1161
|
+
return `Could not find layer for id: ${t}`;
|
|
1161
1162
|
const c = {
|
|
1162
1163
|
styleName: "type",
|
|
1163
1164
|
fields: a,
|
|
1164
|
-
layer:
|
|
1165
|
+
layer: i,
|
|
1165
1166
|
view: l,
|
|
1166
1167
|
colorSchemeTags: o,
|
|
1167
1168
|
theme: n
|
|
1168
1169
|
};
|
|
1169
1170
|
try {
|
|
1170
|
-
const u =
|
|
1171
|
-
return
|
|
1171
|
+
const u = Wr(c), d = await Vr(u);
|
|
1172
|
+
return i.renderer = d.renderer, i.visible = !0, `Type renderer applied to layer: ${i.title ?? i.id} using fields ${a.join(", ")}`;
|
|
1172
1173
|
} catch (u) {
|
|
1173
1174
|
return `Error applying type renderer: ${u instanceof Error ? u.message : String(u)}`;
|
|
1174
1175
|
}
|
|
1175
1176
|
}
|
|
1176
|
-
async function
|
|
1177
|
+
async function Br({
|
|
1177
1178
|
layerId: e,
|
|
1178
|
-
fields:
|
|
1179
|
-
colorSchemes:
|
|
1179
|
+
fields: r,
|
|
1180
|
+
colorSchemes: t,
|
|
1180
1181
|
theme: a
|
|
1181
1182
|
}, o) {
|
|
1182
1183
|
const { mapView: n } = R(o);
|
|
1183
|
-
return await x({ type: "show-legend", data: { layerIds: [e] } }, o), await
|
|
1184
|
+
return await x({ type: "show-legend", data: { layerIds: [e] } }, o), await Ur({
|
|
1184
1185
|
arcgisMap: n.map,
|
|
1185
1186
|
arcgisMapView: n,
|
|
1186
1187
|
layerId: e,
|
|
1187
|
-
fields:
|
|
1188
|
-
colorSchemes:
|
|
1188
|
+
fields: r,
|
|
1189
|
+
colorSchemes: t,
|
|
1189
1190
|
theme: a
|
|
1190
1191
|
});
|
|
1191
1192
|
}
|
|
1192
|
-
const Kr =
|
|
1193
|
-
layerId:
|
|
1194
|
-
fields:
|
|
1195
|
-
colorSchemes:
|
|
1196
|
-
theme:
|
|
1197
|
-
}),
|
|
1193
|
+
const Kr = s.object({
|
|
1194
|
+
layerId: s.string().describe("The id of the layer to apply the type renderer to"),
|
|
1195
|
+
fields: s.array(s.string()).describe("The field(s) to use for the type renderer (categorical data)"),
|
|
1196
|
+
colorSchemes: s.array(s.string()).optional().describe("Optional color scheme tags to use"),
|
|
1197
|
+
theme: s.enum(["above-and-below", "above", "below", "centered-on", "extremes", "high-to-low"]).optional().describe("Optional theme for the color scheme")
|
|
1198
|
+
}), Un = w(Br, {
|
|
1198
1199
|
name: "type",
|
|
1199
1200
|
description: `Label: Types (unique symbols)
|
|
1200
1201
|
Description: Represent features as categories with different symbol colors or shapes. Examples include type of tree, road class, or province name.
|
|
@@ -1202,119 +1203,119 @@ Keywords: categorical, category, type, unique, discrete, point of interest, regi
|
|
|
1202
1203
|
Example: Color each feature based on the region it belongs to
|
|
1203
1204
|
Fields: This style requires a single field which may be a string, number, or date type. It is usually a string.`,
|
|
1204
1205
|
schema: Kr
|
|
1205
|
-
}),
|
|
1206
|
-
...
|
|
1206
|
+
}), Bn = b.Root({
|
|
1207
|
+
...H(),
|
|
1207
1208
|
vectorSearchLayerIds: b(),
|
|
1208
1209
|
vectorSearchFieldResults: b(),
|
|
1209
1210
|
layerFieldInfo: b(),
|
|
1210
1211
|
selectedLayerId: b()
|
|
1211
1212
|
}), Kn = b.Root({
|
|
1212
|
-
...
|
|
1213
|
+
...H(),
|
|
1213
1214
|
vectorSearchLayerIds: b(),
|
|
1214
1215
|
vectorSearchFieldResults: b(),
|
|
1215
1216
|
layerFieldInfo: b(),
|
|
1216
1217
|
queryResponse: b(),
|
|
1217
1218
|
dataExplorationMessages: b({
|
|
1218
|
-
reducer:
|
|
1219
|
+
reducer: be,
|
|
1219
1220
|
default: () => []
|
|
1220
1221
|
})
|
|
1221
|
-
}),
|
|
1222
|
-
function
|
|
1223
|
-
const
|
|
1224
|
-
if (!
|
|
1222
|
+
}), Hr = ["mapView"];
|
|
1223
|
+
function N(e) {
|
|
1224
|
+
const t = e?.configurable?.context;
|
|
1225
|
+
if (!t || typeof t != "object")
|
|
1225
1226
|
throw new Error("DataExplorationAgent context missing");
|
|
1226
|
-
const a =
|
|
1227
|
+
const a = Hr.filter((o) => !(o in t));
|
|
1227
1228
|
if (a.length)
|
|
1228
1229
|
throw new Error(`DataExplorationAgent context missing: ${a.join(", ")}`);
|
|
1229
|
-
return
|
|
1230
|
+
return t;
|
|
1230
1231
|
}
|
|
1231
|
-
const
|
|
1232
|
-
const
|
|
1233
|
-
let
|
|
1234
|
-
return
|
|
1232
|
+
const Jr = (e) => {
|
|
1233
|
+
const r = e.map?.allLayers.filter((a) => a.type === "feature");
|
|
1234
|
+
let t = 0;
|
|
1235
|
+
return r?.forEach((a) => {
|
|
1235
1236
|
const o = a;
|
|
1236
|
-
o.featureEffect && (o.featureEffect = null,
|
|
1237
|
-
}),
|
|
1238
|
-
},
|
|
1239
|
-
const { mapView:
|
|
1240
|
-
return
|
|
1241
|
-
},
|
|
1237
|
+
o.featureEffect && (o.featureEffect = null, t++);
|
|
1238
|
+
}), t > 0 ? `Cleared filters from ${t} layer(s). View unchanged.` : "No active filters to clear. View unchanged.";
|
|
1239
|
+
}, Zr = async (e, r) => {
|
|
1240
|
+
const { mapView: t } = N(r);
|
|
1241
|
+
return Jr(t);
|
|
1242
|
+
}, Yr = w(Zr, {
|
|
1242
1243
|
name: "clearFilters",
|
|
1243
1244
|
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.",
|
|
1244
|
-
schema:
|
|
1245
|
-
}),
|
|
1245
|
+
schema: s.object({})
|
|
1246
|
+
}), Xr = async (e) => {
|
|
1246
1247
|
e.map?.allLayers.filter((o) => o.type === "feature")?.forEach((o) => {
|
|
1247
1248
|
const n = o;
|
|
1248
1249
|
n.featureEffect && (n.featureEffect = null);
|
|
1249
1250
|
});
|
|
1250
1251
|
const a = e.map.initialViewProperties?.viewpoint?.targetGeometry;
|
|
1251
1252
|
return a ? (await e.goTo(a), "Cleared all filters and returned to home extent.") : "Cleared all filters. Could not determine home extent.";
|
|
1252
|
-
},
|
|
1253
|
-
const { mapView:
|
|
1254
|
-
return await
|
|
1255
|
-
},
|
|
1253
|
+
}, ea = async (e, r) => {
|
|
1254
|
+
const { mapView: t } = N(r);
|
|
1255
|
+
return await Xr(t);
|
|
1256
|
+
}, ta = w(ea, {
|
|
1256
1257
|
name: "resetMap",
|
|
1257
1258
|
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.",
|
|
1258
|
-
schema:
|
|
1259
|
-
}),
|
|
1260
|
-
function
|
|
1259
|
+
schema: s.object({})
|
|
1260
|
+
}), we = 750;
|
|
1261
|
+
function B(e) {
|
|
1261
1262
|
return "point" in e && e.point !== void 0;
|
|
1262
1263
|
}
|
|
1263
|
-
function
|
|
1264
|
+
function L(e) {
|
|
1264
1265
|
return "layerId" in e && e.layerId !== void 0;
|
|
1265
1266
|
}
|
|
1266
|
-
const
|
|
1267
|
-
if (
|
|
1268
|
-
const { point:
|
|
1269
|
-
return { geometry: new
|
|
1270
|
-
x:
|
|
1271
|
-
y:
|
|
1272
|
-
spatialReference:
|
|
1267
|
+
const J = async (e, r) => {
|
|
1268
|
+
if (B(e)) {
|
|
1269
|
+
const { point: t } = e;
|
|
1270
|
+
return { geometry: new Te({
|
|
1271
|
+
x: t.x,
|
|
1272
|
+
y: t.y,
|
|
1273
|
+
spatialReference: t.spatialReference ? { wkid: t.spatialReference.wkid } : r.spatialReference
|
|
1273
1274
|
}) };
|
|
1274
1275
|
}
|
|
1275
|
-
if (
|
|
1276
|
-
const
|
|
1276
|
+
if (L(e)) {
|
|
1277
|
+
const t = r.map?.allLayers.find(
|
|
1277
1278
|
(n) => n.id === e.layerId
|
|
1278
1279
|
);
|
|
1279
|
-
if (!
|
|
1280
|
+
if (!t)
|
|
1280
1281
|
return { error: `Could not find geometry layer with ID: ${e.layerId}` };
|
|
1281
|
-
const a =
|
|
1282
|
+
const a = t.title ?? t.id, o = e.where?.trim() || "1=1";
|
|
1282
1283
|
try {
|
|
1283
|
-
const n = await
|
|
1284
|
+
const n = await t.queryFeatures({
|
|
1284
1285
|
where: o,
|
|
1285
1286
|
returnGeometry: !0,
|
|
1286
|
-
outSpatialReference:
|
|
1287
|
-
num:
|
|
1287
|
+
outSpatialReference: r.spatialReference,
|
|
1288
|
+
num: we + 1
|
|
1288
1289
|
});
|
|
1289
1290
|
if (!n.features.length)
|
|
1290
1291
|
return {
|
|
1291
1292
|
error: `No features found in geometry layer "${a}" with the specified where clause: ${o}`
|
|
1292
1293
|
};
|
|
1293
|
-
if (n.features.length >
|
|
1294
|
+
if (n.features.length > we)
|
|
1294
1295
|
return {
|
|
1295
1296
|
error: `Geometry filter for layer "${a}" matched too many features (${n.features.length}+). Please narrow the geometry layer filter.`
|
|
1296
1297
|
};
|
|
1297
1298
|
const l = n.features.map((c) => c.geometry).filter((c) => !!c);
|
|
1298
1299
|
if (!l.length)
|
|
1299
1300
|
return { error: "No valid geometries found for the matched geometry layer features." };
|
|
1300
|
-
const
|
|
1301
|
-
return
|
|
1301
|
+
const i = l.length === 1 ? l[0] : st.executeMany(l);
|
|
1302
|
+
return i ? (i.spatialReference || (i.spatialReference = r.spatialReference), { geometry: i }) : { error: "Failed to combine geometries from geometry layer." };
|
|
1302
1303
|
} catch (n) {
|
|
1303
1304
|
return { error: `Failed to query geometry: ${String(n)}` };
|
|
1304
1305
|
}
|
|
1305
1306
|
}
|
|
1306
1307
|
return { error: "Invalid geometry configuration provided" };
|
|
1307
|
-
},
|
|
1308
|
-
const l = e.map?.allLayers.find((c) => c.id ===
|
|
1308
|
+
}, ra = async (e, r, t, a, o, n) => {
|
|
1309
|
+
const l = e.map?.allLayers.find((c) => c.id === r);
|
|
1309
1310
|
if (!l)
|
|
1310
|
-
return { success: !1, error: `Layer '${
|
|
1311
|
-
const
|
|
1312
|
-
|
|
1311
|
+
return { success: !1, error: `Layer '${r}' not found.` };
|
|
1312
|
+
const i = l.createQuery();
|
|
1313
|
+
i.where = t ?? "1=1", a && (i.geometry = a, i.spatialRelationship = "intersects", o && (i.distance = o), n && (i.units = n));
|
|
1313
1314
|
try {
|
|
1314
|
-
const { extent: c, count: u } = await l.queryExtent(
|
|
1315
|
+
const { extent: c, count: u } = await l.queryExtent(i);
|
|
1315
1316
|
return !c || u === 0 ? {
|
|
1316
1317
|
success: !1,
|
|
1317
|
-
error: `No features found for filter (where: ${
|
|
1318
|
+
error: `No features found for filter (where: ${i.where}${a ? ", spatial filter used" : ""})`
|
|
1318
1319
|
} : (await e.goTo(c), { success: !0 });
|
|
1319
1320
|
} catch (c) {
|
|
1320
1321
|
return {
|
|
@@ -1322,351 +1323,351 @@ const H = async (e, t) => {
|
|
|
1322
1323
|
error: c instanceof Error ? c.message : String(c)
|
|
1323
1324
|
};
|
|
1324
1325
|
}
|
|
1325
|
-
},
|
|
1326
|
-
const l =
|
|
1326
|
+
}, aa = async (e, r, t, a, o, n) => {
|
|
1327
|
+
const l = r.map?.allLayers.find(
|
|
1327
1328
|
(p) => p.id === e.layerId
|
|
1328
1329
|
);
|
|
1329
1330
|
if (!l)
|
|
1330
1331
|
return `Could not find target layer with ID: ${e.layerId}`;
|
|
1331
|
-
let
|
|
1332
|
+
let i;
|
|
1332
1333
|
if (o) {
|
|
1333
|
-
const p = await
|
|
1334
|
+
const p = await J(o, r);
|
|
1334
1335
|
if ("error" in p)
|
|
1335
1336
|
return p.error;
|
|
1336
|
-
|
|
1337
|
+
i = p.geometry;
|
|
1337
1338
|
}
|
|
1338
|
-
if (l.featureEffect = null, l.featureEffect = new
|
|
1339
|
-
filter: new
|
|
1339
|
+
if (l.featureEffect = null, l.featureEffect = new it({
|
|
1340
|
+
filter: new ve({
|
|
1340
1341
|
...e.objectIds?.length ? { objectIds: e.objectIds } : { where: e.where },
|
|
1341
|
-
geometry:
|
|
1342
|
+
geometry: i,
|
|
1342
1343
|
spatialRelationship: "intersects",
|
|
1343
1344
|
distance: o?.distance,
|
|
1344
1345
|
units: o?.units
|
|
1345
1346
|
}),
|
|
1346
|
-
includedEffect:
|
|
1347
|
+
includedEffect: t,
|
|
1347
1348
|
excludedEffect: a
|
|
1348
1349
|
}), l.visible = !0, n)
|
|
1349
1350
|
return `Applied feature effects to "${l.title ?? e.layerId}" within current map extent.`;
|
|
1350
|
-
const c = e.objectIds?.length ? `${l.objectIdField} IN (${e.objectIds.join(",")})` : e.where, u = await
|
|
1351
|
-
|
|
1351
|
+
const c = e.objectIds?.length ? `${l.objectIdField} IN (${e.objectIds.join(",")})` : e.where, u = await ra(
|
|
1352
|
+
r,
|
|
1352
1353
|
e.layerId,
|
|
1353
1354
|
c,
|
|
1354
|
-
|
|
1355
|
+
i,
|
|
1355
1356
|
o?.distance,
|
|
1356
1357
|
o?.units
|
|
1357
1358
|
), d = l.title ?? e.layerId;
|
|
1358
1359
|
return u.success ? `Applied feature effects to target layer "${l.title ?? e.layerId}"${o && "layerId" in o ? ` using geometry from layer "${o.layerId}"` : ""}.` : `Applied filter to "${d}" but no features matched. ${u.error}`;
|
|
1359
|
-
},
|
|
1360
|
+
}, oa = ["feet", "kilometers", "meters", "miles", "nautical-miles", "us-nautical-miles"], F = s.enum(oa), na = async ({
|
|
1360
1361
|
targetLayer: e,
|
|
1361
|
-
geometryFilter:
|
|
1362
|
-
useCurrentExtent:
|
|
1362
|
+
geometryFilter: r,
|
|
1363
|
+
useCurrentExtent: t,
|
|
1363
1364
|
includedEffect: a = "drop-shadow(2px, 2px, 2px, gray)",
|
|
1364
1365
|
excludedEffect: o = "grayscale(100%) opacity(60%) blur(2px)"
|
|
1365
1366
|
}, n) => {
|
|
1366
|
-
const { mapView: l } =
|
|
1367
|
-
return await
|
|
1368
|
-
},
|
|
1369
|
-
layerId:
|
|
1370
|
-
where:
|
|
1371
|
-
distance:
|
|
1372
|
-
units:
|
|
1373
|
-
}),
|
|
1374
|
-
point:
|
|
1375
|
-
x:
|
|
1376
|
-
y:
|
|
1377
|
-
spatialReference:
|
|
1378
|
-
wkid:
|
|
1367
|
+
const { mapView: l } = N(n);
|
|
1368
|
+
return await aa(e, l, a, o, r, t);
|
|
1369
|
+
}, ia = s.object({
|
|
1370
|
+
layerId: s.string().describe("The layerId of the layer containing the geometry by which to filter."),
|
|
1371
|
+
where: s.string().describe("The SQL-92 where clause representing the features from which to filter."),
|
|
1372
|
+
distance: s.number().optional().describe("The buffer distance around the geometry."),
|
|
1373
|
+
units: F.optional().describe("The units for the distance buffer.")
|
|
1374
|
+
}), sa = s.object({
|
|
1375
|
+
point: s.object({
|
|
1376
|
+
x: s.number().describe("X coordinate (longitude) from navigation result"),
|
|
1377
|
+
y: s.number().describe("Y coordinate (latitude) from navigation result"),
|
|
1378
|
+
spatialReference: s.object({
|
|
1379
|
+
wkid: s.number().describe("Spatial reference WKID (e.g., 4326 for WGS84)")
|
|
1379
1380
|
}).optional().describe("Spatial reference. Defaults to map's spatial reference if not provided.")
|
|
1380
1381
|
}).describe("Point coordinates from a previous navigation/geocoding result"),
|
|
1381
|
-
distance:
|
|
1382
|
-
units:
|
|
1383
|
-
}),
|
|
1384
|
-
targetLayer:
|
|
1385
|
-
layerId:
|
|
1386
|
-
where:
|
|
1387
|
-
objectIds:
|
|
1382
|
+
distance: s.number().optional().describe("Optional buffer distance around the point."),
|
|
1383
|
+
units: F.optional().describe("The units for the distance buffer.")
|
|
1384
|
+
}), la = s.object({
|
|
1385
|
+
targetLayer: s.object({
|
|
1386
|
+
layerId: s.string().describe("The layerId of the layer on which to set a feature effect."),
|
|
1387
|
+
where: s.string().describe("The SQL-92 where clause representing the features to emphasize."),
|
|
1388
|
+
objectIds: s.array(s.number()).optional().describe(
|
|
1388
1389
|
"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."
|
|
1389
1390
|
)
|
|
1390
1391
|
}),
|
|
1391
|
-
geometryFilter:
|
|
1392
|
-
useCurrentExtent:
|
|
1392
|
+
geometryFilter: s.union([ia, sa]).optional().describe("Optional geometry-based filtering parameters for spatial queries."),
|
|
1393
|
+
useCurrentExtent: s.boolean().optional().describe(
|
|
1393
1394
|
"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."
|
|
1394
1395
|
),
|
|
1395
|
-
includedEffect:
|
|
1396
|
+
includedEffect: s.string().default("drop-shadow(2px, 2px, 2px, gray)").describe(
|
|
1396
1397
|
"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."
|
|
1397
1398
|
),
|
|
1398
|
-
excludedEffect:
|
|
1399
|
+
excludedEffect: s.string().default("grayscale(100%) opacity(60%) blur(2px)").describe(
|
|
1399
1400
|
"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."
|
|
1400
1401
|
)
|
|
1401
|
-
}),
|
|
1402
|
+
}), ca = w(na, {
|
|
1402
1403
|
name: "setFeatureEffect",
|
|
1403
1404
|
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.",
|
|
1404
|
-
schema:
|
|
1405
|
-
}),
|
|
1405
|
+
schema: la
|
|
1406
|
+
}), te = (e) => {
|
|
1406
1407
|
if (e instanceof Date)
|
|
1407
1408
|
return Number.isNaN(e.getTime()) ? null : e;
|
|
1408
1409
|
if (typeof e == "number" && Number.isFinite(e)) {
|
|
1409
|
-
const
|
|
1410
|
-
return Number.isNaN(
|
|
1410
|
+
const r = new Date(e);
|
|
1411
|
+
return Number.isNaN(r.getTime()) ? null : r;
|
|
1411
1412
|
}
|
|
1412
1413
|
return null;
|
|
1413
|
-
},
|
|
1414
|
+
}, ua = (e) => !e || e === "system" ? Intl.DateTimeFormat().resolvedOptions().timeZone : e === "unknown" ? "UTC" : e, da = (e) => {
|
|
1414
1415
|
if (typeof e == "string" && e)
|
|
1415
1416
|
return e;
|
|
1416
|
-
const
|
|
1417
|
-
return
|
|
1418
|
-
},
|
|
1419
|
-
const e = (/* @__PURE__ */ new Date()).getTimezoneOffset(),
|
|
1417
|
+
const r = te(e);
|
|
1418
|
+
return r ? r.toISOString().slice(0, 10) : null;
|
|
1419
|
+
}, Hn = () => {
|
|
1420
|
+
const e = (/* @__PURE__ */ new Date()).getTimezoneOffset(), r = e <= 0 ? "+" : "-", t = Math.floor(Math.abs(e) / 60).toString().padStart(2, "0"), a = (Math.abs(e) % 60).toString().padStart(2, "0"), o = `${r}${t}:${a}`;
|
|
1420
1421
|
return { userTimezone: Intl.DateTimeFormat().resolvedOptions().timeZone, userTimezoneOffset: o };
|
|
1421
|
-
},
|
|
1422
|
-
const a =
|
|
1422
|
+
}, pa = (e, r, t) => {
|
|
1423
|
+
const a = r?.toLowerCase();
|
|
1423
1424
|
if (a === "date-only") {
|
|
1424
|
-
const n =
|
|
1425
|
-
return n ?
|
|
1425
|
+
const n = da(e);
|
|
1426
|
+
return n ? lt(n, _("short-date")) : e;
|
|
1426
1427
|
}
|
|
1427
1428
|
if (a === "time-only") {
|
|
1428
1429
|
if (typeof e == "string" && e)
|
|
1429
|
-
return
|
|
1430
|
-
const n =
|
|
1431
|
-
return n ?
|
|
1432
|
-
...
|
|
1430
|
+
return ct(e, _("long-time"));
|
|
1431
|
+
const n = te(e);
|
|
1432
|
+
return n ? ye(n, {
|
|
1433
|
+
..._("long-time"),
|
|
1433
1434
|
timeZone: "UTC"
|
|
1434
1435
|
}) : e;
|
|
1435
1436
|
}
|
|
1436
|
-
const o =
|
|
1437
|
-
return o ?
|
|
1438
|
-
...
|
|
1439
|
-
timeZone:
|
|
1437
|
+
const o = te(e);
|
|
1438
|
+
return o ? ye(o, {
|
|
1439
|
+
..._("short-date-short-time"),
|
|
1440
|
+
timeZone: ua(t)
|
|
1440
1441
|
}) : e;
|
|
1441
|
-
},
|
|
1442
|
+
}, Re = (e, r, t) => {
|
|
1442
1443
|
if (e && typeof e != "function") {
|
|
1443
|
-
const a = "getField" in
|
|
1444
|
+
const a = "getField" in t && t.getField?.(e), o = a && "getFieldDomain" in t && t.getFieldDomain ? t.getFieldDomain(a.name) : null;
|
|
1444
1445
|
if (o?.type === "coded-value") {
|
|
1445
|
-
const l = o.codedValues.find((
|
|
1446
|
+
const l = o.codedValues.find((i) => i.code === r);
|
|
1446
1447
|
return l ? l.name : null;
|
|
1447
1448
|
}
|
|
1448
1449
|
}
|
|
1449
1450
|
return null;
|
|
1450
|
-
},
|
|
1451
|
+
}, ha = (e) => !e || e === "system" ? Intl.DateTimeFormat().resolvedOptions().timeZone : e === "unknown" ? "UTC" : e, ma = (e) => {
|
|
1451
1452
|
if (e instanceof Date)
|
|
1452
1453
|
return Number.isNaN(e.getTime()) ? null : e;
|
|
1453
1454
|
if (typeof e == "number" && Number.isFinite(e)) {
|
|
1454
|
-
const
|
|
1455
|
-
return Number.isNaN(
|
|
1455
|
+
const r = new Date(e);
|
|
1456
|
+
return Number.isNaN(r.getTime()) ? null : r;
|
|
1456
1457
|
}
|
|
1457
1458
|
if (typeof e == "string" && e) {
|
|
1458
|
-
const
|
|
1459
|
-
return Number.isNaN(
|
|
1459
|
+
const r = new Date(e);
|
|
1460
|
+
return Number.isNaN(r.getTime()) ? null : r;
|
|
1460
1461
|
}
|
|
1461
1462
|
return null;
|
|
1462
|
-
},
|
|
1463
|
+
}, ya = (e, r) => {
|
|
1463
1464
|
if (typeof e != "number")
|
|
1464
1465
|
return e;
|
|
1465
|
-
const
|
|
1466
|
-
|
|
1466
|
+
const t = {};
|
|
1467
|
+
r.minimumFractionDigits !== void 0 && (t.minimumFractionDigits = r.minimumFractionDigits), r.maximumFractionDigits !== void 0 && (t.maximumFractionDigits = r.maximumFractionDigits), r.useGrouping === "always" ? t.useGrouping = !0 : r.useGrouping === "never" && (t.useGrouping = !1);
|
|
1467
1468
|
try {
|
|
1468
|
-
return new Intl.NumberFormat(void 0,
|
|
1469
|
+
return new Intl.NumberFormat(void 0, t).format(e);
|
|
1469
1470
|
} catch {
|
|
1470
1471
|
return e;
|
|
1471
1472
|
}
|
|
1472
|
-
},
|
|
1473
|
-
const a =
|
|
1473
|
+
}, fa = (e, r, t) => {
|
|
1474
|
+
const a = ma(e);
|
|
1474
1475
|
if (!a)
|
|
1475
1476
|
return e;
|
|
1476
1477
|
const o = {};
|
|
1477
|
-
|
|
1478
|
+
r.dateStyle ? o.dateStyle = r.dateStyle : (r.year && (o.year = r.year), r.month && (o.month = r.month)), r.timeStyle && (o.timeStyle = r.timeStyle), r.timeStyle && r.hour12 === "always" ? o.hour12 = !0 : r.timeStyle && r.hour12 === "never" && (o.hour12 = !1), o.timeZone = ha(t);
|
|
1478
1479
|
try {
|
|
1479
1480
|
return new Intl.DateTimeFormat(void 0, o).format(a);
|
|
1480
1481
|
} catch {
|
|
1481
1482
|
return e;
|
|
1482
1483
|
}
|
|
1483
|
-
},
|
|
1484
|
-
if (
|
|
1485
|
-
return
|
|
1486
|
-
const l = e.getFieldConfiguration?.(
|
|
1487
|
-
return l?.type === "number" ?
|
|
1488
|
-
},
|
|
1489
|
-
const o = e.fieldsIndex?.get(
|
|
1490
|
-
return
|
|
1491
|
-
},
|
|
1492
|
-
const a = e.objectIdField, o =
|
|
1484
|
+
}, $e = (e, r) => e.getFieldAlias?.(r) ?? e.fieldsIndex?.get(r)?.alias ?? e.fieldsIndex?.get(r)?.name ?? r, Ce = (e, r, t, a, o) => {
|
|
1485
|
+
if (t == null)
|
|
1486
|
+
return t;
|
|
1487
|
+
const l = e.getFieldConfiguration?.(r)?.fieldFormat;
|
|
1488
|
+
return l?.type === "number" ? ya(t, l) : l?.type === "date-time" ? fa(t, l, o) : pa(t, a, o);
|
|
1489
|
+
}, ga = (e, r, t, a) => {
|
|
1490
|
+
const o = e.fieldsIndex?.get(r), n = Re(r, t, e) ?? t;
|
|
1491
|
+
return Ce(e, r, n, o?.type, a);
|
|
1492
|
+
}, wa = (e, r) => $e(e, r), Ee = (e, r, t) => {
|
|
1493
|
+
const a = e.objectIdField, o = r.features.map(
|
|
1493
1494
|
(l) => l.attributes[a]
|
|
1494
|
-
), n =
|
|
1495
|
-
const
|
|
1495
|
+
), n = r.features.map((l) => {
|
|
1496
|
+
const i = l.attributes, c = {};
|
|
1496
1497
|
return e.fields.forEach((u) => {
|
|
1497
|
-
if (!Object.hasOwn(
|
|
1498
|
+
if (!Object.hasOwn(i, u.name))
|
|
1498
1499
|
return;
|
|
1499
|
-
const d =
|
|
1500
|
+
const d = i[u.name];
|
|
1500
1501
|
if (u.name === a) {
|
|
1501
1502
|
c[u.name] = d;
|
|
1502
1503
|
return;
|
|
1503
1504
|
}
|
|
1504
|
-
const p =
|
|
1505
|
-
c[h] =
|
|
1505
|
+
const p = Re(u.name, d, e) ?? d, h = $e(e, u.name);
|
|
1506
|
+
c[h] = Ce(e, u.name, p, u.type, t);
|
|
1506
1507
|
}), c;
|
|
1507
1508
|
});
|
|
1508
1509
|
return { objectIds: o, attributes: n };
|
|
1509
|
-
},
|
|
1510
|
+
}, ba = (e, r, t) => {
|
|
1510
1511
|
const a = e.createQuery();
|
|
1511
|
-
return a.outFields = [
|
|
1512
|
-
},
|
|
1513
|
-
const o = a.map?.allLayers.find((h) => h.id === e), n =
|
|
1512
|
+
return a.outFields = [r], a.where = t || "1=1", a.num = 1, a;
|
|
1513
|
+
}, Ta = async (e, r, t, a) => {
|
|
1514
|
+
const o = a.map?.allLayers.find((h) => h.id === e), n = ba(o, r, t.where), i = (await o.queryFeatures(n)).features[0], c = i ? i.attributes[r] : null, u = ga(o, r, c, a.timeZone), d = wa(o, r);
|
|
1514
1515
|
return {
|
|
1515
1516
|
tool: "getAttribute",
|
|
1516
1517
|
layerName: o.title ?? e,
|
|
1517
1518
|
summary: `${d} = ${u}`,
|
|
1518
1519
|
details: {
|
|
1519
|
-
fieldName:
|
|
1520
|
-
fieldAlias: d !==
|
|
1520
|
+
fieldName: r,
|
|
1521
|
+
fieldAlias: d !== r ? d : void 0,
|
|
1521
1522
|
value: u,
|
|
1522
|
-
where:
|
|
1523
|
+
where: t.where
|
|
1523
1524
|
}
|
|
1524
1525
|
};
|
|
1525
1526
|
};
|
|
1526
|
-
async function
|
|
1527
|
-
const { mapView: o } =
|
|
1527
|
+
async function va({ layerId: e, fieldName: r, query: t }, a) {
|
|
1528
|
+
const { mapView: o } = N(a), n = await Ta(e, r, t, o);
|
|
1528
1529
|
return JSON.stringify(n, null, 2);
|
|
1529
1530
|
}
|
|
1530
|
-
const
|
|
1531
|
-
layerId:
|
|
1532
|
-
fieldName:
|
|
1533
|
-
query:
|
|
1534
|
-
where:
|
|
1531
|
+
const Sa = s.object({
|
|
1532
|
+
layerId: s.string().describe("The layerId of the layer containing the field from which to get a value."),
|
|
1533
|
+
fieldName: s.string().describe("The name of the field/attribute from which to get a field value."),
|
|
1534
|
+
query: s.object({
|
|
1535
|
+
where: s.string().describe("The SQL-92 where clause representing the feature from which to get an attribute value.")
|
|
1535
1536
|
})
|
|
1536
|
-
}),
|
|
1537
|
+
}), xa = w(va, {
|
|
1537
1538
|
name: "getAttribute",
|
|
1538
1539
|
description: "Returns an attribute value for a given feature.",
|
|
1539
|
-
schema:
|
|
1540
|
-
}),
|
|
1541
|
-
function K(e,
|
|
1542
|
-
let
|
|
1543
|
-
return
|
|
1544
|
-
}
|
|
1545
|
-
const
|
|
1546
|
-
const { targetLayer:
|
|
1547
|
-
if (!
|
|
1548
|
-
throw new Error(`Layer '${
|
|
1549
|
-
const c = await o.whenLayerView(
|
|
1540
|
+
schema: Sa
|
|
1541
|
+
}), le = (e, r, t) => t ? e.hasAllFeaturesInView && e.availableFields === r : e.hasAllFeatures && e.availableFields === r;
|
|
1542
|
+
function K(e, r) {
|
|
1543
|
+
let t = e ?? "";
|
|
1544
|
+
return r != null && r && (t = t ? `(${t}) AND (${r})` : r), t || null;
|
|
1545
|
+
}
|
|
1546
|
+
const Ra = async (e) => {
|
|
1547
|
+
const { targetLayer: r, fieldName: t, statisticType: a, mapView: o, layersAndFieldsRegistry: n, geometryFilter: l } = e, i = o.map?.allLayers.find((v) => v.id === r.layerId);
|
|
1548
|
+
if (!i)
|
|
1549
|
+
throw new Error(`Layer '${r.layerId}' not found.`);
|
|
1550
|
+
const c = await o.whenLayerView(i), d = n.get(r.layerId)?.fieldRegistry.get(t), p = d?.alias;
|
|
1550
1551
|
if (!d)
|
|
1551
|
-
throw new Error(`Field '${
|
|
1552
|
-
let h,
|
|
1552
|
+
throw new Error(`Field '${t}' not found.`);
|
|
1553
|
+
let h, f;
|
|
1553
1554
|
if (l) {
|
|
1554
|
-
const v = await
|
|
1555
|
+
const v = await J(l, o);
|
|
1555
1556
|
if ("error" in v)
|
|
1556
1557
|
throw new Error(v.error);
|
|
1557
1558
|
if (!v.geometry)
|
|
1558
|
-
throw
|
|
1559
|
-
if (
|
|
1560
|
-
const
|
|
1559
|
+
throw L(l) ? new Error(`No features found matching: ${l.where}`) : new Error("Failed to create geometry");
|
|
1560
|
+
if (L(l)) {
|
|
1561
|
+
const Q = o.map?.allLayers.find((A) => A.id === l.layerId);
|
|
1561
1562
|
h = {
|
|
1562
|
-
geometryLayerName:
|
|
1563
|
+
geometryLayerName: Q?.title ?? Q?.id,
|
|
1563
1564
|
geometryLayerId: l.layerId,
|
|
1564
1565
|
geometryWhere: l.where,
|
|
1565
1566
|
distance: l.distance,
|
|
1566
1567
|
units: l.units,
|
|
1567
1568
|
applied: !0
|
|
1568
1569
|
};
|
|
1569
|
-
} else
|
|
1570
|
+
} else B(l) && (h = {
|
|
1570
1571
|
point: l.point,
|
|
1571
1572
|
distance: l.distance,
|
|
1572
1573
|
units: l.units,
|
|
1573
1574
|
applied: !0
|
|
1574
1575
|
});
|
|
1575
|
-
|
|
1576
|
+
f = new ve({
|
|
1576
1577
|
geometry: v.geometry,
|
|
1577
1578
|
distance: l.distance,
|
|
1578
1579
|
units: l.units,
|
|
1579
1580
|
spatialRelationship: "intersects"
|
|
1580
1581
|
});
|
|
1581
1582
|
}
|
|
1582
|
-
const
|
|
1583
|
-
let m = null,
|
|
1583
|
+
const y = le(c, [t], !1);
|
|
1584
|
+
let m = null, g = null;
|
|
1584
1585
|
const T = 10;
|
|
1585
1586
|
if (d.type !== "geometry" && d.type !== "oid" && d.type !== "global-id")
|
|
1586
1587
|
try {
|
|
1587
1588
|
const v = {
|
|
1588
|
-
layer:
|
|
1589
|
-
useFeaturesInView:
|
|
1590
|
-
view:
|
|
1591
|
-
field:
|
|
1592
|
-
sqlWhere: K(
|
|
1593
|
-
...
|
|
1589
|
+
layer: i,
|
|
1590
|
+
useFeaturesInView: y,
|
|
1591
|
+
view: y ? o : void 0,
|
|
1592
|
+
field: t,
|
|
1593
|
+
sqlWhere: K(i.definitionExpression, r.where),
|
|
1594
|
+
...f && { filter: f },
|
|
1594
1595
|
outStatisticTypes: { include: [a] }
|
|
1595
1596
|
};
|
|
1596
|
-
m = await
|
|
1597
|
-
const
|
|
1598
|
-
(
|
|
1599
|
-
layer:
|
|
1600
|
-
useFeaturesInView:
|
|
1601
|
-
view:
|
|
1602
|
-
field:
|
|
1603
|
-
sqlWhere: K(
|
|
1604
|
-
...
|
|
1605
|
-
})).uniqueValueInfos.sort((
|
|
1606
|
-
...
|
|
1607
|
-
value:
|
|
1597
|
+
m = await ut(v);
|
|
1598
|
+
const Q = ["string", "small-integer", "integer"], A = d.domain?.type === "coded-value" ? d.domain : null;
|
|
1599
|
+
(Q.includes(d.type) || A) && (g = (await dt({
|
|
1600
|
+
layer: i,
|
|
1601
|
+
useFeaturesInView: y,
|
|
1602
|
+
view: y ? o : void 0,
|
|
1603
|
+
field: t,
|
|
1604
|
+
sqlWhere: K(i.definitionExpression, r.where),
|
|
1605
|
+
...f && { filter: f }
|
|
1606
|
+
})).uniqueValueInfos.sort((I, ze) => ze.count - I.count).slice(0, T)), g && d.domain?.type === "coded-value" && (g = g.map((I) => ({
|
|
1607
|
+
...I,
|
|
1608
|
+
value: A ? A.getName(I.value) ?? I.value : I.value
|
|
1608
1609
|
})));
|
|
1609
1610
|
} catch (v) {
|
|
1610
1611
|
console.error("Statistics error:", v);
|
|
1611
1612
|
}
|
|
1612
1613
|
return {
|
|
1613
1614
|
tool: "getStatistics",
|
|
1614
|
-
layerName:
|
|
1615
|
+
layerName: i.title ?? r.layerId,
|
|
1615
1616
|
summary: `${a} = ${typeof m?.[a] == "number" ? m[a] : "N/A"}`,
|
|
1616
1617
|
details: {
|
|
1617
|
-
fieldName:
|
|
1618
|
+
fieldName: t,
|
|
1618
1619
|
fieldAlias: p,
|
|
1619
1620
|
statisticType: a,
|
|
1620
1621
|
statistic: m?.[a] ?? null,
|
|
1621
1622
|
summaryStatistics: m,
|
|
1622
|
-
uniqueValues:
|
|
1623
|
-
where:
|
|
1623
|
+
uniqueValues: g,
|
|
1624
|
+
where: r.where,
|
|
1624
1625
|
spatialFilterInfo: h
|
|
1625
1626
|
}
|
|
1626
1627
|
};
|
|
1627
1628
|
};
|
|
1628
|
-
async function
|
|
1629
|
+
async function $a({
|
|
1629
1630
|
targetLayer: e,
|
|
1630
|
-
fieldName:
|
|
1631
|
-
statisticType:
|
|
1631
|
+
fieldName: r,
|
|
1632
|
+
statisticType: t,
|
|
1632
1633
|
geometryFilter: a
|
|
1633
1634
|
}, o) {
|
|
1634
|
-
const n =
|
|
1635
|
+
const n = xe(o, "layersAndFieldsRegistry"), { mapView: l } = N(o), i = await Ra({
|
|
1635
1636
|
targetLayer: e,
|
|
1636
|
-
fieldName:
|
|
1637
|
-
statisticType:
|
|
1637
|
+
fieldName: r,
|
|
1638
|
+
statisticType: t,
|
|
1638
1639
|
mapView: l,
|
|
1639
1640
|
layersAndFieldsRegistry: n,
|
|
1640
1641
|
geometryFilter: a
|
|
1641
1642
|
});
|
|
1642
|
-
return JSON.stringify(
|
|
1643
|
-
}
|
|
1644
|
-
const
|
|
1645
|
-
layerId:
|
|
1646
|
-
where:
|
|
1647
|
-
distance:
|
|
1648
|
-
units:
|
|
1649
|
-
}),
|
|
1650
|
-
point:
|
|
1651
|
-
x:
|
|
1652
|
-
y:
|
|
1653
|
-
spatialReference:
|
|
1654
|
-
wkid:
|
|
1643
|
+
return JSON.stringify(i, null, 2);
|
|
1644
|
+
}
|
|
1645
|
+
const Ca = s.object({
|
|
1646
|
+
layerId: s.string().describe("The layerId of the layer containing the geometry by which to filter."),
|
|
1647
|
+
where: s.string().describe("The SQL-92 where clause representing the features from which to filter."),
|
|
1648
|
+
distance: s.number().optional().describe("The buffer distance around the geometry."),
|
|
1649
|
+
units: F.optional().describe("The units for the distance buffer.")
|
|
1650
|
+
}), Ea = s.object({
|
|
1651
|
+
point: s.object({
|
|
1652
|
+
x: s.number().describe("X coordinate (longitude) from navigation result"),
|
|
1653
|
+
y: s.number().describe("Y coordinate (latitude) from navigation result"),
|
|
1654
|
+
spatialReference: s.object({
|
|
1655
|
+
wkid: s.number().describe("Spatial reference WKID (e.g., 4326 for WGS84)")
|
|
1655
1656
|
}).optional().describe("Spatial reference. Defaults to map's spatial reference if not provided.")
|
|
1656
1657
|
}).describe("Point coordinates from a previous navigation/geocoding result"),
|
|
1657
|
-
distance:
|
|
1658
|
-
units:
|
|
1659
|
-
}),
|
|
1660
|
-
targetLayer:
|
|
1661
|
-
layerId:
|
|
1662
|
-
where:
|
|
1658
|
+
distance: s.number().optional().describe("Optional buffer distance around the point."),
|
|
1659
|
+
units: F.optional().describe("The units for the distance buffer.")
|
|
1660
|
+
}), Fa = s.object({
|
|
1661
|
+
targetLayer: s.object({
|
|
1662
|
+
layerId: s.string().describe("The layerId of the layer containing the field from which to get a value."),
|
|
1663
|
+
where: s.string().describe("The SQL-92 where clause representing the feature from which to get an attribute value.")
|
|
1663
1664
|
}),
|
|
1664
|
-
geometryFilter:
|
|
1665
|
+
geometryFilter: s.union([Ca, Ea]).optional().describe(
|
|
1665
1666
|
"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."
|
|
1666
1667
|
),
|
|
1667
|
-
fieldName:
|
|
1668
|
-
statisticType:
|
|
1669
|
-
}),
|
|
1668
|
+
fieldName: s.string().describe("The name of the field for which to get statistics. STRICTLY DO NOT use OBJECTID. Use any other field"),
|
|
1669
|
+
statisticType: s.enum(["avg", "max", "median", "min", "stddev", "sum", "variance", "nullcount", "count"]).describe("The statistic type to calculate.")
|
|
1670
|
+
}), ka = w($a, {
|
|
1670
1671
|
name: "getStatistics",
|
|
1671
1672
|
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.
|
|
1672
1673
|
|
|
@@ -1681,35 +1682,35 @@ DO NOT USE FOR:
|
|
|
1681
1682
|
- Simple counts of features matching a condition — use queryFeatures instead
|
|
1682
1683
|
|
|
1683
1684
|
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.`,
|
|
1684
|
-
schema:
|
|
1685
|
-
}),
|
|
1686
|
-
const n =
|
|
1685
|
+
schema: Fa
|
|
1686
|
+
}), Na = async (e, r, t, a, o) => {
|
|
1687
|
+
const n = t.map?.allLayers.find((h) => h.id === e.layerId), l = await t.whenLayerView(n), i = n.title ?? e.layerId;
|
|
1687
1688
|
let c;
|
|
1688
1689
|
if (a) {
|
|
1689
|
-
const h = await
|
|
1690
|
+
const h = await J(a, t);
|
|
1690
1691
|
if ("error" in h)
|
|
1691
1692
|
return {
|
|
1692
1693
|
tool: "getTopFeatures",
|
|
1693
|
-
layerName:
|
|
1694
|
+
layerName: i,
|
|
1694
1695
|
summary: "Geometry lookup failed",
|
|
1695
1696
|
details: { error: h.error }
|
|
1696
1697
|
};
|
|
1697
1698
|
if (!h.geometry)
|
|
1698
1699
|
return {
|
|
1699
1700
|
tool: "getTopFeatures",
|
|
1700
|
-
layerName:
|
|
1701
|
+
layerName: i,
|
|
1701
1702
|
summary: "No features found for geometry filter",
|
|
1702
1703
|
details: {
|
|
1703
1704
|
error: `No features found matching: ${"where" in a ? a.where : "unknown criteria"}`
|
|
1704
1705
|
}
|
|
1705
1706
|
};
|
|
1706
1707
|
c = h.geometry;
|
|
1707
|
-
} else o && (c =
|
|
1708
|
-
const u =
|
|
1708
|
+
} else o && (c = t.extent.clone());
|
|
1709
|
+
const u = r.groupByFields && r.groupByFields.length > 0, d = n.objectIdField, p = e.outFields.includes("*") ? ["*"] : [.../* @__PURE__ */ new Set([...e.outFields, d])];
|
|
1709
1710
|
try {
|
|
1710
1711
|
let h;
|
|
1711
1712
|
if (u) {
|
|
1712
|
-
const m = new
|
|
1713
|
+
const m = new pt({
|
|
1713
1714
|
where: e.where || "1=1",
|
|
1714
1715
|
outFields: p,
|
|
1715
1716
|
orderByFields: e.orderByFields,
|
|
@@ -1717,139 +1718,139 @@ Only call this tool when the answer requires computing an aggregate (avg, max, m
|
|
|
1717
1718
|
spatialRelationship: c ? "intersects" : void 0,
|
|
1718
1719
|
distance: a?.distance,
|
|
1719
1720
|
units: a?.units,
|
|
1720
|
-
topFilter: new
|
|
1721
|
-
topCount:
|
|
1722
|
-
groupByFields:
|
|
1723
|
-
orderByFields:
|
|
1721
|
+
topFilter: new ht({
|
|
1722
|
+
topCount: r.topCount,
|
|
1723
|
+
groupByFields: r.groupByFields,
|
|
1724
|
+
orderByFields: r.orderByFields
|
|
1724
1725
|
})
|
|
1725
1726
|
});
|
|
1726
1727
|
h = await n.queryTopFeatures(m);
|
|
1727
1728
|
} else {
|
|
1728
1729
|
const m = n.createQuery();
|
|
1729
|
-
m.where = K(n.definitionExpression, e.where || "1=1"), m.outFields = p.length ? p : ["*"], m.orderByFields =
|
|
1730
|
-
const
|
|
1730
|
+
m.where = K(n.definitionExpression, e.where || "1=1"), m.outFields = p.length ? p : ["*"], m.orderByFields = r.orderByFields, m.num = r.topCount, c && (m.geometry = c, m.spatialRelationship = "intersects"), a?.distance && (m.distance = a.distance), a?.units && (m.units = a.units), m.outSpatialReference = t.spatialReference;
|
|
1731
|
+
const g = le(l, e.outFields, o ?? !1);
|
|
1731
1732
|
try {
|
|
1732
|
-
h =
|
|
1733
|
+
h = g ? await l.queryFeatures(m) : await n.queryFeatures(m);
|
|
1733
1734
|
} catch (T) {
|
|
1734
1735
|
console.warn("Client-side query failed, falling back to server:", T), h = await n.queryFeatures(m);
|
|
1735
1736
|
}
|
|
1736
1737
|
}
|
|
1737
|
-
const
|
|
1738
|
+
const f = h.features.map((m) => m.attributes[d]), { attributes: y } = Ee(n, h, t.timeZone);
|
|
1738
1739
|
return {
|
|
1739
1740
|
tool: "getTopFeatures",
|
|
1740
|
-
layerName:
|
|
1741
|
-
summary: `Top ${
|
|
1741
|
+
layerName: i,
|
|
1742
|
+
summary: `Top ${r.topCount} features extracted`,
|
|
1742
1743
|
details: {
|
|
1743
|
-
topCount:
|
|
1744
|
-
attributes:
|
|
1745
|
-
objectIds:
|
|
1744
|
+
topCount: r.topCount,
|
|
1745
|
+
attributes: y,
|
|
1746
|
+
objectIds: f,
|
|
1746
1747
|
objectIdField: d,
|
|
1747
1748
|
where: e.where,
|
|
1748
|
-
orderByFields:
|
|
1749
|
-
...u && { groupByFields:
|
|
1749
|
+
orderByFields: r.orderByFields,
|
|
1750
|
+
...u && { groupByFields: r.groupByFields }
|
|
1750
1751
|
}
|
|
1751
1752
|
};
|
|
1752
1753
|
} catch (h) {
|
|
1753
1754
|
return {
|
|
1754
1755
|
tool: "getTopFeatures",
|
|
1755
|
-
layerName:
|
|
1756
|
+
layerName: i,
|
|
1756
1757
|
summary: "Query failed",
|
|
1757
1758
|
details: { error: h instanceof Error ? h.message : String(h) }
|
|
1758
1759
|
};
|
|
1759
1760
|
}
|
|
1760
|
-
},
|
|
1761
|
+
}, qa = async ({
|
|
1761
1762
|
targetLayer: e,
|
|
1762
|
-
topFilter:
|
|
1763
|
-
geometryFilter:
|
|
1763
|
+
topFilter: r,
|
|
1764
|
+
geometryFilter: t,
|
|
1764
1765
|
useCurrentExtent: a
|
|
1765
1766
|
}, o) => {
|
|
1766
|
-
const { mapView: n } =
|
|
1767
|
+
const { mapView: n } = N(o), l = await Na(e, r, n, t, a);
|
|
1767
1768
|
return JSON.stringify(l, null, 2);
|
|
1768
|
-
},
|
|
1769
|
-
layerId:
|
|
1770
|
-
where:
|
|
1771
|
-
distance:
|
|
1772
|
-
units:
|
|
1773
|
-
}), za =
|
|
1774
|
-
point:
|
|
1775
|
-
x:
|
|
1776
|
-
y:
|
|
1777
|
-
spatialReference:
|
|
1778
|
-
wkid:
|
|
1769
|
+
}, Ia = s.object({
|
|
1770
|
+
layerId: s.string().describe("The layerId of the layer containing the geometry by which to filter."),
|
|
1771
|
+
where: s.string().describe("The SQL-92 where clause representing the features from which to filter."),
|
|
1772
|
+
distance: s.number().optional().describe("The buffer distance around the geometry."),
|
|
1773
|
+
units: F.optional().describe("The units for the distance buffer.")
|
|
1774
|
+
}), za = s.object({
|
|
1775
|
+
point: s.object({
|
|
1776
|
+
x: s.number().describe("X coordinate (longitude) from navigation result"),
|
|
1777
|
+
y: s.number().describe("Y coordinate (latitude) from navigation result"),
|
|
1778
|
+
spatialReference: s.object({
|
|
1779
|
+
wkid: s.number().describe("Spatial reference WKID (e.g., 4326 for WGS84)")
|
|
1779
1780
|
}).optional().describe("Spatial reference. Defaults to map's spatial reference if not provided.")
|
|
1780
1781
|
}).describe("Point coordinates from a previous navigation/geocoding result"),
|
|
1781
|
-
distance:
|
|
1782
|
-
units:
|
|
1783
|
-
}),
|
|
1784
|
-
targetLayer:
|
|
1785
|
-
layerId:
|
|
1786
|
-
where:
|
|
1787
|
-
orderByFields:
|
|
1788
|
-
outFields:
|
|
1789
|
-
|
|
1782
|
+
distance: s.number().optional().describe("Optional buffer distance around the point."),
|
|
1783
|
+
units: F.optional().describe("The units for the distance buffer.")
|
|
1784
|
+
}), Da = s.object({
|
|
1785
|
+
targetLayer: s.object({
|
|
1786
|
+
layerId: s.string().describe("The layerId of the layer containing the field from which to get a value."),
|
|
1787
|
+
where: s.string().describe("The SQL-92 where clause representing the feature from which to get an attribute value."),
|
|
1788
|
+
orderByFields: s.array(s.string().describe("The field(s) and order for which to sort the resulting features.")),
|
|
1789
|
+
outFields: s.array(
|
|
1790
|
+
s.string().describe(
|
|
1790
1791
|
'The fields to include in the output that will be presented to the user. This should include identifying information about the resulting features, like a name or id, along with the values desired in the output. If unsure, choose all fields ("*").'
|
|
1791
1792
|
).default("*")
|
|
1792
1793
|
)
|
|
1793
1794
|
}),
|
|
1794
|
-
geometryFilter:
|
|
1795
|
+
geometryFilter: s.union([Ia, za]).optional().describe(
|
|
1795
1796
|
"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."
|
|
1796
1797
|
),
|
|
1797
|
-
topFilter:
|
|
1798
|
-
topCount:
|
|
1799
|
-
orderByFields:
|
|
1800
|
-
|
|
1798
|
+
topFilter: s.object({
|
|
1799
|
+
topCount: s.number().describe("Number of top features to return per group."),
|
|
1800
|
+
orderByFields: s.array(
|
|
1801
|
+
s.string().describe("Field(s) to rank by with ASC/DESC. Must be existing field names, not aggregate functions.")
|
|
1801
1802
|
),
|
|
1802
|
-
groupByFields:
|
|
1803
|
+
groupByFields: s.array(s.string().describe("Field(s) to group results by. Returns top N per group."))
|
|
1803
1804
|
}).required(),
|
|
1804
|
-
useCurrentExtent:
|
|
1805
|
+
useCurrentExtent: s.boolean().optional().describe(
|
|
1805
1806
|
"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)."
|
|
1806
1807
|
)
|
|
1807
|
-
}),
|
|
1808
|
+
}), Pa = w(qa, {
|
|
1808
1809
|
name: "getTopFeatures",
|
|
1809
1810
|
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.',
|
|
1810
|
-
schema:
|
|
1811
|
-
}), ee = 25, Aa = async (e,
|
|
1812
|
-
const o =
|
|
1813
|
-
let
|
|
1814
|
-
if (
|
|
1815
|
-
const m = await
|
|
1811
|
+
schema: Da
|
|
1812
|
+
}), ee = 25, Aa = async (e, r, t, a) => {
|
|
1813
|
+
const o = r.map?.allLayers.find((m) => m.id === e.layerId), n = await r.whenLayerView(o), l = o.title ?? e.layerId;
|
|
1814
|
+
let i;
|
|
1815
|
+
if (t) {
|
|
1816
|
+
const m = await J(t, r);
|
|
1816
1817
|
if ("error" in m) {
|
|
1817
|
-
const
|
|
1818
|
-
if (
|
|
1819
|
-
const T =
|
|
1820
|
-
|
|
1821
|
-
} else
|
|
1818
|
+
const g = { error: m.error };
|
|
1819
|
+
if (L(t)) {
|
|
1820
|
+
const T = r.map?.allLayers.find(($) => $.id === t.layerId);
|
|
1821
|
+
g.geometryLayerName = T?.title ?? T?.id, g.geometryLayerId = t.layerId, g.geometryWhere = t.where;
|
|
1822
|
+
} else B(t) && (g.point = t.point);
|
|
1822
1823
|
return {
|
|
1823
1824
|
tool: "queryFeatures",
|
|
1824
1825
|
layerName: l,
|
|
1825
1826
|
summary: "Geometry lookup failed",
|
|
1826
|
-
details:
|
|
1827
|
+
details: g
|
|
1827
1828
|
};
|
|
1828
1829
|
}
|
|
1829
1830
|
if (!m.geometry) {
|
|
1830
|
-
const
|
|
1831
|
-
if (
|
|
1832
|
-
const T =
|
|
1833
|
-
|
|
1834
|
-
} else
|
|
1831
|
+
const g = {};
|
|
1832
|
+
if (L(t)) {
|
|
1833
|
+
const T = r.map?.allLayers.find(($) => $.id === t.layerId);
|
|
1834
|
+
g.error = `No features found matching: ${t.where}`, g.geometryLayerName = T?.title ?? T?.id, g.geometryLayerId = t.layerId, g.geometryWhere = t.where;
|
|
1835
|
+
} else B(t) && (g.error = "Failed to create point geometry", g.point = t.point);
|
|
1835
1836
|
return {
|
|
1836
1837
|
tool: "queryFeatures",
|
|
1837
1838
|
layerName: l,
|
|
1838
1839
|
summary: "No features found for geometry filter",
|
|
1839
|
-
details:
|
|
1840
|
+
details: g
|
|
1840
1841
|
};
|
|
1841
1842
|
}
|
|
1842
|
-
|
|
1843
|
-
} else a && (
|
|
1844
|
-
const c =
|
|
1845
|
-
d.where = K(o.definitionExpression, e.where || "1=1"), d.outFields = e.outFields.includes("*") ? ["*"] : [.../* @__PURE__ */ new Set([...e.outFields, u])], d.orderByFields = e.orderByFields,
|
|
1843
|
+
i = m.geometry;
|
|
1844
|
+
} else a && (i = r.extent.clone());
|
|
1845
|
+
const c = le(n, e.outFields, a ?? !1), u = o.objectIdField, d = o.createQuery();
|
|
1846
|
+
d.where = K(o.definitionExpression, e.where || "1=1"), d.outFields = e.outFields.includes("*") ? ["*"] : [.../* @__PURE__ */ new Set([...e.outFields, u])], d.orderByFields = e.orderByFields, i && (d.geometry = i, d.spatialRelationship = "intersects"), t?.distance && (d.distance = t.distance), t?.units && (d.units = t.units), d.outSpatialReference = r.spatialReference;
|
|
1846
1847
|
let p, h;
|
|
1847
1848
|
try {
|
|
1848
1849
|
p = c ? await n.queryFeatureCount(d) : await o.queryFeatureCount(d), p > 0 && p <= ee && (h = c ? await n.queryFeatures(d) : await o.queryFeatures(d));
|
|
1849
1850
|
} catch (m) {
|
|
1850
1851
|
console.warn("Client-side query failed, falling back to server:", m), p = await o.queryFeatureCount(d), p > 0 && p <= ee && (h = await o.queryFeatures(d));
|
|
1851
1852
|
}
|
|
1852
|
-
const { objectIds:
|
|
1853
|
+
const { objectIds: f, attributes: y } = h ? Ee(o, h, r.timeZone) : { objectIds: void 0, attributes: void 0 };
|
|
1853
1854
|
return {
|
|
1854
1855
|
tool: "queryFeatures",
|
|
1855
1856
|
layerName: l,
|
|
@@ -1859,57 +1860,57 @@ Only call this tool when the answer requires computing an aggregate (avg, max, m
|
|
|
1859
1860
|
where: e.where,
|
|
1860
1861
|
orderByFields: e.orderByFields,
|
|
1861
1862
|
outFields: e.outFields,
|
|
1862
|
-
...
|
|
1863
|
-
...
|
|
1863
|
+
...f && { objectIds: f, objectIdField: u },
|
|
1864
|
+
...y && { attributes: y },
|
|
1864
1865
|
...p > ee && {
|
|
1865
1866
|
note: `${p} features found.`
|
|
1866
1867
|
}
|
|
1867
1868
|
}
|
|
1868
1869
|
};
|
|
1869
1870
|
};
|
|
1870
|
-
async function
|
|
1871
|
+
async function ja({
|
|
1871
1872
|
targetLayer: e,
|
|
1872
|
-
geometryFilter:
|
|
1873
|
-
useCurrentExtent:
|
|
1873
|
+
geometryFilter: r,
|
|
1874
|
+
useCurrentExtent: t
|
|
1874
1875
|
}, a) {
|
|
1875
|
-
const { mapView: o } =
|
|
1876
|
+
const { mapView: o } = N(a), n = await Aa(e, o, r, t);
|
|
1876
1877
|
return JSON.stringify(n, null, 2);
|
|
1877
1878
|
}
|
|
1878
|
-
const La =
|
|
1879
|
-
layerId:
|
|
1880
|
-
where:
|
|
1881
|
-
distance:
|
|
1882
|
-
units:
|
|
1883
|
-
}),
|
|
1884
|
-
point:
|
|
1885
|
-
x:
|
|
1886
|
-
y:
|
|
1887
|
-
spatialReference:
|
|
1888
|
-
wkid:
|
|
1879
|
+
const La = s.object({
|
|
1880
|
+
layerId: s.string().describe("The layerId of the layer containing the geometry by which to filter."),
|
|
1881
|
+
where: s.string().describe("The SQL-92 where clause representing the features from which to filter."),
|
|
1882
|
+
distance: s.number().optional().describe("The buffer distance around the geometry."),
|
|
1883
|
+
units: F.optional().describe("The units for the distance buffer.")
|
|
1884
|
+
}), Ga = s.object({
|
|
1885
|
+
point: s.object({
|
|
1886
|
+
x: s.number().describe("X coordinate (longitude) from navigation result"),
|
|
1887
|
+
y: s.number().describe("Y coordinate (latitude) from navigation result"),
|
|
1888
|
+
spatialReference: s.object({
|
|
1889
|
+
wkid: s.number().describe("Spatial reference WKID (e.g., 4326 for WGS84)")
|
|
1889
1890
|
}).optional().describe("Spatial reference. Defaults to map's spatial reference if not provided.")
|
|
1890
1891
|
}).describe("Point coordinates from a previous navigation/geocoding result"),
|
|
1891
|
-
distance:
|
|
1892
|
-
units:
|
|
1893
|
-
}),
|
|
1894
|
-
targetLayer:
|
|
1895
|
-
layerId:
|
|
1896
|
-
where:
|
|
1892
|
+
distance: s.number().optional().describe("Optional buffer distance around the point."),
|
|
1893
|
+
units: F.optional().describe("The units for the distance buffer.")
|
|
1894
|
+
}), Oa = s.object({
|
|
1895
|
+
targetLayer: s.object({
|
|
1896
|
+
layerId: s.string().describe("The layerId of the layer containing the field from which to get a value."),
|
|
1897
|
+
where: s.string().describe(
|
|
1897
1898
|
"SQL-92 where clause. IMPORTANT: When using geometryFilter.point for point-in-polygon queries, set this to '1=1' to return all features that intersect the point. Only add attribute filters if the user specifically requests them in addition to the spatial query."
|
|
1898
1899
|
),
|
|
1899
|
-
orderByFields:
|
|
1900
|
-
outFields:
|
|
1901
|
-
|
|
1900
|
+
orderByFields: s.array(s.string().describe("The field(s) and order for which to sort the resulting features.")),
|
|
1901
|
+
outFields: s.array(
|
|
1902
|
+
s.string().describe(
|
|
1902
1903
|
'The fields to include in the output that will be presented to the user. This should include identifying information about the resulting features, like a name or id, along with the values desired in the output. If unsure, choose all fields ("*").'
|
|
1903
1904
|
).default("*")
|
|
1904
1905
|
)
|
|
1905
1906
|
}),
|
|
1906
|
-
geometryFilter:
|
|
1907
|
+
geometryFilter: s.union([La, Ga]).optional().describe(
|
|
1907
1908
|
"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."
|
|
1908
1909
|
),
|
|
1909
|
-
useCurrentExtent:
|
|
1910
|
+
useCurrentExtent: s.boolean().optional().describe(
|
|
1910
1911
|
"Set to true ONLY when user explicitly asks about features 'in my view', 'on my map', 'I am looking at', OR when the user refers back to features previously identified using the current extent (e.g. 'these', 'those', 'them', 'the same ones'). Default is false (queries entire layer)."
|
|
1911
1912
|
)
|
|
1912
|
-
}),
|
|
1913
|
+
}), Ma = w(ja, {
|
|
1913
1914
|
name: "queryFeatures",
|
|
1914
1915
|
description: `Queries features from a layer. Returns the total count of matching features, plus individual feature attributes if ≤25 features match.
|
|
1915
1916
|
|
|
@@ -1921,165 +1922,163 @@ USE THIS TOOL FOR:
|
|
|
1921
1922
|
- Any question where the user wants to SEE or COUNT matching features
|
|
1922
1923
|
|
|
1923
1924
|
This is the DEFAULT tool for most queries. When in doubt, use this tool.`,
|
|
1924
|
-
schema:
|
|
1925
|
-
}),
|
|
1926
|
-
async function
|
|
1927
|
-
const { messages:
|
|
1928
|
-
for (const n of
|
|
1925
|
+
schema: Oa
|
|
1926
|
+
}), Qa = [xa, ka, Pa, Ma], Jn = [ca, ta, Yr], _a = new nt(Qa, { handleToolErrors: !1 });
|
|
1927
|
+
async function Zn(e, r) {
|
|
1928
|
+
const { messages: t } = await _a.invoke({ messages: e.dataExplorationMessages }, r), a = [], o = [];
|
|
1929
|
+
for (const n of t) {
|
|
1929
1930
|
const l = n.content;
|
|
1930
|
-
let
|
|
1931
|
-
typeof l != "string" && (
|
|
1931
|
+
let i;
|
|
1932
|
+
typeof l != "string" && (i = {
|
|
1932
1933
|
tool: n.name ?? "unknown",
|
|
1933
1934
|
layerName: "unknown",
|
|
1934
1935
|
summary: "Query failed",
|
|
1935
1936
|
details: { error: "Skipping non-string tool output:", raw: l }
|
|
1936
1937
|
});
|
|
1937
1938
|
try {
|
|
1938
|
-
typeof l == "string" ?
|
|
1939
|
+
typeof l == "string" ? i = JSON.parse(l) : i = {
|
|
1939
1940
|
tool: n.name ?? "unknown",
|
|
1940
1941
|
layerName: "unknown",
|
|
1941
1942
|
summary: "Query failed",
|
|
1942
1943
|
details: { error: "Invalid tool output type", raw: l }
|
|
1943
1944
|
};
|
|
1944
1945
|
} catch {
|
|
1945
|
-
|
|
1946
|
+
i = {
|
|
1946
1947
|
tool: n.name ?? "unknown",
|
|
1947
1948
|
layerName: "unknown",
|
|
1948
1949
|
summary: "Query failed",
|
|
1949
1950
|
details: { error: l }
|
|
1950
1951
|
};
|
|
1951
1952
|
}
|
|
1952
|
-
a.push(
|
|
1953
|
+
a.push(i), i.details && typeof i.details == "object" && "error" in i.details ? o.push(`- ${i.tool}: Error - ${String(i.details.error)}`) : o.push(`- ${i.layerName}: ${i.summary}`);
|
|
1953
1954
|
}
|
|
1954
|
-
return await S({ text: `Finished executing layer query tool: ${o.join(", ")}` },
|
|
1955
|
+
return await S({ text: `Finished executing layer query tool: ${o.join(", ")}` }, r), {
|
|
1955
1956
|
...e,
|
|
1956
|
-
dataExplorationMessages: [...e.dataExplorationMessages, ...
|
|
1957
|
+
dataExplorationMessages: [...e.dataExplorationMessages, ...t],
|
|
1957
1958
|
queryResponse: a,
|
|
1958
1959
|
status: "success",
|
|
1959
|
-
summary: o.length > 0 ?
|
|
1960
|
+
summary: o.length > 0 ? Ut(o.join(`
|
|
1960
1961
|
`)) : "Query executed."
|
|
1961
1962
|
};
|
|
1962
1963
|
}
|
|
1963
|
-
const
|
|
1964
|
-
...
|
|
1964
|
+
const Yn = b.Root({
|
|
1965
|
+
...H(),
|
|
1965
1966
|
// internal to the help agent
|
|
1966
1967
|
helpInternalState: b({
|
|
1967
|
-
reducer:
|
|
1968
|
+
reducer: j,
|
|
1968
1969
|
default: () => ({
|
|
1969
1970
|
toolCallMessage: void 0
|
|
1970
1971
|
})
|
|
1971
1972
|
})
|
|
1972
|
-
}),
|
|
1973
|
-
const
|
|
1974
|
-
({ layerItem: n }) => n.title?.toLowerCase().includes(
|
|
1973
|
+
}), Wa = (e, r) => {
|
|
1974
|
+
const t = Array.from(e.values()).find(
|
|
1975
|
+
({ layerItem: n }) => n.title?.toLowerCase().includes(r.toLowerCase())
|
|
1975
1976
|
);
|
|
1976
|
-
if (!
|
|
1977
|
+
if (!t) {
|
|
1977
1978
|
const n = Array.from(e.values()).map((l) => l.layerItem.title).join(", ");
|
|
1978
|
-
return `Could not find a layer matching "${
|
|
1979
|
+
return `Could not find a layer matching "${r}". Available layers: ${n}`;
|
|
1979
1980
|
}
|
|
1980
|
-
const a = Array.from(
|
|
1981
|
+
const a = Array.from(t.fieldRegistry.values()), o = a.map((n) => `- **${n.alias || n.name}** (\`${n.name}\`, ${n.type})${n.description ? `: ${n.description}` : ""}`).join(`
|
|
1981
1982
|
`);
|
|
1982
|
-
return `**${
|
|
1983
|
+
return `**${t.layerItem.title}** has ${a.length} field(s):
|
|
1983
1984
|
|
|
1984
1985
|
${o}`;
|
|
1985
|
-
},
|
|
1986
|
-
const
|
|
1987
|
-
return
|
|
1988
|
-
},
|
|
1986
|
+
}, Va = async ({ layerTitle: e }, r) => {
|
|
1987
|
+
const t = xe(r, "layersAndFieldsRegistry");
|
|
1988
|
+
return Wa(t, e);
|
|
1989
|
+
}, Xn = w(Va, {
|
|
1989
1990
|
name: "listLayerFields",
|
|
1990
1991
|
description: "Lists all fields for a given layer by title. Use ONLY when the user explicitly asks to see fields, columns, or attributes of a specific named layer. Do NOT call this tool for general help questions, capability overviews, or layer listing.",
|
|
1991
|
-
schema:
|
|
1992
|
-
layerTitle:
|
|
1992
|
+
schema: s.object({
|
|
1993
|
+
layerTitle: s.string().describe("The title or partial title of the layer to list fields for.")
|
|
1993
1994
|
})
|
|
1994
|
-
}),
|
|
1995
|
-
...
|
|
1995
|
+
}), ei = b.Root({
|
|
1996
|
+
...H(),
|
|
1996
1997
|
intent: b({
|
|
1997
|
-
reducer: (e,
|
|
1998
|
+
reducer: (e, r) => r
|
|
1998
1999
|
}),
|
|
1999
2000
|
arcgisKnowledgeMessages: b({
|
|
2000
|
-
reducer:
|
|
2001
|
+
reducer: be,
|
|
2001
2002
|
default: () => []
|
|
2002
2003
|
}),
|
|
2003
2004
|
arcgisKnowledgeToolResult: b({
|
|
2004
|
-
reducer: (e,
|
|
2005
|
+
reducer: (e, r) => r,
|
|
2005
2006
|
default: () => null
|
|
2006
2007
|
})
|
|
2007
|
-
})
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
const t = e.map?.allLayers.filter((r) => r.type === "knowledge-graph");
|
|
2012
|
-
if (!t || t?.length !== 1)
|
|
2008
|
+
});
|
|
2009
|
+
function ce(e) {
|
|
2010
|
+
const r = e.map?.allLayers.filter((t) => t.type === "knowledge-graph");
|
|
2011
|
+
if (!r || r?.length !== 1)
|
|
2013
2012
|
throw new Error("The Knowledge Agent currently only supports maps with exactly one Knowledge Graph Layer.");
|
|
2014
2013
|
}
|
|
2015
|
-
function
|
|
2014
|
+
function q(e) {
|
|
2016
2015
|
return !!e?.map && !("activeLinkChartLayer" in e.map);
|
|
2017
2016
|
}
|
|
2018
|
-
async function
|
|
2019
|
-
!e ||
|
|
2017
|
+
async function Z(e) {
|
|
2018
|
+
!e || q(e) || !e.map?.diagramNodesExtent || await e.goTo(e.map.diagramNodesExtent);
|
|
2020
2019
|
}
|
|
2021
|
-
function
|
|
2022
|
-
const
|
|
2023
|
-
if (!
|
|
2020
|
+
function O(e) {
|
|
2021
|
+
const t = e?.configurable?.context;
|
|
2022
|
+
if (!t || typeof t != "object")
|
|
2024
2023
|
throw new Error("ArcgisKnowledgeAgent context missing");
|
|
2025
|
-
if (!("view" in
|
|
2024
|
+
if (!("view" in t))
|
|
2026
2025
|
throw new Error("View context missing");
|
|
2027
|
-
const a =
|
|
2028
|
-
return a.map && !("activeLinkChartLayer" in a.map) &&
|
|
2026
|
+
const a = t.view;
|
|
2027
|
+
return a.map && !("activeLinkChartLayer" in a.map) && ce(a), {
|
|
2029
2028
|
view: a
|
|
2030
2029
|
};
|
|
2031
2030
|
}
|
|
2032
|
-
function
|
|
2033
|
-
const
|
|
2034
|
-
if (
|
|
2031
|
+
function ti(e) {
|
|
2032
|
+
const t = e?.configurable?.context;
|
|
2033
|
+
if (Fe(e) === "knowledgeGraph")
|
|
2035
2034
|
return "knowledgeGraph";
|
|
2036
|
-
const o =
|
|
2037
|
-
return
|
|
2035
|
+
const o = t.view;
|
|
2036
|
+
return q(o) ? (ce(o), "map") : "linkChart";
|
|
2038
2037
|
}
|
|
2039
|
-
async function
|
|
2040
|
-
const
|
|
2041
|
-
if (
|
|
2042
|
-
return
|
|
2038
|
+
async function M(e) {
|
|
2039
|
+
const t = e?.configurable?.context;
|
|
2040
|
+
if (Fe(e) === "knowledgeGraph")
|
|
2041
|
+
return t;
|
|
2043
2042
|
{
|
|
2044
|
-
const o =
|
|
2043
|
+
const o = t.view.map;
|
|
2045
2044
|
if (o && "activeLinkChartLayer" in o) {
|
|
2046
2045
|
const n = o.knowledgeGraph?.url;
|
|
2047
2046
|
if (!n)
|
|
2048
2047
|
throw new Error("Knowledge graph url missing from link chart.");
|
|
2049
2048
|
return {
|
|
2050
|
-
knowledgeGraph: await
|
|
2049
|
+
knowledgeGraph: await fe(n)
|
|
2051
2050
|
};
|
|
2052
2051
|
} else {
|
|
2053
|
-
|
|
2054
|
-
const l = (
|
|
2052
|
+
ce(t.view);
|
|
2053
|
+
const l = (t.view.map?.allLayers.find(
|
|
2055
2054
|
(c) => c.type === "knowledge-graph"
|
|
2056
2055
|
)).url;
|
|
2057
2056
|
if (!l)
|
|
2058
2057
|
throw new Error("Knowledge graph url missing from map.");
|
|
2059
2058
|
return {
|
|
2060
|
-
knowledgeGraph: await
|
|
2059
|
+
knowledgeGraph: await fe(l)
|
|
2061
2060
|
};
|
|
2062
2061
|
}
|
|
2063
2062
|
}
|
|
2064
2063
|
}
|
|
2065
|
-
function
|
|
2066
|
-
const
|
|
2067
|
-
if (!
|
|
2064
|
+
function Fe(e) {
|
|
2065
|
+
const t = e?.configurable?.context;
|
|
2066
|
+
if (!t || typeof t != "object")
|
|
2068
2067
|
throw new Error("ArcgisKnowledgeAgent context missing");
|
|
2069
|
-
if ("knowledgeGraph" in
|
|
2068
|
+
if ("knowledgeGraph" in t && "view" in t)
|
|
2070
2069
|
throw new Error("Knowledge Graph context should only have a view or knowledgeGraph, but never both.");
|
|
2071
|
-
if ("knowledgeGraph" in
|
|
2070
|
+
if ("knowledgeGraph" in t)
|
|
2072
2071
|
return "knowledgeGraph";
|
|
2073
|
-
if ("view" in
|
|
2072
|
+
if ("view" in t)
|
|
2074
2073
|
return "view";
|
|
2075
2074
|
throw new Error("ArcgisKnowledgeAgent context must have either a view or knowledgeGraph property.");
|
|
2076
2075
|
}
|
|
2077
|
-
class
|
|
2078
|
-
constructor(
|
|
2079
|
-
this.dataModel =
|
|
2076
|
+
class Ua {
|
|
2077
|
+
constructor(r) {
|
|
2078
|
+
this.dataModel = r, this.kind = "GraphQueryGenerationRequest", this.explainQuery = !0, this.schemaInformation = ue.fromDataModel(r);
|
|
2080
2079
|
}
|
|
2081
2080
|
}
|
|
2082
|
-
class
|
|
2081
|
+
class ue {
|
|
2083
2082
|
constructor() {
|
|
2084
2083
|
this.schemaType = "ArcgisGraphSchema", this.entityTypes = [], this.relationshipTypes = [], this.identifierInfo = {
|
|
2085
2084
|
mappingInfo: {
|
|
@@ -2088,25 +2087,25 @@ class de {
|
|
|
2088
2087
|
}
|
|
2089
2088
|
};
|
|
2090
2089
|
}
|
|
2091
|
-
static fromDataModel(
|
|
2092
|
-
const
|
|
2093
|
-
for (const a of
|
|
2094
|
-
|
|
2095
|
-
for (const a of
|
|
2096
|
-
|
|
2097
|
-
return
|
|
2090
|
+
static fromDataModel(r) {
|
|
2091
|
+
const t = new ue();
|
|
2092
|
+
for (const a of r.entityTypes)
|
|
2093
|
+
t.entityTypes.push(G.fromEntityType(a));
|
|
2094
|
+
for (const a of r.relationshipTypes)
|
|
2095
|
+
t.relationshipTypes.push(Ba.fromRelationshipType(a));
|
|
2096
|
+
return t.identifierInfo = {
|
|
2098
2097
|
mappingInfo: {
|
|
2099
2098
|
identifierMapsTo: Ka(
|
|
2100
|
-
|
|
2099
|
+
r.identifierInfo.identifierMappingInfo.identifierInfoType
|
|
2101
2100
|
),
|
|
2102
|
-
identifierPropertyName:
|
|
2101
|
+
identifierPropertyName: r.identifierInfo.identifierMappingInfo.uniformPropertyIdentifier.identifierPropertyName
|
|
2103
2102
|
}
|
|
2104
|
-
},
|
|
2103
|
+
}, t.spatialReference = JSON.parse(JSON.stringify(r.spatialReference)), t;
|
|
2105
2104
|
}
|
|
2106
2105
|
// Generates a short summary of the types in the data model for LLM consumption.
|
|
2107
|
-
static getDataModelTypesSummary(
|
|
2108
|
-
const
|
|
2109
|
-
return `Entity Types: ${
|
|
2106
|
+
static getDataModelTypesSummary(r) {
|
|
2107
|
+
const t = r.entityTypes.map((o) => o.name).join(", "), a = r.relationshipTypes.map((o) => o.name).join(", ");
|
|
2108
|
+
return `Entity Types: ${t}.
|
|
2110
2109
|
Relationship Types: ${a}.`;
|
|
2111
2110
|
}
|
|
2112
2111
|
}
|
|
@@ -2114,39 +2113,39 @@ class G {
|
|
|
2114
2113
|
constructor() {
|
|
2115
2114
|
this.name = "", this.properties = [];
|
|
2116
2115
|
}
|
|
2117
|
-
static fromEntityType(
|
|
2118
|
-
const
|
|
2119
|
-
|
|
2120
|
-
for (const a of
|
|
2116
|
+
static fromEntityType(r) {
|
|
2117
|
+
const t = new G();
|
|
2118
|
+
t.name = r.name, t.alias = r.alias ? r.alias : void 0, t.role = Ha(r.role);
|
|
2119
|
+
for (const a of r.properties) {
|
|
2121
2120
|
const o = {
|
|
2122
2121
|
name: a.name,
|
|
2123
2122
|
alias: a.alias ? a.alias : void 0,
|
|
2124
2123
|
fieldType: a.fieldType,
|
|
2125
|
-
role:
|
|
2124
|
+
role: Ja(a.role),
|
|
2126
2125
|
geometryDef: a.fieldType === "esriFieldTypeGeometry" ? {
|
|
2127
2126
|
geometryType: a.geometryType ?? "esriGeometryAny",
|
|
2128
2127
|
hasM: a.hasM ? a.hasM : void 0,
|
|
2129
2128
|
hasZ: a.hasZ ? a.hasZ : void 0
|
|
2130
2129
|
} : void 0
|
|
2131
2130
|
};
|
|
2132
|
-
|
|
2131
|
+
t.properties.push(o);
|
|
2133
2132
|
}
|
|
2134
|
-
return
|
|
2133
|
+
return t;
|
|
2135
2134
|
}
|
|
2136
2135
|
}
|
|
2137
|
-
class
|
|
2136
|
+
class Ba extends G {
|
|
2138
2137
|
constructor() {
|
|
2139
2138
|
super(...arguments), this.observedEndPoints = [];
|
|
2140
2139
|
}
|
|
2141
|
-
static fromRelationshipType(
|
|
2142
|
-
const
|
|
2143
|
-
|
|
2144
|
-
for (const a of
|
|
2145
|
-
|
|
2140
|
+
static fromRelationshipType(r) {
|
|
2141
|
+
const t = G.fromEntityType(r);
|
|
2142
|
+
t.observedEndPoints = [];
|
|
2143
|
+
for (const a of r.endPoints)
|
|
2144
|
+
t.observedEndPoints.push({
|
|
2146
2145
|
originEntityType: a.originEntityType,
|
|
2147
2146
|
destinationEntityType: a.destinationEntityType
|
|
2148
2147
|
});
|
|
2149
|
-
return
|
|
2148
|
+
return t;
|
|
2150
2149
|
}
|
|
2151
2150
|
}
|
|
2152
2151
|
const Ka = (e) => {
|
|
@@ -2160,7 +2159,7 @@ const Ka = (e) => {
|
|
|
2160
2159
|
default:
|
|
2161
2160
|
return e;
|
|
2162
2161
|
}
|
|
2163
|
-
},
|
|
2162
|
+
}, Ha = (e) => {
|
|
2164
2163
|
switch (e) {
|
|
2165
2164
|
case "Regular":
|
|
2166
2165
|
return "esriGraphNamedObjectRegular";
|
|
@@ -2172,7 +2171,7 @@ const Ka = (e) => {
|
|
|
2172
2171
|
return e;
|
|
2173
2172
|
}
|
|
2174
2173
|
};
|
|
2175
|
-
function
|
|
2174
|
+
function Ja(e) {
|
|
2176
2175
|
switch (e) {
|
|
2177
2176
|
case "esriGraphPropertyRegular":
|
|
2178
2177
|
return "Regular";
|
|
@@ -2213,255 +2212,323 @@ function Ha(e) {
|
|
|
2213
2212
|
function Y(e) {
|
|
2214
2213
|
return e?.signal;
|
|
2215
2214
|
}
|
|
2216
|
-
function
|
|
2217
|
-
|
|
2215
|
+
async function Za(e, r) {
|
|
2216
|
+
const t = await U("arcgis_knowledge_cypher_query_prompt");
|
|
2217
|
+
return r ? `${e} ${t}
|
|
2218
2218
|
|
|
2219
2219
|
Your previous attempt to generate a cypher query failed. See the details below and generate a new cypher query that avoids this error.
|
|
2220
2220
|
|
|
2221
|
-
Attempt Number: ${
|
|
2222
|
-
Execution Error: ${
|
|
2221
|
+
Attempt Number: ${r.attemptCount}
|
|
2222
|
+
Execution Error: ${r.executionError}
|
|
2223
2223
|
Failed Query:
|
|
2224
|
-
${
|
|
2224
|
+
${r.failedGraphQuery}` : `${e} ${t}`;
|
|
2225
2225
|
}
|
|
2226
|
-
async function
|
|
2227
|
-
const { graphQuery: o, explanation: n } = await
|
|
2226
|
+
async function Ya(e, r, t, a) {
|
|
2227
|
+
const { graphQuery: o, explanation: n } = await de(e, r, t, a);
|
|
2228
2228
|
return { graphQuery: o, explanation: n };
|
|
2229
2229
|
}
|
|
2230
|
-
async function
|
|
2230
|
+
async function de(e, r, t, a, o) {
|
|
2231
2231
|
const n = {
|
|
2232
|
-
message:
|
|
2233
|
-
context: new
|
|
2234
|
-
};
|
|
2235
|
-
_.conversationId && (n.conversationId = _.conversationId);
|
|
2236
|
-
const l = Y(a);
|
|
2232
|
+
message: await Za(e, o),
|
|
2233
|
+
context: new Ua(r)
|
|
2234
|
+
}, l = Y(a);
|
|
2237
2235
|
await S({ text: "Attempting to generate a cypher query from your prompt..." }, a);
|
|
2238
|
-
const
|
|
2236
|
+
const i = await he(`${t}/chat`, {
|
|
2239
2237
|
method: "post",
|
|
2240
2238
|
body: JSON.stringify(n),
|
|
2241
2239
|
headers: {
|
|
2242
2240
|
"Content-Type": "application/json",
|
|
2243
|
-
token:
|
|
2241
|
+
token: pe.findCredential(k.getDefault().url)?.token ?? ""
|
|
2244
2242
|
},
|
|
2245
2243
|
signal: l
|
|
2246
2244
|
});
|
|
2247
|
-
if (
|
|
2248
|
-
throw new Error(`Graph query service returned an error: ${
|
|
2249
|
-
cause:
|
|
2245
|
+
if (i.httpStatus !== 200)
|
|
2246
|
+
throw new Error(`Graph query service returned an error: ${i.httpStatus}`, {
|
|
2247
|
+
cause: i.data
|
|
2250
2248
|
});
|
|
2251
|
-
_.conversationId || (_.conversationId = s.data.conversationId);
|
|
2252
2249
|
let c = !1;
|
|
2253
2250
|
const u = Date.now();
|
|
2254
|
-
let d =
|
|
2251
|
+
let d = i.data.sequenceNumber, p = "", h = "", f = 1;
|
|
2255
2252
|
for (; !c; ) {
|
|
2256
2253
|
await new Promise((m) => setTimeout(m, 1e3)), await S(
|
|
2257
|
-
{ text: `Periodically requesting status of job from ArcGIS AI Services${"...".substring(0,
|
|
2254
|
+
{ text: `Periodically requesting status of job from ArcGIS AI Services${"...".substring(0, f)}` },
|
|
2258
2255
|
a
|
|
2259
|
-
),
|
|
2260
|
-
const
|
|
2256
|
+
), f = f % 3 + 1;
|
|
2257
|
+
const y = await he(`${t}/chat`, {
|
|
2261
2258
|
method: "post",
|
|
2262
2259
|
body: JSON.stringify({
|
|
2263
|
-
conversationId:
|
|
2264
|
-
inquiryId:
|
|
2260
|
+
conversationId: i.data.conversationId,
|
|
2261
|
+
inquiryId: i.data.inquiryId,
|
|
2265
2262
|
ackSequenceNumber: d
|
|
2266
2263
|
}),
|
|
2267
2264
|
headers: {
|
|
2268
2265
|
"Content-Type": "application/json",
|
|
2269
|
-
token:
|
|
2266
|
+
token: pe.findCredential(k.getDefault().url)?.token ?? ""
|
|
2270
2267
|
},
|
|
2271
2268
|
signal: l
|
|
2272
2269
|
});
|
|
2273
|
-
if (
|
|
2274
|
-
throw new Error(`Graph query service polling returned an error: ${
|
|
2275
|
-
cause:
|
|
2270
|
+
if (y.httpStatus !== 200)
|
|
2271
|
+
throw new Error(`Graph query service polling returned an error: ${y.httpStatus}`, {
|
|
2272
|
+
cause: y.data
|
|
2276
2273
|
});
|
|
2277
|
-
if (
|
|
2278
|
-
if (
|
|
2279
|
-
throw new Error(`Unexpected response from graph query service polling. Message: ${
|
|
2280
|
-
cause:
|
|
2274
|
+
if (y.data.context?.kind) {
|
|
2275
|
+
if (y.data.context.kind !== "GraphQueryGenerationResponse")
|
|
2276
|
+
throw new Error(`Unexpected response from graph query service polling. Message: ${y.data.message}`, {
|
|
2277
|
+
cause: y.data
|
|
2281
2278
|
});
|
|
2282
|
-
p =
|
|
2283
|
-
} else if (!
|
|
2279
|
+
p = y.data.context.graphQuery, h = y.data.message || "", c = !0;
|
|
2280
|
+
} else if (!y.data.hasMore)
|
|
2284
2281
|
c = !0;
|
|
2285
2282
|
else if (Date.now() - u > 6e4)
|
|
2286
2283
|
throw new Error("Graph query service polling timed out after 1 minute.");
|
|
2287
|
-
d =
|
|
2284
|
+
d = y.data.sequenceNumber;
|
|
2288
2285
|
}
|
|
2289
2286
|
return { graphQuery: p, explanation: h };
|
|
2290
2287
|
}
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
2288
|
+
function Xa(e, r) {
|
|
2289
|
+
z(e, (t) => {
|
|
2290
|
+
r.set(`${t.typeName}__${t.id}`, {
|
|
2291
|
+
id: t.id,
|
|
2292
|
+
typeName: t.typeName
|
|
2293
|
+
});
|
|
2294
|
+
});
|
|
2295
|
+
}
|
|
2296
|
+
function z(e, r) {
|
|
2297
|
+
if (!(!e || typeof e != "object")) {
|
|
2298
|
+
if (to(e))
|
|
2299
|
+
for (const t of e.path)
|
|
2300
|
+
z(t, r);
|
|
2301
|
+
else if (eo(e))
|
|
2302
|
+
r(e);
|
|
2303
|
+
else if (Array.isArray(e))
|
|
2304
|
+
for (const t of e)
|
|
2305
|
+
z(t, r);
|
|
2306
|
+
else if (ro(e))
|
|
2307
|
+
for (const t of Object.values(e.properties ?? {}))
|
|
2308
|
+
z(t, r);
|
|
2309
|
+
}
|
|
2310
|
+
}
|
|
2311
|
+
function eo(e) {
|
|
2312
|
+
return !e || typeof e != "object" || Array.isArray(e) ? !1 : "id" in e && "typeName" in e;
|
|
2313
|
+
}
|
|
2314
|
+
function to(e) {
|
|
2315
|
+
return !e || typeof e != "object" || Array.isArray(e) ? !1 : e && "path" in e && Array.isArray(e.path);
|
|
2316
|
+
}
|
|
2317
|
+
function ro(e) {
|
|
2318
|
+
return !e || typeof e != "object" || Array.isArray(e) || "id" in e ? !1 : "properties" in e && typeof e.properties == "object";
|
|
2319
|
+
}
|
|
2320
|
+
function ao(e, r) {
|
|
2321
|
+
const t = [], a = [], o = [
|
|
2322
|
+
[r.dataModel.entityTypes, t],
|
|
2323
|
+
[r.dataModel.relationshipTypes, a]
|
|
2324
|
+
];
|
|
2325
|
+
for (const [n, l] of o)
|
|
2326
|
+
for (const i of n) {
|
|
2327
|
+
const c = e.getMemberIdsByType(i.name);
|
|
2328
|
+
l.push(...c);
|
|
2329
|
+
}
|
|
2330
|
+
return { entityIds: t, relationshipIds: a };
|
|
2331
|
+
}
|
|
2332
|
+
function oo(e, r) {
|
|
2333
|
+
const t = { entityIds: new Array(), relationshipIds: new Array() }, a = [], n = e?.allLayers.find((c) => c.type === "knowledge-graph")?.inclusionModeDefinition;
|
|
2334
|
+
if (!n)
|
|
2335
|
+
return { allNamedTypesFullyDynamic: !0, bindParameters: t, nonDynamicTypes: a };
|
|
2336
|
+
const l = [
|
|
2337
|
+
[r.dataModel.entityTypes, t.entityIds],
|
|
2338
|
+
[r.dataModel.relationshipTypes, t.relationshipIds]
|
|
2339
|
+
];
|
|
2340
|
+
let i = !0;
|
|
2341
|
+
for (const [c, u] of l)
|
|
2342
|
+
for (const d of c) {
|
|
2343
|
+
const p = n.namedTypeDefinitions.get(d.name);
|
|
2344
|
+
if (!p) {
|
|
2345
|
+
i = !1, a.push(d.name);
|
|
2346
|
+
continue;
|
|
2347
|
+
}
|
|
2348
|
+
if (!p.useAllData) {
|
|
2349
|
+
i = !1, a.push(d.name);
|
|
2350
|
+
for (const [h] of p.members || [])
|
|
2351
|
+
u.push(h);
|
|
2352
|
+
}
|
|
2353
|
+
}
|
|
2354
|
+
return { allNamedTypesFullyDynamic: i, bindParameters: t, nonDynamicTypes: a };
|
|
2355
|
+
}
|
|
2356
|
+
const D = 3;
|
|
2357
|
+
function ke(e, r = 100) {
|
|
2358
|
+
const t = {};
|
|
2294
2359
|
for (const a of Object.entries(e.properties ?? {})) {
|
|
2295
2360
|
const [o, n] = a;
|
|
2296
|
-
typeof n == "string" && n.length >
|
|
2361
|
+
typeof n == "string" && n.length > r ? t[o] = `${n.slice(0, r)}... (truncated, original length: ${n.length})` : t[o] = n;
|
|
2297
2362
|
}
|
|
2298
|
-
return e.properties =
|
|
2363
|
+
return e.properties = t, e;
|
|
2299
2364
|
}
|
|
2300
|
-
function
|
|
2365
|
+
function P(e) {
|
|
2301
2366
|
return typeof e != "object" || e === null ? String(e) : "details" in e && typeof e.details == "object" && e.details !== null && "errorMessage" in e.details && typeof e.details.errorMessage == "string" ? e.details.errorMessage : "message" in e && typeof e.message == "string" ? e.message : String(e);
|
|
2302
2367
|
}
|
|
2303
|
-
const
|
|
2368
|
+
const no = async ({
|
|
2304
2369
|
kg: e,
|
|
2305
|
-
queryParams:
|
|
2306
|
-
targetStructure:
|
|
2370
|
+
queryParams: r,
|
|
2371
|
+
targetStructure: t,
|
|
2307
2372
|
targetStructureReducer: a,
|
|
2308
2373
|
requestOptions: o,
|
|
2309
2374
|
queryRowLimit: n,
|
|
2310
2375
|
queryTimeoutMs: l
|
|
2311
2376
|
}) => {
|
|
2312
|
-
let
|
|
2377
|
+
let i = null, c = t;
|
|
2313
2378
|
const u = new AbortController(), d = o?.signal, p = () => {
|
|
2314
2379
|
u.abort(d?.reason);
|
|
2315
2380
|
};
|
|
2316
2381
|
d && (d.aborted ? u.abort(d.reason) : d.addEventListener("abort", p, { once: !0 }));
|
|
2317
2382
|
try {
|
|
2318
|
-
const h = await
|
|
2319
|
-
|
|
2320
|
-
const
|
|
2321
|
-
let
|
|
2322
|
-
const m = Date.now(),
|
|
2383
|
+
const h = await yt(e, r, o);
|
|
2384
|
+
i = h.resultHeader;
|
|
2385
|
+
const f = h.resultRowsStream.getReader();
|
|
2386
|
+
let y = 0;
|
|
2387
|
+
const m = Date.now(), g = !1;
|
|
2323
2388
|
for (; ; ) {
|
|
2324
|
-
const { done: T, value:
|
|
2389
|
+
const { done: T, value: $ } = await f.read();
|
|
2325
2390
|
if (T)
|
|
2326
2391
|
break;
|
|
2327
|
-
if (!
|
|
2392
|
+
if (!g && l && Date.now() - m > l)
|
|
2328
2393
|
return u.abort(), { type: "timeout" };
|
|
2329
|
-
for (const v of
|
|
2330
|
-
if (
|
|
2331
|
-
return u.abort(), { type: "success", rowLimitReached: !0, resultHeader:
|
|
2394
|
+
for (const v of $) {
|
|
2395
|
+
if (y++, n && y > n)
|
|
2396
|
+
return u.abort(), { type: "success", rowLimitReached: !0, resultHeader: i, processedResult: c };
|
|
2332
2397
|
c = a(c, v);
|
|
2333
2398
|
}
|
|
2334
2399
|
}
|
|
2335
2400
|
} catch (h) {
|
|
2336
|
-
return u.signal.aborted ? { type: "aborted" } : { type: "error", errorMessage:
|
|
2401
|
+
return u.signal.aborted ? { type: "aborted" } : { type: "error", errorMessage: P(h), error: h };
|
|
2337
2402
|
} finally {
|
|
2338
2403
|
d?.removeEventListener("abort", p);
|
|
2339
2404
|
}
|
|
2340
|
-
return { type: "success", rowLimitReached: !1, resultHeader:
|
|
2405
|
+
return { type: "success", rowLimitReached: !1, resultHeader: i, processedResult: c };
|
|
2341
2406
|
};
|
|
2342
|
-
async function
|
|
2407
|
+
async function Ne({
|
|
2343
2408
|
prompt: e,
|
|
2409
|
+
bindParameters: r,
|
|
2344
2410
|
kg: t,
|
|
2345
|
-
graphQueryServiceUrl:
|
|
2346
|
-
targetStructure:
|
|
2347
|
-
targetStructureReducer:
|
|
2348
|
-
requestOptions:
|
|
2349
|
-
queryRowLimit:
|
|
2350
|
-
queryTimeoutMs:
|
|
2351
|
-
config:
|
|
2411
|
+
graphQueryServiceUrl: a,
|
|
2412
|
+
targetStructure: o,
|
|
2413
|
+
targetStructureReducer: n,
|
|
2414
|
+
requestOptions: l,
|
|
2415
|
+
queryRowLimit: i,
|
|
2416
|
+
queryTimeoutMs: c,
|
|
2417
|
+
config: u
|
|
2352
2418
|
}) {
|
|
2353
|
-
let
|
|
2354
|
-
for (let
|
|
2355
|
-
let
|
|
2419
|
+
let d;
|
|
2420
|
+
for (let p = 1; p <= D; p++) {
|
|
2421
|
+
let h;
|
|
2356
2422
|
try {
|
|
2357
|
-
|
|
2358
|
-
} catch (
|
|
2423
|
+
h = await de(e, t.dataModel, a, u, d);
|
|
2424
|
+
} catch (m) {
|
|
2359
2425
|
return {
|
|
2360
2426
|
type: "generation-error",
|
|
2361
|
-
errorMessage:
|
|
2362
|
-
error:
|
|
2427
|
+
errorMessage: P(m),
|
|
2428
|
+
error: m
|
|
2363
2429
|
};
|
|
2364
2430
|
}
|
|
2365
2431
|
await S(
|
|
2366
2432
|
{
|
|
2367
|
-
text: `Attempting to execute query: ${
|
|
2433
|
+
text: `Attempting to execute query: ${h.graphQuery.substring(0, 500)}${h.graphQuery.length > 500 ? "..." : ""}`
|
|
2368
2434
|
},
|
|
2369
|
-
|
|
2435
|
+
u
|
|
2370
2436
|
);
|
|
2371
|
-
const
|
|
2437
|
+
const f = await no({
|
|
2372
2438
|
kg: t,
|
|
2373
|
-
queryParams: new
|
|
2374
|
-
openCypherQuery:
|
|
2439
|
+
queryParams: new Se({
|
|
2440
|
+
openCypherQuery: h.graphQuery,
|
|
2441
|
+
bindParameters: r
|
|
2375
2442
|
}),
|
|
2376
|
-
targetStructure:
|
|
2377
|
-
targetStructureReducer:
|
|
2378
|
-
requestOptions:
|
|
2379
|
-
queryRowLimit:
|
|
2380
|
-
queryTimeoutMs:
|
|
2381
|
-
}), y =
|
|
2382
|
-
if (
|
|
2443
|
+
targetStructure: o,
|
|
2444
|
+
targetStructureReducer: n,
|
|
2445
|
+
requestOptions: l,
|
|
2446
|
+
queryRowLimit: i,
|
|
2447
|
+
queryTimeoutMs: c
|
|
2448
|
+
}), y = f.type === "aborted" ? "Query execution was aborted." : f.type === "timeout" ? "Query execution timed out." : f.type === "error" ? `Query failed with error: ${f.errorMessage}` : "";
|
|
2449
|
+
if (f.type === "success")
|
|
2383
2450
|
return {
|
|
2384
2451
|
type: "success",
|
|
2385
|
-
graphQuery:
|
|
2386
|
-
explanation:
|
|
2387
|
-
rowLimitReached:
|
|
2388
|
-
resultHeader:
|
|
2389
|
-
processedResult:
|
|
2452
|
+
graphQuery: h.graphQuery,
|
|
2453
|
+
explanation: h.explanation,
|
|
2454
|
+
rowLimitReached: f.rowLimitReached,
|
|
2455
|
+
resultHeader: f.resultHeader,
|
|
2456
|
+
processedResult: f.processedResult
|
|
2390
2457
|
};
|
|
2391
|
-
if (
|
|
2458
|
+
if (f.type === "aborted")
|
|
2392
2459
|
return {
|
|
2393
2460
|
type: "aborted",
|
|
2394
2461
|
errorMessage: y,
|
|
2395
|
-
graphQuery:
|
|
2396
|
-
explanation:
|
|
2462
|
+
graphQuery: h.graphQuery,
|
|
2463
|
+
explanation: h.explanation
|
|
2397
2464
|
};
|
|
2398
|
-
if (
|
|
2399
|
-
return
|
|
2465
|
+
if (p >= D)
|
|
2466
|
+
return f.type === "timeout" ? {
|
|
2400
2467
|
type: "timeout",
|
|
2401
2468
|
errorMessage: y,
|
|
2402
|
-
graphQuery:
|
|
2403
|
-
explanation:
|
|
2469
|
+
graphQuery: h.graphQuery,
|
|
2470
|
+
explanation: h.explanation
|
|
2404
2471
|
} : {
|
|
2405
2472
|
type: "execution-error",
|
|
2406
2473
|
errorMessage: y,
|
|
2407
|
-
error:
|
|
2408
|
-
graphQuery:
|
|
2409
|
-
explanation:
|
|
2474
|
+
error: f.error,
|
|
2475
|
+
graphQuery: h.graphQuery,
|
|
2476
|
+
explanation: h.explanation
|
|
2410
2477
|
};
|
|
2411
|
-
|
|
2412
|
-
failedGraphQuery:
|
|
2478
|
+
d = {
|
|
2479
|
+
failedGraphQuery: h.graphQuery,
|
|
2413
2480
|
executionError: y,
|
|
2414
|
-
attemptCount:
|
|
2481
|
+
attemptCount: p
|
|
2415
2482
|
}, await S(
|
|
2416
|
-
{ text: `Attempt ${
|
|
2417
|
-
|
|
2483
|
+
{ text: `Attempt ${p} failed with error: ${y}. Retrying...` },
|
|
2484
|
+
u
|
|
2418
2485
|
);
|
|
2419
2486
|
}
|
|
2420
2487
|
throw new Error(
|
|
2421
|
-
`Failed to execute generated cypher due to an unexpected error after ${
|
|
2488
|
+
`Failed to execute generated cypher due to an unexpected error after ${D} attempts.`
|
|
2422
2489
|
);
|
|
2423
2490
|
}
|
|
2424
|
-
const
|
|
2491
|
+
const io = async ({
|
|
2425
2492
|
kg: e,
|
|
2426
|
-
searchQuery:
|
|
2427
|
-
typeCategoryFilter:
|
|
2493
|
+
searchQuery: r,
|
|
2494
|
+
typeCategoryFilter: t,
|
|
2428
2495
|
namedTypesFilter: a,
|
|
2429
2496
|
searchResultLimit: o,
|
|
2430
2497
|
requestOptions: n
|
|
2431
2498
|
}) => {
|
|
2432
2499
|
const l = [];
|
|
2433
|
-
let
|
|
2434
|
-
|
|
2500
|
+
let i = [t];
|
|
2501
|
+
t === "both" && !e.serviceDefinition.serviceCapabilities.searchCapabilities.searchTypeFilterCapabilities.includes("esriTypeBoth") && (i = ["entity", "relationship"]);
|
|
2435
2502
|
const c = o ?? 1 / 0;
|
|
2436
2503
|
try {
|
|
2437
|
-
for (const u of
|
|
2504
|
+
for (const u of i) {
|
|
2438
2505
|
const d = c - l.length;
|
|
2439
2506
|
if (d <= 0)
|
|
2440
2507
|
break;
|
|
2441
|
-
const
|
|
2508
|
+
const f = (await ft(
|
|
2442
2509
|
e,
|
|
2443
|
-
new
|
|
2444
|
-
searchQuery:
|
|
2510
|
+
new gt({
|
|
2511
|
+
searchQuery: r,
|
|
2445
2512
|
typeCategoryFilter: u,
|
|
2446
2513
|
namedTypesFilter: a ?? void 0,
|
|
2447
2514
|
num: d
|
|
2448
2515
|
}),
|
|
2449
2516
|
n
|
|
2450
2517
|
)).resultRowsStream.getReader();
|
|
2451
|
-
let
|
|
2452
|
-
for (; !
|
|
2453
|
-
const { done: m, value:
|
|
2518
|
+
let y = !1;
|
|
2519
|
+
for (; !y; ) {
|
|
2520
|
+
const { done: m, value: g } = await f.read();
|
|
2454
2521
|
if (m) {
|
|
2455
|
-
|
|
2522
|
+
y = !0;
|
|
2456
2523
|
break;
|
|
2457
2524
|
}
|
|
2458
|
-
for (const T of
|
|
2459
|
-
for (const
|
|
2460
|
-
l.push(
|
|
2525
|
+
for (const T of g)
|
|
2526
|
+
for (const $ of T)
|
|
2527
|
+
l.push($);
|
|
2461
2528
|
}
|
|
2462
2529
|
}
|
|
2463
2530
|
} catch (u) {
|
|
2464
|
-
const d =
|
|
2531
|
+
const d = P(u);
|
|
2465
2532
|
return n?.signal?.aborted ? {
|
|
2466
2533
|
type: "aborted",
|
|
2467
2534
|
errorMessage: d,
|
|
@@ -2472,156 +2539,156 @@ const Xa = async ({
|
|
|
2472
2539
|
type: "success",
|
|
2473
2540
|
results: l
|
|
2474
2541
|
};
|
|
2475
|
-
};
|
|
2476
|
-
function
|
|
2477
|
-
|
|
2478
|
-
|
|
2479
|
-
|
|
2480
|
-
|
|
2481
|
-
|
|
2482
|
-
|
|
2483
|
-
|
|
2484
|
-
|
|
2485
|
-
|
|
2486
|
-
|
|
2487
|
-
|
|
2488
|
-
|
|
2489
|
-
|
|
2490
|
-
|
|
2491
|
-
|
|
2492
|
-
for (const r of e)
|
|
2493
|
-
D(r, t);
|
|
2494
|
-
else if (ao(e))
|
|
2495
|
-
for (const r of Object.values(e.properties ?? {}))
|
|
2496
|
-
D(r, t);
|
|
2497
|
-
}
|
|
2498
|
-
}
|
|
2499
|
-
function to(e) {
|
|
2500
|
-
return !e || typeof e != "object" || Array.isArray(e) ? !1 : "id" in e && "typeName" in e;
|
|
2501
|
-
}
|
|
2502
|
-
function ro(e) {
|
|
2503
|
-
return !e || typeof e != "object" || Array.isArray(e) ? !1 : e && "path" in e && Array.isArray(e.path);
|
|
2504
|
-
}
|
|
2505
|
-
function ao(e) {
|
|
2506
|
-
return !e || typeof e != "object" || Array.isArray(e) || "id" in e ? !1 : "properties" in e && typeof e.properties == "object";
|
|
2507
|
-
}
|
|
2508
|
-
function oo(e, t) {
|
|
2509
|
-
const r = [];
|
|
2510
|
-
for (const a of [...t.dataModel.entityTypes, ...t.dataModel.relationshipTypes]) {
|
|
2511
|
-
const o = e.getMemberIdsByType(a.name);
|
|
2512
|
-
for (const n of o)
|
|
2513
|
-
r.push({ id: n, typeName: a.name });
|
|
2542
|
+
}, qe = "IMPORTANT: The generated cypher query must return entire entities and relationships ONLY.";
|
|
2543
|
+
async function Ie({
|
|
2544
|
+
prompt: e,
|
|
2545
|
+
view: r,
|
|
2546
|
+
knowledgeGraph: t,
|
|
2547
|
+
includeReturnEntityAndRelationshipContext: a = !1
|
|
2548
|
+
}) {
|
|
2549
|
+
const o = [e];
|
|
2550
|
+
if (a && o.push(qe), !q(r)) {
|
|
2551
|
+
const d = await U("arcgis_knowledge_current_lc_context"), p = ao(r.map, t);
|
|
2552
|
+
return o.push(d), {
|
|
2553
|
+
enhancedPrompt: o.join(`
|
|
2554
|
+
|
|
2555
|
+
`),
|
|
2556
|
+
bindParameters: p,
|
|
2557
|
+
allNamedTypesFullyDynamic: !1
|
|
2558
|
+
};
|
|
2514
2559
|
}
|
|
2515
|
-
|
|
2516
|
-
|
|
2517
|
-
|
|
2518
|
-
|
|
2519
|
-
if (
|
|
2520
|
-
return {
|
|
2521
|
-
|
|
2522
|
-
|
|
2523
|
-
|
|
2524
|
-
|
|
2525
|
-
|
|
2526
|
-
|
|
2527
|
-
|
|
2560
|
+
const n = r.map, { allNamedTypesFullyDynamic: l, bindParameters: i, nonDynamicTypes: c } = oo(
|
|
2561
|
+
n,
|
|
2562
|
+
t
|
|
2563
|
+
);
|
|
2564
|
+
if (l)
|
|
2565
|
+
return {
|
|
2566
|
+
enhancedPrompt: o.join(`
|
|
2567
|
+
|
|
2568
|
+
`),
|
|
2569
|
+
bindParameters: i,
|
|
2570
|
+
allNamedTypesFullyDynamic: !0
|
|
2571
|
+
};
|
|
2572
|
+
const u = (await U("arcgis_knowledge_current_map_context")).replaceAll(
|
|
2573
|
+
"{nonDynamicTypes}",
|
|
2574
|
+
JSON.stringify(c)
|
|
2575
|
+
);
|
|
2576
|
+
return o.push(u), {
|
|
2577
|
+
enhancedPrompt: o.join(`
|
|
2578
|
+
|
|
2579
|
+
`),
|
|
2580
|
+
bindParameters: i,
|
|
2581
|
+
allNamedTypesFullyDynamic: l
|
|
2582
|
+
};
|
|
2528
2583
|
}
|
|
2529
|
-
async function
|
|
2530
|
-
const { view:
|
|
2584
|
+
async function so(e, r, t, a, o, n) {
|
|
2585
|
+
const { view: l } = o, i = await Ne({
|
|
2531
2586
|
prompt: e,
|
|
2587
|
+
bindParameters: r,
|
|
2532
2588
|
kg: t,
|
|
2533
|
-
graphQueryServiceUrl:
|
|
2589
|
+
graphQueryServiceUrl: a,
|
|
2534
2590
|
targetStructure: /* @__PURE__ */ new Map(),
|
|
2535
|
-
targetStructureReducer: (
|
|
2536
|
-
for (const y of
|
|
2537
|
-
|
|
2538
|
-
return
|
|
2591
|
+
targetStructureReducer: (h, f) => {
|
|
2592
|
+
for (const y of f)
|
|
2593
|
+
Xa(y, h);
|
|
2594
|
+
return h;
|
|
2539
2595
|
},
|
|
2540
2596
|
requestOptions: {
|
|
2541
|
-
signal: Y(
|
|
2542
|
-
timeout:
|
|
2597
|
+
signal: Y(n),
|
|
2598
|
+
timeout: n?.timeout
|
|
2543
2599
|
},
|
|
2544
|
-
config:
|
|
2600
|
+
config: n
|
|
2545
2601
|
});
|
|
2546
|
-
if (
|
|
2547
|
-
const
|
|
2548
|
-
throw new Error(`Failed to add records to the link chart. ${
|
|
2602
|
+
if (i.type !== "success") {
|
|
2603
|
+
const h = i.type === "generation-error" ? i.errorMessage : `${i.errorMessage} Cypher query: ${i.graphQuery}`;
|
|
2604
|
+
throw new Error(`Failed to add records to the link chart. ${h}`);
|
|
2549
2605
|
}
|
|
2550
|
-
const { graphQuery:
|
|
2606
|
+
const { graphQuery: c, explanation: u, processedResult: d } = i, p = Array.from(d.values());
|
|
2551
2607
|
return await S(
|
|
2552
2608
|
{
|
|
2553
|
-
text: `Query Results parsed into ${
|
|
2609
|
+
text: `Query Results parsed into ${p.length} unique relationships and entities. Atempting to add to link chart...`
|
|
2554
2610
|
},
|
|
2555
|
-
|
|
2556
|
-
), !
|
|
2557
|
-
(
|
|
2558
|
-
)?.addRecords(
|
|
2559
|
-
}
|
|
2560
|
-
const W = "addRecords",
|
|
2561
|
-
prompt:
|
|
2562
|
-
|
|
2563
|
-
|
|
2564
|
-
|
|
2565
|
-
|
|
2566
|
-
|
|
2567
|
-
|
|
2568
|
-
|
|
2569
|
-
|
|
2570
|
-
|
|
2571
|
-
|
|
2572
|
-
|
|
2573
|
-
|
|
2574
|
-
|
|
2575
|
-
|
|
2576
|
-
|
|
2577
|
-
|
|
2578
|
-
|
|
2579
|
-
|
|
2580
|
-
|
|
2581
|
-
|
|
2582
|
-
|
|
2583
|
-
|
|
2584
|
-
|
|
2585
|
-
|
|
2611
|
+
n
|
|
2612
|
+
), !q(l) && l?.map ? (await l.map.addRecords(p), await Z(l), { generatedQuery: c, explanation: u, addedIdTypePairs: p }) : (await l?.map?.allLayers.find(
|
|
2613
|
+
(f) => f.type === "knowledge-graph"
|
|
2614
|
+
)?.addRecords(p), { generatedQuery: c, explanation: u, addedIdTypePairs: p });
|
|
2615
|
+
}
|
|
2616
|
+
const W = "addRecords", lo = s.object({
|
|
2617
|
+
prompt: s.string().describe(
|
|
2618
|
+
"The user's inquiry and context required in order to generate a cypher query that will be used to add records to the link chart."
|
|
2619
|
+
)
|
|
2620
|
+
}), co = async ({ prompt: e }, r) => {
|
|
2621
|
+
const { knowledgeGraph: t } = await M(r), a = O(r), { view: o } = a, l = k.getDefault().helperServices, {
|
|
2622
|
+
enhancedPrompt: i,
|
|
2623
|
+
bindParameters: c,
|
|
2624
|
+
allNamedTypesFullyDynamic: u
|
|
2625
|
+
} = await Ie({
|
|
2626
|
+
prompt: e,
|
|
2627
|
+
view: o,
|
|
2628
|
+
knowledgeGraph: t,
|
|
2629
|
+
includeReturnEntityAndRelationshipContext: !0
|
|
2630
|
+
});
|
|
2631
|
+
if (u)
|
|
2632
|
+
return {
|
|
2633
|
+
toolName: W,
|
|
2634
|
+
status: "success",
|
|
2635
|
+
summary: "No records have been added to the map because all data in the knowledge graph is contained in the map.",
|
|
2636
|
+
details: {
|
|
2637
|
+
generatedQuery: "N/A",
|
|
2638
|
+
explanation: "All named types in the knowledge graph are fully dynamic and therefore all data is already contained in the map. No records have been added.",
|
|
2639
|
+
addedIdTypePairs: []
|
|
2640
|
+
}
|
|
2641
|
+
};
|
|
2586
2642
|
try {
|
|
2587
|
-
const { generatedQuery:
|
|
2588
|
-
|
|
2589
|
-
|
|
2643
|
+
const { generatedQuery: d, explanation: p, addedIdTypePairs: h } = await so(
|
|
2644
|
+
i,
|
|
2645
|
+
c,
|
|
2646
|
+
t,
|
|
2590
2647
|
`${l.aiAssistantServices.url}${l.aiAssistantServices.graphQueryAssistant}`,
|
|
2591
2648
|
a,
|
|
2592
|
-
|
|
2649
|
+
r
|
|
2593
2650
|
);
|
|
2594
2651
|
return {
|
|
2595
2652
|
toolName: W,
|
|
2596
2653
|
status: "success",
|
|
2597
|
-
summary: `Records added successfully. Cypher Query used: ${
|
|
2654
|
+
summary: `Records added successfully. Cypher Query used: ${d}
|
|
2598
2655
|
|
|
2599
|
-
Number of records added: ${
|
|
2656
|
+
Number of records added: ${h.length}`,
|
|
2600
2657
|
details: {
|
|
2601
|
-
generatedQuery:
|
|
2602
|
-
explanation:
|
|
2603
|
-
addedIdTypePairs:
|
|
2658
|
+
generatedQuery: d,
|
|
2659
|
+
explanation: p,
|
|
2660
|
+
addedIdTypePairs: h
|
|
2604
2661
|
}
|
|
2605
2662
|
};
|
|
2606
|
-
} catch (
|
|
2607
|
-
const
|
|
2608
|
-
return
|
|
2663
|
+
} catch (d) {
|
|
2664
|
+
const p = P(d);
|
|
2665
|
+
return {
|
|
2609
2666
|
toolName: W,
|
|
2610
2667
|
status: "error",
|
|
2611
|
-
errorMessage: `Failed to add records to the link chart. ${
|
|
2612
|
-
error:
|
|
2668
|
+
errorMessage: `Failed to add records to the link chart. ${p}`,
|
|
2669
|
+
error: d
|
|
2613
2670
|
};
|
|
2614
2671
|
}
|
|
2615
|
-
},
|
|
2672
|
+
}, ri = w(co, {
|
|
2616
2673
|
name: W,
|
|
2617
|
-
description:
|
|
2618
|
-
|
|
2674
|
+
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. "add to new link chart" is not a valid prompt for this tool.
|
|
2675
|
+
|
|
2676
|
+
example prompts:
|
|
2677
|
+
- "add all suppliers and the parts they produce to the link chart"
|
|
2678
|
+
- "show me the competitors of company x and add them to the link chart"
|
|
2679
|
+
- "add the relationships between company x and company y to the link chart"
|
|
2680
|
+
- "expand all the companies"
|
|
2681
|
+
- "expand company x through all the buildings it owns"
|
|
2682
|
+
- "connect company x and company y"
|
|
2683
|
+
- "connect all buildings on the link chart"
|
|
2684
|
+
`,
|
|
2685
|
+
schema: lo
|
|
2619
2686
|
});
|
|
2620
|
-
async function
|
|
2621
|
-
return await
|
|
2687
|
+
async function uo(e, r) {
|
|
2688
|
+
return await r.map?.applyLayout(e), await Z(r), { appliedLayout: e };
|
|
2622
2689
|
}
|
|
2623
|
-
const
|
|
2624
|
-
layout:
|
|
2690
|
+
const re = "applyLayout", po = s.object({
|
|
2691
|
+
layout: s.enum([
|
|
2625
2692
|
"organic-standard",
|
|
2626
2693
|
"organic-community",
|
|
2627
2694
|
"basic-grid",
|
|
@@ -2634,19 +2701,19 @@ const ae = "applyLayout", uo = i.object({
|
|
|
2634
2701
|
]).describe(
|
|
2635
2702
|
"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"
|
|
2636
2703
|
)
|
|
2637
|
-
}),
|
|
2638
|
-
const { view:
|
|
2639
|
-
if (
|
|
2704
|
+
}), ho = async ({ layout: e }, r) => {
|
|
2705
|
+
const { view: t } = O(r);
|
|
2706
|
+
if (q(t))
|
|
2640
2707
|
return {
|
|
2641
|
-
toolName:
|
|
2708
|
+
toolName: re,
|
|
2642
2709
|
status: "error",
|
|
2643
2710
|
errorMessage: "The applyLayout tool can only be used with a LinkChartView.",
|
|
2644
2711
|
error: new Error()
|
|
2645
2712
|
};
|
|
2646
2713
|
{
|
|
2647
|
-
const { appliedLayout: a } = await
|
|
2714
|
+
const { appliedLayout: a } = await uo(e, t);
|
|
2648
2715
|
return {
|
|
2649
|
-
toolName:
|
|
2716
|
+
toolName: re,
|
|
2650
2717
|
status: "success",
|
|
2651
2718
|
summary: `Successfully applied layout: ${a}.`,
|
|
2652
2719
|
details: {
|
|
@@ -2654,29 +2721,29 @@ const ae = "applyLayout", uo = i.object({
|
|
|
2654
2721
|
}
|
|
2655
2722
|
};
|
|
2656
2723
|
}
|
|
2657
|
-
},
|
|
2658
|
-
name:
|
|
2724
|
+
}, ai = w(ho, {
|
|
2725
|
+
name: re,
|
|
2659
2726
|
description: "Apply a diagram layout to the link chart",
|
|
2660
|
-
schema:
|
|
2727
|
+
schema: po
|
|
2661
2728
|
});
|
|
2662
|
-
async function
|
|
2663
|
-
return
|
|
2664
|
-
}
|
|
2665
|
-
const
|
|
2666
|
-
setting:
|
|
2667
|
-
}),
|
|
2668
|
-
const { view:
|
|
2669
|
-
if (
|
|
2729
|
+
async function mo(e, r) {
|
|
2730
|
+
return r.map?.changeNonspatialDataDisplay(e), await Z(r), { appliedNonspatialDataDisplayMode: e };
|
|
2731
|
+
}
|
|
2732
|
+
const ae = "changeNonspatialVisibility", yo = s.object({
|
|
2733
|
+
setting: s.enum(["hidden", "visible"]).describe("The setting of nonspatial visibility")
|
|
2734
|
+
}), fo = async ({ setting: e }, r) => {
|
|
2735
|
+
const { view: t } = O(r);
|
|
2736
|
+
if (q(t))
|
|
2670
2737
|
return {
|
|
2671
|
-
toolName:
|
|
2738
|
+
toolName: ae,
|
|
2672
2739
|
status: "error",
|
|
2673
2740
|
errorMessage: "The changeNonspatialVisibility tool can only be used with a LinkChartView.",
|
|
2674
2741
|
error: new Error()
|
|
2675
2742
|
};
|
|
2676
2743
|
{
|
|
2677
|
-
const { appliedNonspatialDataDisplayMode: a } = await
|
|
2744
|
+
const { appliedNonspatialDataDisplayMode: a } = await mo(e, t);
|
|
2678
2745
|
return {
|
|
2679
|
-
toolName:
|
|
2746
|
+
toolName: ae,
|
|
2680
2747
|
status: "success",
|
|
2681
2748
|
summary: `Successfully applied nonspatial visibility setting: ${a}.`,
|
|
2682
2749
|
details: {
|
|
@@ -2684,26 +2751,26 @@ const oe = "changeNonspatialVisibility", mo = i.object({
|
|
|
2684
2751
|
}
|
|
2685
2752
|
};
|
|
2686
2753
|
}
|
|
2687
|
-
},
|
|
2688
|
-
name:
|
|
2754
|
+
}, oi = w(fo, {
|
|
2755
|
+
name: ae,
|
|
2689
2756
|
description: "Change whether or not nonspatial data is visible in the link chart. The value must be either 'hidden' or 'visible'.",
|
|
2690
|
-
schema:
|
|
2757
|
+
schema: yo
|
|
2691
2758
|
});
|
|
2692
|
-
async function
|
|
2759
|
+
async function go(e, r, t, a, o) {
|
|
2693
2760
|
let n, l = "";
|
|
2694
|
-
for (let
|
|
2695
|
-
const { graphQuery: c, explanation: u } = await
|
|
2761
|
+
for (let i = 1; i <= D; i++) {
|
|
2762
|
+
const { graphQuery: c, explanation: u } = await de(
|
|
2696
2763
|
e,
|
|
2697
|
-
|
|
2698
|
-
|
|
2764
|
+
r.dataModel,
|
|
2765
|
+
t,
|
|
2699
2766
|
o,
|
|
2700
2767
|
n
|
|
2701
2768
|
);
|
|
2702
2769
|
try {
|
|
2703
2770
|
await S({ text: `Attempting to create link chart from derived query: ${c}` }, o);
|
|
2704
|
-
const d = await
|
|
2705
|
-
|
|
2706
|
-
new
|
|
2771
|
+
const d = await mt.fromCypherQuery(
|
|
2772
|
+
r,
|
|
2773
|
+
new Se({
|
|
2707
2774
|
openCypherQuery: c
|
|
2708
2775
|
})
|
|
2709
2776
|
);
|
|
@@ -2715,39 +2782,39 @@ async function fo(e, t, r, a, o) {
|
|
|
2715
2782
|
${c}
|
|
2716
2783
|
|
|
2717
2784
|
Explanation: ${u}`
|
|
2718
|
-
}) : (await
|
|
2785
|
+
}) : (await Z(a), {
|
|
2719
2786
|
type: "success",
|
|
2720
2787
|
graphQuery: c,
|
|
2721
2788
|
explanation: u
|
|
2722
2789
|
});
|
|
2723
2790
|
} catch (d) {
|
|
2724
|
-
const p =
|
|
2725
|
-
if (
|
|
2791
|
+
const p = P(d);
|
|
2792
|
+
if (i >= D) {
|
|
2726
2793
|
l = p;
|
|
2727
2794
|
break;
|
|
2728
2795
|
}
|
|
2729
2796
|
n = {
|
|
2730
2797
|
failedGraphQuery: c,
|
|
2731
2798
|
executionError: p,
|
|
2732
|
-
attemptCount:
|
|
2799
|
+
attemptCount: i
|
|
2733
2800
|
}, await S(
|
|
2734
|
-
{ text: `Attempt ${
|
|
2801
|
+
{ text: `Attempt ${i} to create link chart failed with error: ${p}. Retrying ...` },
|
|
2735
2802
|
o
|
|
2736
2803
|
);
|
|
2737
2804
|
}
|
|
2738
2805
|
}
|
|
2739
2806
|
return {
|
|
2740
2807
|
type: "error",
|
|
2741
|
-
errorMessage: `Failed to create link chart after ${
|
|
2808
|
+
errorMessage: `Failed to create link chart after ${D} attempts. Last error: ${l}`
|
|
2742
2809
|
};
|
|
2743
2810
|
}
|
|
2744
|
-
const V = "createLinkChart",
|
|
2745
|
-
prompt:
|
|
2746
|
-
"The user's inquiry
|
|
2811
|
+
const V = "createLinkChart", wo = s.object({
|
|
2812
|
+
prompt: s.string().describe(
|
|
2813
|
+
"The user's inquiry and context required in order to generate a cypher query that will be used to create a link chart visualization. Only include information relevant to generating a cypher query. Do not suggest entity types, relationship types or properties. Do not include limits or formatting instructions for the query results unless specifically requested by the user. The prompt should be focused on the data the user wants to see in the link chart, not how to generate it."
|
|
2747
2814
|
)
|
|
2748
|
-
}),
|
|
2749
|
-
const { knowledgeGraph:
|
|
2750
|
-
if (
|
|
2815
|
+
}), bo = async ({ prompt: e }, r) => {
|
|
2816
|
+
const { knowledgeGraph: t } = await M(r), { view: a } = O(r);
|
|
2817
|
+
if (q(a))
|
|
2751
2818
|
return {
|
|
2752
2819
|
toolName: V,
|
|
2753
2820
|
status: "error",
|
|
@@ -2755,12 +2822,14 @@ const V = "createLinkChart", go = i.object({
|
|
|
2755
2822
|
error: new Error()
|
|
2756
2823
|
};
|
|
2757
2824
|
{
|
|
2758
|
-
const n =
|
|
2759
|
-
e
|
|
2760
|
-
|
|
2825
|
+
const n = k.getDefault().helperServices, l = await go(
|
|
2826
|
+
`${e}
|
|
2827
|
+
|
|
2828
|
+
${qe}`,
|
|
2829
|
+
t,
|
|
2761
2830
|
`${n.aiAssistantServices.url}${n.aiAssistantServices.graphQueryAssistant}`,
|
|
2762
2831
|
a,
|
|
2763
|
-
|
|
2832
|
+
r
|
|
2764
2833
|
);
|
|
2765
2834
|
if (l.type === "error")
|
|
2766
2835
|
return {
|
|
@@ -2769,107 +2838,116 @@ const V = "createLinkChart", go = i.object({
|
|
|
2769
2838
|
errorMessage: l.errorMessage,
|
|
2770
2839
|
error: new Error()
|
|
2771
2840
|
};
|
|
2772
|
-
const { graphQuery:
|
|
2841
|
+
const { graphQuery: i, explanation: c } = l;
|
|
2773
2842
|
return {
|
|
2774
2843
|
toolName: V,
|
|
2775
2844
|
status: "success",
|
|
2776
2845
|
summary: `Link chart created successfully. Cypher Query used to create the link chart:
|
|
2777
|
-
${
|
|
2846
|
+
${i}
|
|
2778
2847
|
|
|
2779
2848
|
Explanation: ${c}`,
|
|
2780
2849
|
details: {
|
|
2781
|
-
generatedQuery:
|
|
2850
|
+
generatedQuery: i,
|
|
2782
2851
|
explanation: c
|
|
2783
2852
|
}
|
|
2784
2853
|
};
|
|
2785
2854
|
}
|
|
2786
|
-
},
|
|
2855
|
+
}, ni = w(bo, {
|
|
2787
2856
|
name: V,
|
|
2788
|
-
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.",
|
|
2789
|
-
schema:
|
|
2790
|
-
}),
|
|
2791
|
-
prompt:
|
|
2792
|
-
|
|
2793
|
-
|
|
2794
|
-
REQUEST LIMIT: If the user does not specifically request for no limits or an explicit limit to be placed on the query, or the number of rows will not be limited by e.g. the number of entity or relationship types in the graph, ensure that the generated query has a reasonable row limit (e.g. 10 rows).
|
|
2795
|
-
|
|
2796
|
-
DESCRIPTIVE COLUMN NAMES: If the user's prompt does not explicitly request for specific column names in the result, ensure that the generated query has descriptive column names (using AS statements) to make the results easier to understand when displayed in a table format.`
|
|
2857
|
+
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 using language like 'create new link chart' or 'add to new link chart'.",
|
|
2858
|
+
schema: wo
|
|
2859
|
+
}), oe = "queryGraphData", To = s.object({
|
|
2860
|
+
prompt: s.string().describe(
|
|
2861
|
+
"The user's inquiry into the knowledge graph, from which a cypher query will be generated and executed to answer the inquiry. Only include entity types, relationship types or properties if they are provided in the user prompt or prior steps. Do not suggest entity types, relationship types or properties. Do not include limits, information on what to return, instructions on how to write the query, or formatting instructions for the query results unless specifically requested by the user."
|
|
2797
2862
|
)
|
|
2798
|
-
}),
|
|
2799
|
-
const { knowledgeGraph:
|
|
2863
|
+
}), vo = async ({ prompt: e }, r) => {
|
|
2864
|
+
const { knowledgeGraph: t } = await M(r), o = k.getDefault().helperServices;
|
|
2865
|
+
let n = e, l = null, i = null;
|
|
2866
|
+
try {
|
|
2867
|
+
({ view: i } = O(r));
|
|
2868
|
+
} catch {
|
|
2869
|
+
}
|
|
2870
|
+
i && ({ enhancedPrompt: n, bindParameters: l } = await Ie({
|
|
2800
2871
|
prompt: e,
|
|
2801
|
-
|
|
2872
|
+
view: i,
|
|
2873
|
+
knowledgeGraph: t,
|
|
2874
|
+
includeReturnEntityAndRelationshipContext: !1
|
|
2875
|
+
}));
|
|
2876
|
+
const c = await Ne({
|
|
2877
|
+
prompt: n,
|
|
2878
|
+
bindParameters: l,
|
|
2879
|
+
kg: t,
|
|
2802
2880
|
graphQueryServiceUrl: `${o.aiAssistantServices.url}${o.aiAssistantServices.graphQueryAssistant}`,
|
|
2803
2881
|
targetStructure: new Array(),
|
|
2804
|
-
targetStructureReducer: (
|
|
2882
|
+
targetStructureReducer: (g, T) => (g.push(T), g),
|
|
2805
2883
|
requestOptions: {
|
|
2806
|
-
signal: Y(
|
|
2807
|
-
timeout:
|
|
2884
|
+
signal: Y(r),
|
|
2885
|
+
timeout: r?.timeout
|
|
2808
2886
|
},
|
|
2809
|
-
config:
|
|
2887
|
+
config: r
|
|
2810
2888
|
});
|
|
2811
|
-
if (
|
|
2812
|
-
const
|
|
2889
|
+
if (c.type !== "success") {
|
|
2890
|
+
const g = c.type === "generation-error" ? c.errorMessage : `${c.errorMessage} Cypher query: ${c.graphQuery}`;
|
|
2813
2891
|
return {
|
|
2814
|
-
toolName:
|
|
2892
|
+
toolName: oe,
|
|
2815
2893
|
status: "error",
|
|
2816
|
-
errorMessage: `Failed to query the knowledge graph. ${
|
|
2817
|
-
error: "error" in
|
|
2894
|
+
errorMessage: `Failed to query the knowledge graph. ${g}`,
|
|
2895
|
+
error: "error" in c ? c.error : null
|
|
2818
2896
|
};
|
|
2819
2897
|
}
|
|
2820
|
-
const { graphQuery:
|
|
2821
|
-
for (const
|
|
2822
|
-
for (const
|
|
2823
|
-
|
|
2824
|
-
|
|
2825
|
-
(
|
|
2898
|
+
const { graphQuery: u, explanation: d, processedResult: p, resultHeader: h } = c, f = h.headerKeys;
|
|
2899
|
+
for (const g of p)
|
|
2900
|
+
for (const T of g)
|
|
2901
|
+
z(
|
|
2902
|
+
T,
|
|
2903
|
+
($) => ke($)
|
|
2826
2904
|
);
|
|
2827
|
-
const
|
|
2905
|
+
const y = 50, m = p.slice(0, y).map((g) => JSON.stringify(g));
|
|
2828
2906
|
return {
|
|
2829
|
-
toolName:
|
|
2907
|
+
toolName: oe,
|
|
2830
2908
|
status: "success",
|
|
2831
2909
|
summary: `To answer the inquiry, the following cypher query was executed against the knowledge graph:
|
|
2832
2910
|
|
|
2833
2911
|
\`\`\`cypher
|
|
2834
|
-
${
|
|
2912
|
+
${u}
|
|
2835
2913
|
\`\`\`
|
|
2836
2914
|
|
|
2837
2915
|
Query Results:
|
|
2838
|
-
${
|
|
2916
|
+
${m.length} result(s) found.
|
|
2839
2917
|
|
|
2840
|
-
Column Headers: ${
|
|
2918
|
+
Column Headers: ${f.join(", ")}
|
|
2841
2919
|
|
|
2842
|
-
${
|
|
2920
|
+
${m.length > y ? `Showing top ${y} results:
|
|
2843
2921
|
|
|
2844
2922
|
` : `Results:
|
|
2845
2923
|
|
|
2846
|
-
`}${
|
|
2924
|
+
`}${m.join(`
|
|
2847
2925
|
`)}
|
|
2848
2926
|
`,
|
|
2849
2927
|
details: {
|
|
2850
|
-
generatedQuery:
|
|
2851
|
-
explanation:
|
|
2852
|
-
resultHeader:
|
|
2853
|
-
queryResults:
|
|
2928
|
+
generatedQuery: u,
|
|
2929
|
+
explanation: d,
|
|
2930
|
+
resultHeader: h,
|
|
2931
|
+
queryResults: p
|
|
2854
2932
|
}
|
|
2855
2933
|
};
|
|
2856
|
-
},
|
|
2857
|
-
name:
|
|
2934
|
+
}, ii = w(vo, {
|
|
2935
|
+
name: oe,
|
|
2858
2936
|
description: "Allows users to explore the data in their knowledge graph via cypher query. Generates and executes a cypher query based on the user's inquiry into the knowledge graph, and displays the results in the chat pane without modifying the user's link chart if any. Use this tool when the user is asking an exploratory question about their data as a whole that can be answered via cypher query, for example 'What are the top 5 suppliers by total parts cost?' or 'How many employees do we have in each department?'.",
|
|
2859
|
-
schema:
|
|
2860
|
-
}),
|
|
2861
|
-
prompt:
|
|
2862
|
-
}),
|
|
2863
|
-
const { knowledgeGraph:
|
|
2937
|
+
schema: To
|
|
2938
|
+
}), ne = "generateCypher", So = s.object({
|
|
2939
|
+
prompt: s.string().describe("The user's inquiry into the knowledge graph that needs to be translated into a cypher query.")
|
|
2940
|
+
}), xo = async ({ prompt: e }, r) => {
|
|
2941
|
+
const { knowledgeGraph: t } = await M(r), o = k.getDefault().helperServices;
|
|
2864
2942
|
try {
|
|
2865
|
-
const { graphQuery: n, explanation: l } = await
|
|
2943
|
+
const { graphQuery: n, explanation: l } = await Ya(
|
|
2866
2944
|
e,
|
|
2867
|
-
|
|
2945
|
+
t.dataModel,
|
|
2868
2946
|
`${o.aiAssistantServices.url}${o.aiAssistantServices.graphQueryAssistant}`,
|
|
2869
|
-
|
|
2947
|
+
r
|
|
2870
2948
|
);
|
|
2871
2949
|
return {
|
|
2872
|
-
toolName:
|
|
2950
|
+
toolName: ne,
|
|
2873
2951
|
status: "success",
|
|
2874
2952
|
summary: `Generated Graph Query:
|
|
2875
2953
|
${n}
|
|
@@ -2881,94 +2959,95 @@ Explanation: ${l}`,
|
|
|
2881
2959
|
}
|
|
2882
2960
|
};
|
|
2883
2961
|
} catch (n) {
|
|
2884
|
-
const l =
|
|
2962
|
+
const l = P(n);
|
|
2885
2963
|
return {
|
|
2886
|
-
toolName:
|
|
2964
|
+
toolName: ne,
|
|
2887
2965
|
status: "error",
|
|
2888
2966
|
errorMessage: `Failed to generate Cypher query. ${l}`,
|
|
2889
2967
|
error: n
|
|
2890
2968
|
};
|
|
2891
2969
|
}
|
|
2892
|
-
},
|
|
2893
|
-
name:
|
|
2970
|
+
}, si = w(xo, {
|
|
2971
|
+
name: ne,
|
|
2894
2972
|
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.",
|
|
2895
|
-
schema:
|
|
2896
|
-
}),
|
|
2897
|
-
const
|
|
2898
|
-
for (const
|
|
2899
|
-
if (
|
|
2900
|
-
for (const [c, u] of
|
|
2901
|
-
const d =
|
|
2902
|
-
u.propertyNames.forEach((p) => d.add(p)),
|
|
2973
|
+
schema: So
|
|
2974
|
+
}), Ro = (e) => {
|
|
2975
|
+
const r = e.dataModel, t = /* @__PURE__ */ new Map();
|
|
2976
|
+
for (const i of r.searchIndexes)
|
|
2977
|
+
if (i.supportedCategory !== "esriTypeMetaEntityProvenance")
|
|
2978
|
+
for (const [c, u] of i.searchProperties.entries()) {
|
|
2979
|
+
const d = t.get(c) ?? /* @__PURE__ */ new Set();
|
|
2980
|
+
u.propertyNames.forEach((p) => d.add(p)), t.set(c, d);
|
|
2903
2981
|
}
|
|
2904
|
-
const a =
|
|
2905
|
-
${a.map(({ name:
|
|
2982
|
+
const a = r.entityTypes.filter((i) => t.has(i.name)), o = r.relationshipTypes.filter((i) => t.has(i.name)), n = `Entity Types:
|
|
2983
|
+
${a.map(({ name: i }) => `${i}: [${Array.from(t.get(i) ?? []).join(", ")}]`).join(`
|
|
2906
2984
|
`)}`, l = `Relationship Types:
|
|
2907
|
-
${o.map(({ name:
|
|
2985
|
+
${o.map(({ name: i }) => `${i}: [${Array.from(t.get(i) ?? []).join(", ")}]`).join(`
|
|
2908
2986
|
`)}`;
|
|
2909
2987
|
return `${n}
|
|
2910
2988
|
|
|
2911
2989
|
${l}`;
|
|
2912
2990
|
};
|
|
2913
|
-
async function
|
|
2914
|
-
const
|
|
2991
|
+
async function $o(e, r, t) {
|
|
2992
|
+
const a = await U("arcgis_knowledge_lucene_generation_prompt"), o = {
|
|
2915
2993
|
inquiry: e,
|
|
2916
|
-
dataModelForSearch:
|
|
2917
|
-
},
|
|
2994
|
+
dataModelForSearch: Ro(r)
|
|
2995
|
+
}, n = s.enum(["entity", "relationship", "both"]).describe("The graph element category to search against - entity, relationship, or both"), l = s.number().int().positive().nullable().describe(
|
|
2918
2996
|
"The maximum number of search results to return. Default to 10 if not specified by the user, or set to null if the user specifically requests no limits or all results."
|
|
2919
|
-
),
|
|
2920
|
-
|
|
2921
|
-
|
|
2997
|
+
), i = s.array(
|
|
2998
|
+
s.enum(
|
|
2999
|
+
r.dataModel.entityTypes.map((d) => d.name).concat(r.dataModel.relationshipTypes.map((d) => d.name))
|
|
2922
3000
|
)
|
|
2923
|
-
).min(1),
|
|
2924
|
-
query:
|
|
2925
|
-
typeFilters:
|
|
3001
|
+
).min(1), c = s.object({
|
|
3002
|
+
query: s.string().describe("A lucene syntax query string to be executed against the knowledge graph search API"),
|
|
3003
|
+
typeFilters: i.nullable().describe(
|
|
2926
3004
|
"Nullable list of entity or relationship types from the graph to limit the search to. If set to null, search will execute against all named types with indexed properties in the graph"
|
|
2927
3005
|
),
|
|
2928
|
-
typeCategoryFilter:
|
|
2929
|
-
resultLimit:
|
|
3006
|
+
typeCategoryFilter: n,
|
|
3007
|
+
resultLimit: l
|
|
2930
3008
|
});
|
|
2931
|
-
return await
|
|
2932
|
-
promptText:
|
|
2933
|
-
inputVariables:
|
|
2934
|
-
schema:
|
|
3009
|
+
return await Pe({
|
|
3010
|
+
promptText: a,
|
|
3011
|
+
inputVariables: o,
|
|
3012
|
+
schema: c,
|
|
3013
|
+
config: t
|
|
2935
3014
|
});
|
|
2936
3015
|
}
|
|
2937
|
-
const
|
|
2938
|
-
prompt:
|
|
3016
|
+
const ie = "searchGraphData", Co = s.object({
|
|
3017
|
+
prompt: s.string().describe(
|
|
2939
3018
|
"The user's inquiry into the knowledge graph, from which a lucene search query will be generated and executed against the graph to return relevant results."
|
|
2940
3019
|
)
|
|
2941
|
-
}),
|
|
2942
|
-
const { knowledgeGraph:
|
|
2943
|
-
await S({ text: "Generating search query for the user inquiry" },
|
|
2944
|
-
const a = await
|
|
2945
|
-
await S({ text: "Executing graph search with generated search query" },
|
|
2946
|
-
const o = await
|
|
2947
|
-
kg:
|
|
3020
|
+
}), Eo = async ({ prompt: e }, r) => {
|
|
3021
|
+
const { knowledgeGraph: t } = await M(r);
|
|
3022
|
+
await S({ text: "Generating search query for the user inquiry" }, r);
|
|
3023
|
+
const a = await $o(e, t, r);
|
|
3024
|
+
await S({ text: "Executing graph search with generated search query" }, r);
|
|
3025
|
+
const o = await io({
|
|
3026
|
+
kg: t,
|
|
2948
3027
|
searchQuery: a.query,
|
|
2949
3028
|
typeCategoryFilter: a.typeCategoryFilter,
|
|
2950
3029
|
namedTypesFilter: a.typeFilters,
|
|
2951
3030
|
searchResultLimit: a.resultLimit,
|
|
2952
3031
|
requestOptions: {
|
|
2953
|
-
signal: Y(
|
|
2954
|
-
timeout:
|
|
3032
|
+
signal: Y(r),
|
|
3033
|
+
timeout: r?.timeout
|
|
2955
3034
|
}
|
|
2956
3035
|
});
|
|
2957
3036
|
if (o.type !== "success")
|
|
2958
3037
|
return {
|
|
2959
|
-
toolName:
|
|
3038
|
+
toolName: ie,
|
|
2960
3039
|
status: "error",
|
|
2961
3040
|
errorMessage: o.errorMessage,
|
|
2962
3041
|
error: "error" in o ? o.error : null
|
|
2963
3042
|
};
|
|
2964
|
-
for (const
|
|
2965
|
-
|
|
2966
|
-
|
|
3043
|
+
for (const i of o.results)
|
|
3044
|
+
z(
|
|
3045
|
+
i,
|
|
2967
3046
|
(c) => ke(c)
|
|
2968
3047
|
);
|
|
2969
3048
|
const n = 10, l = o.results.slice(0, n);
|
|
2970
3049
|
return {
|
|
2971
|
-
toolName:
|
|
3050
|
+
toolName: ie,
|
|
2972
3051
|
status: "success",
|
|
2973
3052
|
summary: `To answer the query, the following lucene query was generated and executed:
|
|
2974
3053
|
Query: ${a.query}
|
|
@@ -2980,63 +3059,72 @@ const se = "searchGraphData", $o = i.object({
|
|
|
2980
3059
|
|
|
2981
3060
|
${o.results.length > n ? `Showing top ${n} results:
|
|
2982
3061
|
|
|
2983
|
-
` : ""}${l.map((
|
|
3062
|
+
` : ""}${l.map((i) => JSON.stringify(i)).join(`
|
|
2984
3063
|
`)}`,
|
|
2985
3064
|
details: {
|
|
2986
3065
|
generatedSearchQuery: a,
|
|
2987
3066
|
searchResults: o.results
|
|
2988
3067
|
}
|
|
2989
3068
|
};
|
|
2990
|
-
},
|
|
2991
|
-
name:
|
|
2992
|
-
description:
|
|
2993
|
-
|
|
3069
|
+
}, li = w(Eo, {
|
|
3070
|
+
name: ie,
|
|
3071
|
+
description: `
|
|
3072
|
+
Search the knowledge graph using one or more search texts, using lucene search syntax, against indexed string properties defined on their entities and relationships. Use this tool when the user asks a question about their knowledge graph data as a whole, that could be answered via lucene text search of properties stored on graph elements, e.g requiring fuzzy matching. Otherwise if the inquiry is looking for connected records (e.g. paths), data aggregations, etc explore the data via the queryGraphData tool.
|
|
3073
|
+
Example prompts:
|
|
3074
|
+
- "Find 'Bradley'"
|
|
3075
|
+
- "find the person john smith"
|
|
3076
|
+
- "find all people named smith"
|
|
3077
|
+
- "Find all references to 'delayed parts shipment'"
|
|
3078
|
+
- "Find all reports authored by someone with the title of 'Researcher'"
|
|
3079
|
+
- "Find the first 5 reports where summary mentions flood zoning near Sacramento, and the organization name is the City of Sacramento Utilities, and tags containing stormwater".
|
|
3080
|
+
- "Search for all john smiths and show their global ids`,
|
|
3081
|
+
schema: Co
|
|
2994
3082
|
});
|
|
2995
3083
|
export {
|
|
2996
|
-
|
|
3084
|
+
jn as A,
|
|
2997
3085
|
Ln as B,
|
|
2998
|
-
|
|
2999
|
-
|
|
3000
|
-
|
|
3001
|
-
|
|
3002
|
-
|
|
3003
|
-
|
|
3004
|
-
|
|
3005
|
-
|
|
3006
|
-
|
|
3007
|
-
|
|
3008
|
-
|
|
3009
|
-
|
|
3010
|
-
|
|
3011
|
-
|
|
3012
|
-
|
|
3013
|
-
|
|
3086
|
+
Gn as C,
|
|
3087
|
+
On as D,
|
|
3088
|
+
Mn as E,
|
|
3089
|
+
Qn as F,
|
|
3090
|
+
ue as G,
|
|
3091
|
+
Yn as H,
|
|
3092
|
+
_n as I,
|
|
3093
|
+
Wn as J,
|
|
3094
|
+
Vn as K,
|
|
3095
|
+
Un as L,
|
|
3096
|
+
Bn as M,
|
|
3097
|
+
$n as N,
|
|
3098
|
+
Hn as O,
|
|
3099
|
+
Jn as P,
|
|
3100
|
+
Qa as Q,
|
|
3101
|
+
N as R,
|
|
3014
3102
|
Kn as S,
|
|
3015
|
-
|
|
3016
|
-
|
|
3017
|
-
|
|
3018
|
-
|
|
3019
|
-
|
|
3020
|
-
|
|
3021
|
-
|
|
3022
|
-
|
|
3023
|
-
|
|
3024
|
-
|
|
3025
|
-
|
|
3026
|
-
|
|
3027
|
-
|
|
3028
|
-
|
|
3029
|
-
|
|
3030
|
-
|
|
3031
|
-
|
|
3032
|
-
|
|
3033
|
-
|
|
3034
|
-
|
|
3035
|
-
|
|
3036
|
-
|
|
3037
|
-
|
|
3103
|
+
Zn as T,
|
|
3104
|
+
ai as a,
|
|
3105
|
+
si as b,
|
|
3106
|
+
oi as c,
|
|
3107
|
+
ni as d,
|
|
3108
|
+
ri as e,
|
|
3109
|
+
xe as f,
|
|
3110
|
+
U as g,
|
|
3111
|
+
ti as h,
|
|
3112
|
+
M as i,
|
|
3113
|
+
ei as j,
|
|
3114
|
+
Cn as k,
|
|
3115
|
+
Xn as l,
|
|
3116
|
+
En as m,
|
|
3117
|
+
Fn as n,
|
|
3118
|
+
kn as o,
|
|
3119
|
+
Nn as p,
|
|
3120
|
+
ii as q,
|
|
3121
|
+
Pn as r,
|
|
3122
|
+
li as s,
|
|
3123
|
+
Ut as t,
|
|
3124
|
+
qn as u,
|
|
3125
|
+
In as v,
|
|
3038
3126
|
zn as w,
|
|
3039
|
-
|
|
3040
|
-
|
|
3127
|
+
Dn as x,
|
|
3128
|
+
C as y,
|
|
3041
3129
|
An as z
|
|
3042
3130
|
};
|