super-agent-sdk 1.0.5 → 1.0.6

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,146 +1,146 @@
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";
1
+ import Y, { useState as T, useRef as F, useCallback as I, useEffect as R, createContext as ie, useMemo as V, useContext as oe } from "react";
2
2
  import { createRoot as le } from "react-dom/client";
3
3
  import { jsx as e, jsxs as d, Fragment as q } from "react/jsx-runtime";
4
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);
5
+ const { sdk: t, sessionId: r, onSessionCreated: s, onStreamStart: n, onStreamEnd: o, onError: i, onMessageSend: l } = a, [c, p] = T([]), [f, u] = T("ready"), [h, w] = T(null), k = F(null), b = F(!1), v = F(r);
6
+ v.current = r;
7
+ const m = I((L) => {
8
+ if (b.current) return;
9
+ b.current = !0, l == null || l(L);
10
10
  const O = {
11
11
  id: `user_${Date.now()}`,
12
12
  role: "user",
13
- parts: [{ type: "text", content: M }],
13
+ parts: [{ type: "text", content: L }],
14
14
  timestamp: Date.now()
15
- }, y = `assistant_${Date.now()}`, L = {
15
+ }, y = `assistant_${Date.now()}`, D = {
16
16
  id: y,
17
17
  role: "assistant",
18
18
  parts: [],
19
19
  timestamp: Date.now()
20
20
  };
21
- p((S) => [...S, O, L]), u("submitted"), v(null);
22
- const $ = (S) => {
21
+ p((M) => [...M, O, D]), u("submitted"), w(null);
22
+ const P = (M) => {
23
23
  let E = "", A = "", H = [], z = !1;
24
- const P = () => {
25
- const w = [...H];
24
+ const $ = () => {
25
+ const x = [...H];
26
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 });
27
+ const _ = x.findIndex((B) => B.type === "thinking");
28
+ _ >= 0 ? x[_] = { type: "thinking", content: E } : x.unshift({ type: "thinking", content: E });
29
29
  }
30
30
  if (A) {
31
- const W = w.findLastIndex((R) => R.type === "text");
32
- W >= 0 ? w[W] = { type: "text", content: A } : w.push({ type: "text", content: A });
31
+ const _ = x.findLastIndex((B) => B.type === "text");
32
+ _ >= 0 ? x[_] = { type: "text", content: A } : x.push({ type: "text", content: A });
33
33
  }
34
34
  p(
35
- (W) => W.map((R) => R.id === y ? { ...R, parts: w } : R)
35
+ (_) => _.map((B) => B.id === y ? { ...B, parts: x } : B)
36
36
  );
37
37
  };
38
38
  k.current = t.chat({
39
- sessionId: S,
40
- message: M,
39
+ sessionId: M,
40
+ message: L,
41
41
  stream: !0,
42
- onMessage: (w) => {
43
- switch (z || (z = !0, u("streaming")), w.type) {
42
+ onMessage: (x) => {
43
+ switch (z || (z = !0, u("streaming")), x.type) {
44
44
  case "thinking":
45
- E += w.content;
45
+ E += x.content;
46
46
  break;
47
47
  case "ai":
48
- A += w.content;
48
+ A += x.content;
49
49
  break;
50
50
  case "tool_call":
51
51
  H.push({
52
52
  type: "tool_call",
53
- toolName: w.toolName,
54
- toolCallId: w.toolCallId,
55
- args: w.args ?? "{}"
53
+ toolName: x.toolName,
54
+ toolCallId: x.toolCallId,
55
+ args: x.args ?? "{}"
56
56
  });
57
57
  break;
58
58
  case "tool_result":
59
59
  H.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
61
+ toolName: x.toolName ?? "",
62
+ toolCallId: x.toolCallId,
63
+ content: x.content,
64
+ artifacts: x.artifacts,
65
+ renderMode: x.renderMode,
66
+ html: x.html
67
67
  }), A && (H.push({ type: "text", content: A }), A = "");
68
68
  break;
69
69
  case "interrupt":
70
- w.interrupt && H.push({
70
+ x.interrupt && H.push({
71
71
  type: "interrupt",
72
- interrupt: w.interrupt,
72
+ interrupt: x.interrupt,
73
73
  resolved: !1
74
74
  });
75
75
  break;
76
76
  }
77
- P();
77
+ $();
78
78
  },
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;
79
+ onDone: (x) => {
80
+ (A || H.length > 0 || E) && $(), x.messageId && p(
81
+ (_) => _.map((B) => B.id === y ? { ...B, id: x.messageId } : B)
82
+ ), x.sessionId && x.sessionId !== v.current && (s == null || s(x.sessionId)), o == null || o(x.sessionId || M), u("ready"), b.current = !1, k.current = null;
83
83
  },
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;
84
+ onError: (x) => {
85
+ H.push({ type: "error", content: x.message }), $(), w(x), u("error"), i == null || i(x), b.current = !1, k.current = null;
86
86
  }
87
- }), n == null || n(S);
87
+ }), n == null || n(M);
88
88
  };
89
- b.current ? $(b.current) : t.createSession().then((S) => {
90
- b.current = S, r == null || r(S), $(S);
91
- }).catch((S) => {
92
- v(S instanceof Error ? S : new Error(String(S))), u("error"), i == null || i(S instanceof Error ? S : new Error(String(S))), g.current = !1;
89
+ v.current ? P(v.current) : t.createSession().then((M) => {
90
+ v.current = M, s == null || s(M), P(M);
91
+ }).catch((M) => {
92
+ w(M instanceof Error ? M : new Error(String(M))), u("error"), i == null || i(M instanceof Error ? M : new Error(String(M))), b.current = !1;
93
93
  });
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) => {
94
+ }, [t, s, n, o, i, l]), g = I(() => {
95
+ var L;
96
+ (L = k.current) == null || L.abort(), k.current = null, u("ready"), b.current = !1;
97
+ }, []), N = I(() => {
98
+ if (b.current) return;
99
+ const L = c.findLastIndex((y) => y.role === "user");
100
+ if (L < 0) return;
101
+ const O = c[L].parts.filter((y) => y.type === "text").map((y) => y.content).join("");
102
+ p((y) => y.slice(0, L)), m(O);
103
+ }, [c, m]), S = I((L, O) => {
104
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
105
+ (z) => z.map(($) => ({
106
+ ...$,
107
+ parts: $.parts.map(
108
+ (x) => x.type === "interrupt" && x.interrupt.interruptId === L ? { ...x, resolved: !0, response: O } : x
109
109
  )
110
110
  }))
111
111
  );
112
- const y = b.current;
112
+ const y = v.current;
113
113
  if (!y) return;
114
- const L = `assistant_${Date.now()}`, $ = {
115
- id: L,
114
+ const D = `assistant_${Date.now()}`, P = {
115
+ id: D,
116
116
  role: "assistant",
117
117
  parts: [],
118
118
  timestamp: Date.now()
119
119
  };
120
- p((z) => [...z, $]), u("streaming");
121
- let S = "", E = "", A = [];
120
+ p((z) => [...z, P]), u("streaming");
121
+ let M = "", E = "", A = [];
122
122
  const H = () => {
123
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 });
124
+ if (M) {
125
+ const $ = z.findIndex((x) => x.type === "thinking");
126
+ $ >= 0 ? z[$] = { type: "thinking", content: M } : z.unshift({ type: "thinking", content: M });
127
127
  }
128
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 });
129
+ const $ = z.findLastIndex((x) => x.type === "text");
130
+ $ >= 0 ? z[$] = { type: "text", content: E } : z.push({ type: "text", content: E });
131
131
  }
132
132
  p(
133
- (P) => P.map((w) => w.id === L ? { ...w, parts: z } : w)
133
+ ($) => $.map((x) => x.id === D ? { ...x, parts: z } : x)
134
134
  );
135
135
  };
136
136
  t.respondInterrupt(
137
- M,
137
+ L,
138
138
  y,
139
139
  O,
140
140
  (z) => {
141
141
  switch (z.type) {
142
142
  case "thinking":
143
- S += z.content;
143
+ M += z.content;
144
144
  break;
145
145
  case "ai":
146
146
  E += z.content;
@@ -168,19 +168,21 @@ function ce(a) {
168
168
  z.interrupt && A.push({ type: "interrupt", interrupt: z.interrupt, resolved: !1 });
169
169
  break;
170
170
  case "done":
171
- u("ready");
171
+ z.messageId && p(
172
+ ($) => $.map((x) => x.id === D ? { ...x, id: z.messageId } : x)
173
+ ), u("ready");
172
174
  break;
173
175
  }
174
176
  H();
175
177
  },
176
178
  (z) => {
177
- A.push({ type: "error", content: z.message }), H(), v(z), u("error"), i == null || i(z);
179
+ A.push({ type: "error", content: z.message }), H(), w(z), u("error"), i == null || i(z);
178
180
  }
179
181
  ).catch((z) => {
180
182
  i == null || i(z instanceof Error ? z : new Error(String(z))), u("error");
181
183
  });
182
184
  }, [t, i]);
183
- return { messages: c, status: f, error: h, sendMessage: m, stop: x, regenerate: I, setMessages: p, respondToInterrupt: D };
185
+ return { messages: c, status: f, error: h, sendMessage: m, stop: g, regenerate: N, setMessages: p, respondToInterrupt: S };
184
186
  }
185
187
  const X = "sa_active_conversation";
186
188
  function J() {
@@ -197,46 +199,46 @@ function de(a) {
197
199
  }
198
200
  }
199
201
  function pe(a) {
200
- const { sdk: t, onConversationChange: s } = a, [r, n] = T([]), [o, i] = T(
202
+ const { sdk: t, onConversationChange: r } = a, [s, n] = T([]), [o, i] = T(
201
203
  () => J()
202
- ), [l, c] = T(!1), p = _(!0);
203
- B(() => () => {
204
+ ), [l, c] = T(!1), p = F(!0);
205
+ R(() => () => {
204
206
  p.current = !1;
205
207
  }, []);
206
- const f = N((m) => {
207
- i(m), de(m), m && (s == null || s(m));
208
- }, [s]), u = N(async () => {
208
+ const f = I((m) => {
209
+ i(m), de(m), m && (r == null || r(m));
210
+ }, [r]), u = I(async () => {
209
211
  c(!0);
210
212
  try {
211
213
  const m = await t.listConversations({ page: 1, size: 100 });
212
214
  if (!p.current) return;
213
215
  n(m.items);
214
- const x = J();
215
- x && !m.items.find((I) => I.sessionId === x) && f(null);
216
+ const g = J();
217
+ g && !m.items.find((N) => N.sessionId === g) && f(null);
216
218
  } catch {
217
219
  } finally {
218
220
  p.current && c(!1);
219
221
  }
220
- }, [t, f]), h = N(async (m) => (f(m), await t.getMessages(m)), [t, f]), v = N(() => {
222
+ }, [t, f]), h = I(async (m) => (f(m), await t.getMessages(m)), [t, f]), w = I(() => {
221
223
  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)
224
+ }, [f]), k = I(async (m) => {
225
+ await t.deleteConversation(m), n((g) => g.filter((N) => N.sessionId !== m)), o === m && f(null);
226
+ }, [t, o, f]), b = I(async (m, g) => {
227
+ await t.renameConversation(m, g), n(
228
+ (N) => N.map((S) => S.sessionId === m ? { ...S, title: g } : S)
227
229
  );
228
- }, [t]), { enabled: b = !0 } = a;
229
- return B(() => {
230
- b && u();
231
- }, [b, u]), {
232
- conversations: r,
230
+ }, [t]), { enabled: v = !0 } = a;
231
+ return R(() => {
232
+ v && u();
233
+ }, [v, u]), {
234
+ conversations: s,
233
235
  activeConversationId: o,
234
236
  loading: l,
235
237
  loadConversations: u,
236
238
  switchConversation: h,
237
- newConversation: v,
239
+ newConversation: w,
238
240
  deleteConversation: k,
239
- renameConversation: g,
241
+ renameConversation: b,
240
242
  setActiveConversationId: f
241
243
  };
242
244
  }
@@ -249,15 +251,15 @@ function ee(a) {
249
251
  function ae(a) {
250
252
  if (!a) return [];
251
253
  const t = [];
252
- for (const s of a)
253
- s.type === "file" && s.data && t.push({
254
- id: s.data.id ?? "",
255
- type: s.data.fileType ?? s.data.type ?? "",
256
- filename: s.data.name ?? s.data.filename ?? "",
257
- url: s.data.url ?? "",
258
- mime: s.data.mime,
259
- size: s.data.size,
260
- summary: s.data.summary
254
+ for (const r of a)
255
+ r.type === "file" && r.data && t.push({
256
+ id: r.data.id ?? "",
257
+ type: r.data.fileType ?? r.data.type ?? "",
258
+ filename: r.data.name ?? r.data.filename ?? "",
259
+ url: r.data.url ?? "",
260
+ mime: r.data.mime,
261
+ size: r.data.size,
262
+ summary: r.data.summary
261
263
  });
262
264
  return t;
263
265
  }
@@ -265,22 +267,22 @@ async function U(a) {
265
267
  try {
266
268
  const t = await fetch(a.url);
267
269
  if (!t.ok) throw new Error(`HTTP ${t.status}`);
268
- const s = await t.blob(), r = URL.createObjectURL(s), n = document.createElement("a");
269
- n.href = r, n.download = a.filename, document.body.appendChild(n), n.click(), n.remove(), setTimeout(() => URL.revokeObjectURL(r), 4e3);
270
+ const r = await t.blob(), s = URL.createObjectURL(r), n = document.createElement("a");
271
+ n.href = s, n.download = a.filename, document.body.appendChild(n), n.click(), n.remove(), setTimeout(() => URL.revokeObjectURL(s), 4e3);
270
272
  } catch {
271
273
  const t = document.createElement("a");
272
274
  t.href = a.url, t.download = a.filename, t.target = "_blank", document.body.appendChild(t), t.click(), t.remove();
273
275
  }
274
276
  }
275
277
  const te = ie(null);
276
- function F() {
278
+ function W() {
277
279
  const a = oe(te);
278
280
  if (!a) throw new Error("useChatContext must be used within ChatProvider");
279
281
  return a;
280
282
  }
281
- function G({ sdk: a, hooks: t, children: s }) {
282
- const [r, n] = T(!1), [o, i] = T(!1), [l, c] = T(null), [p, f] = T(!1);
283
- B(() => {
283
+ function G({ sdk: a, hooks: t, children: r }) {
284
+ const [s, n] = T(!1), [o, i] = T(!1), [l, c] = T(null), [p, f] = T(!1);
285
+ R(() => {
284
286
  a.getToken().then(() => {
285
287
  f(!0);
286
288
  }).catch(() => {
@@ -299,45 +301,45 @@ function G({ sdk: a, hooks: t, children: s }) {
299
301
  },
300
302
  onStreamStart: t == null ? void 0 : t.onStreamStart,
301
303
  onStreamEnd: (y) => {
302
- var L;
303
- (L = t == null ? void 0 : t.onStreamEnd) == null || L.call(t, y), u.loadConversations();
304
+ var D;
305
+ (D = t == null ? void 0 : t.onStreamEnd) == null || D.call(t, y), u.loadConversations();
304
306
  },
305
307
  onError: t == null ? void 0 : t.onError,
306
308
  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(() => {
309
+ }), w = I(async (y) => {
310
+ const D = await u.switchConversation(y);
311
+ h.setMessages(D), n(!1);
312
+ }, [u, h]), k = I(() => {
311
313
  u.newConversation(), h.setMessages([]), n(!1);
312
- }, [u, h]), g = N(async (y) => {
314
+ }, [u, h]), b = I(async (y) => {
313
315
  await u.deleteConversation(y), u.activeConversationId === y && h.setMessages([]);
314
316
  }, [u, h]);
315
- B(() => {
317
+ R(() => {
316
318
  u.activeConversationId && h.messages.length === 0 && a.getMessages(u.activeConversationId).then((y) => {
317
319
  h.setMessages(y);
318
320
  }).catch(() => {
319
321
  });
320
322
  }, []);
321
- const b = N(() => {
323
+ const v = I(() => {
322
324
  n((y) => !y);
323
- }, []), m = N(() => {
325
+ }, []), m = I(() => {
324
326
  i((y) => !y), c((y) => null);
325
- }, []), x = N((y) => {
327
+ }, []), g = I((y) => {
326
328
  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)) {
329
+ }, []), N = V(() => {
330
+ const y = /* @__PURE__ */ new Set(), D = [];
331
+ for (const P of h.messages)
332
+ for (const M of P.parts)
333
+ if (M.type === "tool_result" && M.artifacts)
334
+ for (const E of ae(M.artifacts)) {
333
335
  const A = E.id || `${E.url}:${E.filename}`;
334
- y.has(A) || (y.add(A), L.push(E));
336
+ y.has(A) || (y.add(A), D.push(E));
335
337
  }
336
- return L;
337
- }, [h.messages]), D = N((y, L, $) => {
338
- a.feedback(y, L, $).catch(() => {
338
+ return D;
339
+ }, [h.messages]), S = I((y, D, P) => {
340
+ a.feedback(y, D, P).catch(() => {
339
341
  });
340
- }, [a]), M = N((y) => {
342
+ }, [a]), L = I((y) => {
341
343
  a.cancelFeedback(y).catch(() => {
342
344
  });
343
345
  }, [a]), O = V(() => ({
@@ -346,22 +348,22 @@ function G({ sdk: a, hooks: t, children: s }) {
346
348
  messages: h.messages,
347
349
  conversations: u.conversations,
348
350
  activeConversationId: u.activeConversationId,
349
- isThreadListOpen: r,
351
+ isThreadListOpen: s,
350
352
  isArtifactDrawerOpen: o,
351
- allArtifacts: I,
353
+ allArtifacts: N,
352
354
  activePreviewArtifact: l,
353
355
  sendMessage: h.sendMessage,
354
356
  stop: h.stop,
355
357
  regenerate: h.regenerate,
356
- switchConversation: v,
358
+ switchConversation: w,
357
359
  newConversation: k,
358
- deleteConversation: g,
360
+ deleteConversation: b,
359
361
  renameConversation: u.renameConversation,
360
- toggleThreadList: b,
362
+ toggleThreadList: v,
361
363
  toggleArtifactDrawer: m,
362
- openArtifactPreview: x,
363
- feedback: D,
364
- cancelFeedback: M,
364
+ openArtifactPreview: g,
365
+ feedback: S,
366
+ cancelFeedback: L,
365
367
  respondToInterrupt: h.respondToInterrupt
366
368
  }), [
367
369
  h.status,
@@ -374,27 +376,27 @@ function G({ sdk: a, hooks: t, children: s }) {
374
376
  u.conversations,
375
377
  u.activeConversationId,
376
378
  u.renameConversation,
377
- r,
379
+ s,
378
380
  o,
379
- I,
381
+ N,
380
382
  l,
381
- v,
383
+ w,
382
384
  k,
383
- g,
384
385
  b,
386
+ v,
385
387
  m,
386
- x,
387
- D,
388
- M
388
+ g,
389
+ S,
390
+ L
389
391
  ]);
390
- return /* @__PURE__ */ e(te.Provider, { value: O, children: s });
392
+ return /* @__PURE__ */ e(te.Provider, { value: O, children: r });
391
393
  }
392
- function C({ name: a, size: t = 16, color: s = "currentColor", className: r, style: n }) {
394
+ function C({ name: a, size: t = 16, color: r = "currentColor", className: s, style: n }) {
393
395
  return /* @__PURE__ */ e(
394
396
  "svg",
395
397
  {
396
- className: r,
397
- style: { width: t, height: t, fill: s, verticalAlign: "middle", ...n },
398
+ className: s,
399
+ style: { width: t, height: t, fill: r, verticalAlign: "middle", ...n },
398
400
  "aria-hidden": "true",
399
401
  children: /* @__PURE__ */ e("use", { href: `#icon-${a}` })
400
402
  }
@@ -403,7 +405,7 @@ function C({ name: a, size: t = 16, color: s = "currentColor", className: r, sty
403
405
  function fe({ isOpen: a, onClick: t }) {
404
406
  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" }) });
405
407
  }
406
- function ue({ title: a, onClose: t, onToggleThreadList: s, showClose: r = !0, artifactCount: n = 0, onToggleArtifactDrawer: o }) {
408
+ function ue({ title: a, onClose: t, onToggleThreadList: r, showClose: s = !0, artifactCount: n = 0, onToggleArtifactDrawer: o }) {
407
409
  return /* @__PURE__ */ d("div", { className: "sa-header", children: [
408
410
  /* @__PURE__ */ d("div", { className: "sa-header-left", children: [
409
411
  /* @__PURE__ */ e("div", { className: "sa-header-avatar", children: "A" }),
@@ -420,16 +422,16 @@ function ue({ title: a, onClose: t, onToggleThreadList: s, showClose: r = !0, ar
420
422
  ] }),
421
423
  /* @__PURE__ */ e("span", { children: "产物" })
422
424
  ] }),
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 }) })
425
+ /* @__PURE__ */ e("button", { className: "sa-header-btn", onClick: r, title: "会话列表", children: /* @__PURE__ */ e(C, { name: "menu", size: 16 }) }),
426
+ s && /* @__PURE__ */ e("button", { className: "sa-header-btn", onClick: t, title: "关闭", children: /* @__PURE__ */ e(C, { name: "x", size: 16 }) })
425
427
  ] })
426
428
  ] });
427
429
  }
428
430
  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 = [];
431
+ const t = /* @__PURE__ */ new Date(), r = new Date(t.getFullYear(), t.getMonth(), t.getDate()).getTime(), s = r - 6 * 864e5, n = [], o = [], i = [];
430
432
  for (const c of a) {
431
433
  const p = new Date(c.updateTime).getTime();
432
- p >= s ? n.push(c) : p >= r ? o.push(c) : i.push(c);
434
+ p >= r ? n.push(c) : p >= s ? o.push(c) : i.push(c);
433
435
  }
434
436
  const l = [];
435
437
  return n.length && l.push({ label: "今天", items: n }), o.length && l.push({ label: "最近 7 天", items: o }), i.length && l.push({ label: "更早", items: i }), l;
@@ -438,46 +440,46 @@ function he() {
438
440
  const {
439
441
  conversations: a,
440
442
  activeConversationId: t,
441
- switchConversation: s,
442
- newConversation: r,
443
+ switchConversation: r,
444
+ newConversation: s,
443
445
  deleteConversation: n,
444
446
  renameConversation: o,
445
447
  isThreadListOpen: i,
446
448
  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);
449
+ } = W(), [c, p] = T(null), [f, u] = T(""), h = I((b, v) => {
450
+ p(b), u(v ?? "");
451
+ }, []), w = I((b) => {
452
+ f.trim() && o(b, f.trim()), p(null);
451
453
  }, [f, o]), k = V(() => me(a), [a]);
452
454
  return i ? /* @__PURE__ */ d(q, { children: [
453
455
  /* @__PURE__ */ e("div", { className: "sa-thread-list-overlay", onClick: l }),
454
456
  /* @__PURE__ */ d("div", { className: "sa-thread-list", children: [
455
457
  /* @__PURE__ */ d("div", { className: "sa-thread-list-header", children: [
456
458
  /* @__PURE__ */ e("span", { className: "sa-thread-list-title", children: "会话记录" }),
457
- /* @__PURE__ */ d("button", { className: "sa-thread-list-new", onClick: r, children: [
459
+ /* @__PURE__ */ d("button", { className: "sa-thread-list-new", onClick: s, children: [
458
460
  /* @__PURE__ */ e(C, { name: "plus", size: 14 }),
459
461
  " 新会话"
460
462
  ] })
461
463
  ] }),
462
464
  /* @__PURE__ */ d("div", { className: "sa-thread-list-items", children: [
463
465
  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(
466
+ k.map((b) => /* @__PURE__ */ d("div", { className: "sa-thread-group", children: [
467
+ /* @__PURE__ */ e("div", { className: "sa-thread-group-label", children: b.label }),
468
+ b.items.map((v) => /* @__PURE__ */ d(
467
469
  "div",
468
470
  {
469
- className: `sa-thread-item ${b.sessionId === t ? "active" : ""}`,
470
- onClick: () => s(b.sessionId),
471
+ className: `sa-thread-item ${v.sessionId === t ? "active" : ""}`,
472
+ onClick: () => r(v.sessionId),
471
473
  children: [
472
- c === b.sessionId ? /* @__PURE__ */ e(
474
+ c === v.sessionId ? /* @__PURE__ */ e(
473
475
  "input",
474
476
  {
475
477
  className: "sa-thread-item-edit",
476
478
  value: f,
477
479
  onChange: (m) => u(m.target.value),
478
- onBlur: () => v(b.sessionId),
480
+ onBlur: () => w(v.sessionId),
479
481
  onKeyDown: (m) => {
480
- m.key === "Enter" && v(b.sessionId), m.key === "Escape" && p(null);
482
+ m.key === "Enter" && w(v.sessionId), m.key === "Escape" && p(null);
481
483
  },
482
484
  onClick: (m) => m.stopPropagation(),
483
485
  autoFocus: !0
@@ -487,9 +489,9 @@ function he() {
487
489
  {
488
490
  className: "sa-thread-item-title",
489
491
  onDoubleClick: (m) => {
490
- m.stopPropagation(), h(b.sessionId, b.title);
492
+ m.stopPropagation(), h(v.sessionId, v.title);
491
493
  },
492
- children: b.title || "新会话"
494
+ children: v.title || "新会话"
493
495
  }
494
496
  ),
495
497
  /* @__PURE__ */ e(
@@ -497,7 +499,7 @@ function he() {
497
499
  {
498
500
  className: "sa-thread-item-delete",
499
501
  onClick: (m) => {
500
- m.stopPropagation(), n(b.sessionId);
502
+ m.stopPropagation(), n(v.sessionId);
501
503
  },
502
504
  title: "删除",
503
505
  children: /* @__PURE__ */ e(C, { name: "trash2", size: 14 })
@@ -505,33 +507,33 @@ function he() {
505
507
  )
506
508
  ]
507
509
  },
508
- b.sessionId
510
+ v.sessionId
509
511
  ))
510
- ] }, g.label))
512
+ ] }, b.label))
511
513
  ] })
512
514
  ] })
513
515
  ] }) : null;
514
516
  }
515
517
  function ge(a) {
516
- const t = _(null), s = _(!1), r = _(0), n = N(() => {
518
+ const t = F(null), r = F(!1), s = F(0), n = I(() => {
517
519
  const i = t.current;
518
520
  if (!i) return;
519
521
  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;
522
+ l < s.current && !f && (r.current = !0), f && (r.current = !1), s.current = l;
521
523
  }, []);
522
- B(() => {
524
+ R(() => {
523
525
  const i = t.current;
524
526
  if (i)
525
527
  return i.addEventListener("scroll", n, { passive: !0 }), () => i.removeEventListener("scroll", n);
526
- }, [n]), B(() => {
527
- if (s.current) return;
528
+ }, [n]), R(() => {
529
+ if (r.current) return;
528
530
  const i = t.current;
529
531
  i && requestAnimationFrame(() => {
530
532
  i.scrollTop = i.scrollHeight;
531
533
  });
532
534
  }, a);
533
- const o = N(() => {
534
- s.current = !1;
535
+ const o = I(() => {
536
+ r.current = !1;
535
537
  const i = t.current;
536
538
  i && (i.scrollTop = i.scrollHeight);
537
539
  }, []);
@@ -541,8 +543,8 @@ function j(a) {
541
543
  return a.value++;
542
544
  }
543
545
  function K(a, t) {
544
- const s = [], r = [], n = () => {
545
- r.length > 0 && (s.push(r.join("")), r.length = 0);
546
+ const r = [], s = [], n = () => {
547
+ s.length > 0 && (r.push(s.join("")), s.length = 0);
546
548
  };
547
549
  let o = 0;
548
550
  for (; o < a.length; ) {
@@ -550,7 +552,7 @@ function K(a, t) {
550
552
  if (i === "`") {
551
553
  const l = a.indexOf("`", o + 1);
552
554
  if (l !== -1) {
553
- n(), s.push(
555
+ n(), r.push(
554
556
  /* @__PURE__ */ e("code", { className: "sa-inline-code", children: a.slice(o + 1, l) }, j(t))
555
557
  ), o = l + 1;
556
558
  continue;
@@ -558,7 +560,7 @@ function K(a, t) {
558
560
  } else if (i === "*" && a[o + 1] === "*") {
559
561
  const l = a.indexOf("**", o + 2);
560
562
  if (l !== -1) {
561
- n(), s.push(
563
+ n(), r.push(
562
564
  /* @__PURE__ */ e("strong", { children: K(a.slice(o + 2, l), t) }, j(t))
563
565
  ), o = l + 2;
564
566
  continue;
@@ -566,7 +568,7 @@ function K(a, t) {
566
568
  } else if (i === "*") {
567
569
  const l = a.indexOf("*", o + 1);
568
570
  if (l !== -1) {
569
- n(), s.push(
571
+ n(), r.push(
570
572
  /* @__PURE__ */ e("em", { children: K(a.slice(o + 1, l), t) }, j(t))
571
573
  ), o = l + 1;
572
574
  continue;
@@ -577,7 +579,7 @@ function K(a, t) {
577
579
  const c = a.indexOf(")", l + 2);
578
580
  if (c !== -1) {
579
581
  const p = a.slice(o + 1, l), f = a.slice(l + 2, c);
580
- n(), s.push(
582
+ n(), r.push(
581
583
  /* @__PURE__ */ e(
582
584
  "a",
583
585
  {
@@ -593,17 +595,17 @@ function K(a, t) {
593
595
  }
594
596
  }
595
597
  }
596
- r.push(i), o++;
598
+ s.push(i), o++;
597
599
  }
598
- return n(), s;
600
+ return n(), r;
599
601
  }
600
- function xe(a, t) {
601
- const s = [], r = a.split(`
602
+ function be(a, t) {
603
+ const r = [], s = a.split(`
602
604
  `);
603
605
  let n = 0;
604
606
  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
+ for (; n < s.length; ) {
608
+ const c = s[n], p = c.trim();
607
609
  if (o(c)) {
608
610
  n++;
609
611
  continue;
@@ -611,10 +613,10 @@ function xe(a, t) {
611
613
  if (i(c)) {
612
614
  const u = p.match(/^(#{1,6})\s+(.*)$/);
613
615
  if (u) {
614
- const v = `h${Math.min(u[1].length, 6)}`;
615
- s.push(
616
+ const w = `h${Math.min(u[1].length, 6)}`;
617
+ r.push(
616
618
  Y.createElement(
617
- v,
619
+ w,
618
620
  { key: j(t) },
619
621
  K(u[2], t)
620
622
  )
@@ -625,45 +627,45 @@ function xe(a, t) {
625
627
  }
626
628
  if (l(c)) {
627
629
  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))
630
+ for (; n < s.length && l(s[n]); ) {
631
+ const w = s[n].trim().match(/^(?:[-*+]|\d+[.)])\s+(.*)$/);
632
+ w && h.push(
633
+ /* @__PURE__ */ e("li", { children: K(w[1], t) }, j(t))
632
634
  ), n++;
633
635
  }
634
- s.push(
636
+ r.push(
635
637
  u ? /* @__PURE__ */ e("ol", { className: "sa-list", children: h }, j(t)) : /* @__PURE__ */ e("ul", { className: "sa-list", children: h }, j(t))
636
638
  );
637
639
  continue;
638
640
  }
639
641
  const f = [];
640
- for (; n < r.length && !o(r[n]) && !i(r[n]) && !l(r[n]); )
641
- f.push(r[n]), n++;
642
- s.push(
642
+ for (; n < s.length && !o(s[n]) && !i(s[n]) && !l(s[n]); )
643
+ f.push(s[n]), n++;
644
+ r.push(
643
645
  /* @__PURE__ */ e("p", { className: "sa-text-paragraph", children: K(f.join(" "), t) }, j(t))
644
646
  );
645
647
  }
646
- return s;
648
+ return r;
647
649
  }
648
- function be(a) {
649
- const t = { value: 0 }, s = [], r = a.split("```");
650
- for (let n = 0; n < r.length; n++)
650
+ function xe(a) {
651
+ const t = { value: 0 }, r = [], s = a.split("```");
652
+ for (let n = 0; n < s.length; n++)
651
653
  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(
654
+ r.push(...be(s[n], t));
655
+ else if (s[n].trim() !== "") {
656
+ let o = s[n].replace(/^\r?\n/, "");
657
+ o = o.replace(/^[a-zA-Z0-9_+#.-]+\r?\n/, ""), o = o.replace(/\r?\n$/, ""), r.push(
656
658
  /* @__PURE__ */ e("pre", { className: "sa-code-block", children: /* @__PURE__ */ e("code", { children: o }) }, j(t))
657
659
  );
658
660
  }
659
- return s;
661
+ return r;
660
662
  }
661
663
  function ve({ content: a }) {
662
- return /* @__PURE__ */ e("div", { className: "sa-text-part", children: be(a) });
664
+ return /* @__PURE__ */ e("div", { className: "sa-text-part", children: xe(a) });
663
665
  }
664
666
  function we({ content: a }) {
665
- const [t, s] = T(!1);
666
- return /* @__PURE__ */ d("div", { className: "sa-thinking-part", onClick: () => s(!t), children: [
667
+ const [t, r] = T(!1);
668
+ return /* @__PURE__ */ d("div", { className: "sa-thinking-part", onClick: () => r(!t), children: [
667
669
  /* @__PURE__ */ d("div", { className: "sa-thinking-header", children: [
668
670
  /* @__PURE__ */ e("span", { className: "sa-thinking-icon", children: /* @__PURE__ */ e(C, { name: "brain", size: 14 }) }),
669
671
  /* @__PURE__ */ e("span", { className: "sa-thinking-label", children: "思考过程" }),
@@ -672,44 +674,44 @@ function we({ content: a }) {
672
674
  t && /* @__PURE__ */ e("div", { className: "sa-thinking-content", children: a })
673
675
  ] });
674
676
  }
675
- function ye({ toolName: a, toolCallId: t, args: s }) {
676
- const [r, n] = T(!1);
677
- let o = s;
677
+ function ye({ toolName: a, toolCallId: t, args: r }) {
678
+ const [s, n] = T(!1);
679
+ let o = r;
678
680
  try {
679
- o = JSON.stringify(JSON.parse(s), null, 2);
681
+ o = JSON.stringify(JSON.parse(r), null, 2);
680
682
  } catch {
681
683
  }
682
684
  return /* @__PURE__ */ d("div", { className: "sa-tool-call-part", children: [
683
- /* @__PURE__ */ d("div", { className: "sa-tool-call-header", onClick: () => n(!r), children: [
685
+ /* @__PURE__ */ d("div", { className: "sa-tool-call-header", onClick: () => n(!s), children: [
684
686
  /* @__PURE__ */ e("span", { className: "sa-tool-icon", children: /* @__PURE__ */ e(C, { name: "zap", size: 14 }) }),
685
687
  /* @__PURE__ */ d("span", { className: "sa-tool-name", children: [
686
688
  "调用工具: ",
687
689
  a
688
690
  ] }),
689
- /* @__PURE__ */ e("span", { className: `sa-thinking-arrow ${r ? "expanded" : ""}`, children: /* @__PURE__ */ e(C, { name: "chevron-right", size: 12 }) })
691
+ /* @__PURE__ */ e("span", { className: `sa-thinking-arrow ${s ? "expanded" : ""}`, children: /* @__PURE__ */ e(C, { name: "chevron-right", size: 12 }) })
690
692
  ] }),
691
- r && /* @__PURE__ */ e("pre", { className: "sa-tool-args", children: o })
693
+ s && /* @__PURE__ */ e("pre", { className: "sa-tool-args", children: o })
692
694
  ] });
693
695
  }
694
696
  function ke({ html: a }) {
695
- const [t, s] = T(null);
696
- return B(() => {
697
- let r = !1;
697
+ const [t, r] = T(null);
698
+ return R(() => {
699
+ let s = !1;
698
700
  return import("./purify.es-C-6FFqDW.js").then((n) => {
699
- r || s(n.default.sanitize(a, { FORCE_BODY: !0 }));
701
+ s || r(n.default.sanitize(a, { FORCE_BODY: !0 }));
700
702
  }), () => {
701
- r = !0;
703
+ s = !0;
702
704
  };
703
705
  }, [a]), t === null ? null : /* @__PURE__ */ e("div", { className: "sa-tool-result-html", children: /* @__PURE__ */ e("iframe", { srcDoc: t, className: "sa-tool-result-html-iframe", sandbox: "", title: "HTML 产物" }) });
704
706
  }
705
- function Ce({ toolName: a, content: t, artifacts: s, renderMode: r, html: n, artifactPreview: o }) {
706
- const { openArtifactPreview: i } = F(), l = ae(s);
707
+ function Ce({ toolName: a, content: t, artifacts: r, renderMode: s, html: n, artifactPreview: o }) {
708
+ const { openArtifactPreview: i } = W(), l = ae(r);
707
709
  return /* @__PURE__ */ d("div", { className: "sa-tool-result-part", children: [
708
710
  /* @__PURE__ */ d("div", { className: "sa-tool-result-header", children: [
709
711
  /* @__PURE__ */ e("span", { className: "sa-tool-icon", children: /* @__PURE__ */ e(C, { name: "circle-check", size: 14, color: "#10b981" }) }),
710
712
  /* @__PURE__ */ e("span", { className: "sa-tool-result-label", children: a || "工具返回" })
711
713
  ] }),
712
- r === "html" && n ? /* @__PURE__ */ e(ke, { html: n }) : t ? /* @__PURE__ */ e("div", { className: "sa-tool-result-content", children: t }) : null,
714
+ s === "html" && n ? /* @__PURE__ */ e(ke, { html: n }) : t ? /* @__PURE__ */ e("div", { className: "sa-tool-result-content", children: t }) : null,
713
715
  l.length > 0 && /* @__PURE__ */ e("ul", { className: "sa-artifact-file-list", role: "list", children: l.map((c, p) => /* @__PURE__ */ d(
714
716
  "li",
715
717
  {
@@ -757,7 +759,7 @@ function Ne({ content: a, onRetry: t }) {
757
759
  }
758
760
  function ze({ interrupt: a, onRespond: t }) {
759
761
  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) || "取消";
762
+ const r = a.options, s = (typeof (r == null ? void 0 : r[0]) == "string" ? r[0] : (o = r == null ? void 0 : r[0]) == null ? void 0 : o.label) || "确认", n = (typeof (r == null ? void 0 : r[1]) == "string" ? r[1] : (i = r == null ? void 0 : r[1]) == null ? void 0 : i.label) || "取消";
761
763
  return /* @__PURE__ */ d("div", { className: "sa-interrupt-card", children: [
762
764
  /* @__PURE__ */ d("div", { className: "sa-interrupt-content", children: [
763
765
  /* @__PURE__ */ e(C, { name: "circle-alert", size: 16, color: "#f59e0b" }),
@@ -767,7 +769,7 @@ function ze({ interrupt: a, onRespond: t }) {
767
769
  /* @__PURE__ */ d("button", { className: "sa-interrupt-btn sa-interrupt-btn-primary", onClick: () => t({ action: "confirm" }), children: [
768
770
  /* @__PURE__ */ e(C, { name: "check", size: 14 }),
769
771
  " ",
770
- r
772
+ s
771
773
  ] }),
772
774
  /* @__PURE__ */ d("button", { className: "sa-interrupt-btn sa-interrupt-btn-secondary", onClick: () => t({ action: "cancel" }), children: [
773
775
  /* @__PURE__ */ e(C, { name: "x", size: 14 }),
@@ -779,7 +781,7 @@ function ze({ interrupt: a, onRespond: t }) {
779
781
  }
780
782
  function Ie({ interrupt: a, onRespond: t }) {
781
783
  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;
784
+ const r = a.options, s = (typeof (r == null ? void 0 : r[0]) == "string" ? r[0] : (l = r == null ? void 0 : r[0]) == null ? void 0 : l.label) || "批准", n = (typeof (r == null ? void 0 : r[1]) == "string" ? r[1] : (c = r == null ? void 0 : r[1]) == null ? void 0 : c.label) || "拒绝", o = (typeof (r == null ? void 0 : r[2]) == "string" ? r[2] : (p = r == null ? void 0 : r[2]) == null ? void 0 : p.label) || "跳过", i = ((f = a.metadata) == null ? void 0 : f.showSkip) !== !1;
783
785
  return /* @__PURE__ */ d("div", { className: "sa-interrupt-card", children: [
784
786
  /* @__PURE__ */ d("div", { className: "sa-interrupt-content", children: [
785
787
  /* @__PURE__ */ e(C, { name: "circle-alert", size: 16, color: "#f59e0b" }),
@@ -789,7 +791,7 @@ function Ie({ interrupt: a, onRespond: t }) {
789
791
  /* @__PURE__ */ d("button", { className: "sa-interrupt-btn sa-interrupt-btn-primary", onClick: () => t({ action: "approve" }), children: [
790
792
  /* @__PURE__ */ e(C, { name: "check", size: 14 }),
791
793
  " ",
792
- r
794
+ s
793
795
  ] }),
794
796
  /* @__PURE__ */ d("button", { className: "sa-interrupt-btn sa-interrupt-btn-danger", onClick: () => t({ action: "reject" }), children: [
795
797
  /* @__PURE__ */ e(C, { name: "x", size: 14 }),
@@ -808,32 +810,32 @@ function Te(a) {
808
810
  return typeof a == "string" ? { value: a, label: a } : a;
809
811
  }
810
812
  function Se({ interrupt: a, onRespond: t }) {
811
- const s = (a.options ?? []).map(Te);
813
+ const r = (a.options ?? []).map(Te);
812
814
  return /* @__PURE__ */ d("div", { className: "sa-interrupt-card", children: [
813
815
  /* @__PURE__ */ d("div", { className: "sa-interrupt-content", children: [
814
816
  /* @__PURE__ */ e(C, { name: "list", size: 16, color: "#6366f1" }),
815
817
  /* @__PURE__ */ e("span", { children: a.content })
816
818
  ] }),
817
- /* @__PURE__ */ e("div", { className: "sa-interrupt-options", children: s.map((r) => /* @__PURE__ */ d(
819
+ /* @__PURE__ */ e("div", { className: "sa-interrupt-options", children: r.map((s) => /* @__PURE__ */ d(
818
820
  "button",
819
821
  {
820
- className: `sa-interrupt-option ${r.danger ? "sa-interrupt-option-danger" : ""}`,
821
- onClick: () => t({ action: "select", value: r.value }),
822
+ className: `sa-interrupt-option ${s.danger ? "sa-interrupt-option-danger" : ""}`,
823
+ onClick: () => t({ action: "select", value: s.value }),
822
824
  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 })
825
+ s.icon && /* @__PURE__ */ e(C, { name: s.icon, size: 14 }),
826
+ /* @__PURE__ */ e("span", { children: s.label }),
827
+ s.description && /* @__PURE__ */ e("span", { className: "sa-interrupt-option-desc", children: s.description })
826
828
  ]
827
829
  },
828
- r.value
830
+ s.value
829
831
  )) })
830
832
  ] });
831
833
  }
832
834
  function Me(a) {
833
835
  return typeof a == "string" ? { value: a, label: a } : a;
834
836
  }
835
- function De({ interrupt: a, onRespond: t }) {
836
- const s = (a.options ?? []).map(Me), [r, n] = T(/* @__PURE__ */ new Set()), o = (i) => {
837
+ function Le({ interrupt: a, onRespond: t }) {
838
+ const r = (a.options ?? []).map(Me), [s, n] = T(/* @__PURE__ */ new Set()), o = (i) => {
837
839
  n((l) => {
838
840
  const c = new Set(l);
839
841
  return c.has(i) ? c.delete(i) : c.add(i), c;
@@ -844,13 +846,13 @@ function De({ interrupt: a, onRespond: t }) {
844
846
  /* @__PURE__ */ e(C, { name: "list-checks", size: 16, color: "#6366f1" }),
845
847
  /* @__PURE__ */ e("span", { children: a.content })
846
848
  ] }),
847
- /* @__PURE__ */ e("div", { className: "sa-interrupt-options", children: s.map((i) => /* @__PURE__ */ d(
849
+ /* @__PURE__ */ e("div", { className: "sa-interrupt-options", children: r.map((i) => /* @__PURE__ */ d(
848
850
  "button",
849
851
  {
850
- className: `sa-interrupt-option ${r.has(i.value) ? "sa-interrupt-option-selected" : ""}`,
852
+ className: `sa-interrupt-option ${s.has(i.value) ? "sa-interrupt-option-selected" : ""}`,
851
853
  onClick: () => o(i.value),
852
854
  children: [
853
- /* @__PURE__ */ e(C, { name: r.has(i.value) ? "square-check" : "square", size: 14 }),
855
+ /* @__PURE__ */ e(C, { name: s.has(i.value) ? "square-check" : "square", size: 14 }),
854
856
  /* @__PURE__ */ e("span", { children: i.label })
855
857
  ]
856
858
  },
@@ -860,21 +862,21 @@ function De({ interrupt: a, onRespond: t }) {
860
862
  "button",
861
863
  {
862
864
  className: "sa-interrupt-btn sa-interrupt-btn-primary",
863
- disabled: r.size === 0,
864
- onClick: () => t({ action: "submit", value: Array.from(r) }),
865
+ disabled: s.size === 0,
866
+ onClick: () => t({ action: "submit", value: Array.from(s) }),
865
867
  children: [
866
868
  /* @__PURE__ */ e(C, { name: "check", size: 14 }),
867
869
  " 确认 (",
868
- r.size,
870
+ s.size,
869
871
  ")"
870
872
  ]
871
873
  }
872
874
  ) })
873
875
  ] });
874
876
  }
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() });
877
+ function De({ interrupt: a, onRespond: t }) {
878
+ const [r, s] = T(""), n = a.inputType ?? "text", o = n === "textarea", i = () => {
879
+ a.required && !r.trim() || t({ action: "submit", value: r.trim() });
878
880
  };
879
881
  return /* @__PURE__ */ d("div", { className: "sa-interrupt-card", children: [
880
882
  /* @__PURE__ */ d("div", { className: "sa-interrupt-content", children: [
@@ -885,8 +887,8 @@ function Le({ interrupt: a, onRespond: t }) {
885
887
  "textarea",
886
888
  {
887
889
  className: "sa-interrupt-textarea",
888
- value: s,
889
- onChange: (l) => r(l.target.value),
890
+ value: r,
891
+ onChange: (l) => s(l.target.value),
890
892
  placeholder: a.placeholder,
891
893
  maxLength: a.maxLength,
892
894
  rows: 3
@@ -896,8 +898,8 @@ function Le({ interrupt: a, onRespond: t }) {
896
898
  {
897
899
  className: "sa-interrupt-input",
898
900
  type: n,
899
- value: s,
900
- onChange: (l) => r(l.target.value),
901
+ value: r,
902
+ onChange: (l) => s(l.target.value),
901
903
  placeholder: a.placeholder,
902
904
  maxLength: a.maxLength,
903
905
  onKeyDown: (l) => l.key === "Enter" && i()
@@ -907,7 +909,7 @@ function Le({ interrupt: a, onRespond: t }) {
907
909
  "button",
908
910
  {
909
911
  className: "sa-interrupt-btn sa-interrupt-btn-primary",
910
- disabled: a.required ? !s.trim() : !1,
912
+ disabled: a.required ? !r.trim() : !1,
911
913
  onClick: i,
912
914
  children: [
913
915
  /* @__PURE__ */ e(C, { name: "check", size: 14 }),
@@ -918,27 +920,27 @@ function Le({ interrupt: a, onRespond: t }) {
918
920
  ] });
919
921
  }
920
922
  function Ee({ interrupt: a, onRespond: t }) {
921
- const s = a.fields ?? [], [r, n] = T(() => {
923
+ const r = a.fields ?? [], [s, n] = T(() => {
922
924
  const c = {};
923
- for (const p of s)
925
+ for (const p of r)
924
926
  c[p.name] = p.defaultValue ?? "";
925
927
  return c;
926
928
  }), o = (c, p) => {
927
929
  n((f) => ({ ...f, [c]: p }));
928
- }, i = s.every((c) => !c.required || r[c.name]), l = () => {
929
- i && t({ action: "submit", value: r });
930
+ }, i = r.every((c) => !c.required || s[c.name]), l = () => {
931
+ i && t({ action: "submit", value: s });
930
932
  };
931
933
  return /* @__PURE__ */ d("div", { className: "sa-interrupt-card", children: [
932
934
  /* @__PURE__ */ d("div", { className: "sa-interrupt-content", children: [
933
935
  /* @__PURE__ */ e(C, { name: "file-text", size: 16, color: "#6366f1" }),
934
936
  /* @__PURE__ */ e("span", { children: a.content })
935
937
  ] }),
936
- /* @__PURE__ */ e("div", { className: "sa-interrupt-form", children: s.map((c) => /* @__PURE__ */ d("div", { className: "sa-interrupt-form-field", children: [
938
+ /* @__PURE__ */ e("div", { className: "sa-interrupt-form", children: r.map((c) => /* @__PURE__ */ d("div", { className: "sa-interrupt-form-field", children: [
937
939
  /* @__PURE__ */ d("label", { className: "sa-interrupt-form-label", children: [
938
940
  c.label,
939
941
  c.required && /* @__PURE__ */ e("span", { className: "sa-interrupt-form-required", children: "*" })
940
942
  ] }),
941
- Ae(c, r[c.name], (p) => o(c.name, p))
943
+ Ae(c, s[c.name], (p) => o(c.name, p))
942
944
  ] }, c.name)) }),
943
945
  /* @__PURE__ */ d("div", { className: "sa-interrupt-actions", children: [
944
946
  /* @__PURE__ */ d("button", { className: "sa-interrupt-btn sa-interrupt-btn-primary", disabled: !i, onClick: l, children: [
@@ -949,38 +951,38 @@ function Ee({ interrupt: a, onRespond: t }) {
949
951
  ] })
950
952
  ] });
951
953
  }
952
- function Ae(a, t, s) {
954
+ function Ae(a, t, r) {
953
955
  switch (a.type) {
954
956
  case "textarea":
955
- return /* @__PURE__ */ e("textarea", { className: "sa-interrupt-textarea", value: t, onChange: (r) => s(r.target.value), placeholder: a.placeholder, rows: 3 });
957
+ return /* @__PURE__ */ e("textarea", { className: "sa-interrupt-textarea", value: t, onChange: (s) => r(s.target.value), placeholder: a.placeholder, rows: 3 });
956
958
  case "select":
957
- return /* @__PURE__ */ d("select", { className: "sa-interrupt-select", value: t, onChange: (r) => s(r.target.value), children: [
959
+ return /* @__PURE__ */ d("select", { className: "sa-interrupt-select", value: t, onChange: (s) => r(s.target.value), children: [
958
960
  /* @__PURE__ */ e("option", { value: "", children: "请选择" }),
959
- (a.options ?? []).map((r) => /* @__PURE__ */ e("option", { value: r, children: r }, r))
961
+ (a.options ?? []).map((s) => /* @__PURE__ */ e("option", { value: s, children: s }, s))
960
962
  ] });
961
963
  default:
962
- return /* @__PURE__ */ e("input", { className: "sa-interrupt-input", type: a.type, value: t, onChange: (r) => s(r.target.value), placeholder: a.placeholder });
964
+ return /* @__PURE__ */ e("input", { className: "sa-interrupt-input", type: a.type, value: t, onChange: (s) => r(s.target.value), placeholder: a.placeholder });
963
965
  }
964
966
  }
965
- function $e({ interrupt: a, resolved: t, response: s, onRespond: r }) {
967
+ function $e({ interrupt: a, resolved: t, response: r, onRespond: s }) {
966
968
  if (t)
967
969
  return /* @__PURE__ */ d("div", { className: "sa-interrupt-resolved", children: [
968
970
  /* @__PURE__ */ e(C, { name: "circle-check", size: 14, color: "#10b981" }),
969
- /* @__PURE__ */ e("span", { children: Pe(a.interruptType, s) })
971
+ /* @__PURE__ */ e("span", { children: Pe(a.interruptType, r) })
970
972
  ] });
971
973
  switch (a.interruptType) {
972
974
  case "confirm":
973
- return /* @__PURE__ */ e(ze, { interrupt: a, onRespond: r });
975
+ return /* @__PURE__ */ e(ze, { interrupt: a, onRespond: s });
974
976
  case "approve":
975
- return /* @__PURE__ */ e(Ie, { interrupt: a, onRespond: r });
977
+ return /* @__PURE__ */ e(Ie, { interrupt: a, onRespond: s });
976
978
  case "select":
977
- return /* @__PURE__ */ e(Se, { interrupt: a, onRespond: r });
979
+ return /* @__PURE__ */ e(Se, { interrupt: a, onRespond: s });
978
980
  case "multiSelect":
979
- return /* @__PURE__ */ e(De, { interrupt: a, onRespond: r });
981
+ return /* @__PURE__ */ e(Le, { interrupt: a, onRespond: s });
980
982
  case "input":
981
- return /* @__PURE__ */ e(Le, { interrupt: a, onRespond: r });
983
+ return /* @__PURE__ */ e(De, { interrupt: a, onRespond: s });
982
984
  case "form":
983
- return /* @__PURE__ */ e(Ee, { interrupt: a, onRespond: r });
985
+ return /* @__PURE__ */ e(Ee, { interrupt: a, onRespond: s });
984
986
  default:
985
987
  return /* @__PURE__ */ d("div", { className: "sa-interrupt-unknown", children: [
986
988
  "未知的交互类型: ",
@@ -1017,25 +1019,37 @@ const Oe = [
1017
1019
  { value: 5, label: "冗长啰嗦" },
1018
1020
  { value: 6, label: "难以理解" }
1019
1021
  ];
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 }),
1022
+ function Re({ message: a, onCopy: t, onRegenerate: r }) {
1023
+ const { status: s, feedback: n, cancelFeedback: o } = W(), [i, l] = T(null), [c, p] = T(!1), [f, u] = T(!1), h = F(null);
1024
+ if (s !== "ready" && s !== "error") return null;
1025
+ const w = I(() => {
1026
+ t(), p(!0), setTimeout(() => p(!1), 2e3);
1027
+ }, [t]), k = I(() => {
1028
+ i === "like" ? (l(null), o(a.id)) : (l("like"), u(!1), n(a.id, "like"));
1029
+ }, [i, a.id, n, o]), b = I(() => {
1030
+ i === "dislike" ? (l(null), u(!1), o(a.id)) : u(!0);
1031
+ }, [i, a.id, o]), v = I((g, N) => {
1032
+ l("dislike"), u(!1), n(a.id, "dislike", { reason: g, remark: (N == null ? void 0 : N.trim()) || void 0 });
1033
+ }, [a.id, n]), m = I(() => {
1034
+ u(!1);
1035
+ }, []);
1036
+ return R(() => {
1037
+ if (!f) return;
1038
+ const g = (S) => {
1039
+ h.current && !h.current.contains(S.target) && u(!1);
1040
+ }, N = (S) => {
1041
+ S.key === "Escape" && u(!1);
1042
+ };
1043
+ return document.addEventListener("mousedown", g), document.addEventListener("keydown", N), () => {
1044
+ document.removeEventListener("mousedown", g), document.removeEventListener("keydown", N);
1045
+ };
1046
+ }, [f]), /* @__PURE__ */ d("div", { className: "sa-action-bar", children: [
1047
+ /* @__PURE__ */ d("button", { className: "sa-action-btn", onClick: w, title: "复制", children: [
1048
+ /* @__PURE__ */ e(C, { name: c ? "circle-check" : "copy", size: 14 }),
1035
1049
  " ",
1036
- p ? "已复制" : "复制"
1050
+ c ? "已复制" : "复制"
1037
1051
  ] }),
1038
- /* @__PURE__ */ d("button", { className: "sa-action-btn", onClick: s, title: "重新生成", children: [
1052
+ /* @__PURE__ */ d("button", { className: "sa-action-btn", onClick: r, title: "重新生成", children: [
1039
1053
  /* @__PURE__ */ e(C, { name: "refresh-cw", size: 14 }),
1040
1054
  " 重新生成"
1041
1055
  ] }),
@@ -1043,7 +1057,7 @@ function Re({ message: a, onCopy: t, onRegenerate: s, onFeedback: r }) {
1043
1057
  /* @__PURE__ */ e(
1044
1058
  "button",
1045
1059
  {
1046
- className: `sa-action-btn ${l === "like" ? "sa-action-btn-active" : ""}`,
1060
+ className: `sa-action-btn ${i === "like" ? "sa-action-btn-active" : ""}`,
1047
1061
  onClick: k,
1048
1062
  title: "有用",
1049
1063
  "aria-label": "点赞",
@@ -1053,31 +1067,27 @@ function Re({ message: a, onCopy: t, onRegenerate: s, onFeedback: r }) {
1053
1067
  /* @__PURE__ */ e(
1054
1068
  "button",
1055
1069
  {
1056
- className: `sa-action-btn ${l === "dislike" ? "sa-action-btn-active" : ""}`,
1057
- onClick: g,
1070
+ className: `sa-action-btn ${i === "dislike" ? "sa-action-btn-active" : ""}`,
1071
+ onClick: b,
1058
1072
  title: "无用",
1059
1073
  "aria-label": "踩",
1074
+ "aria-expanded": f,
1075
+ "aria-haspopup": "dialog",
1060
1076
  children: /* @__PURE__ */ e(C, { name: "thumbs-down", size: 14 })
1061
1077
  }
1062
1078
  ),
1063
- u && /* @__PURE__ */ e(
1064
- Be,
1065
- {
1066
- onSubmit: b,
1067
- onCancel: () => h(!1)
1068
- }
1069
- )
1079
+ f && /* @__PURE__ */ e("div", { ref: h, children: /* @__PURE__ */ e(Be, { onSubmit: v, onCancel: m }) })
1070
1080
  ] });
1071
1081
  }
1072
1082
  function Be({ onSubmit: a, onCancel: t }) {
1073
- const [s, r] = T(void 0), [n, o] = T("");
1083
+ const [r, s] = T(void 0), [n, o] = T("");
1074
1084
  return /* @__PURE__ */ d("div", { className: "sa-dislike-panel", children: [
1075
1085
  /* @__PURE__ */ e("div", { className: "sa-dislike-panel-title", children: "请选择不满意的原因(可选)" }),
1076
1086
  /* @__PURE__ */ e("div", { className: "sa-dislike-reasons", children: Oe.map((i) => /* @__PURE__ */ e(
1077
1087
  "button",
1078
1088
  {
1079
- className: `sa-dislike-reason-btn ${s === i.value ? "active" : ""}`,
1080
- onClick: () => r(s === i.value ? void 0 : i.value),
1089
+ className: `sa-dislike-reason-btn ${r === i.value ? "active" : ""}`,
1090
+ onClick: () => s(r === i.value ? void 0 : i.value),
1081
1091
  children: i.label
1082
1092
  },
1083
1093
  i.value
@@ -1094,118 +1104,118 @@ function Be({ onSubmit: a, onCancel: t }) {
1094
1104
  }
1095
1105
  ),
1096
1106
  /* @__PURE__ */ d("div", { className: "sa-dislike-actions", children: [
1097
- /* @__PURE__ */ e("button", { className: "sa-dislike-submit", onClick: () => a(s, n || void 0), children: "提交" }),
1107
+ /* @__PURE__ */ e("button", { className: "sa-dislike-submit", onClick: () => a(r, n || void 0), children: "提交" }),
1098
1108
  /* @__PURE__ */ e("button", { className: "sa-dislike-cancel", onClick: t, children: "取消" })
1099
1109
  ] })
1100
1110
  ] });
1101
1111
  }
1102
1112
  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 });
1113
+ const r = t === "assistant" ? "A" : "U";
1114
+ 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: r });
1105
1115
  }
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(`
1116
+ function Fe({ message: a, isStreaming: t, isLast: r, slots: s, avatar: n, artifactPreview: o }) {
1117
+ const { regenerate: i, feedback: l, respondToInterrupt: c } = W(), p = I(() => {
1118
+ var N;
1119
+ const g = a.parts.filter((S) => S.type === "text").map((S) => S.content).join(`
1110
1120
  `);
1111
- (I = navigator.clipboard) == null || I.writeText(x).catch(() => {
1121
+ (N = navigator.clipboard) == null || N.writeText(g).catch(() => {
1112
1122
  });
1113
- }, [a]), f = a.role === "user", u = r.Message;
1123
+ }, [a]), f = a.role === "user", u = s.Message;
1114
1124
  if (u)
1115
1125
  return /* @__PURE__ */ e(
1116
1126
  u,
1117
1127
  {
1118
1128
  message: a,
1119
1129
  isStreaming: t,
1120
- isLast: s,
1130
+ isLast: r,
1121
1131
  avatar: n,
1122
- slots: r,
1132
+ slots: s,
1123
1133
  onCopy: p,
1124
1134
  onRegenerate: i,
1125
1135
  onFeedback: l
1126
1136
  }
1127
1137
  );
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;
1138
+ const h = s.TextPart ?? ve, w = s.ThinkingPart ?? we, k = s.ToolCallPart ?? ye, b = s.ToolResultPart ?? Ce, v = s.ErrorPart ?? Ne, m = s.ActionBar ?? Re;
1129
1139
  return /* @__PURE__ */ d("div", { className: `sa-message ${f ? "sa-message-user" : "sa-message-assistant"}`, children: [
1130
1140
  !f && /* @__PURE__ */ e(Z, { src: n == null ? void 0 : n.assistant, role: "assistant" }),
1131
1141
  /* @__PURE__ */ d("div", { className: "sa-message-body", children: [
1132
- a.parts.map((x, I) => {
1133
- switch (x.type) {
1142
+ a.parts.map((g, N) => {
1143
+ switch (g.type) {
1134
1144
  case "text":
1135
- return /* @__PURE__ */ e(h, { content: x.content }, I);
1145
+ return /* @__PURE__ */ e(h, { content: g.content }, N);
1136
1146
  case "thinking":
1137
- return /* @__PURE__ */ e(v, { content: x.content }, I);
1147
+ return /* @__PURE__ */ e(w, { content: g.content }, N);
1138
1148
  case "tool_call":
1139
- return /* @__PURE__ */ e(k, { toolName: x.toolName, toolCallId: x.toolCallId, args: x.args }, I);
1149
+ return /* @__PURE__ */ e(k, { toolName: g.toolName, toolCallId: g.toolCallId, args: g.args }, N);
1140
1150
  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);
1151
+ return /* @__PURE__ */ e(b, { toolName: g.toolName, toolCallId: g.toolCallId, content: g.content, artifacts: g.artifacts, renderMode: g.renderMode, html: g.html, artifactPreview: o }, N);
1142
1152
  case "error":
1143
- return /* @__PURE__ */ e(b, { content: x.content, onRetry: i }, I);
1153
+ return /* @__PURE__ */ e(v, { content: g.content, onRetry: i }, N);
1144
1154
  case "interrupt":
1145
1155
  return /* @__PURE__ */ e(
1146
1156
  $e,
1147
1157
  {
1148
- interrupt: x.interrupt,
1149
- resolved: x.resolved ?? !1,
1150
- response: x.response,
1151
- onRespond: (D) => c(x.interrupt.interruptId, D)
1158
+ interrupt: g.interrupt,
1159
+ resolved: g.resolved ?? !1,
1160
+ response: g.response,
1161
+ onRespond: (S) => c(g.interrupt.interruptId, S)
1152
1162
  },
1153
- I
1163
+ N
1154
1164
  );
1155
1165
  default:
1156
1166
  return null;
1157
1167
  }
1158
1168
  }),
1159
- t && s && !f && /* @__PURE__ */ e("span", { className: "sa-streaming-cursor", children: "|" }),
1169
+ t && r && !f && /* @__PURE__ */ e("span", { className: "sa-streaming-cursor", children: "|" }),
1160
1170
  !f && !t && a.parts.length > 0 && /* @__PURE__ */ e(m, { message: a, onCopy: p, onRegenerate: i, onFeedback: l })
1161
1171
  ] }),
1162
1172
  f && /* @__PURE__ */ e(Z, { src: n == null ? void 0 : n.user, role: "user" })
1163
1173
  ] });
1164
1174
  }
1165
- function je({ message: a, suggestedPrompts: t, onPromptClick: s }) {
1175
+ function He({ message: a, suggestedPrompts: t, onPromptClick: r }) {
1166
1176
  return /* @__PURE__ */ d("div", { className: "sa-welcome", children: [
1167
1177
  /* @__PURE__ */ e("div", { className: "sa-welcome-icon", children: /* @__PURE__ */ e(C, { name: "sparkles", size: 40 }) }),
1168
1178
  /* @__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(
1179
+ t && t.length > 0 && /* @__PURE__ */ e("div", { className: "sa-welcome-prompts", children: t.map((s, n) => /* @__PURE__ */ e(
1170
1180
  "button",
1171
1181
  {
1172
1182
  className: "sa-welcome-prompt",
1173
- onClick: () => s(r),
1174
- children: r
1183
+ onClick: () => r(s),
1184
+ children: s
1175
1185
  },
1176
1186
  n
1177
1187
  )) })
1178
1188
  ] });
1179
1189
  }
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;
1190
+ function re({ slots: a, welcomeMessage: t, suggestedPrompts: r, avatar: s, artifactPreview: n }) {
1191
+ const { messages: o, status: i, sendMessage: l } = W(), { containerRef: c } = ge([o]), p = i === "streaming", f = a.WelcomeScreen ?? He;
1182
1192
  return o.length === 0 ? /* @__PURE__ */ e("div", { className: "sa-thread", ref: c, children: /* @__PURE__ */ e(
1183
1193
  f,
1184
1194
  {
1185
1195
  message: t,
1186
- suggestedPrompts: s,
1196
+ suggestedPrompts: r,
1187
1197
  onPromptClick: l
1188
1198
  }
1189
1199
  ) }) : /* @__PURE__ */ e("div", { className: "sa-thread", ref: c, children: o.map((u, h) => /* @__PURE__ */ e(
1190
- He,
1200
+ Fe,
1191
1201
  {
1192
1202
  message: u,
1193
1203
  isStreaming: p,
1194
1204
  isLast: h === o.length - 1,
1195
1205
  slots: a,
1196
- avatar: r,
1206
+ avatar: s,
1197
1207
  artifactPreview: n
1198
1208
  },
1199
1209
  u.id
1200
1210
  )) });
1201
1211
  }
1202
1212
  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();
1213
+ const { status: a, sendMessage: t, stop: r } = W(), [s, n] = T(""), o = F(null), i = a === "streaming" || a === "submitted", l = I(() => {
1214
+ const f = s.trim();
1205
1215
  !f || i || (t(f), n(""), o.current && (o.current.style.height = "auto"));
1206
- }, [r, i, t]), c = N((f) => {
1216
+ }, [s, i, t]), c = I((f) => {
1207
1217
  f.key === "Enter" && !f.shiftKey && (f.preventDefault(), l());
1208
- }, [l]), p = N((f) => {
1218
+ }, [l]), p = I((f) => {
1209
1219
  n(f.target.value);
1210
1220
  const u = f.target;
1211
1221
  u.style.height = "auto", u.style.height = Math.min(u.scrollHeight, 120) + "px";
@@ -1216,7 +1226,7 @@ function se() {
1216
1226
  {
1217
1227
  ref: o,
1218
1228
  className: "sa-composer-input",
1219
- value: r,
1229
+ value: s,
1220
1230
  onChange: p,
1221
1231
  onKeyDown: c,
1222
1232
  placeholder: "输入消息...",
@@ -1224,23 +1234,23 @@ function se() {
1224
1234
  disabled: a === "submitted"
1225
1235
  }
1226
1236
  ),
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(
1237
+ i ? /* @__PURE__ */ e("button", { className: "sa-composer-stop", onClick: r, title: "停止", children: /* @__PURE__ */ e(C, { name: "circle-stop", size: 16, color: "#fff" }) }) : /* @__PURE__ */ e(
1228
1238
  "button",
1229
1239
  {
1230
1240
  className: "sa-composer-send",
1231
1241
  onClick: l,
1232
- disabled: !r.trim(),
1242
+ disabled: !s.trim(),
1233
1243
  title: "发送",
1234
1244
  children: /* @__PURE__ */ e(C, { name: "arrow-up", size: 16, color: "#fff" })
1235
1245
  }
1236
1246
  )
1237
1247
  ] });
1238
1248
  }
1239
- function _e({ artifact: a }) {
1240
- const [t, s] = Y.useState(null), [r, n] = Y.useState(!0), [o, i] = Y.useState(null);
1249
+ function je({ artifact: a }) {
1250
+ const [t, r] = Y.useState(null), [s, n] = Y.useState(!0), [o, i] = Y.useState(null);
1241
1251
  return Y.useEffect(() => {
1242
1252
  let l = !1;
1243
- n(!0), i(null), s(null);
1253
+ n(!0), i(null), r(null);
1244
1254
  async function c() {
1245
1255
  try {
1246
1256
  if (a.type === "pdf") {
@@ -1251,14 +1261,14 @@ function _e({ artifact: a }) {
1251
1261
  const p = await fetch(a.url);
1252
1262
  if (!p.ok) throw new Error(`HTTP ${p.status}`);
1253
1263
  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));
1264
+ l || (r(u.sanitize(f, { FORCE_BODY: !0 })), n(!1));
1255
1265
  return;
1256
1266
  }
1257
1267
  if (a.type === "docx") {
1258
1268
  const p = await fetch(a.url);
1259
1269
  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));
1270
+ const f = await p.arrayBuffer(), h = await (await import("./mammoth.browser-COPV53yV.js").then((k) => k.m)).convertToHtml({ arrayBuffer: f }), w = (await import("./purify.es-C-6FFqDW.js")).default;
1271
+ l || (r(w.sanitize(h.value, { FORCE_BODY: !0 })), n(!1));
1262
1272
  return;
1263
1273
  }
1264
1274
  l || (n(!1), i(`不支持预览「${a.type}」类型`));
@@ -1269,54 +1279,54 @@ function _e({ artifact: a }) {
1269
1279
  return c(), () => {
1270
1280
  l = !0;
1271
1281
  };
1272
- }, [a]), r ? /* @__PURE__ */ e("div", { className: "sa-drawer-preview-loading", children: "加载中" }) : o ? /* @__PURE__ */ d("div", { className: "sa-drawer-preview-error", children: [
1282
+ }, [a]), s ? /* @__PURE__ */ e("div", { className: "sa-drawer-preview-loading", children: "加载中" }) : o ? /* @__PURE__ */ d("div", { className: "sa-drawer-preview-error", children: [
1273
1283
  o,
1274
1284
  /* @__PURE__ */ e("button", { className: "sa-drawer-btn-sm", onClick: () => void U(a), children: "下载查看" })
1275
1285
  ] }) : a.type === "pdf" ? /* @__PURE__ */ e("iframe", { src: a.url, title: a.filename, className: "sa-drawer-preview-iframe", sandbox: "allow-scripts" }) : t !== null ? /* @__PURE__ */ e("iframe", { srcDoc: t, title: a.filename, className: "sa-drawer-preview-iframe", sandbox: "allow-same-origin" }) : null;
1276
1286
  }
1277
- function ne({ artifacts: a, initialArtifact: t, onClose: s }) {
1278
- const [r, n] = T(
1287
+ function ne({ artifacts: a, initialArtifact: t, onClose: r }) {
1288
+ const [s, n] = T(
1279
1289
  t ? { mode: "preview", artifact: t } : { mode: "list" }
1280
- ), [o, i] = T(!1), l = _(null), [c, p] = T(340), f = _(null);
1281
- B(() => {
1290
+ ), [o, i] = T(!1), l = F(null), [c, p] = T(340), f = F(null);
1291
+ R(() => {
1282
1292
  t && (l.current && (clearTimeout(l.current), l.current = null, i(!1)), n({ mode: "preview", artifact: t }));
1283
1293
  }, [t]);
1284
- const u = N(() => {
1294
+ const u = I(() => {
1285
1295
  i(!0), l.current = setTimeout(() => {
1286
- l.current = null, s();
1296
+ l.current = null, r();
1287
1297
  }, 240);
1288
- }, [s]);
1289
- B(() => () => {
1290
- var g;
1291
- l.current && clearTimeout(l.current), (g = f.current) == null || g.call(f);
1298
+ }, [r]);
1299
+ R(() => () => {
1300
+ var b;
1301
+ l.current && clearTimeout(l.current), (b = f.current) == null || b.call(f);
1292
1302
  }, []);
1293
- const h = N((g) => {
1294
- n({ mode: "preview", artifact: g });
1295
- }, []), v = N(() => {
1303
+ const h = I((b) => {
1304
+ n({ mode: "preview", artifact: b });
1305
+ }, []), w = I(() => {
1296
1306
  n({ mode: "list" });
1297
1307
  }, []);
1298
- B(() => {
1299
- const g = (b) => {
1300
- b.key === "Escape" && u();
1308
+ R(() => {
1309
+ const b = (v) => {
1310
+ v.key === "Escape" && u();
1301
1311
  };
1302
- return document.addEventListener("keydown", g), () => document.removeEventListener("keydown", g);
1312
+ return document.addEventListener("keydown", b), () => document.removeEventListener("keydown", b);
1303
1313
  }, [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;
1314
+ const k = I((b) => {
1315
+ b.preventDefault();
1316
+ const v = b.clientX, m = c, g = (S) => {
1317
+ const L = v - S.clientX;
1318
+ p(Math.max(240, Math.min(window.innerWidth * 0.7, m + L)));
1319
+ }, N = () => {
1320
+ document.removeEventListener("mousemove", g), document.removeEventListener("mouseup", N), document.body.style.cursor = "", document.body.style.userSelect = "", f.current = null;
1311
1321
  };
1312
- document.body.style.cursor = "col-resize", document.body.style.userSelect = "none", document.addEventListener("mousemove", x), document.addEventListener("mouseup", I), f.current = I;
1322
+ document.body.style.cursor = "col-resize", document.body.style.userSelect = "none", document.addEventListener("mousemove", g), document.addEventListener("mouseup", N), f.current = N;
1313
1323
  }, [c]);
1314
1324
  return /* @__PURE__ */ d("div", { className: `sa-artifact-drawer ${o ? "sa-drawer-closing" : ""}`, style: { width: c }, children: [
1315
1325
  /* @__PURE__ */ e("div", { className: "sa-drawer-resize-handle", onMouseDown: k }),
1316
1326
  /* @__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 })
1327
+ s.mode === "preview" ? /* @__PURE__ */ d(q, { children: [
1328
+ /* @__PURE__ */ e("button", { className: "sa-drawer-btn", onClick: w, 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" }) }) }),
1329
+ /* @__PURE__ */ e("span", { className: "sa-artifact-drawer-title", children: s.artifact.filename })
1320
1330
  ] }) : /* @__PURE__ */ d(q, { children: [
1321
1331
  /* @__PURE__ */ d("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", style: { flexShrink: 0 }, children: [
1322
1332
  /* @__PURE__ */ e("path", { d: "M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z" }),
@@ -1325,103 +1335,103 @@ function ne({ artifacts: a, initialArtifact: t, onClose: s }) {
1325
1335
  /* @__PURE__ */ e("span", { className: "sa-artifact-drawer-title", children: "会话产物" })
1326
1336
  ] }),
1327
1337
  /* @__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" }) }) }),
1338
+ s.mode === "preview" && /* @__PURE__ */ e("button", { className: "sa-drawer-btn", onClick: () => void U(s.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
1339
  /* @__PURE__ */ e("button", { className: "sa-drawer-btn", onClick: u, title: "关闭", "aria-label": "关闭", children: /* @__PURE__ */ e("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: /* @__PURE__ */ e("path", { d: "M18 6L6 18M6 6l12 12" }) }) })
1330
1340
  ] }),
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(
1341
+ /* @__PURE__ */ e("div", { className: "sa-artifact-drawer-body", children: s.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((b, v) => /* @__PURE__ */ d(
1332
1342
  "li",
1333
1343
  {
1334
1344
  className: "sa-drawer-file-card",
1335
- onClick: () => h(g),
1345
+ onClick: () => h(b),
1336
1346
  onKeyDown: (m) => {
1337
- (m.key === "Enter" || m.key === " ") && (m.preventDefault(), h(g));
1347
+ (m.key === "Enter" || m.key === " ") && (m.preventDefault(), h(b));
1338
1348
  },
1339
1349
  tabIndex: 0,
1340
1350
  role: "button",
1341
- "aria-label": `预览 ${g.filename}`,
1351
+ "aria-label": `预览 ${b.filename}`,
1342
1352
  children: [
1343
- /* @__PURE__ */ e("div", { className: "sa-drawer-file-icon", children: /* @__PURE__ */ e("span", { className: "sa-artifact-chip-type", children: ee(g.type) }) }),
1353
+ /* @__PURE__ */ e("div", { className: "sa-drawer-file-icon", children: /* @__PURE__ */ e("span", { className: "sa-artifact-chip-type", children: ee(b.type) }) }),
1344
1354
  /* @__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) })
1355
+ /* @__PURE__ */ e("span", { className: "sa-drawer-file-name", children: b.filename }),
1356
+ /* @__PURE__ */ e("span", { className: "sa-drawer-file-size", children: Q(b.size) })
1347
1357
  ] }),
1348
1358
  /* @__PURE__ */ e(
1349
1359
  "button",
1350
1360
  {
1351
1361
  className: "sa-drawer-btn",
1352
1362
  title: "下载",
1353
- "aria-label": `下载 ${g.filename}`,
1363
+ "aria-label": `下载 ${b.filename}`,
1354
1364
  onClick: (m) => {
1355
- m.stopPropagation(), U(g);
1365
+ m.stopPropagation(), U(b);
1356
1366
  },
1357
1367
  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
1368
  }
1359
1369
  )
1360
1370
  ]
1361
1371
  },
1362
- g.id || `artifact-${b}`
1363
- )) }) : /* @__PURE__ */ e("div", { className: "sa-drawer-view-enter", children: /* @__PURE__ */ e(_e, { artifact: r.artifact }) }) })
1372
+ b.id || `artifact-${v}`
1373
+ )) }) : /* @__PURE__ */ e("div", { className: "sa-drawer-view-enter", children: /* @__PURE__ */ e(je, { artifact: s.artifact }) }) })
1364
1374
  ] });
1365
1375
  }
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();
1376
+ function _e({ isOpen: a, onClose: t, title: r, slots: s, welcomeMessage: n, suggestedPrompts: o, avatar: i, artifactPreview: l }) {
1377
+ const { status: c, sendMessage: p, stop: f, toggleThreadList: u, toggleArtifactDrawer: h, conversations: w, activeConversationId: k, switchConversation: b, newConversation: v, deleteConversation: m, renameConversation: g, isThreadListOpen: N, isArtifactDrawerOpen: S, allArtifacts: L, activePreviewArtifact: O } = W();
1368
1378
  if (!a) return null;
1369
- const y = r.Header, L = r.Composer, $ = r.ThreadList;
1379
+ const y = s.Header, D = s.Composer, P = s.ThreadList;
1370
1380
  return /* @__PURE__ */ d("div", { className: "sa-panel", children: [
1371
- y ? /* @__PURE__ */ e(y, { title: s, onClose: t, onToggleThreadList: u }) : /* @__PURE__ */ e(
1381
+ y ? /* @__PURE__ */ e(y, { title: r, onClose: t, onToggleThreadList: u }) : /* @__PURE__ */ e(
1372
1382
  ue,
1373
1383
  {
1374
- title: s,
1384
+ title: r,
1375
1385
  onClose: t,
1376
1386
  onToggleThreadList: u,
1377
- artifactCount: l ? M.length : 0,
1387
+ artifactCount: l ? L.length : 0,
1378
1388
  onToggleArtifactDrawer: l ? h : void 0
1379
1389
  }
1380
1390
  ),
1381
- $ && I ? /* @__PURE__ */ e(
1382
- $,
1391
+ P && N ? /* @__PURE__ */ e(
1392
+ P,
1383
1393
  {
1384
- conversations: v,
1394
+ conversations: w,
1385
1395
  activeSessionId: k,
1386
- onSwitch: g,
1387
- onNew: b,
1396
+ onSwitch: b,
1397
+ onNew: v,
1388
1398
  onDelete: m,
1389
- onRename: x
1399
+ onRename: g
1390
1400
  }
1391
1401
  ) : /* @__PURE__ */ e(he, {}),
1392
1402
  /* @__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 })
1403
+ /* @__PURE__ */ e(re, { slots: s, welcomeMessage: n, suggestedPrompts: o, avatar: i, artifactPreview: l }),
1404
+ l && S && /* @__PURE__ */ e(ne, { artifacts: L, initialArtifact: O, onClose: h })
1395
1405
  ] }),
1396
- L ? /* @__PURE__ */ e(L, { status: c, onSend: p, onStop: f }) : /* @__PURE__ */ e(se, {})
1406
+ D ? /* @__PURE__ */ e(D, { status: c, onSend: p, onStop: f }) : /* @__PURE__ */ e(se, {})
1397
1407
  ] });
1398
1408
  }
1399
- function Fe({
1409
+ function We({
1400
1410
  conversations: a,
1401
1411
  activeSessionId: t,
1402
- onSwitch: s,
1403
- onNew: r,
1412
+ onSwitch: r,
1413
+ onNew: s,
1404
1414
  onDelete: n,
1405
1415
  isCollapsed: o,
1406
1416
  onToggleCollapse: i
1407
1417
  }) {
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));
1418
+ const [l, c] = T(null), [p, f] = T(null), u = I((w, k) => {
1419
+ k.stopPropagation(), p === w ? (n(w), f(null)) : (f(w), setTimeout(() => f(null), 3e3));
1410
1420
  }, [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);
1421
+ const w = Date.now(), k = [], b = [], v = [];
1422
+ for (const g of a) {
1423
+ const N = w - new Date(g.updateTime).getTime();
1424
+ N < 864e5 ? k.push(g) : N < 6048e5 ? b.push(g) : v.push(g);
1415
1425
  }
1416
1426
  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;
1427
+ return k.length && m.push({ label: "今天", items: k }), b.length && m.push({ label: "最近 7 天", items: b }), v.length && m.push({ label: "更早", items: v }), m;
1418
1428
  })();
1419
1429
  return o ? /* @__PURE__ */ d("div", { className: "sa-fp-sidebar sa-fp-sidebar-collapsed", children: [
1420
1430
  /* @__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 }) })
1431
+ /* @__PURE__ */ e("button", { className: "sa-fp-sidebar-toggle", onClick: s, title: "新会话", style: { marginTop: 4 }, children: /* @__PURE__ */ e(C, { name: "plus", size: 18 }) })
1422
1432
  ] }) : /* @__PURE__ */ d("div", { className: "sa-fp-sidebar", children: [
1423
1433
  /* @__PURE__ */ d("div", { className: "sa-fp-sidebar-header", children: [
1424
- /* @__PURE__ */ d("button", { className: "sa-fp-sidebar-new", onClick: r, children: [
1434
+ /* @__PURE__ */ d("button", { className: "sa-fp-sidebar-new", onClick: s, children: [
1425
1435
  /* @__PURE__ */ e(C, { name: "plus", size: 15 }),
1426
1436
  " ",
1427
1437
  /* @__PURE__ */ e("span", { children: "新会话" })
@@ -1430,24 +1440,24 @@ function Fe({
1430
1440
  ] }),
1431
1441
  /* @__PURE__ */ d("div", { className: "sa-fp-sidebar-list", children: [
1432
1442
  a.length === 0 && /* @__PURE__ */ e("div", { className: "sa-fp-sidebar-empty", children: "开始你的第一个对话" }),
1433
- h.map((v) => /* @__PURE__ */ d("div", { children: [
1434
- /* @__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;
1443
+ h.map((w) => /* @__PURE__ */ d("div", { children: [
1444
+ /* @__PURE__ */ e("div", { className: "sa-fp-sidebar-group", children: w.label }),
1445
+ w.items.map((k) => {
1446
+ const b = k.sessionId === t, v = l === k.sessionId, m = p === k.sessionId;
1437
1447
  return /* @__PURE__ */ d(
1438
1448
  "div",
1439
1449
  {
1440
- className: `sa-fp-sidebar-item ${g ? "active" : ""}`,
1441
- onClick: () => s(k.sessionId),
1450
+ className: `sa-fp-sidebar-item ${b ? "active" : ""}`,
1451
+ onClick: () => r(k.sessionId),
1442
1452
  onMouseEnter: () => c(k.sessionId),
1443
1453
  onMouseLeave: () => c(null),
1444
1454
  children: [
1445
1455
  /* @__PURE__ */ e("span", { className: "sa-fp-sidebar-item-title", children: k.title || "新会话" }),
1446
- b && /* @__PURE__ */ e(
1456
+ v && /* @__PURE__ */ e(
1447
1457
  "button",
1448
1458
  {
1449
1459
  className: `sa-fp-sidebar-item-action ${m ? "danger" : ""}`,
1450
- onClick: (x) => u(k.sessionId, x),
1460
+ onClick: (g) => u(k.sessionId, g),
1451
1461
  title: m ? "确认删除" : "删除",
1452
1462
  children: /* @__PURE__ */ e(C, { name: m ? "x" : "trash2", size: 14 })
1453
1463
  }
@@ -1457,56 +1467,56 @@ function Fe({
1457
1467
  k.sessionId
1458
1468
  );
1459
1469
  })
1460
- ] }, v.label))
1470
+ ] }, w.label))
1461
1471
  ] })
1462
1472
  ] });
1463
1473
  }
1464
- function Ye({ title: a, slots: t, welcomeMessage: s, suggestedPrompts: r, sidebarDefaultOpen: n = !0, onClose: o, avatar: i, artifactPreview: l }) {
1474
+ function Ye({ title: a, slots: t, welcomeMessage: r, suggestedPrompts: s, sidebarDefaultOpen: n = !0, onClose: o, avatar: i, artifactPreview: l }) {
1465
1475
  const {
1466
1476
  status: c,
1467
1477
  sendMessage: p,
1468
1478
  stop: f,
1469
1479
  conversations: u,
1470
1480
  activeConversationId: h,
1471
- switchConversation: v,
1481
+ switchConversation: w,
1472
1482
  newConversation: k,
1473
- deleteConversation: g,
1474
- renameConversation: b,
1483
+ deleteConversation: b,
1484
+ renameConversation: v,
1475
1485
  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;
1486
+ isArtifactDrawerOpen: g,
1487
+ allArtifacts: N,
1488
+ activePreviewArtifact: S
1489
+ } = W(), [L, O] = T(n), y = I(() => O((M) => !M), []), D = t.ThreadList, P = t.Composer;
1480
1490
  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,
1491
+ D ? /* @__PURE__ */ e("div", { className: `sa-fp-sidebar-wrapper ${L ? "" : "sa-fp-sidebar-wrapper-collapsed"}`, children: /* @__PURE__ */ e(
1492
+ D,
1483
1493
  {
1484
1494
  conversations: u,
1485
1495
  activeSessionId: h,
1486
- onSwitch: v,
1496
+ onSwitch: w,
1487
1497
  onNew: k,
1488
- onDelete: g,
1489
- onRename: b
1498
+ onDelete: b,
1499
+ onRename: v
1490
1500
  }
1491
1501
  ) }) : /* @__PURE__ */ e(
1492
- Fe,
1502
+ We,
1493
1503
  {
1494
1504
  conversations: u,
1495
1505
  activeSessionId: h,
1496
- onSwitch: v,
1506
+ onSwitch: w,
1497
1507
  onNew: k,
1498
- onDelete: g,
1499
- onRename: b,
1500
- isCollapsed: !M,
1508
+ onDelete: b,
1509
+ onRename: v,
1510
+ isCollapsed: !L,
1501
1511
  onToggleCollapse: y
1502
1512
  }
1503
1513
  ),
1504
1514
  /* @__PURE__ */ d("div", { className: "sa-fp-main", children: [
1505
1515
  /* @__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 }) }),
1516
+ !L && !D && /* @__PURE__ */ e("button", { className: "sa-fp-header-btn", onClick: y, title: "展开侧边栏", children: /* @__PURE__ */ e(C, { name: "panel-left", size: 18 }) }),
1507
1517
  /* @__PURE__ */ e("div", { className: "sa-fp-header-title", children: a }),
1508
1518
  /* @__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: [
1519
+ l && N.length > 0 && /* @__PURE__ */ d("button", { className: "sa-fp-header-btn sa-header-btn-artifact", onClick: m, title: "会话产物", children: [
1510
1520
  /* @__PURE__ */ d("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: [
1511
1521
  /* @__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
1522
  /* @__PURE__ */ e("polyline", { points: "14 2 14 8 20 8" })
@@ -1517,47 +1527,47 @@ function Ye({ title: a, slots: t, welcomeMessage: s, suggestedPrompts: r, sideba
1517
1527
  ] })
1518
1528
  ] }),
1519
1529
  /* @__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 })
1530
+ /* @__PURE__ */ e(re, { slots: t, welcomeMessage: r, suggestedPrompts: s, avatar: i, artifactPreview: l }),
1531
+ l && g && /* @__PURE__ */ e(ne, { artifacts: N, initialArtifact: S, onClose: m })
1522
1532
  ] }),
1523
- $ ? /* @__PURE__ */ e($, { status: c, onSend: p, onStop: f }) : /* @__PURE__ */ e(se, {})
1533
+ P ? /* @__PURE__ */ e(P, { status: c, onSend: p, onStop: f }) : /* @__PURE__ */ e(se, {})
1524
1534
  ] })
1525
1535
  ] });
1526
1536
  }
1527
1537
  function Ke(a) {
1528
- const { sdk: t, mode: s = "floating", slots: r = {}, hooks: n = {}, welcomeMessage: o, suggestedPrompts: i, title: l = "AI Assistant", initialOpen: c = !1, onOpenChange: p, sidebarDefaultOpen: f, avatar: u, artifactPreview: h } = a, [v, k] = T(c);
1529
- B(() => {
1538
+ const { sdk: t, mode: r = "floating", slots: s = {}, hooks: n = {}, welcomeMessage: o, suggestedPrompts: i, title: l = "AI Assistant", initialOpen: c = !1, onOpenChange: p, sidebarDefaultOpen: f, avatar: u, artifactPreview: h } = a, [w, k] = T(c);
1539
+ R(() => {
1530
1540
  k(c);
1531
1541
  }, [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(
1542
+ const b = I(() => {
1543
+ var N, S;
1544
+ const g = !w;
1545
+ k(g), p == null || p(g), g ? (N = n.onOpen) == null || N.call(n) : (S = n.onClose) == null || S.call(n);
1546
+ }, [w, n, p]), v = I(() => {
1547
+ var g;
1548
+ k(!1), p == null || p(!1), (g = n.onClose) == null || g.call(n);
1549
+ }, [n, p]), m = s.Trigger ?? fe;
1550
+ return r === "fullpage" ? w ? /* @__PURE__ */ e(G, { sdk: t, hooks: n, children: /* @__PURE__ */ e(
1541
1551
  Ye,
1542
1552
  {
1543
1553
  title: l,
1544
- slots: r,
1554
+ slots: s,
1545
1555
  welcomeMessage: o,
1546
1556
  suggestedPrompts: i,
1547
1557
  sidebarDefaultOpen: f,
1548
- onClose: b,
1558
+ onClose: v,
1549
1559
  avatar: u,
1550
1560
  artifactPreview: h
1551
1561
  }
1552
1562
  ) }) : null : /* @__PURE__ */ d(G, { sdk: t, hooks: n, children: [
1553
- /* @__PURE__ */ e(m, { isOpen: v, onClick: g }),
1563
+ /* @__PURE__ */ e(m, { isOpen: w, onClick: b }),
1554
1564
  /* @__PURE__ */ e(
1555
- We,
1565
+ _e,
1556
1566
  {
1557
- isOpen: v,
1558
- onClose: b,
1567
+ isOpen: w,
1568
+ onClose: v,
1559
1569
  title: l,
1560
- slots: r,
1570
+ slots: s,
1561
1571
  welcomeMessage: o,
1562
1572
  suggestedPrompts: i,
1563
1573
  avatar: u,
@@ -2124,8 +2134,8 @@ const Ue = `
2124
2134
 
2125
2135
  /* ── Dislike Panel ── */
2126
2136
  .sa-dislike-panel {
2127
- position: absolute; bottom: 100%; left: 0; right: 0;
2128
- margin-bottom: 6px; padding: 12px;
2137
+ position: absolute; top: 100%; left: 0; right: 0;
2138
+ margin-top: 6px; padding: 12px;
2129
2139
  background: #fff; border: 1px solid var(--sa-border); border-radius: 10px;
2130
2140
  box-shadow: 0 4px 16px rgba(0,0,0,0.08);
2131
2141
  animation: sa-fade-in-up 0.2s cubic-bezier(0.16,1,0.3,1) both;
@@ -3117,17 +3127,17 @@ function qe(a) {
3117
3127
  ].join("; ");
3118
3128
  }
3119
3129
  function Ze(a, t) {
3120
- const s = typeof a == "string" ? document.querySelector(a) : a;
3121
- if (!s)
3130
+ const r = typeof a == "string" ? document.querySelector(a) : a;
3131
+ if (!r)
3122
3132
  throw new Error(`Target element not found: ${a}`);
3123
- const r = document.createElement("div");
3124
- r.setAttribute("data-super-agent-widget", "");
3133
+ const s = document.createElement("div");
3134
+ s.setAttribute("data-super-agent-widget", "");
3125
3135
  const n = qe(t.theme ?? {});
3126
- if (r.setAttribute("style", n), s.appendChild(r), !document.getElementById("sa-widget-styles")) {
3136
+ if (s.setAttribute("style", n), r.appendChild(s), !document.getElementById("sa-widget-styles")) {
3127
3137
  const c = document.createElement("style");
3128
3138
  c.id = "sa-widget-styles", c.textContent = Ue, document.head.appendChild(c);
3129
3139
  }
3130
- let o = le(r), i = !1;
3140
+ let o = le(s), i = !1;
3131
3141
  const l = (c) => {
3132
3142
  o && o.render(
3133
3143
  Y.createElement(Ke, {
@@ -3147,7 +3157,7 @@ function Ze(a, t) {
3147
3157
  i = !1, l(!1);
3148
3158
  },
3149
3159
  destroy() {
3150
- o && (o.unmount(), o = null), r.remove();
3160
+ o && (o.unmount(), o = null), s.remove();
3151
3161
  }
3152
3162
  };
3153
3163
  }
@@ -3161,7 +3171,7 @@ export {
3161
3171
  ue as Header,
3162
3172
  C as Icon,
3163
3173
  $e as InterruptCard,
3164
- He as Message,
3174
+ Fe as Message,
3165
3175
  ve as TextPart,
3166
3176
  we as ThinkingPart,
3167
3177
  re as Thread,
@@ -3169,13 +3179,13 @@ export {
3169
3179
  ye as ToolCallPart,
3170
3180
  Ce as ToolResultPart,
3171
3181
  fe as Trigger,
3172
- je as WelcomeScreen,
3182
+ He as WelcomeScreen,
3173
3183
  Ve as defaultTheme,
3174
3184
  Ze as mount,
3175
3185
  qe as themeToCSSVars,
3176
3186
  ge as useAutoScroll,
3177
3187
  ce as useChat,
3178
- F as useChatContext,
3188
+ W as useChatContext,
3179
3189
  pe as useConversations,
3180
3190
  Ue as widgetStyles
3181
3191
  };