@arcgis/ai-components 5.2.0-next.8 → 5.2.0-next.85
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +4 -2
- package/README.md +2 -2
- package/dist/agent-utils/FunctionAgent.d.ts +2 -2
- package/dist/agent-utils/LLMAgent.d.ts +7 -4
- package/dist/agent-utils/LLMAgent.js +3 -2
- package/dist/agent-utils/WorkflowAgent.d.ts +2 -2
- package/dist/agent-utils/index.d.ts +177 -0
- package/dist/agent-utils/index.js +167 -0
- package/dist/agent-utils/middlewares/trace.d.ts +2 -0
- package/dist/agent-utils/middlewares/trace.js +25 -33
- package/dist/agent-utils/tools/FunctionTool.d.ts +2 -2
- package/dist/agent-utils/types.d.ts +37 -8
- package/dist/agent-utils/workflows/ConditionalWorkflow.d.ts +2 -2
- package/dist/agent-utils/workflows/LoopWorkflow.d.ts +2 -2
- package/dist/agent-utils/workflows/ParallelWorkflow.d.ts +2 -2
- package/dist/agent-utils/workflows/RouterWorkflow.d.ts +2 -2
- package/dist/agent-utils/workflows/SequentialWorkflow.d.ts +2 -2
- package/dist/agent-utils/workflows/SwitchWorkflow.d.ts +2 -2
- package/dist/agentic-workflow/AgenticWorkflowRuntime.d.ts +24 -0
- package/dist/agentic-workflow/Edge.d.ts +16 -0
- package/dist/agentic-workflow/WebAgent.d.ts +39 -0
- package/dist/agentic-workflow/jsonTypes.d.ts +183 -0
- package/dist/agentic-workflow/nodes/AgentNode.d.ts +27 -0
- package/dist/agentic-workflow/nodes/BaseNode.d.ts +35 -0
- package/dist/agentic-workflow/nodes/EndMessageNode.d.ts +25 -0
- package/dist/agentic-workflow/nodes/StartNode.d.ts +21 -0
- package/dist/agentic-workflow/nodes/tools/ArcgisTool.d.ts +21 -0
- package/dist/agentic-workflow/types.d.ts +29 -0
- package/dist/agents/tools/filter/clearFilters/adapter.d.ts +8 -0
- package/dist/agents/tools/filter/clearFilters/adapter.js +22 -0
- package/dist/agents/tools/filter/resetMap/adapter.d.ts +8 -0
- package/dist/agents/tools/filter/resetMap/adapter.js +22 -0
- package/dist/agents/tools/filter/setFeatureEffect/adapter.d.ts +8 -0
- package/dist/agents/tools/filter/setFeatureEffect/adapter.js +109 -0
- package/dist/agents/tools/help/listFields/adapter.d.ts +11 -0
- package/dist/agents/tools/help/listFields/adapter.js +30 -0
- package/dist/agents/tools/navigation/goToAddress/adapter.d.ts +10 -0
- package/dist/agents/tools/navigation/goToAddress/adapter.js +52 -0
- package/dist/agents/tools/navigation/goToBookmark/adapter.d.ts +8 -0
- package/dist/agents/tools/navigation/goToBookmark/adapter.js +30 -0
- package/dist/agents/tools/navigation/goToFeatures/adapter.d.ts +8 -0
- package/dist/agents/tools/navigation/goToFeatures/adapter.js +50 -0
- package/dist/agents/tools/navigation/goToFullExtent/adapter.d.ts +8 -0
- package/dist/agents/tools/navigation/goToFullExtent/adapter.js +27 -0
- package/dist/agents/tools/navigation/goToHomeExtent/adapter.d.ts +8 -0
- package/dist/agents/tools/navigation/goToHomeExtent/adapter.js +24 -0
- package/dist/agents/tools/navigation/goToLayer/adapter.d.ts +8 -0
- package/dist/agents/tools/navigation/goToLayer/adapter.js +26 -0
- package/dist/agents/tools/navigation/goToScale/adapter.d.ts +8 -0
- package/dist/agents/tools/navigation/goToScale/adapter.js +21 -0
- package/dist/agents/tools/navigation/goToViewpoint/adapter.d.ts +8 -0
- package/dist/agents/tools/navigation/goToViewpoint/adapter.js +42 -0
- package/dist/agents/tools/navigation/goToZoom/adapter.d.ts +8 -0
- package/dist/agents/tools/navigation/goToZoom/adapter.js +21 -0
- package/dist/agents/tools/query/getAttribute/adapter.d.ts +8 -0
- package/dist/agents/tools/query/getAttribute/adapter.js +40 -0
- package/dist/agents/tools/query/getStatistics/adapter.d.ts +8 -0
- package/dist/agents/tools/query/getStatistics/adapter.js +154 -0
- package/dist/agents/tools/query/getTopFeatures/adapter.d.ts +8 -0
- package/dist/agents/tools/query/getTopFeatures/adapter.js +141 -0
- package/dist/agents/tools/query/queryFeatures/adapter.d.ts +8 -0
- package/dist/agents/tools/query/queryFeatures/adapter.js +127 -0
- package/dist/agents/tools/search/findRelevantFields/adapter.d.ts +8 -0
- package/dist/agents/tools/search/findRelevantFields/adapter.js +57 -0
- package/dist/agents/tools/search/findRelevantLayers/adapter.d.ts +8 -0
- package/dist/agents/tools/search/findRelevantLayers/adapter.js +38 -0
- package/dist/cdn/2EY3BQQX.js +2 -0
- package/dist/cdn/34O57OGV.js +2 -0
- package/dist/cdn/3POGAH2X.js +2 -0
- package/dist/cdn/3SEKXQVK.js +9 -0
- package/dist/cdn/{AMP6IALT.js → 3UEKINYC.js} +1 -1
- package/dist/cdn/434TAA3J.js +2 -0
- package/dist/cdn/4HDDRBIY.js +2 -0
- package/dist/cdn/4NJ2FF7H.js +2 -0
- package/dist/cdn/4OGR5QKS.js +2 -0
- package/dist/cdn/4QGVOLW6.js +22 -0
- package/dist/cdn/4WIDLQUH.js +2 -0
- package/dist/cdn/5WYRJMBW.js +2 -0
- package/dist/cdn/5X7EG7D2.js +2 -0
- package/dist/cdn/5ZFUGNRN.js +2 -0
- package/dist/cdn/6HF36IKA.js +2 -0
- package/dist/cdn/6KFMRBAA.js +2 -0
- package/dist/cdn/6NHYXISD.js +2 -0
- package/dist/cdn/6U4GTCLJ.js +66 -0
- package/dist/cdn/7BCQMK6D.js +2 -0
- package/dist/cdn/7GMCLVSZ.js +2 -0
- package/dist/cdn/7M6VKBTK.js +6 -0
- package/dist/cdn/{GGSZM7KV.js → 7Q5EESAR.js} +6 -4
- package/dist/cdn/7SRLZQVC.js +5 -0
- package/dist/cdn/7TXR75RG.js +2 -0
- package/dist/cdn/7V6OSTFC.js +2 -0
- package/dist/cdn/7VAQUCBU.js +9 -0
- package/dist/cdn/7ZFAFKJT.js +2 -0
- package/dist/cdn/ACJTJLZN.js +2 -0
- package/dist/cdn/AI6DYOKR.js +181 -0
- package/dist/cdn/{ZS2TZ6BF.js → AOVJ34QE.js} +1 -1
- package/dist/cdn/APFZY4PI.js +2 -0
- package/dist/cdn/AT4XVTJR.js +44 -0
- package/dist/cdn/AZ5G7YZH.js +3 -0
- package/dist/cdn/{FL4W4VYN.js → BL273EGZ.js} +17 -1
- package/dist/cdn/BM3WFHJG.js +2 -0
- package/dist/cdn/{DHOVCT6R.js → BPCBE7J6.js} +1 -1
- package/dist/cdn/CCC6LBMY.js +2 -0
- package/dist/cdn/{5ZZGKP7N.js → CEKOEHB3.js} +1 -1
- package/dist/cdn/CJMUJXPL.js +2 -0
- package/dist/cdn/CP5BVGJU.js +2 -0
- package/dist/cdn/CZM4URK7.js +2 -0
- package/dist/cdn/DPALM2OW.js +2 -0
- package/dist/cdn/E7JZ7GUW.js +18 -0
- package/dist/cdn/EMLOVMD4.js +2 -0
- package/dist/cdn/EWLXNGKH.js +208 -0
- package/dist/cdn/F2J6BMMX.js +36 -0
- package/dist/cdn/FAR3DFFK.js +2 -0
- package/dist/cdn/FDOMMK2M.js +2 -0
- package/dist/cdn/{ZLXN7NMF.js → FYZATVB3.js} +10 -8
- package/dist/cdn/GFEOVHJK.js +2 -0
- package/dist/cdn/HDM2D2GD.js +2 -0
- package/dist/cdn/HHFNQR6Z.js +2 -0
- package/dist/cdn/HMUWQCXU.js +2 -0
- package/dist/cdn/I3ONG4AX.js +2 -0
- package/dist/cdn/IBZ2NEAO.js +2 -0
- package/dist/cdn/{FX7UOGHP.js → ICBIUFK7.js} +1 -1
- package/dist/cdn/IFJM5XEQ.js +2 -0
- package/dist/cdn/IHP25JWI.js +99 -0
- package/dist/cdn/J6A4AS7E.js +22 -0
- package/dist/cdn/J6SZIQJA.js +2 -0
- package/dist/cdn/{NE7E52YR.js → JEBRN3EU.js} +9 -3
- package/dist/cdn/JKIESH74.js +2 -0
- package/dist/cdn/JO5ETMPS.js +2 -0
- package/dist/cdn/JWIE3YK3.js +2 -0
- package/dist/cdn/K2R6XVK3.js +2 -0
- package/dist/cdn/KITIP6J2.js +2 -0
- package/dist/cdn/KPO4XX6J.js +2 -0
- package/dist/cdn/KWD2ECTM.js +2 -0
- package/dist/cdn/L7XTRDFM.js +3 -0
- package/dist/cdn/{7RCQFLPP.js → LK7ZIQW6.js} +1 -1
- package/dist/cdn/LLUGJKAQ.js +2 -0
- package/dist/cdn/LMPNXXTQ.js +2 -0
- package/dist/cdn/LYKCYBGB.js +2 -0
- package/dist/cdn/{3PKJWIC3.js → M2L5R4LA.js} +1 -1
- package/dist/cdn/{V2P4AIGG.js → M4URMXDS.js} +1 -1
- package/dist/cdn/MDAKBX7N.js +2 -0
- package/dist/cdn/MWYBF3F3.js +66 -0
- package/dist/cdn/NEV6OZN3.js +71 -0
- package/dist/cdn/NQDOAPE3.js +2 -0
- package/dist/cdn/OAKRPM7D.js +2 -0
- package/dist/cdn/{23EQTPO3.js → OKVLGJAG.js} +1 -1
- package/dist/cdn/ONMNQBPO.js +2 -0
- package/dist/cdn/ONQ6JSBJ.js +2 -0
- package/dist/cdn/OWTGH34K.js +2 -0
- package/dist/cdn/{LQ6R5YRN.js → PQ2DPOFM.js} +1 -1
- package/dist/cdn/PSYRZMX2.js +2 -0
- package/dist/cdn/PUHRBGKB.js +2 -0
- package/dist/cdn/Q57QWN5W.js +2 -0
- package/dist/cdn/QNNGPA3Q.js +2 -0
- package/dist/cdn/R74ZHFA6.js +2 -0
- package/dist/cdn/RBE55SWR.js +2 -0
- package/dist/cdn/RHYNE5OE.js +2 -0
- package/dist/cdn/RLEHNAIA.js +2 -0
- package/dist/cdn/RV55GABG.js +2 -0
- package/dist/cdn/RWWOOC7S.js +2 -0
- package/dist/cdn/{X2ZDYHCG.js → SDWWUWAF.js} +10 -5
- package/dist/cdn/T4RIGOXB.js +2 -0
- package/dist/cdn/TACBKKBI.js +2 -0
- package/dist/cdn/TMJMDCSA.js +4 -0
- package/dist/cdn/TPULIO6I.js +34 -0
- package/dist/cdn/U2D53TAX.js +14 -0
- package/dist/cdn/UEEH5ZQK.js +156 -0
- package/dist/cdn/{6YMR4QSD.js → UHEYPSOR.js} +1 -1
- package/dist/cdn/UHZG7SKO.js +2 -0
- package/dist/cdn/UZLQALHY.js +2 -0
- package/dist/cdn/V52XWEGV.js +11 -0
- package/dist/cdn/V6HOUZPZ.js +2 -0
- package/dist/cdn/VAXH6RUQ.js +134 -0
- package/dist/cdn/VLLZ2FFU.js +2 -0
- package/dist/cdn/VNJMTA6O.js +2 -0
- package/dist/cdn/VOKXKU7M.js +56 -0
- package/dist/cdn/VXFQANGJ.js +2 -0
- package/dist/cdn/W5G35GO4.js +2 -0
- package/dist/cdn/WKTQVBFJ.js +2 -0
- package/dist/cdn/WLH47YFC.js +14 -0
- package/dist/cdn/WP7ORLSB.js +6 -0
- package/dist/cdn/Y7XD7ZRD.js +2 -0
- package/dist/cdn/YEZ3AMNX.js +2 -0
- package/dist/cdn/YLVJA4ZE.js +2 -0
- package/dist/cdn/Z5W4V7RC.js +2 -0
- package/dist/cdn/ZLWWWTH4.js +2 -0
- package/dist/cdn/ZOEMBHRF.js +2 -0
- package/dist/cdn/ZQMBJ6MI.js +2 -0
- package/dist/cdn/ZRESBCJL.js +2 -0
- package/dist/cdn/{ZTBA5PM7.js → ZU2FHVNK.js} +1 -1
- package/dist/cdn/ZUNLFO6M.js +3 -0
- package/dist/cdn/agent-utils/index.js +2 -0
- package/dist/cdn/agent-utils/middlewares/humanInTheLoop.js +3 -0
- package/dist/cdn/agent-utils/middlewares/middleware.js +2 -0
- package/dist/cdn/agent-utils/middlewares/trace.js +2 -0
- package/dist/cdn/assets/assistant/t9n/messages.en.json +1 -1
- package/dist/cdn/assets/assistant-interrupt/t9n/messages.en.json +1 -1
- package/dist/cdn/assets/assistant-interrupt-preview/t9n/messages.en.json +1 -0
- package/dist/cdn/assets/assistant-message/t9n/messages.en.json +1 -0
- package/dist/cdn/assets/assistant-message-loading/t9n/messages.en.json +1 -0
- package/dist/cdn/index.js +1 -1
- package/dist/chunks/adapter.js +1294 -2112
- package/dist/chunks/arcgisKnowledgeGraph.js +127 -72
- package/dist/chunks/arcgis_knowledge_current_lc_context.js +19 -2
- package/dist/chunks/arcgis_knowledge_current_map_context.js +31 -2
- package/dist/chunks/arcgis_knowledge_cypher_query_prompt.js +102 -0
- package/dist/chunks/arcgis_knowledge_summarize_result_prompt.js +116 -27
- package/dist/chunks/baseAgentState.js +56 -0
- package/dist/chunks/converterUtils.js +66 -41
- package/dist/chunks/dataExplorationGraph.js +132 -177
- package/dist/chunks/data_explore_query_prompt.js +9 -4
- package/dist/chunks/fetchAgentContext.js +13 -0
- package/dist/chunks/fetchService.js +10 -0
- package/dist/chunks/fieldStatistics.js +79 -0
- package/dist/chunks/formatFeatureAttributes.js +132 -0
- package/dist/chunks/generateLayerDescriptions.js +259 -282
- package/dist/chunks/helpGraph.js +34 -25
- package/dist/chunks/help_prompt.js +34 -17
- package/dist/chunks/index.js +11 -0
- package/dist/chunks/intent_prompt.js +16 -0
- package/dist/chunks/layerStylingGraph.js +36 -31
- package/dist/chunks/mergeWhereClauses.js +15 -0
- package/dist/chunks/navigationGraph.js +123 -103
- package/dist/chunks/navigation_intent_prompt.js +8 -2
- package/dist/chunks/orchestrator.js +205 -175
- package/dist/chunks/slottableRequestUtils.js +3 -7
- package/dist/chunks/state.js +21 -27
- package/dist/chunks/summarize_query_response_prompt.js +9 -7
- package/dist/chunks/toolCallResponse.js +13 -10
- package/dist/chunks/types.js +59 -0
- package/dist/chunks/utils2.js +11 -11
- package/dist/components/arcgis-assistant/customElement.d.ts +56 -0
- package/dist/components/arcgis-assistant/customElement.js +387 -155
- package/dist/components/arcgis-assistant/index.js +2 -3
- package/dist/components/arcgis-assistant/types.d.ts +14 -1
- package/dist/components/arcgis-assistant-agent/customElement.d.ts +13 -1
- package/dist/components/arcgis-assistant-agent/customElement.js +608 -10
- package/dist/components/arcgis-assistant-chat/customElement.d.ts +2 -1
- package/dist/components/arcgis-assistant-chat/customElement.js +23 -18
- package/dist/components/arcgis-assistant-chat-entry/customElement.d.ts +2 -0
- package/dist/components/arcgis-assistant-chat-entry/customElement.js +25 -18
- package/dist/components/arcgis-assistant-data-exploration-agent/customElement.js +19 -3
- package/dist/components/arcgis-assistant-help-agent/customElement.js +28 -6
- package/dist/components/arcgis-assistant-interrupt/customElement.d.ts +4 -0
- package/dist/components/arcgis-assistant-interrupt/customElement.js +17 -14
- package/dist/components/arcgis-assistant-interrupt-preview/customElement.js +24 -0
- package/dist/components/arcgis-assistant-interrupt-preview/index.js +2 -0
- package/dist/components/arcgis-assistant-knowledge-agent/customElement.d.ts +7 -7
- package/dist/components/arcgis-assistant-knowledge-agent/customElement.js +39 -16
- package/dist/components/arcgis-assistant-layer-styling-agent/customElement.js +29 -6
- package/dist/components/arcgis-assistant-message/customElement.d.ts +5 -0
- package/dist/components/arcgis-assistant-message/customElement.js +29 -26
- package/dist/components/arcgis-assistant-message/index.js +2 -0
- package/dist/components/arcgis-assistant-message-block/customElement.js +18 -11
- package/dist/components/arcgis-assistant-message-block/index.js +1 -0
- package/dist/components/arcgis-assistant-message-loading/customElement.d.ts +7 -0
- package/dist/components/arcgis-assistant-message-loading/customElement.js +8 -7
- package/dist/components/arcgis-assistant-message-loading/index.js +1 -0
- package/dist/components/arcgis-assistant-message-text/customElement.d.ts +1 -0
- package/dist/components/arcgis-assistant-message-text/customElement.js +12 -12
- package/dist/components/arcgis-assistant-navigation-agent/customElement.js +17 -3
- package/dist/components/arcgis-assistant-speech-input/customElement.js +29 -46
- package/dist/components/arcgis-assistant-suggested-prompts/customElement.js +8 -8
- package/dist/components/arcgis-assistant-user-message/customElement.d.ts +2 -0
- package/dist/components/arcgis-assistant-user-message/customElement.js +15 -10
- package/dist/docs/api.json +1 -1
- package/dist/docs/docs.json +1 -1
- package/dist/docs/vscode.html-custom-data.json +1 -1
- package/dist/docs/web-types.json +1 -1
- package/dist/loader.js +9 -8
- package/dist/oauth-callback.html +1 -1
- package/dist/types/lumina.d.ts +9 -8
- package/dist/types/preact.d.ts +9 -8
- package/dist/types/react.d.ts +9 -8
- package/dist/types/stencil.d.ts +11 -10
- package/dist/utils/index.d.ts +10 -10
- package/dist/utils/index.js +56 -55
- package/package.json +32 -12
- package/dist/cdn/2AXF774U.js +0 -2
- package/dist/cdn/462JBSEV.js +0 -422
- package/dist/cdn/53ZCUPKK.js +0 -22
- package/dist/cdn/5QAHYX7Y.js +0 -5
- package/dist/cdn/5XRDJL7R.js +0 -14
- package/dist/cdn/7BCR6TUO.js +0 -2
- package/dist/cdn/7GH7VSB2.js +0 -2
- package/dist/cdn/7PLV4QH6.js +0 -2
- package/dist/cdn/AO7BQHKC.js +0 -2
- package/dist/cdn/AXDZBBNL.js +0 -45
- package/dist/cdn/DDLZOMUY.js +0 -2
- package/dist/cdn/EECZLT6C.js +0 -166
- package/dist/cdn/ETRWZ3MS.js +0 -108
- package/dist/cdn/F2AHA4GB.js +0 -54
- package/dist/cdn/FX5JFRDL.js +0 -2
- package/dist/cdn/H7422XUG.js +0 -2
- package/dist/cdn/HB5A5R2E.js +0 -2
- package/dist/cdn/I6HNBTWY.js +0 -2
- package/dist/cdn/IG6YKZH3.js +0 -3
- package/dist/cdn/KMQ3SP4I.js +0 -5
- package/dist/cdn/MH5RPXHM.js +0 -2
- package/dist/cdn/NAUXSHIE.js +0 -72
- package/dist/cdn/NVI3I46B.js +0 -2
- package/dist/cdn/OAVEHGB6.js +0 -2
- package/dist/cdn/OH64RMOR.js +0 -4
- package/dist/cdn/P26NON3Z.js +0 -16
- package/dist/cdn/P6OPJQMC.js +0 -3
- package/dist/cdn/QR54T33D.js +0 -2
- package/dist/cdn/RVOAPUBN.js +0 -2
- package/dist/cdn/S3VPZFWQ.js +0 -36
- package/dist/cdn/SXDLXCIM.js +0 -2
- package/dist/cdn/USMDJUFS.js +0 -2
- package/dist/cdn/Y333DGV6.js +0 -2
- package/dist/cdn/YIMNOUTF.js +0 -2
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import
|
|
2
|
+
import w from "@esri/arcgis-html-sanitizer";
|
|
3
3
|
import { marked as S } from "marked";
|
|
4
4
|
S.use({
|
|
5
5
|
gfm: !0,
|
|
6
6
|
breaks: !0,
|
|
7
7
|
async: !1
|
|
8
8
|
});
|
|
9
|
-
const C = new
|
|
9
|
+
const C = new w(
|
|
10
10
|
{
|
|
11
11
|
whiteList: {
|
|
12
12
|
// LLMs sometimes return lists like "- 2) Foo". `marked` parses that into a nested ordered list
|
|
@@ -17,6 +17,7 @@ const C = new g(
|
|
|
17
17
|
"calcite-table-row": ["slot", "class"],
|
|
18
18
|
"calcite-table-header": ["heading", "alignment", "description", "class"],
|
|
19
19
|
"calcite-table-cell": ["alignment", "colspan", "rowspan", "class"],
|
|
20
|
+
"calcite-link": ["href", "target", "rel", "title"],
|
|
20
21
|
// Allow markdown code blocks to render as <pre><code>…</code></pre>.
|
|
21
22
|
pre: ["class"],
|
|
22
23
|
code: ["class"]
|
|
@@ -27,44 +28,67 @@ const C = new g(
|
|
|
27
28
|
function T(e) {
|
|
28
29
|
return C.sanitize(e);
|
|
29
30
|
}
|
|
31
|
+
function k(e) {
|
|
32
|
+
if (!e || typeof DOMParser > "u")
|
|
33
|
+
return e;
|
|
34
|
+
try {
|
|
35
|
+
const t = new DOMParser().parseFromString(e, "text/html");
|
|
36
|
+
return t.querySelectorAll("a").forEach((r) => {
|
|
37
|
+
const n = t.createElement("calcite-link");
|
|
38
|
+
for (const l of ["href", "target", "rel", "title"]) {
|
|
39
|
+
const a = r.getAttribute(l);
|
|
40
|
+
a !== null && n.setAttribute(l, a);
|
|
41
|
+
}
|
|
42
|
+
n.append(...r.childNodes), r.replaceWith(n);
|
|
43
|
+
}), t.body.innerHTML;
|
|
44
|
+
} catch {
|
|
45
|
+
return e;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
30
48
|
function A(e, t) {
|
|
31
|
-
const r = e.indexOf("{", t),
|
|
32
|
-
return r === -1 ?
|
|
49
|
+
const r = e.indexOf("{", t), n = e.indexOf("[", t);
|
|
50
|
+
return r === -1 ? n : n === -1 ? r : Math.min(r, n);
|
|
33
51
|
}
|
|
34
52
|
function x(e) {
|
|
35
53
|
if (e.trimStart().startsWith("```"))
|
|
36
54
|
return null;
|
|
37
55
|
for (let r = A(e, 0); r !== -1; r = A(e, r + 1)) {
|
|
38
|
-
let
|
|
39
|
-
for (let
|
|
40
|
-
const
|
|
41
|
-
if (
|
|
56
|
+
let n = 0, l = 0;
|
|
57
|
+
for (let a = r; a < e.length; a++) {
|
|
58
|
+
const c = e[a];
|
|
59
|
+
if (c === "{" ? n++ : c === "}" ? n-- : c === "[" ? l++ : c === "]" && l--, n < 0 || l < 0)
|
|
42
60
|
break;
|
|
43
|
-
if (
|
|
44
|
-
return e.slice(r,
|
|
61
|
+
if (n === 0 && l === 0 && a > r)
|
|
62
|
+
return e.slice(r, a + 1);
|
|
45
63
|
}
|
|
46
64
|
}
|
|
47
65
|
return null;
|
|
48
66
|
}
|
|
49
|
-
function
|
|
67
|
+
function z(e) {
|
|
50
68
|
if (!e)
|
|
51
69
|
return "";
|
|
52
70
|
let t = e;
|
|
53
71
|
const r = x(e);
|
|
54
72
|
if (r)
|
|
55
73
|
try {
|
|
56
|
-
const l = JSON.parse(r),
|
|
74
|
+
const l = JSON.parse(r), c = `
|
|
57
75
|
|
|
58
76
|
\`\`\`json
|
|
59
77
|
${JSON.stringify(l, null, 2)}
|
|
60
78
|
\`\`\`
|
|
61
79
|
|
|
62
80
|
`;
|
|
63
|
-
t = e.replace(r,
|
|
81
|
+
t = e.replace(r, c);
|
|
64
82
|
} catch {
|
|
65
83
|
}
|
|
66
|
-
const
|
|
67
|
-
return
|
|
84
|
+
const n = q(t);
|
|
85
|
+
return M(n);
|
|
86
|
+
}
|
|
87
|
+
function M(e) {
|
|
88
|
+
if (!e)
|
|
89
|
+
return "";
|
|
90
|
+
const t = E(e), r = k(t);
|
|
91
|
+
return T(r);
|
|
68
92
|
}
|
|
69
93
|
function q(e) {
|
|
70
94
|
return e ? S.parse(e, { async: !1 }) : "";
|
|
@@ -74,44 +98,45 @@ function E(e) {
|
|
|
74
98
|
return e;
|
|
75
99
|
try {
|
|
76
100
|
const t = new DOMParser().parseFromString(e, "text/html");
|
|
77
|
-
return Array.from(t.querySelectorAll("table")).forEach((
|
|
78
|
-
const
|
|
79
|
-
|
|
80
|
-
const
|
|
81
|
-
if (
|
|
82
|
-
const
|
|
83
|
-
for (const
|
|
101
|
+
return Array.from(t.querySelectorAll("table")).forEach((n, l) => {
|
|
102
|
+
const a = t.createElement("calcite-table");
|
|
103
|
+
a.setAttribute("caption", `Table ${l + 1}`), a.setAttribute("striped", "true");
|
|
104
|
+
const c = n.querySelector("thead");
|
|
105
|
+
if (c) {
|
|
106
|
+
const f = Array.from(c.querySelectorAll("tr"));
|
|
107
|
+
for (const u of f) {
|
|
84
108
|
const o = t.createElement("calcite-table-row");
|
|
85
109
|
o.setAttribute("slot", "table-header");
|
|
86
|
-
const
|
|
87
|
-
for (const
|
|
88
|
-
const
|
|
89
|
-
|
|
110
|
+
const d = Array.from(u.querySelectorAll("th, td"));
|
|
111
|
+
for (const h of d) {
|
|
112
|
+
const i = (h.textContent ?? "").trim(), s = t.createElement("calcite-table-header");
|
|
113
|
+
s.setAttribute("heading", i), o.appendChild(s);
|
|
90
114
|
}
|
|
91
|
-
|
|
115
|
+
a.appendChild(o);
|
|
92
116
|
}
|
|
93
117
|
}
|
|
94
|
-
const
|
|
95
|
-
(
|
|
96
|
-
const o = t.createElement("calcite-table-row"),
|
|
97
|
-
|
|
98
|
-
const
|
|
99
|
-
for (const
|
|
100
|
-
if (
|
|
101
|
-
const
|
|
102
|
-
y.setAttribute("heading",
|
|
118
|
+
const b = n.querySelector("tbody");
|
|
119
|
+
(b ? Array.from(b.querySelectorAll("tr")) : Array.from(n.querySelectorAll("tr")).filter((f) => !c?.contains(f))).forEach((f, u) => {
|
|
120
|
+
const o = t.createElement("calcite-table-row"), d = !c && u === 0 && f.querySelectorAll("th").length > 0;
|
|
121
|
+
d && o.setAttribute("slot", "table-header");
|
|
122
|
+
const h = Array.from(f.querySelectorAll("th, td"));
|
|
123
|
+
for (const i of h) {
|
|
124
|
+
if (d && i.localName === "th") {
|
|
125
|
+
const g = (i.textContent ?? "").trim(), y = t.createElement("calcite-table-header");
|
|
126
|
+
y.setAttribute("heading", g), o.appendChild(y);
|
|
103
127
|
return;
|
|
104
128
|
}
|
|
105
|
-
const
|
|
106
|
-
p &&
|
|
129
|
+
const s = t.createElement("calcite-table-cell"), p = i.getAttribute("colspan"), m = i.getAttribute("rowspan");
|
|
130
|
+
p && s.setAttribute("colspan", p), m && s.setAttribute("rowspan", m), s.innerHTML = i.innerHTML, o.appendChild(s);
|
|
107
131
|
}
|
|
108
|
-
|
|
109
|
-
}),
|
|
132
|
+
a.appendChild(o);
|
|
133
|
+
}), n.replaceWith(a);
|
|
110
134
|
}), t.body.innerHTML;
|
|
111
135
|
} catch {
|
|
112
136
|
return e;
|
|
113
137
|
}
|
|
114
138
|
}
|
|
115
139
|
export {
|
|
116
|
-
|
|
140
|
+
M as a,
|
|
141
|
+
z as p
|
|
117
142
|
};
|
|
@@ -1,275 +1,228 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import { StateGraph as
|
|
3
|
-
import { g as
|
|
2
|
+
import { StateGraph as R, START as F, END as y } from "@langchain/langgraph/web";
|
|
3
|
+
import { g as x, j as w, t as v, k as C, r as N, D as T, l as b } from "./adapter.js";
|
|
4
4
|
import "@arcgis/core/identity/IdentityManager.js";
|
|
5
5
|
import "@arcgis/core/portal/Portal.js";
|
|
6
|
-
import
|
|
7
|
-
import
|
|
6
|
+
import "@arcgis/core/request.js";
|
|
7
|
+
import "@arcgis/toolkit/string";
|
|
8
|
+
import { h as M, e as A } from "./generateLayerDescriptions.js";
|
|
9
|
+
import { AIMessage as _ } from "@langchain/core/messages";
|
|
10
|
+
import { s } from "./index.js";
|
|
8
11
|
import "@langchain/openai";
|
|
12
|
+
import "@arcgis/core/config.js";
|
|
9
13
|
import "@arcgis/core/core/reactiveUtils.js";
|
|
10
14
|
import "@arcgis/core/layers/FeatureLayer.js";
|
|
11
|
-
import "@arcgis/core/request.js";
|
|
12
15
|
import "@langchain/core/prompts";
|
|
13
|
-
import { h as
|
|
14
|
-
import {
|
|
15
|
-
import
|
|
16
|
-
import
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
import { h as L } from "./toolCallResponse.js";
|
|
17
|
+
import { b as q } from "./formatFeatureAttributes.js";
|
|
18
|
+
import { ToolNode as k } from "@langchain/langgraph/prebuilt";
|
|
19
|
+
import { b as $ } from "./fieldStatistics.js";
|
|
20
|
+
import { f as D } from "./fetchAgentContext.js";
|
|
21
|
+
import { f as m } from "./fetchService.js";
|
|
22
|
+
const I = async (t, e) => (await s({ text: "Exiting Data Exploration agent" }, e), t), z = async (t, e) => {
|
|
23
|
+
await s({ text: "Requesting LLM for layer filter results" }, e);
|
|
24
|
+
const l = await x("data_explore_filter_prompt");
|
|
20
25
|
if (!e?.configurable)
|
|
21
26
|
throw new Error("config.configurable is required for layer filter tools");
|
|
22
|
-
const { userTimezone:
|
|
27
|
+
const { userTimezone: d, userTimezoneOffset: r } = q(), o = {
|
|
23
28
|
layerFieldInfo: t.layerFieldInfo,
|
|
24
|
-
userTimezone:
|
|
29
|
+
userTimezone: d,
|
|
25
30
|
userTimezoneOffset: r,
|
|
26
31
|
queryResponse: t.queryResponse,
|
|
27
32
|
assignedTask: t.agentExecutionContext.assignedTask,
|
|
28
33
|
userRequest: t.agentExecutionContext.userRequest,
|
|
29
34
|
priorSteps: t.agentExecutionContext.priorSteps
|
|
30
|
-
},
|
|
31
|
-
promptText:
|
|
35
|
+
}, i = await M({
|
|
36
|
+
promptText: l,
|
|
32
37
|
modelTier: "advanced",
|
|
38
|
+
config: e,
|
|
33
39
|
messages: t.dataExplorationMessages,
|
|
34
40
|
inputVariables: o,
|
|
35
|
-
tools:
|
|
36
|
-
}),
|
|
37
|
-
if (!((
|
|
38
|
-
return await
|
|
41
|
+
tools: w
|
|
42
|
+
}), n = [...t.dataExplorationMessages, i];
|
|
43
|
+
if (!((i.tool_calls?.length ?? 0) > 0))
|
|
44
|
+
return await s({ text: "LLM determined no filter changes needed" }, e), {
|
|
39
45
|
...t,
|
|
40
|
-
dataExplorationMessages:
|
|
46
|
+
dataExplorationMessages: n
|
|
41
47
|
// Don't overwrite outputMessage if query already set it
|
|
42
48
|
};
|
|
43
|
-
const
|
|
44
|
-
return await
|
|
45
|
-
},
|
|
46
|
-
await
|
|
47
|
-
const
|
|
49
|
+
const u = n, p = i.content.toString();
|
|
50
|
+
return await L(i, e), { ...t, dataExplorationMessages: u, outputMessage: p };
|
|
51
|
+
}, Q = async (t, e) => {
|
|
52
|
+
await s({ text: "Requesting LLM for layer query results" }, e);
|
|
53
|
+
const l = await x("data_explore_query_prompt");
|
|
48
54
|
if (!e?.configurable)
|
|
49
55
|
throw new Error("config.configurable is required for layer query tools");
|
|
50
|
-
const { userTimezone:
|
|
51
|
-
let
|
|
56
|
+
const { userTimezone: d, userTimezoneOffset: r } = q(), o = t.agentExecutionContext.sharedState, i = o.lastNavigatedFeatures?.value, n = o.lastResolvedLocation?.value;
|
|
57
|
+
let c = "none";
|
|
52
58
|
if (i != null)
|
|
53
59
|
try {
|
|
54
|
-
|
|
60
|
+
c = JSON.stringify(i);
|
|
61
|
+
} catch {
|
|
62
|
+
c = "none";
|
|
63
|
+
}
|
|
64
|
+
let u = "none";
|
|
65
|
+
if (n != null)
|
|
66
|
+
try {
|
|
67
|
+
u = JSON.stringify({
|
|
68
|
+
address: n.address,
|
|
69
|
+
location: n.location
|
|
70
|
+
});
|
|
55
71
|
} catch {
|
|
56
|
-
|
|
72
|
+
u = "none";
|
|
57
73
|
}
|
|
58
|
-
const
|
|
74
|
+
const p = {
|
|
59
75
|
layerFieldInfo: t.layerFieldInfo,
|
|
60
|
-
userTimezone:
|
|
76
|
+
userTimezone: d,
|
|
61
77
|
userTimezoneOffset: r,
|
|
62
78
|
assignedTask: t.agentExecutionContext.assignedTask,
|
|
63
79
|
userRequest: t.agentExecutionContext.userRequest,
|
|
64
80
|
priorSteps: t.agentExecutionContext.priorSteps,
|
|
65
|
-
lastNavigatedFeatures:
|
|
66
|
-
|
|
67
|
-
|
|
81
|
+
lastNavigatedFeatures: c,
|
|
82
|
+
lastResolvedLocation: u
|
|
83
|
+
}, g = await M({
|
|
84
|
+
promptText: l,
|
|
68
85
|
modelTier: "advanced",
|
|
86
|
+
config: e,
|
|
69
87
|
messages: t.dataExplorationMessages,
|
|
70
|
-
inputVariables:
|
|
71
|
-
tools:
|
|
72
|
-
}),
|
|
73
|
-
return await
|
|
88
|
+
inputVariables: p,
|
|
89
|
+
tools: C
|
|
90
|
+
}), f = (g.tool_calls?.length ?? 0) > 0, h = g.content.toString();
|
|
91
|
+
return await L(g, e), {
|
|
74
92
|
...t,
|
|
75
|
-
dataExplorationMessages: [...t.dataExplorationMessages,
|
|
76
|
-
|
|
93
|
+
dataExplorationMessages: [...t.dataExplorationMessages, g],
|
|
94
|
+
// Only emit output here when no tools are being called.
|
|
95
|
+
// For tool-calling flows, downstream summarizer nodes provide the final user-facing message.
|
|
96
|
+
...f ? {} : { outputMessage: h },
|
|
77
97
|
status: "success",
|
|
78
|
-
summary:
|
|
98
|
+
summary: h && !f ? v(h) : "Query planning completed."
|
|
79
99
|
};
|
|
80
|
-
},
|
|
100
|
+
}, V = async (t, e) => {
|
|
81
101
|
try {
|
|
82
|
-
await
|
|
83
|
-
const
|
|
102
|
+
await s({ text: "Requesting LLM for summary on query results" }, e);
|
|
103
|
+
const l = await x("summarize_query_response_prompt"), d = {
|
|
84
104
|
queryResponse: t.queryResponse,
|
|
85
105
|
assignedTask: t.agentExecutionContext.assignedTask,
|
|
86
106
|
userRequest: t.agentExecutionContext.userRequest,
|
|
87
107
|
priorSteps: t.agentExecutionContext.priorSteps
|
|
88
|
-
}, r = await
|
|
89
|
-
promptText:
|
|
108
|
+
}, r = await A({
|
|
109
|
+
promptText: l,
|
|
90
110
|
modelTier: "fast",
|
|
111
|
+
config: e,
|
|
91
112
|
messages: t.dataExplorationMessages,
|
|
92
|
-
inputVariables:
|
|
93
|
-
}), o = typeof r == "string" ? r : r.content,
|
|
94
|
-
await
|
|
95
|
-
const
|
|
113
|
+
inputVariables: d
|
|
114
|
+
}), o = typeof r == "string" ? r : r.content, i = new _(o);
|
|
115
|
+
await s({ text: `Received response from LLM: ${o}` }, e);
|
|
116
|
+
const n = o;
|
|
96
117
|
return {
|
|
97
118
|
...t,
|
|
98
|
-
outputMessage:
|
|
119
|
+
outputMessage: n,
|
|
99
120
|
status: "success",
|
|
100
|
-
summary:
|
|
101
|
-
dataExplorationMessages: [...t.dataExplorationMessages,
|
|
121
|
+
summary: n ? v(n) : "Summary generated.",
|
|
122
|
+
dataExplorationMessages: [...t.dataExplorationMessages, i]
|
|
102
123
|
};
|
|
103
124
|
} catch (a) {
|
|
104
|
-
throw await
|
|
125
|
+
throw await s({ text: "Error during filter LLM request" }, e), new Error(`Error during filter LLM request: ${a instanceof Error ? a.message : String(a)}`);
|
|
105
126
|
}
|
|
106
127
|
};
|
|
107
|
-
async function
|
|
108
|
-
|
|
128
|
+
async function O(t, e) {
|
|
129
|
+
if ((t.queryResponse ?? []).some((r) => {
|
|
130
|
+
const o = r.details;
|
|
131
|
+
return typeof o == "object" && o !== null && "error" in o;
|
|
132
|
+
}))
|
|
133
|
+
return await s({ text: "Skipping layer filter tool because query response contains an error." }, e), { ...t };
|
|
134
|
+
const d = await new k(w, { handleToolErrors: !1 }).invoke(
|
|
109
135
|
{
|
|
110
136
|
messages: t.dataExplorationMessages
|
|
111
137
|
},
|
|
112
138
|
e
|
|
113
139
|
);
|
|
114
|
-
return await
|
|
115
|
-
{ text: `Finished executing layer filter tool: ${d.messages.map((
|
|
140
|
+
return await s(
|
|
141
|
+
{ text: `Finished executing layer filter tool: ${d.messages.map((r) => r.content).join(", ")}` },
|
|
116
142
|
e
|
|
117
143
|
), { ...t };
|
|
118
144
|
}
|
|
119
|
-
const
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
if (e.type !== "geometry" && e.type !== "oid" && e.type !== "global-id") {
|
|
123
|
-
a && (n = await G({ layer: t, field: e.name }));
|
|
124
|
-
const o = e.domain?.type === "coded-value" ? e.domain : null;
|
|
125
|
-
d && (Y.includes(e.type) || o) && (r = (await U({ layer: t, field: e.name })).uniqueValueInfos.sort((s, i) => i.count - s.count).slice(0, X), o && (r = r.map((s) => ({
|
|
126
|
-
...s,
|
|
127
|
-
value: o.getName(s.value) ?? s.value
|
|
128
|
-
}))));
|
|
129
|
-
}
|
|
130
|
-
} catch (o) {
|
|
131
|
-
console.error(`Error fetching statistics for field ${e.name}:`, o);
|
|
132
|
-
}
|
|
133
|
-
return {
|
|
134
|
-
summaryStatistics: n,
|
|
135
|
-
uniqueValues: r
|
|
136
|
-
};
|
|
137
|
-
};
|
|
138
|
-
function ee(t, e) {
|
|
139
|
-
return ["string", "small-integer", "integer"].includes(t) || e === "coded-value";
|
|
140
|
-
}
|
|
141
|
-
async function te(t, e, a, d = !0) {
|
|
142
|
-
const n = [], r = [], o = [];
|
|
143
|
-
for (const s of t) {
|
|
144
|
-
let i = function(g) {
|
|
145
|
-
const u = e.get(g)?.layerItem;
|
|
146
|
-
return u ? [
|
|
147
|
-
u.name && `Name: ${u.name}`,
|
|
148
|
-
u.title && `Title: ${u.title}`,
|
|
149
|
-
u.description && `Description: ${u.description}`
|
|
150
|
-
].filter(Boolean).join(" | ") : g;
|
|
151
|
-
};
|
|
152
|
-
const { layerId: l, results: m } = s, p = a.map?.allLayers.find((g) => g.id === l), y = e.get(l)?.fieldRegistry;
|
|
153
|
-
if (!y)
|
|
154
|
-
continue;
|
|
155
|
-
let f = n.find((g) => g.layerId === l);
|
|
156
|
-
f || (f = {
|
|
157
|
-
layerId: l,
|
|
158
|
-
layerSummary: i(l),
|
|
159
|
-
fieldInfos: []
|
|
160
|
-
}, n.push(f));
|
|
161
|
-
for (const g of m) {
|
|
162
|
-
const u = y.get(g.name);
|
|
163
|
-
if (!u)
|
|
164
|
-
continue;
|
|
165
|
-
const x = u.statistics, E = d && !x?.summaryStatistics, w = ee(u.type, u.domain?.type) && !x?.uniqueValues, q = E || w;
|
|
166
|
-
if (o.push({
|
|
167
|
-
layerId: l,
|
|
168
|
-
fieldName: u.name,
|
|
169
|
-
didFetchStatistics: q
|
|
170
|
-
}), q) {
|
|
171
|
-
const _ = Z(p, u, {
|
|
172
|
-
includeSummaryStatistics: E,
|
|
173
|
-
includeUniqueValues: w
|
|
174
|
-
}).then((F) => {
|
|
175
|
-
const S = {
|
|
176
|
-
summaryStatistics: x?.summaryStatistics ?? null,
|
|
177
|
-
uniqueValues: x?.uniqueValues ?? null
|
|
178
|
-
};
|
|
179
|
-
E && (S.summaryStatistics = F.summaryStatistics), w && (S.uniqueValues = F.uniqueValues), y.set(u.name, { ...u, statistics: S }), u.statistics = S;
|
|
180
|
-
});
|
|
181
|
-
r.push(_);
|
|
182
|
-
}
|
|
183
|
-
f.fieldInfos.push(u);
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
return await Promise.all(r), {
|
|
187
|
-
layerFieldInfo: n,
|
|
188
|
-
didFetchStatistics: r.length > 0,
|
|
189
|
-
fieldStatisticsFetchStatus: o
|
|
190
|
-
};
|
|
191
|
-
}
|
|
192
|
-
const M = /\b(average|avg|mean|median|max(?:imum)?|min(?:imum)?|sum|total|count|std(?:dev|\s*deviation)|variance|null\s*count|missing\s*values?|range)\b/iu;
|
|
193
|
-
function ae(t, e) {
|
|
194
|
-
return M.test(t) || M.test(e);
|
|
145
|
+
const E = /\b(average|avg|mean|median|max(?:imum)?|min(?:imum)?|sum|total|count|std(?:dev|\s*deviation)|variance|null\s*count|missing\s*values?|range)\b/iu;
|
|
146
|
+
function P(t, e) {
|
|
147
|
+
return E.test(t) || E.test(e);
|
|
195
148
|
}
|
|
196
|
-
const
|
|
149
|
+
const j = async (t, e) => {
|
|
197
150
|
try {
|
|
198
|
-
await
|
|
199
|
-
const a =
|
|
151
|
+
await s({ text: "Preparing field information for vector search results" }, e);
|
|
152
|
+
const a = m(e, "layersAndFieldsRegistry"), { mapView: l } = D(e, ["mapView"]), { assignedTask: d, userRequest: r } = t.agentExecutionContext, o = P(d, r), { layerFieldInfo: i, didFetchStatistics: n, fieldStatisticsFetchStatus: c } = await $(
|
|
200
153
|
t.vectorSearchFieldResults,
|
|
201
154
|
a,
|
|
202
|
-
|
|
155
|
+
l,
|
|
203
156
|
o
|
|
204
157
|
);
|
|
205
|
-
|
|
206
|
-
for (const
|
|
207
|
-
await
|
|
158
|
+
n ? await s({ text: "Statistics fetched" }, e) : await s({ text: "Statistics skipped" }, e);
|
|
159
|
+
for (const u of c)
|
|
160
|
+
await s(
|
|
208
161
|
{
|
|
209
|
-
text: ` - ${
|
|
162
|
+
text: ` - ${u.fieldName} - stats ${u.didFetchStatistics ? "fetched" : "skipped"}`
|
|
210
163
|
},
|
|
211
164
|
e
|
|
212
165
|
);
|
|
213
|
-
return await
|
|
166
|
+
return await s({ text: "Field information prepared" }, e), { ...t, layerFieldInfo: i };
|
|
214
167
|
} catch (a) {
|
|
215
|
-
throw await
|
|
168
|
+
throw await s({ text: "Error during fetching statistics" }, e), new Error(`Error during fetching statistics: ${a instanceof Error ? a.message : String(a)}`);
|
|
216
169
|
}
|
|
217
|
-
},
|
|
170
|
+
}, S = 0.7, G = 10, W = async (t, e) => {
|
|
218
171
|
try {
|
|
219
|
-
await
|
|
220
|
-
const a =
|
|
172
|
+
await s({ text: "Similarity search to find fields" }, e);
|
|
173
|
+
const a = m(e, "fieldSearch"), l = m(e, "layersAndFieldsRegistry"), d = m(e, "embeddingCache"), r = await a.searchFields({
|
|
221
174
|
text: t.agentExecutionContext.assignedTask,
|
|
222
175
|
layerIds: t.vectorSearchLayerIds,
|
|
223
|
-
minScore:
|
|
224
|
-
topResults:
|
|
225
|
-
embeddingCache:
|
|
226
|
-
}), o = r.map(({ layerId:
|
|
227
|
-
const
|
|
176
|
+
minScore: S,
|
|
177
|
+
topResults: G,
|
|
178
|
+
embeddingCache: d
|
|
179
|
+
}), o = r.map(({ layerId: n, results: c }) => {
|
|
180
|
+
const u = c.map((p) => ` - ${p.name} (${p.score.toFixed(2)})`).join(`
|
|
228
181
|
`);
|
|
229
|
-
return `${
|
|
230
|
-
${
|
|
182
|
+
return `${l.get(n)?.layerItem.name ?? n}:
|
|
183
|
+
${u}`;
|
|
231
184
|
}).join(`
|
|
232
185
|
`);
|
|
233
|
-
let
|
|
234
|
-
return r.length > 0 ?
|
|
235
|
-
${o}` :
|
|
186
|
+
let i;
|
|
187
|
+
return r.length > 0 ? i = `Vector search completed. Matching layers and fields with scores:
|
|
188
|
+
${o}` : i = `No vector search results found for score over ${S}.`, await s({ text: i }, e), {
|
|
236
189
|
...t,
|
|
237
190
|
vectorSearchFieldResults: r
|
|
238
191
|
};
|
|
239
192
|
} catch (a) {
|
|
240
|
-
throw await
|
|
193
|
+
throw await s(
|
|
241
194
|
{ text: `Error during vector search: ${a instanceof Error ? a.message : String(a)}` },
|
|
242
195
|
e
|
|
243
196
|
), new Error(`Vector search failed: ${a instanceof Error ? a.message : String(a)}`);
|
|
244
197
|
}
|
|
245
|
-
},
|
|
198
|
+
}, H = 0.7, J = async (t, e) => {
|
|
246
199
|
try {
|
|
247
|
-
await
|
|
200
|
+
await s(
|
|
248
201
|
{ text: `Similarity search to find layers: ${t.agentExecutionContext.assignedTask}` },
|
|
249
202
|
e
|
|
250
203
|
);
|
|
251
|
-
const a =
|
|
204
|
+
const a = m(e, "layerSearch"), l = m(e, "layersAndFieldsRegistry"), d = m(e, "embeddingCache"), r = await a.searchLayers({
|
|
252
205
|
text: t.agentExecutionContext.assignedTask,
|
|
253
|
-
minScore:
|
|
254
|
-
embeddingCache:
|
|
255
|
-
}), o = r.map((
|
|
206
|
+
minScore: H,
|
|
207
|
+
embeddingCache: d
|
|
208
|
+
}), o = r.map((c) => c.id), i = r.map(({ id: c, score: u }) => `${l.get(c)?.layerItem.name ?? c} (${u.toFixed(2)})`).join(`
|
|
256
209
|
`);
|
|
257
|
-
let
|
|
258
|
-
return o.length > 0 ?
|
|
259
|
-
${
|
|
210
|
+
let n;
|
|
211
|
+
return o.length > 0 ? n = `Vector search completed. Matching layers with scores:
|
|
212
|
+
${i}` : n = "Vector search completed. No matching layers found.", await s({ text: n }, e), {
|
|
260
213
|
...t,
|
|
261
214
|
vectorSearchLayerIds: o
|
|
262
215
|
};
|
|
263
216
|
} catch (a) {
|
|
264
|
-
throw await
|
|
217
|
+
throw await s(
|
|
265
218
|
{ text: `Error during vector search: ${a instanceof Error ? a.message : String(a)}` },
|
|
266
219
|
e
|
|
267
220
|
), new Error(`Vector search failed: ${a instanceof Error ? a.message : String(a)}`);
|
|
268
221
|
}
|
|
269
|
-
},
|
|
222
|
+
}, U = (t, e) => N(["layerSearch", "fieldSearch", "layersAndFieldsRegistry"], "Data Exploration Agent")(
|
|
270
223
|
t,
|
|
271
224
|
e
|
|
272
|
-
),
|
|
225
|
+
), B = () => new R(T).addNode("requireDataExplorationServices", U).addNode("vectorSearchLayers", J).addNode("vectorSearchFields", W).addNode("fieldStatistics", j).addNode("queryAgent", Q).addNode("queryTools", b).addNode("summarizeQueryResponseLLM", V).addNode("filterAgent", z).addNode("filterTools", O).addNode("earlyExit", I).addEdge(F, "requireDataExplorationServices").addEdge("requireDataExplorationServices", "vectorSearchLayers").addConditionalEdges(
|
|
273
226
|
"vectorSearchLayers",
|
|
274
227
|
(e) => e.vectorSearchLayerIds.length ? "vectorSearchFields" : "earlyExit"
|
|
275
228
|
).addConditionalEdges(
|
|
@@ -278,7 +231,7 @@ ${s}` : i = "Vector search completed. No matching layers found.", await c({ text
|
|
|
278
231
|
).addEdge("fieldStatistics", "queryAgent").addConditionalEdges("queryAgent", (e) => (e.dataExplorationMessages[e.dataExplorationMessages.length - 1]?.tool_calls?.length ?? 0) > 0 ? "queryTools" : "filterAgent").addConditionalEdges(
|
|
279
232
|
"queryTools",
|
|
280
233
|
(e) => e.queryResponse.length ? "summarizeQueryResponseLLM" : "filterAgent"
|
|
281
|
-
).addEdge("summarizeQueryResponseLLM", "filterAgent").addConditionalEdges("filterAgent", (e) => (e.dataExplorationMessages[e.dataExplorationMessages.length - 1]?.tool_calls?.length ?? 0) > 0 ? "filterTools" :
|
|
234
|
+
).addEdge("summarizeQueryResponseLLM", "filterAgent").addConditionalEdges("filterAgent", (e) => (e.dataExplorationMessages[e.dataExplorationMessages.length - 1]?.tool_calls?.length ?? 0) > 0 ? "filterTools" : y).addEdge("filterTools", y).addEdge("earlyExit", y), K = String.raw`- **data exploration** — User is asking about the feature layer’s data (e.g. counts, summaries, statistics, field values), either for all features, a subset based on a condition, or for a subset based on the current view. And/Or user wants to include or exclude features based on field values, or visually style features differently (e.g., highlight or deemphasize them).
|
|
282
235
|
The Data Exploration Agent will automatically zoom to the affected features for action taken by this agent. In this case, no need to call navigation tool separately.
|
|
283
236
|
_Example: “Only show stations where Brand is Shell”_
|
|
284
237
|
_Example: “Make Shell stations stand out on the map”_
|
|
@@ -286,13 +239,15 @@ ${s}` : i = "Vector search completed. No matching layers found.", await c({ text
|
|
|
286
239
|
This also includes questions that ask which feature meets a given condition or where a particular feature in the data is located (e.g., “Where is the spring with the highest elevation?”). However, this agent does not handle addresses.
|
|
287
240
|
_Example: “How many features are there?”_
|
|
288
241
|
_Example: “What’s the average population?”_
|
|
289
|
-
_Example: “Which values are in the status field?”_
|
|
242
|
+
_Example: “Which values are in the status field?”_
|
|
243
|
+
|
|
244
|
+
This agent does NOT handle help/metadata requests such as listing available layers, listing field names/columns/attributes for a layer, or capability guidance.`, xe = {
|
|
290
245
|
id: "dataExploration",
|
|
291
246
|
name: "Data Exploration Agent",
|
|
292
|
-
description:
|
|
293
|
-
createGraph:
|
|
294
|
-
workspace:
|
|
247
|
+
description: K,
|
|
248
|
+
createGraph: B,
|
|
249
|
+
workspace: T
|
|
295
250
|
};
|
|
296
251
|
export {
|
|
297
|
-
|
|
252
|
+
xe as D
|
|
298
253
|
};
|
|
@@ -39,10 +39,13 @@ Prior steps:
|
|
|
39
39
|
Last navigated features from shared state (if available):
|
|
40
40
|
{lastNavigatedFeatures}
|
|
41
41
|
|
|
42
|
+
Last resolved location from shared state (if available):
|
|
43
|
+
{lastResolvedLocation}
|
|
44
|
+
|
|
42
45
|
Use the assigned task as the primary instruction for the current query.
|
|
43
46
|
Use the latest user request as supporting context when needed.
|
|
44
47
|
Use prior steps only when the assigned task or user request clearly depends on earlier results.
|
|
45
|
-
Use
|
|
48
|
+
Use shared-state context (\`lastResolvedLocation\`, \`lastNavigatedFeatures\`) for referential follow-ups when relevant.
|
|
46
49
|
Use chat history only when necessary to understand conversational references, and do not override the assigned task.
|
|
47
50
|
|
|
48
51
|
### Anchor selection rule (strict, single source of truth)
|
|
@@ -50,8 +53,9 @@ Use chat history only when necessary to understand conversational references, an
|
|
|
50
53
|
When the request is referential (for example: "this", "it", "that", "those", "them", "of those", "the same one(s)"), choose exactly one anchor using this priority order:
|
|
51
54
|
|
|
52
55
|
1. Explicit entity named in the current request (if present)
|
|
53
|
-
2. \`
|
|
54
|
-
3.
|
|
56
|
+
2. \`lastResolvedLocation\` (if present and the request refers to a place/location)
|
|
57
|
+
3. \`lastNavigatedFeatures\` (if present)
|
|
58
|
+
4. The immediately previous successful relevant step from \`priorSteps\`
|
|
55
59
|
|
|
56
60
|
After selecting the anchor, keep that anchor for this query and do not switch to an older entity.
|
|
57
61
|
If \`lastNavigatedFeatures\` is used as the anchor, reuse its \`layerId\` and \`where\` for query scope unless the current request explicitly overrides it.
|
|
@@ -78,7 +82,8 @@ Start with a fresh WHERE clause for each new question. Do not inherit filters fr
|
|
|
78
82
|
|
|
79
83
|
This is an exception to the "fresh WHERE clause" rule above.
|
|
80
84
|
|
|
81
|
-
- If the anchored context
|
|
85
|
+
- If the anchored context is \`lastResolvedLocation\` with a point, prefer \`geometryFilter.point\` and use \`where: "1=1"\` unless the user asked for additional attribute filters.
|
|
86
|
+
- Only use \`useCurrentExtent: true\` when the user explicitly asks about the current view/map extent (for example: "in my view", "on my map", "visible now").
|
|
82
87
|
- If the anchored context includes specific feature IDs/objectIds, scope to those IDs.
|
|
83
88
|
- Otherwise, use the anchored \`layerId\` + \`where\` combination.
|
|
84
89
|
|