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