super-agent-sdk 1.0.4 → 1.0.5
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/README.md +21 -12
- package/dist/index.cjs +4 -4
- package/dist/index.d.ts +38 -8
- package/dist/index.mjs +195 -167
- package/dist/mammoth.browser-COPV53yV.js +14917 -0
- package/dist/mammoth.browser-DiAPPO3x.cjs +230 -0
- package/dist/purify.es-C-6FFqDW.js +898 -0
- package/dist/purify.es-Dsdnkgrg.cjs +3 -0
- package/dist/widget.cjs +214 -5
- package/dist/widget.d.ts +61 -13
- package/dist/widget.mjs +1308 -655
- package/package.json +8 -3
package/dist/widget.mjs
CHANGED
|
@@ -1,336 +1,493 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { createRoot as
|
|
3
|
-
import { jsx as e, jsxs as
|
|
4
|
-
function
|
|
5
|
-
const { sdk: t, sessionId:
|
|
6
|
-
b.current =
|
|
7
|
-
const
|
|
1
|
+
import Y, { useState as T, useRef as _, useCallback as N, useEffect as B, createContext as ie, useMemo as V, useContext as oe } from "react";
|
|
2
|
+
import { createRoot as le } from "react-dom/client";
|
|
3
|
+
import { jsx as e, jsxs as d, Fragment as q } from "react/jsx-runtime";
|
|
4
|
+
function ce(a) {
|
|
5
|
+
const { sdk: t, sessionId: s, onSessionCreated: r, onStreamStart: n, onStreamEnd: o, onError: i, onMessageSend: l } = a, [c, p] = T([]), [f, u] = T("ready"), [h, v] = T(null), k = _(null), g = _(!1), b = _(s);
|
|
6
|
+
b.current = s;
|
|
7
|
+
const m = N((M) => {
|
|
8
8
|
if (g.current) return;
|
|
9
|
-
g.current = !0, l == null || l(
|
|
10
|
-
const
|
|
9
|
+
g.current = !0, l == null || l(M);
|
|
10
|
+
const O = {
|
|
11
11
|
id: `user_${Date.now()}`,
|
|
12
12
|
role: "user",
|
|
13
|
-
parts: [{ type: "text", content:
|
|
13
|
+
parts: [{ type: "text", content: M }],
|
|
14
14
|
timestamp: Date.now()
|
|
15
|
-
},
|
|
16
|
-
id:
|
|
15
|
+
}, y = `assistant_${Date.now()}`, L = {
|
|
16
|
+
id: y,
|
|
17
17
|
role: "assistant",
|
|
18
18
|
parts: [],
|
|
19
19
|
timestamp: Date.now()
|
|
20
20
|
};
|
|
21
|
-
p((
|
|
22
|
-
const
|
|
23
|
-
let
|
|
24
|
-
const
|
|
25
|
-
const
|
|
26
|
-
if (_) {
|
|
27
|
-
const P = k.findIndex((R) => R.type === "thinking");
|
|
28
|
-
P >= 0 ? k[P] = { type: "thinking", content: _ } : k.unshift({ type: "thinking", content: _ });
|
|
29
|
-
}
|
|
21
|
+
p((S) => [...S, O, L]), u("submitted"), v(null);
|
|
22
|
+
const $ = (S) => {
|
|
23
|
+
let E = "", A = "", H = [], z = !1;
|
|
24
|
+
const P = () => {
|
|
25
|
+
const w = [...H];
|
|
30
26
|
if (E) {
|
|
31
|
-
const
|
|
32
|
-
|
|
27
|
+
const W = w.findIndex((R) => R.type === "thinking");
|
|
28
|
+
W >= 0 ? w[W] = { type: "thinking", content: E } : w.unshift({ type: "thinking", content: E });
|
|
29
|
+
}
|
|
30
|
+
if (A) {
|
|
31
|
+
const W = w.findLastIndex((R) => R.type === "text");
|
|
32
|
+
W >= 0 ? w[W] = { type: "text", content: A } : w.push({ type: "text", content: A });
|
|
33
33
|
}
|
|
34
34
|
p(
|
|
35
|
-
(
|
|
35
|
+
(W) => W.map((R) => R.id === y ? { ...R, parts: w } : R)
|
|
36
36
|
);
|
|
37
37
|
};
|
|
38
|
-
|
|
39
|
-
sessionId:
|
|
40
|
-
message:
|
|
38
|
+
k.current = t.chat({
|
|
39
|
+
sessionId: S,
|
|
40
|
+
message: M,
|
|
41
41
|
stream: !0,
|
|
42
|
-
onMessage: (
|
|
43
|
-
switch (
|
|
42
|
+
onMessage: (w) => {
|
|
43
|
+
switch (z || (z = !0, u("streaming")), w.type) {
|
|
44
44
|
case "thinking":
|
|
45
|
-
|
|
45
|
+
E += w.content;
|
|
46
46
|
break;
|
|
47
47
|
case "ai":
|
|
48
|
-
|
|
48
|
+
A += w.content;
|
|
49
49
|
break;
|
|
50
50
|
case "tool_call":
|
|
51
|
-
|
|
51
|
+
H.push({
|
|
52
52
|
type: "tool_call",
|
|
53
|
-
toolName:
|
|
54
|
-
toolCallId:
|
|
55
|
-
args:
|
|
53
|
+
toolName: w.toolName,
|
|
54
|
+
toolCallId: w.toolCallId,
|
|
55
|
+
args: w.args ?? "{}"
|
|
56
56
|
});
|
|
57
57
|
break;
|
|
58
58
|
case "tool_result":
|
|
59
|
-
|
|
59
|
+
H.push({
|
|
60
60
|
type: "tool_result",
|
|
61
|
-
toolName:
|
|
62
|
-
toolCallId:
|
|
63
|
-
content:
|
|
64
|
-
|
|
61
|
+
toolName: w.toolName ?? "",
|
|
62
|
+
toolCallId: w.toolCallId,
|
|
63
|
+
content: w.content,
|
|
64
|
+
artifacts: w.artifacts,
|
|
65
|
+
renderMode: w.renderMode,
|
|
66
|
+
html: w.html
|
|
67
|
+
}), A && (H.push({ type: "text", content: A }), A = "");
|
|
65
68
|
break;
|
|
66
69
|
case "interrupt":
|
|
67
|
-
|
|
70
|
+
w.interrupt && H.push({
|
|
68
71
|
type: "interrupt",
|
|
69
|
-
interrupt:
|
|
72
|
+
interrupt: w.interrupt,
|
|
70
73
|
resolved: !1
|
|
71
74
|
});
|
|
72
75
|
break;
|
|
73
76
|
}
|
|
74
|
-
|
|
77
|
+
P();
|
|
75
78
|
},
|
|
76
|
-
onDone: (
|
|
77
|
-
(
|
|
79
|
+
onDone: (w) => {
|
|
80
|
+
(A || H.length > 0 || E) && P(), w.messageId && p(
|
|
81
|
+
(W) => W.map((R) => R.id === y ? { ...R, id: w.messageId } : R)
|
|
82
|
+
), w.sessionId && w.sessionId !== b.current && (r == null || r(w.sessionId)), o == null || o(w.sessionId || S), u("ready"), g.current = !1, k.current = null;
|
|
78
83
|
},
|
|
79
|
-
onError: (
|
|
80
|
-
|
|
84
|
+
onError: (w) => {
|
|
85
|
+
H.push({ type: "error", content: w.message }), P(), v(w), u("error"), i == null || i(w), g.current = !1, k.current = null;
|
|
81
86
|
}
|
|
82
|
-
}),
|
|
87
|
+
}), n == null || n(S);
|
|
83
88
|
};
|
|
84
|
-
b.current ?
|
|
85
|
-
b.current =
|
|
86
|
-
}).catch((
|
|
87
|
-
v(
|
|
89
|
+
b.current ? $(b.current) : t.createSession().then((S) => {
|
|
90
|
+
b.current = S, r == null || r(S), $(S);
|
|
91
|
+
}).catch((S) => {
|
|
92
|
+
v(S instanceof Error ? S : new Error(String(S))), u("error"), i == null || i(S instanceof Error ? S : new Error(String(S))), g.current = !1;
|
|
88
93
|
});
|
|
89
|
-
}, [t, r,
|
|
90
|
-
var
|
|
91
|
-
(
|
|
92
|
-
}, []),
|
|
94
|
+
}, [t, r, n, o, i, l]), x = N(() => {
|
|
95
|
+
var M;
|
|
96
|
+
(M = k.current) == null || M.abort(), k.current = null, u("ready"), g.current = !1;
|
|
97
|
+
}, []), I = N(() => {
|
|
93
98
|
if (g.current) return;
|
|
94
|
-
const
|
|
95
|
-
if (
|
|
96
|
-
const
|
|
97
|
-
p((
|
|
98
|
-
}, [
|
|
99
|
+
const M = c.findLastIndex((y) => y.role === "user");
|
|
100
|
+
if (M < 0) return;
|
|
101
|
+
const O = c[M].parts.filter((y) => y.type === "text").map((y) => y.content).join("");
|
|
102
|
+
p((y) => y.slice(0, M)), m(O);
|
|
103
|
+
}, [c, m]), D = N((M, O) => {
|
|
99
104
|
p(
|
|
100
|
-
(
|
|
101
|
-
...
|
|
102
|
-
parts:
|
|
103
|
-
(
|
|
105
|
+
(z) => z.map((P) => ({
|
|
106
|
+
...P,
|
|
107
|
+
parts: P.parts.map(
|
|
108
|
+
(w) => w.type === "interrupt" && w.interrupt.interruptId === M ? { ...w, resolved: !0, response: O } : w
|
|
104
109
|
)
|
|
105
110
|
}))
|
|
106
111
|
);
|
|
107
|
-
const
|
|
108
|
-
|
|
109
|
-
|
|
112
|
+
const y = b.current;
|
|
113
|
+
if (!y) return;
|
|
114
|
+
const L = `assistant_${Date.now()}`, $ = {
|
|
115
|
+
id: L,
|
|
116
|
+
role: "assistant",
|
|
117
|
+
parts: [],
|
|
118
|
+
timestamp: Date.now()
|
|
119
|
+
};
|
|
120
|
+
p((z) => [...z, $]), u("streaming");
|
|
121
|
+
let S = "", E = "", A = [];
|
|
122
|
+
const H = () => {
|
|
123
|
+
const z = [...A];
|
|
124
|
+
if (S) {
|
|
125
|
+
const P = z.findIndex((w) => w.type === "thinking");
|
|
126
|
+
P >= 0 ? z[P] = { type: "thinking", content: S } : z.unshift({ type: "thinking", content: S });
|
|
127
|
+
}
|
|
128
|
+
if (E) {
|
|
129
|
+
const P = z.findLastIndex((w) => w.type === "text");
|
|
130
|
+
P >= 0 ? z[P] = { type: "text", content: E } : z.push({ type: "text", content: E });
|
|
131
|
+
}
|
|
132
|
+
p(
|
|
133
|
+
(P) => P.map((w) => w.id === L ? { ...w, parts: z } : w)
|
|
134
|
+
);
|
|
135
|
+
};
|
|
136
|
+
t.respondInterrupt(
|
|
137
|
+
M,
|
|
138
|
+
y,
|
|
139
|
+
O,
|
|
140
|
+
(z) => {
|
|
141
|
+
switch (z.type) {
|
|
142
|
+
case "thinking":
|
|
143
|
+
S += z.content;
|
|
144
|
+
break;
|
|
145
|
+
case "ai":
|
|
146
|
+
E += z.content;
|
|
147
|
+
break;
|
|
148
|
+
case "tool_call":
|
|
149
|
+
A.push({
|
|
150
|
+
type: "tool_call",
|
|
151
|
+
toolName: z.toolName,
|
|
152
|
+
toolCallId: z.toolCallId,
|
|
153
|
+
args: z.args ?? "{}"
|
|
154
|
+
});
|
|
155
|
+
break;
|
|
156
|
+
case "tool_result":
|
|
157
|
+
A.push({
|
|
158
|
+
type: "tool_result",
|
|
159
|
+
toolName: z.toolName ?? "",
|
|
160
|
+
toolCallId: z.toolCallId,
|
|
161
|
+
content: z.content,
|
|
162
|
+
artifacts: z.artifacts,
|
|
163
|
+
renderMode: z.renderMode,
|
|
164
|
+
html: z.html
|
|
165
|
+
}), E && (A.push({ type: "text", content: E }), E = "");
|
|
166
|
+
break;
|
|
167
|
+
case "interrupt":
|
|
168
|
+
z.interrupt && A.push({ type: "interrupt", interrupt: z.interrupt, resolved: !1 });
|
|
169
|
+
break;
|
|
170
|
+
case "done":
|
|
171
|
+
u("ready");
|
|
172
|
+
break;
|
|
173
|
+
}
|
|
174
|
+
H();
|
|
175
|
+
},
|
|
176
|
+
(z) => {
|
|
177
|
+
A.push({ type: "error", content: z.message }), H(), v(z), u("error"), i == null || i(z);
|
|
178
|
+
}
|
|
179
|
+
).catch((z) => {
|
|
180
|
+
i == null || i(z instanceof Error ? z : new Error(String(z))), u("error");
|
|
110
181
|
});
|
|
111
|
-
}, [t,
|
|
112
|
-
return { messages:
|
|
182
|
+
}, [t, i]);
|
|
183
|
+
return { messages: c, status: f, error: h, sendMessage: m, stop: x, regenerate: I, setMessages: p, respondToInterrupt: D };
|
|
113
184
|
}
|
|
114
|
-
const
|
|
115
|
-
function
|
|
185
|
+
const X = "sa_active_conversation";
|
|
186
|
+
function J() {
|
|
116
187
|
try {
|
|
117
|
-
return localStorage.getItem(
|
|
188
|
+
return localStorage.getItem(X);
|
|
118
189
|
} catch {
|
|
119
190
|
return null;
|
|
120
191
|
}
|
|
121
192
|
}
|
|
122
|
-
function
|
|
193
|
+
function de(a) {
|
|
123
194
|
try {
|
|
124
|
-
a ? localStorage.setItem(
|
|
195
|
+
a ? localStorage.setItem(X, a) : localStorage.removeItem(X);
|
|
125
196
|
} catch {
|
|
126
197
|
}
|
|
127
198
|
}
|
|
128
|
-
function
|
|
129
|
-
const { sdk: t, onConversationChange:
|
|
130
|
-
() =>
|
|
131
|
-
), [l,
|
|
132
|
-
|
|
199
|
+
function pe(a) {
|
|
200
|
+
const { sdk: t, onConversationChange: s } = a, [r, n] = T([]), [o, i] = T(
|
|
201
|
+
() => J()
|
|
202
|
+
), [l, c] = T(!1), p = _(!0);
|
|
203
|
+
B(() => () => {
|
|
133
204
|
p.current = !1;
|
|
134
205
|
}, []);
|
|
135
|
-
const f =
|
|
136
|
-
|
|
137
|
-
}, [
|
|
138
|
-
|
|
206
|
+
const f = N((m) => {
|
|
207
|
+
i(m), de(m), m && (s == null || s(m));
|
|
208
|
+
}, [s]), u = N(async () => {
|
|
209
|
+
c(!0);
|
|
139
210
|
try {
|
|
140
|
-
const
|
|
211
|
+
const m = await t.listConversations({ page: 1, size: 100 });
|
|
141
212
|
if (!p.current) return;
|
|
142
|
-
|
|
143
|
-
const
|
|
144
|
-
|
|
213
|
+
n(m.items);
|
|
214
|
+
const x = J();
|
|
215
|
+
x && !m.items.find((I) => I.sessionId === x) && f(null);
|
|
145
216
|
} catch {
|
|
146
217
|
} finally {
|
|
147
|
-
p.current &&
|
|
218
|
+
p.current && c(!1);
|
|
148
219
|
}
|
|
149
|
-
}, [t, f]),
|
|
220
|
+
}, [t, f]), h = N(async (m) => (f(m), await t.getMessages(m)), [t, f]), v = N(() => {
|
|
150
221
|
f(null);
|
|
151
|
-
}, [f]),
|
|
152
|
-
await t.deleteConversation(
|
|
153
|
-
}, [t,
|
|
154
|
-
await t.renameConversation(
|
|
155
|
-
(
|
|
222
|
+
}, [f]), k = N(async (m) => {
|
|
223
|
+
await t.deleteConversation(m), n((x) => x.filter((I) => I.sessionId !== m)), o === m && f(null);
|
|
224
|
+
}, [t, o, f]), g = N(async (m, x) => {
|
|
225
|
+
await t.renameConversation(m, x), n(
|
|
226
|
+
(I) => I.map((D) => D.sessionId === m ? { ...D, title: x } : D)
|
|
156
227
|
);
|
|
157
228
|
}, [t]), { enabled: b = !0 } = a;
|
|
158
|
-
return
|
|
159
|
-
b &&
|
|
160
|
-
}, [b,
|
|
229
|
+
return B(() => {
|
|
230
|
+
b && u();
|
|
231
|
+
}, [b, u]), {
|
|
161
232
|
conversations: r,
|
|
162
|
-
activeConversationId:
|
|
233
|
+
activeConversationId: o,
|
|
163
234
|
loading: l,
|
|
164
|
-
loadConversations:
|
|
165
|
-
switchConversation:
|
|
235
|
+
loadConversations: u,
|
|
236
|
+
switchConversation: h,
|
|
166
237
|
newConversation: v,
|
|
167
|
-
deleteConversation:
|
|
238
|
+
deleteConversation: k,
|
|
168
239
|
renameConversation: g,
|
|
169
240
|
setActiveConversationId: f
|
|
170
241
|
};
|
|
171
242
|
}
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
243
|
+
function Q(a) {
|
|
244
|
+
return !a && a !== 0 ? "" : a < 1024 ? `${a} B` : a < 1024 * 1024 ? `${(a / 1024).toFixed(1)} KB` : `${(a / 1024 / 1024).toFixed(1)} MB`;
|
|
245
|
+
}
|
|
246
|
+
function ee(a) {
|
|
247
|
+
return a === "pdf" ? "PDF" : a === "docx" ? "DOC" : a === "html" ? "HTM" : a.slice(0, 3).toUpperCase() || "FILE";
|
|
248
|
+
}
|
|
249
|
+
function ae(a) {
|
|
250
|
+
if (!a) return [];
|
|
251
|
+
const t = [];
|
|
252
|
+
for (const s of a)
|
|
253
|
+
s.type === "file" && s.data && t.push({
|
|
254
|
+
id: s.data.id ?? "",
|
|
255
|
+
type: s.data.fileType ?? s.data.type ?? "",
|
|
256
|
+
filename: s.data.name ?? s.data.filename ?? "",
|
|
257
|
+
url: s.data.url ?? "",
|
|
258
|
+
mime: s.data.mime,
|
|
259
|
+
size: s.data.size,
|
|
260
|
+
summary: s.data.summary
|
|
261
|
+
});
|
|
262
|
+
return t;
|
|
263
|
+
}
|
|
264
|
+
async function U(a) {
|
|
265
|
+
try {
|
|
266
|
+
const t = await fetch(a.url);
|
|
267
|
+
if (!t.ok) throw new Error(`HTTP ${t.status}`);
|
|
268
|
+
const s = await t.blob(), r = URL.createObjectURL(s), n = document.createElement("a");
|
|
269
|
+
n.href = r, n.download = a.filename, document.body.appendChild(n), n.click(), n.remove(), setTimeout(() => URL.revokeObjectURL(r), 4e3);
|
|
270
|
+
} catch {
|
|
271
|
+
const t = document.createElement("a");
|
|
272
|
+
t.href = a.url, t.download = a.filename, t.target = "_blank", document.body.appendChild(t), t.click(), t.remove();
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
const te = ie(null);
|
|
276
|
+
function F() {
|
|
277
|
+
const a = oe(te);
|
|
175
278
|
if (!a) throw new Error("useChatContext must be used within ChatProvider");
|
|
176
279
|
return a;
|
|
177
280
|
}
|
|
178
|
-
function
|
|
179
|
-
const [r,
|
|
180
|
-
|
|
281
|
+
function G({ sdk: a, hooks: t, children: s }) {
|
|
282
|
+
const [r, n] = T(!1), [o, i] = T(!1), [l, c] = T(null), [p, f] = T(!1);
|
|
283
|
+
B(() => {
|
|
181
284
|
a.getToken().then(() => {
|
|
182
|
-
|
|
285
|
+
f(!0);
|
|
183
286
|
}).catch(() => {
|
|
184
|
-
|
|
287
|
+
f(!0);
|
|
185
288
|
});
|
|
186
289
|
}, [a]);
|
|
187
|
-
const
|
|
290
|
+
const u = pe({
|
|
188
291
|
sdk: a,
|
|
189
292
|
onConversationChange: t == null ? void 0 : t.onConversationChange,
|
|
190
|
-
enabled:
|
|
191
|
-
}),
|
|
293
|
+
enabled: p
|
|
294
|
+
}), h = ce({
|
|
192
295
|
sdk: a,
|
|
193
|
-
sessionId:
|
|
194
|
-
onSessionCreated: (
|
|
195
|
-
|
|
296
|
+
sessionId: u.activeConversationId,
|
|
297
|
+
onSessionCreated: (y) => {
|
|
298
|
+
u.setActiveConversationId(y), u.loadConversations();
|
|
196
299
|
},
|
|
197
300
|
onStreamStart: t == null ? void 0 : t.onStreamStart,
|
|
198
|
-
onStreamEnd: (
|
|
199
|
-
var
|
|
200
|
-
(
|
|
301
|
+
onStreamEnd: (y) => {
|
|
302
|
+
var L;
|
|
303
|
+
(L = t == null ? void 0 : t.onStreamEnd) == null || L.call(t, y), u.loadConversations();
|
|
201
304
|
},
|
|
202
305
|
onError: t == null ? void 0 : t.onError,
|
|
203
306
|
onMessageSend: t == null ? void 0 : t.onMessageSend
|
|
204
|
-
}),
|
|
205
|
-
const
|
|
206
|
-
|
|
207
|
-
}, [
|
|
208
|
-
|
|
209
|
-
}, [
|
|
210
|
-
await
|
|
211
|
-
}, [
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
307
|
+
}), v = N(async (y) => {
|
|
308
|
+
const L = await u.switchConversation(y);
|
|
309
|
+
h.setMessages(L), n(!1);
|
|
310
|
+
}, [u, h]), k = N(() => {
|
|
311
|
+
u.newConversation(), h.setMessages([]), n(!1);
|
|
312
|
+
}, [u, h]), g = N(async (y) => {
|
|
313
|
+
await u.deleteConversation(y), u.activeConversationId === y && h.setMessages([]);
|
|
314
|
+
}, [u, h]);
|
|
315
|
+
B(() => {
|
|
316
|
+
u.activeConversationId && h.messages.length === 0 && a.getMessages(u.activeConversationId).then((y) => {
|
|
317
|
+
h.setMessages(y);
|
|
215
318
|
}).catch(() => {
|
|
216
319
|
});
|
|
217
320
|
}, []);
|
|
218
|
-
const
|
|
219
|
-
|
|
220
|
-
}, []),
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
321
|
+
const b = N(() => {
|
|
322
|
+
n((y) => !y);
|
|
323
|
+
}, []), m = N(() => {
|
|
324
|
+
i((y) => !y), c((y) => null);
|
|
325
|
+
}, []), x = N((y) => {
|
|
326
|
+
c(y), i(!0);
|
|
327
|
+
}, []), I = V(() => {
|
|
328
|
+
const y = /* @__PURE__ */ new Set(), L = [];
|
|
329
|
+
for (const $ of h.messages)
|
|
330
|
+
for (const S of $.parts)
|
|
331
|
+
if (S.type === "tool_result" && S.artifacts)
|
|
332
|
+
for (const E of ae(S.artifacts)) {
|
|
333
|
+
const A = E.id || `${E.url}:${E.filename}`;
|
|
334
|
+
y.has(A) || (y.add(A), L.push(E));
|
|
335
|
+
}
|
|
336
|
+
return L;
|
|
337
|
+
}, [h.messages]), D = N((y, L, $) => {
|
|
338
|
+
a.feedback(y, L, $).catch(() => {
|
|
339
|
+
});
|
|
340
|
+
}, [a]), M = N((y) => {
|
|
341
|
+
a.cancelFeedback(y).catch(() => {
|
|
342
|
+
});
|
|
343
|
+
}, [a]), O = V(() => ({
|
|
344
|
+
status: h.status,
|
|
345
|
+
error: h.error,
|
|
346
|
+
messages: h.messages,
|
|
347
|
+
conversations: u.conversations,
|
|
348
|
+
activeConversationId: u.activeConversationId,
|
|
226
349
|
isThreadListOpen: r,
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
350
|
+
isArtifactDrawerOpen: o,
|
|
351
|
+
allArtifacts: I,
|
|
352
|
+
activePreviewArtifact: l,
|
|
353
|
+
sendMessage: h.sendMessage,
|
|
354
|
+
stop: h.stop,
|
|
355
|
+
regenerate: h.regenerate,
|
|
356
|
+
switchConversation: v,
|
|
357
|
+
newConversation: k,
|
|
358
|
+
deleteConversation: g,
|
|
359
|
+
renameConversation: u.renameConversation,
|
|
360
|
+
toggleThreadList: b,
|
|
361
|
+
toggleArtifactDrawer: m,
|
|
362
|
+
openArtifactPreview: x,
|
|
363
|
+
feedback: D,
|
|
364
|
+
cancelFeedback: M,
|
|
365
|
+
respondToInterrupt: h.respondToInterrupt
|
|
366
|
+
}), [
|
|
367
|
+
h.status,
|
|
368
|
+
h.error,
|
|
369
|
+
h.messages,
|
|
370
|
+
h.sendMessage,
|
|
371
|
+
h.stop,
|
|
372
|
+
h.regenerate,
|
|
373
|
+
h.respondToInterrupt,
|
|
374
|
+
u.conversations,
|
|
375
|
+
u.activeConversationId,
|
|
376
|
+
u.renameConversation,
|
|
377
|
+
r,
|
|
378
|
+
o,
|
|
379
|
+
I,
|
|
380
|
+
l,
|
|
381
|
+
v,
|
|
382
|
+
k,
|
|
383
|
+
g,
|
|
384
|
+
b,
|
|
385
|
+
m,
|
|
386
|
+
x,
|
|
387
|
+
D,
|
|
388
|
+
M
|
|
389
|
+
]);
|
|
390
|
+
return /* @__PURE__ */ e(te.Provider, { value: O, children: s });
|
|
241
391
|
}
|
|
242
|
-
function
|
|
392
|
+
function C({ name: a, size: t = 16, color: s = "currentColor", className: r, style: n }) {
|
|
243
393
|
return /* @__PURE__ */ e(
|
|
244
394
|
"svg",
|
|
245
395
|
{
|
|
246
396
|
className: r,
|
|
247
|
-
style: { width: t, height: t, fill:
|
|
397
|
+
style: { width: t, height: t, fill: s, verticalAlign: "middle", ...n },
|
|
248
398
|
"aria-hidden": "true",
|
|
249
399
|
children: /* @__PURE__ */ e("use", { href: `#icon-${a}` })
|
|
250
400
|
}
|
|
251
401
|
);
|
|
252
402
|
}
|
|
253
|
-
function
|
|
254
|
-
return /* @__PURE__ */ e("button", { className: `sa-trigger ${a ? "sa-trigger-open" : ""}`, onClick: t, children: a ? /* @__PURE__ */ e(
|
|
403
|
+
function fe({ isOpen: a, onClick: t }) {
|
|
404
|
+
return /* @__PURE__ */ e("button", { className: `sa-trigger ${a ? "sa-trigger-open" : ""}`, onClick: t, children: a ? /* @__PURE__ */ e(C, { name: "x", size: 24, color: "#fff" }) : /* @__PURE__ */ e(C, { name: "message-square", size: 24, color: "#fff" }) });
|
|
255
405
|
}
|
|
256
|
-
function
|
|
257
|
-
return /* @__PURE__ */
|
|
258
|
-
/* @__PURE__ */
|
|
406
|
+
function ue({ title: a, onClose: t, onToggleThreadList: s, showClose: r = !0, artifactCount: n = 0, onToggleArtifactDrawer: o }) {
|
|
407
|
+
return /* @__PURE__ */ d("div", { className: "sa-header", children: [
|
|
408
|
+
/* @__PURE__ */ d("div", { className: "sa-header-left", children: [
|
|
259
409
|
/* @__PURE__ */ e("div", { className: "sa-header-avatar", children: "A" }),
|
|
260
|
-
/* @__PURE__ */
|
|
410
|
+
/* @__PURE__ */ d("div", { className: "sa-header-info", children: [
|
|
261
411
|
/* @__PURE__ */ e("div", { className: "sa-header-title", children: a }),
|
|
262
412
|
/* @__PURE__ */ e("div", { className: "sa-header-status", children: "● Online" })
|
|
263
413
|
] })
|
|
264
414
|
] }),
|
|
265
|
-
/* @__PURE__ */
|
|
266
|
-
/* @__PURE__ */
|
|
267
|
-
|
|
415
|
+
/* @__PURE__ */ d("div", { className: "sa-header-actions", children: [
|
|
416
|
+
n > 0 && o && /* @__PURE__ */ d("button", { className: "sa-header-btn sa-header-btn-artifact", onClick: o, title: "会话产物", children: [
|
|
417
|
+
/* @__PURE__ */ d("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: [
|
|
418
|
+
/* @__PURE__ */ e("path", { d: "M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z" }),
|
|
419
|
+
/* @__PURE__ */ e("polyline", { points: "14 2 14 8 20 8" })
|
|
420
|
+
] }),
|
|
421
|
+
/* @__PURE__ */ e("span", { children: "产物" })
|
|
422
|
+
] }),
|
|
423
|
+
/* @__PURE__ */ e("button", { className: "sa-header-btn", onClick: s, title: "会话列表", children: /* @__PURE__ */ e(C, { name: "menu", size: 16 }) }),
|
|
424
|
+
r && /* @__PURE__ */ e("button", { className: "sa-header-btn", onClick: t, title: "关闭", children: /* @__PURE__ */ e(C, { name: "x", size: 16 }) })
|
|
268
425
|
] })
|
|
269
426
|
] });
|
|
270
427
|
}
|
|
271
|
-
function
|
|
272
|
-
const t = /* @__PURE__ */ new Date(),
|
|
273
|
-
for (const
|
|
274
|
-
const p = new Date(
|
|
275
|
-
p >=
|
|
428
|
+
function me(a) {
|
|
429
|
+
const t = /* @__PURE__ */ new Date(), s = new Date(t.getFullYear(), t.getMonth(), t.getDate()).getTime(), r = s - 6 * 864e5, n = [], o = [], i = [];
|
|
430
|
+
for (const c of a) {
|
|
431
|
+
const p = new Date(c.updateTime).getTime();
|
|
432
|
+
p >= s ? n.push(c) : p >= r ? o.push(c) : i.push(c);
|
|
276
433
|
}
|
|
277
434
|
const l = [];
|
|
278
|
-
return
|
|
435
|
+
return n.length && l.push({ label: "今天", items: n }), o.length && l.push({ label: "最近 7 天", items: o }), i.length && l.push({ label: "更早", items: i }), l;
|
|
279
436
|
}
|
|
280
|
-
function
|
|
437
|
+
function he() {
|
|
281
438
|
const {
|
|
282
439
|
conversations: a,
|
|
283
440
|
activeConversationId: t,
|
|
284
|
-
switchConversation:
|
|
441
|
+
switchConversation: s,
|
|
285
442
|
newConversation: r,
|
|
286
|
-
deleteConversation:
|
|
287
|
-
renameConversation:
|
|
288
|
-
isThreadListOpen:
|
|
443
|
+
deleteConversation: n,
|
|
444
|
+
renameConversation: o,
|
|
445
|
+
isThreadListOpen: i,
|
|
289
446
|
toggleThreadList: l
|
|
290
|
-
} =
|
|
291
|
-
p(g),
|
|
292
|
-
}, []), v =
|
|
293
|
-
f.trim() &&
|
|
294
|
-
}, [f,
|
|
295
|
-
return
|
|
447
|
+
} = F(), [c, p] = T(null), [f, u] = T(""), h = N((g, b) => {
|
|
448
|
+
p(g), u(b ?? "");
|
|
449
|
+
}, []), v = N((g) => {
|
|
450
|
+
f.trim() && o(g, f.trim()), p(null);
|
|
451
|
+
}, [f, o]), k = V(() => me(a), [a]);
|
|
452
|
+
return i ? /* @__PURE__ */ d(q, { children: [
|
|
296
453
|
/* @__PURE__ */ e("div", { className: "sa-thread-list-overlay", onClick: l }),
|
|
297
|
-
/* @__PURE__ */
|
|
298
|
-
/* @__PURE__ */
|
|
454
|
+
/* @__PURE__ */ d("div", { className: "sa-thread-list", children: [
|
|
455
|
+
/* @__PURE__ */ d("div", { className: "sa-thread-list-header", children: [
|
|
299
456
|
/* @__PURE__ */ e("span", { className: "sa-thread-list-title", children: "会话记录" }),
|
|
300
|
-
/* @__PURE__ */
|
|
301
|
-
/* @__PURE__ */ e(
|
|
457
|
+
/* @__PURE__ */ d("button", { className: "sa-thread-list-new", onClick: r, children: [
|
|
458
|
+
/* @__PURE__ */ e(C, { name: "plus", size: 14 }),
|
|
302
459
|
" 新会话"
|
|
303
460
|
] })
|
|
304
461
|
] }),
|
|
305
|
-
/* @__PURE__ */
|
|
462
|
+
/* @__PURE__ */ d("div", { className: "sa-thread-list-items", children: [
|
|
306
463
|
a.length === 0 && /* @__PURE__ */ e("div", { className: "sa-thread-list-empty", children: "暂无会话" }),
|
|
307
|
-
|
|
464
|
+
k.map((g) => /* @__PURE__ */ d("div", { className: "sa-thread-group", children: [
|
|
308
465
|
/* @__PURE__ */ e("div", { className: "sa-thread-group-label", children: g.label }),
|
|
309
|
-
g.items.map((b) => /* @__PURE__ */
|
|
466
|
+
g.items.map((b) => /* @__PURE__ */ d(
|
|
310
467
|
"div",
|
|
311
468
|
{
|
|
312
469
|
className: `sa-thread-item ${b.sessionId === t ? "active" : ""}`,
|
|
313
|
-
onClick: () =>
|
|
470
|
+
onClick: () => s(b.sessionId),
|
|
314
471
|
children: [
|
|
315
|
-
|
|
472
|
+
c === b.sessionId ? /* @__PURE__ */ e(
|
|
316
473
|
"input",
|
|
317
474
|
{
|
|
318
475
|
className: "sa-thread-item-edit",
|
|
319
476
|
value: f,
|
|
320
|
-
onChange: (
|
|
477
|
+
onChange: (m) => u(m.target.value),
|
|
321
478
|
onBlur: () => v(b.sessionId),
|
|
322
|
-
onKeyDown: (
|
|
323
|
-
|
|
479
|
+
onKeyDown: (m) => {
|
|
480
|
+
m.key === "Enter" && v(b.sessionId), m.key === "Escape" && p(null);
|
|
324
481
|
},
|
|
325
|
-
onClick: (
|
|
482
|
+
onClick: (m) => m.stopPropagation(),
|
|
326
483
|
autoFocus: !0
|
|
327
484
|
}
|
|
328
485
|
) : /* @__PURE__ */ e(
|
|
329
486
|
"span",
|
|
330
487
|
{
|
|
331
488
|
className: "sa-thread-item-title",
|
|
332
|
-
onDoubleClick: (
|
|
333
|
-
|
|
489
|
+
onDoubleClick: (m) => {
|
|
490
|
+
m.stopPropagation(), h(b.sessionId, b.title);
|
|
334
491
|
},
|
|
335
492
|
children: b.title || "新会话"
|
|
336
493
|
}
|
|
@@ -339,11 +496,11 @@ function de() {
|
|
|
339
496
|
"button",
|
|
340
497
|
{
|
|
341
498
|
className: "sa-thread-item-delete",
|
|
342
|
-
onClick: (
|
|
343
|
-
|
|
499
|
+
onClick: (m) => {
|
|
500
|
+
m.stopPropagation(), n(b.sessionId);
|
|
344
501
|
},
|
|
345
502
|
title: "删除",
|
|
346
|
-
children: /* @__PURE__ */ e(
|
|
503
|
+
children: /* @__PURE__ */ e(C, { name: "trash2", size: 14 })
|
|
347
504
|
}
|
|
348
505
|
)
|
|
349
506
|
]
|
|
@@ -355,242 +512,315 @@ function de() {
|
|
|
355
512
|
] })
|
|
356
513
|
] }) : null;
|
|
357
514
|
}
|
|
358
|
-
function
|
|
359
|
-
const t =
|
|
360
|
-
const
|
|
361
|
-
if (!
|
|
362
|
-
const { scrollTop: l, scrollHeight:
|
|
363
|
-
l < r.current && !f && (
|
|
515
|
+
function ge(a) {
|
|
516
|
+
const t = _(null), s = _(!1), r = _(0), n = N(() => {
|
|
517
|
+
const i = t.current;
|
|
518
|
+
if (!i) return;
|
|
519
|
+
const { scrollTop: l, scrollHeight: c, clientHeight: p } = i, f = c - l - p < 40;
|
|
520
|
+
l < r.current && !f && (s.current = !0), f && (s.current = !1), r.current = l;
|
|
364
521
|
}, []);
|
|
365
|
-
|
|
366
|
-
const
|
|
367
|
-
if (
|
|
368
|
-
return
|
|
369
|
-
}, [
|
|
370
|
-
if (
|
|
371
|
-
const
|
|
372
|
-
|
|
373
|
-
|
|
522
|
+
B(() => {
|
|
523
|
+
const i = t.current;
|
|
524
|
+
if (i)
|
|
525
|
+
return i.addEventListener("scroll", n, { passive: !0 }), () => i.removeEventListener("scroll", n);
|
|
526
|
+
}, [n]), B(() => {
|
|
527
|
+
if (s.current) return;
|
|
528
|
+
const i = t.current;
|
|
529
|
+
i && requestAnimationFrame(() => {
|
|
530
|
+
i.scrollTop = i.scrollHeight;
|
|
374
531
|
});
|
|
375
532
|
}, a);
|
|
376
|
-
const
|
|
377
|
-
|
|
378
|
-
const
|
|
379
|
-
|
|
533
|
+
const o = N(() => {
|
|
534
|
+
s.current = !1;
|
|
535
|
+
const i = t.current;
|
|
536
|
+
i && (i.scrollTop = i.scrollHeight);
|
|
380
537
|
}, []);
|
|
381
|
-
return { containerRef: t, scrollToBottom:
|
|
538
|
+
return { containerRef: t, scrollToBottom: o };
|
|
382
539
|
}
|
|
383
|
-
function
|
|
540
|
+
function j(a) {
|
|
384
541
|
return a.value++;
|
|
385
542
|
}
|
|
386
|
-
function
|
|
387
|
-
const
|
|
388
|
-
r.length > 0 && (
|
|
543
|
+
function K(a, t) {
|
|
544
|
+
const s = [], r = [], n = () => {
|
|
545
|
+
r.length > 0 && (s.push(r.join("")), r.length = 0);
|
|
389
546
|
};
|
|
390
|
-
let
|
|
391
|
-
for (;
|
|
392
|
-
const
|
|
393
|
-
if (
|
|
394
|
-
const l = a.indexOf("`",
|
|
547
|
+
let o = 0;
|
|
548
|
+
for (; o < a.length; ) {
|
|
549
|
+
const i = a[o];
|
|
550
|
+
if (i === "`") {
|
|
551
|
+
const l = a.indexOf("`", o + 1);
|
|
395
552
|
if (l !== -1) {
|
|
396
|
-
|
|
397
|
-
/* @__PURE__ */ e("code", { className: "sa-inline-code", children: a.slice(
|
|
398
|
-
),
|
|
553
|
+
n(), s.push(
|
|
554
|
+
/* @__PURE__ */ e("code", { className: "sa-inline-code", children: a.slice(o + 1, l) }, j(t))
|
|
555
|
+
), o = l + 1;
|
|
399
556
|
continue;
|
|
400
557
|
}
|
|
401
|
-
} else if (
|
|
402
|
-
const l = a.indexOf("**",
|
|
558
|
+
} else if (i === "*" && a[o + 1] === "*") {
|
|
559
|
+
const l = a.indexOf("**", o + 2);
|
|
403
560
|
if (l !== -1) {
|
|
404
|
-
|
|
405
|
-
/* @__PURE__ */ e("strong", { children:
|
|
406
|
-
),
|
|
561
|
+
n(), s.push(
|
|
562
|
+
/* @__PURE__ */ e("strong", { children: K(a.slice(o + 2, l), t) }, j(t))
|
|
563
|
+
), o = l + 2;
|
|
407
564
|
continue;
|
|
408
565
|
}
|
|
409
|
-
} else if (
|
|
410
|
-
const l = a.indexOf("*",
|
|
566
|
+
} else if (i === "*") {
|
|
567
|
+
const l = a.indexOf("*", o + 1);
|
|
411
568
|
if (l !== -1) {
|
|
412
|
-
|
|
413
|
-
/* @__PURE__ */ e("em", { children:
|
|
414
|
-
),
|
|
569
|
+
n(), s.push(
|
|
570
|
+
/* @__PURE__ */ e("em", { children: K(a.slice(o + 1, l), t) }, j(t))
|
|
571
|
+
), o = l + 1;
|
|
415
572
|
continue;
|
|
416
573
|
}
|
|
417
|
-
} else if (
|
|
418
|
-
const l = a.indexOf("]",
|
|
574
|
+
} else if (i === "[") {
|
|
575
|
+
const l = a.indexOf("]", o + 1);
|
|
419
576
|
if (l !== -1 && a[l + 1] === "(") {
|
|
420
|
-
const
|
|
421
|
-
if (
|
|
422
|
-
const p = a.slice(
|
|
423
|
-
|
|
577
|
+
const c = a.indexOf(")", l + 2);
|
|
578
|
+
if (c !== -1) {
|
|
579
|
+
const p = a.slice(o + 1, l), f = a.slice(l + 2, c);
|
|
580
|
+
n(), s.push(
|
|
424
581
|
/* @__PURE__ */ e(
|
|
425
582
|
"a",
|
|
426
583
|
{
|
|
427
584
|
href: f,
|
|
428
585
|
target: "_blank",
|
|
429
586
|
rel: "noreferrer",
|
|
430
|
-
children:
|
|
587
|
+
children: K(p, t)
|
|
431
588
|
},
|
|
432
|
-
|
|
589
|
+
j(t)
|
|
433
590
|
)
|
|
434
|
-
),
|
|
591
|
+
), o = c + 1;
|
|
435
592
|
continue;
|
|
436
593
|
}
|
|
437
594
|
}
|
|
438
595
|
}
|
|
439
|
-
r.push(
|
|
596
|
+
r.push(i), o++;
|
|
440
597
|
}
|
|
441
|
-
return
|
|
598
|
+
return n(), s;
|
|
442
599
|
}
|
|
443
|
-
function
|
|
444
|
-
const
|
|
600
|
+
function xe(a, t) {
|
|
601
|
+
const s = [], r = a.split(`
|
|
445
602
|
`);
|
|
446
|
-
let
|
|
447
|
-
const
|
|
448
|
-
for (;
|
|
449
|
-
const
|
|
450
|
-
if (c
|
|
451
|
-
|
|
603
|
+
let n = 0;
|
|
604
|
+
const o = (c) => c.trim() === "", i = (c) => /^#{1,6}\s+\S/.test(c.trim()), l = (c) => /^(?:[-*+]|\d+[.)])\s+\S/.test(c.trim());
|
|
605
|
+
for (; n < r.length; ) {
|
|
606
|
+
const c = r[n], p = c.trim();
|
|
607
|
+
if (o(c)) {
|
|
608
|
+
n++;
|
|
452
609
|
continue;
|
|
453
610
|
}
|
|
454
|
-
if (
|
|
455
|
-
const
|
|
456
|
-
if (
|
|
457
|
-
const v = `h${Math.min(
|
|
458
|
-
|
|
459
|
-
|
|
611
|
+
if (i(c)) {
|
|
612
|
+
const u = p.match(/^(#{1,6})\s+(.*)$/);
|
|
613
|
+
if (u) {
|
|
614
|
+
const v = `h${Math.min(u[1].length, 6)}`;
|
|
615
|
+
s.push(
|
|
616
|
+
Y.createElement(
|
|
460
617
|
v,
|
|
461
|
-
{ key:
|
|
462
|
-
|
|
618
|
+
{ key: j(t) },
|
|
619
|
+
K(u[2], t)
|
|
463
620
|
)
|
|
464
621
|
);
|
|
465
622
|
}
|
|
466
|
-
|
|
623
|
+
n++;
|
|
467
624
|
continue;
|
|
468
625
|
}
|
|
469
|
-
if (l(
|
|
470
|
-
const
|
|
471
|
-
for (;
|
|
472
|
-
const v = r[
|
|
473
|
-
v &&
|
|
474
|
-
/* @__PURE__ */ e("li", { children:
|
|
475
|
-
),
|
|
626
|
+
if (l(c)) {
|
|
627
|
+
const u = /^\d+[.)]/.test(p), h = [];
|
|
628
|
+
for (; n < r.length && l(r[n]); ) {
|
|
629
|
+
const v = r[n].trim().match(/^(?:[-*+]|\d+[.)])\s+(.*)$/);
|
|
630
|
+
v && h.push(
|
|
631
|
+
/* @__PURE__ */ e("li", { children: K(v[1], t) }, j(t))
|
|
632
|
+
), n++;
|
|
476
633
|
}
|
|
477
|
-
|
|
478
|
-
|
|
634
|
+
s.push(
|
|
635
|
+
u ? /* @__PURE__ */ e("ol", { className: "sa-list", children: h }, j(t)) : /* @__PURE__ */ e("ul", { className: "sa-list", children: h }, j(t))
|
|
479
636
|
);
|
|
480
637
|
continue;
|
|
481
638
|
}
|
|
482
639
|
const f = [];
|
|
483
|
-
for (;
|
|
484
|
-
f.push(r[
|
|
485
|
-
|
|
486
|
-
/* @__PURE__ */ e("p", { className: "sa-text-paragraph", children:
|
|
640
|
+
for (; n < r.length && !o(r[n]) && !i(r[n]) && !l(r[n]); )
|
|
641
|
+
f.push(r[n]), n++;
|
|
642
|
+
s.push(
|
|
643
|
+
/* @__PURE__ */ e("p", { className: "sa-text-paragraph", children: K(f.join(" "), t) }, j(t))
|
|
487
644
|
);
|
|
488
645
|
}
|
|
489
|
-
return
|
|
646
|
+
return s;
|
|
490
647
|
}
|
|
491
|
-
function
|
|
492
|
-
const t = { value: 0 },
|
|
493
|
-
for (let
|
|
494
|
-
if (
|
|
495
|
-
|
|
496
|
-
else if (r[
|
|
497
|
-
let
|
|
498
|
-
|
|
499
|
-
/* @__PURE__ */ e("pre", { className: "sa-code-block", children: /* @__PURE__ */ e("code", { children:
|
|
648
|
+
function be(a) {
|
|
649
|
+
const t = { value: 0 }, s = [], r = a.split("```");
|
|
650
|
+
for (let n = 0; n < r.length; n++)
|
|
651
|
+
if (n % 2 === 0)
|
|
652
|
+
s.push(...xe(r[n], t));
|
|
653
|
+
else if (r[n].trim() !== "") {
|
|
654
|
+
let o = r[n].replace(/^\r?\n/, "");
|
|
655
|
+
o = o.replace(/^[a-zA-Z0-9_+#.-]+\r?\n/, ""), o = o.replace(/\r?\n$/, ""), s.push(
|
|
656
|
+
/* @__PURE__ */ e("pre", { className: "sa-code-block", children: /* @__PURE__ */ e("code", { children: o }) }, j(t))
|
|
500
657
|
);
|
|
501
658
|
}
|
|
502
|
-
return
|
|
659
|
+
return s;
|
|
503
660
|
}
|
|
504
|
-
function
|
|
505
|
-
return /* @__PURE__ */ e("div", { className: "sa-text-part", children:
|
|
661
|
+
function ve({ content: a }) {
|
|
662
|
+
return /* @__PURE__ */ e("div", { className: "sa-text-part", children: be(a) });
|
|
506
663
|
}
|
|
507
|
-
function
|
|
508
|
-
const [t,
|
|
509
|
-
return /* @__PURE__ */
|
|
510
|
-
/* @__PURE__ */
|
|
511
|
-
/* @__PURE__ */ e("span", { className: "sa-thinking-icon", children: /* @__PURE__ */ e(
|
|
664
|
+
function we({ content: a }) {
|
|
665
|
+
const [t, s] = T(!1);
|
|
666
|
+
return /* @__PURE__ */ d("div", { className: "sa-thinking-part", onClick: () => s(!t), children: [
|
|
667
|
+
/* @__PURE__ */ d("div", { className: "sa-thinking-header", children: [
|
|
668
|
+
/* @__PURE__ */ e("span", { className: "sa-thinking-icon", children: /* @__PURE__ */ e(C, { name: "brain", size: 14 }) }),
|
|
512
669
|
/* @__PURE__ */ e("span", { className: "sa-thinking-label", children: "思考过程" }),
|
|
513
|
-
/* @__PURE__ */ e("span", { className: `sa-thinking-arrow ${t ? "expanded" : ""}`, children: /* @__PURE__ */ e(
|
|
670
|
+
/* @__PURE__ */ e("span", { className: `sa-thinking-arrow ${t ? "expanded" : ""}`, children: /* @__PURE__ */ e(C, { name: "chevron-right", size: 12 }) })
|
|
514
671
|
] }),
|
|
515
672
|
t && /* @__PURE__ */ e("div", { className: "sa-thinking-content", children: a })
|
|
516
673
|
] });
|
|
517
674
|
}
|
|
518
|
-
function
|
|
519
|
-
const [r,
|
|
520
|
-
let
|
|
675
|
+
function ye({ toolName: a, toolCallId: t, args: s }) {
|
|
676
|
+
const [r, n] = T(!1);
|
|
677
|
+
let o = s;
|
|
521
678
|
try {
|
|
522
|
-
|
|
679
|
+
o = JSON.stringify(JSON.parse(s), null, 2);
|
|
523
680
|
} catch {
|
|
524
681
|
}
|
|
525
|
-
return /* @__PURE__ */
|
|
526
|
-
/* @__PURE__ */
|
|
527
|
-
/* @__PURE__ */ e("span", { className: "sa-tool-icon", children: /* @__PURE__ */ e(
|
|
528
|
-
/* @__PURE__ */
|
|
682
|
+
return /* @__PURE__ */ d("div", { className: "sa-tool-call-part", children: [
|
|
683
|
+
/* @__PURE__ */ d("div", { className: "sa-tool-call-header", onClick: () => n(!r), children: [
|
|
684
|
+
/* @__PURE__ */ e("span", { className: "sa-tool-icon", children: /* @__PURE__ */ e(C, { name: "zap", size: 14 }) }),
|
|
685
|
+
/* @__PURE__ */ d("span", { className: "sa-tool-name", children: [
|
|
529
686
|
"调用工具: ",
|
|
530
687
|
a
|
|
531
688
|
] }),
|
|
532
|
-
/* @__PURE__ */ e("span", { className: `sa-thinking-arrow ${r ? "expanded" : ""}`, children: /* @__PURE__ */ e(
|
|
689
|
+
/* @__PURE__ */ e("span", { className: `sa-thinking-arrow ${r ? "expanded" : ""}`, children: /* @__PURE__ */ e(C, { name: "chevron-right", size: 12 }) })
|
|
533
690
|
] }),
|
|
534
|
-
r && /* @__PURE__ */ e("pre", { className: "sa-tool-args", children:
|
|
691
|
+
r && /* @__PURE__ */ e("pre", { className: "sa-tool-args", children: o })
|
|
535
692
|
] });
|
|
536
693
|
}
|
|
537
|
-
function
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
694
|
+
function ke({ html: a }) {
|
|
695
|
+
const [t, s] = T(null);
|
|
696
|
+
return B(() => {
|
|
697
|
+
let r = !1;
|
|
698
|
+
return import("./purify.es-C-6FFqDW.js").then((n) => {
|
|
699
|
+
r || s(n.default.sanitize(a, { FORCE_BODY: !0 }));
|
|
700
|
+
}), () => {
|
|
701
|
+
r = !0;
|
|
702
|
+
};
|
|
703
|
+
}, [a]), t === null ? null : /* @__PURE__ */ e("div", { className: "sa-tool-result-html", children: /* @__PURE__ */ e("iframe", { srcDoc: t, className: "sa-tool-result-html-iframe", sandbox: "", title: "HTML 产物" }) });
|
|
704
|
+
}
|
|
705
|
+
function Ce({ toolName: a, content: t, artifacts: s, renderMode: r, html: n, artifactPreview: o }) {
|
|
706
|
+
const { openArtifactPreview: i } = F(), l = ae(s);
|
|
707
|
+
return /* @__PURE__ */ d("div", { className: "sa-tool-result-part", children: [
|
|
708
|
+
/* @__PURE__ */ d("div", { className: "sa-tool-result-header", children: [
|
|
709
|
+
/* @__PURE__ */ e("span", { className: "sa-tool-icon", children: /* @__PURE__ */ e(C, { name: "circle-check", size: 14, color: "#10b981" }) }),
|
|
541
710
|
/* @__PURE__ */ e("span", { className: "sa-tool-result-label", children: a || "工具返回" })
|
|
542
711
|
] }),
|
|
543
|
-
/* @__PURE__ */ e("div", { className: "sa-tool-result-content", children:
|
|
712
|
+
r === "html" && n ? /* @__PURE__ */ e(ke, { html: n }) : t ? /* @__PURE__ */ e("div", { className: "sa-tool-result-content", children: t }) : null,
|
|
713
|
+
l.length > 0 && /* @__PURE__ */ e("ul", { className: "sa-artifact-file-list", role: "list", children: l.map((c, p) => /* @__PURE__ */ d(
|
|
714
|
+
"li",
|
|
715
|
+
{
|
|
716
|
+
className: "sa-artifact-file-card",
|
|
717
|
+
onClick: o ? () => i(c) : void 0,
|
|
718
|
+
onKeyDown: o ? (f) => {
|
|
719
|
+
(f.key === "Enter" || f.key === " ") && (f.preventDefault(), i(c));
|
|
720
|
+
} : void 0,
|
|
721
|
+
tabIndex: o ? 0 : void 0,
|
|
722
|
+
role: o ? "button" : void 0,
|
|
723
|
+
"aria-label": o ? `预览 ${c.filename}` : void 0,
|
|
724
|
+
style: o ? { cursor: "pointer" } : void 0,
|
|
725
|
+
children: [
|
|
726
|
+
/* @__PURE__ */ e("div", { className: "sa-artifact-file-icon", children: /* @__PURE__ */ e("span", { className: "sa-artifact-chip-type", children: ee(c.type) }) }),
|
|
727
|
+
/* @__PURE__ */ d("div", { className: "sa-artifact-file-info", children: [
|
|
728
|
+
/* @__PURE__ */ e("span", { className: "sa-artifact-file-name", children: c.filename }),
|
|
729
|
+
c.size != null && /* @__PURE__ */ e("span", { className: "sa-artifact-file-size", children: Q(c.size) })
|
|
730
|
+
] }),
|
|
731
|
+
o && /* @__PURE__ */ e(
|
|
732
|
+
"button",
|
|
733
|
+
{
|
|
734
|
+
className: "sa-artifact-file-download",
|
|
735
|
+
title: "下载",
|
|
736
|
+
"aria-label": `下载 ${c.filename}`,
|
|
737
|
+
onClick: (f) => {
|
|
738
|
+
f.stopPropagation(), U(c);
|
|
739
|
+
},
|
|
740
|
+
children: /* @__PURE__ */ e("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: /* @__PURE__ */ e("path", { d: "M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4M7 10l5 5 5-5M12 15V3" }) })
|
|
741
|
+
}
|
|
742
|
+
)
|
|
743
|
+
]
|
|
744
|
+
},
|
|
745
|
+
c.id || `art-${p}`
|
|
746
|
+
)) })
|
|
544
747
|
] });
|
|
545
748
|
}
|
|
546
|
-
function
|
|
547
|
-
return /* @__PURE__ */
|
|
548
|
-
/* @__PURE__ */
|
|
549
|
-
/* @__PURE__ */ e("span", { className: "sa-error-icon", children: /* @__PURE__ */ e(
|
|
749
|
+
function Ne({ content: a, onRetry: t }) {
|
|
750
|
+
return /* @__PURE__ */ d("div", { className: "sa-error-part", children: [
|
|
751
|
+
/* @__PURE__ */ d("div", { className: "sa-error-content", children: [
|
|
752
|
+
/* @__PURE__ */ e("span", { className: "sa-error-icon", children: /* @__PURE__ */ e(C, { name: "triangle-alert", size: 14 }) }),
|
|
550
753
|
/* @__PURE__ */ e("span", { children: a })
|
|
551
754
|
] }),
|
|
552
755
|
t && /* @__PURE__ */ e("button", { className: "sa-error-retry", onClick: t, children: "重试" })
|
|
553
756
|
] });
|
|
554
757
|
}
|
|
555
|
-
function
|
|
556
|
-
var
|
|
557
|
-
const
|
|
558
|
-
return /* @__PURE__ */
|
|
559
|
-
/* @__PURE__ */
|
|
560
|
-
/* @__PURE__ */ e(
|
|
758
|
+
function ze({ interrupt: a, onRespond: t }) {
|
|
759
|
+
var o, i;
|
|
760
|
+
const s = a.options, r = (typeof (s == null ? void 0 : s[0]) == "string" ? s[0] : (o = s == null ? void 0 : s[0]) == null ? void 0 : o.label) || "确认", n = (typeof (s == null ? void 0 : s[1]) == "string" ? s[1] : (i = s == null ? void 0 : s[1]) == null ? void 0 : i.label) || "取消";
|
|
761
|
+
return /* @__PURE__ */ d("div", { className: "sa-interrupt-card", children: [
|
|
762
|
+
/* @__PURE__ */ d("div", { className: "sa-interrupt-content", children: [
|
|
763
|
+
/* @__PURE__ */ e(C, { name: "circle-alert", size: 16, color: "#f59e0b" }),
|
|
561
764
|
/* @__PURE__ */ e("span", { children: a.content })
|
|
562
765
|
] }),
|
|
563
|
-
/* @__PURE__ */
|
|
564
|
-
/* @__PURE__ */
|
|
565
|
-
/* @__PURE__ */ e(
|
|
766
|
+
/* @__PURE__ */ d("div", { className: "sa-interrupt-actions", children: [
|
|
767
|
+
/* @__PURE__ */ d("button", { className: "sa-interrupt-btn sa-interrupt-btn-primary", onClick: () => t({ action: "confirm" }), children: [
|
|
768
|
+
/* @__PURE__ */ e(C, { name: "check", size: 14 }),
|
|
566
769
|
" ",
|
|
567
770
|
r
|
|
568
771
|
] }),
|
|
569
|
-
/* @__PURE__ */
|
|
570
|
-
/* @__PURE__ */ e(
|
|
772
|
+
/* @__PURE__ */ d("button", { className: "sa-interrupt-btn sa-interrupt-btn-secondary", onClick: () => t({ action: "cancel" }), children: [
|
|
773
|
+
/* @__PURE__ */ e(C, { name: "x", size: 14 }),
|
|
571
774
|
" ",
|
|
572
|
-
|
|
775
|
+
n
|
|
573
776
|
] })
|
|
574
777
|
] })
|
|
575
778
|
] });
|
|
576
779
|
}
|
|
577
|
-
function
|
|
780
|
+
function Ie({ interrupt: a, onRespond: t }) {
|
|
781
|
+
var l, c, p, f;
|
|
782
|
+
const s = a.options, r = (typeof (s == null ? void 0 : s[0]) == "string" ? s[0] : (l = s == null ? void 0 : s[0]) == null ? void 0 : l.label) || "批准", n = (typeof (s == null ? void 0 : s[1]) == "string" ? s[1] : (c = s == null ? void 0 : s[1]) == null ? void 0 : c.label) || "拒绝", o = (typeof (s == null ? void 0 : s[2]) == "string" ? s[2] : (p = s == null ? void 0 : s[2]) == null ? void 0 : p.label) || "跳过", i = ((f = a.metadata) == null ? void 0 : f.showSkip) !== !1;
|
|
783
|
+
return /* @__PURE__ */ d("div", { className: "sa-interrupt-card", children: [
|
|
784
|
+
/* @__PURE__ */ d("div", { className: "sa-interrupt-content", children: [
|
|
785
|
+
/* @__PURE__ */ e(C, { name: "circle-alert", size: 16, color: "#f59e0b" }),
|
|
786
|
+
/* @__PURE__ */ e("span", { children: a.content })
|
|
787
|
+
] }),
|
|
788
|
+
/* @__PURE__ */ d("div", { className: "sa-interrupt-actions", children: [
|
|
789
|
+
/* @__PURE__ */ d("button", { className: "sa-interrupt-btn sa-interrupt-btn-primary", onClick: () => t({ action: "approve" }), children: [
|
|
790
|
+
/* @__PURE__ */ e(C, { name: "check", size: 14 }),
|
|
791
|
+
" ",
|
|
792
|
+
r
|
|
793
|
+
] }),
|
|
794
|
+
/* @__PURE__ */ d("button", { className: "sa-interrupt-btn sa-interrupt-btn-danger", onClick: () => t({ action: "reject" }), children: [
|
|
795
|
+
/* @__PURE__ */ e(C, { name: "x", size: 14 }),
|
|
796
|
+
" ",
|
|
797
|
+
n
|
|
798
|
+
] }),
|
|
799
|
+
i && /* @__PURE__ */ d("button", { className: "sa-interrupt-btn sa-interrupt-btn-secondary", onClick: () => t({ action: "skip" }), children: [
|
|
800
|
+
/* @__PURE__ */ e(C, { name: "chevron-right", size: 14 }),
|
|
801
|
+
" ",
|
|
802
|
+
o
|
|
803
|
+
] })
|
|
804
|
+
] })
|
|
805
|
+
] });
|
|
806
|
+
}
|
|
807
|
+
function Te(a) {
|
|
578
808
|
return typeof a == "string" ? { value: a, label: a } : a;
|
|
579
809
|
}
|
|
580
|
-
function
|
|
581
|
-
const
|
|
582
|
-
return /* @__PURE__ */
|
|
583
|
-
/* @__PURE__ */
|
|
584
|
-
/* @__PURE__ */ e(
|
|
810
|
+
function Se({ interrupt: a, onRespond: t }) {
|
|
811
|
+
const s = (a.options ?? []).map(Te);
|
|
812
|
+
return /* @__PURE__ */ d("div", { className: "sa-interrupt-card", children: [
|
|
813
|
+
/* @__PURE__ */ d("div", { className: "sa-interrupt-content", children: [
|
|
814
|
+
/* @__PURE__ */ e(C, { name: "list", size: 16, color: "#6366f1" }),
|
|
585
815
|
/* @__PURE__ */ e("span", { children: a.content })
|
|
586
816
|
] }),
|
|
587
|
-
/* @__PURE__ */ e("div", { className: "sa-interrupt-options", children:
|
|
817
|
+
/* @__PURE__ */ e("div", { className: "sa-interrupt-options", children: s.map((r) => /* @__PURE__ */ d(
|
|
588
818
|
"button",
|
|
589
819
|
{
|
|
590
820
|
className: `sa-interrupt-option ${r.danger ? "sa-interrupt-option-danger" : ""}`,
|
|
591
821
|
onClick: () => t({ action: "select", value: r.value }),
|
|
592
822
|
children: [
|
|
593
|
-
r.icon && /* @__PURE__ */ e(
|
|
823
|
+
r.icon && /* @__PURE__ */ e(C, { name: r.icon, size: 14 }),
|
|
594
824
|
/* @__PURE__ */ e("span", { children: r.label }),
|
|
595
825
|
r.description && /* @__PURE__ */ e("span", { className: "sa-interrupt-option-desc", children: r.description })
|
|
596
826
|
]
|
|
@@ -599,41 +829,41 @@ function we({ interrupt: a, onRespond: t }) {
|
|
|
599
829
|
)) })
|
|
600
830
|
] });
|
|
601
831
|
}
|
|
602
|
-
function
|
|
832
|
+
function Me(a) {
|
|
603
833
|
return typeof a == "string" ? { value: a, label: a } : a;
|
|
604
834
|
}
|
|
605
|
-
function
|
|
606
|
-
const
|
|
607
|
-
|
|
608
|
-
const
|
|
609
|
-
return
|
|
835
|
+
function De({ interrupt: a, onRespond: t }) {
|
|
836
|
+
const s = (a.options ?? []).map(Me), [r, n] = T(/* @__PURE__ */ new Set()), o = (i) => {
|
|
837
|
+
n((l) => {
|
|
838
|
+
const c = new Set(l);
|
|
839
|
+
return c.has(i) ? c.delete(i) : c.add(i), c;
|
|
610
840
|
});
|
|
611
841
|
};
|
|
612
|
-
return /* @__PURE__ */
|
|
613
|
-
/* @__PURE__ */
|
|
614
|
-
/* @__PURE__ */ e(
|
|
842
|
+
return /* @__PURE__ */ d("div", { className: "sa-interrupt-card", children: [
|
|
843
|
+
/* @__PURE__ */ d("div", { className: "sa-interrupt-content", children: [
|
|
844
|
+
/* @__PURE__ */ e(C, { name: "list-checks", size: 16, color: "#6366f1" }),
|
|
615
845
|
/* @__PURE__ */ e("span", { children: a.content })
|
|
616
846
|
] }),
|
|
617
|
-
/* @__PURE__ */ e("div", { className: "sa-interrupt-options", children:
|
|
847
|
+
/* @__PURE__ */ e("div", { className: "sa-interrupt-options", children: s.map((i) => /* @__PURE__ */ d(
|
|
618
848
|
"button",
|
|
619
849
|
{
|
|
620
|
-
className: `sa-interrupt-option ${r.has(
|
|
621
|
-
onClick: () =>
|
|
850
|
+
className: `sa-interrupt-option ${r.has(i.value) ? "sa-interrupt-option-selected" : ""}`,
|
|
851
|
+
onClick: () => o(i.value),
|
|
622
852
|
children: [
|
|
623
|
-
/* @__PURE__ */ e(
|
|
624
|
-
/* @__PURE__ */ e("span", { children:
|
|
853
|
+
/* @__PURE__ */ e(C, { name: r.has(i.value) ? "square-check" : "square", size: 14 }),
|
|
854
|
+
/* @__PURE__ */ e("span", { children: i.label })
|
|
625
855
|
]
|
|
626
856
|
},
|
|
627
|
-
|
|
857
|
+
i.value
|
|
628
858
|
)) }),
|
|
629
|
-
/* @__PURE__ */ e("div", { className: "sa-interrupt-actions", children: /* @__PURE__ */
|
|
859
|
+
/* @__PURE__ */ e("div", { className: "sa-interrupt-actions", children: /* @__PURE__ */ d(
|
|
630
860
|
"button",
|
|
631
861
|
{
|
|
632
862
|
className: "sa-interrupt-btn sa-interrupt-btn-primary",
|
|
633
863
|
disabled: r.size === 0,
|
|
634
864
|
onClick: () => t({ action: "submit", value: Array.from(r) }),
|
|
635
865
|
children: [
|
|
636
|
-
/* @__PURE__ */ e(
|
|
866
|
+
/* @__PURE__ */ e(C, { name: "check", size: 14 }),
|
|
637
867
|
" 确认 (",
|
|
638
868
|
r.size,
|
|
639
869
|
")"
|
|
@@ -642,20 +872,20 @@ function Ce({ interrupt: a, onRespond: t }) {
|
|
|
642
872
|
) })
|
|
643
873
|
] });
|
|
644
874
|
}
|
|
645
|
-
function
|
|
646
|
-
const [
|
|
647
|
-
a.required && !
|
|
875
|
+
function Le({ interrupt: a, onRespond: t }) {
|
|
876
|
+
const [s, r] = T(""), n = a.inputType ?? "text", o = n === "textarea", i = () => {
|
|
877
|
+
a.required && !s.trim() || t({ action: "submit", value: s.trim() });
|
|
648
878
|
};
|
|
649
|
-
return /* @__PURE__ */
|
|
650
|
-
/* @__PURE__ */
|
|
651
|
-
/* @__PURE__ */ e(
|
|
879
|
+
return /* @__PURE__ */ d("div", { className: "sa-interrupt-card", children: [
|
|
880
|
+
/* @__PURE__ */ d("div", { className: "sa-interrupt-content", children: [
|
|
881
|
+
/* @__PURE__ */ e(C, { name: "text-cursor-input", size: 16, color: "#6366f1" }),
|
|
652
882
|
/* @__PURE__ */ e("span", { children: a.content })
|
|
653
883
|
] }),
|
|
654
|
-
/* @__PURE__ */ e("div", { className: "sa-interrupt-input-area", children:
|
|
884
|
+
/* @__PURE__ */ e("div", { className: "sa-interrupt-input-area", children: o ? /* @__PURE__ */ e(
|
|
655
885
|
"textarea",
|
|
656
886
|
{
|
|
657
887
|
className: "sa-interrupt-textarea",
|
|
658
|
-
value:
|
|
888
|
+
value: s,
|
|
659
889
|
onChange: (l) => r(l.target.value),
|
|
660
890
|
placeholder: a.placeholder,
|
|
661
891
|
maxLength: a.maxLength,
|
|
@@ -665,98 +895,100 @@ function Ne({ interrupt: a, onRespond: t }) {
|
|
|
665
895
|
"input",
|
|
666
896
|
{
|
|
667
897
|
className: "sa-interrupt-input",
|
|
668
|
-
type:
|
|
669
|
-
value:
|
|
898
|
+
type: n,
|
|
899
|
+
value: s,
|
|
670
900
|
onChange: (l) => r(l.target.value),
|
|
671
901
|
placeholder: a.placeholder,
|
|
672
902
|
maxLength: a.maxLength,
|
|
673
|
-
onKeyDown: (l) => l.key === "Enter" &&
|
|
903
|
+
onKeyDown: (l) => l.key === "Enter" && i()
|
|
674
904
|
}
|
|
675
905
|
) }),
|
|
676
|
-
/* @__PURE__ */ e("div", { className: "sa-interrupt-actions", children: /* @__PURE__ */
|
|
906
|
+
/* @__PURE__ */ e("div", { className: "sa-interrupt-actions", children: /* @__PURE__ */ d(
|
|
677
907
|
"button",
|
|
678
908
|
{
|
|
679
909
|
className: "sa-interrupt-btn sa-interrupt-btn-primary",
|
|
680
|
-
disabled: a.required ? !
|
|
681
|
-
onClick:
|
|
910
|
+
disabled: a.required ? !s.trim() : !1,
|
|
911
|
+
onClick: i,
|
|
682
912
|
children: [
|
|
683
|
-
/* @__PURE__ */ e(
|
|
913
|
+
/* @__PURE__ */ e(C, { name: "check", size: 14 }),
|
|
684
914
|
" 提交"
|
|
685
915
|
]
|
|
686
916
|
}
|
|
687
917
|
) })
|
|
688
918
|
] });
|
|
689
919
|
}
|
|
690
|
-
function
|
|
691
|
-
const
|
|
692
|
-
const
|
|
693
|
-
for (const p of
|
|
694
|
-
|
|
695
|
-
return
|
|
696
|
-
}),
|
|
697
|
-
|
|
698
|
-
},
|
|
699
|
-
|
|
920
|
+
function Ee({ interrupt: a, onRespond: t }) {
|
|
921
|
+
const s = a.fields ?? [], [r, n] = T(() => {
|
|
922
|
+
const c = {};
|
|
923
|
+
for (const p of s)
|
|
924
|
+
c[p.name] = p.defaultValue ?? "";
|
|
925
|
+
return c;
|
|
926
|
+
}), o = (c, p) => {
|
|
927
|
+
n((f) => ({ ...f, [c]: p }));
|
|
928
|
+
}, i = s.every((c) => !c.required || r[c.name]), l = () => {
|
|
929
|
+
i && t({ action: "submit", value: r });
|
|
700
930
|
};
|
|
701
|
-
return /* @__PURE__ */
|
|
702
|
-
/* @__PURE__ */
|
|
703
|
-
/* @__PURE__ */ e(
|
|
931
|
+
return /* @__PURE__ */ d("div", { className: "sa-interrupt-card", children: [
|
|
932
|
+
/* @__PURE__ */ d("div", { className: "sa-interrupt-content", children: [
|
|
933
|
+
/* @__PURE__ */ e(C, { name: "file-text", size: 16, color: "#6366f1" }),
|
|
704
934
|
/* @__PURE__ */ e("span", { children: a.content })
|
|
705
935
|
] }),
|
|
706
|
-
/* @__PURE__ */ e("div", { className: "sa-interrupt-form", children:
|
|
707
|
-
/* @__PURE__ */
|
|
708
|
-
|
|
709
|
-
|
|
936
|
+
/* @__PURE__ */ e("div", { className: "sa-interrupt-form", children: s.map((c) => /* @__PURE__ */ d("div", { className: "sa-interrupt-form-field", children: [
|
|
937
|
+
/* @__PURE__ */ d("label", { className: "sa-interrupt-form-label", children: [
|
|
938
|
+
c.label,
|
|
939
|
+
c.required && /* @__PURE__ */ e("span", { className: "sa-interrupt-form-required", children: "*" })
|
|
710
940
|
] }),
|
|
711
|
-
|
|
712
|
-
] },
|
|
713
|
-
/* @__PURE__ */
|
|
714
|
-
/* @__PURE__ */
|
|
715
|
-
/* @__PURE__ */ e(
|
|
941
|
+
Ae(c, r[c.name], (p) => o(c.name, p))
|
|
942
|
+
] }, c.name)) }),
|
|
943
|
+
/* @__PURE__ */ d("div", { className: "sa-interrupt-actions", children: [
|
|
944
|
+
/* @__PURE__ */ d("button", { className: "sa-interrupt-btn sa-interrupt-btn-primary", disabled: !i, onClick: l, children: [
|
|
945
|
+
/* @__PURE__ */ e(C, { name: "check", size: 14 }),
|
|
716
946
|
" 提交"
|
|
717
947
|
] }),
|
|
718
948
|
/* @__PURE__ */ e("button", { className: "sa-interrupt-btn sa-interrupt-btn-secondary", onClick: () => t({ action: "cancel" }), children: "取消" })
|
|
719
949
|
] })
|
|
720
950
|
] });
|
|
721
951
|
}
|
|
722
|
-
function
|
|
952
|
+
function Ae(a, t, s) {
|
|
723
953
|
switch (a.type) {
|
|
724
954
|
case "textarea":
|
|
725
|
-
return /* @__PURE__ */ e("textarea", { className: "sa-interrupt-textarea", value: t, onChange: (r) =>
|
|
955
|
+
return /* @__PURE__ */ e("textarea", { className: "sa-interrupt-textarea", value: t, onChange: (r) => s(r.target.value), placeholder: a.placeholder, rows: 3 });
|
|
726
956
|
case "select":
|
|
727
|
-
return /* @__PURE__ */
|
|
957
|
+
return /* @__PURE__ */ d("select", { className: "sa-interrupt-select", value: t, onChange: (r) => s(r.target.value), children: [
|
|
728
958
|
/* @__PURE__ */ e("option", { value: "", children: "请选择" }),
|
|
729
959
|
(a.options ?? []).map((r) => /* @__PURE__ */ e("option", { value: r, children: r }, r))
|
|
730
960
|
] });
|
|
731
961
|
default:
|
|
732
|
-
return /* @__PURE__ */ e("input", { className: "sa-interrupt-input", type: a.type, value: t, onChange: (r) =>
|
|
962
|
+
return /* @__PURE__ */ e("input", { className: "sa-interrupt-input", type: a.type, value: t, onChange: (r) => s(r.target.value), placeholder: a.placeholder });
|
|
733
963
|
}
|
|
734
964
|
}
|
|
735
|
-
function
|
|
965
|
+
function $e({ interrupt: a, resolved: t, response: s, onRespond: r }) {
|
|
736
966
|
if (t)
|
|
737
|
-
return /* @__PURE__ */
|
|
738
|
-
/* @__PURE__ */ e(
|
|
739
|
-
/* @__PURE__ */ e("span", { children:
|
|
967
|
+
return /* @__PURE__ */ d("div", { className: "sa-interrupt-resolved", children: [
|
|
968
|
+
/* @__PURE__ */ e(C, { name: "circle-check", size: 14, color: "#10b981" }),
|
|
969
|
+
/* @__PURE__ */ e("span", { children: Pe(a.interruptType, s) })
|
|
740
970
|
] });
|
|
741
971
|
switch (a.interruptType) {
|
|
742
972
|
case "confirm":
|
|
743
|
-
return /* @__PURE__ */ e(
|
|
973
|
+
return /* @__PURE__ */ e(ze, { interrupt: a, onRespond: r });
|
|
974
|
+
case "approve":
|
|
975
|
+
return /* @__PURE__ */ e(Ie, { interrupt: a, onRespond: r });
|
|
744
976
|
case "select":
|
|
745
|
-
return /* @__PURE__ */ e(
|
|
977
|
+
return /* @__PURE__ */ e(Se, { interrupt: a, onRespond: r });
|
|
746
978
|
case "multiSelect":
|
|
747
|
-
return /* @__PURE__ */ e(
|
|
979
|
+
return /* @__PURE__ */ e(De, { interrupt: a, onRespond: r });
|
|
748
980
|
case "input":
|
|
749
|
-
return /* @__PURE__ */ e(
|
|
981
|
+
return /* @__PURE__ */ e(Le, { interrupt: a, onRespond: r });
|
|
750
982
|
case "form":
|
|
751
|
-
return /* @__PURE__ */ e(
|
|
983
|
+
return /* @__PURE__ */ e(Ee, { interrupt: a, onRespond: r });
|
|
752
984
|
default:
|
|
753
|
-
return /* @__PURE__ */
|
|
985
|
+
return /* @__PURE__ */ d("div", { className: "sa-interrupt-unknown", children: [
|
|
754
986
|
"未知的交互类型: ",
|
|
755
987
|
a.interruptType
|
|
756
988
|
] });
|
|
757
989
|
}
|
|
758
990
|
}
|
|
759
|
-
function
|
|
991
|
+
function Pe(a, t) {
|
|
760
992
|
if (!t) return "已完成";
|
|
761
993
|
switch (t.action) {
|
|
762
994
|
case "confirm":
|
|
@@ -767,362 +999,574 @@ function Se(a, t) {
|
|
|
767
999
|
return `已选择: ${t.value}`;
|
|
768
1000
|
case "submit":
|
|
769
1001
|
return "已提交";
|
|
1002
|
+
case "approve":
|
|
1003
|
+
return "已批准";
|
|
770
1004
|
case "reject":
|
|
771
1005
|
return "已拒绝";
|
|
1006
|
+
case "skip":
|
|
1007
|
+
return "已跳过";
|
|
772
1008
|
default:
|
|
773
1009
|
return "已完成";
|
|
774
1010
|
}
|
|
775
1011
|
}
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
1012
|
+
const Oe = [
|
|
1013
|
+
{ value: 1, label: "事实错误" },
|
|
1014
|
+
{ value: 2, label: "逻辑问题" },
|
|
1015
|
+
{ value: 3, label: "不相关" },
|
|
1016
|
+
{ value: 4, label: "信息过时" },
|
|
1017
|
+
{ value: 5, label: "冗长啰嗦" },
|
|
1018
|
+
{ value: 6, label: "难以理解" }
|
|
1019
|
+
];
|
|
1020
|
+
function Re({ message: a, onCopy: t, onRegenerate: s, onFeedback: r }) {
|
|
1021
|
+
const { status: n, feedback: o, cancelFeedback: i } = F(), [l, c] = T(null), [p, f] = T(!1), [u, h] = T(!1);
|
|
1022
|
+
if (n !== "ready" && n !== "error") return null;
|
|
1023
|
+
const v = N(() => {
|
|
1024
|
+
t(), f(!0), setTimeout(() => f(!1), 2e3);
|
|
1025
|
+
}, [t]), k = N(() => {
|
|
1026
|
+
l === "like" ? (c(null), i(a.id)) : (c("like"), h(!1), o(a.id, "like"), r == null || r(a.id, "like"));
|
|
1027
|
+
}, [l, a.id, o, i, r]), g = N(() => {
|
|
1028
|
+
l === "dislike" ? (c(null), h(!1), i(a.id)) : h(!0);
|
|
1029
|
+
}, [l, a.id, i]), b = N((m, x) => {
|
|
1030
|
+
c("dislike"), h(!1), o(a.id, "dislike", { reason: m, remark: x }), r == null || r(a.id, "dislike");
|
|
1031
|
+
}, [a.id, o, r]);
|
|
1032
|
+
return /* @__PURE__ */ d("div", { className: "sa-action-bar", children: [
|
|
1033
|
+
/* @__PURE__ */ d("button", { className: "sa-action-btn", onClick: v, title: "复制", children: [
|
|
1034
|
+
/* @__PURE__ */ e(C, { name: p ? "circle-check" : "copy", size: 14 }),
|
|
788
1035
|
" ",
|
|
789
|
-
|
|
1036
|
+
p ? "已复制" : "复制"
|
|
790
1037
|
] }),
|
|
791
|
-
/* @__PURE__ */
|
|
792
|
-
/* @__PURE__ */ e(
|
|
1038
|
+
/* @__PURE__ */ d("button", { className: "sa-action-btn", onClick: s, title: "重新生成", children: [
|
|
1039
|
+
/* @__PURE__ */ e(C, { name: "refresh-cw", size: 14 }),
|
|
793
1040
|
" 重新生成"
|
|
794
1041
|
] }),
|
|
795
1042
|
/* @__PURE__ */ e("span", { className: "sa-action-divider" }),
|
|
796
1043
|
/* @__PURE__ */ e(
|
|
797
1044
|
"button",
|
|
798
1045
|
{
|
|
799
|
-
className: `sa-action-btn ${
|
|
800
|
-
onClick:
|
|
1046
|
+
className: `sa-action-btn ${l === "like" ? "sa-action-btn-active" : ""}`,
|
|
1047
|
+
onClick: k,
|
|
801
1048
|
title: "有用",
|
|
802
|
-
|
|
1049
|
+
"aria-label": "点赞",
|
|
1050
|
+
children: /* @__PURE__ */ e(C, { name: "thumbs-up", size: 14 })
|
|
803
1051
|
}
|
|
804
1052
|
),
|
|
805
1053
|
/* @__PURE__ */ e(
|
|
806
1054
|
"button",
|
|
807
1055
|
{
|
|
808
|
-
className: `sa-action-btn ${
|
|
809
|
-
onClick:
|
|
1056
|
+
className: `sa-action-btn ${l === "dislike" ? "sa-action-btn-active" : ""}`,
|
|
1057
|
+
onClick: g,
|
|
810
1058
|
title: "无用",
|
|
811
|
-
|
|
1059
|
+
"aria-label": "踩",
|
|
1060
|
+
children: /* @__PURE__ */ e(C, { name: "thumbs-down", size: 14 })
|
|
1061
|
+
}
|
|
1062
|
+
),
|
|
1063
|
+
u && /* @__PURE__ */ e(
|
|
1064
|
+
Be,
|
|
1065
|
+
{
|
|
1066
|
+
onSubmit: b,
|
|
1067
|
+
onCancel: () => h(!1)
|
|
812
1068
|
}
|
|
813
1069
|
)
|
|
814
1070
|
] });
|
|
815
1071
|
}
|
|
816
|
-
function
|
|
817
|
-
const
|
|
818
|
-
return
|
|
1072
|
+
function Be({ onSubmit: a, onCancel: t }) {
|
|
1073
|
+
const [s, r] = T(void 0), [n, o] = T("");
|
|
1074
|
+
return /* @__PURE__ */ d("div", { className: "sa-dislike-panel", children: [
|
|
1075
|
+
/* @__PURE__ */ e("div", { className: "sa-dislike-panel-title", children: "请选择不满意的原因(可选)" }),
|
|
1076
|
+
/* @__PURE__ */ e("div", { className: "sa-dislike-reasons", children: Oe.map((i) => /* @__PURE__ */ e(
|
|
1077
|
+
"button",
|
|
1078
|
+
{
|
|
1079
|
+
className: `sa-dislike-reason-btn ${s === i.value ? "active" : ""}`,
|
|
1080
|
+
onClick: () => r(s === i.value ? void 0 : i.value),
|
|
1081
|
+
children: i.label
|
|
1082
|
+
},
|
|
1083
|
+
i.value
|
|
1084
|
+
)) }),
|
|
1085
|
+
/* @__PURE__ */ e(
|
|
1086
|
+
"textarea",
|
|
1087
|
+
{
|
|
1088
|
+
className: "sa-dislike-remark",
|
|
1089
|
+
placeholder: "补充描述(选填,≤500 字)",
|
|
1090
|
+
maxLength: 500,
|
|
1091
|
+
value: n,
|
|
1092
|
+
onChange: (i) => o(i.target.value),
|
|
1093
|
+
rows: 2
|
|
1094
|
+
}
|
|
1095
|
+
),
|
|
1096
|
+
/* @__PURE__ */ d("div", { className: "sa-dislike-actions", children: [
|
|
1097
|
+
/* @__PURE__ */ e("button", { className: "sa-dislike-submit", onClick: () => a(s, n || void 0), children: "提交" }),
|
|
1098
|
+
/* @__PURE__ */ e("button", { className: "sa-dislike-cancel", onClick: t, children: "取消" })
|
|
1099
|
+
] })
|
|
1100
|
+
] });
|
|
819
1101
|
}
|
|
820
|
-
function
|
|
821
|
-
const
|
|
822
|
-
|
|
823
|
-
|
|
1102
|
+
function Z({ src: a, role: t }) {
|
|
1103
|
+
const s = t === "assistant" ? "A" : "U";
|
|
1104
|
+
return a ? a.startsWith("http") || a.startsWith("/") || a.startsWith("data:") ? /* @__PURE__ */ e("div", { className: `sa-avatar sa-avatar-${t}`, children: /* @__PURE__ */ e("img", { src: a, alt: t, style: { width: "100%", height: "100%", borderRadius: "inherit", objectFit: "cover" } }) }) : /* @__PURE__ */ e("div", { className: `sa-avatar sa-avatar-${t}`, children: a }) : /* @__PURE__ */ e("div", { className: `sa-avatar sa-avatar-${t}`, children: s });
|
|
1105
|
+
}
|
|
1106
|
+
function He({ message: a, isStreaming: t, isLast: s, slots: r, avatar: n, artifactPreview: o }) {
|
|
1107
|
+
const { regenerate: i, feedback: l, respondToInterrupt: c } = F(), p = N(() => {
|
|
1108
|
+
var I;
|
|
1109
|
+
const x = a.parts.filter((D) => D.type === "text").map((D) => D.content).join(`
|
|
824
1110
|
`);
|
|
825
|
-
(
|
|
1111
|
+
(I = navigator.clipboard) == null || I.writeText(x).catch(() => {
|
|
826
1112
|
});
|
|
827
|
-
}, [a]),
|
|
828
|
-
if (
|
|
1113
|
+
}, [a]), f = a.role === "user", u = r.Message;
|
|
1114
|
+
if (u)
|
|
829
1115
|
return /* @__PURE__ */ e(
|
|
830
|
-
|
|
1116
|
+
u,
|
|
831
1117
|
{
|
|
832
1118
|
message: a,
|
|
833
1119
|
isStreaming: t,
|
|
834
|
-
isLast:
|
|
835
|
-
avatar:
|
|
1120
|
+
isLast: s,
|
|
1121
|
+
avatar: n,
|
|
836
1122
|
slots: r,
|
|
837
|
-
onCopy:
|
|
838
|
-
onRegenerate:
|
|
839
|
-
onFeedback:
|
|
1123
|
+
onCopy: p,
|
|
1124
|
+
onRegenerate: i,
|
|
1125
|
+
onFeedback: l
|
|
840
1126
|
}
|
|
841
1127
|
);
|
|
842
|
-
const h = r.TextPart ??
|
|
843
|
-
return /* @__PURE__ */
|
|
844
|
-
!
|
|
845
|
-
/* @__PURE__ */
|
|
846
|
-
a.parts.map((
|
|
847
|
-
switch (
|
|
1128
|
+
const h = r.TextPart ?? ve, v = r.ThinkingPart ?? we, k = r.ToolCallPart ?? ye, g = r.ToolResultPart ?? Ce, b = r.ErrorPart ?? Ne, m = r.ActionBar ?? Re;
|
|
1129
|
+
return /* @__PURE__ */ d("div", { className: `sa-message ${f ? "sa-message-user" : "sa-message-assistant"}`, children: [
|
|
1130
|
+
!f && /* @__PURE__ */ e(Z, { src: n == null ? void 0 : n.assistant, role: "assistant" }),
|
|
1131
|
+
/* @__PURE__ */ d("div", { className: "sa-message-body", children: [
|
|
1132
|
+
a.parts.map((x, I) => {
|
|
1133
|
+
switch (x.type) {
|
|
848
1134
|
case "text":
|
|
849
|
-
return /* @__PURE__ */ e(h, { content:
|
|
1135
|
+
return /* @__PURE__ */ e(h, { content: x.content }, I);
|
|
850
1136
|
case "thinking":
|
|
851
|
-
return /* @__PURE__ */ e(
|
|
1137
|
+
return /* @__PURE__ */ e(v, { content: x.content }, I);
|
|
852
1138
|
case "tool_call":
|
|
853
|
-
return /* @__PURE__ */ e(
|
|
1139
|
+
return /* @__PURE__ */ e(k, { toolName: x.toolName, toolCallId: x.toolCallId, args: x.args }, I);
|
|
854
1140
|
case "tool_result":
|
|
855
|
-
return /* @__PURE__ */ e(
|
|
1141
|
+
return /* @__PURE__ */ e(g, { toolName: x.toolName, toolCallId: x.toolCallId, content: x.content, artifacts: x.artifacts, renderMode: x.renderMode, html: x.html, artifactPreview: o }, I);
|
|
856
1142
|
case "error":
|
|
857
|
-
return /* @__PURE__ */ e(
|
|
1143
|
+
return /* @__PURE__ */ e(b, { content: x.content, onRetry: i }, I);
|
|
858
1144
|
case "interrupt":
|
|
859
1145
|
return /* @__PURE__ */ e(
|
|
860
|
-
|
|
1146
|
+
$e,
|
|
861
1147
|
{
|
|
862
|
-
interrupt:
|
|
863
|
-
resolved:
|
|
864
|
-
response:
|
|
865
|
-
onRespond: (
|
|
1148
|
+
interrupt: x.interrupt,
|
|
1149
|
+
resolved: x.resolved ?? !1,
|
|
1150
|
+
response: x.response,
|
|
1151
|
+
onRespond: (D) => c(x.interrupt.interruptId, D)
|
|
866
1152
|
},
|
|
867
|
-
|
|
1153
|
+
I
|
|
868
1154
|
);
|
|
869
1155
|
default:
|
|
870
1156
|
return null;
|
|
871
1157
|
}
|
|
872
1158
|
}),
|
|
873
|
-
t &&
|
|
874
|
-
!
|
|
1159
|
+
t && s && !f && /* @__PURE__ */ e("span", { className: "sa-streaming-cursor", children: "|" }),
|
|
1160
|
+
!f && !t && a.parts.length > 0 && /* @__PURE__ */ e(m, { message: a, onCopy: p, onRegenerate: i, onFeedback: l })
|
|
875
1161
|
] }),
|
|
876
|
-
|
|
1162
|
+
f && /* @__PURE__ */ e(Z, { src: n == null ? void 0 : n.user, role: "user" })
|
|
877
1163
|
] });
|
|
878
1164
|
}
|
|
879
|
-
function
|
|
880
|
-
return /* @__PURE__ */
|
|
881
|
-
/* @__PURE__ */ e("div", { className: "sa-welcome-icon", children: /* @__PURE__ */ e(
|
|
1165
|
+
function je({ message: a, suggestedPrompts: t, onPromptClick: s }) {
|
|
1166
|
+
return /* @__PURE__ */ d("div", { className: "sa-welcome", children: [
|
|
1167
|
+
/* @__PURE__ */ e("div", { className: "sa-welcome-icon", children: /* @__PURE__ */ e(C, { name: "sparkles", size: 40 }) }),
|
|
882
1168
|
/* @__PURE__ */ e("p", { className: "sa-welcome-message", children: a || "你好!有什么可以帮你的?" }),
|
|
883
|
-
t && t.length > 0 && /* @__PURE__ */ e("div", { className: "sa-welcome-prompts", children: t.map((r,
|
|
1169
|
+
t && t.length > 0 && /* @__PURE__ */ e("div", { className: "sa-welcome-prompts", children: t.map((r, n) => /* @__PURE__ */ e(
|
|
884
1170
|
"button",
|
|
885
1171
|
{
|
|
886
1172
|
className: "sa-welcome-prompt",
|
|
887
|
-
onClick: () =>
|
|
1173
|
+
onClick: () => s(r),
|
|
888
1174
|
children: r
|
|
889
1175
|
},
|
|
890
|
-
|
|
1176
|
+
n
|
|
891
1177
|
)) })
|
|
892
1178
|
] });
|
|
893
1179
|
}
|
|
894
|
-
function
|
|
895
|
-
const { messages:
|
|
896
|
-
return
|
|
897
|
-
|
|
1180
|
+
function re({ slots: a, welcomeMessage: t, suggestedPrompts: s, avatar: r, artifactPreview: n }) {
|
|
1181
|
+
const { messages: o, status: i, sendMessage: l } = F(), { containerRef: c } = ge([o]), p = i === "streaming", f = a.WelcomeScreen ?? je;
|
|
1182
|
+
return o.length === 0 ? /* @__PURE__ */ e("div", { className: "sa-thread", ref: c, children: /* @__PURE__ */ e(
|
|
1183
|
+
f,
|
|
898
1184
|
{
|
|
899
1185
|
message: t,
|
|
900
|
-
suggestedPrompts:
|
|
901
|
-
onPromptClick:
|
|
1186
|
+
suggestedPrompts: s,
|
|
1187
|
+
onPromptClick: l
|
|
902
1188
|
}
|
|
903
|
-
) }) : /* @__PURE__ */ e("div", { className: "sa-thread", ref:
|
|
904
|
-
|
|
1189
|
+
) }) : /* @__PURE__ */ e("div", { className: "sa-thread", ref: c, children: o.map((u, h) => /* @__PURE__ */ e(
|
|
1190
|
+
He,
|
|
905
1191
|
{
|
|
906
|
-
message:
|
|
907
|
-
isStreaming:
|
|
908
|
-
isLast: h ===
|
|
1192
|
+
message: u,
|
|
1193
|
+
isStreaming: p,
|
|
1194
|
+
isLast: h === o.length - 1,
|
|
909
1195
|
slots: a,
|
|
910
|
-
avatar: r
|
|
1196
|
+
avatar: r,
|
|
1197
|
+
artifactPreview: n
|
|
911
1198
|
},
|
|
912
|
-
|
|
1199
|
+
u.id
|
|
913
1200
|
)) });
|
|
914
1201
|
}
|
|
915
|
-
function
|
|
916
|
-
const { status: a, sendMessage: t, stop:
|
|
1202
|
+
function se() {
|
|
1203
|
+
const { status: a, sendMessage: t, stop: s } = F(), [r, n] = T(""), o = _(null), i = a === "streaming" || a === "submitted", l = N(() => {
|
|
917
1204
|
const f = r.trim();
|
|
918
|
-
!f ||
|
|
919
|
-
}, [r,
|
|
1205
|
+
!f || i || (t(f), n(""), o.current && (o.current.style.height = "auto"));
|
|
1206
|
+
}, [r, i, t]), c = N((f) => {
|
|
920
1207
|
f.key === "Enter" && !f.shiftKey && (f.preventDefault(), l());
|
|
921
|
-
}, [l]), p =
|
|
922
|
-
|
|
923
|
-
const
|
|
924
|
-
|
|
1208
|
+
}, [l]), p = N((f) => {
|
|
1209
|
+
n(f.target.value);
|
|
1210
|
+
const u = f.target;
|
|
1211
|
+
u.style.height = "auto", u.style.height = Math.min(u.scrollHeight, 120) + "px";
|
|
925
1212
|
}, []);
|
|
926
|
-
return /* @__PURE__ */
|
|
1213
|
+
return /* @__PURE__ */ d("div", { className: "sa-composer", children: [
|
|
927
1214
|
/* @__PURE__ */ e(
|
|
928
1215
|
"textarea",
|
|
929
1216
|
{
|
|
930
|
-
ref:
|
|
1217
|
+
ref: o,
|
|
931
1218
|
className: "sa-composer-input",
|
|
932
1219
|
value: r,
|
|
933
1220
|
onChange: p,
|
|
934
|
-
onKeyDown:
|
|
1221
|
+
onKeyDown: c,
|
|
935
1222
|
placeholder: "输入消息...",
|
|
936
1223
|
rows: 1,
|
|
937
1224
|
disabled: a === "submitted"
|
|
938
1225
|
}
|
|
939
1226
|
),
|
|
940
|
-
|
|
1227
|
+
i ? /* @__PURE__ */ e("button", { className: "sa-composer-stop", onClick: s, title: "停止", children: /* @__PURE__ */ e(C, { name: "circle-stop", size: 16, color: "#fff" }) }) : /* @__PURE__ */ e(
|
|
941
1228
|
"button",
|
|
942
1229
|
{
|
|
943
1230
|
className: "sa-composer-send",
|
|
944
1231
|
onClick: l,
|
|
945
1232
|
disabled: !r.trim(),
|
|
946
1233
|
title: "发送",
|
|
947
|
-
children: /* @__PURE__ */ e(
|
|
1234
|
+
children: /* @__PURE__ */ e(C, { name: "arrow-up", size: 16, color: "#fff" })
|
|
948
1235
|
}
|
|
949
1236
|
)
|
|
950
1237
|
] });
|
|
951
1238
|
}
|
|
952
|
-
function
|
|
953
|
-
const
|
|
1239
|
+
function _e({ artifact: a }) {
|
|
1240
|
+
const [t, s] = Y.useState(null), [r, n] = Y.useState(!0), [o, i] = Y.useState(null);
|
|
1241
|
+
return Y.useEffect(() => {
|
|
1242
|
+
let l = !1;
|
|
1243
|
+
n(!0), i(null), s(null);
|
|
1244
|
+
async function c() {
|
|
1245
|
+
try {
|
|
1246
|
+
if (a.type === "pdf") {
|
|
1247
|
+
l || n(!1);
|
|
1248
|
+
return;
|
|
1249
|
+
}
|
|
1250
|
+
if (a.type === "html") {
|
|
1251
|
+
const p = await fetch(a.url);
|
|
1252
|
+
if (!p.ok) throw new Error(`HTTP ${p.status}`);
|
|
1253
|
+
const f = await p.text(), u = (await import("./purify.es-C-6FFqDW.js")).default;
|
|
1254
|
+
l || (s(u.sanitize(f, { FORCE_BODY: !0 })), n(!1));
|
|
1255
|
+
return;
|
|
1256
|
+
}
|
|
1257
|
+
if (a.type === "docx") {
|
|
1258
|
+
const p = await fetch(a.url);
|
|
1259
|
+
if (!p.ok) throw new Error(`HTTP ${p.status}`);
|
|
1260
|
+
const f = await p.arrayBuffer(), h = await (await import("./mammoth.browser-COPV53yV.js").then((k) => k.m)).convertToHtml({ arrayBuffer: f }), v = (await import("./purify.es-C-6FFqDW.js")).default;
|
|
1261
|
+
l || (s(v.sanitize(h.value, { FORCE_BODY: !0 })), n(!1));
|
|
1262
|
+
return;
|
|
1263
|
+
}
|
|
1264
|
+
l || (n(!1), i(`不支持预览「${a.type}」类型`));
|
|
1265
|
+
} catch (p) {
|
|
1266
|
+
l || (n(!1), i(p instanceof Error ? p.message : "加载失败"));
|
|
1267
|
+
}
|
|
1268
|
+
}
|
|
1269
|
+
return c(), () => {
|
|
1270
|
+
l = !0;
|
|
1271
|
+
};
|
|
1272
|
+
}, [a]), r ? /* @__PURE__ */ e("div", { className: "sa-drawer-preview-loading", children: "加载中" }) : o ? /* @__PURE__ */ d("div", { className: "sa-drawer-preview-error", children: [
|
|
1273
|
+
o,
|
|
1274
|
+
/* @__PURE__ */ e("button", { className: "sa-drawer-btn-sm", onClick: () => void U(a), children: "下载查看" })
|
|
1275
|
+
] }) : a.type === "pdf" ? /* @__PURE__ */ e("iframe", { src: a.url, title: a.filename, className: "sa-drawer-preview-iframe", sandbox: "allow-scripts" }) : t !== null ? /* @__PURE__ */ e("iframe", { srcDoc: t, title: a.filename, className: "sa-drawer-preview-iframe", sandbox: "allow-same-origin" }) : null;
|
|
1276
|
+
}
|
|
1277
|
+
function ne({ artifacts: a, initialArtifact: t, onClose: s }) {
|
|
1278
|
+
const [r, n] = T(
|
|
1279
|
+
t ? { mode: "preview", artifact: t } : { mode: "list" }
|
|
1280
|
+
), [o, i] = T(!1), l = _(null), [c, p] = T(340), f = _(null);
|
|
1281
|
+
B(() => {
|
|
1282
|
+
t && (l.current && (clearTimeout(l.current), l.current = null, i(!1)), n({ mode: "preview", artifact: t }));
|
|
1283
|
+
}, [t]);
|
|
1284
|
+
const u = N(() => {
|
|
1285
|
+
i(!0), l.current = setTimeout(() => {
|
|
1286
|
+
l.current = null, s();
|
|
1287
|
+
}, 240);
|
|
1288
|
+
}, [s]);
|
|
1289
|
+
B(() => () => {
|
|
1290
|
+
var g;
|
|
1291
|
+
l.current && clearTimeout(l.current), (g = f.current) == null || g.call(f);
|
|
1292
|
+
}, []);
|
|
1293
|
+
const h = N((g) => {
|
|
1294
|
+
n({ mode: "preview", artifact: g });
|
|
1295
|
+
}, []), v = N(() => {
|
|
1296
|
+
n({ mode: "list" });
|
|
1297
|
+
}, []);
|
|
1298
|
+
B(() => {
|
|
1299
|
+
const g = (b) => {
|
|
1300
|
+
b.key === "Escape" && u();
|
|
1301
|
+
};
|
|
1302
|
+
return document.addEventListener("keydown", g), () => document.removeEventListener("keydown", g);
|
|
1303
|
+
}, [u]);
|
|
1304
|
+
const k = N((g) => {
|
|
1305
|
+
g.preventDefault();
|
|
1306
|
+
const b = g.clientX, m = c, x = (D) => {
|
|
1307
|
+
const M = b - D.clientX;
|
|
1308
|
+
p(Math.max(240, Math.min(window.innerWidth * 0.7, m + M)));
|
|
1309
|
+
}, I = () => {
|
|
1310
|
+
document.removeEventListener("mousemove", x), document.removeEventListener("mouseup", I), document.body.style.cursor = "", document.body.style.userSelect = "", f.current = null;
|
|
1311
|
+
};
|
|
1312
|
+
document.body.style.cursor = "col-resize", document.body.style.userSelect = "none", document.addEventListener("mousemove", x), document.addEventListener("mouseup", I), f.current = I;
|
|
1313
|
+
}, [c]);
|
|
1314
|
+
return /* @__PURE__ */ d("div", { className: `sa-artifact-drawer ${o ? "sa-drawer-closing" : ""}`, style: { width: c }, children: [
|
|
1315
|
+
/* @__PURE__ */ e("div", { className: "sa-drawer-resize-handle", onMouseDown: k }),
|
|
1316
|
+
/* @__PURE__ */ d("div", { className: "sa-artifact-drawer-header", children: [
|
|
1317
|
+
r.mode === "preview" ? /* @__PURE__ */ d(q, { children: [
|
|
1318
|
+
/* @__PURE__ */ e("button", { className: "sa-drawer-btn", onClick: v, title: "返回列表", "aria-label": "返回列表", children: /* @__PURE__ */ e("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: /* @__PURE__ */ e("path", { d: "M15 18l-6-6 6-6" }) }) }),
|
|
1319
|
+
/* @__PURE__ */ e("span", { className: "sa-artifact-drawer-title", children: r.artifact.filename })
|
|
1320
|
+
] }) : /* @__PURE__ */ d(q, { children: [
|
|
1321
|
+
/* @__PURE__ */ d("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", style: { flexShrink: 0 }, children: [
|
|
1322
|
+
/* @__PURE__ */ e("path", { d: "M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z" }),
|
|
1323
|
+
/* @__PURE__ */ e("polyline", { points: "14 2 14 8 20 8" })
|
|
1324
|
+
] }),
|
|
1325
|
+
/* @__PURE__ */ e("span", { className: "sa-artifact-drawer-title", children: "会话产物" })
|
|
1326
|
+
] }),
|
|
1327
|
+
/* @__PURE__ */ e("div", { style: { flex: 1 } }),
|
|
1328
|
+
r.mode === "preview" && /* @__PURE__ */ e("button", { className: "sa-drawer-btn", onClick: () => void U(r.artifact), title: "下载", "aria-label": "下载", children: /* @__PURE__ */ e("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: /* @__PURE__ */ e("path", { d: "M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4M7 10l5 5 5-5M12 15V3" }) }) }),
|
|
1329
|
+
/* @__PURE__ */ e("button", { className: "sa-drawer-btn", onClick: u, title: "关闭", "aria-label": "关闭", children: /* @__PURE__ */ e("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: /* @__PURE__ */ e("path", { d: "M18 6L6 18M6 6l12 12" }) }) })
|
|
1330
|
+
] }),
|
|
1331
|
+
/* @__PURE__ */ e("div", { className: "sa-artifact-drawer-body", children: r.mode === "list" ? a.length === 0 ? /* @__PURE__ */ e("div", { className: "sa-drawer-empty", children: "暂无产物" }) : /* @__PURE__ */ e("ul", { className: "sa-drawer-file-list", role: "list", children: a.map((g, b) => /* @__PURE__ */ d(
|
|
1332
|
+
"li",
|
|
1333
|
+
{
|
|
1334
|
+
className: "sa-drawer-file-card",
|
|
1335
|
+
onClick: () => h(g),
|
|
1336
|
+
onKeyDown: (m) => {
|
|
1337
|
+
(m.key === "Enter" || m.key === " ") && (m.preventDefault(), h(g));
|
|
1338
|
+
},
|
|
1339
|
+
tabIndex: 0,
|
|
1340
|
+
role: "button",
|
|
1341
|
+
"aria-label": `预览 ${g.filename}`,
|
|
1342
|
+
children: [
|
|
1343
|
+
/* @__PURE__ */ e("div", { className: "sa-drawer-file-icon", children: /* @__PURE__ */ e("span", { className: "sa-artifact-chip-type", children: ee(g.type) }) }),
|
|
1344
|
+
/* @__PURE__ */ d("div", { className: "sa-drawer-file-info", children: [
|
|
1345
|
+
/* @__PURE__ */ e("span", { className: "sa-drawer-file-name", children: g.filename }),
|
|
1346
|
+
/* @__PURE__ */ e("span", { className: "sa-drawer-file-size", children: Q(g.size) })
|
|
1347
|
+
] }),
|
|
1348
|
+
/* @__PURE__ */ e(
|
|
1349
|
+
"button",
|
|
1350
|
+
{
|
|
1351
|
+
className: "sa-drawer-btn",
|
|
1352
|
+
title: "下载",
|
|
1353
|
+
"aria-label": `下载 ${g.filename}`,
|
|
1354
|
+
onClick: (m) => {
|
|
1355
|
+
m.stopPropagation(), U(g);
|
|
1356
|
+
},
|
|
1357
|
+
children: /* @__PURE__ */ e("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: /* @__PURE__ */ e("path", { d: "M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4M7 10l5 5 5-5M12 15V3" }) })
|
|
1358
|
+
}
|
|
1359
|
+
)
|
|
1360
|
+
]
|
|
1361
|
+
},
|
|
1362
|
+
g.id || `artifact-${b}`
|
|
1363
|
+
)) }) : /* @__PURE__ */ e("div", { className: "sa-drawer-view-enter", children: /* @__PURE__ */ e(_e, { artifact: r.artifact }) }) })
|
|
1364
|
+
] });
|
|
1365
|
+
}
|
|
1366
|
+
function We({ isOpen: a, onClose: t, title: s, slots: r, welcomeMessage: n, suggestedPrompts: o, avatar: i, artifactPreview: l }) {
|
|
1367
|
+
const { status: c, sendMessage: p, stop: f, toggleThreadList: u, toggleArtifactDrawer: h, conversations: v, activeConversationId: k, switchConversation: g, newConversation: b, deleteConversation: m, renameConversation: x, isThreadListOpen: I, isArtifactDrawerOpen: D, allArtifacts: M, activePreviewArtifact: O } = F();
|
|
954
1368
|
if (!a) return null;
|
|
955
|
-
const y = r.Header,
|
|
956
|
-
return /* @__PURE__ */
|
|
957
|
-
y ? /* @__PURE__ */ e(y, { title:
|
|
958
|
-
|
|
959
|
-
M,
|
|
1369
|
+
const y = r.Header, L = r.Composer, $ = r.ThreadList;
|
|
1370
|
+
return /* @__PURE__ */ d("div", { className: "sa-panel", children: [
|
|
1371
|
+
y ? /* @__PURE__ */ e(y, { title: s, onClose: t, onToggleThreadList: u }) : /* @__PURE__ */ e(
|
|
1372
|
+
ue,
|
|
960
1373
|
{
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
onRename: b
|
|
1374
|
+
title: s,
|
|
1375
|
+
onClose: t,
|
|
1376
|
+
onToggleThreadList: u,
|
|
1377
|
+
artifactCount: l ? M.length : 0,
|
|
1378
|
+
onToggleArtifactDrawer: l ? h : void 0
|
|
967
1379
|
}
|
|
968
|
-
)
|
|
969
|
-
/* @__PURE__ */ e(
|
|
970
|
-
|
|
1380
|
+
),
|
|
1381
|
+
$ && I ? /* @__PURE__ */ e(
|
|
1382
|
+
$,
|
|
1383
|
+
{
|
|
1384
|
+
conversations: v,
|
|
1385
|
+
activeSessionId: k,
|
|
1386
|
+
onSwitch: g,
|
|
1387
|
+
onNew: b,
|
|
1388
|
+
onDelete: m,
|
|
1389
|
+
onRename: x
|
|
1390
|
+
}
|
|
1391
|
+
) : /* @__PURE__ */ e(he, {}),
|
|
1392
|
+
/* @__PURE__ */ d("div", { className: "sa-panel-content", children: [
|
|
1393
|
+
/* @__PURE__ */ e(re, { slots: r, welcomeMessage: n, suggestedPrompts: o, avatar: i, artifactPreview: l }),
|
|
1394
|
+
l && D && /* @__PURE__ */ e(ne, { artifacts: M, initialArtifact: O, onClose: h })
|
|
1395
|
+
] }),
|
|
1396
|
+
L ? /* @__PURE__ */ e(L, { status: c, onSend: p, onStop: f }) : /* @__PURE__ */ e(se, {})
|
|
971
1397
|
] });
|
|
972
1398
|
}
|
|
973
|
-
function
|
|
1399
|
+
function Fe({
|
|
974
1400
|
conversations: a,
|
|
975
1401
|
activeSessionId: t,
|
|
976
|
-
onSwitch:
|
|
1402
|
+
onSwitch: s,
|
|
977
1403
|
onNew: r,
|
|
978
|
-
onDelete:
|
|
979
|
-
isCollapsed:
|
|
980
|
-
onToggleCollapse:
|
|
1404
|
+
onDelete: n,
|
|
1405
|
+
isCollapsed: o,
|
|
1406
|
+
onToggleCollapse: i
|
|
981
1407
|
}) {
|
|
982
|
-
const [l,
|
|
983
|
-
|
|
984
|
-
}, [p,
|
|
985
|
-
const v = Date.now(),
|
|
986
|
-
for (const
|
|
987
|
-
const
|
|
988
|
-
|
|
1408
|
+
const [l, c] = T(null), [p, f] = T(null), u = N((v, k) => {
|
|
1409
|
+
k.stopPropagation(), p === v ? (n(v), f(null)) : (f(v), setTimeout(() => f(null), 3e3));
|
|
1410
|
+
}, [p, n]), h = (() => {
|
|
1411
|
+
const v = Date.now(), k = [], g = [], b = [];
|
|
1412
|
+
for (const x of a) {
|
|
1413
|
+
const I = v - new Date(x.updateTime).getTime();
|
|
1414
|
+
I < 864e5 ? k.push(x) : I < 6048e5 ? g.push(x) : b.push(x);
|
|
989
1415
|
}
|
|
990
|
-
const
|
|
991
|
-
return
|
|
1416
|
+
const m = [];
|
|
1417
|
+
return k.length && m.push({ label: "今天", items: k }), g.length && m.push({ label: "最近 7 天", items: g }), b.length && m.push({ label: "更早", items: b }), m;
|
|
992
1418
|
})();
|
|
993
|
-
return
|
|
994
|
-
/* @__PURE__ */ e("button", { className: "sa-fp-sidebar-toggle", onClick:
|
|
995
|
-
/* @__PURE__ */ e("button", { className: "sa-fp-sidebar-toggle", onClick: r, title: "新会话", style: { marginTop: 4 }, children: /* @__PURE__ */ e(
|
|
996
|
-
] }) : /* @__PURE__ */
|
|
997
|
-
/* @__PURE__ */
|
|
998
|
-
/* @__PURE__ */
|
|
999
|
-
/* @__PURE__ */ e(
|
|
1419
|
+
return o ? /* @__PURE__ */ d("div", { className: "sa-fp-sidebar sa-fp-sidebar-collapsed", children: [
|
|
1420
|
+
/* @__PURE__ */ e("button", { className: "sa-fp-sidebar-toggle", onClick: i, title: "展开", children: /* @__PURE__ */ e(C, { name: "panel-left", size: 18 }) }),
|
|
1421
|
+
/* @__PURE__ */ e("button", { className: "sa-fp-sidebar-toggle", onClick: r, title: "新会话", style: { marginTop: 4 }, children: /* @__PURE__ */ e(C, { name: "plus", size: 18 }) })
|
|
1422
|
+
] }) : /* @__PURE__ */ d("div", { className: "sa-fp-sidebar", children: [
|
|
1423
|
+
/* @__PURE__ */ d("div", { className: "sa-fp-sidebar-header", children: [
|
|
1424
|
+
/* @__PURE__ */ d("button", { className: "sa-fp-sidebar-new", onClick: r, children: [
|
|
1425
|
+
/* @__PURE__ */ e(C, { name: "plus", size: 15 }),
|
|
1000
1426
|
" ",
|
|
1001
1427
|
/* @__PURE__ */ e("span", { children: "新会话" })
|
|
1002
1428
|
] }),
|
|
1003
|
-
/* @__PURE__ */ e("button", { className: "sa-fp-sidebar-toggle", onClick:
|
|
1429
|
+
/* @__PURE__ */ e("button", { className: "sa-fp-sidebar-toggle", onClick: i, title: "收起侧边栏", children: /* @__PURE__ */ e(C, { name: "panel-left-close", size: 18 }) })
|
|
1004
1430
|
] }),
|
|
1005
|
-
/* @__PURE__ */
|
|
1431
|
+
/* @__PURE__ */ d("div", { className: "sa-fp-sidebar-list", children: [
|
|
1006
1432
|
a.length === 0 && /* @__PURE__ */ e("div", { className: "sa-fp-sidebar-empty", children: "开始你的第一个对话" }),
|
|
1007
|
-
|
|
1433
|
+
h.map((v) => /* @__PURE__ */ d("div", { children: [
|
|
1008
1434
|
/* @__PURE__ */ e("div", { className: "sa-fp-sidebar-group", children: v.label }),
|
|
1009
|
-
v.items.map((
|
|
1010
|
-
const g =
|
|
1011
|
-
return /* @__PURE__ */
|
|
1435
|
+
v.items.map((k) => {
|
|
1436
|
+
const g = k.sessionId === t, b = l === k.sessionId, m = p === k.sessionId;
|
|
1437
|
+
return /* @__PURE__ */ d(
|
|
1012
1438
|
"div",
|
|
1013
1439
|
{
|
|
1014
1440
|
className: `sa-fp-sidebar-item ${g ? "active" : ""}`,
|
|
1015
|
-
onClick: () =>
|
|
1016
|
-
onMouseEnter: () =>
|
|
1017
|
-
onMouseLeave: () =>
|
|
1441
|
+
onClick: () => s(k.sessionId),
|
|
1442
|
+
onMouseEnter: () => c(k.sessionId),
|
|
1443
|
+
onMouseLeave: () => c(null),
|
|
1018
1444
|
children: [
|
|
1019
|
-
/* @__PURE__ */ e("span", { className: "sa-fp-sidebar-item-title", children:
|
|
1445
|
+
/* @__PURE__ */ e("span", { className: "sa-fp-sidebar-item-title", children: k.title || "新会话" }),
|
|
1020
1446
|
b && /* @__PURE__ */ e(
|
|
1021
1447
|
"button",
|
|
1022
1448
|
{
|
|
1023
|
-
className: `sa-fp-sidebar-item-action ${
|
|
1024
|
-
onClick: (
|
|
1025
|
-
title:
|
|
1026
|
-
children: /* @__PURE__ */ e(
|
|
1449
|
+
className: `sa-fp-sidebar-item-action ${m ? "danger" : ""}`,
|
|
1450
|
+
onClick: (x) => u(k.sessionId, x),
|
|
1451
|
+
title: m ? "确认删除" : "删除",
|
|
1452
|
+
children: /* @__PURE__ */ e(C, { name: m ? "x" : "trash2", size: 14 })
|
|
1027
1453
|
}
|
|
1028
1454
|
)
|
|
1029
1455
|
]
|
|
1030
1456
|
},
|
|
1031
|
-
|
|
1457
|
+
k.sessionId
|
|
1032
1458
|
);
|
|
1033
1459
|
})
|
|
1034
1460
|
] }, v.label))
|
|
1035
1461
|
] })
|
|
1036
1462
|
] });
|
|
1037
1463
|
}
|
|
1038
|
-
function
|
|
1464
|
+
function Ye({ title: a, slots: t, welcomeMessage: s, suggestedPrompts: r, sidebarDefaultOpen: n = !0, onClose: o, avatar: i, artifactPreview: l }) {
|
|
1039
1465
|
const {
|
|
1040
|
-
status:
|
|
1041
|
-
sendMessage:
|
|
1042
|
-
stop:
|
|
1043
|
-
conversations:
|
|
1466
|
+
status: c,
|
|
1467
|
+
sendMessage: p,
|
|
1468
|
+
stop: f,
|
|
1469
|
+
conversations: u,
|
|
1044
1470
|
activeConversationId: h,
|
|
1045
|
-
switchConversation:
|
|
1046
|
-
newConversation:
|
|
1047
|
-
deleteConversation:
|
|
1048
|
-
renameConversation:
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1471
|
+
switchConversation: v,
|
|
1472
|
+
newConversation: k,
|
|
1473
|
+
deleteConversation: g,
|
|
1474
|
+
renameConversation: b,
|
|
1475
|
+
toggleArtifactDrawer: m,
|
|
1476
|
+
isArtifactDrawerOpen: x,
|
|
1477
|
+
allArtifacts: I,
|
|
1478
|
+
activePreviewArtifact: D
|
|
1479
|
+
} = F(), [M, O] = T(n), y = N(() => O((S) => !S), []), L = t.ThreadList, $ = t.Composer;
|
|
1480
|
+
return /* @__PURE__ */ d("div", { className: "sa-fullpage", children: [
|
|
1481
|
+
L ? /* @__PURE__ */ e("div", { className: `sa-fp-sidebar-wrapper ${M ? "" : "sa-fp-sidebar-wrapper-collapsed"}`, children: /* @__PURE__ */ e(
|
|
1482
|
+
L,
|
|
1053
1483
|
{
|
|
1054
|
-
conversations:
|
|
1484
|
+
conversations: u,
|
|
1055
1485
|
activeSessionId: h,
|
|
1056
|
-
onSwitch:
|
|
1057
|
-
onNew:
|
|
1058
|
-
onDelete:
|
|
1059
|
-
onRename:
|
|
1486
|
+
onSwitch: v,
|
|
1487
|
+
onNew: k,
|
|
1488
|
+
onDelete: g,
|
|
1489
|
+
onRename: b
|
|
1060
1490
|
}
|
|
1061
1491
|
) }) : /* @__PURE__ */ e(
|
|
1062
|
-
|
|
1492
|
+
Fe,
|
|
1063
1493
|
{
|
|
1064
|
-
conversations:
|
|
1494
|
+
conversations: u,
|
|
1065
1495
|
activeSessionId: h,
|
|
1066
|
-
onSwitch:
|
|
1067
|
-
onNew:
|
|
1068
|
-
onDelete:
|
|
1069
|
-
onRename:
|
|
1070
|
-
isCollapsed: !
|
|
1496
|
+
onSwitch: v,
|
|
1497
|
+
onNew: k,
|
|
1498
|
+
onDelete: g,
|
|
1499
|
+
onRename: b,
|
|
1500
|
+
isCollapsed: !M,
|
|
1071
1501
|
onToggleCollapse: y
|
|
1072
1502
|
}
|
|
1073
1503
|
),
|
|
1074
|
-
/* @__PURE__ */
|
|
1075
|
-
/* @__PURE__ */
|
|
1076
|
-
!
|
|
1504
|
+
/* @__PURE__ */ d("div", { className: "sa-fp-main", children: [
|
|
1505
|
+
/* @__PURE__ */ d("div", { className: "sa-fp-header", children: [
|
|
1506
|
+
!M && !L && /* @__PURE__ */ e("button", { className: "sa-fp-header-btn", onClick: y, title: "展开侧边栏", children: /* @__PURE__ */ e(C, { name: "panel-left", size: 18 }) }),
|
|
1077
1507
|
/* @__PURE__ */ e("div", { className: "sa-fp-header-title", children: a }),
|
|
1078
|
-
/* @__PURE__ */
|
|
1508
|
+
/* @__PURE__ */ d("div", { className: "sa-fp-header-actions", children: [
|
|
1509
|
+
l && I.length > 0 && /* @__PURE__ */ d("button", { className: "sa-fp-header-btn sa-header-btn-artifact", onClick: m, title: "会话产物", children: [
|
|
1510
|
+
/* @__PURE__ */ d("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: [
|
|
1511
|
+
/* @__PURE__ */ e("path", { d: "M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z" }),
|
|
1512
|
+
/* @__PURE__ */ e("polyline", { points: "14 2 14 8 20 8" })
|
|
1513
|
+
] }),
|
|
1514
|
+
/* @__PURE__ */ e("span", { children: "产物" })
|
|
1515
|
+
] }),
|
|
1516
|
+
o && /* @__PURE__ */ e("button", { className: "sa-fp-header-btn", onClick: o, title: "关闭", children: /* @__PURE__ */ e(C, { name: "x", size: 18 }) })
|
|
1517
|
+
] })
|
|
1518
|
+
] }),
|
|
1519
|
+
/* @__PURE__ */ d("div", { className: "sa-fp-content-row", children: [
|
|
1520
|
+
/* @__PURE__ */ e(re, { slots: t, welcomeMessage: s, suggestedPrompts: r, avatar: i, artifactPreview: l }),
|
|
1521
|
+
l && x && /* @__PURE__ */ e(ne, { artifacts: I, initialArtifact: D, onClose: m })
|
|
1079
1522
|
] }),
|
|
1080
|
-
/* @__PURE__ */ e(
|
|
1081
|
-
M ? /* @__PURE__ */ e(M, { status: l, onSend: i, onStop: p }) : /* @__PURE__ */ e(Z, {})
|
|
1523
|
+
$ ? /* @__PURE__ */ e($, { status: c, onSend: p, onStop: f }) : /* @__PURE__ */ e(se, {})
|
|
1082
1524
|
] })
|
|
1083
1525
|
] });
|
|
1084
1526
|
}
|
|
1085
|
-
function
|
|
1086
|
-
const { sdk: t, mode:
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
}, [
|
|
1090
|
-
const
|
|
1091
|
-
var
|
|
1092
|
-
const
|
|
1093
|
-
|
|
1094
|
-
}, [
|
|
1095
|
-
var
|
|
1096
|
-
|
|
1097
|
-
}, [
|
|
1098
|
-
return
|
|
1099
|
-
|
|
1527
|
+
function Ke(a) {
|
|
1528
|
+
const { sdk: t, mode: s = "floating", slots: r = {}, hooks: n = {}, welcomeMessage: o, suggestedPrompts: i, title: l = "AI Assistant", initialOpen: c = !1, onOpenChange: p, sidebarDefaultOpen: f, avatar: u, artifactPreview: h } = a, [v, k] = T(c);
|
|
1529
|
+
B(() => {
|
|
1530
|
+
k(c);
|
|
1531
|
+
}, [c]);
|
|
1532
|
+
const g = N(() => {
|
|
1533
|
+
var I, D;
|
|
1534
|
+
const x = !v;
|
|
1535
|
+
k(x), p == null || p(x), x ? (I = n.onOpen) == null || I.call(n) : (D = n.onClose) == null || D.call(n);
|
|
1536
|
+
}, [v, n, p]), b = N(() => {
|
|
1537
|
+
var x;
|
|
1538
|
+
k(!1), p == null || p(!1), (x = n.onClose) == null || x.call(n);
|
|
1539
|
+
}, [n, p]), m = r.Trigger ?? fe;
|
|
1540
|
+
return s === "fullpage" ? v ? /* @__PURE__ */ e(G, { sdk: t, hooks: n, children: /* @__PURE__ */ e(
|
|
1541
|
+
Ye,
|
|
1100
1542
|
{
|
|
1101
1543
|
title: l,
|
|
1102
1544
|
slots: r,
|
|
1103
|
-
welcomeMessage:
|
|
1104
|
-
suggestedPrompts:
|
|
1545
|
+
welcomeMessage: o,
|
|
1546
|
+
suggestedPrompts: i,
|
|
1105
1547
|
sidebarDefaultOpen: f,
|
|
1106
|
-
onClose:
|
|
1107
|
-
avatar:
|
|
1548
|
+
onClose: b,
|
|
1549
|
+
avatar: u,
|
|
1550
|
+
artifactPreview: h
|
|
1108
1551
|
}
|
|
1109
|
-
) }) : null : /* @__PURE__ */
|
|
1110
|
-
/* @__PURE__ */ e(
|
|
1552
|
+
) }) : null : /* @__PURE__ */ d(G, { sdk: t, hooks: n, children: [
|
|
1553
|
+
/* @__PURE__ */ e(m, { isOpen: v, onClick: g }),
|
|
1111
1554
|
/* @__PURE__ */ e(
|
|
1112
|
-
|
|
1555
|
+
We,
|
|
1113
1556
|
{
|
|
1114
|
-
isOpen:
|
|
1115
|
-
onClose:
|
|
1557
|
+
isOpen: v,
|
|
1558
|
+
onClose: b,
|
|
1116
1559
|
title: l,
|
|
1117
1560
|
slots: r,
|
|
1118
|
-
welcomeMessage:
|
|
1119
|
-
suggestedPrompts:
|
|
1120
|
-
avatar:
|
|
1561
|
+
welcomeMessage: o,
|
|
1562
|
+
suggestedPrompts: i,
|
|
1563
|
+
avatar: u,
|
|
1564
|
+
artifactPreview: h
|
|
1121
1565
|
}
|
|
1122
1566
|
)
|
|
1123
1567
|
] });
|
|
1124
1568
|
}
|
|
1125
|
-
const
|
|
1569
|
+
const Ue = `
|
|
1126
1570
|
[data-super-agent-widget] {
|
|
1127
1571
|
--sa-primary-dark: color-mix(in srgb, var(--sa-primary) 82%, #000);
|
|
1128
1572
|
--sa-primary-light: color-mix(in srgb, var(--sa-primary) 10%, #fff);
|
|
@@ -1646,6 +2090,7 @@ const Re = `
|
|
|
1646
2090
|
display: flex;
|
|
1647
2091
|
gap: 6px;
|
|
1648
2092
|
margin-top: 6px;
|
|
2093
|
+
position: relative;
|
|
1649
2094
|
}
|
|
1650
2095
|
|
|
1651
2096
|
.sa-action-btn {
|
|
@@ -1677,6 +2122,44 @@ const Re = `
|
|
|
1677
2122
|
align-self: center;
|
|
1678
2123
|
}
|
|
1679
2124
|
|
|
2125
|
+
/* ── Dislike Panel ── */
|
|
2126
|
+
.sa-dislike-panel {
|
|
2127
|
+
position: absolute; bottom: 100%; left: 0; right: 0;
|
|
2128
|
+
margin-bottom: 6px; padding: 12px;
|
|
2129
|
+
background: #fff; border: 1px solid var(--sa-border); border-radius: 10px;
|
|
2130
|
+
box-shadow: 0 4px 16px rgba(0,0,0,0.08);
|
|
2131
|
+
animation: sa-fade-in-up 0.2s cubic-bezier(0.16,1,0.3,1) both;
|
|
2132
|
+
z-index: 10;
|
|
2133
|
+
}
|
|
2134
|
+
.sa-dislike-panel-title { font-size: 13px; font-weight: 500; color: var(--sa-text); margin-bottom: 8px; }
|
|
2135
|
+
.sa-dislike-reasons { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
|
|
2136
|
+
.sa-dislike-reason-btn {
|
|
2137
|
+
padding: 4px 10px; border: 1px solid var(--sa-border); border-radius: 6px;
|
|
2138
|
+
background: #fff; color: var(--sa-text); font-size: 12px; cursor: pointer;
|
|
2139
|
+
transition: border-color 0.15s, background 0.15s, color 0.15s;
|
|
2140
|
+
}
|
|
2141
|
+
.sa-dislike-reason-btn:hover { border-color: var(--sa-primary); color: var(--sa-primary); }
|
|
2142
|
+
.sa-dislike-reason-btn.active { background: var(--sa-primary); color: #fff; border-color: var(--sa-primary); }
|
|
2143
|
+
.sa-dislike-remark {
|
|
2144
|
+
width: 100%; padding: 8px 10px; border: 1px solid var(--sa-border); border-radius: 8px;
|
|
2145
|
+
font-size: 13px; color: var(--sa-text); resize: none; outline: none;
|
|
2146
|
+
transition: border-color 0.15s;
|
|
2147
|
+
}
|
|
2148
|
+
.sa-dislike-remark:focus { border-color: var(--sa-primary); }
|
|
2149
|
+
.sa-dislike-actions { display: flex; gap: 8px; margin-top: 10px; justify-content: flex-end; }
|
|
2150
|
+
.sa-dislike-submit {
|
|
2151
|
+
padding: 5px 14px; border: none; border-radius: 6px;
|
|
2152
|
+
background: var(--sa-primary); color: #fff; font-size: 13px; font-weight: 500; cursor: pointer;
|
|
2153
|
+
transition: opacity 0.15s;
|
|
2154
|
+
}
|
|
2155
|
+
.sa-dislike-submit:hover { opacity: 0.9; }
|
|
2156
|
+
.sa-dislike-cancel {
|
|
2157
|
+
padding: 5px 14px; border: 1px solid var(--sa-border); border-radius: 6px;
|
|
2158
|
+
background: #fff; color: var(--sa-text-muted); font-size: 13px; cursor: pointer;
|
|
2159
|
+
transition: background 0.15s;
|
|
2160
|
+
}
|
|
2161
|
+
.sa-dislike-cancel:hover { background: var(--sa-surface); }
|
|
2162
|
+
|
|
1680
2163
|
/* ── Composer ────────────────────────────────────────────── */
|
|
1681
2164
|
|
|
1682
2165
|
.sa-composer {
|
|
@@ -2014,6 +2497,15 @@ const Re = `
|
|
|
2014
2497
|
background: #e5e7eb;
|
|
2015
2498
|
}
|
|
2016
2499
|
|
|
2500
|
+
.sa-interrupt-btn-danger {
|
|
2501
|
+
background: #fef2f2;
|
|
2502
|
+
color: #dc2626;
|
|
2503
|
+
}
|
|
2504
|
+
|
|
2505
|
+
.sa-interrupt-btn-danger:hover:not(:disabled) {
|
|
2506
|
+
background: #fee2e2;
|
|
2507
|
+
}
|
|
2508
|
+
|
|
2017
2509
|
.sa-interrupt-options {
|
|
2018
2510
|
display: flex;
|
|
2019
2511
|
flex-direction: column;
|
|
@@ -2398,7 +2890,7 @@ const Re = `
|
|
|
2398
2890
|
}
|
|
2399
2891
|
|
|
2400
2892
|
.sa-fp-header-btn {
|
|
2401
|
-
width: 34px;
|
|
2893
|
+
min-width: 34px;
|
|
2402
2894
|
height: 34px;
|
|
2403
2895
|
border: none;
|
|
2404
2896
|
border-radius: 8px;
|
|
@@ -2442,7 +2934,168 @@ const Re = `
|
|
|
2442
2934
|
border-color: #d4d4d8;
|
|
2443
2935
|
box-shadow: 0 0 0 3px rgba(99,102,241,0.08);
|
|
2444
2936
|
}
|
|
2445
|
-
|
|
2937
|
+
|
|
2938
|
+
/* ── Artifact file cards (in ToolResultPart) ── */
|
|
2939
|
+
.sa-artifact-file-list { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
|
|
2940
|
+
.sa-artifact-file-card {
|
|
2941
|
+
display: flex; align-items: center; gap: 10px; padding: 8px 10px;
|
|
2942
|
+
border: 1px solid var(--sa-border); border-radius: 10px; background: var(--sa-surface);
|
|
2943
|
+
font-size: 13px; color: var(--sa-text);
|
|
2944
|
+
transition: border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease, transform 0.15s ease;
|
|
2945
|
+
animation: sa-fade-in-up 0.3s cubic-bezier(0.16, 1, 0.3, 1) both;
|
|
2946
|
+
}
|
|
2947
|
+
.sa-artifact-file-card:hover { border-color: var(--sa-primary); background: #fff; box-shadow: 0 2px 8px rgba(99,102,241,0.1); transform: translateY(-1px); }
|
|
2948
|
+
.sa-artifact-file-card:active { transform: translateY(0) scale(0.99); }
|
|
2949
|
+
.sa-artifact-file-icon { flex-shrink: 0; }
|
|
2950
|
+
.sa-artifact-chip-type {
|
|
2951
|
+
display: inline-flex; align-items: center; justify-content: center;
|
|
2952
|
+
min-width: 36px; padding: 2px 6px; border-radius: 5px;
|
|
2953
|
+
background: var(--sa-primary); color: #fff;
|
|
2954
|
+
font-size: 10px; font-weight: 700; letter-spacing: 0.3px; line-height: 1.4;
|
|
2955
|
+
}
|
|
2956
|
+
.sa-artifact-file-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
|
|
2957
|
+
.sa-artifact-file-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
|
|
2958
|
+
.sa-artifact-file-size { color: var(--sa-text-muted); font-size: 12px; }
|
|
2959
|
+
.sa-artifact-file-download {
|
|
2960
|
+
border: none; background: none; cursor: pointer; color: var(--sa-text-muted);
|
|
2961
|
+
padding: 6px; border-radius: 6px; display: inline-flex;
|
|
2962
|
+
transition: color 0.15s ease, background 0.15s ease, transform 0.1s ease;
|
|
2963
|
+
}
|
|
2964
|
+
.sa-artifact-file-download:hover { color: var(--sa-primary); background: rgba(99,102,241,0.08); }
|
|
2965
|
+
.sa-artifact-file-download:active { transform: scale(0.9); }
|
|
2966
|
+
|
|
2967
|
+
/* ── Inline HTML rendering (render_mode=html) ── */
|
|
2968
|
+
.sa-tool-result-html { margin-top: 8px; border: 1px solid var(--sa-border); border-radius: 8px; overflow: hidden; }
|
|
2969
|
+
.sa-tool-result-html-iframe { width: 100%; min-height: 120px; max-height: 400px; border: none; background: #fff; }
|
|
2970
|
+
|
|
2971
|
+
/* ── Header artifact button ── */
|
|
2972
|
+
.sa-header-btn-artifact {
|
|
2973
|
+
display: inline-flex; align-items: center; gap: 4px;
|
|
2974
|
+
padding: 4px 12px !important; border-radius: 8px;
|
|
2975
|
+
background: var(--sa-primary) !important; color: #fff !important;
|
|
2976
|
+
font-size: 12px; font-weight: 600;
|
|
2977
|
+
transition: opacity 0.15s ease, transform 0.15s ease, box-shadow 0.2s ease;
|
|
2978
|
+
box-shadow: 0 1px 4px rgba(99,102,241,0.25);
|
|
2979
|
+
}
|
|
2980
|
+
.sa-header-btn-artifact:hover { opacity: 0.92; transform: translateY(-1px); box-shadow: 0 3px 10px rgba(99,102,241,0.3); }
|
|
2981
|
+
.sa-header-btn-artifact:active { transform: translateY(0) scale(0.97); }
|
|
2982
|
+
.sa-header-btn-artifact svg { stroke: #fff; }
|
|
2983
|
+
.sa-header-btn-artifact.sa-artifact-pulse { animation: sa-artifact-pulse 2s ease-in-out 3; }
|
|
2984
|
+
|
|
2985
|
+
/* ── Artifact drawer (right side panel) ── */
|
|
2986
|
+
.sa-artifact-drawer {
|
|
2987
|
+
display: flex; flex-direction: column; min-width: 240px; max-width: 70%;
|
|
2988
|
+
border-left: 1px solid var(--sa-border); background: #fff; flex-shrink: 0; overflow: hidden;
|
|
2989
|
+
animation: sa-slide-in-right 0.3s cubic-bezier(0.16, 1, 0.3, 1) both;
|
|
2990
|
+
position: relative;
|
|
2991
|
+
}
|
|
2992
|
+
.sa-artifact-drawer.sa-drawer-closing {
|
|
2993
|
+
animation: sa-slide-out-right 0.25s cubic-bezier(0.4, 0, 1, 1) both;
|
|
2994
|
+
}
|
|
2995
|
+
.sa-drawer-resize-handle {
|
|
2996
|
+
position: absolute; left: -3px; top: 0; bottom: 0; width: 6px;
|
|
2997
|
+
cursor: col-resize; z-index: 2;
|
|
2998
|
+
transition: background 0.15s ease;
|
|
2999
|
+
}
|
|
3000
|
+
.sa-drawer-resize-handle:hover, .sa-drawer-resize-handle:active {
|
|
3001
|
+
background: var(--sa-primary); opacity: 0.3; border-radius: 3px;
|
|
3002
|
+
}
|
|
3003
|
+
.sa-artifact-drawer-header {
|
|
3004
|
+
display: flex; align-items: center; gap: 8px; padding: 12px 14px;
|
|
3005
|
+
border-bottom: 1px solid var(--sa-border); font-weight: 600; font-size: 15px; color: var(--sa-text);
|
|
3006
|
+
background: var(--sa-surface);
|
|
3007
|
+
}
|
|
3008
|
+
.sa-artifact-drawer-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
3009
|
+
.sa-drawer-btn {
|
|
3010
|
+
border: none; background: none; cursor: pointer; color: var(--sa-text-muted);
|
|
3011
|
+
padding: 6px; border-radius: 6px; display: inline-flex; align-items: center;
|
|
3012
|
+
transition: background 0.15s ease, color 0.15s ease, transform 0.1s ease;
|
|
3013
|
+
}
|
|
3014
|
+
.sa-drawer-btn:hover { background: var(--sa-border); color: var(--sa-text); }
|
|
3015
|
+
.sa-drawer-btn:active { transform: scale(0.92); }
|
|
3016
|
+
.sa-drawer-btn-sm {
|
|
3017
|
+
border: 1px solid var(--sa-border); background: #fff; cursor: pointer; color: var(--sa-primary);
|
|
3018
|
+
padding: 6px 14px; border-radius: 8px; font-size: 13px; font-weight: 500;
|
|
3019
|
+
transition: background 0.15s ease, border-color 0.15s ease;
|
|
3020
|
+
}
|
|
3021
|
+
.sa-drawer-btn-sm:hover { background: var(--sa-surface); border-color: var(--sa-primary); }
|
|
3022
|
+
.sa-artifact-drawer-body { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; scroll-behavior: smooth; }
|
|
3023
|
+
.sa-drawer-empty { padding: 48px 24px; text-align: center; color: var(--sa-text-muted); font-size: 14px; }
|
|
3024
|
+
.sa-drawer-file-list { list-style: none; margin: 0; padding: 10px; display: flex; flex-direction: column; gap: 8px; }
|
|
3025
|
+
.sa-drawer-file-card {
|
|
3026
|
+
display: flex; align-items: center; gap: 10px; padding: 12px 14px;
|
|
3027
|
+
border: 1px solid var(--sa-border); border-radius: 10px; cursor: pointer; background: #fff;
|
|
3028
|
+
transition: border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease, transform 0.15s ease;
|
|
3029
|
+
animation: sa-fade-in-up 0.3s cubic-bezier(0.16, 1, 0.3, 1) both;
|
|
3030
|
+
}
|
|
3031
|
+
.sa-drawer-file-card:nth-child(1) { animation-delay: 0s; }
|
|
3032
|
+
.sa-drawer-file-card:nth-child(2) { animation-delay: 0.04s; }
|
|
3033
|
+
.sa-drawer-file-card:nth-child(3) { animation-delay: 0.08s; }
|
|
3034
|
+
.sa-drawer-file-card:nth-child(4) { animation-delay: 0.12s; }
|
|
3035
|
+
.sa-drawer-file-card:nth-child(5) { animation-delay: 0.16s; }
|
|
3036
|
+
.sa-drawer-file-card:hover { border-color: var(--sa-primary); background: var(--sa-surface); box-shadow: 0 2px 8px rgba(99,102,241,0.08); transform: translateY(-1px); }
|
|
3037
|
+
.sa-drawer-file-card:active { transform: translateY(0) scale(0.98); }
|
|
3038
|
+
.sa-drawer-file-icon { flex-shrink: 0; }
|
|
3039
|
+
.sa-drawer-file-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
|
|
3040
|
+
.sa-drawer-file-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; font-size: 14px; color: var(--sa-text); }
|
|
3041
|
+
.sa-drawer-file-size { color: var(--sa-text-muted); font-size: 12px; }
|
|
3042
|
+
|
|
3043
|
+
/* ── Drawer preview ── */
|
|
3044
|
+
.sa-drawer-preview-iframe { width: 100%; height: 100%; border: none; background: #fff; animation: sa-fade-in 0.3s ease both; }
|
|
3045
|
+
.sa-drawer-preview-loading {
|
|
3046
|
+
display: flex; flex-direction: column; align-items: center; justify-content: center;
|
|
3047
|
+
height: 100%; gap: 12px; color: var(--sa-text-muted); font-size: 14px;
|
|
3048
|
+
}
|
|
3049
|
+
.sa-drawer-preview-loading::before {
|
|
3050
|
+
content: ''; width: 28px; height: 28px; border-radius: 50%;
|
|
3051
|
+
border: 3px solid var(--sa-border); border-top-color: var(--sa-primary);
|
|
3052
|
+
animation: sa-spinner 0.7s linear infinite;
|
|
3053
|
+
}
|
|
3054
|
+
.sa-drawer-preview-error {
|
|
3055
|
+
display: flex; flex-direction: column; align-items: center; justify-content: center;
|
|
3056
|
+
gap: 14px; height: 100%; color: var(--sa-text-muted); font-size: 14px;
|
|
3057
|
+
animation: sa-fade-in 0.2s ease both;
|
|
3058
|
+
}
|
|
3059
|
+
|
|
3060
|
+
/* ── Drawer view transition ── */
|
|
3061
|
+
.sa-drawer-view-enter { animation: sa-drawer-view-in 0.25s cubic-bezier(0.16, 1, 0.3, 1) both; }
|
|
3062
|
+
|
|
3063
|
+
/* ── Layout helpers for drawer alongside thread ── */
|
|
3064
|
+
.sa-panel-content { display: flex; flex: 1; min-height: 0; overflow: hidden; }
|
|
3065
|
+
.sa-panel-content .sa-thread { flex: 1; min-width: 120px; transition: flex 0.3s cubic-bezier(0.16, 1, 0.3, 1); }
|
|
3066
|
+
.sa-panel-content .sa-artifact-drawer { max-width: 60%; }
|
|
3067
|
+
.sa-fp-content-row { display: flex; flex: 1; min-height: 0; overflow: hidden; }
|
|
3068
|
+
.sa-fp-content-row .sa-thread { flex: 1; min-width: 0; transition: flex 0.3s cubic-bezier(0.16, 1, 0.3, 1); }
|
|
3069
|
+
|
|
3070
|
+
/* ── Artifact keyframes ── */
|
|
3071
|
+
@keyframes sa-slide-in-right {
|
|
3072
|
+
from { opacity: 0; transform: translateX(100%); }
|
|
3073
|
+
to { opacity: 1; transform: translateX(0); }
|
|
3074
|
+
}
|
|
3075
|
+
@keyframes sa-slide-out-right {
|
|
3076
|
+
from { opacity: 1; transform: translateX(0); }
|
|
3077
|
+
to { opacity: 0; transform: translateX(100%); }
|
|
3078
|
+
}
|
|
3079
|
+
@keyframes sa-fade-in-up {
|
|
3080
|
+
from { opacity: 0; transform: translateY(8px); }
|
|
3081
|
+
to { opacity: 1; transform: translateY(0); }
|
|
3082
|
+
}
|
|
3083
|
+
@keyframes sa-fade-in {
|
|
3084
|
+
from { opacity: 0; }
|
|
3085
|
+
to { opacity: 1; }
|
|
3086
|
+
}
|
|
3087
|
+
@keyframes sa-spinner {
|
|
3088
|
+
to { transform: rotate(360deg); }
|
|
3089
|
+
}
|
|
3090
|
+
@keyframes sa-artifact-pulse {
|
|
3091
|
+
0%, 100% { box-shadow: 0 1px 4px rgba(99,102,241,0.25); }
|
|
3092
|
+
50% { box-shadow: 0 2px 12px rgba(99,102,241,0.5); }
|
|
3093
|
+
}
|
|
3094
|
+
@keyframes sa-drawer-view-in {
|
|
3095
|
+
from { opacity: 0; transform: translateX(12px); }
|
|
3096
|
+
to { opacity: 1; transform: translateX(0); }
|
|
3097
|
+
}
|
|
3098
|
+
`, Ve = {
|
|
2446
3099
|
primaryColor: "#6366f1",
|
|
2447
3100
|
backgroundColor: "#ffffff",
|
|
2448
3101
|
fontFamily: "system-ui, -apple-system, sans-serif",
|
|
@@ -2451,8 +3104,8 @@ const Re = `
|
|
|
2451
3104
|
panelHeight: 520,
|
|
2452
3105
|
zIndex: 9999
|
|
2453
3106
|
};
|
|
2454
|
-
function
|
|
2455
|
-
const t = { ...
|
|
3107
|
+
function qe(a) {
|
|
3108
|
+
const t = { ...Ve, ...a };
|
|
2456
3109
|
return [
|
|
2457
3110
|
`--sa-primary: ${t.primaryColor}`,
|
|
2458
3111
|
`--sa-bg: ${t.backgroundColor}`,
|
|
@@ -2463,66 +3116,66 @@ function Oe(a) {
|
|
|
2463
3116
|
`--sa-z-index: ${t.zIndex}`
|
|
2464
3117
|
].join("; ");
|
|
2465
3118
|
}
|
|
2466
|
-
function
|
|
2467
|
-
const
|
|
2468
|
-
if (!
|
|
3119
|
+
function Ze(a, t) {
|
|
3120
|
+
const s = typeof a == "string" ? document.querySelector(a) : a;
|
|
3121
|
+
if (!s)
|
|
2469
3122
|
throw new Error(`Target element not found: ${a}`);
|
|
2470
3123
|
const r = document.createElement("div");
|
|
2471
3124
|
r.setAttribute("data-super-agent-widget", "");
|
|
2472
|
-
const
|
|
2473
|
-
if (r.setAttribute("style",
|
|
2474
|
-
const
|
|
2475
|
-
|
|
2476
|
-
}
|
|
2477
|
-
let
|
|
2478
|
-
const l = (
|
|
2479
|
-
|
|
2480
|
-
|
|
3125
|
+
const n = qe(t.theme ?? {});
|
|
3126
|
+
if (r.setAttribute("style", n), s.appendChild(r), !document.getElementById("sa-widget-styles")) {
|
|
3127
|
+
const c = document.createElement("style");
|
|
3128
|
+
c.id = "sa-widget-styles", c.textContent = Ue, document.head.appendChild(c);
|
|
3129
|
+
}
|
|
3130
|
+
let o = le(r), i = !1;
|
|
3131
|
+
const l = (c) => {
|
|
3132
|
+
o && o.render(
|
|
3133
|
+
Y.createElement(Ke, {
|
|
2481
3134
|
...t,
|
|
2482
|
-
initialOpen:
|
|
3135
|
+
initialOpen: c ?? i,
|
|
2483
3136
|
onOpenChange: (p) => {
|
|
2484
|
-
|
|
3137
|
+
i = p;
|
|
2485
3138
|
}
|
|
2486
3139
|
})
|
|
2487
3140
|
);
|
|
2488
3141
|
};
|
|
2489
3142
|
return l(!1), {
|
|
2490
3143
|
open() {
|
|
2491
|
-
|
|
3144
|
+
i = !0, l(!0);
|
|
2492
3145
|
},
|
|
2493
3146
|
close() {
|
|
2494
|
-
|
|
3147
|
+
i = !1, l(!1);
|
|
2495
3148
|
},
|
|
2496
3149
|
destroy() {
|
|
2497
|
-
|
|
3150
|
+
o && (o.unmount(), o = null), r.remove();
|
|
2498
3151
|
}
|
|
2499
3152
|
};
|
|
2500
3153
|
}
|
|
2501
3154
|
export {
|
|
2502
|
-
|
|
2503
|
-
|
|
2504
|
-
|
|
2505
|
-
|
|
2506
|
-
|
|
2507
|
-
|
|
2508
|
-
|
|
2509
|
-
|
|
2510
|
-
|
|
2511
|
-
|
|
2512
|
-
|
|
2513
|
-
|
|
2514
|
-
|
|
2515
|
-
|
|
2516
|
-
|
|
2517
|
-
|
|
2518
|
-
|
|
2519
|
-
|
|
2520
|
-
|
|
2521
|
-
|
|
2522
|
-
|
|
2523
|
-
|
|
2524
|
-
|
|
2525
|
-
|
|
2526
|
-
|
|
2527
|
-
|
|
3155
|
+
Re as ActionBar,
|
|
3156
|
+
G as ChatProvider,
|
|
3157
|
+
Ke as ChatWidget,
|
|
3158
|
+
se as Composer,
|
|
3159
|
+
Ne as ErrorPart,
|
|
3160
|
+
Ye as FullpageLayout,
|
|
3161
|
+
ue as Header,
|
|
3162
|
+
C as Icon,
|
|
3163
|
+
$e as InterruptCard,
|
|
3164
|
+
He as Message,
|
|
3165
|
+
ve as TextPart,
|
|
3166
|
+
we as ThinkingPart,
|
|
3167
|
+
re as Thread,
|
|
3168
|
+
he as ThreadList,
|
|
3169
|
+
ye as ToolCallPart,
|
|
3170
|
+
Ce as ToolResultPart,
|
|
3171
|
+
fe as Trigger,
|
|
3172
|
+
je as WelcomeScreen,
|
|
3173
|
+
Ve as defaultTheme,
|
|
3174
|
+
Ze as mount,
|
|
3175
|
+
qe as themeToCSSVars,
|
|
3176
|
+
ge as useAutoScroll,
|
|
3177
|
+
ce as useChat,
|
|
3178
|
+
F as useChatContext,
|
|
3179
|
+
pe as useConversations,
|
|
3180
|
+
Ue as widgetStyles
|
|
2528
3181
|
};
|