@fencyai/react 0.1.136 → 0.1.138
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/AgentTaskProgress.d.ts +2 -0
- package/dist/agent-task/AgentTaskProgress.d.ts.map +1 -1
- package/dist/agent-task/AgentTaskProgressSimple.d.ts +2 -0
- package/dist/agent-task/AgentTaskProgressSimple.d.ts.map +1 -1
- package/dist/agent-task/AgentTaskProgressVerbose.d.ts +2 -0
- package/dist/agent-task/AgentTaskProgressVerbose.d.ts.map +1 -1
- package/dist/agent-task/data-types/MemoryChatCompletionExploreMemory.d.ts +2 -0
- package/dist/agent-task/data-types/MemoryChatCompletionExploreMemory.d.ts.map +1 -1
- package/dist/agent-task/data-types/MemoryChatCompletionFindSources.d.ts +2 -0
- package/dist/agent-task/data-types/MemoryChatCompletionFindSources.d.ts.map +1 -1
- package/dist/agent-task/data-types/MemoryChatCompletionSearch.d.ts +2 -0
- package/dist/agent-task/data-types/MemoryChatCompletionSearch.d.ts.map +1 -1
- package/dist/agent-task/data-types/MemoryChatCompletionSourcesResult.d.ts +2 -0
- package/dist/agent-task/data-types/MemoryChatCompletionSourcesResult.d.ts.map +1 -1
- package/dist/agent-task/translations.d.ts +28 -0
- package/dist/agent-task/translations.d.ts.map +1 -0
- package/dist/hooks/useAgentTasks/index.d.ts.map +1 -1
- package/dist/index.js +509 -434
- package/dist/types/CreateAgentTaskParams.d.ts +4 -1
- package/dist/types/CreateAgentTaskParams.d.ts.map +1 -1
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -1,78 +1,78 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { createStream as
|
|
3
|
-
import { createContext as
|
|
4
|
-
import { useInView as
|
|
5
|
-
import
|
|
6
|
-
import { Prism as
|
|
7
|
-
import
|
|
8
|
-
import './assets/index.css';const W =
|
|
1
|
+
import { jsxs as x, jsx as i } from "react/jsx-runtime";
|
|
2
|
+
import { createStream as G, isStreamTimeoutEvent as J, isStreamNotFoundEvent as V, isAgentTaskProgressItemUpdatedEvent as X, createAgentTask as q } from "@fencyai/js";
|
|
3
|
+
import { createContext as Y, useState as v, useRef as w, useEffect as E, useCallback as _, useContext as Q, useMemo as z } from "react";
|
|
4
|
+
import { useInView as Z, motion as k, AnimatePresence as $ } from "motion/react";
|
|
5
|
+
import ee from "react-markdown";
|
|
6
|
+
import { Prism as j } from "react-syntax-highlighter";
|
|
7
|
+
import te from "remark-gfm";
|
|
8
|
+
import './assets/index.css';const W = Y(
|
|
9
9
|
void 0
|
|
10
10
|
);
|
|
11
|
-
async function
|
|
12
|
-
const
|
|
13
|
-
let
|
|
14
|
-
for (; !(
|
|
15
|
-
t(
|
|
11
|
+
async function re(e, t) {
|
|
12
|
+
const r = e.getReader();
|
|
13
|
+
let n;
|
|
14
|
+
for (; !(n = await r.read()).done; )
|
|
15
|
+
t(n.value);
|
|
16
16
|
}
|
|
17
|
-
function
|
|
18
|
-
let t,
|
|
17
|
+
function ne(e) {
|
|
18
|
+
let t, r, n, s = !1;
|
|
19
19
|
return function(o) {
|
|
20
|
-
t === void 0 ? (t = o,
|
|
21
|
-
const
|
|
20
|
+
t === void 0 ? (t = o, r = 0, n = -1) : t = ae(t, o);
|
|
21
|
+
const l = t.length;
|
|
22
22
|
let y = 0;
|
|
23
|
-
for (;
|
|
24
|
-
|
|
23
|
+
for (; r < l; ) {
|
|
24
|
+
s && (t[r] === 10 && (y = ++r), s = !1);
|
|
25
25
|
let a = -1;
|
|
26
|
-
for (;
|
|
27
|
-
switch (t[
|
|
26
|
+
for (; r < l && a === -1; ++r)
|
|
27
|
+
switch (t[r]) {
|
|
28
28
|
case 58:
|
|
29
|
-
|
|
29
|
+
n === -1 && (n = r - y);
|
|
30
30
|
break;
|
|
31
31
|
case 13:
|
|
32
|
-
|
|
32
|
+
s = !0;
|
|
33
33
|
case 10:
|
|
34
|
-
a =
|
|
34
|
+
a = r;
|
|
35
35
|
break;
|
|
36
36
|
}
|
|
37
37
|
if (a === -1)
|
|
38
38
|
break;
|
|
39
|
-
e(t.subarray(y, a),
|
|
39
|
+
e(t.subarray(y, a), n), y = r, n = -1;
|
|
40
40
|
}
|
|
41
|
-
y ===
|
|
41
|
+
y === l ? t = void 0 : y !== 0 && (t = t.subarray(y), r -= y);
|
|
42
42
|
};
|
|
43
43
|
}
|
|
44
|
-
function
|
|
45
|
-
let
|
|
46
|
-
const
|
|
47
|
-
return function(o,
|
|
44
|
+
function oe(e, t, r) {
|
|
45
|
+
let n = F();
|
|
46
|
+
const s = new TextDecoder();
|
|
47
|
+
return function(o, l) {
|
|
48
48
|
if (o.length === 0)
|
|
49
|
-
|
|
50
|
-
else if (
|
|
51
|
-
const y =
|
|
49
|
+
r == null || r(n), n = F();
|
|
50
|
+
else if (l > 0) {
|
|
51
|
+
const y = s.decode(o.subarray(0, l)), a = l + (o[l + 1] === 32 ? 2 : 1), c = s.decode(o.subarray(a));
|
|
52
52
|
switch (y) {
|
|
53
53
|
case "data":
|
|
54
|
-
|
|
55
|
-
` +
|
|
54
|
+
n.data = n.data ? n.data + `
|
|
55
|
+
` + c : c;
|
|
56
56
|
break;
|
|
57
57
|
case "event":
|
|
58
|
-
|
|
58
|
+
n.event = c;
|
|
59
59
|
break;
|
|
60
60
|
case "id":
|
|
61
|
-
e(
|
|
61
|
+
e(n.id = c);
|
|
62
62
|
break;
|
|
63
63
|
case "retry":
|
|
64
|
-
const m = parseInt(
|
|
65
|
-
isNaN(m) || t(
|
|
64
|
+
const m = parseInt(c, 10);
|
|
65
|
+
isNaN(m) || t(n.retry = m);
|
|
66
66
|
break;
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
69
|
};
|
|
70
70
|
}
|
|
71
|
-
function
|
|
72
|
-
const
|
|
73
|
-
return
|
|
71
|
+
function ae(e, t) {
|
|
72
|
+
const r = new Uint8Array(e.length + t.length);
|
|
73
|
+
return r.set(e), r.set(t, e.length), r;
|
|
74
74
|
}
|
|
75
|
-
function
|
|
75
|
+
function F() {
|
|
76
76
|
return {
|
|
77
77
|
data: "",
|
|
78
78
|
event: "",
|
|
@@ -80,68 +80,68 @@ function R() {
|
|
|
80
80
|
retry: void 0
|
|
81
81
|
};
|
|
82
82
|
}
|
|
83
|
-
var
|
|
84
|
-
var
|
|
85
|
-
for (var
|
|
83
|
+
var se = function(e, t) {
|
|
84
|
+
var r = {};
|
|
85
|
+
for (var n in e) Object.prototype.hasOwnProperty.call(e, n) && t.indexOf(n) < 0 && (r[n] = e[n]);
|
|
86
86
|
if (e != null && typeof Object.getOwnPropertySymbols == "function")
|
|
87
|
-
for (var
|
|
88
|
-
t.indexOf(
|
|
89
|
-
return
|
|
87
|
+
for (var s = 0, n = Object.getOwnPropertySymbols(e); s < n.length; s++)
|
|
88
|
+
t.indexOf(n[s]) < 0 && Object.prototype.propertyIsEnumerable.call(e, n[s]) && (r[n[s]] = e[n[s]]);
|
|
89
|
+
return r;
|
|
90
90
|
};
|
|
91
|
-
const
|
|
92
|
-
function
|
|
93
|
-
var { signal:
|
|
91
|
+
const R = "text/event-stream", ie = 1e3, B = "last-event-id";
|
|
92
|
+
function le(e, t) {
|
|
93
|
+
var { signal: r, headers: n, onopen: s, onmessage: d, onclose: o, onerror: l, openWhenHidden: y, fetch: a } = t, c = se(t, ["signal", "headers", "onopen", "onmessage", "onclose", "onerror", "openWhenHidden", "fetch"]);
|
|
94
94
|
return new Promise((m, u) => {
|
|
95
|
-
const f = Object.assign({},
|
|
96
|
-
f.accept || (f.accept =
|
|
95
|
+
const f = Object.assign({}, n);
|
|
96
|
+
f.accept || (f.accept = R);
|
|
97
97
|
let g;
|
|
98
|
-
function
|
|
99
|
-
g.abort(), document.hidden ||
|
|
98
|
+
function h() {
|
|
99
|
+
g.abort(), document.hidden || C();
|
|
100
100
|
}
|
|
101
|
-
y || document.addEventListener("visibilitychange",
|
|
102
|
-
let
|
|
103
|
-
function
|
|
104
|
-
document.removeEventListener("visibilitychange",
|
|
101
|
+
y || document.addEventListener("visibilitychange", h);
|
|
102
|
+
let p = ie, S = 0;
|
|
103
|
+
function T() {
|
|
104
|
+
document.removeEventListener("visibilitychange", h), window.clearTimeout(S), g.abort();
|
|
105
105
|
}
|
|
106
|
-
|
|
107
|
-
|
|
106
|
+
r == null || r.addEventListener("abort", () => {
|
|
107
|
+
T(), m();
|
|
108
108
|
});
|
|
109
|
-
const
|
|
110
|
-
async function
|
|
109
|
+
const P = a ?? window.fetch, I = s ?? ce;
|
|
110
|
+
async function C() {
|
|
111
111
|
var M;
|
|
112
112
|
g = new AbortController();
|
|
113
113
|
try {
|
|
114
|
-
const A = await
|
|
115
|
-
await I(A), await
|
|
116
|
-
|
|
117
|
-
}, (
|
|
118
|
-
|
|
119
|
-
},
|
|
114
|
+
const A = await P(e, Object.assign(Object.assign({}, c), { headers: f, signal: g.signal }));
|
|
115
|
+
await I(A), await re(A.body, ne(oe((b) => {
|
|
116
|
+
b ? f[B] = b : delete f[B];
|
|
117
|
+
}, (b) => {
|
|
118
|
+
p = b;
|
|
119
|
+
}, d))), o == null || o(), T(), m();
|
|
120
120
|
} catch (A) {
|
|
121
121
|
if (!g.signal.aborted)
|
|
122
122
|
try {
|
|
123
|
-
const
|
|
124
|
-
window.clearTimeout(S), S = window.setTimeout(
|
|
125
|
-
} catch (
|
|
126
|
-
|
|
123
|
+
const b = (M = l == null ? void 0 : l(A)) !== null && M !== void 0 ? M : p;
|
|
124
|
+
window.clearTimeout(S), S = window.setTimeout(C, b);
|
|
125
|
+
} catch (b) {
|
|
126
|
+
T(), u(b);
|
|
127
127
|
}
|
|
128
128
|
}
|
|
129
129
|
}
|
|
130
|
-
|
|
130
|
+
C();
|
|
131
131
|
});
|
|
132
132
|
}
|
|
133
133
|
function ce(e) {
|
|
134
134
|
const t = e.headers.get("content-type");
|
|
135
|
-
if (!(t != null && t.startsWith(
|
|
136
|
-
throw new Error(`Expected content-type to be ${
|
|
135
|
+
if (!(t != null && t.startsWith(R)))
|
|
136
|
+
throw new Error(`Expected content-type to be ${R}, Actual: ${t}`);
|
|
137
137
|
}
|
|
138
|
-
function
|
|
139
|
-
const t = atob(e),
|
|
140
|
-
for (let
|
|
141
|
-
n
|
|
142
|
-
return new TextDecoder("utf-8").decode(
|
|
138
|
+
function de(e) {
|
|
139
|
+
const t = atob(e), r = new Uint8Array(t.length);
|
|
140
|
+
for (let n = 0; n < t.length; n++)
|
|
141
|
+
r[n] = t.charCodeAt(n);
|
|
142
|
+
return new TextDecoder("utf-8").decode(r);
|
|
143
143
|
}
|
|
144
|
-
class
|
|
144
|
+
class ue {
|
|
145
145
|
constructor(t) {
|
|
146
146
|
this.eventSources = /* @__PURE__ */ new Map(), this.subscribers = /* @__PURE__ */ new Map(), this.fency = t;
|
|
147
147
|
}
|
|
@@ -150,37 +150,37 @@ class de {
|
|
|
150
150
|
* Creates new connections and removes old ones.
|
|
151
151
|
*/
|
|
152
152
|
updateStreams(t) {
|
|
153
|
-
t.forEach((
|
|
154
|
-
const
|
|
155
|
-
this.eventSources.has(
|
|
153
|
+
t.forEach((n) => {
|
|
154
|
+
const s = n.stream.id;
|
|
155
|
+
this.eventSources.has(s) || this.connectStream(n);
|
|
156
156
|
});
|
|
157
|
-
const
|
|
158
|
-
this.eventSources.forEach((
|
|
159
|
-
|
|
157
|
+
const r = new Set(t.map((n) => n.stream.id));
|
|
158
|
+
this.eventSources.forEach((n, s) => {
|
|
159
|
+
r.has(s) || (n.abort(), this.eventSources.delete(s));
|
|
160
160
|
});
|
|
161
161
|
}
|
|
162
162
|
connectStream(t) {
|
|
163
|
-
const
|
|
164
|
-
this.eventSources.set(
|
|
165
|
-
const
|
|
163
|
+
const r = t.stream.id, n = new AbortController();
|
|
164
|
+
this.eventSources.set(r, n);
|
|
165
|
+
const s = `${this.fency.baseUrl}/sse/streams/${r}`, d = {
|
|
166
166
|
"X-Fency-Publishable-Key": this.fency.publishableKey,
|
|
167
167
|
"X-Fency-Stream-Token": t.stream.token
|
|
168
168
|
};
|
|
169
|
-
|
|
170
|
-
headers:
|
|
171
|
-
signal:
|
|
169
|
+
le(s, {
|
|
170
|
+
headers: d,
|
|
171
|
+
signal: n.signal,
|
|
172
172
|
async onopen(o) {
|
|
173
173
|
if (!o.ok && o.status >= 400 && o.status < 500 && o.status !== 429)
|
|
174
174
|
throw new Error(`Client error ${o.status}`);
|
|
175
175
|
},
|
|
176
176
|
onmessage: (o) => {
|
|
177
177
|
if (o.data) {
|
|
178
|
-
const
|
|
179
|
-
this.broadcast(
|
|
178
|
+
const l = de(o.data);
|
|
179
|
+
this.broadcast(l, r);
|
|
180
180
|
}
|
|
181
181
|
},
|
|
182
182
|
onerror: (o) => {
|
|
183
|
-
throw console.error("EventSource error for stream",
|
|
183
|
+
throw console.error("EventSource error for stream", r, ":", o), this.broadcastError(r), o;
|
|
184
184
|
},
|
|
185
185
|
onclose() {
|
|
186
186
|
}
|
|
@@ -190,19 +190,19 @@ class de {
|
|
|
190
190
|
* Subscribe to events from all active streams.
|
|
191
191
|
* Returns an unsubscribe function.
|
|
192
192
|
*/
|
|
193
|
-
subscribe(t,
|
|
194
|
-
return this.subscribers.set(t,
|
|
193
|
+
subscribe(t, r) {
|
|
194
|
+
return this.subscribers.set(t, r), () => {
|
|
195
195
|
this.subscribers.delete(t);
|
|
196
196
|
};
|
|
197
197
|
}
|
|
198
|
-
broadcast(t,
|
|
199
|
-
this.subscribers.forEach((
|
|
200
|
-
|
|
198
|
+
broadcast(t, r) {
|
|
199
|
+
this.subscribers.forEach((n) => {
|
|
200
|
+
n.onMessage(t, r);
|
|
201
201
|
});
|
|
202
202
|
}
|
|
203
203
|
broadcastError(t) {
|
|
204
|
-
this.subscribers.forEach((
|
|
205
|
-
|
|
204
|
+
this.subscribers.forEach((r) => {
|
|
205
|
+
r.onError(t);
|
|
206
206
|
});
|
|
207
207
|
}
|
|
208
208
|
/**
|
|
@@ -212,76 +212,76 @@ class de {
|
|
|
212
212
|
this.eventSources.forEach((t) => t.abort()), this.eventSources.clear(), this.subscribers.clear();
|
|
213
213
|
}
|
|
214
214
|
}
|
|
215
|
-
const
|
|
215
|
+
const me = 12e4, ge = (e) => {
|
|
216
216
|
const t = Date.now();
|
|
217
|
-
return e.filter((
|
|
217
|
+
return e.filter((r) => t - r.createdAt < me);
|
|
218
218
|
};
|
|
219
|
-
function
|
|
220
|
-
const [
|
|
219
|
+
function We({ fency: e, fetchCreateStreamClientToken: t, children: r }) {
|
|
220
|
+
const [n, s] = v(
|
|
221
221
|
null
|
|
222
|
-
), [
|
|
223
|
-
|
|
224
|
-
e.then((
|
|
225
|
-
|
|
226
|
-
}).catch((
|
|
227
|
-
y(
|
|
222
|
+
), [d, o] = v(!0), [l, y] = v(null), [a, c] = v([]), m = w(null), u = w(null);
|
|
223
|
+
E(() => {
|
|
224
|
+
e.then((p) => {
|
|
225
|
+
s(p), o(!1);
|
|
226
|
+
}).catch((p) => {
|
|
227
|
+
y(p), o(!1);
|
|
228
228
|
});
|
|
229
|
-
}, [e]),
|
|
230
|
-
|
|
231
|
-
}, [
|
|
229
|
+
}, [e]), E(() => {
|
|
230
|
+
n && !u.current && (u.current = new ue(n));
|
|
231
|
+
}, [n]), E(() => {
|
|
232
232
|
u.current && u.current.updateStreams(a);
|
|
233
|
-
}, [a]),
|
|
234
|
-
var
|
|
235
|
-
(
|
|
233
|
+
}, [a]), E(() => () => {
|
|
234
|
+
var p;
|
|
235
|
+
(p = u.current) == null || p.cleanup();
|
|
236
236
|
}, []);
|
|
237
|
-
const f =
|
|
238
|
-
async (
|
|
237
|
+
const f = _(
|
|
238
|
+
async (p = 3e4) => {
|
|
239
239
|
if (m.current)
|
|
240
240
|
return m.current;
|
|
241
|
-
const S = Date.now(),
|
|
242
|
-
if (
|
|
243
|
-
return
|
|
244
|
-
const
|
|
245
|
-
if (!
|
|
241
|
+
const S = Date.now(), T = a.length > 0 ? a[a.length - 1] : null;
|
|
242
|
+
if (T && S - T.createdAt < p)
|
|
243
|
+
return T.stream;
|
|
244
|
+
const P = (async () => {
|
|
245
|
+
if (!n)
|
|
246
246
|
throw new Error("Fency instance not initialized");
|
|
247
|
-
const I = await t(),
|
|
248
|
-
pk:
|
|
249
|
-
baseUrl:
|
|
247
|
+
const I = await t(), C = await G({
|
|
248
|
+
pk: n.publishableKey,
|
|
249
|
+
baseUrl: n.baseUrl,
|
|
250
250
|
clientToken: (I == null ? void 0 : I.clientToken) ?? ""
|
|
251
251
|
});
|
|
252
|
-
if (
|
|
252
|
+
if (C.type === "success") {
|
|
253
253
|
const M = {
|
|
254
|
-
stream:
|
|
254
|
+
stream: C.stream,
|
|
255
255
|
createdAt: Date.now()
|
|
256
256
|
};
|
|
257
|
-
return
|
|
258
|
-
const
|
|
259
|
-
return
|
|
260
|
-
}), m.current = null,
|
|
257
|
+
return c((A) => {
|
|
258
|
+
const b = [...A, M];
|
|
259
|
+
return ge(b);
|
|
260
|
+
}), m.current = null, C.stream;
|
|
261
261
|
} else
|
|
262
262
|
throw m.current = null, new Error("Failed to create stream");
|
|
263
263
|
})();
|
|
264
|
-
return m.current =
|
|
264
|
+
return m.current = P, P;
|
|
265
265
|
},
|
|
266
|
-
[
|
|
266
|
+
[n, a]
|
|
267
267
|
);
|
|
268
|
-
if (
|
|
269
|
-
return /* @__PURE__ */
|
|
268
|
+
if (l)
|
|
269
|
+
return /* @__PURE__ */ x("div", { children: [
|
|
270
270
|
"Fency error: ",
|
|
271
|
-
|
|
271
|
+
l.message
|
|
272
272
|
] });
|
|
273
|
-
if (!
|
|
273
|
+
if (!n)
|
|
274
274
|
return null;
|
|
275
|
-
const g = a.length > 0 ? a[a.length - 1] : null,
|
|
276
|
-
fency:
|
|
277
|
-
loading:
|
|
278
|
-
error:
|
|
275
|
+
const g = a.length > 0 ? a[a.length - 1] : null, h = {
|
|
276
|
+
fency: n,
|
|
277
|
+
loading: d,
|
|
278
|
+
error: l,
|
|
279
279
|
activeStreams: a,
|
|
280
280
|
latestStream: g,
|
|
281
281
|
eventManager: u.current,
|
|
282
282
|
getOrCreateStream: f
|
|
283
283
|
};
|
|
284
|
-
return /* @__PURE__ */
|
|
284
|
+
return /* @__PURE__ */ i(W.Provider, { value: h, children: r });
|
|
285
285
|
}
|
|
286
286
|
function H() {
|
|
287
287
|
const e = Q(W);
|
|
@@ -289,14 +289,14 @@ function H() {
|
|
|
289
289
|
throw new Error("useFencyContext must be used within a FencyProvider");
|
|
290
290
|
return e;
|
|
291
291
|
}
|
|
292
|
-
const
|
|
292
|
+
const ye = (e) => {
|
|
293
293
|
try {
|
|
294
294
|
const t = JSON.parse(e);
|
|
295
|
-
return
|
|
295
|
+
return fe(t);
|
|
296
296
|
} catch (t) {
|
|
297
297
|
return console.error("Error parsing message:", t), null;
|
|
298
298
|
}
|
|
299
|
-
},
|
|
299
|
+
}, fe = (e) => J(e) ? pe(e) : V(e) ? he(e) : X(e) ? Se(e) : null, pe = (e) => ({
|
|
300
300
|
type: "STREAM_TIMEOUT",
|
|
301
301
|
streamId: e.streamId,
|
|
302
302
|
timestamp: e.timestamp
|
|
@@ -304,7 +304,7 @@ const ge = (e) => {
|
|
|
304
304
|
type: "STREAM_NOT_FOUND",
|
|
305
305
|
streamId: e.streamId,
|
|
306
306
|
timestamp: e.timestamp
|
|
307
|
-
}),
|
|
307
|
+
}), Se = (e) => ({
|
|
308
308
|
type: "AGENT_TASK_PROGRESS_ITEM_UPDATED",
|
|
309
309
|
streamId: e.streamId,
|
|
310
310
|
agentTaskId: e.agentTaskId,
|
|
@@ -312,24 +312,24 @@ const ge = (e) => {
|
|
|
312
312
|
timestamp: e.timestamp,
|
|
313
313
|
createdAt: e.createdAt,
|
|
314
314
|
data: JSON.parse(e.data)
|
|
315
|
-
}),
|
|
316
|
-
const t = H(), [
|
|
317
|
-
return
|
|
315
|
+
}), Te = (e) => {
|
|
316
|
+
const t = H(), [r, n] = v(null), s = w(`subscriber-${Math.random().toString(36).substr(2, 9)}`);
|
|
317
|
+
return E(() => {
|
|
318
318
|
if (!t.eventManager) return;
|
|
319
319
|
const o = {
|
|
320
320
|
onMessage: (y, a) => {
|
|
321
321
|
var m, u, f;
|
|
322
|
-
const
|
|
323
|
-
if (
|
|
324
|
-
switch (
|
|
322
|
+
const c = ye(y);
|
|
323
|
+
if (c)
|
|
324
|
+
switch (c.type) {
|
|
325
325
|
case "STREAM_TIMEOUT":
|
|
326
|
-
(m = e == null ? void 0 : e.onStreamTimeout) == null || m.call(e,
|
|
326
|
+
(m = e == null ? void 0 : e.onStreamTimeout) == null || m.call(e, c);
|
|
327
327
|
break;
|
|
328
328
|
case "STREAM_NOT_FOUND":
|
|
329
|
-
(u = e == null ? void 0 : e.onStreamNotFound) == null || u.call(e,
|
|
329
|
+
(u = e == null ? void 0 : e.onStreamNotFound) == null || u.call(e, c);
|
|
330
330
|
break;
|
|
331
331
|
case "AGENT_TASK_PROGRESS_ITEM_UPDATED":
|
|
332
|
-
(f = e == null ? void 0 : e.onAgentTaskProgressItemUpdated) == null || f.call(e,
|
|
332
|
+
(f = e == null ? void 0 : e.onAgentTaskProgressItemUpdated) == null || f.call(e, c);
|
|
333
333
|
break;
|
|
334
334
|
}
|
|
335
335
|
},
|
|
@@ -345,14 +345,14 @@ const ge = (e) => {
|
|
|
345
345
|
}
|
|
346
346
|
};
|
|
347
347
|
return t.eventManager.subscribe(
|
|
348
|
-
|
|
348
|
+
s.current,
|
|
349
349
|
o
|
|
350
350
|
);
|
|
351
351
|
}, [t.eventManager, e]), {
|
|
352
352
|
createStream: async () => {
|
|
353
353
|
try {
|
|
354
354
|
const o = await t.getOrCreateStream(3e4);
|
|
355
|
-
return
|
|
355
|
+
return n(o), {
|
|
356
356
|
type: "success",
|
|
357
357
|
stream: o
|
|
358
358
|
};
|
|
@@ -366,38 +366,38 @@ const ge = (e) => {
|
|
|
366
366
|
};
|
|
367
367
|
}
|
|
368
368
|
},
|
|
369
|
-
stream:
|
|
369
|
+
stream: r
|
|
370
370
|
};
|
|
371
|
-
},
|
|
372
|
-
const t = H(), [
|
|
371
|
+
}, He = (e) => {
|
|
372
|
+
const t = H(), [r, n] = v([]), s = w(/* @__PURE__ */ new Set()), d = w(/* @__PURE__ */ new Map()), { createStream: o } = Te({
|
|
373
373
|
onAgentTaskProgressItemUpdated: (a) => {
|
|
374
374
|
var u;
|
|
375
|
-
if (!
|
|
376
|
-
const
|
|
377
|
-
if (
|
|
378
|
-
const f =
|
|
375
|
+
if (!s.current.has(a.agentTaskId)) return;
|
|
376
|
+
const c = a.data;
|
|
377
|
+
if (c.taskType === "StreamingChatCompletion" && c.eventType === "Completed" || c.taskType === "StructuredChatCompletion" && c.eventType === "Completed" || c.taskType === "MemoryChatCompletion" && c.eventType === "Completed") {
|
|
378
|
+
const f = d.current.get(
|
|
379
379
|
a.agentTaskId
|
|
380
380
|
);
|
|
381
|
-
f && (
|
|
381
|
+
f && (d.current.delete(a.agentTaskId), f(c));
|
|
382
382
|
return;
|
|
383
383
|
}
|
|
384
|
-
(u = e.onAgentTaskProgressItemUpdated) == null || u.call(e, a),
|
|
384
|
+
(u = e.onAgentTaskProgressItemUpdated) == null || u.call(e, a), n(
|
|
385
385
|
(f) => f.map((g) => {
|
|
386
386
|
var S;
|
|
387
387
|
if (((S = g.confirmedData) == null ? void 0 : S.taskId) !== a.agentTaskId)
|
|
388
388
|
return g;
|
|
389
|
-
const
|
|
390
|
-
(
|
|
389
|
+
const p = g.progressItems.some(
|
|
390
|
+
(T) => T.progressItemId === a.progressItemId
|
|
391
391
|
) ? g.progressItems.map(
|
|
392
|
-
(
|
|
392
|
+
(T) => T.progressItemId === a.progressItemId ? a : T
|
|
393
393
|
) : [...g.progressItems, a];
|
|
394
|
-
return { ...g, progressItems:
|
|
394
|
+
return { ...g, progressItems: p };
|
|
395
395
|
})
|
|
396
396
|
);
|
|
397
397
|
},
|
|
398
398
|
onStreamError: (a) => {
|
|
399
|
-
var
|
|
400
|
-
(
|
|
399
|
+
var c;
|
|
400
|
+
(c = e == null ? void 0 : e.onStreamError) == null || c.call(e, a), n((m) => {
|
|
401
401
|
const u = m.find((f) => f.streamId === a.streamId);
|
|
402
402
|
return u ? [
|
|
403
403
|
...m.filter((f) => f.streamId !== a.streamId),
|
|
@@ -410,19 +410,19 @@ const ge = (e) => {
|
|
|
410
410
|
});
|
|
411
411
|
},
|
|
412
412
|
onStreamNotFound: (a) => {
|
|
413
|
-
var
|
|
414
|
-
(
|
|
413
|
+
var c;
|
|
414
|
+
(c = e == null ? void 0 : e.onStreamNotFound) == null || c.call(e, a);
|
|
415
415
|
},
|
|
416
416
|
onStreamTimeout: (a) => {
|
|
417
|
-
var
|
|
418
|
-
(
|
|
417
|
+
var c;
|
|
418
|
+
(c = e == null ? void 0 : e.onStreamTimeout) == null || c.call(e, a);
|
|
419
419
|
}
|
|
420
|
-
}),
|
|
421
|
-
async (a,
|
|
420
|
+
}), l = _(
|
|
421
|
+
async (a, c) => {
|
|
422
422
|
const m = `task-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`, u = await o();
|
|
423
423
|
if (u.type === "success") {
|
|
424
|
-
|
|
425
|
-
...
|
|
424
|
+
n([
|
|
425
|
+
...r,
|
|
426
426
|
{
|
|
427
427
|
taskKey: m,
|
|
428
428
|
streamId: u.stream.id,
|
|
@@ -432,10 +432,10 @@ const ge = (e) => {
|
|
|
432
432
|
params: a,
|
|
433
433
|
progressItems: [],
|
|
434
434
|
loading: !0,
|
|
435
|
-
loadingText:
|
|
435
|
+
loadingText: c == null ? void 0 : c.loadingText
|
|
436
436
|
}
|
|
437
437
|
]);
|
|
438
|
-
const { clientToken: f } = await e.fetchCreateAgentTaskClientToken(a.type), g = await
|
|
438
|
+
const { clientToken: f } = await e.fetchCreateAgentTaskClientToken(a.type), g = await q({
|
|
439
439
|
pk: t.fency.publishableKey,
|
|
440
440
|
baseUrl: t.fency.baseUrl,
|
|
441
441
|
clientToken: f,
|
|
@@ -452,15 +452,18 @@ const ge = (e) => {
|
|
|
452
452
|
} : void 0,
|
|
453
453
|
memoryChatCompletionTask: a.type === "MemoryChatCompletion" ? {
|
|
454
454
|
messages: a.messages,
|
|
455
|
-
model: a.model
|
|
455
|
+
model: a.model,
|
|
456
|
+
language: a.language ?? "en",
|
|
457
|
+
chunkLimit: a.chunkLimit ?? 10,
|
|
458
|
+
memoryScanLimit: a.memoryScanLimit ?? 3
|
|
456
459
|
} : void 0
|
|
457
460
|
}
|
|
458
461
|
});
|
|
459
462
|
if (g.type === "success" && g.agentTask) {
|
|
460
|
-
|
|
463
|
+
s.current.add(
|
|
461
464
|
g.agentTask.id
|
|
462
|
-
),
|
|
463
|
-
...
|
|
465
|
+
), n((p) => [
|
|
466
|
+
...p.filter((S) => S.taskKey !== m),
|
|
464
467
|
{
|
|
465
468
|
taskKey: m,
|
|
466
469
|
streamId: u.stream.id,
|
|
@@ -471,29 +474,29 @@ const ge = (e) => {
|
|
|
471
474
|
params: a,
|
|
472
475
|
progressItems: [],
|
|
473
476
|
loading: !0,
|
|
474
|
-
loadingText:
|
|
477
|
+
loadingText: c == null ? void 0 : c.loadingText,
|
|
475
478
|
confirmedData: {
|
|
476
479
|
taskId: g.agentTask.id,
|
|
477
480
|
createdAt: g.agentTask.createdAt
|
|
478
481
|
}
|
|
479
482
|
}
|
|
480
483
|
]);
|
|
481
|
-
const
|
|
482
|
-
|
|
484
|
+
const h = await new Promise((p) => {
|
|
485
|
+
d.current.set(
|
|
483
486
|
g.agentTask.id,
|
|
484
|
-
|
|
487
|
+
p
|
|
485
488
|
);
|
|
486
489
|
});
|
|
487
490
|
return {
|
|
488
491
|
type: "success",
|
|
489
492
|
streamId: u.stream.id,
|
|
490
493
|
agentTaskId: g.agentTask.id,
|
|
491
|
-
response:
|
|
494
|
+
response: h
|
|
492
495
|
};
|
|
493
496
|
} else {
|
|
494
497
|
if (g.type === "error")
|
|
495
|
-
return
|
|
496
|
-
...
|
|
498
|
+
return n((h) => [
|
|
499
|
+
...h.filter((p) => p.taskKey !== m),
|
|
497
500
|
{
|
|
498
501
|
taskKey: m,
|
|
499
502
|
triggeredAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -502,7 +505,7 @@ const ge = (e) => {
|
|
|
502
505
|
error: g.error,
|
|
503
506
|
progressItems: [],
|
|
504
507
|
loading: !1,
|
|
505
|
-
loadingText:
|
|
508
|
+
loadingText: c == null ? void 0 : c.loadingText,
|
|
506
509
|
confirmedData: null
|
|
507
510
|
}
|
|
508
511
|
]), {
|
|
@@ -510,82 +513,82 @@ const ge = (e) => {
|
|
|
510
513
|
error: g.error
|
|
511
514
|
};
|
|
512
515
|
{
|
|
513
|
-
const
|
|
516
|
+
const h = {
|
|
514
517
|
message: "No response received",
|
|
515
518
|
code: "UnknownError"
|
|
516
519
|
};
|
|
517
|
-
return
|
|
518
|
-
...
|
|
520
|
+
return n((p) => [
|
|
521
|
+
...p.filter((S) => S.taskKey !== m),
|
|
519
522
|
{
|
|
520
523
|
taskKey: m,
|
|
521
524
|
triggeredAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
522
525
|
streamId: u.stream.id,
|
|
523
|
-
error:
|
|
526
|
+
error: h,
|
|
524
527
|
params: a,
|
|
525
528
|
progressItems: [],
|
|
526
529
|
loading: !1,
|
|
527
|
-
loadingText:
|
|
530
|
+
loadingText: c == null ? void 0 : c.loadingText,
|
|
528
531
|
confirmedData: null
|
|
529
532
|
}
|
|
530
533
|
]), {
|
|
531
534
|
type: "error",
|
|
532
|
-
error:
|
|
535
|
+
error: h
|
|
533
536
|
};
|
|
534
537
|
}
|
|
535
538
|
}
|
|
536
539
|
} else
|
|
537
540
|
return console.error(u.error), u;
|
|
538
541
|
},
|
|
539
|
-
[t,
|
|
540
|
-
), y =
|
|
541
|
-
if (
|
|
542
|
-
return [...
|
|
543
|
-
}, [
|
|
544
|
-
return
|
|
545
|
-
|
|
542
|
+
[t, r, o]
|
|
543
|
+
), y = z(() => {
|
|
544
|
+
if (r.length !== 0)
|
|
545
|
+
return [...r].sort((a, c) => new Date(c.triggeredAt).getTime() - new Date(a.triggeredAt).getTime())[0];
|
|
546
|
+
}, [r]);
|
|
547
|
+
return E(() => () => {
|
|
548
|
+
s.current.clear(), d.current.clear();
|
|
546
549
|
}, []), {
|
|
547
|
-
agentTasks:
|
|
548
|
-
createAgentTask:
|
|
550
|
+
agentTasks: r,
|
|
551
|
+
createAgentTask: l,
|
|
549
552
|
latest: y
|
|
550
553
|
};
|
|
551
554
|
};
|
|
552
|
-
function
|
|
553
|
-
return e.progressItems.map((t,
|
|
554
|
-
const
|
|
555
|
-
let
|
|
556
|
-
if (
|
|
557
|
-
const o = new Date(t.createdAt).getTime(),
|
|
558
|
-
|
|
555
|
+
function ke(e) {
|
|
556
|
+
return e.progressItems.map((t, r) => {
|
|
557
|
+
const n = e.progressItems[r + 1], s = n != null;
|
|
558
|
+
let d;
|
|
559
|
+
if (n != null && n.createdAt) {
|
|
560
|
+
const o = new Date(t.createdAt).getTime(), l = new Date(n.createdAt).getTime();
|
|
561
|
+
d = Math.round((l - o) / 1e3);
|
|
559
562
|
}
|
|
560
563
|
return {
|
|
561
564
|
item: t,
|
|
562
|
-
completed:
|
|
563
|
-
isLatest:
|
|
564
|
-
durationSeconds:
|
|
565
|
+
completed: s,
|
|
566
|
+
isLatest: r === e.progressItems.length - 1,
|
|
567
|
+
durationSeconds: d
|
|
565
568
|
};
|
|
566
569
|
});
|
|
567
570
|
}
|
|
568
571
|
function O({
|
|
569
572
|
text: e,
|
|
570
573
|
duration: t = 2,
|
|
571
|
-
delay:
|
|
572
|
-
repeat:
|
|
573
|
-
repeatDelay:
|
|
574
|
-
className:
|
|
574
|
+
delay: r = 0,
|
|
575
|
+
repeat: n = !0,
|
|
576
|
+
repeatDelay: s = 0.5,
|
|
577
|
+
className: d,
|
|
575
578
|
startOnView: o = !1,
|
|
576
|
-
once:
|
|
579
|
+
once: l = !1,
|
|
577
580
|
inViewMargin: y,
|
|
578
581
|
spread: a = 2,
|
|
579
|
-
color:
|
|
582
|
+
color: c = "#999",
|
|
580
583
|
shimmerColor: m = "#000",
|
|
581
584
|
direction: u = "fromBottom"
|
|
582
585
|
}) {
|
|
583
|
-
const f =
|
|
584
|
-
return /* @__PURE__ */
|
|
585
|
-
|
|
586
|
+
const f = w(null), g = Z(f, { once: l, margin: y }), h = z(() => e.length * a, [e, a]), p = !o || g, S = u === "fromBottom" ? "100% center" : "-100% center", T = u === "fromBottom" ? "0% center" : "200% center";
|
|
587
|
+
return /* @__PURE__ */ i(
|
|
588
|
+
k.span,
|
|
586
589
|
{
|
|
587
590
|
ref: f,
|
|
588
|
-
className:
|
|
591
|
+
className: d,
|
|
589
592
|
style: {
|
|
590
593
|
position: "relative",
|
|
591
594
|
display: "inline-block",
|
|
@@ -595,8 +598,8 @@ function O({
|
|
|
595
598
|
color: "transparent",
|
|
596
599
|
WebkitTextFillColor: "transparent",
|
|
597
600
|
backgroundRepeat: "no-repeat, padding-box",
|
|
598
|
-
"--spread": `${
|
|
599
|
-
"--base-color":
|
|
601
|
+
"--spread": `${h}px`,
|
|
602
|
+
"--base-color": c,
|
|
600
603
|
"--shimmer-color": m,
|
|
601
604
|
"--shimmer-bg": "linear-gradient(90deg, transparent calc(50% - var(--spread)), var(--shimmer-color), transparent calc(50% + var(--spread)))",
|
|
602
605
|
backgroundImage: "var(--shimmer-bg), linear-gradient(var(--base-color), var(--base-color))"
|
|
@@ -605,79 +608,79 @@ function O({
|
|
|
605
608
|
backgroundPosition: S,
|
|
606
609
|
opacity: 0
|
|
607
610
|
},
|
|
608
|
-
animate:
|
|
609
|
-
backgroundPosition:
|
|
611
|
+
animate: p ? {
|
|
612
|
+
backgroundPosition: T,
|
|
610
613
|
opacity: 1
|
|
611
614
|
} : {},
|
|
612
615
|
transition: {
|
|
613
616
|
backgroundPosition: {
|
|
614
|
-
repeat:
|
|
617
|
+
repeat: n ? 1 / 0 : 0,
|
|
615
618
|
duration: t,
|
|
616
|
-
delay:
|
|
617
|
-
repeatDelay:
|
|
619
|
+
delay: r,
|
|
620
|
+
repeatDelay: s,
|
|
618
621
|
ease: "linear"
|
|
619
622
|
},
|
|
620
623
|
opacity: {
|
|
621
624
|
duration: 0.3,
|
|
622
|
-
delay:
|
|
625
|
+
delay: r
|
|
623
626
|
}
|
|
624
627
|
},
|
|
625
628
|
children: e
|
|
626
629
|
}
|
|
627
630
|
);
|
|
628
631
|
}
|
|
629
|
-
function
|
|
630
|
-
const
|
|
631
|
-
if (
|
|
632
|
-
return
|
|
633
|
-
if (
|
|
634
|
-
if (
|
|
635
|
-
if (
|
|
632
|
+
function be(e, t) {
|
|
633
|
+
const r = e.item.data;
|
|
634
|
+
if (r.eventType === "Error" && "message" in r)
|
|
635
|
+
return t.error;
|
|
636
|
+
if (r.taskType === "StreamingChatCompletion") {
|
|
637
|
+
if (r.eventType === "Text") return t.streaming;
|
|
638
|
+
if (r.eventType === "Completed") return t.completed;
|
|
636
639
|
}
|
|
637
|
-
if (
|
|
638
|
-
if (
|
|
639
|
-
if (
|
|
640
|
+
if (r.taskType === "StructuredChatCompletion") {
|
|
641
|
+
if (r.eventType === "Json") return t.generating;
|
|
642
|
+
if (r.eventType === "Completed") return t.completed;
|
|
640
643
|
}
|
|
641
|
-
if (
|
|
642
|
-
switch (
|
|
644
|
+
if (r.taskType === "MemoryChatCompletion")
|
|
645
|
+
switch (r.eventType) {
|
|
643
646
|
case "Text":
|
|
644
|
-
return
|
|
647
|
+
return t.streaming;
|
|
645
648
|
case "Search":
|
|
646
|
-
return
|
|
649
|
+
return t.searching;
|
|
647
650
|
case "FindSources":
|
|
648
|
-
return
|
|
651
|
+
return t.addingSources;
|
|
649
652
|
case "SourcesResult":
|
|
650
|
-
return
|
|
653
|
+
return t.sourcesAdded;
|
|
651
654
|
case "ExploreMemoryStart":
|
|
652
|
-
return
|
|
655
|
+
return t.exploringMemory;
|
|
653
656
|
case "ExploreMemoryResult":
|
|
654
|
-
return
|
|
657
|
+
return t.memoryExplored;
|
|
655
658
|
case "ExploreMemoryError":
|
|
656
|
-
return
|
|
659
|
+
return t.memoryExplorationFailed;
|
|
657
660
|
case "Completed":
|
|
658
|
-
return
|
|
661
|
+
return t.completed;
|
|
659
662
|
}
|
|
660
|
-
return
|
|
663
|
+
return t.processing;
|
|
661
664
|
}
|
|
662
|
-
const
|
|
663
|
-
const
|
|
664
|
-
if (!
|
|
665
|
-
const n =
|
|
666
|
-
return /* @__PURE__ */
|
|
667
|
-
|
|
665
|
+
const ve = ({ progressViewItems: e, t }) => {
|
|
666
|
+
const r = e[e.length - 1];
|
|
667
|
+
if (!r) return null;
|
|
668
|
+
const n = be(r, t);
|
|
669
|
+
return /* @__PURE__ */ i("div", { className: "simple-mode-container", children: /* @__PURE__ */ i($, { mode: "wait", children: /* @__PURE__ */ i(
|
|
670
|
+
k.div,
|
|
668
671
|
{
|
|
669
672
|
initial: { opacity: 0, y: 10 },
|
|
670
673
|
animate: { opacity: 1, y: 0 },
|
|
671
674
|
exit: { opacity: 0, y: -10 },
|
|
672
675
|
transition: { duration: 0.3 },
|
|
673
|
-
children:
|
|
676
|
+
children: r.completed ? /* @__PURE__ */ i(
|
|
674
677
|
"div",
|
|
675
678
|
{
|
|
676
679
|
className: "simple-mode-title",
|
|
677
680
|
style: { color: "#666" },
|
|
678
681
|
children: n
|
|
679
682
|
}
|
|
680
|
-
) : /* @__PURE__ */
|
|
683
|
+
) : /* @__PURE__ */ i(
|
|
681
684
|
O,
|
|
682
685
|
{
|
|
683
686
|
text: n,
|
|
@@ -689,9 +692,9 @@ const Te = ({ progressViewItems: e }) => {
|
|
|
689
692
|
}
|
|
690
693
|
)
|
|
691
694
|
},
|
|
692
|
-
|
|
695
|
+
r.item.progressItemId
|
|
693
696
|
) }) });
|
|
694
|
-
},
|
|
697
|
+
}, K = {
|
|
695
698
|
'code[class*="language-"]': {
|
|
696
699
|
color: "#f8f8f2",
|
|
697
700
|
background: "none",
|
|
@@ -842,57 +845,114 @@ const Te = ({ progressViewItems: e }) => {
|
|
|
842
845
|
italic: {
|
|
843
846
|
fontStyle: "italic"
|
|
844
847
|
}
|
|
845
|
-
},
|
|
848
|
+
}, L = ({
|
|
846
849
|
text: e
|
|
847
|
-
}) => /* @__PURE__ */
|
|
848
|
-
|
|
850
|
+
}) => /* @__PURE__ */ i("div", { style: { padding: "16px" }, children: /* @__PURE__ */ i(
|
|
851
|
+
k.div,
|
|
849
852
|
{
|
|
850
853
|
className: "fency-markdown-body-raw",
|
|
851
854
|
initial: { opacity: 0, y: -10 },
|
|
852
855
|
animate: { opacity: 1, y: 0 },
|
|
853
856
|
transition: { duration: 0.3, delay: 0 },
|
|
854
|
-
children: /* @__PURE__ */
|
|
855
|
-
|
|
857
|
+
children: /* @__PURE__ */ i(
|
|
858
|
+
ee,
|
|
856
859
|
{
|
|
857
|
-
remarkPlugins: [
|
|
860
|
+
remarkPlugins: [te],
|
|
858
861
|
components: {
|
|
859
862
|
code(t) {
|
|
860
|
-
const { children:
|
|
861
|
-
return
|
|
863
|
+
const { children: r, className: n, node: s, ref: d, ...o } = t, l = /language-(\w+)/.exec(n || "");
|
|
864
|
+
return l ? (
|
|
862
865
|
// @ts-expect-error react-syntax-highlighter types incompatible with @types/react 18
|
|
863
|
-
/* @__PURE__ */
|
|
864
|
-
|
|
866
|
+
/* @__PURE__ */ i(
|
|
867
|
+
j,
|
|
865
868
|
{
|
|
866
869
|
...o,
|
|
867
870
|
PreTag: "div",
|
|
868
|
-
children: String(
|
|
869
|
-
language:
|
|
870
|
-
style:
|
|
871
|
+
children: String(r).replace(/\n$/, ""),
|
|
872
|
+
language: l[1],
|
|
873
|
+
style: K
|
|
871
874
|
}
|
|
872
875
|
)
|
|
873
|
-
) : /* @__PURE__ */
|
|
876
|
+
) : /* @__PURE__ */ i("code", { ...o, className: n, children: String(r) });
|
|
874
877
|
}
|
|
875
878
|
},
|
|
876
879
|
children: e
|
|
877
880
|
}
|
|
878
881
|
)
|
|
879
882
|
}
|
|
880
|
-
) }),
|
|
883
|
+
) }), xe = ({ data: e }) => {
|
|
881
884
|
const t = JSON.stringify(e.json, null, 2);
|
|
882
|
-
return /* @__PURE__ */
|
|
883
|
-
|
|
885
|
+
return /* @__PURE__ */ i("div", { id: "structured-chat-completion-response", children: /* @__PURE__ */ i(
|
|
886
|
+
k.div,
|
|
884
887
|
{
|
|
885
888
|
initial: { opacity: 0, y: -10 },
|
|
886
889
|
animate: { opacity: 1, y: 0 },
|
|
887
890
|
transition: { duration: 0.3, delay: 0 },
|
|
888
|
-
children: /* @__PURE__ */
|
|
891
|
+
children: /* @__PURE__ */ i(j, { language: "json", style: K, PreTag: "div", children: t })
|
|
889
892
|
}
|
|
890
893
|
) });
|
|
891
|
-
},
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
894
|
+
}, Ce = {
|
|
895
|
+
en: {
|
|
896
|
+
error: "Error",
|
|
897
|
+
streaming: "Streaming...",
|
|
898
|
+
completed: "Completed",
|
|
899
|
+
generating: "Generating...",
|
|
900
|
+
searching: "Searching...",
|
|
901
|
+
addingSources: "Adding sources...",
|
|
902
|
+
sourcesAdded: "Sources added...",
|
|
903
|
+
exploringMemory: "Exploring memory...",
|
|
904
|
+
memoryExplored: "Memory explored",
|
|
905
|
+
memoryExplorationFailed: "Memory exploration failed",
|
|
906
|
+
processing: "Processing...",
|
|
907
|
+
processingYourTask: "Processing your task...",
|
|
908
|
+
searchingPrefix: "Searching: ",
|
|
909
|
+
tookSeconds: "Took {n} seconds",
|
|
910
|
+
sources: "Sources",
|
|
911
|
+
noSources: "No sources",
|
|
912
|
+
pageSingle: "page {n}",
|
|
913
|
+
pageTwo: "pages {a} and {b}",
|
|
914
|
+
pageMultiple: "pages {list} and {n}",
|
|
915
|
+
clickToCollapse: "Click to collapse",
|
|
916
|
+
clickToExpand: "Click to expand"
|
|
917
|
+
},
|
|
918
|
+
no: {
|
|
919
|
+
error: "Feil",
|
|
920
|
+
streaming: "Strømmer...",
|
|
921
|
+
completed: "Fullført",
|
|
922
|
+
generating: "Genererer...",
|
|
923
|
+
searching: "Søker...",
|
|
924
|
+
addingSources: "Legger til kilder...",
|
|
925
|
+
sourcesAdded: "Kilder lagt til...",
|
|
926
|
+
exploringMemory: "Utforsker minne...",
|
|
927
|
+
memoryExplored: "Minne utforsket",
|
|
928
|
+
memoryExplorationFailed: "Minneutforskning feilet",
|
|
929
|
+
processing: "Behandler...",
|
|
930
|
+
processingYourTask: "Behandler oppgaven din...",
|
|
931
|
+
searchingPrefix: "Søker: ",
|
|
932
|
+
tookSeconds: "Tok {n} sekunder",
|
|
933
|
+
sources: "Kilder",
|
|
934
|
+
noSources: "Ingen kilder",
|
|
935
|
+
pageSingle: "side {n}",
|
|
936
|
+
pageTwo: "side {a} og {b}",
|
|
937
|
+
pageMultiple: "side {list} og {n}",
|
|
938
|
+
clickToCollapse: "Klikk for å skjule",
|
|
939
|
+
clickToExpand: "Klikk for å utvide"
|
|
940
|
+
}
|
|
941
|
+
};
|
|
942
|
+
function Ee(e) {
|
|
943
|
+
return Ce[e];
|
|
944
|
+
}
|
|
945
|
+
function D(e, t) {
|
|
946
|
+
return Object.entries(t).reduce(
|
|
947
|
+
(r, [n, s]) => r.replace(`{${n}}`, String(s)),
|
|
948
|
+
e
|
|
949
|
+
);
|
|
950
|
+
}
|
|
951
|
+
const we = ({ data: e, isLatest: t = !1, durationSeconds: r, t: n }) => {
|
|
952
|
+
const s = `${n.searchingPrefix}${e.queryDescription}`;
|
|
953
|
+
return /* @__PURE__ */ x("div", { style: { padding: "16px" }, children: [
|
|
954
|
+
/* @__PURE__ */ i(
|
|
955
|
+
k.div,
|
|
896
956
|
{
|
|
897
957
|
style: {
|
|
898
958
|
display: "flex",
|
|
@@ -903,19 +963,19 @@ const Te = ({ progressViewItems: e }) => {
|
|
|
903
963
|
initial: { opacity: 0, y: -10 },
|
|
904
964
|
animate: { opacity: 1, y: 0 },
|
|
905
965
|
transition: { duration: 0.3, delay: 0 },
|
|
906
|
-
children: t && !
|
|
966
|
+
children: t && !r ? /* @__PURE__ */ i(
|
|
907
967
|
O,
|
|
908
968
|
{
|
|
909
|
-
text:
|
|
969
|
+
text: s,
|
|
910
970
|
duration: 2.5,
|
|
911
971
|
repeat: !0,
|
|
912
972
|
color: "#999",
|
|
913
973
|
shimmerColor: "#000"
|
|
914
974
|
}
|
|
915
|
-
) : /* @__PURE__ */
|
|
975
|
+
) : /* @__PURE__ */ i("span", { style: { color: "#666" }, children: s })
|
|
916
976
|
}
|
|
917
977
|
),
|
|
918
|
-
|
|
978
|
+
r !== void 0 && /* @__PURE__ */ i(
|
|
919
979
|
"div",
|
|
920
980
|
{
|
|
921
981
|
style: {
|
|
@@ -924,19 +984,15 @@ const Te = ({ progressViewItems: e }) => {
|
|
|
924
984
|
marginTop: "4px",
|
|
925
985
|
fontStyle: "italic"
|
|
926
986
|
},
|
|
927
|
-
children:
|
|
928
|
-
"Took ",
|
|
929
|
-
n,
|
|
930
|
-
" seconds"
|
|
931
|
-
]
|
|
987
|
+
children: D(n.tookSeconds, { n: r })
|
|
932
988
|
}
|
|
933
989
|
)
|
|
934
990
|
] });
|
|
935
|
-
},
|
|
936
|
-
const n =
|
|
937
|
-
return /* @__PURE__ */
|
|
938
|
-
/* @__PURE__ */
|
|
939
|
-
|
|
991
|
+
}, Ae = ({ isLatest: e = !1, durationSeconds: t, t: r }) => {
|
|
992
|
+
const n = r.addingSources;
|
|
993
|
+
return /* @__PURE__ */ x("div", { style: { padding: "16px" }, children: [
|
|
994
|
+
/* @__PURE__ */ i(
|
|
995
|
+
k.div,
|
|
940
996
|
{
|
|
941
997
|
style: {
|
|
942
998
|
display: "flex",
|
|
@@ -947,7 +1003,7 @@ const Te = ({ progressViewItems: e }) => {
|
|
|
947
1003
|
initial: { opacity: 0, y: -10 },
|
|
948
1004
|
animate: { opacity: 1, y: 0 },
|
|
949
1005
|
transition: { duration: 0.3, delay: 0 },
|
|
950
|
-
children: e && !t ? /* @__PURE__ */
|
|
1006
|
+
children: e && !t ? /* @__PURE__ */ i(
|
|
951
1007
|
O,
|
|
952
1008
|
{
|
|
953
1009
|
text: n,
|
|
@@ -956,10 +1012,10 @@ const Te = ({ progressViewItems: e }) => {
|
|
|
956
1012
|
color: "#999",
|
|
957
1013
|
shimmerColor: "#000"
|
|
958
1014
|
}
|
|
959
|
-
) : /* @__PURE__ */
|
|
1015
|
+
) : /* @__PURE__ */ i("span", { style: { color: "#666" }, children: n })
|
|
960
1016
|
}
|
|
961
1017
|
),
|
|
962
|
-
t !== void 0 && /* @__PURE__ */
|
|
1018
|
+
t !== void 0 && /* @__PURE__ */ i(
|
|
963
1019
|
"div",
|
|
964
1020
|
{
|
|
965
1021
|
style: {
|
|
@@ -968,17 +1024,26 @@ const Te = ({ progressViewItems: e }) => {
|
|
|
968
1024
|
marginTop: "4px",
|
|
969
1025
|
fontStyle: "italic"
|
|
970
1026
|
},
|
|
971
|
-
children:
|
|
972
|
-
"Took ",
|
|
973
|
-
t,
|
|
974
|
-
" seconds"
|
|
975
|
-
]
|
|
1027
|
+
children: D(r.tookSeconds, { n: t })
|
|
976
1028
|
}
|
|
977
1029
|
)
|
|
978
1030
|
] });
|
|
979
|
-
}
|
|
980
|
-
|
|
981
|
-
|
|
1031
|
+
};
|
|
1032
|
+
function Ie(e, t) {
|
|
1033
|
+
if (e.length === 0) return "";
|
|
1034
|
+
if (e.length === 1)
|
|
1035
|
+
return D(t.pageSingle, { n: e[0] });
|
|
1036
|
+
if (e.length === 2)
|
|
1037
|
+
return D(t.pageTwo, {
|
|
1038
|
+
a: e[0],
|
|
1039
|
+
b: e[1]
|
|
1040
|
+
});
|
|
1041
|
+
const r = e[e.length - 1], n = e.slice(0, -1).join(", ");
|
|
1042
|
+
return D(t.pageMultiple, { list: n, n: r });
|
|
1043
|
+
}
|
|
1044
|
+
const Me = ({ data: e, onSourceClick: t, t: r }) => /* @__PURE__ */ x("div", { style: { padding: "16px" }, children: [
|
|
1045
|
+
/* @__PURE__ */ i(
|
|
1046
|
+
k.div,
|
|
982
1047
|
{
|
|
983
1048
|
style: {
|
|
984
1049
|
marginBottom: "10px",
|
|
@@ -991,38 +1056,35 @@ const Te = ({ progressViewItems: e }) => {
|
|
|
991
1056
|
initial: { opacity: 0, y: -10 },
|
|
992
1057
|
animate: { opacity: 1, y: 0 },
|
|
993
1058
|
transition: { duration: 0.3, delay: 0 },
|
|
994
|
-
children:
|
|
1059
|
+
children: r.sources
|
|
995
1060
|
}
|
|
996
1061
|
),
|
|
997
|
-
/* @__PURE__ */
|
|
998
|
-
|
|
1062
|
+
/* @__PURE__ */ i("div", { style: { display: "flex", flexWrap: "wrap", gap: "8px" }, children: e.sources.length === 0 ? /* @__PURE__ */ i("span", { style: { fontSize: "13px", color: "#888" }, children: r.noSources }) : e.sources.map((n, s) => /* @__PURE__ */ i(
|
|
1063
|
+
De,
|
|
999
1064
|
{
|
|
1000
1065
|
source: n,
|
|
1001
|
-
index:
|
|
1002
|
-
onSourceClick: t
|
|
1066
|
+
index: s,
|
|
1067
|
+
onSourceClick: t,
|
|
1068
|
+
t: r
|
|
1003
1069
|
},
|
|
1004
1070
|
n.memoryId
|
|
1005
1071
|
)) })
|
|
1006
|
-
] })
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
const
|
|
1013
|
-
return
|
|
1014
|
-
|
|
1015
|
-
const Ae = ({ source: e, index: t, onSourceClick: n }) => {
|
|
1016
|
-
const [r, c] = k(!1), l = !!n, o = e.pageNumbers ?? [], d = Ee(o);
|
|
1017
|
-
return /* @__PURE__ */ C(
|
|
1018
|
-
v.div,
|
|
1072
|
+
] }), De = ({
|
|
1073
|
+
source: e,
|
|
1074
|
+
index: t,
|
|
1075
|
+
onSourceClick: r,
|
|
1076
|
+
t: n
|
|
1077
|
+
}) => {
|
|
1078
|
+
const [s, d] = v(!1), o = !!r, l = e.pageNumbers ?? [], y = Ie(l, n);
|
|
1079
|
+
return /* @__PURE__ */ x(
|
|
1080
|
+
k.div,
|
|
1019
1081
|
{
|
|
1020
1082
|
initial: { opacity: 0, scale: 0.9 },
|
|
1021
1083
|
animate: { opacity: 1, scale: 1 },
|
|
1022
1084
|
transition: { duration: 0.25, delay: t * 0.05 },
|
|
1023
|
-
onClick:
|
|
1024
|
-
onMouseEnter:
|
|
1025
|
-
onMouseLeave:
|
|
1085
|
+
onClick: o ? () => r(e.memoryId) : void 0,
|
|
1086
|
+
onMouseEnter: o ? () => d(!0) : void 0,
|
|
1087
|
+
onMouseLeave: o ? () => d(!1) : void 0,
|
|
1026
1088
|
style: {
|
|
1027
1089
|
display: "inline-flex",
|
|
1028
1090
|
flexDirection: "column",
|
|
@@ -1030,50 +1092,50 @@ const Ae = ({ source: e, index: t, onSourceClick: n }) => {
|
|
|
1030
1092
|
padding: "8px 12px",
|
|
1031
1093
|
borderRadius: "6px",
|
|
1032
1094
|
border: "1px solid #e0e0e0",
|
|
1033
|
-
backgroundColor:
|
|
1034
|
-
cursor:
|
|
1095
|
+
backgroundColor: s ? "#f5f5f5" : "transparent",
|
|
1096
|
+
cursor: o ? "pointer" : "default",
|
|
1035
1097
|
transition: "background-color 0.15s ease",
|
|
1036
1098
|
userSelect: "none"
|
|
1037
1099
|
},
|
|
1038
1100
|
children: [
|
|
1039
|
-
/* @__PURE__ */
|
|
1040
|
-
|
|
1101
|
+
/* @__PURE__ */ i("span", { style: { fontSize: "13px", fontWeight: 500, color: "#333" }, children: e.memoryTitle }),
|
|
1102
|
+
y && /* @__PURE__ */ i("span", { style: { fontSize: "12px", color: "#666" }, children: y })
|
|
1041
1103
|
]
|
|
1042
1104
|
}
|
|
1043
1105
|
);
|
|
1044
1106
|
}, U = ({
|
|
1045
1107
|
color: e = "#78b13f",
|
|
1046
1108
|
size: t = 24,
|
|
1047
|
-
borderWidth:
|
|
1109
|
+
borderWidth: r = 7
|
|
1048
1110
|
}) => {
|
|
1049
|
-
const
|
|
1050
|
-
return /* @__PURE__ */
|
|
1111
|
+
const n = t * 0.5;
|
|
1112
|
+
return /* @__PURE__ */ i(
|
|
1051
1113
|
"span",
|
|
1052
1114
|
{
|
|
1053
1115
|
style: {
|
|
1054
1116
|
display: "inline-block",
|
|
1055
1117
|
transform: "rotate(45deg)",
|
|
1056
1118
|
height: t,
|
|
1057
|
-
width:
|
|
1058
|
-
borderBottom: `${
|
|
1059
|
-
borderRight: `${
|
|
1119
|
+
width: n,
|
|
1120
|
+
borderBottom: `${r}px solid ${e}`,
|
|
1121
|
+
borderRight: `${r}px solid ${e}`
|
|
1060
1122
|
}
|
|
1061
1123
|
}
|
|
1062
1124
|
);
|
|
1063
|
-
},
|
|
1125
|
+
}, Pe = ({
|
|
1064
1126
|
color: e = "#333",
|
|
1065
1127
|
size: t = 32,
|
|
1066
|
-
lineWidth:
|
|
1128
|
+
lineWidth: r = 2
|
|
1067
1129
|
}) => {
|
|
1068
|
-
const
|
|
1130
|
+
const n = t + 1, s = (t - r) / 2, d = (t - n) / 2, o = {
|
|
1069
1131
|
position: "absolute",
|
|
1070
|
-
left:
|
|
1071
|
-
top:
|
|
1072
|
-
width:
|
|
1073
|
-
height:
|
|
1132
|
+
left: s,
|
|
1133
|
+
top: d,
|
|
1134
|
+
width: r,
|
|
1135
|
+
height: n,
|
|
1074
1136
|
backgroundColor: e
|
|
1075
1137
|
};
|
|
1076
|
-
return /* @__PURE__ */
|
|
1138
|
+
return /* @__PURE__ */ x(
|
|
1077
1139
|
"span",
|
|
1078
1140
|
{
|
|
1079
1141
|
style: {
|
|
@@ -1083,7 +1145,7 @@ const Ae = ({ source: e, index: t, onSourceClick: n }) => {
|
|
|
1083
1145
|
height: t
|
|
1084
1146
|
},
|
|
1085
1147
|
children: [
|
|
1086
|
-
/* @__PURE__ */
|
|
1148
|
+
/* @__PURE__ */ i(
|
|
1087
1149
|
"span",
|
|
1088
1150
|
{
|
|
1089
1151
|
style: {
|
|
@@ -1092,7 +1154,7 @@ const Ae = ({ source: e, index: t, onSourceClick: n }) => {
|
|
|
1092
1154
|
}
|
|
1093
1155
|
}
|
|
1094
1156
|
),
|
|
1095
|
-
/* @__PURE__ */
|
|
1157
|
+
/* @__PURE__ */ i(
|
|
1096
1158
|
"span",
|
|
1097
1159
|
{
|
|
1098
1160
|
style: {
|
|
@@ -1105,21 +1167,21 @@ const Ae = ({ source: e, index: t, onSourceClick: n }) => {
|
|
|
1105
1167
|
}
|
|
1106
1168
|
);
|
|
1107
1169
|
};
|
|
1108
|
-
function
|
|
1170
|
+
function Oe({
|
|
1109
1171
|
eventType: e,
|
|
1110
1172
|
completed: t
|
|
1111
1173
|
}) {
|
|
1112
|
-
return e === "ExploreMemoryError" ? /* @__PURE__ */
|
|
1174
|
+
return e === "ExploreMemoryError" ? /* @__PURE__ */ i(Pe, { color: "#c62828", size: 15, lineWidth: 2 }) : e === "ExploreMemoryResult" ? /* @__PURE__ */ i(U, { color: "#999", size: 15, borderWidth: 2 }) : e === "ExploreMemoryStart" ? t ? /* @__PURE__ */ i(U, { color: "#999", size: 15, borderWidth: 2 }) : /* @__PURE__ */ i("span", { className: "explore-memory-loader" }) : null;
|
|
1113
1175
|
}
|
|
1114
|
-
const
|
|
1115
|
-
const [
|
|
1116
|
-
return /* @__PURE__ */
|
|
1117
|
-
|
|
1176
|
+
const N = 80, Re = ({ data: e, completed: t, isLatest: r = !1, t: n }) => {
|
|
1177
|
+
const [s, d] = v(!1), o = e.eventType === "ExploreMemoryResult" ? e.result : void 0, l = o != null && o.length > N, y = o != null ? s || !l ? o : `${o.slice(0, N)}...` : void 0, a = l;
|
|
1178
|
+
return /* @__PURE__ */ i("div", { style: { padding: "10px" }, children: /* @__PURE__ */ x(
|
|
1179
|
+
k.div,
|
|
1118
1180
|
{
|
|
1119
1181
|
initial: { opacity: 0 },
|
|
1120
1182
|
animate: { opacity: 1 },
|
|
1121
1183
|
transition: { duration: 0.25 },
|
|
1122
|
-
onClick:
|
|
1184
|
+
onClick: a ? () => d((c) => !c) : void 0,
|
|
1123
1185
|
style: {
|
|
1124
1186
|
paddingBottom: "12px",
|
|
1125
1187
|
borderBottom: "1px solid #eee",
|
|
@@ -1128,10 +1190,10 @@ const $ = 80, De = ({ data: e, completed: t, isLatest: n = !1 }) => {
|
|
|
1128
1190
|
alignItems: "center",
|
|
1129
1191
|
gap: "10px",
|
|
1130
1192
|
minWidth: 0,
|
|
1131
|
-
cursor:
|
|
1193
|
+
cursor: a ? "pointer" : "default"
|
|
1132
1194
|
},
|
|
1133
1195
|
children: [
|
|
1134
|
-
/* @__PURE__ */
|
|
1196
|
+
/* @__PURE__ */ i(
|
|
1135
1197
|
"div",
|
|
1136
1198
|
{
|
|
1137
1199
|
style: {
|
|
@@ -1141,8 +1203,8 @@ const $ = 80, De = ({ data: e, completed: t, isLatest: n = !1 }) => {
|
|
|
1141
1203
|
flexShrink: 0,
|
|
1142
1204
|
width: 32
|
|
1143
1205
|
},
|
|
1144
|
-
children: /* @__PURE__ */
|
|
1145
|
-
|
|
1206
|
+
children: /* @__PURE__ */ i(
|
|
1207
|
+
Oe,
|
|
1146
1208
|
{
|
|
1147
1209
|
eventType: e.eventType,
|
|
1148
1210
|
completed: t
|
|
@@ -1150,7 +1212,7 @@ const $ = 80, De = ({ data: e, completed: t, isLatest: n = !1 }) => {
|
|
|
1150
1212
|
)
|
|
1151
1213
|
}
|
|
1152
1214
|
),
|
|
1153
|
-
/* @__PURE__ */
|
|
1215
|
+
/* @__PURE__ */ x(
|
|
1154
1216
|
"div",
|
|
1155
1217
|
{
|
|
1156
1218
|
style: {
|
|
@@ -1160,26 +1222,26 @@ const $ = 80, De = ({ data: e, completed: t, isLatest: n = !1 }) => {
|
|
|
1160
1222
|
minWidth: 0
|
|
1161
1223
|
},
|
|
1162
1224
|
children: [
|
|
1163
|
-
/* @__PURE__ */
|
|
1225
|
+
/* @__PURE__ */ i(
|
|
1164
1226
|
"span",
|
|
1165
1227
|
{
|
|
1166
1228
|
style: { fontSize: 13, fontWeight: 500, color: "#333" },
|
|
1167
1229
|
children: e.memoryTitle
|
|
1168
1230
|
}
|
|
1169
1231
|
),
|
|
1170
|
-
|
|
1232
|
+
y != null && /* @__PURE__ */ i(
|
|
1171
1233
|
"span",
|
|
1172
1234
|
{
|
|
1173
1235
|
style: {
|
|
1174
1236
|
fontSize: 12,
|
|
1175
1237
|
color: "#666",
|
|
1176
1238
|
lineHeight: 1.4,
|
|
1177
|
-
whiteSpace:
|
|
1239
|
+
whiteSpace: s ? "pre-wrap" : void 0
|
|
1178
1240
|
},
|
|
1179
|
-
children:
|
|
1241
|
+
children: y
|
|
1180
1242
|
}
|
|
1181
1243
|
),
|
|
1182
|
-
|
|
1244
|
+
a && /* @__PURE__ */ i(
|
|
1183
1245
|
"span",
|
|
1184
1246
|
{
|
|
1185
1247
|
style: {
|
|
@@ -1187,7 +1249,7 @@ const $ = 80, De = ({ data: e, completed: t, isLatest: n = !1 }) => {
|
|
|
1187
1249
|
color: "#999",
|
|
1188
1250
|
marginTop: 2
|
|
1189
1251
|
},
|
|
1190
|
-
children:
|
|
1252
|
+
children: s ? n.clickToCollapse : n.clickToExpand
|
|
1191
1253
|
}
|
|
1192
1254
|
)
|
|
1193
1255
|
]
|
|
@@ -1196,8 +1258,8 @@ const $ = 80, De = ({ data: e, completed: t, isLatest: n = !1 }) => {
|
|
|
1196
1258
|
]
|
|
1197
1259
|
}
|
|
1198
1260
|
) });
|
|
1199
|
-
},
|
|
1200
|
-
|
|
1261
|
+
}, Fe = ({ message: e }) => /* @__PURE__ */ i("div", { style: { padding: "16px" }, children: /* @__PURE__ */ i(
|
|
1262
|
+
k.div,
|
|
1201
1263
|
{
|
|
1202
1264
|
initial: { opacity: 0, y: -10 },
|
|
1203
1265
|
animate: { opacity: 1, y: 0 },
|
|
@@ -1207,7 +1269,7 @@ const $ = 80, De = ({ data: e, completed: t, isLatest: n = !1 }) => {
|
|
|
1207
1269
|
alignItems: "flex-start",
|
|
1208
1270
|
gap: "10px"
|
|
1209
1271
|
},
|
|
1210
|
-
children: /* @__PURE__ */
|
|
1272
|
+
children: /* @__PURE__ */ i(
|
|
1211
1273
|
"span",
|
|
1212
1274
|
{
|
|
1213
1275
|
style: {
|
|
@@ -1219,111 +1281,124 @@ const $ = 80, De = ({ data: e, completed: t, isLatest: n = !1 }) => {
|
|
|
1219
1281
|
}
|
|
1220
1282
|
)
|
|
1221
1283
|
}
|
|
1222
|
-
) }),
|
|
1284
|
+
) }), Be = ({
|
|
1223
1285
|
progressViewItems: e,
|
|
1224
1286
|
loadingText: t,
|
|
1287
|
+
t: r,
|
|
1225
1288
|
onSourceClick: n
|
|
1226
1289
|
}) => {
|
|
1227
|
-
const
|
|
1228
|
-
|
|
1229
|
-
|
|
1290
|
+
const s = w(null);
|
|
1291
|
+
E(() => {
|
|
1292
|
+
s.current && (s.current.scrollTop = s.current.scrollHeight);
|
|
1230
1293
|
}, [e.length]);
|
|
1231
|
-
const
|
|
1232
|
-
const
|
|
1233
|
-
if (
|
|
1234
|
-
return /* @__PURE__ */
|
|
1235
|
-
if (
|
|
1236
|
-
return /* @__PURE__ */
|
|
1237
|
-
if (
|
|
1238
|
-
switch (
|
|
1294
|
+
const d = (o) => {
|
|
1295
|
+
const l = o.item.data;
|
|
1296
|
+
if (l.taskType === "StreamingChatCompletion" && l.eventType === "Text")
|
|
1297
|
+
return /* @__PURE__ */ i(L, { text: l.text });
|
|
1298
|
+
if (l.taskType === "StructuredChatCompletion" && l.eventType === "Json")
|
|
1299
|
+
return /* @__PURE__ */ i(xe, { data: l });
|
|
1300
|
+
if (l.taskType === "MemoryChatCompletion")
|
|
1301
|
+
switch (l.eventType) {
|
|
1239
1302
|
case "Text":
|
|
1240
|
-
return /* @__PURE__ */
|
|
1303
|
+
return /* @__PURE__ */ i(L, { text: l.text });
|
|
1241
1304
|
case "Search":
|
|
1242
|
-
return /* @__PURE__ */
|
|
1243
|
-
|
|
1305
|
+
return /* @__PURE__ */ i(
|
|
1306
|
+
we,
|
|
1244
1307
|
{
|
|
1245
|
-
data:
|
|
1246
|
-
isLatest:
|
|
1247
|
-
durationSeconds:
|
|
1308
|
+
data: l,
|
|
1309
|
+
isLatest: o.isLatest,
|
|
1310
|
+
durationSeconds: o.durationSeconds,
|
|
1311
|
+
t: r
|
|
1248
1312
|
}
|
|
1249
1313
|
);
|
|
1250
1314
|
case "FindSources":
|
|
1251
|
-
return /* @__PURE__ */
|
|
1252
|
-
|
|
1315
|
+
return /* @__PURE__ */ i(
|
|
1316
|
+
Ae,
|
|
1253
1317
|
{
|
|
1254
|
-
data:
|
|
1255
|
-
isLatest:
|
|
1256
|
-
durationSeconds:
|
|
1318
|
+
data: l,
|
|
1319
|
+
isLatest: o.isLatest,
|
|
1320
|
+
durationSeconds: o.durationSeconds,
|
|
1321
|
+
t: r
|
|
1257
1322
|
}
|
|
1258
1323
|
);
|
|
1259
1324
|
case "SourcesResult":
|
|
1260
|
-
return /* @__PURE__ */
|
|
1261
|
-
|
|
1325
|
+
return /* @__PURE__ */ i(
|
|
1326
|
+
Me,
|
|
1262
1327
|
{
|
|
1263
|
-
data:
|
|
1264
|
-
onSourceClick: n
|
|
1328
|
+
data: l,
|
|
1329
|
+
onSourceClick: n,
|
|
1330
|
+
t: r
|
|
1265
1331
|
}
|
|
1266
1332
|
);
|
|
1267
1333
|
case "ExploreMemoryStart":
|
|
1268
1334
|
case "ExploreMemoryResult":
|
|
1269
1335
|
case "ExploreMemoryError":
|
|
1270
|
-
return /* @__PURE__ */
|
|
1271
|
-
|
|
1336
|
+
return /* @__PURE__ */ i(
|
|
1337
|
+
Re,
|
|
1272
1338
|
{
|
|
1273
|
-
data:
|
|
1274
|
-
completed:
|
|
1275
|
-
isLatest:
|
|
1339
|
+
data: l,
|
|
1340
|
+
completed: o.completed,
|
|
1341
|
+
isLatest: o.isLatest,
|
|
1342
|
+
t: r
|
|
1276
1343
|
}
|
|
1277
1344
|
);
|
|
1278
1345
|
case "Completed":
|
|
1279
1346
|
return null;
|
|
1280
1347
|
}
|
|
1281
|
-
return
|
|
1348
|
+
return l.taskType === "StreamingChatCompletion" && l.eventType === "Completed" || l.taskType === "StructuredChatCompletion" && l.eventType === "Completed" ? null : l.eventType === "Error" && "message" in l ? /* @__PURE__ */ i(Fe, { message: l.message }) : null;
|
|
1282
1349
|
};
|
|
1283
|
-
return e.length === 0 ? /* @__PURE__ */
|
|
1350
|
+
return e.length === 0 ? /* @__PURE__ */ i("div", { style: { width: "fit-content" }, children: /* @__PURE__ */ i(
|
|
1284
1351
|
O,
|
|
1285
1352
|
{
|
|
1286
|
-
text: t ??
|
|
1353
|
+
text: t ?? r.processingYourTask,
|
|
1287
1354
|
duration: 1.5,
|
|
1288
1355
|
repeat: !0,
|
|
1289
1356
|
repeatDelay: 0,
|
|
1290
1357
|
color: "#999",
|
|
1291
1358
|
shimmerColor: "#000"
|
|
1292
1359
|
}
|
|
1293
|
-
) }) : /* @__PURE__ */
|
|
1294
|
-
|
|
1360
|
+
) }) : /* @__PURE__ */ i("div", { id: "agent-task-progress-verbose", ref: s, children: /* @__PURE__ */ i($, { children: e.map((o, l) => /* @__PURE__ */ i(
|
|
1361
|
+
k.div,
|
|
1295
1362
|
{
|
|
1296
|
-
id: `agent-task-progress-item-${
|
|
1363
|
+
id: `agent-task-progress-item-${o.item.progressItemId}`,
|
|
1297
1364
|
initial: { opacity: 0, y: -20 },
|
|
1298
1365
|
animate: { opacity: 1, y: 0 },
|
|
1299
1366
|
transition: {
|
|
1300
1367
|
duration: 0.4,
|
|
1301
|
-
delay:
|
|
1368
|
+
delay: l * 0.1,
|
|
1302
1369
|
ease: "easeOut"
|
|
1303
1370
|
},
|
|
1304
|
-
children:
|
|
1371
|
+
children: d(o)
|
|
1305
1372
|
},
|
|
1306
|
-
|
|
1373
|
+
o.item.progressItemId
|
|
1307
1374
|
)) }) });
|
|
1308
|
-
},
|
|
1375
|
+
}, Ke = ({
|
|
1309
1376
|
agentTask: e,
|
|
1310
1377
|
mode: t = "verbose",
|
|
1378
|
+
language: r,
|
|
1311
1379
|
onSourceClick: n
|
|
1312
1380
|
}) => {
|
|
1313
|
-
const
|
|
1314
|
-
return t === "simple" ? /* @__PURE__ */
|
|
1315
|
-
|
|
1381
|
+
const s = ke(e), d = e.params.type === "MemoryChatCompletion" && "language" in e.params ? e.params.language ?? "en" : r ?? "en", o = Ee(d);
|
|
1382
|
+
return t === "simple" ? /* @__PURE__ */ i(
|
|
1383
|
+
ve,
|
|
1384
|
+
{
|
|
1385
|
+
progressViewItems: s,
|
|
1386
|
+
t: o
|
|
1387
|
+
}
|
|
1388
|
+
) : /* @__PURE__ */ i(
|
|
1389
|
+
Be,
|
|
1316
1390
|
{
|
|
1317
|
-
progressViewItems:
|
|
1391
|
+
progressViewItems: s,
|
|
1318
1392
|
loadingText: e.loadingText,
|
|
1393
|
+
t: o,
|
|
1319
1394
|
onSourceClick: n
|
|
1320
1395
|
}
|
|
1321
1396
|
);
|
|
1322
1397
|
};
|
|
1323
1398
|
export {
|
|
1324
|
-
|
|
1399
|
+
Ke as AgentTaskProgress,
|
|
1325
1400
|
U as Checkmark,
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1401
|
+
We as FencyProvider,
|
|
1402
|
+
Pe as XMark,
|
|
1403
|
+
He as useAgentTasks
|
|
1329
1404
|
};
|