super-agent-sdk 1.0.5 → 1.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/widget.mjs CHANGED
@@ -1,256 +1,302 @@
1
- import Y, { useState as T, useRef as _, useCallback as N, useEffect as B, createContext as ie, useMemo as V, useContext as oe } from "react";
2
- import { createRoot as le } from "react-dom/client";
3
- import { jsx as e, jsxs as d, Fragment as q } from "react/jsx-runtime";
4
- function ce(a) {
5
- const { sdk: t, sessionId: s, onSessionCreated: r, onStreamStart: n, onStreamEnd: o, onError: i, onMessageSend: l } = a, [c, p] = T([]), [f, u] = T("ready"), [h, v] = T(null), k = _(null), g = _(!1), b = _(s);
6
- b.current = s;
7
- const m = N((M) => {
8
- if (g.current) return;
9
- g.current = !0, l == null || l(M);
10
- const O = {
1
+ import Y, { useState as D, useRef as O, useCallback as N, useEffect as B, createContext as ue, useMemo as G, useContext as me } from "react";
2
+ import { createRoot as he } from "react-dom/client";
3
+ import { jsx as e, jsxs as p, Fragment as J } from "react/jsx-runtime";
4
+ function ge(t) {
5
+ const { sdk: r, sessionId: s, onSessionCreated: n, onStreamStart: a, onStreamEnd: i, onError: o, onMessageSend: l } = t, [c, f] = D([]), [u, d] = D("ready"), [m, g] = D(null), x = O(null), w = O(!1), T = O(s), L = O(!0);
6
+ T.current = s, L.current = c.length === 0;
7
+ const E = N((y) => {
8
+ if (w.current) return;
9
+ w.current = !0, l == null || l(y);
10
+ const b = {
11
11
  id: `user_${Date.now()}`,
12
12
  role: "user",
13
- parts: [{ type: "text", content: M }],
13
+ parts: [{ type: "text", content: y }],
14
14
  timestamp: Date.now()
15
- }, y = `assistant_${Date.now()}`, L = {
16
- id: y,
15
+ }, v = `assistant_${Date.now()}`, C = {
16
+ id: v,
17
17
  role: "assistant",
18
18
  parts: [],
19
19
  timestamp: Date.now()
20
- };
21
- p((S) => [...S, O, L]), u("submitted"), v(null);
22
- const $ = (S) => {
23
- let E = "", A = "", H = [], z = !1;
24
- const P = () => {
25
- const w = [...H];
26
- if (E) {
27
- const W = w.findIndex((R) => R.type === "thinking");
28
- W >= 0 ? w[W] = { type: "thinking", content: E } : w.unshift({ type: "thinking", content: E });
29
- }
20
+ }, P = L.current;
21
+ f((S) => [...S, b, C]), d("submitted"), g(null);
22
+ const R = (S) => {
23
+ let A = "", j = "", I = [], _ = !1;
24
+ const H = () => {
25
+ const $ = [...I];
30
26
  if (A) {
31
- const W = w.findLastIndex((R) => R.type === "text");
32
- W >= 0 ? w[W] = { type: "text", content: A } : w.push({ type: "text", content: A });
27
+ const W = $.findIndex((F) => F.type === "thinking");
28
+ W >= 0 ? $[W] = { type: "thinking", content: A } : $.unshift({ type: "thinking", content: A });
29
+ }
30
+ if (j) {
31
+ const W = $.findLastIndex((F) => F.type === "text");
32
+ W >= 0 ? $[W] = { type: "text", content: j } : $.push({ type: "text", content: j });
33
33
  }
34
- p(
35
- (W) => W.map((R) => R.id === y ? { ...R, parts: w } : R)
34
+ f(
35
+ (W) => W.map((F) => F.id === v ? { ...F, parts: $ } : F)
36
36
  );
37
37
  };
38
- k.current = t.chat({
38
+ x.current = r.chat({
39
39
  sessionId: S,
40
- message: M,
40
+ message: y,
41
41
  stream: !0,
42
- onMessage: (w) => {
43
- switch (z || (z = !0, u("streaming")), w.type) {
42
+ onMessage: ($) => {
43
+ switch (_ || (_ = !0, d("streaming")), $.type) {
44
44
  case "thinking":
45
- E += w.content;
45
+ A += $.content;
46
46
  break;
47
47
  case "ai":
48
- A += w.content;
48
+ j += $.content;
49
49
  break;
50
50
  case "tool_call":
51
- H.push({
51
+ I.push({
52
52
  type: "tool_call",
53
- toolName: w.toolName,
54
- toolCallId: w.toolCallId,
55
- args: w.args ?? "{}"
53
+ toolName: $.toolName,
54
+ toolCallId: $.toolCallId,
55
+ args: $.args ?? "{}"
56
56
  });
57
57
  break;
58
58
  case "tool_result":
59
- H.push({
59
+ I.push({
60
60
  type: "tool_result",
61
- toolName: w.toolName ?? "",
62
- toolCallId: w.toolCallId,
63
- content: w.content,
64
- artifacts: w.artifacts,
65
- renderMode: w.renderMode,
66
- html: w.html
67
- }), A && (H.push({ type: "text", content: A }), A = "");
61
+ toolName: $.toolName ?? "",
62
+ toolCallId: $.toolCallId,
63
+ content: $.content,
64
+ artifacts: $.artifacts,
65
+ renderMode: $.renderMode,
66
+ html: $.html
67
+ }), j && (I.push({ type: "text", content: j }), j = "");
68
68
  break;
69
69
  case "interrupt":
70
- w.interrupt && H.push({
70
+ $.interrupt && I.push({
71
71
  type: "interrupt",
72
- interrupt: w.interrupt,
72
+ interrupt: $.interrupt,
73
73
  resolved: !1
74
74
  });
75
75
  break;
76
+ case "stop":
77
+ $.content && (j = $.content), H();
78
+ return;
76
79
  }
77
- P();
80
+ H();
78
81
  },
79
- onDone: (w) => {
80
- (A || H.length > 0 || E) && P(), w.messageId && p(
81
- (W) => W.map((R) => R.id === y ? { ...R, id: w.messageId } : R)
82
- ), w.sessionId && w.sessionId !== b.current && (r == null || r(w.sessionId)), o == null || o(w.sessionId || S), u("ready"), g.current = !1, k.current = null;
82
+ onDone: ($) => {
83
+ (j || I.length > 0 || A) && H(), $.messageId && f(
84
+ (F) => F.map((V) => V.id === v ? { ...V, id: $.messageId } : V)
85
+ ), $.sessionId && $.sessionId !== T.current && (n == null || n($.sessionId));
86
+ const W = () => {
87
+ i == null || i($.sessionId || S), d("ready"), w.current = !1, x.current = null;
88
+ };
89
+ if (P) {
90
+ const F = y.slice(0, 30), V = $.sessionId || S;
91
+ r.renameConversation(V, F).catch(() => {
92
+ }).finally(W);
93
+ } else
94
+ W();
83
95
  },
84
- onError: (w) => {
85
- H.push({ type: "error", content: w.message }), P(), v(w), u("error"), i == null || i(w), g.current = !1, k.current = null;
96
+ onError: ($) => {
97
+ I.push({ type: "error", content: $.message }), H(), g($), d("error"), o == null || o($), w.current = !1, x.current = null;
86
98
  }
87
- }), n == null || n(S);
99
+ }), a == null || a(S);
88
100
  };
89
- b.current ? $(b.current) : t.createSession().then((S) => {
90
- b.current = S, r == null || r(S), $(S);
101
+ T.current ? R(T.current) : r.createSession().then((S) => {
102
+ T.current = S, n == null || n(S), R(S);
91
103
  }).catch((S) => {
92
- v(S instanceof Error ? S : new Error(String(S))), u("error"), i == null || i(S instanceof Error ? S : new Error(String(S))), g.current = !1;
104
+ g(S instanceof Error ? S : new Error(String(S))), d("error"), o == null || o(S instanceof Error ? S : new Error(String(S))), w.current = !1;
93
105
  });
94
- }, [t, r, n, o, i, l]), x = N(() => {
95
- var M;
96
- (M = k.current) == null || M.abort(), k.current = null, u("ready"), g.current = !1;
97
- }, []), I = N(() => {
98
- if (g.current) return;
99
- const M = c.findLastIndex((y) => y.role === "user");
100
- if (M < 0) return;
101
- const O = c[M].parts.filter((y) => y.type === "text").map((y) => y.content).join("");
102
- p((y) => y.slice(0, M)), m(O);
103
- }, [c, m]), D = N((M, O) => {
104
- p(
105
- (z) => z.map((P) => ({
106
- ...P,
107
- parts: P.parts.map(
108
- (w) => w.type === "interrupt" && w.interrupt.interruptId === M ? { ...w, resolved: !0, response: O } : w
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(() => {
110
+ });
111
+ }, [r]), h = N(() => {
112
+ if (w.current) return;
113
+ const y = c.findLastIndex((v) => v.role === "user");
114
+ if (y < 0) return;
115
+ const b = c[y].parts.filter((v) => v.type === "text").map((v) => v.content).join("");
116
+ f((v) => v.slice(0, y)), E(b);
117
+ }, [c, E]), M = N((y, b) => {
118
+ f(
119
+ (I) => I.map((_) => ({
120
+ ..._,
121
+ parts: _.parts.map(
122
+ (H) => H.type === "interrupt" && H.interrupt.interruptId === y ? { ...H, resolved: !0, response: b } : H
109
123
  )
110
124
  }))
111
125
  );
112
- const y = b.current;
113
- if (!y) return;
114
- const L = `assistant_${Date.now()}`, $ = {
115
- id: L,
126
+ const v = T.current;
127
+ if (!v) return;
128
+ const C = `assistant_${Date.now()}`, P = {
129
+ id: C,
116
130
  role: "assistant",
117
131
  parts: [],
118
132
  timestamp: Date.now()
119
133
  };
120
- p((z) => [...z, $]), u("streaming");
121
- let S = "", E = "", A = [];
122
- const H = () => {
123
- const z = [...A];
124
- if (S) {
125
- const P = z.findIndex((w) => w.type === "thinking");
126
- P >= 0 ? z[P] = { type: "thinking", content: S } : z.unshift({ type: "thinking", content: S });
134
+ f((I) => [...I, P]), d("streaming");
135
+ let R = "", S = "", A = [];
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 });
127
141
  }
128
- if (E) {
129
- const P = z.findLastIndex((w) => w.type === "text");
130
- P >= 0 ? z[P] = { type: "text", content: E } : z.push({ type: "text", content: E });
142
+ if (S) {
143
+ const _ = I.findLastIndex((H) => H.type === "text");
144
+ _ >= 0 ? I[_] = { type: "text", content: S } : I.push({ type: "text", content: S });
131
145
  }
132
- p(
133
- (P) => P.map((w) => w.id === L ? { ...w, parts: z } : w)
146
+ f(
147
+ (_) => _.map((H) => H.id === C ? { ...H, parts: I } : H)
134
148
  );
135
149
  };
136
- t.respondInterrupt(
137
- M,
150
+ r.respondInterrupt(
138
151
  y,
139
- O,
140
- (z) => {
141
- switch (z.type) {
152
+ v,
153
+ b,
154
+ (I) => {
155
+ switch (I.type) {
142
156
  case "thinking":
143
- S += z.content;
157
+ R += I.content;
144
158
  break;
145
159
  case "ai":
146
- E += z.content;
160
+ S += I.content;
147
161
  break;
148
162
  case "tool_call":
149
163
  A.push({
150
164
  type: "tool_call",
151
- toolName: z.toolName,
152
- toolCallId: z.toolCallId,
153
- args: z.args ?? "{}"
165
+ toolName: I.toolName,
166
+ toolCallId: I.toolCallId,
167
+ args: I.args ?? "{}"
154
168
  });
155
169
  break;
156
170
  case "tool_result":
157
171
  A.push({
158
172
  type: "tool_result",
159
- toolName: z.toolName ?? "",
160
- toolCallId: z.toolCallId,
161
- content: z.content,
162
- artifacts: z.artifacts,
163
- renderMode: z.renderMode,
164
- html: z.html
165
- }), E && (A.push({ type: "text", content: E }), E = "");
173
+ toolName: I.toolName ?? "",
174
+ toolCallId: I.toolCallId,
175
+ content: I.content,
176
+ artifacts: I.artifacts,
177
+ renderMode: I.renderMode,
178
+ html: I.html
179
+ }), S && (A.push({ type: "text", content: S }), S = "");
166
180
  break;
167
181
  case "interrupt":
168
- z.interrupt && A.push({ type: "interrupt", interrupt: z.interrupt, resolved: !1 });
182
+ I.interrupt && A.push({ type: "interrupt", interrupt: I.interrupt, resolved: !1 });
169
183
  break;
170
184
  case "done":
171
- u("ready");
185
+ I.messageId && f(
186
+ (_) => _.map((H) => H.id === C ? { ...H, id: I.messageId } : H)
187
+ ), d("ready");
172
188
  break;
173
189
  }
174
- H();
190
+ j();
175
191
  },
176
- (z) => {
177
- A.push({ type: "error", content: z.message }), H(), v(z), u("error"), i == null || i(z);
192
+ (I) => {
193
+ A.push({ type: "error", content: I.message }), j(), g(I), d("error"), o == null || o(I);
178
194
  }
179
- ).catch((z) => {
180
- i == null || i(z instanceof Error ? z : new Error(String(z))), u("error");
195
+ ).catch((I) => {
196
+ o == null || o(I instanceof Error ? I : new Error(String(I))), d("error");
181
197
  });
182
- }, [t, i]);
183
- return { messages: c, status: f, error: h, sendMessage: m, stop: x, regenerate: I, setMessages: p, respondToInterrupt: D };
198
+ }, [r, o]);
199
+ return { messages: c, status: u, error: m, sendMessage: E, stop: k, regenerate: h, setMessages: f, respondToInterrupt: M };
184
200
  }
185
- const X = "sa_active_conversation";
186
- function J() {
201
+ const ee = "sa_active_conversation", Q = 20;
202
+ function te() {
187
203
  try {
188
- return localStorage.getItem(X);
204
+ return localStorage.getItem(ee);
189
205
  } catch {
190
206
  return null;
191
207
  }
192
208
  }
193
- function de(a) {
209
+ function xe(t) {
194
210
  try {
195
- a ? localStorage.setItem(X, a) : localStorage.removeItem(X);
211
+ t ? localStorage.setItem(ee, t) : localStorage.removeItem(ee);
196
212
  } catch {
197
213
  }
198
214
  }
199
- function pe(a) {
200
- const { sdk: t, onConversationChange: s } = a, [r, n] = T([]), [o, i] = T(
201
- () => J()
202
- ), [l, c] = T(!1), p = _(!0);
215
+ function be(t) {
216
+ const { sdk: r, onConversationChange: s } = t, [n, a] = D([]), [i, o] = D(
217
+ () => te()
218
+ ), [l, c] = D(!1), [f, u] = D(!0), d = O(!0), m = O(1), g = O(!1);
203
219
  B(() => () => {
204
- p.current = !1;
220
+ d.current = !1;
205
221
  }, []);
206
- const f = N((m) => {
207
- i(m), de(m), m && (s == null || s(m));
208
- }, [s]), u = N(async () => {
209
- c(!0);
222
+ const x = N((y) => {
223
+ o(y), xe(y), y && (s == null || s(y));
224
+ }, [s]), w = N(async () => {
225
+ if (!g.current) {
226
+ g.current = !0, c(!0);
227
+ try {
228
+ m.current = 1;
229
+ const y = await r.listConversations({ page: 1, size: Q });
230
+ if (!d.current) return;
231
+ a(y.items), u(y.items.length < y.total);
232
+ const b = te();
233
+ b && !y.items.find((v) => v.sessionId === b) && x(null);
234
+ } catch {
235
+ } finally {
236
+ g.current = !1, d.current && c(!1);
237
+ }
238
+ }
239
+ }, [r, x]), T = N(async () => {
240
+ if (!(g.current || !f)) {
241
+ g.current = !0, c(!0);
242
+ try {
243
+ const y = m.current + 1, b = await r.listConversations({ page: y, size: Q });
244
+ if (!d.current) return;
245
+ m.current = y, a((C) => {
246
+ const P = new Set(C.map((S) => S.sessionId)), R = b.items.filter((S) => !P.has(S.sessionId));
247
+ return [...C, ...R];
248
+ });
249
+ const v = m.current * Q;
250
+ u(v < b.total);
251
+ } catch {
252
+ } finally {
253
+ g.current = !1, d.current && c(!1);
254
+ }
255
+ }
256
+ }, [r, f]), L = N(async (y) => (x(y), await r.getMessages(y)), [r, x]), E = N(async () => {
210
257
  try {
211
- const m = await t.listConversations({ page: 1, size: 100 });
212
- if (!p.current) return;
213
- n(m.items);
214
- const x = J();
215
- x && !m.items.find((I) => I.sessionId === x) && f(null);
258
+ const y = await r.createSession(), b = (/* @__PURE__ */ new Date()).toISOString();
259
+ a((v) => [
260
+ { sessionId: y, botId: 0, title: "新对话", createTime: b, updateTime: b },
261
+ ...v
262
+ ]), x(y);
216
263
  } catch {
217
- } finally {
218
- p.current && c(!1);
264
+ x(null);
219
265
  }
220
- }, [t, f]), h = N(async (m) => (f(m), await t.getMessages(m)), [t, f]), v = N(() => {
221
- f(null);
222
- }, [f]), k = N(async (m) => {
223
- await t.deleteConversation(m), n((x) => x.filter((I) => I.sessionId !== m)), o === m && f(null);
224
- }, [t, o, f]), g = N(async (m, x) => {
225
- await t.renameConversation(m, x), n(
226
- (I) => I.map((D) => D.sessionId === m ? { ...D, title: x } : D)
266
+ }, [r, x]), k = N(async (y) => {
267
+ await r.deleteConversation(y), a((b) => b.filter((v) => v.sessionId !== y)), i === y && x(null);
268
+ }, [r, i, x]), h = N(async (y, b) => {
269
+ await r.renameConversation(y, b), a(
270
+ (v) => v.map((C) => C.sessionId === y ? { ...C, title: b } : C)
227
271
  );
228
- }, [t]), { enabled: b = !0 } = a;
272
+ }, [r]), { enabled: M = !0 } = t;
229
273
  return B(() => {
230
- b && u();
231
- }, [b, u]), {
232
- conversations: r,
233
- activeConversationId: o,
274
+ M && w();
275
+ }, [M, w]), {
276
+ conversations: n,
277
+ activeConversationId: i,
234
278
  loading: l,
235
- loadConversations: u,
236
- switchConversation: h,
237
- newConversation: v,
279
+ hasMore: f,
280
+ loadConversations: w,
281
+ loadMore: T,
282
+ switchConversation: L,
283
+ newConversation: E,
238
284
  deleteConversation: k,
239
- renameConversation: g,
240
- setActiveConversationId: f
285
+ renameConversation: h,
286
+ setActiveConversationId: x
241
287
  };
242
288
  }
243
- function Q(a) {
244
- return !a && a !== 0 ? "" : a < 1024 ? `${a} B` : a < 1024 * 1024 ? `${(a / 1024).toFixed(1)} KB` : `${(a / 1024 / 1024).toFixed(1)} MB`;
289
+ function ne(t) {
290
+ return !t && t !== 0 ? "" : t < 1024 ? `${t} B` : t < 1024 * 1024 ? `${(t / 1024).toFixed(1)} KB` : `${(t / 1024 / 1024).toFixed(1)} MB`;
245
291
  }
246
- function ee(a) {
247
- return a === "pdf" ? "PDF" : a === "docx" ? "DOC" : a === "html" ? "HTM" : a.slice(0, 3).toUpperCase() || "FILE";
292
+ function ie(t) {
293
+ return t === "pdf" ? "PDF" : t === "docx" ? "DOC" : t === "html" ? "HTM" : t.slice(0, 3).toUpperCase() || "FILE";
248
294
  }
249
- function ae(a) {
250
- if (!a) return [];
251
- const t = [];
252
- for (const s of a)
253
- s.type === "file" && s.data && t.push({
295
+ function oe(t) {
296
+ if (!t) return [];
297
+ const r = [];
298
+ for (const s of t)
299
+ s.type === "file" && s.data && r.push({
254
300
  id: s.data.id ?? "",
255
301
  type: s.data.fileType ?? s.data.type ?? "",
256
302
  filename: s.data.name ?? s.data.filename ?? "",
@@ -259,757 +305,870 @@ function ae(a) {
259
305
  size: s.data.size,
260
306
  summary: s.data.summary
261
307
  });
262
- return t;
308
+ return r;
263
309
  }
264
- async function U(a) {
310
+ async function Z(t) {
265
311
  try {
266
- const t = await fetch(a.url);
267
- if (!t.ok) throw new Error(`HTTP ${t.status}`);
268
- const s = await t.blob(), r = URL.createObjectURL(s), n = document.createElement("a");
269
- n.href = r, n.download = a.filename, document.body.appendChild(n), n.click(), n.remove(), setTimeout(() => URL.revokeObjectURL(r), 4e3);
312
+ const r = await fetch(t.url);
313
+ if (!r.ok) throw new Error(`HTTP ${r.status}`);
314
+ const s = await r.blob(), n = URL.createObjectURL(s), a = document.createElement("a");
315
+ a.href = n, a.download = t.filename, document.body.appendChild(a), a.click(), a.remove(), setTimeout(() => URL.revokeObjectURL(n), 4e3);
270
316
  } catch {
271
- const t = document.createElement("a");
272
- t.href = a.url, t.download = a.filename, t.target = "_blank", document.body.appendChild(t), t.click(), t.remove();
317
+ const r = document.createElement("a");
318
+ r.href = t.url, r.download = t.filename, r.target = "_blank", document.body.appendChild(r), r.click(), r.remove();
273
319
  }
274
320
  }
275
- const te = ie(null);
276
- function F() {
277
- const a = oe(te);
278
- if (!a) throw new Error("useChatContext must be used within ChatProvider");
279
- return a;
321
+ const le = ue(null);
322
+ function U() {
323
+ const t = me(le);
324
+ if (!t) throw new Error("useChatContext must be used within ChatProvider");
325
+ return t;
280
326
  }
281
- function G({ sdk: a, hooks: t, children: s }) {
282
- const [r, n] = T(!1), [o, i] = T(!1), [l, c] = T(null), [p, f] = T(!1);
327
+ function ae({ sdk: t, hooks: r, children: s }) {
328
+ const [n, a] = D(!1), [i, o] = D(!1), [l, c] = D(null), [f, u] = D(!1);
283
329
  B(() => {
284
- a.getToken().then(() => {
285
- f(!0);
330
+ t.getToken().then(() => {
331
+ u(!0);
286
332
  }).catch(() => {
287
- f(!0);
333
+ u(!0);
288
334
  });
289
- }, [a]);
290
- const u = pe({
291
- sdk: a,
292
- onConversationChange: t == null ? void 0 : t.onConversationChange,
293
- enabled: p
294
- }), h = ce({
295
- sdk: a,
296
- sessionId: u.activeConversationId,
297
- onSessionCreated: (y) => {
298
- u.setActiveConversationId(y), u.loadConversations();
335
+ }, [t]);
336
+ const d = be({
337
+ sdk: t,
338
+ onConversationChange: r == null ? void 0 : r.onConversationChange,
339
+ enabled: f
340
+ }), m = ge({
341
+ sdk: t,
342
+ sessionId: d.activeConversationId,
343
+ onSessionCreated: (b) => {
344
+ d.setActiveConversationId(b);
299
345
  },
300
- onStreamStart: t == null ? void 0 : t.onStreamStart,
301
- onStreamEnd: (y) => {
302
- var L;
303
- (L = t == null ? void 0 : t.onStreamEnd) == null || L.call(t, y), u.loadConversations();
346
+ onStreamStart: r == null ? void 0 : r.onStreamStart,
347
+ onStreamEnd: (b) => {
348
+ var v;
349
+ (v = r == null ? void 0 : r.onStreamEnd) == null || v.call(r, b), d.loadConversations();
304
350
  },
305
- onError: t == null ? void 0 : t.onError,
306
- onMessageSend: t == null ? void 0 : t.onMessageSend
307
- }), v = N(async (y) => {
308
- const L = await u.switchConversation(y);
309
- h.setMessages(L), n(!1);
310
- }, [u, h]), k = N(() => {
311
- u.newConversation(), h.setMessages([]), n(!1);
312
- }, [u, h]), g = N(async (y) => {
313
- await u.deleteConversation(y), u.activeConversationId === y && h.setMessages([]);
314
- }, [u, h]);
351
+ onError: r == null ? void 0 : r.onError,
352
+ onMessageSend: r == null ? void 0 : r.onMessageSend
353
+ }), g = N(async (b) => {
354
+ const v = await d.switchConversation(b);
355
+ m.setMessages(v), a(!1);
356
+ }, [d, m]), x = N(async () => {
357
+ m.setMessages([]), a(!1), await d.newConversation();
358
+ }, [d, m]), w = N(async (b) => {
359
+ await d.deleteConversation(b), d.activeConversationId === b && m.setMessages([]);
360
+ }, [d, m]);
315
361
  B(() => {
316
- u.activeConversationId && h.messages.length === 0 && a.getMessages(u.activeConversationId).then((y) => {
317
- h.setMessages(y);
362
+ d.activeConversationId && m.messages.length === 0 && t.getMessages(d.activeConversationId).then((b) => {
363
+ m.setMessages(b);
318
364
  }).catch(() => {
319
365
  });
320
366
  }, []);
321
- const b = N(() => {
322
- n((y) => !y);
323
- }, []), m = N(() => {
324
- i((y) => !y), c((y) => null);
325
- }, []), x = N((y) => {
326
- c(y), i(!0);
327
- }, []), I = V(() => {
328
- const y = /* @__PURE__ */ new Set(), L = [];
329
- for (const $ of h.messages)
330
- for (const S of $.parts)
331
- if (S.type === "tool_result" && S.artifacts)
332
- for (const E of ae(S.artifacts)) {
333
- const A = E.id || `${E.url}:${E.filename}`;
334
- y.has(A) || (y.add(A), L.push(E));
367
+ const T = N(() => {
368
+ a((b) => !b);
369
+ }, []), L = N(() => {
370
+ o((b) => !b), c((b) => null);
371
+ }, []), E = N((b) => {
372
+ c(b), o(!0);
373
+ }, []), k = G(() => {
374
+ const b = /* @__PURE__ */ new Set(), v = [];
375
+ for (const C of m.messages)
376
+ for (const P of C.parts)
377
+ if (P.type === "tool_result" && P.artifacts)
378
+ for (const R of oe(P.artifacts)) {
379
+ const S = R.id || `${R.url}:${R.filename}`;
380
+ b.has(S) || (b.add(S), v.push(R));
335
381
  }
336
- return L;
337
- }, [h.messages]), D = N((y, L, $) => {
338
- a.feedback(y, L, $).catch(() => {
382
+ return v;
383
+ }, [m.messages]), h = N((b, v, C) => {
384
+ t.feedback(b, v, C).catch(() => {
339
385
  });
340
- }, [a]), M = N((y) => {
341
- a.cancelFeedback(y).catch(() => {
386
+ }, [t]), M = N((b) => {
387
+ t.cancelFeedback(b).catch(() => {
342
388
  });
343
- }, [a]), O = V(() => ({
344
- status: h.status,
345
- error: h.error,
346
- messages: h.messages,
347
- conversations: u.conversations,
348
- activeConversationId: u.activeConversationId,
349
- isThreadListOpen: r,
350
- isArtifactDrawerOpen: o,
351
- allArtifacts: I,
389
+ }, [t]), y = G(() => ({
390
+ sdk: t,
391
+ status: m.status,
392
+ error: m.error,
393
+ messages: m.messages,
394
+ conversations: d.conversations,
395
+ activeConversationId: d.activeConversationId,
396
+ isThreadListOpen: n,
397
+ isArtifactDrawerOpen: i,
398
+ allArtifacts: k,
352
399
  activePreviewArtifact: l,
353
- sendMessage: h.sendMessage,
354
- stop: h.stop,
355
- regenerate: h.regenerate,
356
- switchConversation: v,
357
- newConversation: k,
358
- deleteConversation: g,
359
- renameConversation: u.renameConversation,
360
- toggleThreadList: b,
361
- toggleArtifactDrawer: m,
362
- openArtifactPreview: x,
363
- feedback: D,
400
+ hasMore: d.hasMore,
401
+ sendMessage: m.sendMessage,
402
+ stop: m.stop,
403
+ regenerate: m.regenerate,
404
+ switchConversation: g,
405
+ newConversation: x,
406
+ deleteConversation: w,
407
+ renameConversation: d.renameConversation,
408
+ loadMoreConversations: d.loadMore,
409
+ toggleThreadList: T,
410
+ toggleArtifactDrawer: L,
411
+ openArtifactPreview: E,
412
+ feedback: h,
364
413
  cancelFeedback: M,
365
- respondToInterrupt: h.respondToInterrupt
414
+ respondToInterrupt: m.respondToInterrupt
366
415
  }), [
367
- h.status,
368
- h.error,
369
- h.messages,
370
- h.sendMessage,
371
- h.stop,
372
- h.regenerate,
373
- h.respondToInterrupt,
374
- u.conversations,
375
- u.activeConversationId,
376
- u.renameConversation,
377
- r,
378
- o,
379
- I,
380
- l,
381
- v,
416
+ t,
417
+ m.status,
418
+ m.error,
419
+ m.messages,
420
+ m.sendMessage,
421
+ m.stop,
422
+ m.regenerate,
423
+ m.respondToInterrupt,
424
+ d.conversations,
425
+ d.activeConversationId,
426
+ d.renameConversation,
427
+ d.hasMore,
428
+ d.loadMore,
429
+ n,
430
+ i,
382
431
  k,
432
+ l,
383
433
  g,
384
- b,
385
- m,
386
434
  x,
387
- D,
435
+ w,
436
+ T,
437
+ L,
438
+ E,
439
+ h,
388
440
  M
389
441
  ]);
390
- return /* @__PURE__ */ e(te.Provider, { value: O, children: s });
442
+ return /* @__PURE__ */ e(le.Provider, { value: y, children: s });
443
+ }
444
+ const ve = "https://at.alicdn.com/t/c/font_5210396_pffyg5g21kn.js";
445
+ let re = !1;
446
+ function we(t = ve) {
447
+ if (re || typeof document > "u") return;
448
+ re = !0;
449
+ const r = t.split("?")[0].split("/").pop();
450
+ if (r && document.querySelector(`script[src*="${r}"]`)) return;
451
+ const s = document.createElement("script");
452
+ s.src = t, document.head.appendChild(s);
391
453
  }
392
- function C({ name: a, size: t = 16, color: s = "currentColor", className: r, style: n }) {
454
+ we();
455
+ function z({ name: t, size: r = 16, color: s = "currentColor", className: n, style: a }) {
393
456
  return /* @__PURE__ */ e(
394
457
  "svg",
395
458
  {
396
- className: r,
397
- style: { width: t, height: t, fill: s, verticalAlign: "middle", ...n },
459
+ className: n,
460
+ style: { width: r, height: r, fill: s, verticalAlign: "middle", ...a },
398
461
  "aria-hidden": "true",
399
- children: /* @__PURE__ */ e("use", { href: `#icon-${a}` })
462
+ children: /* @__PURE__ */ e("use", { href: `#icon-${t}` })
400
463
  }
401
464
  );
402
465
  }
403
- function fe({ isOpen: a, onClick: t }) {
404
- return /* @__PURE__ */ e("button", { className: `sa-trigger ${a ? "sa-trigger-open" : ""}`, onClick: t, children: a ? /* @__PURE__ */ e(C, { name: "x", size: 24, color: "#fff" }) : /* @__PURE__ */ e(C, { name: "message-square", size: 24, color: "#fff" }) });
466
+ function ye({ isOpen: t, onClick: r }) {
467
+ return /* @__PURE__ */ e("button", { className: `sa-trigger ${t ? "sa-trigger-open" : ""}`, onClick: r, children: t ? /* @__PURE__ */ e(z, { name: "x", size: 24, color: "#fff" }) : /* @__PURE__ */ e(z, { name: "message-square", size: 24, color: "#fff" }) });
405
468
  }
406
- function ue({ title: a, onClose: t, onToggleThreadList: s, showClose: r = !0, artifactCount: n = 0, onToggleArtifactDrawer: o }) {
407
- return /* @__PURE__ */ d("div", { className: "sa-header", children: [
408
- /* @__PURE__ */ d("div", { className: "sa-header-left", children: [
469
+ function ke({ title: t, onClose: r, onToggleThreadList: s, showClose: n = !0, artifactCount: a = 0, onToggleArtifactDrawer: i }) {
470
+ return /* @__PURE__ */ p("div", { className: "sa-header", children: [
471
+ /* @__PURE__ */ p("div", { className: "sa-header-left", children: [
409
472
  /* @__PURE__ */ e("div", { className: "sa-header-avatar", children: "A" }),
410
- /* @__PURE__ */ d("div", { className: "sa-header-info", children: [
411
- /* @__PURE__ */ e("div", { className: "sa-header-title", children: a }),
473
+ /* @__PURE__ */ p("div", { className: "sa-header-info", children: [
474
+ /* @__PURE__ */ e("div", { className: "sa-header-title", children: t }),
412
475
  /* @__PURE__ */ e("div", { className: "sa-header-status", children: "● Online" })
413
476
  ] })
414
477
  ] }),
415
- /* @__PURE__ */ d("div", { className: "sa-header-actions", children: [
416
- n > 0 && o && /* @__PURE__ */ d("button", { className: "sa-header-btn sa-header-btn-artifact", onClick: o, title: "会话产物", children: [
417
- /* @__PURE__ */ d("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: [
478
+ /* @__PURE__ */ p("div", { className: "sa-header-actions", children: [
479
+ a > 0 && i && /* @__PURE__ */ p("button", { className: "sa-header-btn sa-header-btn-artifact", onClick: i, title: "会话产物", children: [
480
+ /* @__PURE__ */ p("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: [
418
481
  /* @__PURE__ */ e("path", { d: "M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z" }),
419
482
  /* @__PURE__ */ e("polyline", { points: "14 2 14 8 20 8" })
420
483
  ] }),
421
484
  /* @__PURE__ */ e("span", { children: "产物" })
422
485
  ] }),
423
- /* @__PURE__ */ e("button", { className: "sa-header-btn", onClick: s, title: "会话列表", children: /* @__PURE__ */ e(C, { name: "menu", size: 16 }) }),
424
- r && /* @__PURE__ */ e("button", { className: "sa-header-btn", onClick: t, title: "关闭", children: /* @__PURE__ */ e(C, { name: "x", size: 16 }) })
486
+ /* @__PURE__ */ e("button", { className: "sa-header-btn", onClick: s, title: "会话列表", children: /* @__PURE__ */ e(z, { name: "menu", size: 16 }) }),
487
+ n && /* @__PURE__ */ e("button", { className: "sa-header-btn", onClick: r, title: "关闭", children: /* @__PURE__ */ e(z, { name: "x", size: 16 }) })
425
488
  ] })
426
489
  ] });
427
490
  }
428
- function me(a) {
429
- const t = /* @__PURE__ */ new Date(), s = new Date(t.getFullYear(), t.getMonth(), t.getDate()).getTime(), r = s - 6 * 864e5, n = [], o = [], i = [];
430
- for (const c of a) {
431
- const p = new Date(c.updateTime).getTime();
432
- p >= s ? n.push(c) : p >= r ? o.push(c) : i.push(c);
491
+ const X = (t) => String(t).padStart(2, "0");
492
+ function ce(t) {
493
+ if (!t) return "";
494
+ const r = new Date(t);
495
+ return isNaN(r.getTime()) ? "" : `${r.getFullYear()}-${X(r.getMonth() + 1)}-${X(r.getDate())} ${X(r.getHours())}:${X(r.getMinutes())}:${X(r.getSeconds())}`;
496
+ }
497
+ function Ne(t) {
498
+ const r = /* @__PURE__ */ new Date(), s = new Date(
499
+ r.getFullYear(),
500
+ r.getMonth(),
501
+ r.getDate()
502
+ ).getTime(), n = s - 6 * 864e5, a = [], i = [], o = [];
503
+ for (const c of t) {
504
+ const f = new Date(c.updateTime).getTime();
505
+ f >= s ? a.push(c) : f >= n ? i.push(c) : o.push(c);
433
506
  }
434
507
  const l = [];
435
- return n.length && l.push({ label: "今天", items: n }), o.length && l.push({ label: "最近 7 天", items: o }), i.length && l.push({ label: "更早", items: i }), l;
508
+ return a.length && l.push({ label: "今天", items: a }), i.length && l.push({ label: "最近 7 天", items: i }), o.length && l.push({ label: "更早", items: o }), l;
436
509
  }
437
- function he() {
510
+ function Ce() {
438
511
  const {
439
- conversations: a,
440
- activeConversationId: t,
512
+ conversations: t,
513
+ activeConversationId: r,
441
514
  switchConversation: s,
442
- newConversation: r,
443
- deleteConversation: n,
444
- renameConversation: o,
445
- isThreadListOpen: i,
446
- toggleThreadList: l
447
- } = F(), [c, p] = T(null), [f, u] = T(""), h = N((g, b) => {
448
- p(g), u(b ?? "");
449
- }, []), v = N((g) => {
450
- f.trim() && o(g, f.trim()), p(null);
451
- }, [f, o]), k = V(() => me(a), [a]);
452
- return i ? /* @__PURE__ */ d(q, { children: [
515
+ newConversation: n,
516
+ deleteConversation: a,
517
+ renameConversation: i,
518
+ isThreadListOpen: o,
519
+ toggleThreadList: l,
520
+ hasMore: c,
521
+ loadMoreConversations: f
522
+ } = U(), [u, d] = D(null), [m, g] = D(""), x = O(null), w = N(
523
+ (k, h) => {
524
+ d(k), g(h ?? "");
525
+ },
526
+ []
527
+ ), T = N(
528
+ (k) => {
529
+ m.trim() && i(k, m.trim()), d(null);
530
+ },
531
+ [m, i]
532
+ ), L = N(() => {
533
+ const k = x.current;
534
+ !k || !c || k.scrollHeight - k.scrollTop - k.clientHeight < 50 && f();
535
+ }, [c, f]), E = G(() => Ne(t), [t]);
536
+ return o ? /* @__PURE__ */ p(J, { children: [
453
537
  /* @__PURE__ */ e("div", { className: "sa-thread-list-overlay", onClick: l }),
454
- /* @__PURE__ */ d("div", { className: "sa-thread-list", children: [
455
- /* @__PURE__ */ d("div", { className: "sa-thread-list-header", children: [
538
+ /* @__PURE__ */ p("div", { className: "sa-thread-list", children: [
539
+ /* @__PURE__ */ p("div", { className: "sa-thread-list-header", children: [
456
540
  /* @__PURE__ */ e("span", { className: "sa-thread-list-title", children: "会话记录" }),
457
- /* @__PURE__ */ d("button", { className: "sa-thread-list-new", onClick: r, children: [
458
- /* @__PURE__ */ e(C, { name: "plus", size: 14 }),
541
+ /* @__PURE__ */ p("button", { className: "sa-thread-list-new", onClick: n, children: [
542
+ /* @__PURE__ */ e(z, { name: "plus", size: 14 }),
459
543
  " 新会话"
460
544
  ] })
461
545
  ] }),
462
- /* @__PURE__ */ d("div", { className: "sa-thread-list-items", children: [
463
- a.length === 0 && /* @__PURE__ */ e("div", { className: "sa-thread-list-empty", children: "暂无会话" }),
464
- k.map((g) => /* @__PURE__ */ d("div", { className: "sa-thread-group", children: [
465
- /* @__PURE__ */ e("div", { className: "sa-thread-group-label", children: g.label }),
466
- g.items.map((b) => /* @__PURE__ */ d(
467
- "div",
468
- {
469
- className: `sa-thread-item ${b.sessionId === t ? "active" : ""}`,
470
- onClick: () => s(b.sessionId),
471
- children: [
472
- c === b.sessionId ? /* @__PURE__ */ e(
473
- "input",
474
- {
475
- className: "sa-thread-item-edit",
476
- value: f,
477
- onChange: (m) => u(m.target.value),
478
- onBlur: () => v(b.sessionId),
479
- onKeyDown: (m) => {
480
- m.key === "Enter" && v(b.sessionId), m.key === "Escape" && p(null);
481
- },
482
- onClick: (m) => m.stopPropagation(),
483
- autoFocus: !0
484
- }
485
- ) : /* @__PURE__ */ e(
486
- "span",
487
- {
488
- className: "sa-thread-item-title",
489
- onDoubleClick: (m) => {
490
- m.stopPropagation(), h(b.sessionId, b.title);
491
- },
492
- children: b.title || "新会话"
493
- }
494
- ),
495
- /* @__PURE__ */ e(
496
- "button",
497
- {
498
- className: "sa-thread-item-delete",
499
- onClick: (m) => {
500
- m.stopPropagation(), n(b.sessionId);
501
- },
502
- title: "删除",
503
- children: /* @__PURE__ */ e(C, { name: "trash2", size: 14 })
504
- }
505
- )
506
- ]
507
- },
508
- b.sessionId
509
- ))
510
- ] }, g.label))
511
- ] })
546
+ /* @__PURE__ */ p(
547
+ "div",
548
+ {
549
+ className: "sa-thread-list-items",
550
+ ref: x,
551
+ onScroll: L,
552
+ children: [
553
+ t.length === 0 && /* @__PURE__ */ e("div", { className: "sa-thread-list-empty", children: "暂无会话" }),
554
+ E.map((k) => /* @__PURE__ */ p("div", { className: "sa-thread-group", children: [
555
+ /* @__PURE__ */ e("div", { className: "sa-thread-group-label", children: k.label }),
556
+ k.items.map((h) => /* @__PURE__ */ p(
557
+ "div",
558
+ {
559
+ className: `sa-thread-item ${h.sessionId === r ? "active" : ""}`,
560
+ onClick: () => {
561
+ u !== h.sessionId && s(h.sessionId);
562
+ },
563
+ children: [
564
+ u === h.sessionId ? /* @__PURE__ */ e(
565
+ "input",
566
+ {
567
+ className: "sa-thread-item-edit",
568
+ value: m,
569
+ onChange: (M) => g(M.target.value),
570
+ onBlur: () => T(h.sessionId),
571
+ onKeyDown: (M) => {
572
+ M.key === "Enter" && T(h.sessionId), M.key === "Escape" && d(null);
573
+ },
574
+ onClick: (M) => M.stopPropagation(),
575
+ autoFocus: !0
576
+ }
577
+ ) : /* @__PURE__ */ p("div", { className: "sa-thread-item-info", children: [
578
+ /* @__PURE__ */ e("span", { className: "sa-thread-item-title", children: h.title || "新会话" }),
579
+ /* @__PURE__ */ e("span", { className: "sa-thread-item-time", children: ce(h.updateTime) })
580
+ ] }),
581
+ /* @__PURE__ */ p("div", { className: "sa-thread-item-actions", children: [
582
+ /* @__PURE__ */ e(
583
+ "button",
584
+ {
585
+ className: "sa-thread-item-action-btn",
586
+ onClick: (M) => {
587
+ M.stopPropagation(), w(h.sessionId, h.title);
588
+ },
589
+ title: "重命名",
590
+ children: /* @__PURE__ */ e(z, { name: "pen", size: 13 })
591
+ }
592
+ ),
593
+ /* @__PURE__ */ e(
594
+ "button",
595
+ {
596
+ className: "sa-thread-item-action-btn",
597
+ onClick: (M) => {
598
+ M.stopPropagation(), a(h.sessionId);
599
+ },
600
+ title: "删除",
601
+ children: /* @__PURE__ */ e(z, { name: "trash2", size: 13 })
602
+ }
603
+ )
604
+ ] })
605
+ ]
606
+ },
607
+ h.sessionId
608
+ ))
609
+ ] }, k.label)),
610
+ c && /* @__PURE__ */ e("div", { className: "sa-thread-list-loading", children: "加载更多..." })
611
+ ]
612
+ }
613
+ )
512
614
  ] })
513
615
  ] }) : null;
514
616
  }
515
- function ge(a) {
516
- const t = _(null), s = _(!1), r = _(0), n = N(() => {
517
- const i = t.current;
518
- if (!i) return;
519
- const { scrollTop: l, scrollHeight: c, clientHeight: p } = i, f = c - l - p < 40;
520
- l < r.current && !f && (s.current = !0), f && (s.current = !1), r.current = l;
617
+ function ze(t) {
618
+ const r = O(null), s = O(!1), n = O(0), a = N(() => {
619
+ const o = r.current;
620
+ if (!o) return;
621
+ const { scrollTop: l, scrollHeight: c, clientHeight: f } = o, u = c - l - f < 40;
622
+ l < n.current && !u && (s.current = !0), u && (s.current = !1), n.current = l;
521
623
  }, []);
522
624
  B(() => {
523
- const i = t.current;
524
- if (i)
525
- return i.addEventListener("scroll", n, { passive: !0 }), () => i.removeEventListener("scroll", n);
526
- }, [n]), B(() => {
625
+ const o = r.current;
626
+ if (o)
627
+ return o.addEventListener("scroll", a, { passive: !0 }), () => o.removeEventListener("scroll", a);
628
+ }, [a]), B(() => {
527
629
  if (s.current) return;
528
- const i = t.current;
529
- i && requestAnimationFrame(() => {
530
- i.scrollTop = i.scrollHeight;
630
+ const o = r.current;
631
+ o && requestAnimationFrame(() => {
632
+ o.scrollTop = o.scrollHeight;
531
633
  });
532
- }, a);
533
- const o = N(() => {
634
+ }, t);
635
+ const i = N(() => {
534
636
  s.current = !1;
535
- const i = t.current;
536
- i && (i.scrollTop = i.scrollHeight);
637
+ const o = r.current;
638
+ o && (o.scrollTop = o.scrollHeight);
537
639
  }, []);
538
- return { containerRef: t, scrollToBottom: o };
640
+ return { containerRef: r, scrollToBottom: i };
539
641
  }
540
- function j(a) {
541
- return a.value++;
642
+ function K(t) {
643
+ return t.value++;
542
644
  }
543
- function K(a, t) {
544
- const s = [], r = [], n = () => {
545
- r.length > 0 && (s.push(r.join("")), r.length = 0);
645
+ function q(t, r) {
646
+ const s = [], n = [], a = () => {
647
+ n.length > 0 && (s.push(n.join("")), n.length = 0);
546
648
  };
547
- let o = 0;
548
- for (; o < a.length; ) {
549
- const i = a[o];
550
- if (i === "`") {
551
- const l = a.indexOf("`", o + 1);
649
+ let i = 0;
650
+ for (; i < t.length; ) {
651
+ const o = t[i];
652
+ if (o === "`") {
653
+ const l = t.indexOf("`", i + 1);
552
654
  if (l !== -1) {
553
- n(), s.push(
554
- /* @__PURE__ */ e("code", { className: "sa-inline-code", children: a.slice(o + 1, l) }, j(t))
555
- ), o = l + 1;
655
+ a(), s.push(
656
+ /* @__PURE__ */ e("code", { className: "sa-inline-code", children: t.slice(i + 1, l) }, K(r))
657
+ ), i = l + 1;
556
658
  continue;
557
659
  }
558
- } else if (i === "*" && a[o + 1] === "*") {
559
- const l = a.indexOf("**", o + 2);
660
+ } else if (o === "*" && t[i + 1] === "*") {
661
+ const l = t.indexOf("**", i + 2);
560
662
  if (l !== -1) {
561
- n(), s.push(
562
- /* @__PURE__ */ e("strong", { children: K(a.slice(o + 2, l), t) }, j(t))
563
- ), o = l + 2;
663
+ a(), s.push(
664
+ /* @__PURE__ */ e("strong", { children: q(t.slice(i + 2, l), r) }, K(r))
665
+ ), i = l + 2;
564
666
  continue;
565
667
  }
566
- } else if (i === "*") {
567
- const l = a.indexOf("*", o + 1);
668
+ } else if (o === "*") {
669
+ const l = t.indexOf("*", i + 1);
568
670
  if (l !== -1) {
569
- n(), s.push(
570
- /* @__PURE__ */ e("em", { children: K(a.slice(o + 1, l), t) }, j(t))
571
- ), o = l + 1;
671
+ a(), s.push(
672
+ /* @__PURE__ */ e("em", { children: q(t.slice(i + 1, l), r) }, K(r))
673
+ ), i = l + 1;
572
674
  continue;
573
675
  }
574
- } else if (i === "[") {
575
- const l = a.indexOf("]", o + 1);
576
- if (l !== -1 && a[l + 1] === "(") {
577
- const c = a.indexOf(")", l + 2);
676
+ } else if (o === "[") {
677
+ const l = t.indexOf("]", i + 1);
678
+ if (l !== -1 && t[l + 1] === "(") {
679
+ const c = t.indexOf(")", l + 2);
578
680
  if (c !== -1) {
579
- const p = a.slice(o + 1, l), f = a.slice(l + 2, c);
580
- n(), s.push(
681
+ const f = t.slice(i + 1, l), u = t.slice(l + 2, c);
682
+ a(), s.push(
581
683
  /* @__PURE__ */ e(
582
684
  "a",
583
685
  {
584
- href: f,
686
+ href: u,
585
687
  target: "_blank",
586
688
  rel: "noreferrer",
587
- children: K(p, t)
689
+ children: q(f, r)
588
690
  },
589
- j(t)
691
+ K(r)
590
692
  )
591
- ), o = c + 1;
693
+ ), i = c + 1;
592
694
  continue;
593
695
  }
594
696
  }
595
697
  }
596
- r.push(i), o++;
698
+ n.push(o), i++;
597
699
  }
598
- return n(), s;
700
+ return a(), s;
599
701
  }
600
- function xe(a, t) {
601
- const s = [], r = a.split(`
702
+ function Ie(t, r) {
703
+ const s = [], n = t.split(`
602
704
  `);
603
- let n = 0;
604
- const o = (c) => c.trim() === "", i = (c) => /^#{1,6}\s+\S/.test(c.trim()), l = (c) => /^(?:[-*+]|\d+[.)])\s+\S/.test(c.trim());
605
- for (; n < r.length; ) {
606
- const c = r[n], p = c.trim();
607
- if (o(c)) {
608
- n++;
705
+ let a = 0;
706
+ const i = (c) => c.trim() === "", o = (c) => /^#{1,6}\s+\S/.test(c.trim()), l = (c) => /^(?:[-*+]|\d+[.)])\s+\S/.test(c.trim());
707
+ for (; a < n.length; ) {
708
+ const c = n[a], f = c.trim();
709
+ if (i(c)) {
710
+ a++;
609
711
  continue;
610
712
  }
611
- if (i(c)) {
612
- const u = p.match(/^(#{1,6})\s+(.*)$/);
613
- if (u) {
614
- const v = `h${Math.min(u[1].length, 6)}`;
713
+ if (o(c)) {
714
+ const d = f.match(/^(#{1,6})\s+(.*)$/);
715
+ if (d) {
716
+ const g = `h${Math.min(d[1].length, 6)}`;
615
717
  s.push(
616
718
  Y.createElement(
617
- v,
618
- { key: j(t) },
619
- K(u[2], t)
719
+ g,
720
+ { key: K(r) },
721
+ q(d[2], r)
620
722
  )
621
723
  );
622
724
  }
623
- n++;
725
+ a++;
624
726
  continue;
625
727
  }
626
728
  if (l(c)) {
627
- const u = /^\d+[.)]/.test(p), h = [];
628
- for (; n < r.length && l(r[n]); ) {
629
- const v = r[n].trim().match(/^(?:[-*+]|\d+[.)])\s+(.*)$/);
630
- v && h.push(
631
- /* @__PURE__ */ e("li", { children: K(v[1], t) }, j(t))
632
- ), n++;
729
+ const d = /^\d+[.)]/.test(f), m = [];
730
+ for (; a < n.length && l(n[a]); ) {
731
+ const g = n[a].trim().match(/^(?:[-*+]|\d+[.)])\s+(.*)$/);
732
+ g && m.push(
733
+ /* @__PURE__ */ e("li", { children: q(g[1], r) }, K(r))
734
+ ), a++;
633
735
  }
634
736
  s.push(
635
- u ? /* @__PURE__ */ e("ol", { className: "sa-list", children: h }, j(t)) : /* @__PURE__ */ e("ul", { className: "sa-list", children: h }, j(t))
737
+ d ? /* @__PURE__ */ e("ol", { className: "sa-list", children: m }, K(r)) : /* @__PURE__ */ e("ul", { className: "sa-list", children: m }, K(r))
636
738
  );
637
739
  continue;
638
740
  }
639
- const f = [];
640
- for (; n < r.length && !o(r[n]) && !i(r[n]) && !l(r[n]); )
641
- f.push(r[n]), n++;
741
+ const u = [];
742
+ for (; a < n.length && !i(n[a]) && !o(n[a]) && !l(n[a]); )
743
+ u.push(n[a]), a++;
642
744
  s.push(
643
- /* @__PURE__ */ e("p", { className: "sa-text-paragraph", children: K(f.join(" "), t) }, j(t))
745
+ /* @__PURE__ */ e("p", { className: "sa-text-paragraph", children: q(u.join(" "), r) }, K(r))
644
746
  );
645
747
  }
646
748
  return s;
647
749
  }
648
- function be(a) {
649
- const t = { value: 0 }, s = [], r = a.split("```");
650
- for (let n = 0; n < r.length; n++)
651
- if (n % 2 === 0)
652
- s.push(...xe(r[n], t));
653
- else if (r[n].trim() !== "") {
654
- let o = r[n].replace(/^\r?\n/, "");
655
- o = o.replace(/^[a-zA-Z0-9_+#.-]+\r?\n/, ""), o = o.replace(/\r?\n$/, ""), s.push(
656
- /* @__PURE__ */ e("pre", { className: "sa-code-block", children: /* @__PURE__ */ e("code", { children: o }) }, j(t))
750
+ function Se(t) {
751
+ const r = { value: 0 }, s = [], n = t.split("```");
752
+ for (let a = 0; a < n.length; a++)
753
+ if (a % 2 === 0)
754
+ s.push(...Ie(n[a], r));
755
+ else if (n[a].trim() !== "") {
756
+ let i = n[a].replace(/^\r?\n/, "");
757
+ 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(r))
657
759
  );
658
760
  }
659
761
  return s;
660
762
  }
661
- function ve({ content: a }) {
662
- return /* @__PURE__ */ e("div", { className: "sa-text-part", children: be(a) });
763
+ function Te({ content: t }) {
764
+ return /* @__PURE__ */ e("div", { className: "sa-text-part", children: Se(t) });
663
765
  }
664
- function we({ content: a }) {
665
- const [t, s] = T(!1);
666
- return /* @__PURE__ */ d("div", { className: "sa-thinking-part", onClick: () => s(!t), children: [
667
- /* @__PURE__ */ d("div", { className: "sa-thinking-header", children: [
668
- /* @__PURE__ */ e("span", { className: "sa-thinking-icon", children: /* @__PURE__ */ e(C, { name: "brain", size: 14 }) }),
766
+ function Me({ content: t }) {
767
+ const [r, s] = D(!1);
768
+ return /* @__PURE__ */ p("div", { className: "sa-thinking-part", onClick: () => s(!r), children: [
769
+ /* @__PURE__ */ p("div", { className: "sa-thinking-header", children: [
770
+ /* @__PURE__ */ e("span", { className: "sa-thinking-icon", children: /* @__PURE__ */ e(z, { name: "brain", size: 14 }) }),
669
771
  /* @__PURE__ */ e("span", { className: "sa-thinking-label", children: "思考过程" }),
670
- /* @__PURE__ */ e("span", { className: `sa-thinking-arrow ${t ? "expanded" : ""}`, children: /* @__PURE__ */ e(C, { name: "chevron-right", size: 12 }) })
772
+ /* @__PURE__ */ e("span", { className: `sa-thinking-arrow ${r ? "expanded" : ""}`, children: /* @__PURE__ */ e(z, { name: "chevron-right", size: 12 }) })
671
773
  ] }),
672
- t && /* @__PURE__ */ e("div", { className: "sa-thinking-content", children: a })
774
+ r && /* @__PURE__ */ e("div", { className: "sa-thinking-content", children: t })
673
775
  ] });
674
776
  }
675
- function ye({ toolName: a, toolCallId: t, args: s }) {
676
- const [r, n] = T(!1);
677
- let o = s;
777
+ function De({ toolName: t, toolCallId: r, args: s }) {
778
+ const [n, a] = D(!1);
779
+ let i = s;
678
780
  try {
679
- o = JSON.stringify(JSON.parse(s), null, 2);
781
+ i = JSON.stringify(JSON.parse(s), null, 2);
680
782
  } catch {
681
783
  }
682
- return /* @__PURE__ */ d("div", { className: "sa-tool-call-part", children: [
683
- /* @__PURE__ */ d("div", { className: "sa-tool-call-header", onClick: () => n(!r), children: [
684
- /* @__PURE__ */ e("span", { className: "sa-tool-icon", children: /* @__PURE__ */ e(C, { name: "zap", size: 14 }) }),
685
- /* @__PURE__ */ d("span", { className: "sa-tool-name", children: [
784
+ return /* @__PURE__ */ p("div", { className: "sa-tool-call-part", children: [
785
+ /* @__PURE__ */ p("div", { className: "sa-tool-call-header", onClick: () => a(!n), children: [
786
+ /* @__PURE__ */ e("span", { className: "sa-tool-icon", children: /* @__PURE__ */ e(z, { name: "zap", size: 14 }) }),
787
+ /* @__PURE__ */ p("span", { className: "sa-tool-name", children: [
686
788
  "调用工具: ",
687
- a
789
+ t
688
790
  ] }),
689
- /* @__PURE__ */ e("span", { className: `sa-thinking-arrow ${r ? "expanded" : ""}`, children: /* @__PURE__ */ e(C, { name: "chevron-right", size: 12 }) })
791
+ /* @__PURE__ */ e("span", { className: `sa-thinking-arrow ${n ? "expanded" : ""}`, children: /* @__PURE__ */ e(z, { name: "chevron-right", size: 12 }) })
690
792
  ] }),
691
- r && /* @__PURE__ */ e("pre", { className: "sa-tool-args", children: o })
793
+ n && /* @__PURE__ */ e("pre", { className: "sa-tool-args", children: i })
692
794
  ] });
693
795
  }
694
- function ke({ html: a }) {
695
- const [t, s] = T(null);
696
- return B(() => {
697
- let r = !1;
698
- return import("./purify.es-C-6FFqDW.js").then((n) => {
699
- r || s(n.default.sanitize(a, { FORCE_BODY: !0 }));
796
+ function $e({ html: t }) {
797
+ const [r, s] = D(null), n = Y.useRef(null);
798
+ B(() => {
799
+ let i = !1;
800
+ return import("./purify.es-C-6FFqDW.js").then((o) => {
801
+ i || s(o.default.sanitize(t, { FORCE_BODY: !0 }));
700
802
  }), () => {
701
- r = !0;
803
+ i = !0;
702
804
  };
703
- }, [a]), t === null ? null : /* @__PURE__ */ e("div", { className: "sa-tool-result-html", children: /* @__PURE__ */ e("iframe", { srcDoc: t, className: "sa-tool-result-html-iframe", sandbox: "", title: "HTML 产物" }) });
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
+ ) });
704
832
  }
705
- function Ce({ toolName: a, content: t, artifacts: s, renderMode: r, html: n, artifactPreview: o }) {
706
- const { openArtifactPreview: i } = F(), l = ae(s);
707
- return /* @__PURE__ */ d("div", { className: "sa-tool-result-part", children: [
708
- /* @__PURE__ */ d("div", { className: "sa-tool-result-header", children: [
709
- /* @__PURE__ */ e("span", { className: "sa-tool-icon", children: /* @__PURE__ */ e(C, { name: "circle-check", size: 14, color: "#10b981" }) }),
710
- /* @__PURE__ */ e("span", { className: "sa-tool-result-label", children: a || "工具返回" })
833
+ function Ee({ toolName: t, content: r, artifacts: s, renderMode: n, html: a, artifactPreview: i }) {
834
+ const { openArtifactPreview: o } = U(), l = oe(s);
835
+ return /* @__PURE__ */ p("div", { className: "sa-tool-result-part", children: [
836
+ /* @__PURE__ */ p("div", { className: "sa-tool-result-header", children: [
837
+ /* @__PURE__ */ e("span", { className: "sa-tool-icon", children: /* @__PURE__ */ e(z, { name: "circle-check", size: 14, color: "#10b981" }) }),
838
+ /* @__PURE__ */ e("span", { className: "sa-tool-result-label", children: t || "工具返回" })
711
839
  ] }),
712
- r === "html" && n ? /* @__PURE__ */ e(ke, { html: n }) : t ? /* @__PURE__ */ e("div", { className: "sa-tool-result-content", children: t }) : null,
713
- l.length > 0 && /* @__PURE__ */ e("ul", { className: "sa-artifact-file-list", role: "list", children: l.map((c, p) => /* @__PURE__ */ d(
840
+ n === "html" && a ? /* @__PURE__ */ e($e, { html: a }) : r ? /* @__PURE__ */ e("div", { className: "sa-tool-result-content", children: r }) : null,
841
+ l.length > 0 && /* @__PURE__ */ e("ul", { className: "sa-artifact-file-list", role: "list", children: l.map((c, f) => /* @__PURE__ */ p(
714
842
  "li",
715
843
  {
716
844
  className: "sa-artifact-file-card",
717
- onClick: o ? () => i(c) : void 0,
718
- onKeyDown: o ? (f) => {
719
- (f.key === "Enter" || f.key === " ") && (f.preventDefault(), i(c));
845
+ onClick: i ? () => o(c) : void 0,
846
+ onKeyDown: i ? (u) => {
847
+ (u.key === "Enter" || u.key === " ") && (u.preventDefault(), o(c));
720
848
  } : void 0,
721
- tabIndex: o ? 0 : void 0,
722
- role: o ? "button" : void 0,
723
- "aria-label": o ? `预览 ${c.filename}` : void 0,
724
- style: o ? { cursor: "pointer" } : void 0,
849
+ tabIndex: i ? 0 : void 0,
850
+ role: i ? "button" : void 0,
851
+ "aria-label": i ? `预览 ${c.filename}` : void 0,
852
+ style: i ? { cursor: "pointer" } : void 0,
725
853
  children: [
726
- /* @__PURE__ */ e("div", { className: "sa-artifact-file-icon", children: /* @__PURE__ */ e("span", { className: "sa-artifact-chip-type", children: ee(c.type) }) }),
727
- /* @__PURE__ */ d("div", { className: "sa-artifact-file-info", children: [
854
+ /* @__PURE__ */ e("div", { className: "sa-artifact-file-icon", children: /* @__PURE__ */ e("span", { className: "sa-artifact-chip-type", children: ie(c.type) }) }),
855
+ /* @__PURE__ */ p("div", { className: "sa-artifact-file-info", children: [
728
856
  /* @__PURE__ */ e("span", { className: "sa-artifact-file-name", children: c.filename }),
729
- c.size != null && /* @__PURE__ */ e("span", { className: "sa-artifact-file-size", children: Q(c.size) })
857
+ c.size != null && /* @__PURE__ */ e("span", { className: "sa-artifact-file-size", children: ne(c.size) })
730
858
  ] }),
731
- o && /* @__PURE__ */ e(
859
+ i && /* @__PURE__ */ e(
732
860
  "button",
733
861
  {
734
862
  className: "sa-artifact-file-download",
735
863
  title: "下载",
736
864
  "aria-label": `下载 ${c.filename}`,
737
- onClick: (f) => {
738
- f.stopPropagation(), U(c);
865
+ onClick: (u) => {
866
+ u.stopPropagation(), Z(c);
739
867
  },
740
868
  children: /* @__PURE__ */ e("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: /* @__PURE__ */ e("path", { d: "M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4M7 10l5 5 5-5M12 15V3" }) })
741
869
  }
742
870
  )
743
871
  ]
744
872
  },
745
- c.id || `art-${p}`
873
+ c.id || `art-${f}`
746
874
  )) })
747
875
  ] });
748
876
  }
749
- function Ne({ content: a, onRetry: t }) {
750
- return /* @__PURE__ */ d("div", { className: "sa-error-part", children: [
751
- /* @__PURE__ */ d("div", { className: "sa-error-content", children: [
752
- /* @__PURE__ */ e("span", { className: "sa-error-icon", children: /* @__PURE__ */ e(C, { name: "triangle-alert", size: 14 }) }),
753
- /* @__PURE__ */ e("span", { children: a })
877
+ function Le({ content: t, onRetry: r }) {
878
+ return /* @__PURE__ */ p("div", { className: "sa-error-part", children: [
879
+ /* @__PURE__ */ p("div", { className: "sa-error-content", children: [
880
+ /* @__PURE__ */ e("span", { className: "sa-error-icon", children: /* @__PURE__ */ e(z, { name: "triangle-alert", size: 14 }) }),
881
+ /* @__PURE__ */ e("span", { children: t })
754
882
  ] }),
755
- t && /* @__PURE__ */ e("button", { className: "sa-error-retry", onClick: t, children: "重试" })
883
+ r && /* @__PURE__ */ e("button", { className: "sa-error-retry", onClick: r, children: "重试" })
756
884
  ] });
757
885
  }
758
- function ze({ interrupt: a, onRespond: t }) {
759
- var o, i;
760
- const s = a.options, r = (typeof (s == null ? void 0 : s[0]) == "string" ? s[0] : (o = s == null ? void 0 : s[0]) == null ? void 0 : o.label) || "确认", n = (typeof (s == null ? void 0 : s[1]) == "string" ? s[1] : (i = s == null ? void 0 : s[1]) == null ? void 0 : i.label) || "取消";
761
- return /* @__PURE__ */ d("div", { className: "sa-interrupt-card", children: [
762
- /* @__PURE__ */ d("div", { className: "sa-interrupt-content", children: [
763
- /* @__PURE__ */ e(C, { name: "circle-alert", size: 16, color: "#f59e0b" }),
764
- /* @__PURE__ */ e("span", { children: a.content })
886
+ function Ae({ interrupt: t, onRespond: r, disabled: s, answeredAction: n }) {
887
+ var l, c;
888
+ const a = t.options, i = (typeof (a == null ? void 0 : a[0]) == "string" ? a[0] : (l = a == null ? void 0 : a[0]) == null ? void 0 : l.label) || "确认", o = (typeof (a == null ? void 0 : a[1]) == "string" ? a[1] : (c = a == null ? void 0 : a[1]) == null ? void 0 : c.label) || "取消";
889
+ return /* @__PURE__ */ p("div", { className: "sa-interrupt-card", children: [
890
+ /* @__PURE__ */ p("div", { className: "sa-interrupt-content", children: [
891
+ /* @__PURE__ */ e(z, { name: "circle-alert", size: 16, color: "#f59e0b" }),
892
+ /* @__PURE__ */ e("span", { children: t.content })
765
893
  ] }),
766
- /* @__PURE__ */ d("div", { className: "sa-interrupt-actions", children: [
767
- /* @__PURE__ */ d("button", { className: "sa-interrupt-btn sa-interrupt-btn-primary", onClick: () => t({ action: "confirm" }), children: [
768
- /* @__PURE__ */ e(C, { name: "check", size: 14 }),
769
- " ",
770
- r
771
- ] }),
772
- /* @__PURE__ */ d("button", { className: "sa-interrupt-btn sa-interrupt-btn-secondary", onClick: () => t({ action: "cancel" }), children: [
773
- /* @__PURE__ */ e(C, { name: "x", size: 14 }),
774
- " ",
775
- n
776
- ] })
777
- ] })
894
+ /* @__PURE__ */ p("div", { className: "sa-interrupt-actions", children: [
895
+ /* @__PURE__ */ p(
896
+ "button",
897
+ {
898
+ className: `sa-interrupt-btn sa-interrupt-btn-primary ${n === "confirm" ? "sa-interrupt-btn-answered" : ""}`,
899
+ disabled: s,
900
+ onClick: () => r({ action: "confirm" }),
901
+ children: [
902
+ /* @__PURE__ */ e(z, { name: "check", size: 14 }),
903
+ " ",
904
+ i
905
+ ]
906
+ }
907
+ ),
908
+ /* @__PURE__ */ p(
909
+ "button",
910
+ {
911
+ className: `sa-interrupt-btn sa-interrupt-btn-secondary ${n === "cancel" ? "sa-interrupt-btn-answered" : ""}`,
912
+ disabled: s,
913
+ onClick: () => r({ action: "cancel" }),
914
+ children: [
915
+ /* @__PURE__ */ e(z, { name: "x", size: 14 }),
916
+ " ",
917
+ o
918
+ ]
919
+ }
920
+ )
921
+ ] }),
922
+ s && /* @__PURE__ */ e("div", { className: "sa-interrupt-submitted", children: "已提交" })
778
923
  ] });
779
924
  }
780
- function Ie({ interrupt: a, onRespond: t }) {
781
- var l, c, p, f;
782
- const s = a.options, r = (typeof (s == null ? void 0 : s[0]) == "string" ? s[0] : (l = s == null ? void 0 : s[0]) == null ? void 0 : l.label) || "批准", n = (typeof (s == null ? void 0 : s[1]) == "string" ? s[1] : (c = s == null ? void 0 : s[1]) == null ? void 0 : c.label) || "拒绝", o = (typeof (s == null ? void 0 : s[2]) == "string" ? s[2] : (p = s == null ? void 0 : s[2]) == null ? void 0 : p.label) || "跳过", i = ((f = a.metadata) == null ? void 0 : f.showSkip) !== !1;
783
- return /* @__PURE__ */ d("div", { className: "sa-interrupt-card", children: [
784
- /* @__PURE__ */ d("div", { className: "sa-interrupt-content", children: [
785
- /* @__PURE__ */ e(C, { name: "circle-alert", size: 16, color: "#f59e0b" }),
786
- /* @__PURE__ */ e("span", { children: a.content })
925
+ function Re({ interrupt: t, onRespond: r, disabled: s, answeredAction: n }) {
926
+ var f, u, d, m;
927
+ const a = t.options, i = (typeof (a == null ? void 0 : a[0]) == "string" ? a[0] : (f = a == null ? void 0 : a[0]) == null ? void 0 : f.label) || "批准", o = (typeof (a == null ? void 0 : a[1]) == "string" ? a[1] : (u = a == null ? void 0 : a[1]) == null ? void 0 : u.label) || "拒绝", l = (typeof (a == null ? void 0 : a[2]) == "string" ? a[2] : (d = a == null ? void 0 : a[2]) == null ? void 0 : d.label) || "跳过", c = ((m = t.metadata) == null ? void 0 : m.showSkip) !== !1;
928
+ return /* @__PURE__ */ p("div", { className: "sa-interrupt-card", children: [
929
+ /* @__PURE__ */ p("div", { className: "sa-interrupt-content", children: [
930
+ /* @__PURE__ */ e(z, { name: "circle-alert", size: 16, color: "#f59e0b" }),
931
+ /* @__PURE__ */ e("span", { children: t.content })
787
932
  ] }),
788
- /* @__PURE__ */ d("div", { className: "sa-interrupt-actions", children: [
789
- /* @__PURE__ */ d("button", { className: "sa-interrupt-btn sa-interrupt-btn-primary", onClick: () => t({ action: "approve" }), children: [
790
- /* @__PURE__ */ e(C, { name: "check", size: 14 }),
791
- " ",
792
- r
793
- ] }),
794
- /* @__PURE__ */ d("button", { className: "sa-interrupt-btn sa-interrupt-btn-danger", onClick: () => t({ action: "reject" }), children: [
795
- /* @__PURE__ */ e(C, { name: "x", size: 14 }),
796
- " ",
797
- n
798
- ] }),
799
- i && /* @__PURE__ */ d("button", { className: "sa-interrupt-btn sa-interrupt-btn-secondary", onClick: () => t({ action: "skip" }), children: [
800
- /* @__PURE__ */ e(C, { name: "chevron-right", size: 14 }),
801
- " ",
802
- o
803
- ] })
804
- ] })
933
+ /* @__PURE__ */ p("div", { className: "sa-interrupt-actions", children: [
934
+ /* @__PURE__ */ p(
935
+ "button",
936
+ {
937
+ className: `sa-interrupt-btn sa-interrupt-btn-primary ${n === "approve" ? "sa-interrupt-btn-answered" : ""}`,
938
+ disabled: s,
939
+ onClick: () => r({ action: "approve" }),
940
+ children: [
941
+ /* @__PURE__ */ e(z, { name: "check", size: 14 }),
942
+ " ",
943
+ i
944
+ ]
945
+ }
946
+ ),
947
+ /* @__PURE__ */ p(
948
+ "button",
949
+ {
950
+ className: `sa-interrupt-btn sa-interrupt-btn-danger ${n === "reject" ? "sa-interrupt-btn-answered" : ""}`,
951
+ disabled: s,
952
+ onClick: () => r({ action: "reject" }),
953
+ children: [
954
+ /* @__PURE__ */ e(z, { name: "x", size: 14 }),
955
+ " ",
956
+ o
957
+ ]
958
+ }
959
+ ),
960
+ c && /* @__PURE__ */ p(
961
+ "button",
962
+ {
963
+ className: `sa-interrupt-btn sa-interrupt-btn-secondary ${n === "skip" ? "sa-interrupt-btn-answered" : ""}`,
964
+ disabled: s,
965
+ onClick: () => r({ action: "skip" }),
966
+ children: [
967
+ /* @__PURE__ */ e(z, { name: "chevron-right", size: 14 }),
968
+ " ",
969
+ l
970
+ ]
971
+ }
972
+ )
973
+ ] }),
974
+ s && /* @__PURE__ */ e("div", { className: "sa-interrupt-submitted", children: "已提交" })
805
975
  ] });
806
976
  }
807
- function Te(a) {
808
- return typeof a == "string" ? { value: a, label: a } : a;
977
+ function Oe(t) {
978
+ return typeof t == "string" ? { value: t, label: t } : t;
809
979
  }
810
- function Se({ interrupt: a, onRespond: t }) {
811
- const s = (a.options ?? []).map(Te);
812
- return /* @__PURE__ */ d("div", { className: "sa-interrupt-card", children: [
813
- /* @__PURE__ */ d("div", { className: "sa-interrupt-content", children: [
814
- /* @__PURE__ */ e(C, { name: "list", size: 16, color: "#6366f1" }),
815
- /* @__PURE__ */ e("span", { children: a.content })
980
+ function Pe({ interrupt: t, onRespond: r, disabled: s, initialValue: n }) {
981
+ const a = (t.options ?? []).map(Oe);
982
+ return /* @__PURE__ */ p("div", { className: "sa-interrupt-card", children: [
983
+ /* @__PURE__ */ p("div", { className: "sa-interrupt-content", children: [
984
+ /* @__PURE__ */ e(z, { name: "list", size: 16, color: "#6366f1" }),
985
+ /* @__PURE__ */ e("span", { children: t.content })
816
986
  ] }),
817
- /* @__PURE__ */ e("div", { className: "sa-interrupt-options", children: s.map((r) => /* @__PURE__ */ d(
818
- "button",
819
- {
820
- className: `sa-interrupt-option ${r.danger ? "sa-interrupt-option-danger" : ""}`,
821
- onClick: () => t({ action: "select", value: r.value }),
822
- children: [
823
- r.icon && /* @__PURE__ */ e(C, { name: r.icon, size: 14 }),
824
- /* @__PURE__ */ e("span", { children: r.label }),
825
- r.description && /* @__PURE__ */ e("span", { className: "sa-interrupt-option-desc", children: r.description })
826
- ]
827
- },
828
- r.value
829
- )) })
987
+ /* @__PURE__ */ e("div", { className: "sa-interrupt-options", children: a.map((i) => {
988
+ const o = n === i.value;
989
+ return /* @__PURE__ */ p(
990
+ "button",
991
+ {
992
+ className: `sa-interrupt-option ${i.danger ? "sa-interrupt-option-danger" : ""} ${o ? "sa-interrupt-option-selected" : ""}`,
993
+ disabled: s,
994
+ onClick: () => r({ action: "select", value: i.value }),
995
+ children: [
996
+ /* @__PURE__ */ e(z, { name: o ? "circle-check" : "circle", size: 14 }),
997
+ i.icon && /* @__PURE__ */ e(z, { name: i.icon, size: 14 }),
998
+ /* @__PURE__ */ e("span", { children: i.label }),
999
+ i.description && /* @__PURE__ */ e("span", { className: "sa-interrupt-option-desc", children: i.description })
1000
+ ]
1001
+ },
1002
+ i.value
1003
+ );
1004
+ }) }),
1005
+ s && /* @__PURE__ */ e("div", { className: "sa-interrupt-submitted", children: "已提交" })
830
1006
  ] });
831
1007
  }
832
- function Me(a) {
833
- return typeof a == "string" ? { value: a, label: a } : a;
1008
+ function He(t) {
1009
+ return typeof t == "string" ? { value: t, label: t } : t;
834
1010
  }
835
- function De({ interrupt: a, onRespond: t }) {
836
- const s = (a.options ?? []).map(Me), [r, n] = T(/* @__PURE__ */ new Set()), o = (i) => {
837
- n((l) => {
838
- const c = new Set(l);
839
- return c.has(i) ? c.delete(i) : c.add(i), c;
1011
+ function Be({ interrupt: t, onRespond: r, disabled: s, initialValue: n }) {
1012
+ const a = (t.options ?? []).map(He), [i, o] = D(
1013
+ () => new Set(Array.isArray(n) ? n : [])
1014
+ ), l = (c) => {
1015
+ s || o((f) => {
1016
+ const u = new Set(f);
1017
+ return u.has(c) ? u.delete(c) : u.add(c), u;
840
1018
  });
841
1019
  };
842
- return /* @__PURE__ */ d("div", { className: "sa-interrupt-card", children: [
843
- /* @__PURE__ */ d("div", { className: "sa-interrupt-content", children: [
844
- /* @__PURE__ */ e(C, { name: "list-checks", size: 16, color: "#6366f1" }),
845
- /* @__PURE__ */ e("span", { children: a.content })
1020
+ return /* @__PURE__ */ p("div", { className: "sa-interrupt-card", children: [
1021
+ /* @__PURE__ */ p("div", { className: "sa-interrupt-content", children: [
1022
+ /* @__PURE__ */ e(z, { name: "list-checks", size: 16, color: "#6366f1" }),
1023
+ /* @__PURE__ */ e("span", { children: t.content })
846
1024
  ] }),
847
- /* @__PURE__ */ e("div", { className: "sa-interrupt-options", children: s.map((i) => /* @__PURE__ */ d(
1025
+ /* @__PURE__ */ e("div", { className: "sa-interrupt-options", children: a.map((c) => /* @__PURE__ */ p(
848
1026
  "button",
849
1027
  {
850
- className: `sa-interrupt-option ${r.has(i.value) ? "sa-interrupt-option-selected" : ""}`,
851
- onClick: () => o(i.value),
1028
+ className: `sa-interrupt-option ${i.has(c.value) ? "sa-interrupt-option-selected" : ""}`,
1029
+ disabled: s,
1030
+ onClick: () => l(c.value),
852
1031
  children: [
853
- /* @__PURE__ */ e(C, { name: r.has(i.value) ? "square-check" : "square", size: 14 }),
854
- /* @__PURE__ */ e("span", { children: i.label })
1032
+ /* @__PURE__ */ e(z, { name: i.has(c.value) ? "square-check" : "square", size: 14 }),
1033
+ /* @__PURE__ */ e("span", { children: c.label })
855
1034
  ]
856
1035
  },
857
- i.value
1036
+ c.value
858
1037
  )) }),
859
- /* @__PURE__ */ e("div", { className: "sa-interrupt-actions", children: /* @__PURE__ */ d(
1038
+ !s && /* @__PURE__ */ e("div", { className: "sa-interrupt-actions", children: /* @__PURE__ */ p(
860
1039
  "button",
861
1040
  {
862
1041
  className: "sa-interrupt-btn sa-interrupt-btn-primary",
863
- disabled: r.size === 0,
864
- onClick: () => t({ action: "submit", value: Array.from(r) }),
1042
+ disabled: i.size === 0,
1043
+ onClick: () => r({ action: "submit", value: Array.from(i) }),
865
1044
  children: [
866
- /* @__PURE__ */ e(C, { name: "check", size: 14 }),
1045
+ /* @__PURE__ */ e(z, { name: "check", size: 14 }),
867
1046
  " 确认 (",
868
- r.size,
1047
+ i.size,
869
1048
  ")"
870
1049
  ]
871
1050
  }
872
- ) })
1051
+ ) }),
1052
+ s && /* @__PURE__ */ e("div", { className: "sa-interrupt-submitted", children: "已提交" })
873
1053
  ] });
874
1054
  }
875
- function Le({ interrupt: a, onRespond: t }) {
876
- const [s, r] = T(""), n = a.inputType ?? "text", o = n === "textarea", i = () => {
877
- a.required && !s.trim() || t({ action: "submit", value: s.trim() });
1055
+ function je({ interrupt: t, onRespond: r, disabled: s, initialValue: n }) {
1056
+ const [a, i] = D(n ?? ""), o = t.inputType ?? "text", l = o === "textarea", c = () => {
1057
+ s || t.required && !a.trim() || r({ action: "submit", value: a.trim() });
878
1058
  };
879
- return /* @__PURE__ */ d("div", { className: "sa-interrupt-card", children: [
880
- /* @__PURE__ */ d("div", { className: "sa-interrupt-content", children: [
881
- /* @__PURE__ */ e(C, { name: "text-cursor-input", size: 16, color: "#6366f1" }),
882
- /* @__PURE__ */ e("span", { children: a.content })
1059
+ return /* @__PURE__ */ p("div", { className: "sa-interrupt-card", children: [
1060
+ /* @__PURE__ */ p("div", { className: "sa-interrupt-content", children: [
1061
+ /* @__PURE__ */ e(z, { name: "text-cursor-input", size: 16, color: "#6366f1" }),
1062
+ /* @__PURE__ */ e("span", { children: t.content })
883
1063
  ] }),
884
- /* @__PURE__ */ e("div", { className: "sa-interrupt-input-area", children: o ? /* @__PURE__ */ e(
1064
+ /* @__PURE__ */ e("div", { className: "sa-interrupt-input-area", children: l ? /* @__PURE__ */ e(
885
1065
  "textarea",
886
1066
  {
887
1067
  className: "sa-interrupt-textarea",
888
- value: s,
889
- onChange: (l) => r(l.target.value),
890
- placeholder: a.placeholder,
891
- maxLength: a.maxLength,
892
- rows: 3
1068
+ value: a,
1069
+ onChange: (f) => i(f.target.value),
1070
+ placeholder: t.placeholder,
1071
+ maxLength: t.maxLength,
1072
+ rows: 3,
1073
+ disabled: s
893
1074
  }
894
1075
  ) : /* @__PURE__ */ e(
895
1076
  "input",
896
1077
  {
897
1078
  className: "sa-interrupt-input",
898
- type: n,
899
- value: s,
900
- onChange: (l) => r(l.target.value),
901
- placeholder: a.placeholder,
902
- maxLength: a.maxLength,
903
- onKeyDown: (l) => l.key === "Enter" && i()
1079
+ type: o,
1080
+ value: a,
1081
+ onChange: (f) => i(f.target.value),
1082
+ placeholder: t.placeholder,
1083
+ maxLength: t.maxLength,
1084
+ onKeyDown: (f) => f.key === "Enter" && c(),
1085
+ disabled: s
904
1086
  }
905
1087
  ) }),
906
- /* @__PURE__ */ e("div", { className: "sa-interrupt-actions", children: /* @__PURE__ */ d(
1088
+ !s && /* @__PURE__ */ e("div", { className: "sa-interrupt-actions", children: /* @__PURE__ */ p(
907
1089
  "button",
908
1090
  {
909
1091
  className: "sa-interrupt-btn sa-interrupt-btn-primary",
910
- disabled: a.required ? !s.trim() : !1,
911
- onClick: i,
1092
+ disabled: t.required ? !a.trim() : !1,
1093
+ onClick: c,
912
1094
  children: [
913
- /* @__PURE__ */ e(C, { name: "check", size: 14 }),
1095
+ /* @__PURE__ */ e(z, { name: "check", size: 14 }),
914
1096
  " 提交"
915
1097
  ]
916
1098
  }
917
- ) })
1099
+ ) }),
1100
+ s && /* @__PURE__ */ e("div", { className: "sa-interrupt-submitted", children: "已提交" })
918
1101
  ] });
919
1102
  }
920
- function Ee({ interrupt: a, onRespond: t }) {
921
- const s = a.fields ?? [], [r, n] = T(() => {
922
- const c = {};
923
- for (const p of s)
924
- c[p.name] = p.defaultValue ?? "";
925
- return c;
926
- }), o = (c, p) => {
927
- n((f) => ({ ...f, [c]: p }));
928
- }, i = s.every((c) => !c.required || r[c.name]), l = () => {
929
- i && t({ action: "submit", value: r });
1103
+ function _e({ interrupt: t, onRespond: r, disabled: s, initialValue: n }) {
1104
+ const a = t.fields ?? [], [i, o] = D(() => {
1105
+ const u = {};
1106
+ for (const d of a)
1107
+ u[d.name] = (n == null ? void 0 : n[d.name]) ?? d.defaultValue ?? "";
1108
+ return u;
1109
+ }), l = (u, d) => {
1110
+ s || o((m) => ({ ...m, [u]: d }));
1111
+ }, c = !s && a.every((u) => !u.required || i[u.name]), f = () => {
1112
+ c && r({ action: "submit", value: i });
930
1113
  };
931
- return /* @__PURE__ */ d("div", { className: "sa-interrupt-card", children: [
932
- /* @__PURE__ */ d("div", { className: "sa-interrupt-content", children: [
933
- /* @__PURE__ */ e(C, { name: "file-text", size: 16, color: "#6366f1" }),
934
- /* @__PURE__ */ e("span", { children: a.content })
1114
+ return /* @__PURE__ */ p("div", { className: "sa-interrupt-card", children: [
1115
+ /* @__PURE__ */ p("div", { className: "sa-interrupt-content", children: [
1116
+ /* @__PURE__ */ e(z, { name: "file-text", size: 16, color: "#6366f1" }),
1117
+ /* @__PURE__ */ e("span", { children: t.content })
935
1118
  ] }),
936
- /* @__PURE__ */ e("div", { className: "sa-interrupt-form", children: s.map((c) => /* @__PURE__ */ d("div", { className: "sa-interrupt-form-field", children: [
937
- /* @__PURE__ */ d("label", { className: "sa-interrupt-form-label", children: [
938
- c.label,
939
- c.required && /* @__PURE__ */ e("span", { className: "sa-interrupt-form-required", children: "*" })
1119
+ /* @__PURE__ */ e("div", { className: "sa-interrupt-form", children: a.map((u) => /* @__PURE__ */ p("div", { className: "sa-interrupt-form-field", children: [
1120
+ /* @__PURE__ */ p("label", { className: "sa-interrupt-form-label", children: [
1121
+ u.label,
1122
+ u.required && /* @__PURE__ */ e("span", { className: "sa-interrupt-form-required", children: "*" })
940
1123
  ] }),
941
- Ae(c, r[c.name], (p) => o(c.name, p))
942
- ] }, c.name)) }),
943
- /* @__PURE__ */ d("div", { className: "sa-interrupt-actions", children: [
944
- /* @__PURE__ */ d("button", { className: "sa-interrupt-btn sa-interrupt-btn-primary", disabled: !i, onClick: l, children: [
945
- /* @__PURE__ */ e(C, { name: "check", size: 14 }),
1124
+ Fe(u, i[u.name], (d) => l(u.name, d), s)
1125
+ ] }, u.name)) }),
1126
+ !s && /* @__PURE__ */ p("div", { className: "sa-interrupt-actions", children: [
1127
+ /* @__PURE__ */ p("button", { className: "sa-interrupt-btn sa-interrupt-btn-primary", disabled: !c, onClick: f, children: [
1128
+ /* @__PURE__ */ e(z, { name: "check", size: 14 }),
946
1129
  " 提交"
947
1130
  ] }),
948
- /* @__PURE__ */ e("button", { className: "sa-interrupt-btn sa-interrupt-btn-secondary", onClick: () => t({ action: "cancel" }), children: "取消" })
949
- ] })
1131
+ /* @__PURE__ */ e("button", { className: "sa-interrupt-btn sa-interrupt-btn-secondary", onClick: () => r({ action: "cancel" }), children: "取消" })
1132
+ ] }),
1133
+ s && /* @__PURE__ */ e("div", { className: "sa-interrupt-submitted", children: "已提交" })
950
1134
  ] });
951
1135
  }
952
- function Ae(a, t, s) {
953
- switch (a.type) {
1136
+ function Fe(t, r, s, n) {
1137
+ switch (t.type) {
954
1138
  case "textarea":
955
- return /* @__PURE__ */ e("textarea", { className: "sa-interrupt-textarea", value: t, onChange: (r) => s(r.target.value), placeholder: a.placeholder, rows: 3 });
1139
+ return /* @__PURE__ */ e("textarea", { className: "sa-interrupt-textarea", value: r, onChange: (a) => s(a.target.value), placeholder: t.placeholder, rows: 3, disabled: n });
956
1140
  case "select":
957
- return /* @__PURE__ */ d("select", { className: "sa-interrupt-select", value: t, onChange: (r) => s(r.target.value), children: [
1141
+ return /* @__PURE__ */ p("select", { className: "sa-interrupt-select", value: r, onChange: (a) => s(a.target.value), disabled: n, children: [
958
1142
  /* @__PURE__ */ e("option", { value: "", children: "请选择" }),
959
- (a.options ?? []).map((r) => /* @__PURE__ */ e("option", { value: r, children: r }, r))
1143
+ (t.options ?? []).map((a) => /* @__PURE__ */ e("option", { value: a, children: a }, a))
960
1144
  ] });
961
1145
  default:
962
- return /* @__PURE__ */ e("input", { className: "sa-interrupt-input", type: a.type, value: t, onChange: (r) => s(r.target.value), placeholder: a.placeholder });
1146
+ return /* @__PURE__ */ e("input", { className: "sa-interrupt-input", type: t.type, value: r, onChange: (a) => s(a.target.value), placeholder: t.placeholder, disabled: n });
963
1147
  }
964
1148
  }
965
- function $e({ interrupt: a, resolved: t, response: s, onRespond: r }) {
966
- if (t)
967
- return /* @__PURE__ */ d("div", { className: "sa-interrupt-resolved", children: [
968
- /* @__PURE__ */ e(C, { name: "circle-check", size: 14, color: "#10b981" }),
969
- /* @__PURE__ */ e("span", { children: Pe(a.interruptType, s) })
970
- ] });
971
- switch (a.interruptType) {
1149
+ function We({ interrupt: t, resolved: r, response: s, onRespond: n }) {
1150
+ const a = r, i = s == null ? void 0 : s.value;
1151
+ switch (t.interruptType) {
972
1152
  case "confirm":
973
- return /* @__PURE__ */ e(ze, { interrupt: a, onRespond: r });
1153
+ return /* @__PURE__ */ e(Ae, { interrupt: t, onRespond: n, disabled: a, answeredAction: s == null ? void 0 : s.action });
974
1154
  case "approve":
975
- return /* @__PURE__ */ e(Ie, { interrupt: a, onRespond: r });
1155
+ return /* @__PURE__ */ e(Re, { interrupt: t, onRespond: n, disabled: a, answeredAction: s == null ? void 0 : s.action });
976
1156
  case "select":
977
- return /* @__PURE__ */ e(Se, { interrupt: a, onRespond: r });
1157
+ return /* @__PURE__ */ e(Pe, { interrupt: t, onRespond: n, disabled: a, initialValue: i });
978
1158
  case "multiSelect":
979
- return /* @__PURE__ */ e(De, { interrupt: a, onRespond: r });
1159
+ return /* @__PURE__ */ e(Be, { interrupt: t, onRespond: n, disabled: a, initialValue: i });
980
1160
  case "input":
981
- return /* @__PURE__ */ e(Le, { interrupt: a, onRespond: r });
1161
+ return /* @__PURE__ */ e(je, { interrupt: t, onRespond: n, disabled: a, initialValue: i });
982
1162
  case "form":
983
- return /* @__PURE__ */ e(Ee, { interrupt: a, onRespond: r });
1163
+ return /* @__PURE__ */ e(_e, { interrupt: t, onRespond: n, disabled: a, initialValue: i });
984
1164
  default:
985
- return /* @__PURE__ */ d("div", { className: "sa-interrupt-unknown", children: [
1165
+ return /* @__PURE__ */ p("div", { className: "sa-interrupt-unknown", children: [
986
1166
  "未知的交互类型: ",
987
- a.interruptType
1167
+ t.interruptType
988
1168
  ] });
989
1169
  }
990
1170
  }
991
- function Pe(a, t) {
992
- if (!t) return "已完成";
993
- switch (t.action) {
994
- case "confirm":
995
- return "已确认";
996
- case "cancel":
997
- return "已取消";
998
- case "select":
999
- return `已选择: ${t.value}`;
1000
- case "submit":
1001
- return "已提交";
1002
- case "approve":
1003
- return "已批准";
1004
- case "reject":
1005
- return "已拒绝";
1006
- case "skip":
1007
- return "已跳过";
1008
- default:
1009
- return "已完成";
1010
- }
1011
- }
1012
- const Oe = [
1171
+ const Ke = [
1013
1172
  { value: 1, label: "事实错误" },
1014
1173
  { value: 2, label: "逻辑问题" },
1015
1174
  { value: 3, label: "不相关" },
@@ -1017,70 +1176,78 @@ const Oe = [
1017
1176
  { value: 5, label: "冗长啰嗦" },
1018
1177
  { value: 6, label: "难以理解" }
1019
1178
  ];
1020
- function Re({ message: a, onCopy: t, onRegenerate: s, onFeedback: r }) {
1021
- const { status: n, feedback: o, cancelFeedback: i } = F(), [l, c] = T(null), [p, f] = T(!1), [u, h] = T(!1);
1022
- if (n !== "ready" && n !== "error") return null;
1023
- const v = N(() => {
1024
- t(), f(!0), setTimeout(() => f(!1), 2e3);
1025
- }, [t]), k = N(() => {
1026
- l === "like" ? (c(null), i(a.id)) : (c("like"), h(!1), o(a.id, "like"), r == null || r(a.id, "like"));
1027
- }, [l, a.id, o, i, r]), g = N(() => {
1028
- l === "dislike" ? (c(null), h(!1), i(a.id)) : h(!0);
1029
- }, [l, a.id, i]), b = N((m, x) => {
1030
- c("dislike"), h(!1), o(a.id, "dislike", { reason: m, remark: x }), r == null || r(a.id, "dislike");
1031
- }, [a.id, o, r]);
1032
- return /* @__PURE__ */ d("div", { className: "sa-action-bar", children: [
1033
- /* @__PURE__ */ d("button", { className: "sa-action-btn", onClick: v, title: "复制", children: [
1034
- /* @__PURE__ */ e(C, { name: p ? "circle-check" : "copy", size: 14 }),
1179
+ function Ye({ message: t, onCopy: r, onRegenerate: s, onFeedback: n }) {
1180
+ const { status: a, cancelFeedback: i } = U(), [o, l] = D(null), [c, f] = D(!1), [u, d] = D(!1), m = O(null), g = N(() => {
1181
+ r(), f(!0), setTimeout(() => f(!1), 2e3);
1182
+ }, [r]), x = N(() => {
1183
+ o === "like" ? (l(null), i(t.id)) : (l("like"), d(!1), n == null || n(t.id, "like"));
1184
+ }, [o, t.id, n, i]), w = N(() => {
1185
+ o === "dislike" ? (l(null), d(!1), i(t.id)) : d(!0);
1186
+ }, [o, t.id, i]), T = N((E, k) => {
1187
+ l("dislike"), d(!1), n == null || n(t.id, "dislike", { reason: E, remark: (k == null ? void 0 : k.trim()) || void 0 });
1188
+ }, [t.id, n]), L = N(() => {
1189
+ d(!1);
1190
+ }, []);
1191
+ return B(() => {
1192
+ if (!u) return;
1193
+ const E = (h) => {
1194
+ m.current && !m.current.contains(h.target) && d(!1);
1195
+ }, k = (h) => {
1196
+ h.key === "Escape" && d(!1);
1197
+ };
1198
+ return document.addEventListener("mousedown", E), document.addEventListener("keydown", k), () => {
1199
+ document.removeEventListener("mousedown", E), document.removeEventListener("keydown", k);
1200
+ };
1201
+ }, [u]), a !== "ready" && a !== "error" ? null : /* @__PURE__ */ p("div", { className: "sa-action-bar", children: [
1202
+ /* @__PURE__ */ p("button", { className: "sa-action-btn", onClick: g, title: "复制", children: [
1203
+ /* @__PURE__ */ e(z, { name: c ? "circle-check" : "copy", size: 14 }),
1035
1204
  " ",
1036
- p ? "已复制" : "复制"
1205
+ c ? "已复制" : "复制"
1037
1206
  ] }),
1038
- /* @__PURE__ */ d("button", { className: "sa-action-btn", onClick: s, title: "重新生成", children: [
1039
- /* @__PURE__ */ e(C, { name: "refresh-cw", size: 14 }),
1207
+ s && /* @__PURE__ */ p("button", { className: "sa-action-btn", onClick: s, title: "重新生成", children: [
1208
+ /* @__PURE__ */ e(z, { name: "refresh-cw", size: 14 }),
1040
1209
  " 重新生成"
1041
1210
  ] }),
1042
- /* @__PURE__ */ e("span", { className: "sa-action-divider" }),
1043
- /* @__PURE__ */ e(
1044
- "button",
1045
- {
1046
- className: `sa-action-btn ${l === "like" ? "sa-action-btn-active" : ""}`,
1047
- onClick: k,
1048
- title: "有用",
1049
- "aria-label": "点赞",
1050
- children: /* @__PURE__ */ e(C, { name: "thumbs-up", size: 14 })
1051
- }
1052
- ),
1053
- /* @__PURE__ */ e(
1054
- "button",
1055
- {
1056
- className: `sa-action-btn ${l === "dislike" ? "sa-action-btn-active" : ""}`,
1057
- onClick: g,
1058
- title: "无用",
1059
- "aria-label": "",
1060
- children: /* @__PURE__ */ e(C, { name: "thumbs-down", size: 14 })
1061
- }
1062
- ),
1063
- u && /* @__PURE__ */ e(
1064
- Be,
1065
- {
1066
- onSubmit: b,
1067
- onCancel: () => h(!1)
1068
- }
1069
- )
1211
+ n && /* @__PURE__ */ p(J, { children: [
1212
+ /* @__PURE__ */ e("span", { className: "sa-action-divider" }),
1213
+ /* @__PURE__ */ e(
1214
+ "button",
1215
+ {
1216
+ className: `sa-action-btn ${o === "like" ? "sa-action-btn-active" : ""}`,
1217
+ onClick: x,
1218
+ title: "有用",
1219
+ "aria-label": "点赞",
1220
+ children: /* @__PURE__ */ e(z, { name: "thumbs-up", size: 14 })
1221
+ }
1222
+ ),
1223
+ /* @__PURE__ */ e(
1224
+ "button",
1225
+ {
1226
+ className: `sa-action-btn ${o === "dislike" ? "sa-action-btn-active" : ""}`,
1227
+ onClick: w,
1228
+ title: "无用",
1229
+ "aria-label": "",
1230
+ "aria-expanded": u,
1231
+ "aria-haspopup": "dialog",
1232
+ children: /* @__PURE__ */ e(z, { name: "thumbs-down", size: 14 })
1233
+ }
1234
+ )
1235
+ ] }),
1236
+ u && /* @__PURE__ */ e("div", { ref: m, children: /* @__PURE__ */ e(Ue, { onSubmit: T, onCancel: L }) })
1070
1237
  ] });
1071
1238
  }
1072
- function Be({ onSubmit: a, onCancel: t }) {
1073
- const [s, r] = T(void 0), [n, o] = T("");
1074
- return /* @__PURE__ */ d("div", { className: "sa-dislike-panel", children: [
1239
+ function Ue({ onSubmit: t, onCancel: r }) {
1240
+ const [s, n] = D(void 0), [a, i] = D("");
1241
+ return /* @__PURE__ */ p("div", { className: "sa-dislike-panel", children: [
1075
1242
  /* @__PURE__ */ e("div", { className: "sa-dislike-panel-title", children: "请选择不满意的原因(可选)" }),
1076
- /* @__PURE__ */ e("div", { className: "sa-dislike-reasons", children: Oe.map((i) => /* @__PURE__ */ e(
1243
+ /* @__PURE__ */ e("div", { className: "sa-dislike-reasons", children: Ke.map((o) => /* @__PURE__ */ e(
1077
1244
  "button",
1078
1245
  {
1079
- className: `sa-dislike-reason-btn ${s === i.value ? "active" : ""}`,
1080
- onClick: () => r(s === i.value ? void 0 : i.value),
1081
- children: i.label
1246
+ className: `sa-dislike-reason-btn ${s === o.value ? "active" : ""}`,
1247
+ onClick: () => n(s === o.value ? void 0 : o.value),
1248
+ children: o.label
1082
1249
  },
1083
- i.value
1250
+ o.value
1084
1251
  )) }),
1085
1252
  /* @__PURE__ */ e(
1086
1253
  "textarea",
@@ -1088,492 +1255,723 @@ function Be({ onSubmit: a, onCancel: t }) {
1088
1255
  className: "sa-dislike-remark",
1089
1256
  placeholder: "补充描述(选填,≤500 字)",
1090
1257
  maxLength: 500,
1091
- value: n,
1092
- onChange: (i) => o(i.target.value),
1258
+ value: a,
1259
+ onChange: (o) => i(o.target.value),
1093
1260
  rows: 2
1094
1261
  }
1095
1262
  ),
1096
- /* @__PURE__ */ d("div", { className: "sa-dislike-actions", children: [
1097
- /* @__PURE__ */ e("button", { className: "sa-dislike-submit", onClick: () => a(s, n || void 0), children: "提交" }),
1098
- /* @__PURE__ */ e("button", { className: "sa-dislike-cancel", onClick: t, children: "取消" })
1263
+ /* @__PURE__ */ p("div", { className: "sa-dislike-actions", children: [
1264
+ /* @__PURE__ */ e("button", { className: "sa-dislike-submit", onClick: () => t(s, a || void 0), children: "提交" }),
1265
+ /* @__PURE__ */ e("button", { className: "sa-dislike-cancel", onClick: r, children: "取消" })
1099
1266
  ] })
1100
1267
  ] });
1101
1268
  }
1102
- function Z({ src: a, role: t }) {
1103
- const s = t === "assistant" ? "A" : "U";
1104
- return a ? a.startsWith("http") || a.startsWith("/") || a.startsWith("data:") ? /* @__PURE__ */ e("div", { className: `sa-avatar sa-avatar-${t}`, children: /* @__PURE__ */ e("img", { src: a, alt: t, style: { width: "100%", height: "100%", borderRadius: "inherit", objectFit: "cover" } }) }) : /* @__PURE__ */ e("div", { className: `sa-avatar sa-avatar-${t}`, children: a }) : /* @__PURE__ */ e("div", { className: `sa-avatar sa-avatar-${t}`, children: s });
1269
+ function se({ src: t, role: r }) {
1270
+ const s = r === "assistant" ? "A" : "U";
1271
+ return t ? t.startsWith("http") || t.startsWith("/") || t.startsWith("data:") ? /* @__PURE__ */ e("div", { className: `sa-avatar sa-avatar-${r}`, children: /* @__PURE__ */ e("img", { src: t, alt: r, style: { width: "100%", height: "100%", borderRadius: "inherit", objectFit: "cover" } }) }) : /* @__PURE__ */ e("div", { className: `sa-avatar sa-avatar-${r}`, children: t }) : /* @__PURE__ */ e("div", { className: `sa-avatar sa-avatar-${r}`, children: s });
1105
1272
  }
1106
- function He({ message: a, isStreaming: t, isLast: s, slots: r, avatar: n, artifactPreview: o }) {
1107
- const { regenerate: i, feedback: l, respondToInterrupt: c } = F(), p = N(() => {
1108
- var I;
1109
- const x = a.parts.filter((D) => D.type === "text").map((D) => D.content).join(`
1273
+ function qe({ message: t, isStreaming: r, isLast: s, slots: n, avatar: a, artifactPreview: i }) {
1274
+ const { regenerate: o, feedback: l, respondToInterrupt: c } = U(), f = N(() => {
1275
+ var M;
1276
+ const h = t.parts.filter((y) => y.type === "text").map((y) => y.content).join(`
1110
1277
  `);
1111
- (I = navigator.clipboard) == null || I.writeText(x).catch(() => {
1278
+ (M = navigator.clipboard) == null || M.writeText(h).catch(() => {
1112
1279
  });
1113
- }, [a]), f = a.role === "user", u = r.Message;
1114
- if (u)
1280
+ }, [t]), u = t.role === "user", d = n.Message;
1281
+ if (d)
1115
1282
  return /* @__PURE__ */ e(
1116
- u,
1283
+ d,
1117
1284
  {
1118
- message: a,
1119
- isStreaming: t,
1285
+ message: t,
1286
+ isStreaming: r,
1120
1287
  isLast: s,
1121
- avatar: n,
1122
- slots: r,
1123
- onCopy: p,
1124
- onRegenerate: i,
1288
+ avatar: a,
1289
+ slots: n,
1290
+ onCopy: f,
1291
+ onRegenerate: o,
1125
1292
  onFeedback: l
1126
1293
  }
1127
1294
  );
1128
- const h = r.TextPart ?? ve, v = r.ThinkingPart ?? we, k = r.ToolCallPart ?? ye, g = r.ToolResultPart ?? Ce, b = r.ErrorPart ?? Ne, m = r.ActionBar ?? Re;
1129
- return /* @__PURE__ */ d("div", { className: `sa-message ${f ? "sa-message-user" : "sa-message-assistant"}`, children: [
1130
- !f && /* @__PURE__ */ e(Z, { src: n == null ? void 0 : n.assistant, role: "assistant" }),
1131
- /* @__PURE__ */ d("div", { className: "sa-message-body", children: [
1132
- a.parts.map((x, I) => {
1133
- switch (x.type) {
1134
- case "text":
1135
- return /* @__PURE__ */ e(h, { content: x.content }, I);
1136
- case "thinking":
1137
- return /* @__PURE__ */ e(v, { content: x.content }, I);
1138
- case "tool_call":
1139
- return /* @__PURE__ */ e(k, { toolName: x.toolName, toolCallId: x.toolCallId, args: x.args }, I);
1140
- case "tool_result":
1141
- return /* @__PURE__ */ e(g, { toolName: x.toolName, toolCallId: x.toolCallId, content: x.content, artifacts: x.artifacts, renderMode: x.renderMode, html: x.html, artifactPreview: o }, I);
1142
- case "error":
1143
- return /* @__PURE__ */ e(b, { content: x.content, onRetry: i }, I);
1144
- case "interrupt":
1145
- return /* @__PURE__ */ e(
1146
- $e,
1147
- {
1148
- interrupt: x.interrupt,
1149
- resolved: x.resolved ?? !1,
1150
- response: x.response,
1151
- onRespond: (D) => c(x.interrupt.interruptId, D)
1152
- },
1153
- I
1154
- );
1155
- default:
1156
- return null;
1157
- }
1158
- }),
1159
- t && s && !f && /* @__PURE__ */ e("span", { className: "sa-streaming-cursor", children: "|" }),
1160
- !f && !t && a.parts.length > 0 && /* @__PURE__ */ e(m, { message: a, onCopy: p, onRegenerate: i, onFeedback: l })
1295
+ const m = n.TextPart ?? Te, g = n.ThinkingPart ?? Me, x = n.ToolCallPart ?? De, w = n.ToolResultPart ?? Ee, T = n.ErrorPart ?? Le, L = n.ActionBar ?? Ye, E = !u && t.parts.some((h) => h.type === "text" && h.content), k = !t.id.startsWith("assistant_") && !t.id.startsWith("user_");
1296
+ return /* @__PURE__ */ p("div", { className: `sa-message ${u ? "sa-message-user" : "sa-message-assistant"}`, children: [
1297
+ !u && /* @__PURE__ */ e(se, { src: a == null ? void 0 : a.assistant, role: "assistant" }),
1298
+ /* @__PURE__ */ p("div", { className: "sa-message-content", children: [
1299
+ /* @__PURE__ */ e("span", { className: `sa-message-time ${u ? "sa-message-time-right" : ""}`, children: ce(t.timestamp) }),
1300
+ /* @__PURE__ */ p("div", { className: "sa-message-body", children: [
1301
+ t.parts.map((h, M) => {
1302
+ switch (h.type) {
1303
+ case "text":
1304
+ return /* @__PURE__ */ e(m, { content: h.content }, M);
1305
+ case "thinking":
1306
+ return /* @__PURE__ */ e(g, { content: h.content }, M);
1307
+ case "tool_call":
1308
+ return /* @__PURE__ */ e(x, { toolName: h.toolName, toolCallId: h.toolCallId, args: h.args }, M);
1309
+ case "tool_result":
1310
+ return /* @__PURE__ */ e(w, { toolName: h.toolName, toolCallId: h.toolCallId, content: h.content, artifacts: h.artifacts, renderMode: h.renderMode, html: h.html, artifactPreview: i }, M);
1311
+ case "error":
1312
+ return /* @__PURE__ */ e(T, { content: h.content, onRetry: o }, M);
1313
+ case "interrupt":
1314
+ return /* @__PURE__ */ e(
1315
+ We,
1316
+ {
1317
+ interrupt: h.interrupt,
1318
+ resolved: h.resolved ?? !1,
1319
+ response: h.response,
1320
+ onRespond: (y) => c(h.interrupt.interruptId, y)
1321
+ },
1322
+ M
1323
+ );
1324
+ default:
1325
+ return null;
1326
+ }
1327
+ }),
1328
+ r && s && !u && /* @__PURE__ */ e("span", { className: "sa-streaming-cursor", children: "|" }),
1329
+ !u && !r && E && /* @__PURE__ */ e(L, { message: t, onCopy: f, onRegenerate: s ? o : void 0, onFeedback: k ? l : void 0 })
1330
+ ] })
1161
1331
  ] }),
1162
- f && /* @__PURE__ */ e(Z, { src: n == null ? void 0 : n.user, role: "user" })
1332
+ u && /* @__PURE__ */ e(se, { src: a == null ? void 0 : a.user, role: "user" })
1163
1333
  ] });
1164
1334
  }
1165
- function je({ message: a, suggestedPrompts: t, onPromptClick: s }) {
1166
- return /* @__PURE__ */ d("div", { className: "sa-welcome", children: [
1167
- /* @__PURE__ */ e("div", { className: "sa-welcome-icon", children: /* @__PURE__ */ e(C, { name: "sparkles", size: 40 }) }),
1168
- /* @__PURE__ */ e("p", { className: "sa-welcome-message", children: a || "你好!有什么可以帮你的?" }),
1169
- t && t.length > 0 && /* @__PURE__ */ e("div", { className: "sa-welcome-prompts", children: t.map((r, n) => /* @__PURE__ */ e(
1335
+ function Ve({ message: t, suggestedPrompts: r, onPromptClick: s }) {
1336
+ return /* @__PURE__ */ p("div", { className: "sa-welcome", children: [
1337
+ /* @__PURE__ */ e("div", { className: "sa-welcome-icon", children: /* @__PURE__ */ e(z, { name: "sparkles", size: 40 }) }),
1338
+ /* @__PURE__ */ e("p", { className: "sa-welcome-message", children: t || "你好!有什么可以帮你的?" }),
1339
+ r && r.length > 0 && /* @__PURE__ */ e("div", { className: "sa-welcome-prompts", children: r.map((n, a) => /* @__PURE__ */ e(
1170
1340
  "button",
1171
1341
  {
1172
1342
  className: "sa-welcome-prompt",
1173
- onClick: () => s(r),
1174
- children: r
1343
+ onClick: () => s(n),
1344
+ children: n
1175
1345
  },
1176
- n
1346
+ a
1177
1347
  )) })
1178
1348
  ] });
1179
1349
  }
1180
- function re({ slots: a, welcomeMessage: t, suggestedPrompts: s, avatar: r, artifactPreview: n }) {
1181
- const { messages: o, status: i, sendMessage: l } = F(), { containerRef: c } = ge([o]), p = i === "streaming", f = a.WelcomeScreen ?? je;
1182
- return o.length === 0 ? /* @__PURE__ */ e("div", { className: "sa-thread", ref: c, children: /* @__PURE__ */ e(
1183
- f,
1350
+ function de({ slots: t, welcomeMessage: r, suggestedPrompts: s, avatar: n, artifactPreview: a }) {
1351
+ const { messages: i, status: o, sendMessage: l } = U(), { containerRef: c } = ze([i]), f = o === "streaming", u = t.WelcomeScreen ?? Ve;
1352
+ return i.length === 0 ? /* @__PURE__ */ e("div", { className: "sa-thread", ref: c, children: /* @__PURE__ */ e(
1353
+ u,
1184
1354
  {
1185
- message: t,
1355
+ message: r,
1186
1356
  suggestedPrompts: s,
1187
1357
  onPromptClick: l
1188
1358
  }
1189
- ) }) : /* @__PURE__ */ e("div", { className: "sa-thread", ref: c, children: o.map((u, h) => /* @__PURE__ */ e(
1190
- He,
1359
+ ) }) : /* @__PURE__ */ e("div", { className: "sa-thread", ref: c, children: i.map((d, m) => /* @__PURE__ */ e(
1360
+ qe,
1191
1361
  {
1192
- message: u,
1193
- isStreaming: p,
1194
- isLast: h === o.length - 1,
1195
- slots: a,
1196
- avatar: r,
1197
- artifactPreview: n
1362
+ message: d,
1363
+ isStreaming: f,
1364
+ isLast: m === i.length - 1,
1365
+ slots: t,
1366
+ avatar: n,
1367
+ artifactPreview: a
1198
1368
  },
1199
- u.id
1369
+ d.id
1200
1370
  )) });
1201
1371
  }
1202
- function se() {
1203
- const { status: a, sendMessage: t, stop: s } = F(), [r, n] = T(""), o = _(null), i = a === "streaming" || a === "submitted", l = N(() => {
1204
- const f = r.trim();
1205
- !f || i || (t(f), n(""), o.current && (o.current.style.height = "auto"));
1206
- }, [r, i, t]), c = N((f) => {
1207
- f.key === "Enter" && !f.shiftKey && (f.preventDefault(), l());
1208
- }, [l]), p = N((f) => {
1209
- n(f.target.value);
1210
- const u = f.target;
1211
- u.style.height = "auto", u.style.height = Math.min(u.scrollHeight, 120) + "px";
1372
+ function Xe({ items: t, activeIndex: r, onSelect: s }) {
1373
+ const n = O(null);
1374
+ return B(() => {
1375
+ var i;
1376
+ const a = (i = n.current) == null ? void 0 : i.children[r];
1377
+ a == null || a.scrollIntoView({ block: "nearest" });
1378
+ }, [r]), 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((a, i) => /* @__PURE__ */ p(
1379
+ "div",
1380
+ {
1381
+ className: `sa-slash-menu-item${i === r ? " sa-slash-menu-item--active" : ""}`,
1382
+ onMouseDown: (o) => {
1383
+ o.preventDefault(), s(a);
1384
+ },
1385
+ children: [
1386
+ /* @__PURE__ */ p("span", { className: "sa-slash-menu-item-name", children: [
1387
+ "/",
1388
+ a.name
1389
+ ] }),
1390
+ (a.displayName || a.description) && /* @__PURE__ */ e("span", { className: "sa-slash-menu-item-desc", children: a.displayName || a.description })
1391
+ ]
1392
+ },
1393
+ a.code
1394
+ )) });
1395
+ }
1396
+ function Ge({ sdk: t, input: r, onSelect: s }) {
1397
+ const [n, a] = D([]), [i, o] = D(!1), [l, c] = D(0), f = O(!1);
1398
+ B(() => {
1399
+ f.current || (f.current = !0, t.listSkills().then(a).catch(() => a([])));
1400
+ }, [t]);
1401
+ const u = /^\/\S*$/.test(r);
1402
+ B(() => {
1403
+ o(u);
1404
+ }, [u]), B(() => {
1405
+ u && c(0);
1406
+ }, [r, u]);
1407
+ const d = r.startsWith("/") ? r.slice(1).toLowerCase() : "", m = G(
1408
+ () => n.filter(
1409
+ (k) => !d || k.code.toLowerCase().includes(d) || k.name.toLowerCase().includes(d) || k.displayName && k.displayName.toLowerCase().includes(d)
1410
+ ),
1411
+ [n, d]
1412
+ ), g = O(i), x = O(m), w = O(l), T = O(s);
1413
+ g.current = i, x.current = m, w.current = l, T.current = s;
1414
+ const L = N((k) => {
1415
+ if (!g.current || x.current.length === 0) return !1;
1416
+ switch (k.key) {
1417
+ case "ArrowDown":
1418
+ return k.preventDefault(), c((h) => (h + 1) % x.current.length), !0;
1419
+ case "ArrowUp":
1420
+ return k.preventDefault(), c((h) => (h - 1 + x.current.length) % x.current.length), !0;
1421
+ case "Enter":
1422
+ case "Tab":
1423
+ return k.preventDefault(), T.current(x.current[w.current]), o(!1), !0;
1424
+ case "Escape":
1425
+ return k.preventDefault(), o(!1), !0;
1426
+ default:
1427
+ return !1;
1428
+ }
1429
+ }, []), E = N(() => o(!1), []);
1430
+ return { isOpen: i, items: m, activeIndex: l, handleKeyDown: L, close: E };
1431
+ }
1432
+ function pe() {
1433
+ const { status: t, sendMessage: r, stop: s, sdk: n } = U(), [a, i] = D(""), o = O(null), l = t === "streaming" || t === "submitted", c = N((g) => {
1434
+ i(`/${g.name} `), setTimeout(() => {
1435
+ const x = o.current;
1436
+ x && (x.focus(), x.selectionStart = x.selectionEnd = x.value.length);
1437
+ }, 0);
1438
+ }, []), f = Ge({
1439
+ sdk: n,
1440
+ input: a,
1441
+ onSelect: c
1442
+ }), u = N(() => {
1443
+ const g = a.trim();
1444
+ !g || l || (r(g), i(""), o.current && (o.current.style.height = "auto"));
1445
+ }, [a, l, r]), d = N((g) => {
1446
+ f.handleKeyDown(g) || g.key === "Enter" && !g.shiftKey && (g.preventDefault(), u());
1447
+ }, [u, f.handleKeyDown]), m = N((g) => {
1448
+ i(g.target.value);
1449
+ const x = g.target;
1450
+ x.style.height = "auto", x.style.height = Math.min(x.scrollHeight, 120) + "px";
1212
1451
  }, []);
1213
- return /* @__PURE__ */ d("div", { className: "sa-composer", children: [
1452
+ return /* @__PURE__ */ p("div", { className: "sa-composer", children: [
1453
+ f.isOpen && /* @__PURE__ */ e(
1454
+ Xe,
1455
+ {
1456
+ items: f.items,
1457
+ activeIndex: f.activeIndex,
1458
+ onSelect: c
1459
+ }
1460
+ ),
1214
1461
  /* @__PURE__ */ e(
1215
1462
  "textarea",
1216
1463
  {
1217
1464
  ref: o,
1218
1465
  className: "sa-composer-input",
1219
- value: r,
1220
- onChange: p,
1221
- onKeyDown: c,
1222
- placeholder: "输入消息...",
1466
+ value: a,
1467
+ onChange: m,
1468
+ onKeyDown: d,
1469
+ placeholder: "输入消息,按 / 选择技能...",
1223
1470
  rows: 1,
1224
- disabled: a === "submitted"
1471
+ disabled: t === "submitted"
1225
1472
  }
1226
1473
  ),
1227
- i ? /* @__PURE__ */ e("button", { className: "sa-composer-stop", onClick: s, title: "停止", children: /* @__PURE__ */ e(C, { name: "circle-stop", size: 16, color: "#fff" }) }) : /* @__PURE__ */ e(
1474
+ l ? /* @__PURE__ */ e("button", { className: "sa-composer-stop", onClick: s, title: "停止", children: /* @__PURE__ */ e(z, { name: "circle-stop", size: 16, color: "#fff" }) }) : /* @__PURE__ */ e(
1228
1475
  "button",
1229
1476
  {
1230
1477
  className: "sa-composer-send",
1231
- onClick: l,
1232
- disabled: !r.trim(),
1478
+ onClick: u,
1479
+ disabled: !a.trim(),
1233
1480
  title: "发送",
1234
- children: /* @__PURE__ */ e(C, { name: "arrow-up", size: 16, color: "#fff" })
1481
+ children: /* @__PURE__ */ e(z, { name: "arrow-up", size: 16, color: "#fff" })
1235
1482
  }
1236
1483
  )
1237
1484
  ] });
1238
1485
  }
1239
- function _e({ artifact: a }) {
1240
- const [t, s] = Y.useState(null), [r, n] = Y.useState(!0), [o, i] = Y.useState(null);
1486
+ function Je({ artifact: t }) {
1487
+ const [r, s] = Y.useState(null), [n, a] = Y.useState(!0), [i, o] = Y.useState(null);
1241
1488
  return Y.useEffect(() => {
1242
1489
  let l = !1;
1243
- n(!0), i(null), s(null);
1490
+ a(!0), o(null), s(null);
1244
1491
  async function c() {
1245
1492
  try {
1246
- if (a.type === "pdf") {
1247
- l || n(!1);
1493
+ if (t.type === "pdf") {
1494
+ l || a(!1);
1248
1495
  return;
1249
1496
  }
1250
- if (a.type === "html") {
1251
- const p = await fetch(a.url);
1252
- if (!p.ok) throw new Error(`HTTP ${p.status}`);
1253
- const f = await p.text(), u = (await import("./purify.es-C-6FFqDW.js")).default;
1254
- l || (s(u.sanitize(f, { FORCE_BODY: !0 })), n(!1));
1497
+ if (t.type === "html") {
1498
+ const f = await fetch(t.url);
1499
+ if (!f.ok) throw new Error(`HTTP ${f.status}`);
1500
+ const u = await f.text(), d = (await import("./purify.es-C-6FFqDW.js")).default;
1501
+ l || (s(d.sanitize(u, { FORCE_BODY: !0, ADD_ATTR: ["target"] })), a(!1));
1255
1502
  return;
1256
1503
  }
1257
- if (a.type === "docx") {
1258
- const p = await fetch(a.url);
1259
- if (!p.ok) throw new Error(`HTTP ${p.status}`);
1260
- const f = await p.arrayBuffer(), h = await (await import("./mammoth.browser-COPV53yV.js").then((k) => k.m)).convertToHtml({ arrayBuffer: f }), v = (await import("./purify.es-C-6FFqDW.js")).default;
1261
- l || (s(v.sanitize(h.value, { FORCE_BODY: !0 })), n(!1));
1504
+ if (t.type === "docx") {
1505
+ const f = await fetch(t.url);
1506
+ if (!f.ok) throw new Error(`HTTP ${f.status}`);
1507
+ const u = await f.arrayBuffer(), m = await (await import("./mammoth.browser-COPV53yV.js").then((x) => x.m)).convertToHtml({ arrayBuffer: u }), g = (await import("./purify.es-C-6FFqDW.js")).default;
1508
+ l || (s(g.sanitize(m.value, { FORCE_BODY: !0, ADD_ATTR: ["target"] })), a(!1));
1262
1509
  return;
1263
1510
  }
1264
- l || (n(!1), i(`不支持预览「${a.type}」类型`));
1265
- } catch (p) {
1266
- l || (n(!1), i(p instanceof Error ? p.message : "加载失败"));
1511
+ l || (a(!1), o(`不支持预览「${t.type}」类型`));
1512
+ } catch (f) {
1513
+ l || (a(!1), o(f instanceof Error ? f.message : "加载失败"));
1267
1514
  }
1268
1515
  }
1269
1516
  return c(), () => {
1270
1517
  l = !0;
1271
1518
  };
1272
- }, [a]), r ? /* @__PURE__ */ e("div", { className: "sa-drawer-preview-loading", children: "加载中" }) : o ? /* @__PURE__ */ d("div", { className: "sa-drawer-preview-error", children: [
1273
- o,
1274
- /* @__PURE__ */ e("button", { className: "sa-drawer-btn-sm", onClick: () => void U(a), children: "下载查看" })
1275
- ] }) : a.type === "pdf" ? /* @__PURE__ */ e("iframe", { src: a.url, title: a.filename, className: "sa-drawer-preview-iframe", sandbox: "allow-scripts" }) : t !== null ? /* @__PURE__ */ e("iframe", { srcDoc: t, title: a.filename, className: "sa-drawer-preview-iframe", sandbox: "allow-same-origin" }) : null;
1519
+ }, [t]), n ? /* @__PURE__ */ e("div", { className: "sa-drawer-preview-loading", children: "加载中" }) : i ? /* @__PURE__ */ p("div", { className: "sa-drawer-preview-error", children: [
1520
+ i,
1521
+ /* @__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" }) : r !== null ? /* @__PURE__ */ e("iframe", { srcDoc: r, title: t.filename, className: "sa-drawer-preview-iframe", sandbox: "allow-same-origin" }) : null;
1276
1523
  }
1277
- function ne({ artifacts: a, initialArtifact: t, onClose: s }) {
1278
- const [r, n] = T(
1279
- t ? { mode: "preview", artifact: t } : { mode: "list" }
1280
- ), [o, i] = T(!1), l = _(null), [c, p] = T(340), f = _(null);
1524
+ function fe({ artifacts: t, initialArtifact: r, onClose: s }) {
1525
+ const [n, a] = D(
1526
+ r ? { mode: "preview", artifact: r } : { mode: "list" }
1527
+ ), [i, o] = D(!1), l = O(null), [c, f] = D(340), u = O(null);
1281
1528
  B(() => {
1282
- t && (l.current && (clearTimeout(l.current), l.current = null, i(!1)), n({ mode: "preview", artifact: t }));
1283
- }, [t]);
1284
- const u = N(() => {
1285
- i(!0), l.current = setTimeout(() => {
1529
+ r && (l.current && (clearTimeout(l.current), l.current = null, o(!1)), a({ mode: "preview", artifact: r }));
1530
+ }, [r]);
1531
+ const d = N(() => {
1532
+ o(!0), l.current = setTimeout(() => {
1286
1533
  l.current = null, s();
1287
1534
  }, 240);
1288
1535
  }, [s]);
1289
1536
  B(() => () => {
1290
- var g;
1291
- l.current && clearTimeout(l.current), (g = f.current) == null || g.call(f);
1537
+ var w;
1538
+ l.current && clearTimeout(l.current), (w = u.current) == null || w.call(u);
1292
1539
  }, []);
1293
- const h = N((g) => {
1294
- n({ mode: "preview", artifact: g });
1295
- }, []), v = N(() => {
1296
- n({ mode: "list" });
1540
+ const m = N((w) => {
1541
+ a({ mode: "preview", artifact: w });
1542
+ }, []), g = N(() => {
1543
+ a({ mode: "list" });
1297
1544
  }, []);
1298
1545
  B(() => {
1299
- const g = (b) => {
1300
- b.key === "Escape" && u();
1546
+ const w = (T) => {
1547
+ T.key === "Escape" && d();
1301
1548
  };
1302
- return document.addEventListener("keydown", g), () => document.removeEventListener("keydown", g);
1303
- }, [u]);
1304
- const k = N((g) => {
1305
- g.preventDefault();
1306
- const b = g.clientX, m = c, x = (D) => {
1307
- const M = b - D.clientX;
1308
- p(Math.max(240, Math.min(window.innerWidth * 0.7, m + M)));
1309
- }, I = () => {
1310
- document.removeEventListener("mousemove", x), document.removeEventListener("mouseup", I), document.body.style.cursor = "", document.body.style.userSelect = "", f.current = null;
1549
+ return document.addEventListener("keydown", w), () => document.removeEventListener("keydown", w);
1550
+ }, [d]);
1551
+ const x = N((w) => {
1552
+ w.preventDefault();
1553
+ const T = w.clientX, L = c, E = (h) => {
1554
+ const M = T - h.clientX;
1555
+ f(Math.max(240, Math.min(window.innerWidth * 0.7, L + M)));
1556
+ }, k = () => {
1557
+ document.removeEventListener("mousemove", E), document.removeEventListener("mouseup", k), document.body.style.cursor = "", document.body.style.userSelect = "", u.current = null;
1311
1558
  };
1312
- document.body.style.cursor = "col-resize", document.body.style.userSelect = "none", document.addEventListener("mousemove", x), document.addEventListener("mouseup", I), f.current = I;
1559
+ document.body.style.cursor = "col-resize", document.body.style.userSelect = "none", document.addEventListener("mousemove", E), document.addEventListener("mouseup", k), u.current = k;
1313
1560
  }, [c]);
1314
- return /* @__PURE__ */ d("div", { className: `sa-artifact-drawer ${o ? "sa-drawer-closing" : ""}`, style: { width: c }, children: [
1315
- /* @__PURE__ */ e("div", { className: "sa-drawer-resize-handle", onMouseDown: k }),
1316
- /* @__PURE__ */ d("div", { className: "sa-artifact-drawer-header", children: [
1317
- r.mode === "preview" ? /* @__PURE__ */ d(q, { children: [
1318
- /* @__PURE__ */ e("button", { className: "sa-drawer-btn", onClick: v, title: "返回列表", "aria-label": "返回列表", children: /* @__PURE__ */ e("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: /* @__PURE__ */ e("path", { d: "M15 18l-6-6 6-6" }) }) }),
1319
- /* @__PURE__ */ e("span", { className: "sa-artifact-drawer-title", children: r.artifact.filename })
1320
- ] }) : /* @__PURE__ */ d(q, { children: [
1321
- /* @__PURE__ */ d("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", style: { flexShrink: 0 }, children: [
1561
+ return /* @__PURE__ */ p("div", { className: `sa-artifact-drawer ${i ? "sa-drawer-closing" : ""}`, style: { width: c }, children: [
1562
+ /* @__PURE__ */ e("div", { className: "sa-drawer-resize-handle", onMouseDown: x }),
1563
+ /* @__PURE__ */ p("div", { className: "sa-artifact-drawer-header", children: [
1564
+ n.mode === "preview" ? /* @__PURE__ */ p(J, { children: [
1565
+ /* @__PURE__ */ e("button", { className: "sa-drawer-btn", onClick: g, 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
+ /* @__PURE__ */ e("span", { className: "sa-artifact-drawer-title", children: n.artifact.filename })
1567
+ ] }) : /* @__PURE__ */ p(J, { children: [
1568
+ /* @__PURE__ */ p("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", style: { flexShrink: 0 }, children: [
1322
1569
  /* @__PURE__ */ e("path", { d: "M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z" }),
1323
1570
  /* @__PURE__ */ e("polyline", { points: "14 2 14 8 20 8" })
1324
1571
  ] }),
1325
1572
  /* @__PURE__ */ e("span", { className: "sa-artifact-drawer-title", children: "会话产物" })
1326
1573
  ] }),
1327
1574
  /* @__PURE__ */ e("div", { style: { flex: 1 } }),
1328
- r.mode === "preview" && /* @__PURE__ */ e("button", { className: "sa-drawer-btn", onClick: () => void U(r.artifact), title: "下载", "aria-label": "下载", children: /* @__PURE__ */ e("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: /* @__PURE__ */ e("path", { d: "M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4M7 10l5 5 5-5M12 15V3" }) }) }),
1329
- /* @__PURE__ */ e("button", { className: "sa-drawer-btn", onClick: u, title: "关闭", "aria-label": "关闭", children: /* @__PURE__ */ e("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: /* @__PURE__ */ e("path", { d: "M18 6L6 18M6 6l12 12" }) }) })
1575
+ 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: d, title: "关闭", "aria-label": "关闭", children: /* @__PURE__ */ e("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: /* @__PURE__ */ e("path", { d: "M18 6L6 18M6 6l12 12" }) }) })
1330
1577
  ] }),
1331
- /* @__PURE__ */ e("div", { className: "sa-artifact-drawer-body", children: r.mode === "list" ? a.length === 0 ? /* @__PURE__ */ e("div", { className: "sa-drawer-empty", children: "暂无产物" }) : /* @__PURE__ */ e("ul", { className: "sa-drawer-file-list", role: "list", children: a.map((g, b) => /* @__PURE__ */ d(
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((w, T) => /* @__PURE__ */ p(
1332
1579
  "li",
1333
1580
  {
1334
1581
  className: "sa-drawer-file-card",
1335
- onClick: () => h(g),
1336
- onKeyDown: (m) => {
1337
- (m.key === "Enter" || m.key === " ") && (m.preventDefault(), h(g));
1582
+ onClick: () => m(w),
1583
+ onKeyDown: (L) => {
1584
+ (L.key === "Enter" || L.key === " ") && (L.preventDefault(), m(w));
1338
1585
  },
1339
1586
  tabIndex: 0,
1340
1587
  role: "button",
1341
- "aria-label": `预览 ${g.filename}`,
1588
+ "aria-label": `预览 ${w.filename}`,
1342
1589
  children: [
1343
- /* @__PURE__ */ e("div", { className: "sa-drawer-file-icon", children: /* @__PURE__ */ e("span", { className: "sa-artifact-chip-type", children: ee(g.type) }) }),
1344
- /* @__PURE__ */ d("div", { className: "sa-drawer-file-info", children: [
1345
- /* @__PURE__ */ e("span", { className: "sa-drawer-file-name", children: g.filename }),
1346
- /* @__PURE__ */ e("span", { className: "sa-drawer-file-size", children: Q(g.size) })
1590
+ /* @__PURE__ */ e("div", { className: "sa-drawer-file-icon", children: /* @__PURE__ */ e("span", { className: "sa-artifact-chip-type", children: ie(w.type) }) }),
1591
+ /* @__PURE__ */ p("div", { className: "sa-drawer-file-info", children: [
1592
+ /* @__PURE__ */ e("span", { className: "sa-drawer-file-name", children: w.filename }),
1593
+ /* @__PURE__ */ e("span", { className: "sa-drawer-file-size", children: ne(w.size) })
1347
1594
  ] }),
1348
1595
  /* @__PURE__ */ e(
1349
1596
  "button",
1350
1597
  {
1351
1598
  className: "sa-drawer-btn",
1352
1599
  title: "下载",
1353
- "aria-label": `下载 ${g.filename}`,
1354
- onClick: (m) => {
1355
- m.stopPropagation(), U(g);
1600
+ "aria-label": `下载 ${w.filename}`,
1601
+ onClick: (L) => {
1602
+ L.stopPropagation(), Z(w);
1356
1603
  },
1357
1604
  children: /* @__PURE__ */ e("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: /* @__PURE__ */ e("path", { d: "M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4M7 10l5 5 5-5M12 15V3" }) })
1358
1605
  }
1359
1606
  )
1360
1607
  ]
1361
1608
  },
1362
- g.id || `artifact-${b}`
1363
- )) }) : /* @__PURE__ */ e("div", { className: "sa-drawer-view-enter", children: /* @__PURE__ */ e(_e, { artifact: r.artifact }) }) })
1609
+ w.id || `artifact-${T}`
1610
+ )) }) : /* @__PURE__ */ e("div", { className: "sa-drawer-view-enter", children: /* @__PURE__ */ e(Je, { artifact: n.artifact }) }) })
1364
1611
  ] });
1365
1612
  }
1366
- function We({ isOpen: a, onClose: t, title: s, slots: r, welcomeMessage: n, suggestedPrompts: o, avatar: i, artifactPreview: l }) {
1367
- const { status: c, sendMessage: p, stop: f, toggleThreadList: u, toggleArtifactDrawer: h, conversations: v, activeConversationId: k, switchConversation: g, newConversation: b, deleteConversation: m, renameConversation: x, isThreadListOpen: I, isArtifactDrawerOpen: D, allArtifacts: M, activePreviewArtifact: O } = F();
1368
- if (!a) return null;
1369
- const y = r.Header, L = r.Composer, $ = r.ThreadList;
1370
- return /* @__PURE__ */ d("div", { className: "sa-panel", children: [
1371
- y ? /* @__PURE__ */ e(y, { title: s, onClose: t, onToggleThreadList: u }) : /* @__PURE__ */ e(
1372
- ue,
1613
+ function Ze({ isOpen: t, onClose: r, title: s, slots: n, welcomeMessage: a, suggestedPrompts: i, avatar: o, artifactPreview: l }) {
1614
+ const { status: c, sendMessage: f, stop: u, toggleThreadList: d, toggleArtifactDrawer: m, conversations: g, activeConversationId: x, switchConversation: w, newConversation: T, deleteConversation: L, renameConversation: E, isThreadListOpen: k, isArtifactDrawerOpen: h, allArtifacts: M, activePreviewArtifact: y } = U();
1615
+ if (!t) return null;
1616
+ const b = n.Header, v = n.Composer, C = n.ThreadList;
1617
+ return /* @__PURE__ */ p("div", { className: "sa-panel", children: [
1618
+ b ? /* @__PURE__ */ e(b, { title: s, onClose: r, onToggleThreadList: d }) : /* @__PURE__ */ e(
1619
+ ke,
1373
1620
  {
1374
1621
  title: s,
1375
- onClose: t,
1376
- onToggleThreadList: u,
1622
+ onClose: r,
1623
+ onToggleThreadList: d,
1377
1624
  artifactCount: l ? M.length : 0,
1378
- onToggleArtifactDrawer: l ? h : void 0
1625
+ onToggleArtifactDrawer: l ? m : void 0
1379
1626
  }
1380
1627
  ),
1381
- $ && I ? /* @__PURE__ */ e(
1382
- $,
1628
+ C && k ? /* @__PURE__ */ e(
1629
+ C,
1383
1630
  {
1384
- conversations: v,
1385
- activeSessionId: k,
1386
- onSwitch: g,
1387
- onNew: b,
1388
- onDelete: m,
1389
- onRename: x
1631
+ conversations: g,
1632
+ activeSessionId: x,
1633
+ onSwitch: w,
1634
+ onNew: T,
1635
+ onDelete: L,
1636
+ onRename: E
1390
1637
  }
1391
- ) : /* @__PURE__ */ e(he, {}),
1392
- /* @__PURE__ */ d("div", { className: "sa-panel-content", children: [
1393
- /* @__PURE__ */ e(re, { slots: r, welcomeMessage: n, suggestedPrompts: o, avatar: i, artifactPreview: l }),
1394
- l && D && /* @__PURE__ */ e(ne, { artifacts: M, initialArtifact: O, onClose: h })
1638
+ ) : /* @__PURE__ */ e(Ce, {}),
1639
+ /* @__PURE__ */ p("div", { className: "sa-panel-content", children: [
1640
+ /* @__PURE__ */ e(de, { slots: n, welcomeMessage: a, suggestedPrompts: i, avatar: o, artifactPreview: l }),
1641
+ l && h && /* @__PURE__ */ e(fe, { artifacts: M, initialArtifact: y, onClose: m })
1395
1642
  ] }),
1396
- L ? /* @__PURE__ */ e(L, { status: c, onSend: p, onStop: f }) : /* @__PURE__ */ e(se, {})
1643
+ v ? /* @__PURE__ */ e(v, { status: c, onSend: f, onStop: u }) : /* @__PURE__ */ e(pe, {})
1397
1644
  ] });
1398
1645
  }
1399
- function Fe({
1400
- conversations: a,
1401
- activeSessionId: t,
1646
+ function Qe({
1647
+ conversations: t,
1648
+ activeSessionId: r,
1402
1649
  onSwitch: s,
1403
- onNew: r,
1404
- onDelete: n,
1650
+ onNew: n,
1651
+ onDelete: a,
1652
+ onRename: i,
1405
1653
  isCollapsed: o,
1406
- onToggleCollapse: i
1654
+ onToggleCollapse: l,
1655
+ hasMore: c,
1656
+ onLoadMore: f
1407
1657
  }) {
1408
- const [l, c] = T(null), [p, f] = T(null), u = N((v, k) => {
1409
- k.stopPropagation(), p === v ? (n(v), f(null)) : (f(v), setTimeout(() => f(null), 3e3));
1410
- }, [p, n]), h = (() => {
1411
- const v = Date.now(), k = [], g = [], b = [];
1412
- for (const x of a) {
1413
- const I = v - new Date(x.updateTime).getTime();
1414
- I < 864e5 ? k.push(x) : I < 6048e5 ? g.push(x) : b.push(x);
1658
+ const [u, d] = D(null), [m, g] = D(null), [x, w] = D(null), [T, L] = D(""), E = N(
1659
+ (v, C) => {
1660
+ C.stopPropagation(), m === v ? (a(v), g(null)) : (g(v), setTimeout(() => g(null), 3e3));
1661
+ },
1662
+ [m, a]
1663
+ ), k = N(
1664
+ (v, C, P) => {
1665
+ P.stopPropagation(), w(v), L(C ?? "");
1666
+ },
1667
+ []
1668
+ ), h = N(
1669
+ (v) => {
1670
+ T.trim() && i(v, T.trim()), w(null);
1671
+ },
1672
+ [T, i]
1673
+ ), M = O(null), y = N(() => {
1674
+ const v = M.current;
1675
+ !v || !c || !f || v.scrollHeight - v.scrollTop - v.clientHeight < 50 && f();
1676
+ }, [c, f]), b = (() => {
1677
+ const v = Date.now(), C = [], P = [], R = [];
1678
+ for (const A of t) {
1679
+ const j = v - new Date(A.updateTime).getTime();
1680
+ j < 864e5 ? C.push(A) : j < 6048e5 ? P.push(A) : R.push(A);
1415
1681
  }
1416
- const m = [];
1417
- return k.length && m.push({ label: "今天", items: k }), g.length && m.push({ label: "最近 7 天", items: g }), b.length && m.push({ label: "更早", items: b }), m;
1682
+ const S = [];
1683
+ return C.length && S.push({ label: "今天", items: C }), P.length && S.push({ label: "最近 7 天", items: P }), R.length && S.push({ label: "更早", items: R }), S;
1418
1684
  })();
1419
- return o ? /* @__PURE__ */ d("div", { className: "sa-fp-sidebar sa-fp-sidebar-collapsed", children: [
1420
- /* @__PURE__ */ e("button", { className: "sa-fp-sidebar-toggle", onClick: i, title: "展开", children: /* @__PURE__ */ e(C, { name: "panel-left", size: 18 }) }),
1421
- /* @__PURE__ */ e("button", { className: "sa-fp-sidebar-toggle", onClick: r, title: "新会话", style: { marginTop: 4 }, children: /* @__PURE__ */ e(C, { name: "plus", size: 18 }) })
1422
- ] }) : /* @__PURE__ */ d("div", { className: "sa-fp-sidebar", children: [
1423
- /* @__PURE__ */ d("div", { className: "sa-fp-sidebar-header", children: [
1424
- /* @__PURE__ */ d("button", { className: "sa-fp-sidebar-new", onClick: r, children: [
1425
- /* @__PURE__ */ e(C, { name: "plus", size: 15 }),
1685
+ return o ? /* @__PURE__ */ p("div", { className: "sa-fp-sidebar sa-fp-sidebar-collapsed", children: [
1686
+ /* @__PURE__ */ e(
1687
+ "button",
1688
+ {
1689
+ className: "sa-fp-sidebar-toggle",
1690
+ onClick: l,
1691
+ title: "展开",
1692
+ children: /* @__PURE__ */ e(z, { name: "panel-left", size: 18 })
1693
+ }
1694
+ ),
1695
+ /* @__PURE__ */ e(
1696
+ "button",
1697
+ {
1698
+ className: "sa-fp-sidebar-toggle",
1699
+ onClick: n,
1700
+ title: "新会话",
1701
+ style: { marginTop: 4 },
1702
+ children: /* @__PURE__ */ e(z, { name: "plus", size: 18 })
1703
+ }
1704
+ )
1705
+ ] }) : /* @__PURE__ */ p("div", { className: "sa-fp-sidebar", children: [
1706
+ /* @__PURE__ */ p("div", { className: "sa-fp-sidebar-header", children: [
1707
+ /* @__PURE__ */ p("button", { className: "sa-fp-sidebar-new", onClick: n, children: [
1708
+ /* @__PURE__ */ e(z, { name: "plus", size: 15 }),
1426
1709
  " ",
1427
1710
  /* @__PURE__ */ e("span", { children: "新会话" })
1428
1711
  ] }),
1429
- /* @__PURE__ */ e("button", { className: "sa-fp-sidebar-toggle", onClick: i, title: "收起侧边栏", children: /* @__PURE__ */ e(C, { name: "panel-left-close", size: 18 }) })
1712
+ /* @__PURE__ */ e(
1713
+ "button",
1714
+ {
1715
+ className: "sa-fp-sidebar-toggle",
1716
+ onClick: l,
1717
+ title: "收起侧边栏",
1718
+ children: /* @__PURE__ */ e(z, { name: "panel-left-close", size: 18 })
1719
+ }
1720
+ )
1430
1721
  ] }),
1431
- /* @__PURE__ */ d("div", { className: "sa-fp-sidebar-list", children: [
1432
- a.length === 0 && /* @__PURE__ */ e("div", { className: "sa-fp-sidebar-empty", children: "开始你的第一个对话" }),
1433
- h.map((v) => /* @__PURE__ */ d("div", { children: [
1722
+ /* @__PURE__ */ p("div", { className: "sa-fp-sidebar-list", ref: M, onScroll: y, children: [
1723
+ t.length === 0 && /* @__PURE__ */ e("div", { className: "sa-fp-sidebar-empty", children: "开始你的第一个对话" }),
1724
+ b.map((v) => /* @__PURE__ */ p("div", { children: [
1434
1725
  /* @__PURE__ */ e("div", { className: "sa-fp-sidebar-group", children: v.label }),
1435
- v.items.map((k) => {
1436
- const g = k.sessionId === t, b = l === k.sessionId, m = p === k.sessionId;
1437
- return /* @__PURE__ */ d(
1726
+ v.items.map((C) => {
1727
+ const P = C.sessionId === r, R = u === C.sessionId, S = m === C.sessionId;
1728
+ return /* @__PURE__ */ p(
1438
1729
  "div",
1439
1730
  {
1440
- className: `sa-fp-sidebar-item ${g ? "active" : ""}`,
1441
- onClick: () => s(k.sessionId),
1442
- onMouseEnter: () => c(k.sessionId),
1443
- onMouseLeave: () => c(null),
1731
+ className: `sa-fp-sidebar-item ${P ? "active" : ""}`,
1732
+ onClick: () => {
1733
+ x !== C.sessionId && s(C.sessionId);
1734
+ },
1735
+ onMouseEnter: () => d(C.sessionId),
1736
+ onMouseLeave: () => d(null),
1444
1737
  children: [
1445
- /* @__PURE__ */ e("span", { className: "sa-fp-sidebar-item-title", children: k.title || "新会话" }),
1446
- b && /* @__PURE__ */ e(
1447
- "button",
1738
+ x === C.sessionId ? /* @__PURE__ */ e(
1739
+ "input",
1448
1740
  {
1449
- className: `sa-fp-sidebar-item-action ${m ? "danger" : ""}`,
1450
- onClick: (x) => u(k.sessionId, x),
1451
- title: m ? "确认删除" : "删除",
1452
- children: /* @__PURE__ */ e(C, { name: m ? "x" : "trash2", size: 14 })
1741
+ className: "sa-fp-sidebar-item-edit",
1742
+ value: T,
1743
+ onChange: (A) => L(A.target.value),
1744
+ onBlur: () => h(C.sessionId),
1745
+ onKeyDown: (A) => {
1746
+ A.key === "Enter" && h(C.sessionId), A.key === "Escape" && w(null);
1747
+ },
1748
+ onClick: (A) => A.stopPropagation(),
1749
+ autoFocus: !0
1750
+ }
1751
+ ) : /* @__PURE__ */ e("span", { className: "sa-fp-sidebar-item-title", children: C.title || "新会话" }),
1752
+ /* @__PURE__ */ p(
1753
+ "div",
1754
+ {
1755
+ className: `sa-fp-sidebar-item-actions ${R && x !== C.sessionId ? "visible" : ""}`,
1756
+ children: [
1757
+ /* @__PURE__ */ e(
1758
+ "button",
1759
+ {
1760
+ className: "sa-fp-sidebar-item-action",
1761
+ onClick: (A) => k(C.sessionId, C.title, A),
1762
+ title: "重命名",
1763
+ children: /* @__PURE__ */ e(z, { name: "pen", size: 14 })
1764
+ }
1765
+ ),
1766
+ /* @__PURE__ */ e(
1767
+ "button",
1768
+ {
1769
+ className: `sa-fp-sidebar-item-action ${S ? "danger" : ""}`,
1770
+ onClick: (A) => E(C.sessionId, A),
1771
+ title: S ? "确认删除" : "删除",
1772
+ children: /* @__PURE__ */ e(z, { name: S ? "x" : "trash2", size: 14 })
1773
+ }
1774
+ )
1775
+ ]
1453
1776
  }
1454
1777
  )
1455
1778
  ]
1456
1779
  },
1457
- k.sessionId
1780
+ C.sessionId
1458
1781
  );
1459
1782
  })
1460
- ] }, v.label))
1783
+ ] }, v.label)),
1784
+ c && /* @__PURE__ */ e("div", { className: "sa-thread-list-loading", children: "加载更多..." })
1461
1785
  ] })
1462
1786
  ] });
1463
1787
  }
1464
- function Ye({ title: a, slots: t, welcomeMessage: s, suggestedPrompts: r, sidebarDefaultOpen: n = !0, onClose: o, avatar: i, artifactPreview: l }) {
1788
+ function et({
1789
+ title: t,
1790
+ slots: r,
1791
+ welcomeMessage: s,
1792
+ suggestedPrompts: n,
1793
+ sidebarDefaultOpen: a = !0,
1794
+ onClose: i,
1795
+ avatar: o,
1796
+ artifactPreview: l
1797
+ }) {
1465
1798
  const {
1466
1799
  status: c,
1467
- sendMessage: p,
1468
- stop: f,
1469
- conversations: u,
1470
- activeConversationId: h,
1471
- switchConversation: v,
1472
- newConversation: k,
1473
- deleteConversation: g,
1474
- renameConversation: b,
1475
- toggleArtifactDrawer: m,
1476
- isArtifactDrawerOpen: x,
1477
- allArtifacts: I,
1478
- activePreviewArtifact: D
1479
- } = F(), [M, O] = T(n), y = N(() => O((S) => !S), []), L = t.ThreadList, $ = t.Composer;
1480
- return /* @__PURE__ */ d("div", { className: "sa-fullpage", children: [
1481
- L ? /* @__PURE__ */ e("div", { className: `sa-fp-sidebar-wrapper ${M ? "" : "sa-fp-sidebar-wrapper-collapsed"}`, children: /* @__PURE__ */ e(
1482
- L,
1800
+ sendMessage: f,
1801
+ stop: u,
1802
+ conversations: d,
1803
+ activeConversationId: m,
1804
+ switchConversation: g,
1805
+ newConversation: x,
1806
+ deleteConversation: w,
1807
+ renameConversation: T,
1808
+ toggleArtifactDrawer: L,
1809
+ isArtifactDrawerOpen: E,
1810
+ allArtifacts: k,
1811
+ activePreviewArtifact: h,
1812
+ hasMore: M,
1813
+ loadMoreConversations: y
1814
+ } = U(), [b, v] = D(a), C = N(() => v((S) => !S), []), P = r.ThreadList, R = r.Composer;
1815
+ return /* @__PURE__ */ p("div", { className: "sa-fullpage", children: [
1816
+ P ? /* @__PURE__ */ e(
1817
+ "div",
1483
1818
  {
1484
- conversations: u,
1485
- activeSessionId: h,
1486
- onSwitch: v,
1487
- onNew: k,
1488
- onDelete: g,
1489
- onRename: b
1819
+ className: `sa-fp-sidebar-wrapper ${b ? "" : "sa-fp-sidebar-wrapper-collapsed"}`,
1820
+ children: /* @__PURE__ */ e(
1821
+ P,
1822
+ {
1823
+ conversations: d,
1824
+ activeSessionId: m,
1825
+ onSwitch: g,
1826
+ onNew: x,
1827
+ onDelete: w,
1828
+ onRename: T,
1829
+ hasMore: M,
1830
+ onLoadMore: y
1831
+ }
1832
+ )
1490
1833
  }
1491
- ) }) : /* @__PURE__ */ e(
1492
- Fe,
1834
+ ) : /* @__PURE__ */ e(
1835
+ Qe,
1493
1836
  {
1494
- conversations: u,
1495
- activeSessionId: h,
1496
- onSwitch: v,
1497
- onNew: k,
1498
- onDelete: g,
1499
- onRename: b,
1500
- isCollapsed: !M,
1501
- onToggleCollapse: y
1837
+ conversations: d,
1838
+ activeSessionId: m,
1839
+ onSwitch: g,
1840
+ onNew: x,
1841
+ onDelete: w,
1842
+ onRename: T,
1843
+ isCollapsed: !b,
1844
+ onToggleCollapse: C,
1845
+ hasMore: M,
1846
+ onLoadMore: y
1502
1847
  }
1503
1848
  ),
1504
- /* @__PURE__ */ d("div", { className: "sa-fp-main", children: [
1505
- /* @__PURE__ */ d("div", { className: "sa-fp-header", children: [
1506
- !M && !L && /* @__PURE__ */ e("button", { className: "sa-fp-header-btn", onClick: y, title: "展开侧边栏", children: /* @__PURE__ */ e(C, { name: "panel-left", size: 18 }) }),
1507
- /* @__PURE__ */ e("div", { className: "sa-fp-header-title", children: a }),
1508
- /* @__PURE__ */ d("div", { className: "sa-fp-header-actions", children: [
1509
- l && I.length > 0 && /* @__PURE__ */ d("button", { className: "sa-fp-header-btn sa-header-btn-artifact", onClick: m, title: "会话产物", children: [
1510
- /* @__PURE__ */ d("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: [
1511
- /* @__PURE__ */ e("path", { d: "M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z" }),
1512
- /* @__PURE__ */ e("polyline", { points: "14 2 14 8 20 8" })
1513
- ] }),
1514
- /* @__PURE__ */ e("span", { children: "产物" })
1515
- ] }),
1516
- o && /* @__PURE__ */ e("button", { className: "sa-fp-header-btn", onClick: o, title: "关闭", children: /* @__PURE__ */ e(C, { name: "x", size: 18 }) })
1849
+ /* @__PURE__ */ p("div", { className: "sa-fp-main", children: [
1850
+ /* @__PURE__ */ p("div", { className: "sa-fp-header", children: [
1851
+ !b && !P && /* @__PURE__ */ e(
1852
+ "button",
1853
+ {
1854
+ className: "sa-fp-header-btn",
1855
+ onClick: C,
1856
+ title: "展开侧边栏",
1857
+ children: /* @__PURE__ */ e(z, { name: "panel-left", size: 18 })
1858
+ }
1859
+ ),
1860
+ /* @__PURE__ */ e("div", { className: "sa-fp-header-title", children: t }),
1861
+ /* @__PURE__ */ p("div", { className: "sa-fp-header-actions", children: [
1862
+ l && k.length > 0 && /* @__PURE__ */ p(
1863
+ "button",
1864
+ {
1865
+ className: "sa-fp-header-btn sa-header-btn-artifact",
1866
+ onClick: L,
1867
+ title: "会话产物",
1868
+ children: [
1869
+ /* @__PURE__ */ p(
1870
+ "svg",
1871
+ {
1872
+ width: "14",
1873
+ height: "14",
1874
+ viewBox: "0 0 24 24",
1875
+ fill: "none",
1876
+ stroke: "currentColor",
1877
+ strokeWidth: "2",
1878
+ children: [
1879
+ /* @__PURE__ */ e("path", { d: "M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z" }),
1880
+ /* @__PURE__ */ e("polyline", { points: "14 2 14 8 20 8" })
1881
+ ]
1882
+ }
1883
+ ),
1884
+ /* @__PURE__ */ e("span", { children: "产物" })
1885
+ ]
1886
+ }
1887
+ ),
1888
+ i && /* @__PURE__ */ e(
1889
+ "button",
1890
+ {
1891
+ className: "sa-fp-header-btn",
1892
+ onClick: i,
1893
+ title: "关闭",
1894
+ children: /* @__PURE__ */ e(z, { name: "x", size: 18 })
1895
+ }
1896
+ )
1517
1897
  ] })
1518
1898
  ] }),
1519
- /* @__PURE__ */ d("div", { className: "sa-fp-content-row", children: [
1520
- /* @__PURE__ */ e(re, { slots: t, welcomeMessage: s, suggestedPrompts: r, avatar: i, artifactPreview: l }),
1521
- l && x && /* @__PURE__ */ e(ne, { artifacts: I, initialArtifact: D, onClose: m })
1899
+ /* @__PURE__ */ p("div", { className: "sa-fp-content-row", children: [
1900
+ /* @__PURE__ */ e(
1901
+ de,
1902
+ {
1903
+ slots: r,
1904
+ welcomeMessage: s,
1905
+ suggestedPrompts: n,
1906
+ avatar: o,
1907
+ artifactPreview: l
1908
+ }
1909
+ ),
1910
+ l && E && /* @__PURE__ */ e(
1911
+ fe,
1912
+ {
1913
+ artifacts: k,
1914
+ initialArtifact: h,
1915
+ onClose: L
1916
+ }
1917
+ )
1522
1918
  ] }),
1523
- $ ? /* @__PURE__ */ e($, { status: c, onSend: p, onStop: f }) : /* @__PURE__ */ e(se, {})
1919
+ R ? /* @__PURE__ */ e(R, { status: c, onSend: f, onStop: u }) : /* @__PURE__ */ e(pe, {})
1524
1920
  ] })
1525
1921
  ] });
1526
1922
  }
1527
- function Ke(a) {
1528
- const { sdk: t, mode: s = "floating", slots: r = {}, hooks: n = {}, welcomeMessage: o, suggestedPrompts: i, title: l = "AI Assistant", initialOpen: c = !1, onOpenChange: p, sidebarDefaultOpen: f, avatar: u, artifactPreview: h } = a, [v, k] = T(c);
1923
+ function tt(t) {
1924
+ const { sdk: r, mode: s = "floating", slots: n = {}, hooks: a = {}, welcomeMessage: i, suggestedPrompts: o, title: l = "AI Assistant", initialOpen: c = !1, onOpenChange: f, sidebarDefaultOpen: u, avatar: d, artifactPreview: m } = t, [g, x] = D(c);
1529
1925
  B(() => {
1530
- k(c);
1926
+ x(c);
1531
1927
  }, [c]);
1532
- const g = N(() => {
1533
- var I, D;
1534
- const x = !v;
1535
- k(x), p == null || p(x), x ? (I = n.onOpen) == null || I.call(n) : (D = n.onClose) == null || D.call(n);
1536
- }, [v, n, p]), b = N(() => {
1537
- var x;
1538
- k(!1), p == null || p(!1), (x = n.onClose) == null || x.call(n);
1539
- }, [n, p]), m = r.Trigger ?? fe;
1540
- return s === "fullpage" ? v ? /* @__PURE__ */ e(G, { sdk: t, hooks: n, children: /* @__PURE__ */ e(
1541
- Ye,
1928
+ const w = N(() => {
1929
+ var k, h;
1930
+ const E = !g;
1931
+ x(E), f == null || f(E), E ? (k = a.onOpen) == null || k.call(a) : (h = a.onClose) == null || h.call(a);
1932
+ }, [g, a, f]), T = N(() => {
1933
+ var E;
1934
+ x(!1), f == null || f(!1), (E = a.onClose) == null || E.call(a);
1935
+ }, [a, f]), L = n.Trigger ?? ye;
1936
+ return s === "fullpage" ? g ? /* @__PURE__ */ e(ae, { sdk: r, hooks: a, children: /* @__PURE__ */ e(
1937
+ et,
1542
1938
  {
1543
1939
  title: l,
1544
- slots: r,
1545
- welcomeMessage: o,
1546
- suggestedPrompts: i,
1547
- sidebarDefaultOpen: f,
1548
- onClose: b,
1549
- avatar: u,
1550
- artifactPreview: h
1940
+ slots: n,
1941
+ welcomeMessage: i,
1942
+ suggestedPrompts: o,
1943
+ sidebarDefaultOpen: u,
1944
+ onClose: T,
1945
+ avatar: d,
1946
+ artifactPreview: m
1551
1947
  }
1552
- ) }) : null : /* @__PURE__ */ d(G, { sdk: t, hooks: n, children: [
1553
- /* @__PURE__ */ e(m, { isOpen: v, onClick: g }),
1948
+ ) }) : null : /* @__PURE__ */ p(ae, { sdk: r, hooks: a, children: [
1949
+ /* @__PURE__ */ e(L, { isOpen: g, onClick: w }),
1554
1950
  /* @__PURE__ */ e(
1555
- We,
1951
+ Ze,
1556
1952
  {
1557
- isOpen: v,
1558
- onClose: b,
1953
+ isOpen: g,
1954
+ onClose: T,
1559
1955
  title: l,
1560
- slots: r,
1561
- welcomeMessage: o,
1562
- suggestedPrompts: i,
1563
- avatar: u,
1564
- artifactPreview: h
1956
+ slots: n,
1957
+ welcomeMessage: i,
1958
+ suggestedPrompts: o,
1959
+ avatar: d,
1960
+ artifactPreview: m
1565
1961
  }
1566
1962
  )
1567
1963
  ] });
1568
1964
  }
1569
- const Ue = `
1965
+ const at = `
1570
1966
  [data-super-agent-widget] {
1571
1967
  --sa-primary-dark: color-mix(in srgb, var(--sa-primary) 82%, #000);
1572
1968
  --sa-primary-light: color-mix(in srgb, var(--sa-primary) 10%, #fff);
1573
1969
  --sa-text: #1f2937;
1574
1970
  --sa-text-muted: #6b7280;
1971
+ --sa-text-light: #9ca3af;
1575
1972
  --sa-border: #e5e7eb;
1576
1973
  --sa-surface: #f9fafb;
1974
+ --sa-hover: #f3f4f6;
1577
1975
 
1578
1976
  font-family: var(--sa-font);
1579
1977
  color: var(--sa-text);
@@ -1761,13 +2159,19 @@ const Ue = `
1761
2159
  justify-content: flex-end;
1762
2160
  }
1763
2161
 
1764
- .sa-message-body {
2162
+ .sa-message-content {
1765
2163
  max-width: 78%;
1766
2164
  display: flex;
1767
2165
  flex-direction: column;
1768
2166
  gap: 4px;
1769
2167
  }
1770
2168
 
2169
+ .sa-message-body {
2170
+ display: flex;
2171
+ flex-direction: column;
2172
+ gap: 4px;
2173
+ }
2174
+
1771
2175
  .sa-message-user .sa-message-body {
1772
2176
  padding: 10px 14px;
1773
2177
  border-radius: 16px;
@@ -1791,6 +2195,16 @@ const Ue = `
1791
2195
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
1792
2196
  }
1793
2197
 
2198
+ .sa-message-time {
2199
+ font-size: 11px;
2200
+ color: var(--sa-text-muted);
2201
+ opacity: 0.7;
2202
+ }
2203
+
2204
+ .sa-message-time-right {
2205
+ text-align: right;
2206
+ }
2207
+
1794
2208
  .sa-avatar {
1795
2209
  width: 28px;
1796
2210
  height: 28px;
@@ -2036,6 +2450,8 @@ const Ue = `
2036
2450
  }
2037
2451
 
2038
2452
  .sa-tool-result-content {
2453
+ max-height: 100px;
2454
+ overflow-y: auto;
2039
2455
  padding: 10px 12px;
2040
2456
  color: #4b5563;
2041
2457
  font-size: 13px;
@@ -2088,12 +2504,21 @@ const Ue = `
2088
2504
 
2089
2505
  .sa-action-bar {
2090
2506
  display: flex;
2507
+ align-items: center;
2508
+ flex-wrap: wrap;
2091
2509
  gap: 6px;
2092
2510
  margin-top: 6px;
2093
2511
  position: relative;
2094
2512
  }
2095
2513
 
2096
2514
  .sa-action-btn {
2515
+ display: inline-flex;
2516
+ align-items: center;
2517
+ justify-content: center;
2518
+ gap: 4px;
2519
+ flex: none;
2520
+ white-space: nowrap;
2521
+ line-height: 1;
2097
2522
  padding: 4px 10px;
2098
2523
  border: none;
2099
2524
  border-radius: 6px;
@@ -2104,6 +2529,11 @@ const Ue = `
2104
2529
  transition: color 0.15s ease, background 0.15s ease;
2105
2530
  }
2106
2531
 
2532
+ .sa-action-btn svg {
2533
+ display: block;
2534
+ flex: none;
2535
+ }
2536
+
2107
2537
  .sa-action-btn:hover {
2108
2538
  color: var(--sa-text);
2109
2539
  background: rgba(0, 0, 0, 0.05);
@@ -2124,8 +2554,8 @@ const Ue = `
2124
2554
 
2125
2555
  /* ── Dislike Panel ── */
2126
2556
  .sa-dislike-panel {
2127
- position: absolute; bottom: 100%; left: 0; right: 0;
2128
- margin-bottom: 6px; padding: 12px;
2557
+ position: absolute; top: 100%; left: 0; right: 0;
2558
+ margin-top: 6px; padding: 12px;
2129
2559
  background: #fff; border: 1px solid var(--sa-border); border-radius: 10px;
2130
2560
  box-shadow: 0 4px 16px rgba(0,0,0,0.08);
2131
2561
  animation: sa-fade-in-up 0.2s cubic-bezier(0.16,1,0.3,1) both;
@@ -2163,6 +2593,7 @@ const Ue = `
2163
2593
  /* ── Composer ────────────────────────────────────────────── */
2164
2594
 
2165
2595
  .sa-composer {
2596
+ position: relative;
2166
2597
  display: flex;
2167
2598
  align-items: flex-end;
2168
2599
  gap: 10px;
@@ -2238,6 +2669,62 @@ const Ue = `
2238
2669
  transform: scale(1.05);
2239
2670
  }
2240
2671
 
2672
+ /* ── Slash Menu ─────────────────────────────────────────── */
2673
+
2674
+ .sa-slash-menu {
2675
+ position: absolute;
2676
+ bottom: 100%;
2677
+ left: 14px;
2678
+ right: 14px;
2679
+ max-width: 400px;
2680
+ max-height: 200px;
2681
+ overflow-y: auto;
2682
+ background: var(--sa-surface);
2683
+ border: 1px solid var(--sa-border);
2684
+ border-radius: 8px;
2685
+ box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.1);
2686
+ margin-bottom: 4px;
2687
+ z-index: 10;
2688
+ }
2689
+
2690
+ .sa-slash-menu-empty {
2691
+ padding: 12px 14px;
2692
+ color: #9ca3af;
2693
+ font-size: 13px;
2694
+ text-align: center;
2695
+ }
2696
+
2697
+ .sa-slash-menu-item {
2698
+ display: flex;
2699
+ align-items: center;
2700
+ gap: 8px;
2701
+ padding: 8px 14px;
2702
+ cursor: pointer;
2703
+ transition: background 0.15s ease;
2704
+ }
2705
+
2706
+ .sa-slash-menu-item:hover,
2707
+ .sa-slash-menu-item--active {
2708
+ background: var(--sa-hover);
2709
+ }
2710
+
2711
+ .sa-slash-menu-item-name {
2712
+ font-size: 13px;
2713
+ font-weight: 500;
2714
+ color: var(--sa-text);
2715
+ white-space: nowrap;
2716
+ }
2717
+
2718
+ .sa-slash-menu-item-desc {
2719
+ font-size: 12px;
2720
+ color: #9ca3af;
2721
+ overflow: hidden;
2722
+ text-overflow: ellipsis;
2723
+ white-space: nowrap;
2724
+ flex: 1;
2725
+ min-width: 0;
2726
+ }
2727
+
2241
2728
  /* ── Thread list ─────────────────────────────────────────── */
2242
2729
 
2243
2730
  .sa-thread-list-overlay {
@@ -2308,6 +2795,13 @@ const Ue = `
2308
2795
  font-size: 14px;
2309
2796
  }
2310
2797
 
2798
+ .sa-thread-list-loading {
2799
+ padding: 12px 16px;
2800
+ text-align: center;
2801
+ color: #9ca3af;
2802
+ font-size: 13px;
2803
+ }
2804
+
2311
2805
  .sa-thread-group-label {
2312
2806
  padding: 16px 8px 6px;
2313
2807
  font-size: 12px;
@@ -2339,13 +2833,26 @@ const Ue = `
2339
2833
  font-weight: 500;
2340
2834
  }
2341
2835
 
2342
- .sa-thread-item-title {
2836
+ .sa-thread-item-info {
2343
2837
  flex: 1;
2838
+ overflow: hidden;
2839
+ display: flex;
2840
+ flex-direction: column;
2841
+ gap: 2px;
2842
+ }
2843
+
2844
+ .sa-thread-item-title {
2344
2845
  overflow: hidden;
2345
2846
  white-space: nowrap;
2346
2847
  text-overflow: ellipsis;
2347
2848
  }
2348
2849
 
2850
+ .sa-thread-item-time {
2851
+ font-size: 11px;
2852
+ color: var(--sa-text-light);
2853
+ white-space: nowrap;
2854
+ }
2855
+
2349
2856
  .sa-thread-item-edit {
2350
2857
  width: 100%;
2351
2858
  padding: 4px 8px;
@@ -2357,22 +2864,33 @@ const Ue = `
2357
2864
  color: var(--sa-text);
2358
2865
  }
2359
2866
 
2360
- .sa-thread-item-delete {
2867
+ /* 操作按钮组:始终占位(visibility 控制),hover 时显示,高度不变 */
2868
+ .sa-thread-item-actions {
2869
+ display: flex;
2870
+ gap: 2px;
2871
+ flex-shrink: 0;
2872
+ visibility: hidden;
2873
+ }
2874
+
2875
+ .sa-thread-item:hover .sa-thread-item-actions {
2876
+ visibility: visible;
2877
+ }
2878
+
2879
+ .sa-thread-item-action-btn {
2361
2880
  border: none;
2362
2881
  background: transparent;
2363
2882
  color: var(--sa-text-muted);
2364
- font-size: 14px;
2365
2883
  cursor: pointer;
2366
- opacity: 0;
2367
- transition: opacity 0.15s ease, color 0.15s ease;
2368
- }
2369
-
2370
- .sa-thread-item:hover .sa-thread-item-delete {
2371
- opacity: 1;
2884
+ padding: 2px;
2885
+ border-radius: 4px;
2886
+ display: inline-flex;
2887
+ align-items: center;
2888
+ transition: color 0.15s ease, background 0.15s ease;
2372
2889
  }
2373
2890
 
2374
- .sa-thread-item-delete:hover {
2375
- color: #ef4444;
2891
+ .sa-thread-item-action-btn:hover {
2892
+ color: var(--sa-primary);
2893
+ background: rgba(99,102,241,0.08);
2376
2894
  }
2377
2895
 
2378
2896
  /* ── Welcome ─────────────────────────────────────────────── */
@@ -2608,16 +3126,34 @@ const Ue = `
2608
3126
  margin-left: 2px;
2609
3127
  }
2610
3128
 
2611
- .sa-interrupt-resolved {
2612
- display: flex;
2613
- align-items: center;
2614
- gap: 6px;
2615
- padding: 8px 12px;
2616
- border-radius: 8px;
2617
- background: #ecfdf5;
2618
- color: #065f46;
2619
- font-size: 13px;
2620
- margin: 6px 0;
3129
+ .sa-interrupt-submitted {
3130
+ margin-top: 8px;
3131
+ font-size: 12px;
3132
+ color: #9ca3af;
3133
+ }
3134
+
3135
+ .sa-interrupt-btn-answered {
3136
+ background: var(--sa-primary) !important;
3137
+ color: #fff !important;
3138
+ opacity: 0.7;
3139
+ }
3140
+
3141
+ .sa-interrupt-btn:disabled {
3142
+ opacity: 0.5;
3143
+ cursor: not-allowed;
3144
+ }
3145
+
3146
+ .sa-interrupt-option:disabled {
3147
+ opacity: 0.6;
3148
+ cursor: not-allowed;
3149
+ }
3150
+
3151
+ .sa-interrupt-input:disabled,
3152
+ .sa-interrupt-textarea:disabled,
3153
+ .sa-interrupt-select:disabled {
3154
+ opacity: 0.6;
3155
+ cursor: not-allowed;
3156
+ background: #f9fafb;
2621
3157
  }
2622
3158
 
2623
3159
  .sa-interrupt-unknown {
@@ -2666,13 +3202,11 @@ const Ue = `
2666
3202
  /* ── Fullpage Layout (DeepSeek-style) ────────────────────────── */
2667
3203
 
2668
3204
  .sa-fullpage {
2669
- position: fixed;
2670
- inset: 0;
2671
- width: 100vw;
2672
- height: 100vh;
3205
+ position: relative;
3206
+ width: 100%;
3207
+ height: 100%;
2673
3208
  display: flex;
2674
- background: #f7f7f8;
2675
- z-index: var(--sa-z-index, 9999);
3209
+ background: var(--sa-bg, #ffffff);
2676
3210
  }
2677
3211
 
2678
3212
  /* Sidebar */
@@ -2680,7 +3214,7 @@ const Ue = `
2680
3214
  width: 260px;
2681
3215
  display: flex;
2682
3216
  flex-direction: column;
2683
- background: #f2f2f3;
3217
+ background: var(--sa-surface, #ffffff);
2684
3218
  flex-shrink: 0;
2685
3219
  transition: width 0.2s cubic-bezier(0.16,1,0.3,1);
2686
3220
  overflow: hidden;
@@ -2806,6 +3340,29 @@ const Ue = `
2806
3340
  text-overflow: ellipsis;
2807
3341
  }
2808
3342
 
3343
+ .sa-fp-sidebar-item-edit {
3344
+ flex: 1;
3345
+ min-width: 0;
3346
+ padding: 2px 6px;
3347
+ border: 1px solid var(--sa-primary, #6366f1);
3348
+ border-radius: 4px;
3349
+ font-size: 13px;
3350
+ color: #27272a;
3351
+ background: #fff;
3352
+ outline: none;
3353
+ }
3354
+
3355
+ .sa-fp-sidebar-item-actions {
3356
+ display: flex;
3357
+ gap: 2px;
3358
+ flex-shrink: 0;
3359
+ visibility: hidden;
3360
+ }
3361
+
3362
+ .sa-fp-sidebar-item-actions.visible {
3363
+ visibility: visible;
3364
+ }
3365
+
2809
3366
  .sa-fp-sidebar-item-action {
2810
3367
  width: 24px;
2811
3368
  height: 24px;
@@ -2966,7 +3523,7 @@ const Ue = `
2966
3523
 
2967
3524
  /* ── Inline HTML rendering (render_mode=html) ── */
2968
3525
  .sa-tool-result-html { margin-top: 8px; border: 1px solid var(--sa-border); border-radius: 8px; overflow: hidden; }
2969
- .sa-tool-result-html-iframe { width: 100%; min-height: 120px; max-height: 400px; border: none; background: #fff; }
3526
+ .sa-tool-result-html-iframe { width: 100%; height: 120px; max-height: 500px; border: none; background: #fff; }
2970
3527
 
2971
3528
  /* ── Header artifact button ── */
2972
3529
  .sa-header-btn-artifact {
@@ -3095,7 +3652,7 @@ const Ue = `
3095
3652
  from { opacity: 0; transform: translateX(12px); }
3096
3653
  to { opacity: 1; transform: translateX(0); }
3097
3654
  }
3098
- `, Ve = {
3655
+ `, rt = {
3099
3656
  primaryColor: "#6366f1",
3100
3657
  backgroundColor: "#ffffff",
3101
3658
  fontFamily: "system-ui, -apple-system, sans-serif",
@@ -3104,78 +3661,98 @@ const Ue = `
3104
3661
  panelHeight: 520,
3105
3662
  zIndex: 9999
3106
3663
  };
3107
- function qe(a) {
3108
- const t = { ...Ve, ...a };
3664
+ function st(t, r) {
3665
+ const s = parseInt(t.slice(1, 3), 16), n = parseInt(t.slice(3, 5), 16), a = parseInt(t.slice(5, 7), 16), i = 1 - r;
3666
+ return `#${Math.round(s * i).toString(16).padStart(2, "0")}${Math.round(n * i).toString(16).padStart(2, "0")}${Math.round(a * i).toString(16).padStart(2, "0")}`;
3667
+ }
3668
+ function nt(t, r) {
3669
+ const s = parseInt(t.slice(1, 3), 16), n = parseInt(t.slice(3, 5), 16), a = parseInt(t.slice(5, 7), 16);
3670
+ return `#${Math.round(s + (255 - s) * r).toString(16).padStart(2, "0")}${Math.round(n + (255 - n) * r).toString(16).padStart(2, "0")}${Math.round(a + (255 - a) * r).toString(16).padStart(2, "0")}`;
3671
+ }
3672
+ function it(t) {
3673
+ const r = { ...rt, ...t }, s = r.primaryColor, n = r.backgroundColor;
3109
3674
  return [
3110
- `--sa-primary: ${t.primaryColor}`,
3111
- `--sa-bg: ${t.backgroundColor}`,
3112
- `--sa-font: ${t.fontFamily}`,
3113
- `--sa-radius: ${t.borderRadius}px`,
3114
- `--sa-panel-width: ${t.panelWidth}px`,
3115
- `--sa-panel-height: ${t.panelHeight}px`,
3116
- `--sa-z-index: ${t.zIndex}`
3675
+ // 用户直接配置的变量
3676
+ `--sa-primary: ${s}`,
3677
+ `--sa-bg: ${n}`,
3678
+ `--sa-font: ${r.fontFamily}`,
3679
+ `--sa-radius: ${r.borderRadius}px`,
3680
+ `--sa-panel-width: ${r.panelWidth}px`,
3681
+ `--sa-panel-height: ${r.panelHeight}px`,
3682
+ `--sa-z-index: ${r.zIndex}`,
3683
+ // 从 primaryColor 自动派生
3684
+ `--sa-primary-dark: ${st(s, 0.15)}`,
3685
+ `--sa-primary-light: ${nt(s, 0.9)}`,
3686
+ // 从 backgroundColor 自动派生的语义色
3687
+ `--sa-surface: ${n}`,
3688
+ "--sa-border: #e5e7eb",
3689
+ "--sa-hover: #f4f4f5",
3690
+ "--sa-text: #374151",
3691
+ "--sa-text-muted: #9ca3af",
3692
+ "--sa-text-light: #6b7280"
3117
3693
  ].join("; ");
3118
3694
  }
3119
- function Ze(a, t) {
3120
- const s = typeof a == "string" ? document.querySelector(a) : a;
3695
+ function dt(t, r) {
3696
+ const s = typeof t == "string" ? document.querySelector(t) : t;
3121
3697
  if (!s)
3122
- throw new Error(`Target element not found: ${a}`);
3123
- const r = document.createElement("div");
3124
- r.setAttribute("data-super-agent-widget", "");
3125
- const n = qe(t.theme ?? {});
3126
- if (r.setAttribute("style", n), s.appendChild(r), !document.getElementById("sa-widget-styles")) {
3698
+ throw new Error(`Target element not found: ${t}`);
3699
+ const n = document.createElement("div");
3700
+ n.setAttribute("data-super-agent-widget", "");
3701
+ const a = it(r.theme ?? {});
3702
+ if (n.setAttribute("style", `${a}; height: 100%;`), s.appendChild(n), !document.getElementById("sa-widget-styles")) {
3127
3703
  const c = document.createElement("style");
3128
- c.id = "sa-widget-styles", c.textContent = Ue, document.head.appendChild(c);
3704
+ c.id = "sa-widget-styles", c.textContent = at, document.head.appendChild(c);
3129
3705
  }
3130
- let o = le(r), i = !1;
3706
+ let i = he(n), o = !1;
3131
3707
  const l = (c) => {
3132
- o && o.render(
3133
- Y.createElement(Ke, {
3134
- ...t,
3135
- initialOpen: c ?? i,
3136
- onOpenChange: (p) => {
3137
- i = p;
3708
+ i && i.render(
3709
+ Y.createElement(tt, {
3710
+ ...r,
3711
+ initialOpen: c ?? o,
3712
+ onOpenChange: (f) => {
3713
+ o = f;
3138
3714
  }
3139
3715
  })
3140
3716
  );
3141
3717
  };
3142
3718
  return l(!1), {
3143
3719
  open() {
3144
- i = !0, l(!0);
3720
+ o = !0, l(!0);
3145
3721
  },
3146
3722
  close() {
3147
- i = !1, l(!1);
3723
+ o = !1, l(!1);
3148
3724
  },
3149
3725
  destroy() {
3150
- o && (o.unmount(), o = null), r.remove();
3726
+ i && (i.unmount(), i = null), n.remove();
3151
3727
  }
3152
3728
  };
3153
3729
  }
3154
3730
  export {
3155
- Re as ActionBar,
3156
- G as ChatProvider,
3157
- Ke as ChatWidget,
3158
- se as Composer,
3159
- Ne as ErrorPart,
3160
- Ye as FullpageLayout,
3161
- ue as Header,
3162
- C as Icon,
3163
- $e as InterruptCard,
3164
- He as Message,
3165
- ve as TextPart,
3166
- we as ThinkingPart,
3167
- re as Thread,
3168
- he as ThreadList,
3169
- ye as ToolCallPart,
3170
- Ce as ToolResultPart,
3171
- fe as Trigger,
3172
- je as WelcomeScreen,
3173
- Ve as defaultTheme,
3174
- Ze as mount,
3175
- qe as themeToCSSVars,
3176
- ge as useAutoScroll,
3177
- ce as useChat,
3178
- F as useChatContext,
3179
- pe as useConversations,
3180
- Ue as widgetStyles
3731
+ Ye as ActionBar,
3732
+ ae as ChatProvider,
3733
+ tt as ChatWidget,
3734
+ pe as Composer,
3735
+ Le as ErrorPart,
3736
+ et as FullpageLayout,
3737
+ ke as Header,
3738
+ z as Icon,
3739
+ We as InterruptCard,
3740
+ qe as Message,
3741
+ Te as TextPart,
3742
+ Me as ThinkingPart,
3743
+ de as Thread,
3744
+ Ce as ThreadList,
3745
+ De as ToolCallPart,
3746
+ Ee as ToolResultPart,
3747
+ ye as Trigger,
3748
+ Ve as WelcomeScreen,
3749
+ rt as defaultTheme,
3750
+ we as ensureIconFont,
3751
+ dt as mount,
3752
+ it as themeToCSSVars,
3753
+ ze as useAutoScroll,
3754
+ ge as useChat,
3755
+ U as useChatContext,
3756
+ be as useConversations,
3757
+ at as widgetStyles
3181
3758
  };