@fencyai/react 0.1.153 → 0.1.155
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agent-task/AgentTaskProgressSimple.d.ts.map +1 -1
- package/dist/agent-task/AgentTaskProgressVerbose.d.ts.map +1 -1
- package/dist/agent-task/data-types/MemorySearchCompletedResults.d.ts.map +1 -1
- package/dist/agent-task/data-types/StructuredChatCompletionJson.d.ts +1 -1
- package/dist/agent-task/data-types/StructuredChatCompletionJson.d.ts.map +1 -1
- package/dist/agent-task/data-types/mergeOverlappingChunkContents.d.ts +9 -0
- package/dist/agent-task/data-types/mergeOverlappingChunkContents.d.ts.map +1 -0
- package/dist/hooks/useAgentTasks/index.d.ts.map +1 -1
- package/dist/index.js +354 -307
- package/dist/types/CreateAgentTaskParams.d.ts +7 -3
- package/dist/types/CreateAgentTaskParams.d.ts.map +1 -1
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -17,13 +17,13 @@ async function le(e, t) {
|
|
|
17
17
|
function ce(e) {
|
|
18
18
|
let t, n, r, l = !1;
|
|
19
19
|
return function(a) {
|
|
20
|
-
t === void 0 ? (t = a, n = 0, r = -1) : t =
|
|
21
|
-
const
|
|
20
|
+
t === void 0 ? (t = a, n = 0, r = -1) : t = ue(t, a);
|
|
21
|
+
const u = t.length;
|
|
22
22
|
let d = 0;
|
|
23
|
-
for (; n <
|
|
23
|
+
for (; n < u; ) {
|
|
24
24
|
l && (t[n] === 10 && (d = ++n), l = !1);
|
|
25
25
|
let o = -1;
|
|
26
|
-
for (; n <
|
|
26
|
+
for (; n < u && o === -1; ++n)
|
|
27
27
|
switch (t[n]) {
|
|
28
28
|
case 58:
|
|
29
29
|
r === -1 && (r = n - d);
|
|
@@ -38,17 +38,17 @@ function ce(e) {
|
|
|
38
38
|
break;
|
|
39
39
|
e(t.subarray(d, o), r), d = n, r = -1;
|
|
40
40
|
}
|
|
41
|
-
d ===
|
|
41
|
+
d === u ? t = void 0 : d !== 0 && (t = t.subarray(d), n -= d);
|
|
42
42
|
};
|
|
43
43
|
}
|
|
44
44
|
function de(e, t, n) {
|
|
45
|
-
let r =
|
|
45
|
+
let r = H();
|
|
46
46
|
const l = new TextDecoder();
|
|
47
|
-
return function(a,
|
|
47
|
+
return function(a, u) {
|
|
48
48
|
if (a.length === 0)
|
|
49
|
-
n == null || n(r), r =
|
|
50
|
-
else if (
|
|
51
|
-
const d = l.decode(a.subarray(0,
|
|
49
|
+
n == null || n(r), r = H();
|
|
50
|
+
else if (u > 0) {
|
|
51
|
+
const d = l.decode(a.subarray(0, u)), o = u + (a[u + 1] === 32 ? 2 : 1), c = l.decode(a.subarray(o));
|
|
52
52
|
switch (d) {
|
|
53
53
|
case "data":
|
|
54
54
|
r.data = r.data ? r.data + `
|
|
@@ -61,18 +61,18 @@ function de(e, t, n) {
|
|
|
61
61
|
e(r.id = c);
|
|
62
62
|
break;
|
|
63
63
|
case "retry":
|
|
64
|
-
const
|
|
65
|
-
isNaN(
|
|
64
|
+
const m = parseInt(c, 10);
|
|
65
|
+
isNaN(m) || t(r.retry = m);
|
|
66
66
|
break;
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
69
|
};
|
|
70
70
|
}
|
|
71
|
-
function
|
|
71
|
+
function ue(e, t) {
|
|
72
72
|
const n = new Uint8Array(e.length + t.length);
|
|
73
73
|
return n.set(e), n.set(t, e.length), n;
|
|
74
74
|
}
|
|
75
|
-
function
|
|
75
|
+
function H() {
|
|
76
76
|
return {
|
|
77
77
|
data: "",
|
|
78
78
|
event: "",
|
|
@@ -80,7 +80,7 @@ function N() {
|
|
|
80
80
|
retry: void 0
|
|
81
81
|
};
|
|
82
82
|
}
|
|
83
|
-
var
|
|
83
|
+
var me = function(e, t) {
|
|
84
84
|
var n = {};
|
|
85
85
|
for (var r in e) Object.prototype.hasOwnProperty.call(e, r) && t.indexOf(r) < 0 && (n[r] = e[r]);
|
|
86
86
|
if (e != null && typeof Object.getOwnPropertySymbols == "function")
|
|
@@ -88,49 +88,49 @@ var ue = function(e, t) {
|
|
|
88
88
|
t.indexOf(r[l]) < 0 && Object.prototype.propertyIsEnumerable.call(e, r[l]) && (n[r[l]] = e[r[l]]);
|
|
89
89
|
return n;
|
|
90
90
|
};
|
|
91
|
-
const $ = "text/event-stream", ge = 1e3,
|
|
92
|
-
function
|
|
93
|
-
var { signal: n, headers: r, onopen: l, onmessage: s, onclose: a, onerror:
|
|
94
|
-
return new Promise((
|
|
91
|
+
const $ = "text/event-stream", ge = 1e3, N = "last-event-id";
|
|
92
|
+
function pe(e, t) {
|
|
93
|
+
var { signal: n, headers: r, onopen: l, onmessage: s, onclose: a, onerror: u, openWhenHidden: d, fetch: o } = t, c = me(t, ["signal", "headers", "onopen", "onmessage", "onclose", "onerror", "openWhenHidden", "fetch"]);
|
|
94
|
+
return new Promise((m, g) => {
|
|
95
95
|
const h = Object.assign({}, r);
|
|
96
96
|
h.accept || (h.accept = $);
|
|
97
|
-
let
|
|
97
|
+
let y;
|
|
98
98
|
function T() {
|
|
99
|
-
|
|
99
|
+
y.abort(), document.hidden || w();
|
|
100
100
|
}
|
|
101
101
|
d || document.addEventListener("visibilitychange", T);
|
|
102
|
-
let
|
|
102
|
+
let p = ge, x = 0;
|
|
103
103
|
function b() {
|
|
104
|
-
document.removeEventListener("visibilitychange", T), window.clearTimeout(x),
|
|
104
|
+
document.removeEventListener("visibilitychange", T), window.clearTimeout(x), y.abort();
|
|
105
105
|
}
|
|
106
106
|
n == null || n.addEventListener("abort", () => {
|
|
107
|
-
b(),
|
|
107
|
+
b(), m();
|
|
108
108
|
});
|
|
109
|
-
const I = o ?? window.fetch, C = l ??
|
|
109
|
+
const I = o ?? window.fetch, C = l ?? ye;
|
|
110
110
|
async function w() {
|
|
111
111
|
var R;
|
|
112
|
-
|
|
112
|
+
y = new AbortController();
|
|
113
113
|
try {
|
|
114
|
-
const D = await I(e, Object.assign(Object.assign({}, c), { headers: h, signal:
|
|
114
|
+
const D = await I(e, Object.assign(Object.assign({}, c), { headers: h, signal: y.signal }));
|
|
115
115
|
await C(D), await le(D.body, ce(de((M) => {
|
|
116
|
-
M ? h[
|
|
116
|
+
M ? h[N] = M : delete h[N];
|
|
117
117
|
}, (M) => {
|
|
118
|
-
|
|
119
|
-
}, s))), a == null || a(), b(),
|
|
118
|
+
p = M;
|
|
119
|
+
}, s))), a == null || a(), b(), m();
|
|
120
120
|
} catch (D) {
|
|
121
|
-
if (!
|
|
121
|
+
if (!y.signal.aborted)
|
|
122
122
|
try {
|
|
123
|
-
const M = (R =
|
|
123
|
+
const M = (R = u == null ? void 0 : u(D)) !== null && R !== void 0 ? R : p;
|
|
124
124
|
window.clearTimeout(x), x = window.setTimeout(w, M);
|
|
125
125
|
} catch (M) {
|
|
126
|
-
b(),
|
|
126
|
+
b(), g(M);
|
|
127
127
|
}
|
|
128
128
|
}
|
|
129
129
|
}
|
|
130
130
|
w();
|
|
131
131
|
});
|
|
132
132
|
}
|
|
133
|
-
function
|
|
133
|
+
function ye(e) {
|
|
134
134
|
const t = e.headers.get("content-type");
|
|
135
135
|
if (!(t != null && t.startsWith($)))
|
|
136
136
|
throw new Error(`Expected content-type to be ${$}, Actual: ${t}`);
|
|
@@ -166,7 +166,7 @@ class fe {
|
|
|
166
166
|
"X-Fency-Publishable-Key": this.fency.publishableKey,
|
|
167
167
|
"X-Fency-Stream-Token": t.stream.token
|
|
168
168
|
};
|
|
169
|
-
|
|
169
|
+
pe(l, {
|
|
170
170
|
headers: s,
|
|
171
171
|
signal: r.signal,
|
|
172
172
|
async onopen(a) {
|
|
@@ -175,8 +175,8 @@ class fe {
|
|
|
175
175
|
},
|
|
176
176
|
onmessage: (a) => {
|
|
177
177
|
if (a.data) {
|
|
178
|
-
const
|
|
179
|
-
this.broadcast(
|
|
178
|
+
const u = he(a.data);
|
|
179
|
+
this.broadcast(u, n);
|
|
180
180
|
}
|
|
181
181
|
},
|
|
182
182
|
onerror: (a) => {
|
|
@@ -216,30 +216,30 @@ const Se = 12e4, Te = (e) => {
|
|
|
216
216
|
const t = Date.now();
|
|
217
217
|
return e.filter((n) => t - n.createdAt < Se);
|
|
218
218
|
};
|
|
219
|
-
function
|
|
219
|
+
function ut({ fency: e, fetchCreateStreamClientToken: t, children: n }) {
|
|
220
220
|
const [r, l] = v(
|
|
221
221
|
null
|
|
222
|
-
), [s, a] = v(!0), [
|
|
222
|
+
), [s, a] = v(!0), [u, d] = v(null), [o, c] = v([]), m = F(null), g = F(null);
|
|
223
223
|
A(() => {
|
|
224
|
-
e.then((
|
|
225
|
-
l(
|
|
226
|
-
}).catch((
|
|
227
|
-
d(
|
|
224
|
+
e.then((p) => {
|
|
225
|
+
l(p), a(!1);
|
|
226
|
+
}).catch((p) => {
|
|
227
|
+
d(p), a(!1);
|
|
228
228
|
});
|
|
229
229
|
}, [e]), A(() => {
|
|
230
|
-
r && !
|
|
230
|
+
r && !g.current && (g.current = new fe(r));
|
|
231
231
|
}, [r]), A(() => {
|
|
232
|
-
|
|
232
|
+
g.current && g.current.updateStreams(o);
|
|
233
233
|
}, [o]), A(() => () => {
|
|
234
|
-
var
|
|
235
|
-
(
|
|
234
|
+
var p;
|
|
235
|
+
(p = g.current) == null || p.cleanup();
|
|
236
236
|
}, []);
|
|
237
237
|
const h = K(
|
|
238
|
-
async (
|
|
239
|
-
if (
|
|
240
|
-
return
|
|
238
|
+
async (p = 3e4) => {
|
|
239
|
+
if (m.current)
|
|
240
|
+
return m.current;
|
|
241
241
|
const x = Date.now(), b = o.length > 0 ? o[o.length - 1] : null;
|
|
242
|
-
if (b && x - b.createdAt <
|
|
242
|
+
if (b && x - b.createdAt < p)
|
|
243
243
|
return b.stream;
|
|
244
244
|
const I = (async () => {
|
|
245
245
|
if (!r)
|
|
@@ -257,33 +257,33 @@ function at({ fency: e, fetchCreateStreamClientToken: t, children: n }) {
|
|
|
257
257
|
return c((D) => {
|
|
258
258
|
const M = [...D, R];
|
|
259
259
|
return Te(M);
|
|
260
|
-
}),
|
|
260
|
+
}), m.current = null, w.stream;
|
|
261
261
|
} else
|
|
262
|
-
throw
|
|
262
|
+
throw m.current = null, new Error("Failed to create stream");
|
|
263
263
|
})();
|
|
264
|
-
return
|
|
264
|
+
return m.current = I, I;
|
|
265
265
|
},
|
|
266
266
|
[r, o]
|
|
267
267
|
);
|
|
268
|
-
if (
|
|
268
|
+
if (u)
|
|
269
269
|
return /* @__PURE__ */ f("div", { children: [
|
|
270
270
|
"Fency error: ",
|
|
271
|
-
|
|
271
|
+
u.message
|
|
272
272
|
] });
|
|
273
273
|
if (!r)
|
|
274
274
|
return null;
|
|
275
|
-
const
|
|
275
|
+
const y = o.length > 0 ? o[o.length - 1] : null, T = {
|
|
276
276
|
fency: r,
|
|
277
277
|
loading: s,
|
|
278
|
-
error:
|
|
278
|
+
error: u,
|
|
279
279
|
activeStreams: o,
|
|
280
|
-
latestStream:
|
|
281
|
-
eventManager:
|
|
280
|
+
latestStream: y,
|
|
281
|
+
eventManager: g.current,
|
|
282
282
|
getOrCreateStream: h
|
|
283
283
|
};
|
|
284
284
|
return /* @__PURE__ */ i(X.Provider, { value: T, children: n });
|
|
285
285
|
}
|
|
286
|
-
function
|
|
286
|
+
function V() {
|
|
287
287
|
const e = oe(X);
|
|
288
288
|
if (e === void 0)
|
|
289
289
|
throw new Error("useFencyContext must be used within a FencyProvider");
|
|
@@ -313,20 +313,20 @@ const xe = (e) => {
|
|
|
313
313
|
createdAt: e.createdAt,
|
|
314
314
|
data: JSON.parse(e.data)
|
|
315
315
|
}), Me = (e) => {
|
|
316
|
-
const t =
|
|
316
|
+
const t = V(), [n, r] = v(null), l = F(`subscriber-${Math.random().toString(36).substr(2, 9)}`);
|
|
317
317
|
return A(() => {
|
|
318
318
|
if (!t.eventManager) return;
|
|
319
319
|
const a = {
|
|
320
320
|
onMessage: (d, o) => {
|
|
321
|
-
var
|
|
321
|
+
var m, g, h;
|
|
322
322
|
const c = xe(d);
|
|
323
323
|
if (c)
|
|
324
324
|
switch (c.type) {
|
|
325
325
|
case "STREAM_TIMEOUT":
|
|
326
|
-
(
|
|
326
|
+
(m = e == null ? void 0 : e.onStreamTimeout) == null || m.call(e, c);
|
|
327
327
|
break;
|
|
328
328
|
case "STREAM_NOT_FOUND":
|
|
329
|
-
(
|
|
329
|
+
(g = e == null ? void 0 : e.onStreamNotFound) == null || g.call(e, c);
|
|
330
330
|
break;
|
|
331
331
|
case "AGENT_TASK_PROGRESS_ITEM_UPDATED":
|
|
332
332
|
(h = e == null ? void 0 : e.onAgentTaskProgressItemUpdated) == null || h.call(e, c);
|
|
@@ -368,68 +368,68 @@ const xe = (e) => {
|
|
|
368
368
|
},
|
|
369
369
|
stream: n
|
|
370
370
|
};
|
|
371
|
-
},
|
|
372
|
-
const t =
|
|
371
|
+
}, mt = (e) => {
|
|
372
|
+
const t = V(), [n, r] = v([]), l = F(/* @__PURE__ */ new Set()), s = F(/* @__PURE__ */ new Map()), { createStream: a } = Me({
|
|
373
373
|
onAgentTaskProgressItemUpdated: (o) => {
|
|
374
|
-
var
|
|
374
|
+
var g;
|
|
375
375
|
if (!l.current.has(o.agentTaskId)) return;
|
|
376
376
|
const c = o.data;
|
|
377
377
|
if (c.taskType === "StreamingChatCompletion" && c.eventType === "Completed" || c.taskType === "StructuredChatCompletion" && c.eventType === "Completed" || c.taskType === "MemoryChatCompletion" && c.eventType === "Completed" || c.taskType === "MemorySearch" && c.eventType === "Completed") {
|
|
378
|
-
const h = c.taskType === "MemorySearch" && c.eventType === "Completed";
|
|
378
|
+
const h = c.taskType === "MemorySearch" && c.eventType === "Completed" || c.taskType === "StructuredChatCompletion" && c.eventType === "Completed";
|
|
379
379
|
r(
|
|
380
|
-
h ? (T) => T.map((
|
|
380
|
+
h ? (T) => T.map((p) => {
|
|
381
381
|
var I;
|
|
382
|
-
if (((I =
|
|
383
|
-
return
|
|
384
|
-
const b =
|
|
382
|
+
if (((I = p.confirmedData) == null ? void 0 : I.taskId) !== o.agentTaskId)
|
|
383
|
+
return p;
|
|
384
|
+
const b = p.progressItems.some(
|
|
385
385
|
(C) => C.progressItemId === o.progressItemId
|
|
386
|
-
) ?
|
|
386
|
+
) ? p.progressItems.map(
|
|
387
387
|
(C) => C.progressItemId === o.progressItemId ? o : C
|
|
388
|
-
) : [...
|
|
388
|
+
) : [...p.progressItems, o];
|
|
389
389
|
return {
|
|
390
|
-
...
|
|
390
|
+
...p,
|
|
391
391
|
progressItems: b,
|
|
392
392
|
loading: !1
|
|
393
393
|
};
|
|
394
394
|
}) : (T) => T.map(
|
|
395
|
-
(
|
|
395
|
+
(p) => {
|
|
396
396
|
var x;
|
|
397
|
-
return ((x =
|
|
397
|
+
return ((x = p.confirmedData) == null ? void 0 : x.taskId) === o.agentTaskId ? { ...p, loading: !1 } : p;
|
|
398
398
|
}
|
|
399
399
|
)
|
|
400
400
|
);
|
|
401
|
-
const
|
|
401
|
+
const y = s.current.get(
|
|
402
402
|
o.agentTaskId
|
|
403
403
|
);
|
|
404
|
-
|
|
404
|
+
y && (s.current.delete(o.agentTaskId), y(c));
|
|
405
405
|
return;
|
|
406
406
|
}
|
|
407
|
-
(
|
|
408
|
-
(h) => h.map((
|
|
407
|
+
(g = e.onAgentTaskProgressItemUpdated) == null || g.call(e, o), r(
|
|
408
|
+
(h) => h.map((y) => {
|
|
409
409
|
var x;
|
|
410
|
-
if (((x =
|
|
411
|
-
return
|
|
412
|
-
const
|
|
410
|
+
if (((x = y.confirmedData) == null ? void 0 : x.taskId) !== o.agentTaskId)
|
|
411
|
+
return y;
|
|
412
|
+
const p = y.progressItems.some(
|
|
413
413
|
(b) => b.progressItemId === o.progressItemId
|
|
414
|
-
) ?
|
|
414
|
+
) ? y.progressItems.map(
|
|
415
415
|
(b) => b.progressItemId === o.progressItemId ? o : b
|
|
416
|
-
) : [...
|
|
417
|
-
return { ...
|
|
416
|
+
) : [...y.progressItems, o];
|
|
417
|
+
return { ...y, progressItems: p };
|
|
418
418
|
})
|
|
419
419
|
);
|
|
420
420
|
},
|
|
421
421
|
onStreamError: (o) => {
|
|
422
422
|
var c;
|
|
423
|
-
(c = e == null ? void 0 : e.onStreamError) == null || c.call(e, o), r((
|
|
424
|
-
const
|
|
425
|
-
return
|
|
426
|
-
...
|
|
423
|
+
(c = e == null ? void 0 : e.onStreamError) == null || c.call(e, o), r((m) => {
|
|
424
|
+
const g = m.find((h) => h.streamId === o.streamId);
|
|
425
|
+
return g ? [
|
|
426
|
+
...m.filter((h) => h.streamId !== o.streamId),
|
|
427
427
|
{
|
|
428
|
-
...
|
|
428
|
+
...g,
|
|
429
429
|
loading: !1,
|
|
430
430
|
error: o.error
|
|
431
431
|
}
|
|
432
|
-
] :
|
|
432
|
+
] : m;
|
|
433
433
|
});
|
|
434
434
|
},
|
|
435
435
|
onStreamNotFound: (o) => {
|
|
@@ -440,15 +440,15 @@ const xe = (e) => {
|
|
|
440
440
|
var c;
|
|
441
441
|
(c = e == null ? void 0 : e.onStreamTimeout) == null || c.call(e, o);
|
|
442
442
|
}
|
|
443
|
-
}),
|
|
443
|
+
}), u = K(
|
|
444
444
|
async (o, c) => {
|
|
445
|
-
const
|
|
446
|
-
if (
|
|
445
|
+
const m = `task-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`, g = await a();
|
|
446
|
+
if (g.type === "success") {
|
|
447
447
|
r([
|
|
448
448
|
...n,
|
|
449
449
|
{
|
|
450
|
-
taskKey:
|
|
451
|
-
streamId:
|
|
450
|
+
taskKey: m,
|
|
451
|
+
streamId: g.stream.id,
|
|
452
452
|
triggeredAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
453
453
|
confirmedData: null,
|
|
454
454
|
error: null,
|
|
@@ -458,11 +458,11 @@ const xe = (e) => {
|
|
|
458
458
|
loadingText: c == null ? void 0 : c.loadingText
|
|
459
459
|
}
|
|
460
460
|
]);
|
|
461
|
-
const { clientToken: h } = await e.fetchCreateAgentTaskClientToken(o.type),
|
|
461
|
+
const { clientToken: h } = await e.fetchCreateAgentTaskClientToken(o.type), y = await ne({
|
|
462
462
|
pk: t.fency.publishableKey,
|
|
463
463
|
baseUrl: t.fency.baseUrl,
|
|
464
464
|
clientToken: h,
|
|
465
|
-
streamToken:
|
|
465
|
+
streamToken: g.stream.token,
|
|
466
466
|
request: {
|
|
467
467
|
streamingChatCompletionTask: o.type === "StreamingChatCompletion" ? {
|
|
468
468
|
messages: o.messages,
|
|
@@ -484,54 +484,55 @@ const xe = (e) => {
|
|
|
484
484
|
query: o.query,
|
|
485
485
|
model: o.model,
|
|
486
486
|
language: o.language ?? "en",
|
|
487
|
-
chunkLimit: o.chunkLimit ?? 10
|
|
487
|
+
chunkLimit: o.chunkLimit ?? 10,
|
|
488
|
+
contextExpansion: o.contextExpansion
|
|
488
489
|
} : void 0
|
|
489
490
|
}
|
|
490
491
|
});
|
|
491
|
-
if (
|
|
492
|
+
if (y.type === "success" && y.agentTask) {
|
|
492
493
|
l.current.add(
|
|
493
|
-
|
|
494
|
-
), r((
|
|
495
|
-
...
|
|
494
|
+
y.agentTask.id
|
|
495
|
+
), r((p) => [
|
|
496
|
+
...p.filter((x) => x.taskKey !== m),
|
|
496
497
|
{
|
|
497
|
-
taskKey:
|
|
498
|
-
streamId:
|
|
498
|
+
taskKey: m,
|
|
499
|
+
streamId: g.stream.id,
|
|
499
500
|
triggeredAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
500
|
-
taskId:
|
|
501
|
-
createdAt:
|
|
501
|
+
taskId: y.agentTask.id,
|
|
502
|
+
createdAt: y.agentTask.createdAt,
|
|
502
503
|
error: null,
|
|
503
504
|
params: o,
|
|
504
505
|
progressItems: [],
|
|
505
506
|
loading: !0,
|
|
506
507
|
loadingText: c == null ? void 0 : c.loadingText,
|
|
507
508
|
confirmedData: {
|
|
508
|
-
taskId:
|
|
509
|
-
createdAt:
|
|
509
|
+
taskId: y.agentTask.id,
|
|
510
|
+
createdAt: y.agentTask.createdAt
|
|
510
511
|
}
|
|
511
512
|
}
|
|
512
513
|
]);
|
|
513
|
-
const T = await new Promise((
|
|
514
|
+
const T = await new Promise((p) => {
|
|
514
515
|
s.current.set(
|
|
515
|
-
|
|
516
|
-
|
|
516
|
+
y.agentTask.id,
|
|
517
|
+
p
|
|
517
518
|
);
|
|
518
519
|
});
|
|
519
520
|
return {
|
|
520
521
|
type: "success",
|
|
521
|
-
streamId:
|
|
522
|
-
agentTaskId:
|
|
522
|
+
streamId: g.stream.id,
|
|
523
|
+
agentTaskId: y.agentTask.id,
|
|
523
524
|
response: T
|
|
524
525
|
};
|
|
525
526
|
} else {
|
|
526
|
-
if (
|
|
527
|
+
if (y.type === "error")
|
|
527
528
|
return r((T) => [
|
|
528
|
-
...T.filter((
|
|
529
|
+
...T.filter((p) => p.taskKey !== m),
|
|
529
530
|
{
|
|
530
|
-
taskKey:
|
|
531
|
+
taskKey: m,
|
|
531
532
|
triggeredAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
532
|
-
streamId:
|
|
533
|
+
streamId: g.stream.id,
|
|
533
534
|
params: o,
|
|
534
|
-
error:
|
|
535
|
+
error: y.error,
|
|
535
536
|
progressItems: [],
|
|
536
537
|
loading: !1,
|
|
537
538
|
loadingText: c == null ? void 0 : c.loadingText,
|
|
@@ -539,19 +540,19 @@ const xe = (e) => {
|
|
|
539
540
|
}
|
|
540
541
|
]), {
|
|
541
542
|
type: "error",
|
|
542
|
-
error:
|
|
543
|
+
error: y.error
|
|
543
544
|
};
|
|
544
545
|
{
|
|
545
546
|
const T = {
|
|
546
547
|
message: "No response received",
|
|
547
548
|
code: "UnknownError"
|
|
548
549
|
};
|
|
549
|
-
return r((
|
|
550
|
-
...
|
|
550
|
+
return r((p) => [
|
|
551
|
+
...p.filter((x) => x.taskKey !== m),
|
|
551
552
|
{
|
|
552
|
-
taskKey:
|
|
553
|
+
taskKey: m,
|
|
553
554
|
triggeredAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
554
|
-
streamId:
|
|
555
|
+
streamId: g.stream.id,
|
|
555
556
|
error: T,
|
|
556
557
|
params: o,
|
|
557
558
|
progressItems: [],
|
|
@@ -566,7 +567,7 @@ const xe = (e) => {
|
|
|
566
567
|
}
|
|
567
568
|
}
|
|
568
569
|
} else
|
|
569
|
-
return console.error(
|
|
570
|
+
return console.error(g.error), g;
|
|
570
571
|
},
|
|
571
572
|
[t, n, a]
|
|
572
573
|
), d = W(() => {
|
|
@@ -577,7 +578,7 @@ const xe = (e) => {
|
|
|
577
578
|
l.current.clear(), s.current.clear();
|
|
578
579
|
}, []), {
|
|
579
580
|
agentTasks: n,
|
|
580
|
-
createAgentTask:
|
|
581
|
+
createAgentTask: u,
|
|
581
582
|
latest: d
|
|
582
583
|
};
|
|
583
584
|
};
|
|
@@ -586,8 +587,8 @@ function Ee(e) {
|
|
|
586
587
|
const r = e.progressItems[n + 1], l = r != null;
|
|
587
588
|
let s;
|
|
588
589
|
if (r != null && r.createdAt) {
|
|
589
|
-
const a = new Date(t.createdAt).getTime(),
|
|
590
|
-
s = Math.round((
|
|
590
|
+
const a = new Date(t.createdAt).getTime(), u = new Date(r.createdAt).getTime();
|
|
591
|
+
s = Math.round((u - a) / 1e3);
|
|
591
592
|
}
|
|
592
593
|
return {
|
|
593
594
|
item: t,
|
|
@@ -605,14 +606,14 @@ function P({
|
|
|
605
606
|
repeatDelay: l = 0.5,
|
|
606
607
|
className: s,
|
|
607
608
|
startOnView: a = !1,
|
|
608
|
-
once:
|
|
609
|
+
once: u = !1,
|
|
609
610
|
inViewMargin: d,
|
|
610
611
|
spread: o = 2,
|
|
611
612
|
color: c = "#999",
|
|
612
|
-
shimmerColor:
|
|
613
|
-
direction:
|
|
613
|
+
shimmerColor: m = "#000",
|
|
614
|
+
direction: g = "fromBottom"
|
|
614
615
|
}) {
|
|
615
|
-
const h = F(null),
|
|
616
|
+
const h = F(null), y = ie(h, { once: u, margin: d }), T = W(() => e.length * o, [e, o]), p = !a || y, x = g === "fromBottom" ? "100% center" : "-100% center", b = g === "fromBottom" ? "0% center" : "200% center";
|
|
616
617
|
return /* @__PURE__ */ i(
|
|
617
618
|
k.span,
|
|
618
619
|
{
|
|
@@ -629,7 +630,7 @@ function P({
|
|
|
629
630
|
backgroundRepeat: "no-repeat, padding-box",
|
|
630
631
|
"--spread": `${T}px`,
|
|
631
632
|
"--base-color": c,
|
|
632
|
-
"--shimmer-color":
|
|
633
|
+
"--shimmer-color": m,
|
|
633
634
|
"--shimmer-bg": "linear-gradient(90deg, transparent calc(50% - var(--spread)), var(--shimmer-color), transparent calc(50% + var(--spread)))",
|
|
634
635
|
backgroundImage: "var(--shimmer-bg), linear-gradient(var(--base-color), var(--base-color))"
|
|
635
636
|
},
|
|
@@ -637,7 +638,7 @@ function P({
|
|
|
637
638
|
backgroundPosition: x,
|
|
638
639
|
opacity: 0
|
|
639
640
|
},
|
|
640
|
-
animate:
|
|
641
|
+
animate: p ? {
|
|
641
642
|
backgroundPosition: b,
|
|
642
643
|
opacity: 1
|
|
643
644
|
} : {},
|
|
@@ -666,10 +667,8 @@ function Ie(e, t) {
|
|
|
666
667
|
if (n.eventType === "Text") return t.streaming;
|
|
667
668
|
if (n.eventType === "Completed") return t.completed;
|
|
668
669
|
}
|
|
669
|
-
if (n.taskType === "StructuredChatCompletion")
|
|
670
|
-
|
|
671
|
-
if (n.eventType === "Completed") return t.completed;
|
|
672
|
-
}
|
|
670
|
+
if (n.taskType === "StructuredChatCompletion" && n.eventType === "Completed")
|
|
671
|
+
return t.completed;
|
|
673
672
|
if (n.taskType === "MemorySearch")
|
|
674
673
|
switch (n.eventType) {
|
|
675
674
|
case "SearchMemoryTypes":
|
|
@@ -732,7 +731,7 @@ const we = ({ progressViewItems: e, t }) => {
|
|
|
732
731
|
},
|
|
733
732
|
n.item.progressItemId
|
|
734
733
|
) }) });
|
|
735
|
-
},
|
|
734
|
+
}, J = {
|
|
736
735
|
'code[class*="language-"]': {
|
|
737
736
|
color: "#f8f8f2",
|
|
738
737
|
background: "none",
|
|
@@ -883,7 +882,7 @@ const we = ({ progressViewItems: e, t }) => {
|
|
|
883
882
|
italic: {
|
|
884
883
|
fontStyle: "italic"
|
|
885
884
|
}
|
|
886
|
-
},
|
|
885
|
+
}, U = ({
|
|
887
886
|
text: e
|
|
888
887
|
}) => /* @__PURE__ */ i("div", { style: { padding: "16px" }, children: /* @__PURE__ */ i(
|
|
889
888
|
k.div,
|
|
@@ -898,8 +897,8 @@ const we = ({ progressViewItems: e, t }) => {
|
|
|
898
897
|
remarkPlugins: [se],
|
|
899
898
|
components: {
|
|
900
899
|
code(t) {
|
|
901
|
-
const { children: n, className: r, node: l, ref: s, ...a } = t,
|
|
902
|
-
return
|
|
900
|
+
const { children: n, className: r, node: l, ref: s, ...a } = t, u = /language-(\w+)/.exec(r || "");
|
|
901
|
+
return u ? (
|
|
903
902
|
// @ts-expect-error react-syntax-highlighter types incompatible with @types/react 18
|
|
904
903
|
/* @__PURE__ */ i(
|
|
905
904
|
G,
|
|
@@ -907,8 +906,8 @@ const we = ({ progressViewItems: e, t }) => {
|
|
|
907
906
|
...a,
|
|
908
907
|
PreTag: "div",
|
|
909
908
|
children: String(n).replace(/\n$/, ""),
|
|
910
|
-
language:
|
|
911
|
-
style:
|
|
909
|
+
language: u[1],
|
|
910
|
+
style: J
|
|
912
911
|
}
|
|
913
912
|
)
|
|
914
913
|
) : /* @__PURE__ */ i("code", { ...a, className: r, children: String(n) });
|
|
@@ -919,14 +918,18 @@ const we = ({ progressViewItems: e, t }) => {
|
|
|
919
918
|
)
|
|
920
919
|
}
|
|
921
920
|
) }), Ae = ({ data: e }) => {
|
|
922
|
-
const t = JSON.stringify(
|
|
921
|
+
const t = JSON.stringify(
|
|
922
|
+
JSON.parse(e.response.jsonResponse),
|
|
923
|
+
null,
|
|
924
|
+
2
|
|
925
|
+
);
|
|
923
926
|
return /* @__PURE__ */ i("div", { id: "structured-chat-completion-response", children: /* @__PURE__ */ i(
|
|
924
927
|
k.div,
|
|
925
928
|
{
|
|
926
929
|
initial: { opacity: 0, y: -10 },
|
|
927
930
|
animate: { opacity: 1, y: 0 },
|
|
928
931
|
transition: { duration: 0.3, delay: 0 },
|
|
929
|
-
children: /* @__PURE__ */ i(G, { language: "json", style:
|
|
932
|
+
children: /* @__PURE__ */ i(G, { language: "json", style: J, PreTag: "div", children: t })
|
|
930
933
|
}
|
|
931
934
|
) });
|
|
932
935
|
}, Fe = {
|
|
@@ -1036,7 +1039,7 @@ function S(e, t) {
|
|
|
1036
1039
|
e
|
|
1037
1040
|
);
|
|
1038
1041
|
}
|
|
1039
|
-
function
|
|
1042
|
+
function _(e, t) {
|
|
1040
1043
|
const n = e.map((r) => `'${r}'`);
|
|
1041
1044
|
if (t != null && n.length >= 2) {
|
|
1042
1045
|
const r = n.pop();
|
|
@@ -1045,10 +1048,10 @@ function H(e, t) {
|
|
|
1045
1048
|
return n.join(", ");
|
|
1046
1049
|
}
|
|
1047
1050
|
const O = 5, De = ({ data: e, isLatest: t = !1, durationSeconds: n, t: r }) => {
|
|
1048
|
-
const [l, s] = v(!1),
|
|
1051
|
+
const [l, s] = v(!1), u = (e.memories ?? []).map((p) => p.memoryTitle), d = u.length > 0, o = d && u.length > O, c = o && !l ? u.slice(0, O) : u, m = u.length - O, g = !o || l, h = `${r.searchingFor}'${e.queryDescription}'`, y = d ? `${r.searchingIn}${_(
|
|
1049
1052
|
c,
|
|
1050
|
-
|
|
1051
|
-
)}` : "", T = d ? `${h}${
|
|
1053
|
+
g ? r.and : void 0
|
|
1054
|
+
)}` : "", T = d ? `${h}${y}` : `${r.searchingPrefix}${e.queryDescription}`;
|
|
1052
1055
|
return /* @__PURE__ */ f("div", { style: { padding: "16px" }, children: [
|
|
1053
1056
|
/* @__PURE__ */ i(
|
|
1054
1057
|
k.div,
|
|
@@ -1074,7 +1077,7 @@ const O = 5, De = ({ data: e, isLatest: t = !1, durationSeconds: n, t: r }) => {
|
|
|
1074
1077
|
e.queryDescription,
|
|
1075
1078
|
"'"
|
|
1076
1079
|
] }),
|
|
1077
|
-
|
|
1080
|
+
y
|
|
1078
1081
|
] }) : `${r.searchingPrefix}${e.queryDescription}` }),
|
|
1079
1082
|
o && !l && /* @__PURE__ */ f(E, { children: [
|
|
1080
1083
|
" ",
|
|
@@ -1095,7 +1098,7 @@ const O = 5, De = ({ data: e, isLatest: t = !1, durationSeconds: n, t: r }) => {
|
|
|
1095
1098
|
fontFamily: "inherit"
|
|
1096
1099
|
},
|
|
1097
1100
|
children: S(r.moreMemories, {
|
|
1098
|
-
n:
|
|
1101
|
+
n: m
|
|
1099
1102
|
})
|
|
1100
1103
|
}
|
|
1101
1104
|
)
|
|
@@ -1139,9 +1142,9 @@ const O = 5, De = ({ data: e, isLatest: t = !1, durationSeconds: n, t: r }) => {
|
|
|
1139
1142
|
)
|
|
1140
1143
|
] });
|
|
1141
1144
|
}, L = 5, Re = ({ data: e, isLatest: t = !1, durationSeconds: n, t: r }) => {
|
|
1142
|
-
const [l, s] = v(!1), a = e.titles,
|
|
1145
|
+
const [l, s] = v(!1), a = e.titles, u = a.length > 0, d = u && a.length > L, o = d && !l ? a.slice(0, L) : a, c = a.length - L, m = !d || l, g = u ? `${r.findingMemoriesIn}${_(
|
|
1143
1146
|
o,
|
|
1144
|
-
|
|
1147
|
+
m ? r.and : void 0
|
|
1145
1148
|
)}` : r.findingMemories;
|
|
1146
1149
|
return /* @__PURE__ */ f("div", { style: { padding: "16px" }, children: [
|
|
1147
1150
|
/* @__PURE__ */ i(
|
|
@@ -1156,14 +1159,14 @@ const O = 5, De = ({ data: e, isLatest: t = !1, durationSeconds: n, t: r }) => {
|
|
|
1156
1159
|
children: t && !n && !d ? /* @__PURE__ */ i(
|
|
1157
1160
|
P,
|
|
1158
1161
|
{
|
|
1159
|
-
text:
|
|
1162
|
+
text: g,
|
|
1160
1163
|
duration: 2.5,
|
|
1161
1164
|
repeat: !0,
|
|
1162
1165
|
color: "#999",
|
|
1163
1166
|
shimmerColor: "#000"
|
|
1164
1167
|
}
|
|
1165
1168
|
) : /* @__PURE__ */ f(E, { children: [
|
|
1166
|
-
/* @__PURE__ */ i("span", { style: { color: "#666" }, children:
|
|
1169
|
+
/* @__PURE__ */ i("span", { style: { color: "#666" }, children: g }),
|
|
1167
1170
|
d && !l && /* @__PURE__ */ f(E, { children: [
|
|
1168
1171
|
" ",
|
|
1169
1172
|
/* @__PURE__ */ i(
|
|
@@ -1227,7 +1230,7 @@ const O = 5, De = ({ data: e, isLatest: t = !1, durationSeconds: n, t: r }) => {
|
|
|
1227
1230
|
)
|
|
1228
1231
|
] });
|
|
1229
1232
|
}, z = 5, Oe = ({ data: e, t }) => {
|
|
1230
|
-
const [n, r] = v(!1), s = e.memories.map((h) => h.memoryTitle), a = s.length > 0,
|
|
1233
|
+
const [n, r] = v(!1), s = e.memories.map((h) => h.memoryTitle), a = s.length > 0, u = a && s.length > z, d = u && !n ? s.slice(0, z) : s, o = s.length - z, c = !u || n, m = s.length === 1 ? t.memoryFound : t.memoriesFoundPrefix, g = a ? `${m}${_(
|
|
1231
1234
|
d,
|
|
1232
1235
|
c ? t.and : void 0
|
|
1233
1236
|
)}` : t.memoriesFound;
|
|
@@ -1239,8 +1242,8 @@ const O = 5, De = ({ data: e, isLatest: t = !1, durationSeconds: n, t: r }) => {
|
|
|
1239
1242
|
animate: { opacity: 1, y: 0 },
|
|
1240
1243
|
transition: { duration: 0.3, delay: 0 },
|
|
1241
1244
|
children: /* @__PURE__ */ f(E, { children: [
|
|
1242
|
-
/* @__PURE__ */ i("span", { style: { color: "#666" }, children:
|
|
1243
|
-
|
|
1245
|
+
/* @__PURE__ */ i("span", { style: { color: "#666" }, children: g }),
|
|
1246
|
+
u && !n && /* @__PURE__ */ f(E, { children: [
|
|
1244
1247
|
" ",
|
|
1245
1248
|
/* @__PURE__ */ i(
|
|
1246
1249
|
"button",
|
|
@@ -1264,7 +1267,7 @@ const O = 5, De = ({ data: e, isLatest: t = !1, durationSeconds: n, t: r }) => {
|
|
|
1264
1267
|
}
|
|
1265
1268
|
)
|
|
1266
1269
|
] }),
|
|
1267
|
-
|
|
1270
|
+
u && n && /* @__PURE__ */ f(E, { children: [
|
|
1268
1271
|
" ",
|
|
1269
1272
|
/* @__PURE__ */ i(
|
|
1270
1273
|
"button",
|
|
@@ -1376,7 +1379,7 @@ const $e = ({ data: e, onSourceClick: t, t: n }) => /* @__PURE__ */ f("div", { s
|
|
|
1376
1379
|
onSourceClick: n,
|
|
1377
1380
|
t: r
|
|
1378
1381
|
}) => {
|
|
1379
|
-
const [l, s] = v(!1), a = !!n,
|
|
1382
|
+
const [l, s] = v(!1), a = !!n, u = e.pageNumbers ?? [], d = ze(u, r);
|
|
1380
1383
|
return /* @__PURE__ */ f(
|
|
1381
1384
|
k.div,
|
|
1382
1385
|
{
|
|
@@ -1385,7 +1388,7 @@ const $e = ({ data: e, onSourceClick: t, t: n }) => /* @__PURE__ */ f("div", { s
|
|
|
1385
1388
|
transition: { duration: 0.25, delay: t * 0.05 },
|
|
1386
1389
|
onClick: a ? () => n({
|
|
1387
1390
|
memoryId: e.memoryId,
|
|
1388
|
-
pageNumbers: [...
|
|
1391
|
+
pageNumbers: [...u]
|
|
1389
1392
|
}) : void 0,
|
|
1390
1393
|
onMouseEnter: a ? () => s(!0) : void 0,
|
|
1391
1394
|
onMouseLeave: a ? () => s(!1) : void 0,
|
|
@@ -1478,12 +1481,12 @@ function We({
|
|
|
1478
1481
|
return e.error != null ? /* @__PURE__ */ i(Y, { color: "#c62828", size: 15, lineWidth: 2 }) : e.result != null ? /* @__PURE__ */ i(B, { color: "#999", size: 15, borderWidth: 2 }) : t ? /* @__PURE__ */ i(B, { color: "#999", size: 15, borderWidth: 2 }) : /* @__PURE__ */ i("span", { className: "explore-memory-loader" });
|
|
1479
1482
|
}
|
|
1480
1483
|
const j = 80;
|
|
1481
|
-
function
|
|
1484
|
+
function _e({
|
|
1482
1485
|
memory: e,
|
|
1483
1486
|
completed: t,
|
|
1484
1487
|
t: n
|
|
1485
1488
|
}) {
|
|
1486
|
-
const [r, l] = v(!1), s = e.result ?? e.error, a = s != null && s.length > j,
|
|
1489
|
+
const [r, l] = v(!1), s = e.result ?? e.error, a = s != null && s.length > j, u = s != null ? r || !a ? s : `${s.slice(0, j)}...` : void 0, d = a, o = e.error != null;
|
|
1487
1490
|
return /* @__PURE__ */ f(
|
|
1488
1491
|
k.div,
|
|
1489
1492
|
{
|
|
@@ -1533,7 +1536,7 @@ function He({
|
|
|
1533
1536
|
children: e.memoryTitle
|
|
1534
1537
|
}
|
|
1535
1538
|
),
|
|
1536
|
-
|
|
1539
|
+
u != null && /* @__PURE__ */ i(
|
|
1537
1540
|
"span",
|
|
1538
1541
|
{
|
|
1539
1542
|
style: {
|
|
@@ -1542,7 +1545,7 @@ function He({
|
|
|
1542
1545
|
lineHeight: 1.4,
|
|
1543
1546
|
whiteSpace: r ? "pre-wrap" : void 0
|
|
1544
1547
|
},
|
|
1545
|
-
children:
|
|
1548
|
+
children: u
|
|
1546
1549
|
}
|
|
1547
1550
|
),
|
|
1548
1551
|
d && /* @__PURE__ */ i(
|
|
@@ -1563,8 +1566,8 @@ function He({
|
|
|
1563
1566
|
}
|
|
1564
1567
|
);
|
|
1565
1568
|
}
|
|
1566
|
-
const
|
|
1567
|
-
|
|
1569
|
+
const He = ({ data: e, completed: t, t: n }) => /* @__PURE__ */ i("div", { style: { padding: "10px" }, children: e.memories.map((r) => /* @__PURE__ */ i(
|
|
1570
|
+
_e,
|
|
1568
1571
|
{
|
|
1569
1572
|
memory: r,
|
|
1570
1573
|
completed: t,
|
|
@@ -1572,7 +1575,7 @@ const Ne = ({ data: e, completed: t, t: n }) => /* @__PURE__ */ i("div", { style
|
|
|
1572
1575
|
},
|
|
1573
1576
|
r.memoryId
|
|
1574
1577
|
)) });
|
|
1575
|
-
function
|
|
1578
|
+
function Ne(e, t) {
|
|
1576
1579
|
if (e.length === 0) return "";
|
|
1577
1580
|
if (e.length === 1)
|
|
1578
1581
|
return S(t.pageSingle, { n: e[0] });
|
|
@@ -1584,7 +1587,7 @@ function Ue(e, t) {
|
|
|
1584
1587
|
const n = e[e.length - 1], r = e.slice(0, -1).join(", ");
|
|
1585
1588
|
return S(t.pageMultiple, { list: r, n });
|
|
1586
1589
|
}
|
|
1587
|
-
function
|
|
1590
|
+
function Ue(e, t) {
|
|
1588
1591
|
return e === 1 ? t.chunkFound : S(t.chunksFound, { n: e });
|
|
1589
1592
|
}
|
|
1590
1593
|
const je = ({ data: e, t }) => {
|
|
@@ -1608,7 +1611,7 @@ const je = ({ data: e, t }) => {
|
|
|
1608
1611
|
},
|
|
1609
1612
|
children: [
|
|
1610
1613
|
/* @__PURE__ */ i("span", { style: { fontSize: 13, fontWeight: 500, color: "#333" }, children: e.memoryTitle }),
|
|
1611
|
-
/* @__PURE__ */ i("span", { style: { fontSize: 12, color: "#666" }, children:
|
|
1614
|
+
/* @__PURE__ */ i("span", { style: { fontSize: 12, color: "#666" }, children: Ue(l, t) }),
|
|
1612
1615
|
s && /* @__PURE__ */ i(
|
|
1613
1616
|
"span",
|
|
1614
1617
|
{
|
|
@@ -1637,8 +1640,8 @@ const je = ({ data: e, t }) => {
|
|
|
1637
1640
|
flexDirection: "column",
|
|
1638
1641
|
gap: 8
|
|
1639
1642
|
},
|
|
1640
|
-
children: e.chunks.map((a,
|
|
1641
|
-
const d = a.pageNumbers ?? [], o =
|
|
1643
|
+
children: e.chunks.map((a, u) => {
|
|
1644
|
+
const d = a.pageNumbers ?? [], o = Ne(d, t);
|
|
1642
1645
|
return /* @__PURE__ */ f(
|
|
1643
1646
|
"div",
|
|
1644
1647
|
{
|
|
@@ -1681,7 +1684,7 @@ const je = ({ data: e, t }) => {
|
|
|
1681
1684
|
)
|
|
1682
1685
|
]
|
|
1683
1686
|
},
|
|
1684
|
-
|
|
1687
|
+
u
|
|
1685
1688
|
);
|
|
1686
1689
|
})
|
|
1687
1690
|
}
|
|
@@ -1780,8 +1783,8 @@ function Ge({
|
|
|
1780
1783
|
const Xe = ({ data: e, isLatest: t = !1, durationSeconds: n, t: r }) => {
|
|
1781
1784
|
const l = W(() => {
|
|
1782
1785
|
let s = -1;
|
|
1783
|
-
return e.memoryTypes.forEach((a,
|
|
1784
|
-
a.result == null && a.error == null && (s =
|
|
1786
|
+
return e.memoryTypes.forEach((a, u) => {
|
|
1787
|
+
a.result == null && a.error == null && (s = u);
|
|
1785
1788
|
}), s;
|
|
1786
1789
|
}, [e.memoryTypes]);
|
|
1787
1790
|
return /* @__PURE__ */ f("div", { style: { padding: "10px" }, children: [
|
|
@@ -1817,7 +1820,32 @@ const Xe = ({ data: e, isLatest: t = !1, durationSeconds: n, t: r }) => {
|
|
|
1817
1820
|
)
|
|
1818
1821
|
] });
|
|
1819
1822
|
};
|
|
1820
|
-
function
|
|
1823
|
+
function Ve(e, t) {
|
|
1824
|
+
const n = Math.min(e.length, t.length);
|
|
1825
|
+
for (let r = n; r >= 0; r--)
|
|
1826
|
+
if (e.slice(-r) === t.slice(0, r)) return r;
|
|
1827
|
+
return 0;
|
|
1828
|
+
}
|
|
1829
|
+
const Je = `
|
|
1830
|
+
|
|
1831
|
+
`;
|
|
1832
|
+
function Ye(e) {
|
|
1833
|
+
var n, r;
|
|
1834
|
+
if (e.length === 0) return "";
|
|
1835
|
+
let t = ((n = e[0]) == null ? void 0 : n.content) ?? "";
|
|
1836
|
+
for (let l = 1; l < e.length; l++) {
|
|
1837
|
+
const s = ((r = e[l]) == null ? void 0 : r.content) ?? "";
|
|
1838
|
+
if (s === "") continue;
|
|
1839
|
+
if (t === "") {
|
|
1840
|
+
t = s;
|
|
1841
|
+
continue;
|
|
1842
|
+
}
|
|
1843
|
+
const a = Ve(t, s);
|
|
1844
|
+
a === 0 ? t += Je + s : t += s.slice(a);
|
|
1845
|
+
}
|
|
1846
|
+
return t;
|
|
1847
|
+
}
|
|
1848
|
+
function Qe(e, t) {
|
|
1821
1849
|
if (e.length === 0) return "";
|
|
1822
1850
|
if (e.length === 1)
|
|
1823
1851
|
return S(t.memorySearchPagesSingle, {
|
|
@@ -1834,8 +1862,19 @@ function Je(e, t) {
|
|
|
1834
1862
|
n
|
|
1835
1863
|
});
|
|
1836
1864
|
}
|
|
1837
|
-
|
|
1838
|
-
const
|
|
1865
|
+
function Ze(e) {
|
|
1866
|
+
const t = /* @__PURE__ */ new Set();
|
|
1867
|
+
for (const n of e)
|
|
1868
|
+
for (const r of n.pageNumbers) t.add(r);
|
|
1869
|
+
return [...t].sort((n, r) => n - r);
|
|
1870
|
+
}
|
|
1871
|
+
function et(e) {
|
|
1872
|
+
const t = e.memoryTypeName.trim();
|
|
1873
|
+
if (t !== "") return t;
|
|
1874
|
+
if (e.memoryTypeId !== "") return e.memoryTypeId;
|
|
1875
|
+
}
|
|
1876
|
+
const tt = ({ data: e, onSearchResultClick: t, t: n }) => {
|
|
1877
|
+
const r = e.response.items, l = !!t;
|
|
1839
1878
|
return /* @__PURE__ */ f("div", { style: { padding: "16px" }, children: [
|
|
1840
1879
|
/* @__PURE__ */ i(
|
|
1841
1880
|
k.div,
|
|
@@ -1860,116 +1899,118 @@ const Ve = ({ data: e, onSearchResultClick: t, t: n }) => {
|
|
|
1860
1899
|
flexDirection: "column",
|
|
1861
1900
|
gap: 0
|
|
1862
1901
|
},
|
|
1863
|
-
children: r.map((s, a) =>
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1902
|
+
children: r.map((s, a) => {
|
|
1903
|
+
const u = s.memory.title != null && s.memory.title !== "" ? s.memory.title : s.memory.id, d = Ze(
|
|
1904
|
+
s.chunks
|
|
1905
|
+
), o = [
|
|
1906
|
+
et(s.memory),
|
|
1907
|
+
S(n.scoreLabel, {
|
|
1908
|
+
n: s.score.toFixed(2)
|
|
1909
|
+
}),
|
|
1910
|
+
d.length > 0 ? Qe(d, n) : n.pagesNotAvailable
|
|
1911
|
+
].filter(
|
|
1912
|
+
(m) => m != null && m !== ""
|
|
1913
|
+
), c = {
|
|
1914
|
+
memoryId: s.memory.id,
|
|
1915
|
+
pageNumbers: d
|
|
1916
|
+
};
|
|
1917
|
+
return /* @__PURE__ */ f(
|
|
1918
|
+
k.div,
|
|
1919
|
+
{
|
|
1920
|
+
initial: { opacity: 0 },
|
|
1921
|
+
animate: { opacity: 1 },
|
|
1922
|
+
transition: { duration: 0.2, delay: a * 0.04 },
|
|
1923
|
+
style: {
|
|
1924
|
+
display: "flex",
|
|
1925
|
+
flexDirection: "row",
|
|
1926
|
+
alignItems: "flex-start",
|
|
1927
|
+
gap: "12px",
|
|
1928
|
+
paddingTop: "12px",
|
|
1929
|
+
paddingBottom: "12px",
|
|
1930
|
+
borderBottom: a < r.length - 1 ? "1px solid #eee" : void 0,
|
|
1931
|
+
minWidth: 0
|
|
1932
|
+
},
|
|
1933
|
+
children: [
|
|
1934
|
+
/* @__PURE__ */ f(
|
|
1935
|
+
"div",
|
|
1936
|
+
{
|
|
1937
|
+
style: {
|
|
1938
|
+
flex: 1,
|
|
1939
|
+
minWidth: 0,
|
|
1940
|
+
display: "flex",
|
|
1941
|
+
flexDirection: "column",
|
|
1942
|
+
gap: "6px"
|
|
1943
|
+
},
|
|
1944
|
+
children: [
|
|
1945
|
+
/* @__PURE__ */ i(
|
|
1946
|
+
"span",
|
|
1947
|
+
{
|
|
1948
|
+
style: {
|
|
1949
|
+
fontSize: 13,
|
|
1950
|
+
fontWeight: 600,
|
|
1951
|
+
color: "#333"
|
|
1952
|
+
},
|
|
1953
|
+
children: u
|
|
1954
|
+
}
|
|
1955
|
+
),
|
|
1956
|
+
/* @__PURE__ */ i(
|
|
1957
|
+
"span",
|
|
1958
|
+
{
|
|
1959
|
+
style: {
|
|
1960
|
+
fontSize: 13,
|
|
1961
|
+
color: "#1f2937",
|
|
1962
|
+
lineHeight: 1.5,
|
|
1963
|
+
whiteSpace: "pre-wrap",
|
|
1964
|
+
wordBreak: "break-word"
|
|
1965
|
+
},
|
|
1966
|
+
children: Ye(s.chunks)
|
|
1967
|
+
}
|
|
1968
|
+
),
|
|
1969
|
+
/* @__PURE__ */ i(
|
|
1970
|
+
"div",
|
|
1971
|
+
{
|
|
1972
|
+
style: {
|
|
1973
|
+
fontSize: 11,
|
|
1974
|
+
fontWeight: 400,
|
|
1975
|
+
color: "#94a3b8",
|
|
1976
|
+
lineHeight: 1.35
|
|
1977
|
+
},
|
|
1978
|
+
children: o.join(" · ")
|
|
1979
|
+
}
|
|
1980
|
+
)
|
|
1981
|
+
]
|
|
1982
|
+
}
|
|
1983
|
+
),
|
|
1984
|
+
l && /* @__PURE__ */ i(
|
|
1985
|
+
"button",
|
|
1986
|
+
{
|
|
1987
|
+
type: "button",
|
|
1988
|
+
onClick: () => t(c),
|
|
1989
|
+
style: {
|
|
1990
|
+
flexShrink: 0,
|
|
1991
|
+
alignSelf: "center",
|
|
1992
|
+
padding: "6px 12px",
|
|
1993
|
+
fontSize: 12,
|
|
1994
|
+
fontWeight: 600,
|
|
1995
|
+
color: "#2563eb",
|
|
1996
|
+
background: "#eff6ff",
|
|
1997
|
+
border: "1px solid #bfdbfe",
|
|
1998
|
+
borderRadius: 6,
|
|
1999
|
+
cursor: "pointer",
|
|
2000
|
+
fontFamily: "inherit"
|
|
2001
|
+
},
|
|
2002
|
+
children: n.viewButton
|
|
2003
|
+
}
|
|
2004
|
+
)
|
|
2005
|
+
]
|
|
1878
2006
|
},
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
{
|
|
1883
|
-
style: {
|
|
1884
|
-
flex: 1,
|
|
1885
|
-
minWidth: 0,
|
|
1886
|
-
display: "flex",
|
|
1887
|
-
flexDirection: "column",
|
|
1888
|
-
gap: "6px"
|
|
1889
|
-
},
|
|
1890
|
-
children: [
|
|
1891
|
-
/* @__PURE__ */ i(
|
|
1892
|
-
"span",
|
|
1893
|
-
{
|
|
1894
|
-
style: {
|
|
1895
|
-
fontSize: 13,
|
|
1896
|
-
fontWeight: 600,
|
|
1897
|
-
color: "#333"
|
|
1898
|
-
},
|
|
1899
|
-
children: s.memoryTitle
|
|
1900
|
-
}
|
|
1901
|
-
),
|
|
1902
|
-
/* @__PURE__ */ i(
|
|
1903
|
-
"span",
|
|
1904
|
-
{
|
|
1905
|
-
style: {
|
|
1906
|
-
fontSize: 13,
|
|
1907
|
-
color: "#1f2937",
|
|
1908
|
-
lineHeight: 1.5,
|
|
1909
|
-
whiteSpace: "pre-wrap",
|
|
1910
|
-
wordBreak: "break-word"
|
|
1911
|
-
},
|
|
1912
|
-
children: s.content
|
|
1913
|
-
}
|
|
1914
|
-
),
|
|
1915
|
-
/* @__PURE__ */ i(
|
|
1916
|
-
"div",
|
|
1917
|
-
{
|
|
1918
|
-
style: {
|
|
1919
|
-
fontSize: 11,
|
|
1920
|
-
fontWeight: 400,
|
|
1921
|
-
color: "#94a3b8",
|
|
1922
|
-
lineHeight: 1.35
|
|
1923
|
-
},
|
|
1924
|
-
children: [
|
|
1925
|
-
s.memoryTypeName != null && s.memoryTypeName !== "" ? s.memoryTypeName : void 0,
|
|
1926
|
-
S(n.scoreLabel, {
|
|
1927
|
-
n: s.score.toFixed(2)
|
|
1928
|
-
}),
|
|
1929
|
-
s.pageNumbers.length > 0 ? Je(
|
|
1930
|
-
s.pageNumbers,
|
|
1931
|
-
n
|
|
1932
|
-
) : n.pagesNotAvailable
|
|
1933
|
-
].filter(
|
|
1934
|
-
(m) => m != null && m !== ""
|
|
1935
|
-
).join(" · ")
|
|
1936
|
-
}
|
|
1937
|
-
)
|
|
1938
|
-
]
|
|
1939
|
-
}
|
|
1940
|
-
),
|
|
1941
|
-
l && /* @__PURE__ */ i(
|
|
1942
|
-
"button",
|
|
1943
|
-
{
|
|
1944
|
-
type: "button",
|
|
1945
|
-
onClick: () => t({
|
|
1946
|
-
memoryId: s.memoryId,
|
|
1947
|
-
pageNumbers: [...s.pageNumbers]
|
|
1948
|
-
}),
|
|
1949
|
-
style: {
|
|
1950
|
-
flexShrink: 0,
|
|
1951
|
-
alignSelf: "center",
|
|
1952
|
-
padding: "6px 12px",
|
|
1953
|
-
fontSize: 12,
|
|
1954
|
-
fontWeight: 600,
|
|
1955
|
-
color: "#2563eb",
|
|
1956
|
-
background: "#eff6ff",
|
|
1957
|
-
border: "1px solid #bfdbfe",
|
|
1958
|
-
borderRadius: 6,
|
|
1959
|
-
cursor: "pointer",
|
|
1960
|
-
fontFamily: "inherit"
|
|
1961
|
-
},
|
|
1962
|
-
children: n.viewButton
|
|
1963
|
-
}
|
|
1964
|
-
)
|
|
1965
|
-
]
|
|
1966
|
-
},
|
|
1967
|
-
`${s.memoryId}-${a}`
|
|
1968
|
-
))
|
|
2007
|
+
`${s.memory.id}-${a}`
|
|
2008
|
+
);
|
|
2009
|
+
})
|
|
1969
2010
|
}
|
|
1970
2011
|
)
|
|
1971
2012
|
] });
|
|
1972
|
-
},
|
|
2013
|
+
}, nt = ({ message: e }) => /* @__PURE__ */ i("div", { style: { padding: "16px" }, children: /* @__PURE__ */ i(
|
|
1973
2014
|
k.div,
|
|
1974
2015
|
{
|
|
1975
2016
|
initial: { opacity: 0, y: -10 },
|
|
@@ -1992,7 +2033,7 @@ const Ve = ({ data: e, onSearchResultClick: t, t: n }) => {
|
|
|
1992
2033
|
}
|
|
1993
2034
|
)
|
|
1994
2035
|
}
|
|
1995
|
-
) }),
|
|
2036
|
+
) }), rt = ({
|
|
1996
2037
|
progressViewItems: e,
|
|
1997
2038
|
loadingText: t,
|
|
1998
2039
|
t: n,
|
|
@@ -2006,13 +2047,13 @@ const Ve = ({ data: e, onSearchResultClick: t, t: n }) => {
|
|
|
2006
2047
|
const a = (d) => {
|
|
2007
2048
|
const o = d.item.data;
|
|
2008
2049
|
if (o.taskType === "StreamingChatCompletion" && o.eventType === "Text")
|
|
2009
|
-
return /* @__PURE__ */ i(
|
|
2010
|
-
if (o.taskType === "StructuredChatCompletion" && o.eventType === "
|
|
2050
|
+
return /* @__PURE__ */ i(U, { text: o.text });
|
|
2051
|
+
if (o.taskType === "StructuredChatCompletion" && o.eventType === "Completed")
|
|
2011
2052
|
return /* @__PURE__ */ i(Ae, { data: o });
|
|
2012
2053
|
if (o.taskType === "MemoryChatCompletion")
|
|
2013
2054
|
switch (o.eventType) {
|
|
2014
2055
|
case "Text":
|
|
2015
|
-
return /* @__PURE__ */ i(
|
|
2056
|
+
return /* @__PURE__ */ i(U, { text: o.text });
|
|
2016
2057
|
case "FindMemories":
|
|
2017
2058
|
return /* @__PURE__ */ i(
|
|
2018
2059
|
Re,
|
|
@@ -2024,7 +2065,13 @@ const Ve = ({ data: e, onSearchResultClick: t, t: n }) => {
|
|
|
2024
2065
|
}
|
|
2025
2066
|
);
|
|
2026
2067
|
case "FindMemoriesResult":
|
|
2027
|
-
return /* @__PURE__ */ i(
|
|
2068
|
+
return /* @__PURE__ */ i(
|
|
2069
|
+
Oe,
|
|
2070
|
+
{
|
|
2071
|
+
data: o,
|
|
2072
|
+
t: n
|
|
2073
|
+
}
|
|
2074
|
+
);
|
|
2028
2075
|
case "Search":
|
|
2029
2076
|
return /* @__PURE__ */ i(
|
|
2030
2077
|
De,
|
|
@@ -2056,7 +2103,7 @@ const Ve = ({ data: e, onSearchResultClick: t, t: n }) => {
|
|
|
2056
2103
|
);
|
|
2057
2104
|
case "ExploreMemories":
|
|
2058
2105
|
return /* @__PURE__ */ i(
|
|
2059
|
-
|
|
2106
|
+
He,
|
|
2060
2107
|
{
|
|
2061
2108
|
data: o,
|
|
2062
2109
|
completed: d.completed,
|
|
@@ -2083,7 +2130,7 @@ const Ve = ({ data: e, onSearchResultClick: t, t: n }) => {
|
|
|
2083
2130
|
);
|
|
2084
2131
|
case "Completed":
|
|
2085
2132
|
return /* @__PURE__ */ i(
|
|
2086
|
-
|
|
2133
|
+
tt,
|
|
2087
2134
|
{
|
|
2088
2135
|
data: o,
|
|
2089
2136
|
onSearchResultClick: l,
|
|
@@ -2091,7 +2138,7 @@ const Ve = ({ data: e, onSearchResultClick: t, t: n }) => {
|
|
|
2091
2138
|
}
|
|
2092
2139
|
);
|
|
2093
2140
|
}
|
|
2094
|
-
return o.taskType === "StreamingChatCompletion" && o.eventType === "Completed"
|
|
2141
|
+
return o.taskType === "StreamingChatCompletion" && o.eventType === "Completed" ? null : o.eventType === "Error" && "message" in o ? /* @__PURE__ */ i(nt, { message: o.message }) : null;
|
|
2095
2142
|
};
|
|
2096
2143
|
if (e.length === 0)
|
|
2097
2144
|
return /* @__PURE__ */ i("div", { style: { width: "fit-content" }, children: /* @__PURE__ */ i(
|
|
@@ -2105,13 +2152,13 @@ const Ve = ({ data: e, onSearchResultClick: t, t: n }) => {
|
|
|
2105
2152
|
shimmerColor: "#000"
|
|
2106
2153
|
}
|
|
2107
2154
|
) });
|
|
2108
|
-
const
|
|
2155
|
+
const u = e.filter((d, o) => {
|
|
2109
2156
|
const c = d.item.data;
|
|
2110
2157
|
return c.taskType === "MemoryChatCompletion" && c.eventType === "ExploreMemories" ? !e.slice(o + 1).some(
|
|
2111
2158
|
(h) => h.item.data.taskType === "MemoryChatCompletion" && h.item.data.eventType === "ExploreMemories"
|
|
2112
2159
|
) : !0;
|
|
2113
2160
|
});
|
|
2114
|
-
return /* @__PURE__ */ i("div", { id: "agent-task-progress-verbose", ref: s, children: /* @__PURE__ */ i(q, { children:
|
|
2161
|
+
return /* @__PURE__ */ i("div", { id: "agent-task-progress-verbose", ref: s, children: /* @__PURE__ */ i(q, { children: u.map((d, o) => /* @__PURE__ */ i(
|
|
2115
2162
|
k.div,
|
|
2116
2163
|
{
|
|
2117
2164
|
id: `agent-task-progress-item-${d.item.progressItemId}`,
|
|
@@ -2126,36 +2173,36 @@ const Ve = ({ data: e, onSearchResultClick: t, t: n }) => {
|
|
|
2126
2173
|
},
|
|
2127
2174
|
d.item.progressItemId
|
|
2128
2175
|
)) }) });
|
|
2129
|
-
},
|
|
2176
|
+
}, gt = ({
|
|
2130
2177
|
agentTask: e,
|
|
2131
2178
|
mode: t = "verbose",
|
|
2132
2179
|
language: n,
|
|
2133
2180
|
onSourceClick: r,
|
|
2134
2181
|
onSearchResultClick: l
|
|
2135
2182
|
}) => {
|
|
2136
|
-
const s = Ee(e), a = (e.params.type === "MemoryChatCompletion" || e.params.type === "MemorySearch") && "language" in e.params ? e.params.language ?? "en" : n ?? "en",
|
|
2183
|
+
const s = Ee(e), a = (e.params.type === "MemoryChatCompletion" || e.params.type === "MemorySearch") && "language" in e.params ? e.params.language ?? "en" : n ?? "en", u = Pe(a);
|
|
2137
2184
|
return t === "simple" ? /* @__PURE__ */ i(
|
|
2138
2185
|
we,
|
|
2139
2186
|
{
|
|
2140
2187
|
progressViewItems: s,
|
|
2141
|
-
t:
|
|
2188
|
+
t: u
|
|
2142
2189
|
}
|
|
2143
2190
|
) : /* @__PURE__ */ i(
|
|
2144
|
-
|
|
2191
|
+
rt,
|
|
2145
2192
|
{
|
|
2146
2193
|
progressViewItems: s,
|
|
2147
2194
|
loadingText: e.loadingText,
|
|
2148
|
-
t:
|
|
2195
|
+
t: u,
|
|
2149
2196
|
onSourceClick: r,
|
|
2150
2197
|
onSearchResultClick: l
|
|
2151
2198
|
}
|
|
2152
2199
|
);
|
|
2153
2200
|
};
|
|
2154
2201
|
export {
|
|
2155
|
-
|
|
2202
|
+
gt as AgentTaskProgress,
|
|
2156
2203
|
B as Checkmark,
|
|
2157
|
-
|
|
2158
|
-
|
|
2204
|
+
ut as FencyProvider,
|
|
2205
|
+
tt as MemorySearchCompletedResults,
|
|
2159
2206
|
Y as XMark,
|
|
2160
|
-
|
|
2207
|
+
mt as useAgentTasks
|
|
2161
2208
|
};
|