@arcgis/ai-components 5.2.0-next.72 → 5.2.0-next.74
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agent-utils/LLMAgent.d.ts +5 -2
- package/dist/agent-utils/LLMAgent.js +1 -1
- package/dist/agentic-workflow/jsonTypes.d.ts +8 -1
- package/dist/agentic-workflow/nodes/AgentNode.d.ts +2 -0
- package/dist/agentic-workflow/nodes/tools/ArcgisTool.d.ts +21 -0
- package/dist/cdn/253R5CBD.js +2 -0
- package/dist/cdn/2VBPA27M.js +18 -0
- package/dist/cdn/{DWYODVWW.js → 323DHVYA.js} +5 -5
- package/dist/cdn/34O57OGV.js +2 -0
- package/dist/cdn/{FSMHR7GK.js → 4HDDRBIY.js} +1 -1
- package/dist/cdn/4MFEKBKL.js +11 -0
- package/dist/cdn/{Y5UFOH54.js → 4NJ2FF7H.js} +1 -1
- package/dist/cdn/4YXYLX4H.js +2 -0
- package/dist/cdn/5DVRVY4L.js +2 -0
- package/dist/cdn/5PJXNTLZ.js +2 -0
- package/dist/cdn/5R6QUF5B.js +2 -0
- package/dist/cdn/5RVELJU4.js +36 -0
- package/dist/cdn/5WLNL4HZ.js +2 -0
- package/dist/cdn/66SKMECC.js +2 -0
- package/dist/cdn/6CLF7KIK.js +2 -0
- package/dist/cdn/{S6ZAQRC6.js → 6KFMRBAA.js} +1 -1
- package/dist/cdn/77QFSIWW.js +5 -0
- package/dist/cdn/7E2QMWK6.js +2 -0
- package/dist/cdn/{HO2YDJI2.js → 7M6VKBTK.js} +1 -1
- package/dist/cdn/{HJG7QM2R.js → 7VAQUCBU.js} +1 -1
- package/dist/cdn/ACJTJLZN.js +2 -0
- package/dist/cdn/AI6DYOKR.js +181 -0
- package/dist/cdn/AT4XVTJR.js +44 -0
- package/dist/cdn/BS2PFNU4.js +2 -0
- package/dist/cdn/CCC6LBMY.js +2 -0
- package/dist/cdn/CGXQAB3A.js +2 -0
- package/dist/cdn/{M3MRIGDZ.js → CP5BVGJU.js} +1 -1
- package/dist/cdn/CWD37QFT.js +2 -0
- package/dist/cdn/DY36ATOA.js +2 -0
- package/dist/cdn/DYASSC7Z.js +2 -0
- package/dist/cdn/EAEQONP7.js +2 -0
- package/dist/cdn/EMLOVMD4.js +2 -0
- package/dist/cdn/EWLXNGKH.js +208 -0
- package/dist/cdn/FAR3DFFK.js +2 -0
- package/dist/cdn/FDOMMK2M.js +2 -0
- package/dist/cdn/GRHIFCQX.js +2 -0
- package/dist/cdn/{S3XUYAUX.js → HHFNQR6Z.js} +1 -1
- package/dist/cdn/{WQKNV6KK.js → HMUWQCXU.js} +1 -1
- package/dist/cdn/HZ5ARNAM.js +2 -0
- package/dist/cdn/I6PD2HSL.js +2 -0
- package/dist/cdn/IDUC4CPV.js +2 -0
- package/dist/cdn/IRNSIUBT.js +2 -0
- package/dist/cdn/{OYNIFMCJ.js → J6SZIQJA.js} +1 -1
- package/dist/cdn/K335IAIE.js +2 -0
- package/dist/cdn/K33MZ726.js +2 -0
- package/dist/cdn/KA3FF3ZO.js +2 -0
- package/dist/cdn/{DBHLKLKM.js → KPO4XX6J.js} +1 -1
- package/dist/cdn/{I4L45WQS.js → L7XTRDFM.js} +1 -1
- package/dist/cdn/LCFIADOZ.js +2 -0
- package/dist/cdn/MDM2K3U7.js +2 -0
- package/dist/cdn/MM33KJPF.js +2 -0
- package/dist/cdn/NIY32GK2.js +2 -0
- package/dist/cdn/{3ZPPYCNL.js → ONMNQBPO.js} +1 -1
- package/dist/cdn/ONQ6JSBJ.js +2 -0
- package/dist/cdn/{6QJFOL6M.js → OWTGH34K.js} +1 -1
- package/dist/cdn/{XPTCV6YV.js → PSYRZMX2.js} +1 -1
- package/dist/cdn/Q4IQUEZN.js +14 -0
- package/dist/cdn/QNNGPA3Q.js +2 -0
- package/dist/cdn/QRHZXLZN.js +2 -0
- package/dist/cdn/QVOMX3R6.js +2 -0
- package/dist/cdn/QZ3NQTNQ.js +2 -0
- package/dist/cdn/RADWN4ZP.js +2 -0
- package/dist/cdn/RU2T7GUX.js +2 -0
- package/dist/cdn/S6OYR4VI.js +156 -0
- package/dist/cdn/T2GJLEYV.js +2 -0
- package/dist/cdn/TKYI5QRL.js +2 -0
- package/dist/cdn/{5SFZS2RD.js → TQXLSW4A.js} +2 -2
- package/dist/cdn/{NJJYZP3R.js → U6FBRUM4.js} +1 -1
- package/dist/cdn/UIXX3XEN.js +2 -0
- package/dist/cdn/UPWAOZXQ.js +2 -0
- package/dist/cdn/{5SF6DEMO.js → VNJMTA6O.js} +1 -1
- package/dist/cdn/VOKXKU7M.js +56 -0
- package/dist/cdn/{33BF35AO.js → VYTYVWR6.js} +4 -4
- package/dist/cdn/WMZ24LWS.js +2 -0
- package/dist/cdn/{JYVBCHR6.js → WP7ORLSB.js} +1 -1
- package/dist/cdn/WS3T73IY.js +2 -0
- package/dist/cdn/{UZL6UVE4.js → ZLWWWTH4.js} +1 -1
- package/dist/cdn/{PAUIFUMO.js → ZQMBJ6MI.js} +1 -1
- 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 +938 -1938
- 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/dataExplorationGraph.js +30 -27
- 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 +145 -148
- 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 +68 -57
- package/dist/chunks/types.js +59 -0
- package/dist/components/arcgis-assistant-agent/customElement.js +404 -279
- 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/web-types.json +1 -1
- package/dist/types/stencil.d.ts +2 -2
- package/dist/utils/index.d.ts +4 -5
- package/dist/utils/index.js +19 -20
- package/package.json +8 -8
- package/dist/cdn/55M2HE4U.js +0 -2
- package/dist/cdn/5RZGG4F2.js +0 -2
- package/dist/cdn/BAB3MK4Y.js +0 -2
- package/dist/cdn/BMBV6Y2A.js +0 -2
- package/dist/cdn/D3RKQSWS.js +0 -2
- package/dist/cdn/E7KEOJZG.js +0 -208
- package/dist/cdn/IGQFAL3H.js +0 -2
- package/dist/cdn/LUY6V4TP.js +0 -181
- package/dist/cdn/NSXX2KYS.js +0 -2
- package/dist/cdn/OFRFP4BX.js +0 -2
- package/dist/cdn/OUFGJV3R.js +0 -2
- package/dist/cdn/RWM5T4XB.js +0 -180
- package/dist/cdn/SRFLL6ET.js +0 -2
- package/dist/cdn/WDOM6Z5O.js +0 -18
- package/dist/cdn/WZFC5HUX.js +0 -56
- package/dist/cdn/Z4XUJQ2I.js +0 -36
- package/dist/cdn/ZJEWP2ND.js +0 -44
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 { i as
|
|
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 { b as
|
|
16
|
-
import
|
|
17
|
-
import
|
|
18
|
-
import {
|
|
19
|
-
import
|
|
20
|
-
import
|
|
21
|
-
import
|
|
22
|
-
import
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
26
|
-
import {
|
|
27
|
-
import {
|
|
28
|
-
import { getSchemesByTag as
|
|
29
|
-
import {
|
|
30
|
-
import {
|
|
31
|
-
import {
|
|
32
|
-
import {
|
|
33
|
-
import {
|
|
34
|
-
import { createRenderer as
|
|
35
|
-
import { getSchemesByTag as
|
|
36
|
-
import {
|
|
37
|
-
import {
|
|
38
|
-
import {
|
|
39
|
-
import {
|
|
40
|
-
import {
|
|
41
|
-
import {
|
|
42
|
-
import
|
|
43
|
-
import
|
|
44
|
-
import
|
|
45
|
-
import
|
|
46
|
-
import ut from "@arcgis/core/smartMapping/statistics/summaryStatistics.js";
|
|
47
|
-
import dt from "@arcgis/core/smartMapping/statistics/uniqueValues.js";
|
|
48
|
-
import pt from "@arcgis/core/rest/support/TopFeaturesQuery.js";
|
|
49
|
-
import mt from "@arcgis/core/rest/support/TopFilter.js";
|
|
50
|
-
import ht from "@arcgis/core/WebLinkChart.js";
|
|
51
|
-
import Se 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";
|
|
52
46
|
import "@arcgis/core/views/LinkChartView.js";
|
|
53
|
-
import { fetchKnowledgeGraph as
|
|
54
|
-
import
|
|
55
|
-
import { getBindParametersFromCypherQuery as
|
|
56
|
-
const
|
|
57
|
-
...
|
|
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(),
|
|
58
52
|
// internal to the navigation agent
|
|
59
|
-
intent:
|
|
60
|
-
reducer:
|
|
53
|
+
intent: m({
|
|
54
|
+
reducer: k
|
|
61
55
|
}),
|
|
62
|
-
vectorSearchLayerResults:
|
|
63
|
-
reducer:
|
|
56
|
+
vectorSearchLayerResults: m({
|
|
57
|
+
reducer: k,
|
|
64
58
|
default: () => []
|
|
65
59
|
}),
|
|
66
|
-
vectorSearchFieldResults:
|
|
67
|
-
reducer:
|
|
60
|
+
vectorSearchFieldResults: m({
|
|
61
|
+
reducer: k
|
|
68
62
|
}),
|
|
69
|
-
navigationInternalState:
|
|
70
|
-
reducer:
|
|
63
|
+
navigationInternalState: m({
|
|
64
|
+
reducer: k,
|
|
71
65
|
default: () => ({
|
|
72
66
|
toolCallMessage: void 0
|
|
73
67
|
})
|
|
74
68
|
})
|
|
75
|
-
})
|
|
76
|
-
async function bt(e, t) {
|
|
77
|
-
const a = k.getDefault().helperServices, o = a.geocode.find((m) => m.name === "ArcGIS World Geocoding Service") ?? a.geocode[0];
|
|
78
|
-
if (!o)
|
|
79
|
-
throw new Error("No geocoding service found in helperServices.");
|
|
80
|
-
const n = o.url, l = `${Z.assetsPath?.endsWith("/") ? Z.assetsPath : `${Z.assetsPath}/`}esri/images/search/search-symbol-32.png`, c = (await je(n, {
|
|
81
|
-
address: { SingleLine: e },
|
|
82
|
-
outFields: ["Match_addr"]
|
|
83
|
-
}))?.[0];
|
|
84
|
-
if (!c?.extent || !c.location)
|
|
85
|
-
throw new Error(`Could not find location for: ${e}`);
|
|
86
|
-
const u = new Ge({
|
|
87
|
-
url: l,
|
|
88
|
-
width: 24,
|
|
89
|
-
height: 24
|
|
90
|
-
}), d = new Le({
|
|
91
|
-
geometry: c.location,
|
|
92
|
-
symbol: u
|
|
93
|
-
});
|
|
94
|
-
t.graphics.removeAll(), t.graphics.add(d), await t.goTo(c.extent);
|
|
95
|
-
const p = {
|
|
96
|
-
address: c.address ?? "",
|
|
97
|
-
location: c.location ? c.location.toJSON() : null,
|
|
98
|
-
extent: c.extent ? c.extent.toJSON() : null
|
|
99
|
-
};
|
|
100
|
-
return {
|
|
101
|
-
text: `Successfully zoomed to ${e}.`,
|
|
102
|
-
sharedStatePatch: { lastResolvedLocation: { value: p } }
|
|
103
|
-
};
|
|
104
|
-
}
|
|
105
|
-
function v(e, t) {
|
|
106
|
-
const a = e?.configurable?.context;
|
|
107
|
-
if (!a || typeof a != "object")
|
|
108
|
-
throw new Error("Agent context missing");
|
|
109
|
-
const o = t.filter((n) => !(n in a));
|
|
110
|
-
if (o.length)
|
|
111
|
-
throw new Error(`Agent context missing: ${o.join(", ")}`);
|
|
112
|
-
return a;
|
|
113
|
-
}
|
|
114
|
-
async function Tt({ address: e }, t) {
|
|
115
|
-
const { mapView: r } = v(t, ["mapView"]);
|
|
116
|
-
return await bt(e, r);
|
|
117
|
-
}
|
|
118
|
-
const St = s.object({
|
|
119
|
-
address: s.string().describe("The full address or place name to locate.")
|
|
120
|
-
}), In = f(Tt, {
|
|
121
|
-
name: "goToAddress",
|
|
122
|
-
description: "Geocodes an address using Esri's World Geocoding Service and zooms the map to that location.",
|
|
123
|
-
schema: St
|
|
124
|
-
});
|
|
125
|
-
async function vt(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 xt({ bookmarkName: e }, t) {
|
|
138
|
-
const { mapView: r } = v(t, ["mapView"]);
|
|
139
|
-
return await Promise.resolve(vt(e, r));
|
|
140
|
-
}
|
|
141
|
-
const Rt = E.object({
|
|
142
|
-
bookmarkName: E.string().describe("The name of the bookmark to navigate to.")
|
|
143
|
-
}), qn = f(xt, {
|
|
144
|
-
name: "goToBookmark",
|
|
145
|
-
description: "Go to the extent of the bookmark with the given name.",
|
|
146
|
-
schema: Rt
|
|
147
|
-
});
|
|
148
|
-
async function $t(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 Ct({ layerId: e, where: t }, r) {
|
|
178
|
-
const { mapView: a } = v(r, ["mapView"]);
|
|
179
|
-
return await $t(e, t, a);
|
|
180
|
-
}
|
|
181
|
-
const Et = 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
|
-
}), zn = f(Ct, {
|
|
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: Et
|
|
190
|
-
});
|
|
191
|
-
async function Ft(e) {
|
|
192
|
-
const r = new Oe({
|
|
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 kt(e, t) {
|
|
202
|
-
const { mapView: r } = v(t, ["mapView"]);
|
|
203
|
-
return await Ft(r);
|
|
204
|
-
}
|
|
205
|
-
const Nt = E.object({}), Dn = f(kt, {
|
|
206
|
-
name: "goToFullExtent",
|
|
207
|
-
description: "Zooms the map to the full world extent using Esri's Geocoding Service.",
|
|
208
|
-
schema: Nt
|
|
209
|
-
});
|
|
210
|
-
async function It(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 qt(e, t) {
|
|
219
|
-
const { mapView: r } = v(t, ["mapView"]);
|
|
220
|
-
return await It(r);
|
|
221
|
-
}
|
|
222
|
-
const zt = s.object({}), Pn = f(qt, {
|
|
223
|
-
name: "goToHomeExtent",
|
|
224
|
-
description: "Go to the initial web map view extent",
|
|
225
|
-
schema: zt
|
|
226
|
-
});
|
|
227
|
-
async function Dt(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 Pt({ layerId: e }, t) {
|
|
236
|
-
const { mapView: r } = v(t, ["mapView"]);
|
|
237
|
-
return await Dt(e, r);
|
|
238
|
-
}
|
|
239
|
-
const At = E.object({
|
|
240
|
-
layerId: E.string().describe("The id of the layer to navigate to")
|
|
241
|
-
}), An = f(Pt, {
|
|
242
|
-
name: "goToLayer",
|
|
243
|
-
description: "Zooms the map view to the full extent of the top matching layer.",
|
|
244
|
-
schema: At
|
|
245
|
-
});
|
|
246
|
-
async function Lt(e, t) {
|
|
247
|
-
return await t.goTo({ scale: e }), { text: `Successfully zoomed to: ${e}` };
|
|
248
|
-
}
|
|
249
|
-
async function jt({ scale: e }, t) {
|
|
250
|
-
const { mapView: r } = v(t, ["mapView"]);
|
|
251
|
-
return await Lt(e, r);
|
|
252
|
-
}
|
|
253
|
-
const Gt = s.object({
|
|
254
|
-
scale: s.number().describe("The map scale of the view to go to.")
|
|
255
|
-
}), Ln = f(jt, {
|
|
256
|
-
name: "goToScale",
|
|
257
|
-
description: "Go to the specified view scale.",
|
|
258
|
-
schema: Gt
|
|
259
|
-
});
|
|
260
|
-
async function Ot(e, t, r) {
|
|
261
|
-
const o = {
|
|
262
|
-
target: new be({
|
|
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 Mt({
|
|
275
|
-
center: e,
|
|
276
|
-
zoom: t,
|
|
277
|
-
scale: r
|
|
278
|
-
}, a) {
|
|
279
|
-
const { mapView: o } = v(a, ["mapView"]);
|
|
280
|
-
return await Ot(e, o, { zoom: t, scale: r });
|
|
281
|
-
}
|
|
282
|
-
const Qt = 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
|
-
}), jn = f(Mt, {
|
|
290
|
-
name: "goToViewpoint",
|
|
291
|
-
description: "Go to the specified viewpoint. This can contain a combination of scale, center, zoom, etc.",
|
|
292
|
-
schema: Qt
|
|
293
|
-
});
|
|
294
|
-
async function Vt(e, t) {
|
|
295
|
-
return await t.goTo({ zoom: e }), { text: `Successfully zoomed to: ${e}` };
|
|
296
|
-
}
|
|
297
|
-
async function _t({ zoom: e }, t) {
|
|
298
|
-
const { mapView: r } = v(t, ["mapView"]);
|
|
299
|
-
return await Vt(e, r);
|
|
300
|
-
}
|
|
301
|
-
const Wt = s.object({
|
|
302
|
-
zoom: s.number().min(1).max(20).describe("The zoom level of the view to go to.")
|
|
303
|
-
}), Gn = f(_t, {
|
|
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: Wt
|
|
307
|
-
}), fe = /* @__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 Wt = 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
|
-
}, On = (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 Zt = 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 hr(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 gr({
|
|
|
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 wr = 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 vr({
|
|
|
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 Fr = 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,11 +725,11 @@ async function qr({
|
|
|
968
725
|
colorSchemes: r
|
|
969
726
|
});
|
|
970
727
|
}
|
|
971
|
-
const zr =
|
|
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.
|
|
@@ -981,142 +738,142 @@ const zr = s.object({
|
|
|
981
738
|
Fields: This style requires two number fields.`,
|
|
982
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,76 +886,76 @@ 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
891
|
function _r(e) {
|
|
1135
|
-
const { fields: t, layer: r, view: a, colorSchemeTags: o } = e,
|
|
1136
|
-
let
|
|
1137
|
-
return o && (
|
|
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 Kr =
|
|
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.
|
|
@@ -1206,883 +963,139 @@ Keywords: categorical, category, type, unique, discrete, point of interest, regi
|
|
|
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
965
|
schema: Kr
|
|
1209
|
-
}),
|
|
1210
|
-
...
|
|
1211
|
-
vectorSearchLayerIds:
|
|
1212
|
-
vectorSearchFieldResults:
|
|
1213
|
-
layerFieldInfo:
|
|
1214
|
-
selectedLayerId:
|
|
1215
|
-
}),
|
|
1216
|
-
...
|
|
1217
|
-
vectorSearchLayerIds:
|
|
1218
|
-
vectorSearchFieldResults:
|
|
1219
|
-
layerFieldInfo:
|
|
1220
|
-
queryResponse:
|
|
1221
|
-
dataExplorationMessages:
|
|
1222
|
-
reducer:
|
|
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
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
const
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
const { mapView: r } = v(t, ["mapView"]);
|
|
1234
|
-
return Hr(r);
|
|
1235
|
-
}, Yr = f(Jr, {
|
|
1236
|
-
name: "clearFilters",
|
|
1237
|
-
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.",
|
|
1238
|
-
schema: s.object({})
|
|
1239
|
-
}), Zr = async (e) => {
|
|
1240
|
-
e.map?.allLayers.filter((o) => o.type === "feature")?.forEach((o) => {
|
|
1241
|
-
const n = o;
|
|
1242
|
-
n.featureEffect && (n.featureEffect = null);
|
|
1243
|
-
});
|
|
1244
|
-
const a = e.map.initialViewProperties?.viewpoint?.targetGeometry;
|
|
1245
|
-
return a ? (await e.goTo(a), "Cleared all filters and returned to home extent.") : "Cleared all filters. Could not determine home extent.";
|
|
1246
|
-
}, Xr = async (e, t) => {
|
|
1247
|
-
const { mapView: r } = v(t, ["mapView"]);
|
|
1248
|
-
return await Zr(r);
|
|
1249
|
-
}, ea = f(Xr, {
|
|
1250
|
-
name: "resetMap",
|
|
1251
|
-
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.",
|
|
1252
|
-
schema: s.object({})
|
|
1253
|
-
}), ge = 750;
|
|
1254
|
-
function B(e) {
|
|
1255
|
-
return "point" in e && e.point !== void 0;
|
|
1256
|
-
}
|
|
1257
|
-
function L(e) {
|
|
1258
|
-
return "layerId" in e && e.layerId !== void 0;
|
|
1259
|
-
}
|
|
1260
|
-
const H = async (e, t) => {
|
|
1261
|
-
if (B(e)) {
|
|
1262
|
-
const { point: r } = e;
|
|
1263
|
-
return { geometry: new be({
|
|
1264
|
-
x: r.x,
|
|
1265
|
-
y: r.y,
|
|
1266
|
-
spatialReference: r.spatialReference ? { wkid: r.spatialReference.wkid } : t.spatialReference
|
|
1267
|
-
}) };
|
|
1268
|
-
}
|
|
1269
|
-
if (L(e)) {
|
|
1270
|
-
const r = t.map?.allLayers.find(
|
|
1271
|
-
(n) => n.id === e.layerId
|
|
1272
|
-
);
|
|
1273
|
-
if (!r)
|
|
1274
|
-
return { error: `Could not find geometry layer with ID: ${e.layerId}` };
|
|
1275
|
-
const a = r.title ?? r.id, o = e.where?.trim() || "1=1";
|
|
1276
|
-
try {
|
|
1277
|
-
const n = await r.queryFeatures({
|
|
1278
|
-
where: o,
|
|
1279
|
-
returnGeometry: !0,
|
|
1280
|
-
outSpatialReference: t.spatialReference,
|
|
1281
|
-
num: ge + 1
|
|
1282
|
-
});
|
|
1283
|
-
if (!n.features.length)
|
|
1284
|
-
return {
|
|
1285
|
-
error: `No features found in geometry layer "${a}" with the specified where clause: ${o}`
|
|
1286
|
-
};
|
|
1287
|
-
if (n.features.length > ge)
|
|
1288
|
-
return {
|
|
1289
|
-
error: `Geometry filter for layer "${a}" matched too many features (${n.features.length}+). Please narrow the geometry layer filter.`
|
|
1290
|
-
};
|
|
1291
|
-
const l = n.features.map((c) => c.geometry).filter((c) => !!c);
|
|
1292
|
-
if (!l.length)
|
|
1293
|
-
return { error: "No valid geometries found for the matched geometry layer features." };
|
|
1294
|
-
const i = l.length === 1 ? l[0] : st.executeMany(l);
|
|
1295
|
-
return i ? (i.spatialReference || (i.spatialReference = t.spatialReference), { geometry: i }) : { error: "Failed to combine geometries from geometry layer." };
|
|
1296
|
-
} catch (n) {
|
|
1297
|
-
return { error: `Failed to query geometry: ${String(n)}` };
|
|
1298
|
-
}
|
|
1299
|
-
}
|
|
1300
|
-
return { error: "Invalid geometry configuration provided" };
|
|
1301
|
-
}, ta = async (e, t, r, a, o, n) => {
|
|
1302
|
-
const l = e.map?.allLayers.find((c) => c.id === t);
|
|
1303
|
-
if (!l)
|
|
1304
|
-
return { success: !1, error: `Layer '${t}' not found.` };
|
|
1305
|
-
const i = l.createQuery();
|
|
1306
|
-
i.where = r ?? "1=1", a && (i.geometry = a, i.spatialRelationship = "intersects", o && (i.distance = o), n && (i.units = n));
|
|
1307
|
-
try {
|
|
1308
|
-
const { extent: c, count: u } = await l.queryExtent(i);
|
|
1309
|
-
return !c || u === 0 ? {
|
|
1310
|
-
success: !1,
|
|
1311
|
-
error: `No features found for filter (where: ${i.where}${a ? ", spatial filter used" : ""})`
|
|
1312
|
-
} : (await e.goTo(c), { success: !0 });
|
|
1313
|
-
} catch (c) {
|
|
1314
|
-
return {
|
|
1315
|
-
success: !1,
|
|
1316
|
-
error: c instanceof Error ? c.message : String(c)
|
|
1317
|
-
};
|
|
1318
|
-
}
|
|
1319
|
-
}, ra = async (e, t, r, a, o, n) => {
|
|
1320
|
-
const l = t.map?.allLayers.find(
|
|
1321
|
-
(p) => p.id === e.layerId
|
|
1322
|
-
);
|
|
1323
|
-
if (!l)
|
|
1324
|
-
return `Could not find target layer with ID: ${e.layerId}`;
|
|
1325
|
-
let i;
|
|
1326
|
-
if (o) {
|
|
1327
|
-
const p = await H(o, t);
|
|
1328
|
-
if ("error" in p)
|
|
1329
|
-
return p.error;
|
|
1330
|
-
i = p.geometry;
|
|
1331
|
-
}
|
|
1332
|
-
if (l.featureEffect = null, l.featureEffect = new it({
|
|
1333
|
-
filter: new Te({
|
|
1334
|
-
...e.objectIds?.length ? { objectIds: e.objectIds } : { where: e.where },
|
|
1335
|
-
geometry: i,
|
|
1336
|
-
spatialRelationship: "intersects",
|
|
1337
|
-
distance: o?.distance,
|
|
1338
|
-
units: o?.units
|
|
1339
|
-
}),
|
|
1340
|
-
includedEffect: r,
|
|
1341
|
-
excludedEffect: a
|
|
1342
|
-
}), l.visible = !0, n)
|
|
1343
|
-
return `Applied feature effects to "${l.title ?? e.layerId}" within current map extent.`;
|
|
1344
|
-
const c = e.objectIds?.length ? `${l.objectIdField} IN (${e.objectIds.join(",")})` : e.where, u = await ta(
|
|
1345
|
-
t,
|
|
1346
|
-
e.layerId,
|
|
1347
|
-
c,
|
|
1348
|
-
i,
|
|
1349
|
-
o?.distance,
|
|
1350
|
-
o?.units
|
|
1351
|
-
), d = l.title ?? e.layerId;
|
|
1352
|
-
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}`;
|
|
1353
|
-
}, aa = ["feet", "kilometers", "meters", "miles", "nautical-miles", "us-nautical-miles"], F = s.enum(aa), oa = async ({
|
|
1354
|
-
targetLayer: e,
|
|
1355
|
-
geometryFilter: t,
|
|
1356
|
-
useCurrentExtent: r,
|
|
1357
|
-
includedEffect: a = "drop-shadow(2px, 2px, 2px, gray)",
|
|
1358
|
-
excludedEffect: o = "grayscale(100%) opacity(60%) blur(2px)"
|
|
1359
|
-
}, n) => {
|
|
1360
|
-
const { mapView: l } = v(n, ["mapView"]);
|
|
1361
|
-
return await ra(e, l, a, o, t, r);
|
|
1362
|
-
}, na = s.object({
|
|
1363
|
-
layerId: s.string().describe("The layerId of the layer containing the geometry by which to filter."),
|
|
1364
|
-
where: s.string().describe("The SQL-92 where clause representing the features from which to filter."),
|
|
1365
|
-
distance: s.number().optional().describe("The buffer distance around the geometry."),
|
|
1366
|
-
units: F.optional().describe("The units for the distance buffer.")
|
|
1367
|
-
}), ia = s.object({
|
|
1368
|
-
point: s.object({
|
|
1369
|
-
x: s.number().describe("X coordinate (longitude) from navigation result"),
|
|
1370
|
-
y: s.number().describe("Y coordinate (latitude) from navigation result"),
|
|
1371
|
-
spatialReference: s.object({
|
|
1372
|
-
wkid: s.number().describe("Spatial reference WKID (e.g., 4326 for WGS84)")
|
|
1373
|
-
}).optional().describe("Spatial reference. Defaults to map's spatial reference if not provided.")
|
|
1374
|
-
}).describe("Point coordinates from a previous navigation/geocoding result"),
|
|
1375
|
-
distance: s.number().optional().describe("Optional buffer distance around the point."),
|
|
1376
|
-
units: F.optional().describe("The units for the distance buffer.")
|
|
1377
|
-
}), sa = s.object({
|
|
1378
|
-
targetLayer: s.object({
|
|
1379
|
-
layerId: s.string().describe("The layerId of the layer on which to set a feature effect."),
|
|
1380
|
-
where: s.string().describe("The SQL-92 where clause representing the features to emphasize."),
|
|
1381
|
-
objectIds: s.array(s.number()).optional().describe(
|
|
1382
|
-
"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."
|
|
1383
|
-
)
|
|
1384
|
-
}),
|
|
1385
|
-
geometryFilter: s.union([na, ia]).optional().describe("Optional geometry-based filtering parameters for spatial queries."),
|
|
1386
|
-
useCurrentExtent: s.boolean().optional().describe(
|
|
1387
|
-
"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."
|
|
1388
|
-
),
|
|
1389
|
-
includedEffect: s.string().default("drop-shadow(2px, 2px, 2px, gray)").describe(
|
|
1390
|
-
"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."
|
|
1391
|
-
),
|
|
1392
|
-
excludedEffect: s.string().default("grayscale(100%) opacity(60%) blur(2px)").describe(
|
|
1393
|
-
"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."
|
|
1394
|
-
)
|
|
1395
|
-
}), la = f(oa, {
|
|
1396
|
-
name: "setFeatureEffect",
|
|
1397
|
-
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.",
|
|
1398
|
-
schema: sa
|
|
1399
|
-
}), ca = /* @__PURE__ */ new Set([
|
|
1400
|
-
"date",
|
|
1401
|
-
"esrifieldtypedate",
|
|
1402
|
-
"date-only",
|
|
1403
|
-
"dateonly",
|
|
1404
|
-
"esrifieldtypedateonly",
|
|
1405
|
-
"time-only",
|
|
1406
|
-
"timeonly",
|
|
1407
|
-
"esrifieldtypetimeonly",
|
|
1408
|
-
"timestamp-offset",
|
|
1409
|
-
"timestampoffset",
|
|
1410
|
-
"esrifieldtypetimestampoffset"
|
|
1411
|
-
]), xe = (e) => {
|
|
1412
|
-
if (!e)
|
|
1413
|
-
return !1;
|
|
1414
|
-
const t = e.toLowerCase();
|
|
1415
|
-
return ca.has(t);
|
|
1416
|
-
}, ee = (e) => {
|
|
1417
|
-
if (e instanceof Date)
|
|
1418
|
-
return Number.isNaN(e.getTime()) ? null : e;
|
|
1419
|
-
if (typeof e == "number" && Number.isFinite(e)) {
|
|
1420
|
-
const t = new Date(e);
|
|
1421
|
-
return Number.isNaN(t.getTime()) ? null : t;
|
|
1422
|
-
}
|
|
1423
|
-
return null;
|
|
1424
|
-
}, ua = (e) => !e || e === "system" ? Intl.DateTimeFormat().resolvedOptions().timeZone : e === "unknown" ? "UTC" : e, da = (e) => {
|
|
1425
|
-
if (typeof e == "string" && e)
|
|
1426
|
-
return e;
|
|
1427
|
-
const t = ee(e);
|
|
1428
|
-
return t ? t.toISOString().slice(0, 10) : null;
|
|
1429
|
-
}, ei = () => {
|
|
1430
|
-
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}`;
|
|
1431
|
-
return { userTimezone: Intl.DateTimeFormat().resolvedOptions().timeZone, userTimezoneOffset: o };
|
|
1432
|
-
}, pa = (e, t, r) => {
|
|
1433
|
-
const a = t?.toLowerCase();
|
|
1434
|
-
if (a && !xe(a))
|
|
1435
|
-
return e;
|
|
1436
|
-
if (a === "date-only") {
|
|
1437
|
-
const n = da(e);
|
|
1438
|
-
return n ? lt(n, Q("short-date")) : e;
|
|
1439
|
-
}
|
|
1440
|
-
if (a === "time-only") {
|
|
1441
|
-
if (typeof e == "string" && e)
|
|
1442
|
-
return ct(e, Q("long-time"));
|
|
1443
|
-
const n = ee(e);
|
|
1444
|
-
return n ? he(n, {
|
|
1445
|
-
...Q("long-time"),
|
|
1446
|
-
timeZone: "UTC"
|
|
1447
|
-
}) : e;
|
|
1448
|
-
}
|
|
1449
|
-
const o = ee(e);
|
|
1450
|
-
return o ? he(o, {
|
|
1451
|
-
...Q("short-date-short-time"),
|
|
1452
|
-
timeZone: ua(r)
|
|
1453
|
-
}) : e;
|
|
1454
|
-
}, Re = (e, t, r) => {
|
|
1455
|
-
if (e && typeof e != "function") {
|
|
1456
|
-
const a = "getField" in r && r.getField?.(e), o = a && "getFieldDomain" in r && r.getFieldDomain ? r.getFieldDomain(a.name) : null;
|
|
1457
|
-
if (o?.type === "coded-value") {
|
|
1458
|
-
const n = o.codedValues.find((l) => l.code === t);
|
|
1459
|
-
return n ? n.name : null;
|
|
1460
|
-
}
|
|
1461
|
-
}
|
|
1462
|
-
return null;
|
|
1463
|
-
}, ma = (e) => !e || e === "system" ? Intl.DateTimeFormat().resolvedOptions().timeZone : e === "unknown" ? "UTC" : e, ha = (e) => {
|
|
1464
|
-
if (e instanceof Date)
|
|
1465
|
-
return Number.isNaN(e.getTime()) ? null : e;
|
|
1466
|
-
if (typeof e == "number" && Number.isFinite(e)) {
|
|
1467
|
-
const t = new Date(e);
|
|
1468
|
-
return Number.isNaN(t.getTime()) ? null : t;
|
|
1469
|
-
}
|
|
1470
|
-
if (typeof e == "string" && e) {
|
|
1471
|
-
const t = new Date(e);
|
|
1472
|
-
return Number.isNaN(t.getTime()) ? null : t;
|
|
1473
|
-
}
|
|
1474
|
-
return null;
|
|
1475
|
-
}, ya = (e, t) => {
|
|
1476
|
-
if (typeof e != "number")
|
|
1477
|
-
return e;
|
|
1478
|
-
const r = {};
|
|
1479
|
-
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);
|
|
1480
|
-
try {
|
|
1481
|
-
return new Intl.NumberFormat(void 0, r).format(e);
|
|
1482
|
-
} catch {
|
|
1483
|
-
return e;
|
|
1484
|
-
}
|
|
1485
|
-
}, fa = (e, t, r) => {
|
|
1486
|
-
const a = ha(e);
|
|
1487
|
-
if (!a)
|
|
1488
|
-
return e;
|
|
1489
|
-
const o = {};
|
|
1490
|
-
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 = ma(r);
|
|
1491
|
-
try {
|
|
1492
|
-
return new Intl.DateTimeFormat(void 0, o).format(a);
|
|
1493
|
-
} catch {
|
|
1494
|
-
return e;
|
|
1495
|
-
}
|
|
1496
|
-
}, $e = (e, t) => e.getFieldAlias?.(t) ?? e.fieldsIndex?.get(t)?.alias ?? e.fieldsIndex?.get(t)?.name ?? t, Ce = (e, t, r, a, o) => {
|
|
1497
|
-
if (r == null)
|
|
1498
|
-
return r;
|
|
1499
|
-
const l = e.getFieldConfiguration?.(t)?.fieldFormat;
|
|
1500
|
-
return l?.type === "number" ? ya(r, l) : l?.type === "date-time" ? !a || xe(a) ? fa(r, l, o) : r : pa(r, a, o);
|
|
1501
|
-
}, ga = (e, t, r, a) => {
|
|
1502
|
-
const o = e.fieldsIndex?.get(t), n = Re(t, r, e) ?? r;
|
|
1503
|
-
return Ce(e, t, n, o?.type, a);
|
|
1504
|
-
}, wa = (e, t) => $e(e, t), Ee = (e, t, r) => {
|
|
1505
|
-
const a = e.objectIdField, o = t.features.map(
|
|
1506
|
-
(l) => l.attributes[a]
|
|
1507
|
-
), n = t.features.map((l) => {
|
|
1508
|
-
const i = l.attributes, c = {};
|
|
1509
|
-
return e.fields.forEach((u) => {
|
|
1510
|
-
if (!Object.hasOwn(i, u.name))
|
|
1511
|
-
return;
|
|
1512
|
-
const d = i[u.name];
|
|
1513
|
-
if (u.name === a) {
|
|
1514
|
-
c[u.name] = d;
|
|
1515
|
-
return;
|
|
1516
|
-
}
|
|
1517
|
-
const p = Re(u.name, d, e) ?? d, m = $e(e, u.name);
|
|
1518
|
-
c[m] = Ce(e, u.name, p, u.type, r);
|
|
1519
|
-
}), c;
|
|
1520
|
-
});
|
|
1521
|
-
return { objectIds: o, attributes: n };
|
|
1522
|
-
}, ba = (e, t, r) => {
|
|
1523
|
-
const a = e.createQuery();
|
|
1524
|
-
return a.outFields = [t], a.where = r || "1=1", a.num = 1, a;
|
|
1525
|
-
}, Ta = async (e, t, r, a) => {
|
|
1526
|
-
const o = a.map?.allLayers.find((m) => m.id === e), n = ba(o, t, r.where), i = (await o.queryFeatures(n)).features[0], c = i ? i.attributes[t] : null, u = ga(o, t, c, a.timeZone), d = wa(o, t);
|
|
1527
|
-
return {
|
|
1528
|
-
tool: "getAttribute",
|
|
1529
|
-
layerName: o.title ?? e,
|
|
1530
|
-
summary: `${d} = ${u}`,
|
|
1531
|
-
details: {
|
|
1532
|
-
fieldName: t,
|
|
1533
|
-
fieldAlias: d !== t ? d : void 0,
|
|
1534
|
-
value: u,
|
|
1535
|
-
where: r.where
|
|
1536
|
-
}
|
|
1537
|
-
};
|
|
1538
|
-
};
|
|
1539
|
-
async function Sa({ layerId: e, fieldName: t, query: r }, a) {
|
|
1540
|
-
const { mapView: o } = v(a, ["mapView"]), n = await Ta(e, t, r, o);
|
|
1541
|
-
return JSON.stringify(n, null, 2);
|
|
1542
|
-
}
|
|
1543
|
-
const va = s.object({
|
|
1544
|
-
layerId: s.string().describe("The layerId of the layer containing the field from which to get a value."),
|
|
1545
|
-
fieldName: s.string().describe("The name of the field/attribute from which to get a field value."),
|
|
1546
|
-
query: s.object({
|
|
1547
|
-
where: s.string().describe("The SQL-92 where clause representing the feature from which to get an attribute value.")
|
|
1548
|
-
})
|
|
1549
|
-
}), xa = f(Sa, {
|
|
1550
|
-
name: "getAttribute",
|
|
1551
|
-
description: "Returns an attribute value for a given feature.",
|
|
1552
|
-
schema: va
|
|
1553
|
-
}), se = (e, t, r) => {
|
|
1554
|
-
if (!(r ? e.hasAllFeaturesInView : e.hasAllFeatures))
|
|
1555
|
-
return !1;
|
|
1556
|
-
const o = new Set((e.availableFields ?? []).map((n) => n.toLowerCase()));
|
|
1557
|
-
return o.has("*") ? !0 : t.every((n) => o.has(n.toLowerCase()));
|
|
1558
|
-
};
|
|
1559
|
-
function U(e, t) {
|
|
1560
|
-
let r = e ?? "";
|
|
1561
|
-
return t != null && t && (r = r ? `(${r}) AND (${t})` : t), r || null;
|
|
1562
|
-
}
|
|
1563
|
-
const Ra = async (e) => {
|
|
1564
|
-
const { targetLayer: t, fieldName: r, statisticType: a, mapView: o, layersAndFieldsRegistry: n, geometryFilter: l } = e, i = o.map?.allLayers.find((S) => S.id === t.layerId);
|
|
1565
|
-
if (!i)
|
|
1566
|
-
throw new Error(`Layer '${t.layerId}' not found.`);
|
|
1567
|
-
const c = await o.whenLayerView(i), d = n.get(t.layerId)?.fieldRegistry.get(r), p = d?.alias;
|
|
1568
|
-
if (!d)
|
|
1569
|
-
throw new Error(`Field '${r}' not found.`);
|
|
1570
|
-
let m, w;
|
|
1571
|
-
if (l) {
|
|
1572
|
-
const S = await H(l, o);
|
|
1573
|
-
if ("error" in S)
|
|
1574
|
-
throw new Error(S.error);
|
|
1575
|
-
if (!S.geometry)
|
|
1576
|
-
throw L(l) ? new Error(`No features found matching: ${l.where}`) : new Error("Failed to create geometry");
|
|
1577
|
-
if (L(l)) {
|
|
1578
|
-
const M = o.map?.allLayers.find((P) => P.id === l.layerId);
|
|
1579
|
-
m = {
|
|
1580
|
-
geometryLayerName: M?.title ?? M?.id,
|
|
1581
|
-
geometryLayerId: l.layerId,
|
|
1582
|
-
geometryWhere: l.where,
|
|
1583
|
-
distance: l.distance,
|
|
1584
|
-
units: l.units,
|
|
1585
|
-
applied: !0
|
|
1586
|
-
};
|
|
1587
|
-
} else B(l) && (m = {
|
|
1588
|
-
point: l.point,
|
|
1589
|
-
distance: l.distance,
|
|
1590
|
-
units: l.units,
|
|
1591
|
-
applied: !0
|
|
1592
|
-
});
|
|
1593
|
-
w = new Te({
|
|
1594
|
-
geometry: S.geometry,
|
|
1595
|
-
distance: l.distance,
|
|
1596
|
-
units: l.units,
|
|
1597
|
-
spatialRelationship: "intersects"
|
|
1598
|
-
});
|
|
1599
|
-
}
|
|
1600
|
-
const h = se(c, [r], !1);
|
|
1601
|
-
let y = null, g = null;
|
|
1602
|
-
const b = 10;
|
|
1603
|
-
if (d.type !== "geometry" && d.type !== "oid" && d.type !== "global-id")
|
|
1604
|
-
try {
|
|
1605
|
-
const S = {
|
|
1606
|
-
layer: i,
|
|
1607
|
-
useFeaturesInView: h,
|
|
1608
|
-
view: h ? o : void 0,
|
|
1609
|
-
field: r,
|
|
1610
|
-
sqlWhere: U(i.definitionExpression, t.where),
|
|
1611
|
-
...w && { filter: w },
|
|
1612
|
-
outStatisticTypes: { include: [a] }
|
|
1613
|
-
};
|
|
1614
|
-
y = await ut(S);
|
|
1615
|
-
const M = ["string", "small-integer", "integer"], P = d.domain?.type === "coded-value" ? d.domain : null;
|
|
1616
|
-
(M.includes(d.type) || P) && (g = (await dt({
|
|
1617
|
-
layer: i,
|
|
1618
|
-
useFeaturesInView: h,
|
|
1619
|
-
view: h ? o : void 0,
|
|
1620
|
-
field: r,
|
|
1621
|
-
sqlWhere: U(i.definitionExpression, t.where),
|
|
1622
|
-
...w && { filter: w }
|
|
1623
|
-
})).uniqueValueInfos.sort((I, ze) => ze.count - I.count).slice(0, b)), g && d.domain?.type === "coded-value" && (g = g.map((I) => ({
|
|
1624
|
-
...I,
|
|
1625
|
-
value: P ? P.getName(I.value) ?? I.value : I.value
|
|
1626
|
-
})));
|
|
1627
|
-
} catch (S) {
|
|
1628
|
-
console.error("Statistics error:", S);
|
|
1629
|
-
}
|
|
1630
|
-
return {
|
|
1631
|
-
tool: "getStatistics",
|
|
1632
|
-
layerName: i.title ?? t.layerId,
|
|
1633
|
-
summary: `${a} = ${typeof y?.[a] == "number" ? y[a] : "N/A"}`,
|
|
1634
|
-
details: {
|
|
1635
|
-
fieldName: r,
|
|
1636
|
-
fieldAlias: p,
|
|
1637
|
-
statisticType: a,
|
|
1638
|
-
statistic: y?.[a] ?? null,
|
|
1639
|
-
summaryStatistics: y,
|
|
1640
|
-
uniqueValues: g,
|
|
1641
|
-
where: t.where,
|
|
1642
|
-
spatialFilterInfo: m
|
|
1643
|
-
}
|
|
1644
|
-
};
|
|
1645
|
-
};
|
|
1646
|
-
async function $a({
|
|
1647
|
-
targetLayer: e,
|
|
1648
|
-
fieldName: t,
|
|
1649
|
-
statisticType: r,
|
|
1650
|
-
geometryFilter: a
|
|
1651
|
-
}, o) {
|
|
1652
|
-
const n = ve(o, "layersAndFieldsRegistry"), { mapView: l } = v(o, ["mapView"]), i = await Ra({
|
|
1653
|
-
targetLayer: e,
|
|
1654
|
-
fieldName: t,
|
|
1655
|
-
statisticType: r,
|
|
1656
|
-
mapView: l,
|
|
1657
|
-
layersAndFieldsRegistry: n,
|
|
1658
|
-
geometryFilter: a
|
|
1659
|
-
});
|
|
1660
|
-
return JSON.stringify(i, null, 2);
|
|
1661
|
-
}
|
|
1662
|
-
const Ca = s.object({
|
|
1663
|
-
layerId: s.string().describe("The layerId of the layer containing the geometry by which to filter."),
|
|
1664
|
-
where: s.string().describe("The SQL-92 where clause representing the features from which to filter."),
|
|
1665
|
-
distance: s.number().optional().describe("The buffer distance around the geometry."),
|
|
1666
|
-
units: F.optional().describe("The units for the distance buffer.")
|
|
1667
|
-
}), Ea = s.object({
|
|
1668
|
-
point: s.object({
|
|
1669
|
-
x: s.number().describe("X coordinate (longitude) from navigation result"),
|
|
1670
|
-
y: s.number().describe("Y coordinate (latitude) from navigation result"),
|
|
1671
|
-
spatialReference: s.object({
|
|
1672
|
-
wkid: s.number().describe("Spatial reference WKID (e.g., 4326 for WGS84)")
|
|
1673
|
-
}).optional().describe("Spatial reference. Defaults to map's spatial reference if not provided.")
|
|
1674
|
-
}).describe("Point coordinates from a previous navigation/geocoding result"),
|
|
1675
|
-
distance: s.number().optional().describe("Optional buffer distance around the point."),
|
|
1676
|
-
units: F.optional().describe("The units for the distance buffer.")
|
|
1677
|
-
}), Fa = s.object({
|
|
1678
|
-
targetLayer: s.object({
|
|
1679
|
-
layerId: s.string().describe("The layerId of the layer containing the field from which to get a value."),
|
|
1680
|
-
where: s.string().describe("The SQL-92 where clause representing the feature from which to get an attribute value.")
|
|
1681
|
-
}),
|
|
1682
|
-
geometryFilter: s.union([Ca, Ea]).optional().describe(
|
|
1683
|
-
"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."
|
|
1684
|
-
),
|
|
1685
|
-
fieldName: s.string().describe("The name of the field for which to get statistics. STRICTLY DO NOT use OBJECTID. Use any other field"),
|
|
1686
|
-
statisticType: s.enum(["avg", "max", "median", "min", "stddev", "sum", "variance", "nullcount", "count"]).describe("The statistic type to calculate.")
|
|
1687
|
-
}), ka = f($a, {
|
|
1688
|
-
name: "getStatistics",
|
|
1689
|
-
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.
|
|
1690
|
-
|
|
1691
|
-
USE THIS TOOL FOR:
|
|
1692
|
-
- "What is the average/maximum/minimum/total [field]?" — aggregate computations
|
|
1693
|
-
- "Most common/frequent value of [field]?" — frequency analysis
|
|
1694
|
-
- Questions requiring a mathematical aggregation across many features
|
|
1695
|
-
|
|
1696
|
-
DO NOT USE FOR:
|
|
1697
|
-
- "How many features match X?" — use queryFeatures instead (it returns totalCount)
|
|
1698
|
-
- "Show / list / find features" — use queryFeatures instead
|
|
1699
|
-
- Simple counts of features matching a condition — use queryFeatures instead
|
|
1700
|
-
|
|
1701
|
-
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.`,
|
|
1702
|
-
schema: Fa
|
|
1703
|
-
}), Na = (e) => e.flatMap((t) => t.split(",")).map((t) => t.trim()).map((t) => t.split(/\s+/u)[0]?.replace(/^"|"$/gu, "")).filter((t) => !!t), Ia = async (e, t, r, a, o) => {
|
|
1704
|
-
const n = r.map?.allLayers.find((m) => m.id === e.layerId), l = await r.whenLayerView(n), i = n.title ?? e.layerId;
|
|
1705
|
-
let c;
|
|
1706
|
-
if (a) {
|
|
1707
|
-
const m = await H(a, r);
|
|
1708
|
-
if ("error" in m)
|
|
1709
|
-
return {
|
|
1710
|
-
tool: "getTopFeatures",
|
|
1711
|
-
layerName: i,
|
|
1712
|
-
summary: "Geometry lookup failed",
|
|
1713
|
-
details: { error: m.error }
|
|
1714
|
-
};
|
|
1715
|
-
if (!m.geometry)
|
|
1716
|
-
return {
|
|
1717
|
-
tool: "getTopFeatures",
|
|
1718
|
-
layerName: i,
|
|
1719
|
-
summary: "No features found for geometry filter",
|
|
1720
|
-
details: {
|
|
1721
|
-
error: `No features found matching: ${"where" in a ? a.where : "unknown criteria"}`
|
|
1722
|
-
}
|
|
1723
|
-
};
|
|
1724
|
-
c = m.geometry;
|
|
1725
|
-
} else o && (c = r.extent.clone());
|
|
1726
|
-
const u = t.groupByFields && t.groupByFields.length > 0, d = n.objectIdField, p = e.outFields.includes("*") ? ["*"] : [.../* @__PURE__ */ new Set([...e.outFields, d])];
|
|
1727
|
-
try {
|
|
1728
|
-
let m;
|
|
1729
|
-
if (u) {
|
|
1730
|
-
const y = new pt({
|
|
1731
|
-
where: e.where || "1=1",
|
|
1732
|
-
outFields: p,
|
|
1733
|
-
orderByFields: e.orderByFields,
|
|
1734
|
-
geometry: c,
|
|
1735
|
-
spatialRelationship: c ? "intersects" : void 0,
|
|
1736
|
-
distance: a?.distance,
|
|
1737
|
-
units: a?.units,
|
|
1738
|
-
topFilter: new mt({
|
|
1739
|
-
topCount: t.topCount,
|
|
1740
|
-
groupByFields: t.groupByFields,
|
|
1741
|
-
orderByFields: t.orderByFields
|
|
1742
|
-
})
|
|
1743
|
-
});
|
|
1744
|
-
m = await n.queryTopFeatures(y);
|
|
1745
|
-
} else {
|
|
1746
|
-
const y = n.createQuery();
|
|
1747
|
-
y.where = U(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;
|
|
1748
|
-
const g = [
|
|
1749
|
-
.../* @__PURE__ */ new Set([...e.outFields, ...Na(t.orderByFields)])
|
|
1750
|
-
], b = se(l, g, o ?? !1);
|
|
1751
|
-
try {
|
|
1752
|
-
m = b ? await l.queryFeatures(y) : await n.queryFeatures(y);
|
|
1753
|
-
} catch (x) {
|
|
1754
|
-
console.warn("Client-side query failed, falling back to server:", x), m = await n.queryFeatures(y);
|
|
1755
|
-
}
|
|
1756
|
-
}
|
|
1757
|
-
const w = m.features.map((y) => y.attributes[d]), { attributes: h } = Ee(n, m, r.timeZone);
|
|
1758
|
-
return {
|
|
1759
|
-
tool: "getTopFeatures",
|
|
1760
|
-
layerName: i,
|
|
1761
|
-
summary: `Top ${t.topCount} features extracted`,
|
|
1762
|
-
details: {
|
|
1763
|
-
topCount: t.topCount,
|
|
1764
|
-
attributes: h,
|
|
1765
|
-
objectIds: w,
|
|
1766
|
-
objectIdField: d,
|
|
1767
|
-
where: e.where,
|
|
1768
|
-
orderByFields: t.orderByFields,
|
|
1769
|
-
...u && { groupByFields: t.groupByFields }
|
|
1770
|
-
}
|
|
1771
|
-
};
|
|
1772
|
-
} catch (m) {
|
|
1773
|
-
return {
|
|
1774
|
-
tool: "getTopFeatures",
|
|
1775
|
-
layerName: i,
|
|
1776
|
-
summary: "Query failed",
|
|
1777
|
-
details: { error: m instanceof Error ? m.message : String(m) }
|
|
1778
|
-
};
|
|
1779
|
-
}
|
|
1780
|
-
}, qa = async ({
|
|
1781
|
-
targetLayer: e,
|
|
1782
|
-
topFilter: t,
|
|
1783
|
-
geometryFilter: r,
|
|
1784
|
-
useCurrentExtent: a
|
|
1785
|
-
}, o) => {
|
|
1786
|
-
const { mapView: n } = v(o, ["mapView"]), l = await Ia(e, t, n, r, a);
|
|
1787
|
-
return JSON.stringify(l, null, 2);
|
|
1788
|
-
}, za = s.object({
|
|
1789
|
-
layerId: s.string().describe("The layerId of the layer containing the geometry by which to filter."),
|
|
1790
|
-
where: s.string().describe("The SQL-92 where clause representing the features from which to filter."),
|
|
1791
|
-
distance: s.number().optional().describe("The buffer distance around the geometry."),
|
|
1792
|
-
units: F.optional().describe("The units for the distance buffer.")
|
|
1793
|
-
}), Da = s.object({
|
|
1794
|
-
point: s.object({
|
|
1795
|
-
x: s.number().describe("X coordinate (longitude) from navigation result"),
|
|
1796
|
-
y: s.number().describe("Y coordinate (latitude) from navigation result"),
|
|
1797
|
-
spatialReference: s.object({
|
|
1798
|
-
wkid: s.number().describe("Spatial reference WKID (e.g., 4326 for WGS84)")
|
|
1799
|
-
}).optional().describe("Spatial reference. Defaults to map's spatial reference if not provided.")
|
|
1800
|
-
}).describe("Point coordinates from a previous navigation/geocoding result"),
|
|
1801
|
-
distance: s.number().optional().describe("Optional buffer distance around the point."),
|
|
1802
|
-
units: F.optional().describe("The units for the distance buffer.")
|
|
1803
|
-
}), Pa = s.object({
|
|
1804
|
-
targetLayer: s.object({
|
|
1805
|
-
layerId: s.string().describe("The layerId of the layer containing the field from which to get a value."),
|
|
1806
|
-
where: s.string().describe("The SQL-92 where clause representing the feature from which to get an attribute value."),
|
|
1807
|
-
orderByFields: s.array(s.string().describe("The field(s) and order for which to sort the resulting features.")),
|
|
1808
|
-
outFields: s.array(
|
|
1809
|
-
s.string().describe(
|
|
1810
|
-
'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 ("*").'
|
|
1811
|
-
).default("*")
|
|
1812
|
-
)
|
|
1813
|
-
}),
|
|
1814
|
-
geometryFilter: s.union([za, Da]).optional().describe(
|
|
1815
|
-
"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."
|
|
1816
|
-
),
|
|
1817
|
-
topFilter: s.object({
|
|
1818
|
-
topCount: s.number().describe("Number of top features to return per group."),
|
|
1819
|
-
orderByFields: s.array(
|
|
1820
|
-
s.string().describe("Field(s) to rank by with ASC/DESC. Must be existing field names, not aggregate functions.")
|
|
1821
|
-
),
|
|
1822
|
-
groupByFields: s.array(s.string().describe("Field(s) to group results by. Returns top N per group."))
|
|
1823
|
-
}).required(),
|
|
1824
|
-
useCurrentExtent: s.boolean().optional().describe(
|
|
1825
|
-
"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)."
|
|
1826
|
-
)
|
|
1827
|
-
}), Aa = f(qa, {
|
|
1828
|
-
name: "getTopFeatures",
|
|
1829
|
-
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.',
|
|
1830
|
-
schema: Pa
|
|
1831
|
-
}), X = 25, La = (e) => e.flatMap((t) => t.split(",")).map((t) => t.trim()).map((t) => t.split(/\s+/u)[0]?.replace(/^"|"$/gu, "")).filter((t) => !!t), ja = async (e, t, r, a) => {
|
|
1832
|
-
const o = t.map?.allLayers.find((g) => g.id === e.layerId), n = await t.whenLayerView(o), l = o.title ?? e.layerId;
|
|
1833
|
-
let i;
|
|
1834
|
-
if (r) {
|
|
1835
|
-
const g = await H(r, t);
|
|
1836
|
-
if ("error" in g) {
|
|
1837
|
-
const b = { error: g.error };
|
|
1838
|
-
if (L(r)) {
|
|
1839
|
-
const x = t.map?.allLayers.find((S) => S.id === r.layerId);
|
|
1840
|
-
b.geometryLayerName = x?.title ?? x?.id, b.geometryLayerId = r.layerId, b.geometryWhere = r.where;
|
|
1841
|
-
} else B(r) && (b.point = r.point);
|
|
1842
|
-
return {
|
|
1843
|
-
tool: "queryFeatures",
|
|
1844
|
-
layerName: l,
|
|
1845
|
-
summary: "Geometry lookup failed",
|
|
1846
|
-
details: b
|
|
1847
|
-
};
|
|
1848
|
-
}
|
|
1849
|
-
if (!g.geometry) {
|
|
1850
|
-
const b = {};
|
|
1851
|
-
if (L(r)) {
|
|
1852
|
-
const x = t.map?.allLayers.find((S) => S.id === r.layerId);
|
|
1853
|
-
b.error = `No features found matching: ${r.where}`, b.geometryLayerName = x?.title ?? x?.id, b.geometryLayerId = r.layerId, b.geometryWhere = r.where;
|
|
1854
|
-
} else B(r) && (b.error = "Failed to create point geometry", b.point = r.point);
|
|
1855
|
-
return {
|
|
1856
|
-
tool: "queryFeatures",
|
|
1857
|
-
layerName: l,
|
|
1858
|
-
summary: "No features found for geometry filter",
|
|
1859
|
-
details: b
|
|
1860
|
-
};
|
|
1861
|
-
}
|
|
1862
|
-
i = g.geometry;
|
|
1863
|
-
} else a && (i = t.extent.clone());
|
|
1864
|
-
const c = [
|
|
1865
|
-
.../* @__PURE__ */ new Set([...e.outFields, ...La(e.orderByFields)])
|
|
1866
|
-
], u = se(n, c, a ?? !1), d = o.objectIdField, p = o.createQuery();
|
|
1867
|
-
p.where = U(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;
|
|
1868
|
-
let m, w;
|
|
1869
|
-
try {
|
|
1870
|
-
m = u ? await n.queryFeatureCount(p) : await o.queryFeatureCount(p), m > 0 && m <= X && (w = u ? await n.queryFeatures(p) : await o.queryFeatures(p));
|
|
1871
|
-
} catch (g) {
|
|
1872
|
-
console.warn("Client-side query failed, falling back to server:", g), m = await o.queryFeatureCount(p), m > 0 && m <= X && (w = await o.queryFeatures(p));
|
|
1873
|
-
}
|
|
1874
|
-
const { objectIds: h, attributes: y } = w ? Ee(o, w, t.timeZone) : { objectIds: void 0, attributes: void 0 };
|
|
1875
|
-
return {
|
|
1876
|
-
tool: "queryFeatures",
|
|
1877
|
-
layerName: l,
|
|
1878
|
-
summary: `${m} features found`,
|
|
1879
|
-
details: {
|
|
1880
|
-
totalCount: m,
|
|
1881
|
-
where: e.where,
|
|
1882
|
-
orderByFields: e.orderByFields,
|
|
1883
|
-
outFields: e.outFields,
|
|
1884
|
-
...h && { objectIds: h, objectIdField: d },
|
|
1885
|
-
...y && { attributes: y },
|
|
1886
|
-
...m > X && {
|
|
1887
|
-
note: `${m} features found.`
|
|
1888
|
-
}
|
|
1889
|
-
}
|
|
1890
|
-
};
|
|
1891
|
-
};
|
|
1892
|
-
async function Ga({
|
|
1893
|
-
targetLayer: e,
|
|
1894
|
-
geometryFilter: t,
|
|
1895
|
-
useCurrentExtent: r
|
|
1896
|
-
}, a) {
|
|
1897
|
-
const { mapView: o } = v(a, ["mapView"]), n = await ja(e, o, t, r);
|
|
1898
|
-
return JSON.stringify(n, null, 2);
|
|
1899
|
-
}
|
|
1900
|
-
const Oa = s.object({
|
|
1901
|
-
layerId: s.string().describe("The layerId of the layer containing the geometry by which to filter."),
|
|
1902
|
-
where: s.string().describe("The SQL-92 where clause representing the features from which to filter."),
|
|
1903
|
-
distance: s.number().optional().describe("The buffer distance around the geometry."),
|
|
1904
|
-
units: F.optional().describe("The units for the distance buffer.")
|
|
1905
|
-
}), Ma = s.object({
|
|
1906
|
-
point: s.object({
|
|
1907
|
-
x: s.number().describe("X coordinate (longitude) from navigation result"),
|
|
1908
|
-
y: s.number().describe("Y coordinate (latitude) from navigation result"),
|
|
1909
|
-
spatialReference: s.object({
|
|
1910
|
-
wkid: s.number().describe("Spatial reference WKID (e.g., 4326 for WGS84)")
|
|
1911
|
-
}).optional().describe("Spatial reference. Defaults to map's spatial reference if not provided.")
|
|
1912
|
-
}).describe("Point coordinates from a previous navigation/geocoding result"),
|
|
1913
|
-
distance: s.number().optional().describe("Optional buffer distance around the point."),
|
|
1914
|
-
units: F.optional().describe("The units for the distance buffer.")
|
|
1915
|
-
}), Qa = s.object({
|
|
1916
|
-
targetLayer: s.object({
|
|
1917
|
-
layerId: s.string().describe("The layerId of the layer containing the field from which to get a value."),
|
|
1918
|
-
where: s.string().describe(
|
|
1919
|
-
"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."
|
|
1920
|
-
),
|
|
1921
|
-
orderByFields: s.array(s.string().describe("The field(s) and order for which to sort the resulting features.")),
|
|
1922
|
-
outFields: s.array(
|
|
1923
|
-
s.string().describe(
|
|
1924
|
-
'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 ("*").'
|
|
1925
|
-
).default("*")
|
|
1926
|
-
)
|
|
1927
|
-
}),
|
|
1928
|
-
geometryFilter: s.union([Oa, Ma]).optional().describe(
|
|
1929
|
-
"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."
|
|
1930
|
-
),
|
|
1931
|
-
useCurrentExtent: s.boolean().optional().describe(
|
|
1932
|
-
"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)."
|
|
1933
|
-
)
|
|
1934
|
-
}), Va = f(Ga, {
|
|
1935
|
-
name: "queryFeatures",
|
|
1936
|
-
description: `Queries features from a layer. Returns the total count of matching features, plus individual feature attributes if ≤25 features match.
|
|
1937
|
-
|
|
1938
|
-
USE THIS TOOL FOR:
|
|
1939
|
-
- "Show / display / list features where..." — finding and listing features
|
|
1940
|
-
- "How many X are Y?" — counting features that match a condition
|
|
1941
|
-
- "Which features..." / "Find features..." — identifying specific features
|
|
1942
|
-
- Spatial queries — finding features near/within/intersecting other features
|
|
1943
|
-
- Any question where the user wants to SEE or COUNT matching features
|
|
1944
|
-
|
|
1945
|
-
This is the DEFAULT tool for most queries. When in doubt, use this tool.`,
|
|
1946
|
-
schema: Qa
|
|
1947
|
-
}), _a = [xa, ka, Aa, Va], ti = [la, ea, Yr], Wa = new nt(_a, { handleToolErrors: !1 });
|
|
1948
|
-
async function ri(e, t) {
|
|
1949
|
-
const { messages: r } = await Wa.invoke({ messages: e.dataExplorationMessages }, t), a = [], o = [];
|
|
1950
|
-
for (const n of r) {
|
|
1951
|
-
const l = n.content;
|
|
1952
|
-
let i;
|
|
1953
|
-
typeof l != "string" && (i = {
|
|
1954
|
-
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",
|
|
1955
990
|
layerName: "unknown",
|
|
1956
991
|
summary: "Query failed",
|
|
1957
|
-
details: { error: "Skipping non-string tool output:", raw:
|
|
992
|
+
details: { error: "Skipping non-string tool output:", raw: s }
|
|
1958
993
|
});
|
|
1959
994
|
try {
|
|
1960
|
-
typeof
|
|
1961
|
-
tool:
|
|
995
|
+
typeof s == "string" ? n = JSON.parse(s) : n = {
|
|
996
|
+
tool: i.name ?? "unknown",
|
|
1962
997
|
layerName: "unknown",
|
|
1963
998
|
summary: "Query failed",
|
|
1964
|
-
details: { error: "Invalid tool output type", raw:
|
|
999
|
+
details: { error: "Invalid tool output type", raw: s }
|
|
1965
1000
|
};
|
|
1966
1001
|
} catch {
|
|
1967
|
-
|
|
1968
|
-
tool:
|
|
1002
|
+
n = {
|
|
1003
|
+
tool: i.name ?? "unknown",
|
|
1969
1004
|
layerName: "unknown",
|
|
1970
1005
|
summary: "Query failed",
|
|
1971
|
-
details: { error:
|
|
1006
|
+
details: { error: s }
|
|
1972
1007
|
};
|
|
1973
1008
|
}
|
|
1974
|
-
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}`);
|
|
1975
1010
|
}
|
|
1976
|
-
return await
|
|
1011
|
+
return await T({ text: `Finished executing layer query tool: ${o.join(", ")}` }, t), {
|
|
1977
1012
|
...e,
|
|
1978
1013
|
dataExplorationMessages: [...e.dataExplorationMessages, ...r],
|
|
1979
1014
|
queryResponse: a,
|
|
1980
1015
|
status: "success",
|
|
1981
|
-
summary: o.length > 0 ?
|
|
1016
|
+
summary: o.length > 0 ? Ie(o.join(`
|
|
1982
1017
|
`)) : "Query executed."
|
|
1983
1018
|
};
|
|
1984
1019
|
}
|
|
1985
|
-
const
|
|
1986
|
-
...
|
|
1020
|
+
const Fa = m.Root({
|
|
1021
|
+
...G(),
|
|
1987
1022
|
// internal to the help agent
|
|
1988
|
-
helpInternalState:
|
|
1989
|
-
reducer:
|
|
1023
|
+
helpInternalState: m({
|
|
1024
|
+
reducer: k,
|
|
1990
1025
|
default: () => ({
|
|
1991
1026
|
toolCallMessage: void 0
|
|
1992
1027
|
})
|
|
1993
1028
|
})
|
|
1994
|
-
}),
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
);
|
|
1998
|
-
if (!r) {
|
|
1999
|
-
const n = Array.from(e.values()).map((l) => l.layerItem.title).join(", ");
|
|
2000
|
-
return `Could not find a layer matching "${t}". Available layers: ${n}`;
|
|
2001
|
-
}
|
|
2002
|
-
const a = Array.from(r.fieldRegistry.values()), o = a.map((n) => `- **${n.alias || n.name}** (\`${n.name}\`, ${n.type})${n.description ? `: ${n.description}` : ""}`).join(`
|
|
2003
|
-
`);
|
|
2004
|
-
return `**${r.layerItem.title}** has ${a.length} field(s):
|
|
2005
|
-
|
|
2006
|
-
${o}`;
|
|
2007
|
-
}, Ua = ({ layerTitle: e }, t) => {
|
|
2008
|
-
const r = ve(t, "layersAndFieldsRegistry");
|
|
2009
|
-
return Ba(r, e);
|
|
2010
|
-
}, oi = f(Ua, {
|
|
2011
|
-
name: "listLayerFields",
|
|
2012
|
-
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.",
|
|
2013
|
-
schema: s.object({
|
|
2014
|
-
layerTitle: s.string().describe("The title or partial title of the layer to list fields for.")
|
|
2015
|
-
})
|
|
2016
|
-
}), ni = T.Root({
|
|
2017
|
-
...K(),
|
|
2018
|
-
intent: T({
|
|
1029
|
+
}), _a = m.Root({
|
|
1030
|
+
...G(),
|
|
1031
|
+
intent: m({
|
|
2019
1032
|
reducer: (e, t) => t
|
|
2020
1033
|
}),
|
|
2021
|
-
arcgisKnowledgeMessages:
|
|
2022
|
-
reducer:
|
|
1034
|
+
arcgisKnowledgeMessages: m({
|
|
1035
|
+
reducer: ee,
|
|
2023
1036
|
default: () => []
|
|
2024
1037
|
}),
|
|
2025
|
-
arcgisKnowledgeToolResult:
|
|
1038
|
+
arcgisKnowledgeToolResult: m({
|
|
2026
1039
|
reducer: (e, t) => t,
|
|
2027
1040
|
default: () => null
|
|
2028
1041
|
})
|
|
2029
1042
|
});
|
|
2030
|
-
function
|
|
1043
|
+
function W(e) {
|
|
2031
1044
|
const t = e.map?.allLayers.filter((r) => r.type === "knowledge-graph");
|
|
2032
1045
|
if (!t || t?.length !== 1)
|
|
2033
1046
|
throw new Error("The Knowledge Agent currently only supports maps with exactly one Knowledge Graph Layer.");
|
|
2034
1047
|
}
|
|
2035
|
-
function
|
|
1048
|
+
function x(e) {
|
|
2036
1049
|
return !!e?.map && !("activeLinkChartLayer" in e.map);
|
|
2037
1050
|
}
|
|
2038
|
-
async function
|
|
2039
|
-
!e ||
|
|
1051
|
+
async function j(e) {
|
|
1052
|
+
!e || x(e) || !e.map?.diagramNodesExtent || await e.goTo(e.map.diagramNodesExtent);
|
|
2040
1053
|
}
|
|
2041
|
-
function
|
|
1054
|
+
function q(e) {
|
|
2042
1055
|
const r = e?.configurable?.context;
|
|
2043
1056
|
if (!r || typeof r != "object")
|
|
2044
1057
|
throw new Error("ArcgisKnowledgeAgent context missing");
|
|
2045
1058
|
if (!("view" in r))
|
|
2046
1059
|
throw new Error("View context missing");
|
|
2047
1060
|
const a = r.view;
|
|
2048
|
-
return a.map && !("activeLinkChartLayer" in a.map) &&
|
|
1061
|
+
return a.map && !("activeLinkChartLayer" in a.map) && W(a), {
|
|
2049
1062
|
view: a
|
|
2050
1063
|
};
|
|
2051
1064
|
}
|
|
2052
|
-
function
|
|
1065
|
+
function Qa(e) {
|
|
2053
1066
|
const r = e?.configurable?.context;
|
|
2054
|
-
if (
|
|
1067
|
+
if (te(e) === "knowledgeGraph")
|
|
2055
1068
|
return "knowledgeGraph";
|
|
2056
1069
|
const o = r.view;
|
|
2057
|
-
return
|
|
1070
|
+
return x(o) ? (W(o), "map") : "linkChart";
|
|
2058
1071
|
}
|
|
2059
|
-
async function
|
|
1072
|
+
async function M(e) {
|
|
2060
1073
|
const r = e?.configurable?.context;
|
|
2061
|
-
if (
|
|
1074
|
+
if (te(e) === "knowledgeGraph")
|
|
2062
1075
|
return r;
|
|
2063
1076
|
{
|
|
2064
1077
|
const o = r.view.map;
|
|
2065
1078
|
if (o && "activeLinkChartLayer" in o) {
|
|
2066
|
-
const
|
|
2067
|
-
if (!
|
|
1079
|
+
const i = o.knowledgeGraph?.url;
|
|
1080
|
+
if (!i)
|
|
2068
1081
|
throw new Error("Knowledge graph url missing from link chart.");
|
|
2069
1082
|
return {
|
|
2070
|
-
knowledgeGraph: await
|
|
1083
|
+
knowledgeGraph: await Z(i)
|
|
2071
1084
|
};
|
|
2072
1085
|
} else {
|
|
2073
|
-
|
|
2074
|
-
const
|
|
2075
|
-
(
|
|
1086
|
+
W(r.view);
|
|
1087
|
+
const s = (r.view.map?.allLayers.find(
|
|
1088
|
+
(l) => l.type === "knowledge-graph"
|
|
2076
1089
|
)).url;
|
|
2077
|
-
if (!
|
|
1090
|
+
if (!s)
|
|
2078
1091
|
throw new Error("Knowledge graph url missing from map.");
|
|
2079
1092
|
return {
|
|
2080
|
-
knowledgeGraph: await
|
|
1093
|
+
knowledgeGraph: await Z(s)
|
|
2081
1094
|
};
|
|
2082
1095
|
}
|
|
2083
1096
|
}
|
|
2084
1097
|
}
|
|
2085
|
-
function
|
|
1098
|
+
function te(e) {
|
|
2086
1099
|
const r = e?.configurable?.context;
|
|
2087
1100
|
if (!r || typeof r != "object")
|
|
2088
1101
|
throw new Error("ArcgisKnowledgeAgent context missing");
|
|
@@ -2094,12 +1107,12 @@ function Fe(e) {
|
|
|
2094
1107
|
return "view";
|
|
2095
1108
|
throw new Error("ArcgisKnowledgeAgent context must have either a view or knowledgeGraph property.");
|
|
2096
1109
|
}
|
|
2097
|
-
class
|
|
1110
|
+
class Br {
|
|
2098
1111
|
constructor(t) {
|
|
2099
|
-
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);
|
|
2100
1113
|
}
|
|
2101
1114
|
}
|
|
2102
|
-
class
|
|
1115
|
+
class B {
|
|
2103
1116
|
constructor() {
|
|
2104
1117
|
this.schemaType = "ArcgisGraphSchema", this.entityTypes = [], this.relationshipTypes = [], this.identifierInfo = {
|
|
2105
1118
|
mappingInfo: {
|
|
@@ -2109,14 +1122,14 @@ class ce {
|
|
|
2109
1122
|
};
|
|
2110
1123
|
}
|
|
2111
1124
|
static fromDataModel(t) {
|
|
2112
|
-
const r = new
|
|
1125
|
+
const r = new B();
|
|
2113
1126
|
for (const a of t.entityTypes)
|
|
2114
|
-
r.entityTypes.push(
|
|
1127
|
+
r.entityTypes.push(A.fromEntityType(a));
|
|
2115
1128
|
for (const a of t.relationshipTypes)
|
|
2116
|
-
r.relationshipTypes.push(
|
|
1129
|
+
r.relationshipTypes.push(Ur.fromRelationshipType(a));
|
|
2117
1130
|
return r.identifierInfo = {
|
|
2118
1131
|
mappingInfo: {
|
|
2119
|
-
identifierMapsTo:
|
|
1132
|
+
identifierMapsTo: Hr(
|
|
2120
1133
|
t.identifierInfo.identifierMappingInfo.identifierInfoType
|
|
2121
1134
|
),
|
|
2122
1135
|
identifierPropertyName: t.identifierInfo.identifierMappingInfo.uniformPropertyIdentifier.identifierPropertyName
|
|
@@ -2130,19 +1143,19 @@ class ce {
|
|
|
2130
1143
|
Relationship Types: ${a}.`;
|
|
2131
1144
|
}
|
|
2132
1145
|
}
|
|
2133
|
-
class
|
|
1146
|
+
class A {
|
|
2134
1147
|
constructor() {
|
|
2135
1148
|
this.name = "", this.properties = [];
|
|
2136
1149
|
}
|
|
2137
1150
|
static fromEntityType(t) {
|
|
2138
|
-
const r = new
|
|
2139
|
-
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);
|
|
2140
1153
|
for (const a of t.properties) {
|
|
2141
1154
|
const o = {
|
|
2142
1155
|
name: a.name,
|
|
2143
1156
|
alias: a.alias ? a.alias : void 0,
|
|
2144
1157
|
fieldType: a.fieldType,
|
|
2145
|
-
role:
|
|
1158
|
+
role: Yr(a.role),
|
|
2146
1159
|
geometryDef: a.fieldType === "esriFieldTypeGeometry" ? {
|
|
2147
1160
|
geometryType: a.geometryType ?? "esriGeometryAny",
|
|
2148
1161
|
hasM: a.hasM ? a.hasM : void 0,
|
|
@@ -2154,12 +1167,12 @@ class j {
|
|
|
2154
1167
|
return r;
|
|
2155
1168
|
}
|
|
2156
1169
|
}
|
|
2157
|
-
class
|
|
1170
|
+
class Ur extends A {
|
|
2158
1171
|
constructor() {
|
|
2159
1172
|
super(...arguments), this.observedEndPoints = [];
|
|
2160
1173
|
}
|
|
2161
1174
|
static fromRelationshipType(t) {
|
|
2162
|
-
const r =
|
|
1175
|
+
const r = A.fromEntityType(t);
|
|
2163
1176
|
r.observedEndPoints = [];
|
|
2164
1177
|
for (const a of t.endPoints)
|
|
2165
1178
|
r.observedEndPoints.push({
|
|
@@ -2169,7 +1182,7 @@ class Ha extends j {
|
|
|
2169
1182
|
return r;
|
|
2170
1183
|
}
|
|
2171
1184
|
}
|
|
2172
|
-
const
|
|
1185
|
+
const Hr = (e) => {
|
|
2173
1186
|
switch (e) {
|
|
2174
1187
|
case "esriIdentifierInfoTypeUNSPECIFIED":
|
|
2175
1188
|
return "UNSPECIFIED";
|
|
@@ -2180,7 +1193,7 @@ const Ja = (e) => {
|
|
|
2180
1193
|
default:
|
|
2181
1194
|
return e;
|
|
2182
1195
|
}
|
|
2183
|
-
},
|
|
1196
|
+
}, Jr = (e) => {
|
|
2184
1197
|
switch (e) {
|
|
2185
1198
|
case "Regular":
|
|
2186
1199
|
return "esriGraphNamedObjectRegular";
|
|
@@ -2192,7 +1205,7 @@ const Ja = (e) => {
|
|
|
2192
1205
|
return e;
|
|
2193
1206
|
}
|
|
2194
1207
|
};
|
|
2195
|
-
function
|
|
1208
|
+
function Yr(e) {
|
|
2196
1209
|
switch (e) {
|
|
2197
1210
|
case "esriGraphPropertyRegular":
|
|
2198
1211
|
return "Regular";
|
|
@@ -2230,11 +1243,11 @@ function Za(e) {
|
|
|
2230
1243
|
return "Regular";
|
|
2231
1244
|
}
|
|
2232
1245
|
}
|
|
2233
|
-
function
|
|
1246
|
+
function F(e) {
|
|
2234
1247
|
return e?.signal;
|
|
2235
1248
|
}
|
|
2236
|
-
async function
|
|
2237
|
-
const r = await
|
|
1249
|
+
async function Zr(e, t) {
|
|
1250
|
+
const r = await L("arcgis_knowledge_cypher_query_prompt");
|
|
2238
1251
|
return t ? `${e} ${r}
|
|
2239
1252
|
|
|
2240
1253
|
Your previous attempt to generate a cypher query failed. See the details below and generate a new cypher query that avoids this error.
|
|
@@ -2244,424 +1257,424 @@ Execution Error: ${t.executionError}
|
|
|
2244
1257
|
Failed Query:
|
|
2245
1258
|
${t.failedGraphQuery}` : `${e} ${r}`;
|
|
2246
1259
|
}
|
|
2247
|
-
async function
|
|
2248
|
-
const { graphQuery: o, explanation:
|
|
2249
|
-
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 };
|
|
2250
1263
|
}
|
|
2251
|
-
async function
|
|
2252
|
-
const
|
|
2253
|
-
message: await
|
|
2254
|
-
context: new
|
|
2255
|
-
},
|
|
2256
|
-
await
|
|
2257
|
-
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`, {
|
|
2258
1271
|
method: "post",
|
|
2259
|
-
body: JSON.stringify(
|
|
1272
|
+
body: JSON.stringify(i),
|
|
2260
1273
|
headers: {
|
|
2261
1274
|
"Content-Type": "application/json",
|
|
2262
|
-
token:
|
|
1275
|
+
token: H.findCredential(P.getDefault().url)?.token ?? ""
|
|
2263
1276
|
},
|
|
2264
|
-
signal:
|
|
1277
|
+
signal: s
|
|
2265
1278
|
});
|
|
2266
|
-
if (
|
|
2267
|
-
throw new Error(`Graph query service returned an error: ${
|
|
2268
|
-
cause:
|
|
1279
|
+
if (n.httpStatus !== 200)
|
|
1280
|
+
throw new Error(`Graph query service returned an error: ${n.httpStatus}`, {
|
|
1281
|
+
cause: n.data
|
|
2269
1282
|
});
|
|
2270
|
-
let
|
|
2271
|
-
const
|
|
2272
|
-
let d =
|
|
2273
|
-
for (; !
|
|
2274
|
-
await new Promise((
|
|
2275
|
-
{ 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)}` },
|
|
2276
1289
|
a
|
|
2277
|
-
),
|
|
2278
|
-
const
|
|
1290
|
+
), f = f % 3 + 1;
|
|
1291
|
+
const y = await J(`${r}/chat`, {
|
|
2279
1292
|
method: "post",
|
|
2280
1293
|
body: JSON.stringify({
|
|
2281
|
-
conversationId:
|
|
2282
|
-
inquiryId:
|
|
1294
|
+
conversationId: n.data.conversationId,
|
|
1295
|
+
inquiryId: n.data.inquiryId,
|
|
2283
1296
|
ackSequenceNumber: d
|
|
2284
1297
|
}),
|
|
2285
1298
|
headers: {
|
|
2286
1299
|
"Content-Type": "application/json",
|
|
2287
|
-
token:
|
|
1300
|
+
token: H.findCredential(P.getDefault().url)?.token ?? ""
|
|
2288
1301
|
},
|
|
2289
|
-
signal:
|
|
1302
|
+
signal: s
|
|
2290
1303
|
});
|
|
2291
|
-
if (
|
|
2292
|
-
throw new Error(`Graph query service polling returned an error: ${
|
|
2293
|
-
cause:
|
|
1304
|
+
if (y.httpStatus !== 200)
|
|
1305
|
+
throw new Error(`Graph query service polling returned an error: ${y.httpStatus}`, {
|
|
1306
|
+
cause: y.data
|
|
2294
1307
|
});
|
|
2295
|
-
if (
|
|
2296
|
-
if (
|
|
2297
|
-
throw new Error(`Unexpected response from graph query service polling. Message: ${
|
|
2298
|
-
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
|
|
2299
1312
|
});
|
|
2300
|
-
|
|
2301
|
-
} else if (!
|
|
2302
|
-
|
|
2303
|
-
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)
|
|
2304
1317
|
throw new Error("Graph query service polling timed out after 1 minute.");
|
|
2305
|
-
d =
|
|
1318
|
+
d = y.data.sequenceNumber;
|
|
2306
1319
|
}
|
|
2307
|
-
return { graphQuery:
|
|
1320
|
+
return { graphQuery: u, explanation: h };
|
|
2308
1321
|
}
|
|
2309
|
-
function
|
|
2310
|
-
|
|
1322
|
+
function et(e, t) {
|
|
1323
|
+
C(e, (r) => {
|
|
2311
1324
|
t.set(`${r.typeName}__${r.id}`, {
|
|
2312
1325
|
id: r.id,
|
|
2313
1326
|
typeName: r.typeName
|
|
2314
1327
|
});
|
|
2315
1328
|
});
|
|
2316
1329
|
}
|
|
2317
|
-
function
|
|
1330
|
+
function C(e, t) {
|
|
2318
1331
|
if (!(!e || typeof e != "object")) {
|
|
2319
|
-
if (
|
|
1332
|
+
if (tt(e))
|
|
2320
1333
|
for (const r of e.path)
|
|
2321
|
-
|
|
2322
|
-
else if (
|
|
1334
|
+
C(r, t);
|
|
1335
|
+
else if (rt(e))
|
|
2323
1336
|
t(e);
|
|
2324
1337
|
else if (Array.isArray(e))
|
|
2325
1338
|
for (const r of e)
|
|
2326
|
-
|
|
2327
|
-
else if (
|
|
1339
|
+
C(r, t);
|
|
1340
|
+
else if (at(e))
|
|
2328
1341
|
for (const r of Object.values(e.properties ?? {}))
|
|
2329
|
-
|
|
1342
|
+
C(r, t);
|
|
2330
1343
|
}
|
|
2331
1344
|
}
|
|
2332
|
-
function
|
|
1345
|
+
function rt(e) {
|
|
2333
1346
|
return !e || typeof e != "object" || Array.isArray(e) ? !1 : "id" in e && "typeName" in e;
|
|
2334
1347
|
}
|
|
2335
|
-
function
|
|
1348
|
+
function tt(e) {
|
|
2336
1349
|
return !e || typeof e != "object" || Array.isArray(e) ? !1 : e && "path" in e && Array.isArray(e.path);
|
|
2337
1350
|
}
|
|
2338
|
-
function
|
|
1351
|
+
function at(e) {
|
|
2339
1352
|
return !e || typeof e != "object" || Array.isArray(e) || "id" in e ? !1 : "properties" in e && typeof e.properties == "object";
|
|
2340
1353
|
}
|
|
2341
|
-
function
|
|
1354
|
+
function ot(e, t) {
|
|
2342
1355
|
const r = [], a = [], o = [
|
|
2343
1356
|
[t.dataModel.entityTypes, r],
|
|
2344
1357
|
[t.dataModel.relationshipTypes, a]
|
|
2345
1358
|
];
|
|
2346
|
-
for (const [
|
|
2347
|
-
for (const
|
|
2348
|
-
const
|
|
2349
|
-
|
|
1359
|
+
for (const [i, s] of o)
|
|
1360
|
+
for (const n of i) {
|
|
1361
|
+
const l = e.getMemberIdsByType(n.name);
|
|
1362
|
+
s.push(...l);
|
|
2350
1363
|
}
|
|
2351
1364
|
return { entityIds: r, relationshipIds: a };
|
|
2352
1365
|
}
|
|
2353
|
-
function
|
|
2354
|
-
const r = { entityIds: new Array(), relationshipIds: new Array() }, a = [],
|
|
2355
|
-
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)
|
|
2356
1369
|
return { allNamedTypesFullyDynamic: !0, bindParameters: r, nonDynamicTypes: a };
|
|
2357
|
-
const
|
|
1370
|
+
const s = [
|
|
2358
1371
|
[t.dataModel.entityTypes, r.entityIds],
|
|
2359
1372
|
[t.dataModel.relationshipTypes, r.relationshipIds]
|
|
2360
1373
|
];
|
|
2361
|
-
let
|
|
2362
|
-
for (const [
|
|
2363
|
-
for (const d of
|
|
2364
|
-
const
|
|
2365
|
-
if (!
|
|
2366
|
-
|
|
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);
|
|
2367
1380
|
continue;
|
|
2368
1381
|
}
|
|
2369
|
-
if (!
|
|
2370
|
-
|
|
2371
|
-
for (const [
|
|
2372
|
-
|
|
1382
|
+
if (!u.useAllData) {
|
|
1383
|
+
n = !1, a.push(d.name);
|
|
1384
|
+
for (const [h] of u.members || [])
|
|
1385
|
+
p.push(h);
|
|
2373
1386
|
}
|
|
2374
1387
|
}
|
|
2375
|
-
return { allNamedTypesFullyDynamic:
|
|
1388
|
+
return { allNamedTypesFullyDynamic: n, bindParameters: r, nonDynamicTypes: a };
|
|
2376
1389
|
}
|
|
2377
|
-
const
|
|
2378
|
-
function
|
|
1390
|
+
const $ = 3;
|
|
1391
|
+
function ae(e, t = 100) {
|
|
2379
1392
|
const r = {};
|
|
2380
1393
|
for (const a of Object.entries(e.properties ?? {})) {
|
|
2381
|
-
const [o,
|
|
2382
|
-
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;
|
|
2383
1396
|
}
|
|
2384
1397
|
return e.properties = r, e;
|
|
2385
1398
|
}
|
|
2386
|
-
function
|
|
1399
|
+
function E(e) {
|
|
2387
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);
|
|
2388
1401
|
}
|
|
2389
|
-
const
|
|
1402
|
+
const it = async ({
|
|
2390
1403
|
kg: e,
|
|
2391
1404
|
queryParams: t,
|
|
2392
1405
|
targetStructure: r,
|
|
2393
1406
|
targetStructureReducer: a,
|
|
2394
1407
|
requestOptions: o,
|
|
2395
|
-
queryRowLimit:
|
|
2396
|
-
queryTimeoutMs:
|
|
1408
|
+
queryRowLimit: i,
|
|
1409
|
+
queryTimeoutMs: s
|
|
2397
1410
|
}) => {
|
|
2398
|
-
let
|
|
2399
|
-
const
|
|
2400
|
-
|
|
1411
|
+
let n = null, l = r;
|
|
1412
|
+
const p = new AbortController(), d = o?.signal, u = () => {
|
|
1413
|
+
p.abort(d?.reason);
|
|
2401
1414
|
};
|
|
2402
|
-
d && (d.aborted ?
|
|
1415
|
+
d && (d.aborted ? p.abort(d.reason) : d.addEventListener("abort", u, { once: !0 }));
|
|
2403
1416
|
try {
|
|
2404
|
-
const
|
|
2405
|
-
|
|
2406
|
-
const
|
|
2407
|
-
let
|
|
2408
|
-
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;
|
|
2409
1422
|
for (; ; ) {
|
|
2410
|
-
const { done:
|
|
2411
|
-
if (
|
|
1423
|
+
const { done: R, value: z } = await f.read();
|
|
1424
|
+
if (R)
|
|
2412
1425
|
break;
|
|
2413
|
-
if (!
|
|
2414
|
-
return
|
|
2415
|
-
for (const
|
|
2416
|
-
if (
|
|
2417
|
-
return
|
|
2418
|
-
|
|
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);
|
|
2419
1432
|
}
|
|
2420
1433
|
}
|
|
2421
|
-
} catch (
|
|
2422
|
-
return
|
|
1434
|
+
} catch (h) {
|
|
1435
|
+
return p.signal.aborted ? { type: "aborted" } : { type: "error", errorMessage: E(h), error: h };
|
|
2423
1436
|
} finally {
|
|
2424
|
-
d?.removeEventListener("abort",
|
|
1437
|
+
d?.removeEventListener("abort", u);
|
|
2425
1438
|
}
|
|
2426
|
-
return { type: "success", rowLimitReached: !1, resultHeader:
|
|
1439
|
+
return { type: "success", rowLimitReached: !1, resultHeader: n, processedResult: l };
|
|
2427
1440
|
};
|
|
2428
|
-
async function
|
|
1441
|
+
async function oe({
|
|
2429
1442
|
prompt: e,
|
|
2430
1443
|
bindParameters: t,
|
|
2431
1444
|
kg: r,
|
|
2432
1445
|
graphQueryServiceUrl: a,
|
|
2433
1446
|
targetStructure: o,
|
|
2434
|
-
targetStructureReducer:
|
|
2435
|
-
requestOptions:
|
|
2436
|
-
queryRowLimit:
|
|
2437
|
-
queryTimeoutMs:
|
|
2438
|
-
config:
|
|
1447
|
+
targetStructureReducer: i,
|
|
1448
|
+
requestOptions: s,
|
|
1449
|
+
queryRowLimit: n,
|
|
1450
|
+
queryTimeoutMs: l,
|
|
1451
|
+
config: p
|
|
2439
1452
|
}) {
|
|
2440
1453
|
let d;
|
|
2441
|
-
for (let
|
|
2442
|
-
let
|
|
1454
|
+
for (let u = 1; u <= $; u++) {
|
|
1455
|
+
let h;
|
|
2443
1456
|
try {
|
|
2444
|
-
|
|
2445
|
-
} catch (
|
|
1457
|
+
h = await U(e, r.dataModel, a, p, d);
|
|
1458
|
+
} catch (b) {
|
|
2446
1459
|
return {
|
|
2447
1460
|
type: "generation-error",
|
|
2448
|
-
errorMessage:
|
|
2449
|
-
error:
|
|
1461
|
+
errorMessage: E(b),
|
|
1462
|
+
error: b
|
|
2450
1463
|
};
|
|
2451
1464
|
}
|
|
2452
|
-
await
|
|
1465
|
+
await T(
|
|
2453
1466
|
{
|
|
2454
|
-
text: `Attempting to execute query: ${
|
|
1467
|
+
text: `Attempting to execute query: ${h.graphQuery.substring(0, 500)}${h.graphQuery.length > 500 ? "..." : ""}`
|
|
2455
1468
|
},
|
|
2456
|
-
|
|
1469
|
+
p
|
|
2457
1470
|
);
|
|
2458
|
-
const
|
|
1471
|
+
const f = await st(h.graphQuery, t), y = await it({
|
|
2459
1472
|
kg: r,
|
|
2460
|
-
queryParams: new
|
|
2461
|
-
openCypherQuery:
|
|
2462
|
-
bindParameters:
|
|
1473
|
+
queryParams: new re({
|
|
1474
|
+
openCypherQuery: h.graphQuery,
|
|
1475
|
+
bindParameters: f
|
|
2463
1476
|
}),
|
|
2464
1477
|
targetStructure: o,
|
|
2465
|
-
targetStructureReducer:
|
|
2466
|
-
requestOptions:
|
|
2467
|
-
queryRowLimit:
|
|
2468
|
-
queryTimeoutMs:
|
|
2469
|
-
}),
|
|
2470
|
-
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")
|
|
2471
1484
|
return {
|
|
2472
1485
|
type: "success",
|
|
2473
|
-
graphQuery:
|
|
2474
|
-
explanation:
|
|
2475
|
-
rowLimitReached:
|
|
2476
|
-
resultHeader:
|
|
2477
|
-
processedResult:
|
|
1486
|
+
graphQuery: h.graphQuery,
|
|
1487
|
+
explanation: h.explanation,
|
|
1488
|
+
rowLimitReached: y.rowLimitReached,
|
|
1489
|
+
resultHeader: y.resultHeader,
|
|
1490
|
+
processedResult: y.processedResult
|
|
2478
1491
|
};
|
|
2479
|
-
if (
|
|
1492
|
+
if (y.type === "aborted")
|
|
2480
1493
|
return {
|
|
2481
1494
|
type: "aborted",
|
|
2482
|
-
errorMessage:
|
|
2483
|
-
graphQuery:
|
|
2484
|
-
explanation:
|
|
1495
|
+
errorMessage: w,
|
|
1496
|
+
graphQuery: h.graphQuery,
|
|
1497
|
+
explanation: h.explanation
|
|
2485
1498
|
};
|
|
2486
|
-
if (
|
|
2487
|
-
return
|
|
1499
|
+
if (u >= $)
|
|
1500
|
+
return y.type === "timeout" ? {
|
|
2488
1501
|
type: "timeout",
|
|
2489
|
-
errorMessage:
|
|
2490
|
-
graphQuery:
|
|
2491
|
-
explanation:
|
|
1502
|
+
errorMessage: w,
|
|
1503
|
+
graphQuery: h.graphQuery,
|
|
1504
|
+
explanation: h.explanation
|
|
2492
1505
|
} : {
|
|
2493
1506
|
type: "execution-error",
|
|
2494
|
-
errorMessage:
|
|
2495
|
-
error:
|
|
2496
|
-
graphQuery:
|
|
2497
|
-
explanation:
|
|
1507
|
+
errorMessage: w,
|
|
1508
|
+
error: y.error,
|
|
1509
|
+
graphQuery: h.graphQuery,
|
|
1510
|
+
explanation: h.explanation
|
|
2498
1511
|
};
|
|
2499
1512
|
d = {
|
|
2500
|
-
failedGraphQuery:
|
|
2501
|
-
executionError:
|
|
2502
|
-
attemptCount:
|
|
2503
|
-
}, await
|
|
2504
|
-
{ text: `Attempt ${
|
|
2505
|
-
|
|
1513
|
+
failedGraphQuery: h.graphQuery,
|
|
1514
|
+
executionError: w,
|
|
1515
|
+
attemptCount: u
|
|
1516
|
+
}, await T(
|
|
1517
|
+
{ text: `Attempt ${u} failed with error: ${w}. Retrying...` },
|
|
1518
|
+
p
|
|
2506
1519
|
);
|
|
2507
1520
|
}
|
|
2508
1521
|
throw new Error(
|
|
2509
|
-
`Failed to execute generated cypher due to an unexpected error after ${
|
|
1522
|
+
`Failed to execute generated cypher due to an unexpected error after ${$} attempts.`
|
|
2510
1523
|
);
|
|
2511
1524
|
}
|
|
2512
|
-
const
|
|
1525
|
+
const st = async (e, t) => {
|
|
2513
1526
|
if (!t)
|
|
2514
1527
|
return {};
|
|
2515
|
-
const { bindParameters: r, parseErrors: a } = await
|
|
1528
|
+
const { bindParameters: r, parseErrors: a } = await Qe(e);
|
|
2516
1529
|
if (a)
|
|
2517
1530
|
return t;
|
|
2518
1531
|
const o = {};
|
|
2519
|
-
for (const
|
|
2520
|
-
|
|
1532
|
+
for (const i of r)
|
|
1533
|
+
i in t && (o[i] = t[i]);
|
|
2521
1534
|
return o;
|
|
2522
|
-
},
|
|
1535
|
+
}, lt = async ({
|
|
2523
1536
|
kg: e,
|
|
2524
1537
|
searchQuery: t,
|
|
2525
1538
|
typeCategoryFilter: r,
|
|
2526
1539
|
namedTypesFilter: a,
|
|
2527
1540
|
searchResultLimit: o,
|
|
2528
|
-
requestOptions:
|
|
1541
|
+
requestOptions: i
|
|
2529
1542
|
}) => {
|
|
2530
|
-
const
|
|
2531
|
-
let
|
|
2532
|
-
r === "both" && !e.serviceDefinition.serviceCapabilities.searchCapabilities.searchTypeFilterCapabilities.includes("esriTypeBoth") && (
|
|
2533
|
-
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;
|
|
2534
1547
|
try {
|
|
2535
|
-
for (const
|
|
2536
|
-
const d =
|
|
1548
|
+
for (const p of n) {
|
|
1549
|
+
const d = l - s.length;
|
|
2537
1550
|
if (d <= 0)
|
|
2538
1551
|
break;
|
|
2539
|
-
const
|
|
1552
|
+
const f = (await Fe(
|
|
2540
1553
|
e,
|
|
2541
|
-
new
|
|
1554
|
+
new _e({
|
|
2542
1555
|
searchQuery: t,
|
|
2543
|
-
typeCategoryFilter:
|
|
1556
|
+
typeCategoryFilter: p,
|
|
2544
1557
|
namedTypesFilter: a ?? void 0,
|
|
2545
1558
|
num: d
|
|
2546
1559
|
}),
|
|
2547
|
-
|
|
1560
|
+
i
|
|
2548
1561
|
)).resultRowsStream.getReader();
|
|
2549
|
-
let
|
|
2550
|
-
for (; !
|
|
2551
|
-
const { done:
|
|
2552
|
-
if (
|
|
2553
|
-
|
|
1562
|
+
let y = !1;
|
|
1563
|
+
for (; !y; ) {
|
|
1564
|
+
const { done: w, value: b } = await f.read();
|
|
1565
|
+
if (w) {
|
|
1566
|
+
y = !0;
|
|
2554
1567
|
break;
|
|
2555
1568
|
}
|
|
2556
|
-
for (const
|
|
2557
|
-
for (const
|
|
2558
|
-
|
|
1569
|
+
for (const R of b)
|
|
1570
|
+
for (const z of R)
|
|
1571
|
+
s.push(z);
|
|
2559
1572
|
}
|
|
2560
1573
|
}
|
|
2561
|
-
} catch (
|
|
2562
|
-
const d =
|
|
2563
|
-
return
|
|
1574
|
+
} catch (p) {
|
|
1575
|
+
const d = E(p);
|
|
1576
|
+
return i?.signal?.aborted ? {
|
|
2564
1577
|
type: "aborted",
|
|
2565
1578
|
errorMessage: d,
|
|
2566
|
-
error:
|
|
2567
|
-
} : { type: "error", errorMessage: d, error:
|
|
1579
|
+
error: p
|
|
1580
|
+
} : { type: "error", errorMessage: d, error: p };
|
|
2568
1581
|
}
|
|
2569
1582
|
return {
|
|
2570
1583
|
type: "success",
|
|
2571
|
-
results:
|
|
1584
|
+
results: s
|
|
2572
1585
|
};
|
|
2573
|
-
},
|
|
2574
|
-
async function
|
|
1586
|
+
}, ne = "IMPORTANT: The generated cypher query must return entire entities and relationships ONLY.";
|
|
1587
|
+
async function ie({
|
|
2575
1588
|
prompt: e,
|
|
2576
1589
|
view: t,
|
|
2577
1590
|
knowledgeGraph: r,
|
|
2578
1591
|
includeReturnEntityAndRelationshipContext: a = !1
|
|
2579
1592
|
}) {
|
|
2580
1593
|
const o = [e];
|
|
2581
|
-
if (a && o.push(
|
|
2582
|
-
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);
|
|
2583
1596
|
return o.push(d), {
|
|
2584
1597
|
enhancedPrompt: o.join(`
|
|
2585
1598
|
|
|
2586
1599
|
`),
|
|
2587
|
-
bindParameters:
|
|
1600
|
+
bindParameters: u,
|
|
2588
1601
|
allNamedTypesFullyDynamic: !1
|
|
2589
1602
|
};
|
|
2590
1603
|
}
|
|
2591
|
-
const
|
|
2592
|
-
|
|
1604
|
+
const i = t.map, { allNamedTypesFullyDynamic: s, bindParameters: n, nonDynamicTypes: l } = nt(
|
|
1605
|
+
i,
|
|
2593
1606
|
r
|
|
2594
1607
|
);
|
|
2595
|
-
if (
|
|
1608
|
+
if (s)
|
|
2596
1609
|
return {
|
|
2597
1610
|
enhancedPrompt: o.join(`
|
|
2598
1611
|
|
|
2599
1612
|
`),
|
|
2600
|
-
bindParameters:
|
|
1613
|
+
bindParameters: n,
|
|
2601
1614
|
allNamedTypesFullyDynamic: !0
|
|
2602
1615
|
};
|
|
2603
|
-
const
|
|
1616
|
+
const p = (await L("arcgis_knowledge_current_map_context")).replaceAll(
|
|
2604
1617
|
"{nonDynamicTypes}",
|
|
2605
|
-
JSON.stringify(
|
|
1618
|
+
JSON.stringify(l)
|
|
2606
1619
|
);
|
|
2607
|
-
return o.push(
|
|
1620
|
+
return o.push(p), {
|
|
2608
1621
|
enhancedPrompt: o.join(`
|
|
2609
1622
|
|
|
2610
1623
|
`),
|
|
2611
|
-
bindParameters:
|
|
2612
|
-
allNamedTypesFullyDynamic:
|
|
1624
|
+
bindParameters: n,
|
|
1625
|
+
allNamedTypesFullyDynamic: s
|
|
2613
1626
|
};
|
|
2614
1627
|
}
|
|
2615
|
-
async function
|
|
2616
|
-
const { view:
|
|
1628
|
+
async function ct(e, t, r, a, o, i) {
|
|
1629
|
+
const { view: s } = o, n = await oe({
|
|
2617
1630
|
prompt: e,
|
|
2618
1631
|
bindParameters: t,
|
|
2619
1632
|
kg: r,
|
|
2620
1633
|
graphQueryServiceUrl: a,
|
|
2621
1634
|
targetStructure: /* @__PURE__ */ new Map(),
|
|
2622
|
-
targetStructureReducer: (
|
|
2623
|
-
for (const
|
|
2624
|
-
|
|
2625
|
-
return
|
|
1635
|
+
targetStructureReducer: (h, f) => {
|
|
1636
|
+
for (const y of f)
|
|
1637
|
+
et(y, h);
|
|
1638
|
+
return h;
|
|
2626
1639
|
},
|
|
2627
1640
|
requestOptions: {
|
|
2628
|
-
signal:
|
|
2629
|
-
timeout:
|
|
1641
|
+
signal: F(i),
|
|
1642
|
+
timeout: i?.timeout
|
|
2630
1643
|
},
|
|
2631
|
-
config:
|
|
1644
|
+
config: i
|
|
2632
1645
|
});
|
|
2633
|
-
if (
|
|
2634
|
-
const
|
|
2635
|
-
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}`);
|
|
2636
1649
|
}
|
|
2637
|
-
const { graphQuery:
|
|
2638
|
-
return await
|
|
1650
|
+
const { graphQuery: l, explanation: p, processedResult: d } = n, u = Array.from(d.values());
|
|
1651
|
+
return await T(
|
|
2639
1652
|
{
|
|
2640
|
-
text: `Query Results parsed into ${
|
|
1653
|
+
text: `Query Results parsed into ${u.length} unique relationships and entities. Atempting to add to link chart...`
|
|
2641
1654
|
},
|
|
2642
|
-
|
|
2643
|
-
), !
|
|
2644
|
-
(
|
|
2645
|
-
)?.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 });
|
|
2646
1659
|
}
|
|
2647
|
-
const
|
|
2648
|
-
prompt:
|
|
1660
|
+
const N = "addRecords", pt = c.object({
|
|
1661
|
+
prompt: c.string().describe(
|
|
2649
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."
|
|
2650
1663
|
)
|
|
2651
|
-
}),
|
|
2652
|
-
const { knowledgeGraph: r } = await
|
|
2653
|
-
enhancedPrompt:
|
|
2654
|
-
bindParameters:
|
|
2655
|
-
allNamedTypesFullyDynamic:
|
|
2656
|
-
} = 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({
|
|
2657
1670
|
prompt: e,
|
|
2658
1671
|
view: o,
|
|
2659
1672
|
knowledgeGraph: r,
|
|
2660
1673
|
includeReturnEntityAndRelationshipContext: !0
|
|
2661
1674
|
});
|
|
2662
|
-
if (
|
|
1675
|
+
if (p)
|
|
2663
1676
|
return {
|
|
2664
|
-
toolName:
|
|
1677
|
+
toolName: N,
|
|
2665
1678
|
status: "success",
|
|
2666
1679
|
summary: "No records have been added to the map because all data in the knowledge graph is contained in the map.",
|
|
2667
1680
|
details: {
|
|
@@ -2671,37 +1684,37 @@ const V = "addRecords", po = s.object({
|
|
|
2671
1684
|
}
|
|
2672
1685
|
};
|
|
2673
1686
|
try {
|
|
2674
|
-
const { generatedQuery: d, explanation:
|
|
2675
|
-
|
|
2676
|
-
|
|
1687
|
+
const { generatedQuery: d, explanation: u, addedIdTypePairs: h } = await ct(
|
|
1688
|
+
n,
|
|
1689
|
+
l,
|
|
2677
1690
|
r,
|
|
2678
|
-
`${
|
|
1691
|
+
`${s.aiAssistantServices.url}${s.aiAssistantServices.graphQueryAssistant}`,
|
|
2679
1692
|
a,
|
|
2680
1693
|
t
|
|
2681
1694
|
);
|
|
2682
1695
|
return {
|
|
2683
|
-
toolName:
|
|
1696
|
+
toolName: N,
|
|
2684
1697
|
status: "success",
|
|
2685
1698
|
summary: `Records added successfully. Cypher Query used: ${d}
|
|
2686
1699
|
|
|
2687
|
-
Number of records added: ${
|
|
1700
|
+
Number of records added: ${h.length}`,
|
|
2688
1701
|
details: {
|
|
2689
1702
|
generatedQuery: d,
|
|
2690
|
-
explanation:
|
|
2691
|
-
addedIdTypePairs:
|
|
1703
|
+
explanation: u,
|
|
1704
|
+
addedIdTypePairs: h
|
|
2692
1705
|
}
|
|
2693
1706
|
};
|
|
2694
1707
|
} catch (d) {
|
|
2695
|
-
const
|
|
1708
|
+
const u = E(d);
|
|
2696
1709
|
return {
|
|
2697
|
-
toolName:
|
|
1710
|
+
toolName: N,
|
|
2698
1711
|
status: "error",
|
|
2699
|
-
errorMessage: `Failed to add records to the link chart. ${
|
|
1712
|
+
errorMessage: `Failed to add records to the link chart. ${u}`,
|
|
2700
1713
|
error: d
|
|
2701
1714
|
};
|
|
2702
1715
|
}
|
|
2703
|
-
},
|
|
2704
|
-
name:
|
|
1716
|
+
}, Ia = g(dt, {
|
|
1717
|
+
name: N,
|
|
2705
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.
|
|
2706
1719
|
|
|
2707
1720
|
example prompts:
|
|
@@ -2713,13 +1726,13 @@ Number of records added: ${m.length}`,
|
|
|
2713
1726
|
- "connect company x and company y"
|
|
2714
1727
|
- "connect all buildings on the link chart"
|
|
2715
1728
|
`,
|
|
2716
|
-
schema:
|
|
1729
|
+
schema: pt
|
|
2717
1730
|
});
|
|
2718
|
-
async function
|
|
2719
|
-
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 };
|
|
2720
1733
|
}
|
|
2721
|
-
const
|
|
2722
|
-
layout:
|
|
1734
|
+
const _ = "applyLayout", ht = c.object({
|
|
1735
|
+
layout: c.enum([
|
|
2723
1736
|
"organic-standard",
|
|
2724
1737
|
"organic-community",
|
|
2725
1738
|
"basic-grid",
|
|
@@ -2732,19 +1745,19 @@ const te = "applyLayout", yo = s.object({
|
|
|
2732
1745
|
]).describe(
|
|
2733
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"
|
|
2734
1747
|
)
|
|
2735
|
-
}),
|
|
2736
|
-
const { view: r } =
|
|
2737
|
-
if (
|
|
1748
|
+
}), yt = async ({ layout: e }, t) => {
|
|
1749
|
+
const { view: r } = q(t);
|
|
1750
|
+
if (x(r))
|
|
2738
1751
|
return {
|
|
2739
|
-
toolName:
|
|
1752
|
+
toolName: _,
|
|
2740
1753
|
status: "error",
|
|
2741
1754
|
errorMessage: "The applyLayout tool can only be used with a LinkChartView.",
|
|
2742
1755
|
error: new Error()
|
|
2743
1756
|
};
|
|
2744
1757
|
{
|
|
2745
|
-
const { appliedLayout: a } = await
|
|
1758
|
+
const { appliedLayout: a } = await ut(e, r);
|
|
2746
1759
|
return {
|
|
2747
|
-
toolName:
|
|
1760
|
+
toolName: _,
|
|
2748
1761
|
status: "success",
|
|
2749
1762
|
summary: `Successfully applied layout: ${a}.`,
|
|
2750
1763
|
details: {
|
|
@@ -2752,29 +1765,29 @@ const te = "applyLayout", yo = s.object({
|
|
|
2752
1765
|
}
|
|
2753
1766
|
};
|
|
2754
1767
|
}
|
|
2755
|
-
},
|
|
2756
|
-
name:
|
|
1768
|
+
}, Oa = g(yt, {
|
|
1769
|
+
name: _,
|
|
2757
1770
|
description: "Apply a diagram layout to the link chart",
|
|
2758
|
-
schema:
|
|
1771
|
+
schema: ht
|
|
2759
1772
|
});
|
|
2760
|
-
async function
|
|
2761
|
-
return t.map?.changeNonspatialDataDisplay(e), await
|
|
2762
|
-
}
|
|
2763
|
-
const
|
|
2764
|
-
setting:
|
|
2765
|
-
}),
|
|
2766
|
-
const { view: r } =
|
|
2767
|
-
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))
|
|
2768
1781
|
return {
|
|
2769
|
-
toolName:
|
|
1782
|
+
toolName: Q,
|
|
2770
1783
|
status: "error",
|
|
2771
1784
|
errorMessage: "The changeNonspatialVisibility tool can only be used with a LinkChartView.",
|
|
2772
1785
|
error: new Error()
|
|
2773
1786
|
};
|
|
2774
1787
|
{
|
|
2775
|
-
const { appliedNonspatialDataDisplayMode: a } = await
|
|
1788
|
+
const { appliedNonspatialDataDisplayMode: a } = await mt(e, r);
|
|
2776
1789
|
return {
|
|
2777
|
-
toolName:
|
|
1790
|
+
toolName: Q,
|
|
2778
1791
|
status: "success",
|
|
2779
1792
|
summary: `Successfully applied nonspatial visibility setting: ${a}.`,
|
|
2780
1793
|
details: {
|
|
@@ -2782,303 +1795,303 @@ const re = "changeNonspatialVisibility", wo = s.object({
|
|
|
2782
1795
|
}
|
|
2783
1796
|
};
|
|
2784
1797
|
}
|
|
2785
|
-
},
|
|
2786
|
-
name:
|
|
1798
|
+
}, Ka = g(ft, {
|
|
1799
|
+
name: Q,
|
|
2787
1800
|
description: "Change whether or not nonspatial data is visible in the link chart. The value must be either 'hidden' or 'visible'.",
|
|
2788
|
-
schema:
|
|
1801
|
+
schema: gt
|
|
2789
1802
|
});
|
|
2790
|
-
async function
|
|
2791
|
-
let
|
|
2792
|
-
for (let
|
|
2793
|
-
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(
|
|
2794
1807
|
e,
|
|
2795
1808
|
t.dataModel,
|
|
2796
1809
|
r,
|
|
2797
1810
|
o,
|
|
2798
|
-
|
|
1811
|
+
i
|
|
2799
1812
|
);
|
|
2800
1813
|
try {
|
|
2801
|
-
await
|
|
2802
|
-
const d = await
|
|
1814
|
+
await T({ text: `Attempting to create link chart from derived query: ${l}` }, o);
|
|
1815
|
+
const d = await Ge.fromCypherQuery(
|
|
2803
1816
|
t,
|
|
2804
|
-
new
|
|
2805
|
-
openCypherQuery:
|
|
1817
|
+
new re({
|
|
1818
|
+
openCypherQuery: l
|
|
2806
1819
|
})
|
|
2807
1820
|
);
|
|
2808
|
-
await
|
|
2809
|
-
const
|
|
2810
|
-
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(), {
|
|
2811
1824
|
type: "error",
|
|
2812
1825
|
errorMessage: `Query returned no results. Cypher Query used to create the link chart:
|
|
2813
|
-
${
|
|
1826
|
+
${l}
|
|
2814
1827
|
|
|
2815
|
-
Explanation: ${
|
|
2816
|
-
}) : (await
|
|
1828
|
+
Explanation: ${p}`
|
|
1829
|
+
}) : (await j(a), {
|
|
2817
1830
|
type: "success",
|
|
2818
|
-
graphQuery:
|
|
2819
|
-
explanation:
|
|
1831
|
+
graphQuery: l,
|
|
1832
|
+
explanation: p
|
|
2820
1833
|
});
|
|
2821
1834
|
} catch (d) {
|
|
2822
|
-
const
|
|
2823
|
-
if (
|
|
2824
|
-
|
|
1835
|
+
const u = E(d);
|
|
1836
|
+
if (n >= $) {
|
|
1837
|
+
s = u;
|
|
2825
1838
|
break;
|
|
2826
1839
|
}
|
|
2827
|
-
|
|
2828
|
-
failedGraphQuery:
|
|
2829
|
-
executionError:
|
|
2830
|
-
attemptCount:
|
|
2831
|
-
}, await
|
|
2832
|
-
{ 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 ...` },
|
|
2833
1846
|
o
|
|
2834
1847
|
);
|
|
2835
1848
|
}
|
|
2836
1849
|
}
|
|
2837
1850
|
return {
|
|
2838
1851
|
type: "error",
|
|
2839
|
-
errorMessage: `Failed to create link chart after ${
|
|
1852
|
+
errorMessage: `Failed to create link chart after ${$} attempts. Last error: ${s}`
|
|
2840
1853
|
};
|
|
2841
1854
|
}
|
|
2842
|
-
const
|
|
2843
|
-
prompt:
|
|
1855
|
+
const D = "createLinkChart", bt = c.object({
|
|
1856
|
+
prompt: c.string().describe(
|
|
2844
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."
|
|
2845
1858
|
)
|
|
2846
|
-
}),
|
|
2847
|
-
const { knowledgeGraph: r } = await
|
|
2848
|
-
if (
|
|
1859
|
+
}), Tt = async ({ prompt: e }, t) => {
|
|
1860
|
+
const { knowledgeGraph: r } = await M(t), { view: a } = q(t);
|
|
1861
|
+
if (x(a))
|
|
2849
1862
|
return {
|
|
2850
|
-
toolName:
|
|
1863
|
+
toolName: D,
|
|
2851
1864
|
status: "error",
|
|
2852
1865
|
errorMessage: "The createLinkChart tool can only be used with a LinkChartView.",
|
|
2853
1866
|
error: new Error()
|
|
2854
1867
|
};
|
|
2855
1868
|
{
|
|
2856
|
-
const
|
|
1869
|
+
const i = P.getDefault().helperServices, s = await wt(
|
|
2857
1870
|
`${e}
|
|
2858
1871
|
|
|
2859
|
-
${
|
|
1872
|
+
${ne}`,
|
|
2860
1873
|
r,
|
|
2861
|
-
`${
|
|
1874
|
+
`${i.aiAssistantServices.url}${i.aiAssistantServices.graphQueryAssistant}`,
|
|
2862
1875
|
a,
|
|
2863
1876
|
t
|
|
2864
1877
|
);
|
|
2865
|
-
if (
|
|
1878
|
+
if (s.type === "error")
|
|
2866
1879
|
return {
|
|
2867
|
-
toolName:
|
|
1880
|
+
toolName: D,
|
|
2868
1881
|
status: "error",
|
|
2869
|
-
errorMessage:
|
|
1882
|
+
errorMessage: s.errorMessage,
|
|
2870
1883
|
error: new Error()
|
|
2871
1884
|
};
|
|
2872
|
-
const { graphQuery:
|
|
1885
|
+
const { graphQuery: n, explanation: l } = s;
|
|
2873
1886
|
return {
|
|
2874
|
-
toolName:
|
|
1887
|
+
toolName: D,
|
|
2875
1888
|
status: "success",
|
|
2876
1889
|
summary: `Link chart created successfully. Cypher Query used to create the link chart:
|
|
2877
|
-
${
|
|
1890
|
+
${n}
|
|
2878
1891
|
|
|
2879
|
-
Explanation: ${
|
|
1892
|
+
Explanation: ${l}`,
|
|
2880
1893
|
details: {
|
|
2881
|
-
generatedQuery:
|
|
2882
|
-
explanation:
|
|
1894
|
+
generatedQuery: n,
|
|
1895
|
+
explanation: l
|
|
2883
1896
|
}
|
|
2884
1897
|
};
|
|
2885
1898
|
}
|
|
2886
|
-
},
|
|
2887
|
-
name:
|
|
1899
|
+
}, Va = g(Tt, {
|
|
1900
|
+
name: D,
|
|
2888
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'.",
|
|
2889
|
-
schema:
|
|
2890
|
-
}),
|
|
2891
|
-
prompt:
|
|
1902
|
+
schema: bt
|
|
1903
|
+
}), I = "queryGraphData", St = c.object({
|
|
1904
|
+
prompt: c.string().describe(
|
|
2892
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."
|
|
2893
1906
|
)
|
|
2894
|
-
}),
|
|
2895
|
-
const { knowledgeGraph: r } = await
|
|
2896
|
-
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;
|
|
2897
1910
|
try {
|
|
2898
|
-
({ view:
|
|
1911
|
+
({ view: n } = q(t));
|
|
2899
1912
|
} catch {
|
|
2900
1913
|
}
|
|
2901
|
-
|
|
1914
|
+
n && ({ enhancedPrompt: i, bindParameters: s } = await ie({
|
|
2902
1915
|
prompt: e,
|
|
2903
|
-
view:
|
|
1916
|
+
view: n,
|
|
2904
1917
|
knowledgeGraph: r,
|
|
2905
1918
|
includeReturnEntityAndRelationshipContext: !1
|
|
2906
1919
|
}));
|
|
2907
|
-
const
|
|
2908
|
-
prompt:
|
|
2909
|
-
bindParameters:
|
|
1920
|
+
const l = await oe({
|
|
1921
|
+
prompt: i,
|
|
1922
|
+
bindParameters: s,
|
|
2910
1923
|
kg: r,
|
|
2911
1924
|
graphQueryServiceUrl: `${o.aiAssistantServices.url}${o.aiAssistantServices.graphQueryAssistant}`,
|
|
2912
1925
|
targetStructure: new Array(),
|
|
2913
|
-
targetStructureReducer: (
|
|
1926
|
+
targetStructureReducer: (b, R) => (b.push(R), b),
|
|
2914
1927
|
requestOptions: {
|
|
2915
|
-
signal:
|
|
1928
|
+
signal: F(t),
|
|
2916
1929
|
timeout: t?.timeout
|
|
2917
1930
|
},
|
|
2918
1931
|
config: t
|
|
2919
1932
|
});
|
|
2920
|
-
if (
|
|
2921
|
-
const
|
|
1933
|
+
if (l.type !== "success") {
|
|
1934
|
+
const b = l.type === "generation-error" ? l.errorMessage : `${l.errorMessage} Cypher query: ${l.graphQuery}`;
|
|
2922
1935
|
return {
|
|
2923
|
-
toolName:
|
|
1936
|
+
toolName: I,
|
|
2924
1937
|
status: "error",
|
|
2925
|
-
errorMessage: `Failed to query the knowledge graph. ${
|
|
2926
|
-
error: "error" in
|
|
1938
|
+
errorMessage: `Failed to query the knowledge graph. ${b}`,
|
|
1939
|
+
error: "error" in l ? l.error : null
|
|
2927
1940
|
};
|
|
2928
1941
|
}
|
|
2929
|
-
const { graphQuery:
|
|
2930
|
-
for (const
|
|
2931
|
-
for (const
|
|
2932
|
-
|
|
2933
|
-
|
|
2934
|
-
(
|
|
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)
|
|
2935
1948
|
);
|
|
2936
|
-
const
|
|
1949
|
+
const y = 50, w = u.slice(0, y).map((b) => JSON.stringify(b));
|
|
2937
1950
|
return {
|
|
2938
|
-
toolName:
|
|
1951
|
+
toolName: I,
|
|
2939
1952
|
status: "success",
|
|
2940
1953
|
summary: `To answer the inquiry, the following cypher query was executed against the knowledge graph:
|
|
2941
1954
|
|
|
2942
1955
|
\`\`\`cypher
|
|
2943
|
-
${
|
|
1956
|
+
${p}
|
|
2944
1957
|
\`\`\`
|
|
2945
1958
|
|
|
2946
1959
|
Query Results:
|
|
2947
|
-
${
|
|
1960
|
+
${w.length} result(s) found.
|
|
2948
1961
|
|
|
2949
|
-
Column Headers: ${
|
|
1962
|
+
Column Headers: ${f.join(", ")}
|
|
2950
1963
|
|
|
2951
|
-
${
|
|
1964
|
+
${w.length > y ? `Showing top ${y} results:
|
|
2952
1965
|
|
|
2953
1966
|
` : `Results:
|
|
2954
1967
|
|
|
2955
|
-
`}${
|
|
1968
|
+
`}${w.join(`
|
|
2956
1969
|
`)}
|
|
2957
1970
|
`,
|
|
2958
1971
|
details: {
|
|
2959
|
-
generatedQuery:
|
|
1972
|
+
generatedQuery: p,
|
|
2960
1973
|
explanation: d,
|
|
2961
|
-
resultHeader:
|
|
2962
|
-
queryResults:
|
|
1974
|
+
resultHeader: h,
|
|
1975
|
+
queryResults: u
|
|
2963
1976
|
}
|
|
2964
1977
|
};
|
|
2965
|
-
},
|
|
2966
|
-
name:
|
|
1978
|
+
}, Wa = g(vt, {
|
|
1979
|
+
name: I,
|
|
2967
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?'.",
|
|
2968
|
-
schema:
|
|
2969
|
-
}),
|
|
2970
|
-
prompt:
|
|
2971
|
-
}),
|
|
2972
|
-
const { knowledgeGraph: r } = await
|
|
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;
|
|
2973
1986
|
try {
|
|
2974
|
-
const { graphQuery:
|
|
1987
|
+
const { graphQuery: i, explanation: s } = await Xr(
|
|
2975
1988
|
e,
|
|
2976
1989
|
r.dataModel,
|
|
2977
1990
|
`${o.aiAssistantServices.url}${o.aiAssistantServices.graphQueryAssistant}`,
|
|
2978
1991
|
t
|
|
2979
1992
|
);
|
|
2980
1993
|
return {
|
|
2981
|
-
toolName:
|
|
1994
|
+
toolName: O,
|
|
2982
1995
|
status: "success",
|
|
2983
1996
|
summary: `Generated Graph Query:
|
|
2984
|
-
${
|
|
1997
|
+
${i}
|
|
2985
1998
|
|
|
2986
|
-
Explanation: ${
|
|
1999
|
+
Explanation: ${s}`,
|
|
2987
2000
|
details: {
|
|
2988
|
-
generatedQuery:
|
|
2989
|
-
explanation:
|
|
2001
|
+
generatedQuery: i,
|
|
2002
|
+
explanation: s
|
|
2990
2003
|
}
|
|
2991
2004
|
};
|
|
2992
|
-
} catch (
|
|
2993
|
-
const
|
|
2005
|
+
} catch (i) {
|
|
2006
|
+
const s = E(i);
|
|
2994
2007
|
return {
|
|
2995
|
-
toolName:
|
|
2008
|
+
toolName: O,
|
|
2996
2009
|
status: "error",
|
|
2997
|
-
errorMessage: `Failed to generate Cypher query. ${
|
|
2998
|
-
error:
|
|
2010
|
+
errorMessage: `Failed to generate Cypher query. ${s}`,
|
|
2011
|
+
error: i
|
|
2999
2012
|
};
|
|
3000
2013
|
}
|
|
3001
|
-
},
|
|
3002
|
-
name:
|
|
2014
|
+
}, Ba = g(xt, {
|
|
2015
|
+
name: O,
|
|
3003
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.",
|
|
3004
|
-
schema:
|
|
3005
|
-
}),
|
|
2017
|
+
schema: Rt
|
|
2018
|
+
}), Ct = (e) => {
|
|
3006
2019
|
const t = e.dataModel, r = /* @__PURE__ */ new Map();
|
|
3007
|
-
for (const
|
|
3008
|
-
if (
|
|
3009
|
-
for (const [
|
|
3010
|
-
const d = r.get(
|
|
3011
|
-
|
|
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);
|
|
3012
2025
|
}
|
|
3013
|
-
const a = t.entityTypes.filter((
|
|
3014
|
-
${a.map(({ name:
|
|
3015
|
-
`)}`,
|
|
3016
|
-
${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(`
|
|
3017
2030
|
`)}`;
|
|
3018
|
-
return `${
|
|
2031
|
+
return `${i}
|
|
3019
2032
|
|
|
3020
|
-
${
|
|
2033
|
+
${s}`;
|
|
3021
2034
|
};
|
|
3022
|
-
async function
|
|
3023
|
-
const a = await
|
|
2035
|
+
async function $t(e, t, r) {
|
|
2036
|
+
const a = await L("arcgis_knowledge_lucene_generation_prompt"), o = {
|
|
3024
2037
|
inquiry: e,
|
|
3025
|
-
dataModelForSearch:
|
|
3026
|
-
},
|
|
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(
|
|
3027
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."
|
|
3028
|
-
),
|
|
3029
|
-
|
|
2041
|
+
), n = c.array(
|
|
2042
|
+
c.enum(
|
|
3030
2043
|
t.dataModel.entityTypes.map((d) => d.name).concat(t.dataModel.relationshipTypes.map((d) => d.name))
|
|
3031
2044
|
)
|
|
3032
|
-
).min(1),
|
|
3033
|
-
query:
|
|
3034
|
-
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(
|
|
3035
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"
|
|
3036
2049
|
),
|
|
3037
|
-
typeCategoryFilter:
|
|
3038
|
-
resultLimit:
|
|
2050
|
+
typeCategoryFilter: i,
|
|
2051
|
+
resultLimit: s
|
|
3039
2052
|
});
|
|
3040
|
-
return await
|
|
2053
|
+
return await le({
|
|
3041
2054
|
promptText: a,
|
|
3042
2055
|
inputVariables: o,
|
|
3043
|
-
schema:
|
|
2056
|
+
schema: l,
|
|
3044
2057
|
config: r
|
|
3045
2058
|
});
|
|
3046
2059
|
}
|
|
3047
|
-
const
|
|
3048
|
-
prompt:
|
|
2060
|
+
const K = "searchGraphData", Pt = c.object({
|
|
2061
|
+
prompt: c.string().describe(
|
|
3049
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."
|
|
3050
2063
|
)
|
|
3051
|
-
}),
|
|
3052
|
-
const { knowledgeGraph: r } = await
|
|
3053
|
-
await
|
|
3054
|
-
const a = await
|
|
3055
|
-
await
|
|
3056
|
-
const o = await
|
|
2064
|
+
}), Et = async ({ prompt: e }, t) => {
|
|
2065
|
+
const { knowledgeGraph: r } = await M(t);
|
|
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({
|
|
3057
2070
|
kg: r,
|
|
3058
2071
|
searchQuery: a.query,
|
|
3059
2072
|
typeCategoryFilter: a.typeCategoryFilter,
|
|
3060
2073
|
namedTypesFilter: a.typeFilters,
|
|
3061
2074
|
searchResultLimit: a.resultLimit,
|
|
3062
2075
|
requestOptions: {
|
|
3063
|
-
signal:
|
|
2076
|
+
signal: F(t),
|
|
3064
2077
|
timeout: t?.timeout
|
|
3065
2078
|
}
|
|
3066
2079
|
});
|
|
3067
2080
|
if (o.type !== "success")
|
|
3068
2081
|
return {
|
|
3069
|
-
toolName:
|
|
2082
|
+
toolName: K,
|
|
3070
2083
|
status: "error",
|
|
3071
2084
|
errorMessage: o.errorMessage,
|
|
3072
2085
|
error: "error" in o ? o.error : null
|
|
3073
2086
|
};
|
|
3074
|
-
for (const
|
|
3075
|
-
|
|
3076
|
-
|
|
3077
|
-
(
|
|
2087
|
+
for (const n of o.results)
|
|
2088
|
+
C(
|
|
2089
|
+
n,
|
|
2090
|
+
(l) => ae(l)
|
|
3078
2091
|
);
|
|
3079
|
-
const
|
|
2092
|
+
const i = 10, s = o.results.slice(0, i);
|
|
3080
2093
|
return {
|
|
3081
|
-
toolName:
|
|
2094
|
+
toolName: K,
|
|
3082
2095
|
status: "success",
|
|
3083
2096
|
summary: `To answer the query, the following lucene query was generated and executed:
|
|
3084
2097
|
Query: ${a.query}
|
|
@@ -3088,17 +2101,17 @@ const ne = "searchGraphData", ko = s.object({
|
|
|
3088
2101
|
|
|
3089
2102
|
Search Results: ${o.results.length} result(s) found.
|
|
3090
2103
|
|
|
3091
|
-
${o.results.length >
|
|
2104
|
+
${o.results.length > i ? `Showing top ${i} results:
|
|
3092
2105
|
|
|
3093
|
-
` : ""}${
|
|
2106
|
+
` : ""}${s.map((n) => JSON.stringify(n)).join(`
|
|
3094
2107
|
`)}`,
|
|
3095
2108
|
details: {
|
|
3096
2109
|
generatedSearchQuery: a,
|
|
3097
2110
|
searchResults: o.results
|
|
3098
2111
|
}
|
|
3099
2112
|
};
|
|
3100
|
-
},
|
|
3101
|
-
name:
|
|
2113
|
+
}, Ua = g(Et, {
|
|
2114
|
+
name: K,
|
|
3102
2115
|
description: `
|
|
3103
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.
|
|
3104
2117
|
Example prompts:
|
|
@@ -3109,52 +2122,39 @@ const ne = "searchGraphData", ko = s.object({
|
|
|
3109
2122
|
- "Find all reports authored by someone with the title of 'Researcher'"
|
|
3110
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".
|
|
3111
2124
|
- "Search for all john smiths and show their global ids`,
|
|
3112
|
-
schema:
|
|
2125
|
+
schema: Pt
|
|
3113
2126
|
});
|
|
3114
2127
|
export {
|
|
3115
|
-
|
|
3116
|
-
|
|
3117
|
-
|
|
3118
|
-
|
|
3119
|
-
|
|
3120
|
-
|
|
3121
|
-
|
|
3122
|
-
|
|
3123
|
-
|
|
3124
|
-
|
|
3125
|
-
|
|
3126
|
-
|
|
3127
|
-
|
|
3128
|
-
|
|
3129
|
-
|
|
3130
|
-
|
|
3131
|
-
|
|
3132
|
-
|
|
3133
|
-
|
|
3134
|
-
|
|
3135
|
-
|
|
3136
|
-
|
|
3137
|
-
|
|
3138
|
-
|
|
3139
|
-
|
|
3140
|
-
|
|
3141
|
-
|
|
3142
|
-
|
|
3143
|
-
|
|
3144
|
-
|
|
3145
|
-
|
|
3146
|
-
|
|
3147
|
-
zn as n,
|
|
3148
|
-
Dn as o,
|
|
3149
|
-
Pn as p,
|
|
3150
|
-
di as q,
|
|
3151
|
-
On as r,
|
|
3152
|
-
mi as s,
|
|
3153
|
-
Bt as t,
|
|
3154
|
-
An as u,
|
|
3155
|
-
Ln as v,
|
|
3156
|
-
jn as w,
|
|
3157
|
-
Gn as x,
|
|
3158
|
-
v as y,
|
|
3159
|
-
Mn 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
|
|
3160
2160
|
};
|