@arcgis/ai-components 5.2.0-next.7 → 5.2.0-next.71

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/{H7422XUG.js → 2GH3K5JP.js} +1 -1
  19. package/dist/cdn/2Y4DTOGT.js +2 -0
  20. package/dist/cdn/3DJDRAGV.js +2 -0
  21. package/dist/cdn/3S5G5SIX.js +2 -0
  22. package/dist/cdn/{AMP6IALT.js → 3UEKINYC.js} +1 -1
  23. package/dist/cdn/3ZPPYCNL.js +2 -0
  24. package/dist/cdn/434TAA3J.js +2 -0
  25. package/dist/cdn/4CEMUECT.js +2 -0
  26. package/dist/cdn/4PCAK3ET.js +2 -0
  27. package/dist/cdn/57OMVTIU.js +2 -0
  28. package/dist/cdn/5TI2F5XX.js +2 -0
  29. package/dist/cdn/6TA5KFAQ.js +4 -0
  30. package/dist/cdn/6U7TEAAJ.js +2 -0
  31. package/dist/cdn/{ZS2TZ6BF.js → AOVJ34QE.js} +1 -1
  32. package/dist/cdn/APFZY4PI.js +2 -0
  33. package/dist/cdn/B6CJG5UH.js +66 -0
  34. package/dist/cdn/BE7ZN5FZ.js +2 -0
  35. package/dist/cdn/{FL4W4VYN.js → BL273EGZ.js} +17 -1
  36. package/dist/cdn/BNSJO6X2.js +2 -0
  37. package/dist/cdn/{5ZZGKP7N.js → CEKOEHB3.js} +1 -1
  38. package/dist/cdn/CMDRED5H.js +2 -0
  39. package/dist/cdn/CXW5URTF.js +14 -0
  40. package/dist/cdn/DCSZPL7R.js +2 -0
  41. package/dist/cdn/DTIVDIDY.js +2 -0
  42. package/dist/cdn/DUSILSNJ.js +9 -0
  43. package/dist/cdn/E5ZKBC24.js +36 -0
  44. package/dist/cdn/FSGIG7UN.js +2 -0
  45. package/dist/cdn/{ZLXN7NMF.js → FYZATVB3.js} +10 -8
  46. package/dist/cdn/GLBE7OW2.js +2 -0
  47. package/dist/cdn/GP6NDTUE.js +18 -0
  48. package/dist/cdn/HBLRVXEB.js +2 -0
  49. package/dist/cdn/HJG7QM2R.js +9 -0
  50. package/dist/cdn/HQXPPYMD.js +2 -0
  51. package/dist/cdn/{FX7UOGHP.js → ICBIUFK7.js} +1 -1
  52. package/dist/cdn/ICYUPLZM.js +56 -0
  53. package/dist/cdn/IEHPNCTL.js +2 -0
  54. package/dist/cdn/IHP25JWI.js +99 -0
  55. package/dist/cdn/J6A4AS7E.js +22 -0
  56. package/dist/cdn/{NE7E52YR.js → JEBRN3EU.js} +9 -3
  57. package/dist/cdn/KKLAQF3Z.js +2 -0
  58. package/dist/cdn/KLYNL2ZT.js +2 -0
  59. package/dist/cdn/KQHLOYKL.js +3 -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/{VOQX4AVB.js → MW5S2XCB.js} +6 -4
  65. package/dist/cdn/MWYBF3F3.js +66 -0
  66. package/dist/cdn/NEV6OZN3.js +71 -0
  67. package/dist/cdn/OKMZQXBQ.js +2 -0
  68. package/dist/cdn/OKTBWKNG.js +2 -0
  69. package/dist/cdn/{23EQTPO3.js → OKVLGJAG.js} +1 -1
  70. package/dist/cdn/OWXCOUIQ.js +2 -0
  71. package/dist/cdn/OYNIFMCJ.js +2 -0
  72. package/dist/cdn/{LQ6R5YRN.js → PQ2DPOFM.js} +1 -1
  73. package/dist/cdn/PUFTYLJ2.js +22 -0
  74. package/dist/cdn/PVE7Q43N.js +2 -0
  75. package/dist/cdn/R74ZHFA6.js +2 -0
  76. package/dist/cdn/RLEHNAIA.js +2 -0
  77. package/dist/cdn/{X2ZDYHCG.js → SDWWUWAF.js} +10 -5
  78. package/dist/cdn/ST5FQYT7.js +180 -0
  79. package/dist/cdn/SXHH575T.js +48 -0
  80. package/dist/cdn/T4ECSHM7.js +2 -0
  81. package/dist/cdn/TFT6HK3O.js +208 -0
  82. package/dist/cdn/TPULIO6I.js +34 -0
  83. package/dist/cdn/U3XIDLHO.js +3 -0
  84. package/dist/cdn/{6YMR4QSD.js → UHEYPSOR.js} +1 -1
  85. package/dist/cdn/UZLQALHY.js +2 -0
  86. package/dist/cdn/V6HOUZPZ.js +2 -0
  87. package/dist/cdn/VAXH6RUQ.js +134 -0
  88. package/dist/cdn/VXFQANGJ.js +2 -0
  89. package/dist/cdn/WQGJATNJ.js +2 -0
  90. package/dist/cdn/WSHWQDO2.js +2 -0
  91. package/dist/cdn/WUNCZOGU.js +2 -0
  92. package/dist/cdn/WVPU4QOO.js +2 -0
  93. package/dist/cdn/WXWO5D3W.js +2 -0
  94. package/dist/cdn/XCRR2EEG.js +6 -0
  95. package/dist/cdn/XETNZW4D.js +3 -0
  96. package/dist/cdn/XRE5USHA.js +2 -0
  97. package/dist/cdn/YHQJ66WJ.js +2 -0
  98. package/dist/cdn/ZCEMEUP7.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 +1795 -1598
  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 +265 -240
  116. package/dist/chunks/helpGraph.js +30 -23
  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 +79 -70
  122. package/dist/chunks/navigation_intent_prompt.js +8 -2
  123. package/dist/chunks/orchestrator.js +205 -175
  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 +95 -47
  171. package/dist/utils/index.js +80 -65
  172. package/package.json +12 -11
  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";
2
+ import { Annotation as m } from "@langchain/langgraph/web";
3
+ import u, { z as i } from "zod";
4
+ import { ChatPromptTemplate as D, SystemMessagePromptTemplate as B } from "@langchain/core/prompts";
5
+ import { s as y } from "./index.js";
6
+ import { AIMessage as W, isAIMessage as H, isToolMessage as X } from "@langchain/core/messages";
7
+ import { createAgent as G, summarizationMiddleware as J, modelCallLimitMiddleware as Q } from "langchain";
8
+ import { ChatOpenAI as Y, OpenAIEmbeddings as Z } from "@langchain/openai";
9
+ import F from "@arcgis/core/portal/Portal.js";
10
+ import U 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";
11
14
  const P = {
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 M = 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
+ }, _ = async (e) => {
28
+ const t = se();
29
+ k.size === 0 && (M || (M = (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 U(`${t}/models`)).data.models.forEach((o) => k.set(o.name, o));
32
32
  } catch (n) {
33
- throw v = null, n;
33
+ throw M = null, n;
34
34
  }
35
- })()), await v);
36
- const s = M.get(e);
35
+ })()), await M);
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
+ }, re = async (e = "default") => await _(P[e]), oe = async (e = "default") => await _(E[e]), f = (e, t) => t, j = (e, t) => ({
41
41
  ...e,
42
42
  ...t
43
43
  }), $ = (e = "", t) => {
@@ -49,82 +49,82 @@ const te = () => {
49
49
  return s;
50
50
  if (n === s)
51
51
  return e;
52
- const a = n.split(`
52
+ const r = n.split(`
53
53
 
54
54
  `);
55
- return a[a.length - 1]?.trim() === s ? e : `${e}
55
+ return r[r.length - 1]?.trim() === s ? e : `${e}
56
56
 
57
57
  ${s}`;
58
- }, N = () => ({
58
+ }, O = () => ({
59
59
  userRequest: "",
60
60
  assignedTask: "",
61
61
  messages: [],
62
62
  priorSteps: [],
63
63
  sharedState: {}
64
- }), ae = () => ({
65
- agentExecutionContext: d({
64
+ }), ie = () => ({
65
+ agentExecutionContext: m({
66
66
  reducer: j,
67
- default: N
67
+ default: O
68
68
  }),
69
- outputMessage: d({
69
+ outputMessage: m({
70
70
  reducer: $,
71
71
  default: () => ""
72
72
  }),
73
- summary: d({
74
- reducer: h,
73
+ summary: m({
74
+ reducer: f,
75
75
  default: () => ""
76
76
  }),
77
- status: d({
78
- reducer: h
77
+ status: m({
78
+ reducer: f
79
79
  })
80
- }), De = () => ({
81
- ...ae(),
82
- sharedStatePatch: d({
83
- reducer: h
80
+ }), Le = () => ({
81
+ ...ie(),
82
+ sharedStatePatch: m({
83
+ reducer: f
84
84
  })
85
- }), Fe = d.Root({
86
- agentExecutionContext: d({
87
- default: N,
85
+ }), ze = m.Root({
86
+ agentExecutionContext: m({
87
+ default: O,
88
88
  reducer: j
89
89
  }),
90
- currentIntent: d({
90
+ currentIntent: m({
91
91
  default: () => "none",
92
- reducer: h
92
+ reducer: f
93
93
  }),
94
- lastExecutedAgent: d({
94
+ routing: m({
95
+ default: () => ({ mode: "auto" }),
96
+ reducer: f
97
+ }),
98
+ lastExecutedAgent: m({
95
99
  default: () => "",
96
- reducer: h
100
+ reducer: f
97
101
  }),
98
- requiresFollowUp: d({
102
+ requiresFollowUp: m({
99
103
  default: () => !0,
100
- reducer: h
104
+ reducer: f
101
105
  }),
102
- stepCount: d({
106
+ stepCount: m({
103
107
  default: () => 0,
104
108
  reducer: (e, t) => t ?? e + 1
105
109
  }),
106
- finalOutputMessage: d({
110
+ finalOutputMessage: m({
107
111
  default: () => "",
108
112
  reducer: $
109
113
  })
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) => {
114
+ }), ae = (e) => {
115
115
  if (!e || typeof e != "object" || !("services" in e))
116
116
  return !1;
117
117
  const t = e.services;
118
118
  return !!t && typeof t == "object" && "agentRegistry" in t;
119
- }, oe = (e) => {
119
+ }, ce = (e) => {
120
120
  const t = e?.configurable;
121
- return ie(t) ? t : void 0;
122
- }, re = (e, t, s) => {
121
+ return ae(t) ? t : void 0;
122
+ }, le = (e, t, s) => {
123
123
  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." : ""))));
124
+ return n ? typeof n == "function" ? n() : Promise.resolve(n) : new Promise((r, o) => {
125
+ (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
126
  });
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) => {
127
+ }, 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
128
  const { agent: t, messages: s, config: n } = e;
129
129
  return { structuredResponse: (await t.invoke(
130
130
  {
@@ -132,125 +132,152 @@ ${s}`;
132
132
  },
133
133
  n
134
134
  )).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({
135
+ }, pe = (e) => typeof e == "string" && e.length > 0 ? e : void 0, me = () => te(), ue = (e) => typeof e != "string" || e.trim().length === 0 ? "MapsSDK" : `MapsSDK - ${e.trim()}`, ge = (e) => {
136
+ const t = e?.configurable;
137
+ return {
138
+ conversationId: pe(t?.thread_id),
139
+ abortSignal: e?.signal,
140
+ requestId: me(),
141
+ requestSource: ue(ne.applicationName)
142
+ };
143
+ }, fe = (e) => {
144
+ if (e == null || typeof e == "string" || e instanceof FormData || e instanceof HTMLFormElement)
145
+ return e;
146
+ if (e instanceof URLSearchParams)
147
+ return e.toString();
148
+ throw new TypeError(`Unsupported request body type: ${Object.prototype.toString.call(e)}`);
149
+ }, N = async ({ config: e }) => {
150
+ const t = F.getDefault(), n = (await ee.getCredential(`${t.url}/sharing`))?.token;
151
+ return async (r, o) => {
152
+ const { conversationId: a, abortSignal: c, requestId: l, requestSource: d } = ge(e), p = new Headers(o?.headers);
153
+ for (const x of [...p.keys()]) {
154
+ const g = x.toLowerCase();
155
+ (g === "authorization" || g === "api-key" || g.startsWith("x-stainless-")) && p.delete(x);
156
+ }
157
+ n && n.length > 0 && p.set("X-Esri-Authorization", `Bearer ${n}`), t.isPortal || (d && d.length > 0 && p.set("X-Esri-Request-Source", d), a && a.length > 0 && p.set("X-Esri-Conversation-Id", a), l.length > 0 && p.set("X-Esri-Request-Id", l));
158
+ const w = c && o?.signal ? AbortSignal.any([c, o.signal]) : o?.signal ?? c;
159
+ return (await U(r instanceof Request ? r.url : r.toString(), {
160
+ body: fe(o?.body),
161
+ headers: Object.fromEntries(p),
162
+ responseType: "native",
163
+ signal: w
164
+ })).data;
165
+ };
166
+ }, v = async (e = {}) => {
167
+ const { modelTier: t = "default", temperature: s = 0, config: n } = e, r = P[t], o = await re(t);
168
+ return new Y({
147
169
  modelName: r,
148
170
  apiKey: "dummy-key",
149
171
  // 5-mini does not support temperature parameter
150
172
  ...t !== "default" && { temperature: s },
151
173
  configuration: {
152
- baseURL: c,
153
- fetch: O(i.token, n)
174
+ baseURL: o,
175
+ fetch: await N({ config: n })
154
176
  }
155
177
  });
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,
178
+ }, Ve = async (e = {}) => {
179
+ const { tier: t = "default", config: s } = e, n = E[t], r = await oe(t);
180
+ return new Z({
181
+ modelName: n,
160
182
  apiKey: "dummy-key",
161
183
  configuration: {
162
- baseURL: i,
163
- fetch: O(n.token, t)
184
+ baseURL: r,
185
+ fetch: await N({ config: s })
164
186
  },
165
187
  batchSize: 2048,
166
188
  maxConcurrency: 10
167
189
  });
168
- }, le = o.object({
169
- id: o.string().min(1),
170
- name: o.string().min(1),
171
- description: o.string().min(1)
190
+ }, he = i.object({
191
+ id: i.string().min(1),
192
+ name: i.string().min(1),
193
+ description: i.string().min(1)
172
194
  });
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({
195
+ i.array(he);
196
+ const C = (e) => JSON.stringify(e, null, 2), ye = (e) => {
197
+ const t = e.map((n) => n.id), s = i.enum(t);
198
+ return i.object({
177
199
  intent: s.nullable(),
178
- assignedTask: o.string().nullable(),
179
- requiresFollowUp: o.boolean()
200
+ assignedTask: i.string().nullable(),
201
+ requiresFollowUp: i.boolean()
180
202
  });
181
- }, Pe = async (e, t) => {
182
- const s = oe(t);
183
- if (s.abortSignal?.aborted)
184
- return await f({ text: "Run cancelled; skipping intent routing" }, t), {
203
+ }, Ke = async (e, t) => {
204
+ const s = ce(t);
205
+ if (t?.signal?.aborted)
206
+ return await y({ text: "Run cancelled; skipping intent routing" }, t), {
185
207
  ...e,
186
208
  currentIntent: "none",
187
209
  finalOutputMessage: "Operation cancelled.",
188
210
  requiresFollowUp: !1
189
211
  };
190
212
  try {
191
- await f({ text: "Asking LLM to route to an agent" }, t);
192
- const a = s.services.agentRegistry?.list() ?? [], i = a.map(({ agent: g }) => ({
193
- id: g.id,
194
- name: g.name,
195
- description: g.description
213
+ await y({ text: "Asking LLM to route to an agent" }, t);
214
+ const r = s.services.agentRegistry?.list() ?? [], o = r.map(({ agent: h }) => ({
215
+ id: h.id,
216
+ name: h.name,
217
+ description: h.description
196
218
  }));
197
- if (!i.length)
198
- return await f({ text: "No agents registered; skipping intent detection" }, t), {
219
+ if (!o.length)
220
+ return await y({ text: "No agents registered; skipping intent detection" }, t), {
199
221
  ...e,
200
222
  currentIntent: "none",
201
223
  finalOutputMessage: "No agents registered; skipping intent detection."
202
224
  };
203
- const r = await I("intent_prompt"), c = R(i), l = de(i), m = {
225
+ const a = await R("intent_prompt"), c = C(o), l = ye(o), d = {
204
226
  registeredAgents: c,
205
- priorSteps: R(e.agentExecutionContext.priorSteps),
227
+ priorSteps: C(e.agentExecutionContext.priorSteps),
206
228
  userRequest: e.agentExecutionContext.userRequest
207
- }, T = await F.fromTemplate(r).format(m), C = G({
208
- model: await b({ modelTier: "fast", abortSignal: s.abortSignal }),
229
+ }, w = await D.fromTemplate(a).format(d), S = G({
230
+ model: await v({
231
+ modelTier: "fast",
232
+ config: t
233
+ }),
209
234
  tools: [],
210
- systemPrompt: T,
211
- checkpointer: !0,
235
+ systemPrompt: w,
212
236
  responseFormat: l,
213
237
  middleware: [
214
238
  // Preserve recent conversation context while summarizing older messages
215
239
  // to control token usage without losing important intent signals.
216
240
  // 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 }),
241
+ J({
242
+ model: await v({
243
+ modelTier: "fast",
244
+ config: t
245
+ }),
219
246
  trigger: { tokens: 4e3 },
220
247
  keep: { messages: 6 }
221
248
  }),
222
249
  // Enforce no loop/retry.
223
250
  // 1 usual LLM call and 1 optional summarization call.
224
- Y({ runLimit: 2 })
251
+ Q({ runLimit: 2 })
225
252
  ]
226
- }), { structuredResponse: L } = await ce({
227
- agent: C,
253
+ }), { structuredResponse: x } = await de({
254
+ agent: S,
228
255
  messages: e.agentExecutionContext.messages,
229
256
  config: t
230
- }), y = l.parse(
231
- L ?? { intent: null, assignedTask: null, requiresFollowUp: !1 }
232
- ), x = y.intent ?? "none", K = {
257
+ }), g = l.parse(
258
+ x ?? { intent: null, assignedTask: null, requiresFollowUp: !1 }
259
+ ), T = g.intent ?? "none", V = {
233
260
  ...e,
234
- currentIntent: x,
235
- requiresFollowUp: y.requiresFollowUp,
261
+ currentIntent: T,
262
+ requiresFollowUp: g.requiresFollowUp,
236
263
  agentExecutionContext: {
237
264
  ...e.agentExecutionContext,
238
- assignedTask: y.assignedTask ?? ""
265
+ assignedTask: g.assignedTask ?? ""
239
266
  }
240
267
  };
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(", ")}.
268
+ if (T === "none") {
269
+ const h = `I could not find an agent that can handle that request. I have access to the following agents: ${r.map(({ agent: K }) => K.name).join(", ")}.
243
270
 
244
271
  Please ask a question that can be answered by one of these agents.`;
245
- return await f({ text: "LLM did not identify a clear intent." }, t), {
272
+ return await y({ text: "LLM did not identify a clear intent." }, t), {
246
273
  ...e,
247
- currentIntent: x,
274
+ currentIntent: T,
248
275
  requiresFollowUp: !1,
249
- finalOutputMessage: g,
276
+ finalOutputMessage: h,
250
277
  agentExecutionContext: {
251
278
  ...e.agentExecutionContext,
252
279
  assignedTask: "",
253
- messages: [...e.agentExecutionContext.messages, new H(g)],
280
+ messages: [...e.agentExecutionContext.messages, new W(h)],
254
281
  priorSteps: [
255
282
  ...e.agentExecutionContext.priorSteps ?? [],
256
283
  {
@@ -263,179 +290,177 @@ Please ask a question that can be answered by one of these agents.`;
263
290
  }
264
291
  };
265
292
  }
266
- return await f(
293
+ return await y(
267
294
  {
268
- text: `Agent picked: ${x}
269
- Task Assigned: ${y.assignedTask ?? ""}
270
- Requires Follow-Up: ${y.requiresFollowUp}`
295
+ text: `Agent picked: ${T}
296
+ Task Assigned: ${g.assignedTask ?? ""}
297
+ Requires Follow-Up: ${g.requiresFollowUp}`
271
298
  },
272
299
  t
273
- ), K;
300
+ ), V;
274
301
  } catch (n) {
275
- throw await f({ text: "Error during intent detection" }, t), new Error(`Error during intent detection: ${n instanceof Error ? n.message : String(n)}`);
302
+ throw await y({ text: "Error during intent detection" }, t), new Error(`Error during intent detection: ${n instanceof Error ? n.message : String(n)}`);
276
303
  }
277
- }, pe = "0.1", w = 1536, me = "openai", ue = A.default, ge = `Name: {name}
304
+ }, we = "0.1", b = 1536, be = "openai", ve = E.default, xe = `Name: {name}
278
305
  Title: {title}
279
- Description: {description}`, fe = `Name: {name}
306
+ Description: {description}`, Te = `Name: {name}
280
307
  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)
308
+ Description: {description}`, Be = i.object({
309
+ schemaVersion: i.literal(we),
310
+ modified: i.number().int().nonnegative(),
311
+ embeddings: i.object({
312
+ modelProvider: i.literal(be),
313
+ model: i.literal(ve),
314
+ dimensions: i.literal(b),
315
+ templates: i.object({
316
+ layer: i.string().default(xe),
317
+ field: i.string().default(Te)
291
318
  })
292
319
  }),
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`
320
+ layers: i.array(
321
+ i.object({
322
+ id: i.string().min(1),
323
+ name: i.string().min(1),
324
+ title: i.string().catch(""),
325
+ description: i.string().catch(""),
326
+ vector: i.array(i.number()).length(b, {
327
+ message: `Layer vector must be exactly ${b} dimensions`
301
328
  }),
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`
329
+ fields: i.array(
330
+ i.object({
331
+ name: i.string().min(1),
332
+ alias: i.string().catch(""),
333
+ description: i.string().catch(""),
334
+ vector: i.array(i.number()).length(b, {
335
+ message: `Field vector must be exactly ${b} dimensions`
309
336
  })
310
337
  })
311
338
  )
312
339
  })
313
340
  ).default([])
314
- }), he = (e) => {
341
+ }), Me = (e) => {
315
342
  const t = /* @__PURE__ */ new Set();
316
343
  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);
344
+ if (H(n)) {
345
+ const r = n;
346
+ r.tool_calls && r.tool_calls.length > 0 && r.tool_calls.forEach((o) => {
347
+ o.id && t.add(o.id);
321
348
  });
322
349
  }
323
350
  return e.filter((n) => {
324
351
  if (X(n)) {
325
- const a = n;
326
- return t.has(a.tool_call_id);
352
+ const r = n;
353
+ return t.has(r.tool_call_id);
327
354
  }
328
355
  return !0;
329
356
  });
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({
357
+ }, A = (e, t) => {
358
+ const s = B.fromTemplate(e);
359
+ return D.fromMessages([s, ...t]);
360
+ }, Se = async (e) => {
361
+ const { promptText: t, modelTier: s, temperature: n, messages: r, config: o } = e, a = A(t, r ?? []), c = await v({ modelTier: s, temperature: n, config: o });
362
+ return a.pipe(c);
363
+ }, We = async (e) => {
364
+ const { promptText: t, modelTier: s = "default", temperature: n = 0, messages: r, inputVariables: o, config: a } = e, l = await (await Se({
338
365
  promptText: t,
339
366
  modelTier: s,
340
367
  temperature: n,
341
- messages: a,
342
- abortSignal: r
343
- })).invoke(i ?? {});
368
+ messages: r,
369
+ config: a
370
+ })).invoke(o ?? {}, a);
344
371
  if (typeof l == "string")
345
372
  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) => {
373
+ const d = l.content;
374
+ return typeof d == "string" ? d : JSON.stringify(d);
375
+ }, L = async (e) => {
376
+ const { promptText: t, modelTier: s = "default", temperature: n = 0, messages: r, inputVariables: o, schema: a, config: c } = e, l = A(t, r ?? []), p = (await v({ modelTier: s, temperature: n, config: c })).withStructuredOutput(a);
377
+ return await l.pipe(p).invoke(o ?? {}, c);
378
+ }, He = async (e) => {
379
+ const { promptText: t, modelTier: s = "default", temperature: n = 0, messages: r, inputVariables: o, tools: a, config: c } = e, l = a.length > 0 ? Me(r ?? []) : r ?? [], d = A(t, l), p = await v({ modelTier: s, temperature: n, config: c });
380
+ return await d.pipe(p.bindTools(a)).invoke(o ?? {}, c);
381
+ }, ke = u.object({
382
+ name: u.string(),
383
+ description: u.string(),
384
+ valueType: u.string(),
385
+ alias: u.string()
386
+ }), Ie = u.object({
387
+ fields: u.array(ke)
388
+ }), z = (e, t) => e.getFieldAlias(t) ?? void 0, I = (e, t) => z(e, t.name) ?? t.alias ?? "", Ee = (e, t) => {
362
389
  const s = z(e, t.name);
363
390
  return !!(s && s !== (t.alias ?? ""));
364
391
  };
365
- function D(e, t) {
392
+ function q(e, t) {
366
393
  const s = /* @__PURE__ */ new Map();
367
394
  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 = {
395
+ const r = t.fields.find((l) => l.name === n.name), o = I(e, n), a = Ee(e, n), c = {
369
396
  name: n.name,
370
397
  type: n.type,
371
- alias: r ? i : a?.alias ?? i,
372
- description: a?.description ?? n.description ?? "",
373
- valueType: a?.valueType ?? n.valueType ?? "",
398
+ alias: a ? o : r?.alias ?? o,
399
+ description: r?.description ?? n.description ?? "",
400
+ valueType: r?.valueType ?? n.valueType ?? "",
374
401
  domain: e.getFieldDomain(n.name) ?? void 0
375
402
  };
376
403
  s.set(n.name, c);
377
404
  }
378
405
  return s;
379
406
  }
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(", ");
407
+ const Xe = async (e) => {
408
+ const s = await R("field_descriptions_prompt"), n = e.fields.filter((a) => !(I(e, a) && a.description)).map((a) => {
409
+ const { name: c, type: l, description: d } = a, p = I(e, a);
410
+ return [`Name: ${c}`, `Type: ${l}`, `Alias: ${p}`, `Description: ${d ?? "N/A"}`].join(", ");
384
411
  }).join(`
385
412
  `);
386
413
  if (n.length === 0)
387
- return D(e, { fields: [] });
388
- const a = {
414
+ return q(e, { fields: [] });
415
+ const r = {
389
416
  existingItemTitle: e.portalItem?.title,
390
417
  existingItemDescription: e.portalItem?.description,
391
418
  existingLayerTitle: e.title,
392
419
  existingLayerDescription: e.portalItem?.description,
393
420
  fieldInformation: n
394
- }, i = await V({
421
+ }, o = await L({
395
422
  promptText: s,
396
- schema: be,
397
- inputVariables: a
423
+ schema: Ie,
424
+ inputVariables: r
398
425
  });
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),
426
+ return q(e, o);
427
+ }, Re = u.object({
428
+ title: u.string(),
429
+ description: u.string(),
430
+ name: u.string().nullable()
431
+ }), Ge = async (e, t) => {
432
+ const n = await R("layer_descriptions_prompt"), r = Array.from(t.values()), o = {
433
+ fieldInformation: JSON.stringify(r, null, 2),
407
434
  existingLayerTitle: e.title,
408
435
  existingLayerDescription: e.portalItem?.description,
409
436
  existingLayerSnippet: e.portalItem?.snippet,
410
437
  layerGeometryType: e.geometryType
411
438
  };
412
- return { ...await V({
439
+ return { ...await L({
413
440
  promptText: n,
414
- schema: ve,
415
- inputVariables: i
441
+ schema: Re,
442
+ inputVariables: o
416
443
  }), name: e.title ?? null };
417
444
  };
418
445
  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
446
+ ze as D,
447
+ Be as W,
448
+ Ge as a,
449
+ be as b,
450
+ v as c,
451
+ b as d,
452
+ We as e,
453
+ Te as f,
454
+ Xe as g,
455
+ He as h,
456
+ L as i,
457
+ ie as j,
458
+ Le as k,
459
+ xe as l,
460
+ ve as m,
461
+ oe as n,
462
+ ce as o,
463
+ Ke as p,
464
+ Ve as q,
465
+ we as s
441
466
  };