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