super-agent-sdk 1.0.7 → 1.0.8
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 +79 -18
- package/dist/index.cjs +3 -3
- package/dist/index.d.ts +7 -2
- package/dist/index.mjs +90 -85
- package/dist/widget.cjs +51 -8
- package/dist/widget.d.ts +11 -4
- package/dist/widget.mjs +1256 -1065
- package/package.json +1 -1
package/dist/widget.mjs
CHANGED
|
@@ -1,302 +1,303 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { createRoot as
|
|
3
|
-
import { jsx as e, jsxs as
|
|
4
|
-
function
|
|
5
|
-
const { sdk:
|
|
6
|
-
T.current = s,
|
|
7
|
-
const
|
|
8
|
-
if (
|
|
9
|
-
|
|
10
|
-
const
|
|
1
|
+
import V, { useState as M, useRef as _, useCallback as C, useEffect as B, createContext as ge, useMemo as J, useContext as xe } from "react";
|
|
2
|
+
import { createRoot as be } from "react-dom/client";
|
|
3
|
+
import { jsx as e, jsxs as d, Fragment as q } from "react/jsx-runtime";
|
|
4
|
+
function ve(t) {
|
|
5
|
+
const { sdk: a, sessionId: s, onSessionCreated: n, onStreamStart: r, onStreamEnd: i, onError: o, onMessageSend: l } = t, [c, p] = M([]), [f, h] = M("ready"), [w, u] = M(null), m = _(null), v = _(!1), S = _(null), T = _(s), A = _(!0);
|
|
6
|
+
T.current = s, A.current = c.length === 0;
|
|
7
|
+
const x = C((N) => {
|
|
8
|
+
if (v.current) return;
|
|
9
|
+
v.current = !0, l == null || l(N);
|
|
10
|
+
const R = {
|
|
11
11
|
id: `user_${Date.now()}`,
|
|
12
12
|
role: "user",
|
|
13
|
-
parts: [{ type: "text", content:
|
|
13
|
+
parts: [{ type: "text", content: N }],
|
|
14
14
|
timestamp: Date.now()
|
|
15
|
-
},
|
|
16
|
-
id:
|
|
15
|
+
}, y = `assistant_${Date.now()}`, g = {
|
|
16
|
+
id: y,
|
|
17
17
|
role: "assistant",
|
|
18
18
|
parts: [],
|
|
19
19
|
timestamp: Date.now()
|
|
20
|
-
},
|
|
21
|
-
|
|
22
|
-
const
|
|
23
|
-
let
|
|
24
|
-
const
|
|
25
|
-
const
|
|
26
|
-
if (
|
|
27
|
-
const
|
|
28
|
-
|
|
20
|
+
}, E = A.current;
|
|
21
|
+
p((k) => [...k, R, g]), h("submitted"), u(null);
|
|
22
|
+
const L = (k) => {
|
|
23
|
+
let O = "", b = "", H = [], j = !1;
|
|
24
|
+
const W = () => {
|
|
25
|
+
const D = [...H];
|
|
26
|
+
if (O) {
|
|
27
|
+
const F = D.findIndex((U) => U.type === "thinking");
|
|
28
|
+
F >= 0 ? D[F] = { type: "thinking", content: O } : D.unshift({ type: "thinking", content: O });
|
|
29
29
|
}
|
|
30
|
-
if (
|
|
31
|
-
const
|
|
32
|
-
|
|
30
|
+
if (b) {
|
|
31
|
+
const F = D[D.length - 1];
|
|
32
|
+
(F == null ? void 0 : F.type) === "text" ? D[D.length - 1] = { type: "text", content: b } : D.push({ type: "text", content: b });
|
|
33
33
|
}
|
|
34
|
-
|
|
35
|
-
(
|
|
34
|
+
p(
|
|
35
|
+
(F) => F.map((U) => U.id === y ? { ...U, parts: D } : U)
|
|
36
36
|
);
|
|
37
37
|
};
|
|
38
|
-
|
|
39
|
-
sessionId:
|
|
40
|
-
message:
|
|
38
|
+
m.current = a.chat({
|
|
39
|
+
sessionId: k,
|
|
40
|
+
message: N,
|
|
41
41
|
stream: !0,
|
|
42
|
-
onMessage: (
|
|
43
|
-
switch (
|
|
42
|
+
onMessage: (D) => {
|
|
43
|
+
switch (j || (j = !0, h("streaming")), D.type) {
|
|
44
44
|
case "thinking":
|
|
45
|
-
|
|
45
|
+
O += D.content;
|
|
46
46
|
break;
|
|
47
47
|
case "ai":
|
|
48
|
-
|
|
48
|
+
b += D.content;
|
|
49
49
|
break;
|
|
50
50
|
case "tool_call":
|
|
51
|
-
|
|
51
|
+
b && (H.push({ type: "text", content: b }), b = ""), H.push({
|
|
52
52
|
type: "tool_call",
|
|
53
|
-
toolName:
|
|
54
|
-
toolCallId:
|
|
55
|
-
args:
|
|
53
|
+
toolName: D.toolName,
|
|
54
|
+
toolCallId: D.toolCallId,
|
|
55
|
+
args: D.args ?? "{}"
|
|
56
56
|
});
|
|
57
57
|
break;
|
|
58
58
|
case "tool_result":
|
|
59
|
-
|
|
59
|
+
b && (H.push({ type: "text", content: b }), b = ""), H.push({
|
|
60
60
|
type: "tool_result",
|
|
61
|
-
toolName:
|
|
62
|
-
toolCallId:
|
|
63
|
-
content:
|
|
64
|
-
artifacts:
|
|
65
|
-
renderMode:
|
|
66
|
-
html:
|
|
67
|
-
})
|
|
61
|
+
toolName: D.toolName ?? "",
|
|
62
|
+
toolCallId: D.toolCallId,
|
|
63
|
+
content: D.content,
|
|
64
|
+
artifacts: D.artifacts,
|
|
65
|
+
renderMode: D.renderMode,
|
|
66
|
+
html: D.html
|
|
67
|
+
});
|
|
68
68
|
break;
|
|
69
69
|
case "interrupt":
|
|
70
|
-
|
|
70
|
+
b && (H.push({ type: "text", content: b }), b = ""), D.interrupt && H.push({
|
|
71
71
|
type: "interrupt",
|
|
72
|
-
interrupt:
|
|
72
|
+
interrupt: D.interrupt,
|
|
73
73
|
resolved: !1
|
|
74
74
|
});
|
|
75
75
|
break;
|
|
76
76
|
case "stop":
|
|
77
|
-
|
|
77
|
+
D.content && (b = D.content), W();
|
|
78
78
|
return;
|
|
79
79
|
}
|
|
80
|
-
|
|
80
|
+
W();
|
|
81
81
|
},
|
|
82
|
-
onDone: (
|
|
83
|
-
(
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
const W = () => {
|
|
87
|
-
i == null || i($.sessionId || S), d("ready"), w.current = !1, x.current = null;
|
|
82
|
+
onDone: (D) => {
|
|
83
|
+
(b || H.length > 0 || O) && W(), D.sessionId && D.sessionId !== T.current && (n == null || n(D.sessionId));
|
|
84
|
+
const F = () => {
|
|
85
|
+
S.current && (clearTimeout(S.current), S.current = null), i == null || i(D.sessionId || k), h("ready"), v.current = !1, m.current = null;
|
|
88
86
|
};
|
|
89
|
-
if (
|
|
90
|
-
const
|
|
91
|
-
|
|
92
|
-
}).finally(
|
|
87
|
+
if (E) {
|
|
88
|
+
const U = N.slice(0, 30), he = D.sessionId || k;
|
|
89
|
+
a.renameConversation(he, U).catch(() => {
|
|
90
|
+
}).finally(F);
|
|
93
91
|
} else
|
|
94
|
-
|
|
92
|
+
F();
|
|
95
93
|
},
|
|
96
|
-
onError: (
|
|
97
|
-
|
|
94
|
+
onError: (D) => {
|
|
95
|
+
H.push({ type: "error", content: D.message }), W(), S.current && (clearTimeout(S.current), S.current = null), u(D), h("error"), o == null || o(D), v.current = !1, m.current = null;
|
|
98
96
|
}
|
|
99
|
-
}),
|
|
97
|
+
}), r == null || r(k);
|
|
100
98
|
};
|
|
101
|
-
T.current ?
|
|
102
|
-
T.current =
|
|
103
|
-
}).catch((
|
|
104
|
-
|
|
105
|
-
});
|
|
106
|
-
}, [r, n, a, i, o, l]), k = N(() => {
|
|
107
|
-
var b;
|
|
108
|
-
const y = T.current;
|
|
109
|
-
(b = x.current) == null || b.abort(), x.current = null, d("ready"), w.current = !1, y && r.stopGeneration(y).catch(() => {
|
|
99
|
+
T.current ? L(T.current) : a.createSession().then((k) => {
|
|
100
|
+
T.current = k, n == null || n(k), L(k);
|
|
101
|
+
}).catch((k) => {
|
|
102
|
+
u(k instanceof Error ? k : new Error(String(k))), h("error"), o == null || o(k instanceof Error ? k : new Error(String(k))), v.current = !1;
|
|
110
103
|
});
|
|
111
|
-
}, [r]),
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
104
|
+
}, [a, n, r, i, o, l]), z = C(() => {
|
|
105
|
+
const N = T.current;
|
|
106
|
+
N && (S.current && clearTimeout(S.current), S.current = setTimeout(() => {
|
|
107
|
+
var R;
|
|
108
|
+
S.current = null, (R = m.current) == null || R.abort(), m.current = null, v.current = !1, h("ready");
|
|
109
|
+
}, 8e3), a.stopGeneration(N).catch(() => {
|
|
110
|
+
}));
|
|
111
|
+
}, [a]), $ = C(() => {
|
|
112
|
+
if (v.current) return;
|
|
113
|
+
const N = c.findLastIndex((y) => y.role === "user");
|
|
114
|
+
if (N < 0) return;
|
|
115
|
+
const R = c[N].parts.filter((y) => y.type === "text").map((y) => y.content).join("");
|
|
116
|
+
p((y) => y.slice(0, N)), x(R);
|
|
117
|
+
}, [c, x]), P = C((N, R) => {
|
|
118
|
+
p(
|
|
119
|
+
(b) => b.map((H) => ({
|
|
120
|
+
...H,
|
|
121
|
+
parts: H.parts.map(
|
|
122
|
+
(j) => j.type === "interrupt" && j.interrupt.interruptId === N ? { ...j, resolved: !0, response: R } : j
|
|
123
123
|
)
|
|
124
124
|
}))
|
|
125
125
|
);
|
|
126
|
-
const
|
|
127
|
-
if (!
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
const j = () => {
|
|
137
|
-
const I = [...A];
|
|
138
|
-
if (R) {
|
|
139
|
-
const _ = I.findIndex((H) => H.type === "thinking");
|
|
140
|
-
_ >= 0 ? I[_] = { type: "thinking", content: R } : I.unshift({ type: "thinking", content: R });
|
|
126
|
+
const y = T.current;
|
|
127
|
+
if (!y) return;
|
|
128
|
+
let g = 0;
|
|
129
|
+
p((b) => b.length > 0 && b[b.length - 1].role === "assistant" ? (g = b[b.length - 1].parts.length, b) : (g = 0, [...b, { id: `assistant_${Date.now()}`, role: "assistant", parts: [], timestamp: Date.now() }])), h("streaming");
|
|
130
|
+
let E = "", L = "", k = [];
|
|
131
|
+
const O = () => {
|
|
132
|
+
const b = [...k];
|
|
133
|
+
if (E) {
|
|
134
|
+
const H = b.findIndex((j) => j.type === "thinking");
|
|
135
|
+
H >= 0 ? b[H] = { type: "thinking", content: E } : b.unshift({ type: "thinking", content: E });
|
|
141
136
|
}
|
|
142
|
-
if (
|
|
143
|
-
const
|
|
144
|
-
|
|
137
|
+
if (L) {
|
|
138
|
+
const H = b[b.length - 1];
|
|
139
|
+
(H == null ? void 0 : H.type) === "text" ? b[b.length - 1] = { type: "text", content: L } : b.push({ type: "text", content: L });
|
|
145
140
|
}
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
141
|
+
p((H) => {
|
|
142
|
+
const j = H.findLastIndex((W) => W.role === "assistant");
|
|
143
|
+
return j < 0 ? H : H.map(
|
|
144
|
+
(W, D) => D === j ? { ...W, parts: [...W.parts.slice(0, g), ...b] } : W
|
|
145
|
+
);
|
|
146
|
+
});
|
|
149
147
|
};
|
|
150
|
-
|
|
148
|
+
a.respondInterrupt(
|
|
149
|
+
N,
|
|
151
150
|
y,
|
|
152
|
-
|
|
153
|
-
b
|
|
154
|
-
|
|
155
|
-
switch (I.type) {
|
|
151
|
+
R,
|
|
152
|
+
(b) => {
|
|
153
|
+
switch (b.type) {
|
|
156
154
|
case "thinking":
|
|
157
|
-
|
|
155
|
+
E += b.content;
|
|
158
156
|
break;
|
|
159
157
|
case "ai":
|
|
160
|
-
|
|
158
|
+
L += b.content;
|
|
161
159
|
break;
|
|
162
160
|
case "tool_call":
|
|
163
|
-
|
|
161
|
+
L && (k.push({ type: "text", content: L }), L = ""), k.push({
|
|
164
162
|
type: "tool_call",
|
|
165
|
-
toolName:
|
|
166
|
-
toolCallId:
|
|
167
|
-
args:
|
|
163
|
+
toolName: b.toolName,
|
|
164
|
+
toolCallId: b.toolCallId,
|
|
165
|
+
args: b.args ?? "{}"
|
|
168
166
|
});
|
|
169
167
|
break;
|
|
170
168
|
case "tool_result":
|
|
171
|
-
|
|
169
|
+
L && (k.push({ type: "text", content: L }), L = ""), k.push({
|
|
172
170
|
type: "tool_result",
|
|
173
|
-
toolName:
|
|
174
|
-
toolCallId:
|
|
175
|
-
content:
|
|
176
|
-
artifacts:
|
|
177
|
-
renderMode:
|
|
178
|
-
html:
|
|
179
|
-
})
|
|
171
|
+
toolName: b.toolName ?? "",
|
|
172
|
+
toolCallId: b.toolCallId,
|
|
173
|
+
content: b.content,
|
|
174
|
+
artifacts: b.artifacts,
|
|
175
|
+
renderMode: b.renderMode,
|
|
176
|
+
html: b.html
|
|
177
|
+
});
|
|
180
178
|
break;
|
|
181
179
|
case "interrupt":
|
|
182
|
-
|
|
180
|
+
L && (k.push({ type: "text", content: L }), L = ""), b.interrupt && k.push({ type: "interrupt", interrupt: b.interrupt, resolved: !1 });
|
|
183
181
|
break;
|
|
184
182
|
case "done":
|
|
185
|
-
|
|
186
|
-
(_) => _.map((H) => H.id === C ? { ...H, id: I.messageId } : H)
|
|
187
|
-
), d("ready");
|
|
183
|
+
i == null || i(y), h("ready");
|
|
188
184
|
break;
|
|
189
185
|
}
|
|
190
|
-
|
|
186
|
+
O();
|
|
191
187
|
},
|
|
192
|
-
(
|
|
193
|
-
|
|
188
|
+
(b) => {
|
|
189
|
+
k.push({ type: "error", content: b.message }), O(), u(b), h("error"), o == null || o(b);
|
|
194
190
|
}
|
|
195
|
-
).catch((
|
|
196
|
-
o == null || o(
|
|
191
|
+
).catch((b) => {
|
|
192
|
+
o == null || o(b instanceof Error ? b : new Error(String(b))), h("error");
|
|
197
193
|
});
|
|
198
|
-
}, [
|
|
199
|
-
return { messages: c, status:
|
|
194
|
+
}, [a, o, i]);
|
|
195
|
+
return { messages: c, status: f, error: w, sendMessage: x, stop: z, regenerate: $, setMessages: p, respondToInterrupt: P };
|
|
200
196
|
}
|
|
201
|
-
const
|
|
202
|
-
function
|
|
197
|
+
const ie = "sa_active_conversation", Q = 20;
|
|
198
|
+
function ee(t) {
|
|
203
199
|
try {
|
|
204
|
-
return localStorage.getItem(
|
|
200
|
+
return localStorage.getItem(`${ie}_${t}`);
|
|
205
201
|
} catch {
|
|
206
202
|
return null;
|
|
207
203
|
}
|
|
208
204
|
}
|
|
209
|
-
function
|
|
205
|
+
function we(t, a) {
|
|
210
206
|
try {
|
|
211
|
-
|
|
207
|
+
const s = `${ie}_${t}`;
|
|
208
|
+
a ? localStorage.setItem(s, a) : localStorage.removeItem(s);
|
|
212
209
|
} catch {
|
|
213
210
|
}
|
|
214
211
|
}
|
|
215
|
-
function
|
|
216
|
-
const { sdk:
|
|
217
|
-
() =>
|
|
218
|
-
), [
|
|
212
|
+
function ye(t) {
|
|
213
|
+
const { sdk: a, onConversationChange: s } = t, n = a.botId, [r, i] = M([]), [o, l] = M(
|
|
214
|
+
() => ee(n)
|
|
215
|
+
), [c, p] = M(!1), [f, h] = M(!0), w = _(!0), u = _(1), m = _(!1);
|
|
219
216
|
B(() => () => {
|
|
220
|
-
|
|
217
|
+
w.current = !1;
|
|
221
218
|
}, []);
|
|
222
|
-
const
|
|
223
|
-
|
|
224
|
-
}, [s]),
|
|
225
|
-
if (!
|
|
226
|
-
|
|
219
|
+
const v = C((N) => {
|
|
220
|
+
l(N), we(n, N), N && (s == null || s(N));
|
|
221
|
+
}, [n, s]), S = C(async () => {
|
|
222
|
+
if (!m.current) {
|
|
223
|
+
m.current = !0, p(!0);
|
|
227
224
|
try {
|
|
228
|
-
|
|
229
|
-
const
|
|
230
|
-
if (!
|
|
231
|
-
|
|
232
|
-
const
|
|
233
|
-
|
|
225
|
+
u.current = 1;
|
|
226
|
+
const N = await a.listConversations({ page: 1, size: Q });
|
|
227
|
+
if (!w.current) return;
|
|
228
|
+
i(N.items), h(N.items.length < N.total);
|
|
229
|
+
const R = ee(n);
|
|
230
|
+
R && !N.items.find((y) => y.sessionId === R) && v(null);
|
|
234
231
|
} catch {
|
|
235
232
|
} finally {
|
|
236
|
-
|
|
233
|
+
m.current = !1, w.current && p(!1);
|
|
237
234
|
}
|
|
238
235
|
}
|
|
239
|
-
}, [
|
|
240
|
-
if (!(
|
|
241
|
-
|
|
236
|
+
}, [a, v]), T = C(async () => {
|
|
237
|
+
if (!(m.current || !f)) {
|
|
238
|
+
m.current = !0, p(!0);
|
|
242
239
|
try {
|
|
243
|
-
const
|
|
244
|
-
if (!
|
|
245
|
-
|
|
246
|
-
const
|
|
247
|
-
return [...
|
|
240
|
+
const N = u.current + 1, R = await a.listConversations({ page: N, size: Q });
|
|
241
|
+
if (!w.current) return;
|
|
242
|
+
u.current = N, i((g) => {
|
|
243
|
+
const E = new Set(g.map((k) => k.sessionId)), L = R.items.filter((k) => !E.has(k.sessionId));
|
|
244
|
+
return [...g, ...L];
|
|
248
245
|
});
|
|
249
|
-
const
|
|
250
|
-
|
|
246
|
+
const y = u.current * Q;
|
|
247
|
+
h(y < R.total);
|
|
251
248
|
} catch {
|
|
252
249
|
} finally {
|
|
253
|
-
|
|
250
|
+
m.current = !1, w.current && p(!1);
|
|
254
251
|
}
|
|
255
252
|
}
|
|
256
|
-
}, [
|
|
253
|
+
}, [a, f]), A = C(async (N) => (v(N), await a.getMessages(N)), [a, v]), x = C(async () => {
|
|
254
|
+
try {
|
|
255
|
+
const N = await a.createSession(), R = (/* @__PURE__ */ new Date()).toISOString();
|
|
256
|
+
i((y) => [
|
|
257
|
+
{ sessionId: N, botId: 0, title: "新对话", createTime: R, updateTime: R },
|
|
258
|
+
...y
|
|
259
|
+
]), v(N);
|
|
260
|
+
} catch {
|
|
261
|
+
v(null);
|
|
262
|
+
}
|
|
263
|
+
}, [a, v]), z = C(async (N) => {
|
|
264
|
+
i((R) => R.filter((y) => y.sessionId !== N)), o === N && v(null);
|
|
257
265
|
try {
|
|
258
|
-
|
|
259
|
-
a((v) => [
|
|
260
|
-
{ sessionId: y, botId: 0, title: "新对话", createTime: b, updateTime: b },
|
|
261
|
-
...v
|
|
262
|
-
]), x(y);
|
|
266
|
+
await a.deleteConversation(N);
|
|
263
267
|
} catch {
|
|
264
|
-
x(null);
|
|
265
268
|
}
|
|
266
|
-
}, [
|
|
267
|
-
await
|
|
268
|
-
|
|
269
|
-
await r.renameConversation(y, b), a(
|
|
270
|
-
(v) => v.map((C) => C.sessionId === y ? { ...C, title: b } : C)
|
|
269
|
+
}, [a, o, v]), $ = C(async (N, R) => {
|
|
270
|
+
await a.renameConversation(N, R), i(
|
|
271
|
+
(y) => y.map((g) => g.sessionId === N ? { ...g, title: R } : g)
|
|
271
272
|
);
|
|
272
|
-
}, [
|
|
273
|
+
}, [a]), { enabled: P = !0 } = t;
|
|
273
274
|
return B(() => {
|
|
274
|
-
|
|
275
|
-
}, [
|
|
276
|
-
conversations:
|
|
277
|
-
activeConversationId:
|
|
278
|
-
loading:
|
|
275
|
+
P && S();
|
|
276
|
+
}, [P, S]), {
|
|
277
|
+
conversations: r,
|
|
278
|
+
activeConversationId: o,
|
|
279
|
+
loading: c,
|
|
279
280
|
hasMore: f,
|
|
280
|
-
loadConversations:
|
|
281
|
+
loadConversations: S,
|
|
281
282
|
loadMore: T,
|
|
282
|
-
switchConversation:
|
|
283
|
-
newConversation:
|
|
284
|
-
deleteConversation:
|
|
285
|
-
renameConversation:
|
|
286
|
-
setActiveConversationId:
|
|
283
|
+
switchConversation: A,
|
|
284
|
+
newConversation: x,
|
|
285
|
+
deleteConversation: z,
|
|
286
|
+
renameConversation: $,
|
|
287
|
+
setActiveConversationId: v
|
|
287
288
|
};
|
|
288
289
|
}
|
|
289
|
-
function
|
|
290
|
+
function oe(t) {
|
|
290
291
|
return !t && t !== 0 ? "" : t < 1024 ? `${t} B` : t < 1024 * 1024 ? `${(t / 1024).toFixed(1)} KB` : `${(t / 1024 / 1024).toFixed(1)} MB`;
|
|
291
292
|
}
|
|
292
|
-
function
|
|
293
|
+
function le(t) {
|
|
293
294
|
return t === "pdf" ? "PDF" : t === "docx" ? "DOC" : t === "html" ? "HTM" : t.slice(0, 3).toUpperCase() || "FILE";
|
|
294
295
|
}
|
|
295
|
-
function
|
|
296
|
+
function ce(t) {
|
|
296
297
|
if (!t) return [];
|
|
297
|
-
const
|
|
298
|
+
const a = [];
|
|
298
299
|
for (const s of t)
|
|
299
|
-
s.type === "file" && s.data &&
|
|
300
|
+
s.type === "file" && s.data && a.push({
|
|
300
301
|
id: s.data.id ?? "",
|
|
301
302
|
type: s.data.fileType ?? s.data.type ?? "",
|
|
302
303
|
filename: s.data.name ?? s.data.filename ?? "",
|
|
@@ -305,112 +306,144 @@ function oe(t) {
|
|
|
305
306
|
size: s.data.size,
|
|
306
307
|
summary: s.data.summary
|
|
307
308
|
});
|
|
308
|
-
return
|
|
309
|
+
return a;
|
|
309
310
|
}
|
|
310
311
|
async function Z(t) {
|
|
311
312
|
try {
|
|
312
|
-
const
|
|
313
|
-
if (!
|
|
314
|
-
const s = await
|
|
315
|
-
|
|
313
|
+
const a = await fetch(t.url);
|
|
314
|
+
if (!a.ok) throw new Error(`HTTP ${a.status}`);
|
|
315
|
+
const s = await a.blob(), n = URL.createObjectURL(s), r = document.createElement("a");
|
|
316
|
+
r.href = n, r.download = t.filename, document.body.appendChild(r), r.click(), r.remove(), setTimeout(() => URL.revokeObjectURL(n), 4e3);
|
|
316
317
|
} catch {
|
|
317
|
-
const
|
|
318
|
-
|
|
318
|
+
const a = document.createElement("a");
|
|
319
|
+
a.href = t.url, a.download = t.filename, a.target = "_blank", document.body.appendChild(a), a.click(), a.remove();
|
|
319
320
|
}
|
|
320
321
|
}
|
|
321
|
-
const
|
|
322
|
-
function
|
|
323
|
-
const t =
|
|
322
|
+
const de = ge(null);
|
|
323
|
+
function Y() {
|
|
324
|
+
const t = xe(de);
|
|
324
325
|
if (!t) throw new Error("useChatContext must be used within ChatProvider");
|
|
325
326
|
return t;
|
|
326
327
|
}
|
|
327
|
-
function
|
|
328
|
-
const [n,
|
|
328
|
+
function te({ sdk: t, hooks: a, children: s }) {
|
|
329
|
+
const [n, r] = M(!1), [i, o] = M(!1), [l, c] = M(null), [p, f] = M(!1), [h, w] = M(!1);
|
|
329
330
|
B(() => {
|
|
330
331
|
t.getToken().then(() => {
|
|
331
|
-
|
|
332
|
+
f(!0);
|
|
332
333
|
}).catch(() => {
|
|
333
|
-
|
|
334
|
+
f(!0);
|
|
334
335
|
});
|
|
335
336
|
}, [t]);
|
|
336
|
-
const
|
|
337
|
+
const u = ye({
|
|
337
338
|
sdk: t,
|
|
338
|
-
onConversationChange:
|
|
339
|
-
enabled:
|
|
340
|
-
}), m =
|
|
339
|
+
onConversationChange: a == null ? void 0 : a.onConversationChange,
|
|
340
|
+
enabled: p
|
|
341
|
+
}), m = ve({
|
|
341
342
|
sdk: t,
|
|
342
|
-
sessionId:
|
|
343
|
-
onSessionCreated: (
|
|
344
|
-
|
|
343
|
+
sessionId: u.activeConversationId,
|
|
344
|
+
onSessionCreated: (g) => {
|
|
345
|
+
u.setActiveConversationId(g);
|
|
345
346
|
},
|
|
346
|
-
onStreamStart:
|
|
347
|
-
onStreamEnd: (
|
|
348
|
-
var
|
|
349
|
-
(
|
|
347
|
+
onStreamStart: a == null ? void 0 : a.onStreamStart,
|
|
348
|
+
onStreamEnd: (g) => {
|
|
349
|
+
var E;
|
|
350
|
+
(E = a == null ? void 0 : a.onStreamEnd) == null || E.call(a, g), u.loadConversations();
|
|
350
351
|
},
|
|
351
|
-
onError:
|
|
352
|
-
onMessageSend:
|
|
353
|
-
}),
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
352
|
+
onError: a == null ? void 0 : a.onError,
|
|
353
|
+
onMessageSend: a == null ? void 0 : a.onMessageSend
|
|
354
|
+
}), v = C(async (g) => {
|
|
355
|
+
w(!0);
|
|
356
|
+
try {
|
|
357
|
+
const E = await u.switchConversation(g);
|
|
358
|
+
m.setMessages(E), r(!1);
|
|
359
|
+
} finally {
|
|
360
|
+
w(!1);
|
|
361
|
+
}
|
|
362
|
+
}, [u, m]), S = C(async () => {
|
|
363
|
+
m.setMessages([]), r(!1), await u.newConversation();
|
|
364
|
+
}, [u, m]), T = C(async (g) => {
|
|
365
|
+
u.activeConversationId === g && m.setMessages([]), await u.deleteConversation(g);
|
|
366
|
+
}, [u, m]);
|
|
361
367
|
B(() => {
|
|
362
|
-
|
|
363
|
-
m.setMessages(
|
|
368
|
+
u.activeConversationId && m.messages.length === 0 && (w(!0), t.getMessages(u.activeConversationId).then((g) => {
|
|
369
|
+
m.setMessages(g);
|
|
364
370
|
}).catch(() => {
|
|
365
|
-
});
|
|
371
|
+
}).finally(() => w(!1)));
|
|
366
372
|
}, []);
|
|
367
|
-
const
|
|
368
|
-
|
|
369
|
-
}, []),
|
|
370
|
-
o((
|
|
371
|
-
}, []),
|
|
372
|
-
c(
|
|
373
|
-
}, []),
|
|
374
|
-
const
|
|
375
|
-
for (const
|
|
376
|
-
for (const
|
|
377
|
-
if (
|
|
378
|
-
for (const
|
|
379
|
-
const
|
|
380
|
-
|
|
373
|
+
const A = C(() => {
|
|
374
|
+
r((g) => !g);
|
|
375
|
+
}, []), x = C(() => {
|
|
376
|
+
o((g) => !g), c((g) => null);
|
|
377
|
+
}, []), z = C((g) => {
|
|
378
|
+
c(g), o(!0);
|
|
379
|
+
}, []), $ = J(() => {
|
|
380
|
+
const g = /* @__PURE__ */ new Set(), E = [];
|
|
381
|
+
for (const L of m.messages)
|
|
382
|
+
for (const k of L.parts)
|
|
383
|
+
if (k.type === "tool_result" && k.artifacts)
|
|
384
|
+
for (const O of ce(k.artifacts)) {
|
|
385
|
+
const b = O.id || `${O.url}:${O.filename}`;
|
|
386
|
+
g.has(b) || (g.add(b), E.push(O));
|
|
381
387
|
}
|
|
382
|
-
return
|
|
383
|
-
}, [m.messages]),
|
|
384
|
-
|
|
388
|
+
return E;
|
|
389
|
+
}, [m.messages]), P = C(async () => {
|
|
390
|
+
const g = u.activeConversationId;
|
|
391
|
+
if (!g) return null;
|
|
392
|
+
try {
|
|
393
|
+
const E = await t.getMessages(g);
|
|
394
|
+
m.setMessages(E);
|
|
395
|
+
const L = E.findLast((k) => k.role === "assistant");
|
|
396
|
+
return (L == null ? void 0 : L.id) ?? null;
|
|
397
|
+
} catch {
|
|
398
|
+
return null;
|
|
399
|
+
}
|
|
400
|
+
}, [t, u.activeConversationId, m]), N = C((g, E, L) => {
|
|
401
|
+
if (/^\d+$/.test(g)) {
|
|
402
|
+
t.feedback(g, E, L).catch(() => {
|
|
403
|
+
});
|
|
404
|
+
return;
|
|
405
|
+
}
|
|
406
|
+
P().then((k) => {
|
|
407
|
+
k && t.feedback(k, E, L).catch(() => {
|
|
408
|
+
});
|
|
385
409
|
});
|
|
386
|
-
}, [t]),
|
|
387
|
-
|
|
410
|
+
}, [t, P]), R = C((g) => {
|
|
411
|
+
if (/^\d+$/.test(g)) {
|
|
412
|
+
t.cancelFeedback(g).catch(() => {
|
|
413
|
+
});
|
|
414
|
+
return;
|
|
415
|
+
}
|
|
416
|
+
P().then((E) => {
|
|
417
|
+
E && t.cancelFeedback(E).catch(() => {
|
|
418
|
+
});
|
|
388
419
|
});
|
|
389
|
-
}, [t]), y =
|
|
420
|
+
}, [t, P]), y = J(() => ({
|
|
390
421
|
sdk: t,
|
|
391
422
|
status: m.status,
|
|
392
423
|
error: m.error,
|
|
393
424
|
messages: m.messages,
|
|
394
|
-
conversations:
|
|
395
|
-
activeConversationId:
|
|
425
|
+
conversations: u.conversations,
|
|
426
|
+
activeConversationId: u.activeConversationId,
|
|
396
427
|
isThreadListOpen: n,
|
|
397
428
|
isArtifactDrawerOpen: i,
|
|
398
|
-
allArtifacts:
|
|
429
|
+
allArtifacts: $,
|
|
399
430
|
activePreviewArtifact: l,
|
|
400
|
-
hasMore:
|
|
431
|
+
hasMore: u.hasMore,
|
|
432
|
+
conversationsLoading: u.loading,
|
|
433
|
+
messagesLoading: h,
|
|
401
434
|
sendMessage: m.sendMessage,
|
|
402
435
|
stop: m.stop,
|
|
403
436
|
regenerate: m.regenerate,
|
|
404
|
-
switchConversation:
|
|
405
|
-
newConversation:
|
|
406
|
-
deleteConversation:
|
|
407
|
-
renameConversation:
|
|
408
|
-
loadMoreConversations:
|
|
409
|
-
toggleThreadList:
|
|
410
|
-
toggleArtifactDrawer:
|
|
411
|
-
openArtifactPreview:
|
|
412
|
-
feedback:
|
|
413
|
-
cancelFeedback:
|
|
437
|
+
switchConversation: v,
|
|
438
|
+
newConversation: S,
|
|
439
|
+
deleteConversation: T,
|
|
440
|
+
renameConversation: u.renameConversation,
|
|
441
|
+
loadMoreConversations: u.loadMore,
|
|
442
|
+
toggleThreadList: A,
|
|
443
|
+
toggleArtifactDrawer: x,
|
|
444
|
+
openArtifactPreview: z,
|
|
445
|
+
feedback: N,
|
|
446
|
+
cancelFeedback: R,
|
|
414
447
|
respondToInterrupt: m.respondToInterrupt
|
|
415
448
|
}), [
|
|
416
449
|
t,
|
|
@@ -421,229 +454,234 @@ function ae({ sdk: t, hooks: r, children: s }) {
|
|
|
421
454
|
m.stop,
|
|
422
455
|
m.regenerate,
|
|
423
456
|
m.respondToInterrupt,
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
457
|
+
u.conversations,
|
|
458
|
+
u.activeConversationId,
|
|
459
|
+
u.renameConversation,
|
|
460
|
+
u.hasMore,
|
|
461
|
+
u.loadMore,
|
|
462
|
+
u.loading,
|
|
429
463
|
n,
|
|
430
464
|
i,
|
|
431
|
-
|
|
465
|
+
$,
|
|
432
466
|
l,
|
|
433
|
-
g,
|
|
434
|
-
x,
|
|
435
|
-
w,
|
|
436
|
-
T,
|
|
437
|
-
L,
|
|
438
|
-
E,
|
|
439
467
|
h,
|
|
440
|
-
|
|
468
|
+
v,
|
|
469
|
+
S,
|
|
470
|
+
T,
|
|
471
|
+
A,
|
|
472
|
+
x,
|
|
473
|
+
z,
|
|
474
|
+
N,
|
|
475
|
+
R
|
|
441
476
|
]);
|
|
442
|
-
return /* @__PURE__ */ e(
|
|
477
|
+
return /* @__PURE__ */ e(de.Provider, { value: y, children: s });
|
|
443
478
|
}
|
|
444
|
-
const
|
|
445
|
-
let
|
|
446
|
-
function
|
|
447
|
-
if (
|
|
448
|
-
|
|
449
|
-
const
|
|
450
|
-
if (
|
|
479
|
+
const ke = "https://at.alicdn.com/t/c/font_5210396_pffyg5g21kn.js";
|
|
480
|
+
let ae = !1;
|
|
481
|
+
function Ne(t = ke) {
|
|
482
|
+
if (ae || typeof document > "u") return;
|
|
483
|
+
ae = !0;
|
|
484
|
+
const a = t.split("?")[0].split("/").pop();
|
|
485
|
+
if (a && document.querySelector(`script[src*="${a}"]`)) return;
|
|
451
486
|
const s = document.createElement("script");
|
|
452
487
|
s.src = t, document.head.appendChild(s);
|
|
453
488
|
}
|
|
454
|
-
|
|
455
|
-
function
|
|
489
|
+
Ne();
|
|
490
|
+
function I({ name: t, size: a = 16, color: s = "currentColor", className: n, style: r }) {
|
|
456
491
|
return /* @__PURE__ */ e(
|
|
457
492
|
"svg",
|
|
458
493
|
{
|
|
459
494
|
className: n,
|
|
460
|
-
style: { width:
|
|
495
|
+
style: { width: a, height: a, fill: s, verticalAlign: "middle", ...r },
|
|
461
496
|
"aria-hidden": "true",
|
|
462
497
|
children: /* @__PURE__ */ e("use", { href: `#icon-${t}` })
|
|
463
498
|
}
|
|
464
499
|
);
|
|
465
500
|
}
|
|
466
|
-
function
|
|
467
|
-
return /* @__PURE__ */ e("button", { className: `sa-trigger ${t ? "sa-trigger-open" : ""}`, onClick:
|
|
501
|
+
function Ce({ isOpen: t, onClick: a }) {
|
|
502
|
+
return /* @__PURE__ */ e("button", { className: `sa-trigger ${t ? "sa-trigger-open" : ""}`, onClick: a, children: t ? /* @__PURE__ */ e(I, { name: "x", size: 24, color: "#fff" }) : /* @__PURE__ */ e(I, { name: "message-square", size: 24, color: "#fff" }) });
|
|
468
503
|
}
|
|
469
|
-
function
|
|
470
|
-
return /* @__PURE__ */
|
|
471
|
-
/* @__PURE__ */
|
|
504
|
+
function ze({ title: t, onClose: a, onToggleThreadList: s, showClose: n = !0, artifactCount: r = 0, onToggleArtifactDrawer: i }) {
|
|
505
|
+
return /* @__PURE__ */ d("div", { className: "sa-header", children: [
|
|
506
|
+
/* @__PURE__ */ d("div", { className: "sa-header-left", children: [
|
|
472
507
|
/* @__PURE__ */ e("div", { className: "sa-header-avatar", children: "A" }),
|
|
473
|
-
/* @__PURE__ */
|
|
508
|
+
/* @__PURE__ */ d("div", { className: "sa-header-info", children: [
|
|
474
509
|
/* @__PURE__ */ e("div", { className: "sa-header-title", children: t }),
|
|
475
510
|
/* @__PURE__ */ e("div", { className: "sa-header-status", children: "● Online" })
|
|
476
511
|
] })
|
|
477
512
|
] }),
|
|
478
|
-
/* @__PURE__ */
|
|
479
|
-
|
|
480
|
-
/* @__PURE__ */
|
|
513
|
+
/* @__PURE__ */ d("div", { className: "sa-header-actions", children: [
|
|
514
|
+
r > 0 && i && /* @__PURE__ */ d("button", { className: "sa-header-btn sa-header-btn-artifact", onClick: i, title: "会话产物", children: [
|
|
515
|
+
/* @__PURE__ */ d("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: [
|
|
481
516
|
/* @__PURE__ */ e("path", { d: "M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z" }),
|
|
482
517
|
/* @__PURE__ */ e("polyline", { points: "14 2 14 8 20 8" })
|
|
483
518
|
] }),
|
|
484
519
|
/* @__PURE__ */ e("span", { children: "产物" })
|
|
485
520
|
] }),
|
|
486
|
-
/* @__PURE__ */ e("button", { className: "sa-header-btn", onClick: s, title: "会话列表", children: /* @__PURE__ */ e(
|
|
487
|
-
n && /* @__PURE__ */ e("button", { className: "sa-header-btn", onClick:
|
|
521
|
+
/* @__PURE__ */ e("button", { className: "sa-header-btn", onClick: s, title: "会话列表", children: /* @__PURE__ */ e(I, { name: "menu", size: 16 }) }),
|
|
522
|
+
n && /* @__PURE__ */ e("button", { className: "sa-header-btn", onClick: a, title: "关闭", children: /* @__PURE__ */ e(I, { name: "x", size: 16 }) })
|
|
488
523
|
] })
|
|
489
524
|
] });
|
|
490
525
|
}
|
|
491
|
-
const
|
|
492
|
-
function
|
|
526
|
+
const G = (t) => String(t).padStart(2, "0");
|
|
527
|
+
function pe(t) {
|
|
493
528
|
if (!t) return "";
|
|
494
|
-
const
|
|
495
|
-
return isNaN(
|
|
529
|
+
const a = new Date(t);
|
|
530
|
+
return isNaN(a.getTime()) ? "" : `${a.getFullYear()}-${G(a.getMonth() + 1)}-${G(a.getDate())} ${G(a.getHours())}:${G(a.getMinutes())}:${G(a.getSeconds())}`;
|
|
496
531
|
}
|
|
497
|
-
function
|
|
498
|
-
const
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
).getTime(), n = s - 6 * 864e5,
|
|
532
|
+
function Ie(t) {
|
|
533
|
+
const a = /* @__PURE__ */ new Date(), s = new Date(
|
|
534
|
+
a.getFullYear(),
|
|
535
|
+
a.getMonth(),
|
|
536
|
+
a.getDate()
|
|
537
|
+
).getTime(), n = s - 6 * 864e5, r = [], i = [], o = [];
|
|
503
538
|
for (const c of t) {
|
|
504
|
-
const
|
|
505
|
-
|
|
539
|
+
const p = new Date(c.updateTime).getTime();
|
|
540
|
+
p >= s ? r.push(c) : p >= n ? i.push(c) : o.push(c);
|
|
506
541
|
}
|
|
507
542
|
const l = [];
|
|
508
|
-
return
|
|
543
|
+
return r.length && l.push({ label: "今天", items: r }), i.length && l.push({ label: "最近 7 天", items: i }), o.length && l.push({ label: "更早", items: o }), l;
|
|
509
544
|
}
|
|
510
|
-
function
|
|
545
|
+
function Se() {
|
|
511
546
|
const {
|
|
512
547
|
conversations: t,
|
|
513
|
-
activeConversationId:
|
|
548
|
+
activeConversationId: a,
|
|
514
549
|
switchConversation: s,
|
|
515
550
|
newConversation: n,
|
|
516
|
-
deleteConversation:
|
|
551
|
+
deleteConversation: r,
|
|
517
552
|
renameConversation: i,
|
|
518
553
|
isThreadListOpen: o,
|
|
519
554
|
toggleThreadList: l,
|
|
520
555
|
hasMore: c,
|
|
521
|
-
loadMoreConversations:
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
556
|
+
loadMoreConversations: p,
|
|
557
|
+
conversationsLoading: f
|
|
558
|
+
} = Y(), [h, w] = M(null), [u, m] = M(""), v = _(null), S = C(
|
|
559
|
+
(z, $) => {
|
|
560
|
+
w(z), m($ ?? "");
|
|
525
561
|
},
|
|
526
562
|
[]
|
|
527
|
-
), T =
|
|
528
|
-
(
|
|
529
|
-
|
|
563
|
+
), T = C(
|
|
564
|
+
(z) => {
|
|
565
|
+
u.trim() && i(z, u.trim()), w(null);
|
|
530
566
|
},
|
|
531
|
-
[
|
|
532
|
-
),
|
|
533
|
-
const
|
|
534
|
-
!
|
|
535
|
-
}, [c,
|
|
536
|
-
return o ? /* @__PURE__ */
|
|
567
|
+
[u, i]
|
|
568
|
+
), A = C(() => {
|
|
569
|
+
const z = v.current;
|
|
570
|
+
!z || !c || z.scrollHeight - z.scrollTop - z.clientHeight < 50 && p();
|
|
571
|
+
}, [c, p]), x = J(() => Ie(t), [t]);
|
|
572
|
+
return o ? /* @__PURE__ */ d(q, { children: [
|
|
537
573
|
/* @__PURE__ */ e("div", { className: "sa-thread-list-overlay", onClick: l }),
|
|
538
|
-
/* @__PURE__ */
|
|
539
|
-
/* @__PURE__ */
|
|
574
|
+
/* @__PURE__ */ d("div", { className: "sa-thread-list", children: [
|
|
575
|
+
/* @__PURE__ */ d("div", { className: "sa-thread-list-header", children: [
|
|
540
576
|
/* @__PURE__ */ e("span", { className: "sa-thread-list-title", children: "会话记录" }),
|
|
541
|
-
/* @__PURE__ */
|
|
542
|
-
/* @__PURE__ */ e(
|
|
577
|
+
/* @__PURE__ */ d("button", { className: "sa-thread-list-new", onClick: n, children: [
|
|
578
|
+
/* @__PURE__ */ e(I, { name: "plus", size: 14 }),
|
|
543
579
|
" 新会话"
|
|
544
580
|
] })
|
|
545
581
|
] }),
|
|
546
|
-
/* @__PURE__ */
|
|
582
|
+
/* @__PURE__ */ d(
|
|
547
583
|
"div",
|
|
548
584
|
{
|
|
549
585
|
className: "sa-thread-list-items",
|
|
550
|
-
ref:
|
|
551
|
-
onScroll:
|
|
586
|
+
ref: v,
|
|
587
|
+
onScroll: A,
|
|
552
588
|
children: [
|
|
553
|
-
t.length === 0 && /* @__PURE__ */ e("div", { className: "sa-thread-list-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
589
|
+
f && t.length === 0 && /* @__PURE__ */ e("div", { className: "sa-thread-list-loading", children: "加载中..." }),
|
|
590
|
+
!f && t.length === 0 && /* @__PURE__ */ e("div", { className: "sa-thread-list-empty", children: "暂无会话" }),
|
|
591
|
+
x.map((z) => /* @__PURE__ */ d("div", { className: "sa-thread-group", children: [
|
|
592
|
+
/* @__PURE__ */ e("div", { className: "sa-thread-group-label", children: z.label }),
|
|
593
|
+
z.items.map(($) => /* @__PURE__ */ d(
|
|
557
594
|
"div",
|
|
558
595
|
{
|
|
559
|
-
className: `sa-thread-item ${
|
|
596
|
+
className: `sa-thread-item ${$.sessionId === a ? "active" : ""}`,
|
|
560
597
|
onClick: () => {
|
|
561
|
-
|
|
598
|
+
h !== $.sessionId && s($.sessionId);
|
|
562
599
|
},
|
|
563
600
|
children: [
|
|
564
|
-
|
|
601
|
+
h === $.sessionId ? /* @__PURE__ */ e(
|
|
565
602
|
"input",
|
|
566
603
|
{
|
|
567
604
|
className: "sa-thread-item-edit",
|
|
568
|
-
value:
|
|
569
|
-
onChange: (
|
|
570
|
-
onBlur: () => T(
|
|
571
|
-
onKeyDown: (
|
|
572
|
-
|
|
605
|
+
value: u,
|
|
606
|
+
onChange: (P) => m(P.target.value),
|
|
607
|
+
onBlur: () => T($.sessionId),
|
|
608
|
+
onKeyDown: (P) => {
|
|
609
|
+
P.key === "Enter" && T($.sessionId), P.key === "Escape" && w(null);
|
|
573
610
|
},
|
|
574
|
-
onClick: (
|
|
611
|
+
onClick: (P) => P.stopPropagation(),
|
|
575
612
|
autoFocus: !0
|
|
576
613
|
}
|
|
577
|
-
) : /* @__PURE__ */
|
|
578
|
-
/* @__PURE__ */ e("span", { className: "sa-thread-item-title", children:
|
|
579
|
-
/* @__PURE__ */ e("span", { className: "sa-thread-item-time", children:
|
|
614
|
+
) : /* @__PURE__ */ d("div", { className: "sa-thread-item-info", children: [
|
|
615
|
+
/* @__PURE__ */ e("span", { className: "sa-thread-item-title", children: $.title || "新会话" }),
|
|
616
|
+
/* @__PURE__ */ e("span", { className: "sa-thread-item-time", children: pe($.updateTime) })
|
|
580
617
|
] }),
|
|
581
|
-
/* @__PURE__ */
|
|
618
|
+
/* @__PURE__ */ d("div", { className: "sa-thread-item-actions", children: [
|
|
582
619
|
/* @__PURE__ */ e(
|
|
583
620
|
"button",
|
|
584
621
|
{
|
|
585
622
|
className: "sa-thread-item-action-btn",
|
|
586
|
-
onClick: (
|
|
587
|
-
|
|
623
|
+
onClick: (P) => {
|
|
624
|
+
P.stopPropagation(), S($.sessionId, $.title);
|
|
588
625
|
},
|
|
589
626
|
title: "重命名",
|
|
590
|
-
children: /* @__PURE__ */ e(
|
|
627
|
+
children: /* @__PURE__ */ e(I, { name: "pen", size: 13 })
|
|
591
628
|
}
|
|
592
629
|
),
|
|
593
630
|
/* @__PURE__ */ e(
|
|
594
631
|
"button",
|
|
595
632
|
{
|
|
596
633
|
className: "sa-thread-item-action-btn",
|
|
597
|
-
onClick: (
|
|
598
|
-
|
|
634
|
+
onClick: (P) => {
|
|
635
|
+
P.stopPropagation(), r($.sessionId);
|
|
599
636
|
},
|
|
600
637
|
title: "删除",
|
|
601
|
-
children: /* @__PURE__ */ e(
|
|
638
|
+
children: /* @__PURE__ */ e(I, { name: "trash2", size: 13 })
|
|
602
639
|
}
|
|
603
640
|
)
|
|
604
641
|
] })
|
|
605
642
|
]
|
|
606
643
|
},
|
|
607
|
-
|
|
644
|
+
$.sessionId
|
|
608
645
|
))
|
|
609
|
-
] },
|
|
610
|
-
|
|
646
|
+
] }, z.label)),
|
|
647
|
+
f && t.length > 0 && /* @__PURE__ */ e("div", { className: "sa-thread-list-loading", children: c ? "加载更多..." : "加载中..." }),
|
|
648
|
+
!f && c && /* @__PURE__ */ e("div", { className: "sa-thread-list-hint", children: "向下滚动加载更多" })
|
|
611
649
|
]
|
|
612
650
|
}
|
|
613
651
|
)
|
|
614
652
|
] })
|
|
615
653
|
] }) : null;
|
|
616
654
|
}
|
|
617
|
-
function
|
|
618
|
-
const
|
|
619
|
-
const o =
|
|
655
|
+
function Te(t) {
|
|
656
|
+
const a = _(null), s = _(!1), n = _(0), r = C(() => {
|
|
657
|
+
const o = a.current;
|
|
620
658
|
if (!o) return;
|
|
621
|
-
const { scrollTop: l, scrollHeight: c, clientHeight:
|
|
622
|
-
l < n.current && !
|
|
659
|
+
const { scrollTop: l, scrollHeight: c, clientHeight: p } = o, f = c - l - p < 40;
|
|
660
|
+
l < n.current && !f && (s.current = !0), f && (s.current = !1), n.current = l;
|
|
623
661
|
}, []);
|
|
624
662
|
B(() => {
|
|
625
|
-
const o =
|
|
663
|
+
const o = a.current;
|
|
626
664
|
if (o)
|
|
627
|
-
return o.addEventListener("scroll",
|
|
628
|
-
}, [
|
|
665
|
+
return o.addEventListener("scroll", r, { passive: !0 }), () => o.removeEventListener("scroll", r);
|
|
666
|
+
}, [r]), B(() => {
|
|
629
667
|
if (s.current) return;
|
|
630
|
-
const o =
|
|
668
|
+
const o = a.current;
|
|
631
669
|
o && requestAnimationFrame(() => {
|
|
632
670
|
o.scrollTop = o.scrollHeight;
|
|
633
671
|
});
|
|
634
672
|
}, t);
|
|
635
|
-
const i =
|
|
673
|
+
const i = C(() => {
|
|
636
674
|
s.current = !1;
|
|
637
|
-
const o =
|
|
675
|
+
const o = a.current;
|
|
638
676
|
o && (o.scrollTop = o.scrollHeight);
|
|
639
677
|
}, []);
|
|
640
|
-
return { containerRef:
|
|
678
|
+
return { containerRef: a, scrollToBottom: i };
|
|
641
679
|
}
|
|
642
680
|
function K(t) {
|
|
643
681
|
return t.value++;
|
|
644
682
|
}
|
|
645
|
-
function
|
|
646
|
-
const s = [], n = [],
|
|
683
|
+
function X(t, a) {
|
|
684
|
+
const s = [], n = [], r = () => {
|
|
647
685
|
n.length > 0 && (s.push(n.join("")), n.length = 0);
|
|
648
686
|
};
|
|
649
687
|
let i = 0;
|
|
@@ -652,24 +690,24 @@ function q(t, r) {
|
|
|
652
690
|
if (o === "`") {
|
|
653
691
|
const l = t.indexOf("`", i + 1);
|
|
654
692
|
if (l !== -1) {
|
|
655
|
-
|
|
656
|
-
/* @__PURE__ */ e("code", { className: "sa-inline-code", children: t.slice(i + 1, l) }, K(
|
|
693
|
+
r(), s.push(
|
|
694
|
+
/* @__PURE__ */ e("code", { className: "sa-inline-code", children: t.slice(i + 1, l) }, K(a))
|
|
657
695
|
), i = l + 1;
|
|
658
696
|
continue;
|
|
659
697
|
}
|
|
660
698
|
} else if (o === "*" && t[i + 1] === "*") {
|
|
661
699
|
const l = t.indexOf("**", i + 2);
|
|
662
700
|
if (l !== -1) {
|
|
663
|
-
|
|
664
|
-
/* @__PURE__ */ e("strong", { children:
|
|
701
|
+
r(), s.push(
|
|
702
|
+
/* @__PURE__ */ e("strong", { children: X(t.slice(i + 2, l), a) }, K(a))
|
|
665
703
|
), i = l + 2;
|
|
666
704
|
continue;
|
|
667
705
|
}
|
|
668
706
|
} else if (o === "*") {
|
|
669
707
|
const l = t.indexOf("*", i + 1);
|
|
670
708
|
if (l !== -1) {
|
|
671
|
-
|
|
672
|
-
/* @__PURE__ */ e("em", { children:
|
|
709
|
+
r(), s.push(
|
|
710
|
+
/* @__PURE__ */ e("em", { children: X(t.slice(i + 1, l), a) }, K(a))
|
|
673
711
|
), i = l + 1;
|
|
674
712
|
continue;
|
|
675
713
|
}
|
|
@@ -678,17 +716,17 @@ function q(t, r) {
|
|
|
678
716
|
if (l !== -1 && t[l + 1] === "(") {
|
|
679
717
|
const c = t.indexOf(")", l + 2);
|
|
680
718
|
if (c !== -1) {
|
|
681
|
-
const
|
|
682
|
-
|
|
719
|
+
const p = t.slice(i + 1, l), f = t.slice(l + 2, c);
|
|
720
|
+
r(), s.push(
|
|
683
721
|
/* @__PURE__ */ e(
|
|
684
722
|
"a",
|
|
685
723
|
{
|
|
686
|
-
href:
|
|
724
|
+
href: f,
|
|
687
725
|
target: "_blank",
|
|
688
726
|
rel: "noreferrer",
|
|
689
|
-
children:
|
|
727
|
+
children: X(p, a)
|
|
690
728
|
},
|
|
691
|
-
K(
|
|
729
|
+
K(a)
|
|
692
730
|
)
|
|
693
731
|
), i = c + 1;
|
|
694
732
|
continue;
|
|
@@ -697,164 +735,172 @@ function q(t, r) {
|
|
|
697
735
|
}
|
|
698
736
|
n.push(o), i++;
|
|
699
737
|
}
|
|
700
|
-
return
|
|
738
|
+
return r(), s;
|
|
701
739
|
}
|
|
702
|
-
function
|
|
740
|
+
function Me(t, a) {
|
|
703
741
|
const s = [], n = t.split(`
|
|
704
742
|
`);
|
|
705
|
-
let
|
|
743
|
+
let r = 0;
|
|
706
744
|
const i = (c) => c.trim() === "", o = (c) => /^#{1,6}\s+\S/.test(c.trim()), l = (c) => /^(?:[-*+]|\d+[.)])\s+\S/.test(c.trim());
|
|
707
|
-
for (;
|
|
708
|
-
const c = n[
|
|
745
|
+
for (; r < n.length; ) {
|
|
746
|
+
const c = n[r], p = c.trim();
|
|
709
747
|
if (i(c)) {
|
|
710
|
-
|
|
748
|
+
r++;
|
|
711
749
|
continue;
|
|
712
750
|
}
|
|
713
751
|
if (o(c)) {
|
|
714
|
-
const
|
|
715
|
-
if (
|
|
716
|
-
const
|
|
752
|
+
const h = p.match(/^(#{1,6})\s+(.*)$/);
|
|
753
|
+
if (h) {
|
|
754
|
+
const u = `h${Math.min(h[1].length, 6)}`;
|
|
717
755
|
s.push(
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
{ key: K(
|
|
721
|
-
|
|
756
|
+
V.createElement(
|
|
757
|
+
u,
|
|
758
|
+
{ key: K(a) },
|
|
759
|
+
X(h[2], a)
|
|
722
760
|
)
|
|
723
761
|
);
|
|
724
762
|
}
|
|
725
|
-
|
|
763
|
+
r++;
|
|
726
764
|
continue;
|
|
727
765
|
}
|
|
728
766
|
if (l(c)) {
|
|
729
|
-
const
|
|
730
|
-
for (;
|
|
731
|
-
const
|
|
732
|
-
|
|
733
|
-
/* @__PURE__ */ e("li", { children:
|
|
734
|
-
),
|
|
767
|
+
const h = /^\d+[.)]/.test(p), w = [];
|
|
768
|
+
for (; r < n.length && l(n[r]); ) {
|
|
769
|
+
const u = n[r].trim().match(/^(?:[-*+]|\d+[.)])\s+(.*)$/);
|
|
770
|
+
u && w.push(
|
|
771
|
+
/* @__PURE__ */ e("li", { children: X(u[1], a) }, K(a))
|
|
772
|
+
), r++;
|
|
735
773
|
}
|
|
736
774
|
s.push(
|
|
737
|
-
|
|
775
|
+
h ? /* @__PURE__ */ e("ol", { className: "sa-list", children: w }, K(a)) : /* @__PURE__ */ e("ul", { className: "sa-list", children: w }, K(a))
|
|
738
776
|
);
|
|
739
777
|
continue;
|
|
740
778
|
}
|
|
741
|
-
const
|
|
742
|
-
for (;
|
|
743
|
-
|
|
779
|
+
const f = [];
|
|
780
|
+
for (; r < n.length && !i(n[r]) && !o(n[r]) && !l(n[r]); )
|
|
781
|
+
f.push(n[r]), r++;
|
|
744
782
|
s.push(
|
|
745
|
-
/* @__PURE__ */ e("p", { className: "sa-text-paragraph", children:
|
|
783
|
+
/* @__PURE__ */ e("p", { className: "sa-text-paragraph", children: X(f.join(" "), a) }, K(a))
|
|
746
784
|
);
|
|
747
785
|
}
|
|
748
786
|
return s;
|
|
749
787
|
}
|
|
750
|
-
function
|
|
751
|
-
const
|
|
752
|
-
for (let
|
|
753
|
-
if (
|
|
754
|
-
s.push(...
|
|
755
|
-
else if (n[
|
|
756
|
-
let i = n[
|
|
788
|
+
function $e(t) {
|
|
789
|
+
const a = { value: 0 }, s = [], n = t.split("```");
|
|
790
|
+
for (let r = 0; r < n.length; r++)
|
|
791
|
+
if (r % 2 === 0)
|
|
792
|
+
s.push(...Me(n[r], a));
|
|
793
|
+
else if (n[r].trim() !== "") {
|
|
794
|
+
let i = n[r].replace(/^\r?\n/, "");
|
|
757
795
|
i = i.replace(/^[a-zA-Z0-9_+#.-]+\r?\n/, ""), i = i.replace(/\r?\n$/, ""), s.push(
|
|
758
|
-
/* @__PURE__ */ e("pre", { className: "sa-code-block", children: /* @__PURE__ */ e("code", { children: i }) }, K(
|
|
796
|
+
/* @__PURE__ */ e("pre", { className: "sa-code-block", children: /* @__PURE__ */ e("code", { children: i }) }, K(a))
|
|
759
797
|
);
|
|
760
798
|
}
|
|
761
799
|
return s;
|
|
762
800
|
}
|
|
763
|
-
function
|
|
764
|
-
return /* @__PURE__ */ e("div", { className: "sa-text-part", children:
|
|
801
|
+
function De({ content: t }) {
|
|
802
|
+
return /* @__PURE__ */ e("div", { className: "sa-text-part", children: $e(t) });
|
|
765
803
|
}
|
|
766
|
-
function
|
|
767
|
-
const [
|
|
768
|
-
return /* @__PURE__ */
|
|
769
|
-
/* @__PURE__ */
|
|
770
|
-
/* @__PURE__ */ e("span", { className: "sa-thinking-icon", children: /* @__PURE__ */ e(
|
|
804
|
+
function Le({ content: t }) {
|
|
805
|
+
const [a, s] = M(!1);
|
|
806
|
+
return /* @__PURE__ */ d("div", { className: "sa-thinking-part", onClick: () => s(!a), children: [
|
|
807
|
+
/* @__PURE__ */ d("div", { className: "sa-thinking-header", children: [
|
|
808
|
+
/* @__PURE__ */ e("span", { className: "sa-thinking-icon", children: /* @__PURE__ */ e(I, { name: "brain", size: 14 }) }),
|
|
771
809
|
/* @__PURE__ */ e("span", { className: "sa-thinking-label", children: "思考过程" }),
|
|
772
|
-
/* @__PURE__ */ e("span", { className: `sa-thinking-arrow ${
|
|
810
|
+
/* @__PURE__ */ e("span", { className: `sa-thinking-arrow ${a ? "expanded" : ""}`, children: /* @__PURE__ */ e(I, { name: "chevron-right", size: 12 }) })
|
|
773
811
|
] }),
|
|
774
|
-
|
|
812
|
+
a && /* @__PURE__ */ e("div", { className: "sa-thinking-content", children: t })
|
|
775
813
|
] });
|
|
776
814
|
}
|
|
777
|
-
function
|
|
778
|
-
const [n,
|
|
779
|
-
let
|
|
815
|
+
function Ee({ toolName: t, toolCallId: a, args: s }) {
|
|
816
|
+
const [n, r] = M(!1), [i, o] = M(!1);
|
|
817
|
+
let l = s;
|
|
780
818
|
try {
|
|
781
|
-
|
|
819
|
+
l = JSON.stringify(JSON.parse(s), null, 2);
|
|
782
820
|
} catch {
|
|
783
821
|
}
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
822
|
+
const c = C(() => {
|
|
823
|
+
var p;
|
|
824
|
+
(p = navigator.clipboard) == null || p.writeText(l).then(() => {
|
|
825
|
+
o(!0), setTimeout(() => o(!1), 2e3);
|
|
826
|
+
}).catch(() => {
|
|
827
|
+
});
|
|
828
|
+
}, [l]);
|
|
829
|
+
return /* @__PURE__ */ d("div", { className: "sa-tool-call-part", children: [
|
|
830
|
+
/* @__PURE__ */ d("div", { className: "sa-tool-call-header", onClick: () => r(!n), children: [
|
|
831
|
+
/* @__PURE__ */ e("span", { className: "sa-tool-icon", children: /* @__PURE__ */ e(I, { name: "zap", size: 14 }) }),
|
|
832
|
+
/* @__PURE__ */ d("span", { className: "sa-tool-name", children: [
|
|
788
833
|
"调用工具: ",
|
|
789
834
|
t
|
|
790
835
|
] }),
|
|
791
|
-
/* @__PURE__ */ e("span", { className: `sa-thinking-arrow ${n ? "expanded" : ""}`, children: /* @__PURE__ */ e(
|
|
836
|
+
/* @__PURE__ */ e("span", { className: `sa-thinking-arrow ${n ? "expanded" : ""}`, children: /* @__PURE__ */ e(I, { name: "chevron-right", size: 12 }) })
|
|
792
837
|
] }),
|
|
793
|
-
n && /* @__PURE__ */
|
|
838
|
+
n && /* @__PURE__ */ d(q, { children: [
|
|
839
|
+
/* @__PURE__ */ e("pre", { className: "sa-tool-args", children: l }),
|
|
840
|
+
/* @__PURE__ */ e("div", { className: "sa-tool-result-actions", children: /* @__PURE__ */ d("button", { className: "sa-action-btn", onClick: c, title: "复制", children: [
|
|
841
|
+
/* @__PURE__ */ e(I, { name: i ? "circle-check" : "copy", size: 14 }),
|
|
842
|
+
" ",
|
|
843
|
+
i ? "已复制" : "复制"
|
|
844
|
+
] }) })
|
|
845
|
+
] })
|
|
794
846
|
] });
|
|
795
847
|
}
|
|
796
|
-
function
|
|
797
|
-
const [
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
848
|
+
function re({ text: t }) {
|
|
849
|
+
const [a, s] = M(!1);
|
|
850
|
+
return /* @__PURE__ */ d("button", { className: "sa-action-btn", onClick: () => {
|
|
851
|
+
var r;
|
|
852
|
+
(r = navigator.clipboard) == null || r.writeText(t).then(() => {
|
|
853
|
+
s(!0), setTimeout(() => s(!1), 2e3);
|
|
854
|
+
}).catch(() => {
|
|
855
|
+
});
|
|
856
|
+
}, title: "复制", children: [
|
|
857
|
+
/* @__PURE__ */ e(I, { name: a ? "circle-check" : "copy", size: 14 }),
|
|
858
|
+
" ",
|
|
859
|
+
a ? "已复制" : "复制"
|
|
860
|
+
] });
|
|
861
|
+
}
|
|
862
|
+
function Ae({ html: t }) {
|
|
863
|
+
const [a, s] = M(null);
|
|
864
|
+
return B(() => {
|
|
865
|
+
let n = !1;
|
|
866
|
+
return import("./purify.es-C-6FFqDW.js").then((r) => {
|
|
867
|
+
n || s(r.default.sanitize(t, { FORCE_BODY: !0, ADD_ATTR: ["target"] }));
|
|
802
868
|
}), () => {
|
|
803
|
-
|
|
869
|
+
n = !0;
|
|
804
870
|
};
|
|
805
|
-
}, [t]);
|
|
806
|
-
const a = Y.useCallback(() => {
|
|
807
|
-
var o;
|
|
808
|
-
const i = n.current;
|
|
809
|
-
if (i)
|
|
810
|
-
try {
|
|
811
|
-
const l = i.contentDocument || ((o = i.contentWindow) == null ? void 0 : o.document);
|
|
812
|
-
if (!(l != null && l.body)) return;
|
|
813
|
-
const c = l.body.scrollHeight;
|
|
814
|
-
i.style.height = Math.min(c, 500) + "px";
|
|
815
|
-
} catch {
|
|
816
|
-
}
|
|
817
|
-
}, []);
|
|
818
|
-
return B(() => {
|
|
819
|
-
const i = n.current;
|
|
820
|
-
if (!(!i || r === null))
|
|
821
|
-
return i.addEventListener("load", a), () => i.removeEventListener("load", a);
|
|
822
|
-
}, [r, a]), r === null ? null : /* @__PURE__ */ e("div", { className: "sa-tool-result-html", children: /* @__PURE__ */ e(
|
|
823
|
-
"iframe",
|
|
824
|
-
{
|
|
825
|
-
ref: n,
|
|
826
|
-
srcDoc: r,
|
|
827
|
-
className: "sa-tool-result-html-iframe",
|
|
828
|
-
sandbox: "allow-same-origin",
|
|
829
|
-
title: "HTML 产物"
|
|
830
|
-
}
|
|
831
|
-
) });
|
|
871
|
+
}, [t]), a === null ? null : /* @__PURE__ */ e("div", { className: "sa-tool-result-html-scroll", children: /* @__PURE__ */ e("div", { className: "sa-tool-result-html sa-text-part", dangerouslySetInnerHTML: { __html: a } }) });
|
|
832
872
|
}
|
|
833
|
-
function
|
|
834
|
-
const { openArtifactPreview: o } =
|
|
835
|
-
return /* @__PURE__ */
|
|
836
|
-
/* @__PURE__ */
|
|
837
|
-
/* @__PURE__ */ e("span", { className: "sa-tool-icon", children: /* @__PURE__ */ e(
|
|
873
|
+
function Re({ toolName: t, content: a, artifacts: s, renderMode: n, html: r, artifactPreview: i }) {
|
|
874
|
+
const { openArtifactPreview: o } = Y(), l = ce(s);
|
|
875
|
+
return /* @__PURE__ */ d("div", { className: "sa-tool-result-part", children: [
|
|
876
|
+
/* @__PURE__ */ d("div", { className: "sa-tool-result-header", children: [
|
|
877
|
+
/* @__PURE__ */ e("span", { className: "sa-tool-icon", children: /* @__PURE__ */ e(I, { name: "circle-check", size: 14, color: "#10b981" }) }),
|
|
838
878
|
/* @__PURE__ */ e("span", { className: "sa-tool-result-label", children: t || "工具返回" })
|
|
839
879
|
] }),
|
|
840
|
-
n === "html" &&
|
|
841
|
-
|
|
880
|
+
n === "html" && r ? /* @__PURE__ */ d(q, { children: [
|
|
881
|
+
/* @__PURE__ */ e(Ae, { html: r }),
|
|
882
|
+
/* @__PURE__ */ e("div", { className: "sa-tool-result-actions", children: /* @__PURE__ */ e(re, { text: r }) })
|
|
883
|
+
] }) : a ? /* @__PURE__ */ d(q, { children: [
|
|
884
|
+
/* @__PURE__ */ e("pre", { className: "sa-tool-result-content", children: a }),
|
|
885
|
+
/* @__PURE__ */ e("div", { className: "sa-tool-result-actions", children: /* @__PURE__ */ e(re, { text: a }) })
|
|
886
|
+
] }) : /* @__PURE__ */ e("pre", { className: "sa-tool-result-content", children: "—" }),
|
|
887
|
+
l.length > 0 && /* @__PURE__ */ e("ul", { className: "sa-artifact-file-list", role: "list", children: l.map((c, p) => /* @__PURE__ */ d(
|
|
842
888
|
"li",
|
|
843
889
|
{
|
|
844
890
|
className: "sa-artifact-file-card",
|
|
845
891
|
onClick: i ? () => o(c) : void 0,
|
|
846
|
-
onKeyDown: i ? (
|
|
847
|
-
(
|
|
892
|
+
onKeyDown: i ? (f) => {
|
|
893
|
+
(f.key === "Enter" || f.key === " ") && (f.preventDefault(), o(c));
|
|
848
894
|
} : void 0,
|
|
849
895
|
tabIndex: i ? 0 : void 0,
|
|
850
896
|
role: i ? "button" : void 0,
|
|
851
897
|
"aria-label": i ? `预览 ${c.filename}` : void 0,
|
|
852
898
|
style: i ? { cursor: "pointer" } : void 0,
|
|
853
899
|
children: [
|
|
854
|
-
/* @__PURE__ */ e("div", { className: "sa-artifact-file-icon", children: /* @__PURE__ */ e("span", { className: "sa-artifact-chip-type", children:
|
|
855
|
-
/* @__PURE__ */
|
|
900
|
+
/* @__PURE__ */ e("div", { className: "sa-artifact-file-icon", children: /* @__PURE__ */ e("span", { className: "sa-artifact-chip-type", children: le(c.type) }) }),
|
|
901
|
+
/* @__PURE__ */ d("div", { className: "sa-artifact-file-info", children: [
|
|
856
902
|
/* @__PURE__ */ e("span", { className: "sa-artifact-file-name", children: c.filename }),
|
|
857
|
-
c.size != null && /* @__PURE__ */ e("span", { className: "sa-artifact-file-size", children:
|
|
903
|
+
c.size != null && /* @__PURE__ */ e("span", { className: "sa-artifact-file-size", children: oe(c.size) })
|
|
858
904
|
] }),
|
|
859
905
|
i && /* @__PURE__ */ e(
|
|
860
906
|
"button",
|
|
@@ -862,57 +908,57 @@ function Ee({ toolName: t, content: r, artifacts: s, renderMode: n, html: a, art
|
|
|
862
908
|
className: "sa-artifact-file-download",
|
|
863
909
|
title: "下载",
|
|
864
910
|
"aria-label": `下载 ${c.filename}`,
|
|
865
|
-
onClick: (
|
|
866
|
-
|
|
911
|
+
onClick: (f) => {
|
|
912
|
+
f.stopPropagation(), Z(c);
|
|
867
913
|
},
|
|
868
914
|
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" }) })
|
|
869
915
|
}
|
|
870
916
|
)
|
|
871
917
|
]
|
|
872
918
|
},
|
|
873
|
-
c.id || `art-${
|
|
919
|
+
c.id || `art-${p}`
|
|
874
920
|
)) })
|
|
875
921
|
] });
|
|
876
922
|
}
|
|
877
|
-
function
|
|
878
|
-
return /* @__PURE__ */
|
|
879
|
-
/* @__PURE__ */
|
|
880
|
-
/* @__PURE__ */ e("span", { className: "sa-error-icon", children: /* @__PURE__ */ e(
|
|
923
|
+
function Oe({ content: t, onRetry: a }) {
|
|
924
|
+
return /* @__PURE__ */ d("div", { className: "sa-error-part", children: [
|
|
925
|
+
/* @__PURE__ */ d("div", { className: "sa-error-content", children: [
|
|
926
|
+
/* @__PURE__ */ e("span", { className: "sa-error-icon", children: /* @__PURE__ */ e(I, { name: "triangle-alert", size: 14 }) }),
|
|
881
927
|
/* @__PURE__ */ e("span", { children: t })
|
|
882
928
|
] }),
|
|
883
|
-
|
|
929
|
+
a && /* @__PURE__ */ e("button", { className: "sa-error-retry", onClick: a, children: "重试" })
|
|
884
930
|
] });
|
|
885
931
|
}
|
|
886
|
-
function
|
|
932
|
+
function Pe({ interrupt: t, onRespond: a, disabled: s, answeredAction: n }) {
|
|
887
933
|
var l, c;
|
|
888
|
-
const
|
|
889
|
-
return /* @__PURE__ */
|
|
890
|
-
/* @__PURE__ */
|
|
891
|
-
/* @__PURE__ */ e(
|
|
934
|
+
const r = t.options, i = (typeof (r == null ? void 0 : r[0]) == "string" ? r[0] : (l = r == null ? void 0 : r[0]) == null ? void 0 : l.label) || "确认", o = (typeof (r == null ? void 0 : r[1]) == "string" ? r[1] : (c = r == null ? void 0 : r[1]) == null ? void 0 : c.label) || "取消";
|
|
935
|
+
return /* @__PURE__ */ d("div", { className: "sa-interrupt-card", children: [
|
|
936
|
+
/* @__PURE__ */ d("div", { className: "sa-interrupt-content", children: [
|
|
937
|
+
/* @__PURE__ */ e(I, { name: "circle-alert", size: 16, color: "#f59e0b" }),
|
|
892
938
|
/* @__PURE__ */ e("span", { children: t.content })
|
|
893
939
|
] }),
|
|
894
|
-
/* @__PURE__ */
|
|
895
|
-
/* @__PURE__ */
|
|
940
|
+
/* @__PURE__ */ d("div", { className: "sa-interrupt-actions", children: [
|
|
941
|
+
/* @__PURE__ */ d(
|
|
896
942
|
"button",
|
|
897
943
|
{
|
|
898
944
|
className: `sa-interrupt-btn sa-interrupt-btn-primary ${n === "confirm" ? "sa-interrupt-btn-answered" : ""}`,
|
|
899
945
|
disabled: s,
|
|
900
|
-
onClick: () =>
|
|
946
|
+
onClick: () => a({ action: "confirm" }),
|
|
901
947
|
children: [
|
|
902
|
-
/* @__PURE__ */ e(
|
|
948
|
+
/* @__PURE__ */ e(I, { name: "check", size: 14 }),
|
|
903
949
|
" ",
|
|
904
950
|
i
|
|
905
951
|
]
|
|
906
952
|
}
|
|
907
953
|
),
|
|
908
|
-
/* @__PURE__ */
|
|
954
|
+
/* @__PURE__ */ d(
|
|
909
955
|
"button",
|
|
910
956
|
{
|
|
911
957
|
className: `sa-interrupt-btn sa-interrupt-btn-secondary ${n === "cancel" ? "sa-interrupt-btn-answered" : ""}`,
|
|
912
958
|
disabled: s,
|
|
913
|
-
onClick: () =>
|
|
959
|
+
onClick: () => a({ action: "cancel" }),
|
|
914
960
|
children: [
|
|
915
|
-
/* @__PURE__ */ e(
|
|
961
|
+
/* @__PURE__ */ e(I, { name: "x", size: 14 }),
|
|
916
962
|
" ",
|
|
917
963
|
o
|
|
918
964
|
]
|
|
@@ -922,49 +968,49 @@ function Ae({ interrupt: t, onRespond: r, disabled: s, answeredAction: n }) {
|
|
|
922
968
|
s && /* @__PURE__ */ e("div", { className: "sa-interrupt-submitted", children: "已提交" })
|
|
923
969
|
] });
|
|
924
970
|
}
|
|
925
|
-
function
|
|
926
|
-
var
|
|
927
|
-
const
|
|
928
|
-
return /* @__PURE__ */
|
|
929
|
-
/* @__PURE__ */
|
|
930
|
-
/* @__PURE__ */ e(
|
|
971
|
+
function He({ interrupt: t, onRespond: a, disabled: s, answeredAction: n }) {
|
|
972
|
+
var p, f, h, w;
|
|
973
|
+
const r = t.options, i = (typeof (r == null ? void 0 : r[0]) == "string" ? r[0] : (p = r == null ? void 0 : r[0]) == null ? void 0 : p.label) || "批准", o = (typeof (r == null ? void 0 : r[1]) == "string" ? r[1] : (f = r == null ? void 0 : r[1]) == null ? void 0 : f.label) || "拒绝", l = (typeof (r == null ? void 0 : r[2]) == "string" ? r[2] : (h = r == null ? void 0 : r[2]) == null ? void 0 : h.label) || "跳过", c = ((w = t.metadata) == null ? void 0 : w.showSkip) !== !1;
|
|
974
|
+
return /* @__PURE__ */ d("div", { className: "sa-interrupt-card", children: [
|
|
975
|
+
/* @__PURE__ */ d("div", { className: "sa-interrupt-content", children: [
|
|
976
|
+
/* @__PURE__ */ e(I, { name: "circle-alert", size: 16, color: "#f59e0b" }),
|
|
931
977
|
/* @__PURE__ */ e("span", { children: t.content })
|
|
932
978
|
] }),
|
|
933
|
-
/* @__PURE__ */
|
|
934
|
-
/* @__PURE__ */
|
|
979
|
+
/* @__PURE__ */ d("div", { className: "sa-interrupt-actions", children: [
|
|
980
|
+
/* @__PURE__ */ d(
|
|
935
981
|
"button",
|
|
936
982
|
{
|
|
937
983
|
className: `sa-interrupt-btn sa-interrupt-btn-primary ${n === "approve" ? "sa-interrupt-btn-answered" : ""}`,
|
|
938
984
|
disabled: s,
|
|
939
|
-
onClick: () =>
|
|
985
|
+
onClick: () => a({ action: "approve" }),
|
|
940
986
|
children: [
|
|
941
|
-
/* @__PURE__ */ e(
|
|
987
|
+
/* @__PURE__ */ e(I, { name: "check", size: 14 }),
|
|
942
988
|
" ",
|
|
943
989
|
i
|
|
944
990
|
]
|
|
945
991
|
}
|
|
946
992
|
),
|
|
947
|
-
/* @__PURE__ */
|
|
993
|
+
/* @__PURE__ */ d(
|
|
948
994
|
"button",
|
|
949
995
|
{
|
|
950
996
|
className: `sa-interrupt-btn sa-interrupt-btn-danger ${n === "reject" ? "sa-interrupt-btn-answered" : ""}`,
|
|
951
997
|
disabled: s,
|
|
952
|
-
onClick: () =>
|
|
998
|
+
onClick: () => a({ action: "reject" }),
|
|
953
999
|
children: [
|
|
954
|
-
/* @__PURE__ */ e(
|
|
1000
|
+
/* @__PURE__ */ e(I, { name: "x", size: 14 }),
|
|
955
1001
|
" ",
|
|
956
1002
|
o
|
|
957
1003
|
]
|
|
958
1004
|
}
|
|
959
1005
|
),
|
|
960
|
-
c && /* @__PURE__ */
|
|
1006
|
+
c && /* @__PURE__ */ d(
|
|
961
1007
|
"button",
|
|
962
1008
|
{
|
|
963
1009
|
className: `sa-interrupt-btn sa-interrupt-btn-secondary ${n === "skip" ? "sa-interrupt-btn-answered" : ""}`,
|
|
964
1010
|
disabled: s,
|
|
965
|
-
onClick: () =>
|
|
1011
|
+
onClick: () => a({ action: "skip" }),
|
|
966
1012
|
children: [
|
|
967
|
-
/* @__PURE__ */ e(
|
|
1013
|
+
/* @__PURE__ */ e(I, { name: "chevron-right", size: 14 }),
|
|
968
1014
|
" ",
|
|
969
1015
|
l
|
|
970
1016
|
]
|
|
@@ -974,27 +1020,27 @@ function Re({ interrupt: t, onRespond: r, disabled: s, answeredAction: n }) {
|
|
|
974
1020
|
s && /* @__PURE__ */ e("div", { className: "sa-interrupt-submitted", children: "已提交" })
|
|
975
1021
|
] });
|
|
976
1022
|
}
|
|
977
|
-
function
|
|
1023
|
+
function _e(t) {
|
|
978
1024
|
return typeof t == "string" ? { value: t, label: t } : t;
|
|
979
1025
|
}
|
|
980
|
-
function
|
|
981
|
-
const
|
|
982
|
-
return /* @__PURE__ */
|
|
983
|
-
/* @__PURE__ */
|
|
984
|
-
/* @__PURE__ */ e(
|
|
1026
|
+
function Be({ interrupt: t, onRespond: a, disabled: s, initialValue: n }) {
|
|
1027
|
+
const r = (t.options ?? []).map(_e);
|
|
1028
|
+
return /* @__PURE__ */ d("div", { className: "sa-interrupt-card", children: [
|
|
1029
|
+
/* @__PURE__ */ d("div", { className: "sa-interrupt-content", children: [
|
|
1030
|
+
/* @__PURE__ */ e(I, { name: "list", size: 16, color: "#6366f1" }),
|
|
985
1031
|
/* @__PURE__ */ e("span", { children: t.content })
|
|
986
1032
|
] }),
|
|
987
|
-
/* @__PURE__ */ e("div", { className: "sa-interrupt-options", children:
|
|
1033
|
+
/* @__PURE__ */ e("div", { className: "sa-interrupt-options", children: r.map((i) => {
|
|
988
1034
|
const o = n === i.value;
|
|
989
|
-
return /* @__PURE__ */
|
|
1035
|
+
return /* @__PURE__ */ d(
|
|
990
1036
|
"button",
|
|
991
1037
|
{
|
|
992
1038
|
className: `sa-interrupt-option ${i.danger ? "sa-interrupt-option-danger" : ""} ${o ? "sa-interrupt-option-selected" : ""}`,
|
|
993
1039
|
disabled: s,
|
|
994
|
-
onClick: () =>
|
|
1040
|
+
onClick: () => a({ action: "select", value: i.value }),
|
|
995
1041
|
children: [
|
|
996
|
-
/* @__PURE__ */ e(
|
|
997
|
-
i.icon && /* @__PURE__ */ e(
|
|
1042
|
+
/* @__PURE__ */ e(I, { name: o ? "circle-check" : "circle", size: 14 }),
|
|
1043
|
+
i.icon && /* @__PURE__ */ e(I, { name: i.icon, size: 14 }),
|
|
998
1044
|
/* @__PURE__ */ e("span", { children: i.label }),
|
|
999
1045
|
i.description && /* @__PURE__ */ e("span", { className: "sa-interrupt-option-desc", children: i.description })
|
|
1000
1046
|
]
|
|
@@ -1005,44 +1051,44 @@ function Pe({ interrupt: t, onRespond: r, disabled: s, initialValue: n }) {
|
|
|
1005
1051
|
s && /* @__PURE__ */ e("div", { className: "sa-interrupt-submitted", children: "已提交" })
|
|
1006
1052
|
] });
|
|
1007
1053
|
}
|
|
1008
|
-
function
|
|
1054
|
+
function je(t) {
|
|
1009
1055
|
return typeof t == "string" ? { value: t, label: t } : t;
|
|
1010
1056
|
}
|
|
1011
|
-
function
|
|
1012
|
-
const
|
|
1057
|
+
function Fe({ interrupt: t, onRespond: a, disabled: s, initialValue: n }) {
|
|
1058
|
+
const r = (t.options ?? []).map(je), [i, o] = M(
|
|
1013
1059
|
() => new Set(Array.isArray(n) ? n : [])
|
|
1014
1060
|
), l = (c) => {
|
|
1015
|
-
s || o((
|
|
1016
|
-
const
|
|
1017
|
-
return
|
|
1061
|
+
s || o((p) => {
|
|
1062
|
+
const f = new Set(p);
|
|
1063
|
+
return f.has(c) ? f.delete(c) : f.add(c), f;
|
|
1018
1064
|
});
|
|
1019
1065
|
};
|
|
1020
|
-
return /* @__PURE__ */
|
|
1021
|
-
/* @__PURE__ */
|
|
1022
|
-
/* @__PURE__ */ e(
|
|
1066
|
+
return /* @__PURE__ */ d("div", { className: "sa-interrupt-card", children: [
|
|
1067
|
+
/* @__PURE__ */ d("div", { className: "sa-interrupt-content", children: [
|
|
1068
|
+
/* @__PURE__ */ e(I, { name: "list-checks", size: 16, color: "#6366f1" }),
|
|
1023
1069
|
/* @__PURE__ */ e("span", { children: t.content })
|
|
1024
1070
|
] }),
|
|
1025
|
-
/* @__PURE__ */ e("div", { className: "sa-interrupt-options", children:
|
|
1071
|
+
/* @__PURE__ */ e("div", { className: "sa-interrupt-options", children: r.map((c) => /* @__PURE__ */ d(
|
|
1026
1072
|
"button",
|
|
1027
1073
|
{
|
|
1028
1074
|
className: `sa-interrupt-option ${i.has(c.value) ? "sa-interrupt-option-selected" : ""}`,
|
|
1029
1075
|
disabled: s,
|
|
1030
1076
|
onClick: () => l(c.value),
|
|
1031
1077
|
children: [
|
|
1032
|
-
/* @__PURE__ */ e(
|
|
1078
|
+
/* @__PURE__ */ e(I, { name: i.has(c.value) ? "square-check" : "square", size: 14 }),
|
|
1033
1079
|
/* @__PURE__ */ e("span", { children: c.label })
|
|
1034
1080
|
]
|
|
1035
1081
|
},
|
|
1036
1082
|
c.value
|
|
1037
1083
|
)) }),
|
|
1038
|
-
!s && /* @__PURE__ */ e("div", { className: "sa-interrupt-actions", children: /* @__PURE__ */
|
|
1084
|
+
!s && /* @__PURE__ */ e("div", { className: "sa-interrupt-actions", children: /* @__PURE__ */ d(
|
|
1039
1085
|
"button",
|
|
1040
1086
|
{
|
|
1041
1087
|
className: "sa-interrupt-btn sa-interrupt-btn-primary",
|
|
1042
1088
|
disabled: i.size === 0,
|
|
1043
|
-
onClick: () =>
|
|
1089
|
+
onClick: () => a({ action: "submit", value: Array.from(i) }),
|
|
1044
1090
|
children: [
|
|
1045
|
-
/* @__PURE__ */ e(
|
|
1091
|
+
/* @__PURE__ */ e(I, { name: "check", size: 14 }),
|
|
1046
1092
|
" 确认 (",
|
|
1047
1093
|
i.size,
|
|
1048
1094
|
")"
|
|
@@ -1052,21 +1098,21 @@ function Be({ interrupt: t, onRespond: r, disabled: s, initialValue: n }) {
|
|
|
1052
1098
|
s && /* @__PURE__ */ e("div", { className: "sa-interrupt-submitted", children: "已提交" })
|
|
1053
1099
|
] });
|
|
1054
1100
|
}
|
|
1055
|
-
function
|
|
1056
|
-
const [
|
|
1057
|
-
s || t.required && !
|
|
1101
|
+
function We({ interrupt: t, onRespond: a, disabled: s, initialValue: n }) {
|
|
1102
|
+
const [r, i] = M(n ?? ""), o = t.inputType ?? "text", l = o === "textarea", c = () => {
|
|
1103
|
+
s || t.required && !r.trim() || a({ action: "submit", value: r.trim() });
|
|
1058
1104
|
};
|
|
1059
|
-
return /* @__PURE__ */
|
|
1060
|
-
/* @__PURE__ */
|
|
1061
|
-
/* @__PURE__ */ e(
|
|
1105
|
+
return /* @__PURE__ */ d("div", { className: "sa-interrupt-card", children: [
|
|
1106
|
+
/* @__PURE__ */ d("div", { className: "sa-interrupt-content", children: [
|
|
1107
|
+
/* @__PURE__ */ e(I, { name: "text-cursor-input", size: 16, color: "#6366f1" }),
|
|
1062
1108
|
/* @__PURE__ */ e("span", { children: t.content })
|
|
1063
1109
|
] }),
|
|
1064
1110
|
/* @__PURE__ */ e("div", { className: "sa-interrupt-input-area", children: l ? /* @__PURE__ */ e(
|
|
1065
1111
|
"textarea",
|
|
1066
1112
|
{
|
|
1067
1113
|
className: "sa-interrupt-textarea",
|
|
1068
|
-
value:
|
|
1069
|
-
onChange: (
|
|
1114
|
+
value: r,
|
|
1115
|
+
onChange: (p) => i(p.target.value),
|
|
1070
1116
|
placeholder: t.placeholder,
|
|
1071
1117
|
maxLength: t.maxLength,
|
|
1072
1118
|
rows: 3,
|
|
@@ -1077,22 +1123,22 @@ function je({ interrupt: t, onRespond: r, disabled: s, initialValue: n }) {
|
|
|
1077
1123
|
{
|
|
1078
1124
|
className: "sa-interrupt-input",
|
|
1079
1125
|
type: o,
|
|
1080
|
-
value:
|
|
1081
|
-
onChange: (
|
|
1126
|
+
value: r,
|
|
1127
|
+
onChange: (p) => i(p.target.value),
|
|
1082
1128
|
placeholder: t.placeholder,
|
|
1083
1129
|
maxLength: t.maxLength,
|
|
1084
|
-
onKeyDown: (
|
|
1130
|
+
onKeyDown: (p) => p.key === "Enter" && c(),
|
|
1085
1131
|
disabled: s
|
|
1086
1132
|
}
|
|
1087
1133
|
) }),
|
|
1088
|
-
!s && /* @__PURE__ */ e("div", { className: "sa-interrupt-actions", children: /* @__PURE__ */
|
|
1134
|
+
!s && /* @__PURE__ */ e("div", { className: "sa-interrupt-actions", children: /* @__PURE__ */ d(
|
|
1089
1135
|
"button",
|
|
1090
1136
|
{
|
|
1091
1137
|
className: "sa-interrupt-btn sa-interrupt-btn-primary",
|
|
1092
|
-
disabled: t.required ? !
|
|
1138
|
+
disabled: t.required ? !r.trim() : !1,
|
|
1093
1139
|
onClick: c,
|
|
1094
1140
|
children: [
|
|
1095
|
-
/* @__PURE__ */ e(
|
|
1141
|
+
/* @__PURE__ */ e(I, { name: "check", size: 14 }),
|
|
1096
1142
|
" 提交"
|
|
1097
1143
|
]
|
|
1098
1144
|
}
|
|
@@ -1100,75 +1146,98 @@ function je({ interrupt: t, onRespond: r, disabled: s, initialValue: n }) {
|
|
|
1100
1146
|
s && /* @__PURE__ */ e("div", { className: "sa-interrupt-submitted", children: "已提交" })
|
|
1101
1147
|
] });
|
|
1102
1148
|
}
|
|
1103
|
-
function
|
|
1104
|
-
const
|
|
1105
|
-
const
|
|
1106
|
-
for (const
|
|
1107
|
-
|
|
1108
|
-
return
|
|
1109
|
-
}), l = (
|
|
1110
|
-
s || o((
|
|
1111
|
-
}, c = !s &&
|
|
1112
|
-
c &&
|
|
1149
|
+
function Ke({ interrupt: t, onRespond: a, disabled: s, initialValue: n }) {
|
|
1150
|
+
const r = t.fields ?? [], [i, o] = M(() => {
|
|
1151
|
+
const f = {};
|
|
1152
|
+
for (const h of r)
|
|
1153
|
+
f[h.name] = (n == null ? void 0 : n[h.name]) ?? h.defaultValue ?? "";
|
|
1154
|
+
return f;
|
|
1155
|
+
}), l = (f, h) => {
|
|
1156
|
+
s || o((w) => ({ ...w, [f]: h }));
|
|
1157
|
+
}, c = !s && r.every((f) => !f.required || i[f.name]), p = () => {
|
|
1158
|
+
c && a({ action: "submit", value: i });
|
|
1113
1159
|
};
|
|
1114
|
-
return /* @__PURE__ */
|
|
1115
|
-
/* @__PURE__ */
|
|
1116
|
-
/* @__PURE__ */ e(
|
|
1160
|
+
return /* @__PURE__ */ d("div", { className: "sa-interrupt-card", children: [
|
|
1161
|
+
/* @__PURE__ */ d("div", { className: "sa-interrupt-content", children: [
|
|
1162
|
+
/* @__PURE__ */ e(I, { name: "file-text", size: 16, color: "#6366f1" }),
|
|
1117
1163
|
/* @__PURE__ */ e("span", { children: t.content })
|
|
1118
1164
|
] }),
|
|
1119
|
-
/* @__PURE__ */ e("div", { className: "sa-interrupt-form", children:
|
|
1120
|
-
/* @__PURE__ */
|
|
1121
|
-
|
|
1122
|
-
|
|
1165
|
+
/* @__PURE__ */ e("div", { className: "sa-interrupt-form", children: r.map((f) => /* @__PURE__ */ d("div", { className: "sa-interrupt-form-field", children: [
|
|
1166
|
+
/* @__PURE__ */ d("label", { className: "sa-interrupt-form-label", children: [
|
|
1167
|
+
f.label,
|
|
1168
|
+
f.required && /* @__PURE__ */ e("span", { className: "sa-interrupt-form-required", children: "*" })
|
|
1123
1169
|
] }),
|
|
1124
|
-
|
|
1125
|
-
] },
|
|
1126
|
-
!s && /* @__PURE__ */
|
|
1127
|
-
/* @__PURE__ */
|
|
1128
|
-
/* @__PURE__ */ e(
|
|
1170
|
+
Ye(f, i[f.name], (h) => l(f.name, h), s)
|
|
1171
|
+
] }, f.name)) }),
|
|
1172
|
+
!s && /* @__PURE__ */ d("div", { className: "sa-interrupt-actions", children: [
|
|
1173
|
+
/* @__PURE__ */ d("button", { className: "sa-interrupt-btn sa-interrupt-btn-primary", disabled: !c, onClick: p, children: [
|
|
1174
|
+
/* @__PURE__ */ e(I, { name: "check", size: 14 }),
|
|
1129
1175
|
" 提交"
|
|
1130
1176
|
] }),
|
|
1131
|
-
/* @__PURE__ */ e("button", { className: "sa-interrupt-btn sa-interrupt-btn-secondary", onClick: () =>
|
|
1177
|
+
/* @__PURE__ */ e("button", { className: "sa-interrupt-btn sa-interrupt-btn-secondary", onClick: () => a({ action: "cancel" }), children: "取消" })
|
|
1132
1178
|
] }),
|
|
1133
1179
|
s && /* @__PURE__ */ e("div", { className: "sa-interrupt-submitted", children: "已提交" })
|
|
1134
1180
|
] });
|
|
1135
1181
|
}
|
|
1136
|
-
function
|
|
1182
|
+
function se(t) {
|
|
1183
|
+
return typeof t == "string" ? { value: t, label: t } : t;
|
|
1184
|
+
}
|
|
1185
|
+
function Ye(t, a, s, n) {
|
|
1137
1186
|
switch (t.type) {
|
|
1138
1187
|
case "textarea":
|
|
1139
|
-
return /* @__PURE__ */ e("textarea", { className: "sa-interrupt-textarea", value:
|
|
1140
|
-
case "select":
|
|
1141
|
-
|
|
1188
|
+
return /* @__PURE__ */ e("textarea", { className: "sa-interrupt-textarea", value: a, onChange: (r) => s(r.target.value), placeholder: t.placeholder, rows: 3, disabled: n });
|
|
1189
|
+
case "select": {
|
|
1190
|
+
const r = (t.options ?? []).map(se);
|
|
1191
|
+
return /* @__PURE__ */ d("select", { className: "sa-interrupt-select", value: a, onChange: (i) => s(i.target.value), disabled: n, children: [
|
|
1142
1192
|
/* @__PURE__ */ e("option", { value: "", children: "请选择" }),
|
|
1143
|
-
|
|
1193
|
+
r.map((i) => /* @__PURE__ */ e("option", { value: i.value, children: i.label }, i.value))
|
|
1144
1194
|
] });
|
|
1195
|
+
}
|
|
1196
|
+
case "multiSelect": {
|
|
1197
|
+
const r = (t.options ?? []).map(se), i = Array.isArray(a) ? a : [], o = (l) => {
|
|
1198
|
+
n || s(i.includes(l) ? i.filter((c) => c !== l) : [...i, l]);
|
|
1199
|
+
};
|
|
1200
|
+
return /* @__PURE__ */ e("div", { className: "sa-interrupt-options", children: r.map((l) => /* @__PURE__ */ e(
|
|
1201
|
+
"button",
|
|
1202
|
+
{
|
|
1203
|
+
type: "button",
|
|
1204
|
+
className: `sa-interrupt-option ${i.includes(l.value) ? "sa-interrupt-option-selected" : ""}`,
|
|
1205
|
+
disabled: n,
|
|
1206
|
+
onClick: () => o(l.value),
|
|
1207
|
+
children: l.label
|
|
1208
|
+
},
|
|
1209
|
+
l.value
|
|
1210
|
+
)) });
|
|
1211
|
+
}
|
|
1212
|
+
case "password":
|
|
1213
|
+
return /* @__PURE__ */ e("input", { className: "sa-interrupt-input", type: "password", value: a, onChange: (r) => s(r.target.value), placeholder: t.placeholder, disabled: n });
|
|
1145
1214
|
default:
|
|
1146
|
-
return /* @__PURE__ */ e("input", { className: "sa-interrupt-input", type: t.type, value:
|
|
1215
|
+
return /* @__PURE__ */ e("input", { className: "sa-interrupt-input", type: t.type === "number" ? "number" : t.type === "date" ? "date" : "text", value: a, onChange: (r) => s(r.target.value), placeholder: t.placeholder, disabled: n });
|
|
1147
1216
|
}
|
|
1148
1217
|
}
|
|
1149
|
-
function
|
|
1150
|
-
const
|
|
1218
|
+
function Ue({ interrupt: t, resolved: a, response: s, onRespond: n }) {
|
|
1219
|
+
const r = a, i = s == null ? void 0 : s.value;
|
|
1151
1220
|
switch (t.interruptType) {
|
|
1152
1221
|
case "confirm":
|
|
1153
|
-
return /* @__PURE__ */ e(
|
|
1222
|
+
return /* @__PURE__ */ e(Pe, { interrupt: t, onRespond: n, disabled: r, answeredAction: s == null ? void 0 : s.action });
|
|
1154
1223
|
case "approve":
|
|
1155
|
-
return /* @__PURE__ */ e(
|
|
1224
|
+
return /* @__PURE__ */ e(He, { interrupt: t, onRespond: n, disabled: r, answeredAction: s == null ? void 0 : s.action });
|
|
1156
1225
|
case "select":
|
|
1157
|
-
return /* @__PURE__ */ e(
|
|
1226
|
+
return /* @__PURE__ */ e(Be, { interrupt: t, onRespond: n, disabled: r, initialValue: i });
|
|
1158
1227
|
case "multiSelect":
|
|
1159
|
-
return /* @__PURE__ */ e(
|
|
1228
|
+
return /* @__PURE__ */ e(Fe, { interrupt: t, onRespond: n, disabled: r, initialValue: i });
|
|
1160
1229
|
case "input":
|
|
1161
|
-
return /* @__PURE__ */ e(
|
|
1230
|
+
return /* @__PURE__ */ e(We, { interrupt: t, onRespond: n, disabled: r, initialValue: i });
|
|
1162
1231
|
case "form":
|
|
1163
|
-
return /* @__PURE__ */ e(
|
|
1232
|
+
return /* @__PURE__ */ e(Ke, { interrupt: t, onRespond: n, disabled: r, initialValue: i });
|
|
1164
1233
|
default:
|
|
1165
|
-
return /* @__PURE__ */
|
|
1234
|
+
return /* @__PURE__ */ d("div", { className: "sa-interrupt-unknown", children: [
|
|
1166
1235
|
"未知的交互类型: ",
|
|
1167
1236
|
t.interruptType
|
|
1168
1237
|
] });
|
|
1169
1238
|
}
|
|
1170
1239
|
}
|
|
1171
|
-
const
|
|
1240
|
+
const qe = [
|
|
1172
1241
|
{ value: 1, label: "事实错误" },
|
|
1173
1242
|
{ value: 2, label: "逻辑问题" },
|
|
1174
1243
|
{ value: 3, label: "不相关" },
|
|
@@ -1176,71 +1245,71 @@ const Ke = [
|
|
|
1176
1245
|
{ value: 5, label: "冗长啰嗦" },
|
|
1177
1246
|
{ value: 6, label: "难以理解" }
|
|
1178
1247
|
];
|
|
1179
|
-
function
|
|
1180
|
-
const { status:
|
|
1181
|
-
|
|
1182
|
-
}, [
|
|
1183
|
-
o === "like" ? (l(null), i(t.id)) : (l("like"),
|
|
1184
|
-
}, [o, t.id, n, i]),
|
|
1185
|
-
o === "dislike" ? (l(null),
|
|
1186
|
-
}, [o, t.id, i]),
|
|
1187
|
-
l("dislike"),
|
|
1188
|
-
}, [t.id, n]),
|
|
1189
|
-
|
|
1248
|
+
function Ve({ message: t, onCopy: a, onRegenerate: s, onFeedback: n }) {
|
|
1249
|
+
const { status: r, cancelFeedback: i } = Y(), [o, l] = M(null), [c, p] = M(!1), [f, h] = M(!1), w = _(null), u = C(() => {
|
|
1250
|
+
a(), p(!0), setTimeout(() => p(!1), 2e3);
|
|
1251
|
+
}, [a]), m = C(() => {
|
|
1252
|
+
o === "like" ? (l(null), i(t.id)) : (l("like"), h(!1), n == null || n(t.id, "like"));
|
|
1253
|
+
}, [o, t.id, n, i]), v = C(() => {
|
|
1254
|
+
o === "dislike" ? (l(null), h(!1), i(t.id)) : h(!0);
|
|
1255
|
+
}, [o, t.id, i]), S = C((A, x) => {
|
|
1256
|
+
l("dislike"), h(!1), n == null || n(t.id, "dislike", { reason: A, remark: (x == null ? void 0 : x.trim()) || void 0 });
|
|
1257
|
+
}, [t.id, n]), T = C(() => {
|
|
1258
|
+
h(!1);
|
|
1190
1259
|
}, []);
|
|
1191
1260
|
return B(() => {
|
|
1192
|
-
if (!
|
|
1193
|
-
const
|
|
1194
|
-
|
|
1195
|
-
},
|
|
1196
|
-
|
|
1261
|
+
if (!f) return;
|
|
1262
|
+
const A = (z) => {
|
|
1263
|
+
w.current && !w.current.contains(z.target) && h(!1);
|
|
1264
|
+
}, x = (z) => {
|
|
1265
|
+
z.key === "Escape" && h(!1);
|
|
1197
1266
|
};
|
|
1198
|
-
return document.addEventListener("mousedown",
|
|
1199
|
-
document.removeEventListener("mousedown",
|
|
1267
|
+
return document.addEventListener("mousedown", A), document.addEventListener("keydown", x), () => {
|
|
1268
|
+
document.removeEventListener("mousedown", A), document.removeEventListener("keydown", x);
|
|
1200
1269
|
};
|
|
1201
|
-
}, [
|
|
1202
|
-
/* @__PURE__ */
|
|
1203
|
-
/* @__PURE__ */ e(
|
|
1270
|
+
}, [f]), r !== "ready" && r !== "error" ? null : /* @__PURE__ */ d("div", { className: "sa-action-bar", children: [
|
|
1271
|
+
/* @__PURE__ */ d("button", { className: "sa-action-btn", onClick: u, title: "复制", children: [
|
|
1272
|
+
/* @__PURE__ */ e(I, { name: c ? "circle-check" : "copy", size: 14 }),
|
|
1204
1273
|
" ",
|
|
1205
1274
|
c ? "已复制" : "复制"
|
|
1206
1275
|
] }),
|
|
1207
|
-
s && /* @__PURE__ */
|
|
1208
|
-
/* @__PURE__ */ e(
|
|
1276
|
+
s && /* @__PURE__ */ d("button", { className: "sa-action-btn", onClick: s, title: "重新生成", children: [
|
|
1277
|
+
/* @__PURE__ */ e(I, { name: "refresh-cw", size: 14 }),
|
|
1209
1278
|
" 重新生成"
|
|
1210
1279
|
] }),
|
|
1211
|
-
n && /* @__PURE__ */
|
|
1280
|
+
n && /* @__PURE__ */ d(q, { children: [
|
|
1212
1281
|
/* @__PURE__ */ e("span", { className: "sa-action-divider" }),
|
|
1213
1282
|
/* @__PURE__ */ e(
|
|
1214
1283
|
"button",
|
|
1215
1284
|
{
|
|
1216
1285
|
className: `sa-action-btn ${o === "like" ? "sa-action-btn-active" : ""}`,
|
|
1217
|
-
onClick:
|
|
1286
|
+
onClick: m,
|
|
1218
1287
|
title: "有用",
|
|
1219
1288
|
"aria-label": "点赞",
|
|
1220
|
-
children: /* @__PURE__ */ e(
|
|
1289
|
+
children: /* @__PURE__ */ e(I, { name: "thumbs-up", size: 14 })
|
|
1221
1290
|
}
|
|
1222
1291
|
),
|
|
1223
1292
|
/* @__PURE__ */ e(
|
|
1224
1293
|
"button",
|
|
1225
1294
|
{
|
|
1226
1295
|
className: `sa-action-btn ${o === "dislike" ? "sa-action-btn-active" : ""}`,
|
|
1227
|
-
onClick:
|
|
1296
|
+
onClick: v,
|
|
1228
1297
|
title: "无用",
|
|
1229
1298
|
"aria-label": "踩",
|
|
1230
|
-
"aria-expanded":
|
|
1299
|
+
"aria-expanded": f,
|
|
1231
1300
|
"aria-haspopup": "dialog",
|
|
1232
|
-
children: /* @__PURE__ */ e(
|
|
1301
|
+
children: /* @__PURE__ */ e(I, { name: "thumbs-down", size: 14 })
|
|
1233
1302
|
}
|
|
1234
1303
|
)
|
|
1235
1304
|
] }),
|
|
1236
|
-
|
|
1305
|
+
f && /* @__PURE__ */ e("div", { ref: w, children: /* @__PURE__ */ e(Xe, { onSubmit: S, onCancel: T }) })
|
|
1237
1306
|
] });
|
|
1238
1307
|
}
|
|
1239
|
-
function
|
|
1240
|
-
const [s, n] =
|
|
1241
|
-
return /* @__PURE__ */
|
|
1308
|
+
function Xe({ onSubmit: t, onCancel: a }) {
|
|
1309
|
+
const [s, n] = M(void 0), [r, i] = M("");
|
|
1310
|
+
return /* @__PURE__ */ d("div", { className: "sa-dislike-panel", children: [
|
|
1242
1311
|
/* @__PURE__ */ e("div", { className: "sa-dislike-panel-title", children: "请选择不满意的原因(可选)" }),
|
|
1243
|
-
/* @__PURE__ */ e("div", { className: "sa-dislike-reasons", children:
|
|
1312
|
+
/* @__PURE__ */ e("div", { className: "sa-dislike-reasons", children: qe.map((o) => /* @__PURE__ */ e(
|
|
1244
1313
|
"button",
|
|
1245
1314
|
{
|
|
1246
1315
|
className: `sa-dislike-reason-btn ${s === o.value ? "active" : ""}`,
|
|
@@ -1255,206 +1324,272 @@ function Ue({ onSubmit: t, onCancel: r }) {
|
|
|
1255
1324
|
className: "sa-dislike-remark",
|
|
1256
1325
|
placeholder: "补充描述(选填,≤500 字)",
|
|
1257
1326
|
maxLength: 500,
|
|
1258
|
-
value:
|
|
1327
|
+
value: r,
|
|
1259
1328
|
onChange: (o) => i(o.target.value),
|
|
1260
1329
|
rows: 2
|
|
1261
1330
|
}
|
|
1262
1331
|
),
|
|
1263
|
-
/* @__PURE__ */
|
|
1264
|
-
/* @__PURE__ */ e("button", { className: "sa-dislike-submit", onClick: () => t(s,
|
|
1265
|
-
/* @__PURE__ */ e("button", { className: "sa-dislike-cancel", onClick:
|
|
1332
|
+
/* @__PURE__ */ d("div", { className: "sa-dislike-actions", children: [
|
|
1333
|
+
/* @__PURE__ */ e("button", { className: "sa-dislike-submit", onClick: () => t(s, r || void 0), children: "提交" }),
|
|
1334
|
+
/* @__PURE__ */ e("button", { className: "sa-dislike-cancel", onClick: a, children: "取消" })
|
|
1266
1335
|
] })
|
|
1267
1336
|
] });
|
|
1268
1337
|
}
|
|
1269
|
-
function
|
|
1270
|
-
const s =
|
|
1271
|
-
return t ? t.startsWith("http") || t.startsWith("/") || t.startsWith("data:") ? /* @__PURE__ */ e("div", { className: `sa-avatar sa-avatar-${
|
|
1338
|
+
function ne({ src: t, role: a }) {
|
|
1339
|
+
const s = a === "assistant" ? "A" : "U";
|
|
1340
|
+
return t ? t.startsWith("http") || t.startsWith("/") || t.startsWith("data:") ? /* @__PURE__ */ e("div", { className: `sa-avatar sa-avatar-${a}`, children: /* @__PURE__ */ e(
|
|
1341
|
+
"img",
|
|
1342
|
+
{
|
|
1343
|
+
src: t,
|
|
1344
|
+
alt: a,
|
|
1345
|
+
style: {
|
|
1346
|
+
width: "100%",
|
|
1347
|
+
height: "100%",
|
|
1348
|
+
borderRadius: "inherit",
|
|
1349
|
+
objectFit: "cover"
|
|
1350
|
+
}
|
|
1351
|
+
}
|
|
1352
|
+
) }) : /* @__PURE__ */ e("div", { className: `sa-avatar sa-avatar-${a}`, children: t }) : /* @__PURE__ */ e("div", { className: `sa-avatar sa-avatar-${a}`, children: s });
|
|
1272
1353
|
}
|
|
1273
|
-
function
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1354
|
+
function Ge({
|
|
1355
|
+
message: t,
|
|
1356
|
+
isStreaming: a,
|
|
1357
|
+
isLast: s,
|
|
1358
|
+
slots: n,
|
|
1359
|
+
avatar: r,
|
|
1360
|
+
artifactPreview: i
|
|
1361
|
+
}) {
|
|
1362
|
+
const { regenerate: o, feedback: l, respondToInterrupt: c } = Y(), p = C(() => {
|
|
1363
|
+
var z;
|
|
1364
|
+
const x = t.parts.filter(($) => $.type === "text").map(($) => $.content).join(`
|
|
1277
1365
|
`);
|
|
1278
|
-
(
|
|
1366
|
+
(z = navigator.clipboard) == null || z.writeText(x).catch(() => {
|
|
1279
1367
|
});
|
|
1280
|
-
}, [t]),
|
|
1281
|
-
if (
|
|
1368
|
+
}, [t]), f = t.role === "user", h = n.Message;
|
|
1369
|
+
if (h)
|
|
1282
1370
|
return /* @__PURE__ */ e(
|
|
1283
|
-
|
|
1371
|
+
h,
|
|
1284
1372
|
{
|
|
1285
1373
|
message: t,
|
|
1286
|
-
isStreaming:
|
|
1374
|
+
isStreaming: a,
|
|
1287
1375
|
isLast: s,
|
|
1288
|
-
avatar:
|
|
1376
|
+
avatar: r,
|
|
1289
1377
|
slots: n,
|
|
1290
|
-
onCopy:
|
|
1378
|
+
onCopy: p,
|
|
1291
1379
|
onRegenerate: o,
|
|
1292
1380
|
onFeedback: l
|
|
1293
1381
|
}
|
|
1294
1382
|
);
|
|
1295
|
-
const
|
|
1296
|
-
return /* @__PURE__ */
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1383
|
+
const w = n.TextPart ?? De, u = n.ThinkingPart ?? Le, m = n.ToolCallPart ?? Ee, v = n.ToolResultPart ?? Re, S = n.ErrorPart ?? Oe, T = n.ActionBar ?? Ve, A = !f && t.parts.some((x) => x.type === "text" && x.content);
|
|
1384
|
+
return /* @__PURE__ */ d(
|
|
1385
|
+
"div",
|
|
1386
|
+
{
|
|
1387
|
+
className: `sa-message ${f ? "sa-message-user" : "sa-message-assistant"}`,
|
|
1388
|
+
children: [
|
|
1389
|
+
!f && /* @__PURE__ */ e(ne, { src: r == null ? void 0 : r.assistant, role: "assistant" }),
|
|
1390
|
+
/* @__PURE__ */ d("div", { className: "sa-message-content", children: [
|
|
1391
|
+
/* @__PURE__ */ e(
|
|
1392
|
+
"span",
|
|
1393
|
+
{
|
|
1394
|
+
className: `sa-message-time ${f ? "sa-message-time-right" : ""}`,
|
|
1395
|
+
children: pe(t.timestamp)
|
|
1396
|
+
}
|
|
1397
|
+
),
|
|
1398
|
+
/* @__PURE__ */ d("div", { className: "sa-message-body", children: [
|
|
1399
|
+
t.parts.map((x, z) => {
|
|
1400
|
+
switch (x.type) {
|
|
1401
|
+
case "text":
|
|
1402
|
+
return /* @__PURE__ */ e(w, { content: x.content }, z);
|
|
1403
|
+
case "thinking":
|
|
1404
|
+
return /* @__PURE__ */ e(u, { content: x.content }, z);
|
|
1405
|
+
case "tool_call":
|
|
1406
|
+
return /* @__PURE__ */ e(
|
|
1407
|
+
m,
|
|
1408
|
+
{
|
|
1409
|
+
toolName: x.toolName,
|
|
1410
|
+
toolCallId: x.toolCallId,
|
|
1411
|
+
args: x.args
|
|
1412
|
+
},
|
|
1413
|
+
z
|
|
1414
|
+
);
|
|
1415
|
+
case "tool_result":
|
|
1416
|
+
return /* @__PURE__ */ e(
|
|
1417
|
+
v,
|
|
1418
|
+
{
|
|
1419
|
+
toolName: x.toolName,
|
|
1420
|
+
toolCallId: x.toolCallId,
|
|
1421
|
+
content: x.content,
|
|
1422
|
+
artifacts: x.artifacts,
|
|
1423
|
+
renderMode: x.renderMode,
|
|
1424
|
+
html: x.html,
|
|
1425
|
+
artifactPreview: i
|
|
1426
|
+
},
|
|
1427
|
+
z
|
|
1428
|
+
);
|
|
1429
|
+
case "error":
|
|
1430
|
+
return /* @__PURE__ */ e(
|
|
1431
|
+
S,
|
|
1432
|
+
{
|
|
1433
|
+
content: x.content,
|
|
1434
|
+
onRetry: o
|
|
1435
|
+
},
|
|
1436
|
+
z
|
|
1437
|
+
);
|
|
1438
|
+
case "interrupt":
|
|
1439
|
+
return /* @__PURE__ */ e(
|
|
1440
|
+
Ue,
|
|
1441
|
+
{
|
|
1442
|
+
interrupt: x.interrupt,
|
|
1443
|
+
resolved: x.resolved ?? !1,
|
|
1444
|
+
response: x.response,
|
|
1445
|
+
onRespond: ($) => c(x.interrupt.interruptId, $)
|
|
1446
|
+
},
|
|
1447
|
+
z
|
|
1448
|
+
);
|
|
1449
|
+
default:
|
|
1450
|
+
return null;
|
|
1451
|
+
}
|
|
1452
|
+
}),
|
|
1453
|
+
a && s && !f && /* @__PURE__ */ e("span", { className: "sa-streaming-cursor", children: "|" }),
|
|
1454
|
+
!f && !a && A && /* @__PURE__ */ e(
|
|
1455
|
+
T,
|
|
1456
|
+
{
|
|
1457
|
+
message: t,
|
|
1458
|
+
onCopy: p,
|
|
1459
|
+
onRegenerate: s ? o : void 0,
|
|
1460
|
+
onFeedback: l
|
|
1461
|
+
}
|
|
1462
|
+
)
|
|
1463
|
+
] })
|
|
1464
|
+
] }),
|
|
1465
|
+
f && /* @__PURE__ */ e(ne, { src: r == null ? void 0 : r.user, role: "user" })
|
|
1466
|
+
]
|
|
1467
|
+
}
|
|
1468
|
+
);
|
|
1334
1469
|
}
|
|
1335
|
-
function
|
|
1336
|
-
return /* @__PURE__ */
|
|
1337
|
-
/* @__PURE__ */ e("div", { className: "sa-welcome-icon", children: /* @__PURE__ */ e(
|
|
1470
|
+
function Je({ message: t, suggestedPrompts: a, onPromptClick: s }) {
|
|
1471
|
+
return /* @__PURE__ */ d("div", { className: "sa-welcome", children: [
|
|
1472
|
+
/* @__PURE__ */ e("div", { className: "sa-welcome-icon", children: /* @__PURE__ */ e(I, { name: "sparkles", size: 40 }) }),
|
|
1338
1473
|
/* @__PURE__ */ e("p", { className: "sa-welcome-message", children: t || "你好!有什么可以帮你的?" }),
|
|
1339
|
-
|
|
1474
|
+
a && a.length > 0 && /* @__PURE__ */ e("div", { className: "sa-welcome-prompts", children: a.map((n, r) => /* @__PURE__ */ e(
|
|
1340
1475
|
"button",
|
|
1341
1476
|
{
|
|
1342
1477
|
className: "sa-welcome-prompt",
|
|
1343
1478
|
onClick: () => s(n),
|
|
1344
1479
|
children: n
|
|
1345
1480
|
},
|
|
1346
|
-
|
|
1481
|
+
r
|
|
1347
1482
|
)) })
|
|
1348
1483
|
] });
|
|
1349
1484
|
}
|
|
1350
|
-
function
|
|
1351
|
-
const { messages: i, status: o, sendMessage: l } =
|
|
1485
|
+
function fe({ slots: t, welcomeMessage: a, suggestedPrompts: s, avatar: n, artifactPreview: r }) {
|
|
1486
|
+
const { messages: i, status: o, sendMessage: l } = Y(), { containerRef: c } = Te([i]), p = o === "streaming", f = t.WelcomeScreen ?? Je;
|
|
1352
1487
|
return i.length === 0 ? /* @__PURE__ */ e("div", { className: "sa-thread", ref: c, children: /* @__PURE__ */ e(
|
|
1353
|
-
|
|
1488
|
+
f,
|
|
1354
1489
|
{
|
|
1355
|
-
message:
|
|
1490
|
+
message: a,
|
|
1356
1491
|
suggestedPrompts: s,
|
|
1357
1492
|
onPromptClick: l
|
|
1358
1493
|
}
|
|
1359
|
-
) }) : /* @__PURE__ */ e("div", { className: "sa-thread", ref: c, children: i.map((
|
|
1360
|
-
|
|
1494
|
+
) }) : /* @__PURE__ */ e("div", { className: "sa-thread", ref: c, children: i.map((h, w) => /* @__PURE__ */ e(
|
|
1495
|
+
Ge,
|
|
1361
1496
|
{
|
|
1362
|
-
message:
|
|
1363
|
-
isStreaming:
|
|
1364
|
-
isLast:
|
|
1497
|
+
message: h,
|
|
1498
|
+
isStreaming: p,
|
|
1499
|
+
isLast: w === i.length - 1,
|
|
1365
1500
|
slots: t,
|
|
1366
1501
|
avatar: n,
|
|
1367
|
-
artifactPreview:
|
|
1502
|
+
artifactPreview: r
|
|
1368
1503
|
},
|
|
1369
|
-
|
|
1504
|
+
h.id
|
|
1370
1505
|
)) });
|
|
1371
1506
|
}
|
|
1372
|
-
function
|
|
1373
|
-
const n =
|
|
1507
|
+
function Ze({ items: t, activeIndex: a, onSelect: s }) {
|
|
1508
|
+
const n = _(null);
|
|
1374
1509
|
return B(() => {
|
|
1375
1510
|
var i;
|
|
1376
|
-
const
|
|
1377
|
-
|
|
1378
|
-
}, [
|
|
1511
|
+
const r = (i = n.current) == null ? void 0 : i.children[a];
|
|
1512
|
+
r == null || r.scrollIntoView({ block: "nearest" });
|
|
1513
|
+
}, [a]), t.length === 0 ? /* @__PURE__ */ e("div", { className: "sa-slash-menu", children: /* @__PURE__ */ e("div", { className: "sa-slash-menu-empty", children: "没有匹配的技能" }) }) : /* @__PURE__ */ e("div", { className: "sa-slash-menu", ref: n, children: t.map((r, i) => /* @__PURE__ */ d(
|
|
1379
1514
|
"div",
|
|
1380
1515
|
{
|
|
1381
|
-
className: `sa-slash-menu-item${i ===
|
|
1516
|
+
className: `sa-slash-menu-item${i === a ? " sa-slash-menu-item--active" : ""}`,
|
|
1382
1517
|
onMouseDown: (o) => {
|
|
1383
|
-
o.preventDefault(), s(
|
|
1518
|
+
o.preventDefault(), s(r);
|
|
1384
1519
|
},
|
|
1385
1520
|
children: [
|
|
1386
|
-
/* @__PURE__ */
|
|
1521
|
+
/* @__PURE__ */ d("span", { className: "sa-slash-menu-item-name", children: [
|
|
1387
1522
|
"/",
|
|
1388
|
-
|
|
1523
|
+
r.name
|
|
1389
1524
|
] }),
|
|
1390
|
-
(
|
|
1525
|
+
(r.displayName || r.description) && /* @__PURE__ */ e("span", { className: "sa-slash-menu-item-desc", children: r.displayName || r.description })
|
|
1391
1526
|
]
|
|
1392
1527
|
},
|
|
1393
|
-
|
|
1528
|
+
r.code
|
|
1394
1529
|
)) });
|
|
1395
1530
|
}
|
|
1396
|
-
function
|
|
1397
|
-
const [n,
|
|
1531
|
+
function Qe({ sdk: t, input: a, onSelect: s }) {
|
|
1532
|
+
const [n, r] = M([]), [i, o] = M(!1), [l, c] = M(0), p = _(!1);
|
|
1398
1533
|
B(() => {
|
|
1399
|
-
|
|
1534
|
+
p.current || (p.current = !0, t.listSkills().then(r).catch(() => r([])));
|
|
1400
1535
|
}, [t]);
|
|
1401
|
-
const
|
|
1536
|
+
const f = /^\/\S*$/.test(a);
|
|
1402
1537
|
B(() => {
|
|
1403
|
-
o(
|
|
1404
|
-
}, [
|
|
1405
|
-
|
|
1406
|
-
}, [
|
|
1407
|
-
const
|
|
1538
|
+
o(f);
|
|
1539
|
+
}, [f]), B(() => {
|
|
1540
|
+
f && c(0);
|
|
1541
|
+
}, [a, f]);
|
|
1542
|
+
const h = a.startsWith("/") ? a.slice(1).toLowerCase() : "", w = J(
|
|
1408
1543
|
() => n.filter(
|
|
1409
|
-
(
|
|
1544
|
+
(x) => !h || x.code.toLowerCase().includes(h) || x.name.toLowerCase().includes(h) || x.displayName && x.displayName.toLowerCase().includes(h)
|
|
1410
1545
|
),
|
|
1411
|
-
[n,
|
|
1412
|
-
),
|
|
1413
|
-
|
|
1414
|
-
const
|
|
1415
|
-
if (!
|
|
1416
|
-
switch (
|
|
1546
|
+
[n, h]
|
|
1547
|
+
), u = _(i), m = _(w), v = _(l), S = _(s);
|
|
1548
|
+
u.current = i, m.current = w, v.current = l, S.current = s;
|
|
1549
|
+
const T = C((x) => {
|
|
1550
|
+
if (!u.current || m.current.length === 0) return !1;
|
|
1551
|
+
switch (x.key) {
|
|
1417
1552
|
case "ArrowDown":
|
|
1418
|
-
return
|
|
1553
|
+
return x.preventDefault(), c((z) => (z + 1) % m.current.length), !0;
|
|
1419
1554
|
case "ArrowUp":
|
|
1420
|
-
return
|
|
1555
|
+
return x.preventDefault(), c((z) => (z - 1 + m.current.length) % m.current.length), !0;
|
|
1421
1556
|
case "Enter":
|
|
1422
1557
|
case "Tab":
|
|
1423
|
-
return
|
|
1558
|
+
return x.preventDefault(), S.current(m.current[v.current]), o(!1), !0;
|
|
1424
1559
|
case "Escape":
|
|
1425
|
-
return
|
|
1560
|
+
return x.preventDefault(), o(!1), !0;
|
|
1426
1561
|
default:
|
|
1427
1562
|
return !1;
|
|
1428
1563
|
}
|
|
1429
|
-
}, []),
|
|
1430
|
-
return { isOpen: i, items:
|
|
1564
|
+
}, []), A = C(() => o(!1), []);
|
|
1565
|
+
return { isOpen: i, items: w, activeIndex: l, handleKeyDown: T, close: A };
|
|
1431
1566
|
}
|
|
1432
|
-
function
|
|
1433
|
-
const { status: t, sendMessage:
|
|
1434
|
-
i(`/${
|
|
1435
|
-
const
|
|
1436
|
-
|
|
1567
|
+
function ue() {
|
|
1568
|
+
const { status: t, sendMessage: a, stop: s, sdk: n } = Y(), [r, i] = M(""), o = _(null), l = t === "streaming" || t === "submitted", c = C((u) => {
|
|
1569
|
+
i(`/${u.name} `), setTimeout(() => {
|
|
1570
|
+
const m = o.current;
|
|
1571
|
+
m && (m.focus(), m.selectionStart = m.selectionEnd = m.value.length);
|
|
1437
1572
|
}, 0);
|
|
1438
|
-
}, []),
|
|
1573
|
+
}, []), p = Qe({
|
|
1439
1574
|
sdk: n,
|
|
1440
|
-
input:
|
|
1575
|
+
input: r,
|
|
1441
1576
|
onSelect: c
|
|
1442
|
-
}),
|
|
1443
|
-
const
|
|
1444
|
-
!
|
|
1445
|
-
}, [
|
|
1446
|
-
|
|
1447
|
-
}, [
|
|
1448
|
-
i(
|
|
1449
|
-
const
|
|
1450
|
-
|
|
1577
|
+
}), f = C(() => {
|
|
1578
|
+
const u = r.trim();
|
|
1579
|
+
!u || l || (a(u), i(""), o.current && (o.current.style.height = "auto"));
|
|
1580
|
+
}, [r, l, a]), h = C((u) => {
|
|
1581
|
+
p.handleKeyDown(u) || u.key === "Enter" && !u.shiftKey && (u.preventDefault(), f());
|
|
1582
|
+
}, [f, p.handleKeyDown]), w = C((u) => {
|
|
1583
|
+
i(u.target.value);
|
|
1584
|
+
const m = u.target;
|
|
1585
|
+
m.style.height = "auto", m.style.height = Math.min(m.scrollHeight, 120) + "px";
|
|
1451
1586
|
}, []);
|
|
1452
|
-
return /* @__PURE__ */
|
|
1453
|
-
|
|
1454
|
-
|
|
1587
|
+
return /* @__PURE__ */ d("div", { className: "sa-composer", children: [
|
|
1588
|
+
p.isOpen && /* @__PURE__ */ e(
|
|
1589
|
+
Ze,
|
|
1455
1590
|
{
|
|
1456
|
-
items:
|
|
1457
|
-
activeIndex:
|
|
1591
|
+
items: p.items,
|
|
1592
|
+
activeIndex: p.activeIndex,
|
|
1458
1593
|
onSelect: c
|
|
1459
1594
|
}
|
|
1460
1595
|
),
|
|
@@ -1463,109 +1598,109 @@ function pe() {
|
|
|
1463
1598
|
{
|
|
1464
1599
|
ref: o,
|
|
1465
1600
|
className: "sa-composer-input",
|
|
1466
|
-
value:
|
|
1467
|
-
onChange:
|
|
1468
|
-
onKeyDown:
|
|
1469
|
-
placeholder: "输入消息,按 / 选择技能...",
|
|
1601
|
+
value: r,
|
|
1602
|
+
onChange: w,
|
|
1603
|
+
onKeyDown: h,
|
|
1604
|
+
placeholder: l ? "回答生成中..." : "输入消息,按 / 选择技能...",
|
|
1470
1605
|
rows: 1,
|
|
1471
|
-
disabled:
|
|
1606
|
+
disabled: l
|
|
1472
1607
|
}
|
|
1473
1608
|
),
|
|
1474
|
-
l ? /* @__PURE__ */ e("button", { className: "sa-composer-stop", onClick: s, title: "停止", children: /* @__PURE__ */ e(
|
|
1609
|
+
l ? /* @__PURE__ */ e("button", { className: "sa-composer-stop", onClick: s, title: "停止", children: /* @__PURE__ */ e(I, { name: "circle-stop", size: 16, color: "#fff" }) }) : /* @__PURE__ */ e(
|
|
1475
1610
|
"button",
|
|
1476
1611
|
{
|
|
1477
1612
|
className: "sa-composer-send",
|
|
1478
|
-
onClick:
|
|
1479
|
-
disabled: !
|
|
1613
|
+
onClick: f,
|
|
1614
|
+
disabled: !r.trim(),
|
|
1480
1615
|
title: "发送",
|
|
1481
|
-
children: /* @__PURE__ */ e(
|
|
1616
|
+
children: /* @__PURE__ */ e(I, { name: "arrow-up", size: 16, color: "#fff" })
|
|
1482
1617
|
}
|
|
1483
1618
|
)
|
|
1484
1619
|
] });
|
|
1485
1620
|
}
|
|
1486
|
-
function
|
|
1487
|
-
const [
|
|
1488
|
-
return
|
|
1621
|
+
function et({ artifact: t }) {
|
|
1622
|
+
const [a, s] = V.useState(null), [n, r] = V.useState(!0), [i, o] = V.useState(null);
|
|
1623
|
+
return V.useEffect(() => {
|
|
1489
1624
|
let l = !1;
|
|
1490
|
-
|
|
1625
|
+
r(!0), o(null), s(null);
|
|
1491
1626
|
async function c() {
|
|
1492
1627
|
try {
|
|
1493
1628
|
if (t.type === "pdf") {
|
|
1494
|
-
l ||
|
|
1629
|
+
l || r(!1);
|
|
1495
1630
|
return;
|
|
1496
1631
|
}
|
|
1497
1632
|
if (t.type === "html") {
|
|
1498
|
-
const
|
|
1499
|
-
if (!
|
|
1500
|
-
const
|
|
1501
|
-
l || (s(
|
|
1633
|
+
const p = await fetch(t.url);
|
|
1634
|
+
if (!p.ok) throw new Error(`HTTP ${p.status}`);
|
|
1635
|
+
const f = await p.text(), h = (await import("./purify.es-C-6FFqDW.js")).default;
|
|
1636
|
+
l || (s(h.sanitize(f, { FORCE_BODY: !0, ADD_ATTR: ["target"] })), r(!1));
|
|
1502
1637
|
return;
|
|
1503
1638
|
}
|
|
1504
1639
|
if (t.type === "docx") {
|
|
1505
|
-
const
|
|
1506
|
-
if (!
|
|
1507
|
-
const
|
|
1508
|
-
l || (s(
|
|
1640
|
+
const p = await fetch(t.url);
|
|
1641
|
+
if (!p.ok) throw new Error(`HTTP ${p.status}`);
|
|
1642
|
+
const f = await p.arrayBuffer(), w = await (await import("./mammoth.browser-COPV53yV.js").then((m) => m.m)).convertToHtml({ arrayBuffer: f }), u = (await import("./purify.es-C-6FFqDW.js")).default;
|
|
1643
|
+
l || (s(u.sanitize(w.value, { FORCE_BODY: !0, ADD_ATTR: ["target"] })), r(!1));
|
|
1509
1644
|
return;
|
|
1510
1645
|
}
|
|
1511
|
-
l || (
|
|
1512
|
-
} catch (
|
|
1513
|
-
l || (
|
|
1646
|
+
l || (r(!1), o(`不支持预览「${t.type}」类型`));
|
|
1647
|
+
} catch (p) {
|
|
1648
|
+
l || (r(!1), o(p instanceof Error ? p.message : "加载失败"));
|
|
1514
1649
|
}
|
|
1515
1650
|
}
|
|
1516
1651
|
return c(), () => {
|
|
1517
1652
|
l = !0;
|
|
1518
1653
|
};
|
|
1519
|
-
}, [t]), n ? /* @__PURE__ */ e("div", { className: "sa-drawer-preview-loading", children: "加载中" }) : i ? /* @__PURE__ */
|
|
1654
|
+
}, [t]), n ? /* @__PURE__ */ e("div", { className: "sa-drawer-preview-loading", children: "加载中" }) : i ? /* @__PURE__ */ d("div", { className: "sa-drawer-preview-error", children: [
|
|
1520
1655
|
i,
|
|
1521
1656
|
/* @__PURE__ */ e("button", { className: "sa-drawer-btn-sm", onClick: () => void Z(t), children: "下载查看" })
|
|
1522
|
-
] }) : t.type === "pdf" ? /* @__PURE__ */ e("iframe", { src: t.url, title: t.filename, className: "sa-drawer-preview-iframe", sandbox: "allow-scripts" }) :
|
|
1657
|
+
] }) : t.type === "pdf" ? /* @__PURE__ */ e("iframe", { src: t.url, title: t.filename, className: "sa-drawer-preview-iframe", sandbox: "allow-scripts" }) : a !== null ? /* @__PURE__ */ e("iframe", { srcDoc: a, title: t.filename, className: "sa-drawer-preview-iframe", sandbox: "allow-same-origin" }) : null;
|
|
1523
1658
|
}
|
|
1524
|
-
function
|
|
1525
|
-
const [n,
|
|
1526
|
-
|
|
1527
|
-
), [i, o] =
|
|
1659
|
+
function me({ artifacts: t, initialArtifact: a, onClose: s }) {
|
|
1660
|
+
const [n, r] = M(
|
|
1661
|
+
a ? { mode: "preview", artifact: a } : { mode: "list" }
|
|
1662
|
+
), [i, o] = M(!1), l = _(null), [c, p] = M(340), f = _(null);
|
|
1528
1663
|
B(() => {
|
|
1529
|
-
|
|
1530
|
-
}, [
|
|
1531
|
-
const
|
|
1664
|
+
a && (l.current && (clearTimeout(l.current), l.current = null, o(!1)), r({ mode: "preview", artifact: a }));
|
|
1665
|
+
}, [a]);
|
|
1666
|
+
const h = C(() => {
|
|
1532
1667
|
o(!0), l.current = setTimeout(() => {
|
|
1533
1668
|
l.current = null, s();
|
|
1534
1669
|
}, 240);
|
|
1535
1670
|
}, [s]);
|
|
1536
1671
|
B(() => () => {
|
|
1537
|
-
var
|
|
1538
|
-
l.current && clearTimeout(l.current), (
|
|
1672
|
+
var v;
|
|
1673
|
+
l.current && clearTimeout(l.current), (v = f.current) == null || v.call(f);
|
|
1539
1674
|
}, []);
|
|
1540
|
-
const
|
|
1541
|
-
|
|
1542
|
-
}, []),
|
|
1543
|
-
|
|
1675
|
+
const w = C((v) => {
|
|
1676
|
+
r({ mode: "preview", artifact: v });
|
|
1677
|
+
}, []), u = C(() => {
|
|
1678
|
+
r({ mode: "list" });
|
|
1544
1679
|
}, []);
|
|
1545
1680
|
B(() => {
|
|
1546
|
-
const
|
|
1547
|
-
|
|
1681
|
+
const v = (S) => {
|
|
1682
|
+
S.key === "Escape" && h();
|
|
1548
1683
|
};
|
|
1549
|
-
return document.addEventListener("keydown",
|
|
1550
|
-
}, [
|
|
1551
|
-
const
|
|
1552
|
-
|
|
1553
|
-
const
|
|
1554
|
-
const
|
|
1555
|
-
|
|
1556
|
-
},
|
|
1557
|
-
document.removeEventListener("mousemove",
|
|
1684
|
+
return document.addEventListener("keydown", v), () => document.removeEventListener("keydown", v);
|
|
1685
|
+
}, [h]);
|
|
1686
|
+
const m = C((v) => {
|
|
1687
|
+
v.preventDefault();
|
|
1688
|
+
const S = v.clientX, T = c, A = (z) => {
|
|
1689
|
+
const $ = S - z.clientX;
|
|
1690
|
+
p(Math.max(240, Math.min(window.innerWidth * 0.7, T + $)));
|
|
1691
|
+
}, x = () => {
|
|
1692
|
+
document.removeEventListener("mousemove", A), document.removeEventListener("mouseup", x), document.body.style.cursor = "", document.body.style.userSelect = "", f.current = null;
|
|
1558
1693
|
};
|
|
1559
|
-
document.body.style.cursor = "col-resize", document.body.style.userSelect = "none", document.addEventListener("mousemove",
|
|
1694
|
+
document.body.style.cursor = "col-resize", document.body.style.userSelect = "none", document.addEventListener("mousemove", A), document.addEventListener("mouseup", x), f.current = x;
|
|
1560
1695
|
}, [c]);
|
|
1561
|
-
return /* @__PURE__ */
|
|
1562
|
-
/* @__PURE__ */ e("div", { className: "sa-drawer-resize-handle", onMouseDown:
|
|
1563
|
-
/* @__PURE__ */
|
|
1564
|
-
n.mode === "preview" ? /* @__PURE__ */
|
|
1565
|
-
/* @__PURE__ */ e("button", { className: "sa-drawer-btn", onClick:
|
|
1696
|
+
return /* @__PURE__ */ d("div", { className: `sa-artifact-drawer ${i ? "sa-drawer-closing" : ""}`, style: { width: c }, children: [
|
|
1697
|
+
/* @__PURE__ */ e("div", { className: "sa-drawer-resize-handle", onMouseDown: m }),
|
|
1698
|
+
/* @__PURE__ */ d("div", { className: "sa-artifact-drawer-header", children: [
|
|
1699
|
+
n.mode === "preview" ? /* @__PURE__ */ d(q, { children: [
|
|
1700
|
+
/* @__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: "M15 18l-6-6 6-6" }) }) }),
|
|
1566
1701
|
/* @__PURE__ */ e("span", { className: "sa-artifact-drawer-title", children: n.artifact.filename })
|
|
1567
|
-
] }) : /* @__PURE__ */
|
|
1568
|
-
/* @__PURE__ */
|
|
1702
|
+
] }) : /* @__PURE__ */ d(q, { children: [
|
|
1703
|
+
/* @__PURE__ */ d("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", style: { flexShrink: 0 }, children: [
|
|
1569
1704
|
/* @__PURE__ */ e("path", { d: "M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z" }),
|
|
1570
1705
|
/* @__PURE__ */ e("polyline", { points: "14 2 14 8 20 8" })
|
|
1571
1706
|
] }),
|
|
@@ -1573,139 +1708,145 @@ function fe({ artifacts: t, initialArtifact: r, onClose: s }) {
|
|
|
1573
1708
|
] }),
|
|
1574
1709
|
/* @__PURE__ */ e("div", { style: { flex: 1 } }),
|
|
1575
1710
|
n.mode === "preview" && /* @__PURE__ */ e("button", { className: "sa-drawer-btn", onClick: () => void Z(n.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" }) }) }),
|
|
1576
|
-
/* @__PURE__ */ e("button", { className: "sa-drawer-btn", onClick:
|
|
1711
|
+
/* @__PURE__ */ e("button", { className: "sa-drawer-btn", onClick: h, 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" }) }) })
|
|
1577
1712
|
] }),
|
|
1578
|
-
/* @__PURE__ */ e("div", { className: "sa-artifact-drawer-body", children: n.mode === "list" ? t.length === 0 ? /* @__PURE__ */ e("div", { className: "sa-drawer-empty", children: "暂无产物" }) : /* @__PURE__ */ e("ul", { className: "sa-drawer-file-list", role: "list", children: t.map((
|
|
1713
|
+
/* @__PURE__ */ e("div", { className: "sa-artifact-drawer-body", children: n.mode === "list" ? t.length === 0 ? /* @__PURE__ */ e("div", { className: "sa-drawer-empty", children: "暂无产物" }) : /* @__PURE__ */ e("ul", { className: "sa-drawer-file-list", role: "list", children: t.map((v, S) => /* @__PURE__ */ d(
|
|
1579
1714
|
"li",
|
|
1580
1715
|
{
|
|
1581
1716
|
className: "sa-drawer-file-card",
|
|
1582
|
-
onClick: () =>
|
|
1583
|
-
onKeyDown: (
|
|
1584
|
-
(
|
|
1717
|
+
onClick: () => w(v),
|
|
1718
|
+
onKeyDown: (T) => {
|
|
1719
|
+
(T.key === "Enter" || T.key === " ") && (T.preventDefault(), w(v));
|
|
1585
1720
|
},
|
|
1586
1721
|
tabIndex: 0,
|
|
1587
1722
|
role: "button",
|
|
1588
|
-
"aria-label": `预览 ${
|
|
1723
|
+
"aria-label": `预览 ${v.filename}`,
|
|
1589
1724
|
children: [
|
|
1590
|
-
/* @__PURE__ */ e("div", { className: "sa-drawer-file-icon", children: /* @__PURE__ */ e("span", { className: "sa-artifact-chip-type", children:
|
|
1591
|
-
/* @__PURE__ */
|
|
1592
|
-
/* @__PURE__ */ e("span", { className: "sa-drawer-file-name", children:
|
|
1593
|
-
/* @__PURE__ */ e("span", { className: "sa-drawer-file-size", children:
|
|
1725
|
+
/* @__PURE__ */ e("div", { className: "sa-drawer-file-icon", children: /* @__PURE__ */ e("span", { className: "sa-artifact-chip-type", children: le(v.type) }) }),
|
|
1726
|
+
/* @__PURE__ */ d("div", { className: "sa-drawer-file-info", children: [
|
|
1727
|
+
/* @__PURE__ */ e("span", { className: "sa-drawer-file-name", children: v.filename }),
|
|
1728
|
+
/* @__PURE__ */ e("span", { className: "sa-drawer-file-size", children: oe(v.size) })
|
|
1594
1729
|
] }),
|
|
1595
1730
|
/* @__PURE__ */ e(
|
|
1596
1731
|
"button",
|
|
1597
1732
|
{
|
|
1598
1733
|
className: "sa-drawer-btn",
|
|
1599
1734
|
title: "下载",
|
|
1600
|
-
"aria-label": `下载 ${
|
|
1601
|
-
onClick: (
|
|
1602
|
-
|
|
1735
|
+
"aria-label": `下载 ${v.filename}`,
|
|
1736
|
+
onClick: (T) => {
|
|
1737
|
+
T.stopPropagation(), Z(v);
|
|
1603
1738
|
},
|
|
1604
1739
|
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" }) })
|
|
1605
1740
|
}
|
|
1606
1741
|
)
|
|
1607
1742
|
]
|
|
1608
1743
|
},
|
|
1609
|
-
|
|
1610
|
-
)) }) : /* @__PURE__ */ e("div", { className: "sa-drawer-view-enter", children: /* @__PURE__ */ e(
|
|
1744
|
+
v.id || `artifact-${S}`
|
|
1745
|
+
)) }) : /* @__PURE__ */ e("div", { className: "sa-drawer-view-enter", children: /* @__PURE__ */ e(et, { artifact: n.artifact }) }) })
|
|
1611
1746
|
] });
|
|
1612
1747
|
}
|
|
1613
|
-
function
|
|
1614
|
-
const { status: c, sendMessage:
|
|
1748
|
+
function tt({ isOpen: t, onClose: a, title: s, slots: n, welcomeMessage: r, suggestedPrompts: i, avatar: o, artifactPreview: l }) {
|
|
1749
|
+
const { status: c, sendMessage: p, stop: f, toggleThreadList: h, toggleArtifactDrawer: w, conversations: u, activeConversationId: m, switchConversation: v, newConversation: S, deleteConversation: T, renameConversation: A, isThreadListOpen: x, isArtifactDrawerOpen: z, allArtifacts: $, activePreviewArtifact: P, messagesLoading: N } = Y();
|
|
1615
1750
|
if (!t) return null;
|
|
1616
|
-
const
|
|
1617
|
-
return /* @__PURE__ */
|
|
1618
|
-
|
|
1619
|
-
|
|
1751
|
+
const R = n.Header, y = n.Composer, g = n.ThreadList;
|
|
1752
|
+
return /* @__PURE__ */ d("div", { className: "sa-panel", children: [
|
|
1753
|
+
R ? /* @__PURE__ */ e(R, { title: s, onClose: a, onToggleThreadList: h }) : /* @__PURE__ */ e(
|
|
1754
|
+
ze,
|
|
1620
1755
|
{
|
|
1621
1756
|
title: s,
|
|
1622
|
-
onClose:
|
|
1623
|
-
onToggleThreadList:
|
|
1624
|
-
artifactCount: l ?
|
|
1625
|
-
onToggleArtifactDrawer: l ?
|
|
1757
|
+
onClose: a,
|
|
1758
|
+
onToggleThreadList: h,
|
|
1759
|
+
artifactCount: l ? $.length : 0,
|
|
1760
|
+
onToggleArtifactDrawer: l ? w : void 0
|
|
1626
1761
|
}
|
|
1627
1762
|
),
|
|
1628
|
-
|
|
1629
|
-
|
|
1763
|
+
g && x ? /* @__PURE__ */ e(
|
|
1764
|
+
g,
|
|
1630
1765
|
{
|
|
1631
|
-
conversations:
|
|
1632
|
-
activeSessionId:
|
|
1633
|
-
onSwitch:
|
|
1634
|
-
onNew:
|
|
1635
|
-
onDelete:
|
|
1636
|
-
onRename:
|
|
1766
|
+
conversations: u,
|
|
1767
|
+
activeSessionId: m,
|
|
1768
|
+
onSwitch: v,
|
|
1769
|
+
onNew: S,
|
|
1770
|
+
onDelete: T,
|
|
1771
|
+
onRename: A
|
|
1637
1772
|
}
|
|
1638
|
-
) : /* @__PURE__ */ e(
|
|
1639
|
-
/* @__PURE__ */
|
|
1640
|
-
/* @__PURE__ */
|
|
1641
|
-
|
|
1773
|
+
) : /* @__PURE__ */ e(Se, {}),
|
|
1774
|
+
/* @__PURE__ */ d("div", { className: "sa-panel-content", children: [
|
|
1775
|
+
N ? /* @__PURE__ */ d("div", { className: "sa-messages-loading", children: [
|
|
1776
|
+
/* @__PURE__ */ e("span", { className: "sa-loading-spinner" }),
|
|
1777
|
+
"加载对话..."
|
|
1778
|
+
] }) : /* @__PURE__ */ e(fe, { slots: n, welcomeMessage: r, suggestedPrompts: i, avatar: o, artifactPreview: l }),
|
|
1779
|
+
l && z && /* @__PURE__ */ e(me, { artifacts: $, initialArtifact: P, onClose: w })
|
|
1642
1780
|
] }),
|
|
1643
|
-
|
|
1781
|
+
y ? /* @__PURE__ */ e(y, { status: c, onSend: p, onStop: f }) : /* @__PURE__ */ e(ue, {})
|
|
1644
1782
|
] });
|
|
1645
1783
|
}
|
|
1646
|
-
function
|
|
1784
|
+
function at({
|
|
1647
1785
|
conversations: t,
|
|
1648
|
-
activeSessionId:
|
|
1786
|
+
activeSessionId: a,
|
|
1649
1787
|
onSwitch: s,
|
|
1650
1788
|
onNew: n,
|
|
1651
|
-
onDelete:
|
|
1789
|
+
onDelete: r,
|
|
1652
1790
|
onRename: i,
|
|
1653
1791
|
isCollapsed: o,
|
|
1654
1792
|
onToggleCollapse: l,
|
|
1655
1793
|
hasMore: c,
|
|
1656
|
-
onLoadMore:
|
|
1794
|
+
onLoadMore: p,
|
|
1795
|
+
conversationsLoading: f
|
|
1657
1796
|
}) {
|
|
1658
|
-
const [
|
|
1659
|
-
(
|
|
1660
|
-
|
|
1797
|
+
const [h, w] = M(null), [u, m] = M(null), [v, S] = M(null), [T, A] = M(""), x = C(
|
|
1798
|
+
(y, g) => {
|
|
1799
|
+
g.stopPropagation(), u === y ? (r(y), m(null)) : (m(y), setTimeout(() => m(null), 3e3));
|
|
1661
1800
|
},
|
|
1662
|
-
[
|
|
1663
|
-
),
|
|
1664
|
-
(
|
|
1665
|
-
|
|
1801
|
+
[u, r]
|
|
1802
|
+
), z = C(
|
|
1803
|
+
(y, g, E) => {
|
|
1804
|
+
E.stopPropagation(), S(y), A(g ?? "");
|
|
1666
1805
|
},
|
|
1667
1806
|
[]
|
|
1668
|
-
),
|
|
1669
|
-
(
|
|
1670
|
-
T.trim() && i(
|
|
1807
|
+
), $ = C(
|
|
1808
|
+
(y) => {
|
|
1809
|
+
T.trim() && i(y, T.trim()), S(null);
|
|
1671
1810
|
},
|
|
1672
1811
|
[T, i]
|
|
1673
|
-
),
|
|
1674
|
-
const
|
|
1675
|
-
!
|
|
1676
|
-
}, [c,
|
|
1677
|
-
const
|
|
1678
|
-
for (const
|
|
1679
|
-
const
|
|
1680
|
-
|
|
1812
|
+
), P = _(null), N = C(() => {
|
|
1813
|
+
const y = P.current;
|
|
1814
|
+
!y || !c || !p || y.scrollHeight - y.scrollTop - y.clientHeight < 50 && p();
|
|
1815
|
+
}, [c, p]), R = (() => {
|
|
1816
|
+
const y = Date.now(), g = [], E = [], L = [];
|
|
1817
|
+
for (const O of t) {
|
|
1818
|
+
const b = y - new Date(O.updateTime).getTime();
|
|
1819
|
+
b < 864e5 ? g.push(O) : b < 6048e5 ? E.push(O) : L.push(O);
|
|
1681
1820
|
}
|
|
1682
|
-
const
|
|
1683
|
-
return
|
|
1821
|
+
const k = [];
|
|
1822
|
+
return g.length && k.push({ label: "今天", items: g }), E.length && k.push({ label: "最近 7 天", items: E }), L.length && k.push({ label: "更早", items: L }), k;
|
|
1684
1823
|
})();
|
|
1685
|
-
return o ? /* @__PURE__ */
|
|
1824
|
+
return o ? /* @__PURE__ */ d("div", { className: "sa-fp-sidebar sa-fp-sidebar-collapsed", children: [
|
|
1686
1825
|
/* @__PURE__ */ e(
|
|
1687
1826
|
"button",
|
|
1688
1827
|
{
|
|
1689
1828
|
className: "sa-fp-sidebar-toggle",
|
|
1690
1829
|
onClick: l,
|
|
1691
1830
|
title: "展开",
|
|
1692
|
-
children: /* @__PURE__ */ e(
|
|
1831
|
+
children: /* @__PURE__ */ e(I, { name: "panel-left", size: 18 })
|
|
1693
1832
|
}
|
|
1694
1833
|
),
|
|
1695
1834
|
/* @__PURE__ */ e(
|
|
1696
1835
|
"button",
|
|
1697
1836
|
{
|
|
1698
1837
|
className: "sa-fp-sidebar-toggle",
|
|
1699
|
-
onClick:
|
|
1838
|
+
onClick: () => {
|
|
1839
|
+
n(), l();
|
|
1840
|
+
},
|
|
1700
1841
|
title: "新会话",
|
|
1701
1842
|
style: { marginTop: 4 },
|
|
1702
|
-
children: /* @__PURE__ */ e(
|
|
1843
|
+
children: /* @__PURE__ */ e(I, { name: "plus", size: 18 })
|
|
1703
1844
|
}
|
|
1704
1845
|
)
|
|
1705
|
-
] }) : /* @__PURE__ */
|
|
1706
|
-
/* @__PURE__ */
|
|
1707
|
-
/* @__PURE__ */
|
|
1708
|
-
/* @__PURE__ */ e(
|
|
1846
|
+
] }) : /* @__PURE__ */ d("div", { className: "sa-fp-sidebar", children: [
|
|
1847
|
+
/* @__PURE__ */ d("div", { className: "sa-fp-sidebar-header", children: [
|
|
1848
|
+
/* @__PURE__ */ d("button", { className: "sa-fp-sidebar-new", onClick: n, children: [
|
|
1849
|
+
/* @__PURE__ */ e(I, { name: "plus", size: 15 }),
|
|
1709
1850
|
" ",
|
|
1710
1851
|
/* @__PURE__ */ e("span", { children: "新会话" })
|
|
1711
1852
|
] }),
|
|
@@ -1715,61 +1856,62 @@ function Qe({
|
|
|
1715
1856
|
className: "sa-fp-sidebar-toggle",
|
|
1716
1857
|
onClick: l,
|
|
1717
1858
|
title: "收起侧边栏",
|
|
1718
|
-
children: /* @__PURE__ */ e(
|
|
1859
|
+
children: /* @__PURE__ */ e(I, { name: "panel-left-close", size: 18 })
|
|
1719
1860
|
}
|
|
1720
1861
|
)
|
|
1721
1862
|
] }),
|
|
1722
|
-
/* @__PURE__ */
|
|
1723
|
-
t.length === 0 && /* @__PURE__ */ e("div", { className: "sa-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1863
|
+
/* @__PURE__ */ d("div", { className: "sa-fp-sidebar-list", ref: P, onScroll: N, children: [
|
|
1864
|
+
f && t.length === 0 && /* @__PURE__ */ e("div", { className: "sa-thread-list-loading", children: "加载中..." }),
|
|
1865
|
+
!f && t.length === 0 && /* @__PURE__ */ e("div", { className: "sa-fp-sidebar-empty", children: "开始你的第一个对话" }),
|
|
1866
|
+
R.map((y) => /* @__PURE__ */ d("div", { children: [
|
|
1867
|
+
/* @__PURE__ */ e("div", { className: "sa-fp-sidebar-group", children: y.label }),
|
|
1868
|
+
y.items.map((g) => {
|
|
1869
|
+
const E = g.sessionId === a, L = h === g.sessionId, k = u === g.sessionId;
|
|
1870
|
+
return /* @__PURE__ */ d(
|
|
1729
1871
|
"div",
|
|
1730
1872
|
{
|
|
1731
|
-
className: `sa-fp-sidebar-item ${
|
|
1873
|
+
className: `sa-fp-sidebar-item ${E ? "active" : ""}`,
|
|
1732
1874
|
onClick: () => {
|
|
1733
|
-
|
|
1875
|
+
v !== g.sessionId && s(g.sessionId);
|
|
1734
1876
|
},
|
|
1735
|
-
onMouseEnter: () =>
|
|
1736
|
-
onMouseLeave: () =>
|
|
1877
|
+
onMouseEnter: () => w(g.sessionId),
|
|
1878
|
+
onMouseLeave: () => w(null),
|
|
1737
1879
|
children: [
|
|
1738
|
-
|
|
1880
|
+
v === g.sessionId ? /* @__PURE__ */ e(
|
|
1739
1881
|
"input",
|
|
1740
1882
|
{
|
|
1741
1883
|
className: "sa-fp-sidebar-item-edit",
|
|
1742
1884
|
value: T,
|
|
1743
|
-
onChange: (
|
|
1744
|
-
onBlur: () =>
|
|
1745
|
-
onKeyDown: (
|
|
1746
|
-
|
|
1885
|
+
onChange: (O) => A(O.target.value),
|
|
1886
|
+
onBlur: () => $(g.sessionId),
|
|
1887
|
+
onKeyDown: (O) => {
|
|
1888
|
+
O.key === "Enter" && $(g.sessionId), O.key === "Escape" && S(null);
|
|
1747
1889
|
},
|
|
1748
|
-
onClick: (
|
|
1890
|
+
onClick: (O) => O.stopPropagation(),
|
|
1749
1891
|
autoFocus: !0
|
|
1750
1892
|
}
|
|
1751
|
-
) : /* @__PURE__ */ e("span", { className: "sa-fp-sidebar-item-title", children:
|
|
1752
|
-
/* @__PURE__ */
|
|
1893
|
+
) : /* @__PURE__ */ e("span", { className: "sa-fp-sidebar-item-title", children: g.title || "新会话" }),
|
|
1894
|
+
/* @__PURE__ */ d(
|
|
1753
1895
|
"div",
|
|
1754
1896
|
{
|
|
1755
|
-
className: `sa-fp-sidebar-item-actions ${
|
|
1897
|
+
className: `sa-fp-sidebar-item-actions ${L && v !== g.sessionId ? "visible" : ""}`,
|
|
1756
1898
|
children: [
|
|
1757
1899
|
/* @__PURE__ */ e(
|
|
1758
1900
|
"button",
|
|
1759
1901
|
{
|
|
1760
1902
|
className: "sa-fp-sidebar-item-action",
|
|
1761
|
-
onClick: (
|
|
1903
|
+
onClick: (O) => z(g.sessionId, g.title, O),
|
|
1762
1904
|
title: "重命名",
|
|
1763
|
-
children: /* @__PURE__ */ e(
|
|
1905
|
+
children: /* @__PURE__ */ e(I, { name: "pen", size: 14 })
|
|
1764
1906
|
}
|
|
1765
1907
|
),
|
|
1766
1908
|
/* @__PURE__ */ e(
|
|
1767
1909
|
"button",
|
|
1768
1910
|
{
|
|
1769
|
-
className: `sa-fp-sidebar-item-action ${
|
|
1770
|
-
onClick: (
|
|
1771
|
-
title:
|
|
1772
|
-
children: /* @__PURE__ */ e(
|
|
1911
|
+
className: `sa-fp-sidebar-item-action ${k ? "danger" : ""}`,
|
|
1912
|
+
onClick: (O) => x(g.sessionId, O),
|
|
1913
|
+
title: k ? "确认删除" : "删除",
|
|
1914
|
+
children: /* @__PURE__ */ e(I, { name: k ? "x" : "trash2", size: 14 })
|
|
1773
1915
|
}
|
|
1774
1916
|
)
|
|
1775
1917
|
]
|
|
@@ -1777,96 +1919,99 @@ function Qe({
|
|
|
1777
1919
|
)
|
|
1778
1920
|
]
|
|
1779
1921
|
},
|
|
1780
|
-
|
|
1922
|
+
g.sessionId
|
|
1781
1923
|
);
|
|
1782
1924
|
})
|
|
1783
|
-
] },
|
|
1925
|
+
] }, y.label)),
|
|
1784
1926
|
c && /* @__PURE__ */ e("div", { className: "sa-thread-list-loading", children: "加载更多..." })
|
|
1785
1927
|
] })
|
|
1786
1928
|
] });
|
|
1787
1929
|
}
|
|
1788
|
-
function
|
|
1930
|
+
function rt({
|
|
1789
1931
|
title: t,
|
|
1790
|
-
slots:
|
|
1932
|
+
slots: a,
|
|
1791
1933
|
welcomeMessage: s,
|
|
1792
1934
|
suggestedPrompts: n,
|
|
1793
|
-
sidebarDefaultOpen:
|
|
1935
|
+
sidebarDefaultOpen: r = !0,
|
|
1794
1936
|
onClose: i,
|
|
1795
1937
|
avatar: o,
|
|
1796
1938
|
artifactPreview: l
|
|
1797
1939
|
}) {
|
|
1798
1940
|
const {
|
|
1799
1941
|
status: c,
|
|
1800
|
-
sendMessage:
|
|
1801
|
-
stop:
|
|
1802
|
-
conversations:
|
|
1803
|
-
activeConversationId:
|
|
1804
|
-
switchConversation:
|
|
1805
|
-
newConversation:
|
|
1806
|
-
deleteConversation:
|
|
1807
|
-
renameConversation:
|
|
1808
|
-
toggleArtifactDrawer:
|
|
1809
|
-
isArtifactDrawerOpen:
|
|
1810
|
-
allArtifacts:
|
|
1811
|
-
activePreviewArtifact:
|
|
1812
|
-
hasMore:
|
|
1813
|
-
loadMoreConversations:
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1942
|
+
sendMessage: p,
|
|
1943
|
+
stop: f,
|
|
1944
|
+
conversations: h,
|
|
1945
|
+
activeConversationId: w,
|
|
1946
|
+
switchConversation: u,
|
|
1947
|
+
newConversation: m,
|
|
1948
|
+
deleteConversation: v,
|
|
1949
|
+
renameConversation: S,
|
|
1950
|
+
toggleArtifactDrawer: T,
|
|
1951
|
+
isArtifactDrawerOpen: A,
|
|
1952
|
+
allArtifacts: x,
|
|
1953
|
+
activePreviewArtifact: z,
|
|
1954
|
+
hasMore: $,
|
|
1955
|
+
loadMoreConversations: P,
|
|
1956
|
+
conversationsLoading: N,
|
|
1957
|
+
messagesLoading: R
|
|
1958
|
+
} = Y(), [y, g] = M(r), E = C(() => g((O) => !O), []), L = a.ThreadList, k = a.Composer;
|
|
1959
|
+
return /* @__PURE__ */ d("div", { className: "sa-fullpage", children: [
|
|
1960
|
+
L ? /* @__PURE__ */ e(
|
|
1817
1961
|
"div",
|
|
1818
1962
|
{
|
|
1819
|
-
className: `sa-fp-sidebar-wrapper ${
|
|
1963
|
+
className: `sa-fp-sidebar-wrapper ${y ? "" : "sa-fp-sidebar-wrapper-collapsed"}`,
|
|
1820
1964
|
children: /* @__PURE__ */ e(
|
|
1821
|
-
|
|
1965
|
+
L,
|
|
1822
1966
|
{
|
|
1823
|
-
conversations:
|
|
1824
|
-
activeSessionId:
|
|
1825
|
-
onSwitch:
|
|
1826
|
-
onNew:
|
|
1827
|
-
onDelete:
|
|
1828
|
-
onRename:
|
|
1829
|
-
hasMore:
|
|
1830
|
-
onLoadMore:
|
|
1967
|
+
conversations: h,
|
|
1968
|
+
activeSessionId: w,
|
|
1969
|
+
onSwitch: u,
|
|
1970
|
+
onNew: m,
|
|
1971
|
+
onDelete: v,
|
|
1972
|
+
onRename: S,
|
|
1973
|
+
hasMore: $,
|
|
1974
|
+
onLoadMore: P
|
|
1831
1975
|
}
|
|
1832
1976
|
)
|
|
1833
1977
|
}
|
|
1834
1978
|
) : /* @__PURE__ */ e(
|
|
1835
|
-
|
|
1979
|
+
at,
|
|
1836
1980
|
{
|
|
1837
|
-
conversations:
|
|
1838
|
-
activeSessionId:
|
|
1839
|
-
onSwitch:
|
|
1840
|
-
onNew:
|
|
1841
|
-
onDelete:
|
|
1842
|
-
onRename:
|
|
1843
|
-
isCollapsed: !
|
|
1844
|
-
onToggleCollapse:
|
|
1845
|
-
hasMore:
|
|
1846
|
-
onLoadMore:
|
|
1981
|
+
conversations: h,
|
|
1982
|
+
activeSessionId: w,
|
|
1983
|
+
onSwitch: u,
|
|
1984
|
+
onNew: m,
|
|
1985
|
+
onDelete: v,
|
|
1986
|
+
onRename: S,
|
|
1987
|
+
isCollapsed: !y,
|
|
1988
|
+
onToggleCollapse: E,
|
|
1989
|
+
hasMore: $,
|
|
1990
|
+
onLoadMore: P,
|
|
1991
|
+
conversationsLoading: N
|
|
1847
1992
|
}
|
|
1848
1993
|
),
|
|
1849
|
-
/* @__PURE__ */
|
|
1850
|
-
/* @__PURE__ */
|
|
1851
|
-
!
|
|
1994
|
+
/* @__PURE__ */ d("div", { className: "sa-fp-main", children: [
|
|
1995
|
+
/* @__PURE__ */ d("div", { className: "sa-fp-header", children: [
|
|
1996
|
+
!y && !L && /* @__PURE__ */ e(
|
|
1852
1997
|
"button",
|
|
1853
1998
|
{
|
|
1854
1999
|
className: "sa-fp-header-btn",
|
|
1855
|
-
onClick:
|
|
2000
|
+
onClick: E,
|
|
1856
2001
|
title: "展开侧边栏",
|
|
1857
|
-
children: /* @__PURE__ */ e(
|
|
2002
|
+
children: /* @__PURE__ */ e(I, { name: "panel-left", size: 18 })
|
|
1858
2003
|
}
|
|
1859
2004
|
),
|
|
1860
2005
|
/* @__PURE__ */ e("div", { className: "sa-fp-header-title", children: t }),
|
|
1861
|
-
/* @__PURE__ */
|
|
1862
|
-
l &&
|
|
2006
|
+
/* @__PURE__ */ d("div", { className: "sa-fp-header-actions", children: [
|
|
2007
|
+
l && x.length > 0 && /* @__PURE__ */ d(
|
|
1863
2008
|
"button",
|
|
1864
2009
|
{
|
|
1865
2010
|
className: "sa-fp-header-btn sa-header-btn-artifact",
|
|
1866
|
-
onClick:
|
|
2011
|
+
onClick: T,
|
|
1867
2012
|
title: "会话产物",
|
|
1868
2013
|
children: [
|
|
1869
|
-
/* @__PURE__ */
|
|
2014
|
+
/* @__PURE__ */ d(
|
|
1870
2015
|
"svg",
|
|
1871
2016
|
{
|
|
1872
2017
|
width: "14",
|
|
@@ -1891,78 +2036,81 @@ function et({
|
|
|
1891
2036
|
className: "sa-fp-header-btn",
|
|
1892
2037
|
onClick: i,
|
|
1893
2038
|
title: "关闭",
|
|
1894
|
-
children: /* @__PURE__ */ e(
|
|
2039
|
+
children: /* @__PURE__ */ e(I, { name: "x", size: 18 })
|
|
1895
2040
|
}
|
|
1896
2041
|
)
|
|
1897
2042
|
] })
|
|
1898
2043
|
] }),
|
|
1899
|
-
/* @__PURE__ */
|
|
1900
|
-
/* @__PURE__ */
|
|
1901
|
-
|
|
2044
|
+
/* @__PURE__ */ d("div", { className: "sa-fp-content-row", children: [
|
|
2045
|
+
R ? /* @__PURE__ */ d("div", { className: "sa-messages-loading", children: [
|
|
2046
|
+
/* @__PURE__ */ e("span", { className: "sa-loading-spinner" }),
|
|
2047
|
+
"加载对话..."
|
|
2048
|
+
] }) : /* @__PURE__ */ e(
|
|
2049
|
+
fe,
|
|
1902
2050
|
{
|
|
1903
|
-
slots:
|
|
2051
|
+
slots: a,
|
|
1904
2052
|
welcomeMessage: s,
|
|
1905
2053
|
suggestedPrompts: n,
|
|
1906
2054
|
avatar: o,
|
|
1907
2055
|
artifactPreview: l
|
|
1908
2056
|
}
|
|
1909
2057
|
),
|
|
1910
|
-
l &&
|
|
1911
|
-
|
|
2058
|
+
l && A && /* @__PURE__ */ e(
|
|
2059
|
+
me,
|
|
1912
2060
|
{
|
|
1913
|
-
artifacts:
|
|
1914
|
-
initialArtifact:
|
|
1915
|
-
onClose:
|
|
2061
|
+
artifacts: x,
|
|
2062
|
+
initialArtifact: z,
|
|
2063
|
+
onClose: T
|
|
1916
2064
|
}
|
|
1917
2065
|
)
|
|
1918
2066
|
] }),
|
|
1919
|
-
|
|
2067
|
+
k ? /* @__PURE__ */ e(k, { status: c, onSend: p, onStop: f }) : /* @__PURE__ */ e(ue, {})
|
|
1920
2068
|
] })
|
|
1921
2069
|
] });
|
|
1922
2070
|
}
|
|
1923
|
-
function
|
|
1924
|
-
const { sdk:
|
|
2071
|
+
function st(t) {
|
|
2072
|
+
const { sdk: a, mode: s = "floating", slots: n = {}, hooks: r = {}, welcomeMessage: i, suggestedPrompts: o, title: l = "AI Assistant", initialOpen: c = !1, onOpenChange: p, sidebarDefaultOpen: f, avatar: h, artifactPreview: w } = t, [u, m] = M(c);
|
|
1925
2073
|
B(() => {
|
|
1926
|
-
|
|
2074
|
+
m(c);
|
|
1927
2075
|
}, [c]);
|
|
1928
|
-
const
|
|
1929
|
-
var
|
|
1930
|
-
const
|
|
1931
|
-
|
|
1932
|
-
}, [
|
|
1933
|
-
var
|
|
1934
|
-
|
|
1935
|
-
}, [
|
|
1936
|
-
return s === "fullpage" ?
|
|
1937
|
-
|
|
2076
|
+
const v = C(() => {
|
|
2077
|
+
var x, z;
|
|
2078
|
+
const A = !u;
|
|
2079
|
+
m(A), p == null || p(A), A ? (x = r.onOpen) == null || x.call(r) : (z = r.onClose) == null || z.call(r);
|
|
2080
|
+
}, [u, r, p]), S = C(() => {
|
|
2081
|
+
var A;
|
|
2082
|
+
m(!1), p == null || p(!1), (A = r.onClose) == null || A.call(r);
|
|
2083
|
+
}, [r, p]), T = n.Trigger ?? Ce;
|
|
2084
|
+
return s === "fullpage" ? u ? /* @__PURE__ */ e(te, { sdk: a, hooks: r, children: /* @__PURE__ */ e(
|
|
2085
|
+
rt,
|
|
1938
2086
|
{
|
|
1939
2087
|
title: l,
|
|
1940
2088
|
slots: n,
|
|
1941
2089
|
welcomeMessage: i,
|
|
1942
2090
|
suggestedPrompts: o,
|
|
1943
|
-
sidebarDefaultOpen:
|
|
1944
|
-
onClose:
|
|
1945
|
-
avatar:
|
|
1946
|
-
artifactPreview:
|
|
2091
|
+
sidebarDefaultOpen: f,
|
|
2092
|
+
onClose: S,
|
|
2093
|
+
avatar: h,
|
|
2094
|
+
artifactPreview: w
|
|
1947
2095
|
}
|
|
1948
|
-
) }) : null : /* @__PURE__ */
|
|
1949
|
-
/* @__PURE__ */ e(
|
|
2096
|
+
) }) : null : /* @__PURE__ */ d(te, { sdk: a, hooks: r, children: [
|
|
2097
|
+
/* @__PURE__ */ e(T, { isOpen: u, onClick: v }),
|
|
1950
2098
|
/* @__PURE__ */ e(
|
|
1951
|
-
|
|
2099
|
+
tt,
|
|
1952
2100
|
{
|
|
1953
|
-
isOpen:
|
|
1954
|
-
onClose:
|
|
2101
|
+
isOpen: u,
|
|
2102
|
+
onClose: S,
|
|
1955
2103
|
title: l,
|
|
1956
2104
|
slots: n,
|
|
1957
2105
|
welcomeMessage: i,
|
|
1958
2106
|
suggestedPrompts: o,
|
|
1959
|
-
avatar:
|
|
1960
|
-
artifactPreview:
|
|
2107
|
+
avatar: h,
|
|
2108
|
+
artifactPreview: w
|
|
1961
2109
|
}
|
|
1962
2110
|
)
|
|
1963
2111
|
] });
|
|
1964
2112
|
}
|
|
1965
|
-
const
|
|
2113
|
+
const nt = `
|
|
1966
2114
|
[data-super-agent-widget] {
|
|
1967
2115
|
--sa-primary-dark: color-mix(in srgb, var(--sa-primary) 82%, #000);
|
|
1968
2116
|
--sa-primary-light: color-mix(in srgb, var(--sa-primary) 10%, #fff);
|
|
@@ -2450,14 +2598,24 @@ const at = `
|
|
|
2450
2598
|
}
|
|
2451
2599
|
|
|
2452
2600
|
.sa-tool-result-content {
|
|
2453
|
-
max-height:
|
|
2454
|
-
overflow
|
|
2601
|
+
max-height: 256px;
|
|
2602
|
+
overflow: auto;
|
|
2603
|
+
margin: 8px 0 0;
|
|
2455
2604
|
padding: 10px 12px;
|
|
2456
2605
|
color: #4b5563;
|
|
2457
2606
|
font-size: 13px;
|
|
2458
2607
|
line-height: 1.55;
|
|
2459
2608
|
white-space: pre-wrap;
|
|
2460
2609
|
word-break: break-word;
|
|
2610
|
+
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
|
|
2611
|
+
background: #f9fafb;
|
|
2612
|
+
border-radius: 8px;
|
|
2613
|
+
}
|
|
2614
|
+
|
|
2615
|
+
.sa-tool-result-actions {
|
|
2616
|
+
display: flex;
|
|
2617
|
+
gap: 8px;
|
|
2618
|
+
margin: 4px 0;
|
|
2461
2619
|
}
|
|
2462
2620
|
|
|
2463
2621
|
/* ── Error part ──────────────────────────────────────────── */
|
|
@@ -2802,6 +2960,38 @@ const at = `
|
|
|
2802
2960
|
font-size: 13px;
|
|
2803
2961
|
}
|
|
2804
2962
|
|
|
2963
|
+
.sa-thread-list-hint {
|
|
2964
|
+
padding: 8px 16px 12px;
|
|
2965
|
+
text-align: center;
|
|
2966
|
+
color: #d1d5db;
|
|
2967
|
+
font-size: 12px;
|
|
2968
|
+
}
|
|
2969
|
+
|
|
2970
|
+
/* 消息区加载态 */
|
|
2971
|
+
.sa-messages-loading {
|
|
2972
|
+
flex: 1;
|
|
2973
|
+
display: flex;
|
|
2974
|
+
align-items: center;
|
|
2975
|
+
justify-content: center;
|
|
2976
|
+
gap: 8px;
|
|
2977
|
+
color: #9ca3af;
|
|
2978
|
+
font-size: 14px;
|
|
2979
|
+
}
|
|
2980
|
+
|
|
2981
|
+
.sa-loading-spinner {
|
|
2982
|
+
width: 16px;
|
|
2983
|
+
height: 16px;
|
|
2984
|
+
border: 2px solid var(--sa-border, #e5e7eb);
|
|
2985
|
+
border-top-color: var(--sa-primary, #6366f1);
|
|
2986
|
+
border-radius: 50%;
|
|
2987
|
+
animation: sa-spin 0.8s linear infinite;
|
|
2988
|
+
flex-shrink: 0;
|
|
2989
|
+
}
|
|
2990
|
+
|
|
2991
|
+
@keyframes sa-spin {
|
|
2992
|
+
to { transform: rotate(360deg); }
|
|
2993
|
+
}
|
|
2994
|
+
|
|
2805
2995
|
.sa-thread-group-label {
|
|
2806
2996
|
padding: 16px 8px 6px;
|
|
2807
2997
|
font-size: 12px;
|
|
@@ -3522,8 +3712,9 @@ const at = `
|
|
|
3522
3712
|
.sa-artifact-file-download:active { transform: scale(0.9); }
|
|
3523
3713
|
|
|
3524
3714
|
/* ── Inline HTML rendering (render_mode=html) ── */
|
|
3525
|
-
|
|
3526
|
-
.sa-tool-result-html-
|
|
3715
|
+
/* HTML 工具结果:外层滚动容器 + 内层内容层(与 Playground 一致,无 iframe) */
|
|
3716
|
+
.sa-tool-result-html-scroll { margin-top: 8px; max-height: 60vh; overflow: auto; border: 1px solid var(--sa-border); border-radius: 8px; }
|
|
3717
|
+
.sa-tool-result-html { padding: 12px; background: #fff; min-width: 100%; width: max-content; }
|
|
3527
3718
|
|
|
3528
3719
|
/* ── Header artifact button ── */
|
|
3529
3720
|
.sa-header-btn-artifact {
|
|
@@ -3652,7 +3843,7 @@ const at = `
|
|
|
3652
3843
|
from { opacity: 0; transform: translateX(12px); }
|
|
3653
3844
|
to { opacity: 1; transform: translateX(0); }
|
|
3654
3845
|
}
|
|
3655
|
-
`,
|
|
3846
|
+
`, it = {
|
|
3656
3847
|
primaryColor: "#6366f1",
|
|
3657
3848
|
backgroundColor: "#ffffff",
|
|
3658
3849
|
fontFamily: "system-ui, -apple-system, sans-serif",
|
|
@@ -3661,28 +3852,28 @@ const at = `
|
|
|
3661
3852
|
panelHeight: 520,
|
|
3662
3853
|
zIndex: 9999
|
|
3663
3854
|
};
|
|
3664
|
-
function
|
|
3665
|
-
const s = parseInt(t.slice(1, 3), 16), n = parseInt(t.slice(3, 5), 16),
|
|
3666
|
-
return `#${Math.round(s * i).toString(16).padStart(2, "0")}${Math.round(n * i).toString(16).padStart(2, "0")}${Math.round(
|
|
3855
|
+
function ot(t, a) {
|
|
3856
|
+
const s = parseInt(t.slice(1, 3), 16), n = parseInt(t.slice(3, 5), 16), r = parseInt(t.slice(5, 7), 16), i = 1 - a;
|
|
3857
|
+
return `#${Math.round(s * i).toString(16).padStart(2, "0")}${Math.round(n * i).toString(16).padStart(2, "0")}${Math.round(r * i).toString(16).padStart(2, "0")}`;
|
|
3667
3858
|
}
|
|
3668
|
-
function
|
|
3669
|
-
const s = parseInt(t.slice(1, 3), 16), n = parseInt(t.slice(3, 5), 16),
|
|
3670
|
-
return `#${Math.round(s + (255 - s) *
|
|
3859
|
+
function lt(t, a) {
|
|
3860
|
+
const s = parseInt(t.slice(1, 3), 16), n = parseInt(t.slice(3, 5), 16), r = parseInt(t.slice(5, 7), 16);
|
|
3861
|
+
return `#${Math.round(s + (255 - s) * a).toString(16).padStart(2, "0")}${Math.round(n + (255 - n) * a).toString(16).padStart(2, "0")}${Math.round(r + (255 - r) * a).toString(16).padStart(2, "0")}`;
|
|
3671
3862
|
}
|
|
3672
|
-
function
|
|
3673
|
-
const
|
|
3863
|
+
function ct(t) {
|
|
3864
|
+
const a = { ...it, ...t }, s = a.primaryColor, n = a.backgroundColor;
|
|
3674
3865
|
return [
|
|
3675
3866
|
// 用户直接配置的变量
|
|
3676
3867
|
`--sa-primary: ${s}`,
|
|
3677
3868
|
`--sa-bg: ${n}`,
|
|
3678
|
-
`--sa-font: ${
|
|
3679
|
-
`--sa-radius: ${
|
|
3680
|
-
`--sa-panel-width: ${
|
|
3681
|
-
`--sa-panel-height: ${
|
|
3682
|
-
`--sa-z-index: ${
|
|
3869
|
+
`--sa-font: ${a.fontFamily}`,
|
|
3870
|
+
`--sa-radius: ${a.borderRadius}px`,
|
|
3871
|
+
`--sa-panel-width: ${a.panelWidth}px`,
|
|
3872
|
+
`--sa-panel-height: ${a.panelHeight}px`,
|
|
3873
|
+
`--sa-z-index: ${a.zIndex}`,
|
|
3683
3874
|
// 从 primaryColor 自动派生
|
|
3684
|
-
`--sa-primary-dark: ${
|
|
3685
|
-
`--sa-primary-light: ${
|
|
3875
|
+
`--sa-primary-dark: ${ot(s, 0.15)}`,
|
|
3876
|
+
`--sa-primary-light: ${lt(s, 0.9)}`,
|
|
3686
3877
|
// 从 backgroundColor 自动派生的语义色
|
|
3687
3878
|
`--sa-surface: ${n}`,
|
|
3688
3879
|
"--sa-border: #e5e7eb",
|
|
@@ -3692,25 +3883,25 @@ function it(t) {
|
|
|
3692
3883
|
"--sa-text-light: #6b7280"
|
|
3693
3884
|
].join("; ");
|
|
3694
3885
|
}
|
|
3695
|
-
function
|
|
3886
|
+
function ut(t, a) {
|
|
3696
3887
|
const s = typeof t == "string" ? document.querySelector(t) : t;
|
|
3697
3888
|
if (!s)
|
|
3698
3889
|
throw new Error(`Target element not found: ${t}`);
|
|
3699
3890
|
const n = document.createElement("div");
|
|
3700
3891
|
n.setAttribute("data-super-agent-widget", "");
|
|
3701
|
-
const
|
|
3702
|
-
if (n.setAttribute("style", `${
|
|
3892
|
+
const r = ct(a.theme ?? {});
|
|
3893
|
+
if (n.setAttribute("style", `${r}; height: 100%;`), s.appendChild(n), !document.getElementById("sa-widget-styles")) {
|
|
3703
3894
|
const c = document.createElement("style");
|
|
3704
|
-
c.id = "sa-widget-styles", c.textContent =
|
|
3895
|
+
c.id = "sa-widget-styles", c.textContent = nt, document.head.appendChild(c);
|
|
3705
3896
|
}
|
|
3706
|
-
let i =
|
|
3897
|
+
let i = be(n), o = !1;
|
|
3707
3898
|
const l = (c) => {
|
|
3708
3899
|
i && i.render(
|
|
3709
|
-
|
|
3710
|
-
...
|
|
3900
|
+
V.createElement(st, {
|
|
3901
|
+
...a,
|
|
3711
3902
|
initialOpen: c ?? o,
|
|
3712
|
-
onOpenChange: (
|
|
3713
|
-
o =
|
|
3903
|
+
onOpenChange: (p) => {
|
|
3904
|
+
o = p;
|
|
3714
3905
|
}
|
|
3715
3906
|
})
|
|
3716
3907
|
);
|
|
@@ -3728,31 +3919,31 @@ function dt(t, r) {
|
|
|
3728
3919
|
};
|
|
3729
3920
|
}
|
|
3730
3921
|
export {
|
|
3731
|
-
|
|
3732
|
-
|
|
3733
|
-
|
|
3734
|
-
|
|
3735
|
-
|
|
3736
|
-
|
|
3737
|
-
|
|
3738
|
-
|
|
3739
|
-
|
|
3740
|
-
|
|
3741
|
-
|
|
3742
|
-
|
|
3743
|
-
|
|
3744
|
-
|
|
3745
|
-
|
|
3746
|
-
|
|
3747
|
-
|
|
3748
|
-
|
|
3749
|
-
|
|
3750
|
-
|
|
3751
|
-
|
|
3752
|
-
|
|
3753
|
-
|
|
3754
|
-
|
|
3755
|
-
|
|
3756
|
-
|
|
3757
|
-
|
|
3922
|
+
Ve as ActionBar,
|
|
3923
|
+
te as ChatProvider,
|
|
3924
|
+
st as ChatWidget,
|
|
3925
|
+
ue as Composer,
|
|
3926
|
+
Oe as ErrorPart,
|
|
3927
|
+
rt as FullpageLayout,
|
|
3928
|
+
ze as Header,
|
|
3929
|
+
I as Icon,
|
|
3930
|
+
Ue as InterruptCard,
|
|
3931
|
+
Ge as Message,
|
|
3932
|
+
De as TextPart,
|
|
3933
|
+
Le as ThinkingPart,
|
|
3934
|
+
fe as Thread,
|
|
3935
|
+
Se as ThreadList,
|
|
3936
|
+
Ee as ToolCallPart,
|
|
3937
|
+
Re as ToolResultPart,
|
|
3938
|
+
Ce as Trigger,
|
|
3939
|
+
Je as WelcomeScreen,
|
|
3940
|
+
it as defaultTheme,
|
|
3941
|
+
Ne as ensureIconFont,
|
|
3942
|
+
ut as mount,
|
|
3943
|
+
ct as themeToCSSVars,
|
|
3944
|
+
Te as useAutoScroll,
|
|
3945
|
+
ve as useChat,
|
|
3946
|
+
Y as useChatContext,
|
|
3947
|
+
ye as useConversations,
|
|
3948
|
+
nt as widgetStyles
|
|
3758
3949
|
};
|