@arcgis/ai-components 5.2.0-next.13 → 5.2.0-next.15

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.
@@ -30,7 +30,7 @@ const ne = () => {
30
30
  const n = await fetch(`${t}/models`);
31
31
  if (!n.ok)
32
32
  throw new Error("Failed to fetch AI service discovery data.");
33
- (await n.json()).models.forEach((i) => T.set(i.name, i));
33
+ (await n.json()).models.forEach((o) => T.set(o.name, o));
34
34
  } catch (n) {
35
35
  throw M = null, n;
36
36
  }
@@ -39,7 +39,7 @@ const ne = () => {
39
39
  if (!s)
40
40
  throw new Error(`Model '${e}' is not available in the discovery service.`);
41
41
  return s.endpoint;
42
- }, se = async (e = "default") => await U(F[e]), oe = async (e = "default") => await U(I[e]), h = (e, t) => t, P = (e, t) => ({
42
+ }, se = async (e = "default") => await U(F[e]), ie = async (e = "default") => await U(I[e]), h = (e, t) => t, P = (e, t) => ({
43
43
  ...e,
44
44
  ...t
45
45
  }), _ = (e = "", t) => {
@@ -51,10 +51,10 @@ const ne = () => {
51
51
  return s;
52
52
  if (n === s)
53
53
  return e;
54
- const o = n.split(`
54
+ const i = n.split(`
55
55
 
56
56
  `);
57
- return o[o.length - 1]?.trim() === s ? e : `${e}
57
+ return i[i.length - 1]?.trim() === s ? e : `${e}
58
58
 
59
59
  ${s}`;
60
60
  }, j = () => ({
@@ -63,7 +63,7 @@ ${s}`;
63
63
  messages: [],
64
64
  priorSteps: [],
65
65
  sharedState: {}
66
- }), ie = () => ({
66
+ }), oe = () => ({
67
67
  agentExecutionContext: m({
68
68
  reducer: P,
69
69
  default: j
@@ -79,12 +79,12 @@ ${s}`;
79
79
  status: m({
80
80
  reducer: h
81
81
  })
82
- }), Ne = () => ({
83
- ...ie(),
82
+ }), $e = () => ({
83
+ ...oe(),
84
84
  sharedStatePatch: m({
85
85
  reducer: h
86
86
  })
87
- }), Oe = m.Root({
87
+ }), Ne = m.Root({
88
88
  agentExecutionContext: m({
89
89
  default: j,
90
90
  reducer: P
@@ -119,8 +119,8 @@ ${s}`;
119
119
  return re(t) ? t : void 0;
120
120
  }, ce = (e, t, s) => {
121
121
  const n = e[t];
122
- return n ? typeof n == "function" ? n() : Promise.resolve(n) : new Promise((o, i) => {
123
- (typeof queueMicrotask == "function" ? queueMicrotask : setTimeout)(i.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
+ return n ? typeof n == "function" ? n() : Promise.resolve(n) : new Promise((i, o) => {
123
+ (typeof queueMicrotask == "function" ? queueMicrotask : setTimeout)(o.bind(null, /* @__PURE__ */ new Error("Unknown variable dynamic import: " + t + (t.split("/").length !== s ? ". Note that variables only represent file names one level deep." : ""))));
124
124
  });
125
125
  }, k = async (e) => (await ce(/* @__PURE__ */ Object.assign({ "./field_descriptions_prompt.md": () => import("./field_descriptions_prompt.js"), "./intent_prompt.md": () => import("./intent_prompt.js"), "./layer_descriptions_prompt.md": () => import("./layer_descriptions_prompt.js") }), `./${e}.md`, 2)).default, le = async (e) => {
126
126
  const { agent: t, messages: s, config: n } = e;
@@ -130,66 +130,66 @@ ${s}`;
130
130
  },
131
131
  n
132
132
  )).structuredResponse };
133
- }, de = (e) => typeof e == "string" && e.length > 0 ? e : void 0, pe = (e) => e && typeof e == "object" && "aborted" in e ? e : void 0, me = () => ee(), ue = (e) => typeof e != "string" || e.trim().length === 0 ? "MapsSDK" : `MapsSDK - ${e.trim()}`, ge = (e) => {
133
+ }, de = (e) => typeof e == "string" && e.length > 0 ? e : void 0, pe = () => ee(), me = (e) => typeof e != "string" || e.trim().length === 0 ? "MapsSDK" : `MapsSDK - ${e.trim()}`, ue = (e) => {
134
134
  const t = e?.configurable;
135
135
  return {
136
136
  conversationId: de(t?.thread_id),
137
- abortSignal: pe(t?.abortSignal),
138
- requestId: me(),
139
- requestSource: ue(te.applicationName)
137
+ abortSignal: e?.signal,
138
+ requestId: pe(),
139
+ requestSource: me(te.applicationName)
140
140
  };
141
141
  }, $ = async ({ config: e }) => {
142
142
  const t = q.getDefault(), n = (await Z.getCredential(`${t.url}/sharing`))?.token;
143
- return async (o, i) => {
144
- const { conversationId: a, abortSignal: l, requestId: c, requestSource: p } = ge(e), d = new Headers(i?.headers);
145
- d.delete("Authorization"), d.delete("api-key"), n && n.length > 0 && (d.set("X-Esri-Authorization", `Bearer ${n}`), d.set("X-Esri-Request-Source", p)), a && a.length > 0 && d.set("X-Esri-Conversation-Id", a), c.length > 0 && d.set("X-Esri-Request-Id", c);
146
- const y = l && i?.signal ? AbortSignal.any([l, i.signal]) : i?.signal ?? l;
147
- return await fetch(o, {
148
- ...i,
143
+ return async (i, o) => {
144
+ const { conversationId: a, abortSignal: c, requestId: l, requestSource: p } = ue(e), d = new Headers(o?.headers);
145
+ d.delete("Authorization"), d.delete("api-key"), n && n.length > 0 && (d.set("X-Esri-Authorization", `Bearer ${n}`), d.set("X-Esri-Request-Source", p)), a && a.length > 0 && d.set("X-Esri-Conversation-Id", a), l.length > 0 && d.set("X-Esri-Request-Id", l);
146
+ const y = c && o?.signal ? AbortSignal.any([c, o.signal]) : o?.signal ?? c;
147
+ return await fetch(i, {
148
+ ...o,
149
149
  headers: d,
150
150
  signal: y
151
151
  });
152
152
  };
153
153
  }, v = async (e = {}) => {
154
- const { modelTier: t = "default", temperature: s = 0, config: n } = e, o = F[t], i = await se(t);
154
+ const { modelTier: t = "default", temperature: s = 0, config: n } = e, i = F[t], o = await se(t);
155
155
  return new Q({
156
- modelName: o,
156
+ modelName: i,
157
157
  apiKey: "dummy-key",
158
158
  // 5-mini does not support temperature parameter
159
159
  ...t !== "default" && { temperature: s },
160
160
  configuration: {
161
- baseURL: i,
161
+ baseURL: o,
162
162
  fetch: await $({ config: n })
163
163
  }
164
164
  });
165
- }, Ve = async (e = {}) => {
166
- const { tier: t = "default", config: s } = e, n = I[t], o = await oe(t);
165
+ }, Oe = async (e = {}) => {
166
+ const { tier: t = "default", config: s } = e, n = I[t], i = await ie(t);
167
167
  return new Y({
168
168
  modelName: n,
169
169
  apiKey: "dummy-key",
170
170
  configuration: {
171
- baseURL: o,
171
+ baseURL: i,
172
172
  fetch: await $({ config: s })
173
173
  },
174
174
  batchSize: 2048,
175
175
  maxConcurrency: 10
176
176
  });
177
- }, fe = r.object({
177
+ }, ge = r.object({
178
178
  id: r.string().min(1),
179
179
  name: r.string().min(1),
180
180
  description: r.string().min(1)
181
181
  });
182
- r.array(fe);
183
- const R = (e) => JSON.stringify(e, null, 2), he = (e) => {
182
+ r.array(ge);
183
+ const R = (e) => JSON.stringify(e, null, 2), fe = (e) => {
184
184
  const t = e.map((n) => n.id), s = r.enum(t);
185
185
  return r.object({
186
186
  intent: s.nullable(),
187
187
  assignedTask: r.string().nullable(),
188
188
  requiresFollowUp: r.boolean()
189
189
  });
190
- }, ze = async (e, t) => {
190
+ }, Ve = async (e, t) => {
191
191
  const s = ae(t);
192
- if (s.abortSignal?.aborted)
192
+ if (t?.signal?.aborted)
193
193
  return await f({ text: "Run cancelled; skipping intent routing" }, t), {
194
194
  ...e,
195
195
  currentIntent: "none",
@@ -198,19 +198,19 @@ const R = (e) => JSON.stringify(e, null, 2), he = (e) => {
198
198
  };
199
199
  try {
200
200
  await f({ text: "Asking LLM to route to an agent" }, t);
201
- const o = s.services.agentRegistry?.list() ?? [], i = o.map(({ agent: g }) => ({
201
+ const i = s.services.agentRegistry?.list() ?? [], o = i.map(({ agent: g }) => ({
202
202
  id: g.id,
203
203
  name: g.name,
204
204
  description: g.description
205
205
  }));
206
- if (!i.length)
206
+ if (!o.length)
207
207
  return await f({ text: "No agents registered; skipping intent detection" }, t), {
208
208
  ...e,
209
209
  currentIntent: "none",
210
210
  finalOutputMessage: "No agents registered; skipping intent detection."
211
211
  };
212
- const a = await k("intent_prompt"), l = R(i), c = he(i), p = {
213
- registeredAgents: l,
212
+ const a = await k("intent_prompt"), c = R(o), l = fe(o), p = {
213
+ registeredAgents: c,
214
214
  priorSteps: R(e.agentExecutionContext.priorSteps),
215
215
  userRequest: e.agentExecutionContext.userRequest
216
216
  }, y = await D.fromTemplate(a).format(p), E = G({
@@ -220,7 +220,7 @@ const R = (e) => JSON.stringify(e, null, 2), he = (e) => {
220
220
  }),
221
221
  tools: [],
222
222
  systemPrompt: y,
223
- responseFormat: c,
223
+ responseFormat: l,
224
224
  middleware: [
225
225
  // Preserve recent conversation context while summarizing older messages
226
226
  // to control token usage without losing important intent signals.
@@ -241,7 +241,7 @@ const R = (e) => JSON.stringify(e, null, 2), he = (e) => {
241
241
  agent: E,
242
242
  messages: e.agentExecutionContext.messages,
243
243
  config: t
244
- }), w = c.parse(
244
+ }), w = l.parse(
245
245
  V ?? { intent: null, assignedTask: null, requiresFollowUp: !1 }
246
246
  ), x = w.intent ?? "none", z = {
247
247
  ...e,
@@ -253,7 +253,7 @@ const R = (e) => JSON.stringify(e, null, 2), he = (e) => {
253
253
  }
254
254
  };
255
255
  if (x === "none") {
256
- const g = `I could not find an agent that can handle that request. I have access to the following agents: ${o.map(({ agent: L }) => L.name).join(", ")}.
256
+ const g = `I could not find an agent that can handle that request. I have access to the following agents: ${i.map(({ agent: L }) => L.name).join(", ")}.
257
257
 
258
258
  Please ask a question that can be answered by one of these agents.`;
259
259
  return await f({ text: "LLM did not identify a clear intent." }, t), {
@@ -288,20 +288,20 @@ Requires Follow-Up: ${w.requiresFollowUp}`
288
288
  } catch (n) {
289
289
  throw await f({ text: "Error during intent detection" }, t), new Error(`Error during intent detection: ${n instanceof Error ? n.message : String(n)}`);
290
290
  }
291
- }, ye = "0.1", b = 1536, we = "openai", be = I.default, ve = `Name: {name}
291
+ }, he = "0.1", b = 1536, ye = "openai", we = I.default, be = `Name: {name}
292
292
  Title: {title}
293
- Description: {description}`, xe = `Name: {name}
293
+ Description: {description}`, ve = `Name: {name}
294
294
  Alias: {alias}
295
- Description: {description}`, Le = r.object({
296
- schemaVersion: r.literal(ye),
295
+ Description: {description}`, ze = r.object({
296
+ schemaVersion: r.literal(he),
297
297
  modified: r.number().int().nonnegative(),
298
298
  embeddings: r.object({
299
- modelProvider: r.literal(we),
300
- model: r.literal(be),
299
+ modelProvider: r.literal(ye),
300
+ model: r.literal(we),
301
301
  dimensions: r.literal(b),
302
302
  templates: r.object({
303
- layer: r.string().default(ve),
304
- field: r.string().default(xe)
303
+ layer: r.string().default(be),
304
+ field: r.string().default(ve)
305
305
  })
306
306
  }),
307
307
  layers: r.array(
@@ -325,99 +325,99 @@ Description: {description}`, Le = r.object({
325
325
  )
326
326
  })
327
327
  ).default([])
328
- }), Me = (e) => {
328
+ }), xe = (e) => {
329
329
  const t = /* @__PURE__ */ new Set();
330
330
  for (const n of e)
331
331
  if (W(n)) {
332
- const o = n;
333
- o.tool_calls && o.tool_calls.length > 0 && o.tool_calls.forEach((i) => {
334
- i.id && t.add(i.id);
332
+ const i = n;
333
+ i.tool_calls && i.tool_calls.length > 0 && i.tool_calls.forEach((o) => {
334
+ o.id && t.add(o.id);
335
335
  });
336
336
  }
337
337
  return e.filter((n) => {
338
338
  if (X(n)) {
339
- const o = n;
340
- return t.has(o.tool_call_id);
339
+ const i = n;
340
+ return t.has(i.tool_call_id);
341
341
  }
342
342
  return !0;
343
343
  });
344
344
  }, A = (e, t) => {
345
345
  const s = K.fromTemplate(e);
346
346
  return D.fromMessages([s, ...t]);
347
- }, Te = async (e) => {
348
- const { promptText: t, modelTier: s, temperature: n, messages: o, config: i } = e, a = A(t, o ?? []), l = await v({ modelTier: s, temperature: n, config: i });
349
- return a.pipe(l);
350
- }, Ke = async (e) => {
351
- const { promptText: t, modelTier: s = "default", temperature: n = 0, messages: o, inputVariables: i, config: a } = e, c = await (await Te({
347
+ }, Me = async (e) => {
348
+ const { promptText: t, modelTier: s, temperature: n, messages: i, config: o } = e, a = A(t, i ?? []), c = await v({ modelTier: s, temperature: n, config: o });
349
+ return a.pipe(c);
350
+ }, Le = async (e) => {
351
+ const { promptText: t, modelTier: s = "default", temperature: n = 0, messages: i, inputVariables: o, config: a } = e, l = await (await Me({
352
352
  promptText: t,
353
353
  modelTier: s,
354
354
  temperature: n,
355
- messages: o,
355
+ messages: i,
356
356
  config: a
357
- })).invoke(i ?? {});
358
- if (typeof c == "string")
359
- return c;
360
- const p = c.content;
357
+ })).invoke(o ?? {}, a);
358
+ if (typeof l == "string")
359
+ return l;
360
+ const p = l.content;
361
361
  return typeof p == "string" ? p : JSON.stringify(p);
362
362
  }, N = async (e) => {
363
- const { promptText: t, modelTier: s = "default", temperature: n = 0, messages: o, inputVariables: i, schema: a, config: l } = e, c = A(t, o ?? []), d = (await v({ modelTier: s, temperature: n, config: l })).withStructuredOutput(a);
364
- return await c.pipe(d).invoke(i ?? {});
365
- }, Be = async (e) => {
366
- const { promptText: t, modelTier: s = "default", temperature: n = 0, messages: o, inputVariables: i, tools: a, config: l } = e, c = a.length > 0 ? Me(o ?? []) : o ?? [], p = A(t, c), d = await v({ modelTier: s, temperature: n, config: l });
367
- return await p.pipe(d.bindTools(a)).invoke(i ?? {});
368
- }, Se = u.object({
363
+ const { promptText: t, modelTier: s = "default", temperature: n = 0, messages: i, inputVariables: o, schema: a, config: c } = e, l = A(t, i ?? []), d = (await v({ modelTier: s, temperature: n, config: c })).withStructuredOutput(a);
364
+ return await l.pipe(d).invoke(o ?? {}, c);
365
+ }, Ke = async (e) => {
366
+ const { promptText: t, modelTier: s = "default", temperature: n = 0, messages: i, inputVariables: o, tools: a, config: c } = e, l = a.length > 0 ? xe(i ?? []) : i ?? [], p = A(t, l), d = await v({ modelTier: s, temperature: n, config: c });
367
+ return await p.pipe(d.bindTools(a)).invoke(o ?? {}, c);
368
+ }, Te = u.object({
369
369
  name: u.string(),
370
370
  description: u.string(),
371
371
  valueType: u.string(),
372
372
  alias: u.string()
373
- }), Ie = u.object({
374
- fields: u.array(Se)
375
- }), O = (e, t) => e.getFieldAlias(t) ?? void 0, S = (e, t) => O(e, t.name) ?? t.alias ?? "", ke = (e, t) => {
373
+ }), Se = u.object({
374
+ fields: u.array(Te)
375
+ }), O = (e, t) => e.getFieldAlias(t) ?? void 0, S = (e, t) => O(e, t.name) ?? t.alias ?? "", Ie = (e, t) => {
376
376
  const s = O(e, t.name);
377
377
  return !!(s && s !== (t.alias ?? ""));
378
378
  };
379
379
  function C(e, t) {
380
380
  const s = /* @__PURE__ */ new Map();
381
381
  for (const n of e.fields) {
382
- const o = t.fields.find((c) => c.name === n.name), i = S(e, n), a = ke(e, n), l = {
382
+ const i = t.fields.find((l) => l.name === n.name), o = S(e, n), a = Ie(e, n), c = {
383
383
  name: n.name,
384
384
  type: n.type,
385
- alias: a ? i : o?.alias ?? i,
386
- description: o?.description ?? n.description ?? "",
387
- valueType: o?.valueType ?? n.valueType ?? "",
385
+ alias: a ? o : i?.alias ?? o,
386
+ description: i?.description ?? n.description ?? "",
387
+ valueType: i?.valueType ?? n.valueType ?? "",
388
388
  domain: e.getFieldDomain(n.name) ?? void 0
389
389
  };
390
- s.set(n.name, l);
390
+ s.set(n.name, c);
391
391
  }
392
392
  return s;
393
393
  }
394
- const We = async (e) => {
394
+ const Be = async (e) => {
395
395
  const s = await k("field_descriptions_prompt"), n = e.fields.filter((a) => !(S(e, a) && a.description)).map((a) => {
396
- const { name: l, type: c, description: p } = a, d = S(e, a);
397
- return [`Name: ${l}`, `Type: ${c}`, `Alias: ${d}`, `Description: ${p ?? "N/A"}`].join(", ");
396
+ const { name: c, type: l, description: p } = a, d = S(e, a);
397
+ return [`Name: ${c}`, `Type: ${l}`, `Alias: ${d}`, `Description: ${p ?? "N/A"}`].join(", ");
398
398
  }).join(`
399
399
  `);
400
400
  if (n.length === 0)
401
401
  return C(e, { fields: [] });
402
- const o = {
402
+ const i = {
403
403
  existingItemTitle: e.portalItem?.title,
404
404
  existingItemDescription: e.portalItem?.description,
405
405
  existingLayerTitle: e.title,
406
406
  existingLayerDescription: e.portalItem?.description,
407
407
  fieldInformation: n
408
- }, i = await N({
408
+ }, o = await N({
409
409
  promptText: s,
410
- schema: Ie,
411
- inputVariables: o
410
+ schema: Se,
411
+ inputVariables: i
412
412
  });
413
- return C(e, i);
414
- }, Ae = u.object({
413
+ return C(e, o);
414
+ }, ke = u.object({
415
415
  title: u.string(),
416
416
  description: u.string(),
417
417
  name: u.string().nullable()
418
- }), Xe = async (e, t) => {
419
- const n = await k("layer_descriptions_prompt"), o = Array.from(t.values()), i = {
420
- fieldInformation: JSON.stringify(o, null, 2),
418
+ }), We = async (e, t) => {
419
+ const n = await k("layer_descriptions_prompt"), i = Array.from(t.values()), o = {
420
+ fieldInformation: JSON.stringify(i, null, 2),
421
421
  existingLayerTitle: e.title,
422
422
  existingLayerDescription: e.portalItem?.description,
423
423
  existingLayerSnippet: e.portalItem?.snippet,
@@ -425,29 +425,29 @@ const We = async (e) => {
425
425
  };
426
426
  return { ...await N({
427
427
  promptText: n,
428
- schema: Ae,
429
- inputVariables: i
428
+ schema: ke,
429
+ inputVariables: o
430
430
  }), name: e.title ?? null };
431
431
  };
432
432
  export {
433
- Oe as D,
434
- Le as W,
435
- Xe as a,
436
- we as b,
433
+ Ne as D,
434
+ ze as W,
435
+ We as a,
436
+ ye as b,
437
437
  v as c,
438
438
  b as d,
439
- Ke as e,
440
- xe as f,
441
- We as g,
442
- Be as h,
439
+ Le as e,
440
+ ve as f,
441
+ Be as g,
442
+ Ke as h,
443
443
  N as i,
444
- ie as j,
445
- Ne as k,
446
- ve as l,
447
- be as m,
448
- oe as n,
444
+ oe as j,
445
+ $e as k,
446
+ be as l,
447
+ we as m,
448
+ ie as n,
449
449
  ae as o,
450
- ze as p,
451
- Ve as q,
452
- ye as s
450
+ Ve as p,
451
+ Oe as q,
452
+ he as s
453
453
  };