@arcgis/ai-components 5.2.0-next.3 → 5.2.0-next.30

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 (207) 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 +23 -22
  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/27NEUQN3.js +2 -0
  18. package/dist/cdn/2NMR43NW.js +2 -0
  19. package/dist/cdn/3AXQTBIA.js +134 -0
  20. package/dist/cdn/434TAA3J.js +2 -0
  21. package/dist/cdn/4I4MCV7V.js +71 -0
  22. package/dist/cdn/4RZPOYZ7.js +9 -0
  23. package/dist/cdn/5SBLS4NW.js +2 -0
  24. package/dist/cdn/{AMP6IALT.js → 5W7S2RS4.js} +1 -1
  25. package/dist/cdn/6LZ6GOHF.js +56 -0
  26. package/dist/cdn/7IFCBXV7.js +2 -0
  27. package/dist/cdn/ADYIXCSG.js +2 -0
  28. package/dist/cdn/AFLQZIKS.js +180 -0
  29. package/dist/cdn/AMVOJNWN.js +2 -0
  30. package/dist/cdn/C7E7MJSR.js +2 -0
  31. package/dist/cdn/CAECQD75.js +2 -0
  32. package/dist/cdn/CIW3QMKV.js +2 -0
  33. package/dist/cdn/CJIV4KJZ.js +179 -0
  34. package/dist/cdn/CVHJMR5X.js +2 -0
  35. package/dist/cdn/DEAYZ3MK.js +2 -0
  36. package/dist/cdn/{H7422XUG.js → E2HENO3T.js} +1 -1
  37. package/dist/cdn/E7TMP4YV.js +3 -0
  38. package/dist/cdn/EBRNMPPO.js +48 -0
  39. package/dist/cdn/FWU6DFIB.js +2 -0
  40. package/dist/cdn/HBYZSLEZ.js +22 -0
  41. package/dist/cdn/HOCTVCHH.js +2 -0
  42. package/dist/cdn/{4HU7735A.js → HXOSLGWU.js} +6 -4
  43. package/dist/cdn/I64KIZG3.js +2 -0
  44. package/dist/cdn/IB4WTK74.js +2 -0
  45. package/dist/cdn/IC5P5NYY.js +2 -0
  46. package/dist/cdn/IGZWQJW7.js +3 -0
  47. package/dist/cdn/IKEF7ZHH.js +181 -0
  48. package/dist/cdn/IXAKT6L3.js +2 -0
  49. package/dist/cdn/JEIMRNYM.js +2 -0
  50. package/dist/cdn/JN744CAW.js +2 -0
  51. package/dist/cdn/KRE4U7V7.js +2 -0
  52. package/dist/cdn/{NE7E52YR.js → KTK4HNL2.js} +8 -2
  53. package/dist/cdn/L77BTGXY.js +2 -0
  54. package/dist/cdn/LEPJUN3X.js +22 -0
  55. package/dist/cdn/LODKJRS4.js +2 -0
  56. package/dist/cdn/M3SWPT3M.js +2 -0
  57. package/dist/cdn/MAV3DW27.js +4 -0
  58. package/dist/cdn/NOJYPREL.js +3 -0
  59. package/dist/cdn/NXKKG5TK.js +2 -0
  60. package/dist/cdn/O3F47IO5.js +2 -0
  61. package/dist/cdn/O7TGCM5P.js +6 -0
  62. package/dist/cdn/PBTINZTK.js +65 -0
  63. package/dist/cdn/PKHQW7QU.js +18 -0
  64. package/dist/cdn/PSWI3MFB.js +2 -0
  65. package/dist/cdn/Q73PK7Q7.js +2 -0
  66. package/dist/cdn/Q7TL5Q5N.js +2 -0
  67. package/dist/cdn/QSA4T3BU.js +2 -0
  68. package/dist/cdn/RMLXVQZ5.js +2 -0
  69. package/dist/cdn/RX45PCYB.js +9 -0
  70. package/dist/cdn/S27EJSLC.js +14 -0
  71. package/dist/cdn/SMADRJ67.js +2 -0
  72. package/dist/cdn/{ZLXN7NMF.js → T537PKP4.js} +9 -7
  73. package/dist/cdn/{X2ZDYHCG.js → TNMXWUXU.js} +9 -4
  74. package/dist/cdn/TSEQVE2H.js +36 -0
  75. package/dist/cdn/VKU4WAQV.js +2 -0
  76. package/dist/cdn/W2IHPJ54.js +34 -0
  77. package/dist/cdn/W2JAKE2M.js +2 -0
  78. package/dist/cdn/WAVKMZA6.js +2 -0
  79. package/dist/cdn/WDE3HN7K.js +2 -0
  80. package/dist/cdn/WH6QQK6N.js +2 -0
  81. package/dist/cdn/WNS5ZUF5.js +2 -0
  82. package/dist/cdn/{FL4W4VYN.js → X7GE26KU.js} +16 -0
  83. package/dist/cdn/XVQJBUMY.js +2 -0
  84. package/dist/cdn/YJ3QQXF6.js +2 -0
  85. package/dist/cdn/YRBANNQ5.js +2 -0
  86. package/dist/cdn/YYY7HKYX.js +2 -0
  87. package/dist/cdn/ZEYIBYSF.js +66 -0
  88. package/dist/cdn/ZMSJQB65.js +99 -0
  89. package/dist/cdn/ZOSUDIJH.js +2 -0
  90. package/dist/cdn/ZPLFFLPF.js +2 -0
  91. package/dist/cdn/agent-utils/index.js +2 -0
  92. package/dist/cdn/agent-utils/middlewares/humanInTheLoop.js +3 -0
  93. package/dist/cdn/agent-utils/middlewares/middleware.js +2 -0
  94. package/dist/cdn/agent-utils/middlewares/trace.js +2 -0
  95. package/dist/cdn/index.js +1 -1
  96. package/dist/cdn/main.css +1 -1
  97. package/dist/chunks/adapter.js +1794 -1597
  98. package/dist/chunks/arcgisKnowledgeGraph.js +126 -71
  99. package/dist/chunks/arcgis_knowledge_current_lc_context.js +19 -2
  100. package/dist/chunks/arcgis_knowledge_current_map_context.js +31 -2
  101. package/dist/chunks/arcgis_knowledge_cypher_query_prompt.js +102 -0
  102. package/dist/chunks/arcgis_knowledge_summarize_result_prompt.js +116 -27
  103. package/dist/chunks/converterUtils.js +39 -32
  104. package/dist/chunks/dataExplorationGraph.js +139 -113
  105. package/dist/chunks/data_explore_query_prompt.js +9 -4
  106. package/dist/chunks/generateLayerDescriptions.js +231 -191
  107. package/dist/chunks/helpGraph.js +17 -13
  108. package/dist/chunks/help_prompt.js +34 -17
  109. package/dist/chunks/index.js +11 -0
  110. package/dist/chunks/intent_prompt.js +16 -0
  111. package/dist/chunks/layerStylingGraph.js +24 -20
  112. package/dist/chunks/navigationGraph.js +33 -28
  113. package/dist/chunks/navigation_intent_prompt.js +8 -2
  114. package/dist/chunks/orchestrator.js +267 -226
  115. package/dist/chunks/slottableRequestUtils.js +3 -7
  116. package/dist/chunks/state.js +1 -1
  117. package/dist/chunks/summarize_query_response_prompt.js +9 -7
  118. package/dist/chunks/toolCallResponse.js +12 -9
  119. package/dist/chunks/utils2.js +8 -8
  120. package/dist/components/arcgis-assistant/customElement.d.ts +27 -0
  121. package/dist/components/arcgis-assistant/customElement.js +385 -152
  122. package/dist/components/arcgis-assistant/index.js +2 -3
  123. package/dist/components/arcgis-assistant/types.d.ts +14 -1
  124. package/dist/components/arcgis-assistant-agent/customElement.js +5 -1
  125. package/dist/components/arcgis-assistant-chat/customElement.d.ts +8 -2
  126. package/dist/components/arcgis-assistant-chat/customElement.js +23 -18
  127. package/dist/components/arcgis-assistant-chat-entry/customElement.d.ts +4 -1
  128. package/dist/components/arcgis-assistant-chat-entry/customElement.js +25 -18
  129. package/dist/components/arcgis-assistant-data-exploration-agent/customElement.js +11 -5
  130. package/dist/components/arcgis-assistant-help-agent/customElement.js +8 -2
  131. package/dist/components/arcgis-assistant-interrupt/customElement.d.ts +4 -1
  132. package/dist/components/arcgis-assistant-interrupt/customElement.js +12 -8
  133. package/dist/components/arcgis-assistant-interrupt-preview/customElement.js +20 -0
  134. package/dist/components/arcgis-assistant-interrupt-preview/index.js +2 -0
  135. package/dist/components/arcgis-assistant-knowledge-agent/customElement.d.ts +7 -7
  136. package/dist/components/arcgis-assistant-knowledge-agent/customElement.js +17 -11
  137. package/dist/components/arcgis-assistant-layer-styling-agent/customElement.js +10 -4
  138. package/dist/components/arcgis-assistant-message/customElement.d.ts +23 -0
  139. package/dist/components/arcgis-assistant-message/customElement.js +28 -26
  140. package/dist/components/arcgis-assistant-message/index.d.ts +1 -0
  141. package/dist/components/arcgis-assistant-message/index.js +2 -0
  142. package/dist/components/arcgis-assistant-message-block/customElement.d.ts +1 -1
  143. package/dist/components/arcgis-assistant-message-block/customElement.js +18 -11
  144. package/dist/components/arcgis-assistant-message-block/index.js +1 -0
  145. package/dist/components/arcgis-assistant-message-feedback/customElement.d.ts +4 -1
  146. package/dist/components/arcgis-assistant-message-footer/customElement.d.ts +4 -1
  147. package/dist/components/arcgis-assistant-message-loading/customElement.d.ts +8 -1
  148. package/dist/components/arcgis-assistant-message-loading/customElement.js +8 -8
  149. package/dist/components/arcgis-assistant-message-loading/index.js +1 -0
  150. package/dist/components/arcgis-assistant-message-log/customElement.d.ts +4 -1
  151. package/dist/components/arcgis-assistant-message-read-aloud/customElement.d.ts +4 -1
  152. package/dist/components/arcgis-assistant-message-text/customElement.d.ts +5 -1
  153. package/dist/components/arcgis-assistant-message-text/customElement.js +12 -12
  154. package/dist/components/arcgis-assistant-navigation-agent/customElement.js +11 -5
  155. package/dist/components/arcgis-assistant-speech-input/customElement.d.ts +6 -1
  156. package/dist/components/arcgis-assistant-suggested-prompts/customElement.d.ts +4 -1
  157. package/dist/components/arcgis-assistant-suggested-prompts/customElement.js +8 -8
  158. package/dist/components/arcgis-assistant-user-message/customElement.d.ts +4 -1
  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/index.d.ts +4 -0
  165. package/dist/loader.js +7 -6
  166. package/dist/types/lumina.d.ts +11 -5
  167. package/dist/types/preact.d.ts +12 -5
  168. package/dist/types/react.d.ts +13 -5
  169. package/dist/types/stencil.d.ts +11 -5
  170. package/dist/utils/index.d.ts +85 -42
  171. package/dist/utils/index.js +54 -49
  172. package/package.json +8 -7
  173. package/dist/cdn/2AXF774U.js +0 -2
  174. package/dist/cdn/3PKJWIC3.js +0 -2
  175. package/dist/cdn/462JBSEV.js +0 -422
  176. package/dist/cdn/5QAHYX7Y.js +0 -5
  177. package/dist/cdn/7BCR6TUO.js +0 -2
  178. package/dist/cdn/7GH7VSB2.js +0 -2
  179. package/dist/cdn/7PLV4QH6.js +0 -2
  180. package/dist/cdn/AO7BQHKC.js +0 -2
  181. package/dist/cdn/AXDZBBNL.js +0 -45
  182. package/dist/cdn/DDLZOMUY.js +0 -2
  183. package/dist/cdn/DHOVCT6R.js +0 -2
  184. package/dist/cdn/F2AHA4GB.js +0 -54
  185. package/dist/cdn/FHVXO2WG.js +0 -166
  186. package/dist/cdn/FX5JFRDL.js +0 -2
  187. package/dist/cdn/GSEPHN3A.js +0 -106
  188. package/dist/cdn/HB5A5R2E.js +0 -2
  189. package/dist/cdn/JY6LLOUJ.js +0 -22
  190. package/dist/cdn/KMQ3SP4I.js +0 -5
  191. package/dist/cdn/MDVYQQUG.js +0 -14
  192. package/dist/cdn/MH5RPXHM.js +0 -2
  193. package/dist/cdn/NAUXSHIE.js +0 -72
  194. package/dist/cdn/NVI3I46B.js +0 -2
  195. package/dist/cdn/OAVEHGB6.js +0 -2
  196. package/dist/cdn/OH64RMOR.js +0 -4
  197. package/dist/cdn/ON2V5XI2.js +0 -3
  198. package/dist/cdn/P6OPJQMC.js +0 -3
  199. package/dist/cdn/QR54T33D.js +0 -2
  200. package/dist/cdn/RVOAPUBN.js +0 -2
  201. package/dist/cdn/S6W6HV4T.js +0 -36
  202. package/dist/cdn/SXDLXCIM.js +0 -2
  203. package/dist/cdn/USMDJUFS.js +0 -2
  204. package/dist/cdn/V2P4AIGG.js +0 -2
  205. package/dist/cdn/V5YEZSRY.js +0 -16
  206. package/dist/cdn/Y333DGV6.js +0 -2
  207. package/dist/cdn/YY2SBO3V.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 r } from "zod";
4
- import { ChatPromptTemplate as C, SystemMessagePromptTemplate as K } from "@langchain/core/prompts";
5
- import { dispatchCustomEvent as F } from "@langchain/core/callbacks/dispatch/web";
6
- import { AIMessage as B, isAIMessage as W, isToolMessage as H } from "@langchain/core/messages";
7
- import { createAgent as J, summarizationMiddleware as X, modelCallLimitMiddleware as G } from "langchain";
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
8
  import { ChatOpenAI as Q, OpenAIEmbeddings as Y } from "@langchain/openai";
9
- import U from "@arcgis/core/identity/IdentityManager.js";
10
- import S from "@arcgis/core/portal/Portal.js";
11
- const _ = {
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
- }, k = {
17
+ }, I = {
16
18
  default: "text-embedding-ada-002"
17
- }, M = /* @__PURE__ */ new Map();
18
- let T = null;
19
- const Z = () => {
20
- const t = S.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
- }, P = async (e) => {
25
- const t = Z();
26
- M.size === 0 && (T || (T = (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((o) => M.set(o.name, o));
33
+ (await n.json()).models.forEach((o) => T.set(o.name, o));
32
34
  } catch (n) {
33
- throw T = null, n;
35
+ throw M = null, n;
34
36
  }
35
- })()), await T);
36
- const s = M.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
- }, ee = async (e = "default") => await P(_[e]), te = async (e = "default") => await P(k[e]), u = (e, t) => t, q = (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;
@@ -61,62 +63,66 @@ ${s}`;
61
63
  messages: [],
62
64
  priorSteps: [],
63
65
  sharedState: {}
64
- }), ne = () => ({
65
- agentExecutionContext: d({
66
- reducer: q,
66
+ }), oe = () => ({
67
+ agentExecutionContext: m({
68
+ reducer: P,
67
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: u,
75
+ summary: m({
76
+ reducer: h,
75
77
  default: () => ""
76
78
  }),
77
- status: d({
78
- reducer: u
79
+ status: m({
80
+ reducer: h
79
81
  })
80
- }), Ee = () => ({
81
- ...ne(),
82
- sharedStatePatch: d({
83
- reducer: u
82
+ }), $e = () => ({
83
+ ...oe(),
84
+ sharedStatePatch: m({
85
+ reducer: h
84
86
  })
85
- }), Ie = d.Root({
86
- agentExecutionContext: d({
87
+ }), Ne = m.Root({
88
+ agentExecutionContext: m({
87
89
  default: j,
88
- reducer: q
90
+ reducer: P
89
91
  }),
90
- currentIntent: d({
92
+ currentIntent: m({
91
93
  default: () => "none",
92
- reducer: u
94
+ reducer: h
93
95
  }),
94
- lastExecutedAgent: d({
96
+ lastExecutedAgent: m({
95
97
  default: () => "",
96
- reducer: u
98
+ reducer: h
97
99
  }),
98
- requiresFollowUp: d({
100
+ requiresFollowUp: m({
99
101
  default: () => !0,
100
- reducer: u
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
- }), y = async (e, t) => {
111
- await F("trace_message", e, t);
112
- }, De = async (e, t) => {
113
- await F("graph_ux_suggestion", e, t);
114
- }, se = (e, t, s) => {
112
+ }), re = (e) => {
113
+ if (!e || typeof e != "object" || !("services" in e))
114
+ return !1;
115
+ const t = e.services;
116
+ return !!t && typeof t == "object" && "agentRegistry" in t;
117
+ }, ae = (e) => {
118
+ const t = e?.configurable;
119
+ return re(t) ? t : void 0;
120
+ }, ce = (e, t, s) => {
115
121
  const n = e[t];
116
122
  return n ? typeof n == "function" ? n() : Promise.resolve(n) : new Promise((i, o) => {
117
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." : ""))));
118
124
  });
119
- }, A = async (e) => (await se(/* @__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, ie = 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) => {
120
126
  const { agent: t, messages: s, config: n } = e;
121
127
  return { structuredResponse: (await t.invoke(
122
128
  {
@@ -124,107 +130,141 @@ ${s}`;
124
130
  },
125
131
  n
126
132
  )).structuredResponse };
127
- }, N = (e) => async (t, s) => {
128
- const n = new Headers(s?.headers);
129
- return n.delete("Authorization"), n.delete("api-key"), e && e.length > 0 && (n.set("X-Esri-Authorization", `Bearer ${e}`), n.set("X-Esri-Request-Source", "MapsSDK")), await fetch(t, {
130
- ...s,
131
- headers: n
132
- });
133
- }, x = async (e = "default", t = 0) => {
134
- const s = S.getDefault(), n = await U.getCredential(`${s.url}/sharing`), i = _[e], o = await ee(e);
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);
135
155
  return new Q({
136
156
  modelName: i,
137
157
  apiKey: "dummy-key",
138
158
  // 5-mini does not support temperature parameter
139
- ...e !== "default" && { temperature: t },
159
+ ...t !== "default" && { temperature: s },
140
160
  configuration: {
141
161
  baseURL: o,
142
- fetch: N(n.token)
162
+ fetch: await $({ config: n })
143
163
  }
144
164
  });
145
- }, Re = async (e = "default") => {
146
- const t = S.getDefault(), s = await U.getCredential(`${t.url}/sharing`), n = k[e], i = await te(e);
165
+ }, Oe = async (e = {}) => {
166
+ const { tier: t = "default", config: s } = e, n = I[t], i = await ie(t);
147
167
  return new Y({
148
168
  modelName: n,
149
169
  apiKey: "dummy-key",
150
170
  configuration: {
151
171
  baseURL: i,
152
- fetch: N(s.token)
172
+ fetch: await $({ config: s })
153
173
  },
154
174
  batchSize: 2048,
155
175
  maxConcurrency: 10
156
176
  });
157
- }, re = r.object({
177
+ }, ge = r.object({
158
178
  id: r.string().min(1),
159
179
  name: r.string().min(1),
160
180
  description: r.string().min(1)
161
181
  });
162
- r.array(re);
163
- const D = (e) => JSON.stringify(e, null, 2), oe = (e) => {
182
+ r.array(ge);
183
+ const R = (e) => JSON.stringify(e, null, 2), fe = (e) => {
164
184
  const t = e.map((n) => n.id), s = r.enum(t);
165
185
  return r.object({
166
186
  intent: s.nullable(),
167
187
  assignedTask: r.string().nullable(),
168
188
  requiresFollowUp: r.boolean()
169
189
  });
170
- }, Ce = async (e, 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), {
194
+ ...e,
195
+ currentIntent: "none",
196
+ finalOutputMessage: "Operation cancelled.",
197
+ requiresFollowUp: !1
198
+ };
171
199
  try {
172
- await y({ text: "Asking LLM to route to an agent" }, t);
173
- const i = (t?.configurable?.services.agentRegistry?.list() ?? []).map(({ agent: h }) => ({
174
- id: h.id,
175
- name: h.name,
176
- description: h.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
177
205
  }));
178
- if (!i.length)
179
- return await y({ text: "No agents registered; skipping intent detection" }, t), { ...e, currentIntent: "none" };
180
- const o = await A("intent_prompt"), a = D(i), c = oe(i), l = {
181
- registeredAgents: a,
182
- priorSteps: D(e.agentExecutionContext.priorSteps),
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 = {
213
+ registeredAgents: c,
214
+ priorSteps: R(e.agentExecutionContext.priorSteps),
183
215
  userRequest: e.agentExecutionContext.userRequest
184
- }, g = await C.fromTemplate(o).format(l), I = J({
185
- model: await x("fast"),
216
+ }, y = await D.fromTemplate(a).format(p), E = G({
217
+ model: await v({
218
+ modelTier: "fast",
219
+ config: t
220
+ }),
186
221
  tools: [],
187
- systemPrompt: g,
188
- checkpointer: !0,
189
- responseFormat: c,
222
+ systemPrompt: y,
223
+ responseFormat: l,
190
224
  middleware: [
191
225
  // Preserve recent conversation context while summarizing older messages
192
226
  // to control token usage without losing important intent signals.
193
227
  // The trigger and keep parameters can be tuned based on token limits and behavior.
194
- X({
195
- model: await x("fast"),
228
+ H({
229
+ model: await v({
230
+ modelTier: "fast",
231
+ config: t
232
+ }),
196
233
  trigger: { tokens: 4e3 },
197
234
  keep: { messages: 6 }
198
235
  }),
199
236
  // Enforce no loop/retry.
200
237
  // 1 usual LLM call and 1 optional summarization call.
201
- G({ runLimit: 2 })
238
+ J({ runLimit: 2 })
202
239
  ]
203
- }), { structuredResponse: z } = await ie({
204
- agent: I,
240
+ }), { structuredResponse: V } = await le({
241
+ agent: E,
205
242
  messages: e.agentExecutionContext.messages,
206
243
  config: t
207
- }), f = c.parse(
208
- z ?? { intent: null, assignedTask: null, requiresFollowUp: !1 }
209
- ), v = f.intent ?? "none", L = {
244
+ }), w = l.parse(
245
+ V ?? { intent: null, assignedTask: null, requiresFollowUp: !1 }
246
+ ), x = w.intent ?? "none", z = {
210
247
  ...e,
211
- currentIntent: v,
212
- requiresFollowUp: f.requiresFollowUp,
248
+ currentIntent: x,
249
+ requiresFollowUp: w.requiresFollowUp,
213
250
  agentExecutionContext: {
214
251
  ...e.agentExecutionContext,
215
- assignedTask: f.assignedTask ?? ""
252
+ assignedTask: w.assignedTask ?? ""
216
253
  }
217
254
  };
218
- if (v === "none") {
219
- const h = "I could not find a matching agent for that request. Please rephrase your question with more detail.";
220
- return await y({ text: "LLM did not identify a clear intent." }, t), {
255
+ if (x === "none") {
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), {
221
260
  ...e,
222
- currentIntent: v,
261
+ currentIntent: x,
223
262
  requiresFollowUp: !1,
263
+ finalOutputMessage: g,
224
264
  agentExecutionContext: {
225
265
  ...e.agentExecutionContext,
226
266
  assignedTask: "",
227
- messages: [...e.agentExecutionContext.messages, new B(h)],
267
+ messages: [...e.agentExecutionContext.messages, new B(g)],
228
268
  priorSteps: [
229
269
  ...e.agentExecutionContext.priorSteps ?? [],
230
270
  {
@@ -237,31 +277,31 @@ const D = (e) => JSON.stringify(e, null, 2), oe = (e) => {
237
277
  }
238
278
  };
239
279
  }
240
- return await y(
280
+ return await f(
241
281
  {
242
- text: `Agent picked: ${v}
243
- Task Assigned: ${f.assignedTask ?? ""}
244
- Requires Follow-Up: ${f.requiresFollowUp}`
282
+ text: `Agent picked: ${x}
283
+ Task Assigned: ${w.assignedTask ?? ""}
284
+ Requires Follow-Up: ${w.requiresFollowUp}`
245
285
  },
246
286
  t
247
- ), L;
248
- } catch (s) {
249
- throw await y({ text: "Error during intent detection" }, t), new Error(`Error during intent detection: ${s instanceof Error ? s.message : String(s)}`);
287
+ ), z;
288
+ } catch (n) {
289
+ throw await f({ text: "Error during intent detection" }, t), new Error(`Error during intent detection: ${n instanceof Error ? n.message : String(n)}`);
250
290
  }
251
- }, ae = "0.1", w = 1536, ce = "openai", le = k.default, de = `Name: {name}
291
+ }, he = "0.1", b = 1536, ye = "openai", we = I.default, be = `Name: {name}
252
292
  Title: {title}
253
- Description: {description}`, pe = `Name: {name}
293
+ Description: {description}`, ve = `Name: {name}
254
294
  Alias: {alias}
255
- Description: {description}`, Fe = r.object({
256
- schemaVersion: r.literal(ae),
295
+ Description: {description}`, ze = r.object({
296
+ schemaVersion: r.literal(he),
257
297
  modified: r.number().int().nonnegative(),
258
298
  embeddings: r.object({
259
- modelProvider: r.literal(ce),
260
- model: r.literal(le),
261
- dimensions: r.literal(w),
299
+ modelProvider: r.literal(ye),
300
+ model: r.literal(we),
301
+ dimensions: r.literal(b),
262
302
  templates: r.object({
263
- layer: r.string().default(de),
264
- field: r.string().default(pe)
303
+ layer: r.string().default(be),
304
+ field: r.string().default(ve)
265
305
  })
266
306
  }),
267
307
  layers: r.array(
@@ -270,22 +310,22 @@ Description: {description}`, Fe = r.object({
270
310
  name: r.string().min(1),
271
311
  title: r.string().catch(""),
272
312
  description: r.string().catch(""),
273
- vector: r.array(r.number()).length(w, {
274
- message: `Layer vector must be exactly ${w} dimensions`
313
+ vector: r.array(r.number()).length(b, {
314
+ message: `Layer vector must be exactly ${b} dimensions`
275
315
  }),
276
316
  fields: r.array(
277
317
  r.object({
278
318
  name: r.string().min(1),
279
319
  alias: r.string().catch(""),
280
320
  description: r.string().catch(""),
281
- vector: r.array(r.number()).length(w, {
282
- message: `Field vector must be exactly ${w} dimensions`
321
+ vector: r.array(r.number()).length(b, {
322
+ message: `Field vector must be exactly ${b} dimensions`
283
323
  })
284
324
  })
285
325
  )
286
326
  })
287
327
  ).default([])
288
- }), me = (e) => {
328
+ }), xe = (e) => {
289
329
  const t = /* @__PURE__ */ new Set();
290
330
  for (const n of e)
291
331
  if (W(n)) {
@@ -295,50 +335,51 @@ Description: {description}`, Fe = r.object({
295
335
  });
296
336
  }
297
337
  return e.filter((n) => {
298
- if (H(n)) {
338
+ if (X(n)) {
299
339
  const i = n;
300
340
  return t.has(i.tool_call_id);
301
341
  }
302
342
  return !0;
303
343
  });
304
- }, E = (e, t) => {
344
+ }, A = (e, t) => {
305
345
  const s = K.fromTemplate(e);
306
- return C.fromMessages([s, ...t]);
307
- }, ue = async (e) => {
308
- const { promptText: t, modelTier: s, temperature: n, messages: i } = e, o = E(t, i ?? []), a = await x(s, n);
309
- return o.pipe(a);
310
- }, Ue = async (e) => {
311
- const { promptText: t, modelTier: s = "default", temperature: n = 0, messages: i, inputVariables: o } = e, c = await (await ue({
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 });
349
+ return a.pipe(c);
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({
312
352
  promptText: t,
313
353
  modelTier: s,
314
354
  temperature: n,
315
- messages: i
316
- })).invoke(o ?? {});
317
- if (typeof c == "string")
318
- return c;
319
- const l = c.content;
320
- return typeof l == "string" ? l : JSON.stringify(l);
321
- }, O = async (e) => {
322
- const { promptText: t, modelTier: s = "default", temperature: n = 0, messages: i, inputVariables: o, schema: a } = e, c = E(t, i ?? []), m = (await x(s, n)).withStructuredOutput(a);
323
- return await c.pipe(m).invoke(o ?? {});
324
- }, _e = async (e) => {
325
- const { promptText: t, modelTier: s = "default", temperature: n = 0, messages: i, inputVariables: o, tools: a } = e, c = a.length > 0 ? me(i ?? []) : i ?? [], l = E(t, c), m = await x(s, n);
326
- return await l.pipe(m.bindTools(a)).invoke(o ?? {});
327
- }, ge = p.object({
328
- name: p.string(),
329
- description: p.string(),
330
- valueType: p.string(),
331
- alias: p.string()
332
- }), fe = p.object({
333
- fields: p.array(ge)
334
- }), V = (e, t) => e.getFieldAlias(t) ?? void 0, b = (e, t) => V(e, t.name) ?? t.alias ?? "", he = (e, t) => {
335
- const s = V(e, t.name);
355
+ messages: i,
356
+ config: a
357
+ })).invoke(o ?? {}, a);
358
+ if (typeof l == "string")
359
+ return l;
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);
336
377
  return !!(s && s !== (t.alias ?? ""));
337
378
  };
338
- function R(e, t) {
379
+ function C(e, t) {
339
380
  const s = /* @__PURE__ */ new Map();
340
381
  for (const n of e.fields) {
341
- const i = t.fields.find((l) => l.name === n.name), o = b(e, n), a = he(e, n), c = {
382
+ const i = t.fields.find((l) => l.name === n.name), o = S(e, n), a = Ie(e, n), c = {
342
383
  name: n.name,
343
384
  type: n.type,
344
385
  alias: a ? o : i?.alias ?? o,
@@ -350,64 +391,63 @@ function R(e, t) {
350
391
  }
351
392
  return s;
352
393
  }
353
- const Pe = async (e) => {
354
- const s = await A("field_descriptions_prompt"), n = e.fields.filter((a) => !(b(e, a) && a.description)).map((a) => {
355
- const { name: c, type: l, description: m } = a, g = b(e, a);
356
- return [`Name: ${c}`, `Type: ${l}`, `Alias: ${g}`, `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(", ");
357
398
  }).join(`
358
399
  `);
359
400
  if (n.length === 0)
360
- return R(e, { fields: [] });
401
+ return C(e, { fields: [] });
361
402
  const i = {
362
403
  existingItemTitle: e.portalItem?.title,
363
404
  existingItemDescription: e.portalItem?.description,
364
405
  existingLayerTitle: e.title,
365
406
  existingLayerDescription: e.portalItem?.description,
366
407
  fieldInformation: n
367
- }, o = await O({
408
+ }, o = await N({
368
409
  promptText: s,
369
- schema: fe,
410
+ schema: Se,
370
411
  inputVariables: i
371
412
  });
372
- return R(e, o);
373
- }, ye = p.object({
374
- title: p.string(),
375
- description: p.string(),
376
- name: p.string().nullable()
377
- }), qe = async (e, t) => {
378
- const n = await A("layer_descriptions_prompt"), i = Array.from(t.values()), o = {
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 = {
379
420
  fieldInformation: JSON.stringify(i, null, 2),
380
421
  existingLayerTitle: e.title,
381
422
  existingLayerDescription: e.portalItem?.description,
382
423
  existingLayerSnippet: e.portalItem?.snippet,
383
424
  layerGeometryType: e.geometryType
384
425
  };
385
- return { ...await O({
426
+ return { ...await N({
386
427
  promptText: n,
387
- schema: ye,
428
+ schema: ke,
388
429
  inputVariables: o
389
430
  }), name: e.title ?? null };
390
431
  };
391
432
  export {
392
- Ie as D,
393
- Fe as W,
394
- qe as a,
395
- ce as b,
396
- x as c,
397
- w as d,
398
- ae as e,
399
- pe as f,
400
- Pe as g,
401
- Ue as h,
402
- O as i,
403
- _e as j,
404
- ne as k,
405
- de as l,
406
- le as m,
407
- Ee as n,
408
- De as o,
409
- te as p,
410
- Ce as q,
411
- Re as r,
412
- y as s
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
413
453
  };