@arcgis/ai-components 5.2.0-next.66 → 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.
@@ -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 h } 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]), g = (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,65 +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: g,
73
+ summary: m({
74
+ reducer: f,
75
75
  default: () => ""
76
76
  }),
77
- status: p({
78
- reducer: g
77
+ status: m({
78
+ reducer: f
79
79
  })
80
- }), Oe = () => ({
81
- ...re(),
82
- sharedStatePatch: p({
83
- reducer: g
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: g
92
+ reducer: f
93
93
  }),
94
- routing: p({
94
+ routing: m({
95
95
  default: () => ({ mode: "auto" }),
96
- reducer: g
96
+ reducer: f
97
97
  }),
98
- lastExecutedAgent: p({
98
+ lastExecutedAgent: m({
99
99
  default: () => "",
100
- reducer: g
100
+ reducer: f
101
101
  }),
102
- requiresFollowUp: p({
102
+ requiresFollowUp: m({
103
103
  default: () => !0,
104
- reducer: g
104
+ reducer: f
105
105
  }),
106
- stepCount: p({
106
+ stepCount: m({
107
107
  default: () => 0,
108
108
  reducer: (e, t) => t ?? e + 1
109
109
  }),
110
- finalOutputMessage: p({
110
+ finalOutputMessage: m({
111
111
  default: () => "",
112
112
  reducer: $
113
113
  })
@@ -121,7 +121,7 @@ ${s}`;
121
121
  return ae(t) ? t : void 0;
122
122
  }, le = (e, t, s) => {
123
123
  const n = e[t];
124
- 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) => {
125
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." : ""))));
126
126
  });
127
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) => {
@@ -132,34 +132,41 @@ ${s}`;
132
132
  },
133
133
  n
134
134
  )).structuredResponse };
135
- }, 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) => {
136
136
  const t = e?.configurable;
137
137
  return {
138
- conversationId: me(t?.thread_id),
138
+ conversationId: pe(t?.thread_id),
139
139
  abortSignal: e?.signal,
140
- requestId: pe(),
140
+ requestId: me(),
141
141
  requestSource: ue(ne.applicationName)
142
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)}`);
143
149
  }, N = async ({ config: e }) => {
144
150
  const t = F.getDefault(), n = (await ee.getCredential(`${t.url}/sharing`))?.token;
145
- return async (i, o) => {
146
- const { conversationId: a, abortSignal: c, requestId: l, requestSource: d } = ge(e), m = new Headers(o?.headers);
147
- for (const w of [...m.keys()]) {
148
- const b = w.toLowerCase();
149
- (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);
150
156
  }
151
- 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));
152
- const y = c && o?.signal ? AbortSignal.any([c, o.signal]) : o?.signal ?? c;
153
- return await fetch(i, {
154
- ...o,
155
- headers: m,
156
- signal: y
157
- });
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;
158
165
  };
159
- }, M = async (e = {}) => {
160
- const { modelTier: t = "default", temperature: s = 0, config: n } = e, i = U[t], o = await ie(t);
161
- return new Q({
162
- 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,
163
170
  apiKey: "dummy-key",
164
171
  // 5-mini does not support temperature parameter
165
172
  ...t !== "default" && { temperature: s },
@@ -168,71 +175,71 @@ ${s}`;
168
175
  fetch: await N({ config: n })
169
176
  }
170
177
  });
171
- }, Le = async (e = {}) => {
172
- const { tier: t = "default", config: s } = e, n = E[t], i = await oe(t);
173
- 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({
174
181
  modelName: n,
175
182
  apiKey: "dummy-key",
176
183
  configuration: {
177
- baseURL: i,
184
+ baseURL: r,
178
185
  fetch: await N({ config: s })
179
186
  },
180
187
  batchSize: 2048,
181
188
  maxConcurrency: 10
182
189
  });
183
- }, fe = r.object({
184
- id: r.string().min(1),
185
- name: r.string().min(1),
186
- 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)
187
194
  });
188
- r.array(fe);
189
- const C = (e) => JSON.stringify(e, null, 2), he = (e) => {
190
- const t = e.map((n) => n.id), s = r.enum(t);
191
- 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({
192
199
  intent: s.nullable(),
193
- assignedTask: r.string().nullable(),
194
- requiresFollowUp: r.boolean()
200
+ assignedTask: i.string().nullable(),
201
+ requiresFollowUp: i.boolean()
195
202
  });
196
- }, Ve = async (e, t) => {
203
+ }, Ke = async (e, t) => {
197
204
  const s = ce(t);
198
205
  if (t?.signal?.aborted)
199
- return await h({ text: "Run cancelled; skipping intent routing" }, t), {
206
+ return await y({ text: "Run cancelled; skipping intent routing" }, t), {
200
207
  ...e,
201
208
  currentIntent: "none",
202
209
  finalOutputMessage: "Operation cancelled.",
203
210
  requiresFollowUp: !1
204
211
  };
205
212
  try {
206
- await h({ text: "Asking LLM to route to an agent" }, t);
207
- const i = s.services.agentRegistry?.list() ?? [], o = i.map(({ agent: f }) => ({
208
- id: f.id,
209
- name: f.name,
210
- description: f.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
211
218
  }));
212
219
  if (!o.length)
213
- return await h({ text: "No agents registered; skipping intent detection" }, t), {
220
+ return await y({ text: "No agents registered; skipping intent detection" }, t), {
214
221
  ...e,
215
222
  currentIntent: "none",
216
223
  finalOutputMessage: "No agents registered; skipping intent detection."
217
224
  };
218
- 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 = {
219
226
  registeredAgents: c,
220
227
  priorSteps: C(e.agentExecutionContext.priorSteps),
221
228
  userRequest: e.agentExecutionContext.userRequest
222
- }, y = await q.fromTemplate(a).format(d), w = G({
223
- model: await M({
229
+ }, w = await D.fromTemplate(a).format(d), S = G({
230
+ model: await v({
224
231
  modelTier: "fast",
225
232
  config: t
226
233
  }),
227
234
  tools: [],
228
- systemPrompt: y,
235
+ systemPrompt: w,
229
236
  responseFormat: l,
230
237
  middleware: [
231
238
  // Preserve recent conversation context while summarizing older messages
232
239
  // to control token usage without losing important intent signals.
233
240
  // The trigger and keep parameters can be tuned based on token limits and behavior.
234
- H({
235
- model: await M({
241
+ J({
242
+ model: await v({
236
243
  modelTier: "fast",
237
244
  config: t
238
245
  }),
@@ -241,36 +248,36 @@ const C = (e) => JSON.stringify(e, null, 2), he = (e) => {
241
248
  }),
242
249
  // Enforce no loop/retry.
243
250
  // 1 usual LLM call and 1 optional summarization call.
244
- J({ runLimit: 2 })
251
+ Q({ runLimit: 2 })
245
252
  ]
246
- }), { structuredResponse: b } = await de({
247
- agent: w,
253
+ }), { structuredResponse: x } = await de({
254
+ agent: S,
248
255
  messages: e.agentExecutionContext.messages,
249
256
  config: t
250
- }), v = l.parse(
251
- b ?? { intent: null, assignedTask: null, requiresFollowUp: !1 }
252
- ), T = v.intent ?? "none", L = {
257
+ }), g = l.parse(
258
+ x ?? { intent: null, assignedTask: null, requiresFollowUp: !1 }
259
+ ), T = g.intent ?? "none", V = {
253
260
  ...e,
254
261
  currentIntent: T,
255
- requiresFollowUp: v.requiresFollowUp,
262
+ requiresFollowUp: g.requiresFollowUp,
256
263
  agentExecutionContext: {
257
264
  ...e.agentExecutionContext,
258
- assignedTask: v.assignedTask ?? ""
265
+ assignedTask: g.assignedTask ?? ""
259
266
  }
260
267
  };
261
268
  if (T === "none") {
262
- const f = `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(", ")}.
263
270
 
264
271
  Please ask a question that can be answered by one of these agents.`;
265
- return await h({ text: "LLM did not identify a clear intent." }, t), {
272
+ return await y({ text: "LLM did not identify a clear intent." }, t), {
266
273
  ...e,
267
274
  currentIntent: T,
268
275
  requiresFollowUp: !1,
269
- finalOutputMessage: f,
276
+ finalOutputMessage: h,
270
277
  agentExecutionContext: {
271
278
  ...e.agentExecutionContext,
272
279
  assignedTask: "",
273
- messages: [...e.agentExecutionContext.messages, new W(f)],
280
+ messages: [...e.agentExecutionContext.messages, new W(h)],
274
281
  priorSteps: [
275
282
  ...e.agentExecutionContext.priorSteps ?? [],
276
283
  {
@@ -283,49 +290,49 @@ Please ask a question that can be answered by one of these agents.`;
283
290
  }
284
291
  };
285
292
  }
286
- return await h(
293
+ return await y(
287
294
  {
288
295
  text: `Agent picked: ${T}
289
- Task Assigned: ${v.assignedTask ?? ""}
290
- Requires Follow-Up: ${v.requiresFollowUp}`
296
+ Task Assigned: ${g.assignedTask ?? ""}
297
+ Requires Follow-Up: ${g.requiresFollowUp}`
291
298
  },
292
299
  t
293
- ), L;
300
+ ), V;
294
301
  } catch (n) {
295
- throw await h({ 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)}`);
296
303
  }
297
- }, 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}
298
305
  Title: {title}
299
- Description: {description}`, xe = `Name: {name}
306
+ Description: {description}`, Te = `Name: {name}
300
307
  Alias: {alias}
301
- Description: {description}`, Ke = r.object({
302
- schemaVersion: r.literal(ye),
303
- modified: r.number().int().nonnegative(),
304
- embeddings: r.object({
305
- modelProvider: r.literal(we),
306
- model: r.literal(be),
307
- dimensions: r.literal(x),
308
- templates: r.object({
309
- layer: r.string().default(ve),
310
- 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)
311
318
  })
312
319
  }),
313
- layers: r.array(
314
- r.object({
315
- id: r.string().min(1),
316
- name: r.string().min(1),
317
- title: r.string().catch(""),
318
- description: r.string().catch(""),
319
- vector: r.array(r.number()).length(x, {
320
- 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`
321
328
  }),
322
- fields: r.array(
323
- r.object({
324
- name: r.string().min(1),
325
- alias: r.string().catch(""),
326
- description: r.string().catch(""),
327
- vector: r.array(r.number()).length(x, {
328
- 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`
329
336
  })
330
337
  })
331
338
  )
@@ -334,63 +341,63 @@ Description: {description}`, Ke = r.object({
334
341
  }), Me = (e) => {
335
342
  const t = /* @__PURE__ */ new Set();
336
343
  for (const n of e)
337
- if (B(n)) {
338
- const i = n;
339
- 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) => {
340
347
  o.id && t.add(o.id);
341
348
  });
342
349
  }
343
350
  return e.filter((n) => {
344
351
  if (X(n)) {
345
- const i = n;
346
- return t.has(i.tool_call_id);
352
+ const r = n;
353
+ return t.has(r.tool_call_id);
347
354
  }
348
355
  return !0;
349
356
  });
350
357
  }, A = (e, t) => {
351
- const s = K.fromTemplate(e);
352
- return q.fromMessages([s, ...t]);
353
- }, Te = async (e) => {
354
- 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 });
355
362
  return a.pipe(c);
356
363
  }, We = async (e) => {
357
- 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({
358
365
  promptText: t,
359
366
  modelTier: s,
360
367
  temperature: n,
361
- messages: i,
368
+ messages: r,
362
369
  config: a
363
370
  })).invoke(o ?? {}, a);
364
371
  if (typeof l == "string")
365
372
  return l;
366
373
  const d = l.content;
367
374
  return typeof d == "string" ? d : JSON.stringify(d);
368
- }, O = async (e) => {
369
- 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);
370
- return await l.pipe(m).invoke(o ?? {}, c);
371
- }, Be = async (e) => {
372
- 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 });
373
- return await d.pipe(m.bindTools(a)).invoke(o ?? {}, c);
374
- }, 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({
375
382
  name: u.string(),
376
383
  description: u.string(),
377
384
  valueType: u.string(),
378
385
  alias: u.string()
379
- }), ke = u.object({
380
- fields: u.array(Se)
381
- }), 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) => {
382
389
  const s = z(e, t.name);
383
390
  return !!(s && s !== (t.alias ?? ""));
384
391
  };
385
- function D(e, t) {
392
+ function q(e, t) {
386
393
  const s = /* @__PURE__ */ new Map();
387
394
  for (const n of e.fields) {
388
- 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 = {
389
396
  name: n.name,
390
397
  type: n.type,
391
- alias: a ? o : i?.alias ?? o,
392
- description: i?.description ?? n.description ?? "",
393
- valueType: i?.valueType ?? n.valueType ?? "",
398
+ alias: a ? o : r?.alias ?? o,
399
+ description: r?.description ?? n.description ?? "",
400
+ valueType: r?.valueType ?? n.valueType ?? "",
394
401
  domain: e.getFieldDomain(n.name) ?? void 0
395
402
  };
396
403
  s.set(n.name, c);
@@ -399,61 +406,61 @@ function D(e, t) {
399
406
  }
400
407
  const Xe = async (e) => {
401
408
  const s = await R("field_descriptions_prompt"), n = e.fields.filter((a) => !(I(e, a) && a.description)).map((a) => {
402
- const { name: c, type: l, description: d } = a, m = I(e, a);
403
- 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(", ");
404
411
  }).join(`
405
412
  `);
406
413
  if (n.length === 0)
407
- return D(e, { fields: [] });
408
- const i = {
414
+ return q(e, { fields: [] });
415
+ const r = {
409
416
  existingItemTitle: e.portalItem?.title,
410
417
  existingItemDescription: e.portalItem?.description,
411
418
  existingLayerTitle: e.title,
412
419
  existingLayerDescription: e.portalItem?.description,
413
420
  fieldInformation: n
414
- }, o = await O({
421
+ }, o = await L({
415
422
  promptText: s,
416
- schema: ke,
417
- inputVariables: i
423
+ schema: Ie,
424
+ inputVariables: r
418
425
  });
419
- return D(e, o);
420
- }, Ee = u.object({
426
+ return q(e, o);
427
+ }, Re = u.object({
421
428
  title: u.string(),
422
429
  description: u.string(),
423
430
  name: u.string().nullable()
424
431
  }), Ge = async (e, t) => {
425
- const n = await R("layer_descriptions_prompt"), i = Array.from(t.values()), o = {
426
- 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),
427
434
  existingLayerTitle: e.title,
428
435
  existingLayerDescription: e.portalItem?.description,
429
436
  existingLayerSnippet: e.portalItem?.snippet,
430
437
  layerGeometryType: e.geometryType
431
438
  };
432
- return { ...await O({
439
+ return { ...await L({
433
440
  promptText: n,
434
- schema: Ee,
441
+ schema: Re,
435
442
  inputVariables: o
436
443
  }), name: e.title ?? null };
437
444
  };
438
445
  export {
439
446
  ze as D,
440
- Ke as W,
447
+ Be as W,
441
448
  Ge as a,
442
- we as b,
443
- M as c,
444
- x as d,
449
+ be as b,
450
+ v as c,
451
+ b as d,
445
452
  We as e,
446
- xe as f,
453
+ Te as f,
447
454
  Xe as g,
448
- Be as h,
449
- O as i,
450
- re as j,
451
- Oe as k,
452
- ve as l,
453
- 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,
454
461
  oe as n,
455
462
  ce as o,
456
- Ve as p,
457
- Le as q,
458
- ye as s
463
+ Ke as p,
464
+ Ve as q,
465
+ we as s
459
466
  };