@arcgis/ai-components 5.2.0-next.6 → 5.2.0-next.60

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 (208) hide show
  1. package/README.md +2 -2
  2. package/dist/agent-utils/FunctionAgent.d.ts +2 -2
  3. package/dist/agent-utils/LLMAgent.d.ts +2 -2
  4. package/dist/agent-utils/LLMAgent.js +2 -1
  5. package/dist/agent-utils/WorkflowAgent.d.ts +2 -2
  6. package/dist/agent-utils/index.d.ts +177 -0
  7. package/dist/agent-utils/index.js +167 -0
  8. package/dist/agent-utils/middlewares/trace.d.ts +2 -0
  9. package/dist/agent-utils/middlewares/trace.js +25 -33
  10. package/dist/agent-utils/tools/FunctionTool.d.ts +2 -2
  11. package/dist/agent-utils/types.d.ts +36 -7
  12. package/dist/agent-utils/workflows/ConditionalWorkflow.d.ts +2 -2
  13. package/dist/agent-utils/workflows/LoopWorkflow.d.ts +2 -2
  14. package/dist/agent-utils/workflows/ParallelWorkflow.d.ts +2 -2
  15. package/dist/agent-utils/workflows/RouterWorkflow.d.ts +2 -2
  16. package/dist/agent-utils/workflows/SequentialWorkflow.d.ts +2 -2
  17. package/dist/agent-utils/workflows/SwitchWorkflow.d.ts +2 -2
  18. package/dist/cdn/242OOJML.js +2 -0
  19. package/dist/cdn/2WDZIJQR.js +2 -0
  20. package/dist/cdn/2XQAM2Q3.js +4 -0
  21. package/dist/cdn/3DJDRAGV.js +2 -0
  22. package/dist/cdn/{AMP6IALT.js → 3UEKINYC.js} +1 -1
  23. package/dist/cdn/3YCSUTGV.js +14 -0
  24. package/dist/cdn/3ZPPYCNL.js +2 -0
  25. package/dist/cdn/434TAA3J.js +2 -0
  26. package/dist/cdn/4CEMUECT.js +2 -0
  27. package/dist/cdn/57OMVTIU.js +2 -0
  28. package/dist/cdn/5L7VPEQM.js +2 -0
  29. package/dist/cdn/6U7TEAAJ.js +2 -0
  30. package/dist/cdn/7NP7WGR5.js +2 -0
  31. package/dist/cdn/AHLLB5QW.js +2 -0
  32. package/dist/cdn/{ZS2TZ6BF.js → AOVJ34QE.js} +1 -1
  33. package/dist/cdn/APFZY4PI.js +2 -0
  34. package/dist/cdn/BE7ZN5FZ.js +2 -0
  35. package/dist/cdn/BI3LK5D3.js +2 -0
  36. package/dist/cdn/{FL4W4VYN.js → BL273EGZ.js} +17 -1
  37. package/dist/cdn/BSP6IJY4.js +2 -0
  38. package/dist/cdn/{5ZZGKP7N.js → CEKOEHB3.js} +1 -1
  39. package/dist/cdn/CWZEQ4R6.js +2 -0
  40. package/dist/cdn/EF7OV7SR.js +2 -0
  41. package/dist/cdn/{VOQX4AVB.js → FC45FF2D.js} +6 -4
  42. package/dist/cdn/FNPLHH4E.js +3 -0
  43. package/dist/cdn/FVDFPK3V.js +18 -0
  44. package/dist/cdn/{ZLXN7NMF.js → FYZATVB3.js} +10 -8
  45. package/dist/cdn/GLOALVJR.js +3 -0
  46. package/dist/cdn/HBLRVXEB.js +2 -0
  47. package/dist/cdn/HJG7QM2R.js +9 -0
  48. package/dist/cdn/HLO655UO.js +2 -0
  49. package/dist/cdn/HPSVZVAR.js +2 -0
  50. package/dist/cdn/HQXPPYMD.js +2 -0
  51. package/dist/cdn/HWBVWBDF.js +36 -0
  52. package/dist/cdn/{FX7UOGHP.js → ICBIUFK7.js} +1 -1
  53. package/dist/cdn/ICYUPLZM.js +56 -0
  54. package/dist/cdn/IEHPNCTL.js +2 -0
  55. package/dist/cdn/IHP25JWI.js +99 -0
  56. package/dist/cdn/J6A4AS7E.js +22 -0
  57. package/dist/cdn/{NE7E52YR.js → JEBRN3EU.js} +9 -3
  58. package/dist/cdn/JHFOZPBP.js +2 -0
  59. package/dist/cdn/L4SS54EZ.js +2 -0
  60. package/dist/cdn/LHLO6PTD.js +2 -0
  61. package/dist/cdn/{7RCQFLPP.js → LK7ZIQW6.js} +1 -1
  62. package/dist/cdn/LUY6V4TP.js +181 -0
  63. package/dist/cdn/M3MRIGDZ.js +2 -0
  64. package/dist/cdn/MSDNERUF.js +2 -0
  65. package/dist/cdn/MWYBF3F3.js +66 -0
  66. package/dist/cdn/NEV6OZN3.js +71 -0
  67. package/dist/cdn/NQROZZHC.js +65 -0
  68. package/dist/cdn/OI7EGYZU.js +2 -0
  69. package/dist/cdn/{23EQTPO3.js → OKVLGJAG.js} +1 -1
  70. package/dist/cdn/OY2P2O47.js +180 -0
  71. package/dist/cdn/OYNIFMCJ.js +2 -0
  72. package/dist/cdn/PDKH5ED3.js +22 -0
  73. package/dist/cdn/PJ3UN2RU.js +2 -0
  74. package/dist/cdn/{LQ6R5YRN.js → PQ2DPOFM.js} +1 -1
  75. package/dist/cdn/PVE7Q43N.js +2 -0
  76. package/dist/cdn/QBINZNXI.js +9 -0
  77. package/dist/cdn/QZLE7B6X.js +2 -0
  78. package/dist/cdn/R74ZHFA6.js +2 -0
  79. package/dist/cdn/RAAV47KU.js +3 -0
  80. package/dist/cdn/RLEHNAIA.js +2 -0
  81. package/dist/cdn/{X2ZDYHCG.js → SDWWUWAF.js} +10 -5
  82. package/dist/cdn/SLXOVE7Y.js +2 -0
  83. package/dist/cdn/TFT6HK3O.js +208 -0
  84. package/dist/cdn/TPULIO6I.js +34 -0
  85. package/dist/cdn/U4Z5XNJ5.js +2 -0
  86. package/dist/cdn/{6YMR4QSD.js → UHEYPSOR.js} +1 -1
  87. package/dist/cdn/UZLQALHY.js +2 -0
  88. package/dist/cdn/V6HOUZPZ.js +2 -0
  89. package/dist/cdn/VAXH6RUQ.js +134 -0
  90. package/dist/cdn/{H7422XUG.js → VCXSQWGA.js} +1 -1
  91. package/dist/cdn/VXFQANGJ.js +2 -0
  92. package/dist/cdn/WHOZT5H5.js +48 -0
  93. package/dist/cdn/WY7B6IMH.js +2 -0
  94. package/dist/cdn/XCRR2EEG.js +6 -0
  95. package/dist/cdn/XVPBO2JC.js +2 -0
  96. package/dist/cdn/YHQJ66WJ.js +2 -0
  97. package/dist/cdn/YIA7O2XZ.js +2 -0
  98. package/dist/cdn/YZIUJNAR.js +2 -0
  99. package/dist/cdn/ZS6SXJP2.js +2 -0
  100. package/dist/cdn/{ZTBA5PM7.js → ZU2FHVNK.js} +1 -1
  101. package/dist/cdn/agent-utils/index.js +2 -0
  102. package/dist/cdn/agent-utils/middlewares/humanInTheLoop.js +3 -0
  103. package/dist/cdn/agent-utils/middlewares/middleware.js +2 -0
  104. package/dist/cdn/agent-utils/middlewares/trace.js +2 -0
  105. package/dist/cdn/index.js +1 -1
  106. package/dist/chunks/adapter.js +1794 -1597
  107. package/dist/chunks/arcgisKnowledgeGraph.js +127 -72
  108. package/dist/chunks/arcgis_knowledge_current_lc_context.js +19 -2
  109. package/dist/chunks/arcgis_knowledge_current_map_context.js +31 -2
  110. package/dist/chunks/arcgis_knowledge_cypher_query_prompt.js +102 -0
  111. package/dist/chunks/arcgis_knowledge_summarize_result_prompt.js +116 -27
  112. package/dist/chunks/converterUtils.js +39 -32
  113. package/dist/chunks/dataExplorationGraph.js +140 -114
  114. package/dist/chunks/data_explore_query_prompt.js +9 -4
  115. package/dist/chunks/generateLayerDescriptions.js +239 -225
  116. package/dist/chunks/helpGraph.js +21 -17
  117. package/dist/chunks/help_prompt.js +34 -17
  118. package/dist/chunks/index.js +11 -0
  119. package/dist/chunks/intent_prompt.js +16 -0
  120. package/dist/chunks/layerStylingGraph.js +25 -21
  121. package/dist/chunks/navigationGraph.js +34 -29
  122. package/dist/chunks/navigation_intent_prompt.js +8 -2
  123. package/dist/chunks/orchestrator.js +110 -108
  124. package/dist/chunks/slottableRequestUtils.js +3 -7
  125. package/dist/chunks/state.js +1 -1
  126. package/dist/chunks/summarize_query_response_prompt.js +9 -7
  127. package/dist/chunks/toolCallResponse.js +13 -10
  128. package/dist/chunks/utils2.js +8 -8
  129. package/dist/components/arcgis-assistant/customElement.d.ts +27 -0
  130. package/dist/components/arcgis-assistant/customElement.js +386 -152
  131. package/dist/components/arcgis-assistant/index.js +2 -3
  132. package/dist/components/arcgis-assistant/types.d.ts +14 -1
  133. package/dist/components/arcgis-assistant-agent/customElement.js +5 -1
  134. package/dist/components/arcgis-assistant-chat/customElement.d.ts +2 -1
  135. package/dist/components/arcgis-assistant-chat/customElement.js +23 -18
  136. package/dist/components/arcgis-assistant-chat-entry/customElement.d.ts +2 -0
  137. package/dist/components/arcgis-assistant-chat-entry/customElement.js +25 -18
  138. package/dist/components/arcgis-assistant-data-exploration-agent/customElement.js +12 -6
  139. package/dist/components/arcgis-assistant-help-agent/customElement.js +9 -3
  140. package/dist/components/arcgis-assistant-interrupt/customElement.js +12 -8
  141. package/dist/components/arcgis-assistant-interrupt-preview/customElement.js +20 -0
  142. package/dist/components/arcgis-assistant-interrupt-preview/index.js +2 -0
  143. package/dist/components/arcgis-assistant-knowledge-agent/customElement.d.ts +7 -7
  144. package/dist/components/arcgis-assistant-knowledge-agent/customElement.js +18 -12
  145. package/dist/components/arcgis-assistant-layer-styling-agent/customElement.js +11 -5
  146. package/dist/components/arcgis-assistant-message/customElement.d.ts +2 -0
  147. package/dist/components/arcgis-assistant-message/customElement.js +28 -26
  148. package/dist/components/arcgis-assistant-message/index.js +2 -0
  149. package/dist/components/arcgis-assistant-message-block/customElement.js +18 -11
  150. package/dist/components/arcgis-assistant-message-block/index.js +1 -0
  151. package/dist/components/arcgis-assistant-message-loading/customElement.d.ts +4 -0
  152. package/dist/components/arcgis-assistant-message-loading/customElement.js +10 -10
  153. package/dist/components/arcgis-assistant-message-loading/index.js +1 -0
  154. package/dist/components/arcgis-assistant-message-text/customElement.d.ts +1 -0
  155. package/dist/components/arcgis-assistant-message-text/customElement.js +12 -12
  156. package/dist/components/arcgis-assistant-navigation-agent/customElement.js +12 -6
  157. package/dist/components/arcgis-assistant-speech-input/customElement.js +29 -46
  158. package/dist/components/arcgis-assistant-suggested-prompts/customElement.js +8 -8
  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/loader.js +7 -6
  165. package/dist/oauth-callback.html +1 -1
  166. package/dist/types/lumina.d.ts +7 -6
  167. package/dist/types/preact.d.ts +7 -6
  168. package/dist/types/react.d.ts +7 -6
  169. package/dist/types/stencil.d.ts +7 -6
  170. package/dist/utils/index.d.ts +94 -47
  171. package/dist/utils/index.js +80 -65
  172. package/package.json +13 -12
  173. package/dist/cdn/2AXF774U.js +0 -2
  174. package/dist/cdn/3NI46YCE.js +0 -2
  175. package/dist/cdn/3PKJWIC3.js +0 -2
  176. package/dist/cdn/462JBSEV.js +0 -422
  177. package/dist/cdn/47FWPQ2A.js +0 -16
  178. package/dist/cdn/5QAHYX7Y.js +0 -5
  179. package/dist/cdn/7BCR6TUO.js +0 -2
  180. package/dist/cdn/7GH7VSB2.js +0 -2
  181. package/dist/cdn/7PLV4QH6.js +0 -2
  182. package/dist/cdn/AEJHYRGT.js +0 -166
  183. package/dist/cdn/AO7BQHKC.js +0 -2
  184. package/dist/cdn/AXDZBBNL.js +0 -45
  185. package/dist/cdn/BFZJNJL6.js +0 -22
  186. package/dist/cdn/DDLZOMUY.js +0 -2
  187. package/dist/cdn/DHOVCT6R.js +0 -2
  188. package/dist/cdn/F2AHA4GB.js +0 -54
  189. package/dist/cdn/FX5JFRDL.js +0 -2
  190. package/dist/cdn/GCQLVNNC.js +0 -14
  191. package/dist/cdn/HB5A5R2E.js +0 -2
  192. package/dist/cdn/JV4SI65E.js +0 -108
  193. package/dist/cdn/KMQ3SP4I.js +0 -5
  194. package/dist/cdn/MH5RPXHM.js +0 -2
  195. package/dist/cdn/NAUXSHIE.js +0 -72
  196. package/dist/cdn/NVI3I46B.js +0 -2
  197. package/dist/cdn/OAVEHGB6.js +0 -2
  198. package/dist/cdn/OH64RMOR.js +0 -4
  199. package/dist/cdn/P6OPJQMC.js +0 -3
  200. package/dist/cdn/QR54T33D.js +0 -2
  201. package/dist/cdn/R6HV42YW.js +0 -3
  202. package/dist/cdn/RVOAPUBN.js +0 -2
  203. package/dist/cdn/SXDLXCIM.js +0 -2
  204. package/dist/cdn/USMDJUFS.js +0 -2
  205. package/dist/cdn/V2P4AIGG.js +0 -2
  206. package/dist/cdn/V7OJRG26.js +0 -36
  207. package/dist/cdn/Y333DGV6.js +0 -2
  208. package/dist/cdn/YIMNOUTF.js +0 -2
@@ -1,43 +1,43 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import { Annotation as d } from "@langchain/langgraph/web";
3
- import p, { z as o } from "zod";
4
- import { ChatPromptTemplate as F, SystemMessagePromptTemplate as W } from "@langchain/core/prompts";
5
- import { dispatchCustomEvent as U } from "@langchain/core/callbacks/dispatch/web";
6
- import { AIMessage as H, isAIMessage as J, isToolMessage as X } from "@langchain/core/messages";
7
- import { createAgent as G, summarizationMiddleware as Q, modelCallLimitMiddleware as Y } from "langchain";
8
- import { ChatOpenAI as Z, OpenAIEmbeddings as ee } from "@langchain/openai";
9
- import _ from "@arcgis/core/identity/IdentityManager.js";
10
- import k from "@arcgis/core/portal/Portal.js";
11
- const P = {
2
+ import { Annotation as p } from "@langchain/langgraph/web";
3
+ import u, { z as r } from "zod";
4
+ import { ChatPromptTemplate as q, SystemMessagePromptTemplate as K } from "@langchain/core/prompts";
5
+ import { s as f } from "./index.js";
6
+ import { AIMessage as W, isAIMessage as B, isToolMessage as X } from "@langchain/core/messages";
7
+ import { createAgent as G, summarizationMiddleware as H, modelCallLimitMiddleware as J } from "langchain";
8
+ import { ChatOpenAI as Q, OpenAIEmbeddings as Y } from "@langchain/openai";
9
+ import F from "@arcgis/core/portal/Portal.js";
10
+ import Z from "@arcgis/core/request.js";
11
+ import ee from "@arcgis/core/identity/IdentityManager.js";
12
+ import { generateGuid as te } from "@arcgis/toolkit/string";
13
+ import ne from "@arcgis/core/config.js";
14
+ const U = {
12
15
  advanced: "gpt-5.2",
13
16
  default: "gpt-5-mini",
14
17
  fast: "gpt-5.4-nano"
15
- }, A = {
18
+ }, E = {
16
19
  default: "text-embedding-ada-002"
17
- }, M = /* @__PURE__ */ new Map();
18
- let v = null;
19
- const te = () => {
20
- const t = k.getDefault().helperServices;
20
+ }, k = /* @__PURE__ */ new Map();
21
+ let S = null;
22
+ const se = () => {
23
+ const t = F.getDefault().helperServices;
21
24
  if (!t?.aiModels?.url)
22
25
  throw new Error("AI Models Service URL is not defined in the portal's helper services.");
23
26
  return t.aiModels.url;
24
- }, q = async (e) => {
25
- const t = te();
26
- M.size === 0 && (v || (v = (async () => {
27
+ }, P = async (e) => {
28
+ const t = se();
29
+ k.size === 0 && (S || (S = (async () => {
27
30
  try {
28
- const n = await fetch(`${t}/models`);
29
- if (!n.ok)
30
- throw new Error("Failed to fetch AI service discovery data.");
31
- (await n.json()).models.forEach((i) => M.set(i.name, i));
31
+ (await Z(`${t}/models`)).data.models.forEach((o) => k.set(o.name, o));
32
32
  } catch (n) {
33
- throw v = null, n;
33
+ throw S = null, n;
34
34
  }
35
- })()), await v);
36
- const s = M.get(e);
35
+ })()), await S);
36
+ const s = k.get(e);
37
37
  if (!s)
38
38
  throw new Error(`Model '${e}' is not available in the discovery service.`);
39
39
  return s.endpoint;
40
- }, ne = async (e = "default") => await q(P[e]), se = async (e = "default") => await q(A[e]), h = (e, t) => t, j = (e, t) => ({
40
+ }, ie = async (e = "default") => await P(U[e]), oe = async (e = "default") => await P(E[e]), h = (e, t) => t, _ = (e, t) => ({
41
41
  ...e,
42
42
  ...t
43
43
  }), $ = (e = "", t) => {
@@ -49,82 +49,78 @@ const te = () => {
49
49
  return s;
50
50
  if (n === s)
51
51
  return e;
52
- const a = n.split(`
52
+ const i = n.split(`
53
53
 
54
54
  `);
55
- return a[a.length - 1]?.trim() === s ? e : `${e}
55
+ return i[i.length - 1]?.trim() === s ? e : `${e}
56
56
 
57
57
  ${s}`;
58
- }, N = () => ({
58
+ }, j = () => ({
59
59
  userRequest: "",
60
60
  assignedTask: "",
61
61
  messages: [],
62
62
  priorSteps: [],
63
63
  sharedState: {}
64
- }), ae = () => ({
65
- agentExecutionContext: d({
66
- reducer: j,
67
- default: N
64
+ }), re = () => ({
65
+ agentExecutionContext: p({
66
+ reducer: _,
67
+ default: j
68
68
  }),
69
- outputMessage: d({
69
+ outputMessage: p({
70
70
  reducer: $,
71
71
  default: () => ""
72
72
  }),
73
- summary: d({
73
+ summary: p({
74
74
  reducer: h,
75
75
  default: () => ""
76
76
  }),
77
- status: d({
77
+ status: p({
78
78
  reducer: h
79
79
  })
80
- }), De = () => ({
81
- ...ae(),
82
- sharedStatePatch: d({
80
+ }), Oe = () => ({
81
+ ...re(),
82
+ sharedStatePatch: p({
83
83
  reducer: h
84
84
  })
85
- }), Fe = d.Root({
86
- agentExecutionContext: d({
87
- default: N,
88
- reducer: j
85
+ }), ze = p.Root({
86
+ agentExecutionContext: p({
87
+ default: j,
88
+ reducer: _
89
89
  }),
90
- currentIntent: d({
90
+ currentIntent: p({
91
91
  default: () => "none",
92
92
  reducer: h
93
93
  }),
94
- lastExecutedAgent: d({
94
+ lastExecutedAgent: p({
95
95
  default: () => "",
96
96
  reducer: h
97
97
  }),
98
- requiresFollowUp: d({
98
+ requiresFollowUp: p({
99
99
  default: () => !0,
100
100
  reducer: h
101
101
  }),
102
- stepCount: d({
102
+ stepCount: p({
103
103
  default: () => 0,
104
104
  reducer: (e, t) => t ?? e + 1
105
105
  }),
106
- finalOutputMessage: d({
106
+ finalOutputMessage: p({
107
107
  default: () => "",
108
108
  reducer: $
109
109
  })
110
- }), f = async (e, t) => {
111
- await U("trace_message", e, t);
112
- }, Ue = async (e, t) => {
113
- await U("graph_ux_suggestion", e, t);
114
- }, ie = (e) => {
110
+ }), ae = (e) => {
115
111
  if (!e || typeof e != "object" || !("services" in e))
116
112
  return !1;
117
113
  const t = e.services;
118
114
  return !!t && typeof t == "object" && "agentRegistry" in t;
119
- }, oe = (e) => {
115
+ }, ce = (e) => {
120
116
  const t = e?.configurable;
121
- return ie(t) ? t : void 0;
122
- }, re = (e, t, s) => {
117
+ return ae(t) ? t : void 0;
118
+ }, le = (e, t, s) => {
123
119
  const n = e[t];
124
- return n ? typeof n == "function" ? n() : Promise.resolve(n) : new Promise((a, i) => {
125
- (typeof queueMicrotask == "function" ? queueMicrotask : setTimeout)(i.bind(null, /* @__PURE__ */ new Error("Unknown variable dynamic import: " + t + (t.split("/").length !== s ? ". Note that variables only represent file names one level deep." : ""))));
120
+ return n ? typeof n == "function" ? n() : Promise.resolve(n) : new Promise((i, o) => {
121
+ (typeof queueMicrotask == "function" ? queueMicrotask : setTimeout)(o.bind(null, /* @__PURE__ */ new Error("Unknown variable dynamic import: " + t + (t.split("/").length !== s ? ". Note that variables only represent file names one level deep." : ""))));
126
122
  });
127
- }, I = async (e) => (await re(/* @__PURE__ */ Object.assign({ "./field_descriptions_prompt.md": () => import("./field_descriptions_prompt.js"), "./intent_prompt.md": () => import("./intent_prompt.js"), "./layer_descriptions_prompt.md": () => import("./layer_descriptions_prompt.js") }), `./${e}.md`, 2)).default, ce = async (e) => {
123
+ }, R = async (e) => (await le(/* @__PURE__ */ Object.assign({ "./field_descriptions_prompt.md": () => import("./field_descriptions_prompt.js"), "./intent_prompt.md": () => import("./intent_prompt.js"), "./layer_descriptions_prompt.md": () => import("./layer_descriptions_prompt.js") }), `./${e}.md`, 2)).default, de = async (e) => {
128
124
  const { agent: t, messages: s, config: n } = e;
129
125
  return { structuredResponse: (await t.invoke(
130
126
  {
@@ -132,55 +128,70 @@ ${s}`;
132
128
  },
133
129
  n
134
130
  )).structuredResponse };
135
- }, O = (e, t) => async (s, n) => {
136
- const a = new Headers(n?.headers);
137
- a.delete("Authorization"), a.delete("api-key"), e && e.length > 0 && (a.set("X-Esri-Authorization", `Bearer ${e}`), a.set("X-Esri-Request-Source", "MapsSDK"));
138
- const i = t && n?.signal ? AbortSignal.any([t, n.signal]) : n?.signal ?? t;
139
- return await fetch(s, {
140
- ...n,
141
- headers: a,
142
- signal: i
143
- });
144
- }, b = async (e = {}) => {
145
- const { modelTier: t = "default", temperature: s = 0, abortSignal: n } = e, a = k.getDefault(), i = await _.getCredential(`${a.url}/sharing`), r = P[t], c = await ne(t);
146
- return new Z({
147
- modelName: r,
131
+ }, me = (e) => typeof e == "string" && e.length > 0 ? e : void 0, pe = () => te(), ue = (e) => typeof e != "string" || e.trim().length === 0 ? "MapsSDK" : `MapsSDK - ${e.trim()}`, ge = (e) => {
132
+ const t = e?.configurable;
133
+ return {
134
+ conversationId: me(t?.thread_id),
135
+ abortSignal: e?.signal,
136
+ requestId: pe(),
137
+ requestSource: ue(ne.applicationName)
138
+ };
139
+ }, N = async ({ config: e }) => {
140
+ const t = F.getDefault(), n = (await ee.getCredential(`${t.url}/sharing`))?.token;
141
+ return async (i, o) => {
142
+ const { conversationId: a, abortSignal: c, requestId: l, requestSource: d } = ge(e), m = new Headers(o?.headers);
143
+ for (const w of [...m.keys()]) {
144
+ const b = w.toLowerCase();
145
+ (b === "authorization" || b === "api-key" || b.startsWith("x-stainless-")) && m.delete(w);
146
+ }
147
+ n && n.length > 0 && m.set("X-Esri-Authorization", `Bearer ${n}`), t.isPortal || (d && d.length > 0 && m.set("X-Esri-Request-Source", d), a && a.length > 0 && m.set("X-Esri-Conversation-Id", a), l.length > 0 && m.set("X-Esri-Request-Id", l));
148
+ const y = c && o?.signal ? AbortSignal.any([c, o.signal]) : o?.signal ?? c;
149
+ return await fetch(i, {
150
+ ...o,
151
+ headers: m,
152
+ signal: y
153
+ });
154
+ };
155
+ }, M = async (e = {}) => {
156
+ const { modelTier: t = "default", temperature: s = 0, config: n } = e, i = U[t], o = await ie(t);
157
+ return new Q({
158
+ modelName: i,
148
159
  apiKey: "dummy-key",
149
160
  // 5-mini does not support temperature parameter
150
161
  ...t !== "default" && { temperature: s },
151
162
  configuration: {
152
- baseURL: c,
153
- fetch: O(i.token, n)
163
+ baseURL: o,
164
+ fetch: await N({ config: n })
154
165
  }
155
166
  });
156
- }, _e = async (e = "default", t) => {
157
- const s = k.getDefault(), n = await _.getCredential(`${s.url}/sharing`), a = A[e], i = await se(e);
158
- return new ee({
159
- modelName: a,
167
+ }, Le = async (e = {}) => {
168
+ const { tier: t = "default", config: s } = e, n = E[t], i = await oe(t);
169
+ return new Y({
170
+ modelName: n,
160
171
  apiKey: "dummy-key",
161
172
  configuration: {
162
173
  baseURL: i,
163
- fetch: O(n.token, t)
174
+ fetch: await N({ config: s })
164
175
  },
165
176
  batchSize: 2048,
166
177
  maxConcurrency: 10
167
178
  });
168
- }, le = o.object({
169
- id: o.string().min(1),
170
- name: o.string().min(1),
171
- description: o.string().min(1)
179
+ }, fe = r.object({
180
+ id: r.string().min(1),
181
+ name: r.string().min(1),
182
+ description: r.string().min(1)
172
183
  });
173
- o.array(le);
174
- const R = (e) => JSON.stringify(e, null, 2), de = (e) => {
175
- const t = e.map((n) => n.id), s = o.enum(t);
176
- return o.object({
184
+ r.array(fe);
185
+ const C = (e) => JSON.stringify(e, null, 2), he = (e) => {
186
+ const t = e.map((n) => n.id), s = r.enum(t);
187
+ return r.object({
177
188
  intent: s.nullable(),
178
- assignedTask: o.string().nullable(),
179
- requiresFollowUp: o.boolean()
189
+ assignedTask: r.string().nullable(),
190
+ requiresFollowUp: r.boolean()
180
191
  });
181
- }, Pe = async (e, t) => {
182
- const s = oe(t);
183
- if (s.abortSignal?.aborted)
192
+ }, Ve = async (e, t) => {
193
+ const s = ce(t);
194
+ if (t?.signal?.aborted)
184
195
  return await f({ text: "Run cancelled; skipping intent routing" }, t), {
185
196
  ...e,
186
197
  currentIntent: "none",
@@ -189,68 +200,73 @@ const R = (e) => JSON.stringify(e, null, 2), de = (e) => {
189
200
  };
190
201
  try {
191
202
  await f({ text: "Asking LLM to route to an agent" }, t);
192
- const a = s.services.agentRegistry?.list() ?? [], i = a.map(({ agent: g }) => ({
203
+ const i = s.services.agentRegistry?.list() ?? [], o = i.map(({ agent: g }) => ({
193
204
  id: g.id,
194
205
  name: g.name,
195
206
  description: g.description
196
207
  }));
197
- if (!i.length)
208
+ if (!o.length)
198
209
  return await f({ text: "No agents registered; skipping intent detection" }, t), {
199
210
  ...e,
200
211
  currentIntent: "none",
201
212
  finalOutputMessage: "No agents registered; skipping intent detection."
202
213
  };
203
- const r = await I("intent_prompt"), c = R(i), l = de(i), m = {
214
+ const a = await R("intent_prompt"), c = C(o), l = he(o), d = {
204
215
  registeredAgents: c,
205
- priorSteps: R(e.agentExecutionContext.priorSteps),
216
+ priorSteps: C(e.agentExecutionContext.priorSteps),
206
217
  userRequest: e.agentExecutionContext.userRequest
207
- }, T = await F.fromTemplate(r).format(m), C = G({
208
- model: await b({ modelTier: "fast", abortSignal: s.abortSignal }),
218
+ }, y = await q.fromTemplate(a).format(d), w = G({
219
+ model: await M({
220
+ modelTier: "fast",
221
+ config: t
222
+ }),
209
223
  tools: [],
210
- systemPrompt: T,
211
- checkpointer: !0,
224
+ systemPrompt: y,
212
225
  responseFormat: l,
213
226
  middleware: [
214
227
  // Preserve recent conversation context while summarizing older messages
215
228
  // to control token usage without losing important intent signals.
216
229
  // The trigger and keep parameters can be tuned based on token limits and behavior.
217
- Q({
218
- model: await b({ modelTier: "fast", abortSignal: s.abortSignal }),
230
+ H({
231
+ model: await M({
232
+ modelTier: "fast",
233
+ config: t
234
+ }),
219
235
  trigger: { tokens: 4e3 },
220
236
  keep: { messages: 6 }
221
237
  }),
222
238
  // Enforce no loop/retry.
223
239
  // 1 usual LLM call and 1 optional summarization call.
224
- Y({ runLimit: 2 })
240
+ J({ runLimit: 2 })
225
241
  ]
226
- }), { structuredResponse: L } = await ce({
227
- agent: C,
242
+ }), { structuredResponse: b } = await de({
243
+ agent: w,
228
244
  messages: e.agentExecutionContext.messages,
229
245
  config: t
230
- }), y = l.parse(
231
- L ?? { intent: null, assignedTask: null, requiresFollowUp: !1 }
232
- ), x = y.intent ?? "none", K = {
246
+ }), v = l.parse(
247
+ b ?? { intent: null, assignedTask: null, requiresFollowUp: !1 }
248
+ ), T = v.intent ?? "none", L = {
233
249
  ...e,
234
- currentIntent: x,
235
- requiresFollowUp: y.requiresFollowUp,
250
+ currentIntent: T,
251
+ requiresFollowUp: v.requiresFollowUp,
236
252
  agentExecutionContext: {
237
253
  ...e.agentExecutionContext,
238
- assignedTask: y.assignedTask ?? ""
254
+ assignedTask: v.assignedTask ?? ""
239
255
  }
240
256
  };
241
- if (x === "none") {
242
- const g = `I could not find an agent that can handle that request. I have access to the following agents: ${a.map(({ agent: B }) => B.name).join(", ")}.
257
+ if (T === "none") {
258
+ const g = `I could not find an agent that can handle that request. I have access to the following agents: ${i.map(({ agent: V }) => V.name).join(", ")}.
243
259
 
244
260
  Please ask a question that can be answered by one of these agents.`;
245
261
  return await f({ text: "LLM did not identify a clear intent." }, t), {
246
262
  ...e,
247
- currentIntent: x,
263
+ currentIntent: T,
248
264
  requiresFollowUp: !1,
249
265
  finalOutputMessage: g,
250
266
  agentExecutionContext: {
251
267
  ...e.agentExecutionContext,
252
268
  assignedTask: "",
253
- messages: [...e.agentExecutionContext.messages, new H(g)],
269
+ messages: [...e.agentExecutionContext.messages, new W(g)],
254
270
  priorSteps: [
255
271
  ...e.agentExecutionContext.priorSteps ?? [],
256
272
  {
@@ -265,177 +281,175 @@ Please ask a question that can be answered by one of these agents.`;
265
281
  }
266
282
  return await f(
267
283
  {
268
- text: `Agent picked: ${x}
269
- Task Assigned: ${y.assignedTask ?? ""}
270
- Requires Follow-Up: ${y.requiresFollowUp}`
284
+ text: `Agent picked: ${T}
285
+ Task Assigned: ${v.assignedTask ?? ""}
286
+ Requires Follow-Up: ${v.requiresFollowUp}`
271
287
  },
272
288
  t
273
- ), K;
289
+ ), L;
274
290
  } catch (n) {
275
291
  throw await f({ text: "Error during intent detection" }, t), new Error(`Error during intent detection: ${n instanceof Error ? n.message : String(n)}`);
276
292
  }
277
- }, pe = "0.1", w = 1536, me = "openai", ue = A.default, ge = `Name: {name}
293
+ }, ye = "0.1", x = 1536, we = "openai", be = E.default, ve = `Name: {name}
278
294
  Title: {title}
279
- Description: {description}`, fe = `Name: {name}
295
+ Description: {description}`, xe = `Name: {name}
280
296
  Alias: {alias}
281
- Description: {description}`, qe = o.object({
282
- schemaVersion: o.literal(pe),
283
- modified: o.number().int().nonnegative(),
284
- embeddings: o.object({
285
- modelProvider: o.literal(me),
286
- model: o.literal(ue),
287
- dimensions: o.literal(w),
288
- templates: o.object({
289
- layer: o.string().default(ge),
290
- field: o.string().default(fe)
297
+ Description: {description}`, Ke = r.object({
298
+ schemaVersion: r.literal(ye),
299
+ modified: r.number().int().nonnegative(),
300
+ embeddings: r.object({
301
+ modelProvider: r.literal(we),
302
+ model: r.literal(be),
303
+ dimensions: r.literal(x),
304
+ templates: r.object({
305
+ layer: r.string().default(ve),
306
+ field: r.string().default(xe)
291
307
  })
292
308
  }),
293
- layers: o.array(
294
- o.object({
295
- id: o.string().min(1),
296
- name: o.string().min(1),
297
- title: o.string().catch(""),
298
- description: o.string().catch(""),
299
- vector: o.array(o.number()).length(w, {
300
- message: `Layer vector must be exactly ${w} dimensions`
309
+ layers: r.array(
310
+ r.object({
311
+ id: r.string().min(1),
312
+ name: r.string().min(1),
313
+ title: r.string().catch(""),
314
+ description: r.string().catch(""),
315
+ vector: r.array(r.number()).length(x, {
316
+ message: `Layer vector must be exactly ${x} dimensions`
301
317
  }),
302
- fields: o.array(
303
- o.object({
304
- name: o.string().min(1),
305
- alias: o.string().catch(""),
306
- description: o.string().catch(""),
307
- vector: o.array(o.number()).length(w, {
308
- message: `Field vector must be exactly ${w} dimensions`
318
+ fields: r.array(
319
+ r.object({
320
+ name: r.string().min(1),
321
+ alias: r.string().catch(""),
322
+ description: r.string().catch(""),
323
+ vector: r.array(r.number()).length(x, {
324
+ message: `Field vector must be exactly ${x} dimensions`
309
325
  })
310
326
  })
311
327
  )
312
328
  })
313
329
  ).default([])
314
- }), he = (e) => {
330
+ }), Me = (e) => {
315
331
  const t = /* @__PURE__ */ new Set();
316
332
  for (const n of e)
317
- if (J(n)) {
318
- const a = n;
319
- a.tool_calls && a.tool_calls.length > 0 && a.tool_calls.forEach((i) => {
320
- i.id && t.add(i.id);
333
+ if (B(n)) {
334
+ const i = n;
335
+ i.tool_calls && i.tool_calls.length > 0 && i.tool_calls.forEach((o) => {
336
+ o.id && t.add(o.id);
321
337
  });
322
338
  }
323
339
  return e.filter((n) => {
324
340
  if (X(n)) {
325
- const a = n;
326
- return t.has(a.tool_call_id);
341
+ const i = n;
342
+ return t.has(i.tool_call_id);
327
343
  }
328
344
  return !0;
329
345
  });
330
- }, E = (e, t) => {
331
- const s = W.fromTemplate(e);
332
- return F.fromMessages([s, ...t]);
333
- }, ye = async (e) => {
334
- const { promptText: t, modelTier: s, temperature: n, messages: a, abortSignal: i } = e, r = E(t, a ?? []), c = await b({ modelTier: s, temperature: n, abortSignal: i });
335
- return r.pipe(c);
336
- }, je = async (e) => {
337
- const { promptText: t, modelTier: s = "default", temperature: n = 0, messages: a, inputVariables: i, abortSignal: r } = e, l = await (await ye({
346
+ }, A = (e, t) => {
347
+ const s = K.fromTemplate(e);
348
+ return q.fromMessages([s, ...t]);
349
+ }, Te = async (e) => {
350
+ const { promptText: t, modelTier: s, temperature: n, messages: i, config: o } = e, a = A(t, i ?? []), c = await M({ modelTier: s, temperature: n, config: o });
351
+ return a.pipe(c);
352
+ }, We = async (e) => {
353
+ const { promptText: t, modelTier: s = "default", temperature: n = 0, messages: i, inputVariables: o, config: a } = e, l = await (await Te({
338
354
  promptText: t,
339
355
  modelTier: s,
340
356
  temperature: n,
341
- messages: a,
342
- abortSignal: r
343
- })).invoke(i ?? {});
357
+ messages: i,
358
+ config: a
359
+ })).invoke(o ?? {}, a);
344
360
  if (typeof l == "string")
345
361
  return l;
346
- const m = l.content;
347
- return typeof m == "string" ? m : JSON.stringify(m);
348
- }, V = async (e) => {
349
- const { promptText: t, modelTier: s = "default", temperature: n = 0, messages: a, inputVariables: i, schema: r, abortSignal: c } = e, l = E(t, a ?? []), u = (await b({ modelTier: s, temperature: n, abortSignal: c })).withStructuredOutput(r);
350
- return await l.pipe(u).invoke(i ?? {});
351
- }, $e = async (e) => {
352
- const { promptText: t, modelTier: s = "default", temperature: n = 0, messages: a, inputVariables: i, tools: r, abortSignal: c } = e, l = r.length > 0 ? he(a ?? []) : a ?? [], m = E(t, l), u = await b({ modelTier: s, temperature: n, abortSignal: c });
353
- return await m.pipe(u.bindTools(r)).invoke(i ?? {});
354
- }, we = p.object({
355
- name: p.string(),
356
- description: p.string(),
357
- valueType: p.string(),
358
- alias: p.string()
359
- }), be = p.object({
360
- fields: p.array(we)
361
- }), z = (e, t) => e.getFieldAlias(t) ?? void 0, S = (e, t) => z(e, t.name) ?? t.alias ?? "", xe = (e, t) => {
362
+ const d = l.content;
363
+ return typeof d == "string" ? d : JSON.stringify(d);
364
+ }, O = async (e) => {
365
+ const { promptText: t, modelTier: s = "default", temperature: n = 0, messages: i, inputVariables: o, schema: a, config: c } = e, l = A(t, i ?? []), m = (await M({ modelTier: s, temperature: n, config: c })).withStructuredOutput(a);
366
+ return await l.pipe(m).invoke(o ?? {}, c);
367
+ }, Be = async (e) => {
368
+ const { promptText: t, modelTier: s = "default", temperature: n = 0, messages: i, inputVariables: o, tools: a, config: c } = e, l = a.length > 0 ? Me(i ?? []) : i ?? [], d = A(t, l), m = await M({ modelTier: s, temperature: n, config: c });
369
+ return await d.pipe(m.bindTools(a)).invoke(o ?? {}, c);
370
+ }, Se = u.object({
371
+ name: u.string(),
372
+ description: u.string(),
373
+ valueType: u.string(),
374
+ alias: u.string()
375
+ }), ke = u.object({
376
+ fields: u.array(Se)
377
+ }), z = (e, t) => e.getFieldAlias(t) ?? void 0, I = (e, t) => z(e, t.name) ?? t.alias ?? "", Ie = (e, t) => {
362
378
  const s = z(e, t.name);
363
379
  return !!(s && s !== (t.alias ?? ""));
364
380
  };
365
381
  function D(e, t) {
366
382
  const s = /* @__PURE__ */ new Map();
367
383
  for (const n of e.fields) {
368
- const a = t.fields.find((l) => l.name === n.name), i = S(e, n), r = xe(e, n), c = {
384
+ const i = t.fields.find((l) => l.name === n.name), o = I(e, n), a = Ie(e, n), c = {
369
385
  name: n.name,
370
386
  type: n.type,
371
- alias: r ? i : a?.alias ?? i,
372
- description: a?.description ?? n.description ?? "",
373
- valueType: a?.valueType ?? n.valueType ?? "",
387
+ alias: a ? o : i?.alias ?? o,
388
+ description: i?.description ?? n.description ?? "",
389
+ valueType: i?.valueType ?? n.valueType ?? "",
374
390
  domain: e.getFieldDomain(n.name) ?? void 0
375
391
  };
376
392
  s.set(n.name, c);
377
393
  }
378
394
  return s;
379
395
  }
380
- const Ne = async (e) => {
381
- const s = await I("field_descriptions_prompt"), n = e.fields.filter((r) => !(S(e, r) && r.description)).map((r) => {
382
- const { name: c, type: l, description: m } = r, u = S(e, r);
383
- return [`Name: ${c}`, `Type: ${l}`, `Alias: ${u}`, `Description: ${m ?? "N/A"}`].join(", ");
396
+ const Xe = async (e) => {
397
+ const s = await R("field_descriptions_prompt"), n = e.fields.filter((a) => !(I(e, a) && a.description)).map((a) => {
398
+ const { name: c, type: l, description: d } = a, m = I(e, a);
399
+ return [`Name: ${c}`, `Type: ${l}`, `Alias: ${m}`, `Description: ${d ?? "N/A"}`].join(", ");
384
400
  }).join(`
385
401
  `);
386
402
  if (n.length === 0)
387
403
  return D(e, { fields: [] });
388
- const a = {
404
+ const i = {
389
405
  existingItemTitle: e.portalItem?.title,
390
406
  existingItemDescription: e.portalItem?.description,
391
407
  existingLayerTitle: e.title,
392
408
  existingLayerDescription: e.portalItem?.description,
393
409
  fieldInformation: n
394
- }, i = await V({
410
+ }, o = await O({
395
411
  promptText: s,
396
- schema: be,
397
- inputVariables: a
412
+ schema: ke,
413
+ inputVariables: i
398
414
  });
399
- return D(e, i);
400
- }, ve = p.object({
401
- title: p.string(),
402
- description: p.string(),
403
- name: p.string().nullable()
404
- }), Oe = async (e, t) => {
405
- const n = await I("layer_descriptions_prompt"), a = Array.from(t.values()), i = {
406
- fieldInformation: JSON.stringify(a, null, 2),
415
+ return D(e, o);
416
+ }, Ee = u.object({
417
+ title: u.string(),
418
+ description: u.string(),
419
+ name: u.string().nullable()
420
+ }), Ge = async (e, t) => {
421
+ const n = await R("layer_descriptions_prompt"), i = Array.from(t.values()), o = {
422
+ fieldInformation: JSON.stringify(i, null, 2),
407
423
  existingLayerTitle: e.title,
408
424
  existingLayerDescription: e.portalItem?.description,
409
425
  existingLayerSnippet: e.portalItem?.snippet,
410
426
  layerGeometryType: e.geometryType
411
427
  };
412
- return { ...await V({
428
+ return { ...await O({
413
429
  promptText: n,
414
- schema: ve,
415
- inputVariables: i
430
+ schema: Ee,
431
+ inputVariables: o
416
432
  }), name: e.title ?? null };
417
433
  };
418
434
  export {
419
- Fe as D,
420
- qe as W,
421
- Oe as a,
422
- me as b,
423
- b as c,
424
- w as d,
425
- pe as e,
426
- fe as f,
427
- Ne as g,
428
- je as h,
429
- V as i,
430
- $e as j,
431
- ae as k,
432
- ge as l,
433
- ue as m,
434
- De as n,
435
- Ue as o,
436
- se as p,
437
- oe as q,
438
- Pe as r,
439
- f as s,
440
- _e as t
435
+ ze as D,
436
+ Ke as W,
437
+ Ge as a,
438
+ we as b,
439
+ M as c,
440
+ x as d,
441
+ We as e,
442
+ xe as f,
443
+ Xe as g,
444
+ Be as h,
445
+ O as i,
446
+ re as j,
447
+ Oe as k,
448
+ ve as l,
449
+ be as m,
450
+ oe as n,
451
+ ce as o,
452
+ Ve as p,
453
+ Le as q,
454
+ ye as s
441
455
  };