@arcgis/ai-components 5.2.0-next.120 → 5.2.0-next.121

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 (133) hide show
  1. package/dist/agent-utils/LLMAgent.js +2 -0
  2. package/dist/agents/runtime/skill/createSkillAgent.js +115 -131
  3. package/dist/cdn/2DYOTV7W.js +4 -0
  4. package/dist/cdn/2WT4JANT.js +2 -0
  5. package/dist/cdn/{2NODROJN.js → 3F5EZZSG.js} +20 -24
  6. package/dist/cdn/4V3Q7XGS.js +2 -0
  7. package/dist/cdn/5GALSAQF.js +3 -0
  8. package/dist/cdn/72KYGCIU.js +2 -0
  9. package/dist/cdn/75OPJOCY.js +2 -0
  10. package/dist/cdn/7D6POJJA.js +2 -0
  11. package/dist/cdn/{SLR75R32.js → 7HVK7G55.js} +1 -1
  12. package/dist/cdn/7L6LPWRH.js +2 -0
  13. package/dist/cdn/7TAIUEMW.js +2 -0
  14. package/dist/cdn/{C2W6MBDB.js → D3E5NSY3.js} +1 -1
  15. package/dist/cdn/ESPC6NTI.js +68 -0
  16. package/dist/cdn/{HTB76P2C.js → EWO73MJA.js} +1 -1
  17. package/dist/cdn/{EIZR3Q5O.js → FGQLS3UX.js} +1 -1
  18. package/dist/cdn/FOZAOJCM.js +2 -0
  19. package/dist/cdn/GZDI2LAT.js +2 -0
  20. package/dist/cdn/H4ERKWFA.js +2 -0
  21. package/dist/cdn/{7W7KWR5O.js → H5AVPDSE.js} +4 -4
  22. package/dist/cdn/{2I2FHPHR.js → HDAMDEYL.js} +6 -6
  23. package/dist/cdn/JE55XX2C.js +2 -0
  24. package/dist/cdn/K36XPG2M.js +2 -0
  25. package/dist/cdn/KDE5MMMR.js +2 -0
  26. package/dist/cdn/{ZGZX7GR5.js → KONQTXBJ.js} +1 -1
  27. package/dist/cdn/{J4YHT55S.js → MCZJD3A4.js} +1 -1
  28. package/dist/cdn/MNZAQM3Q.js +3 -0
  29. package/dist/cdn/NHZRDYLP.js +2 -0
  30. package/dist/cdn/NYFV4A6L.js +3 -0
  31. package/dist/cdn/OGYNTGNM.js +2 -0
  32. package/dist/cdn/PGIXKPTW.js +2 -0
  33. package/dist/cdn/PTEKX5TX.js +2 -0
  34. package/dist/cdn/PUHPFUCU.js +2 -0
  35. package/dist/cdn/{GKWMAWFZ.js → QDOKDRBB.js} +1 -1
  36. package/dist/cdn/TGZBLBEJ.js +2 -0
  37. package/dist/cdn/{K7BUBCK7.js → UBKYXKMW.js} +1 -1
  38. package/dist/cdn/UXECAKJ7.js +2 -0
  39. package/dist/cdn/WXOKGQ4D.js +2 -0
  40. package/dist/cdn/Y364LLPN.js +2 -0
  41. package/dist/cdn/YBSY32EU.js +2 -0
  42. package/dist/cdn/{CF2V3NER.js → ZLLVPKDN.js} +35 -35
  43. package/dist/cdn/agent-utils/index.js +1 -1
  44. package/dist/cdn/assets/agents/t9n/messages.ar.json +1 -0
  45. package/dist/cdn/assets/agents/t9n/messages.bg.json +1 -0
  46. package/dist/cdn/assets/agents/t9n/messages.ca.json +1 -0
  47. package/dist/cdn/assets/agents/t9n/messages.cs.json +1 -0
  48. package/dist/cdn/assets/agents/t9n/messages.da.json +1 -0
  49. package/dist/cdn/assets/agents/t9n/messages.de.json +1 -0
  50. package/dist/cdn/assets/agents/t9n/messages.el.json +1 -0
  51. package/dist/cdn/assets/agents/t9n/messages.es.json +1 -0
  52. package/dist/cdn/assets/agents/t9n/messages.et.json +1 -0
  53. package/dist/cdn/assets/agents/t9n/messages.fi.json +1 -0
  54. package/dist/cdn/assets/agents/t9n/messages.fr.json +1 -0
  55. package/dist/cdn/assets/agents/t9n/messages.he.json +1 -0
  56. package/dist/cdn/assets/agents/t9n/messages.hr.json +1 -0
  57. package/dist/cdn/assets/agents/t9n/messages.hu.json +1 -0
  58. package/dist/cdn/assets/agents/t9n/messages.id.json +1 -0
  59. package/dist/cdn/assets/agents/t9n/messages.it.json +1 -0
  60. package/dist/cdn/assets/agents/t9n/messages.ja.json +1 -0
  61. package/dist/cdn/assets/agents/t9n/messages.ko.json +1 -0
  62. package/dist/cdn/assets/agents/t9n/messages.lt.json +1 -0
  63. package/dist/cdn/assets/agents/t9n/messages.lv.json +1 -0
  64. package/dist/cdn/assets/agents/t9n/messages.nl.json +1 -0
  65. package/dist/cdn/assets/agents/t9n/messages.no.json +1 -0
  66. package/dist/cdn/assets/agents/t9n/messages.pl.json +1 -0
  67. package/dist/cdn/assets/agents/t9n/messages.pt-BR.json +1 -0
  68. package/dist/cdn/assets/agents/t9n/messages.pt-PT.json +1 -0
  69. package/dist/cdn/assets/agents/t9n/messages.ro.json +1 -0
  70. package/dist/cdn/assets/agents/t9n/messages.ru.json +1 -0
  71. package/dist/cdn/assets/agents/t9n/messages.sk.json +1 -0
  72. package/dist/cdn/assets/agents/t9n/messages.sl.json +1 -0
  73. package/dist/cdn/assets/agents/t9n/messages.sr.json +1 -0
  74. package/dist/cdn/assets/agents/t9n/messages.sv.json +1 -0
  75. package/dist/cdn/assets/agents/t9n/messages.th.json +1 -0
  76. package/dist/cdn/assets/agents/t9n/messages.tr.json +1 -0
  77. package/dist/cdn/assets/agents/t9n/messages.uk.json +1 -0
  78. package/dist/cdn/assets/agents/t9n/messages.vi.json +1 -0
  79. package/dist/cdn/assets/agents/t9n/messages.zh-CN.json +1 -0
  80. package/dist/cdn/assets/agents/t9n/messages.zh-TW.json +1 -0
  81. package/dist/cdn/assets/orchestrator/t9n/messages.en.json +1 -0
  82. package/dist/cdn/index.js +1 -1
  83. package/dist/chunks/adapter.js +54 -52
  84. package/dist/chunks/aiFactory.js +59 -41
  85. package/dist/chunks/arcgisKnowledgeGraph.js +4 -2
  86. package/dist/chunks/dataExplorationAgent.js +1 -1
  87. package/dist/chunks/generateLayerDescriptions.js +160 -156
  88. package/dist/chunks/layerStylingGraph.js +2 -0
  89. package/dist/chunks/orchestrator.js +325 -295
  90. package/dist/components/arcgis-assistant/customElement.d.ts +1 -1
  91. package/dist/components/arcgis-assistant/customElement.js +113 -112
  92. package/dist/components/arcgis-assistant-agent/customElement.js +1 -0
  93. package/dist/components/arcgis-assistant-data-exploration-agent/customElement.js +1 -0
  94. package/dist/components/arcgis-assistant-help-agent/customElement.js +1 -0
  95. package/dist/components/arcgis-assistant-knowledge-agent/customElement.js +5 -4
  96. package/dist/components/arcgis-assistant-layer-styling-agent/customElement.js +1 -0
  97. package/dist/components/arcgis-assistant-navigation-agent/customElement.js +1 -0
  98. package/dist/docs/api.json +1 -1
  99. package/dist/docs/docs.json +1 -1
  100. package/dist/docs/vscode.html-custom-data.json +1 -1
  101. package/dist/docs/web-types.json +1 -1
  102. package/dist/utils/index.js +38 -36
  103. package/package.json +7 -7
  104. package/dist/cdn/5BBXNT75.js +0 -66
  105. package/dist/cdn/5HBAJ57P.js +0 -2
  106. package/dist/cdn/5MK44FNO.js +0 -2
  107. package/dist/cdn/6ECRQVHY.js +0 -2
  108. package/dist/cdn/AUDVUNF3.js +0 -2
  109. package/dist/cdn/BJUX4AYP.js +0 -2
  110. package/dist/cdn/COH3QXWG.js +0 -4
  111. package/dist/cdn/CPQGLQGY.js +0 -2
  112. package/dist/cdn/CT2ZOYNX.js +0 -2
  113. package/dist/cdn/DNV3L5M6.js +0 -2
  114. package/dist/cdn/EDVH3G5A.js +0 -2
  115. package/dist/cdn/HWGAJ4WN.js +0 -2
  116. package/dist/cdn/IHRX74QJ.js +0 -2
  117. package/dist/cdn/LRH2ZPVW.js +0 -2
  118. package/dist/cdn/OTOQL3QM.js +0 -3
  119. package/dist/cdn/R74ZHFA6.js +0 -2
  120. package/dist/cdn/RGVC76RW.js +0 -2
  121. package/dist/cdn/RIN3RP7D.js +0 -3
  122. package/dist/cdn/SWVRA77H.js +0 -2
  123. package/dist/cdn/TLQ75QXG.js +0 -2
  124. package/dist/cdn/TPF5Z277.js +0 -3
  125. package/dist/cdn/UIIVUHXL.js +0 -2
  126. package/dist/cdn/UWZQWGZP.js +0 -2
  127. package/dist/cdn/UXYYH6XF.js +0 -2
  128. package/dist/cdn/XUYARLRP.js +0 -2
  129. package/dist/cdn/XV3DHHYJ.js +0 -2
  130. package/dist/cdn/Y2BCEVV6.js +0 -2
  131. package/dist/cdn/YJ4MZOVC.js +0 -2
  132. package/dist/cdn/YXIPCGGP.js +0 -2
  133. package/dist/cdn/YYFKFPSN.js +0 -2
@@ -1,87 +1,99 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import M from "@arcgis/core/identity/IdentityManager.js";
3
- import _ from "@arcgis/core/portal/Portal.js";
4
- import { g as $, a as D } from "./aiFactory.js";
5
- import { isGraphInterrupt as F, StateGraph as L, START as q, END as W, MemorySaver as P } from "@langchain/langgraph/web";
6
- import { generateGuid as b } from "@arcgis/toolkit/string";
7
- import { g as A, D as T, b as j, W as H } from "./generateLayerDescriptions.js";
8
- import { HumanMessage as U, AIMessage as O } from "@langchain/core/messages";
2
+ import F from "@arcgis/core/identity/IdentityManager.js";
3
+ import D from "@arcgis/core/portal/Portal.js";
4
+ import { b as L, g as v, a as E, d as q } from "./aiFactory.js";
5
+ import { isGraphInterrupt as W, StateGraph as $, START as P, END as T, MemorySaver as j } from "@langchain/langgraph/web";
6
+ import { generateGuid as C } from "@arcgis/toolkit/string";
7
+ import { g as I, D as H, b as U, W as O } from "./generateLayerDescriptions.js";
8
+ import { HumanMessage as G, AIMessage as N } from "@langchain/core/messages";
9
9
  import { s as p } from "./index.js";
10
- import { BaseCallbackHandler as G } from "@langchain/core/callbacks/base";
11
- import * as N from "@arcgis/core/core/reactiveUtils.js";
12
- import V from "@arcgis/core/layers/FeatureLayer.js";
13
- import z from "@arcgis/core/request.js";
14
- const B = async (n) => {
15
- const e = await Q(), r = await $("default"), s = _.getDefault(), a = (await M.getCredential(`${s.url}/sharing`)).token, i = {
10
+ import { BaseCallbackHandler as V } from "@langchain/core/callbacks/base";
11
+ import * as z from "@arcgis/core/core/reactiveUtils.js";
12
+ import B from "@arcgis/core/layers/FeatureLayer.js";
13
+ import Q from "@arcgis/core/request.js";
14
+ const K = async (t) => {
15
+ const e = await J(), r = await L("default"), s = D.getDefault(), a = (await F.getCredential(`${s.url}/sharing`)).token, o = {
16
16
  type: "generateEmbeddings",
17
- webmapEmbeddings: n,
17
+ webmapEmbeddings: t,
18
18
  auth: { apiUrl: r, token: a }
19
19
  };
20
- return e.postMessage(i), await new Promise((o, d) => {
21
- const c = (g) => {
22
- g.data === "completed" && (e.removeEventListener("message", c), o());
23
- }, u = (g) => {
24
- e.removeEventListener("message", c), d(g instanceof Error ? g : new Error("Embeddings worker error"));
20
+ return e.postMessage(o), await new Promise((i, c) => {
21
+ const u = (g) => {
22
+ g.data === "completed" && (e.removeEventListener("message", u), i());
23
+ }, d = (g) => {
24
+ e.removeEventListener("message", u), c(g instanceof Error ? g : new Error("Embeddings worker error"));
25
25
  };
26
- e.addEventListener("message", c), e.addEventListener("error", u, { once: !0 });
26
+ e.addEventListener("message", u), e.addEventListener("error", d, { once: !0 });
27
27
  }), e;
28
- }, Q = async () => {
28
+ }, J = async () => {
29
29
  {
30
- const n = (await import("./embeddings.worker.js")).default;
31
- return new n();
32
- }
33
- }, K = (n) => {
34
- n.currentIntent = "none";
35
- }, J = async (n, e) => {
36
- const r = A(e);
37
- if (n.agentExecutionContext.userRequest) {
38
- const t = new U(n.agentExecutionContext.userRequest.trim());
39
- n.agentExecutionContext.messages = [...n.agentExecutionContext.messages, t], K(n);
40
- }
41
- const s = r?.services.agentRegistry.list().map((t) => t.agent.id) ?? [];
42
- return await p({ text: `Available agents: ${[...s].join(", ")}` }, e), await p({ text: "Analyzing user input" }, e), n;
43
- }, X = async (n, e) => (await p({ text: "Exiting..." }, e), n), E = (n) => typeof n == "object" && n !== null && !Array.isArray(n), Y = (n, e) => {
44
- if (!E(n)) {
45
- n !== void 0 && console.warn(`Agent "${e}" returned invalid sharedStatePatch. Ignoring it.`);
30
+ const t = (await import("./embeddings.worker.js")).default;
31
+ return new t();
32
+ }
33
+ }, X = (t) => {
34
+ t.currentIntent = "none";
35
+ }, Y = async (t, e) => {
36
+ const r = I(e), s = await v({
37
+ path: "./assets/orchestrator/t9n",
38
+ locale: E(e)
39
+ });
40
+ if (t.agentExecutionContext.userRequest) {
41
+ const a = new G(t.agentExecutionContext.userRequest.trim());
42
+ t.agentExecutionContext.messages = [...t.agentExecutionContext.messages, a], X(t);
43
+ }
44
+ const n = r?.services.agentRegistry.list().map((a) => a.agent.id) ?? [];
45
+ return await p(
46
+ { text: s.availableAgents.replace("{agentIds}", [...n].join(", ")) },
47
+ e
48
+ ), await p({ text: s.analyzingUserInput }, e), t;
49
+ }, Z = async (t, e) => {
50
+ const r = await v({
51
+ path: "./assets/orchestrator/t9n",
52
+ locale: E(e)
53
+ });
54
+ return await p({ text: r.exiting }, e), t;
55
+ }, x = (t) => typeof t == "object" && t !== null && !Array.isArray(t), ee = (t, e) => {
56
+ if (!x(t)) {
57
+ t !== void 0 && console.warn(`Agent "${e}" returned invalid sharedStatePatch. Ignoring it.`);
46
58
  return;
47
59
  }
48
60
  const r = {};
49
- for (const [s, t] of Object.entries(n)) {
50
- if (!E(t) || !("value" in t)) {
61
+ for (const [s, n] of Object.entries(t)) {
62
+ if (!x(n) || !("value" in n)) {
51
63
  console.warn(
52
64
  `Agent "${e}" returned invalid sharedStatePatch entry for key "${s}". Ignoring that entry.`
53
65
  );
54
66
  continue;
55
67
  }
56
- r[s] = { value: t.value };
68
+ r[s] = { value: n.value };
57
69
  }
58
70
  return r;
59
- }, Z = (n) => {
60
- const { previousSharedState: e, patch: r, agentId: s } = n;
71
+ }, te = (t) => {
72
+ const { previousSharedState: e, patch: r, agentId: s } = t;
61
73
  if (!r)
62
74
  return e;
63
- const t = Date.now(), a = {
75
+ const n = Date.now(), a = {
64
76
  ...e
65
77
  };
66
- for (const [i, o] of Object.entries(r))
67
- o?.value !== void 0 && (a[i] = {
68
- value: o.value,
78
+ for (const [o, i] of Object.entries(r))
79
+ i?.value !== void 0 && (a[o] = {
80
+ value: i.value,
69
81
  meta: {
70
82
  updatedByAgentId: s,
71
- updatedAt: t
83
+ updatedAt: n
72
84
  }
73
85
  });
74
86
  return a;
75
- }, ee = 256, te = /* @__PURE__ */ new Set(["point", "polyline", "polygon", "extent", "custom"]), ne = (n) => typeof n == "object" && n !== null && !Array.isArray(n), re = (n, e) => {
76
- if (n === void 0)
87
+ }, ne = 256, re = /* @__PURE__ */ new Set(["point", "polyline", "polygon", "extent", "custom"]), se = (t) => typeof t == "object" && t !== null && !Array.isArray(t), ae = (t, e) => {
88
+ if (t === void 0)
77
89
  return;
78
- if (!Array.isArray(n)) {
90
+ if (!Array.isArray(t)) {
79
91
  console.warn(`Agent "${e}" returned invalid sharedResourceAdditions. Ignoring it.`);
80
92
  return;
81
93
  }
82
94
  const r = [];
83
- for (const [s, t] of n.entries()) {
84
- 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) {
95
+ for (const [s, n] of t.entries()) {
96
+ if (!se(n) || typeof n.kind != "string" || !re.has(n.kind) || typeof n.description != "string" || !n.description.trim() || !("payload" in n) || n.payload === void 0) {
85
97
  console.warn(
86
98
  `Agent "${e}" returned invalid sharedResourceAdditions entry at index ${s}. Ignoring that entry.`
87
99
  );
@@ -89,7 +101,7 @@ const B = async (n) => {
89
101
  }
90
102
  let a;
91
103
  try {
92
- a = structuredClone(t.payload);
104
+ a = structuredClone(n.payload);
93
105
  } catch {
94
106
  console.warn(
95
107
  `Agent "${e}" returned invalid sharedResourceAdditions entry at index ${s}. Ignoring that entry.`
@@ -97,32 +109,32 @@ const B = async (n) => {
97
109
  continue;
98
110
  }
99
111
  r.push({
100
- kind: t.kind,
101
- description: t.description.trim().slice(0, ee),
112
+ kind: n.kind,
113
+ description: n.description.trim().slice(0, ne),
102
114
  payload: a
103
115
  });
104
116
  }
105
117
  return r.length ? r : void 0;
106
- }, se = (n) => {
107
- const { previousSharedResources: e, additions: r, agentId: s } = n;
118
+ }, ie = (t) => {
119
+ const { previousSharedResources: e, additions: r, agentId: s } = t;
108
120
  if (!r?.length)
109
121
  return e;
110
- const t = Date.now(), a = r.map((i) => ({
111
- ...i,
112
- id: b(),
122
+ const n = Date.now(), a = r.map((o) => ({
123
+ ...o,
124
+ id: C(),
113
125
  meta: {
114
126
  createdByAgentId: s,
115
- createdAt: t
127
+ createdAt: n
116
128
  }
117
129
  }));
118
130
  return [...e, ...a].slice(-50);
119
- }, R = (n) => {
120
- if (typeof n != "string")
131
+ }, S = (t) => {
132
+ if (typeof t != "string")
121
133
  return;
122
- const e = n.trim();
134
+ const e = t.trim();
123
135
  return e || void 0;
124
- }, ae = (n) => {
125
- switch (n) {
136
+ }, oe = (t) => {
137
+ switch (t) {
126
138
  case "failed":
127
139
  return "Agent failed without a summary.";
128
140
  case "unknown":
@@ -132,170 +144,188 @@ const B = async (n) => {
132
144
  default:
133
145
  return "Agent completed without a summary.";
134
146
  }
135
- }, ie = (n, e) => {
136
- const r = R(e?.outputMessage), s = R(e?.summary), t = e?.status, a = t === "success" || t === "failed" ? t : "unknown";
137
- a === "unknown" && console.warn(`Agent "${n}" returned missing/invalid status. Defaulting to "unknown".`);
138
- const i = Y(e?.sharedStatePatch, n), o = re(e?.sharedResourceAdditions, n);
147
+ }, ce = (t, e) => {
148
+ const r = S(e?.outputMessage), s = S(e?.summary), n = e?.status, a = n === "success" || n === "failed" ? n : "unknown";
149
+ a === "unknown" && console.warn(`Agent "${t}" returned missing/invalid status. Defaulting to "unknown".`);
150
+ const o = ee(e?.sharedStatePatch, t), i = ae(e?.sharedResourceAdditions, t);
139
151
  return {
140
152
  outputMessage: r,
141
- summary: s ?? r ?? ae(a),
153
+ summary: s ?? r ?? oe(a),
142
154
  status: a,
143
- sharedStatePatch: i,
144
- sharedResourceAdditions: o
155
+ sharedStatePatch: o,
156
+ sharedResourceAdditions: i
145
157
  };
146
- }, x = 4e3, oe = async (n, e) => {
147
- const r = A(e);
158
+ }, b = 4e3, de = async (t, e) => {
159
+ const r = I(e), s = await v({
160
+ path: "./assets/orchestrator/t9n",
161
+ locale: E(e)
162
+ });
148
163
  if (e?.signal?.aborted)
149
- return await p({ text: "Run cancelled; skipping agent execution" }, e), {
150
- ...n,
164
+ return await p({ text: s.runCancelledAgentExecution }, e), {
165
+ ...t,
151
166
  currentIntent: "none",
152
167
  requiresFollowUp: !1
153
168
  };
154
- const { agentRegistry: s } = r?.services ?? {}, t = s?.get(n.currentIntent);
155
- if (!t)
156
- return console.warn(`No agent found for intent: ${n.currentIntent}`), n;
157
- await p({ text: `Executing registered agent: ${t.agent.name}` }, e);
158
- const a = {
169
+ const { agentRegistry: n } = r?.services ?? {}, a = n?.get(t.currentIntent);
170
+ if (!a)
171
+ return console.warn(s.noAgentFoundForIntent.replace("{intent}", t.currentIntent)), t;
172
+ await p(
173
+ { text: s.executingRegisteredAgent.replace("{agentName}", a.agent.name) },
174
+ e
175
+ );
176
+ const o = {
159
177
  ...e ?? {},
160
178
  metadata: {
161
179
  ...e?.metadata,
162
- agentId: t.agent.id
180
+ agentId: a.agent.id
163
181
  },
164
182
  configurable: {
165
183
  ...r ?? {},
166
- agentId: t.agent.id,
167
- context: t.getContext ? await t.getContext() : void 0
184
+ agentId: a.agent.id,
185
+ context: a.getContext ? await a.getContext() : void 0
168
186
  }
169
187
  };
170
188
  let i;
171
189
  try {
172
- const c = await t.agent.createGraph().compile().invoke(
190
+ const d = await a.agent.createGraph().compile().invoke(
173
191
  {
174
192
  agentExecutionContext: {
175
- ...n.agentExecutionContext,
193
+ ...t.agentExecutionContext,
176
194
  // deep clone on messages did not work in agents, so its a shallow clone here.
177
- messages: [...n.agentExecutionContext.messages],
195
+ messages: [...t.agentExecutionContext.messages],
178
196
  // deep clone to prevent accidental mutations by agents
179
- priorSteps: structuredClone(n.agentExecutionContext.priorSteps ?? []),
180
- sharedState: structuredClone(n.agentExecutionContext.sharedState ?? {}),
181
- sharedResources: structuredClone(n.agentExecutionContext.sharedResources ?? [])
197
+ priorSteps: structuredClone(t.agentExecutionContext.priorSteps ?? []),
198
+ sharedState: structuredClone(t.agentExecutionContext.sharedState ?? {}),
199
+ sharedResources: structuredClone(t.agentExecutionContext.sharedResources ?? [])
182
200
  }
183
201
  },
184
- a
202
+ o
185
203
  );
186
- i = ie(t.agent.name, c), await p({ text: `Finished executing registered agent: ${t.agent.name}` }, e);
187
- } catch (c) {
188
- if (F(c) || e?.signal?.aborted || c instanceof Error && c.name === "AbortError")
189
- throw c;
190
- const u = c instanceof Error ? c.message : String(c);
191
- console.error(`Agent "${t.agent.name}" failed:`, c), await p({ text: `Registered agent failed: ${t.agent.name}. ${u}` }, e), i = {
204
+ i = ce(a.agent.name, d), await p(
205
+ { text: s.finishedExecutingRegisteredAgent.replace("{agentName}", a.agent.name) },
206
+ e
207
+ );
208
+ } catch (d) {
209
+ if (W(d) || e?.signal?.aborted || d instanceof Error && d.name === "AbortError")
210
+ throw d;
211
+ const g = d instanceof Error ? d.message : String(d);
212
+ console.error(`Agent "${a.agent.name}" failed:`, d), await p(
213
+ {
214
+ text: s.registeredAgentFailed.replace("{agentName}", a.agent.name).replace("{error}", g)
215
+ },
216
+ e
217
+ ), i = {
192
218
  status: "failed",
193
- outputMessage: `Agent execution failed: ${u}`,
194
- summary: `Agent execution failed: ${u}`
219
+ outputMessage: s.agentExecutionFailed.replace("{error}", g),
220
+ summary: s.agentExecutionFailed.replace("{error}", g)
195
221
  };
196
222
  }
197
- const o = i.outputMessage, d = [...n.agentExecutionContext.messages];
198
- if (o) {
199
- const c = o.length > x ? `${o.slice(0, x - 14)}
200
- [truncated]` : o;
201
- d.push(new O(c));
223
+ const c = i.outputMessage, u = [...t.agentExecutionContext.messages];
224
+ if (c) {
225
+ const d = c.length > b ? `${c.slice(0, b - 14)}
226
+ [truncated]` : c;
227
+ u.push(new N(d));
202
228
  }
203
229
  return {
204
- ...n,
205
- stepCount: n.stepCount + 1,
206
- lastExecutedAgent: t.agent.id,
207
- requiresFollowUp: i.status === "failed" ? !0 : n.requiresFollowUp,
208
- finalOutputMessage: o ?? "",
230
+ ...t,
231
+ stepCount: t.stepCount + 1,
232
+ lastExecutedAgent: a.agent.id,
233
+ requiresFollowUp: i.status === "failed" ? !0 : t.requiresFollowUp,
234
+ finalOutputMessage: c ?? "",
209
235
  agentExecutionContext: {
210
- ...n.agentExecutionContext,
211
- messages: d,
236
+ ...t.agentExecutionContext,
237
+ messages: u,
212
238
  priorSteps: [
213
- ...n.agentExecutionContext.priorSteps ?? [],
239
+ ...t.agentExecutionContext.priorSteps ?? [],
214
240
  {
215
- agentId: t.agent.id,
216
- assignedTask: n.agentExecutionContext.assignedTask,
217
- summary: i?.summary || "No summary provided.",
241
+ agentId: a.agent.id,
242
+ assignedTask: t.agentExecutionContext.assignedTask,
243
+ summary: i?.summary || s.noSummaryProvided,
218
244
  status: i?.status || "unknown"
219
245
  }
220
246
  ],
221
- sharedState: Z({
222
- previousSharedState: n.agentExecutionContext.sharedState,
247
+ sharedState: te({
248
+ previousSharedState: t.agentExecutionContext.sharedState,
223
249
  patch: i.sharedStatePatch,
224
- agentId: t.agent.id
250
+ agentId: a.agent.id
225
251
  }),
226
- sharedResources: se({
227
- previousSharedResources: n.agentExecutionContext.sharedResources,
252
+ sharedResources: ie({
253
+ previousSharedResources: t.agentExecutionContext.sharedResources,
228
254
  additions: i.sharedResourceAdditions,
229
- agentId: t.agent.id
255
+ agentId: a.agent.id
230
256
  })
231
257
  }
232
258
  };
233
- }, ce = async (n, e) => {
234
- if (n.routing.mode !== "direct")
235
- throw new Error("Direct agent assignment requires direct routing.");
236
- return await p({ text: `Doing a direct route to agent: ${n.routing.agentId}` }, e), {
237
- ...n,
238
- currentIntent: n.routing.agentId,
259
+ }, ue = async (t, e) => {
260
+ const r = await v({
261
+ path: "./assets/orchestrator/t9n",
262
+ locale: E(e)
263
+ });
264
+ if (t.routing.mode !== "direct")
265
+ throw new Error(r.directAgentAssignmentRequiresDirectRouting);
266
+ return await p({ text: r.directRouteToAgent.replace("{agentId}", t.routing.agentId) }, e), {
267
+ ...t,
268
+ currentIntent: t.routing.agentId,
239
269
  requiresFollowUp: !1,
240
270
  agentExecutionContext: {
241
- ...n.agentExecutionContext,
242
- assignedTask: n.agentExecutionContext.userRequest
271
+ ...t.agentExecutionContext,
272
+ assignedTask: t.agentExecutionContext.userRequest
243
273
  }
244
274
  };
245
- }, 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 L(T).addNode("ingestInput", J).addNode("assignDirectAgent", ce).addNode("intentLLM", j).addNode("executeRegisteredAgent", oe).addNode("exit", X).addEdge(q, "ingestInput").addConditionalEdges("ingestInput", ue).addEdge("assignDirectAgent", "executeRegisteredAgent").addConditionalEdges("intentLLM", (e) => e.currentIntent === "none" || e.currentIntent === e.lastExecutedAgent ? "exit" : "executeRegisteredAgent").addConditionalEdges("executeRegisteredAgent", ge).addEdge("exit", W), he = (n, e) => {
246
- 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;
247
- if (t === void 0 || a === void 0 || i === void 0)
275
+ }, ge = 3, le = (t) => t.routing.mode === "direct" ? "assignDirectAgent" : "intentLLM", he = (t) => t.routing.mode === "direct" || t.stepCount >= ge || !t.requiresFollowUp ? "exit" : "intentLLM", pe = () => new $(H).addNode("ingestInput", Y).addNode("assignDirectAgent", ue).addNode("intentLLM", U).addNode("executeRegisteredAgent", de).addNode("exit", Z).addEdge(P, "ingestInput").addConditionalEdges("ingestInput", le).addEdge("assignDirectAgent", "executeRegisteredAgent").addConditionalEdges("intentLLM", (e) => e.currentIntent === "none" || e.currentIntent === e.lastExecutedAgent ? "exit" : "executeRegisteredAgent").addConditionalEdges("executeRegisteredAgent", he).addEdge("exit", T), me = (t, e) => {
276
+ 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, o = r?.total_tokens ?? s?.totalTokens;
277
+ if (n === void 0 || a === void 0 || o === void 0)
248
278
  return;
249
- const o = r?.input_token_details?.cache_read, d = r?.output_token_details?.reasoning;
279
+ const i = r?.input_token_details?.cache_read, c = r?.output_token_details?.reasoning;
250
280
  return {
251
- input: t,
281
+ input: n,
252
282
  output: a,
253
- total: i,
254
- ...o !== void 0 && { cacheRead: o },
255
- ...d !== void 0 && { reasoning: d }
283
+ total: o,
284
+ ...i !== void 0 && { cacheRead: i },
285
+ ...c !== void 0 && { reasoning: c }
256
286
  };
257
- }, pe = (n, e, r, s) => {
258
- switch (n) {
287
+ }, ye = (t, e, r, s) => {
288
+ switch (t) {
259
289
  case "chat_model":
260
290
  case "llm":
261
291
  return "model";
262
292
  case "tool":
263
293
  case "retriever":
264
- return n;
294
+ return t;
265
295
  case "chain":
266
296
  return !s || e === "LangGraph" ? "workflow" : r === e ? "node" : "chain";
267
297
  default:
268
298
  return;
269
299
  }
270
- }, me = (n) => {
271
- if (n instanceof Error)
272
- return { message: n.message, name: n.name };
273
- const e = n, r = typeof e?.message == "string" ? e.message : String(n ?? "Unknown runtime error"), s = typeof e?.name == "string" ? e.name : void 0;
300
+ }, fe = (t) => {
301
+ if (t instanceof Error)
302
+ return { message: t.message, name: t.name };
303
+ const e = t, r = typeof e?.message == "string" ? e.message : String(t ?? "Unknown runtime error"), s = typeof e?.name == "string" ? e.name : void 0;
274
304
  return { message: r, ...s && { name: s } };
275
- }, ye = ({
276
- event: n,
305
+ }, we = ({
306
+ event: t,
277
307
  runId: e,
278
308
  parentSpanId: r,
279
309
  timestamp: s
280
310
  }) => {
281
- const t = /^on_(.+)_(start|end|error)$/u.exec(n.event);
282
- if (!t)
311
+ const n = /^on_(.+)_(start|end|error)$/u.exec(t.event);
312
+ if (!n)
283
313
  return;
284
- const [, a, i] = t, o = n.metadata ?? {}, d = o.langgraph_node, c = pe(a, n.name, d, r);
285
- if (!c)
314
+ const [, a, o] = n, i = t.metadata ?? {}, c = i.langgraph_node, u = ye(a, t.name, c, r);
315
+ if (!u)
286
316
  return;
287
- 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 = {
317
+ const d = i.agentId, g = i.model ?? i.ls_model_name, l = t.data, f = o === "end" && u === "model" ? me(l, i) : void 0, h = t.tags?.includes("langsmith:hidden") || c === "__start__", R = {
288
318
  ...g && { model: g },
289
319
  ...f && { tokenUsage: f },
290
320
  ...h && { internal: !0 }
291
321
  }, w = {
292
- id: n.run_id,
322
+ id: t.run_id,
293
323
  ...r && { parentId: r },
294
- label: n.name,
295
- type: c,
296
- ...Object.keys(v).length && { metadata: v }
297
- }, m = { runId: e, timestamp: s, type: "runtime", ...u && { agentId: u } };
298
- switch (i) {
324
+ label: t.name,
325
+ type: u,
326
+ ...Object.keys(R).length && { metadata: R }
327
+ }, m = { runId: e, timestamp: s, type: "runtime", ...d && { agentId: d } };
328
+ switch (o) {
299
329
  case "start":
300
330
  return {
301
331
  ...m,
@@ -315,12 +345,12 @@ const B = async (n) => {
315
345
  }
316
346
  };
317
347
  case "error":
318
- return { ...m, phase: "failed", span: { ...w, error: me(l?.error) } };
348
+ return { ...m, phase: "failed", span: { ...w, error: fe(l?.error) } };
319
349
  default:
320
350
  return;
321
351
  }
322
352
  };
323
- class S {
353
+ class A {
324
354
  constructor() {
325
355
  this.agentRegistry = /* @__PURE__ */ new Map();
326
356
  }
@@ -337,7 +367,7 @@ class S {
337
367
  return [...this.agentRegistry.values()];
338
368
  }
339
369
  }
340
- class fe {
370
+ class ve {
341
371
  /**
342
372
  * Create a new InterruptHandler tied to a specific compiled graph and config.
343
373
  */
@@ -361,7 +391,7 @@ class fe {
361
391
  agentId: e.agentId,
362
392
  id: e.id,
363
393
  payload: r
364
- }, t = this.graph.streamEvents(null, {
394
+ }, n = this.graph.streamEvents(null, {
365
395
  ...this.config,
366
396
  configurable: {
367
397
  ...this.config.configurable,
@@ -370,7 +400,7 @@ class fe {
370
400
  subgraphs: !0,
371
401
  version: "v2"
372
402
  });
373
- this.resolveWait?.(t);
403
+ this.resolveWait?.(n);
374
404
  } catch (s) {
375
405
  this.rejectWait?.(s);
376
406
  } finally {
@@ -384,157 +414,157 @@ class fe {
384
414
  this.rejectWait && (this.rejectWait(new Error("Request cancelled by user.")), this.resolveWait = void 0, this.rejectWait = void 0);
385
415
  }
386
416
  }
387
- const we = async (n) => {
417
+ const Ee = async (t) => {
388
418
  try {
389
- return await (await D()).embedDocuments(n);
419
+ return await (await q()).embedDocuments(t);
390
420
  } catch (e) {
391
421
  throw console.error("Failed to generate embeddings:", e), e;
392
422
  }
393
- }, C = async (n, e) => {
394
- const r = e.get(n);
423
+ }, k = async (t, e) => {
424
+ const r = e.get(t);
395
425
  if (r)
396
426
  return r;
397
- const s = await we([n]);
398
- return e.set(n, s[0]), s[0];
427
+ const s = await Ee([t]);
428
+ return e.set(t, s[0]), s[0];
399
429
  };
400
- async function ve(n, e, r, s) {
401
- const t = `req-${Date.now()}`, i = {
430
+ async function Re(t, e, r, s) {
431
+ const n = `req-${Date.now()}`, o = {
402
432
  type: "layerSearch",
403
- precomputedEmbedding: s ? await C(n, s) : void 0,
404
- requestId: t,
433
+ precomputedEmbedding: s ? await k(t, s) : void 0,
434
+ requestId: n,
405
435
  minScore: r
406
436
  };
407
- return await new Promise((o) => {
408
- const d = (c) => {
409
- c.data.requestId === t && o(c.data.results);
437
+ return await new Promise((i) => {
438
+ const c = (u) => {
439
+ u.data.requestId === n && i(u.data.results);
410
440
  };
411
- e.addEventListener("message", d, { once: !0 }), e.postMessage(i);
441
+ e.addEventListener("message", c, { once: !0 }), e.postMessage(o);
412
442
  });
413
443
  }
414
- function Ee(n) {
415
- const { worker: e } = n;
444
+ function xe(t) {
445
+ const { worker: e } = t;
416
446
  return {
417
447
  async searchLayers({
418
448
  text: r,
419
449
  minScore: s,
420
- embeddingCache: t
450
+ embeddingCache: n
421
451
  }) {
422
- return await ve(r, e, s, t);
452
+ return await Re(r, e, s, n);
423
453
  }
424
454
  };
425
455
  }
426
- const Re = async ({
427
- combinedQuery: n,
456
+ const Se = async ({
457
+ combinedQuery: t,
428
458
  layerIds: e,
429
459
  embeddingsWorker: r,
430
460
  minScore: s,
431
- topResults: t,
461
+ topResults: n,
432
462
  embeddingCache: a
433
463
  }) => {
434
- const i = `req-${Date.now()}`, o = a ? await C(n, a) : void 0, d = {
464
+ const o = `req-${Date.now()}`, i = a ? await k(t, a) : void 0, c = {
435
465
  type: "fieldSearch",
436
466
  layerIdForFieldsSearch: e,
437
- precomputedEmbedding: o,
438
- requestId: i,
467
+ precomputedEmbedding: i,
468
+ requestId: o,
439
469
  minScore: s,
440
- topResults: t
470
+ topResults: n
441
471
  };
442
- return await new Promise((c) => {
443
- const u = (g) => {
444
- if (g.data.requestId !== i)
472
+ return await new Promise((u) => {
473
+ const d = (g) => {
474
+ if (g.data.requestId !== o)
445
475
  return;
446
476
  const l = g.data.results.map(({ layerId: f, results: h }) => ({
447
477
  layerId: f,
448
478
  results: h
449
479
  }));
450
- c(l);
480
+ u(l);
451
481
  };
452
- r.addEventListener("message", u, { once: !0 }), r.postMessage(d);
482
+ r.addEventListener("message", d, { once: !0 }), r.postMessage(c);
453
483
  });
454
484
  };
455
- function xe(n) {
456
- const { worker: e } = n;
485
+ function be(t) {
486
+ const { worker: e } = t;
457
487
  return {
458
- async searchFields({ text: r, layerIds: s, minScore: t, topResults: a, embeddingCache: i }) {
459
- return await Re({
488
+ async searchFields({ text: r, layerIds: s, minScore: n, topResults: a, embeddingCache: o }) {
489
+ return await Se({
460
490
  combinedQuery: r,
461
491
  layerIds: s,
462
492
  embeddingsWorker: e,
463
- minScore: t,
493
+ minScore: n,
464
494
  topResults: a,
465
- embeddingCache: i
495
+ embeddingCache: o
466
496
  });
467
497
  }
468
498
  };
469
499
  }
470
- const Se = (n) => {
471
- const e = H.safeParse(n);
500
+ const Ae = (t) => {
501
+ const e = O.safeParse(t);
472
502
  if (!e.success)
473
503
  throw new Error("Embeddings response validation failed. Regenerate embeddings.");
474
504
  return e.data;
475
- }, be = (n, e) => {
505
+ }, Ce = (t, e) => {
476
506
  const r = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map();
477
- if (e.allLayers.forEach((t) => {
478
- t instanceof V && s.set(t.id, t);
479
- }), n.length !== s.size)
507
+ if (e.allLayers.forEach((n) => {
508
+ n instanceof B && s.set(n.id, n);
509
+ }), t.length !== s.size)
480
510
  throw new Error("Layer count mismatch during registry restoration. Regenerate embeddings.");
481
- for (const t of n) {
482
- const a = s.get(t.id);
511
+ for (const n of t) {
512
+ const a = s.get(n.id);
483
513
  if (!a)
484
514
  throw new Error(
485
- `Layer with ID ${t.id} not found in the original map during registry restoration. Regenerate embeddings.`
515
+ `Layer with ID ${n.id} not found in the original map during registry restoration. Regenerate embeddings.`
486
516
  );
487
- if (t.fields.length !== a.fields.length)
517
+ if (n.fields.length !== a.fields.length)
488
518
  throw new Error(
489
- `Field count mismatch for layer ID ${t.id} during registry restoration. Regenerate embeddings.`
519
+ `Field count mismatch for layer ID ${n.id} during registry restoration. Regenerate embeddings.`
490
520
  );
491
- const i = {
492
- name: t.name,
493
- title: t.title,
494
- description: t.description
495
- }, o = /* @__PURE__ */ new Map();
496
- for (const d of t.fields) {
497
- const c = a.fieldsIndex.get(d.name);
498
- if (!c)
521
+ const o = {
522
+ name: n.name,
523
+ title: n.title,
524
+ description: n.description
525
+ }, i = /* @__PURE__ */ new Map();
526
+ for (const c of n.fields) {
527
+ const u = a.fieldsIndex.get(c.name);
528
+ if (!u)
499
529
  throw new Error(
500
- `Field with name ${d.name} not found in the original layer ${t.id} during registry restoration. Regenerate embeddings.`
530
+ `Field with name ${c.name} not found in the original layer ${n.id} during registry restoration. Regenerate embeddings.`
501
531
  );
502
- o.set(d.name, {
503
- name: d.name,
504
- alias: a.getFieldAlias(d.name) ?? d.alias,
505
- description: d.description,
506
- type: c.type || "unknown",
507
- valueType: c.valueType || "unknown",
508
- domain: a.getFieldDomain(d.name) ?? void 0
532
+ i.set(c.name, {
533
+ name: c.name,
534
+ alias: a.getFieldAlias(c.name) ?? c.alias,
535
+ description: c.description,
536
+ type: u.type || "unknown",
537
+ valueType: u.valueType || "unknown",
538
+ domain: a.getFieldDomain(c.name) ?? void 0
509
539
  });
510
540
  }
511
- r.set(t.id, {
512
- layerItem: i,
513
- fieldRegistry: o
541
+ r.set(n.id, {
542
+ layerItem: o,
543
+ fieldRegistry: i
514
544
  });
515
545
  }
516
546
  return r;
517
- }, Ae = async (n) => {
547
+ }, Ie = async (t) => {
518
548
  try {
519
- return (await z(n, {
549
+ return (await Q(t, {
520
550
  responseType: "json"
521
551
  })).data;
522
552
  } catch (e) {
523
- throw new Error(`Failed to fetch data from ${n}: ${String(e)}`);
553
+ throw new Error(`Failed to fetch data from ${t}: ${String(e)}`);
524
554
  }
525
- }, Ce = async (n) => {
526
- const e = n.map;
555
+ }, ke = async (t) => {
556
+ const e = t.map;
527
557
  if (!e?.portalItem)
528
558
  throw new Error("WebMap portal item is missing.");
529
- const { resources: r } = await e.portalItem.fetchResources(), s = r.find((i) => i.resource.path === "embeddings-v01.json");
559
+ const { resources: r } = await e.portalItem.fetchResources(), s = r.find((o) => o.resource.path === "embeddings-v01.json");
530
560
  if (!s?.resource.url)
531
561
  throw new Error("Embeddings resource 'embeddings-v01.json' not found in the webmap portal item.");
532
- const t = await Ae(s.resource.url);
533
- return Se(t);
562
+ const n = await Ie(s.resource.url);
563
+ return Ae(n);
534
564
  };
535
- class k {
565
+ class M {
536
566
  constructor() {
537
- 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;
567
+ this.orchestratorReady = !1, this.chatHistory = [], this.priorSteps = [], this.sharedState = {}, this.sharedResources = [], this.agentRegistry = new A(), this.activeRunId = "", this.cancelledRunIds = /* @__PURE__ */ new Set(), this.parentRunIds = /* @__PURE__ */ new Map(), this.activeRuntimeSpans = /* @__PURE__ */ new Map(), this.runtimeEventsEnabled = !1, this.streamEpoch = 0;
538
568
  }
539
569
  /**
540
570
  * Creates and returns an AI-ready Orchestrator instance.
@@ -542,16 +572,16 @@ class k {
542
572
  * @returns Ready Orchestrator.
543
573
  */
544
574
  static async init(e) {
545
- const r = new k();
575
+ const r = new M();
546
576
  r.runtimeEventsEnabled = e.runtimeEventsEnabled ?? !1;
547
577
  try {
548
578
  if (e.view?.map) {
549
- await N.whenOnce(() => e.view.ready);
550
- const s = await Ce(e.view), t = be(
579
+ await z.whenOnce(() => e.view.ready);
580
+ const s = await ke(e.view), n = Ce(
551
581
  s.layers,
552
582
  e.view.map
553
583
  );
554
- r.layersAndFieldsRegistry = t, r.embeddingsWorker = await B(s);
584
+ r.layersAndFieldsRegistry = n, r.embeddingsWorker = await K(s);
555
585
  }
556
586
  return e.agents?.forEach((s) => {
557
587
  r.agentRegistry.register(s);
@@ -582,30 +612,30 @@ class k {
582
612
  return;
583
613
  if (!e.trim() && r.routing !== "direct")
584
614
  throw new Error("Requests containing only structured input require direct agent routing.");
585
- const t = b();
586
- this.parentRunIds.clear(), this.activeRuntimeSpans.clear(), this.activeRunId = t, this.activeAbortController = new AbortController(), this.graph || (this.graph = le().compile({ checkpointer: new P() }));
587
- 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 = {
615
+ const n = C();
616
+ this.parentRunIds.clear(), this.activeRuntimeSpans.clear(), this.activeRunId = n, this.activeAbortController = new AbortController(), this.graph || (this.graph = pe().compile({ checkpointer: new j() }));
617
+ const a = this.embeddingsWorker ? xe({ worker: this.embeddingsWorker }) : void 0, o = this.embeddingsWorker ? be({ worker: this.embeddingsWorker }) : void 0, i = /* @__PURE__ */ new Map(), c = r.routing === "direct" ? { mode: "direct", agentId: r.agentId } : { mode: "auto" }, u = {
588
618
  // eslint-disable-next-line @typescript-eslint/naming-convention
589
- thread_id: t,
619
+ thread_id: n,
590
620
  locale: r.locale ?? "en",
591
621
  hitlResponse: null,
592
622
  services: {
593
623
  layerSearch: a,
594
- fieldSearch: i,
624
+ fieldSearch: o,
595
625
  layersAndFieldsRegistry: this.layersAndFieldsRegistry,
596
626
  agentRegistry: s,
597
- embeddingCache: o
627
+ embeddingCache: i
598
628
  }
599
- }, u = {
629
+ }, d = {
600
630
  version: "v2",
601
631
  streamMode: "custom",
602
632
  signal: this.activeAbortController.signal,
603
633
  ...this.runtimeEventsEnabled && { callbacks: [this.createHierarchyCallback()] },
604
- configurable: c,
634
+ configurable: u,
605
635
  subgraphs: !0
606
636
  }, g = this.graph?.streamEvents(
607
637
  {
608
- routing: d,
638
+ routing: c,
609
639
  agentExecutionContext: {
610
640
  userRequest: e,
611
641
  inputParts: [...r.inputParts ?? []],
@@ -615,32 +645,32 @@ class k {
615
645
  sharedResources: this.sharedResources
616
646
  }
617
647
  },
618
- u
648
+ d
619
649
  ), l = ++this.streamEpoch;
620
- if (yield* this.pipeStream(g, l, t), this.isRunCancelled(t)) {
621
- yield* this.createCancellationEvents(t);
650
+ if (yield* this.pipeStream(g, l, n), this.isRunCancelled(n)) {
651
+ yield* this.createCancellationEvents(n);
622
652
  return;
623
653
  }
624
654
  for (; ; ) {
625
- if (this.isRunCancelled(t)) {
626
- yield* this.createCancellationEvents(t);
655
+ if (this.isRunCancelled(n)) {
656
+ yield* this.createCancellationEvents(n);
627
657
  return;
628
658
  }
629
- const m = (await this.graph.getState(u, { subgraphs: !0 })).tasks.find((y) => y.interrupts.length > 0)?.interrupts[0]?.value;
659
+ const m = (await this.graph.getState(d, { subgraphs: !0 })).tasks.find((y) => y.interrupts.length > 0)?.interrupts[0]?.value;
630
660
  if (!m)
631
661
  break;
632
- 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 };
662
+ this.currentInterrupt = m, this.interruptHandler = new ve(this.graph, d), yield* this.closeActiveRuntimeSpans(n, "interrupted"), yield { runId: n, timestamp: Date.now(), type: "interrupt", interrupt: m };
633
663
  try {
634
- const y = await this.interruptHandler.waitForUser(), I = ++this.streamEpoch;
635
- yield* this.pipeStream(y, I, t);
664
+ const y = await this.interruptHandler.waitForUser(), _ = ++this.streamEpoch;
665
+ yield* this.pipeStream(y, _, n);
636
666
  } catch (y) {
637
- if (this.isRunCancelled(t)) {
638
- yield* this.createCancellationEvents(t);
667
+ if (this.isRunCancelled(n)) {
668
+ yield* this.createCancellationEvents(n);
639
669
  return;
640
670
  }
641
671
  if (y) {
642
672
  yield {
643
- runId: t,
673
+ runId: n,
644
674
  timestamp: Date.now(),
645
675
  type: "error",
646
676
  error: { message: y?.message }
@@ -649,17 +679,17 @@ class k {
649
679
  }
650
680
  }
651
681
  }
652
- if (this.isRunCancelled(t)) {
653
- yield* this.createCancellationEvents(t);
682
+ if (this.isRunCancelled(n)) {
683
+ yield* this.createCancellationEvents(n);
654
684
  return;
655
685
  }
656
- const h = (await this.graph.getState(u, { subgraphs: !0 })).values;
657
- if (this.isRunCancelled(t)) {
658
- yield* this.createCancellationEvents(t);
686
+ const h = (await this.graph.getState(d, { subgraphs: !0 })).values;
687
+ if (this.isRunCancelled(n)) {
688
+ yield* this.createCancellationEvents(n);
659
689
  return;
660
690
  }
661
691
  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 {
662
- runId: t,
692
+ runId: n,
663
693
  timestamp: Date.now(),
664
694
  type: "completed",
665
695
  result: { content: h.finalOutputMessage }
@@ -698,45 +728,45 @@ class k {
698
728
  }
699
729
  async *pipeStream(e, r, s) {
700
730
  try {
701
- for await (const t of e) {
731
+ for await (const n of e) {
702
732
  if (this.isRunCancelled(s) || r !== this.streamEpoch)
703
733
  break;
704
734
  if (this.runtimeEventsEnabled) {
705
- const a = ye({
706
- event: t,
735
+ const a = we({
736
+ event: n,
707
737
  runId: s,
708
- parentSpanId: this.parentRunIds.get(t.run_id),
738
+ parentSpanId: this.parentRunIds.get(n.run_id),
709
739
  timestamp: Date.now()
710
740
  });
711
741
  a && (a.phase === "started" ? this.activeRuntimeSpans.set(a.span.id, a) : this.activeRuntimeSpans.delete(a.span.id), yield a);
712
742
  }
713
- 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 {
743
+ 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 {
714
744
  runId: s,
715
745
  timestamp: Date.now(),
716
746
  type: "ux-suggestion",
717
- suggestion: t.data
747
+ suggestion: n.data
718
748
  });
719
749
  }
720
- } catch (t) {
750
+ } catch (n) {
721
751
  if (!this.isRunCancelled(s))
722
- throw t;
752
+ throw n;
723
753
  }
724
754
  }
725
755
  *createCancellationEvents(e) {
726
756
  yield* this.closeActiveRuntimeSpans(e, "cancelled"), yield { runId: e, timestamp: Date.now(), type: "cancelled", reason: "user" };
727
757
  }
728
758
  *closeActiveRuntimeSpans(e, r) {
729
- const s = Date.now(), t = [...this.activeRuntimeSpans.values()].reverse();
759
+ const s = Date.now(), n = [...this.activeRuntimeSpans.values()].reverse();
730
760
  this.activeRuntimeSpans.clear();
731
- for (const a of t) {
732
- const { input: i, ...o } = a.span;
761
+ for (const a of n) {
762
+ const { input: o, ...i } = a.span;
733
763
  yield {
734
764
  type: "runtime",
735
765
  phase: r,
736
766
  runId: e,
737
767
  timestamp: s,
738
768
  ...a.agentId && { agentId: a.agentId },
739
- span: o
769
+ span: i
740
770
  };
741
771
  }
742
772
  }
@@ -745,12 +775,12 @@ class k {
745
775
  const e = (r, s) => {
746
776
  s && this.parentRunIds.set(r, s);
747
777
  };
748
- return G.fromMethods({
749
- handleLLMStart: (r, s, t, a) => e(t, a),
750
- handleChatModelStart: (r, s, t, a) => e(t, a),
751
- handleChainStart: (r, s, t, a) => e(t, a),
752
- handleToolStart: (r, s, t, a) => e(t, a),
753
- handleRetrieverStart: (r, s, t, a) => e(t, a)
778
+ return V.fromMethods({
779
+ handleLLMStart: (r, s, n, a) => e(n, a),
780
+ handleChatModelStart: (r, s, n, a) => e(n, a),
781
+ handleChainStart: (r, s, n, a) => e(n, a),
782
+ handleToolStart: (r, s, n, a) => e(n, a),
783
+ handleRetrieverStart: (r, s, n, a) => e(n, a)
754
784
  });
755
785
  }
756
786
  isRunCancelled(e) {
@@ -762,12 +792,12 @@ class k {
762
792
  */
763
793
  createRequestAgentRegistry(e) {
764
794
  const r = e.routing === "direct" ? [e.agentId] : e.agentIds, s = r ? r.map((a) => {
765
- const i = this.agentRegistry.get(a);
766
- if (!i)
795
+ const o = this.agentRegistry.get(a);
796
+ if (!o)
767
797
  throw new Error(`Agent is not registered: ${a}`);
768
- return i;
769
- }) : this.agentRegistry.list(), t = new S();
770
- return s.forEach((a) => t.register(a)), t;
798
+ return o;
799
+ }) : this.agentRegistry.list(), n = new A();
800
+ return s.forEach((a) => n.register(a)), n;
771
801
  }
772
802
  /**
773
803
  * Disposes this instance by terminating the embeddings worker
@@ -778,6 +808,6 @@ class k {
778
808
  }
779
809
  }
780
810
  export {
781
- k as O,
782
- we as g
811
+ M as O,
812
+ Ee as g
783
813
  };