@arcgis/ai-components 5.2.0-next.77 → 5.2.0-next.79

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 (92) hide show
  1. package/dist/agentic-workflow/jsonTypes.d.ts +2 -12
  2. package/dist/agentic-workflow/nodes/AgentNode.d.ts +2 -3
  3. package/dist/agents/tools/search/findRelevantFields/adapter.d.ts +8 -0
  4. package/dist/agents/tools/search/findRelevantFields/adapter.js +57 -0
  5. package/dist/agents/tools/search/findRelevantLayers/adapter.d.ts +8 -0
  6. package/dist/agents/tools/search/findRelevantLayers/adapter.js +38 -0
  7. package/dist/cdn/3LILAJUD.js +2 -0
  8. package/dist/cdn/{GPZJANRQ.js → 4AGGYAWS.js} +1 -1
  9. package/dist/cdn/4F7Y4RNW.js +2 -0
  10. package/dist/cdn/{H6IJRTHM.js → 6ADMWEVE.js} +1 -1
  11. package/dist/cdn/{B6CJG5UH.js → 6U4GTCLJ.js} +14 -14
  12. package/dist/cdn/7BCQMK6D.js +2 -0
  13. package/dist/cdn/7QOC7FQE.js +2 -0
  14. package/dist/cdn/ADJ63EDN.js +3 -0
  15. package/dist/cdn/ATFNWFKG.js +2 -0
  16. package/dist/cdn/CZLLPKMS.js +2 -0
  17. package/dist/cdn/{JSMNXHYG.js → EAOKCWED.js} +6 -6
  18. package/dist/cdn/EBNVLMUU.js +2 -0
  19. package/dist/cdn/G5XE5D36.js +2 -0
  20. package/dist/cdn/{U3XIDLHO.js → HPU6K67Y.js} +1 -1
  21. package/dist/cdn/IBZ2NEAO.js +2 -0
  22. package/dist/cdn/{TYZ3FRGW.js → J4R7KYJ3.js} +6 -6
  23. package/dist/cdn/{GZGDLURS.js → KP2FWABJ.js} +1 -1
  24. package/dist/cdn/LM2IGECE.js +2 -0
  25. package/dist/cdn/LXQFE5PJ.js +2 -0
  26. package/dist/cdn/{GOKLRL6M.js → MAPKEX67.js} +1 -1
  27. package/dist/cdn/{EZYONVBU.js → MYH43WYG.js} +1 -1
  28. package/dist/cdn/NLEBWLVV.js +2 -0
  29. package/dist/cdn/{UB6PAQZ7.js → NPBXE4EQ.js} +1 -1
  30. package/dist/cdn/{FZ4CURWW.js → NZJ6LLYY.js} +1 -1
  31. package/dist/cdn/ORRMONGJ.js +2 -0
  32. package/dist/cdn/QUMNJVKX.js +2 -0
  33. package/dist/cdn/RHYNE5OE.js +2 -0
  34. package/dist/cdn/W7OT3KRG.js +18 -0
  35. package/dist/cdn/XCNN7BQ3.js +2 -0
  36. package/dist/cdn/{DUSILSNJ.js → XHGVCL22.js} +3 -3
  37. package/dist/cdn/XLHTQ7CF.js +2 -0
  38. package/dist/cdn/ZWBFTKHF.js +2 -0
  39. package/dist/cdn/agent-utils/index.js +1 -1
  40. package/dist/cdn/assets/assistant/t9n/messages.en.json +1 -1
  41. package/dist/cdn/assets/assistant-interrupt/t9n/messages.en.json +1 -1
  42. package/dist/cdn/assets/assistant-interrupt-preview/t9n/messages.en.json +1 -0
  43. package/dist/cdn/assets/assistant-message/t9n/messages.en.json +1 -0
  44. package/dist/cdn/assets/assistant-message-loading/t9n/messages.en.json +1 -0
  45. package/dist/cdn/index.js +1 -1
  46. package/dist/chunks/adapter.js +64 -67
  47. package/dist/chunks/converterUtils.js +66 -48
  48. package/dist/chunks/dataExplorationGraph.js +121 -195
  49. package/dist/chunks/fieldStatistics.js +79 -0
  50. package/dist/chunks/layerStylingGraph.js +9 -9
  51. package/dist/components/arcgis-assistant/customElement.d.ts +30 -1
  52. package/dist/components/arcgis-assistant/customElement.js +133 -135
  53. package/dist/components/arcgis-assistant-agent/customElement.js +152 -184
  54. package/dist/components/arcgis-assistant-interrupt/customElement.d.ts +4 -0
  55. package/dist/components/arcgis-assistant-interrupt/customElement.js +10 -11
  56. package/dist/components/arcgis-assistant-interrupt-preview/customElement.js +12 -8
  57. package/dist/components/arcgis-assistant-message/customElement.d.ts +3 -0
  58. package/dist/components/arcgis-assistant-message/customElement.js +9 -8
  59. package/dist/components/arcgis-assistant-message-loading/customElement.d.ts +3 -0
  60. package/dist/components/arcgis-assistant-message-loading/customElement.js +11 -10
  61. package/dist/components/arcgis-assistant-message-text/customElement.js +4 -4
  62. package/dist/components/arcgis-assistant-user-message/customElement.d.ts +2 -0
  63. package/dist/components/arcgis-assistant-user-message/customElement.js +13 -10
  64. package/dist/docs/api.json +1 -1
  65. package/dist/docs/docs.json +1 -1
  66. package/dist/docs/vscode.html-custom-data.json +1 -1
  67. package/dist/docs/web-types.json +1 -1
  68. package/dist/loader.js +4 -4
  69. package/dist/types/lumina.d.ts +2 -2
  70. package/dist/types/preact.d.ts +2 -2
  71. package/dist/types/react.d.ts +2 -2
  72. package/dist/types/stencil.d.ts +2 -2
  73. package/package.json +8 -6
  74. package/dist/agentic-workflow/nodes/support/Prompt.d.ts +0 -20
  75. package/dist/cdn/2GH3K5JP.js +0 -2
  76. package/dist/cdn/2SQKAJ73.js +0 -2
  77. package/dist/cdn/2Y4DTOGT.js +0 -2
  78. package/dist/cdn/3S5G5SIX.js +0 -2
  79. package/dist/cdn/5TI2F5XX.js +0 -2
  80. package/dist/cdn/BWLXDT75.js +0 -2
  81. package/dist/cdn/DCSZPL7R.js +0 -2
  82. package/dist/cdn/DOXBIASP.js +0 -18
  83. package/dist/cdn/FSGIG7UN.js +0 -2
  84. package/dist/cdn/GLBE7OW2.js +0 -2
  85. package/dist/cdn/KKLAQF3Z.js +0 -2
  86. package/dist/cdn/KLYNL2ZT.js +0 -2
  87. package/dist/cdn/LZP3OBKS.js +0 -3
  88. package/dist/cdn/OKMZQXBQ.js +0 -2
  89. package/dist/cdn/RCFAXADI.js +0 -2
  90. package/dist/cdn/T4ECSHM7.js +0 -2
  91. package/dist/cdn/WSHWQDO2.js +0 -2
  92. package/dist/cdn/XRE5USHA.js +0 -2
@@ -1,12 +1,12 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import g from "@esri/arcgis-html-sanitizer";
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 g(
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,98 +28,115 @@ 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), a = e.indexOf("[", t);
32
- return r === -1 ? a : a === -1 ? r : Math.min(r, a);
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 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)
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 (a === 0 && c === 0 && n > r)
44
- return e.slice(r, n + 1);
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 O(e) {
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 c = JSON.parse(r), l = `
74
+ const l = JSON.parse(r), c = `
57
75
 
58
76
  \`\`\`json
59
- ${JSON.stringify(c, null, 2)}
77
+ ${JSON.stringify(l, null, 2)}
60
78
  \`\`\`
61
79
 
62
80
  `;
63
- t = e.replace(r, l);
81
+ t = e.replace(r, c);
64
82
  } catch {
65
83
  }
66
- const a = E(t);
67
- return q(a);
84
+ const n = q(t);
85
+ return M(n);
68
86
  }
69
- function q(e) {
87
+ function M(e) {
70
88
  if (!e)
71
89
  return "";
72
- const t = M(e);
73
- return T(t);
90
+ const t = E(e), r = k(t);
91
+ return T(r);
74
92
  }
75
- function E(e) {
93
+ function q(e) {
76
94
  return e ? S.parse(e, { async: !1 }) : "";
77
95
  }
78
- function M(e) {
96
+ function E(e) {
79
97
  if (!e || typeof DOMParser > "u")
80
98
  return e;
81
99
  try {
82
100
  const t = new DOMParser().parseFromString(e, "text/html");
83
- return Array.from(t.querySelectorAll("table")).forEach((a, c) => {
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) {
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) {
90
108
  const o = t.createElement("calcite-table-row");
91
109
  o.setAttribute("slot", "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");
95
- i.setAttribute("heading", s), o.appendChild(i);
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);
96
114
  }
97
- n.appendChild(o);
115
+ a.appendChild(o);
98
116
  }
99
117
  }
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") {
107
- const w = (s.textContent ?? "").trim(), y = t.createElement("calcite-table-header");
108
- y.setAttribute("heading", w), o.appendChild(y);
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);
109
127
  return;
110
128
  }
111
- const i = t.createElement("calcite-table-cell"), p = s.getAttribute("colspan"), m = s.getAttribute("rowspan");
112
- p && i.setAttribute("colspan", p), m && i.setAttribute("rowspan", m), i.innerHTML = s.innerHTML, o.appendChild(i);
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);
113
131
  }
114
- n.appendChild(o);
115
- }), a.replaceWith(n);
132
+ a.appendChild(o);
133
+ }), n.replaceWith(a);
116
134
  }), t.body.innerHTML;
117
135
  } catch {
118
136
  return e;
119
137
  }
120
138
  }
121
139
  export {
122
- q as a,
123
- O as p
140
+ M as a,
141
+ z as p
124
142
  };
@@ -1,302 +1,228 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import { StateGraph as I, START as V, END as v } from "@langchain/langgraph/web";
3
- import { g as T, y as R, t as C, z as k, r as D, D as N, A as z } from "./adapter.js";
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
6
  import "@arcgis/core/request.js";
7
7
  import "@arcgis/toolkit/string";
8
- import { h as b, e as P } from "./generateLayerDescriptions.js";
9
- import { AIMessage as Q } from "@langchain/core/messages";
10
- import { s as n } from "./index.js";
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";
11
11
  import "@langchain/openai";
12
12
  import "@arcgis/core/config.js";
13
13
  import "@arcgis/core/core/reactiveUtils.js";
14
14
  import "@arcgis/core/layers/FeatureLayer.js";
15
15
  import "@langchain/core/prompts";
16
- import { h as A } from "./toolCallResponse.js";
17
- import { b as _ } from "./formatFeatureAttributes.js";
18
- import { ToolNode as O } from "@langchain/langgraph/prebuilt";
19
- import j from "@arcgis/core/smartMapping/statistics/summaryStatistics.js";
20
- import G from "@arcgis/core/smartMapping/statistics/uniqueValues.js";
21
- import { f as U } from "./fetchAgentContext.js";
22
- import { f } from "./fetchService.js";
23
- const W = async (t, e) => (await n({ text: "Exiting Data Exploration agent" }, e), t), B = async (t, e) => {
24
- await n({ text: "Requesting LLM for layer filter results" }, e);
25
- const d = await T("data_explore_filter_prompt");
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");
26
25
  if (!e?.configurable)
27
26
  throw new Error("config.configurable is required for layer filter tools");
28
- const { userTimezone: l, userTimezoneOffset: s } = _(), r = {
27
+ const { userTimezone: d, userTimezoneOffset: r } = q(), o = {
29
28
  layerFieldInfo: t.layerFieldInfo,
30
- userTimezone: l,
31
- userTimezoneOffset: s,
29
+ userTimezone: d,
30
+ userTimezoneOffset: r,
32
31
  queryResponse: t.queryResponse,
33
32
  assignedTask: t.agentExecutionContext.assignedTask,
34
33
  userRequest: t.agentExecutionContext.userRequest,
35
34
  priorSteps: t.agentExecutionContext.priorSteps
36
- }, o = await b({
37
- promptText: d,
35
+ }, i = await M({
36
+ promptText: l,
38
37
  modelTier: "advanced",
39
38
  config: e,
40
39
  messages: t.dataExplorationMessages,
41
- inputVariables: r,
42
- tools: R
43
- }), i = [...t.dataExplorationMessages, o];
44
- if (!((o.tool_calls?.length ?? 0) > 0))
45
- return await n({ text: "LLM determined no filter changes needed" }, e), {
40
+ inputVariables: o,
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), {
46
45
  ...t,
47
- dataExplorationMessages: i
46
+ dataExplorationMessages: n
48
47
  // Don't overwrite outputMessage if query already set it
49
48
  };
50
- const m = i, g = o.content.toString();
51
- return await A(o, e), { ...t, dataExplorationMessages: m, outputMessage: g };
52
- }, H = async (t, e) => {
53
- await n({ text: "Requesting LLM for layer query results" }, e);
54
- const d = await T("data_explore_query_prompt");
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");
55
54
  if (!e?.configurable)
56
55
  throw new Error("config.configurable is required for layer query tools");
57
- const { userTimezone: l, userTimezoneOffset: s } = _(), r = t.agentExecutionContext.sharedState, o = r.lastNavigatedFeatures?.value, i = r.lastResolvedLocation?.value;
56
+ const { userTimezone: d, userTimezoneOffset: r } = q(), o = t.agentExecutionContext.sharedState, i = o.lastNavigatedFeatures?.value, n = o.lastResolvedLocation?.value;
58
57
  let c = "none";
59
- if (o != null)
58
+ if (i != null)
60
59
  try {
61
- c = JSON.stringify(o);
60
+ c = JSON.stringify(i);
62
61
  } catch {
63
62
  c = "none";
64
63
  }
65
- let m = "none";
66
- if (i != null)
64
+ let u = "none";
65
+ if (n != null)
67
66
  try {
68
- m = JSON.stringify({
69
- address: i.address,
70
- location: i.location
67
+ u = JSON.stringify({
68
+ address: n.address,
69
+ location: n.location
71
70
  });
72
71
  } catch {
73
- m = "none";
72
+ u = "none";
74
73
  }
75
- const g = {
74
+ const p = {
76
75
  layerFieldInfo: t.layerFieldInfo,
77
- userTimezone: l,
78
- userTimezoneOffset: s,
76
+ userTimezone: d,
77
+ userTimezoneOffset: r,
79
78
  assignedTask: t.agentExecutionContext.assignedTask,
80
79
  userRequest: t.agentExecutionContext.userRequest,
81
80
  priorSteps: t.agentExecutionContext.priorSteps,
82
81
  lastNavigatedFeatures: c,
83
- lastResolvedLocation: m
84
- }, y = await b({
85
- promptText: d,
82
+ lastResolvedLocation: u
83
+ }, g = await M({
84
+ promptText: l,
86
85
  modelTier: "advanced",
87
86
  config: e,
88
87
  messages: t.dataExplorationMessages,
89
- inputVariables: g,
90
- tools: k
91
- }), h = (y.tool_calls?.length ?? 0) > 0, p = y.content.toString();
92
- return await A(y, e), {
88
+ inputVariables: p,
89
+ tools: C
90
+ }), f = (g.tool_calls?.length ?? 0) > 0, h = g.content.toString();
91
+ return await L(g, e), {
93
92
  ...t,
94
- dataExplorationMessages: [...t.dataExplorationMessages, y],
93
+ dataExplorationMessages: [...t.dataExplorationMessages, g],
95
94
  // Only emit output here when no tools are being called.
96
95
  // For tool-calling flows, downstream summarizer nodes provide the final user-facing message.
97
- ...h ? {} : { outputMessage: p },
96
+ ...f ? {} : { outputMessage: h },
98
97
  status: "success",
99
- summary: p && !h ? C(p) : "Query planning completed."
98
+ summary: h && !f ? v(h) : "Query planning completed."
100
99
  };
101
- }, J = async (t, e) => {
100
+ }, V = async (t, e) => {
102
101
  try {
103
- await n({ text: "Requesting LLM for summary on query results" }, e);
104
- const d = await T("summarize_query_response_prompt"), l = {
102
+ await s({ text: "Requesting LLM for summary on query results" }, e);
103
+ const l = await x("summarize_query_response_prompt"), d = {
105
104
  queryResponse: t.queryResponse,
106
105
  assignedTask: t.agentExecutionContext.assignedTask,
107
106
  userRequest: t.agentExecutionContext.userRequest,
108
107
  priorSteps: t.agentExecutionContext.priorSteps
109
- }, s = await P({
110
- promptText: d,
108
+ }, r = await A({
109
+ promptText: l,
111
110
  modelTier: "fast",
112
111
  config: e,
113
112
  messages: t.dataExplorationMessages,
114
- inputVariables: l
115
- }), r = typeof s == "string" ? s : s.content, o = new Q(r);
116
- await n({ text: `Received response from LLM: ${r}` }, e);
117
- const i = r;
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;
118
117
  return {
119
118
  ...t,
120
- outputMessage: i,
119
+ outputMessage: n,
121
120
  status: "success",
122
- summary: i ? C(i) : "Summary generated.",
123
- dataExplorationMessages: [...t.dataExplorationMessages, o]
121
+ summary: n ? v(n) : "Summary generated.",
122
+ dataExplorationMessages: [...t.dataExplorationMessages, i]
124
123
  };
125
124
  } catch (a) {
126
- throw await n({ text: "Error during filter LLM request" }, e), new Error(`Error during filter LLM request: ${a instanceof Error ? a.message : String(a)}`);
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)}`);
127
126
  }
128
127
  };
129
- async function K(t, e) {
130
- if ((t.queryResponse ?? []).some((s) => {
131
- const r = s.details;
132
- return typeof r == "object" && r !== null && "error" in r;
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;
133
132
  }))
134
- return await n({ text: "Skipping layer filter tool because query response contains an error." }, e), { ...t };
135
- const l = await new O(R, { handleToolErrors: !1 }).invoke(
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(
136
135
  {
137
136
  messages: t.dataExplorationMessages
138
137
  },
139
138
  e
140
139
  );
141
- return await n(
142
- { text: `Finished executing layer filter tool: ${l.messages.map((s) => s.content).join(", ")}` },
140
+ return await s(
141
+ { text: `Finished executing layer filter tool: ${d.messages.map((r) => r.content).join(", ")}` },
143
142
  e
144
143
  ), { ...t };
145
144
  }
146
- const X = 10, Y = ["string", "small-integer", "integer"], Z = async (t, e, { includeSummaryStatistics: a = !0, includeUniqueValues: d = !0 } = {}) => {
147
- let l = null, s = null;
148
- try {
149
- if (e.type !== "geometry" && e.type !== "oid" && e.type !== "global-id") {
150
- a && (l = await j({ layer: t, field: e.name }));
151
- const r = e.domain?.type === "coded-value" ? e.domain : null;
152
- d && (Y.includes(e.type) || r) && (s = (await G({ layer: t, field: e.name })).uniqueValueInfos.sort((o, i) => i.count - o.count).slice(0, X), r && (s = s.map((o) => ({
153
- ...o,
154
- value: r.getName(o.value) ?? o.value
155
- }))));
156
- }
157
- } catch (r) {
158
- console.error(`Error fetching statistics for field ${e.name}:`, r);
159
- }
160
- return {
161
- summaryStatistics: l,
162
- uniqueValues: s
163
- };
164
- };
165
- function ee(t, e) {
166
- return ["string", "small-integer", "integer"].includes(t) || e === "coded-value";
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);
167
148
  }
168
- async function te(t, e, a, d = !0) {
169
- const l = [], s = [], r = [];
170
- for (const o of t) {
171
- let i = function(p) {
172
- const u = e.get(p)?.layerItem;
173
- return u ? [
174
- u.name && `Name: ${u.name}`,
175
- u.title && `Title: ${u.title}`,
176
- u.description && `Description: ${u.description}`
177
- ].filter(Boolean).join(" | ") : p;
178
- };
179
- const { layerId: c, results: m } = o, g = a.map?.allLayers.find((p) => p.id === c), y = e.get(c)?.fieldRegistry;
180
- if (!y)
181
- continue;
182
- let h = l.find((p) => p.layerId === c);
183
- h || (h = {
184
- layerId: c,
185
- layerSummary: i(c),
186
- fieldInfos: []
187
- }, l.push(h));
188
- for (const p of m) {
189
- const u = y.get(p.name);
190
- if (!u)
191
- continue;
192
- const x = u.statistics, E = d && !x?.summaryStatistics, w = ee(u.type, u.domain?.type) && !x?.uniqueValues, q = E || w;
193
- if (r.push({
194
- layerId: c,
195
- fieldName: u.name,
196
- didFetchStatistics: q
197
- }), q) {
198
- const $ = Z(g, u, {
199
- includeSummaryStatistics: E,
200
- includeUniqueValues: w
201
- }).then((F) => {
202
- const S = {
203
- summaryStatistics: x?.summaryStatistics ?? null,
204
- uniqueValues: x?.uniqueValues ?? null
205
- };
206
- E && (S.summaryStatistics = F.summaryStatistics), w && (S.uniqueValues = F.uniqueValues), y.set(u.name, { ...u, statistics: S }), u.statistics = S;
207
- });
208
- s.push($);
209
- }
210
- h.fieldInfos.push(u);
211
- }
212
- }
213
- return await Promise.all(s), {
214
- layerFieldInfo: l,
215
- didFetchStatistics: s.length > 0,
216
- fieldStatisticsFetchStatus: r
217
- };
218
- }
219
- 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;
220
- function ae(t, e) {
221
- return L.test(t) || L.test(e);
222
- }
223
- const se = async (t, e) => {
149
+ const j = async (t, e) => {
224
150
  try {
225
- await n({ text: "Preparing field information for vector search results" }, e);
226
- const a = f(e, "layersAndFieldsRegistry"), { mapView: d } = U(e, ["mapView"]), { assignedTask: l, userRequest: s } = t.agentExecutionContext, r = ae(l, s), { layerFieldInfo: o, didFetchStatistics: i, fieldStatisticsFetchStatus: c } = await te(
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 $(
227
153
  t.vectorSearchFieldResults,
228
154
  a,
229
- d,
230
- r
155
+ l,
156
+ o
231
157
  );
232
- i ? await n({ text: "Statistics fetched" }, e) : await n({ text: "Statistics skipped" }, e);
233
- for (const m of c)
234
- await n(
158
+ n ? await s({ text: "Statistics fetched" }, e) : await s({ text: "Statistics skipped" }, e);
159
+ for (const u of c)
160
+ await s(
235
161
  {
236
- text: ` - ${m.fieldName} - stats ${m.didFetchStatistics ? "fetched" : "skipped"}`
162
+ text: ` - ${u.fieldName} - stats ${u.didFetchStatistics ? "fetched" : "skipped"}`
237
163
  },
238
164
  e
239
165
  );
240
- return await n({ text: "Field information prepared" }, e), { ...t, layerFieldInfo: o };
166
+ return await s({ text: "Field information prepared" }, e), { ...t, layerFieldInfo: i };
241
167
  } catch (a) {
242
- throw await n({ text: "Error during fetching statistics" }, e), new Error(`Error during fetching statistics: ${a instanceof Error ? a.message : String(a)}`);
168
+ throw await s({ text: "Error during fetching statistics" }, e), new Error(`Error during fetching statistics: ${a instanceof Error ? a.message : String(a)}`);
243
169
  }
244
- }, M = 0.7, re = 10, oe = async (t, e) => {
170
+ }, S = 0.7, G = 10, W = async (t, e) => {
245
171
  try {
246
- await n({ text: "Similarity search to find fields" }, e);
247
- const a = f(e, "fieldSearch"), d = f(e, "layersAndFieldsRegistry"), l = f(e, "embeddingCache"), s = await a.searchFields({
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({
248
174
  text: t.agentExecutionContext.assignedTask,
249
175
  layerIds: t.vectorSearchLayerIds,
250
- minScore: M,
251
- topResults: re,
252
- embeddingCache: l
253
- }), r = s.map(({ layerId: i, results: c }) => {
254
- const m = c.map((g) => ` - ${g.name} (${g.score.toFixed(2)})`).join(`
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(`
255
181
  `);
256
- return `${d.get(i)?.layerItem.name ?? i}:
257
- ${m}`;
182
+ return `${l.get(n)?.layerItem.name ?? n}:
183
+ ${u}`;
258
184
  }).join(`
259
185
  `);
260
- let o;
261
- return s.length > 0 ? o = `Vector search completed. Matching layers and fields with scores:
262
- ${r}` : o = `No vector search results found for score over ${M}.`, await n({ text: o }, e), {
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), {
263
189
  ...t,
264
- vectorSearchFieldResults: s
190
+ vectorSearchFieldResults: r
265
191
  };
266
192
  } catch (a) {
267
- throw await n(
193
+ throw await s(
268
194
  { text: `Error during vector search: ${a instanceof Error ? a.message : String(a)}` },
269
195
  e
270
196
  ), new Error(`Vector search failed: ${a instanceof Error ? a.message : String(a)}`);
271
197
  }
272
- }, ie = 0.7, ne = async (t, e) => {
198
+ }, H = 0.7, J = async (t, e) => {
273
199
  try {
274
- await n(
200
+ await s(
275
201
  { text: `Similarity search to find layers: ${t.agentExecutionContext.assignedTask}` },
276
202
  e
277
203
  );
278
- const a = f(e, "layerSearch"), d = f(e, "layersAndFieldsRegistry"), l = f(e, "embeddingCache"), s = await a.searchLayers({
204
+ const a = m(e, "layerSearch"), l = m(e, "layersAndFieldsRegistry"), d = m(e, "embeddingCache"), r = await a.searchLayers({
279
205
  text: t.agentExecutionContext.assignedTask,
280
- minScore: ie,
281
- embeddingCache: l
282
- }), r = s.map((c) => c.id), o = s.map(({ id: c, score: m }) => `${d.get(c)?.layerItem.name ?? c} (${m.toFixed(2)})`).join(`
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(`
283
209
  `);
284
- let i;
285
- return r.length > 0 ? i = `Vector search completed. Matching layers with scores:
286
- ${o}` : i = "Vector search completed. No matching layers found.", await n({ text: i }, e), {
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), {
287
213
  ...t,
288
- vectorSearchLayerIds: r
214
+ vectorSearchLayerIds: o
289
215
  };
290
216
  } catch (a) {
291
- throw await n(
217
+ throw await s(
292
218
  { text: `Error during vector search: ${a instanceof Error ? a.message : String(a)}` },
293
219
  e
294
220
  ), new Error(`Vector search failed: ${a instanceof Error ? a.message : String(a)}`);
295
221
  }
296
- }, le = (t, e) => D(["layerSearch", "fieldSearch", "layersAndFieldsRegistry"], "Data Exploration Agent")(
222
+ }, U = (t, e) => N(["layerSearch", "fieldSearch", "layersAndFieldsRegistry"], "Data Exploration Agent")(
297
223
  t,
298
224
  e
299
- ), ce = () => new I(N).addNode("requireDataExplorationServices", le).addNode("vectorSearchLayers", ne).addNode("vectorSearchFields", oe).addNode("fieldStatistics", se).addNode("queryAgent", H).addNode("queryTools", z).addNode("summarizeQueryResponseLLM", J).addNode("filterAgent", B).addNode("filterTools", K).addNode("earlyExit", W).addEdge(V, "requireDataExplorationServices").addEdge("requireDataExplorationServices", "vectorSearchLayers").addConditionalEdges(
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(
300
226
  "vectorSearchLayers",
301
227
  (e) => e.vectorSearchLayerIds.length ? "vectorSearchFields" : "earlyExit"
302
228
  ).addConditionalEdges(
@@ -305,7 +231,7 @@ ${o}` : i = "Vector search completed. No matching layers found.", await n({ text
305
231
  ).addEdge("fieldStatistics", "queryAgent").addConditionalEdges("queryAgent", (e) => (e.dataExplorationMessages[e.dataExplorationMessages.length - 1]?.tool_calls?.length ?? 0) > 0 ? "queryTools" : "filterAgent").addConditionalEdges(
306
232
  "queryTools",
307
233
  (e) => e.queryResponse.length ? "summarizeQueryResponseLLM" : "filterAgent"
308
- ).addEdge("summarizeQueryResponseLLM", "filterAgent").addConditionalEdges("filterAgent", (e) => (e.dataExplorationMessages[e.dataExplorationMessages.length - 1]?.tool_calls?.length ?? 0) > 0 ? "filterTools" : v).addEdge("filterTools", v).addEdge("earlyExit", v), de = 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).
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).
309
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.
310
236
  _Example: “Only show stations where Brand is Shell”_
311
237
  _Example: “Make Shell stations stand out on the map”_
@@ -315,13 +241,13 @@ ${o}` : i = "Vector search completed. No matching layers found.", await n({ text
315
241
  _Example: “What’s the average population?”_
316
242
  _Example: “Which values are in the status field?”_
317
243
 
318
- This agent does NOT handle help/metadata requests such as listing available layers, listing field names/columns/attributes for a layer, or capability guidance.`, Ae = {
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 = {
319
245
  id: "dataExploration",
320
246
  name: "Data Exploration Agent",
321
- description: de,
322
- createGraph: ce,
323
- workspace: N
247
+ description: K,
248
+ createGraph: B,
249
+ workspace: T
324
250
  };
325
251
  export {
326
- Ae as D
252
+ xe as D
327
253
  };