@arcgis/ai-components 5.2.0-next.65 → 5.2.0-next.67

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