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