@arcgis/ai-components 5.2.0-next.70 → 5.2.0-next.72

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