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