@arcgis/ai-components 5.2.0-next.5 → 5.2.0-next.50

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