@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.
- package/dist/agent-utils/LLMAgent.js +2 -0
- package/dist/agents/runtime/skill/createSkillAgent.js +115 -131
- package/dist/cdn/2DYOTV7W.js +4 -0
- package/dist/cdn/2WT4JANT.js +2 -0
- package/dist/cdn/{2NODROJN.js → 3F5EZZSG.js} +20 -24
- package/dist/cdn/4V3Q7XGS.js +2 -0
- package/dist/cdn/5GALSAQF.js +3 -0
- package/dist/cdn/72KYGCIU.js +2 -0
- package/dist/cdn/75OPJOCY.js +2 -0
- package/dist/cdn/7D6POJJA.js +2 -0
- package/dist/cdn/{SLR75R32.js → 7HVK7G55.js} +1 -1
- package/dist/cdn/7L6LPWRH.js +2 -0
- package/dist/cdn/7TAIUEMW.js +2 -0
- package/dist/cdn/{C2W6MBDB.js → D3E5NSY3.js} +1 -1
- package/dist/cdn/ESPC6NTI.js +68 -0
- package/dist/cdn/{HTB76P2C.js → EWO73MJA.js} +1 -1
- package/dist/cdn/{EIZR3Q5O.js → FGQLS3UX.js} +1 -1
- package/dist/cdn/FOZAOJCM.js +2 -0
- package/dist/cdn/GZDI2LAT.js +2 -0
- package/dist/cdn/H4ERKWFA.js +2 -0
- package/dist/cdn/{7W7KWR5O.js → H5AVPDSE.js} +4 -4
- package/dist/cdn/{2I2FHPHR.js → HDAMDEYL.js} +6 -6
- package/dist/cdn/JE55XX2C.js +2 -0
- package/dist/cdn/K36XPG2M.js +2 -0
- package/dist/cdn/KDE5MMMR.js +2 -0
- package/dist/cdn/{ZGZX7GR5.js → KONQTXBJ.js} +1 -1
- package/dist/cdn/{J4YHT55S.js → MCZJD3A4.js} +1 -1
- package/dist/cdn/MNZAQM3Q.js +3 -0
- package/dist/cdn/NHZRDYLP.js +2 -0
- package/dist/cdn/NYFV4A6L.js +3 -0
- package/dist/cdn/OGYNTGNM.js +2 -0
- package/dist/cdn/PGIXKPTW.js +2 -0
- package/dist/cdn/PTEKX5TX.js +2 -0
- package/dist/cdn/PUHPFUCU.js +2 -0
- package/dist/cdn/{GKWMAWFZ.js → QDOKDRBB.js} +1 -1
- package/dist/cdn/TGZBLBEJ.js +2 -0
- package/dist/cdn/{K7BUBCK7.js → UBKYXKMW.js} +1 -1
- package/dist/cdn/UXECAKJ7.js +2 -0
- package/dist/cdn/WXOKGQ4D.js +2 -0
- package/dist/cdn/Y364LLPN.js +2 -0
- package/dist/cdn/YBSY32EU.js +2 -0
- package/dist/cdn/{CF2V3NER.js → ZLLVPKDN.js} +35 -35
- package/dist/cdn/agent-utils/index.js +1 -1
- package/dist/cdn/assets/agents/t9n/messages.ar.json +1 -0
- package/dist/cdn/assets/agents/t9n/messages.bg.json +1 -0
- package/dist/cdn/assets/agents/t9n/messages.ca.json +1 -0
- package/dist/cdn/assets/agents/t9n/messages.cs.json +1 -0
- package/dist/cdn/assets/agents/t9n/messages.da.json +1 -0
- package/dist/cdn/assets/agents/t9n/messages.de.json +1 -0
- package/dist/cdn/assets/agents/t9n/messages.el.json +1 -0
- package/dist/cdn/assets/agents/t9n/messages.es.json +1 -0
- package/dist/cdn/assets/agents/t9n/messages.et.json +1 -0
- package/dist/cdn/assets/agents/t9n/messages.fi.json +1 -0
- package/dist/cdn/assets/agents/t9n/messages.fr.json +1 -0
- package/dist/cdn/assets/agents/t9n/messages.he.json +1 -0
- package/dist/cdn/assets/agents/t9n/messages.hr.json +1 -0
- package/dist/cdn/assets/agents/t9n/messages.hu.json +1 -0
- package/dist/cdn/assets/agents/t9n/messages.id.json +1 -0
- package/dist/cdn/assets/agents/t9n/messages.it.json +1 -0
- package/dist/cdn/assets/agents/t9n/messages.ja.json +1 -0
- package/dist/cdn/assets/agents/t9n/messages.ko.json +1 -0
- package/dist/cdn/assets/agents/t9n/messages.lt.json +1 -0
- package/dist/cdn/assets/agents/t9n/messages.lv.json +1 -0
- package/dist/cdn/assets/agents/t9n/messages.nl.json +1 -0
- package/dist/cdn/assets/agents/t9n/messages.no.json +1 -0
- package/dist/cdn/assets/agents/t9n/messages.pl.json +1 -0
- package/dist/cdn/assets/agents/t9n/messages.pt-BR.json +1 -0
- package/dist/cdn/assets/agents/t9n/messages.pt-PT.json +1 -0
- package/dist/cdn/assets/agents/t9n/messages.ro.json +1 -0
- package/dist/cdn/assets/agents/t9n/messages.ru.json +1 -0
- package/dist/cdn/assets/agents/t9n/messages.sk.json +1 -0
- package/dist/cdn/assets/agents/t9n/messages.sl.json +1 -0
- package/dist/cdn/assets/agents/t9n/messages.sr.json +1 -0
- package/dist/cdn/assets/agents/t9n/messages.sv.json +1 -0
- package/dist/cdn/assets/agents/t9n/messages.th.json +1 -0
- package/dist/cdn/assets/agents/t9n/messages.tr.json +1 -0
- package/dist/cdn/assets/agents/t9n/messages.uk.json +1 -0
- package/dist/cdn/assets/agents/t9n/messages.vi.json +1 -0
- package/dist/cdn/assets/agents/t9n/messages.zh-CN.json +1 -0
- package/dist/cdn/assets/agents/t9n/messages.zh-TW.json +1 -0
- package/dist/cdn/assets/orchestrator/t9n/messages.en.json +1 -0
- package/dist/cdn/index.js +1 -1
- package/dist/chunks/adapter.js +54 -52
- package/dist/chunks/aiFactory.js +59 -41
- package/dist/chunks/arcgisKnowledgeGraph.js +4 -2
- package/dist/chunks/dataExplorationAgent.js +1 -1
- package/dist/chunks/generateLayerDescriptions.js +160 -156
- package/dist/chunks/layerStylingGraph.js +2 -0
- package/dist/chunks/orchestrator.js +325 -295
- package/dist/components/arcgis-assistant/customElement.d.ts +1 -1
- package/dist/components/arcgis-assistant/customElement.js +113 -112
- package/dist/components/arcgis-assistant-agent/customElement.js +1 -0
- package/dist/components/arcgis-assistant-data-exploration-agent/customElement.js +1 -0
- package/dist/components/arcgis-assistant-help-agent/customElement.js +1 -0
- package/dist/components/arcgis-assistant-knowledge-agent/customElement.js +5 -4
- package/dist/components/arcgis-assistant-layer-styling-agent/customElement.js +1 -0
- package/dist/components/arcgis-assistant-navigation-agent/customElement.js +1 -0
- package/dist/docs/api.json +1 -1
- package/dist/docs/docs.json +1 -1
- package/dist/docs/vscode.html-custom-data.json +1 -1
- package/dist/docs/web-types.json +1 -1
- package/dist/utils/index.js +38 -36
- package/package.json +7 -7
- package/dist/cdn/5BBXNT75.js +0 -66
- package/dist/cdn/5HBAJ57P.js +0 -2
- package/dist/cdn/5MK44FNO.js +0 -2
- package/dist/cdn/6ECRQVHY.js +0 -2
- package/dist/cdn/AUDVUNF3.js +0 -2
- package/dist/cdn/BJUX4AYP.js +0 -2
- package/dist/cdn/COH3QXWG.js +0 -4
- package/dist/cdn/CPQGLQGY.js +0 -2
- package/dist/cdn/CT2ZOYNX.js +0 -2
- package/dist/cdn/DNV3L5M6.js +0 -2
- package/dist/cdn/EDVH3G5A.js +0 -2
- package/dist/cdn/HWGAJ4WN.js +0 -2
- package/dist/cdn/IHRX74QJ.js +0 -2
- package/dist/cdn/LRH2ZPVW.js +0 -2
- package/dist/cdn/OTOQL3QM.js +0 -3
- package/dist/cdn/R74ZHFA6.js +0 -2
- package/dist/cdn/RGVC76RW.js +0 -2
- package/dist/cdn/RIN3RP7D.js +0 -3
- package/dist/cdn/SWVRA77H.js +0 -2
- package/dist/cdn/TLQ75QXG.js +0 -2
- package/dist/cdn/TPF5Z277.js +0 -3
- package/dist/cdn/UIIVUHXL.js +0 -2
- package/dist/cdn/UWZQWGZP.js +0 -2
- package/dist/cdn/UXYYH6XF.js +0 -2
- package/dist/cdn/XUYARLRP.js +0 -2
- package/dist/cdn/XV3DHHYJ.js +0 -2
- package/dist/cdn/Y2BCEVV6.js +0 -2
- package/dist/cdn/YJ4MZOVC.js +0 -2
- package/dist/cdn/YXIPCGGP.js +0 -2
- 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
|
|
3
|
-
import
|
|
4
|
-
import { g as
|
|
5
|
-
import { isGraphInterrupt as
|
|
6
|
-
import { generateGuid as
|
|
7
|
-
import { g as
|
|
8
|
-
import { HumanMessage as
|
|
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
|
|
11
|
-
import * as
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
const
|
|
15
|
-
const e = await
|
|
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:
|
|
17
|
+
webmapEmbeddings: t,
|
|
18
18
|
auth: { apiUrl: r, token: a }
|
|
19
19
|
};
|
|
20
|
-
return e.postMessage(
|
|
21
|
-
const
|
|
22
|
-
g.data === "completed" && (e.removeEventListener("message",
|
|
23
|
-
},
|
|
24
|
-
e.removeEventListener("message",
|
|
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",
|
|
26
|
+
e.addEventListener("message", u), e.addEventListener("error", d, { once: !0 });
|
|
27
27
|
}), e;
|
|
28
|
-
},
|
|
28
|
+
}, J = async () => {
|
|
29
29
|
{
|
|
30
|
-
const
|
|
31
|
-
return new
|
|
32
|
-
}
|
|
33
|
-
},
|
|
34
|
-
|
|
35
|
-
},
|
|
36
|
-
const r =
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
|
|
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,
|
|
50
|
-
if (!
|
|
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:
|
|
68
|
+
r[s] = { value: n.value };
|
|
57
69
|
}
|
|
58
70
|
return r;
|
|
59
|
-
},
|
|
60
|
-
const { previousSharedState: e, patch: r, agentId: s } =
|
|
71
|
+
}, te = (t) => {
|
|
72
|
+
const { previousSharedState: e, patch: r, agentId: s } = t;
|
|
61
73
|
if (!r)
|
|
62
74
|
return e;
|
|
63
|
-
const
|
|
75
|
+
const n = Date.now(), a = {
|
|
64
76
|
...e
|
|
65
77
|
};
|
|
66
|
-
for (const [
|
|
67
|
-
|
|
68
|
-
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:
|
|
83
|
+
updatedAt: n
|
|
72
84
|
}
|
|
73
85
|
});
|
|
74
86
|
return a;
|
|
75
|
-
},
|
|
76
|
-
if (
|
|
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(
|
|
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,
|
|
84
|
-
if (!
|
|
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(
|
|
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:
|
|
101
|
-
description:
|
|
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
|
-
},
|
|
107
|
-
const { previousSharedResources: e, additions: r, agentId: s } =
|
|
118
|
+
}, ie = (t) => {
|
|
119
|
+
const { previousSharedResources: e, additions: r, agentId: s } = t;
|
|
108
120
|
if (!r?.length)
|
|
109
121
|
return e;
|
|
110
|
-
const
|
|
111
|
-
...
|
|
112
|
-
id:
|
|
122
|
+
const n = Date.now(), a = r.map((o) => ({
|
|
123
|
+
...o,
|
|
124
|
+
id: C(),
|
|
113
125
|
meta: {
|
|
114
126
|
createdByAgentId: s,
|
|
115
|
-
createdAt:
|
|
127
|
+
createdAt: n
|
|
116
128
|
}
|
|
117
129
|
}));
|
|
118
130
|
return [...e, ...a].slice(-50);
|
|
119
|
-
},
|
|
120
|
-
if (typeof
|
|
131
|
+
}, S = (t) => {
|
|
132
|
+
if (typeof t != "string")
|
|
121
133
|
return;
|
|
122
|
-
const e =
|
|
134
|
+
const e = t.trim();
|
|
123
135
|
return e || void 0;
|
|
124
|
-
},
|
|
125
|
-
switch (
|
|
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
|
-
},
|
|
136
|
-
const r =
|
|
137
|
-
a === "unknown" && console.warn(`Agent "${
|
|
138
|
-
const
|
|
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 ??
|
|
153
|
+
summary: s ?? r ?? oe(a),
|
|
142
154
|
status: a,
|
|
143
|
-
sharedStatePatch:
|
|
144
|
-
sharedResourceAdditions:
|
|
155
|
+
sharedStatePatch: o,
|
|
156
|
+
sharedResourceAdditions: i
|
|
145
157
|
};
|
|
146
|
-
},
|
|
147
|
-
const r =
|
|
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:
|
|
150
|
-
...
|
|
164
|
+
return await p({ text: s.runCancelledAgentExecution }, e), {
|
|
165
|
+
...t,
|
|
151
166
|
currentIntent: "none",
|
|
152
167
|
requiresFollowUp: !1
|
|
153
168
|
};
|
|
154
|
-
const { agentRegistry:
|
|
155
|
-
if (!
|
|
156
|
-
return console.warn(
|
|
157
|
-
await p(
|
|
158
|
-
|
|
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:
|
|
180
|
+
agentId: a.agent.id
|
|
163
181
|
},
|
|
164
182
|
configurable: {
|
|
165
183
|
...r ?? {},
|
|
166
|
-
agentId:
|
|
167
|
-
context:
|
|
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
|
|
190
|
+
const d = await a.agent.createGraph().compile().invoke(
|
|
173
191
|
{
|
|
174
192
|
agentExecutionContext: {
|
|
175
|
-
...
|
|
193
|
+
...t.agentExecutionContext,
|
|
176
194
|
// deep clone on messages did not work in agents, so its a shallow clone here.
|
|
177
|
-
messages: [...
|
|
195
|
+
messages: [...t.agentExecutionContext.messages],
|
|
178
196
|
// deep clone to prevent accidental mutations by agents
|
|
179
|
-
priorSteps: structuredClone(
|
|
180
|
-
sharedState: structuredClone(
|
|
181
|
-
sharedResources: structuredClone(
|
|
197
|
+
priorSteps: structuredClone(t.agentExecutionContext.priorSteps ?? []),
|
|
198
|
+
sharedState: structuredClone(t.agentExecutionContext.sharedState ?? {}),
|
|
199
|
+
sharedResources: structuredClone(t.agentExecutionContext.sharedResources ?? [])
|
|
182
200
|
}
|
|
183
201
|
},
|
|
184
|
-
|
|
202
|
+
o
|
|
185
203
|
);
|
|
186
|
-
i =
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
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:
|
|
194
|
-
summary:
|
|
219
|
+
outputMessage: s.agentExecutionFailed.replace("{error}", g),
|
|
220
|
+
summary: s.agentExecutionFailed.replace("{error}", g)
|
|
195
221
|
};
|
|
196
222
|
}
|
|
197
|
-
const
|
|
198
|
-
if (
|
|
199
|
-
const
|
|
200
|
-
[truncated]` :
|
|
201
|
-
|
|
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
|
-
...
|
|
205
|
-
stepCount:
|
|
206
|
-
lastExecutedAgent:
|
|
207
|
-
requiresFollowUp: i.status === "failed" ? !0 :
|
|
208
|
-
finalOutputMessage:
|
|
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
|
-
...
|
|
211
|
-
messages:
|
|
236
|
+
...t.agentExecutionContext,
|
|
237
|
+
messages: u,
|
|
212
238
|
priorSteps: [
|
|
213
|
-
...
|
|
239
|
+
...t.agentExecutionContext.priorSteps ?? [],
|
|
214
240
|
{
|
|
215
|
-
agentId:
|
|
216
|
-
assignedTask:
|
|
217
|
-
summary: i?.summary ||
|
|
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:
|
|
222
|
-
previousSharedState:
|
|
247
|
+
sharedState: te({
|
|
248
|
+
previousSharedState: t.agentExecutionContext.sharedState,
|
|
223
249
|
patch: i.sharedStatePatch,
|
|
224
|
-
agentId:
|
|
250
|
+
agentId: a.agent.id
|
|
225
251
|
}),
|
|
226
|
-
sharedResources:
|
|
227
|
-
previousSharedResources:
|
|
252
|
+
sharedResources: ie({
|
|
253
|
+
previousSharedResources: t.agentExecutionContext.sharedResources,
|
|
228
254
|
additions: i.sharedResourceAdditions,
|
|
229
|
-
agentId:
|
|
255
|
+
agentId: a.agent.id
|
|
230
256
|
})
|
|
231
257
|
}
|
|
232
258
|
};
|
|
233
|
-
},
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
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
|
-
...
|
|
242
|
-
assignedTask:
|
|
271
|
+
...t.agentExecutionContext,
|
|
272
|
+
assignedTask: t.agentExecutionContext.userRequest
|
|
243
273
|
}
|
|
244
274
|
};
|
|
245
|
-
},
|
|
246
|
-
const r =
|
|
247
|
-
if (
|
|
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
|
|
279
|
+
const i = r?.input_token_details?.cache_read, c = r?.output_token_details?.reasoning;
|
|
250
280
|
return {
|
|
251
|
-
input:
|
|
281
|
+
input: n,
|
|
252
282
|
output: a,
|
|
253
|
-
total:
|
|
254
|
-
...
|
|
255
|
-
...
|
|
283
|
+
total: o,
|
|
284
|
+
...i !== void 0 && { cacheRead: i },
|
|
285
|
+
...c !== void 0 && { reasoning: c }
|
|
256
286
|
};
|
|
257
|
-
},
|
|
258
|
-
switch (
|
|
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
|
|
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
|
-
},
|
|
271
|
-
if (
|
|
272
|
-
return { message:
|
|
273
|
-
const e =
|
|
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
|
-
},
|
|
276
|
-
event:
|
|
305
|
+
}, we = ({
|
|
306
|
+
event: t,
|
|
277
307
|
runId: e,
|
|
278
308
|
parentSpanId: r,
|
|
279
309
|
timestamp: s
|
|
280
310
|
}) => {
|
|
281
|
-
const
|
|
282
|
-
if (!
|
|
311
|
+
const n = /^on_(.+)_(start|end|error)$/u.exec(t.event);
|
|
312
|
+
if (!n)
|
|
283
313
|
return;
|
|
284
|
-
const [, a,
|
|
285
|
-
if (!
|
|
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
|
|
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:
|
|
322
|
+
id: t.run_id,
|
|
293
323
|
...r && { parentId: r },
|
|
294
|
-
label:
|
|
295
|
-
type:
|
|
296
|
-
...Object.keys(
|
|
297
|
-
}, m = { runId: e, timestamp: s, type: "runtime", ...
|
|
298
|
-
switch (
|
|
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:
|
|
348
|
+
return { ...m, phase: "failed", span: { ...w, error: fe(l?.error) } };
|
|
319
349
|
default:
|
|
320
350
|
return;
|
|
321
351
|
}
|
|
322
352
|
};
|
|
323
|
-
class
|
|
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
|
|
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
|
-
},
|
|
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?.(
|
|
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
|
|
417
|
+
const Ee = async (t) => {
|
|
388
418
|
try {
|
|
389
|
-
return await (await
|
|
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
|
-
},
|
|
394
|
-
const r = e.get(
|
|
423
|
+
}, k = async (t, e) => {
|
|
424
|
+
const r = e.get(t);
|
|
395
425
|
if (r)
|
|
396
426
|
return r;
|
|
397
|
-
const s = await
|
|
398
|
-
return e.set(
|
|
427
|
+
const s = await Ee([t]);
|
|
428
|
+
return e.set(t, s[0]), s[0];
|
|
399
429
|
};
|
|
400
|
-
async function
|
|
401
|
-
const
|
|
430
|
+
async function Re(t, e, r, s) {
|
|
431
|
+
const n = `req-${Date.now()}`, o = {
|
|
402
432
|
type: "layerSearch",
|
|
403
|
-
precomputedEmbedding: s ? await
|
|
404
|
-
requestId:
|
|
433
|
+
precomputedEmbedding: s ? await k(t, s) : void 0,
|
|
434
|
+
requestId: n,
|
|
405
435
|
minScore: r
|
|
406
436
|
};
|
|
407
|
-
return await new Promise((
|
|
408
|
-
const
|
|
409
|
-
|
|
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",
|
|
441
|
+
e.addEventListener("message", c, { once: !0 }), e.postMessage(o);
|
|
412
442
|
});
|
|
413
443
|
}
|
|
414
|
-
function
|
|
415
|
-
const { worker: e } =
|
|
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:
|
|
450
|
+
embeddingCache: n
|
|
421
451
|
}) {
|
|
422
|
-
return await
|
|
452
|
+
return await Re(r, e, s, n);
|
|
423
453
|
}
|
|
424
454
|
};
|
|
425
455
|
}
|
|
426
|
-
const
|
|
427
|
-
combinedQuery:
|
|
456
|
+
const Se = async ({
|
|
457
|
+
combinedQuery: t,
|
|
428
458
|
layerIds: e,
|
|
429
459
|
embeddingsWorker: r,
|
|
430
460
|
minScore: s,
|
|
431
|
-
topResults:
|
|
461
|
+
topResults: n,
|
|
432
462
|
embeddingCache: a
|
|
433
463
|
}) => {
|
|
434
|
-
const
|
|
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:
|
|
438
|
-
requestId:
|
|
467
|
+
precomputedEmbedding: i,
|
|
468
|
+
requestId: o,
|
|
439
469
|
minScore: s,
|
|
440
|
-
topResults:
|
|
470
|
+
topResults: n
|
|
441
471
|
};
|
|
442
|
-
return await new Promise((
|
|
443
|
-
const
|
|
444
|
-
if (g.data.requestId !==
|
|
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
|
-
|
|
480
|
+
u(l);
|
|
451
481
|
};
|
|
452
|
-
r.addEventListener("message",
|
|
482
|
+
r.addEventListener("message", d, { once: !0 }), r.postMessage(c);
|
|
453
483
|
});
|
|
454
484
|
};
|
|
455
|
-
function
|
|
456
|
-
const { worker: e } =
|
|
485
|
+
function be(t) {
|
|
486
|
+
const { worker: e } = t;
|
|
457
487
|
return {
|
|
458
|
-
async searchFields({ text: r, layerIds: s, minScore:
|
|
459
|
-
return await
|
|
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:
|
|
493
|
+
minScore: n,
|
|
464
494
|
topResults: a,
|
|
465
|
-
embeddingCache:
|
|
495
|
+
embeddingCache: o
|
|
466
496
|
});
|
|
467
497
|
}
|
|
468
498
|
};
|
|
469
499
|
}
|
|
470
|
-
const
|
|
471
|
-
const e =
|
|
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
|
-
},
|
|
505
|
+
}, Ce = (t, e) => {
|
|
476
506
|
const r = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map();
|
|
477
|
-
if (e.allLayers.forEach((
|
|
478
|
-
|
|
479
|
-
}),
|
|
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
|
|
482
|
-
const a = s.get(
|
|
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 ${
|
|
515
|
+
`Layer with ID ${n.id} not found in the original map during registry restoration. Regenerate embeddings.`
|
|
486
516
|
);
|
|
487
|
-
if (
|
|
517
|
+
if (n.fields.length !== a.fields.length)
|
|
488
518
|
throw new Error(
|
|
489
|
-
`Field count mismatch for layer ID ${
|
|
519
|
+
`Field count mismatch for layer ID ${n.id} during registry restoration. Regenerate embeddings.`
|
|
490
520
|
);
|
|
491
|
-
const
|
|
492
|
-
name:
|
|
493
|
-
title:
|
|
494
|
-
description:
|
|
495
|
-
},
|
|
496
|
-
for (const
|
|
497
|
-
const
|
|
498
|
-
if (!
|
|
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 ${
|
|
530
|
+
`Field with name ${c.name} not found in the original layer ${n.id} during registry restoration. Regenerate embeddings.`
|
|
501
531
|
);
|
|
502
|
-
|
|
503
|
-
name:
|
|
504
|
-
alias: a.getFieldAlias(
|
|
505
|
-
description:
|
|
506
|
-
type:
|
|
507
|
-
valueType:
|
|
508
|
-
domain: a.getFieldDomain(
|
|
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(
|
|
512
|
-
layerItem:
|
|
513
|
-
fieldRegistry:
|
|
541
|
+
r.set(n.id, {
|
|
542
|
+
layerItem: o,
|
|
543
|
+
fieldRegistry: i
|
|
514
544
|
});
|
|
515
545
|
}
|
|
516
546
|
return r;
|
|
517
|
-
},
|
|
547
|
+
}, Ie = async (t) => {
|
|
518
548
|
try {
|
|
519
|
-
return (await
|
|
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 ${
|
|
553
|
+
throw new Error(`Failed to fetch data from ${t}: ${String(e)}`);
|
|
524
554
|
}
|
|
525
|
-
},
|
|
526
|
-
const e =
|
|
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((
|
|
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
|
|
533
|
-
return
|
|
562
|
+
const n = await Ie(s.resource.url);
|
|
563
|
+
return Ae(n);
|
|
534
564
|
};
|
|
535
|
-
class
|
|
565
|
+
class M {
|
|
536
566
|
constructor() {
|
|
537
|
-
this.orchestratorReady = !1, this.chatHistory = [], this.priorSteps = [], this.sharedState = {}, this.sharedResources = [], this.agentRegistry = new
|
|
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
|
|
575
|
+
const r = new M();
|
|
546
576
|
r.runtimeEventsEnabled = e.runtimeEventsEnabled ?? !1;
|
|
547
577
|
try {
|
|
548
578
|
if (e.view?.map) {
|
|
549
|
-
await
|
|
550
|
-
const s = await
|
|
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 =
|
|
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
|
|
586
|
-
this.parentRunIds.clear(), this.activeRuntimeSpans.clear(), this.activeRunId =
|
|
587
|
-
const a = this.embeddingsWorker ?
|
|
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:
|
|
619
|
+
thread_id: n,
|
|
590
620
|
locale: r.locale ?? "en",
|
|
591
621
|
hitlResponse: null,
|
|
592
622
|
services: {
|
|
593
623
|
layerSearch: a,
|
|
594
|
-
fieldSearch:
|
|
624
|
+
fieldSearch: o,
|
|
595
625
|
layersAndFieldsRegistry: this.layersAndFieldsRegistry,
|
|
596
626
|
agentRegistry: s,
|
|
597
|
-
embeddingCache:
|
|
627
|
+
embeddingCache: i
|
|
598
628
|
}
|
|
599
|
-
},
|
|
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:
|
|
634
|
+
configurable: u,
|
|
605
635
|
subgraphs: !0
|
|
606
636
|
}, g = this.graph?.streamEvents(
|
|
607
637
|
{
|
|
608
|
-
routing:
|
|
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
|
-
|
|
648
|
+
d
|
|
619
649
|
), l = ++this.streamEpoch;
|
|
620
|
-
if (yield* this.pipeStream(g, l,
|
|
621
|
-
yield* this.createCancellationEvents(
|
|
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(
|
|
626
|
-
yield* this.createCancellationEvents(
|
|
655
|
+
if (this.isRunCancelled(n)) {
|
|
656
|
+
yield* this.createCancellationEvents(n);
|
|
627
657
|
return;
|
|
628
658
|
}
|
|
629
|
-
const m = (await this.graph.getState(
|
|
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
|
|
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(),
|
|
635
|
-
yield* this.pipeStream(y,
|
|
664
|
+
const y = await this.interruptHandler.waitForUser(), _ = ++this.streamEpoch;
|
|
665
|
+
yield* this.pipeStream(y, _, n);
|
|
636
666
|
} catch (y) {
|
|
637
|
-
if (this.isRunCancelled(
|
|
638
|
-
yield* this.createCancellationEvents(
|
|
667
|
+
if (this.isRunCancelled(n)) {
|
|
668
|
+
yield* this.createCancellationEvents(n);
|
|
639
669
|
return;
|
|
640
670
|
}
|
|
641
671
|
if (y) {
|
|
642
672
|
yield {
|
|
643
|
-
runId:
|
|
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(
|
|
653
|
-
yield* this.createCancellationEvents(
|
|
682
|
+
if (this.isRunCancelled(n)) {
|
|
683
|
+
yield* this.createCancellationEvents(n);
|
|
654
684
|
return;
|
|
655
685
|
}
|
|
656
|
-
const h = (await this.graph.getState(
|
|
657
|
-
if (this.isRunCancelled(
|
|
658
|
-
yield* this.createCancellationEvents(
|
|
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:
|
|
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
|
|
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 =
|
|
706
|
-
event:
|
|
735
|
+
const a = we({
|
|
736
|
+
event: n,
|
|
707
737
|
runId: s,
|
|
708
|
-
parentSpanId: this.parentRunIds.get(
|
|
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
|
-
|
|
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:
|
|
747
|
+
suggestion: n.data
|
|
718
748
|
});
|
|
719
749
|
}
|
|
720
|
-
} catch (
|
|
750
|
+
} catch (n) {
|
|
721
751
|
if (!this.isRunCancelled(s))
|
|
722
|
-
throw
|
|
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(),
|
|
759
|
+
const s = Date.now(), n = [...this.activeRuntimeSpans.values()].reverse();
|
|
730
760
|
this.activeRuntimeSpans.clear();
|
|
731
|
-
for (const a of
|
|
732
|
-
const { input:
|
|
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:
|
|
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
|
|
749
|
-
handleLLMStart: (r, s,
|
|
750
|
-
handleChatModelStart: (r, s,
|
|
751
|
-
handleChainStart: (r, s,
|
|
752
|
-
handleToolStart: (r, s,
|
|
753
|
-
handleRetrieverStart: (r, s,
|
|
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
|
|
766
|
-
if (!
|
|
795
|
+
const o = this.agentRegistry.get(a);
|
|
796
|
+
if (!o)
|
|
767
797
|
throw new Error(`Agent is not registered: ${a}`);
|
|
768
|
-
return
|
|
769
|
-
}) : this.agentRegistry.list(),
|
|
770
|
-
return s.forEach((a) =>
|
|
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
|
-
|
|
782
|
-
|
|
811
|
+
M as O,
|
|
812
|
+
Ee as g
|
|
783
813
|
};
|