@arcgis/ai-orchestrator 5.1.0-next.59 → 5.1.0-next.60

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 (2) hide show
  1. package/dist/index.js +37 -37
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import R from "@arcgis/core/identity/IdentityManager.js";
2
2
  import E from "@arcgis/core/portal/Portal.js";
3
3
  import { Annotation as b, messagesStateReducer as Z, StateGraph as ee, START as te, END as ne, MemorySaver as re } from "@langchain/langgraph/web";
4
- import { HumanMessage as x, AIMessage as P, isAIMessage as se, isToolMessage as ie } from "@langchain/core/messages";
4
+ import { HumanMessage as N, AIMessage as P, isAIMessage as se, isToolMessage as ie } from "@langchain/core/messages";
5
5
  import { dispatchCustomEvent as C } from "@langchain/core/callbacks/dispatch/web";
6
6
  import g, { z as d } from "zod";
7
7
  import { SystemMessagePromptTemplate as ae, ChatPromptTemplate as oe } from "@langchain/core/prompts";
@@ -12,7 +12,7 @@ import le from "@arcgis/core/request.js";
12
12
  const O = {
13
13
  advanced: "gpt-5.2",
14
14
  default: "gpt-5-mini"
15
- }, k = {
15
+ }, x = {
16
16
  default: "text-embedding-ada-002"
17
17
  }, S = /* @__PURE__ */ new Map();
18
18
  let I = null;
@@ -37,7 +37,7 @@ const me = () => {
37
37
  if (!r)
38
38
  throw new Error(`Model '${t}' is not available in the discovery service.`);
39
39
  return r.endpoint;
40
- }, pe = async (t = "default") => await V(O[t]), q = async (t = "default") => await V(k[t]), ge = async (t) => {
40
+ }, pe = async (t = "default") => await V(O[t]), q = async (t = "default") => await V(x[t]), ge = async (t) => {
41
41
  const e = await ue(), r = await q("default"), n = E.getDefault(), a = (await R.getCredential(`${n.url}/sharing`)).token, i = {
42
42
  type: "generateEmbeddings",
43
43
  webmapEmbeddings: t,
@@ -56,7 +56,7 @@ const me = () => {
56
56
  const t = (await import("./embeddings.worker-GH7zdYqF.js")).default;
57
57
  return new t();
58
58
  }
59
- }, $ = (t, e) => e, he = b.Root({
59
+ }, _ = (t, e) => e, he = b.Root({
60
60
  userInput: b(),
61
61
  messages: b({
62
62
  reducer: Z,
@@ -64,11 +64,11 @@ const me = () => {
64
64
  }),
65
65
  pendingIntents: b({
66
66
  default: () => [],
67
- reducer: $
67
+ reducer: _
68
68
  }),
69
69
  currentIntent: b({
70
70
  default: () => "none",
71
- reducer: $
71
+ reducer: _
72
72
  })
73
73
  }), f = async (t, e) => {
74
74
  await C("trace_message", t, e);
@@ -78,7 +78,7 @@ const me = () => {
78
78
  t.currentIntent = "none", t.pendingIntents = [];
79
79
  }, ye = async (t, e) => {
80
80
  if (t.userInput) {
81
- const n = new x(t.userInput.trim());
81
+ const n = new N(t.userInput.trim());
82
82
  t.messages = [...t.messages, n], fe(t);
83
83
  }
84
84
  const r = e?.configurable?.services.agentRegistry.list().map((n) => n.agent.id) ?? [];
@@ -95,7 +95,7 @@ const me = () => {
95
95
  currentIntent: e,
96
96
  pendingIntents: r
97
97
  };
98
- }, j = 4e3, be = async (t, e) => {
98
+ }, $ = 4e3, be = async (t, e) => {
99
99
  const r = e?.configurable, { agentRegistry: n } = r.services, s = n?.get(t.currentIntent);
100
100
  if (!s)
101
101
  return console.warn(`No agent found for intent: ${t.currentIntent}`), t;
@@ -119,7 +119,7 @@ const me = () => {
119
119
  const c = typeof i?.outputMessage == "string" ? i.outputMessage.trim() : "";
120
120
  if (!c)
121
121
  return t;
122
- const o = c.length > j ? `${c.slice(0, j - 14)}
122
+ const o = c.length > $ ? `${c.slice(0, $ - 14)}
123
123
  [truncated]` : c;
124
124
  return {
125
125
  ...t,
@@ -130,10 +130,10 @@ const me = () => {
130
130
  return n ? typeof n == "function" ? n() : Promise.resolve(n) : new Promise((s, a) => {
131
131
  (typeof queueMicrotask == "function" ? queueMicrotask : setTimeout)(a.bind(null, /* @__PURE__ */ new Error("Unknown variable dynamic import: " + e + (e.split("/").length !== r ? ". Note that variables only represent file names one level deep." : ""))));
132
132
  });
133
- }, D = async (t) => (await Ie(/* @__PURE__ */ Object.assign({ "./field_descriptions_prompt.md": () => import("./field_descriptions_prompt-haMV_aoG.js"), "./intent_prompt.md": () => import("./intent_prompt-CRmsldou.js"), "./layer_descriptions_prompt.md": () => import("./layer_descriptions_prompt-NAaKWdJi.js") }), `./${t}.md`, 2)).default, Ee = (t, e = 3) => t.filter((r) => r instanceof x).slice(-e), Me = (t) => {
133
+ }, k = async (t) => (await Ie(/* @__PURE__ */ Object.assign({ "./field_descriptions_prompt.md": () => import("./field_descriptions_prompt-haMV_aoG.js"), "./intent_prompt.md": () => import("./intent_prompt-CRmsldou.js"), "./layer_descriptions_prompt.md": () => import("./layer_descriptions_prompt-NAaKWdJi.js") }), `./${t}.md`, 2)).default, Ee = (t, e = 3) => t.filter((r) => r.type === "human").slice(-e), Me = (t) => {
134
134
  let e = -1;
135
135
  for (let r = t.length - 1; r >= 0; r--)
136
- if (t[r] instanceof x) {
136
+ if (t[r] instanceof N) {
137
137
  e = r;
138
138
  break;
139
139
  }
@@ -145,7 +145,7 @@ const me = () => {
145
145
  ...r,
146
146
  headers: n
147
147
  });
148
- }, T = async (t = "default", e = 0) => {
148
+ }, D = async (t = "default", e = 0) => {
149
149
  const r = E.getDefault(), n = await R.getCredential(`${r.url}/sharing`), s = O[t], a = await pe(t);
150
150
  return new de({
151
151
  modelName: s,
@@ -158,7 +158,7 @@ const me = () => {
158
158
  }
159
159
  });
160
160
  }, Se = async (t = "default") => {
161
- const e = E.getDefault(), r = await R.getCredential(`${e.url}/sharing`), n = k[t], s = await q(t);
161
+ const e = E.getDefault(), r = await R.getCredential(`${e.url}/sharing`), n = x[t], s = await q(t);
162
162
  return new ce({
163
163
  modelName: n,
164
164
  apiKey: "dummy-key",
@@ -185,11 +185,11 @@ const me = () => {
185
185
  }
186
186
  return !0;
187
187
  });
188
- }, A = (t, e) => {
188
+ }, T = (t, e) => {
189
189
  const r = ae.fromTemplate(t);
190
190
  return oe.fromMessages([r, ...e]);
191
191
  }, xe = async (t) => {
192
- const { promptText: e, modelTier: r, temperature: n, messages: s } = t, a = A(e, s ?? []), i = await T(r, n);
192
+ const { promptText: e, modelTier: r, temperature: n, messages: s } = t, a = T(e, s ?? []), i = await D(r, n);
193
193
  return a.pipe(i);
194
194
  }, it = async (t) => {
195
195
  const { promptText: e, modelTier: r = "default", temperature: n = 0, messages: s, inputVariables: a } = t, c = await (await xe({
@@ -202,11 +202,11 @@ const me = () => {
202
202
  return c;
203
203
  const o = c.content;
204
204
  return typeof o == "string" ? o : JSON.stringify(o);
205
- }, F = async (t) => {
206
- const { promptText: e, modelTier: r = "default", temperature: n = 0, messages: s, inputVariables: a, schema: i } = t, c = A(e, s ?? []), l = (await T(r, n)).withStructuredOutput(i);
205
+ }, A = async (t) => {
206
+ const { promptText: e, modelTier: r = "default", temperature: n = 0, messages: s, inputVariables: a, schema: i } = t, c = T(e, s ?? []), l = (await D(r, n)).withStructuredOutput(i);
207
207
  return await c.pipe(l).invoke(a ?? {});
208
208
  }, at = async (t) => {
209
- const { promptText: e, modelTier: r = "default", temperature: n = 0, messages: s, inputVariables: a, tools: i } = t, c = i.length > 0 ? Re(s ?? []) : s ?? [], o = A(e, c), l = await T(r, n);
209
+ const { promptText: e, modelTier: r = "default", temperature: n = 0, messages: s, inputVariables: a, tools: i } = t, c = i.length > 0 ? Re(s ?? []) : s ?? [], o = T(e, c), l = await D(r, n);
210
210
  return await o.pipe(l.bindTools(i)).invoke(a ?? {});
211
211
  }, ke = d.object({
212
212
  id: d.string().min(1),
@@ -222,7 +222,7 @@ const De = (t) => {
222
222
  }, Te = async (t, e) => {
223
223
  try {
224
224
  await f({ text: "Asking LLM to detect intents" }, e);
225
- const n = await D("intent_prompt"), i = (e?.configurable?.services.agentRegistry?.list() ?? []).map(({ agent: y }) => ({
225
+ const n = await k("intent_prompt"), i = (e?.configurable?.services.agentRegistry?.list() ?? []).map(({ agent: y }) => ({
226
226
  id: y.id,
227
227
  name: y.name,
228
228
  description: y.description
@@ -237,7 +237,7 @@ const De = (t) => {
237
237
  `), o = i.length, l = De(i), p = {
238
238
  maxIntents: o,
239
239
  registeredAgents: c
240
- }, m = await F({
240
+ }, m = await A({
241
241
  promptText: n,
242
242
  schema: l,
243
243
  messages: Ee(t.messages),
@@ -402,9 +402,9 @@ function We(t) {
402
402
  }
403
403
  };
404
404
  }
405
- const B = "0.1", v = 1536, J = "openai", X = k.default, L = `Name: {name}
405
+ const B = "0.1", v = 1536, J = "openai", X = x.default, F = `Name: {name}
406
406
  Title: {title}
407
- Description: {description}`, _ = `Name: {name}
407
+ Description: {description}`, L = `Name: {name}
408
408
  Alias: {alias}
409
409
  Description: {description}`, Q = d.object({
410
410
  schemaVersion: d.literal(B),
@@ -414,8 +414,8 @@ Description: {description}`, Q = d.object({
414
414
  model: d.literal(X),
415
415
  dimensions: d.literal(v),
416
416
  templates: d.object({
417
- layer: d.string().default(L),
418
- field: d.string().default(_)
417
+ layer: d.string().default(F),
418
+ field: d.string().default(L)
419
419
  })
420
420
  }),
421
421
  layers: d.array(
@@ -648,7 +648,7 @@ const He = g.object({
648
648
  }), Oe = g.object({
649
649
  fields: g.array(He)
650
650
  });
651
- function W(t, e) {
651
+ function j(t, e) {
652
652
  const r = /* @__PURE__ */ new Map();
653
653
  for (const n of t.fields) {
654
654
  const s = e.fields.find((i) => i.name === n.name), a = {
@@ -664,38 +664,38 @@ function W(t, e) {
664
664
  return r;
665
665
  }
666
666
  const Ve = async (t) => {
667
- const r = await D("field_descriptions_prompt"), n = t.fields.filter((i) => !(i.alias && i.description)).map((i) => {
667
+ const r = await k("field_descriptions_prompt"), n = t.fields.filter((i) => !(i.alias && i.description)).map((i) => {
668
668
  const { name: c, type: o, alias: l, description: p } = i;
669
669
  return [`Name: ${c}`, `Type: ${o}`, `Alias: ${l}`, `Description: ${p ?? "N/A"}`].join(", ");
670
670
  }).join(`
671
671
  `);
672
672
  if (n.length === 0)
673
- return W(t, { fields: [] });
673
+ return j(t, { fields: [] });
674
674
  const s = {
675
675
  existingItemTitle: t.portalItem?.title,
676
676
  existingItemDescription: t.portalItem?.description,
677
677
  existingLayerTitle: t.title,
678
678
  existingLayerDescription: t.portalItem?.description,
679
679
  fieldInformation: n
680
- }, a = await F({
680
+ }, a = await A({
681
681
  promptText: r,
682
682
  schema: Oe,
683
683
  inputVariables: s
684
684
  });
685
- return W(t, a);
685
+ return j(t, a);
686
686
  }, qe = g.object({
687
687
  title: g.string(),
688
688
  description: g.string(),
689
689
  name: g.string().nullable()
690
690
  }), ze = async (t, e) => {
691
- const n = await D("layer_descriptions_prompt"), s = Array.from(e.values()), a = {
691
+ const n = await k("layer_descriptions_prompt"), s = Array.from(e.values()), a = {
692
692
  fieldInformation: JSON.stringify(s, null, 2),
693
693
  existingLayerTitle: t.title,
694
694
  existingLayerDescription: t.portalItem?.description,
695
695
  existingLayerSnippet: t.portalItem?.snippet,
696
696
  layerGeometryType: t.geometryType
697
697
  };
698
- return { ...await F({
698
+ return { ...await A({
699
699
  promptText: n,
700
700
  schema: qe,
701
701
  inputVariables: a
@@ -721,8 +721,8 @@ const Ve = async (t) => {
721
721
  model: X,
722
722
  dimensions: v,
723
723
  templates: {
724
- layer: L,
725
- field: _
724
+ layer: F,
725
+ field: L
726
726
  }
727
727
  },
728
728
  layers: r
@@ -733,7 +733,7 @@ const Ve = async (t) => {
733
733
  }, Ke = async (t) => {
734
734
  const e = [], r = [];
735
735
  for (const [i, { fieldRegistry: c, layerItem: o }] of t.entries()) {
736
- const l = N(L, {
736
+ const l = W(F, {
737
737
  name: o.name,
738
738
  title: o.title,
739
739
  description: o.description
@@ -748,7 +748,7 @@ const Ve = async (t) => {
748
748
  fields: []
749
749
  };
750
750
  for (const [, m] of c.entries()) {
751
- const w = N(_, {
751
+ const w = W(L, {
752
752
  name: m.name,
753
753
  alias: m.alias,
754
754
  description: m.description
@@ -767,7 +767,7 @@ const Ve = async (t) => {
767
767
  return { layers: r.map((i) => (i.vector = n[s++], i.fields.forEach((c) => {
768
768
  c.vector = n[s++];
769
769
  }), i)) };
770
- }, N = (t, e) => t.replace(/\{(\w+)\}/gu, (r, n) => e[n] ?? ""), ct = (t, e) => {
770
+ }, W = (t, e) => t.replace(/\{(\w+)\}/gu, (r, n) => e[n] ?? ""), ct = (t, e) => {
771
771
  if (t.length !== e.length)
772
772
  throw new Error("Vectors must be the same length");
773
773
  let r = 0, n = 0, s = 0;
@@ -786,7 +786,7 @@ export {
786
786
  ct as cosineSimilarity,
787
787
  ot as createWebmapEmbeddings,
788
788
  G as getEmbeddings,
789
- F as invokeStructuredPrompt,
789
+ A as invokeStructuredPrompt,
790
790
  it as invokeTextPrompt,
791
791
  at as invokeToolPrompt,
792
792
  f as sendTraceMessage,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arcgis/ai-orchestrator",
3
- "version": "5.1.0-next.59",
3
+ "version": "5.1.0-next.60",
4
4
  "description": "ArcGIS AI Orchestrator Package",
5
5
  "homepage": "https://developers.arcgis.com/javascript/latest/",
6
6
  "type": "module",