@arcgis/ai-components 5.2.0-next.1 → 5.2.0-next.11

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 (162) 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 +22 -22
  4. package/dist/agent-utils/WorkflowAgent.d.ts +2 -2
  5. package/dist/agent-utils/index.d.ts +99 -0
  6. package/dist/agent-utils/index.js +148 -0
  7. package/dist/agent-utils/middlewares/trace.js +25 -33
  8. package/dist/agent-utils/tools/FunctionTool.d.ts +2 -2
  9. package/dist/agent-utils/types.d.ts +30 -1
  10. package/dist/agent-utils/workflows/ConditionalWorkflow.d.ts +2 -2
  11. package/dist/agent-utils/workflows/LoopWorkflow.d.ts +2 -2
  12. package/dist/agent-utils/workflows/ParallelWorkflow.d.ts +2 -2
  13. package/dist/agent-utils/workflows/RouterWorkflow.d.ts +2 -2
  14. package/dist/agent-utils/workflows/SequentialWorkflow.d.ts +2 -2
  15. package/dist/agent-utils/workflows/SwitchWorkflow.d.ts +2 -2
  16. package/dist/cdn/{V2P4AIGG.js → 24QNMEFG.js} +1 -1
  17. package/dist/cdn/{NAUXSHIE.js → 34SG44C3.js} +2 -2
  18. package/dist/cdn/3JGWGKT6.js +2 -0
  19. package/dist/cdn/3NBDVZ2I.js +2 -0
  20. package/dist/cdn/3VOQD2MR.js +2 -0
  21. package/dist/cdn/434TAA3J.js +2 -0
  22. package/dist/cdn/53NTYC4I.js +2 -0
  23. package/dist/cdn/{4HU7735A.js → 5CV7R5IS.js} +6 -4
  24. package/dist/cdn/{AMP6IALT.js → 5W7S2RS4.js} +1 -1
  25. package/dist/cdn/{FL4W4VYN.js → 6ZW7Z36F.js} +16 -0
  26. package/dist/cdn/7CYGX4F4.js +2 -0
  27. package/dist/cdn/{DHOVCT6R.js → AZGGTNA3.js} +1 -1
  28. package/dist/cdn/B7WJFBOZ.js +2 -0
  29. package/dist/cdn/BX7FSMUU.js +56 -0
  30. package/dist/cdn/CHPQM77M.js +181 -0
  31. package/dist/cdn/DHKUXLU3.js +179 -0
  32. package/dist/cdn/DQSEBKOX.js +2 -0
  33. package/dist/cdn/DXVU45KM.js +2 -0
  34. package/dist/cdn/{P6OPJQMC.js → DZ2QWNUA.js} +1 -1
  35. package/dist/cdn/EBISDZ5H.js +2 -0
  36. package/dist/cdn/{MDVYQQUG.js → ERL2CB2Y.js} +5 -5
  37. package/dist/cdn/F6QHMKF5.js +2 -0
  38. package/dist/cdn/FUIGPHBH.js +2 -0
  39. package/dist/cdn/{AO7BQHKC.js → H2CHHGGH.js} +1 -1
  40. package/dist/cdn/{OH64RMOR.js → HWKDNS4K.js} +2 -2
  41. package/dist/cdn/IMQ4TVHF.js +16 -0
  42. package/dist/cdn/IOD3GDA7.js +2 -0
  43. package/dist/cdn/IR7PTESF.js +2 -0
  44. package/dist/cdn/IRZDTYO2.js +2 -0
  45. package/dist/cdn/JIWK6QK6.js +2 -0
  46. package/dist/cdn/{S6W6HV4T.js → JLKGS6Y5.js} +12 -12
  47. package/dist/cdn/K3JCH4XW.js +2 -0
  48. package/dist/cdn/KHXUWZHB.js +2 -0
  49. package/dist/cdn/LIFK3QSD.js +2 -0
  50. package/dist/cdn/NXKKG5TK.js +2 -0
  51. package/dist/cdn/{FX5JFRDL.js → O3EN27N5.js} +1 -1
  52. package/dist/cdn/O3RFFPU3.js +6 -0
  53. package/dist/cdn/P7DG5T3Z.js +9 -0
  54. package/dist/cdn/PBO6FZN6.js +2 -0
  55. package/dist/cdn/Q3ZW4FYA.js +3 -0
  56. package/dist/cdn/Q6LRANX6.js +2 -0
  57. package/dist/cdn/Q7TL5Q5N.js +2 -0
  58. package/dist/cdn/QCSN44H4.js +2 -0
  59. package/dist/cdn/R56X6ZKR.js +161 -0
  60. package/dist/cdn/{HB5A5R2E.js → RUURNLTP.js} +1 -1
  61. package/dist/cdn/T43LEBBE.js +47 -0
  62. package/dist/cdn/{ZLXN7NMF.js → T537PKP4.js} +9 -7
  63. package/dist/cdn/TR4GFL7X.js +2 -0
  64. package/dist/cdn/{3PKJWIC3.js → UPEEHMSY.js} +1 -1
  65. package/dist/cdn/WAIFKDR3.js +2 -0
  66. package/dist/cdn/WNS5ZUF5.js +2 -0
  67. package/dist/cdn/X4XY5HIE.js +2 -0
  68. package/dist/cdn/XOH56EQ2.js +2 -0
  69. package/dist/cdn/XON27U6U.js +2 -0
  70. package/dist/cdn/{H7422XUG.js → YLN2BZ5J.js} +1 -1
  71. package/dist/cdn/{2AXF774U.js → YUKR4AZW.js} +1 -1
  72. package/dist/cdn/{JY6LLOUJ.js → Z2G7MP5L.js} +3 -3
  73. package/dist/cdn/ZEYIBYSF.js +66 -0
  74. package/dist/cdn/agent-utils/index.js +2 -0
  75. package/dist/cdn/agent-utils/middlewares/humanInTheLoop.js +3 -0
  76. package/dist/cdn/agent-utils/middlewares/middleware.js +2 -0
  77. package/dist/cdn/agent-utils/middlewares/trace.js +2 -0
  78. package/dist/cdn/index.js +1 -1
  79. package/dist/cdn/main.css +1 -1
  80. package/dist/chunks/adapter.js +1390 -1323
  81. package/dist/chunks/arcgisKnowledgeGraph.js +109 -72
  82. package/dist/chunks/dataExplorationGraph.js +108 -96
  83. package/dist/chunks/generateLayerDescriptions.js +206 -168
  84. package/dist/chunks/helpGraph.js +16 -13
  85. package/dist/chunks/index.js +11 -0
  86. package/dist/chunks/intent_prompt.js +16 -0
  87. package/dist/chunks/layerStylingGraph.js +23 -20
  88. package/dist/chunks/navigationGraph.js +34 -30
  89. package/dist/chunks/orchestrator.js +241 -201
  90. package/dist/chunks/slottableRequestUtils.js +3 -7
  91. package/dist/chunks/summarize_query_response_prompt.js +9 -7
  92. package/dist/chunks/toolCallResponse.js +5 -3
  93. package/dist/components/arcgis-assistant/customElement.d.ts +15 -0
  94. package/dist/components/arcgis-assistant/customElement.js +228 -127
  95. package/dist/components/arcgis-assistant/index.js +2 -3
  96. package/dist/components/arcgis-assistant/types.d.ts +14 -1
  97. package/dist/components/arcgis-assistant-chat/customElement.d.ts +8 -2
  98. package/dist/components/arcgis-assistant-chat/customElement.js +7 -7
  99. package/dist/components/arcgis-assistant-chat-entry/customElement.d.ts +4 -1
  100. package/dist/components/arcgis-assistant-chat-entry/customElement.js +25 -18
  101. package/dist/components/arcgis-assistant-data-exploration-agent/customElement.js +1 -0
  102. package/dist/components/arcgis-assistant-help-agent/customElement.js +1 -0
  103. package/dist/components/arcgis-assistant-interrupt/customElement.d.ts +4 -1
  104. package/dist/components/arcgis-assistant-interrupt/customElement.js +13 -9
  105. package/dist/components/arcgis-assistant-interrupt-preview/customElement.js +20 -0
  106. package/dist/components/arcgis-assistant-interrupt-preview/index.js +2 -0
  107. package/dist/components/arcgis-assistant-knowledge-agent/customElement.d.ts +7 -7
  108. package/dist/components/arcgis-assistant-knowledge-agent/customElement.js +1 -0
  109. package/dist/components/arcgis-assistant-layer-styling-agent/customElement.js +1 -0
  110. package/dist/components/arcgis-assistant-message/customElement.d.ts +23 -0
  111. package/dist/components/arcgis-assistant-message/customElement.js +28 -26
  112. package/dist/components/arcgis-assistant-message/index.d.ts +1 -0
  113. package/dist/components/arcgis-assistant-message/index.js +2 -0
  114. package/dist/components/arcgis-assistant-message-block/customElement.d.ts +1 -1
  115. package/dist/components/arcgis-assistant-message-block/customElement.js +18 -11
  116. package/dist/components/arcgis-assistant-message-block/index.js +1 -0
  117. package/dist/components/arcgis-assistant-message-feedback/customElement.d.ts +4 -1
  118. package/dist/components/arcgis-assistant-message-footer/customElement.d.ts +4 -1
  119. package/dist/components/arcgis-assistant-message-loading/customElement.d.ts +8 -1
  120. package/dist/components/arcgis-assistant-message-loading/customElement.js +8 -8
  121. package/dist/components/arcgis-assistant-message-loading/index.js +1 -0
  122. package/dist/components/arcgis-assistant-message-log/customElement.d.ts +4 -1
  123. package/dist/components/arcgis-assistant-message-read-aloud/customElement.d.ts +4 -1
  124. package/dist/components/arcgis-assistant-message-text/customElement.d.ts +4 -1
  125. package/dist/components/arcgis-assistant-navigation-agent/customElement.js +1 -0
  126. package/dist/components/arcgis-assistant-speech-input/customElement.d.ts +6 -1
  127. package/dist/components/arcgis-assistant-suggested-prompts/customElement.d.ts +4 -1
  128. package/dist/components/arcgis-assistant-suggested-prompts/customElement.js +8 -8
  129. package/dist/components/arcgis-assistant-user-message/customElement.d.ts +4 -1
  130. package/dist/components/arcgis-assistant-user-message/customElement.js +1 -1
  131. package/dist/docs/api.json +1 -1
  132. package/dist/docs/docs.json +1 -1
  133. package/dist/docs/vscode.html-custom-data.json +1 -1
  134. package/dist/docs/web-types.json +1 -1
  135. package/dist/index.d.ts +4 -0
  136. package/dist/loader.js +6 -5
  137. package/dist/orchestrator/registry/agentRegistry.d.ts +33 -0
  138. package/dist/types/lumina.d.ts +10 -4
  139. package/dist/types/preact.d.ts +11 -4
  140. package/dist/types/react.d.ts +12 -4
  141. package/dist/types/stencil.d.ts +10 -4
  142. package/dist/utils/index.d.ts +87 -43
  143. package/dist/utils/index.js +54 -49
  144. package/package.json +8 -7
  145. package/dist/cdn/462JBSEV.js +0 -422
  146. package/dist/cdn/7BCR6TUO.js +0 -2
  147. package/dist/cdn/7GH7VSB2.js +0 -2
  148. package/dist/cdn/7PLV4QH6.js +0 -2
  149. package/dist/cdn/DDLZOMUY.js +0 -2
  150. package/dist/cdn/FHVXO2WG.js +0 -166
  151. package/dist/cdn/GSEPHN3A.js +0 -106
  152. package/dist/cdn/MH5RPXHM.js +0 -2
  153. package/dist/cdn/NVI3I46B.js +0 -2
  154. package/dist/cdn/OAVEHGB6.js +0 -2
  155. package/dist/cdn/ON2V5XI2.js +0 -3
  156. package/dist/cdn/QR54T33D.js +0 -2
  157. package/dist/cdn/RVOAPUBN.js +0 -2
  158. package/dist/cdn/SXDLXCIM.js +0 -2
  159. package/dist/cdn/USMDJUFS.js +0 -2
  160. package/dist/cdn/V5YEZSRY.js +0 -16
  161. package/dist/cdn/Y333DGV6.js +0 -2
  162. package/dist/cdn/YY2SBO3V.js +0 -2
@@ -1,46 +1,47 @@
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 p } from "@langchain/langgraph/web";
3
+ import m, { 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 H, summarizationMiddleware as J, modelCallLimitMiddleware as G } 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 F from "@arcgis/core/portal/Portal.js";
10
+ import Z from "@arcgis/core/identity/IdentityManager.js";
11
+ import ee from "@arcgis/core/config.js";
12
+ const q = {
12
13
  advanced: "gpt-5.2",
13
14
  default: "gpt-5-mini",
14
15
  fast: "gpt-5.4-nano"
15
16
  }, k = {
16
17
  default: "text-embedding-ada-002"
17
18
  }, M = /* @__PURE__ */ new Map();
18
- let T = null;
19
- const Z = () => {
20
- const t = S.getDefault().helperServices;
19
+ let x = null;
20
+ const te = () => {
21
+ const t = F.getDefault().helperServices;
21
22
  if (!t?.aiModels?.url)
22
23
  throw new Error("AI Models Service URL is not defined in the portal's helper services.");
23
24
  return t.aiModels.url;
24
- }, P = async (e) => {
25
- const t = Z();
26
- M.size === 0 && (T || (T = (async () => {
25
+ }, U = async (e) => {
26
+ const t = te();
27
+ M.size === 0 && (x || (x = (async () => {
27
28
  try {
28
29
  const n = await fetch(`${t}/models`);
29
30
  if (!n.ok)
30
31
  throw new Error("Failed to fetch AI service discovery data.");
31
32
  (await n.json()).models.forEach((o) => M.set(o.name, o));
32
33
  } catch (n) {
33
- throw T = null, n;
34
+ throw x = null, n;
34
35
  }
35
- })()), await T);
36
+ })()), await x);
36
37
  const s = M.get(e);
37
38
  if (!s)
38
39
  throw new Error(`Model '${e}' is not available in the discovery service.`);
39
40
  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) => ({
41
+ }, ne = async (e = "default") => await U(q[e]), se = async (e = "default") => await U(k[e]), h = (e, t) => t, P = (e, t) => ({
41
42
  ...e,
42
43
  ...t
43
- }), $ = (e = "", t) => {
44
+ }), _ = (e = "", t) => {
44
45
  const s = typeof t == "string" ? t.trim() : "";
45
46
  if (!s)
46
47
  return e;
@@ -61,62 +62,66 @@ ${s}`;
61
62
  messages: [],
62
63
  priorSteps: [],
63
64
  sharedState: {}
64
- }), ne = () => ({
65
- agentExecutionContext: d({
66
- reducer: q,
65
+ }), ie = () => ({
66
+ agentExecutionContext: p({
67
+ reducer: P,
67
68
  default: j
68
69
  }),
69
- outputMessage: d({
70
- reducer: $,
70
+ outputMessage: p({
71
+ reducer: _,
71
72
  default: () => ""
72
73
  }),
73
- summary: d({
74
- reducer: u,
74
+ summary: p({
75
+ reducer: h,
75
76
  default: () => ""
76
77
  }),
77
- status: d({
78
- reducer: u
78
+ status: p({
79
+ reducer: h
79
80
  })
80
- }), Ee = () => ({
81
- ...ne(),
82
- sharedStatePatch: d({
83
- reducer: u
81
+ }), Pe = () => ({
82
+ ...ie(),
83
+ sharedStatePatch: p({
84
+ reducer: h
84
85
  })
85
- }), Ie = d.Root({
86
- agentExecutionContext: d({
86
+ }), _e = p.Root({
87
+ agentExecutionContext: p({
87
88
  default: j,
88
- reducer: q
89
+ reducer: P
89
90
  }),
90
- currentIntent: d({
91
+ currentIntent: p({
91
92
  default: () => "none",
92
- reducer: u
93
+ reducer: h
93
94
  }),
94
- lastExecutedAgent: d({
95
+ lastExecutedAgent: p({
95
96
  default: () => "",
96
- reducer: u
97
+ reducer: h
97
98
  }),
98
- requiresFollowUp: d({
99
+ requiresFollowUp: p({
99
100
  default: () => !0,
100
- reducer: u
101
+ reducer: h
101
102
  }),
102
- stepCount: d({
103
+ stepCount: p({
103
104
  default: () => 0,
104
105
  reducer: (e, t) => t ?? e + 1
105
106
  }),
106
- finalOutputMessage: d({
107
+ finalOutputMessage: p({
107
108
  default: () => "",
108
- reducer: $
109
+ reducer: _
109
110
  })
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) => {
111
+ }), oe = (e) => {
112
+ if (!e || typeof e != "object" || !("services" in e))
113
+ return !1;
114
+ const t = e.services;
115
+ return !!t && typeof t == "object" && "agentRegistry" in t;
116
+ }, re = (e) => {
117
+ const t = e?.configurable;
118
+ return oe(t) ? t : void 0;
119
+ }, ae = (e, t, s) => {
115
120
  const n = e[t];
116
121
  return n ? typeof n == "function" ? n() : Promise.resolve(n) : new Promise((i, o) => {
117
122
  (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
123
  });
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) => {
124
+ }, I = async (e) => (await ae(/* @__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) => {
120
125
  const { agent: t, messages: s, config: n } = e;
121
126
  return { structuredResponse: (await t.invoke(
122
127
  {
@@ -124,75 +129,105 @@ ${s}`;
124
129
  },
125
130
  n
126
131
  )).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);
132
+ }, le = (e) => typeof e == "string" && e.length > 0 ? e : void 0, de = (e) => e && typeof e == "object" && "aborted" in e ? e : void 0, pe = (e) => {
133
+ const t = e?.configurable;
134
+ return {
135
+ conversationId: le(t?.thread_id),
136
+ abortSignal: de(t?.abortSignal),
137
+ requestId: ee.applicationName
138
+ };
139
+ }, N = async ({ config: e }) => {
140
+ const t = F.getDefault(), n = (await Z.getCredential(`${t.url}/sharing`))?.token;
141
+ return async (i, o) => {
142
+ const { conversationId: a, abortSignal: d, requestId: c } = pe(e), l = new Headers(o?.headers);
143
+ l.delete("Authorization"), l.delete("api-key"), n && n.length > 0 && (l.set("X-Esri-Authorization", `Bearer ${n}`), l.set("X-Esri-Request-Source", "MapsSDK")), a && a.length > 0 && l.set("X-Esri-Conversation-Id", a), c && c.length > 0 && l.set("X-Esri-Request-Id", c);
144
+ const u = d && o?.signal ? AbortSignal.any([d, o.signal]) : o?.signal ?? d;
145
+ return await fetch(i, {
146
+ ...o,
147
+ headers: l,
148
+ signal: u
149
+ });
150
+ };
151
+ }, b = async (e = {}) => {
152
+ const { modelTier: t = "default", temperature: s = 0, config: n } = e, i = q[t], o = await ne(t);
135
153
  return new Q({
136
154
  modelName: i,
137
155
  apiKey: "dummy-key",
138
156
  // 5-mini does not support temperature parameter
139
- ...e !== "default" && { temperature: t },
157
+ ...t !== "default" && { temperature: s },
140
158
  configuration: {
141
159
  baseURL: o,
142
- fetch: N(n.token)
160
+ fetch: await N({ config: n })
143
161
  }
144
162
  });
145
- }, Re = async (e = "default") => {
146
- const t = S.getDefault(), s = await U.getCredential(`${t.url}/sharing`), n = k[e], i = await te(e);
163
+ }, je = async (e = {}) => {
164
+ const { tier: t = "default", config: s } = e, n = k[t], i = await se(t);
147
165
  return new Y({
148
166
  modelName: n,
149
167
  apiKey: "dummy-key",
150
168
  configuration: {
151
169
  baseURL: i,
152
- fetch: N(s.token)
170
+ fetch: await N({ config: s })
153
171
  },
154
172
  batchSize: 2048,
155
173
  maxConcurrency: 10
156
174
  });
157
- }, re = r.object({
175
+ }, me = r.object({
158
176
  id: r.string().min(1),
159
177
  name: r.string().min(1),
160
178
  description: r.string().min(1)
161
179
  });
162
- r.array(re);
163
- const D = (e) => JSON.stringify(e, null, 2), oe = (e) => {
180
+ r.array(me);
181
+ const C = (e) => JSON.stringify(e, null, 2), ue = (e) => {
164
182
  const t = e.map((n) => n.id), s = r.enum(t);
165
183
  return r.object({
166
184
  intent: s.nullable(),
167
185
  assignedTask: r.string().nullable(),
168
186
  requiresFollowUp: r.boolean()
169
187
  });
170
- }, Ce = async (e, t) => {
188
+ }, Ne = async (e, t) => {
189
+ const s = re(t);
190
+ if (s.abortSignal?.aborted)
191
+ return await f({ text: "Run cancelled; skipping intent routing" }, t), {
192
+ ...e,
193
+ currentIntent: "none",
194
+ finalOutputMessage: "Operation cancelled.",
195
+ requiresFollowUp: !1
196
+ };
171
197
  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
198
+ await f({ text: "Asking LLM to route to an agent" }, t);
199
+ const i = s.services.agentRegistry?.list() ?? [], o = i.map(({ agent: g }) => ({
200
+ id: g.id,
201
+ name: g.name,
202
+ description: g.description
177
203
  }));
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),
204
+ if (!o.length)
205
+ return await f({ text: "No agents registered; skipping intent detection" }, t), {
206
+ ...e,
207
+ currentIntent: "none",
208
+ finalOutputMessage: "No agents registered; skipping intent detection."
209
+ };
210
+ const a = await I("intent_prompt"), d = C(o), c = ue(o), l = {
211
+ registeredAgents: d,
212
+ priorSteps: C(e.agentExecutionContext.priorSteps),
183
213
  userRequest: e.agentExecutionContext.userRequest
184
- }, g = await C.fromTemplate(o).format(l), I = J({
185
- model: await x("fast"),
214
+ }, T = await D.fromTemplate(a).format(l), E = H({
215
+ model: await b({
216
+ modelTier: "fast",
217
+ config: t
218
+ }),
186
219
  tools: [],
187
- systemPrompt: g,
188
- checkpointer: !0,
220
+ systemPrompt: T,
189
221
  responseFormat: c,
190
222
  middleware: [
191
223
  // Preserve recent conversation context while summarizing older messages
192
224
  // to control token usage without losing important intent signals.
193
225
  // The trigger and keep parameters can be tuned based on token limits and behavior.
194
- X({
195
- model: await x("fast"),
226
+ J({
227
+ model: await b({
228
+ modelTier: "fast",
229
+ config: t
230
+ }),
196
231
  trigger: { tokens: 4e3 },
197
232
  keep: { messages: 6 }
198
233
  }),
@@ -200,31 +235,34 @@ const D = (e) => JSON.stringify(e, null, 2), oe = (e) => {
200
235
  // 1 usual LLM call and 1 optional summarization call.
201
236
  G({ runLimit: 2 })
202
237
  ]
203
- }), { structuredResponse: z } = await ie({
204
- agent: I,
238
+ }), { structuredResponse: V } = await ce({
239
+ agent: E,
205
240
  messages: e.agentExecutionContext.messages,
206
241
  config: t
207
- }), f = c.parse(
208
- z ?? { intent: null, assignedTask: null, requiresFollowUp: !1 }
209
- ), v = f.intent ?? "none", L = {
242
+ }), y = c.parse(
243
+ V ?? { intent: null, assignedTask: null, requiresFollowUp: !1 }
244
+ ), v = y.intent ?? "none", z = {
210
245
  ...e,
211
246
  currentIntent: v,
212
- requiresFollowUp: f.requiresFollowUp,
247
+ requiresFollowUp: y.requiresFollowUp,
213
248
  agentExecutionContext: {
214
249
  ...e.agentExecutionContext,
215
- assignedTask: f.assignedTask ?? ""
250
+ assignedTask: y.assignedTask ?? ""
216
251
  }
217
252
  };
218
253
  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), {
254
+ 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(", ")}.
255
+
256
+ Please ask a question that can be answered by one of these agents.`;
257
+ return await f({ text: "LLM did not identify a clear intent." }, t), {
221
258
  ...e,
222
259
  currentIntent: v,
223
260
  requiresFollowUp: !1,
261
+ finalOutputMessage: g,
224
262
  agentExecutionContext: {
225
263
  ...e.agentExecutionContext,
226
264
  assignedTask: "",
227
- messages: [...e.agentExecutionContext.messages, new B(h)],
265
+ messages: [...e.agentExecutionContext.messages, new B(g)],
228
266
  priorSteps: [
229
267
  ...e.agentExecutionContext.priorSteps ?? [],
230
268
  {
@@ -237,31 +275,31 @@ const D = (e) => JSON.stringify(e, null, 2), oe = (e) => {
237
275
  }
238
276
  };
239
277
  }
240
- return await y(
278
+ return await f(
241
279
  {
242
280
  text: `Agent picked: ${v}
243
- Task Assigned: ${f.assignedTask ?? ""}
244
- Requires Follow-Up: ${f.requiresFollowUp}`
281
+ Task Assigned: ${y.assignedTask ?? ""}
282
+ Requires Follow-Up: ${y.requiresFollowUp}`
245
283
  },
246
284
  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)}`);
285
+ ), z;
286
+ } catch (n) {
287
+ throw await f({ text: "Error during intent detection" }, t), new Error(`Error during intent detection: ${n instanceof Error ? n.message : String(n)}`);
250
288
  }
251
- }, ae = "0.1", w = 1536, ce = "openai", le = k.default, de = `Name: {name}
289
+ }, ge = "0.1", w = 1536, fe = "openai", he = k.default, ye = `Name: {name}
252
290
  Title: {title}
253
- Description: {description}`, pe = `Name: {name}
291
+ Description: {description}`, we = `Name: {name}
254
292
  Alias: {alias}
255
- Description: {description}`, Fe = r.object({
256
- schemaVersion: r.literal(ae),
293
+ Description: {description}`, $e = r.object({
294
+ schemaVersion: r.literal(ge),
257
295
  modified: r.number().int().nonnegative(),
258
296
  embeddings: r.object({
259
- modelProvider: r.literal(ce),
260
- model: r.literal(le),
297
+ modelProvider: r.literal(fe),
298
+ model: r.literal(he),
261
299
  dimensions: r.literal(w),
262
300
  templates: r.object({
263
- layer: r.string().default(de),
264
- field: r.string().default(pe)
301
+ layer: r.string().default(ye),
302
+ field: r.string().default(we)
265
303
  })
266
304
  }),
267
305
  layers: r.array(
@@ -285,7 +323,7 @@ Description: {description}`, Fe = r.object({
285
323
  )
286
324
  })
287
325
  ).default([])
288
- }), me = (e) => {
326
+ }), be = (e) => {
289
327
  const t = /* @__PURE__ */ new Set();
290
328
  for (const n of e)
291
329
  if (W(n)) {
@@ -295,50 +333,51 @@ Description: {description}`, Fe = r.object({
295
333
  });
296
334
  }
297
335
  return e.filter((n) => {
298
- if (H(n)) {
336
+ if (X(n)) {
299
337
  const i = n;
300
338
  return t.has(i.tool_call_id);
301
339
  }
302
340
  return !0;
303
341
  });
304
- }, E = (e, t) => {
342
+ }, A = (e, t) => {
305
343
  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({
344
+ return D.fromMessages([s, ...t]);
345
+ }, ve = async (e) => {
346
+ const { promptText: t, modelTier: s, temperature: n, messages: i, config: o } = e, a = A(t, i ?? []), d = await b({ modelTier: s, temperature: n, config: o });
347
+ return a.pipe(d);
348
+ }, Oe = async (e) => {
349
+ const { promptText: t, modelTier: s = "default", temperature: n = 0, messages: i, inputVariables: o, config: a } = e, c = await (await ve({
312
350
  promptText: t,
313
351
  modelTier: s,
314
352
  temperature: n,
315
- messages: i
353
+ messages: i,
354
+ config: a
316
355
  })).invoke(o ?? {});
317
356
  if (typeof c == "string")
318
357
  return c;
319
358
  const l = c.content;
320
359
  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);
360
+ }, $ = async (e) => {
361
+ const { promptText: t, modelTier: s = "default", temperature: n = 0, messages: i, inputVariables: o, schema: a, config: d } = e, c = A(t, i ?? []), u = (await b({ modelTier: s, temperature: n, config: d })).withStructuredOutput(a);
362
+ return await c.pipe(u).invoke(o ?? {});
363
+ }, Ve = async (e) => {
364
+ const { promptText: t, modelTier: s = "default", temperature: n = 0, messages: i, inputVariables: o, tools: a, config: d } = e, c = a.length > 0 ? be(i ?? []) : i ?? [], l = A(t, c), u = await b({ modelTier: s, temperature: n, config: d });
365
+ return await l.pipe(u.bindTools(a)).invoke(o ?? {});
366
+ }, xe = m.object({
367
+ name: m.string(),
368
+ description: m.string(),
369
+ valueType: m.string(),
370
+ alias: m.string()
371
+ }), Te = m.object({
372
+ fields: m.array(xe)
373
+ }), O = (e, t) => e.getFieldAlias(t) ?? void 0, S = (e, t) => O(e, t.name) ?? t.alias ?? "", Me = (e, t) => {
374
+ const s = O(e, t.name);
336
375
  return !!(s && s !== (t.alias ?? ""));
337
376
  };
338
377
  function R(e, t) {
339
378
  const s = /* @__PURE__ */ new Map();
340
379
  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 = {
380
+ const i = t.fields.find((c) => c.name === n.name), o = S(e, n), a = Me(e, n), d = {
342
381
  name: n.name,
343
382
  type: n.type,
344
383
  alias: a ? o : i?.alias ?? o,
@@ -346,14 +385,14 @@ function R(e, t) {
346
385
  valueType: i?.valueType ?? n.valueType ?? "",
347
386
  domain: e.getFieldDomain(n.name) ?? void 0
348
387
  };
349
- s.set(n.name, c);
388
+ s.set(n.name, d);
350
389
  }
351
390
  return s;
352
391
  }
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(", ");
392
+ const ze = async (e) => {
393
+ const s = await I("field_descriptions_prompt"), n = e.fields.filter((a) => !(S(e, a) && a.description)).map((a) => {
394
+ const { name: d, type: c, description: l } = a, u = S(e, a);
395
+ return [`Name: ${d}`, `Type: ${c}`, `Alias: ${u}`, `Description: ${l ?? "N/A"}`].join(", ");
357
396
  }).join(`
358
397
  `);
359
398
  if (n.length === 0)
@@ -364,50 +403,49 @@ const Pe = async (e) => {
364
403
  existingLayerTitle: e.title,
365
404
  existingLayerDescription: e.portalItem?.description,
366
405
  fieldInformation: n
367
- }, o = await O({
406
+ }, o = await $({
368
407
  promptText: s,
369
- schema: fe,
408
+ schema: Te,
370
409
  inputVariables: i
371
410
  });
372
411
  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 = {
412
+ }, Se = m.object({
413
+ title: m.string(),
414
+ description: m.string(),
415
+ name: m.string().nullable()
416
+ }), Le = async (e, t) => {
417
+ const n = await I("layer_descriptions_prompt"), i = Array.from(t.values()), o = {
379
418
  fieldInformation: JSON.stringify(i, null, 2),
380
419
  existingLayerTitle: e.title,
381
420
  existingLayerDescription: e.portalItem?.description,
382
421
  existingLayerSnippet: e.portalItem?.snippet,
383
422
  layerGeometryType: e.geometryType
384
423
  };
385
- return { ...await O({
424
+ return { ...await $({
386
425
  promptText: n,
387
- schema: ye,
426
+ schema: Se,
388
427
  inputVariables: o
389
428
  }), name: e.title ?? null };
390
429
  };
391
430
  export {
392
- Ie as D,
393
- Fe as W,
394
- qe as a,
395
- ce as b,
396
- x as c,
431
+ _e as D,
432
+ $e as W,
433
+ Le as a,
434
+ fe as b,
435
+ b as c,
397
436
  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
437
+ Oe as e,
438
+ we as f,
439
+ ze as g,
440
+ Ve as h,
441
+ $ as i,
442
+ ie as j,
443
+ Pe as k,
444
+ ye as l,
445
+ he as m,
446
+ se as n,
447
+ re as o,
448
+ Ne as p,
449
+ je as q,
450
+ ge as s
413
451
  };