@arcgis/ai-components 5.2.0-next.0 → 5.2.0-next.10

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 (110) hide show
  1. package/dist/agent-utils/LLMAgent.js +22 -22
  2. package/dist/cdn/{DHOVCT6R.js → 2SJAOYZT.js} +1 -1
  3. package/dist/cdn/434TAA3J.js +2 -0
  4. package/dist/cdn/{AMP6IALT.js → 5W7S2RS4.js} +1 -1
  5. package/dist/cdn/64PJB5NU.js +2 -0
  6. package/dist/cdn/{OH64RMOR.js → 6AWNQHCO.js} +2 -2
  7. package/dist/cdn/BIV2IPHH.js +2 -0
  8. package/dist/cdn/CCY4TSBO.js +2 -0
  9. package/dist/cdn/{AO7BQHKC.js → CTSALWEP.js} +1 -1
  10. package/dist/cdn/{NAUXSHIE.js → D2N2NSRQ.js} +2 -2
  11. package/dist/cdn/{3PKJWIC3.js → D3TNNRP4.js} +1 -1
  12. package/dist/cdn/{H7422XUG.js → DOV5ZJ7M.js} +1 -1
  13. package/dist/cdn/EEUCKMU7.js +2 -0
  14. package/dist/cdn/EGHBXLNG.js +2 -0
  15. package/dist/cdn/{N2VQD46V.js → ETRWZ3MS.js} +31 -29
  16. package/dist/cdn/{QDO2AO53.js → EWI4V3GQ.js} +10 -10
  17. package/dist/cdn/{6MAINSY5.js → FL4W4VYN.js} +0 -1
  18. package/dist/cdn/GTLS44GI.js +2 -0
  19. package/dist/cdn/{SZOVY2QU.js → I6HNBTWY.js} +1 -1
  20. package/dist/cdn/JBHNHHWO.js +3 -0
  21. package/dist/cdn/{FX5JFRDL.js → JOFUPKIB.js} +1 -1
  22. package/dist/cdn/KUEOKIQR.js +2 -0
  23. package/dist/cdn/LKRAPK4A.js +165 -0
  24. package/dist/cdn/{6R6AY3D3.js → MODWHY3R.js} +2 -2
  25. package/dist/cdn/NXKKG5TK.js +2 -0
  26. package/dist/cdn/{2AXF774U.js → OBUZ7HBN.js} +1 -1
  27. package/dist/cdn/OIVRK7HT.js +2 -0
  28. package/dist/cdn/{HB5A5R2E.js → RUURNLTP.js} +1 -1
  29. package/dist/cdn/SWOXSJ62.js +2 -0
  30. package/dist/cdn/{LBVX2JYG.js → T537PKP4.js} +10 -7
  31. package/dist/cdn/{Y67XAMT4.js → TSZPHE7L.js} +2 -2
  32. package/dist/cdn/VAZNJSKA.js +16 -0
  33. package/dist/cdn/{V2P4AIGG.js → VMXLYWUK.js} +1 -1
  34. package/dist/cdn/{FB5DRKEB.js → VNQN5ZQO.js} +2 -2
  35. package/dist/cdn/WIDTPVSU.js +2 -0
  36. package/dist/cdn/{GM3QP65I.js → X2ZDYHCG.js} +18 -5
  37. package/dist/cdn/{P6OPJQMC.js → XER22VYQ.js} +1 -1
  38. package/dist/cdn/index.js +1 -1
  39. package/dist/cdn/main.css +1 -1
  40. package/dist/chunks/adapter.js +527 -522
  41. package/dist/chunks/arcgisKnowledgeGraph.js +3 -3
  42. package/dist/chunks/dataExplorationGraph.js +135 -119
  43. package/dist/chunks/data_explore_query_prompt.js +18 -5
  44. package/dist/chunks/generateLayerDescriptions.js +236 -209
  45. package/dist/chunks/helpGraph.js +4 -4
  46. package/dist/chunks/intent_prompt.js +0 -1
  47. package/dist/chunks/layerStylingGraph.js +10 -10
  48. package/dist/chunks/navigationGraph.js +27 -27
  49. package/dist/chunks/orchestrator.js +240 -201
  50. package/dist/chunks/slottableRequestUtils.js +3 -7
  51. package/dist/chunks/summarize_query_response_prompt.js +10 -7
  52. package/dist/components/arcgis-assistant/customElement.d.ts +15 -0
  53. package/dist/components/arcgis-assistant/customElement.js +227 -127
  54. package/dist/components/arcgis-assistant/index.js +2 -3
  55. package/dist/components/arcgis-assistant/types.d.ts +14 -1
  56. package/dist/components/arcgis-assistant-chat/customElement.d.ts +8 -2
  57. package/dist/components/arcgis-assistant-chat/customElement.js +7 -7
  58. package/dist/components/arcgis-assistant-chat-entry/customElement.d.ts +4 -1
  59. package/dist/components/arcgis-assistant-chat-entry/customElement.js +25 -18
  60. package/dist/components/arcgis-assistant-interrupt/customElement.d.ts +4 -1
  61. package/dist/components/arcgis-assistant-interrupt/customElement.js +13 -9
  62. package/dist/components/arcgis-assistant-interrupt-preview/customElement.js +20 -0
  63. package/dist/components/arcgis-assistant-interrupt-preview/index.js +2 -0
  64. package/dist/components/arcgis-assistant-message/customElement.d.ts +23 -0
  65. package/dist/components/arcgis-assistant-message/customElement.js +28 -26
  66. package/dist/components/arcgis-assistant-message/index.d.ts +1 -0
  67. package/dist/components/arcgis-assistant-message/index.js +2 -0
  68. package/dist/components/arcgis-assistant-message-block/customElement.d.ts +1 -1
  69. package/dist/components/arcgis-assistant-message-block/customElement.js +18 -11
  70. package/dist/components/arcgis-assistant-message-block/index.js +1 -0
  71. package/dist/components/arcgis-assistant-message-feedback/customElement.d.ts +4 -1
  72. package/dist/components/arcgis-assistant-message-footer/customElement.d.ts +4 -1
  73. package/dist/components/arcgis-assistant-message-loading/customElement.d.ts +8 -1
  74. package/dist/components/arcgis-assistant-message-loading/customElement.js +8 -8
  75. package/dist/components/arcgis-assistant-message-loading/index.js +1 -0
  76. package/dist/components/arcgis-assistant-message-log/customElement.d.ts +4 -1
  77. package/dist/components/arcgis-assistant-message-read-aloud/customElement.d.ts +4 -1
  78. package/dist/components/arcgis-assistant-message-text/customElement.d.ts +4 -1
  79. package/dist/components/arcgis-assistant-speech-input/customElement.d.ts +6 -1
  80. package/dist/components/arcgis-assistant-suggested-prompts/customElement.d.ts +4 -1
  81. package/dist/components/arcgis-assistant-suggested-prompts/customElement.js +8 -8
  82. package/dist/components/arcgis-assistant-user-message/customElement.d.ts +4 -1
  83. package/dist/components/arcgis-assistant-user-message/customElement.js +1 -1
  84. package/dist/docs/api.json +1 -1
  85. package/dist/docs/docs.json +1 -1
  86. package/dist/docs/vscode.html-custom-data.json +1 -1
  87. package/dist/docs/web-types.json +1 -1
  88. package/dist/index.d.ts +4 -0
  89. package/dist/loader.js +6 -5
  90. package/dist/types/lumina.d.ts +10 -4
  91. package/dist/types/preact.d.ts +11 -4
  92. package/dist/types/react.d.ts +12 -4
  93. package/dist/types/stencil.d.ts +10 -4
  94. package/dist/utils/index.d.ts +85 -42
  95. package/dist/utils/index.js +22 -18
  96. package/package.json +7 -7
  97. package/dist/cdn/7BCR6TUO.js +0 -2
  98. package/dist/cdn/7GH7VSB2.js +0 -2
  99. package/dist/cdn/7PLV4QH6.js +0 -2
  100. package/dist/cdn/DDLZOMUY.js +0 -2
  101. package/dist/cdn/EF453FJ2.js +0 -3
  102. package/dist/cdn/METXWS7V.js +0 -166
  103. package/dist/cdn/MH5RPXHM.js +0 -2
  104. package/dist/cdn/NVI3I46B.js +0 -2
  105. package/dist/cdn/OAVEHGB6.js +0 -2
  106. package/dist/cdn/QR54T33D.js +0 -2
  107. package/dist/cdn/SXDLXCIM.js +0 -2
  108. package/dist/cdn/U3QQW6VA.js +0 -16
  109. package/dist/cdn/USMDJUFS.js +0 -2
  110. package/dist/cdn/Y333DGV6.js +0 -2
@@ -1,6 +1,6 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
2
  import { StateGraph as w, START as y, END as h } from "@langchain/langgraph/web";
3
- import { a as f, c as x, b as k, d as _, e as b, s as K, q as v, g as p, h as A, t as g, r as M, i as S, G as T, j as u } from "./adapter.js";
3
+ import { a as f, c as x, b as k, d as _, e as b, s as K, q as v, g as p, h as A, t as g, r as M, i as T, G as S, j as u } from "./adapter.js";
4
4
  import "@arcgis/core/identity/IdentityManager.js";
5
5
  import "@arcgis/core/portal/Portal.js";
6
6
  import { j as q, s as c, h as C } from "./generateLayerDescriptions.js";
@@ -47,7 +47,7 @@ async function R(e, o) {
47
47
  };
48
48
  }
49
49
  async function N(e, o) {
50
- const l = new G(m);
50
+ const l = new G(m, { handleToolErrors: !1 });
51
51
  try {
52
52
  const a = await l.invoke(
53
53
  {
@@ -106,7 +106,7 @@ async function z(e, o) {
106
106
  ...d,
107
107
  details: void 0
108
108
  // Remove details to avoid overwhelming the LLM with too much info
109
- })), { knowledgeGraph: r } = await S(o), n = T.getDataModelTypesSummary(r.dataModel), t = {
109
+ })), { knowledgeGraph: r } = await T(o), n = S.getDataModelTypesSummary(r.dataModel), t = {
110
110
  assignedTask: e.agentExecutionContext.assignedTask,
111
111
  userRequest: e.agentExecutionContext.userRequest,
112
112
  toolResult: a,
@@ -1,258 +1,274 @@
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 y, 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 as h, 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 l, j as A, h as Q } from "./generateLayerDescriptions.js";
6
+ import { s as n, j as _, h as Q } from "./generateLayerDescriptions.js";
7
7
  import { AIMessage as j } from "@langchain/core/messages";
8
8
  import "@langchain/openai";
9
9
  import "@arcgis/core/core/reactiveUtils.js";
10
10
  import "@arcgis/core/layers/FeatureLayer.js";
11
11
  import "@arcgis/core/request.js";
12
12
  import "@langchain/core/prompts";
13
- import { h as I } from "./toolCallResponse.js";
13
+ import { h as $ } from "./toolCallResponse.js";
14
14
  import { ToolNode as O } from "@langchain/langgraph/prebuilt";
15
15
  import G from "@arcgis/core/smartMapping/statistics/summaryStatistics.js";
16
16
  import U from "@arcgis/core/smartMapping/statistics/uniqueValues.js";
17
- const W = async (t, e) => (await l({ text: "Exiting Data Exploration agent" }, e), t), B = async (t, e) => {
18
- await l({ text: "Requesting LLM for layer filter results" }, e);
19
- const c = await T("data_explore_filter_prompt");
17
+ const W = async (t, e) => (await n({ text: "Exiting Data Exploration agent" }, e), t), B = async (t, e) => {
18
+ await n({ text: "Requesting LLM for layer filter results" }, e);
19
+ const d = await T("data_explore_filter_prompt");
20
20
  if (!e?.configurable)
21
21
  throw new Error("config.configurable is required for layer filter tools");
22
- const { userTimezone: n, userTimezoneOffset: r } = R(), o = {
22
+ const { userTimezone: l, userTimezoneOffset: s } = R(), o = {
23
23
  layerFieldInfo: t.layerFieldInfo,
24
- userTimezone: n,
25
- userTimezoneOffset: r,
24
+ userTimezone: l,
25
+ userTimezoneOffset: s,
26
26
  queryResponse: t.queryResponse,
27
27
  assignedTask: t.agentExecutionContext.assignedTask,
28
28
  userRequest: t.agentExecutionContext.userRequest,
29
29
  priorSteps: t.agentExecutionContext.priorSteps
30
- }, s = await A({
31
- promptText: c,
30
+ }, r = await _({
31
+ promptText: d,
32
32
  modelTier: "advanced",
33
33
  messages: t.dataExplorationMessages,
34
34
  inputVariables: o,
35
35
  tools: C
36
- }), i = [...t.dataExplorationMessages, s];
37
- if (!((s.tool_calls?.length ?? 0) > 0))
38
- return await l({ text: "LLM determined no filter changes needed" }, e), {
36
+ }), i = [...t.dataExplorationMessages, r];
37
+ if (!((r.tool_calls?.length ?? 0) > 0))
38
+ return await n({ text: "LLM determined no filter changes needed" }, e), {
39
39
  ...t,
40
40
  dataExplorationMessages: i
41
41
  // Don't overwrite outputMessage if query already set it
42
42
  };
43
- const m = [...i, s], g = s.content.toString();
44
- return await I(s, e), { ...t, dataExplorationMessages: m, outputMessage: g };
43
+ const m = i, p = r.content.toString();
44
+ return await $(r, e), { ...t, dataExplorationMessages: m, outputMessage: p };
45
45
  }, H = async (t, e) => {
46
- await l({ text: "Requesting LLM for layer query results" }, e);
47
- const c = await T("data_explore_query_prompt");
46
+ await n({ text: "Requesting LLM for layer query results" }, e);
47
+ const d = await T("data_explore_query_prompt");
48
48
  if (!e?.configurable)
49
49
  throw new Error("config.configurable is required for layer query tools");
50
- const { userTimezone: n, userTimezoneOffset: r } = R(), o = {
50
+ const { userTimezone: l, userTimezoneOffset: s } = R(), r = t.agentExecutionContext.sharedState.lastNavigatedFeatures, i = r && typeof r == "object" && "value" in r ? r.value : r;
51
+ let c = "none";
52
+ if (i != null)
53
+ try {
54
+ c = JSON.stringify(i);
55
+ } catch {
56
+ c = "none";
57
+ }
58
+ const m = {
51
59
  layerFieldInfo: t.layerFieldInfo,
52
- userTimezone: n,
53
- userTimezoneOffset: r,
60
+ userTimezone: l,
61
+ userTimezoneOffset: s,
54
62
  assignedTask: t.agentExecutionContext.assignedTask,
55
63
  userRequest: t.agentExecutionContext.userRequest,
56
- priorSteps: t.agentExecutionContext.priorSteps
57
- }, s = await A({
58
- promptText: c,
64
+ priorSteps: t.agentExecutionContext.priorSteps,
65
+ lastNavigatedFeatures: c
66
+ }, p = await _({
67
+ promptText: d,
59
68
  modelTier: "advanced",
60
69
  messages: t.dataExplorationMessages,
61
- inputVariables: o,
62
- tools: k
63
- }), i = s.content.toString();
64
- return await I(s, e), {
70
+ inputVariables: m,
71
+ tools: V
72
+ }), f = (p.tool_calls?.length ?? 0) > 0, g = p.content.toString();
73
+ return await $(p, e), {
65
74
  ...t,
66
- dataExplorationMessages: [...t.dataExplorationMessages, s],
67
- outputMessage: i,
75
+ dataExplorationMessages: [...t.dataExplorationMessages, p],
76
+ // Only emit output here when no tools are being called.
77
+ // For tool-calling flows, downstream summarizer nodes provide the final user-facing message.
78
+ ...f ? {} : { outputMessage: g },
68
79
  status: "success",
69
- summary: i ? N(i) : "Query executed."
80
+ summary: g && !f ? N(g) : "Query planning completed."
70
81
  };
71
- }, K = async (t, e) => {
82
+ }, J = async (t, e) => {
72
83
  try {
73
- await l({ text: "Requesting LLM for summary on query results" }, e);
74
- const c = await T("summarize_query_response_prompt"), n = {
84
+ await n({ text: "Requesting LLM for summary on query results" }, e);
85
+ const d = await T("summarize_query_response_prompt"), l = {
75
86
  queryResponse: t.queryResponse,
76
87
  assignedTask: t.agentExecutionContext.assignedTask,
77
88
  userRequest: t.agentExecutionContext.userRequest,
78
89
  priorSteps: t.agentExecutionContext.priorSteps
79
- }, r = await Q({
80
- promptText: c,
90
+ }, s = await Q({
91
+ promptText: d,
81
92
  modelTier: "fast",
82
93
  messages: t.dataExplorationMessages,
83
- inputVariables: n
84
- }), o = typeof r == "string" ? r : r.content, s = new j(o);
85
- await l({ text: `Received response from LLM: ${o}` }, e);
94
+ inputVariables: l
95
+ }), o = typeof s == "string" ? s : s.content, r = new j(o);
96
+ await n({ text: `Received response from LLM: ${o}` }, e);
86
97
  const i = o;
87
98
  return {
88
99
  ...t,
89
100
  outputMessage: i,
90
101
  status: "success",
91
102
  summary: i ? N(i) : "Summary generated.",
92
- dataExplorationMessages: [...t.dataExplorationMessages, s]
103
+ dataExplorationMessages: [...t.dataExplorationMessages, r]
93
104
  };
94
105
  } catch (a) {
95
- throw await l({ text: "Error during filter LLM request" }, e), new Error(`Error during filter LLM request: ${a instanceof Error ? a.message : String(a)}`);
106
+ throw await n({ text: "Error during filter LLM request" }, e), new Error(`Error during filter LLM request: ${a instanceof Error ? a.message : String(a)}`);
96
107
  }
97
108
  };
98
- async function J(t, e) {
99
- const c = await new O(C).invoke(
109
+ async function K(t, e) {
110
+ if ((t.queryResponse ?? []).some((s) => {
111
+ const o = s.details;
112
+ return typeof o == "object" && o !== null && "error" in o;
113
+ }))
114
+ return await n({ text: "Skipping layer filter tool because query response contains an error." }, e), { ...t };
115
+ const l = await new O(C, { handleToolErrors: !1 }).invoke(
100
116
  {
101
117
  messages: t.dataExplorationMessages
102
118
  },
103
119
  e
104
120
  );
105
- return await l(
106
- { text: `Finished executing layer filter tool: ${c.messages.map((n) => n.content).join(", ")}` },
121
+ return await n(
122
+ { text: `Finished executing layer filter tool: ${l.messages.map((s) => s.content).join(", ")}` },
107
123
  e
108
124
  ), { ...t };
109
125
  }
110
- const X = 10, Y = ["string", "small-integer", "integer"], Z = async (t, e, { includeSummaryStatistics: a = !0, includeUniqueValues: c = !0 } = {}) => {
111
- let n = null, r = null;
126
+ const X = 10, Y = ["string", "small-integer", "integer"], Z = async (t, e, { includeSummaryStatistics: a = !0, includeUniqueValues: d = !0 } = {}) => {
127
+ let l = null, s = null;
112
128
  try {
113
129
  if (e.type !== "geometry" && e.type !== "oid" && e.type !== "global-id") {
114
- a && (n = await G({ layer: t, field: e.name }));
130
+ a && (l = await G({ layer: t, field: e.name }));
115
131
  const o = e.domain?.type === "coded-value" ? e.domain : null;
116
- c && (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) => ({
117
- ...s,
118
- value: o.getName(s.value) ?? s.value
132
+ d && (Y.includes(e.type) || o) && (s = (await U({ layer: t, field: e.name })).uniqueValueInfos.sort((r, i) => i.count - r.count).slice(0, X), o && (s = s.map((r) => ({
133
+ ...r,
134
+ value: o.getName(r.value) ?? r.value
119
135
  }))));
120
136
  }
121
137
  } catch (o) {
122
138
  console.error(`Error fetching statistics for field ${e.name}:`, o);
123
139
  }
124
140
  return {
125
- summaryStatistics: n,
126
- uniqueValues: r
141
+ summaryStatistics: l,
142
+ uniqueValues: s
127
143
  };
128
144
  };
129
145
  function ee(t, e) {
130
146
  return ["string", "small-integer", "integer"].includes(t) || e === "coded-value";
131
147
  }
132
- async function te(t, e, a, c = !0) {
133
- const n = [], r = [], o = [];
134
- for (const s of t) {
135
- let i = function(p) {
136
- const d = e.get(p)?.layerItem;
137
- return d ? [
138
- d.name && `Name: ${d.name}`,
139
- d.title && `Title: ${d.title}`,
140
- d.description && `Description: ${d.description}`
141
- ].filter(Boolean).join(" | ") : p;
148
+ async function te(t, e, a, d = !0) {
149
+ const l = [], s = [], o = [];
150
+ for (const r of t) {
151
+ let i = function(y) {
152
+ const u = e.get(y)?.layerItem;
153
+ return u ? [
154
+ u.name && `Name: ${u.name}`,
155
+ u.title && `Title: ${u.title}`,
156
+ u.description && `Description: ${u.description}`
157
+ ].filter(Boolean).join(" | ") : y;
142
158
  };
143
- const { layerId: u, results: m } = s, g = a.map?.allLayers.find((p) => p.id === u), S = e.get(u)?.fieldRegistry;
144
- if (!S)
159
+ const { layerId: c, results: m } = r, p = a.map?.allLayers.find((y) => y.id === c), f = e.get(c)?.fieldRegistry;
160
+ if (!f)
145
161
  continue;
146
- let h = n.find((p) => p.layerId === u);
147
- h || (h = {
148
- layerId: u,
149
- layerSummary: i(u),
162
+ let g = l.find((y) => y.layerId === c);
163
+ g || (g = {
164
+ layerId: c,
165
+ layerSummary: i(c),
150
166
  fieldInfos: []
151
- }, n.push(h));
152
- for (const p of m) {
153
- const d = S.get(p.name);
154
- if (!d)
167
+ }, l.push(g));
168
+ for (const y of m) {
169
+ const u = f.get(y.name);
170
+ if (!u)
155
171
  continue;
156
- const f = d.statistics, E = c && !f?.summaryStatistics, w = ee(d.type, d.domain?.type) && !f?.uniqueValues, q = E || w;
172
+ const x = u.statistics, E = d && !x?.summaryStatistics, w = ee(u.type, u.domain?.type) && !x?.uniqueValues, q = E || w;
157
173
  if (o.push({
158
- layerId: u,
159
- fieldName: d.name,
174
+ layerId: c,
175
+ fieldName: u.name,
160
176
  didFetchStatistics: q
161
177
  }), q) {
162
- const _ = Z(g, d, {
178
+ const A = Z(p, u, {
163
179
  includeSummaryStatistics: E,
164
180
  includeUniqueValues: w
165
- }).then((M) => {
166
- const x = {
167
- summaryStatistics: f?.summaryStatistics ?? null,
168
- uniqueValues: f?.uniqueValues ?? null
181
+ }).then((F) => {
182
+ const S = {
183
+ summaryStatistics: x?.summaryStatistics ?? null,
184
+ uniqueValues: x?.uniqueValues ?? null
169
185
  };
170
- E && (x.summaryStatistics = M.summaryStatistics), w && (x.uniqueValues = M.uniqueValues), S.set(d.name, { ...d, statistics: x }), d.statistics = x;
186
+ E && (S.summaryStatistics = F.summaryStatistics), w && (S.uniqueValues = F.uniqueValues), f.set(u.name, { ...u, statistics: S }), u.statistics = S;
171
187
  });
172
- r.push(_);
188
+ s.push(A);
173
189
  }
174
- h.fieldInfos.push(d);
190
+ g.fieldInfos.push(u);
175
191
  }
176
192
  }
177
- return await Promise.all(r), {
178
- layerFieldInfo: n,
179
- didFetchStatistics: r.length > 0,
193
+ return await Promise.all(s), {
194
+ layerFieldInfo: l,
195
+ didFetchStatistics: s.length > 0,
180
196
  fieldStatisticsFetchStatus: o
181
197
  };
182
198
  }
183
- const F = /\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;
199
+ 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;
184
200
  function ae(t, e) {
185
- return F.test(t) || F.test(e);
201
+ return M.test(t) || M.test(e);
186
202
  }
187
203
  const se = async (t, e) => {
188
204
  try {
189
- await l({ text: "Preparing field information for vector search results" }, e);
190
- const a = y(e, "layersAndFieldsRegistry"), { mapView: c } = D(e), { assignedTask: n, userRequest: r } = t.agentExecutionContext, o = ae(n, r), { layerFieldInfo: s, didFetchStatistics: i, fieldStatisticsFetchStatus: u } = await te(
205
+ await n({ text: "Preparing field information for vector search results" }, e);
206
+ const a = h(e, "layersAndFieldsRegistry"), { mapView: d } = D(e), { assignedTask: l, userRequest: s } = t.agentExecutionContext, o = ae(l, s), { layerFieldInfo: r, didFetchStatistics: i, fieldStatisticsFetchStatus: c } = await te(
191
207
  t.vectorSearchFieldResults,
192
208
  a,
193
- c,
209
+ d,
194
210
  o
195
211
  );
196
- i ? await l({ text: "Statistics fetched" }, e) : await l({ text: "Statistics skipped" }, e);
197
- for (const m of u)
198
- await l(
212
+ i ? await n({ text: "Statistics fetched" }, e) : await n({ text: "Statistics skipped" }, e);
213
+ for (const m of c)
214
+ await n(
199
215
  {
200
216
  text: ` - ${m.fieldName} - stats ${m.didFetchStatistics ? "fetched" : "skipped"}`
201
217
  },
202
218
  e
203
219
  );
204
- return await l({ text: "Field information prepared" }, e), { ...t, layerFieldInfo: s };
220
+ return await n({ text: "Field information prepared" }, e), { ...t, layerFieldInfo: r };
205
221
  } catch (a) {
206
- throw await l({ text: "Error during fetching statistics" }, e), new Error(`Error during fetching statistics: ${a instanceof Error ? a.message : String(a)}`);
222
+ throw await n({ text: "Error during fetching statistics" }, e), new Error(`Error during fetching statistics: ${a instanceof Error ? a.message : String(a)}`);
207
223
  }
208
224
  }, L = 0.7, re = 10, oe = async (t, e) => {
209
225
  try {
210
- await l({ text: "Similarity search to find fields" }, e);
211
- const a = y(e, "fieldSearch"), c = y(e, "layersAndFieldsRegistry"), n = y(e, "embeddingCache"), r = await a.searchFields({
226
+ await n({ text: "Similarity search to find fields" }, e);
227
+ const a = h(e, "fieldSearch"), d = h(e, "layersAndFieldsRegistry"), l = h(e, "embeddingCache"), s = await a.searchFields({
212
228
  text: t.agentExecutionContext.assignedTask,
213
229
  layerIds: t.vectorSearchLayerIds,
214
230
  minScore: L,
215
231
  topResults: re,
216
- embeddingCache: n
217
- }), o = r.map(({ layerId: i, results: u }) => {
218
- const m = u.map((g) => ` - ${g.name} (${g.score.toFixed(2)})`).join(`
232
+ embeddingCache: l
233
+ }), o = s.map(({ layerId: i, results: c }) => {
234
+ const m = c.map((p) => ` - ${p.name} (${p.score.toFixed(2)})`).join(`
219
235
  `);
220
- return `${c.get(i)?.layerItem.name ?? i}:
236
+ return `${d.get(i)?.layerItem.name ?? i}:
221
237
  ${m}`;
222
238
  }).join(`
223
239
  `);
224
- let s;
225
- return r.length > 0 ? s = `Vector search completed. Matching layers and fields with scores:
226
- ${o}` : s = `No vector search results found for score over ${L}.`, await l({ text: s }, e), {
240
+ let r;
241
+ return s.length > 0 ? r = `Vector search completed. Matching layers and fields with scores:
242
+ ${o}` : r = `No vector search results found for score over ${L}.`, await n({ text: r }, e), {
227
243
  ...t,
228
- vectorSearchFieldResults: r
244
+ vectorSearchFieldResults: s
229
245
  };
230
246
  } catch (a) {
231
- throw await l(
247
+ throw await n(
232
248
  { text: `Error during vector search: ${a instanceof Error ? a.message : String(a)}` },
233
249
  e
234
250
  ), new Error(`Vector search failed: ${a instanceof Error ? a.message : String(a)}`);
235
251
  }
236
252
  }, ie = 0.7, ne = async (t, e) => {
237
253
  try {
238
- await l(
254
+ await n(
239
255
  { text: `Similarity search to find layers: ${t.agentExecutionContext.assignedTask}` },
240
256
  e
241
257
  );
242
- const a = y(e, "layerSearch"), c = y(e, "layersAndFieldsRegistry"), n = y(e, "embeddingCache"), r = await a.searchLayers({
258
+ const a = h(e, "layerSearch"), d = h(e, "layersAndFieldsRegistry"), l = h(e, "embeddingCache"), s = await a.searchLayers({
243
259
  text: t.agentExecutionContext.assignedTask,
244
260
  minScore: ie,
245
- embeddingCache: n
246
- }), o = r.map((u) => u.id), s = r.map(({ id: u, score: m }) => `${c.get(u)?.layerItem.name ?? u} (${m.toFixed(2)})`).join(`
261
+ embeddingCache: l
262
+ }), o = s.map((c) => c.id), r = s.map(({ id: c, score: m }) => `${d.get(c)?.layerItem.name ?? c} (${m.toFixed(2)})`).join(`
247
263
  `);
248
264
  let i;
249
265
  return o.length > 0 ? i = `Vector search completed. Matching layers with scores:
250
- ${s}` : i = "Vector search completed. No matching layers found.", await l({ text: i }, e), {
266
+ ${r}` : i = "Vector search completed. No matching layers found.", await n({ text: i }, e), {
251
267
  ...t,
252
268
  vectorSearchLayerIds: o
253
269
  };
254
270
  } catch (a) {
255
- throw await l(
271
+ throw await n(
256
272
  { text: `Error during vector search: ${a instanceof Error ? a.message : String(a)}` },
257
273
  e
258
274
  ), new Error(`Vector search failed: ${a instanceof Error ? a.message : String(a)}`);
@@ -260,7 +276,7 @@ ${s}` : i = "Vector search completed. No matching layers found.", await l({ text
260
276
  }, le = (t, e) => z(["layerSearch", "fieldSearch", "layersAndFieldsRegistry"], "Data Exploration Agent")(
261
277
  t,
262
278
  e
263
- ), ce = () => new b($).addNode("requireDataExplorationServices", le).addNode("vectorSearchLayers", ne).addNode("vectorSearchFields", oe).addNode("fieldStatistics", se).addNode("queryAgent", H).addNode("queryTools", P).addNode("summarizeQueryResponseLLM", K).addNode("filterAgent", B).addNode("filterTools", J).addNode("earlyExit", W).addEdge(V, "requireDataExplorationServices").addEdge("requireDataExplorationServices", "vectorSearchLayers").addConditionalEdges(
279
+ ), 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(
264
280
  "vectorSearchLayers",
265
281
  (e) => e.vectorSearchLayerIds.length ? "vectorSearchFields" : "earlyExit"
266
282
  ).addConditionalEdges(
@@ -277,13 +293,13 @@ ${s}` : i = "Vector search completed. No matching layers found.", await l({ text
277
293
  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.
278
294
  _Example: “How many features are there?”_
279
295
  _Example: “What’s the average population?”_
280
- _Example: “Which values are in the status field?”_`, Fe = {
296
+ _Example: “Which values are in the status field?”_`, Me = {
281
297
  id: "dataExploration",
282
298
  name: "Data Exploration Agent",
283
299
  description: de,
284
300
  createGraph: ce,
285
- workspace: $
301
+ workspace: b
286
302
  };
287
303
  export {
288
- Fe as D
304
+ Me as D
289
305
  };
@@ -36,11 +36,26 @@ Latest user request:
36
36
  Prior steps:
37
37
  {priorSteps}
38
38
 
39
+ Last navigated features from shared state (if available):
40
+ {lastNavigatedFeatures}
41
+
39
42
  Use the assigned task as the primary instruction for the current query.
40
43
  Use the latest user request as supporting context when needed.
41
44
  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.
42
46
  Use chat history only when necessary to understand conversational references, and do not override the assigned task.
43
47
 
48
+ ### Anchor selection rule (strict, single source of truth)
49
+
50
+ 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
+
52
+ 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\`
55
+
56
+ After selecting the anchor, keep that anchor for this query and do not switch to an older entity.
57
+ If \`lastNavigatedFeatures\` is used as the anchor, reuse its \`layerId\` and \`where\` for query scope unless the current request explicitly overrides it.
58
+
44
59
  ### Fresh WHERE clause rule
45
60
 
46
61
  Start with a fresh WHERE clause for each new question. Do not inherit filters from previous questions UNLESS the assigned task explicitly references previous results (see "Referencing Previously Identified Features" below).
@@ -63,11 +78,9 @@ Start with a fresh WHERE clause for each new question. Do not inherit filters fr
63
78
 
64
79
  This is an exception to the "fresh WHERE clause" rule above.
65
80
 
66
- When the assigned task uses words like "these", "those", "them", "the same ones" referring to features from a previous turn:
67
-
68
- - If the previous query used useCurrentExtent: true → use useCurrentExtent: true with where: "1=1"
69
- - If the previous assistant response mentions specific objectIds or feature IDs → use {{objectIdField}} IN (id1, id2, ...) to scope to those features
70
- - If neither is available, use the same WHERE clause and layer from the previous query turn to re-select the same features
81
+ - If the anchored context indicates \`useCurrentExtent: true\`, use \`useCurrentExtent: true\` with \`where: "1=1"\`.
82
+ - If the anchored context includes specific feature IDs/objectIds, scope to those IDs.
83
+ - Otherwise, use the anchored \`layerId\` + \`where\` combination.
71
84
 
72
85
  ### Mixed Questions
73
86