@arcgis/ai-components 5.2.0-next.3 → 5.2.0-next.30

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.
Files changed (207) hide show
  1. package/dist/agent-utils/FunctionAgent.d.ts +2 -2
  2. package/dist/agent-utils/LLMAgent.d.ts +2 -2
  3. package/dist/agent-utils/LLMAgent.js +23 -22
  4. package/dist/agent-utils/WorkflowAgent.d.ts +2 -2
  5. package/dist/agent-utils/index.d.ts +177 -0
  6. package/dist/agent-utils/index.js +167 -0
  7. package/dist/agent-utils/middlewares/trace.d.ts +2 -0
  8. package/dist/agent-utils/middlewares/trace.js +25 -33
  9. package/dist/agent-utils/tools/FunctionTool.d.ts +2 -2
  10. package/dist/agent-utils/types.d.ts +36 -7
  11. package/dist/agent-utils/workflows/ConditionalWorkflow.d.ts +2 -2
  12. package/dist/agent-utils/workflows/LoopWorkflow.d.ts +2 -2
  13. package/dist/agent-utils/workflows/ParallelWorkflow.d.ts +2 -2
  14. package/dist/agent-utils/workflows/RouterWorkflow.d.ts +2 -2
  15. package/dist/agent-utils/workflows/SequentialWorkflow.d.ts +2 -2
  16. package/dist/agent-utils/workflows/SwitchWorkflow.d.ts +2 -2
  17. package/dist/cdn/27NEUQN3.js +2 -0
  18. package/dist/cdn/2NMR43NW.js +2 -0
  19. package/dist/cdn/3AXQTBIA.js +134 -0
  20. package/dist/cdn/434TAA3J.js +2 -0
  21. package/dist/cdn/4I4MCV7V.js +71 -0
  22. package/dist/cdn/4RZPOYZ7.js +9 -0
  23. package/dist/cdn/5SBLS4NW.js +2 -0
  24. package/dist/cdn/{AMP6IALT.js → 5W7S2RS4.js} +1 -1
  25. package/dist/cdn/6LZ6GOHF.js +56 -0
  26. package/dist/cdn/7IFCBXV7.js +2 -0
  27. package/dist/cdn/ADYIXCSG.js +2 -0
  28. package/dist/cdn/AFLQZIKS.js +180 -0
  29. package/dist/cdn/AMVOJNWN.js +2 -0
  30. package/dist/cdn/C7E7MJSR.js +2 -0
  31. package/dist/cdn/CAECQD75.js +2 -0
  32. package/dist/cdn/CIW3QMKV.js +2 -0
  33. package/dist/cdn/CJIV4KJZ.js +179 -0
  34. package/dist/cdn/CVHJMR5X.js +2 -0
  35. package/dist/cdn/DEAYZ3MK.js +2 -0
  36. package/dist/cdn/{H7422XUG.js → E2HENO3T.js} +1 -1
  37. package/dist/cdn/E7TMP4YV.js +3 -0
  38. package/dist/cdn/EBRNMPPO.js +48 -0
  39. package/dist/cdn/FWU6DFIB.js +2 -0
  40. package/dist/cdn/HBYZSLEZ.js +22 -0
  41. package/dist/cdn/HOCTVCHH.js +2 -0
  42. package/dist/cdn/{4HU7735A.js → HXOSLGWU.js} +6 -4
  43. package/dist/cdn/I64KIZG3.js +2 -0
  44. package/dist/cdn/IB4WTK74.js +2 -0
  45. package/dist/cdn/IC5P5NYY.js +2 -0
  46. package/dist/cdn/IGZWQJW7.js +3 -0
  47. package/dist/cdn/IKEF7ZHH.js +181 -0
  48. package/dist/cdn/IXAKT6L3.js +2 -0
  49. package/dist/cdn/JEIMRNYM.js +2 -0
  50. package/dist/cdn/JN744CAW.js +2 -0
  51. package/dist/cdn/KRE4U7V7.js +2 -0
  52. package/dist/cdn/{NE7E52YR.js → KTK4HNL2.js} +8 -2
  53. package/dist/cdn/L77BTGXY.js +2 -0
  54. package/dist/cdn/LEPJUN3X.js +22 -0
  55. package/dist/cdn/LODKJRS4.js +2 -0
  56. package/dist/cdn/M3SWPT3M.js +2 -0
  57. package/dist/cdn/MAV3DW27.js +4 -0
  58. package/dist/cdn/NOJYPREL.js +3 -0
  59. package/dist/cdn/NXKKG5TK.js +2 -0
  60. package/dist/cdn/O3F47IO5.js +2 -0
  61. package/dist/cdn/O7TGCM5P.js +6 -0
  62. package/dist/cdn/PBTINZTK.js +65 -0
  63. package/dist/cdn/PKHQW7QU.js +18 -0
  64. package/dist/cdn/PSWI3MFB.js +2 -0
  65. package/dist/cdn/Q73PK7Q7.js +2 -0
  66. package/dist/cdn/Q7TL5Q5N.js +2 -0
  67. package/dist/cdn/QSA4T3BU.js +2 -0
  68. package/dist/cdn/RMLXVQZ5.js +2 -0
  69. package/dist/cdn/RX45PCYB.js +9 -0
  70. package/dist/cdn/S27EJSLC.js +14 -0
  71. package/dist/cdn/SMADRJ67.js +2 -0
  72. package/dist/cdn/{ZLXN7NMF.js → T537PKP4.js} +9 -7
  73. package/dist/cdn/{X2ZDYHCG.js → TNMXWUXU.js} +9 -4
  74. package/dist/cdn/TSEQVE2H.js +36 -0
  75. package/dist/cdn/VKU4WAQV.js +2 -0
  76. package/dist/cdn/W2IHPJ54.js +34 -0
  77. package/dist/cdn/W2JAKE2M.js +2 -0
  78. package/dist/cdn/WAVKMZA6.js +2 -0
  79. package/dist/cdn/WDE3HN7K.js +2 -0
  80. package/dist/cdn/WH6QQK6N.js +2 -0
  81. package/dist/cdn/WNS5ZUF5.js +2 -0
  82. package/dist/cdn/{FL4W4VYN.js → X7GE26KU.js} +16 -0
  83. package/dist/cdn/XVQJBUMY.js +2 -0
  84. package/dist/cdn/YJ3QQXF6.js +2 -0
  85. package/dist/cdn/YRBANNQ5.js +2 -0
  86. package/dist/cdn/YYY7HKYX.js +2 -0
  87. package/dist/cdn/ZEYIBYSF.js +66 -0
  88. package/dist/cdn/ZMSJQB65.js +99 -0
  89. package/dist/cdn/ZOSUDIJH.js +2 -0
  90. package/dist/cdn/ZPLFFLPF.js +2 -0
  91. package/dist/cdn/agent-utils/index.js +2 -0
  92. package/dist/cdn/agent-utils/middlewares/humanInTheLoop.js +3 -0
  93. package/dist/cdn/agent-utils/middlewares/middleware.js +2 -0
  94. package/dist/cdn/agent-utils/middlewares/trace.js +2 -0
  95. package/dist/cdn/index.js +1 -1
  96. package/dist/cdn/main.css +1 -1
  97. package/dist/chunks/adapter.js +1794 -1597
  98. package/dist/chunks/arcgisKnowledgeGraph.js +126 -71
  99. package/dist/chunks/arcgis_knowledge_current_lc_context.js +19 -2
  100. package/dist/chunks/arcgis_knowledge_current_map_context.js +31 -2
  101. package/dist/chunks/arcgis_knowledge_cypher_query_prompt.js +102 -0
  102. package/dist/chunks/arcgis_knowledge_summarize_result_prompt.js +116 -27
  103. package/dist/chunks/converterUtils.js +39 -32
  104. package/dist/chunks/dataExplorationGraph.js +139 -113
  105. package/dist/chunks/data_explore_query_prompt.js +9 -4
  106. package/dist/chunks/generateLayerDescriptions.js +231 -191
  107. package/dist/chunks/helpGraph.js +17 -13
  108. package/dist/chunks/help_prompt.js +34 -17
  109. package/dist/chunks/index.js +11 -0
  110. package/dist/chunks/intent_prompt.js +16 -0
  111. package/dist/chunks/layerStylingGraph.js +24 -20
  112. package/dist/chunks/navigationGraph.js +33 -28
  113. package/dist/chunks/navigation_intent_prompt.js +8 -2
  114. package/dist/chunks/orchestrator.js +267 -226
  115. package/dist/chunks/slottableRequestUtils.js +3 -7
  116. package/dist/chunks/state.js +1 -1
  117. package/dist/chunks/summarize_query_response_prompt.js +9 -7
  118. package/dist/chunks/toolCallResponse.js +12 -9
  119. package/dist/chunks/utils2.js +8 -8
  120. package/dist/components/arcgis-assistant/customElement.d.ts +27 -0
  121. package/dist/components/arcgis-assistant/customElement.js +385 -152
  122. package/dist/components/arcgis-assistant/index.js +2 -3
  123. package/dist/components/arcgis-assistant/types.d.ts +14 -1
  124. package/dist/components/arcgis-assistant-agent/customElement.js +5 -1
  125. package/dist/components/arcgis-assistant-chat/customElement.d.ts +8 -2
  126. package/dist/components/arcgis-assistant-chat/customElement.js +23 -18
  127. package/dist/components/arcgis-assistant-chat-entry/customElement.d.ts +4 -1
  128. package/dist/components/arcgis-assistant-chat-entry/customElement.js +25 -18
  129. package/dist/components/arcgis-assistant-data-exploration-agent/customElement.js +11 -5
  130. package/dist/components/arcgis-assistant-help-agent/customElement.js +8 -2
  131. package/dist/components/arcgis-assistant-interrupt/customElement.d.ts +4 -1
  132. package/dist/components/arcgis-assistant-interrupt/customElement.js +12 -8
  133. package/dist/components/arcgis-assistant-interrupt-preview/customElement.js +20 -0
  134. package/dist/components/arcgis-assistant-interrupt-preview/index.js +2 -0
  135. package/dist/components/arcgis-assistant-knowledge-agent/customElement.d.ts +7 -7
  136. package/dist/components/arcgis-assistant-knowledge-agent/customElement.js +17 -11
  137. package/dist/components/arcgis-assistant-layer-styling-agent/customElement.js +10 -4
  138. package/dist/components/arcgis-assistant-message/customElement.d.ts +23 -0
  139. package/dist/components/arcgis-assistant-message/customElement.js +28 -26
  140. package/dist/components/arcgis-assistant-message/index.d.ts +1 -0
  141. package/dist/components/arcgis-assistant-message/index.js +2 -0
  142. package/dist/components/arcgis-assistant-message-block/customElement.d.ts +1 -1
  143. package/dist/components/arcgis-assistant-message-block/customElement.js +18 -11
  144. package/dist/components/arcgis-assistant-message-block/index.js +1 -0
  145. package/dist/components/arcgis-assistant-message-feedback/customElement.d.ts +4 -1
  146. package/dist/components/arcgis-assistant-message-footer/customElement.d.ts +4 -1
  147. package/dist/components/arcgis-assistant-message-loading/customElement.d.ts +8 -1
  148. package/dist/components/arcgis-assistant-message-loading/customElement.js +8 -8
  149. package/dist/components/arcgis-assistant-message-loading/index.js +1 -0
  150. package/dist/components/arcgis-assistant-message-log/customElement.d.ts +4 -1
  151. package/dist/components/arcgis-assistant-message-read-aloud/customElement.d.ts +4 -1
  152. package/dist/components/arcgis-assistant-message-text/customElement.d.ts +5 -1
  153. package/dist/components/arcgis-assistant-message-text/customElement.js +12 -12
  154. package/dist/components/arcgis-assistant-navigation-agent/customElement.js +11 -5
  155. package/dist/components/arcgis-assistant-speech-input/customElement.d.ts +6 -1
  156. package/dist/components/arcgis-assistant-suggested-prompts/customElement.d.ts +4 -1
  157. package/dist/components/arcgis-assistant-suggested-prompts/customElement.js +8 -8
  158. package/dist/components/arcgis-assistant-user-message/customElement.d.ts +4 -1
  159. package/dist/components/arcgis-assistant-user-message/customElement.js +10 -8
  160. package/dist/docs/api.json +1 -1
  161. package/dist/docs/docs.json +1 -1
  162. package/dist/docs/vscode.html-custom-data.json +1 -1
  163. package/dist/docs/web-types.json +1 -1
  164. package/dist/index.d.ts +4 -0
  165. package/dist/loader.js +7 -6
  166. package/dist/types/lumina.d.ts +11 -5
  167. package/dist/types/preact.d.ts +12 -5
  168. package/dist/types/react.d.ts +13 -5
  169. package/dist/types/stencil.d.ts +11 -5
  170. package/dist/utils/index.d.ts +85 -42
  171. package/dist/utils/index.js +54 -49
  172. package/package.json +8 -7
  173. package/dist/cdn/2AXF774U.js +0 -2
  174. package/dist/cdn/3PKJWIC3.js +0 -2
  175. package/dist/cdn/462JBSEV.js +0 -422
  176. package/dist/cdn/5QAHYX7Y.js +0 -5
  177. package/dist/cdn/7BCR6TUO.js +0 -2
  178. package/dist/cdn/7GH7VSB2.js +0 -2
  179. package/dist/cdn/7PLV4QH6.js +0 -2
  180. package/dist/cdn/AO7BQHKC.js +0 -2
  181. package/dist/cdn/AXDZBBNL.js +0 -45
  182. package/dist/cdn/DDLZOMUY.js +0 -2
  183. package/dist/cdn/DHOVCT6R.js +0 -2
  184. package/dist/cdn/F2AHA4GB.js +0 -54
  185. package/dist/cdn/FHVXO2WG.js +0 -166
  186. package/dist/cdn/FX5JFRDL.js +0 -2
  187. package/dist/cdn/GSEPHN3A.js +0 -106
  188. package/dist/cdn/HB5A5R2E.js +0 -2
  189. package/dist/cdn/JY6LLOUJ.js +0 -22
  190. package/dist/cdn/KMQ3SP4I.js +0 -5
  191. package/dist/cdn/MDVYQQUG.js +0 -14
  192. package/dist/cdn/MH5RPXHM.js +0 -2
  193. package/dist/cdn/NAUXSHIE.js +0 -72
  194. package/dist/cdn/NVI3I46B.js +0 -2
  195. package/dist/cdn/OAVEHGB6.js +0 -2
  196. package/dist/cdn/OH64RMOR.js +0 -4
  197. package/dist/cdn/ON2V5XI2.js +0 -3
  198. package/dist/cdn/P6OPJQMC.js +0 -3
  199. package/dist/cdn/QR54T33D.js +0 -2
  200. package/dist/cdn/RVOAPUBN.js +0 -2
  201. package/dist/cdn/S6W6HV4T.js +0 -36
  202. package/dist/cdn/SXDLXCIM.js +0 -2
  203. package/dist/cdn/USMDJUFS.js +0 -2
  204. package/dist/cdn/V2P4AIGG.js +0 -2
  205. package/dist/cdn/V5YEZSRY.js +0 -16
  206. package/dist/cdn/Y333DGV6.js +0 -2
  207. package/dist/cdn/YY2SBO3V.js +0 -2
@@ -36,68 +36,74 @@ function x(e) {
36
36
  return null;
37
37
  for (let r = A(e, 0); r !== -1; r = A(e, r + 1)) {
38
38
  let a = 0, c = 0;
39
- for (let l = r; l < e.length; l++) {
40
- const n = e[l];
41
- if (n === "{" ? a++ : n === "}" ? a-- : n === "[" ? c++ : n === "]" && c--, a < 0 || c < 0)
39
+ for (let n = r; n < e.length; n++) {
40
+ const l = e[n];
41
+ if (l === "{" ? a++ : l === "}" ? a-- : l === "[" ? c++ : l === "]" && c--, a < 0 || c < 0)
42
42
  break;
43
- if (a === 0 && c === 0 && l > r)
44
- return e.slice(r, l + 1);
43
+ if (a === 0 && c === 0 && n > r)
44
+ return e.slice(r, n + 1);
45
45
  }
46
46
  }
47
47
  return null;
48
48
  }
49
- function H(e) {
49
+ function O(e) {
50
50
  if (!e)
51
51
  return "";
52
52
  let t = e;
53
53
  const r = x(e);
54
54
  if (r)
55
55
  try {
56
- const l = JSON.parse(r), f = `
56
+ const c = JSON.parse(r), l = `
57
57
 
58
58
  \`\`\`json
59
- ${JSON.stringify(l, null, 2)}
59
+ ${JSON.stringify(c, null, 2)}
60
60
  \`\`\`
61
61
 
62
62
  `;
63
- t = e.replace(r, f);
63
+ t = e.replace(r, l);
64
64
  } catch {
65
65
  }
66
- const a = q(t), c = E(a);
67
- return T(c);
66
+ const a = E(t);
67
+ return q(a);
68
68
  }
69
69
  function q(e) {
70
- return e ? S.parse(e, { async: !1 }) : "";
70
+ if (!e)
71
+ return "";
72
+ const t = M(e);
73
+ return T(t);
71
74
  }
72
75
  function E(e) {
76
+ return e ? S.parse(e, { async: !1 }) : "";
77
+ }
78
+ function M(e) {
73
79
  if (!e || typeof DOMParser > "u")
74
80
  return e;
75
81
  try {
76
82
  const t = new DOMParser().parseFromString(e, "text/html");
77
83
  return Array.from(t.querySelectorAll("table")).forEach((a, c) => {
78
- const l = t.createElement("calcite-table");
79
- l.setAttribute("caption", `Table ${c + 1}`), l.setAttribute("striped", "true");
80
- const n = a.querySelector("thead");
81
- if (n) {
82
- const d = Array.from(n.querySelectorAll("tr"));
83
- for (const h of d) {
84
+ const n = t.createElement("calcite-table");
85
+ n.setAttribute("caption", `Table ${c + 1}`), n.setAttribute("striped", "true");
86
+ const l = a.querySelector("thead");
87
+ if (l) {
88
+ const d = Array.from(l.querySelectorAll("tr"));
89
+ for (const u of d) {
84
90
  const o = t.createElement("calcite-table-row");
85
91
  o.setAttribute("slot", "table-header");
86
- const u = Array.from(h.querySelectorAll("th, td"));
87
- for (const b of u) {
88
- const s = (b.textContent ?? "").trim(), i = t.createElement("calcite-table-header");
92
+ const f = Array.from(u.querySelectorAll("th, td"));
93
+ for (const h of f) {
94
+ const s = (h.textContent ?? "").trim(), i = t.createElement("calcite-table-header");
89
95
  i.setAttribute("heading", s), o.appendChild(i);
90
96
  }
91
- l.appendChild(o);
97
+ n.appendChild(o);
92
98
  }
93
99
  }
94
- const f = a.querySelector("tbody");
95
- (f ? Array.from(f.querySelectorAll("tr")) : Array.from(a.querySelectorAll("tr")).filter((d) => !n?.contains(d))).forEach((d, h) => {
96
- const o = t.createElement("calcite-table-row"), u = !n && h === 0 && d.querySelectorAll("th").length > 0;
97
- u && o.setAttribute("slot", "table-header");
98
- const b = Array.from(d.querySelectorAll("th, td"));
99
- for (const s of b) {
100
- if (u && s.localName === "th") {
100
+ const b = a.querySelector("tbody");
101
+ (b ? Array.from(b.querySelectorAll("tr")) : Array.from(a.querySelectorAll("tr")).filter((d) => !l?.contains(d))).forEach((d, u) => {
102
+ const o = t.createElement("calcite-table-row"), f = !l && u === 0 && d.querySelectorAll("th").length > 0;
103
+ f && o.setAttribute("slot", "table-header");
104
+ const h = Array.from(d.querySelectorAll("th, td"));
105
+ for (const s of h) {
106
+ if (f && s.localName === "th") {
101
107
  const w = (s.textContent ?? "").trim(), y = t.createElement("calcite-table-header");
102
108
  y.setAttribute("heading", w), o.appendChild(y);
103
109
  return;
@@ -105,13 +111,14 @@ function E(e) {
105
111
  const i = t.createElement("calcite-table-cell"), p = s.getAttribute("colspan"), m = s.getAttribute("rowspan");
106
112
  p && i.setAttribute("colspan", p), m && i.setAttribute("rowspan", m), i.innerHTML = s.innerHTML, o.appendChild(i);
107
113
  }
108
- l.appendChild(o);
109
- }), a.replaceWith(l);
114
+ n.appendChild(o);
115
+ }), a.replaceWith(n);
110
116
  }), t.body.innerHTML;
111
117
  } catch {
112
118
  return e;
113
119
  }
114
120
  }
115
121
  export {
116
- H as p
122
+ q as a,
123
+ O as p
117
124
  };
@@ -1,174 +1,198 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import { StateGraph as b, START as V, END as v } from "@langchain/langgraph/web";
3
- import { g as T, O as R, P as C, t as N, Q as k, f as h, R as D, r as z, S as $, T as P } from "./adapter.js";
2
+ import { StateGraph as I, START as k, END as v } from "@langchain/langgraph/web";
3
+ import { g as T, O as R, P as C, t as N, Q as V, f, R as D, r as z, S as b, T as P } from "./adapter.js";
4
4
  import "@arcgis/core/identity/IdentityManager.js";
5
5
  import "@arcgis/core/portal/Portal.js";
6
- import { s as c, j as A, h as Q } from "./generateLayerDescriptions.js";
7
- import { AIMessage as j } from "@langchain/core/messages";
6
+ import "@arcgis/toolkit/string";
7
+ import { h as _, e as Q } from "./generateLayerDescriptions.js";
8
+ import { AIMessage as O } from "@langchain/core/messages";
9
+ import { s as n } from "./index.js";
8
10
  import "@langchain/openai";
11
+ import "@arcgis/core/config.js";
9
12
  import "@arcgis/core/core/reactiveUtils.js";
10
13
  import "@arcgis/core/layers/FeatureLayer.js";
11
14
  import "@arcgis/core/request.js";
12
15
  import "@langchain/core/prompts";
13
- import { h as I } from "./toolCallResponse.js";
14
- import { ToolNode as O } from "@langchain/langgraph/prebuilt";
16
+ import { h as $ } from "./toolCallResponse.js";
17
+ import { ToolNode as j } from "@langchain/langgraph/prebuilt";
15
18
  import G from "@arcgis/core/smartMapping/statistics/summaryStatistics.js";
16
19
  import U from "@arcgis/core/smartMapping/statistics/uniqueValues.js";
17
- const W = async (t, e) => (await c({ text: "Exiting Data Exploration agent" }, e), t), B = async (t, e) => {
18
- await c({ text: "Requesting LLM for layer filter results" }, e);
20
+ const W = async (t, e) => (await n({ text: "Exiting Data Exploration agent" }, e), t), B = async (t, e) => {
21
+ await n({ text: "Requesting LLM for layer filter results" }, e);
19
22
  const d = await T("data_explore_filter_prompt");
20
23
  if (!e?.configurable)
21
24
  throw new Error("config.configurable is required for layer filter tools");
22
- const { userTimezone: n, userTimezoneOffset: r } = R(), o = {
25
+ const { userTimezone: l, userTimezoneOffset: s } = R(), r = {
23
26
  layerFieldInfo: t.layerFieldInfo,
24
- userTimezone: n,
25
- userTimezoneOffset: r,
27
+ userTimezone: l,
28
+ userTimezoneOffset: s,
26
29
  queryResponse: t.queryResponse,
27
30
  assignedTask: t.agentExecutionContext.assignedTask,
28
31
  userRequest: t.agentExecutionContext.userRequest,
29
32
  priorSteps: t.agentExecutionContext.priorSteps
30
- }, s = await A({
33
+ }, o = await _({
31
34
  promptText: d,
32
35
  modelTier: "advanced",
36
+ config: e,
33
37
  messages: t.dataExplorationMessages,
34
- inputVariables: o,
38
+ inputVariables: r,
35
39
  tools: C
36
- }), i = [...t.dataExplorationMessages, s];
37
- if (!((s.tool_calls?.length ?? 0) > 0))
38
- return await c({ text: "LLM determined no filter changes needed" }, e), {
40
+ }), i = [...t.dataExplorationMessages, o];
41
+ if (!((o.tool_calls?.length ?? 0) > 0))
42
+ return await n({ text: "LLM determined no filter changes needed" }, e), {
39
43
  ...t,
40
44
  dataExplorationMessages: i
41
45
  // Don't overwrite outputMessage if query already set it
42
46
  };
43
- const m = [...i, s], p = s.content.toString();
44
- return await I(s, e), { ...t, dataExplorationMessages: m, outputMessage: p };
47
+ const m = i, g = o.content.toString();
48
+ return await $(o, e), { ...t, dataExplorationMessages: m, outputMessage: g };
45
49
  }, H = async (t, e) => {
46
- await c({ text: "Requesting LLM for layer query results" }, e);
50
+ await n({ text: "Requesting LLM for layer query results" }, e);
47
51
  const d = await T("data_explore_query_prompt");
48
52
  if (!e?.configurable)
49
53
  throw new Error("config.configurable is required for layer query tools");
50
- const { userTimezone: n, userTimezoneOffset: r } = R(), s = t.agentExecutionContext.sharedState.lastNavigatedFeatures, i = s && typeof s == "object" && "value" in s ? s.value : s;
51
- let l = "none";
54
+ const { userTimezone: l, userTimezoneOffset: s } = R(), r = t.agentExecutionContext.sharedState, o = r.lastNavigatedFeatures?.value, i = r.lastResolvedLocation?.value;
55
+ let c = "none";
56
+ if (o != null)
57
+ try {
58
+ c = JSON.stringify(o);
59
+ } catch {
60
+ c = "none";
61
+ }
62
+ let m = "none";
52
63
  if (i != null)
53
64
  try {
54
- l = JSON.stringify(i);
65
+ m = JSON.stringify({
66
+ address: i.address,
67
+ location: i.location
68
+ });
55
69
  } catch {
56
- l = "none";
70
+ m = "none";
57
71
  }
58
- const m = {
72
+ const g = {
59
73
  layerFieldInfo: t.layerFieldInfo,
60
- userTimezone: n,
61
- userTimezoneOffset: r,
74
+ userTimezone: l,
75
+ userTimezoneOffset: s,
62
76
  assignedTask: t.agentExecutionContext.assignedTask,
63
77
  userRequest: t.agentExecutionContext.userRequest,
64
78
  priorSteps: t.agentExecutionContext.priorSteps,
65
- lastNavigatedFeatures: l
66
- }, p = await A({
79
+ lastNavigatedFeatures: c,
80
+ lastResolvedLocation: m
81
+ }, y = await _({
67
82
  promptText: d,
68
83
  modelTier: "advanced",
84
+ config: e,
69
85
  messages: t.dataExplorationMessages,
70
- inputVariables: m,
71
- tools: k
72
- }), y = p.content.toString();
73
- return await I(p, e), {
86
+ inputVariables: g,
87
+ tools: V
88
+ }), h = (y.tool_calls?.length ?? 0) > 0, p = y.content.toString();
89
+ return await $(y, e), {
74
90
  ...t,
75
- dataExplorationMessages: [...t.dataExplorationMessages, p],
76
- outputMessage: y,
91
+ dataExplorationMessages: [...t.dataExplorationMessages, y],
92
+ // Only emit output here when no tools are being called.
93
+ // For tool-calling flows, downstream summarizer nodes provide the final user-facing message.
94
+ ...h ? {} : { outputMessage: p },
77
95
  status: "success",
78
- summary: y ? N(y) : "Query executed."
96
+ summary: p && !h ? N(p) : "Query planning completed."
79
97
  };
80
98
  }, J = async (t, e) => {
81
99
  try {
82
- await c({ text: "Requesting LLM for summary on query results" }, e);
83
- const d = await T("summarize_query_response_prompt"), n = {
100
+ await n({ text: "Requesting LLM for summary on query results" }, e);
101
+ const d = await T("summarize_query_response_prompt"), l = {
84
102
  queryResponse: t.queryResponse,
85
103
  assignedTask: t.agentExecutionContext.assignedTask,
86
104
  userRequest: t.agentExecutionContext.userRequest,
87
105
  priorSteps: t.agentExecutionContext.priorSteps
88
- }, r = await Q({
106
+ }, s = await Q({
89
107
  promptText: d,
90
108
  modelTier: "fast",
109
+ config: e,
91
110
  messages: t.dataExplorationMessages,
92
- inputVariables: n
93
- }), o = typeof r == "string" ? r : r.content, s = new j(o);
94
- await c({ text: `Received response from LLM: ${o}` }, e);
95
- const i = o;
111
+ inputVariables: l
112
+ }), r = typeof s == "string" ? s : s.content, o = new O(r);
113
+ await n({ text: `Received response from LLM: ${r}` }, e);
114
+ const i = r;
96
115
  return {
97
116
  ...t,
98
117
  outputMessage: i,
99
118
  status: "success",
100
119
  summary: i ? N(i) : "Summary generated.",
101
- dataExplorationMessages: [...t.dataExplorationMessages, s]
120
+ dataExplorationMessages: [...t.dataExplorationMessages, o]
102
121
  };
103
122
  } catch (a) {
104
- throw await c({ text: "Error during filter LLM request" }, e), new Error(`Error during filter LLM request: ${a instanceof Error ? a.message : String(a)}`);
123
+ throw await n({ text: "Error during filter LLM request" }, e), new Error(`Error during filter LLM request: ${a instanceof Error ? a.message : String(a)}`);
105
124
  }
106
125
  };
107
126
  async function K(t, e) {
108
- const d = await new O(C).invoke(
127
+ if ((t.queryResponse ?? []).some((s) => {
128
+ const r = s.details;
129
+ return typeof r == "object" && r !== null && "error" in r;
130
+ }))
131
+ return await n({ text: "Skipping layer filter tool because query response contains an error." }, e), { ...t };
132
+ const l = await new j(C, { handleToolErrors: !1 }).invoke(
109
133
  {
110
134
  messages: t.dataExplorationMessages
111
135
  },
112
136
  e
113
137
  );
114
- return await c(
115
- { text: `Finished executing layer filter tool: ${d.messages.map((n) => n.content).join(", ")}` },
138
+ return await n(
139
+ { text: `Finished executing layer filter tool: ${l.messages.map((s) => s.content).join(", ")}` },
116
140
  e
117
141
  ), { ...t };
118
142
  }
119
143
  const X = 10, Y = ["string", "small-integer", "integer"], Z = async (t, e, { includeSummaryStatistics: a = !0, includeUniqueValues: d = !0 } = {}) => {
120
- let n = null, r = null;
144
+ let l = null, s = null;
121
145
  try {
122
146
  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
147
+ a && (l = await G({ layer: t, field: e.name }));
148
+ const r = e.domain?.type === "coded-value" ? e.domain : null;
149
+ d && (Y.includes(e.type) || r) && (s = (await U({ layer: t, field: e.name })).uniqueValueInfos.sort((o, i) => i.count - o.count).slice(0, X), r && (s = s.map((o) => ({
150
+ ...o,
151
+ value: r.getName(o.value) ?? o.value
128
152
  }))));
129
153
  }
130
- } catch (o) {
131
- console.error(`Error fetching statistics for field ${e.name}:`, o);
154
+ } catch (r) {
155
+ console.error(`Error fetching statistics for field ${e.name}:`, r);
132
156
  }
133
157
  return {
134
- summaryStatistics: n,
135
- uniqueValues: r
158
+ summaryStatistics: l,
159
+ uniqueValues: s
136
160
  };
137
161
  };
138
162
  function ee(t, e) {
139
163
  return ["string", "small-integer", "integer"].includes(t) || e === "coded-value";
140
164
  }
141
165
  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;
166
+ const l = [], s = [], r = [];
167
+ for (const o of t) {
168
+ let i = function(p) {
169
+ const u = e.get(p)?.layerItem;
146
170
  return u ? [
147
171
  u.name && `Name: ${u.name}`,
148
172
  u.title && `Title: ${u.title}`,
149
173
  u.description && `Description: ${u.description}`
150
- ].filter(Boolean).join(" | ") : g;
174
+ ].filter(Boolean).join(" | ") : p;
151
175
  };
152
- const { layerId: l, results: m } = s, p = a.map?.allLayers.find((g) => g.id === l), y = e.get(l)?.fieldRegistry;
176
+ const { layerId: c, results: m } = o, g = a.map?.allLayers.find((p) => p.id === c), y = e.get(c)?.fieldRegistry;
153
177
  if (!y)
154
178
  continue;
155
- let f = n.find((g) => g.layerId === l);
156
- f || (f = {
157
- layerId: l,
158
- layerSummary: i(l),
179
+ let h = l.find((p) => p.layerId === c);
180
+ h || (h = {
181
+ layerId: c,
182
+ layerSummary: i(c),
159
183
  fieldInfos: []
160
- }, n.push(f));
161
- for (const g of m) {
162
- const u = y.get(g.name);
184
+ }, l.push(h));
185
+ for (const p of m) {
186
+ const u = y.get(p.name);
163
187
  if (!u)
164
188
  continue;
165
189
  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,
190
+ if (r.push({
191
+ layerId: c,
168
192
  fieldName: u.name,
169
193
  didFetchStatistics: q
170
194
  }), q) {
171
- const _ = Z(p, u, {
195
+ const A = Z(g, u, {
172
196
  includeSummaryStatistics: E,
173
197
  includeUniqueValues: w
174
198
  }).then((F) => {
@@ -178,90 +202,90 @@ async function te(t, e, a, d = !0) {
178
202
  };
179
203
  E && (S.summaryStatistics = F.summaryStatistics), w && (S.uniqueValues = F.uniqueValues), y.set(u.name, { ...u, statistics: S }), u.statistics = S;
180
204
  });
181
- r.push(_);
205
+ s.push(A);
182
206
  }
183
- f.fieldInfos.push(u);
207
+ h.fieldInfos.push(u);
184
208
  }
185
209
  }
186
- return await Promise.all(r), {
187
- layerFieldInfo: n,
188
- didFetchStatistics: r.length > 0,
189
- fieldStatisticsFetchStatus: o
210
+ return await Promise.all(s), {
211
+ layerFieldInfo: l,
212
+ didFetchStatistics: s.length > 0,
213
+ fieldStatisticsFetchStatus: r
190
214
  };
191
215
  }
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;
216
+ const L = /\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
217
  function ae(t, e) {
194
- return M.test(t) || M.test(e);
218
+ return L.test(t) || L.test(e);
195
219
  }
196
220
  const se = async (t, e) => {
197
221
  try {
198
- await c({ text: "Preparing field information for vector search results" }, e);
199
- const a = h(e, "layersAndFieldsRegistry"), { mapView: d } = D(e), { assignedTask: n, userRequest: r } = t.agentExecutionContext, o = ae(n, r), { layerFieldInfo: s, didFetchStatistics: i, fieldStatisticsFetchStatus: l } = await te(
222
+ await n({ text: "Preparing field information for vector search results" }, e);
223
+ const a = f(e, "layersAndFieldsRegistry"), { mapView: d } = D(e), { assignedTask: l, userRequest: s } = t.agentExecutionContext, r = ae(l, s), { layerFieldInfo: o, didFetchStatistics: i, fieldStatisticsFetchStatus: c } = await te(
200
224
  t.vectorSearchFieldResults,
201
225
  a,
202
226
  d,
203
- o
227
+ r
204
228
  );
205
- i ? await c({ text: "Statistics fetched" }, e) : await c({ text: "Statistics skipped" }, e);
206
- for (const m of l)
207
- await c(
229
+ i ? await n({ text: "Statistics fetched" }, e) : await n({ text: "Statistics skipped" }, e);
230
+ for (const m of c)
231
+ await n(
208
232
  {
209
233
  text: ` - ${m.fieldName} - stats ${m.didFetchStatistics ? "fetched" : "skipped"}`
210
234
  },
211
235
  e
212
236
  );
213
- return await c({ text: "Field information prepared" }, e), { ...t, layerFieldInfo: s };
237
+ return await n({ text: "Field information prepared" }, e), { ...t, layerFieldInfo: o };
214
238
  } catch (a) {
215
- throw await c({ text: "Error during fetching statistics" }, e), new Error(`Error during fetching statistics: ${a instanceof Error ? a.message : String(a)}`);
239
+ throw await n({ text: "Error during fetching statistics" }, e), new Error(`Error during fetching statistics: ${a instanceof Error ? a.message : String(a)}`);
216
240
  }
217
- }, L = 0.7, re = 10, oe = async (t, e) => {
241
+ }, M = 0.7, re = 10, oe = async (t, e) => {
218
242
  try {
219
- await c({ text: "Similarity search to find fields" }, e);
220
- const a = h(e, "fieldSearch"), d = h(e, "layersAndFieldsRegistry"), n = h(e, "embeddingCache"), r = await a.searchFields({
243
+ await n({ text: "Similarity search to find fields" }, e);
244
+ const a = f(e, "fieldSearch"), d = f(e, "layersAndFieldsRegistry"), l = f(e, "embeddingCache"), s = await a.searchFields({
221
245
  text: t.agentExecutionContext.assignedTask,
222
246
  layerIds: t.vectorSearchLayerIds,
223
- minScore: L,
247
+ minScore: M,
224
248
  topResults: re,
225
- embeddingCache: n
226
- }), o = r.map(({ layerId: i, results: l }) => {
227
- const m = l.map((p) => ` - ${p.name} (${p.score.toFixed(2)})`).join(`
249
+ embeddingCache: l
250
+ }), r = s.map(({ layerId: i, results: c }) => {
251
+ const m = c.map((g) => ` - ${g.name} (${g.score.toFixed(2)})`).join(`
228
252
  `);
229
253
  return `${d.get(i)?.layerItem.name ?? i}:
230
254
  ${m}`;
231
255
  }).join(`
232
256
  `);
233
- let s;
234
- return r.length > 0 ? s = `Vector search completed. Matching layers and fields with scores:
235
- ${o}` : s = `No vector search results found for score over ${L}.`, await c({ text: s }, e), {
257
+ let o;
258
+ return s.length > 0 ? o = `Vector search completed. Matching layers and fields with scores:
259
+ ${r}` : o = `No vector search results found for score over ${M}.`, await n({ text: o }, e), {
236
260
  ...t,
237
- vectorSearchFieldResults: r
261
+ vectorSearchFieldResults: s
238
262
  };
239
263
  } catch (a) {
240
- throw await c(
264
+ throw await n(
241
265
  { text: `Error during vector search: ${a instanceof Error ? a.message : String(a)}` },
242
266
  e
243
267
  ), new Error(`Vector search failed: ${a instanceof Error ? a.message : String(a)}`);
244
268
  }
245
269
  }, ie = 0.7, ne = async (t, e) => {
246
270
  try {
247
- await c(
271
+ await n(
248
272
  { text: `Similarity search to find layers: ${t.agentExecutionContext.assignedTask}` },
249
273
  e
250
274
  );
251
- const a = h(e, "layerSearch"), d = h(e, "layersAndFieldsRegistry"), n = h(e, "embeddingCache"), r = await a.searchLayers({
275
+ const a = f(e, "layerSearch"), d = f(e, "layersAndFieldsRegistry"), l = f(e, "embeddingCache"), s = await a.searchLayers({
252
276
  text: t.agentExecutionContext.assignedTask,
253
277
  minScore: ie,
254
- embeddingCache: n
255
- }), o = r.map((l) => l.id), s = r.map(({ id: l, score: m }) => `${d.get(l)?.layerItem.name ?? l} (${m.toFixed(2)})`).join(`
278
+ embeddingCache: l
279
+ }), r = s.map((c) => c.id), o = s.map(({ id: c, score: m }) => `${d.get(c)?.layerItem.name ?? c} (${m.toFixed(2)})`).join(`
256
280
  `);
257
281
  let i;
258
- return o.length > 0 ? i = `Vector search completed. Matching layers with scores:
259
- ${s}` : i = "Vector search completed. No matching layers found.", await c({ text: i }, e), {
282
+ return r.length > 0 ? i = `Vector search completed. Matching layers with scores:
283
+ ${o}` : i = "Vector search completed. No matching layers found.", await n({ text: i }, e), {
260
284
  ...t,
261
- vectorSearchLayerIds: o
285
+ vectorSearchLayerIds: r
262
286
  };
263
287
  } catch (a) {
264
- throw await c(
288
+ throw await n(
265
289
  { text: `Error during vector search: ${a instanceof Error ? a.message : String(a)}` },
266
290
  e
267
291
  ), new Error(`Vector search failed: ${a instanceof Error ? a.message : String(a)}`);
@@ -269,7 +293,7 @@ ${s}` : i = "Vector search completed. No matching layers found.", await c({ text
269
293
  }, le = (t, e) => z(["layerSearch", "fieldSearch", "layersAndFieldsRegistry"], "Data Exploration Agent")(
270
294
  t,
271
295
  e
272
- ), ce = () => new b($).addNode("requireDataExplorationServices", le).addNode("vectorSearchLayers", ne).addNode("vectorSearchFields", oe).addNode("fieldStatistics", se).addNode("queryAgent", H).addNode("queryTools", P).addNode("summarizeQueryResponseLLM", J).addNode("filterAgent", B).addNode("filterTools", K).addNode("earlyExit", W).addEdge(V, "requireDataExplorationServices").addEdge("requireDataExplorationServices", "vectorSearchLayers").addConditionalEdges(
296
+ ), ce = () => new I(b).addNode("requireDataExplorationServices", le).addNode("vectorSearchLayers", ne).addNode("vectorSearchFields", oe).addNode("fieldStatistics", se).addNode("queryAgent", H).addNode("queryTools", P).addNode("summarizeQueryResponseLLM", J).addNode("filterAgent", B).addNode("filterTools", K).addNode("earlyExit", W).addEdge(k, "requireDataExplorationServices").addEdge("requireDataExplorationServices", "vectorSearchLayers").addConditionalEdges(
273
297
  "vectorSearchLayers",
274
298
  (e) => e.vectorSearchLayerIds.length ? "vectorSearchFields" : "earlyExit"
275
299
  ).addConditionalEdges(
@@ -286,13 +310,15 @@ ${s}` : i = "Vector search completed. No matching layers found.", await c({ text
286
310
  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
311
  _Example: “How many features are there?”_
288
312
  _Example: “What’s the average population?”_
289
- _Example: “Which values are in the status field?”_`, Me = {
313
+ _Example: “Which values are in the status field?”_
314
+
315
+ This agent does NOT handle help/metadata requests such as listing available layers, listing field names/columns/attributes for a layer, or capability guidance.`, Ce = {
290
316
  id: "dataExploration",
291
317
  name: "Data Exploration Agent",
292
318
  description: de,
293
319
  createGraph: ce,
294
- workspace: $
320
+ workspace: b
295
321
  };
296
322
  export {
297
- Me as D
323
+ Ce as D
298
324
  };
@@ -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 lastNavigatedFeatures as authoritative context for map-navigation references when present.
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. \`lastNavigatedFeatures\` (if present)
54
- 3. The immediately previous successful relevant step from \`priorSteps\`
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 indicates \`useCurrentExtent: true\`, use \`useCurrentExtent: true\` with \`where: "1=1"\`.
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