@arcgis/ai-components 5.2.0-next.93 → 5.2.0-next.95

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 (69) hide show
  1. package/dist/cdn/{HIPQ3VRW.js → 2O4DON37.js} +1 -1
  2. package/dist/cdn/{7DFXYMEA.js → 2XUL3RTX.js} +1 -1
  3. package/dist/cdn/{YQSU6IUO.js → 5HBAJ57P.js} +1 -1
  4. package/dist/cdn/{EYNEYD34.js → 5MK44FNO.js} +1 -1
  5. package/dist/cdn/{FDDQ67BG.js → 6ECRQVHY.js} +1 -1
  6. package/dist/cdn/{LPR72QZF.js → 6KN5LUAV.js} +1 -1
  7. package/dist/cdn/{V6F3HEK7.js → 6OOZSZRJ.js} +1 -1
  8. package/dist/cdn/{TMZ6DF22.js → 6P44KOKX.js} +1 -1
  9. package/dist/cdn/{QCFICJ7U.js → 6YYPVU7H.js} +1 -1
  10. package/dist/cdn/{OWTGH34K.js → 7VUSIGEM.js} +1 -1
  11. package/dist/cdn/{4EBLRHYE.js → AA4FBYKK.js} +1 -1
  12. package/dist/cdn/{VNJMTA6O.js → ANRQWYU2.js} +1 -1
  13. package/dist/cdn/{HKSFWTWK.js → ASR3I43T.js} +1 -1
  14. package/dist/cdn/{ZVGUAOXE.js → B2JDVLA6.js} +1 -1
  15. package/dist/cdn/{FQH3HOFH.js → B2T7D57Y.js} +1 -1
  16. package/dist/cdn/{AZCIDPML.js → C4FEETBZ.js} +1 -1
  17. package/dist/cdn/{X3COUAXY.js → COH3QXWG.js} +3 -3
  18. package/dist/cdn/{AT4XVTJR.js → D5UFYQHN.js} +1 -1
  19. package/dist/cdn/{COL6QYGQ.js → EKWM5K4K.js} +1 -1
  20. package/dist/cdn/{WNNMKCKS.js → EYOWRGDP.js} +1 -1
  21. package/dist/cdn/{RSNGZQCQ.js → F5NIRETW.js} +1 -1
  22. package/dist/cdn/{HMUWQCXU.js → FG647IP6.js} +1 -1
  23. package/dist/cdn/{6KFMRBAA.js → FUF3NAU7.js} +1 -1
  24. package/dist/cdn/G2EGT3CF.js +6 -0
  25. package/dist/cdn/{PEYYWXFE.js → G7OMHU2B.js} +1 -1
  26. package/dist/cdn/{OL5656NI.js → HAEFC2SJ.js} +1 -1
  27. package/dist/cdn/{ZQMBJ6MI.js → HDACNIZF.js} +1 -1
  28. package/dist/cdn/{WR2SQX3J.js → HHUQXL3R.js} +1 -1
  29. package/dist/cdn/{JJJZ7FOM.js → HNADFHYH.js} +1 -1
  30. package/dist/cdn/{C5ZL5Z52.js → IC3LG6TH.js} +1 -1
  31. package/dist/cdn/JCOA24UH.js +3 -0
  32. package/dist/cdn/{SUYWKYWI.js → LNCT4S4I.js} +1 -1
  33. package/dist/cdn/{OYSPNIJI.js → MX7OEO5Z.js} +1 -1
  34. package/dist/cdn/{EKB7CAMM.js → MXTXJKFE.js} +1 -1
  35. package/dist/cdn/MY47B3CE.js +3 -0
  36. package/dist/cdn/{KCU4FWF7.js → NEZXHUAL.js} +1 -1
  37. package/dist/cdn/{DP6O6PMH.js → NSHLOFIY.js} +1 -1
  38. package/dist/cdn/{PSYRZMX2.js → NZSOJ726.js} +1 -1
  39. package/dist/cdn/{SHD6YFSR.js → O4NVW75A.js} +1 -1
  40. package/dist/cdn/{4HDDRBIY.js → OE3GW5LE.js} +1 -1
  41. package/dist/cdn/{ZLWWWTH4.js → R2PQVY4O.js} +1 -1
  42. package/dist/cdn/{2PTPBAIN.js → SXM4NUT5.js} +1 -1
  43. package/dist/cdn/{FUZ77UGP.js → UAANWCMU.js} +1 -1
  44. package/dist/cdn/{WP7ORLSB.js → WGO5SER7.js} +1 -1
  45. package/dist/cdn/{4KOV2NEI.js → WJXXOKGA.js} +1 -1
  46. package/dist/cdn/{MKOQJXQQ.js → WSWB3B7B.js} +1 -1
  47. package/dist/cdn/{W5JPJWMM.js → YWN57GH4.js} +1 -1
  48. package/dist/cdn/{4NJ2FF7H.js → ZDV4K4WG.js} +1 -1
  49. package/dist/cdn/agent-utils/index.js +1 -1
  50. package/dist/cdn/index.js +1 -1
  51. package/dist/chunks/baseAgentState.js +32 -30
  52. package/dist/chunks/dataExplorationGraph.js +2 -2
  53. package/dist/chunks/orchestrator.js +301 -249
  54. package/dist/components/arcgis-assistant/customElement.d.ts +24 -0
  55. package/dist/components/arcgis-assistant/customElement.js +275 -270
  56. package/dist/docs/api.json +1 -1
  57. package/dist/docs/docs.json +1 -1
  58. package/dist/docs/vscode.html-custom-data.json +1 -1
  59. package/dist/docs/web-types.json +1 -1
  60. package/dist/loader.js +1 -1
  61. package/dist/types/lumina.d.ts +1 -1
  62. package/dist/types/preact.d.ts +1 -1
  63. package/dist/types/react.d.ts +1 -1
  64. package/dist/types/stencil.d.ts +1 -1
  65. package/dist/utils/index.d.ts +57 -30
  66. package/package.json +5 -5
  67. package/dist/cdn/6VJXUIXY.js +0 -3
  68. package/dist/cdn/7M6VKBTK.js +0 -6
  69. package/dist/cdn/PKUDO2RC.js +0 -3
@@ -1,83 +1,127 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import A from "@arcgis/core/identity/IdentityManager.js";
3
- import M from "@arcgis/core/portal/Portal.js";
4
- import { j as _, k as x, D, n as F, o as L, W as $ } from "./generateLayerDescriptions.js";
5
- import { isGraphInterrupt as W, StateGraph as q, START as T, END as H, MemorySaver as j } from "@langchain/langgraph/web";
6
- import { generateGuid as U } from "@arcgis/toolkit/string";
7
- import { HumanMessage as P, AIMessage as O } from "@langchain/core/messages";
8
- import { s as m } from "./index.js";
9
- import { BaseCallbackHandler as N } from "@langchain/core/callbacks/base";
10
- import * as G from "@arcgis/core/core/reactiveUtils.js";
2
+ import M from "@arcgis/core/identity/IdentityManager.js";
3
+ import _ from "@arcgis/core/portal/Portal.js";
4
+ import { j as $, k as b, D, n as F, o as L, W } from "./generateLayerDescriptions.js";
5
+ import { isGraphInterrupt as q, StateGraph as T, START as j, END as H, MemorySaver as P } from "@langchain/langgraph/web";
6
+ import { generateGuid as A } from "@arcgis/toolkit/string";
7
+ import { HumanMessage as U, AIMessage as O } from "@langchain/core/messages";
8
+ import { s as p } from "./index.js";
9
+ import { BaseCallbackHandler as G } from "@langchain/core/callbacks/base";
10
+ import * as N from "@arcgis/core/core/reactiveUtils.js";
11
11
  import V from "@arcgis/core/layers/FeatureLayer.js";
12
12
  import z from "@arcgis/core/request.js";
13
- const B = async (t) => {
14
- const e = await Q(), r = await _("default"), s = M.getDefault(), a = (await A.getCredential(`${s.url}/sharing`)).token, i = {
13
+ const B = async (n) => {
14
+ const e = await Q(), r = await $("default"), s = _.getDefault(), a = (await M.getCredential(`${s.url}/sharing`)).token, i = {
15
15
  type: "generateEmbeddings",
16
- webmapEmbeddings: t,
16
+ webmapEmbeddings: n,
17
17
  auth: { apiUrl: r, token: a }
18
18
  };
19
- return e.postMessage(i), await new Promise((c, d) => {
20
- const o = (g) => {
21
- g.data === "completed" && (e.removeEventListener("message", o), c());
19
+ return e.postMessage(i), await new Promise((o, d) => {
20
+ const c = (g) => {
21
+ g.data === "completed" && (e.removeEventListener("message", c), o());
22
22
  }, u = (g) => {
23
- e.removeEventListener("message", o), d(g instanceof Error ? g : new Error("Embeddings worker error"));
23
+ e.removeEventListener("message", c), d(g instanceof Error ? g : new Error("Embeddings worker error"));
24
24
  };
25
- e.addEventListener("message", o), e.addEventListener("error", u, { once: !0 });
25
+ e.addEventListener("message", c), e.addEventListener("error", u, { once: !0 });
26
26
  }), e;
27
27
  }, Q = async () => {
28
28
  {
29
- const t = (await import("./embeddings.worker.js")).default;
30
- return new t();
31
- }
32
- }, J = (t) => {
33
- t.currentIntent = "none";
34
- }, K = async (t, e) => {
35
- const r = x(e);
36
- if (t.agentExecutionContext.userRequest) {
37
- const n = new P(t.agentExecutionContext.userRequest.trim());
38
- t.agentExecutionContext.messages = [...t.agentExecutionContext.messages, n], J(t);
39
- }
40
- const s = r?.services.agentRegistry.list().map((n) => n.agent.id) ?? [];
41
- return await m({ text: `Available agents: ${[...s].join(", ")}` }, e), await m({ text: "Analyzing user input" }, e), t;
42
- }, X = async (t, e) => (await m({ text: "Exiting..." }, e), t), E = (t) => typeof t == "object" && t !== null && !Array.isArray(t), Y = (t, e) => {
43
- if (!E(t)) {
44
- t !== void 0 && console.warn(`Agent "${e}" returned invalid sharedStatePatch. Ignoring it.`);
29
+ const n = (await import("./embeddings.worker.js")).default;
30
+ return new n();
31
+ }
32
+ }, K = (n) => {
33
+ n.currentIntent = "none";
34
+ }, J = async (n, e) => {
35
+ const r = b(e);
36
+ if (n.agentExecutionContext.userRequest) {
37
+ const t = new U(n.agentExecutionContext.userRequest.trim());
38
+ n.agentExecutionContext.messages = [...n.agentExecutionContext.messages, t], K(n);
39
+ }
40
+ const s = r?.services.agentRegistry.list().map((t) => t.agent.id) ?? [];
41
+ return await p({ text: `Available agents: ${[...s].join(", ")}` }, e), await p({ text: "Analyzing user input" }, e), n;
42
+ }, X = async (n, e) => (await p({ text: "Exiting..." }, e), n), E = (n) => typeof n == "object" && n !== null && !Array.isArray(n), Y = (n, e) => {
43
+ if (!E(n)) {
44
+ n !== void 0 && console.warn(`Agent "${e}" returned invalid sharedStatePatch. Ignoring it.`);
45
45
  return;
46
46
  }
47
47
  const r = {};
48
- for (const [s, n] of Object.entries(t)) {
49
- if (!E(n) || !("value" in n)) {
48
+ for (const [s, t] of Object.entries(n)) {
49
+ if (!E(t) || !("value" in t)) {
50
50
  console.warn(
51
51
  `Agent "${e}" returned invalid sharedStatePatch entry for key "${s}". Ignoring that entry.`
52
52
  );
53
53
  continue;
54
54
  }
55
- r[s] = { value: n.value };
55
+ r[s] = { value: t.value };
56
56
  }
57
57
  return r;
58
- }, Z = (t) => {
59
- const { previousSharedState: e, patch: r, agentId: s } = t;
58
+ }, Z = (n) => {
59
+ const { previousSharedState: e, patch: r, agentId: s } = n;
60
60
  if (!r)
61
61
  return e;
62
- const n = Date.now(), a = {
62
+ const t = Date.now(), a = {
63
63
  ...e
64
64
  };
65
- for (const [i, c] of Object.entries(r))
66
- c?.value !== void 0 && (a[i] = {
67
- value: c.value,
65
+ for (const [i, o] of Object.entries(r))
66
+ o?.value !== void 0 && (a[i] = {
67
+ value: o.value,
68
68
  meta: {
69
69
  updatedByAgentId: s,
70
- updatedAt: n
70
+ updatedAt: t
71
71
  }
72
72
  });
73
73
  return a;
74
- }, S = (t) => {
75
- if (typeof t != "string")
74
+ }, ee = 256, te = /* @__PURE__ */ new Set(["point", "polyline", "polygon", "extent", "custom"]), ne = (n) => typeof n == "object" && n !== null && !Array.isArray(n), re = (n, e) => {
75
+ if (n === void 0)
76
76
  return;
77
- const e = t.trim();
77
+ if (!Array.isArray(n)) {
78
+ console.warn(`Agent "${e}" returned invalid sharedResourceAdditions. Ignoring it.`);
79
+ return;
80
+ }
81
+ const r = [];
82
+ for (const [s, t] of n.entries()) {
83
+ if (!ne(t) || typeof t.kind != "string" || !te.has(t.kind) || typeof t.description != "string" || !t.description.trim() || !("payload" in t) || t.payload === void 0) {
84
+ console.warn(
85
+ `Agent "${e}" returned invalid sharedResourceAdditions entry at index ${s}. Ignoring that entry.`
86
+ );
87
+ continue;
88
+ }
89
+ let a;
90
+ try {
91
+ a = structuredClone(t.payload);
92
+ } catch {
93
+ console.warn(
94
+ `Agent "${e}" returned invalid sharedResourceAdditions entry at index ${s}. Ignoring that entry.`
95
+ );
96
+ continue;
97
+ }
98
+ r.push({
99
+ kind: t.kind,
100
+ description: t.description.trim().slice(0, ee),
101
+ payload: a
102
+ });
103
+ }
104
+ return r.length ? r : void 0;
105
+ }, se = (n) => {
106
+ const { previousSharedResources: e, additions: r, agentId: s } = n;
107
+ if (!r?.length)
108
+ return e;
109
+ const t = Date.now(), a = r.map((i) => ({
110
+ ...i,
111
+ id: A(),
112
+ meta: {
113
+ createdByAgentId: s,
114
+ createdAt: t
115
+ }
116
+ }));
117
+ return [...e, ...a].slice(-50);
118
+ }, R = (n) => {
119
+ if (typeof n != "string")
120
+ return;
121
+ const e = n.trim();
78
122
  return e || void 0;
79
- }, ee = (t) => {
80
- switch (t) {
123
+ }, ae = (n) => {
124
+ switch (n) {
81
125
  case "failed":
82
126
  return "Agent failed without a summary.";
83
127
  case "unknown":
@@ -87,166 +131,173 @@ const B = async (t) => {
87
131
  default:
88
132
  return "Agent completed without a summary.";
89
133
  }
90
- }, te = (t, e) => {
91
- const r = S(e?.outputMessage), s = S(e?.summary), n = e?.status, a = n === "success" || n === "failed" ? n : "unknown";
92
- a === "unknown" && console.warn(`Agent "${t}" returned missing/invalid status. Defaulting to "unknown".`);
93
- const i = Y(e?.sharedStatePatch, t);
134
+ }, ie = (n, e) => {
135
+ const r = R(e?.outputMessage), s = R(e?.summary), t = e?.status, a = t === "success" || t === "failed" ? t : "unknown";
136
+ a === "unknown" && console.warn(`Agent "${n}" returned missing/invalid status. Defaulting to "unknown".`);
137
+ const i = Y(e?.sharedStatePatch, n), o = re(e?.sharedResourceAdditions, n);
94
138
  return {
95
139
  outputMessage: r,
96
- summary: s ?? r ?? ee(a),
140
+ summary: s ?? r ?? ae(a),
97
141
  status: a,
98
- sharedStatePatch: i
142
+ sharedStatePatch: i,
143
+ sharedResourceAdditions: o
99
144
  };
100
- }, b = 4e3, ne = async (t, e) => {
101
- const r = x(e);
145
+ }, x = 4e3, oe = async (n, e) => {
146
+ const r = b(e);
102
147
  if (e?.signal?.aborted)
103
- return await m({ text: "Run cancelled; skipping agent execution" }, e), {
104
- ...t,
148
+ return await p({ text: "Run cancelled; skipping agent execution" }, e), {
149
+ ...n,
105
150
  currentIntent: "none",
106
151
  requiresFollowUp: !1
107
152
  };
108
- const { agentRegistry: s } = r?.services ?? {}, n = s?.get(t.currentIntent);
109
- if (!n)
110
- return console.warn(`No agent found for intent: ${t.currentIntent}`), t;
111
- await m({ text: `Executing registered agent: ${n.agent.name}` }, e);
153
+ const { agentRegistry: s } = r?.services ?? {}, t = s?.get(n.currentIntent);
154
+ if (!t)
155
+ return console.warn(`No agent found for intent: ${n.currentIntent}`), n;
156
+ await p({ text: `Executing registered agent: ${t.agent.name}` }, e);
112
157
  const a = {
113
158
  ...e ?? {},
114
159
  metadata: {
115
160
  ...e?.metadata,
116
- agentId: n.agent.id
161
+ agentId: t.agent.id
117
162
  },
118
163
  configurable: {
119
164
  ...r ?? {},
120
- agentId: n.agent.id,
121
- context: n.getContext ? await n.getContext() : void 0
165
+ agentId: t.agent.id,
166
+ context: t.getContext ? await t.getContext() : void 0
122
167
  }
123
168
  };
124
169
  let i;
125
170
  try {
126
- const o = await n.agent.createGraph().compile().invoke(
171
+ const c = await t.agent.createGraph().compile().invoke(
127
172
  {
128
173
  agentExecutionContext: {
129
- ...t.agentExecutionContext,
174
+ ...n.agentExecutionContext,
130
175
  // deep clone on messages did not work in agents, so its a shallow clone here.
131
- messages: [...t.agentExecutionContext.messages],
176
+ messages: [...n.agentExecutionContext.messages],
132
177
  // deep clone to prevent accidental mutations by agents
133
- priorSteps: structuredClone(t.agentExecutionContext.priorSteps ?? []),
134
- sharedState: structuredClone(t.agentExecutionContext.sharedState ?? {})
178
+ priorSteps: structuredClone(n.agentExecutionContext.priorSteps ?? []),
179
+ sharedState: structuredClone(n.agentExecutionContext.sharedState ?? {}),
180
+ sharedResources: structuredClone(n.agentExecutionContext.sharedResources ?? [])
135
181
  }
136
182
  },
137
183
  a
138
184
  );
139
- i = te(n.agent.name, o), await m({ text: `Finished executing registered agent: ${n.agent.name}` }, e);
140
- } catch (o) {
141
- if (W(o) || e?.signal?.aborted || o instanceof Error && o.name === "AbortError")
142
- throw o;
143
- const u = o instanceof Error ? o.message : String(o);
144
- console.error(`Agent "${n.agent.name}" failed:`, o), await m({ text: `Registered agent failed: ${n.agent.name}. ${u}` }, e), i = {
185
+ i = ie(t.agent.name, c), await p({ text: `Finished executing registered agent: ${t.agent.name}` }, e);
186
+ } catch (c) {
187
+ if (q(c) || e?.signal?.aborted || c instanceof Error && c.name === "AbortError")
188
+ throw c;
189
+ const u = c instanceof Error ? c.message : String(c);
190
+ console.error(`Agent "${t.agent.name}" failed:`, c), await p({ text: `Registered agent failed: ${t.agent.name}. ${u}` }, e), i = {
145
191
  status: "failed",
146
192
  outputMessage: `Agent execution failed: ${u}`,
147
193
  summary: `Agent execution failed: ${u}`
148
194
  };
149
195
  }
150
- const c = i.outputMessage, d = [...t.agentExecutionContext.messages];
151
- if (c) {
152
- const o = c.length > b ? `${c.slice(0, b - 14)}
153
- [truncated]` : c;
154
- d.push(new O(o));
196
+ const o = i.outputMessage, d = [...n.agentExecutionContext.messages];
197
+ if (o) {
198
+ const c = o.length > x ? `${o.slice(0, x - 14)}
199
+ [truncated]` : o;
200
+ d.push(new O(c));
155
201
  }
156
202
  return {
157
- ...t,
158
- stepCount: t.stepCount + 1,
159
- lastExecutedAgent: n.agent.id,
160
- requiresFollowUp: i.status === "failed" ? !0 : t.requiresFollowUp,
161
- finalOutputMessage: c ?? "",
203
+ ...n,
204
+ stepCount: n.stepCount + 1,
205
+ lastExecutedAgent: t.agent.id,
206
+ requiresFollowUp: i.status === "failed" ? !0 : n.requiresFollowUp,
207
+ finalOutputMessage: o ?? "",
162
208
  agentExecutionContext: {
163
- ...t.agentExecutionContext,
209
+ ...n.agentExecutionContext,
164
210
  messages: d,
165
211
  priorSteps: [
166
- ...t.agentExecutionContext.priorSteps ?? [],
212
+ ...n.agentExecutionContext.priorSteps ?? [],
167
213
  {
168
- agentId: n.agent.id,
169
- assignedTask: t.agentExecutionContext.assignedTask,
214
+ agentId: t.agent.id,
215
+ assignedTask: n.agentExecutionContext.assignedTask,
170
216
  summary: i?.summary || "No summary provided.",
171
217
  status: i?.status || "unknown"
172
218
  }
173
219
  ],
174
220
  sharedState: Z({
175
- previousSharedState: t.agentExecutionContext.sharedState,
221
+ previousSharedState: n.agentExecutionContext.sharedState,
176
222
  patch: i.sharedStatePatch,
177
- agentId: n.agent.id
223
+ agentId: t.agent.id
224
+ }),
225
+ sharedResources: se({
226
+ previousSharedResources: n.agentExecutionContext.sharedResources,
227
+ additions: i.sharedResourceAdditions,
228
+ agentId: t.agent.id
178
229
  })
179
230
  }
180
231
  };
181
- }, re = async (t, e) => {
182
- if (t.routing.mode !== "direct")
232
+ }, ce = async (n, e) => {
233
+ if (n.routing.mode !== "direct")
183
234
  throw new Error("Direct agent assignment requires direct routing.");
184
- return await m({ text: `Doing a direct route to agent: ${t.routing.agentId}` }, e), {
185
- ...t,
186
- currentIntent: t.routing.agentId,
235
+ return await p({ text: `Doing a direct route to agent: ${n.routing.agentId}` }, e), {
236
+ ...n,
237
+ currentIntent: n.routing.agentId,
187
238
  requiresFollowUp: !1,
188
239
  agentExecutionContext: {
189
- ...t.agentExecutionContext,
190
- assignedTask: t.agentExecutionContext.userRequest
240
+ ...n.agentExecutionContext,
241
+ assignedTask: n.agentExecutionContext.userRequest
191
242
  }
192
243
  };
193
- }, se = 3, ae = (t) => t.routing.mode === "direct" ? "assignDirectAgent" : "intentLLM", ie = (t) => t.routing.mode === "direct" || t.stepCount >= se || !t.requiresFollowUp ? "exit" : "intentLLM", oe = () => new q(D).addNode("ingestInput", K).addNode("assignDirectAgent", re).addNode("intentLLM", F).addNode("executeRegisteredAgent", ne).addNode("exit", X).addEdge(T, "ingestInput").addConditionalEdges("ingestInput", ae).addEdge("assignDirectAgent", "executeRegisteredAgent").addConditionalEdges("intentLLM", (e) => e.currentIntent === "none" || e.currentIntent === e.lastExecutedAgent ? "exit" : "executeRegisteredAgent").addConditionalEdges("executeRegisteredAgent", ie).addEdge("exit", H), ce = (t, e) => {
194
- const r = t.output?.usage_metadata ?? e.usage_metadata, s = t.output?.llmOutput?.tokenUsage, n = r?.input_tokens ?? s?.promptTokens, a = r?.output_tokens ?? s?.completionTokens, i = r?.total_tokens ?? s?.totalTokens;
195
- if (n === void 0 || a === void 0 || i === void 0)
244
+ }, de = 3, ue = (n) => n.routing.mode === "direct" ? "assignDirectAgent" : "intentLLM", ge = (n) => n.routing.mode === "direct" || n.stepCount >= de || !n.requiresFollowUp ? "exit" : "intentLLM", le = () => new T(D).addNode("ingestInput", J).addNode("assignDirectAgent", ce).addNode("intentLLM", F).addNode("executeRegisteredAgent", oe).addNode("exit", X).addEdge(j, "ingestInput").addConditionalEdges("ingestInput", ue).addEdge("assignDirectAgent", "executeRegisteredAgent").addConditionalEdges("intentLLM", (e) => e.currentIntent === "none" || e.currentIntent === e.lastExecutedAgent ? "exit" : "executeRegisteredAgent").addConditionalEdges("executeRegisteredAgent", ge).addEdge("exit", H), he = (n, e) => {
245
+ const r = n.output?.usage_metadata ?? e.usage_metadata, s = n.output?.llmOutput?.tokenUsage, t = r?.input_tokens ?? s?.promptTokens, a = r?.output_tokens ?? s?.completionTokens, i = r?.total_tokens ?? s?.totalTokens;
246
+ if (t === void 0 || a === void 0 || i === void 0)
196
247
  return;
197
- const c = r?.input_token_details?.cache_read, d = r?.output_token_details?.reasoning;
248
+ const o = r?.input_token_details?.cache_read, d = r?.output_token_details?.reasoning;
198
249
  return {
199
- input: n,
250
+ input: t,
200
251
  output: a,
201
252
  total: i,
202
- ...c !== void 0 && { cacheRead: c },
253
+ ...o !== void 0 && { cacheRead: o },
203
254
  ...d !== void 0 && { reasoning: d }
204
255
  };
205
- }, de = (t, e, r, s) => {
206
- switch (t) {
256
+ }, pe = (n, e, r, s) => {
257
+ switch (n) {
207
258
  case "chat_model":
208
259
  case "llm":
209
260
  return "model";
210
261
  case "tool":
211
262
  case "retriever":
212
- return t;
263
+ return n;
213
264
  case "chain":
214
265
  return !s || e === "LangGraph" ? "workflow" : r === e ? "node" : "chain";
215
266
  default:
216
267
  return;
217
268
  }
218
- }, ue = (t) => {
219
- if (t instanceof Error)
220
- return { message: t.message, name: t.name };
221
- const e = t, r = typeof e?.message == "string" ? e.message : String(t ?? "Unknown runtime error"), s = typeof e?.name == "string" ? e.name : void 0;
269
+ }, me = (n) => {
270
+ if (n instanceof Error)
271
+ return { message: n.message, name: n.name };
272
+ const e = n, r = typeof e?.message == "string" ? e.message : String(n ?? "Unknown runtime error"), s = typeof e?.name == "string" ? e.name : void 0;
222
273
  return { message: r, ...s && { name: s } };
223
- }, ge = ({
224
- event: t,
274
+ }, ye = ({
275
+ event: n,
225
276
  runId: e,
226
277
  parentSpanId: r,
227
278
  timestamp: s
228
279
  }) => {
229
- const n = /^on_(.+)_(start|end|error)$/u.exec(t.event);
230
- if (!n)
280
+ const t = /^on_(.+)_(start|end|error)$/u.exec(n.event);
281
+ if (!t)
231
282
  return;
232
- const [, a, i] = n, c = t.metadata ?? {}, d = c.langgraph_node, o = de(a, t.name, d, r);
233
- if (!o)
283
+ const [, a, i] = t, o = n.metadata ?? {}, d = o.langgraph_node, c = pe(a, n.name, d, r);
284
+ if (!c)
234
285
  return;
235
- const u = c.agentId, g = c.model ?? c.ls_model_name, l = t.data, y = i === "end" && o === "model" ? ce(l, c) : void 0, h = t.tags?.includes("langsmith:hidden") || d === "__start__", v = {
286
+ const u = o.agentId, g = o.model ?? o.ls_model_name, l = n.data, f = i === "end" && c === "model" ? he(l, o) : void 0, h = n.tags?.includes("langsmith:hidden") || d === "__start__", v = {
236
287
  ...g && { model: g },
237
- ...y && { tokenUsage: y },
288
+ ...f && { tokenUsage: f },
238
289
  ...h && { internal: !0 }
239
290
  }, w = {
240
- id: t.run_id,
291
+ id: n.run_id,
241
292
  ...r && { parentId: r },
242
- label: t.name,
243
- type: o,
293
+ label: n.name,
294
+ type: c,
244
295
  ...Object.keys(v).length && { metadata: v }
245
- }, p = { runId: e, timestamp: s, type: "runtime", ...u && { agentId: u } };
296
+ }, m = { runId: e, timestamp: s, type: "runtime", ...u && { agentId: u } };
246
297
  switch (i) {
247
298
  case "start":
248
299
  return {
249
- ...p,
300
+ ...m,
250
301
  phase: "started",
251
302
  span: {
252
303
  ...w,
@@ -255,7 +306,7 @@ const B = async (t) => {
255
306
  };
256
307
  case "end":
257
308
  return {
258
- ...p,
309
+ ...m,
259
310
  phase: "completed",
260
311
  span: {
261
312
  ...w,
@@ -263,12 +314,12 @@ const B = async (t) => {
263
314
  }
264
315
  };
265
316
  case "error":
266
- return { ...p, phase: "failed", span: { ...w, error: ue(l?.error) } };
317
+ return { ...m, phase: "failed", span: { ...w, error: me(l?.error) } };
267
318
  default:
268
319
  return;
269
320
  }
270
321
  };
271
- class R {
322
+ class S {
272
323
  constructor() {
273
324
  this.agentRegistry = /* @__PURE__ */ new Map();
274
325
  }
@@ -285,7 +336,7 @@ class R {
285
336
  return [...this.agentRegistry.values()];
286
337
  }
287
338
  }
288
- class le {
339
+ class fe {
289
340
  /**
290
341
  * Create a new InterruptHandler tied to a specific compiled graph and config.
291
342
  */
@@ -309,7 +360,7 @@ class le {
309
360
  agentId: e.agentId,
310
361
  id: e.id,
311
362
  payload: r
312
- }, n = this.graph.streamEvents(null, {
363
+ }, t = this.graph.streamEvents(null, {
313
364
  ...this.config,
314
365
  configurable: {
315
366
  ...this.config.configurable,
@@ -318,7 +369,7 @@ class le {
318
369
  subgraphs: !0,
319
370
  version: "v2"
320
371
  });
321
- this.resolveWait?.(n);
372
+ this.resolveWait?.(t);
322
373
  } catch (s) {
323
374
  this.rejectWait?.(s);
324
375
  } finally {
@@ -332,157 +383,157 @@ class le {
332
383
  this.rejectWait && (this.rejectWait(new Error("Request cancelled by user.")), this.resolveWait = void 0, this.rejectWait = void 0);
333
384
  }
334
385
  }
335
- const he = async (t) => {
386
+ const we = async (n) => {
336
387
  try {
337
- return await (await L()).embedDocuments(t);
388
+ return await (await L()).embedDocuments(n);
338
389
  } catch (e) {
339
390
  throw console.error("Failed to generate embeddings:", e), e;
340
391
  }
341
- }, C = async (t, e) => {
342
- const r = e.get(t);
392
+ }, C = async (n, e) => {
393
+ const r = e.get(n);
343
394
  if (r)
344
395
  return r;
345
- const s = await he([t]);
346
- return e.set(t, s[0]), s[0];
396
+ const s = await we([n]);
397
+ return e.set(n, s[0]), s[0];
347
398
  };
348
- async function me(t, e, r, s) {
349
- const n = `req-${Date.now()}`, i = {
399
+ async function ve(n, e, r, s) {
400
+ const t = `req-${Date.now()}`, i = {
350
401
  type: "layerSearch",
351
- precomputedEmbedding: s ? await C(t, s) : void 0,
352
- requestId: n,
402
+ precomputedEmbedding: s ? await C(n, s) : void 0,
403
+ requestId: t,
353
404
  minScore: r
354
405
  };
355
- return await new Promise((c) => {
356
- const d = (o) => {
357
- o.data.requestId === n && c(o.data.results);
406
+ return await new Promise((o) => {
407
+ const d = (c) => {
408
+ c.data.requestId === t && o(c.data.results);
358
409
  };
359
410
  e.addEventListener("message", d, { once: !0 }), e.postMessage(i);
360
411
  });
361
412
  }
362
- function pe(t) {
363
- const { worker: e } = t;
413
+ function Ee(n) {
414
+ const { worker: e } = n;
364
415
  return {
365
416
  async searchLayers({
366
417
  text: r,
367
418
  minScore: s,
368
- embeddingCache: n
419
+ embeddingCache: t
369
420
  }) {
370
- return await me(r, e, s, n);
421
+ return await ve(r, e, s, t);
371
422
  }
372
423
  };
373
424
  }
374
- const fe = async ({
375
- combinedQuery: t,
425
+ const Re = async ({
426
+ combinedQuery: n,
376
427
  layerIds: e,
377
428
  embeddingsWorker: r,
378
429
  minScore: s,
379
- topResults: n,
430
+ topResults: t,
380
431
  embeddingCache: a
381
432
  }) => {
382
- const i = `req-${Date.now()}`, c = a ? await C(t, a) : void 0, d = {
433
+ const i = `req-${Date.now()}`, o = a ? await C(n, a) : void 0, d = {
383
434
  type: "fieldSearch",
384
435
  layerIdForFieldsSearch: e,
385
- precomputedEmbedding: c,
436
+ precomputedEmbedding: o,
386
437
  requestId: i,
387
438
  minScore: s,
388
- topResults: n
439
+ topResults: t
389
440
  };
390
- return await new Promise((o) => {
441
+ return await new Promise((c) => {
391
442
  const u = (g) => {
392
443
  if (g.data.requestId !== i)
393
444
  return;
394
- const l = g.data.results.map(({ layerId: y, results: h }) => ({
395
- layerId: y,
445
+ const l = g.data.results.map(({ layerId: f, results: h }) => ({
446
+ layerId: f,
396
447
  results: h
397
448
  }));
398
- o(l);
449
+ c(l);
399
450
  };
400
451
  r.addEventListener("message", u, { once: !0 }), r.postMessage(d);
401
452
  });
402
453
  };
403
- function ye(t) {
404
- const { worker: e } = t;
454
+ function xe(n) {
455
+ const { worker: e } = n;
405
456
  return {
406
- async searchFields({ text: r, layerIds: s, minScore: n, topResults: a, embeddingCache: i }) {
407
- return await fe({
457
+ async searchFields({ text: r, layerIds: s, minScore: t, topResults: a, embeddingCache: i }) {
458
+ return await Re({
408
459
  combinedQuery: r,
409
460
  layerIds: s,
410
461
  embeddingsWorker: e,
411
- minScore: n,
462
+ minScore: t,
412
463
  topResults: a,
413
464
  embeddingCache: i
414
465
  });
415
466
  }
416
467
  };
417
468
  }
418
- const we = (t) => {
419
- const e = $.safeParse(t);
469
+ const Se = (n) => {
470
+ const e = W.safeParse(n);
420
471
  if (!e.success)
421
472
  throw new Error("Embeddings response validation failed. Regenerate embeddings.");
422
473
  return e.data;
423
- }, ve = (t, e) => {
474
+ }, be = (n, e) => {
424
475
  const r = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map();
425
- if (e.allLayers.forEach((n) => {
426
- n instanceof V && s.set(n.id, n);
427
- }), t.length !== s.size)
476
+ if (e.allLayers.forEach((t) => {
477
+ t instanceof V && s.set(t.id, t);
478
+ }), n.length !== s.size)
428
479
  throw new Error("Layer count mismatch during registry restoration. Regenerate embeddings.");
429
- for (const n of t) {
430
- const a = s.get(n.id);
480
+ for (const t of n) {
481
+ const a = s.get(t.id);
431
482
  if (!a)
432
483
  throw new Error(
433
- `Layer with ID ${n.id} not found in the original map during registry restoration. Regenerate embeddings.`
484
+ `Layer with ID ${t.id} not found in the original map during registry restoration. Regenerate embeddings.`
434
485
  );
435
- if (n.fields.length !== a.fields.length)
486
+ if (t.fields.length !== a.fields.length)
436
487
  throw new Error(
437
- `Field count mismatch for layer ID ${n.id} during registry restoration. Regenerate embeddings.`
488
+ `Field count mismatch for layer ID ${t.id} during registry restoration. Regenerate embeddings.`
438
489
  );
439
490
  const i = {
440
- name: n.name,
441
- title: n.title,
442
- description: n.description
443
- }, c = /* @__PURE__ */ new Map();
444
- for (const d of n.fields) {
445
- const o = a.fieldsIndex.get(d.name);
446
- if (!o)
491
+ name: t.name,
492
+ title: t.title,
493
+ description: t.description
494
+ }, o = /* @__PURE__ */ new Map();
495
+ for (const d of t.fields) {
496
+ const c = a.fieldsIndex.get(d.name);
497
+ if (!c)
447
498
  throw new Error(
448
- `Field with name ${d.name} not found in the original layer ${n.id} during registry restoration. Regenerate embeddings.`
499
+ `Field with name ${d.name} not found in the original layer ${t.id} during registry restoration. Regenerate embeddings.`
449
500
  );
450
- c.set(d.name, {
501
+ o.set(d.name, {
451
502
  name: d.name,
452
503
  alias: a.getFieldAlias(d.name) ?? d.alias,
453
504
  description: d.description,
454
- type: o.type || "unknown",
455
- valueType: o.valueType || "unknown",
505
+ type: c.type || "unknown",
506
+ valueType: c.valueType || "unknown",
456
507
  domain: a.getFieldDomain(d.name) ?? void 0
457
508
  });
458
509
  }
459
- r.set(n.id, {
510
+ r.set(t.id, {
460
511
  layerItem: i,
461
- fieldRegistry: c
512
+ fieldRegistry: o
462
513
  });
463
514
  }
464
515
  return r;
465
- }, Ee = async (t) => {
516
+ }, Ae = async (n) => {
466
517
  try {
467
- return (await z(t, {
518
+ return (await z(n, {
468
519
  responseType: "json"
469
520
  })).data;
470
521
  } catch (e) {
471
- throw new Error(`Failed to fetch data from ${t}: ${String(e)}`);
522
+ throw new Error(`Failed to fetch data from ${n}: ${String(e)}`);
472
523
  }
473
- }, Se = async (t) => {
474
- const e = t.map;
524
+ }, Ce = async (n) => {
525
+ const e = n.map;
475
526
  if (!e?.portalItem)
476
527
  throw new Error("WebMap portal item is missing.");
477
528
  const { resources: r } = await e.portalItem.fetchResources(), s = r.find((i) => i.resource.path === "embeddings-v01.json");
478
529
  if (!s?.resource.url)
479
530
  throw new Error("Embeddings resource 'embeddings-v01.json' not found in the webmap portal item.");
480
- const n = await Ee(s.resource.url);
481
- return we(n);
531
+ const t = await Ae(s.resource.url);
532
+ return Se(t);
482
533
  };
483
534
  class k {
484
535
  constructor() {
485
- this.orchestratorReady = !1, this.chatHistory = [], this.priorSteps = [], this.sharedState = {}, this.agentRegistry = new R(), this.activeRunId = "", this.cancelledRunIds = /* @__PURE__ */ new Set(), this.parentRunIds = /* @__PURE__ */ new Map(), this.activeRuntimeSpans = /* @__PURE__ */ new Map(), this.runtimeEventsEnabled = !1, this.streamEpoch = 0;
536
+ this.orchestratorReady = !1, this.chatHistory = [], this.priorSteps = [], this.sharedState = {}, this.sharedResources = [], this.agentRegistry = new S(), this.activeRunId = "", this.cancelledRunIds = /* @__PURE__ */ new Set(), this.parentRunIds = /* @__PURE__ */ new Map(), this.activeRuntimeSpans = /* @__PURE__ */ new Map(), this.runtimeEventsEnabled = !1, this.streamEpoch = 0;
486
537
  }
487
538
  /**
488
539
  * Creates and returns an AI-ready Orchestrator instance.
@@ -494,12 +545,12 @@ class k {
494
545
  r.runtimeEventsEnabled = e.runtimeEventsEnabled ?? !1;
495
546
  try {
496
547
  if (e.view?.map) {
497
- await G.whenOnce(() => e.view.ready);
498
- const s = await Se(e.view), n = ve(
548
+ await N.whenOnce(() => e.view.ready);
549
+ const s = await Ce(e.view), t = be(
499
550
  s.layers,
500
551
  e.view.map
501
552
  );
502
- r.layersAndFieldsRegistry = n, r.embeddingsWorker = await B(s);
553
+ r.layersAndFieldsRegistry = t, r.embeddingsWorker = await B(s);
503
554
  }
504
555
  return e.agents?.forEach((s) => {
505
556
  r.agentRegistry.register(s);
@@ -528,25 +579,25 @@ class k {
528
579
  throw new Error("Orchestrator has no agents selected for this request.");
529
580
  if (++this.streamEpoch, !e.trim())
530
581
  return;
531
- const n = U();
532
- this.parentRunIds.clear(), this.activeRuntimeSpans.clear(), this.activeRunId = n, this.activeAbortController = new AbortController(), this.graph || (this.graph = oe().compile({ checkpointer: new j() }));
533
- const a = this.embeddingsWorker ? pe({ worker: this.embeddingsWorker }) : void 0, i = this.embeddingsWorker ? ye({ worker: this.embeddingsWorker }) : void 0, c = /* @__PURE__ */ new Map(), d = r.routing === "direct" ? { mode: "direct", agentId: r.agentId } : { mode: "auto" }, o = {
582
+ const t = A();
583
+ this.parentRunIds.clear(), this.activeRuntimeSpans.clear(), this.activeRunId = t, this.activeAbortController = new AbortController(), this.graph || (this.graph = le().compile({ checkpointer: new P() }));
584
+ const a = this.embeddingsWorker ? Ee({ worker: this.embeddingsWorker }) : void 0, i = this.embeddingsWorker ? xe({ worker: this.embeddingsWorker }) : void 0, o = /* @__PURE__ */ new Map(), d = r.routing === "direct" ? { mode: "direct", agentId: r.agentId } : { mode: "auto" }, c = {
534
585
  // eslint-disable-next-line @typescript-eslint/naming-convention
535
- thread_id: n,
586
+ thread_id: t,
536
587
  hitlResponse: null,
537
588
  services: {
538
589
  layerSearch: a,
539
590
  fieldSearch: i,
540
591
  layersAndFieldsRegistry: this.layersAndFieldsRegistry,
541
592
  agentRegistry: s,
542
- embeddingCache: c
593
+ embeddingCache: o
543
594
  }
544
595
  }, u = {
545
596
  version: "v2",
546
597
  streamMode: "custom",
547
598
  signal: this.activeAbortController.signal,
548
599
  ...this.runtimeEventsEnabled && { callbacks: [this.createHierarchyCallback()] },
549
- configurable: o,
600
+ configurable: c,
550
601
  subgraphs: !0
551
602
  }, g = this.graph?.streamEvents(
552
603
  {
@@ -555,54 +606,55 @@ class k {
555
606
  userRequest: e,
556
607
  messages: this.chatHistory,
557
608
  priorSteps: this.priorSteps,
558
- sharedState: this.sharedState
609
+ sharedState: this.sharedState,
610
+ sharedResources: this.sharedResources
559
611
  }
560
612
  },
561
613
  u
562
614
  ), l = ++this.streamEpoch;
563
- if (yield* this.pipeStream(g, l, n), this.isRunCancelled(n)) {
564
- yield* this.createCancellationEvents(n);
615
+ if (yield* this.pipeStream(g, l, t), this.isRunCancelled(t)) {
616
+ yield* this.createCancellationEvents(t);
565
617
  return;
566
618
  }
567
619
  for (; ; ) {
568
- if (this.isRunCancelled(n)) {
569
- yield* this.createCancellationEvents(n);
620
+ if (this.isRunCancelled(t)) {
621
+ yield* this.createCancellationEvents(t);
570
622
  return;
571
623
  }
572
- const p = (await this.graph.getState(u, { subgraphs: !0 })).tasks.find((f) => f.interrupts.length > 0)?.interrupts[0]?.value;
573
- if (!p)
624
+ const m = (await this.graph.getState(u, { subgraphs: !0 })).tasks.find((y) => y.interrupts.length > 0)?.interrupts[0]?.value;
625
+ if (!m)
574
626
  break;
575
- this.currentInterrupt = p, this.interruptHandler = new le(this.graph, u), yield* this.closeActiveRuntimeSpans(n, "interrupted"), yield { runId: n, timestamp: Date.now(), type: "interrupt", interrupt: p };
627
+ this.currentInterrupt = m, this.interruptHandler = new fe(this.graph, u), yield* this.closeActiveRuntimeSpans(t, "interrupted"), yield { runId: t, timestamp: Date.now(), type: "interrupt", interrupt: m };
576
628
  try {
577
- const f = await this.interruptHandler.waitForUser(), I = ++this.streamEpoch;
578
- yield* this.pipeStream(f, I, n);
579
- } catch (f) {
580
- if (this.isRunCancelled(n)) {
581
- yield* this.createCancellationEvents(n);
629
+ const y = await this.interruptHandler.waitForUser(), I = ++this.streamEpoch;
630
+ yield* this.pipeStream(y, I, t);
631
+ } catch (y) {
632
+ if (this.isRunCancelled(t)) {
633
+ yield* this.createCancellationEvents(t);
582
634
  return;
583
635
  }
584
- if (f) {
636
+ if (y) {
585
637
  yield {
586
- runId: n,
638
+ runId: t,
587
639
  timestamp: Date.now(),
588
640
  type: "error",
589
- error: { message: f?.message }
641
+ error: { message: y?.message }
590
642
  };
591
643
  return;
592
644
  }
593
645
  }
594
646
  }
595
- if (this.isRunCancelled(n)) {
596
- yield* this.createCancellationEvents(n);
647
+ if (this.isRunCancelled(t)) {
648
+ yield* this.createCancellationEvents(t);
597
649
  return;
598
650
  }
599
651
  const h = (await this.graph.getState(u, { subgraphs: !0 })).values;
600
- if (this.isRunCancelled(n)) {
601
- yield* this.createCancellationEvents(n);
652
+ if (this.isRunCancelled(t)) {
653
+ yield* this.createCancellationEvents(t);
602
654
  return;
603
655
  }
604
- this.chatHistory = h.agentExecutionContext.messages.length ? h.agentExecutionContext.messages : this.chatHistory, this.priorSteps = h.agentExecutionContext.priorSteps?.slice(-5) ?? [], this.sharedState = h.agentExecutionContext.sharedState ?? {}, yield {
605
- runId: n,
656
+ this.chatHistory = h.agentExecutionContext.messages.length ? h.agentExecutionContext.messages : this.chatHistory, this.priorSteps = h.agentExecutionContext.priorSteps?.slice(-5) ?? [], this.sharedState = h.agentExecutionContext.sharedState ?? {}, this.sharedResources = h.agentExecutionContext.sharedResources ?? [], yield {
657
+ runId: t,
606
658
  timestamp: Date.now(),
607
659
  type: "completed",
608
660
  result: { content: h.finalOutputMessage }
@@ -612,7 +664,7 @@ class k {
612
664
  * Start a new conversation by clearing chat history, prior steps, and shared state.
613
665
  */
614
666
  newConversation() {
615
- this.chatHistory = [], this.priorSteps = [], this.sharedState = {};
667
+ this.chatHistory = [], this.priorSteps = [], this.sharedState = {}, this.sharedResources = [];
616
668
  }
617
669
  /**
618
670
  * Generic resume for any HITL interrupt.
@@ -641,45 +693,45 @@ class k {
641
693
  }
642
694
  async *pipeStream(e, r, s) {
643
695
  try {
644
- for await (const n of e) {
696
+ for await (const t of e) {
645
697
  if (this.isRunCancelled(s) || r !== this.streamEpoch)
646
698
  break;
647
699
  if (this.runtimeEventsEnabled) {
648
- const a = ge({
649
- event: n,
700
+ const a = ye({
701
+ event: t,
650
702
  runId: s,
651
- parentSpanId: this.parentRunIds.get(n.run_id),
703
+ parentSpanId: this.parentRunIds.get(t.run_id),
652
704
  timestamp: Date.now()
653
705
  });
654
706
  a && (a.phase === "started" ? this.activeRuntimeSpans.set(a.span.id, a) : this.activeRuntimeSpans.delete(a.span.id), yield a);
655
707
  }
656
- n.event === "on_custom_event" && n.name === "trace_message" ? yield { runId: s, timestamp: Date.now(), type: "trace", data: n.data } : n.name === "graph_ux_suggestion" && (yield {
708
+ t.event === "on_custom_event" && t.name === "trace_message" ? yield { runId: s, timestamp: Date.now(), type: "trace", data: t.data } : t.name === "graph_ux_suggestion" && (yield {
657
709
  runId: s,
658
710
  timestamp: Date.now(),
659
711
  type: "ux-suggestion",
660
- suggestion: n.data
712
+ suggestion: t.data
661
713
  });
662
714
  }
663
- } catch (n) {
715
+ } catch (t) {
664
716
  if (!this.isRunCancelled(s))
665
- throw n;
717
+ throw t;
666
718
  }
667
719
  }
668
720
  *createCancellationEvents(e) {
669
721
  yield* this.closeActiveRuntimeSpans(e, "cancelled"), yield { runId: e, timestamp: Date.now(), type: "cancelled", reason: "user" };
670
722
  }
671
723
  *closeActiveRuntimeSpans(e, r) {
672
- const s = Date.now(), n = [...this.activeRuntimeSpans.values()].reverse();
724
+ const s = Date.now(), t = [...this.activeRuntimeSpans.values()].reverse();
673
725
  this.activeRuntimeSpans.clear();
674
- for (const a of n) {
675
- const { input: i, ...c } = a.span;
726
+ for (const a of t) {
727
+ const { input: i, ...o } = a.span;
676
728
  yield {
677
729
  type: "runtime",
678
730
  phase: r,
679
731
  runId: e,
680
732
  timestamp: s,
681
733
  ...a.agentId && { agentId: a.agentId },
682
- span: c
734
+ span: o
683
735
  };
684
736
  }
685
737
  }
@@ -688,12 +740,12 @@ class k {
688
740
  const e = (r, s) => {
689
741
  s && this.parentRunIds.set(r, s);
690
742
  };
691
- return N.fromMethods({
692
- handleLLMStart: (r, s, n, a) => e(n, a),
693
- handleChatModelStart: (r, s, n, a) => e(n, a),
694
- handleChainStart: (r, s, n, a) => e(n, a),
695
- handleToolStart: (r, s, n, a) => e(n, a),
696
- handleRetrieverStart: (r, s, n, a) => e(n, a)
743
+ return G.fromMethods({
744
+ handleLLMStart: (r, s, t, a) => e(t, a),
745
+ handleChatModelStart: (r, s, t, a) => e(t, a),
746
+ handleChainStart: (r, s, t, a) => e(t, a),
747
+ handleToolStart: (r, s, t, a) => e(t, a),
748
+ handleRetrieverStart: (r, s, t, a) => e(t, a)
697
749
  });
698
750
  }
699
751
  isRunCancelled(e) {
@@ -709,18 +761,18 @@ class k {
709
761
  if (!i)
710
762
  throw new Error(`Agent is not registered: ${a}`);
711
763
  return i;
712
- }) : this.agentRegistry.list(), n = new R();
713
- return s.forEach((a) => n.register(a)), n;
764
+ }) : this.agentRegistry.list(), t = new S();
765
+ return s.forEach((a) => t.register(a)), t;
714
766
  }
715
767
  /**
716
768
  * Disposes this instance by terminating the embeddings worker
717
769
  * and cleaning up all related resources.
718
770
  */
719
771
  dispose() {
720
- this.embeddingsWorker && (this.embeddingsWorker.terminate(), this.embeddingsWorker = void 0), this.orchestratorReady = !1;
772
+ this.sharedResources = [], this.embeddingsWorker && (this.embeddingsWorker.terminate(), this.embeddingsWorker = void 0), this.orchestratorReady = !1;
721
773
  }
722
774
  }
723
775
  export {
724
776
  k as O,
725
- he as g
777
+ we as g
726
778
  };