@automattic/agenttic-client 0.1.13 → 0.1.14
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/{BarChart-Cid6YH81.js → BarChart-CeqsqG1F.js} +23 -23
- package/dist/client/index.d.ts.map +1 -1
- package/dist/index.js +1035 -993
- package/dist/marked.esm-CXPn2rbO.js +1090 -0
- package/dist/mocks.js +1 -1
- package/dist/parseBlocks-DtWG2dnE.js +34 -0
- package/dist/parseIncompleteMarkdown-Di9Hun9H.js +211 -0
- package/dist/react/agentManager.d.ts +1 -0
- package/dist/react/agentManager.d.ts.map +1 -1
- package/dist/react/useAgentChat.d.ts +2 -2
- package/dist/react/useAgentChat.d.ts.map +1 -1
- package/dist/utils/createMessageRenderer.d.ts +3 -1
- package/dist/utils/createMessageRenderer.d.ts.map +1 -1
- package/dist/utils/streaming/parseBlocks.d.ts +26 -0
- package/dist/utils/streaming/parseBlocks.d.ts.map +1 -0
- package/dist/utils/streaming/parseIncompleteMarkdown.d.ts +24 -0
- package/dist/utils/streaming/parseIncompleteMarkdown.d.ts.map +1 -0
- package/package.json +5 -3
- package/dist/utils/markdownParser.d.ts +0 -25
- package/dist/utils/markdownParser.d.ts.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,59 +1,59 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import
|
|
5
|
-
import { j as $, C as
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import { __ as
|
|
9
|
-
import { LineChart as
|
|
10
|
-
import
|
|
11
|
-
const
|
|
12
|
-
|
|
1
|
+
var Dt = Object.defineProperty;
|
|
2
|
+
var _t = (t, e, s) => e in t ? Dt(t, e, { enumerable: !0, configurable: !0, writable: !0, value: s }) : t[e] = s;
|
|
3
|
+
var it = (t, e, s) => _t(t, typeof e != "symbol" ? e + "" : e, s);
|
|
4
|
+
import nt, { useMemo as dt, useCallback as F, Component as jt, useState as Q, useRef as bt, useEffect as X } from "react";
|
|
5
|
+
import { j as $, C as st, g as Ft, a as qt, B as Ht, b as Ut } from "./BarChart-CeqsqG1F.js";
|
|
6
|
+
import Bt from "react-markdown";
|
|
7
|
+
import Jt from "remark-gfm";
|
|
8
|
+
import { __ as q, sprintf as ht } from "@wordpress/i18n";
|
|
9
|
+
import { LineChart as Lt } from "@automattic/charts";
|
|
10
|
+
import yt from "@wordpress/api-fetch";
|
|
11
|
+
const O = (t, ...e) => {
|
|
12
|
+
Wt() && console.log(`[agenttic-client] ${t}`, ...e);
|
|
13
13
|
};
|
|
14
|
-
function
|
|
14
|
+
function Wt() {
|
|
15
15
|
var t;
|
|
16
16
|
return typeof globalThis < "u" && "window" in globalThis && ((t = globalThis.window) == null ? void 0 : t.DEBUG) === "agenttic-client";
|
|
17
17
|
}
|
|
18
|
-
function
|
|
18
|
+
function Tt(t) {
|
|
19
19
|
return JSON.stringify(t, null, 2);
|
|
20
20
|
}
|
|
21
|
-
function
|
|
21
|
+
function wt(t, ...e) {
|
|
22
22
|
console.log(`[agenttic-client] ${t}`, ...e);
|
|
23
23
|
}
|
|
24
|
-
function
|
|
25
|
-
return
|
|
24
|
+
function Qe(t) {
|
|
25
|
+
return dt(() => t ? {
|
|
26
26
|
getClientContext: () => {
|
|
27
27
|
try {
|
|
28
28
|
return t() || {};
|
|
29
29
|
} catch (n) {
|
|
30
|
-
return
|
|
30
|
+
return O("Error getting client context: %O", n), {};
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
33
|
} : void 0, [t]);
|
|
34
34
|
}
|
|
35
|
-
function
|
|
36
|
-
const s =
|
|
35
|
+
function Xe(t, e) {
|
|
36
|
+
const s = F(async () => {
|
|
37
37
|
if (!t)
|
|
38
38
|
return [];
|
|
39
39
|
try {
|
|
40
40
|
return await t();
|
|
41
|
-
} catch (
|
|
42
|
-
return
|
|
41
|
+
} catch (o) {
|
|
42
|
+
return O("Error getting available tools: %O", o), [];
|
|
43
43
|
}
|
|
44
|
-
}, [t]), n =
|
|
45
|
-
async (
|
|
44
|
+
}, [t]), n = F(
|
|
45
|
+
async (o, r) => {
|
|
46
46
|
if (!e)
|
|
47
47
|
throw new Error("No executeTool callback provided");
|
|
48
48
|
try {
|
|
49
|
-
return await e(
|
|
49
|
+
return await e(o, r);
|
|
50
50
|
} catch (i) {
|
|
51
|
-
throw
|
|
51
|
+
throw O("Error executing tool %s: %O", o, i), i;
|
|
52
52
|
}
|
|
53
53
|
},
|
|
54
54
|
[e]
|
|
55
55
|
);
|
|
56
|
-
return
|
|
56
|
+
return dt(() => {
|
|
57
57
|
if (t)
|
|
58
58
|
return {
|
|
59
59
|
getAvailableTools: s,
|
|
@@ -61,7 +61,7 @@ function ze(t, e) {
|
|
|
61
61
|
};
|
|
62
62
|
}, [s, n, t]);
|
|
63
63
|
}
|
|
64
|
-
function
|
|
64
|
+
function gt() {
|
|
65
65
|
const t = "abcdefghijklmnopqrstuvwxyz0123456789";
|
|
66
66
|
let e = "";
|
|
67
67
|
for (let s = 0; s < 8; s++)
|
|
@@ -69,27 +69,27 @@ function lt() {
|
|
|
69
69
|
return e;
|
|
70
70
|
}
|
|
71
71
|
function D() {
|
|
72
|
-
return
|
|
72
|
+
return gt();
|
|
73
73
|
}
|
|
74
|
-
function
|
|
75
|
-
return `req-${
|
|
74
|
+
function Kt() {
|
|
75
|
+
return `req-${gt()}`;
|
|
76
76
|
}
|
|
77
|
-
function
|
|
78
|
-
return `task-${
|
|
77
|
+
function Vt() {
|
|
78
|
+
return `task-${gt()}`;
|
|
79
79
|
}
|
|
80
|
-
function
|
|
80
|
+
function St(t) {
|
|
81
81
|
return {
|
|
82
82
|
type: "text",
|
|
83
83
|
text: t
|
|
84
84
|
};
|
|
85
85
|
}
|
|
86
|
-
function
|
|
86
|
+
function zt(t, e = "message/send", s = !1) {
|
|
87
87
|
const n = {
|
|
88
88
|
jsonrpc: "2.0",
|
|
89
|
-
id:
|
|
89
|
+
id: Kt(),
|
|
90
90
|
method: e,
|
|
91
91
|
params: {
|
|
92
|
-
id: t.id ||
|
|
92
|
+
id: t.id || Vt(),
|
|
93
93
|
...t
|
|
94
94
|
}
|
|
95
95
|
};
|
|
@@ -98,7 +98,7 @@ function Kt(t, e = "message/send", s = !1) {
|
|
|
98
98
|
function U(t) {
|
|
99
99
|
return !t || !t.parts || !Array.isArray(t.parts) ? "" : t.parts.filter((e) => e.type === "text").map((e) => e.text).join(" ");
|
|
100
100
|
}
|
|
101
|
-
function
|
|
101
|
+
function Gt(t) {
|
|
102
102
|
return {
|
|
103
103
|
type: "data",
|
|
104
104
|
data: {
|
|
@@ -110,12 +110,12 @@ function Vt(t) {
|
|
|
110
110
|
metadata: {}
|
|
111
111
|
};
|
|
112
112
|
}
|
|
113
|
-
function
|
|
113
|
+
function B(t) {
|
|
114
114
|
return !t || !t.parts || !Array.isArray(t.parts) ? [] : t.parts.filter(
|
|
115
115
|
(e) => e.type === "data" && "toolCallId" in e.data && "toolId" in e.data && "arguments" in e.data
|
|
116
116
|
);
|
|
117
117
|
}
|
|
118
|
-
function
|
|
118
|
+
function L(t, e, s, n) {
|
|
119
119
|
return {
|
|
120
120
|
type: "data",
|
|
121
121
|
data: {
|
|
@@ -126,7 +126,7 @@ function W(t, e, s, n) {
|
|
|
126
126
|
metadata: n ? { error: n } : void 0
|
|
127
127
|
};
|
|
128
128
|
}
|
|
129
|
-
function
|
|
129
|
+
function Qt(t) {
|
|
130
130
|
return {
|
|
131
131
|
type: "data",
|
|
132
132
|
data: {
|
|
@@ -135,10 +135,10 @@ function zt(t) {
|
|
|
135
135
|
metadata: {}
|
|
136
136
|
};
|
|
137
137
|
}
|
|
138
|
-
function
|
|
138
|
+
function ut(t) {
|
|
139
139
|
return {
|
|
140
140
|
role: "user",
|
|
141
|
-
parts: [
|
|
141
|
+
parts: [St(t)],
|
|
142
142
|
kind: "message",
|
|
143
143
|
messageId: D(),
|
|
144
144
|
metadata: {
|
|
@@ -146,10 +146,10 @@ function rt(t) {
|
|
|
146
146
|
}
|
|
147
147
|
};
|
|
148
148
|
}
|
|
149
|
-
function
|
|
149
|
+
function Y(t) {
|
|
150
150
|
return {
|
|
151
151
|
role: "agent",
|
|
152
|
-
parts: [
|
|
152
|
+
parts: [St(t)],
|
|
153
153
|
kind: "message",
|
|
154
154
|
messageId: D(),
|
|
155
155
|
metadata: {
|
|
@@ -157,7 +157,7 @@ function Z(t) {
|
|
|
157
157
|
}
|
|
158
158
|
};
|
|
159
159
|
}
|
|
160
|
-
function
|
|
160
|
+
function ft(t) {
|
|
161
161
|
return t && typeof t == "object" && "result" in t ? {
|
|
162
162
|
result: t.result,
|
|
163
163
|
returnToAgent: t.returnToAgent !== !1,
|
|
@@ -169,7 +169,7 @@ function ct(t) {
|
|
|
169
169
|
returnToAgent: !0
|
|
170
170
|
};
|
|
171
171
|
}
|
|
172
|
-
function
|
|
172
|
+
function at(t, e = []) {
|
|
173
173
|
return {
|
|
174
174
|
role: "user",
|
|
175
175
|
kind: "message",
|
|
@@ -180,127 +180,127 @@ function et(t, e = []) {
|
|
|
180
180
|
}
|
|
181
181
|
};
|
|
182
182
|
}
|
|
183
|
-
function
|
|
183
|
+
function Ye() {
|
|
184
184
|
return new AbortController();
|
|
185
185
|
}
|
|
186
|
-
async function
|
|
186
|
+
async function Xt(t, e) {
|
|
187
187
|
if (!e)
|
|
188
188
|
return t;
|
|
189
189
|
try {
|
|
190
190
|
const s = await e.getAvailableTools();
|
|
191
191
|
if (s.length === 0)
|
|
192
192
|
return t;
|
|
193
|
-
const n = s.map(
|
|
193
|
+
const n = s.map(Gt);
|
|
194
194
|
return {
|
|
195
195
|
...t,
|
|
196
196
|
parts: [...t.parts, ...n]
|
|
197
197
|
};
|
|
198
198
|
} catch (s) {
|
|
199
|
-
return
|
|
199
|
+
return O("Warning: Failed to get tools: %s", s), t;
|
|
200
200
|
}
|
|
201
201
|
}
|
|
202
|
-
function
|
|
202
|
+
function Yt(t, e) {
|
|
203
203
|
if (!e)
|
|
204
204
|
return t;
|
|
205
205
|
try {
|
|
206
206
|
const s = e.getClientContext();
|
|
207
207
|
if (!s || Object.keys(s).length === 0)
|
|
208
208
|
return t;
|
|
209
|
-
const n =
|
|
209
|
+
const n = Qt(s);
|
|
210
210
|
return {
|
|
211
211
|
...t,
|
|
212
212
|
parts: [...t.parts, n]
|
|
213
213
|
};
|
|
214
214
|
} catch (s) {
|
|
215
|
-
return
|
|
215
|
+
return O("Warning: Failed to get context: %s", s), t;
|
|
216
216
|
}
|
|
217
217
|
}
|
|
218
|
-
async function
|
|
219
|
-
let n = await
|
|
218
|
+
async function Zt(t, e, s) {
|
|
219
|
+
let n = await Xt(
|
|
220
220
|
t,
|
|
221
221
|
e
|
|
222
222
|
);
|
|
223
|
-
n =
|
|
223
|
+
n = Yt(
|
|
224
224
|
n,
|
|
225
225
|
s
|
|
226
226
|
);
|
|
227
|
-
const { metadata: a, ...
|
|
228
|
-
return
|
|
227
|
+
const { metadata: a, ...o } = n;
|
|
228
|
+
return o;
|
|
229
229
|
}
|
|
230
|
-
function
|
|
230
|
+
function te(t, e = "") {
|
|
231
231
|
const s = [], n = e + t;
|
|
232
|
-
let a = "",
|
|
233
|
-
for (;
|
|
232
|
+
let a = "", o = 0, r = 0;
|
|
233
|
+
for (; r < n.length; ) {
|
|
234
234
|
const l = n.indexOf(
|
|
235
235
|
`
|
|
236
236
|
`,
|
|
237
|
-
|
|
238
|
-
),
|
|
239
|
-
if (
|
|
237
|
+
r
|
|
238
|
+
), g = l === -1 ? n.substring(r) : n.substring(r, l);
|
|
239
|
+
if (g.startsWith("data:"))
|
|
240
240
|
a !== "" && (a += `
|
|
241
|
-
`), a +=
|
|
242
|
-
|
|
241
|
+
`), a += g.substring(
|
|
242
|
+
g.startsWith("data: ") ? 6 : 5
|
|
243
243
|
);
|
|
244
|
-
else if (
|
|
244
|
+
else if (g.trim() === "" && a) {
|
|
245
245
|
try {
|
|
246
|
-
s.push(JSON.parse(a)),
|
|
247
|
-
} catch (
|
|
248
|
-
|
|
246
|
+
s.push(JSON.parse(a)), o = l === -1 ? n.length : l + 1;
|
|
247
|
+
} catch (c) {
|
|
248
|
+
O("Failed to parse SSE event: %o", c), O("Problematic payload: %s", a);
|
|
249
249
|
}
|
|
250
250
|
a = "";
|
|
251
251
|
}
|
|
252
|
-
l === -1 ?
|
|
252
|
+
l === -1 ? r = n.length : r = l + 1;
|
|
253
253
|
}
|
|
254
|
-
const i = n.substring(
|
|
254
|
+
const i = n.substring(o);
|
|
255
255
|
return { events: s, nextBuffer: i };
|
|
256
256
|
}
|
|
257
|
-
async function*
|
|
258
|
-
var
|
|
257
|
+
async function* ee(t, e = {}) {
|
|
258
|
+
var g, c, f;
|
|
259
259
|
const { supportDeltas: s = !1 } = e, n = t.getReader(), a = new TextDecoder();
|
|
260
|
-
let
|
|
261
|
-
const
|
|
260
|
+
let o = "";
|
|
261
|
+
const r = new se();
|
|
262
262
|
let i = null, l = null;
|
|
263
263
|
try {
|
|
264
264
|
for (; ; ) {
|
|
265
|
-
const { done:
|
|
266
|
-
if (
|
|
265
|
+
const { done: I, value: k } = await n.read();
|
|
266
|
+
if (I)
|
|
267
267
|
break;
|
|
268
|
-
const
|
|
269
|
-
if (
|
|
270
|
-
for (let
|
|
271
|
-
const u =
|
|
272
|
-
if (
|
|
268
|
+
const A = a.decode(k, { stream: !0 }), { events: T, nextBuffer: M } = te(A, o);
|
|
269
|
+
if (T && Array.isArray(T))
|
|
270
|
+
for (let y = 0; y < T.length; y++) {
|
|
271
|
+
const u = T[y];
|
|
272
|
+
if (y > 0 && u.method === "message/delta" && typeof requestAnimationFrame < "u" && await new Promise((h) => {
|
|
273
273
|
requestAnimationFrame(() => h(void 0));
|
|
274
274
|
}), u.error)
|
|
275
275
|
throw new Error(
|
|
276
276
|
`Streaming error: ${u.error.message}`
|
|
277
277
|
);
|
|
278
|
-
if (s && u.method === "message/delta" && ((
|
|
278
|
+
if (s && u.method === "message/delta" && ((g = u.params) != null && g.delta)) {
|
|
279
279
|
const h = u.params.delta;
|
|
280
280
|
try {
|
|
281
|
-
if (h.deltaType === "content" && (
|
|
281
|
+
if (h.deltaType === "content" && (r.processContentDelta(
|
|
282
282
|
h.content
|
|
283
283
|
), !i && u.params.id && (i = u.params.id), i)) {
|
|
284
|
-
const
|
|
284
|
+
const p = r.getCurrentMessage();
|
|
285
285
|
yield {
|
|
286
286
|
id: i,
|
|
287
287
|
status: {
|
|
288
288
|
state: "working",
|
|
289
|
-
message:
|
|
289
|
+
message: p
|
|
290
290
|
},
|
|
291
291
|
final: !1,
|
|
292
|
-
text:
|
|
292
|
+
text: r.getTextContent()
|
|
293
293
|
};
|
|
294
294
|
}
|
|
295
|
-
} catch (
|
|
296
|
-
|
|
295
|
+
} catch (p) {
|
|
296
|
+
O("Failed to process delta: %o", p);
|
|
297
297
|
}
|
|
298
|
-
} else u.result && u.result.status ? (i = u.result.id, l = u.result.status, (
|
|
298
|
+
} else u.result && u.result.status ? (i = u.result.id, l = u.result.status, (r.getTextContent() || r.getCurrentMessage().parts.length > 0) && r.reset(), yield {
|
|
299
299
|
id: u.result.id,
|
|
300
300
|
status: u.result.status,
|
|
301
301
|
final: u.result.status.state === "completed" || u.result.status.state === "failed" || u.result.status.state === "canceled",
|
|
302
302
|
text: U(
|
|
303
|
-
((
|
|
303
|
+
((c = u.result.status) == null ? void 0 : c.message) || {
|
|
304
304
|
role: "agent",
|
|
305
305
|
parts: []
|
|
306
306
|
}
|
|
@@ -310,23 +310,23 @@ async function* Zt(t, e = {}) {
|
|
|
310
310
|
status: u.result.status,
|
|
311
311
|
final: u.result.status.state === "completed" || u.result.status.state === "failed" || u.result.status.state === "canceled",
|
|
312
312
|
text: U(
|
|
313
|
-
((
|
|
313
|
+
((f = u.result.status) == null ? void 0 : f.message) || {
|
|
314
314
|
role: "agent",
|
|
315
315
|
parts: []
|
|
316
316
|
}
|
|
317
317
|
)
|
|
318
318
|
}));
|
|
319
319
|
}
|
|
320
|
-
|
|
320
|
+
o = M;
|
|
321
321
|
}
|
|
322
322
|
} finally {
|
|
323
323
|
n.releaseLock();
|
|
324
324
|
}
|
|
325
325
|
}
|
|
326
|
-
class
|
|
326
|
+
class se {
|
|
327
327
|
constructor() {
|
|
328
|
-
|
|
329
|
-
|
|
328
|
+
it(this, "textContent", "");
|
|
329
|
+
it(this, "toolCalls", /* @__PURE__ */ new Map());
|
|
330
330
|
}
|
|
331
331
|
/**
|
|
332
332
|
* Process a simple content delta (server's actual format)
|
|
@@ -380,20 +380,20 @@ class te {
|
|
|
380
380
|
});
|
|
381
381
|
for (const [n, a] of this.toolCalls)
|
|
382
382
|
if (a.toolName) {
|
|
383
|
-
const
|
|
384
|
-
let
|
|
385
|
-
if (
|
|
383
|
+
const o = a.argumentFragments.join("");
|
|
384
|
+
let r = {};
|
|
385
|
+
if (o)
|
|
386
386
|
try {
|
|
387
|
-
|
|
387
|
+
r = JSON.parse(o);
|
|
388
388
|
} catch {
|
|
389
|
-
|
|
389
|
+
r = { _raw: o };
|
|
390
390
|
}
|
|
391
391
|
s.push({
|
|
392
392
|
type: "data",
|
|
393
393
|
data: {
|
|
394
394
|
toolCallId: a.toolCallId,
|
|
395
395
|
toolId: a.toolName,
|
|
396
|
-
arguments:
|
|
396
|
+
arguments: r
|
|
397
397
|
}
|
|
398
398
|
});
|
|
399
399
|
}
|
|
@@ -411,38 +411,38 @@ class te {
|
|
|
411
411
|
this.textContent = "", this.toolCalls.clear();
|
|
412
412
|
}
|
|
413
413
|
}
|
|
414
|
-
function
|
|
415
|
-
throw clearTimeout(e),
|
|
414
|
+
function kt(t, e, s = "request") {
|
|
415
|
+
throw clearTimeout(e), O("%s failed with error: %O", s, t), t instanceof Error && (O("Error message: %s", t.message), O("Error stack: %s", t.stack)), t;
|
|
416
416
|
}
|
|
417
|
-
function
|
|
417
|
+
function At(t, e = "request") {
|
|
418
418
|
if (!t.ok)
|
|
419
419
|
throw new Error(`HTTP error! status: ${t.status}`);
|
|
420
420
|
}
|
|
421
|
-
function
|
|
421
|
+
function ne(t, e = "request") {
|
|
422
422
|
if (t.error)
|
|
423
423
|
throw new Error(`A2A ${e} error: ${t.error.message}`);
|
|
424
424
|
if (!t.result)
|
|
425
425
|
throw new Error(`No result in ${e} response`);
|
|
426
426
|
return t.result;
|
|
427
427
|
}
|
|
428
|
-
function
|
|
429
|
-
if (
|
|
428
|
+
function ae(t, e = "streaming request") {
|
|
429
|
+
if (At(t, e), !t.body)
|
|
430
430
|
throw new Error(`No response body for ${e}`);
|
|
431
431
|
}
|
|
432
|
-
function
|
|
432
|
+
function vt(t, e = "request") {
|
|
433
433
|
const s = new AbortController();
|
|
434
434
|
return { timeoutId: setTimeout(
|
|
435
435
|
() => s.abort(),
|
|
436
436
|
t
|
|
437
437
|
), controller: s };
|
|
438
438
|
}
|
|
439
|
-
function
|
|
439
|
+
function re(t, e) {
|
|
440
440
|
return `${t}/${e}`;
|
|
441
441
|
}
|
|
442
|
-
function
|
|
443
|
-
|
|
442
|
+
function oe(t, e, s, n) {
|
|
443
|
+
O("Request: %s %s", t, e), O("Headers: %o", s), n && O("Body: %s", Tt(n));
|
|
444
444
|
}
|
|
445
|
-
async function
|
|
445
|
+
async function ie(t, e = !1) {
|
|
446
446
|
const s = {
|
|
447
447
|
"Content-Type": "application/json"
|
|
448
448
|
};
|
|
@@ -452,7 +452,7 @@ async function oe(t, e = !1) {
|
|
|
452
452
|
}
|
|
453
453
|
return s;
|
|
454
454
|
}
|
|
455
|
-
function
|
|
455
|
+
function Rt(t, e) {
|
|
456
456
|
if (!e)
|
|
457
457
|
return t;
|
|
458
458
|
const s = new AbortController(), n = (a) => {
|
|
@@ -464,7 +464,7 @@ function At(t, e) {
|
|
|
464
464
|
once: !0
|
|
465
465
|
}), s.signal;
|
|
466
466
|
}
|
|
467
|
-
function
|
|
467
|
+
function Et(t, e, s) {
|
|
468
468
|
return {
|
|
469
469
|
method: "POST",
|
|
470
470
|
headers: t,
|
|
@@ -472,93 +472,93 @@ function vt(t, e, s) {
|
|
|
472
472
|
signal: s
|
|
473
473
|
};
|
|
474
474
|
}
|
|
475
|
-
async function
|
|
476
|
-
const { message:
|
|
477
|
-
|
|
475
|
+
async function rt(t, e, s, n, a, o) {
|
|
476
|
+
const { message: r, sessionId: i, taskId: l, metadata: g } = t, { agentId: c, agentUrl: f, authProvider: I, proxy: k } = e, { isStreaming: A = !1, enableTokenStreaming: T = !1 } = s, M = i || o, y = re(f, c), u = await Zt(
|
|
477
|
+
r,
|
|
478
478
|
n,
|
|
479
479
|
a
|
|
480
|
-
), h =
|
|
480
|
+
), h = zt(
|
|
481
481
|
{
|
|
482
482
|
id: l,
|
|
483
|
-
sessionId:
|
|
483
|
+
sessionId: M,
|
|
484
484
|
message: u,
|
|
485
|
-
metadata:
|
|
485
|
+
metadata: g
|
|
486
486
|
},
|
|
487
|
-
|
|
488
|
-
|
|
487
|
+
A ? "message/stream" : "message/send",
|
|
488
|
+
T && A
|
|
489
489
|
// Only enable token streaming if using SSE
|
|
490
|
-
),
|
|
491
|
-
return
|
|
490
|
+
), p = await ie(I, A);
|
|
491
|
+
return oe("POST", y, p, h), {
|
|
492
492
|
request: h,
|
|
493
|
-
headers:
|
|
493
|
+
headers: p,
|
|
494
494
|
enhancedMessage: u,
|
|
495
|
-
effectiveSessionId:
|
|
496
|
-
fullAgentUrl:
|
|
495
|
+
effectiveSessionId: M,
|
|
496
|
+
fullAgentUrl: y
|
|
497
497
|
};
|
|
498
498
|
}
|
|
499
|
-
async function
|
|
500
|
-
const { request: n, headers: a, fullAgentUrl:
|
|
501
|
-
|
|
499
|
+
async function Pt(t, e, s = {}) {
|
|
500
|
+
const { request: n, headers: a, fullAgentUrl: o } = t, { timeout: r } = e, { abortSignal: i } = s, { timeoutId: l, controller: g } = vt(
|
|
501
|
+
r,
|
|
502
502
|
"request"
|
|
503
|
-
),
|
|
503
|
+
), c = i ? Rt(g.signal, i) : g.signal;
|
|
504
504
|
try {
|
|
505
|
-
const
|
|
505
|
+
const f = Et(
|
|
506
506
|
a,
|
|
507
507
|
JSON.stringify(n),
|
|
508
|
-
|
|
508
|
+
c
|
|
509
509
|
);
|
|
510
|
-
|
|
511
|
-
method:
|
|
512
|
-
headers:
|
|
510
|
+
O("Making request to %s with options: %O", o, {
|
|
511
|
+
method: f.method,
|
|
512
|
+
headers: f.headers
|
|
513
513
|
});
|
|
514
|
-
const
|
|
515
|
-
clearTimeout(l),
|
|
516
|
-
const
|
|
517
|
-
return
|
|
514
|
+
const I = await fetch(o, f);
|
|
515
|
+
clearTimeout(l), At(I, "request");
|
|
516
|
+
const k = await I.json();
|
|
517
|
+
return O(
|
|
518
518
|
"Response from %s: %d %O",
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
),
|
|
523
|
-
} catch (
|
|
524
|
-
|
|
519
|
+
o,
|
|
520
|
+
I.status,
|
|
521
|
+
Tt(k)
|
|
522
|
+
), ne(k, "request");
|
|
523
|
+
} catch (f) {
|
|
524
|
+
kt(f, l, "request");
|
|
525
525
|
}
|
|
526
526
|
}
|
|
527
|
-
async function*
|
|
528
|
-
const { request: n, headers: a, fullAgentUrl:
|
|
529
|
-
streamingTimeout:
|
|
527
|
+
async function* Ot(t, e, s) {
|
|
528
|
+
const { request: n, headers: a, fullAgentUrl: o } = t, {
|
|
529
|
+
streamingTimeout: r = 6e4,
|
|
530
530
|
abortSignal: i,
|
|
531
531
|
enableTokenStreaming: l = !1
|
|
532
|
-
} = s, { timeoutId:
|
|
533
|
-
|
|
532
|
+
} = s, { timeoutId: g, controller: c } = vt(
|
|
533
|
+
r,
|
|
534
534
|
"streaming request"
|
|
535
|
-
),
|
|
535
|
+
), f = i ? Rt(c.signal, i) : c.signal;
|
|
536
536
|
try {
|
|
537
|
-
const
|
|
538
|
-
if (clearTimeout(
|
|
537
|
+
const I = JSON.stringify(n), k = Et(a, I, f), A = await fetch(o, k);
|
|
538
|
+
if (clearTimeout(g), ae(A, "streaming request"), !A.body)
|
|
539
539
|
throw new Error(
|
|
540
540
|
"Response body is null - server may not support streaming"
|
|
541
541
|
);
|
|
542
|
-
const
|
|
543
|
-
yield*
|
|
544
|
-
supportDeltas:
|
|
542
|
+
const T = l && n.tokenStreaming === !0;
|
|
543
|
+
yield* ee(A.body, {
|
|
544
|
+
supportDeltas: T
|
|
545
545
|
});
|
|
546
|
-
} catch (
|
|
547
|
-
|
|
546
|
+
} catch (I) {
|
|
547
|
+
kt(I, g, "streaming request");
|
|
548
548
|
}
|
|
549
549
|
}
|
|
550
|
-
const
|
|
551
|
-
async function
|
|
550
|
+
const le = 12e4, mt = /* @__PURE__ */ new Map();
|
|
551
|
+
async function ce(t, e) {
|
|
552
552
|
if (!t || !e || !t.getAvailableTools)
|
|
553
553
|
return !1;
|
|
554
|
-
const s =
|
|
554
|
+
const s = B(e);
|
|
555
555
|
if (s.length === 0)
|
|
556
556
|
return !1;
|
|
557
557
|
try {
|
|
558
558
|
const n = await t.getAvailableTools();
|
|
559
559
|
for (const a of s)
|
|
560
560
|
if (n.some(
|
|
561
|
-
(
|
|
561
|
+
(r) => r.id === a.data.toolId
|
|
562
562
|
))
|
|
563
563
|
return !0;
|
|
564
564
|
} catch {
|
|
@@ -566,20 +566,20 @@ async function ie(t, e) {
|
|
|
566
566
|
}
|
|
567
567
|
return !1;
|
|
568
568
|
}
|
|
569
|
-
function
|
|
570
|
-
|
|
569
|
+
function ue() {
|
|
570
|
+
mt.clear();
|
|
571
571
|
}
|
|
572
|
-
function
|
|
572
|
+
function de(t) {
|
|
573
573
|
return t.map((e) => {
|
|
574
|
-
const s = e.data.toolCallId, n =
|
|
574
|
+
const s = e.data.toolCallId, n = mt.get(s);
|
|
575
575
|
if (n && n.resolvedValue !== null) {
|
|
576
576
|
const a = n.resolvedValue;
|
|
577
|
-
return a.error ?
|
|
577
|
+
return a.error ? L(
|
|
578
578
|
s,
|
|
579
579
|
e.data.toolId,
|
|
580
580
|
void 0,
|
|
581
581
|
a.error
|
|
582
|
-
) :
|
|
582
|
+
) : L(
|
|
583
583
|
s,
|
|
584
584
|
e.data.toolId,
|
|
585
585
|
a
|
|
@@ -588,39 +588,39 @@ function ce(t) {
|
|
|
588
588
|
return e;
|
|
589
589
|
});
|
|
590
590
|
}
|
|
591
|
-
async function
|
|
591
|
+
async function Nt(t, e, s) {
|
|
592
592
|
const n = [], a = [];
|
|
593
|
-
let
|
|
594
|
-
for (const
|
|
595
|
-
const { toolCallId: i, toolId: l, arguments:
|
|
593
|
+
let o = !1;
|
|
594
|
+
for (const r of t) {
|
|
595
|
+
const { toolCallId: i, toolId: l, arguments: g } = r.data;
|
|
596
596
|
try {
|
|
597
|
-
const
|
|
597
|
+
const c = await e.executeTool(
|
|
598
598
|
l,
|
|
599
|
-
|
|
599
|
+
g,
|
|
600
600
|
s,
|
|
601
601
|
i
|
|
602
|
-
), { result:
|
|
603
|
-
|
|
604
|
-
|
|
602
|
+
), { result: f, returnToAgent: I, agentMessage: k } = ft(c);
|
|
603
|
+
I && (o = !0), k && a.push(Y(k)), n.push(
|
|
604
|
+
L(
|
|
605
605
|
i,
|
|
606
606
|
l,
|
|
607
|
-
|
|
607
|
+
f
|
|
608
608
|
)
|
|
609
609
|
);
|
|
610
|
-
} catch (
|
|
611
|
-
|
|
612
|
-
|
|
610
|
+
} catch (c) {
|
|
611
|
+
o = !0, n.push(
|
|
612
|
+
L(
|
|
613
613
|
i,
|
|
614
614
|
l,
|
|
615
615
|
void 0,
|
|
616
|
-
|
|
616
|
+
c instanceof Error ? c.message : String(c)
|
|
617
617
|
)
|
|
618
618
|
);
|
|
619
619
|
}
|
|
620
620
|
}
|
|
621
|
-
return { results: n, shouldReturnToAgent:
|
|
621
|
+
return { results: n, shouldReturnToAgent: o, agentMessages: a };
|
|
622
622
|
}
|
|
623
|
-
function
|
|
623
|
+
function It(t) {
|
|
624
624
|
const e = [];
|
|
625
625
|
for (const s of t)
|
|
626
626
|
for (const n of s.parts)
|
|
@@ -633,8 +633,8 @@ function pt(t) {
|
|
|
633
633
|
}) : n.type === "data" && e.push(n);
|
|
634
634
|
return e;
|
|
635
635
|
}
|
|
636
|
-
async function
|
|
637
|
-
const l = await
|
|
636
|
+
async function lt(t, e, s, n, a, o, r) {
|
|
637
|
+
const l = await rt(
|
|
638
638
|
{
|
|
639
639
|
message: e,
|
|
640
640
|
taskId: t,
|
|
@@ -645,78 +645,78 @@ async function ot(t, e, s, n, a, r, o) {
|
|
|
645
645
|
{ isStreaming: !1 },
|
|
646
646
|
n,
|
|
647
647
|
a,
|
|
648
|
-
|
|
648
|
+
o
|
|
649
649
|
);
|
|
650
|
-
return await
|
|
651
|
-
abortSignal:
|
|
650
|
+
return await Pt(l, s, {
|
|
651
|
+
abortSignal: r
|
|
652
652
|
});
|
|
653
653
|
}
|
|
654
|
-
async function
|
|
655
|
-
const
|
|
654
|
+
async function Ct(t, e, s, n, a, o, r, i, l = []) {
|
|
655
|
+
const g = {
|
|
656
656
|
message: e,
|
|
657
657
|
taskId: t,
|
|
658
658
|
sessionId: void 0
|
|
659
659
|
// Use task's session
|
|
660
|
-
}, c = i || { isStreaming: !0 },
|
|
661
|
-
|
|
660
|
+
}, c = i || { isStreaming: !0 }, f = await rt(
|
|
661
|
+
g,
|
|
662
662
|
s,
|
|
663
663
|
{
|
|
664
664
|
...c
|
|
665
665
|
},
|
|
666
666
|
n,
|
|
667
667
|
a,
|
|
668
|
-
|
|
669
|
-
),
|
|
668
|
+
o
|
|
669
|
+
), I = Ot(f, s, {
|
|
670
670
|
...c,
|
|
671
|
-
abortSignal:
|
|
671
|
+
abortSignal: r
|
|
672
672
|
});
|
|
673
|
-
return
|
|
674
|
-
|
|
673
|
+
return $t(
|
|
674
|
+
I,
|
|
675
675
|
n,
|
|
676
676
|
a,
|
|
677
677
|
s,
|
|
678
|
-
|
|
678
|
+
o,
|
|
679
679
|
!0,
|
|
680
680
|
// withHistory
|
|
681
|
-
|
|
682
|
-
//
|
|
683
|
-
|
|
681
|
+
l,
|
|
682
|
+
// preserve conversation parts across continuation
|
|
683
|
+
r,
|
|
684
684
|
c
|
|
685
685
|
// Pass through the same request options
|
|
686
686
|
);
|
|
687
687
|
}
|
|
688
|
-
async function*
|
|
689
|
-
var c,
|
|
690
|
-
for await (const
|
|
691
|
-
if (yield
|
|
688
|
+
async function* $t(t, e, s, n, a, o = !0, r = [], i, l) {
|
|
689
|
+
var g, c, f, I, k, A, T, M, y, u, h, p;
|
|
690
|
+
for await (const m of t) {
|
|
691
|
+
if (yield m, m.status.state === "running" && m.status.message && e && await ce(
|
|
692
692
|
e,
|
|
693
|
-
|
|
693
|
+
m.status.message
|
|
694
694
|
)) {
|
|
695
|
-
const
|
|
696
|
-
|
|
695
|
+
const w = B(
|
|
696
|
+
m.status.message
|
|
697
697
|
);
|
|
698
|
-
for (const
|
|
699
|
-
const { toolCallId:
|
|
698
|
+
for (const b of w) {
|
|
699
|
+
const { toolCallId: v, toolId: d, arguments: C } = b.data;
|
|
700
700
|
e.executeTool(
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
(
|
|
704
|
-
|
|
705
|
-
).catch((
|
|
701
|
+
d,
|
|
702
|
+
C,
|
|
703
|
+
(c = (g = m.status) == null ? void 0 : g.message) == null ? void 0 : c.messageId,
|
|
704
|
+
v
|
|
705
|
+
).catch((x) => {
|
|
706
706
|
console.error(
|
|
707
|
-
`Tool execution failed for ${
|
|
708
|
-
|
|
707
|
+
`Tool execution failed for ${d}:`,
|
|
708
|
+
x
|
|
709
709
|
);
|
|
710
710
|
});
|
|
711
711
|
}
|
|
712
712
|
yield {
|
|
713
|
-
id:
|
|
713
|
+
id: m.id,
|
|
714
714
|
status: {
|
|
715
715
|
state: "running",
|
|
716
716
|
message: {
|
|
717
717
|
role: "agent",
|
|
718
718
|
kind: "message",
|
|
719
|
-
parts:
|
|
719
|
+
parts: w,
|
|
720
720
|
messageId: D()
|
|
721
721
|
}
|
|
722
722
|
},
|
|
@@ -724,172 +724,174 @@ async function* Ot(t, e, s, n, a, r = !0, o = [], i, l) {
|
|
|
724
724
|
text: ""
|
|
725
725
|
};
|
|
726
726
|
}
|
|
727
|
-
if (
|
|
728
|
-
const
|
|
729
|
-
|
|
727
|
+
if (m.status.state === "input-required" && m.status.message && e) {
|
|
728
|
+
const w = B(
|
|
729
|
+
m.status.message
|
|
730
730
|
);
|
|
731
|
-
if (
|
|
732
|
-
const
|
|
733
|
-
let
|
|
734
|
-
const
|
|
735
|
-
for (const
|
|
731
|
+
if (w.length > 0) {
|
|
732
|
+
const b = [];
|
|
733
|
+
let v = !1;
|
|
734
|
+
const d = [], C = [];
|
|
735
|
+
for (const x of w) {
|
|
736
736
|
const {
|
|
737
|
-
toolCallId:
|
|
737
|
+
toolCallId: S,
|
|
738
738
|
toolId: E,
|
|
739
|
-
arguments:
|
|
740
|
-
} =
|
|
739
|
+
arguments: N
|
|
740
|
+
} = x.data;
|
|
741
741
|
try {
|
|
742
|
-
const
|
|
742
|
+
const P = await e.executeTool(
|
|
743
743
|
E,
|
|
744
|
-
|
|
745
|
-
(
|
|
746
|
-
|
|
747
|
-
), { result:
|
|
748
|
-
if (
|
|
749
|
-
|
|
750
|
-
),
|
|
751
|
-
const
|
|
752
|
-
promise:
|
|
744
|
+
N,
|
|
745
|
+
(I = (f = m.status) == null ? void 0 : f.message) == null ? void 0 : I.messageId,
|
|
746
|
+
S
|
|
747
|
+
), { result: R, returnToAgent: j, agentMessage: _ } = ft(P);
|
|
748
|
+
if (j && (v = !0), _ && C.push(
|
|
749
|
+
Y(_)
|
|
750
|
+
), R.result instanceof Promise) {
|
|
751
|
+
const Z = R.result, V = {
|
|
752
|
+
promise: Z,
|
|
753
753
|
resolvedValue: null
|
|
754
754
|
};
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
),
|
|
759
|
-
|
|
760
|
-
}).catch((
|
|
755
|
+
mt.set(
|
|
756
|
+
S,
|
|
757
|
+
V
|
|
758
|
+
), Z.then((H) => {
|
|
759
|
+
V.resolvedValue = H;
|
|
760
|
+
}).catch((H) => {
|
|
761
761
|
console.error(
|
|
762
|
-
`Promise rejected for tool call ${
|
|
763
|
-
|
|
764
|
-
),
|
|
765
|
-
error:
|
|
762
|
+
`Promise rejected for tool call ${S}:`,
|
|
763
|
+
H
|
|
764
|
+
), V.resolvedValue = {
|
|
765
|
+
error: H instanceof Error ? H.message : String(H)
|
|
766
766
|
};
|
|
767
767
|
});
|
|
768
768
|
}
|
|
769
|
-
const
|
|
770
|
-
|
|
769
|
+
const W = L(
|
|
770
|
+
S,
|
|
771
771
|
E,
|
|
772
|
-
|
|
772
|
+
R
|
|
773
773
|
);
|
|
774
|
-
|
|
775
|
-
} catch (
|
|
776
|
-
const
|
|
777
|
-
|
|
774
|
+
b.push(W), d.push(W);
|
|
775
|
+
} catch (P) {
|
|
776
|
+
const R = L(
|
|
777
|
+
S,
|
|
778
778
|
E,
|
|
779
779
|
void 0,
|
|
780
|
-
|
|
780
|
+
P instanceof Error ? P.message : String(P)
|
|
781
781
|
);
|
|
782
|
-
|
|
782
|
+
b.push(R), d.push(R);
|
|
783
783
|
}
|
|
784
784
|
}
|
|
785
|
-
if (
|
|
786
|
-
const
|
|
787
|
-
|
|
788
|
-
|
|
785
|
+
if (r.push(m.status.message), v) {
|
|
786
|
+
const x = It(r), S = at(
|
|
787
|
+
b,
|
|
788
|
+
x
|
|
789
789
|
);
|
|
790
790
|
yield {
|
|
791
|
-
id:
|
|
791
|
+
id: m.id,
|
|
792
792
|
status: {
|
|
793
793
|
state: "working",
|
|
794
|
-
message:
|
|
794
|
+
message: S
|
|
795
795
|
},
|
|
796
796
|
final: !1,
|
|
797
797
|
text: ""
|
|
798
798
|
};
|
|
799
|
-
const E = await
|
|
800
|
-
|
|
801
|
-
|
|
799
|
+
const E = await Ct(
|
|
800
|
+
m.id,
|
|
801
|
+
S,
|
|
802
802
|
n,
|
|
803
803
|
e,
|
|
804
804
|
s,
|
|
805
805
|
a,
|
|
806
806
|
i,
|
|
807
|
-
l
|
|
807
|
+
l,
|
|
808
|
+
r
|
|
808
809
|
);
|
|
809
|
-
let
|
|
810
|
-
for await (const
|
|
811
|
-
|
|
812
|
-
if (!
|
|
810
|
+
let N = null;
|
|
811
|
+
for await (const j of E)
|
|
812
|
+
j.final ? N = j : yield j;
|
|
813
|
+
if (!N)
|
|
813
814
|
throw new Error(
|
|
814
815
|
"Continue task stream ended without final result"
|
|
815
816
|
);
|
|
816
|
-
let
|
|
817
|
-
|
|
817
|
+
let P = (k = N.status) != null && k.message ? B(
|
|
818
|
+
N.status.message
|
|
818
819
|
) : [];
|
|
819
|
-
|
|
820
|
+
b.length > 0 && r.push({
|
|
820
821
|
role: "agent",
|
|
821
822
|
kind: "message",
|
|
822
|
-
parts:
|
|
823
|
+
parts: b,
|
|
823
824
|
messageId: D()
|
|
824
825
|
});
|
|
825
|
-
let
|
|
826
|
-
if (
|
|
826
|
+
let R = N;
|
|
827
|
+
if (P.length > 0)
|
|
827
828
|
for (yield {
|
|
828
|
-
...
|
|
829
|
+
...N,
|
|
829
830
|
final: !1,
|
|
830
831
|
text: U(
|
|
831
|
-
((
|
|
832
|
+
((A = N.status) == null ? void 0 : A.message) || {
|
|
832
833
|
parts: [],
|
|
833
834
|
messageId: D()
|
|
834
835
|
}
|
|
835
836
|
)
|
|
836
|
-
};
|
|
837
|
-
(
|
|
838
|
-
|
|
837
|
+
}; P.length > 0; ) {
|
|
838
|
+
(T = R.status) != null && T.message && r.push(
|
|
839
|
+
R.status.message
|
|
839
840
|
);
|
|
840
841
|
const {
|
|
841
|
-
results:
|
|
842
|
-
shouldReturnToAgent:
|
|
843
|
-
} = await
|
|
844
|
-
|
|
842
|
+
results: j,
|
|
843
|
+
shouldReturnToAgent: _
|
|
844
|
+
} = await Nt(
|
|
845
|
+
P,
|
|
845
846
|
e,
|
|
846
|
-
(
|
|
847
|
+
(y = (M = R.status) == null ? void 0 : M.message) == null ? void 0 : y.messageId
|
|
847
848
|
);
|
|
848
|
-
if (
|
|
849
|
-
id:
|
|
849
|
+
if (j.length > 0 && (yield {
|
|
850
|
+
id: R.id,
|
|
850
851
|
status: {
|
|
851
852
|
state: "working",
|
|
852
853
|
message: {
|
|
853
854
|
role: "agent",
|
|
854
855
|
kind: "message",
|
|
855
|
-
parts:
|
|
856
|
+
parts: j,
|
|
856
857
|
messageId: D()
|
|
857
858
|
}
|
|
858
859
|
// Simple message with just the results
|
|
859
860
|
},
|
|
860
861
|
final: !1,
|
|
861
862
|
text: ""
|
|
862
|
-
}),
|
|
863
|
-
const
|
|
864
|
-
|
|
865
|
-
) : [],
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
),
|
|
869
|
-
|
|
870
|
-
|
|
863
|
+
}), _) {
|
|
864
|
+
const W = o ? It(
|
|
865
|
+
r
|
|
866
|
+
) : [], Z = at(
|
|
867
|
+
j,
|
|
868
|
+
W
|
|
869
|
+
), V = await Ct(
|
|
870
|
+
R.id,
|
|
871
|
+
Z,
|
|
871
872
|
n,
|
|
872
873
|
e,
|
|
873
874
|
s,
|
|
874
875
|
a,
|
|
875
876
|
i,
|
|
876
|
-
l
|
|
877
|
+
l,
|
|
878
|
+
r
|
|
877
879
|
);
|
|
878
|
-
let
|
|
879
|
-
for await (const
|
|
880
|
-
|
|
881
|
-
if (!
|
|
880
|
+
let H = null;
|
|
881
|
+
for await (const ot of V)
|
|
882
|
+
ot.final ? H = ot : yield ot;
|
|
883
|
+
if (!H)
|
|
882
884
|
throw new Error(
|
|
883
885
|
"Continue task stream ended without final result"
|
|
884
886
|
);
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
) : [],
|
|
888
|
-
id:
|
|
889
|
-
status:
|
|
887
|
+
R = H, P = (u = R.status) != null && u.message ? B(
|
|
888
|
+
R.status.message
|
|
889
|
+
) : [], P.length > 0 && (yield {
|
|
890
|
+
id: R.id,
|
|
891
|
+
status: R.status,
|
|
890
892
|
final: !1,
|
|
891
893
|
text: U(
|
|
892
|
-
((h =
|
|
894
|
+
((h = R.status) == null ? void 0 : h.message) || {
|
|
893
895
|
parts: [],
|
|
894
896
|
messageId: D()
|
|
895
897
|
}
|
|
@@ -899,36 +901,36 @@ async function* Ot(t, e, s, n, a, r = !0, o = [], i, l) {
|
|
|
899
901
|
break;
|
|
900
902
|
}
|
|
901
903
|
yield {
|
|
902
|
-
...
|
|
904
|
+
...R,
|
|
903
905
|
final: !0,
|
|
904
906
|
text: U(
|
|
905
|
-
((
|
|
907
|
+
((p = R.status) == null ? void 0 : p.message) || {
|
|
906
908
|
parts: [],
|
|
907
909
|
messageId: D()
|
|
908
910
|
}
|
|
909
911
|
)
|
|
910
912
|
};
|
|
911
913
|
} else {
|
|
912
|
-
const
|
|
913
|
-
...
|
|
914
|
-
parts:
|
|
915
|
-
},
|
|
916
|
-
...
|
|
914
|
+
const x = {
|
|
915
|
+
...m.status.message,
|
|
916
|
+
parts: d
|
|
917
|
+
}, S = {
|
|
918
|
+
...m,
|
|
917
919
|
status: {
|
|
918
|
-
...
|
|
919
|
-
message:
|
|
920
|
+
...m.status,
|
|
921
|
+
message: x
|
|
920
922
|
},
|
|
921
|
-
final:
|
|
923
|
+
final: C.length === 0,
|
|
922
924
|
// Only final if no agent messages to follow
|
|
923
|
-
text: U(
|
|
925
|
+
text: U(x)
|
|
924
926
|
};
|
|
925
|
-
if (yield
|
|
926
|
-
const E =
|
|
927
|
+
if (yield S, C.length > 0) {
|
|
928
|
+
const E = C.map((P) => U(P)).join(" "), N = Y(E);
|
|
927
929
|
yield {
|
|
928
|
-
id:
|
|
930
|
+
id: S.id,
|
|
929
931
|
status: {
|
|
930
932
|
state: "completed",
|
|
931
|
-
message:
|
|
933
|
+
message: N
|
|
932
934
|
},
|
|
933
935
|
final: !0,
|
|
934
936
|
text: E
|
|
@@ -939,223 +941,223 @@ async function* Ot(t, e, s, n, a, r = !0, o = [], i, l) {
|
|
|
939
941
|
}
|
|
940
942
|
}
|
|
941
943
|
}
|
|
942
|
-
function
|
|
944
|
+
function ge(t) {
|
|
943
945
|
const {
|
|
944
946
|
agentId: e,
|
|
945
947
|
agentUrl: s,
|
|
946
948
|
authProvider: n,
|
|
947
949
|
defaultSessionId: a,
|
|
948
|
-
timeout:
|
|
949
|
-
toolProvider:
|
|
950
|
+
timeout: o = le,
|
|
951
|
+
toolProvider: r,
|
|
950
952
|
contextProvider: i,
|
|
951
953
|
enableStreaming: l = !1
|
|
952
|
-
} = t,
|
|
954
|
+
} = t, g = {
|
|
953
955
|
agentId: e,
|
|
954
956
|
agentUrl: s,
|
|
955
957
|
authProvider: n,
|
|
956
|
-
timeout:
|
|
958
|
+
timeout: o
|
|
957
959
|
};
|
|
958
960
|
return {
|
|
959
|
-
async sendMessage(
|
|
960
|
-
var h,
|
|
961
|
-
const { withHistory:
|
|
962
|
-
|
|
963
|
-
const
|
|
964
|
-
g,
|
|
961
|
+
async sendMessage(c) {
|
|
962
|
+
var h, p;
|
|
963
|
+
const { withHistory: f = !0, abortSignal: I } = c, k = c.sessionId || a || void 0, A = [];
|
|
964
|
+
A.push(c.message);
|
|
965
|
+
const T = await rt(
|
|
965
966
|
c,
|
|
967
|
+
g,
|
|
966
968
|
{ isStreaming: !1 },
|
|
967
|
-
|
|
969
|
+
r,
|
|
968
970
|
i,
|
|
969
|
-
|
|
971
|
+
k
|
|
970
972
|
);
|
|
971
|
-
let
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
{ abortSignal:
|
|
973
|
+
let M = await Pt(
|
|
974
|
+
T,
|
|
975
|
+
g,
|
|
976
|
+
{ abortSignal: I }
|
|
975
977
|
);
|
|
976
|
-
const
|
|
977
|
-
for (;
|
|
978
|
-
const
|
|
979
|
-
|
|
978
|
+
const y = [], u = [];
|
|
979
|
+
for (; M.status.message && r; ) {
|
|
980
|
+
const m = B(
|
|
981
|
+
M.status.message
|
|
980
982
|
);
|
|
981
|
-
if (
|
|
983
|
+
if (m.length === 0)
|
|
982
984
|
break;
|
|
983
|
-
|
|
984
|
-
const
|
|
985
|
-
let
|
|
986
|
-
for (const
|
|
985
|
+
y.push(...m);
|
|
986
|
+
const w = [];
|
|
987
|
+
let b = !1;
|
|
988
|
+
for (const v of m) {
|
|
987
989
|
const {
|
|
988
|
-
toolCallId:
|
|
989
|
-
toolId:
|
|
990
|
-
arguments:
|
|
991
|
-
} =
|
|
990
|
+
toolCallId: d,
|
|
991
|
+
toolId: C,
|
|
992
|
+
arguments: x
|
|
993
|
+
} = v.data;
|
|
992
994
|
try {
|
|
993
|
-
const
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
), { result: E, returnToAgent:
|
|
997
|
-
|
|
998
|
-
|
|
995
|
+
const S = await r.executeTool(
|
|
996
|
+
C,
|
|
997
|
+
x
|
|
998
|
+
), { result: E, returnToAgent: N, agentMessage: P } = ft(S);
|
|
999
|
+
N && (b = !0), P && u.push(
|
|
1000
|
+
Y(P)
|
|
999
1001
|
);
|
|
1000
|
-
const
|
|
1001
|
-
|
|
1002
|
-
|
|
1002
|
+
const R = L(
|
|
1003
|
+
d,
|
|
1004
|
+
C,
|
|
1003
1005
|
E
|
|
1004
1006
|
);
|
|
1005
|
-
|
|
1006
|
-
} catch (
|
|
1007
|
-
const E =
|
|
1008
|
-
|
|
1009
|
-
|
|
1007
|
+
w.push(R), y.push(R);
|
|
1008
|
+
} catch (S) {
|
|
1009
|
+
const E = L(
|
|
1010
|
+
d,
|
|
1011
|
+
C,
|
|
1010
1012
|
void 0,
|
|
1011
|
-
|
|
1013
|
+
S instanceof Error ? S.message : String(S)
|
|
1012
1014
|
);
|
|
1013
|
-
|
|
1015
|
+
w.push(E), y.push(E);
|
|
1014
1016
|
}
|
|
1015
1017
|
}
|
|
1016
|
-
if (
|
|
1017
|
-
const
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1018
|
+
if (A.push(M.status.message), b) {
|
|
1019
|
+
const v = at(w);
|
|
1020
|
+
M = await lt(
|
|
1021
|
+
M.id,
|
|
1022
|
+
v,
|
|
1023
|
+
g,
|
|
1024
|
+
r,
|
|
1023
1025
|
i,
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
+
k,
|
|
1027
|
+
I
|
|
1026
1028
|
);
|
|
1027
1029
|
} else
|
|
1028
1030
|
break;
|
|
1029
1031
|
}
|
|
1030
|
-
if (
|
|
1031
|
-
const
|
|
1032
|
-
...
|
|
1033
|
-
parts:
|
|
1032
|
+
if (y.length > 0 && (h = M.status) != null && h.message) {
|
|
1033
|
+
const m = {
|
|
1034
|
+
...M.status.message,
|
|
1035
|
+
parts: y
|
|
1034
1036
|
};
|
|
1035
|
-
|
|
1036
|
-
...
|
|
1037
|
+
M = {
|
|
1038
|
+
...M,
|
|
1037
1039
|
status: {
|
|
1038
|
-
...
|
|
1039
|
-
message:
|
|
1040
|
+
...M.status,
|
|
1041
|
+
message: m
|
|
1040
1042
|
}
|
|
1041
1043
|
};
|
|
1042
1044
|
}
|
|
1043
1045
|
if (u.length > 0) {
|
|
1044
|
-
const
|
|
1046
|
+
const m = u.map((b) => U(b)).join(" "), w = Y(m);
|
|
1045
1047
|
return {
|
|
1046
|
-
...
|
|
1048
|
+
...M,
|
|
1047
1049
|
// Keep the enhanced message with tool results
|
|
1048
1050
|
// The agent message will be handled separately by the caller
|
|
1049
|
-
text:
|
|
1050
|
-
agentMessage:
|
|
1051
|
+
text: m,
|
|
1052
|
+
agentMessage: w
|
|
1051
1053
|
// Add this for the caller to handle
|
|
1052
1054
|
};
|
|
1053
1055
|
}
|
|
1054
1056
|
return {
|
|
1055
|
-
...
|
|
1057
|
+
...M,
|
|
1056
1058
|
text: U(
|
|
1057
|
-
((
|
|
1059
|
+
((p = M.status) == null ? void 0 : p.message) || {
|
|
1058
1060
|
parts: [],
|
|
1059
1061
|
messageId: D()
|
|
1060
1062
|
}
|
|
1061
1063
|
)
|
|
1062
1064
|
};
|
|
1063
1065
|
},
|
|
1064
|
-
async *sendMessageStream(
|
|
1066
|
+
async *sendMessageStream(c) {
|
|
1065
1067
|
const {
|
|
1066
|
-
withHistory:
|
|
1067
|
-
abortSignal:
|
|
1068
|
-
enableStreaming:
|
|
1069
|
-
} =
|
|
1070
|
-
|
|
1071
|
-
const
|
|
1072
|
-
g,
|
|
1068
|
+
withHistory: f = !0,
|
|
1069
|
+
abortSignal: I,
|
|
1070
|
+
enableStreaming: k
|
|
1071
|
+
} = c, A = c.sessionId || a || void 0, T = k ?? l, M = [];
|
|
1072
|
+
M.push(c.message);
|
|
1073
|
+
const y = await rt(
|
|
1073
1074
|
c,
|
|
1075
|
+
g,
|
|
1074
1076
|
{
|
|
1075
1077
|
isStreaming: !0,
|
|
1076
1078
|
// Always use message/stream endpoint for SSE
|
|
1077
|
-
enableTokenStreaming:
|
|
1079
|
+
enableTokenStreaming: T
|
|
1078
1080
|
},
|
|
1079
|
-
|
|
1081
|
+
r,
|
|
1080
1082
|
i,
|
|
1081
|
-
|
|
1082
|
-
), u =
|
|
1083
|
-
|
|
1084
|
-
|
|
1083
|
+
A
|
|
1084
|
+
), u = Ot(
|
|
1085
|
+
y,
|
|
1086
|
+
g,
|
|
1085
1087
|
{
|
|
1086
|
-
enableTokenStreaming:
|
|
1088
|
+
enableTokenStreaming: T,
|
|
1087
1089
|
// Token streaming is optional
|
|
1088
|
-
streamingTimeout:
|
|
1089
|
-
abortSignal:
|
|
1090
|
+
streamingTimeout: o,
|
|
1091
|
+
abortSignal: I
|
|
1090
1092
|
}
|
|
1091
1093
|
);
|
|
1092
|
-
yield*
|
|
1094
|
+
yield* $t(
|
|
1093
1095
|
u,
|
|
1094
|
-
|
|
1096
|
+
r,
|
|
1095
1097
|
i,
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1098
|
+
g,
|
|
1099
|
+
A,
|
|
1100
|
+
f,
|
|
1101
|
+
M,
|
|
1102
|
+
I,
|
|
1101
1103
|
{
|
|
1102
1104
|
isStreaming: !0,
|
|
1103
|
-
enableTokenStreaming:
|
|
1104
|
-
streamingTimeout:
|
|
1105
|
+
enableTokenStreaming: T,
|
|
1106
|
+
streamingTimeout: o
|
|
1105
1107
|
}
|
|
1106
1108
|
);
|
|
1107
1109
|
},
|
|
1108
|
-
async continueTask(
|
|
1109
|
-
var
|
|
1110
|
-
const
|
|
1111
|
-
let
|
|
1112
|
-
g,
|
|
1113
|
-
A,
|
|
1110
|
+
async continueTask(c, f, I) {
|
|
1111
|
+
var M;
|
|
1112
|
+
const k = ut(f);
|
|
1113
|
+
let T = await lt(
|
|
1114
1114
|
c,
|
|
1115
|
-
|
|
1115
|
+
k,
|
|
1116
|
+
g,
|
|
1117
|
+
r,
|
|
1116
1118
|
i,
|
|
1117
|
-
|
|
1119
|
+
I
|
|
1118
1120
|
);
|
|
1119
|
-
for (;
|
|
1120
|
-
const
|
|
1121
|
-
|
|
1121
|
+
for (; T.status.state === "input-required" && T.status.message && r; ) {
|
|
1122
|
+
const y = B(
|
|
1123
|
+
T.status.message
|
|
1122
1124
|
);
|
|
1123
|
-
if (
|
|
1125
|
+
if (y.length === 0)
|
|
1124
1126
|
break;
|
|
1125
|
-
const { results: u, shouldReturnToAgent: h } = await
|
|
1127
|
+
const { results: u, shouldReturnToAgent: h } = await Nt(y, r);
|
|
1126
1128
|
if (h) {
|
|
1127
|
-
const
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1129
|
+
const p = at(u);
|
|
1130
|
+
T = await lt(
|
|
1131
|
+
T.id,
|
|
1132
|
+
p,
|
|
1133
|
+
g,
|
|
1134
|
+
r,
|
|
1133
1135
|
i,
|
|
1134
|
-
|
|
1136
|
+
I
|
|
1135
1137
|
);
|
|
1136
1138
|
} else
|
|
1137
1139
|
break;
|
|
1138
1140
|
}
|
|
1139
1141
|
return {
|
|
1140
|
-
...
|
|
1142
|
+
...T,
|
|
1141
1143
|
text: U(
|
|
1142
|
-
((
|
|
1144
|
+
((M = T.status) == null ? void 0 : M.message) || {
|
|
1143
1145
|
parts: [],
|
|
1144
1146
|
messageId: D()
|
|
1145
1147
|
}
|
|
1146
1148
|
)
|
|
1147
1149
|
};
|
|
1148
1150
|
},
|
|
1149
|
-
async getTask(
|
|
1151
|
+
async getTask(c) {
|
|
1150
1152
|
throw new Error("getTask not implemented yet");
|
|
1151
1153
|
},
|
|
1152
|
-
async cancelTask(
|
|
1154
|
+
async cancelTask(c) {
|
|
1153
1155
|
throw new Error("cancelTask not implemented yet");
|
|
1154
1156
|
}
|
|
1155
1157
|
};
|
|
1156
1158
|
}
|
|
1157
|
-
const
|
|
1158
|
-
function
|
|
1159
|
+
const pt = "a8c_agenttic_conversation_history";
|
|
1160
|
+
function fe(t) {
|
|
1159
1161
|
var i;
|
|
1160
1162
|
const e = t.parts.filter((l) => l.type === "text").map((l) => l.text).join(`
|
|
1161
1163
|
`), s = t.parts.filter(
|
|
@@ -1170,16 +1172,16 @@ function de(t) {
|
|
|
1170
1172
|
toolCallId: l.data.toolCallId,
|
|
1171
1173
|
result: l.data.result,
|
|
1172
1174
|
error: l.data.error
|
|
1173
|
-
})),
|
|
1175
|
+
})), o = s.length > 0 || n.length > 0 ? "agent" : t.role, r = ((i = t.metadata) == null ? void 0 : i.timestamp) ?? Date.now();
|
|
1174
1176
|
return {
|
|
1175
|
-
role:
|
|
1177
|
+
role: o,
|
|
1176
1178
|
content: e || "(No text content)",
|
|
1177
|
-
timestamp:
|
|
1179
|
+
timestamp: r,
|
|
1178
1180
|
...s.length > 0 && { toolCalls: s },
|
|
1179
1181
|
...n.length > 0 && { toolResults: n }
|
|
1180
1182
|
};
|
|
1181
1183
|
}
|
|
1182
|
-
function
|
|
1184
|
+
function me(t) {
|
|
1183
1185
|
const e = [];
|
|
1184
1186
|
if (t.content && t.content !== "(No text content)" && e.push({
|
|
1185
1187
|
type: "text",
|
|
@@ -1214,48 +1216,48 @@ function ge(t) {
|
|
|
1214
1216
|
}
|
|
1215
1217
|
};
|
|
1216
1218
|
}
|
|
1217
|
-
const
|
|
1218
|
-
async function
|
|
1219
|
+
const J = /* @__PURE__ */ new Map(), pe = 50;
|
|
1220
|
+
async function he(t, e, s) {
|
|
1219
1221
|
const n = s || t;
|
|
1220
|
-
if (
|
|
1221
|
-
const a =
|
|
1222
|
-
a &&
|
|
1222
|
+
if (J.set(n, [...e]), J.size > pe) {
|
|
1223
|
+
const a = J.keys().next().value;
|
|
1224
|
+
a && J.delete(a);
|
|
1223
1225
|
}
|
|
1224
1226
|
if (!(typeof sessionStorage > "u"))
|
|
1225
1227
|
try {
|
|
1226
1228
|
const a = {
|
|
1227
1229
|
storageKey: n,
|
|
1228
|
-
messages: e.map(
|
|
1230
|
+
messages: e.map(fe),
|
|
1229
1231
|
lastUpdated: Date.now()
|
|
1230
1232
|
};
|
|
1231
1233
|
sessionStorage.setItem(
|
|
1232
|
-
`${
|
|
1234
|
+
`${pt}_${n}`,
|
|
1233
1235
|
JSON.stringify(a)
|
|
1234
1236
|
);
|
|
1235
1237
|
} catch (a) {
|
|
1236
|
-
|
|
1238
|
+
O(
|
|
1237
1239
|
"Failed to store conversation in sessionStorage for key %s: %O",
|
|
1238
1240
|
n,
|
|
1239
1241
|
a
|
|
1240
1242
|
);
|
|
1241
1243
|
}
|
|
1242
1244
|
}
|
|
1243
|
-
async function
|
|
1245
|
+
async function ye(t, e) {
|
|
1244
1246
|
const s = e || t;
|
|
1245
|
-
if (
|
|
1246
|
-
return [...
|
|
1247
|
+
if (J.has(s))
|
|
1248
|
+
return [...J.get(s)];
|
|
1247
1249
|
if (typeof sessionStorage > "u")
|
|
1248
1250
|
return [];
|
|
1249
1251
|
try {
|
|
1250
1252
|
const n = sessionStorage.getItem(
|
|
1251
|
-
`${
|
|
1253
|
+
`${pt}_${s}`
|
|
1252
1254
|
);
|
|
1253
1255
|
if (n) {
|
|
1254
|
-
const
|
|
1255
|
-
return
|
|
1256
|
+
const o = JSON.parse(n).messages.map(me);
|
|
1257
|
+
return J.set(s, o), [...o];
|
|
1256
1258
|
}
|
|
1257
1259
|
} catch (n) {
|
|
1258
|
-
|
|
1260
|
+
O(
|
|
1259
1261
|
"Failed to load conversation from sessionStorage for key %s: %O",
|
|
1260
1262
|
s,
|
|
1261
1263
|
n
|
|
@@ -1263,20 +1265,20 @@ async function he(t, e) {
|
|
|
1263
1265
|
}
|
|
1264
1266
|
return [];
|
|
1265
1267
|
}
|
|
1266
|
-
async function
|
|
1268
|
+
async function we(t, e) {
|
|
1267
1269
|
const s = e || t;
|
|
1268
|
-
if (
|
|
1270
|
+
if (J.delete(s), !(typeof sessionStorage > "u"))
|
|
1269
1271
|
try {
|
|
1270
|
-
sessionStorage.removeItem(`${
|
|
1272
|
+
sessionStorage.removeItem(`${pt}_${s}`);
|
|
1271
1273
|
} catch (n) {
|
|
1272
|
-
|
|
1274
|
+
O(
|
|
1273
1275
|
"Failed to clear conversation from sessionStorage for key %s: %O",
|
|
1274
1276
|
s,
|
|
1275
1277
|
n
|
|
1276
1278
|
);
|
|
1277
1279
|
}
|
|
1278
1280
|
}
|
|
1279
|
-
function
|
|
1281
|
+
function z(t) {
|
|
1280
1282
|
const e = t.parts.filter((s) => s.type === "text" ? !0 : s.type === "data" ? "role" in s.data && "text" in s.data ? !1 : "toolCallId" in s.data && "arguments" in s.data || "toolCallId" in s.data && "result" in s.data : !0);
|
|
1281
1283
|
return {
|
|
1282
1284
|
...t,
|
|
@@ -1287,7 +1289,7 @@ function G(t) {
|
|
|
1287
1289
|
}
|
|
1288
1290
|
};
|
|
1289
1291
|
}
|
|
1290
|
-
function
|
|
1292
|
+
function Ie(t) {
|
|
1291
1293
|
const e = [];
|
|
1292
1294
|
for (const s of t)
|
|
1293
1295
|
for (const n of s.parts)
|
|
@@ -1313,11 +1315,11 @@ function ye(t) {
|
|
|
1313
1315
|
}
|
|
1314
1316
|
return e;
|
|
1315
1317
|
}
|
|
1316
|
-
function
|
|
1318
|
+
function xt(t, e = []) {
|
|
1317
1319
|
return {
|
|
1318
1320
|
role: "user",
|
|
1319
1321
|
parts: [
|
|
1320
|
-
...
|
|
1322
|
+
...Ie(e),
|
|
1321
1323
|
{
|
|
1322
1324
|
type: "text",
|
|
1323
1325
|
text: t
|
|
@@ -1330,19 +1332,19 @@ function wt(t, e = []) {
|
|
|
1330
1332
|
}
|
|
1331
1333
|
};
|
|
1332
1334
|
}
|
|
1333
|
-
function
|
|
1335
|
+
function Ce(t) {
|
|
1334
1336
|
return t != null && t.parts ? t.parts.filter(
|
|
1335
1337
|
(e) => e.type === "data" && "toolCallId" in e.data && "result" in e.data
|
|
1336
1338
|
) : [];
|
|
1337
1339
|
}
|
|
1338
|
-
async function
|
|
1340
|
+
async function xe(t) {
|
|
1339
1341
|
const e = [];
|
|
1340
1342
|
for (const s of t)
|
|
1341
1343
|
if (s.parts && Array.isArray(s.parts))
|
|
1342
1344
|
if (s.parts.some(
|
|
1343
1345
|
(a) => a.type === "data" && "toolCallId" in a.data && "result" in a.data
|
|
1344
1346
|
)) {
|
|
1345
|
-
const a =
|
|
1347
|
+
const a = de(
|
|
1346
1348
|
s.parts
|
|
1347
1349
|
);
|
|
1348
1350
|
e.push({
|
|
@@ -1353,23 +1355,23 @@ async function Ie(t) {
|
|
|
1353
1355
|
e.push(s);
|
|
1354
1356
|
else
|
|
1355
1357
|
e.push(s);
|
|
1356
|
-
return
|
|
1358
|
+
return ue(), e;
|
|
1357
1359
|
}
|
|
1358
|
-
function
|
|
1360
|
+
function Me() {
|
|
1359
1361
|
const t = /* @__PURE__ */ new Map();
|
|
1360
1362
|
async function e(s, n) {
|
|
1361
1363
|
const a = t.get(s);
|
|
1362
1364
|
if (a != null && a.sessionId)
|
|
1363
1365
|
try {
|
|
1364
|
-
await
|
|
1366
|
+
await he(
|
|
1365
1367
|
a.sessionId,
|
|
1366
1368
|
n,
|
|
1367
1369
|
a.conversationStorageKey
|
|
1368
1370
|
);
|
|
1369
|
-
} catch (
|
|
1370
|
-
|
|
1371
|
+
} catch (o) {
|
|
1372
|
+
wt(
|
|
1371
1373
|
`Failed to persist conversation history for agent ${s}:`,
|
|
1372
|
-
|
|
1374
|
+
o
|
|
1373
1375
|
);
|
|
1374
1376
|
}
|
|
1375
1377
|
}
|
|
@@ -1377,25 +1379,26 @@ function Ce() {
|
|
|
1377
1379
|
async createAgent(s, n) {
|
|
1378
1380
|
if (t.has(s))
|
|
1379
1381
|
return t.get(s).client;
|
|
1380
|
-
const a =
|
|
1382
|
+
const a = ge(n), o = n.sessionId || null, r = n.conversationStorageKey;
|
|
1381
1383
|
let i = [];
|
|
1382
|
-
if (
|
|
1384
|
+
if (o)
|
|
1383
1385
|
try {
|
|
1384
|
-
i = await
|
|
1385
|
-
|
|
1386
|
-
|
|
1386
|
+
i = await ye(
|
|
1387
|
+
o,
|
|
1388
|
+
r
|
|
1387
1389
|
);
|
|
1388
|
-
} catch (
|
|
1389
|
-
|
|
1390
|
-
`Failed to load conversation history for agent ${s} with session ${
|
|
1391
|
-
|
|
1390
|
+
} catch (g) {
|
|
1391
|
+
wt(
|
|
1392
|
+
`Failed to load conversation history for agent ${s} with session ${o}:`,
|
|
1393
|
+
g
|
|
1392
1394
|
);
|
|
1393
1395
|
}
|
|
1394
1396
|
const l = {
|
|
1395
1397
|
client: a,
|
|
1396
|
-
sessionId:
|
|
1397
|
-
conversationStorageKey:
|
|
1398
|
-
conversationHistory: i
|
|
1398
|
+
sessionId: o,
|
|
1399
|
+
conversationStorageKey: r,
|
|
1400
|
+
conversationHistory: i,
|
|
1401
|
+
currentAbortController: null
|
|
1399
1402
|
};
|
|
1400
1403
|
return t.set(s, l), a;
|
|
1401
1404
|
},
|
|
@@ -1410,148 +1413,158 @@ function Ce() {
|
|
|
1410
1413
|
return t.delete(s);
|
|
1411
1414
|
},
|
|
1412
1415
|
async sendMessage(s, n, a = {}) {
|
|
1413
|
-
var
|
|
1414
|
-
const
|
|
1415
|
-
if (!
|
|
1416
|
+
var T;
|
|
1417
|
+
const o = t.get(s);
|
|
1418
|
+
if (!o)
|
|
1416
1419
|
throw new Error(`Agent with key "${s}" not found`);
|
|
1417
|
-
const { withHistory:
|
|
1418
|
-
message:
|
|
1419
|
-
withHistory:
|
|
1420
|
+
const { withHistory: r = !0, ...i } = a, { client: l, conversationHistory: g } = o, c = a.message || xt(n, g), f = await l.sendMessage({
|
|
1421
|
+
message: c,
|
|
1422
|
+
withHistory: r,
|
|
1420
1423
|
...i
|
|
1421
1424
|
});
|
|
1422
|
-
let
|
|
1423
|
-
if ((
|
|
1424
|
-
const
|
|
1425
|
+
let I = null;
|
|
1426
|
+
if ((T = f.status) != null && T.message) {
|
|
1427
|
+
const M = f.status.message.parts.filter(
|
|
1425
1428
|
(u) => u.type === "data" && "toolCallId" in u.data && ("arguments" in u.data || "result" in u.data)
|
|
1426
|
-
),
|
|
1429
|
+
), y = f.status.message.parts.filter(
|
|
1427
1430
|
(u) => u.type === "text"
|
|
1428
1431
|
);
|
|
1429
|
-
|
|
1432
|
+
I = {
|
|
1430
1433
|
role: "agent",
|
|
1431
1434
|
kind: "message",
|
|
1432
|
-
parts: [...
|
|
1435
|
+
parts: [...M, ...y],
|
|
1433
1436
|
messageId: D(),
|
|
1434
1437
|
metadata: {
|
|
1435
1438
|
timestamp: Date.now()
|
|
1436
1439
|
}
|
|
1437
1440
|
};
|
|
1438
1441
|
}
|
|
1439
|
-
const
|
|
1440
|
-
...
|
|
1442
|
+
const k = [
|
|
1443
|
+
...g,
|
|
1441
1444
|
// Store only the new content from the user message (without history parts)
|
|
1442
|
-
|
|
1445
|
+
ut(n),
|
|
1443
1446
|
// Add complete agent response with tool calls/results if present
|
|
1444
|
-
...
|
|
1447
|
+
...I ? [z(I)] : []
|
|
1445
1448
|
];
|
|
1446
|
-
let
|
|
1447
|
-
if (
|
|
1448
|
-
const
|
|
1449
|
-
|
|
1449
|
+
let A = k;
|
|
1450
|
+
if (f.agentMessage) {
|
|
1451
|
+
const M = z(
|
|
1452
|
+
f.agentMessage
|
|
1450
1453
|
);
|
|
1451
|
-
|
|
1452
|
-
...
|
|
1453
|
-
|
|
1454
|
+
A = [
|
|
1455
|
+
...k,
|
|
1456
|
+
M
|
|
1454
1457
|
];
|
|
1455
1458
|
}
|
|
1456
|
-
return
|
|
1459
|
+
return o.conversationHistory = A, r && await e(
|
|
1457
1460
|
s,
|
|
1458
|
-
|
|
1459
|
-
),
|
|
1461
|
+
A
|
|
1462
|
+
), f;
|
|
1460
1463
|
},
|
|
1461
1464
|
async *sendMessageStream(s, n, a = {}) {
|
|
1462
|
-
var
|
|
1463
|
-
const
|
|
1464
|
-
if (!
|
|
1465
|
+
var M, y, u, h, p, m;
|
|
1466
|
+
const o = t.get(s);
|
|
1467
|
+
if (!o)
|
|
1465
1468
|
throw new Error(`Agent with key "${s}" not found`);
|
|
1466
|
-
const {
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1469
|
+
const {
|
|
1470
|
+
withHistory: r = !0,
|
|
1471
|
+
abortSignal: i,
|
|
1472
|
+
...l
|
|
1473
|
+
} = a, { client: g } = o, c = new AbortController();
|
|
1474
|
+
o.currentAbortController = c, i && i.addEventListener(
|
|
1475
|
+
"abort",
|
|
1476
|
+
() => c.abort()
|
|
1477
|
+
);
|
|
1478
|
+
let f = [
|
|
1479
|
+
...o.conversationHistory
|
|
1480
|
+
], I = [];
|
|
1481
|
+
const k = await xe(
|
|
1482
|
+
f
|
|
1472
1483
|
);
|
|
1473
|
-
|
|
1484
|
+
o.conversationHistory = k, f = k, r && await e(
|
|
1474
1485
|
s,
|
|
1475
|
-
|
|
1486
|
+
k
|
|
1476
1487
|
);
|
|
1477
|
-
const
|
|
1488
|
+
const A = a.message || xt(
|
|
1478
1489
|
n,
|
|
1479
|
-
|
|
1480
|
-
),
|
|
1481
|
-
|
|
1482
|
-
...
|
|
1483
|
-
|
|
1484
|
-
],
|
|
1490
|
+
k
|
|
1491
|
+
), T = ut(n);
|
|
1492
|
+
f = [
|
|
1493
|
+
...f,
|
|
1494
|
+
T
|
|
1495
|
+
], o.conversationHistory = f, r && await e(
|
|
1485
1496
|
s,
|
|
1486
|
-
|
|
1497
|
+
f
|
|
1487
1498
|
);
|
|
1488
|
-
for await (const
|
|
1489
|
-
message:
|
|
1490
|
-
withHistory:
|
|
1491
|
-
|
|
1499
|
+
for await (const w of g.sendMessageStream({
|
|
1500
|
+
message: A,
|
|
1501
|
+
withHistory: r,
|
|
1502
|
+
abortSignal: c.signal,
|
|
1503
|
+
...l
|
|
1492
1504
|
})) {
|
|
1493
|
-
if (((
|
|
1494
|
-
|
|
1495
|
-
|
|
1505
|
+
if (((M = w.status) == null ? void 0 : M.state) === "input-required" && ((y = w.status) != null && y.message)) {
|
|
1506
|
+
I = B(
|
|
1507
|
+
w.status.message
|
|
1496
1508
|
).map(
|
|
1497
|
-
(
|
|
1509
|
+
(d) => d.data.toolCallId
|
|
1498
1510
|
);
|
|
1499
|
-
const
|
|
1500
|
-
|
|
1511
|
+
const v = z(
|
|
1512
|
+
w.status.message
|
|
1501
1513
|
);
|
|
1502
|
-
|
|
1503
|
-
...
|
|
1504
|
-
|
|
1505
|
-
],
|
|
1514
|
+
f = [
|
|
1515
|
+
...f,
|
|
1516
|
+
v
|
|
1517
|
+
], o.conversationHistory = f, r && await e(
|
|
1506
1518
|
s,
|
|
1507
|
-
|
|
1519
|
+
f
|
|
1508
1520
|
);
|
|
1509
1521
|
}
|
|
1510
|
-
if (((
|
|
1511
|
-
const
|
|
1512
|
-
|
|
1522
|
+
if (((u = w.status) == null ? void 0 : u.state) === "working" && ((h = w.status) != null && h.message) && !w.final) {
|
|
1523
|
+
const v = Ce(
|
|
1524
|
+
w.status.message
|
|
1513
1525
|
).filter(
|
|
1514
|
-
(
|
|
1515
|
-
|
|
1526
|
+
(d) => I.includes(
|
|
1527
|
+
d.data.toolCallId
|
|
1516
1528
|
)
|
|
1517
1529
|
);
|
|
1518
|
-
if (
|
|
1519
|
-
const
|
|
1530
|
+
if (v.length > 0) {
|
|
1531
|
+
const d = {
|
|
1520
1532
|
role: "agent",
|
|
1521
1533
|
kind: "message",
|
|
1522
|
-
parts:
|
|
1534
|
+
parts: v,
|
|
1523
1535
|
messageId: D()
|
|
1524
1536
|
};
|
|
1525
|
-
|
|
1526
|
-
...
|
|
1527
|
-
|
|
1528
|
-
],
|
|
1537
|
+
f = [
|
|
1538
|
+
...f,
|
|
1539
|
+
z(d)
|
|
1540
|
+
], o.conversationHistory = f, r && await e(
|
|
1529
1541
|
s,
|
|
1530
|
-
|
|
1542
|
+
f
|
|
1531
1543
|
);
|
|
1532
1544
|
}
|
|
1533
1545
|
}
|
|
1534
|
-
if (
|
|
1535
|
-
|
|
1536
|
-
let
|
|
1537
|
-
(
|
|
1538
|
-
|
|
1539
|
-
),
|
|
1540
|
-
...
|
|
1541
|
-
|
|
1542
|
-
],
|
|
1546
|
+
if (w.final && ((p = w.status) == null ? void 0 : p.state) !== "input-required") {
|
|
1547
|
+
I = [];
|
|
1548
|
+
let b = null;
|
|
1549
|
+
(m = w.status) != null && m.message && (b = z(
|
|
1550
|
+
w.status.message
|
|
1551
|
+
), f = [
|
|
1552
|
+
...f,
|
|
1553
|
+
b
|
|
1554
|
+
], o.conversationHistory = f, r && await e(
|
|
1543
1555
|
s,
|
|
1544
|
-
|
|
1556
|
+
f
|
|
1545
1557
|
));
|
|
1546
1558
|
}
|
|
1547
|
-
yield
|
|
1559
|
+
yield w;
|
|
1548
1560
|
}
|
|
1561
|
+
o.currentAbortController = null;
|
|
1549
1562
|
},
|
|
1550
1563
|
async resetConversation(s) {
|
|
1551
1564
|
const n = t.get(s);
|
|
1552
1565
|
if (!n)
|
|
1553
1566
|
throw new Error(`Agent with key "${s}" not found`);
|
|
1554
|
-
n.conversationHistory = [], n.sessionId && await
|
|
1567
|
+
n.conversationHistory = [], n.sessionId && await we(
|
|
1555
1568
|
n.sessionId,
|
|
1556
1569
|
n.conversationStorageKey
|
|
1557
1570
|
);
|
|
@@ -1562,16 +1575,22 @@ function Ce() {
|
|
|
1562
1575
|
throw new Error(`Agent with key "${s}" not found`);
|
|
1563
1576
|
return [...n.conversationHistory];
|
|
1564
1577
|
},
|
|
1578
|
+
abortCurrentRequest(s) {
|
|
1579
|
+
const n = t.get(s);
|
|
1580
|
+
if (!n)
|
|
1581
|
+
throw new Error(`Agent with key "${s}" not found`);
|
|
1582
|
+
n.currentAbortController && (n.currentAbortController.abort(), n.currentAbortController = null);
|
|
1583
|
+
},
|
|
1565
1584
|
clear() {
|
|
1566
1585
|
t.clear();
|
|
1567
1586
|
}
|
|
1568
1587
|
};
|
|
1569
1588
|
}
|
|
1570
|
-
const
|
|
1571
|
-
function
|
|
1572
|
-
return
|
|
1589
|
+
const be = Me();
|
|
1590
|
+
function ct() {
|
|
1591
|
+
return be;
|
|
1573
1592
|
}
|
|
1574
|
-
class
|
|
1593
|
+
class Te extends jt {
|
|
1575
1594
|
constructor(e) {
|
|
1576
1595
|
super(e), this.state = {
|
|
1577
1596
|
hasError: !1,
|
|
@@ -1611,7 +1630,7 @@ class Me extends Dt {
|
|
|
1611
1630
|
"The error has been logged to the console."
|
|
1612
1631
|
];
|
|
1613
1632
|
return /* @__PURE__ */ $.jsx(
|
|
1614
|
-
|
|
1633
|
+
st,
|
|
1615
1634
|
{
|
|
1616
1635
|
message: s,
|
|
1617
1636
|
details: n.join(`
|
|
@@ -1622,91 +1641,91 @@ class Me extends Dt {
|
|
|
1622
1641
|
return this.props.children;
|
|
1623
1642
|
}
|
|
1624
1643
|
}
|
|
1625
|
-
const
|
|
1644
|
+
const Se = (t) => {
|
|
1626
1645
|
const {
|
|
1627
1646
|
data: e,
|
|
1628
1647
|
currency: s,
|
|
1629
1648
|
showLegend: n = !0,
|
|
1630
1649
|
withTooltips: a = !0,
|
|
1631
|
-
renderTooltip:
|
|
1632
|
-
margin:
|
|
1650
|
+
renderTooltip: o,
|
|
1651
|
+
margin: r,
|
|
1633
1652
|
withGradientFill: i = !0,
|
|
1634
1653
|
error: l,
|
|
1635
|
-
...
|
|
1636
|
-
} = t,
|
|
1637
|
-
...
|
|
1654
|
+
...g
|
|
1655
|
+
} = t, c = {
|
|
1656
|
+
...Ft(),
|
|
1638
1657
|
bottom: 80
|
|
1639
|
-
},
|
|
1658
|
+
}, f = {
|
|
1640
1659
|
data: e,
|
|
1641
1660
|
withTooltips: a,
|
|
1642
|
-
renderTooltip:
|
|
1661
|
+
renderTooltip: o,
|
|
1643
1662
|
showLegend: n,
|
|
1644
1663
|
withGradientFill: i,
|
|
1645
1664
|
withLegendGlyph: !1,
|
|
1646
1665
|
legendOrientation: "horizontal",
|
|
1647
1666
|
legendAlignmentHorizontal: "center",
|
|
1648
1667
|
legendAlignmentVertical: "bottom",
|
|
1649
|
-
margin:
|
|
1668
|
+
margin: c,
|
|
1650
1669
|
options: {
|
|
1651
1670
|
xScale: {
|
|
1652
1671
|
type: "time"
|
|
1653
1672
|
},
|
|
1654
1673
|
axis: {
|
|
1655
1674
|
x: {
|
|
1656
|
-
...
|
|
1675
|
+
...qt(e)
|
|
1657
1676
|
}
|
|
1658
1677
|
}
|
|
1659
1678
|
},
|
|
1660
1679
|
...s && { currency: s },
|
|
1661
|
-
...
|
|
1680
|
+
...g
|
|
1662
1681
|
};
|
|
1663
|
-
return /* @__PURE__ */ $.jsx(
|
|
1664
|
-
},
|
|
1682
|
+
return /* @__PURE__ */ $.jsx(Ht, { error: l, children: /* @__PURE__ */ $.jsx(Lt, { ...f }) });
|
|
1683
|
+
}, ke = ({
|
|
1665
1684
|
data: t,
|
|
1666
1685
|
className: e = "",
|
|
1667
1686
|
config: s
|
|
1668
1687
|
}) => {
|
|
1669
|
-
const [n, a] =
|
|
1688
|
+
const [n, a] = Q(null), [o, r] = Q(
|
|
1670
1689
|
null
|
|
1671
|
-
), [i, l] =
|
|
1672
|
-
(
|
|
1673
|
-
var
|
|
1674
|
-
const { tooltipData: u } =
|
|
1690
|
+
), [i, l] = Q(300), g = bt(null), c = F(
|
|
1691
|
+
(y) => {
|
|
1692
|
+
var v;
|
|
1693
|
+
const { tooltipData: u } = y, h = (v = u == null ? void 0 : u.nearestDatum) == null ? void 0 : v.datum;
|
|
1675
1694
|
if (!h)
|
|
1676
1695
|
return null;
|
|
1677
|
-
const
|
|
1678
|
-
if (
|
|
1679
|
-
const { symbol:
|
|
1680
|
-
let
|
|
1681
|
-
return
|
|
1696
|
+
const p = (d) => {
|
|
1697
|
+
if (o != null && o.currency) {
|
|
1698
|
+
const { symbol: C, symbolPosition: x } = o.currency;
|
|
1699
|
+
let S;
|
|
1700
|
+
return d >= 1e6 ? S = `${(d / 1e6).toFixed(
|
|
1682
1701
|
1
|
|
1683
|
-
)}M` :
|
|
1702
|
+
)}M` : d >= 1e3 ? S = `${(d / 1e3).toFixed(1)}K` : S = d.toLocaleString(), x === "right" ? `${S}${C}` : `${C}${S}`;
|
|
1684
1703
|
}
|
|
1685
|
-
return
|
|
1686
|
-
},
|
|
1687
|
-
const
|
|
1688
|
-
((/* @__PURE__ */ new Date()).getTime() -
|
|
1704
|
+
return d >= 1e6 ? `${(d / 1e6).toFixed(1)}M` : d >= 1e3 ? `${(d / 1e3).toFixed(1)}K` : d.toLocaleString();
|
|
1705
|
+
}, m = (d) => {
|
|
1706
|
+
const x = Math.floor(
|
|
1707
|
+
((/* @__PURE__ */ new Date()).getTime() - d.getTime()) / (1e3 * 60 * 60 * 24)
|
|
1689
1708
|
);
|
|
1690
|
-
return
|
|
1709
|
+
return x === 0 ? q("Today", "a8c-agenttic") : x === 1 ? q("Yesterday", "a8c-agenttic") : x < 7 ? ht(
|
|
1691
1710
|
/* translators: %d: number of days */
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
) :
|
|
1711
|
+
q("%d days ago", "a8c-agenttic"),
|
|
1712
|
+
x
|
|
1713
|
+
) : d.toLocaleDateString("en-US", {
|
|
1695
1714
|
year: "numeric",
|
|
1696
1715
|
month: "short",
|
|
1697
1716
|
day: "numeric"
|
|
1698
1717
|
});
|
|
1699
|
-
},
|
|
1718
|
+
}, w = h.label, b = Object.entries(
|
|
1700
1719
|
(u == null ? void 0 : u.datumByKey) || {}
|
|
1701
|
-
).map(([
|
|
1702
|
-
const
|
|
1720
|
+
).map(([d, C]) => {
|
|
1721
|
+
const x = C.datum;
|
|
1703
1722
|
return {
|
|
1704
|
-
key:
|
|
1705
|
-
value:
|
|
1723
|
+
key: d,
|
|
1724
|
+
value: x.value
|
|
1706
1725
|
};
|
|
1707
|
-
}).sort((
|
|
1726
|
+
}).sort((d, C) => C.value - d.value);
|
|
1708
1727
|
return /* @__PURE__ */ $.jsxs("div", { children: [
|
|
1709
|
-
|
|
1728
|
+
w && /* @__PURE__ */ $.jsx(
|
|
1710
1729
|
"div",
|
|
1711
1730
|
{
|
|
1712
1731
|
style: {
|
|
@@ -1717,7 +1736,7 @@ const Te = (t) => {
|
|
|
1717
1736
|
borderBottom: "1px solid #eee",
|
|
1718
1737
|
paddingBottom: "2px"
|
|
1719
1738
|
},
|
|
1720
|
-
children:
|
|
1739
|
+
children: w
|
|
1721
1740
|
}
|
|
1722
1741
|
),
|
|
1723
1742
|
h.date && /* @__PURE__ */ $.jsx(
|
|
@@ -1728,51 +1747,51 @@ const Te = (t) => {
|
|
|
1728
1747
|
opacity: 0.8,
|
|
1729
1748
|
marginBottom: "4px"
|
|
1730
1749
|
},
|
|
1731
|
-
children:
|
|
1750
|
+
children: m(h.date)
|
|
1732
1751
|
}
|
|
1733
1752
|
),
|
|
1734
|
-
|
|
1753
|
+
b.map((d) => /* @__PURE__ */ $.jsxs(
|
|
1735
1754
|
"div",
|
|
1736
1755
|
{
|
|
1737
1756
|
style: { marginBottom: "2px" },
|
|
1738
1757
|
children: [
|
|
1739
1758
|
/* @__PURE__ */ $.jsxs("strong", { children: [
|
|
1740
|
-
|
|
1759
|
+
d.key,
|
|
1741
1760
|
":"
|
|
1742
1761
|
] }),
|
|
1743
1762
|
" ",
|
|
1744
|
-
d
|
|
1763
|
+
p(d.value)
|
|
1745
1764
|
]
|
|
1746
1765
|
},
|
|
1747
|
-
|
|
1766
|
+
d.key
|
|
1748
1767
|
))
|
|
1749
1768
|
] });
|
|
1750
1769
|
},
|
|
1751
|
-
[
|
|
1770
|
+
[o == null ? void 0 : o.currency]
|
|
1752
1771
|
);
|
|
1753
|
-
|
|
1754
|
-
if (a(null),
|
|
1772
|
+
X(() => {
|
|
1773
|
+
if (a(null), r(null), !t || typeof t != "string") {
|
|
1755
1774
|
a({
|
|
1756
|
-
message:
|
|
1775
|
+
message: q("Invalid chart data provided", "a8c-agenttic"),
|
|
1757
1776
|
details: `Input data: ${t}`
|
|
1758
1777
|
});
|
|
1759
1778
|
return;
|
|
1760
1779
|
}
|
|
1761
1780
|
try {
|
|
1762
|
-
const
|
|
1763
|
-
if (!
|
|
1781
|
+
const y = JSON.parse(t.trim());
|
|
1782
|
+
if (!y.chartType) {
|
|
1764
1783
|
a({
|
|
1765
|
-
message:
|
|
1784
|
+
message: q(
|
|
1766
1785
|
"Chart data must include chartType",
|
|
1767
1786
|
"a8c-agenttic"
|
|
1768
1787
|
),
|
|
1769
|
-
details:
|
|
1788
|
+
details: q("Available types: line, bar", "a8c-agenttic")
|
|
1770
1789
|
});
|
|
1771
1790
|
return;
|
|
1772
1791
|
}
|
|
1773
|
-
if (!
|
|
1792
|
+
if (!y.data || !Array.isArray(y.data)) {
|
|
1774
1793
|
a({
|
|
1775
|
-
message:
|
|
1794
|
+
message: q(
|
|
1776
1795
|
"Chart data must include a data array",
|
|
1777
1796
|
"a8c-agenttic"
|
|
1778
1797
|
),
|
|
@@ -1780,9 +1799,9 @@ const Te = (t) => {
|
|
|
1780
1799
|
});
|
|
1781
1800
|
return;
|
|
1782
1801
|
}
|
|
1783
|
-
if (
|
|
1802
|
+
if (y.data.length === 0) {
|
|
1784
1803
|
a({
|
|
1785
|
-
message:
|
|
1804
|
+
message: q(
|
|
1786
1805
|
"No data points found for chart",
|
|
1787
1806
|
"a8c-agenttic"
|
|
1788
1807
|
),
|
|
@@ -1790,40 +1809,40 @@ const Te = (t) => {
|
|
|
1790
1809
|
});
|
|
1791
1810
|
return;
|
|
1792
1811
|
}
|
|
1793
|
-
const u =
|
|
1794
|
-
...
|
|
1795
|
-
data:
|
|
1796
|
-
if (
|
|
1797
|
-
const
|
|
1798
|
-
return isNaN(
|
|
1799
|
-
`Invalid date string: "${
|
|
1812
|
+
const u = y.data.map((p) => ({
|
|
1813
|
+
...p,
|
|
1814
|
+
data: p.data.map((m) => {
|
|
1815
|
+
if (m.date) {
|
|
1816
|
+
const w = new Date(m.date);
|
|
1817
|
+
return isNaN(w.getTime()) ? (console.warn(
|
|
1818
|
+
`Invalid date string: "${m.date}" in series "${p.label}"`
|
|
1800
1819
|
), {
|
|
1801
|
-
label:
|
|
1802
|
-
value:
|
|
1820
|
+
label: m.label,
|
|
1821
|
+
value: m.value,
|
|
1803
1822
|
date: void 0
|
|
1804
1823
|
}) : {
|
|
1805
|
-
label:
|
|
1806
|
-
value:
|
|
1807
|
-
date:
|
|
1824
|
+
label: m.label,
|
|
1825
|
+
value: m.value,
|
|
1826
|
+
date: w
|
|
1808
1827
|
};
|
|
1809
1828
|
}
|
|
1810
1829
|
return {
|
|
1811
|
-
label:
|
|
1812
|
-
value:
|
|
1830
|
+
label: m.label,
|
|
1831
|
+
value: m.value,
|
|
1813
1832
|
date: void 0
|
|
1814
1833
|
};
|
|
1815
1834
|
})
|
|
1816
1835
|
})), h = {
|
|
1817
|
-
chartType:
|
|
1818
|
-
title:
|
|
1836
|
+
chartType: y.chartType,
|
|
1837
|
+
title: y.title,
|
|
1819
1838
|
data: u,
|
|
1820
|
-
currency:
|
|
1821
|
-
mode:
|
|
1839
|
+
currency: y.currency,
|
|
1840
|
+
mode: y.mode || "time-comparison"
|
|
1822
1841
|
};
|
|
1823
|
-
|
|
1842
|
+
r(h);
|
|
1824
1843
|
} catch {
|
|
1825
1844
|
a({
|
|
1826
|
-
message:
|
|
1845
|
+
message: q(
|
|
1827
1846
|
"Failed to parse chart data as JSON",
|
|
1828
1847
|
"a8c-agenttic"
|
|
1829
1848
|
),
|
|
@@ -1831,139 +1850,166 @@ const Te = (t) => {
|
|
|
1831
1850
|
});
|
|
1832
1851
|
}
|
|
1833
1852
|
}, [t]);
|
|
1834
|
-
const
|
|
1835
|
-
if (
|
|
1836
|
-
const { width: u } =
|
|
1837
|
-
l(h),
|
|
1838
|
-
for (const
|
|
1839
|
-
const
|
|
1853
|
+
const f = F((y) => {
|
|
1854
|
+
if (g.current && g.current.disconnect(), y) {
|
|
1855
|
+
const { width: u } = y.getBoundingClientRect(), h = Math.max(280, u - 4);
|
|
1856
|
+
l(h), g.current = new ResizeObserver((p) => {
|
|
1857
|
+
for (const m of p) {
|
|
1858
|
+
const w = m.contentRect.width, b = Math.max(
|
|
1840
1859
|
280,
|
|
1841
|
-
|
|
1860
|
+
w - 4
|
|
1842
1861
|
);
|
|
1843
|
-
l(
|
|
1862
|
+
l(b);
|
|
1844
1863
|
}
|
|
1845
|
-
}),
|
|
1864
|
+
}), g.current.observe(y);
|
|
1846
1865
|
}
|
|
1847
1866
|
}, []);
|
|
1848
|
-
if (
|
|
1849
|
-
|
|
1867
|
+
if (X(() => () => {
|
|
1868
|
+
g.current && (g.current.disconnect(), g.current = null);
|
|
1850
1869
|
}, []), n)
|
|
1851
|
-
return /* @__PURE__ */ $.jsx(
|
|
1852
|
-
if (!
|
|
1870
|
+
return /* @__PURE__ */ $.jsx(st, { message: n.message, details: n.details });
|
|
1871
|
+
if (!o)
|
|
1853
1872
|
return /* @__PURE__ */ $.jsx(
|
|
1854
|
-
|
|
1873
|
+
st,
|
|
1855
1874
|
{
|
|
1856
|
-
message:
|
|
1875
|
+
message: q("No chart data available", "a8c-agenttic")
|
|
1857
1876
|
}
|
|
1858
1877
|
);
|
|
1859
|
-
const
|
|
1860
|
-
data:
|
|
1861
|
-
currency:
|
|
1862
|
-
showLegend:
|
|
1878
|
+
const k = o.data.length > 1, A = i, T = {
|
|
1879
|
+
data: o.data,
|
|
1880
|
+
currency: o.currency,
|
|
1881
|
+
showLegend: k,
|
|
1863
1882
|
withTooltips: !0,
|
|
1864
|
-
renderTooltip:
|
|
1883
|
+
renderTooltip: c,
|
|
1865
1884
|
error: null,
|
|
1866
|
-
maxWidth:
|
|
1885
|
+
maxWidth: A,
|
|
1867
1886
|
aspectRatio: 1.2,
|
|
1868
1887
|
resizeDebounceTime: 300
|
|
1869
|
-
},
|
|
1870
|
-
switch (
|
|
1888
|
+
}, M = () => {
|
|
1889
|
+
switch (o.chartType) {
|
|
1871
1890
|
case "line":
|
|
1872
|
-
return /* @__PURE__ */ $.jsx(
|
|
1891
|
+
return /* @__PURE__ */ $.jsx(Se, { ...T });
|
|
1873
1892
|
case "bar":
|
|
1874
1893
|
return /* @__PURE__ */ $.jsx(
|
|
1875
|
-
|
|
1894
|
+
Ut,
|
|
1876
1895
|
{
|
|
1877
|
-
...
|
|
1878
|
-
mode:
|
|
1896
|
+
...T,
|
|
1897
|
+
mode: o.mode
|
|
1879
1898
|
}
|
|
1880
1899
|
);
|
|
1881
1900
|
default:
|
|
1882
1901
|
return /* @__PURE__ */ $.jsx(
|
|
1883
|
-
|
|
1902
|
+
st,
|
|
1884
1903
|
{
|
|
1885
|
-
message:
|
|
1904
|
+
message: ht(
|
|
1886
1905
|
/* translators: %s: chart type name */
|
|
1887
|
-
|
|
1888
|
-
|
|
1906
|
+
q("Unsupported chart type: %s", "a8c-agenttic"),
|
|
1907
|
+
o.chartType
|
|
1889
1908
|
)
|
|
1890
1909
|
}
|
|
1891
1910
|
);
|
|
1892
1911
|
}
|
|
1893
1912
|
};
|
|
1894
|
-
return /* @__PURE__ */ $.jsx(
|
|
1913
|
+
return /* @__PURE__ */ $.jsx(Te, { chartData: t, children: /* @__PURE__ */ $.jsxs(
|
|
1895
1914
|
"div",
|
|
1896
1915
|
{
|
|
1897
|
-
ref:
|
|
1916
|
+
ref: f,
|
|
1898
1917
|
className: `chart-block ${e}`,
|
|
1899
1918
|
children: [
|
|
1900
|
-
|
|
1901
|
-
/* @__PURE__ */ $.jsx("div", { className: "chart-container", children:
|
|
1919
|
+
o.title && /* @__PURE__ */ $.jsx("h3", { className: "chart-block-title", children: o.title }),
|
|
1920
|
+
/* @__PURE__ */ $.jsx("div", { className: "chart-container", children: M() })
|
|
1902
1921
|
]
|
|
1903
1922
|
}
|
|
1904
1923
|
) });
|
|
1905
1924
|
};
|
|
1906
|
-
function
|
|
1925
|
+
function Ae(t) {
|
|
1907
1926
|
return function(s) {
|
|
1908
|
-
const { children: n, className: a, ...
|
|
1927
|
+
const { children: n, className: a, ...o } = s;
|
|
1909
1928
|
if (!(a == null ? void 0 : a.includes("language-chart")))
|
|
1910
|
-
return
|
|
1929
|
+
return nt.createElement(
|
|
1911
1930
|
"code",
|
|
1912
|
-
{ className: a, ...
|
|
1931
|
+
{ className: a, ...o },
|
|
1913
1932
|
n
|
|
1914
1933
|
);
|
|
1915
1934
|
const i = typeof n == "string" ? n : "";
|
|
1916
|
-
return
|
|
1935
|
+
return nt.createElement(ke, {
|
|
1917
1936
|
data: i,
|
|
1918
1937
|
className: "markdown-chart",
|
|
1919
1938
|
config: t
|
|
1920
1939
|
});
|
|
1921
1940
|
};
|
|
1922
1941
|
}
|
|
1923
|
-
function
|
|
1942
|
+
function ve(t) {
|
|
1924
1943
|
var n, a;
|
|
1925
1944
|
const e = {}, s = [];
|
|
1926
|
-
return (n = t == null ? void 0 : t.charts) != null && n.enabled && (e.code =
|
|
1945
|
+
return (n = t == null ? void 0 : t.charts) != null && n.enabled && (e.code = Ae(t.charts.config)), (a = t == null ? void 0 : t.gfm) != null && a.enabled && s.push(Jt), { components: e, remarkPlugins: s };
|
|
1927
1946
|
}
|
|
1928
|
-
function
|
|
1947
|
+
function Re(t, e = {}) {
|
|
1929
1948
|
return {
|
|
1930
1949
|
...t,
|
|
1931
1950
|
...e
|
|
1932
1951
|
};
|
|
1933
1952
|
}
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1953
|
+
let tt = null, et = null;
|
|
1954
|
+
async function Ee() {
|
|
1955
|
+
return tt || et || (et = Promise.all([
|
|
1956
|
+
import("./parseIncompleteMarkdown-Di9Hun9H.js"),
|
|
1957
|
+
import("./parseBlocks-DtWG2dnE.js")
|
|
1958
|
+
]).then(([t, e]) => (tt = {
|
|
1959
|
+
parseIncompleteMarkdown: t.parseIncompleteMarkdown,
|
|
1960
|
+
parseMarkdownIntoBlocks: e.parseMarkdownIntoBlocks
|
|
1961
|
+
}, tt)), et);
|
|
1962
|
+
}
|
|
1963
|
+
function Pe(t = {}) {
|
|
1964
|
+
const {
|
|
1965
|
+
components: e = {},
|
|
1966
|
+
extensions: s = {},
|
|
1967
|
+
remarkPlugins: n = [],
|
|
1968
|
+
enableStreaming: a = !1
|
|
1969
|
+
} = t, o = ve(s), r = Re(
|
|
1970
|
+
o.components,
|
|
1937
1971
|
e
|
|
1938
|
-
),
|
|
1939
|
-
return function({ children:
|
|
1940
|
-
|
|
1941
|
-
|
|
1972
|
+
), i = [...o.remarkPlugins, ...n];
|
|
1973
|
+
return function({ children: g }) {
|
|
1974
|
+
const [c, f] = nt.useState(g);
|
|
1975
|
+
return nt.useEffect(() => {
|
|
1976
|
+
a ? Ee().then(async (I) => {
|
|
1977
|
+
const A = (await I.parseMarkdownIntoBlocks(g)).map((T) => I.parseIncompleteMarkdown(
|
|
1978
|
+
T.trim()
|
|
1979
|
+
)).join(`
|
|
1980
|
+
|
|
1981
|
+
`);
|
|
1982
|
+
f(A);
|
|
1983
|
+
}).catch(() => {
|
|
1984
|
+
f(g);
|
|
1985
|
+
}) : f(g);
|
|
1986
|
+
}, [g]), /* @__PURE__ */ $.jsx(
|
|
1987
|
+
Bt,
|
|
1942
1988
|
{
|
|
1943
1989
|
components: r,
|
|
1944
|
-
remarkPlugins:
|
|
1945
|
-
children:
|
|
1990
|
+
remarkPlugins: i,
|
|
1991
|
+
children: c
|
|
1946
1992
|
}
|
|
1947
1993
|
);
|
|
1948
1994
|
};
|
|
1949
1995
|
}
|
|
1950
|
-
const
|
|
1996
|
+
const Oe = (t) => {
|
|
1951
1997
|
const e = t.condition || (() => !0), s = {}, n = [], a = () => {
|
|
1952
|
-
n.forEach((
|
|
1953
|
-
},
|
|
1954
|
-
s[
|
|
1998
|
+
n.forEach((r) => r());
|
|
1999
|
+
}, o = async (r, i) => {
|
|
2000
|
+
s[r] = i, await t.onFeedback(r, i), a();
|
|
1955
2001
|
};
|
|
1956
2002
|
return {
|
|
1957
|
-
getActionsForMessage: (
|
|
1958
|
-
if (!e(
|
|
2003
|
+
getActionsForMessage: (r) => {
|
|
2004
|
+
if (!e(r))
|
|
1959
2005
|
return [];
|
|
1960
|
-
const i = s[
|
|
2006
|
+
const i = s[r.id], l = [];
|
|
1961
2007
|
return l.push({
|
|
1962
2008
|
id: "feedback-up",
|
|
1963
2009
|
icon: t.icons.up,
|
|
1964
2010
|
label: "Good response",
|
|
1965
2011
|
onClick: async () => {
|
|
1966
|
-
i === "up" ? delete s[
|
|
2012
|
+
i === "up" ? delete s[r.id] : await o(r.id, "up"), a();
|
|
1967
2013
|
},
|
|
1968
2014
|
tooltip: "This response was helpful",
|
|
1969
2015
|
pressed: i === "up",
|
|
@@ -1974,7 +2020,7 @@ const Re = (t) => {
|
|
|
1974
2020
|
icon: t.icons.down,
|
|
1975
2021
|
label: "Bad response",
|
|
1976
2022
|
onClick: async () => {
|
|
1977
|
-
i === "down" ? delete s[
|
|
2023
|
+
i === "down" ? delete s[r.id] : await o(r.id, "down"), a();
|
|
1978
2024
|
},
|
|
1979
2025
|
tooltip: "This response was not helpful",
|
|
1980
2026
|
pressed: i === "down",
|
|
@@ -1982,52 +2028,52 @@ const Re = (t) => {
|
|
|
1982
2028
|
// Disable if other is selected
|
|
1983
2029
|
}), l;
|
|
1984
2030
|
},
|
|
1985
|
-
clearFeedback: (
|
|
1986
|
-
delete s[
|
|
2031
|
+
clearFeedback: (r) => {
|
|
2032
|
+
delete s[r], a();
|
|
1987
2033
|
},
|
|
1988
2034
|
clearAllFeedback: () => {
|
|
1989
|
-
Object.keys(s).forEach((
|
|
1990
|
-
delete s[
|
|
2035
|
+
Object.keys(s).forEach((r) => {
|
|
2036
|
+
delete s[r];
|
|
1991
2037
|
}), a();
|
|
1992
2038
|
},
|
|
1993
|
-
onChange: (
|
|
1994
|
-
n.push(
|
|
2039
|
+
onChange: (r) => {
|
|
2040
|
+
n.push(r);
|
|
1995
2041
|
},
|
|
1996
|
-
offChange: (
|
|
1997
|
-
const i = n.indexOf(
|
|
2042
|
+
offChange: (r) => {
|
|
2043
|
+
const i = n.indexOf(r);
|
|
1998
2044
|
i > -1 && n.splice(i, 1);
|
|
1999
2045
|
}
|
|
2000
2046
|
};
|
|
2001
2047
|
};
|
|
2002
|
-
function
|
|
2003
|
-
const [t, e] =
|
|
2004
|
-
(
|
|
2005
|
-
e((
|
|
2006
|
-
const i =
|
|
2007
|
-
(l) => l.id ===
|
|
2048
|
+
function Ne() {
|
|
2049
|
+
const [t, e] = Q([]), s = F(
|
|
2050
|
+
(o) => {
|
|
2051
|
+
e((r) => {
|
|
2052
|
+
const i = r.findIndex(
|
|
2053
|
+
(l) => l.id === o.id
|
|
2008
2054
|
);
|
|
2009
2055
|
if (i >= 0) {
|
|
2010
|
-
const l = [...
|
|
2011
|
-
return l[i] =
|
|
2056
|
+
const l = [...r];
|
|
2057
|
+
return l[i] = o, l;
|
|
2012
2058
|
}
|
|
2013
|
-
return [...
|
|
2059
|
+
return [...r, o];
|
|
2014
2060
|
});
|
|
2015
2061
|
},
|
|
2016
2062
|
[]
|
|
2017
|
-
), n =
|
|
2018
|
-
e((
|
|
2019
|
-
}, []), a =
|
|
2063
|
+
), n = F((o) => {
|
|
2064
|
+
e((r) => r.filter((i) => i.id !== o));
|
|
2065
|
+
}, []), a = F(() => {
|
|
2020
2066
|
e([]);
|
|
2021
2067
|
}, []);
|
|
2022
2068
|
return {
|
|
2023
2069
|
registerMessageActions: s,
|
|
2024
2070
|
unregisterMessageActions: n,
|
|
2025
2071
|
clearAllMessageActions: a,
|
|
2026
|
-
createFeedbackActions:
|
|
2072
|
+
createFeedbackActions: Oe,
|
|
2027
2073
|
registrations: t
|
|
2028
2074
|
};
|
|
2029
2075
|
}
|
|
2030
|
-
function
|
|
2076
|
+
function $e(t, e) {
|
|
2031
2077
|
return e.flatMap((a) => typeof a.actions == "function" ? a.actions(t) : a.actions).filter((a) => !(a.condition && !a.condition(t))).map((a) => ({
|
|
2032
2078
|
id: a.id,
|
|
2033
2079
|
label: a.label,
|
|
@@ -2039,8 +2085,8 @@ function Pe(t, e) {
|
|
|
2039
2085
|
showLabel: a.showLabel
|
|
2040
2086
|
}));
|
|
2041
2087
|
}
|
|
2042
|
-
const
|
|
2043
|
-
var
|
|
2088
|
+
const G = (t) => [...t].sort((e, s) => e.timestamp - s.timestamp), K = (t, e = []) => {
|
|
2089
|
+
var r;
|
|
2044
2090
|
if (t.parts.some((i) => {
|
|
2045
2091
|
if (i.type === "data") {
|
|
2046
2092
|
const l = i.data;
|
|
@@ -2075,7 +2121,7 @@ const Q = (t) => [...t].sort((e, s) => e.timestamp - s.timestamp), V = (t, e = [
|
|
|
2075
2121
|
type: "text",
|
|
2076
2122
|
text: "[Unsupported content]"
|
|
2077
2123
|
};
|
|
2078
|
-
}), a = ((
|
|
2124
|
+
}), a = ((r = t.metadata) == null ? void 0 : r.timestamp) ?? Date.now(), o = {
|
|
2079
2125
|
id: t.messageId,
|
|
2080
2126
|
role: t.role === "agent" ? "agent" : "user",
|
|
2081
2127
|
content: n,
|
|
@@ -2085,78 +2131,77 @@ const Q = (t) => [...t].sort((e, s) => e.timestamp - s.timestamp), V = (t, e = [
|
|
|
2085
2131
|
icon: t.role === "agent" ? "assistant" : void 0
|
|
2086
2132
|
};
|
|
2087
2133
|
if (t.role === "agent" && e.length > 0) {
|
|
2088
|
-
const i =
|
|
2089
|
-
|
|
2134
|
+
const i = $e(
|
|
2135
|
+
o,
|
|
2090
2136
|
e
|
|
2091
2137
|
);
|
|
2092
|
-
i.length > 0 && (
|
|
2138
|
+
i.length > 0 && (o.actions = i);
|
|
2093
2139
|
}
|
|
2094
|
-
return
|
|
2095
|
-
},
|
|
2140
|
+
return o;
|
|
2141
|
+
}, De = () => ({
|
|
2096
2142
|
getClientContext: () => ({})
|
|
2097
|
-
}),
|
|
2143
|
+
}), _e = () => ({
|
|
2098
2144
|
getAvailableTools: async () => [],
|
|
2099
2145
|
executeTool: async () => ({
|
|
2100
2146
|
success: !0,
|
|
2101
2147
|
result: "No tools available"
|
|
2102
2148
|
})
|
|
2103
|
-
}),
|
|
2149
|
+
}), je = (t) => ["agentId", "agentUrl", "sessionId"].every((s) => {
|
|
2104
2150
|
const n = t[s];
|
|
2105
2151
|
return typeof n == "string" && n.trim().length > 0;
|
|
2106
2152
|
});
|
|
2107
|
-
function
|
|
2153
|
+
function Ze(t) {
|
|
2108
2154
|
const e = {
|
|
2109
2155
|
agentId: t.agentId,
|
|
2110
2156
|
agentUrl: t.agentUrl,
|
|
2111
2157
|
sessionId: t.sessionId
|
|
2112
|
-
}, s =
|
|
2158
|
+
}, s = je(e), [n, a] = Q({
|
|
2113
2159
|
clientMessages: [],
|
|
2114
2160
|
uiMessages: [],
|
|
2115
2161
|
isProcessing: !1,
|
|
2116
2162
|
error: s ? null : "Invalid agent configuration",
|
|
2117
2163
|
suggestions: [],
|
|
2118
2164
|
markdownComponents: {},
|
|
2119
|
-
markdownExtensions: {}
|
|
2120
|
-
currentAbortController: null
|
|
2165
|
+
markdownExtensions: {}
|
|
2121
2166
|
}), {
|
|
2122
|
-
registerMessageActions:
|
|
2123
|
-
unregisterMessageActions:
|
|
2167
|
+
registerMessageActions: o,
|
|
2168
|
+
unregisterMessageActions: r,
|
|
2124
2169
|
clearAllMessageActions: i,
|
|
2125
2170
|
createFeedbackActions: l,
|
|
2126
|
-
registrations:
|
|
2127
|
-
} =
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
}, [
|
|
2171
|
+
registrations: g
|
|
2172
|
+
} = Ne(), c = bt(g);
|
|
2173
|
+
X(() => {
|
|
2174
|
+
c.current = g;
|
|
2175
|
+
}, [g]), X(() => {
|
|
2131
2176
|
if (!s)
|
|
2132
2177
|
return;
|
|
2133
2178
|
(async () => {
|
|
2134
2179
|
if (e.sessionId) {
|
|
2135
|
-
const
|
|
2136
|
-
if (!
|
|
2137
|
-
await
|
|
2180
|
+
const p = ct(), m = `${e.agentId}-${e.sessionId}`;
|
|
2181
|
+
if (!p.hasAgent(m)) {
|
|
2182
|
+
await p.createAgent(m, {
|
|
2138
2183
|
agentId: e.agentId,
|
|
2139
2184
|
agentUrl: e.agentUrl,
|
|
2140
2185
|
sessionId: e.sessionId,
|
|
2141
|
-
contextProvider: t.contextProvider ||
|
|
2142
|
-
toolProvider: t.toolProvider ||
|
|
2186
|
+
contextProvider: t.contextProvider || De(),
|
|
2187
|
+
toolProvider: t.toolProvider || _e(),
|
|
2143
2188
|
authProvider: t.authProvider,
|
|
2144
2189
|
enableStreaming: t.enableStreaming
|
|
2145
2190
|
});
|
|
2146
|
-
const
|
|
2147
|
-
a((
|
|
2148
|
-
const
|
|
2149
|
-
(
|
|
2150
|
-
|
|
2151
|
-
|
|
2191
|
+
const w = p.getConversationHistory(m);
|
|
2192
|
+
a((b) => {
|
|
2193
|
+
const v = w.map(
|
|
2194
|
+
(d) => K(
|
|
2195
|
+
d,
|
|
2196
|
+
c.current
|
|
2152
2197
|
)
|
|
2153
2198
|
).filter(
|
|
2154
|
-
(
|
|
2199
|
+
(d) => d !== null
|
|
2155
2200
|
);
|
|
2156
2201
|
return {
|
|
2157
|
-
...
|
|
2158
|
-
clientMessages:
|
|
2159
|
-
uiMessages:
|
|
2202
|
+
...b,
|
|
2203
|
+
clientMessages: w,
|
|
2204
|
+
uiMessages: v
|
|
2160
2205
|
};
|
|
2161
2206
|
});
|
|
2162
2207
|
}
|
|
@@ -2172,309 +2217,306 @@ function Qe(t) {
|
|
|
2172
2217
|
t.enableStreaming,
|
|
2173
2218
|
s
|
|
2174
2219
|
]);
|
|
2175
|
-
const
|
|
2220
|
+
const f = F(
|
|
2176
2221
|
async (h) => {
|
|
2177
|
-
var
|
|
2222
|
+
var v;
|
|
2178
2223
|
if (!s)
|
|
2179
2224
|
throw new Error("Invalid agent configuration");
|
|
2180
|
-
const
|
|
2181
|
-
id: `user-${
|
|
2225
|
+
const p = ct(), m = `${e.agentId}-${e.sessionId}`, w = Date.now(), b = {
|
|
2226
|
+
id: `user-${w}`,
|
|
2182
2227
|
role: "user",
|
|
2183
2228
|
content: [{ type: "text", text: h }],
|
|
2184
|
-
timestamp:
|
|
2229
|
+
timestamp: w,
|
|
2185
2230
|
archived: !1,
|
|
2186
2231
|
showIcon: !1
|
|
2187
|
-
}
|
|
2188
|
-
a((
|
|
2189
|
-
...
|
|
2190
|
-
uiMessages: [...
|
|
2232
|
+
};
|
|
2233
|
+
a((d) => ({
|
|
2234
|
+
...d,
|
|
2235
|
+
uiMessages: [...d.uiMessages, b],
|
|
2191
2236
|
isProcessing: !0,
|
|
2192
|
-
error: null
|
|
2193
|
-
currentAbortController: P
|
|
2237
|
+
error: null
|
|
2194
2238
|
}));
|
|
2195
2239
|
try {
|
|
2196
|
-
let
|
|
2197
|
-
for await (const
|
|
2198
|
-
|
|
2199
|
-
h
|
|
2200
|
-
{
|
|
2201
|
-
abortSignal: P.signal
|
|
2202
|
-
}
|
|
2240
|
+
let d = null, C = !1;
|
|
2241
|
+
for await (const x of p.sendMessageStream(
|
|
2242
|
+
m,
|
|
2243
|
+
h
|
|
2203
2244
|
)) {
|
|
2204
|
-
if (!
|
|
2205
|
-
if (
|
|
2206
|
-
a((
|
|
2207
|
-
...
|
|
2208
|
-
uiMessages:
|
|
2209
|
-
(
|
|
2210
|
-
...
|
|
2245
|
+
if (!x.final && x.text)
|
|
2246
|
+
if (d)
|
|
2247
|
+
a((S) => ({
|
|
2248
|
+
...S,
|
|
2249
|
+
uiMessages: S.uiMessages.map(
|
|
2250
|
+
(E) => E.id === d ? {
|
|
2251
|
+
...E,
|
|
2211
2252
|
content: [
|
|
2212
2253
|
{
|
|
2213
2254
|
type: "text",
|
|
2214
|
-
text:
|
|
2255
|
+
text: x.text
|
|
2215
2256
|
}
|
|
2216
2257
|
]
|
|
2217
|
-
} :
|
|
2258
|
+
} : E
|
|
2218
2259
|
)
|
|
2219
2260
|
}));
|
|
2220
2261
|
else {
|
|
2221
|
-
|
|
2222
|
-
const
|
|
2223
|
-
id:
|
|
2262
|
+
d = `agent-streaming-${Date.now()}`;
|
|
2263
|
+
const S = {
|
|
2264
|
+
id: d,
|
|
2224
2265
|
role: "agent",
|
|
2225
2266
|
content: [
|
|
2226
|
-
{ type: "text", text:
|
|
2267
|
+
{ type: "text", text: x.text }
|
|
2227
2268
|
],
|
|
2228
2269
|
timestamp: Date.now(),
|
|
2229
2270
|
archived: !1,
|
|
2230
2271
|
showIcon: !0,
|
|
2231
2272
|
icon: "assistant"
|
|
2232
2273
|
};
|
|
2233
|
-
a((
|
|
2234
|
-
...
|
|
2274
|
+
a((E) => ({
|
|
2275
|
+
...E,
|
|
2235
2276
|
uiMessages: [
|
|
2236
|
-
...
|
|
2237
|
-
|
|
2277
|
+
...E.uiMessages,
|
|
2278
|
+
S
|
|
2238
2279
|
]
|
|
2239
2280
|
}));
|
|
2240
2281
|
}
|
|
2241
|
-
if (
|
|
2242
|
-
|
|
2243
|
-
const
|
|
2244
|
-
|
|
2245
|
-
|
|
2282
|
+
if (x.final && ((v = x.status) != null && v.message) && d) {
|
|
2283
|
+
C = !0;
|
|
2284
|
+
const S = d, E = K(
|
|
2285
|
+
x.status.message,
|
|
2286
|
+
c.current
|
|
2246
2287
|
);
|
|
2247
|
-
|
|
2248
|
-
const
|
|
2249
|
-
(
|
|
2250
|
-
),
|
|
2251
|
-
|
|
2288
|
+
E && a((N) => {
|
|
2289
|
+
const P = N.uiMessages.map(
|
|
2290
|
+
(j) => j.id === S ? E : j
|
|
2291
|
+
), R = p.getConversationHistory(
|
|
2292
|
+
m
|
|
2252
2293
|
);
|
|
2253
2294
|
return {
|
|
2254
|
-
...
|
|
2255
|
-
clientMessages:
|
|
2256
|
-
uiMessages:
|
|
2257
|
-
isProcessing: !1
|
|
2258
|
-
currentAbortController: null
|
|
2295
|
+
...N,
|
|
2296
|
+
clientMessages: R,
|
|
2297
|
+
uiMessages: P,
|
|
2298
|
+
isProcessing: !1
|
|
2259
2299
|
};
|
|
2260
|
-
}),
|
|
2300
|
+
}), d = null;
|
|
2261
2301
|
}
|
|
2262
2302
|
}
|
|
2263
|
-
if (!
|
|
2264
|
-
const
|
|
2265
|
-
a((
|
|
2266
|
-
let
|
|
2267
|
-
|
|
2268
|
-
(_) => _.id !==
|
|
2303
|
+
if (!C) {
|
|
2304
|
+
const x = p.getConversationHistory(m);
|
|
2305
|
+
a((S) => {
|
|
2306
|
+
let E = S.uiMessages;
|
|
2307
|
+
d && (E = S.uiMessages.filter(
|
|
2308
|
+
(_) => _.id !== d
|
|
2269
2309
|
));
|
|
2270
|
-
const
|
|
2271
|
-
(_) =>
|
|
2310
|
+
const N = x.map(
|
|
2311
|
+
(_) => K(
|
|
2272
2312
|
_,
|
|
2273
|
-
|
|
2313
|
+
c.current
|
|
2274
2314
|
)
|
|
2275
2315
|
).filter(
|
|
2276
2316
|
(_) => _ !== null
|
|
2277
|
-
),
|
|
2278
|
-
|
|
2279
|
-
),
|
|
2317
|
+
), P = new Set(
|
|
2318
|
+
x.map((_) => _.messageId)
|
|
2319
|
+
), R = E.filter(
|
|
2280
2320
|
(_) => {
|
|
2281
|
-
var
|
|
2282
|
-
return !
|
|
2321
|
+
var W;
|
|
2322
|
+
return !P.has(_.id) && ((W = _.content[0]) == null ? void 0 : W.type) === "component";
|
|
2283
2323
|
}
|
|
2284
|
-
),
|
|
2285
|
-
...
|
|
2286
|
-
...
|
|
2324
|
+
), j = G([
|
|
2325
|
+
...N,
|
|
2326
|
+
...R
|
|
2287
2327
|
]);
|
|
2288
2328
|
return {
|
|
2289
|
-
...
|
|
2290
|
-
clientMessages:
|
|
2291
|
-
uiMessages:
|
|
2292
|
-
isProcessing: !1
|
|
2293
|
-
currentAbortController: null
|
|
2329
|
+
...S,
|
|
2330
|
+
clientMessages: x,
|
|
2331
|
+
uiMessages: j,
|
|
2332
|
+
isProcessing: !1
|
|
2294
2333
|
};
|
|
2295
2334
|
});
|
|
2296
2335
|
}
|
|
2297
|
-
} catch (
|
|
2298
|
-
if (
|
|
2299
|
-
console.log("Request was aborted by user"), a((
|
|
2300
|
-
...
|
|
2336
|
+
} catch (d) {
|
|
2337
|
+
if (d instanceof Error && d.name === "AbortError") {
|
|
2338
|
+
console.log("Request was aborted by user"), a((x) => ({
|
|
2339
|
+
...x,
|
|
2301
2340
|
isProcessing: !1,
|
|
2302
|
-
error: null
|
|
2341
|
+
error: null
|
|
2303
2342
|
// Don't show error for user-initiated abort
|
|
2304
|
-
currentAbortController: null
|
|
2305
2343
|
}));
|
|
2306
2344
|
return;
|
|
2307
2345
|
}
|
|
2308
|
-
const
|
|
2309
|
-
throw a((
|
|
2310
|
-
...
|
|
2346
|
+
const C = d instanceof Error ? d.message : "Failed to send message";
|
|
2347
|
+
throw a((x) => ({
|
|
2348
|
+
...x,
|
|
2311
2349
|
isProcessing: !1,
|
|
2312
|
-
error:
|
|
2313
|
-
|
|
2314
|
-
})), m;
|
|
2350
|
+
error: C
|
|
2351
|
+
})), d;
|
|
2315
2352
|
}
|
|
2316
2353
|
},
|
|
2317
2354
|
[e.agentId, e.sessionId, s]
|
|
2318
|
-
),
|
|
2319
|
-
a((
|
|
2320
|
-
...
|
|
2321
|
-
uiMessages:
|
|
2355
|
+
), I = F((h) => {
|
|
2356
|
+
a((p) => ({
|
|
2357
|
+
...p,
|
|
2358
|
+
uiMessages: G([...p.uiMessages, h])
|
|
2322
2359
|
}));
|
|
2323
|
-
}, []),
|
|
2324
|
-
a((
|
|
2325
|
-
...
|
|
2360
|
+
}, []), k = F((h) => {
|
|
2361
|
+
a((p) => ({
|
|
2362
|
+
...p,
|
|
2326
2363
|
suggestions: h
|
|
2327
2364
|
}));
|
|
2328
|
-
}, []),
|
|
2365
|
+
}, []), A = F(() => {
|
|
2329
2366
|
a((h) => ({
|
|
2330
2367
|
...h,
|
|
2331
2368
|
suggestions: []
|
|
2332
2369
|
}));
|
|
2333
|
-
}, []),
|
|
2370
|
+
}, []), T = F(
|
|
2334
2371
|
(h) => {
|
|
2335
|
-
a((
|
|
2336
|
-
const
|
|
2337
|
-
...
|
|
2372
|
+
a((p) => {
|
|
2373
|
+
const m = {
|
|
2374
|
+
...p.markdownComponents,
|
|
2338
2375
|
...h
|
|
2339
|
-
},
|
|
2340
|
-
(
|
|
2341
|
-
|
|
2342
|
-
|
|
2376
|
+
}, w = p.clientMessages.map(
|
|
2377
|
+
(C) => K(
|
|
2378
|
+
C,
|
|
2379
|
+
c.current
|
|
2343
2380
|
)
|
|
2344
|
-
).filter((
|
|
2345
|
-
|
|
2346
|
-
),
|
|
2347
|
-
(
|
|
2348
|
-
var
|
|
2349
|
-
return !
|
|
2381
|
+
).filter((C) => C !== null), b = new Set(
|
|
2382
|
+
p.clientMessages.map((C) => C.messageId)
|
|
2383
|
+
), v = p.uiMessages.filter(
|
|
2384
|
+
(C) => {
|
|
2385
|
+
var x;
|
|
2386
|
+
return !b.has(C.id) && ((x = C.content[0]) == null ? void 0 : x.type) === "component";
|
|
2350
2387
|
}
|
|
2351
|
-
),
|
|
2352
|
-
...
|
|
2353
|
-
...
|
|
2388
|
+
), d = G([
|
|
2389
|
+
...w,
|
|
2390
|
+
...v
|
|
2354
2391
|
]);
|
|
2355
2392
|
return {
|
|
2356
|
-
...
|
|
2357
|
-
markdownComponents:
|
|
2358
|
-
uiMessages:
|
|
2393
|
+
...p,
|
|
2394
|
+
markdownComponents: m,
|
|
2395
|
+
uiMessages: d
|
|
2359
2396
|
};
|
|
2360
2397
|
});
|
|
2361
2398
|
},
|
|
2362
2399
|
[]
|
|
2363
|
-
),
|
|
2400
|
+
), M = F(
|
|
2364
2401
|
(h) => {
|
|
2365
|
-
a((
|
|
2366
|
-
const
|
|
2367
|
-
...
|
|
2402
|
+
a((p) => {
|
|
2403
|
+
const m = {
|
|
2404
|
+
...p.markdownExtensions,
|
|
2368
2405
|
...h
|
|
2369
|
-
},
|
|
2370
|
-
(
|
|
2371
|
-
|
|
2372
|
-
|
|
2406
|
+
}, w = p.clientMessages.map(
|
|
2407
|
+
(C) => K(
|
|
2408
|
+
C,
|
|
2409
|
+
c.current
|
|
2373
2410
|
)
|
|
2374
|
-
).filter((
|
|
2375
|
-
|
|
2376
|
-
),
|
|
2377
|
-
(
|
|
2378
|
-
var
|
|
2379
|
-
return !
|
|
2411
|
+
).filter((C) => C !== null), b = new Set(
|
|
2412
|
+
p.clientMessages.map((C) => C.messageId)
|
|
2413
|
+
), v = p.uiMessages.filter(
|
|
2414
|
+
(C) => {
|
|
2415
|
+
var x;
|
|
2416
|
+
return !b.has(C.id) && ((x = C.content[0]) == null ? void 0 : x.type) === "component";
|
|
2380
2417
|
}
|
|
2381
|
-
),
|
|
2382
|
-
...
|
|
2383
|
-
...
|
|
2418
|
+
), d = G([
|
|
2419
|
+
...w,
|
|
2420
|
+
...v
|
|
2384
2421
|
]);
|
|
2385
2422
|
return {
|
|
2386
|
-
...
|
|
2387
|
-
markdownExtensions:
|
|
2388
|
-
uiMessages:
|
|
2423
|
+
...p,
|
|
2424
|
+
markdownExtensions: m,
|
|
2425
|
+
uiMessages: d
|
|
2389
2426
|
};
|
|
2390
2427
|
});
|
|
2391
2428
|
},
|
|
2392
2429
|
[]
|
|
2393
2430
|
);
|
|
2394
|
-
|
|
2431
|
+
X(() => {
|
|
2395
2432
|
a((h) => {
|
|
2396
2433
|
if (h.clientMessages.length === 0)
|
|
2397
2434
|
return h;
|
|
2398
|
-
const
|
|
2399
|
-
(
|
|
2400
|
-
).filter((
|
|
2401
|
-
h.clientMessages.map((
|
|
2402
|
-
),
|
|
2403
|
-
(
|
|
2404
|
-
var
|
|
2405
|
-
return !
|
|
2435
|
+
const p = h.clientMessages.map(
|
|
2436
|
+
(b) => K(b, c.current)
|
|
2437
|
+
).filter((b) => b !== null), m = new Set(
|
|
2438
|
+
h.clientMessages.map((b) => b.messageId)
|
|
2439
|
+
), w = h.uiMessages.filter(
|
|
2440
|
+
(b) => {
|
|
2441
|
+
var v;
|
|
2442
|
+
return !m.has(b.id) && ((v = b.content[0]) == null ? void 0 : v.type) === "component";
|
|
2406
2443
|
}
|
|
2407
2444
|
);
|
|
2408
2445
|
return {
|
|
2409
2446
|
...h,
|
|
2410
|
-
uiMessages:
|
|
2411
|
-
...
|
|
2412
|
-
...
|
|
2447
|
+
uiMessages: G([
|
|
2448
|
+
...p,
|
|
2449
|
+
...w
|
|
2413
2450
|
])
|
|
2414
2451
|
};
|
|
2415
2452
|
});
|
|
2416
|
-
}, [
|
|
2417
|
-
const
|
|
2418
|
-
|
|
2419
|
-
|
|
2420
|
-
|
|
2421
|
-
|
|
2422
|
-
|
|
2423
|
-
|
|
2424
|
-
|
|
2425
|
-
|
|
2453
|
+
}, [g]);
|
|
2454
|
+
const y = dt(() => Pe({
|
|
2455
|
+
components: n.markdownComponents,
|
|
2456
|
+
extensions: n.markdownExtensions,
|
|
2457
|
+
enableStreaming: t == null ? void 0 : t.enableStreaming
|
|
2458
|
+
}), [
|
|
2459
|
+
n.markdownComponents,
|
|
2460
|
+
n.markdownExtensions,
|
|
2461
|
+
t == null ? void 0 : t.enableStreaming
|
|
2462
|
+
]), u = F(() => {
|
|
2463
|
+
if (!s)
|
|
2464
|
+
return;
|
|
2465
|
+
const h = ct(), p = `${e.agentId}-${e.sessionId}`;
|
|
2466
|
+
h.abortCurrentRequest(p);
|
|
2467
|
+
}, [e.agentId, e.sessionId, s]);
|
|
2426
2468
|
return {
|
|
2427
2469
|
// AgentUI props
|
|
2428
2470
|
messages: n.uiMessages,
|
|
2429
2471
|
isProcessing: n.isProcessing,
|
|
2430
2472
|
error: n.error,
|
|
2431
|
-
onSubmit:
|
|
2473
|
+
onSubmit: f,
|
|
2432
2474
|
suggestions: n.suggestions,
|
|
2433
|
-
messageRenderer:
|
|
2475
|
+
messageRenderer: y,
|
|
2434
2476
|
// UI management methods
|
|
2435
|
-
registerSuggestions:
|
|
2436
|
-
clearSuggestions:
|
|
2437
|
-
registerMarkdownComponents:
|
|
2438
|
-
registerMarkdownExtensions:
|
|
2477
|
+
registerSuggestions: k,
|
|
2478
|
+
clearSuggestions: A,
|
|
2479
|
+
registerMarkdownComponents: T,
|
|
2480
|
+
registerMarkdownExtensions: M,
|
|
2439
2481
|
// Message actions methods
|
|
2440
|
-
registerMessageActions:
|
|
2441
|
-
unregisterMessageActions:
|
|
2482
|
+
registerMessageActions: o,
|
|
2483
|
+
unregisterMessageActions: r,
|
|
2442
2484
|
clearAllMessageActions: i,
|
|
2443
2485
|
createFeedbackActions: l,
|
|
2444
2486
|
// Tool integration
|
|
2445
|
-
addMessage:
|
|
2487
|
+
addMessage: I,
|
|
2446
2488
|
// Abort control
|
|
2447
2489
|
abortCurrentRequest: u
|
|
2448
2490
|
};
|
|
2449
2491
|
}
|
|
2450
|
-
var
|
|
2451
|
-
const
|
|
2452
|
-
function
|
|
2492
|
+
var Fe = /* @__PURE__ */ ((t) => (t[t.PARSE_ERROR = -32700] = "PARSE_ERROR", t[t.INVALID_REQUEST = -32600] = "INVALID_REQUEST", t[t.METHOD_NOT_FOUND = -32601] = "METHOD_NOT_FOUND", t[t.INVALID_PARAMS = -32602] = "INVALID_PARAMS", t[t.INTERNAL_ERROR = -32603] = "INTERNAL_ERROR", t[t.SERVER_ERROR = -32e3] = "SERVER_ERROR", t))(Fe || {});
|
|
2493
|
+
const Mt = "jetpack-ai-jwt-token", qe = 30 * 60 * 1e3;
|
|
2494
|
+
function He() {
|
|
2453
2495
|
var s;
|
|
2454
2496
|
return window.JP_CONNECTION_INITIAL_STATE ? !1 : !!((s = window.Jetpack_Editor_Initial_State) != null && s.wpcomBlogId);
|
|
2455
2497
|
}
|
|
2456
|
-
async function
|
|
2457
|
-
var l,
|
|
2458
|
-
const s = localStorage.getItem(
|
|
2498
|
+
async function Ue(t, e = !0) {
|
|
2499
|
+
var l, g;
|
|
2500
|
+
const s = localStorage.getItem(Mt);
|
|
2459
2501
|
let n;
|
|
2460
2502
|
if (s)
|
|
2461
2503
|
try {
|
|
2462
2504
|
n = JSON.parse(s);
|
|
2463
|
-
} catch (
|
|
2464
|
-
console.warn("Invalid cached Jetpack token:",
|
|
2505
|
+
} catch (c) {
|
|
2506
|
+
console.warn("Invalid cached Jetpack token:", c);
|
|
2465
2507
|
}
|
|
2466
2508
|
if (n && (n != null && n.token) && (n != null && n.expire) && (n == null ? void 0 : n.expire) > Date.now() && e)
|
|
2467
2509
|
return n;
|
|
2468
|
-
const a = (l = window.JP_CONNECTION_INITIAL_STATE) == null ? void 0 : l.apiNonce,
|
|
2469
|
-
let
|
|
2510
|
+
const a = (l = window.JP_CONNECTION_INITIAL_STATE) == null ? void 0 : l.apiNonce, o = (g = window.Jetpack_Editor_Initial_State) == null ? void 0 : g.wpcomBlogId;
|
|
2511
|
+
let r = {
|
|
2470
2512
|
token: "",
|
|
2471
2513
|
blog_id: ""
|
|
2472
2514
|
};
|
|
2473
2515
|
try {
|
|
2474
|
-
|
|
2475
|
-
path: "/wpcom/v2/sites/" +
|
|
2516
|
+
He() ? r = await yt({
|
|
2517
|
+
path: "/wpcom/v2/sites/" + o + "/jetpack-openai-query/jwt",
|
|
2476
2518
|
method: "POST"
|
|
2477
|
-
}) :
|
|
2519
|
+
}) : r = await yt({
|
|
2478
2520
|
path: "/jetpack/v4/jetpack-ai-jwt?_cacheBuster=" + Date.now(),
|
|
2479
2521
|
credentials: "same-origin",
|
|
2480
2522
|
headers: {
|
|
@@ -2482,29 +2524,29 @@ async function Fe(t, e = !0) {
|
|
|
2482
2524
|
},
|
|
2483
2525
|
method: "POST"
|
|
2484
2526
|
});
|
|
2485
|
-
} catch (
|
|
2486
|
-
throw console.log("Failed to fetch Jetpack token:",
|
|
2527
|
+
} catch (c) {
|
|
2528
|
+
throw console.log("Failed to fetch Jetpack token:", c), new Error(t(c));
|
|
2487
2529
|
}
|
|
2488
|
-
if (!(
|
|
2530
|
+
if (!(r != null && r.token))
|
|
2489
2531
|
throw new Error(
|
|
2490
2532
|
"Authentication failed. Please ensure Jetpack is properly connected and try again."
|
|
2491
2533
|
);
|
|
2492
2534
|
const i = {
|
|
2493
|
-
token:
|
|
2494
|
-
blogId:
|
|
2495
|
-
expire: Date.now() +
|
|
2535
|
+
token: r.token,
|
|
2536
|
+
blogId: r.blog_id || "",
|
|
2537
|
+
expire: Date.now() + qe
|
|
2496
2538
|
};
|
|
2497
2539
|
try {
|
|
2498
|
-
localStorage.setItem(
|
|
2499
|
-
} catch (
|
|
2500
|
-
console.log("Error storing token in localStorage:",
|
|
2540
|
+
localStorage.setItem(Mt, JSON.stringify(i));
|
|
2541
|
+
} catch (c) {
|
|
2542
|
+
console.log("Error storing token in localStorage:", c);
|
|
2501
2543
|
}
|
|
2502
2544
|
return i;
|
|
2503
2545
|
}
|
|
2504
|
-
const
|
|
2546
|
+
const ts = (t) => async () => {
|
|
2505
2547
|
const e = {};
|
|
2506
2548
|
try {
|
|
2507
|
-
const s = await
|
|
2549
|
+
const s = await Ue(t);
|
|
2508
2550
|
s != null && s.token && (e.Authorization = `${s.token}`);
|
|
2509
2551
|
} catch (s) {
|
|
2510
2552
|
throw console.error("Failed to get Jetpack token for auth:", s), s;
|
|
@@ -2512,23 +2554,23 @@ const Xe = (t) => async () => {
|
|
|
2512
2554
|
return e;
|
|
2513
2555
|
};
|
|
2514
2556
|
export {
|
|
2515
|
-
|
|
2516
|
-
|
|
2517
|
-
|
|
2518
|
-
|
|
2519
|
-
|
|
2520
|
-
|
|
2521
|
-
|
|
2522
|
-
|
|
2523
|
-
|
|
2524
|
-
|
|
2525
|
-
|
|
2526
|
-
|
|
2557
|
+
Fe as A2AErrorCodes,
|
|
2558
|
+
Ut as BarChart,
|
|
2559
|
+
ke as ChartBlock,
|
|
2560
|
+
Se as LineChart,
|
|
2561
|
+
Ye as createAbortController,
|
|
2562
|
+
ge as createClient,
|
|
2563
|
+
Oe as createFeedbackActions,
|
|
2564
|
+
ts as createJetpackAuthProvider,
|
|
2565
|
+
Pe as createMessageRenderer,
|
|
2566
|
+
Kt as createRequestId,
|
|
2567
|
+
Vt as createTaskId,
|
|
2568
|
+
ut as createTextMessage,
|
|
2527
2569
|
U as extractTextFromMessage,
|
|
2528
|
-
|
|
2529
|
-
|
|
2530
|
-
|
|
2531
|
-
|
|
2532
|
-
|
|
2533
|
-
|
|
2570
|
+
B as extractToolCallsFromMessage,
|
|
2571
|
+
ct as getAgentManager,
|
|
2572
|
+
Ze as useAgentChat,
|
|
2573
|
+
Qe as useClientContext,
|
|
2574
|
+
Xe as useClientTools,
|
|
2575
|
+
Ne as useMessageActions
|
|
2534
2576
|
};
|