super-agent-sdk 1.0.2 → 1.0.4

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,48 +1,48 @@
1
- import V, { useState as I, useRef as R, useCallback as y, useEffect as A, createContext as Z, useContext as Q } from "react";
2
- import { createRoot as ee } from "react-dom/client";
3
- import { jsx as e, jsxs as g, Fragment as ae } from "react/jsx-runtime";
4
- function te(t) {
5
- const { sdk: a, sessionId: l, onSessionCreated: s, onStreamStart: r, onStreamEnd: i, onError: c, onMessageSend: n } = t, [o, h] = I([]), [p, m] = I("ready"), [v, x] = I(null), d = R(null), u = R(!1), b = R(l);
6
- b.current = l;
7
- const f = y((z) => {
8
- if (u.current) return;
9
- u.current = !0, n == null || n(z);
10
- const O = {
1
+ import J, { useState as z, useRef as $, useCallback as C, useEffect as j, createContext as Q, useContext as ee, useMemo as ae } from "react";
2
+ import { createRoot as te } from "react-dom/client";
3
+ import { jsx as e, jsxs as u, Fragment as re } from "react/jsx-runtime";
4
+ function se(a) {
5
+ const { sdk: t, sessionId: n, onSessionCreated: r, onStreamStart: s, onStreamEnd: c, onError: o, onMessageSend: l } = a, [i, p] = z([]), [f, h] = z("ready"), [w, v] = z(null), m = $(null), g = $(!1), b = $(n);
6
+ b.current = n;
7
+ const d = C((T) => {
8
+ if (g.current) return;
9
+ g.current = !0, l == null || l(T);
10
+ const H = {
11
11
  id: `user_${Date.now()}`,
12
12
  role: "user",
13
- parts: [{ type: "text", content: z }],
13
+ parts: [{ type: "text", content: T }],
14
14
  timestamp: Date.now()
15
- }, S = `assistant_${Date.now()}`, G = {
15
+ }, S = `assistant_${Date.now()}`, A = {
16
16
  id: S,
17
17
  role: "assistant",
18
18
  parts: [],
19
19
  timestamp: Date.now()
20
20
  };
21
- h((T) => [...T, O, G]), m("submitted"), x(null);
22
- const F = (T) => {
23
- let H = "", E = "", D = [], W = !1;
24
- const _ = () => {
21
+ p((I) => [...I, H, A]), h("submitted"), v(null);
22
+ const F = (I) => {
23
+ let _ = "", E = "", D = [], K = !1;
24
+ const q = () => {
25
25
  const k = [...D];
26
- if (H) {
27
- const $ = k.findIndex((L) => L.type === "thinking");
28
- $ >= 0 ? k[$] = { type: "thinking", content: H } : k.unshift({ type: "thinking", content: H });
26
+ if (_) {
27
+ const P = k.findIndex((R) => R.type === "thinking");
28
+ P >= 0 ? k[P] = { type: "thinking", content: _ } : k.unshift({ type: "thinking", content: _ });
29
29
  }
30
30
  if (E) {
31
- const $ = k.findLastIndex((L) => L.type === "text");
32
- $ >= 0 ? k[$] = { type: "text", content: E } : k.push({ type: "text", content: E });
31
+ const P = k.findLastIndex((R) => R.type === "text");
32
+ P >= 0 ? k[P] = { type: "text", content: E } : k.push({ type: "text", content: E });
33
33
  }
34
- h(
35
- ($) => $.map((L) => L.id === S ? { ...L, parts: k } : L)
34
+ p(
35
+ (P) => P.map((R) => R.id === S ? { ...R, parts: k } : R)
36
36
  );
37
37
  };
38
- d.current = a.chat({
39
- sessionId: T,
40
- message: z,
38
+ m.current = t.chat({
39
+ sessionId: I,
40
+ message: T,
41
41
  stream: !0,
42
42
  onMessage: (k) => {
43
- switch (W || (W = !0, m("streaming")), k.type) {
43
+ switch (K || (K = !0, h("streaming")), k.type) {
44
44
  case "thinking":
45
- H += k.content;
45
+ _ += k.content;
46
46
  break;
47
47
  case "ai":
48
48
  E += k.content;
@@ -63,801 +63,1066 @@ function te(t) {
63
63
  content: k.content
64
64
  }), E && (D.push({ type: "text", content: E }), E = "");
65
65
  break;
66
+ case "interrupt":
67
+ k.interrupt && D.push({
68
+ type: "interrupt",
69
+ interrupt: k.interrupt,
70
+ resolved: !1
71
+ });
72
+ break;
66
73
  }
67
- _();
74
+ q();
68
75
  },
69
76
  onDone: (k) => {
70
- (E || D.length > 0 || H) && _(), k.sessionId && k.sessionId !== b.current && (s == null || s(k.sessionId)), i == null || i(k.sessionId || T), m("ready"), u.current = !1, d.current = null;
77
+ (E || D.length > 0 || _) && q(), k.sessionId && k.sessionId !== b.current && (r == null || r(k.sessionId)), c == null || c(k.sessionId || I), h("ready"), g.current = !1, m.current = null;
71
78
  },
72
79
  onError: (k) => {
73
- D.push({ type: "error", content: k.message }), _(), x(k), m("error"), c == null || c(k), u.current = !1, d.current = null;
80
+ D.push({ type: "error", content: k.message }), q(), v(k), h("error"), o == null || o(k), g.current = !1, m.current = null;
74
81
  }
75
- }), r == null || r(T);
82
+ }), s == null || s(I);
76
83
  };
77
- b.current ? F(b.current) : a.createSession().then((T) => {
78
- b.current = T, s == null || s(T), F(T);
79
- }).catch((T) => {
80
- x(T instanceof Error ? T : new Error(String(T))), m("error"), c == null || c(T instanceof Error ? T : new Error(String(T))), u.current = !1;
84
+ b.current ? F(b.current) : t.createSession().then((I) => {
85
+ b.current = I, r == null || r(I), F(I);
86
+ }).catch((I) => {
87
+ v(I instanceof Error ? I : new Error(String(I))), h("error"), o == null || o(I instanceof Error ? I : new Error(String(I))), g.current = !1;
88
+ });
89
+ }, [t, r, s, c, o, l]), y = C(() => {
90
+ var T;
91
+ (T = m.current) == null || T.abort(), m.current = null, h("ready"), g.current = !1;
92
+ }, []), N = C(() => {
93
+ if (g.current) return;
94
+ const T = i.findLastIndex((S) => S.role === "user");
95
+ if (T < 0) return;
96
+ const H = i[T].parts.filter((S) => S.type === "text").map((S) => S.content).join("");
97
+ p((S) => S.slice(0, T)), d(H);
98
+ }, [i, d]), M = C((T, H) => {
99
+ p(
100
+ (A) => A.map((F) => ({
101
+ ...F,
102
+ parts: F.parts.map(
103
+ (I) => I.type === "interrupt" && I.interrupt.interruptId === T ? { ...I, resolved: !0, response: H } : I
104
+ )
105
+ }))
106
+ );
107
+ const S = b.current;
108
+ S && t.respondInterrupt(T, S, H).catch((A) => {
109
+ o == null || o(A instanceof Error ? A : new Error(String(A)));
81
110
  });
82
- }, [a, s, r, i, c, n]), w = y(() => {
83
- var z;
84
- (z = d.current) == null || z.abort(), d.current = null, m("ready"), u.current = !1;
85
- }, []), N = y(() => {
86
- if (u.current) return;
87
- const z = o.findLastIndex((S) => S.role === "user");
88
- if (z < 0) return;
89
- const O = o[z].parts.filter((S) => S.type === "text").map((S) => S.content).join("");
90
- h((S) => S.slice(0, z)), f(O);
91
- }, [o, f]);
92
- return { messages: o, status: p, error: v, sendMessage: f, stop: w, regenerate: N, setMessages: h };
111
+ }, [t, o]);
112
+ return { messages: i, status: f, error: w, sendMessage: d, stop: y, regenerate: N, setMessages: p, respondToInterrupt: M };
93
113
  }
94
- const B = "sa_active_conversation";
95
- function K() {
114
+ const W = "sa_active_conversation";
115
+ function V() {
96
116
  try {
97
- return localStorage.getItem(B);
117
+ return localStorage.getItem(W);
98
118
  } catch {
99
119
  return null;
100
120
  }
101
121
  }
102
- function re(t) {
122
+ function ne(a) {
103
123
  try {
104
- t ? localStorage.setItem(B, t) : localStorage.removeItem(B);
124
+ a ? localStorage.setItem(W, a) : localStorage.removeItem(W);
105
125
  } catch {
106
126
  }
107
127
  }
108
- function se(t) {
109
- const { sdk: a, onConversationChange: l } = t, [s, r] = I([]), [i, c] = I(
110
- () => K()
111
- ), [n, o] = I(!1), h = R(!0);
112
- A(() => () => {
113
- h.current = !1;
128
+ function ie(a) {
129
+ const { sdk: t, onConversationChange: n } = a, [r, s] = z([]), [c, o] = z(
130
+ () => V()
131
+ ), [l, i] = z(!1), p = $(!0);
132
+ j(() => () => {
133
+ p.current = !1;
114
134
  }, []);
115
- const p = y((f) => {
116
- c(f), re(f), f && (l == null || l(f));
117
- }, [l]), m = y(async () => {
118
- o(!0);
135
+ const f = C((d) => {
136
+ o(d), ne(d), d && (n == null || n(d));
137
+ }, [n]), h = C(async () => {
138
+ i(!0);
119
139
  try {
120
- const f = await a.listConversations({ page: 1, size: 100 });
121
- if (!h.current) return;
122
- r(f.items);
123
- const w = K();
124
- w && !f.items.find((N) => N.sessionId === w) && p(null);
140
+ const d = await t.listConversations({ page: 1, size: 100 });
141
+ if (!p.current) return;
142
+ s(d.items);
143
+ const y = V();
144
+ y && !d.items.find((N) => N.sessionId === y) && f(null);
125
145
  } catch {
126
146
  } finally {
127
- h.current && o(!1);
147
+ p.current && i(!1);
128
148
  }
129
- }, [a, p]), v = y(async (f) => (p(f), await a.getMessages(f)), [a, p]), x = y(() => {
130
- p(null);
131
- }, [p]), d = y(async (f) => {
132
- await a.deleteConversation(f), r((w) => w.filter((N) => N.sessionId !== f)), i === f && p(null);
133
- }, [a, i, p]), u = y(async (f, w) => {
134
- await a.renameConversation(f, w), r(
135
- (N) => N.map((z) => z.sessionId === f ? { ...z, title: w } : z)
149
+ }, [t, f]), w = C(async (d) => (f(d), await t.getMessages(d)), [t, f]), v = C(() => {
150
+ f(null);
151
+ }, [f]), m = C(async (d) => {
152
+ await t.deleteConversation(d), s((y) => y.filter((N) => N.sessionId !== d)), c === d && f(null);
153
+ }, [t, c, f]), g = C(async (d, y) => {
154
+ await t.renameConversation(d, y), s(
155
+ (N) => N.map((M) => M.sessionId === d ? { ...M, title: y } : M)
136
156
  );
137
- }, [a]), { enabled: b = !0 } = t;
138
- return A(() => {
139
- b && m();
140
- }, [b, m]), {
141
- conversations: s,
142
- activeConversationId: i,
143
- loading: n,
144
- loadConversations: m,
145
- switchConversation: v,
146
- newConversation: x,
147
- deleteConversation: d,
148
- renameConversation: u,
149
- setActiveConversationId: p
157
+ }, [t]), { enabled: b = !0 } = a;
158
+ return j(() => {
159
+ b && h();
160
+ }, [b, h]), {
161
+ conversations: r,
162
+ activeConversationId: c,
163
+ loading: l,
164
+ loadConversations: h,
165
+ switchConversation: w,
166
+ newConversation: v,
167
+ deleteConversation: m,
168
+ renameConversation: g,
169
+ setActiveConversationId: f
150
170
  };
151
171
  }
152
- const Y = Z(null);
153
- function P() {
154
- const t = Q(Y);
155
- if (!t) throw new Error("useChatContext must be used within ChatProvider");
156
- return t;
172
+ const X = Q(null);
173
+ function O() {
174
+ const a = ee(X);
175
+ if (!a) throw new Error("useChatContext must be used within ChatProvider");
176
+ return a;
157
177
  }
158
- function U({ sdk: t, hooks: a, children: l }) {
159
- const [s, r] = I(!1), [i, c] = I(!1);
160
- A(() => {
161
- t.getToken().then(() => {
162
- c(!0);
178
+ function U({ sdk: a, hooks: t, children: n }) {
179
+ const [r, s] = z(!1), [c, o] = z(!1);
180
+ j(() => {
181
+ a.getToken().then(() => {
182
+ o(!0);
163
183
  }).catch(() => {
164
- c(!0);
184
+ o(!0);
165
185
  });
166
- }, [t]);
167
- const n = se({
168
- sdk: t,
169
- onConversationChange: a == null ? void 0 : a.onConversationChange,
170
- enabled: i
171
- }), o = te({
172
- sdk: t,
173
- sessionId: n.activeConversationId,
174
- onSessionCreated: (d) => {
175
- n.setActiveConversationId(d), n.loadConversations();
186
+ }, [a]);
187
+ const l = ie({
188
+ sdk: a,
189
+ onConversationChange: t == null ? void 0 : t.onConversationChange,
190
+ enabled: c
191
+ }), i = se({
192
+ sdk: a,
193
+ sessionId: l.activeConversationId,
194
+ onSessionCreated: (m) => {
195
+ l.setActiveConversationId(m), l.loadConversations();
176
196
  },
177
- onStreamStart: a == null ? void 0 : a.onStreamStart,
178
- onStreamEnd: (d) => {
179
- var u;
180
- (u = a == null ? void 0 : a.onStreamEnd) == null || u.call(a, d), n.loadConversations();
197
+ onStreamStart: t == null ? void 0 : t.onStreamStart,
198
+ onStreamEnd: (m) => {
199
+ var g;
200
+ (g = t == null ? void 0 : t.onStreamEnd) == null || g.call(t, m), l.loadConversations();
181
201
  },
182
- onError: a == null ? void 0 : a.onError,
183
- onMessageSend: a == null ? void 0 : a.onMessageSend
184
- }), h = y(async (d) => {
185
- const u = await n.switchConversation(d);
186
- o.setMessages(u), r(!1);
187
- }, [n, o]), p = y(() => {
188
- n.newConversation(), o.setMessages([]), r(!1);
189
- }, [n, o]), m = y(async (d) => {
190
- await n.deleteConversation(d), n.activeConversationId === d && o.setMessages([]);
191
- }, [n, o]);
192
- A(() => {
193
- n.activeConversationId && o.messages.length === 0 && t.getMessages(n.activeConversationId).then((d) => {
194
- o.setMessages(d);
202
+ onError: t == null ? void 0 : t.onError,
203
+ onMessageSend: t == null ? void 0 : t.onMessageSend
204
+ }), p = C(async (m) => {
205
+ const g = await l.switchConversation(m);
206
+ i.setMessages(g), s(!1);
207
+ }, [l, i]), f = C(() => {
208
+ l.newConversation(), i.setMessages([]), s(!1);
209
+ }, [l, i]), h = C(async (m) => {
210
+ await l.deleteConversation(m), l.activeConversationId === m && i.setMessages([]);
211
+ }, [l, i]);
212
+ j(() => {
213
+ l.activeConversationId && i.messages.length === 0 && a.getMessages(l.activeConversationId).then((m) => {
214
+ i.setMessages(m);
195
215
  }).catch(() => {
196
216
  });
197
217
  }, []);
198
- const v = y(() => {
199
- r((d) => !d);
200
- }, []), x = {
201
- status: o.status,
202
- error: o.error,
203
- messages: o.messages,
204
- conversations: n.conversations,
205
- activeConversationId: n.activeConversationId,
206
- isThreadListOpen: s,
207
- sendMessage: o.sendMessage,
208
- stop: o.stop,
209
- regenerate: o.regenerate,
210
- switchConversation: h,
211
- newConversation: p,
212
- deleteConversation: m,
213
- renameConversation: n.renameConversation,
214
- toggleThreadList: v,
215
- feedback: (d, u) => {
216
- t.feedback(d, u);
217
- }
218
+ const w = C(() => {
219
+ s((m) => !m);
220
+ }, []), v = {
221
+ status: i.status,
222
+ error: i.error,
223
+ messages: i.messages,
224
+ conversations: l.conversations,
225
+ activeConversationId: l.activeConversationId,
226
+ isThreadListOpen: r,
227
+ sendMessage: i.sendMessage,
228
+ stop: i.stop,
229
+ regenerate: i.regenerate,
230
+ switchConversation: p,
231
+ newConversation: f,
232
+ deleteConversation: h,
233
+ renameConversation: l.renameConversation,
234
+ toggleThreadList: w,
235
+ feedback: (m, g) => {
236
+ a.feedback(m, g);
237
+ },
238
+ respondToInterrupt: i.respondToInterrupt
218
239
  };
219
- return /* @__PURE__ */ e(Y.Provider, { value: x, children: l });
240
+ return /* @__PURE__ */ e(X.Provider, { value: v, children: n });
220
241
  }
221
- function C({ name: t, size: a = 16, color: l = "currentColor", className: s, style: r }) {
242
+ function x({ name: a, size: t = 16, color: n = "currentColor", className: r, style: s }) {
222
243
  return /* @__PURE__ */ e(
223
244
  "svg",
224
245
  {
225
- className: s,
226
- style: { width: a, height: a, fill: l, verticalAlign: "middle", ...r },
246
+ className: r,
247
+ style: { width: t, height: t, fill: n, verticalAlign: "middle", ...s },
227
248
  "aria-hidden": "true",
228
- children: /* @__PURE__ */ e("use", { href: `#icon-${t}` })
249
+ children: /* @__PURE__ */ e("use", { href: `#icon-${a}` })
229
250
  }
230
251
  );
231
252
  }
232
- function ne({ isOpen: t, onClick: a }) {
233
- return /* @__PURE__ */ e("button", { className: `sa-trigger ${t ? "sa-trigger-open" : ""}`, onClick: a, children: t ? /* @__PURE__ */ e(C, { name: "x", size: 24, color: "#fff" }) : /* @__PURE__ */ e(C, { name: "message-square", size: 24, color: "#fff" }) });
253
+ function oe({ isOpen: a, onClick: t }) {
254
+ return /* @__PURE__ */ e("button", { className: `sa-trigger ${a ? "sa-trigger-open" : ""}`, onClick: t, children: a ? /* @__PURE__ */ e(x, { name: "x", size: 24, color: "#fff" }) : /* @__PURE__ */ e(x, { name: "message-square", size: 24, color: "#fff" }) });
234
255
  }
235
- function ie({ title: t, onClose: a, onToggleThreadList: l, showClose: s = !0 }) {
236
- return /* @__PURE__ */ g("div", { className: "sa-header", children: [
237
- /* @__PURE__ */ g("div", { className: "sa-header-left", children: [
256
+ function le({ title: a, onClose: t, onToggleThreadList: n, showClose: r = !0 }) {
257
+ return /* @__PURE__ */ u("div", { className: "sa-header", children: [
258
+ /* @__PURE__ */ u("div", { className: "sa-header-left", children: [
238
259
  /* @__PURE__ */ e("div", { className: "sa-header-avatar", children: "A" }),
239
- /* @__PURE__ */ g("div", { className: "sa-header-info", children: [
240
- /* @__PURE__ */ e("div", { className: "sa-header-title", children: t }),
260
+ /* @__PURE__ */ u("div", { className: "sa-header-info", children: [
261
+ /* @__PURE__ */ e("div", { className: "sa-header-title", children: a }),
241
262
  /* @__PURE__ */ e("div", { className: "sa-header-status", children: "● Online" })
242
263
  ] })
243
264
  ] }),
244
- /* @__PURE__ */ g("div", { className: "sa-header-actions", children: [
245
- /* @__PURE__ */ e("button", { className: "sa-header-btn", onClick: l, title: "会话列表", children: /* @__PURE__ */ e(C, { name: "menu", size: 16 }) }),
246
- s && /* @__PURE__ */ e("button", { className: "sa-header-btn", onClick: a, title: "关闭", children: /* @__PURE__ */ e(C, { name: "x", size: 16 }) })
265
+ /* @__PURE__ */ u("div", { className: "sa-header-actions", children: [
266
+ /* @__PURE__ */ e("button", { className: "sa-header-btn", onClick: n, title: "会话列表", children: /* @__PURE__ */ e(x, { name: "menu", size: 16 }) }),
267
+ r && /* @__PURE__ */ e("button", { className: "sa-header-btn", onClick: t, title: "关闭", children: /* @__PURE__ */ e(x, { name: "x", size: 16 }) })
247
268
  ] })
248
269
  ] });
249
270
  }
250
- function oe() {
271
+ function ce(a) {
272
+ const t = /* @__PURE__ */ new Date(), n = new Date(t.getFullYear(), t.getMonth(), t.getDate()).getTime(), r = n - 6 * 864e5, s = [], c = [], o = [];
273
+ for (const i of a) {
274
+ const p = new Date(i.updateTime).getTime();
275
+ p >= n ? s.push(i) : p >= r ? c.push(i) : o.push(i);
276
+ }
277
+ const l = [];
278
+ return s.length && l.push({ label: "今天", items: s }), c.length && l.push({ label: "最近 7 天", items: c }), o.length && l.push({ label: "更早", items: o }), l;
279
+ }
280
+ function de() {
251
281
  const {
252
- conversations: t,
253
- activeConversationId: a,
254
- switchConversation: l,
255
- newConversation: s,
256
- deleteConversation: r,
257
- renameConversation: i,
258
- isThreadListOpen: c,
259
- toggleThreadList: n
260
- } = P(), [o, h] = I(null), [p, m] = I(""), v = y((d, u) => {
261
- h(d), m(u ?? "");
262
- }, []), x = y((d) => {
263
- p.trim() && i(d, p.trim()), h(null);
264
- }, [p, i]);
265
- return c ? /* @__PURE__ */ g(ae, { children: [
266
- /* @__PURE__ */ e("div", { className: "sa-thread-list-overlay", onClick: n }),
267
- /* @__PURE__ */ g("div", { className: "sa-thread-list", children: [
268
- /* @__PURE__ */ g("div", { className: "sa-thread-list-header", children: [
269
- /* @__PURE__ */ e("span", { children: "会话列表" }),
270
- /* @__PURE__ */ g("button", { className: "sa-thread-list-new", onClick: s, children: [
271
- /* @__PURE__ */ e(C, { name: "plus", size: 14 }),
282
+ conversations: a,
283
+ activeConversationId: t,
284
+ switchConversation: n,
285
+ newConversation: r,
286
+ deleteConversation: s,
287
+ renameConversation: c,
288
+ isThreadListOpen: o,
289
+ toggleThreadList: l
290
+ } = O(), [i, p] = z(null), [f, h] = z(""), w = C((g, b) => {
291
+ p(g), h(b ?? "");
292
+ }, []), v = C((g) => {
293
+ f.trim() && c(g, f.trim()), p(null);
294
+ }, [f, c]), m = ae(() => ce(a), [a]);
295
+ return o ? /* @__PURE__ */ u(re, { children: [
296
+ /* @__PURE__ */ e("div", { className: "sa-thread-list-overlay", onClick: l }),
297
+ /* @__PURE__ */ u("div", { className: "sa-thread-list", children: [
298
+ /* @__PURE__ */ u("div", { className: "sa-thread-list-header", children: [
299
+ /* @__PURE__ */ e("span", { className: "sa-thread-list-title", children: "会话记录" }),
300
+ /* @__PURE__ */ u("button", { className: "sa-thread-list-new", onClick: r, children: [
301
+ /* @__PURE__ */ e(x, { name: "plus", size: 14 }),
272
302
  " 新会话"
273
303
  ] })
274
304
  ] }),
275
- /* @__PURE__ */ g("div", { className: "sa-thread-list-items", children: [
276
- t.length === 0 && /* @__PURE__ */ e("div", { className: "sa-thread-list-empty", children: "暂无会话" }),
277
- t.map((d) => /* @__PURE__ */ g(
278
- "div",
279
- {
280
- className: `sa-thread-item ${d.sessionId === a ? "active" : ""}`,
281
- onClick: () => l(d.sessionId),
282
- children: [
283
- o === d.sessionId ? /* @__PURE__ */ e(
284
- "input",
285
- {
286
- className: "sa-thread-item-edit",
287
- value: p,
288
- onChange: (u) => m(u.target.value),
289
- onBlur: () => x(d.sessionId),
290
- onKeyDown: (u) => {
291
- u.key === "Enter" && x(d.sessionId), u.key === "Escape" && h(null);
292
- },
293
- onClick: (u) => u.stopPropagation(),
294
- autoFocus: !0
295
- }
296
- ) : /* @__PURE__ */ e(
297
- "span",
298
- {
299
- className: "sa-thread-item-title",
300
- onDoubleClick: (u) => {
301
- u.stopPropagation(), v(d.sessionId, d.title);
302
- },
303
- children: d.title || "新会话"
304
- }
305
- ),
306
- /* @__PURE__ */ e(
307
- "button",
308
- {
309
- className: "sa-thread-item-delete",
310
- onClick: (u) => {
311
- u.stopPropagation(), r(d.sessionId);
312
- },
313
- title: "删除",
314
- children: /* @__PURE__ */ e(C, { name: "trash2", size: 14 })
315
- }
316
- )
317
- ]
318
- },
319
- d.sessionId
320
- ))
305
+ /* @__PURE__ */ u("div", { className: "sa-thread-list-items", children: [
306
+ a.length === 0 && /* @__PURE__ */ e("div", { className: "sa-thread-list-empty", children: "暂无会话" }),
307
+ m.map((g) => /* @__PURE__ */ u("div", { className: "sa-thread-group", children: [
308
+ /* @__PURE__ */ e("div", { className: "sa-thread-group-label", children: g.label }),
309
+ g.items.map((b) => /* @__PURE__ */ u(
310
+ "div",
311
+ {
312
+ className: `sa-thread-item ${b.sessionId === t ? "active" : ""}`,
313
+ onClick: () => n(b.sessionId),
314
+ children: [
315
+ i === b.sessionId ? /* @__PURE__ */ e(
316
+ "input",
317
+ {
318
+ className: "sa-thread-item-edit",
319
+ value: f,
320
+ onChange: (d) => h(d.target.value),
321
+ onBlur: () => v(b.sessionId),
322
+ onKeyDown: (d) => {
323
+ d.key === "Enter" && v(b.sessionId), d.key === "Escape" && p(null);
324
+ },
325
+ onClick: (d) => d.stopPropagation(),
326
+ autoFocus: !0
327
+ }
328
+ ) : /* @__PURE__ */ e(
329
+ "span",
330
+ {
331
+ className: "sa-thread-item-title",
332
+ onDoubleClick: (d) => {
333
+ d.stopPropagation(), w(b.sessionId, b.title);
334
+ },
335
+ children: b.title || "新会话"
336
+ }
337
+ ),
338
+ /* @__PURE__ */ e(
339
+ "button",
340
+ {
341
+ className: "sa-thread-item-delete",
342
+ onClick: (d) => {
343
+ d.stopPropagation(), s(b.sessionId);
344
+ },
345
+ title: "删除",
346
+ children: /* @__PURE__ */ e(x, { name: "trash2", size: 14 })
347
+ }
348
+ )
349
+ ]
350
+ },
351
+ b.sessionId
352
+ ))
353
+ ] }, g.label))
321
354
  ] })
322
355
  ] })
323
356
  ] }) : null;
324
357
  }
325
- function le(t) {
326
- const a = R(null), l = R(!1), s = R(0), r = y(() => {
327
- const c = a.current;
328
- if (!c) return;
329
- const { scrollTop: n, scrollHeight: o, clientHeight: h } = c, p = o - n - h < 40;
330
- n < s.current && !p && (l.current = !0), p && (l.current = !1), s.current = n;
358
+ function pe(a) {
359
+ const t = $(null), n = $(!1), r = $(0), s = C(() => {
360
+ const o = t.current;
361
+ if (!o) return;
362
+ const { scrollTop: l, scrollHeight: i, clientHeight: p } = o, f = i - l - p < 40;
363
+ l < r.current && !f && (n.current = !0), f && (n.current = !1), r.current = l;
331
364
  }, []);
332
- A(() => {
333
- const c = a.current;
334
- if (c)
335
- return c.addEventListener("scroll", r, { passive: !0 }), () => c.removeEventListener("scroll", r);
336
- }, [r]), A(() => {
337
- if (l.current) return;
338
- const c = a.current;
339
- c && requestAnimationFrame(() => {
340
- c.scrollTop = c.scrollHeight;
365
+ j(() => {
366
+ const o = t.current;
367
+ if (o)
368
+ return o.addEventListener("scroll", s, { passive: !0 }), () => o.removeEventListener("scroll", s);
369
+ }, [s]), j(() => {
370
+ if (n.current) return;
371
+ const o = t.current;
372
+ o && requestAnimationFrame(() => {
373
+ o.scrollTop = o.scrollHeight;
341
374
  });
342
- }, t);
343
- const i = y(() => {
344
- l.current = !1;
345
- const c = a.current;
346
- c && (c.scrollTop = c.scrollHeight);
375
+ }, a);
376
+ const c = C(() => {
377
+ n.current = !1;
378
+ const o = t.current;
379
+ o && (o.scrollTop = o.scrollHeight);
347
380
  }, []);
348
- return { containerRef: a, scrollToBottom: i };
381
+ return { containerRef: t, scrollToBottom: c };
349
382
  }
350
- function M(t) {
351
- return t.value++;
383
+ function L(a) {
384
+ return a.value++;
352
385
  }
353
- function j(t, a) {
354
- const l = [], s = [], r = () => {
355
- s.length > 0 && (l.push(s.join("")), s.length = 0);
386
+ function B(a, t) {
387
+ const n = [], r = [], s = () => {
388
+ r.length > 0 && (n.push(r.join("")), r.length = 0);
356
389
  };
357
- let i = 0;
358
- for (; i < t.length; ) {
359
- const c = t[i];
360
- if (c === "`") {
361
- const n = t.indexOf("`", i + 1);
362
- if (n !== -1) {
363
- r(), l.push(
364
- /* @__PURE__ */ e("code", { className: "sa-inline-code", children: t.slice(i + 1, n) }, M(a))
365
- ), i = n + 1;
390
+ let c = 0;
391
+ for (; c < a.length; ) {
392
+ const o = a[c];
393
+ if (o === "`") {
394
+ const l = a.indexOf("`", c + 1);
395
+ if (l !== -1) {
396
+ s(), n.push(
397
+ /* @__PURE__ */ e("code", { className: "sa-inline-code", children: a.slice(c + 1, l) }, L(t))
398
+ ), c = l + 1;
366
399
  continue;
367
400
  }
368
- } else if (c === "*" && t[i + 1] === "*") {
369
- const n = t.indexOf("**", i + 2);
370
- if (n !== -1) {
371
- r(), l.push(
372
- /* @__PURE__ */ e("strong", { children: j(t.slice(i + 2, n), a) }, M(a))
373
- ), i = n + 2;
401
+ } else if (o === "*" && a[c + 1] === "*") {
402
+ const l = a.indexOf("**", c + 2);
403
+ if (l !== -1) {
404
+ s(), n.push(
405
+ /* @__PURE__ */ e("strong", { children: B(a.slice(c + 2, l), t) }, L(t))
406
+ ), c = l + 2;
374
407
  continue;
375
408
  }
376
- } else if (c === "*") {
377
- const n = t.indexOf("*", i + 1);
378
- if (n !== -1) {
379
- r(), l.push(
380
- /* @__PURE__ */ e("em", { children: j(t.slice(i + 1, n), a) }, M(a))
381
- ), i = n + 1;
409
+ } else if (o === "*") {
410
+ const l = a.indexOf("*", c + 1);
411
+ if (l !== -1) {
412
+ s(), n.push(
413
+ /* @__PURE__ */ e("em", { children: B(a.slice(c + 1, l), t) }, L(t))
414
+ ), c = l + 1;
382
415
  continue;
383
416
  }
384
- } else if (c === "[") {
385
- const n = t.indexOf("]", i + 1);
386
- if (n !== -1 && t[n + 1] === "(") {
387
- const o = t.indexOf(")", n + 2);
388
- if (o !== -1) {
389
- const h = t.slice(i + 1, n), p = t.slice(n + 2, o);
390
- r(), l.push(
417
+ } else if (o === "[") {
418
+ const l = a.indexOf("]", c + 1);
419
+ if (l !== -1 && a[l + 1] === "(") {
420
+ const i = a.indexOf(")", l + 2);
421
+ if (i !== -1) {
422
+ const p = a.slice(c + 1, l), f = a.slice(l + 2, i);
423
+ s(), n.push(
391
424
  /* @__PURE__ */ e(
392
425
  "a",
393
426
  {
394
- href: p,
427
+ href: f,
395
428
  target: "_blank",
396
429
  rel: "noreferrer",
397
- children: j(h, a)
430
+ children: B(p, t)
398
431
  },
399
- M(a)
432
+ L(t)
400
433
  )
401
- ), i = o + 1;
434
+ ), c = i + 1;
402
435
  continue;
403
436
  }
404
437
  }
405
438
  }
406
- s.push(c), i++;
439
+ r.push(o), c++;
407
440
  }
408
- return r(), l;
441
+ return s(), n;
409
442
  }
410
- function ce(t, a) {
411
- const l = [], s = t.split(`
443
+ function ue(a, t) {
444
+ const n = [], r = a.split(`
412
445
  `);
413
- let r = 0;
414
- const i = (o) => o.trim() === "", c = (o) => /^#{1,6}\s+\S/.test(o.trim()), n = (o) => /^(?:[-*+]|\d+[.)])\s+\S/.test(o.trim());
415
- for (; r < s.length; ) {
416
- const o = s[r], h = o.trim();
417
- if (i(o)) {
418
- r++;
446
+ let s = 0;
447
+ const c = (i) => i.trim() === "", o = (i) => /^#{1,6}\s+\S/.test(i.trim()), l = (i) => /^(?:[-*+]|\d+[.)])\s+\S/.test(i.trim());
448
+ for (; s < r.length; ) {
449
+ const i = r[s], p = i.trim();
450
+ if (c(i)) {
451
+ s++;
419
452
  continue;
420
453
  }
421
- if (c(o)) {
422
- const m = h.match(/^(#{1,6})\s+(.*)$/);
423
- if (m) {
424
- const x = `h${Math.min(m[1].length, 6)}`;
425
- l.push(
426
- V.createElement(
427
- x,
428
- { key: M(a) },
429
- j(m[2], a)
454
+ if (o(i)) {
455
+ const h = p.match(/^(#{1,6})\s+(.*)$/);
456
+ if (h) {
457
+ const v = `h${Math.min(h[1].length, 6)}`;
458
+ n.push(
459
+ J.createElement(
460
+ v,
461
+ { key: L(t) },
462
+ B(h[2], t)
430
463
  )
431
464
  );
432
465
  }
433
- r++;
466
+ s++;
434
467
  continue;
435
468
  }
436
- if (n(o)) {
437
- const m = /^\d+[.)]/.test(h), v = [];
438
- for (; r < s.length && n(s[r]); ) {
439
- const x = s[r].trim().match(/^(?:[-*+]|\d+[.)])\s+(.*)$/);
440
- x && v.push(
441
- /* @__PURE__ */ e("li", { children: j(x[1], a) }, M(a))
442
- ), r++;
469
+ if (l(i)) {
470
+ const h = /^\d+[.)]/.test(p), w = [];
471
+ for (; s < r.length && l(r[s]); ) {
472
+ const v = r[s].trim().match(/^(?:[-*+]|\d+[.)])\s+(.*)$/);
473
+ v && w.push(
474
+ /* @__PURE__ */ e("li", { children: B(v[1], t) }, L(t))
475
+ ), s++;
443
476
  }
444
- l.push(
445
- m ? /* @__PURE__ */ e("ol", { className: "sa-list", children: v }, M(a)) : /* @__PURE__ */ e("ul", { className: "sa-list", children: v }, M(a))
477
+ n.push(
478
+ h ? /* @__PURE__ */ e("ol", { className: "sa-list", children: w }, L(t)) : /* @__PURE__ */ e("ul", { className: "sa-list", children: w }, L(t))
446
479
  );
447
480
  continue;
448
481
  }
449
- const p = [];
450
- for (; r < s.length && !i(s[r]) && !c(s[r]) && !n(s[r]); )
451
- p.push(s[r]), r++;
452
- l.push(
453
- /* @__PURE__ */ e("p", { className: "sa-text-paragraph", children: j(p.join(" "), a) }, M(a))
482
+ const f = [];
483
+ for (; s < r.length && !c(r[s]) && !o(r[s]) && !l(r[s]); )
484
+ f.push(r[s]), s++;
485
+ n.push(
486
+ /* @__PURE__ */ e("p", { className: "sa-text-paragraph", children: B(f.join(" "), t) }, L(t))
454
487
  );
455
488
  }
456
- return l;
489
+ return n;
457
490
  }
458
- function de(t) {
459
- const a = { value: 0 }, l = [], s = t.split("```");
460
- for (let r = 0; r < s.length; r++)
461
- if (r % 2 === 0)
462
- l.push(...ce(s[r], a));
463
- else if (s[r].trim() !== "") {
464
- let i = s[r].replace(/^\r?\n/, "");
465
- i = i.replace(/^[a-zA-Z0-9_+#.-]+\r?\n/, ""), i = i.replace(/\r?\n$/, ""), l.push(
466
- /* @__PURE__ */ e("pre", { className: "sa-code-block", children: /* @__PURE__ */ e("code", { children: i }) }, M(a))
491
+ function fe(a) {
492
+ const t = { value: 0 }, n = [], r = a.split("```");
493
+ for (let s = 0; s < r.length; s++)
494
+ if (s % 2 === 0)
495
+ n.push(...ue(r[s], t));
496
+ else if (r[s].trim() !== "") {
497
+ let c = r[s].replace(/^\r?\n/, "");
498
+ c = c.replace(/^[a-zA-Z0-9_+#.-]+\r?\n/, ""), c = c.replace(/\r?\n$/, ""), n.push(
499
+ /* @__PURE__ */ e("pre", { className: "sa-code-block", children: /* @__PURE__ */ e("code", { children: c }) }, L(t))
467
500
  );
468
501
  }
469
- return l;
502
+ return n;
470
503
  }
471
- function pe({ content: t }) {
472
- return /* @__PURE__ */ e("div", { className: "sa-text-part", children: de(t) });
504
+ function me({ content: a }) {
505
+ return /* @__PURE__ */ e("div", { className: "sa-text-part", children: fe(a) });
473
506
  }
474
- function fe({ content: t }) {
475
- const [a, l] = I(!1);
476
- return /* @__PURE__ */ g("div", { className: "sa-thinking-part", onClick: () => l(!a), children: [
477
- /* @__PURE__ */ g("div", { className: "sa-thinking-header", children: [
478
- /* @__PURE__ */ e("span", { className: "sa-thinking-icon", children: /* @__PURE__ */ e(C, { name: "brain", size: 14 }) }),
507
+ function he({ content: a }) {
508
+ const [t, n] = z(!1);
509
+ return /* @__PURE__ */ u("div", { className: "sa-thinking-part", onClick: () => n(!t), children: [
510
+ /* @__PURE__ */ u("div", { className: "sa-thinking-header", children: [
511
+ /* @__PURE__ */ e("span", { className: "sa-thinking-icon", children: /* @__PURE__ */ e(x, { name: "brain", size: 14 }) }),
479
512
  /* @__PURE__ */ e("span", { className: "sa-thinking-label", children: "思考过程" }),
480
- /* @__PURE__ */ e("span", { className: `sa-thinking-arrow ${a ? "expanded" : ""}`, children: /* @__PURE__ */ e(C, { name: "chevron-right", size: 12 }) })
513
+ /* @__PURE__ */ e("span", { className: `sa-thinking-arrow ${t ? "expanded" : ""}`, children: /* @__PURE__ */ e(x, { name: "chevron-right", size: 12 }) })
481
514
  ] }),
482
- a && /* @__PURE__ */ e("div", { className: "sa-thinking-content", children: t })
515
+ t && /* @__PURE__ */ e("div", { className: "sa-thinking-content", children: a })
483
516
  ] });
484
517
  }
485
- function he({ toolName: t, toolCallId: a, args: l }) {
486
- const [s, r] = I(!1);
487
- let i = l;
518
+ function ge({ toolName: a, toolCallId: t, args: n }) {
519
+ const [r, s] = z(!1);
520
+ let c = n;
488
521
  try {
489
- i = JSON.stringify(JSON.parse(l), null, 2);
522
+ c = JSON.stringify(JSON.parse(n), null, 2);
490
523
  } catch {
491
524
  }
492
- return /* @__PURE__ */ g("div", { className: "sa-tool-call-part", children: [
493
- /* @__PURE__ */ g("div", { className: "sa-tool-call-header", onClick: () => r(!s), children: [
494
- /* @__PURE__ */ e("span", { className: "sa-tool-icon", children: /* @__PURE__ */ e(C, { name: "zap", size: 14 }) }),
495
- /* @__PURE__ */ g("span", { className: "sa-tool-name", children: [
525
+ return /* @__PURE__ */ u("div", { className: "sa-tool-call-part", children: [
526
+ /* @__PURE__ */ u("div", { className: "sa-tool-call-header", onClick: () => s(!r), children: [
527
+ /* @__PURE__ */ e("span", { className: "sa-tool-icon", children: /* @__PURE__ */ e(x, { name: "zap", size: 14 }) }),
528
+ /* @__PURE__ */ u("span", { className: "sa-tool-name", children: [
496
529
  "调用工具: ",
497
- t
530
+ a
531
+ ] }),
532
+ /* @__PURE__ */ e("span", { className: `sa-thinking-arrow ${r ? "expanded" : ""}`, children: /* @__PURE__ */ e(x, { name: "chevron-right", size: 12 }) })
533
+ ] }),
534
+ r && /* @__PURE__ */ e("pre", { className: "sa-tool-args", children: c })
535
+ ] });
536
+ }
537
+ function xe({ toolName: a, toolCallId: t, content: n }) {
538
+ return /* @__PURE__ */ u("div", { className: "sa-tool-result-part", children: [
539
+ /* @__PURE__ */ u("div", { className: "sa-tool-result-header", children: [
540
+ /* @__PURE__ */ e("span", { className: "sa-tool-icon", children: /* @__PURE__ */ e(x, { name: "circle-check", size: 14, color: "#10b981" }) }),
541
+ /* @__PURE__ */ e("span", { className: "sa-tool-result-label", children: a || "工具返回" })
542
+ ] }),
543
+ /* @__PURE__ */ e("div", { className: "sa-tool-result-content", children: n })
544
+ ] });
545
+ }
546
+ function be({ content: a, onRetry: t }) {
547
+ return /* @__PURE__ */ u("div", { className: "sa-error-part", children: [
548
+ /* @__PURE__ */ u("div", { className: "sa-error-content", children: [
549
+ /* @__PURE__ */ e("span", { className: "sa-error-icon", children: /* @__PURE__ */ e(x, { name: "triangle-alert", size: 14 }) }),
550
+ /* @__PURE__ */ e("span", { children: a })
551
+ ] }),
552
+ t && /* @__PURE__ */ e("button", { className: "sa-error-retry", onClick: t, children: "重试" })
553
+ ] });
554
+ }
555
+ function ve({ interrupt: a, onRespond: t }) {
556
+ var c, o;
557
+ const n = a.options, r = (typeof (n == null ? void 0 : n[0]) == "string" ? n[0] : (c = n == null ? void 0 : n[0]) == null ? void 0 : c.label) || "确认", s = (typeof (n == null ? void 0 : n[1]) == "string" ? n[1] : (o = n == null ? void 0 : n[1]) == null ? void 0 : o.label) || "取消";
558
+ return /* @__PURE__ */ u("div", { className: "sa-interrupt-card", children: [
559
+ /* @__PURE__ */ u("div", { className: "sa-interrupt-content", children: [
560
+ /* @__PURE__ */ e(x, { name: "circle-alert", size: 16, color: "#f59e0b" }),
561
+ /* @__PURE__ */ e("span", { children: a.content })
562
+ ] }),
563
+ /* @__PURE__ */ u("div", { className: "sa-interrupt-actions", children: [
564
+ /* @__PURE__ */ u("button", { className: "sa-interrupt-btn sa-interrupt-btn-primary", onClick: () => t({ action: "confirm" }), children: [
565
+ /* @__PURE__ */ e(x, { name: "check", size: 14 }),
566
+ " ",
567
+ r
498
568
  ] }),
499
- /* @__PURE__ */ e("span", { className: `sa-thinking-arrow ${s ? "expanded" : ""}`, children: /* @__PURE__ */ e(C, { name: "chevron-right", size: 12 }) })
569
+ /* @__PURE__ */ u("button", { className: "sa-interrupt-btn sa-interrupt-btn-secondary", onClick: () => t({ action: "cancel" }), children: [
570
+ /* @__PURE__ */ e(x, { name: "x", size: 14 }),
571
+ " ",
572
+ s
573
+ ] })
574
+ ] })
575
+ ] });
576
+ }
577
+ function ye(a) {
578
+ return typeof a == "string" ? { value: a, label: a } : a;
579
+ }
580
+ function we({ interrupt: a, onRespond: t }) {
581
+ const n = (a.options ?? []).map(ye);
582
+ return /* @__PURE__ */ u("div", { className: "sa-interrupt-card", children: [
583
+ /* @__PURE__ */ u("div", { className: "sa-interrupt-content", children: [
584
+ /* @__PURE__ */ e(x, { name: "list", size: 16, color: "#6366f1" }),
585
+ /* @__PURE__ */ e("span", { children: a.content })
500
586
  ] }),
501
- s && /* @__PURE__ */ e("pre", { className: "sa-tool-args", children: i })
587
+ /* @__PURE__ */ e("div", { className: "sa-interrupt-options", children: n.map((r) => /* @__PURE__ */ u(
588
+ "button",
589
+ {
590
+ className: `sa-interrupt-option ${r.danger ? "sa-interrupt-option-danger" : ""}`,
591
+ onClick: () => t({ action: "select", value: r.value }),
592
+ children: [
593
+ r.icon && /* @__PURE__ */ e(x, { name: r.icon, size: 14 }),
594
+ /* @__PURE__ */ e("span", { children: r.label }),
595
+ r.description && /* @__PURE__ */ e("span", { className: "sa-interrupt-option-desc", children: r.description })
596
+ ]
597
+ },
598
+ r.value
599
+ )) })
502
600
  ] });
503
601
  }
504
- function ue({ toolName: t, toolCallId: a, content: l }) {
505
- return /* @__PURE__ */ g("div", { className: "sa-tool-result-part", children: [
506
- /* @__PURE__ */ g("div", { className: "sa-tool-result-header", children: [
507
- /* @__PURE__ */ e("span", { className: "sa-tool-icon", children: /* @__PURE__ */ e(C, { name: "circle-check", size: 14, color: "#10b981" }) }),
508
- /* @__PURE__ */ e("span", { className: "sa-tool-result-label", children: t || "工具返回" })
602
+ function ke(a) {
603
+ return typeof a == "string" ? { value: a, label: a } : a;
604
+ }
605
+ function Ce({ interrupt: a, onRespond: t }) {
606
+ const n = (a.options ?? []).map(ke), [r, s] = z(/* @__PURE__ */ new Set()), c = (o) => {
607
+ s((l) => {
608
+ const i = new Set(l);
609
+ return i.has(o) ? i.delete(o) : i.add(o), i;
610
+ });
611
+ };
612
+ return /* @__PURE__ */ u("div", { className: "sa-interrupt-card", children: [
613
+ /* @__PURE__ */ u("div", { className: "sa-interrupt-content", children: [
614
+ /* @__PURE__ */ e(x, { name: "list-checks", size: 16, color: "#6366f1" }),
615
+ /* @__PURE__ */ e("span", { children: a.content })
509
616
  ] }),
510
- /* @__PURE__ */ e("div", { className: "sa-tool-result-content", children: l })
617
+ /* @__PURE__ */ e("div", { className: "sa-interrupt-options", children: n.map((o) => /* @__PURE__ */ u(
618
+ "button",
619
+ {
620
+ className: `sa-interrupt-option ${r.has(o.value) ? "sa-interrupt-option-selected" : ""}`,
621
+ onClick: () => c(o.value),
622
+ children: [
623
+ /* @__PURE__ */ e(x, { name: r.has(o.value) ? "square-check" : "square", size: 14 }),
624
+ /* @__PURE__ */ e("span", { children: o.label })
625
+ ]
626
+ },
627
+ o.value
628
+ )) }),
629
+ /* @__PURE__ */ e("div", { className: "sa-interrupt-actions", children: /* @__PURE__ */ u(
630
+ "button",
631
+ {
632
+ className: "sa-interrupt-btn sa-interrupt-btn-primary",
633
+ disabled: r.size === 0,
634
+ onClick: () => t({ action: "submit", value: Array.from(r) }),
635
+ children: [
636
+ /* @__PURE__ */ e(x, { name: "check", size: 14 }),
637
+ " 确认 (",
638
+ r.size,
639
+ ")"
640
+ ]
641
+ }
642
+ ) })
511
643
  ] });
512
644
  }
513
- function me({ content: t, onRetry: a }) {
514
- return /* @__PURE__ */ g("div", { className: "sa-error-part", children: [
515
- /* @__PURE__ */ g("div", { className: "sa-error-content", children: [
516
- /* @__PURE__ */ e("span", { className: "sa-error-icon", children: /* @__PURE__ */ e(C, { name: "triangle-alert", size: 14 }) }),
517
- /* @__PURE__ */ e("span", { children: t })
645
+ function Ne({ interrupt: a, onRespond: t }) {
646
+ const [n, r] = z(""), s = a.inputType ?? "text", c = s === "textarea", o = () => {
647
+ a.required && !n.trim() || t({ action: "submit", value: n.trim() });
648
+ };
649
+ return /* @__PURE__ */ u("div", { className: "sa-interrupt-card", children: [
650
+ /* @__PURE__ */ u("div", { className: "sa-interrupt-content", children: [
651
+ /* @__PURE__ */ e(x, { name: "text-cursor-input", size: 16, color: "#6366f1" }),
652
+ /* @__PURE__ */ e("span", { children: a.content })
518
653
  ] }),
519
- a && /* @__PURE__ */ e("button", { className: "sa-error-retry", onClick: a, children: "重试" })
654
+ /* @__PURE__ */ e("div", { className: "sa-interrupt-input-area", children: c ? /* @__PURE__ */ e(
655
+ "textarea",
656
+ {
657
+ className: "sa-interrupt-textarea",
658
+ value: n,
659
+ onChange: (l) => r(l.target.value),
660
+ placeholder: a.placeholder,
661
+ maxLength: a.maxLength,
662
+ rows: 3
663
+ }
664
+ ) : /* @__PURE__ */ e(
665
+ "input",
666
+ {
667
+ className: "sa-interrupt-input",
668
+ type: s,
669
+ value: n,
670
+ onChange: (l) => r(l.target.value),
671
+ placeholder: a.placeholder,
672
+ maxLength: a.maxLength,
673
+ onKeyDown: (l) => l.key === "Enter" && o()
674
+ }
675
+ ) }),
676
+ /* @__PURE__ */ e("div", { className: "sa-interrupt-actions", children: /* @__PURE__ */ u(
677
+ "button",
678
+ {
679
+ className: "sa-interrupt-btn sa-interrupt-btn-primary",
680
+ disabled: a.required ? !n.trim() : !1,
681
+ onClick: o,
682
+ children: [
683
+ /* @__PURE__ */ e(x, { name: "check", size: 14 }),
684
+ " 提交"
685
+ ]
686
+ }
687
+ ) })
520
688
  ] });
521
689
  }
522
- function ge({ message: t, onCopy: a, onRegenerate: l, onFeedback: s }) {
523
- const { status: r } = P(), [i, c] = I(null), [n, o] = I(!1);
524
- if (r !== "ready" && r !== "error") return null;
525
- const h = y(() => {
526
- a(), o(!0), setTimeout(() => o(!1), 2e3);
527
- }, [a]), p = y((m) => {
528
- const v = i === m ? null : m;
529
- c(v), v && (s == null || s(t.id, v));
530
- }, [i, t.id, s]);
531
- return /* @__PURE__ */ g("div", { className: "sa-action-bar", children: [
532
- /* @__PURE__ */ g("button", { className: "sa-action-btn", onClick: h, title: "复制", children: [
533
- /* @__PURE__ */ e(C, { name: n ? "circle-check" : "copy", size: 14 }),
690
+ function ze({ interrupt: a, onRespond: t }) {
691
+ const n = a.fields ?? [], [r, s] = z(() => {
692
+ const i = {};
693
+ for (const p of n)
694
+ i[p.name] = p.defaultValue ?? "";
695
+ return i;
696
+ }), c = (i, p) => {
697
+ s((f) => ({ ...f, [i]: p }));
698
+ }, o = n.every((i) => !i.required || r[i.name]), l = () => {
699
+ o && t({ action: "submit", value: r });
700
+ };
701
+ return /* @__PURE__ */ u("div", { className: "sa-interrupt-card", children: [
702
+ /* @__PURE__ */ u("div", { className: "sa-interrupt-content", children: [
703
+ /* @__PURE__ */ e(x, { name: "file-text", size: 16, color: "#6366f1" }),
704
+ /* @__PURE__ */ e("span", { children: a.content })
705
+ ] }),
706
+ /* @__PURE__ */ e("div", { className: "sa-interrupt-form", children: n.map((i) => /* @__PURE__ */ u("div", { className: "sa-interrupt-form-field", children: [
707
+ /* @__PURE__ */ u("label", { className: "sa-interrupt-form-label", children: [
708
+ i.label,
709
+ i.required && /* @__PURE__ */ e("span", { className: "sa-interrupt-form-required", children: "*" })
710
+ ] }),
711
+ Ie(i, r[i.name], (p) => c(i.name, p))
712
+ ] }, i.name)) }),
713
+ /* @__PURE__ */ u("div", { className: "sa-interrupt-actions", children: [
714
+ /* @__PURE__ */ u("button", { className: "sa-interrupt-btn sa-interrupt-btn-primary", disabled: !o, onClick: l, children: [
715
+ /* @__PURE__ */ e(x, { name: "check", size: 14 }),
716
+ " 提交"
717
+ ] }),
718
+ /* @__PURE__ */ e("button", { className: "sa-interrupt-btn sa-interrupt-btn-secondary", onClick: () => t({ action: "cancel" }), children: "取消" })
719
+ ] })
720
+ ] });
721
+ }
722
+ function Ie(a, t, n) {
723
+ switch (a.type) {
724
+ case "textarea":
725
+ return /* @__PURE__ */ e("textarea", { className: "sa-interrupt-textarea", value: t, onChange: (r) => n(r.target.value), placeholder: a.placeholder, rows: 3 });
726
+ case "select":
727
+ return /* @__PURE__ */ u("select", { className: "sa-interrupt-select", value: t, onChange: (r) => n(r.target.value), children: [
728
+ /* @__PURE__ */ e("option", { value: "", children: "请选择" }),
729
+ (a.options ?? []).map((r) => /* @__PURE__ */ e("option", { value: r, children: r }, r))
730
+ ] });
731
+ default:
732
+ return /* @__PURE__ */ e("input", { className: "sa-interrupt-input", type: a.type, value: t, onChange: (r) => n(r.target.value), placeholder: a.placeholder });
733
+ }
734
+ }
735
+ function Te({ interrupt: a, resolved: t, response: n, onRespond: r }) {
736
+ if (t)
737
+ return /* @__PURE__ */ u("div", { className: "sa-interrupt-resolved", children: [
738
+ /* @__PURE__ */ e(x, { name: "circle-check", size: 14, color: "#10b981" }),
739
+ /* @__PURE__ */ e("span", { children: Se(a.interruptType, n) })
740
+ ] });
741
+ switch (a.interruptType) {
742
+ case "confirm":
743
+ return /* @__PURE__ */ e(ve, { interrupt: a, onRespond: r });
744
+ case "select":
745
+ return /* @__PURE__ */ e(we, { interrupt: a, onRespond: r });
746
+ case "multiSelect":
747
+ return /* @__PURE__ */ e(Ce, { interrupt: a, onRespond: r });
748
+ case "input":
749
+ return /* @__PURE__ */ e(Ne, { interrupt: a, onRespond: r });
750
+ case "form":
751
+ return /* @__PURE__ */ e(ze, { interrupt: a, onRespond: r });
752
+ default:
753
+ return /* @__PURE__ */ u("div", { className: "sa-interrupt-unknown", children: [
754
+ "未知的交互类型: ",
755
+ a.interruptType
756
+ ] });
757
+ }
758
+ }
759
+ function Se(a, t) {
760
+ if (!t) return "已完成";
761
+ switch (t.action) {
762
+ case "confirm":
763
+ return "已确认";
764
+ case "cancel":
765
+ return "已取消";
766
+ case "select":
767
+ return `已选择: ${t.value}`;
768
+ case "submit":
769
+ return "已提交";
770
+ case "reject":
771
+ return "已拒绝";
772
+ default:
773
+ return "已完成";
774
+ }
775
+ }
776
+ function Me({ message: a, onCopy: t, onRegenerate: n, onFeedback: r }) {
777
+ const { status: s } = O(), [c, o] = z(null), [l, i] = z(!1);
778
+ if (s !== "ready" && s !== "error") return null;
779
+ const p = C(() => {
780
+ t(), i(!0), setTimeout(() => i(!1), 2e3);
781
+ }, [t]), f = C((h) => {
782
+ const w = c === h ? null : h;
783
+ o(w), w && (r == null || r(a.id, w));
784
+ }, [c, a.id, r]);
785
+ return /* @__PURE__ */ u("div", { className: "sa-action-bar", children: [
786
+ /* @__PURE__ */ u("button", { className: "sa-action-btn", onClick: p, title: "复制", children: [
787
+ /* @__PURE__ */ e(x, { name: l ? "circle-check" : "copy", size: 14 }),
534
788
  " ",
535
- n ? "已复制" : "复制"
789
+ l ? "已复制" : "复制"
536
790
  ] }),
537
- /* @__PURE__ */ g("button", { className: "sa-action-btn", onClick: l, title: "重新生成", children: [
538
- /* @__PURE__ */ e(C, { name: "refresh-cw", size: 14 }),
791
+ /* @__PURE__ */ u("button", { className: "sa-action-btn", onClick: n, title: "重新生成", children: [
792
+ /* @__PURE__ */ e(x, { name: "refresh-cw", size: 14 }),
539
793
  " 重新生成"
540
794
  ] }),
541
795
  /* @__PURE__ */ e("span", { className: "sa-action-divider" }),
542
796
  /* @__PURE__ */ e(
543
797
  "button",
544
798
  {
545
- className: `sa-action-btn ${i === "like" ? "sa-action-btn-active" : ""}`,
546
- onClick: () => p("like"),
799
+ className: `sa-action-btn ${c === "like" ? "sa-action-btn-active" : ""}`,
800
+ onClick: () => f("like"),
547
801
  title: "有用",
548
- children: /* @__PURE__ */ e(C, { name: "thumbs-up", size: 14 })
802
+ children: /* @__PURE__ */ e(x, { name: "thumbs-up", size: 14 })
549
803
  }
550
804
  ),
551
805
  /* @__PURE__ */ e(
552
806
  "button",
553
807
  {
554
- className: `sa-action-btn ${i === "dislike" ? "sa-action-btn-active" : ""}`,
555
- onClick: () => p("dislike"),
808
+ className: `sa-action-btn ${c === "dislike" ? "sa-action-btn-active" : ""}`,
809
+ onClick: () => f("dislike"),
556
810
  title: "无用",
557
- children: /* @__PURE__ */ e(C, { name: "thumbs-down", size: 14 })
811
+ children: /* @__PURE__ */ e(x, { name: "thumbs-down", size: 14 })
558
812
  }
559
813
  )
560
814
  ] });
561
815
  }
562
- function q({ src: t, role: a }) {
563
- const l = a === "assistant" ? "A" : "U";
564
- return t ? t.startsWith("http") || t.startsWith("/") || t.startsWith("data:") ? /* @__PURE__ */ e("div", { className: `sa-avatar sa-avatar-${a}`, children: /* @__PURE__ */ e("img", { src: t, alt: a, style: { width: "100%", height: "100%", borderRadius: "inherit", objectFit: "cover" } }) }) : /* @__PURE__ */ e("div", { className: `sa-avatar sa-avatar-${a}`, children: t }) : /* @__PURE__ */ e("div", { className: `sa-avatar sa-avatar-${a}`, children: l });
816
+ function Y({ src: a, role: t }) {
817
+ const n = t === "assistant" ? "A" : "U";
818
+ 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: n });
565
819
  }
566
- function xe({ message: t, isStreaming: a, isLast: l, slots: s, avatar: r }) {
567
- const { regenerate: i, feedback: c } = P(), n = y(() => {
568
- var f;
569
- const b = t.parts.filter((w) => w.type === "text").map((w) => w.content).join(`
820
+ function Le({ message: a, isStreaming: t, isLast: n, slots: r, avatar: s }) {
821
+ const { regenerate: c, feedback: o, respondToInterrupt: l } = O(), i = C(() => {
822
+ var y;
823
+ const d = a.parts.filter((N) => N.type === "text").map((N) => N.content).join(`
570
824
  `);
571
- (f = navigator.clipboard) == null || f.writeText(b).catch(() => {
825
+ (y = navigator.clipboard) == null || y.writeText(d).catch(() => {
572
826
  });
573
- }, [t]), o = t.role === "user", h = s.Message;
574
- if (h)
827
+ }, [a]), p = a.role === "user", f = r.Message;
828
+ if (f)
575
829
  return /* @__PURE__ */ e(
576
- h,
830
+ f,
577
831
  {
578
- message: t,
579
- isStreaming: a,
580
- isLast: l,
581
- avatar: r,
582
- slots: s,
583
- onCopy: n,
584
- onRegenerate: i,
585
- onFeedback: c
832
+ message: a,
833
+ isStreaming: t,
834
+ isLast: n,
835
+ avatar: s,
836
+ slots: r,
837
+ onCopy: i,
838
+ onRegenerate: c,
839
+ onFeedback: o
586
840
  }
587
841
  );
588
- const p = s.TextPart ?? pe, m = s.ThinkingPart ?? fe, v = s.ToolCallPart ?? he, x = s.ToolResultPart ?? ue, d = s.ErrorPart ?? me, u = s.ActionBar ?? ge;
589
- return /* @__PURE__ */ g("div", { className: `sa-message ${o ? "sa-message-user" : "sa-message-assistant"}`, children: [
590
- !o && /* @__PURE__ */ e(q, { src: r == null ? void 0 : r.assistant, role: "assistant" }),
591
- /* @__PURE__ */ g("div", { className: "sa-message-body", children: [
592
- t.parts.map((b, f) => {
593
- switch (b.type) {
842
+ const h = r.TextPart ?? me, w = r.ThinkingPart ?? he, v = r.ToolCallPart ?? ge, m = r.ToolResultPart ?? xe, g = r.ErrorPart ?? be, b = r.ActionBar ?? Me;
843
+ return /* @__PURE__ */ u("div", { className: `sa-message ${p ? "sa-message-user" : "sa-message-assistant"}`, children: [
844
+ !p && /* @__PURE__ */ e(Y, { src: s == null ? void 0 : s.assistant, role: "assistant" }),
845
+ /* @__PURE__ */ u("div", { className: "sa-message-body", children: [
846
+ a.parts.map((d, y) => {
847
+ switch (d.type) {
594
848
  case "text":
595
- return /* @__PURE__ */ e(p, { content: b.content }, f);
849
+ return /* @__PURE__ */ e(h, { content: d.content }, y);
596
850
  case "thinking":
597
- return /* @__PURE__ */ e(m, { content: b.content }, f);
851
+ return /* @__PURE__ */ e(w, { content: d.content }, y);
598
852
  case "tool_call":
599
- return /* @__PURE__ */ e(v, { toolName: b.toolName, toolCallId: b.toolCallId, args: b.args }, f);
853
+ return /* @__PURE__ */ e(v, { toolName: d.toolName, toolCallId: d.toolCallId, args: d.args }, y);
600
854
  case "tool_result":
601
- return /* @__PURE__ */ e(x, { toolName: b.toolName, toolCallId: b.toolCallId, content: b.content }, f);
855
+ return /* @__PURE__ */ e(m, { toolName: d.toolName, toolCallId: d.toolCallId, content: d.content }, y);
602
856
  case "error":
603
- return /* @__PURE__ */ e(d, { content: b.content, onRetry: i }, f);
857
+ return /* @__PURE__ */ e(g, { content: d.content, onRetry: c }, y);
858
+ case "interrupt":
859
+ return /* @__PURE__ */ e(
860
+ Te,
861
+ {
862
+ interrupt: d.interrupt,
863
+ resolved: d.resolved ?? !1,
864
+ response: d.response,
865
+ onRespond: (N) => l(d.interrupt.interruptId, N)
866
+ },
867
+ y
868
+ );
604
869
  default:
605
870
  return null;
606
871
  }
607
872
  }),
608
- a && l && !o && /* @__PURE__ */ e("span", { className: "sa-streaming-cursor", children: "|" }),
609
- !o && !a && t.parts.length > 0 && /* @__PURE__ */ e(u, { message: t, onCopy: n, onRegenerate: i, onFeedback: c })
873
+ t && n && !p && /* @__PURE__ */ e("span", { className: "sa-streaming-cursor", children: "|" }),
874
+ !p && !t && a.parts.length > 0 && /* @__PURE__ */ e(b, { message: a, onCopy: i, onRegenerate: c, onFeedback: o })
610
875
  ] }),
611
- o && /* @__PURE__ */ e(q, { src: r == null ? void 0 : r.user, role: "user" })
876
+ p && /* @__PURE__ */ e(Y, { src: s == null ? void 0 : s.user, role: "user" })
612
877
  ] });
613
878
  }
614
- function be({ message: t, suggestedPrompts: a, onPromptClick: l }) {
615
- return /* @__PURE__ */ g("div", { className: "sa-welcome", children: [
616
- /* @__PURE__ */ e("div", { className: "sa-welcome-icon", children: /* @__PURE__ */ e(C, { name: "sparkles", size: 40 }) }),
617
- /* @__PURE__ */ e("p", { className: "sa-welcome-message", children: t || "你好!有什么可以帮你的?" }),
618
- a && a.length > 0 && /* @__PURE__ */ e("div", { className: "sa-welcome-prompts", children: a.map((s, r) => /* @__PURE__ */ e(
879
+ function Ee({ message: a, suggestedPrompts: t, onPromptClick: n }) {
880
+ return /* @__PURE__ */ u("div", { className: "sa-welcome", children: [
881
+ /* @__PURE__ */ e("div", { className: "sa-welcome-icon", children: /* @__PURE__ */ e(x, { name: "sparkles", size: 40 }) }),
882
+ /* @__PURE__ */ e("p", { className: "sa-welcome-message", children: a || "你好!有什么可以帮你的?" }),
883
+ t && t.length > 0 && /* @__PURE__ */ e("div", { className: "sa-welcome-prompts", children: t.map((r, s) => /* @__PURE__ */ e(
619
884
  "button",
620
885
  {
621
886
  className: "sa-welcome-prompt",
622
- onClick: () => l(s),
623
- children: s
887
+ onClick: () => n(r),
888
+ children: r
624
889
  },
625
- r
890
+ s
626
891
  )) })
627
892
  ] });
628
893
  }
629
- function J({ slots: t, welcomeMessage: a, suggestedPrompts: l, avatar: s }) {
630
- const { messages: r, status: i, sendMessage: c } = P(), { containerRef: n } = le([r]), o = i === "streaming", h = t.WelcomeScreen ?? be;
631
- return r.length === 0 ? /* @__PURE__ */ e("div", { className: "sa-thread", ref: n, children: /* @__PURE__ */ e(
632
- h,
894
+ function G({ slots: a, welcomeMessage: t, suggestedPrompts: n, avatar: r }) {
895
+ const { messages: s, status: c, sendMessage: o } = O(), { containerRef: l } = pe([s]), i = c === "streaming", p = a.WelcomeScreen ?? Ee;
896
+ return s.length === 0 ? /* @__PURE__ */ e("div", { className: "sa-thread", ref: l, children: /* @__PURE__ */ e(
897
+ p,
633
898
  {
634
- message: a,
635
- suggestedPrompts: l,
636
- onPromptClick: c
899
+ message: t,
900
+ suggestedPrompts: n,
901
+ onPromptClick: o
637
902
  }
638
- ) }) : /* @__PURE__ */ e("div", { className: "sa-thread", ref: n, children: r.map((p, m) => /* @__PURE__ */ e(
639
- xe,
903
+ ) }) : /* @__PURE__ */ e("div", { className: "sa-thread", ref: l, children: s.map((f, h) => /* @__PURE__ */ e(
904
+ Le,
640
905
  {
641
- message: p,
642
- isStreaming: o,
643
- isLast: m === r.length - 1,
644
- slots: t,
645
- avatar: s
906
+ message: f,
907
+ isStreaming: i,
908
+ isLast: h === s.length - 1,
909
+ slots: a,
910
+ avatar: r
646
911
  },
647
- p.id
912
+ f.id
648
913
  )) });
649
914
  }
650
- function X() {
651
- const { status: t, sendMessage: a, stop: l } = P(), [s, r] = I(""), i = R(null), c = t === "streaming" || t === "submitted", n = y(() => {
652
- const p = s.trim();
653
- !p || c || (a(p), r(""), i.current && (i.current.style.height = "auto"));
654
- }, [s, c, a]), o = y((p) => {
655
- p.key === "Enter" && !p.shiftKey && (p.preventDefault(), n());
656
- }, [n]), h = y((p) => {
657
- r(p.target.value);
658
- const m = p.target;
659
- m.style.height = "auto", m.style.height = Math.min(m.scrollHeight, 120) + "px";
915
+ function Z() {
916
+ const { status: a, sendMessage: t, stop: n } = O(), [r, s] = z(""), c = $(null), o = a === "streaming" || a === "submitted", l = C(() => {
917
+ const f = r.trim();
918
+ !f || o || (t(f), s(""), c.current && (c.current.style.height = "auto"));
919
+ }, [r, o, t]), i = C((f) => {
920
+ f.key === "Enter" && !f.shiftKey && (f.preventDefault(), l());
921
+ }, [l]), p = C((f) => {
922
+ s(f.target.value);
923
+ const h = f.target;
924
+ h.style.height = "auto", h.style.height = Math.min(h.scrollHeight, 120) + "px";
660
925
  }, []);
661
- return /* @__PURE__ */ g("div", { className: "sa-composer", children: [
926
+ return /* @__PURE__ */ u("div", { className: "sa-composer", children: [
662
927
  /* @__PURE__ */ e(
663
928
  "textarea",
664
929
  {
665
- ref: i,
930
+ ref: c,
666
931
  className: "sa-composer-input",
667
- value: s,
668
- onChange: h,
669
- onKeyDown: o,
932
+ value: r,
933
+ onChange: p,
934
+ onKeyDown: i,
670
935
  placeholder: "输入消息...",
671
936
  rows: 1,
672
- disabled: t === "submitted"
937
+ disabled: a === "submitted"
673
938
  }
674
939
  ),
675
- c ? /* @__PURE__ */ e("button", { className: "sa-composer-stop", onClick: l, title: "停止", children: /* @__PURE__ */ e(C, { name: "circle-stop", size: 16, color: "#fff" }) }) : /* @__PURE__ */ e(
940
+ o ? /* @__PURE__ */ e("button", { className: "sa-composer-stop", onClick: n, title: "停止", children: /* @__PURE__ */ e(x, { name: "circle-stop", size: 16, color: "#fff" }) }) : /* @__PURE__ */ e(
676
941
  "button",
677
942
  {
678
943
  className: "sa-composer-send",
679
- onClick: n,
680
- disabled: !s.trim(),
944
+ onClick: l,
945
+ disabled: !r.trim(),
681
946
  title: "发送",
682
- children: /* @__PURE__ */ e(C, { name: "arrow-up", size: 16, color: "#fff" })
947
+ children: /* @__PURE__ */ e(x, { name: "arrow-up", size: 16, color: "#fff" })
683
948
  }
684
949
  )
685
950
  ] });
686
951
  }
687
- function ve({ isOpen: t, onClose: a, title: l, slots: s, welcomeMessage: r, suggestedPrompts: i, avatar: c }) {
688
- const { status: n, sendMessage: o, stop: h, toggleThreadList: p, conversations: m, activeConversationId: v, switchConversation: x, newConversation: d, deleteConversation: u, renameConversation: b, isThreadListOpen: f } = P();
689
- if (!t) return null;
690
- const w = s.Header, N = s.Composer, z = s.ThreadList;
691
- return /* @__PURE__ */ g("div", { className: "sa-panel", children: [
692
- w ? /* @__PURE__ */ e(w, { title: l, onClose: a, onToggleThreadList: p }) : /* @__PURE__ */ e(ie, { title: l, onClose: a, onToggleThreadList: p }),
693
- z && f ? /* @__PURE__ */ e(
694
- z,
952
+ function $e({ isOpen: a, onClose: t, title: n, slots: r, welcomeMessage: s, suggestedPrompts: c, avatar: o }) {
953
+ const { status: l, sendMessage: i, stop: p, toggleThreadList: f, conversations: h, activeConversationId: w, switchConversation: v, newConversation: m, deleteConversation: g, renameConversation: b, isThreadListOpen: d } = O();
954
+ if (!a) return null;
955
+ const y = r.Header, N = r.Composer, M = r.ThreadList;
956
+ return /* @__PURE__ */ u("div", { className: "sa-panel", children: [
957
+ y ? /* @__PURE__ */ e(y, { title: n, onClose: t, onToggleThreadList: f }) : /* @__PURE__ */ e(le, { title: n, onClose: t, onToggleThreadList: f }),
958
+ M && d ? /* @__PURE__ */ e(
959
+ M,
695
960
  {
696
- conversations: m,
697
- activeSessionId: v,
698
- onSwitch: x,
699
- onNew: d,
700
- onDelete: u,
961
+ conversations: h,
962
+ activeSessionId: w,
963
+ onSwitch: v,
964
+ onNew: m,
965
+ onDelete: g,
701
966
  onRename: b
702
967
  }
703
- ) : /* @__PURE__ */ e(oe, {}),
704
- /* @__PURE__ */ e(J, { slots: s, welcomeMessage: r, suggestedPrompts: i, avatar: c }),
705
- N ? /* @__PURE__ */ e(N, { status: n, onSend: o, onStop: h }) : /* @__PURE__ */ e(X, {})
968
+ ) : /* @__PURE__ */ e(de, {}),
969
+ /* @__PURE__ */ e(G, { slots: r, welcomeMessage: s, suggestedPrompts: c, avatar: o }),
970
+ N ? /* @__PURE__ */ e(N, { status: l, onSend: i, onStop: p }) : /* @__PURE__ */ e(Z, {})
706
971
  ] });
707
972
  }
708
- function we({
709
- conversations: t,
710
- activeSessionId: a,
711
- onSwitch: l,
712
- onNew: s,
713
- onDelete: r,
714
- isCollapsed: i,
715
- onToggleCollapse: c
973
+ function Ae({
974
+ conversations: a,
975
+ activeSessionId: t,
976
+ onSwitch: n,
977
+ onNew: r,
978
+ onDelete: s,
979
+ isCollapsed: c,
980
+ onToggleCollapse: o
716
981
  }) {
717
- const [n, o] = I(null), [h, p] = I(null), m = y((x, d) => {
718
- d.stopPropagation(), h === x ? (r(x), p(null)) : (p(x), setTimeout(() => p(null), 3e3));
719
- }, [h, r]), v = (() => {
720
- const x = Date.now(), d = [], u = [], b = [];
721
- for (const w of t) {
722
- const N = x - new Date(w.updateTime).getTime();
723
- N < 864e5 ? d.push(w) : N < 6048e5 ? u.push(w) : b.push(w);
982
+ const [l, i] = z(null), [p, f] = z(null), h = C((v, m) => {
983
+ m.stopPropagation(), p === v ? (s(v), f(null)) : (f(v), setTimeout(() => f(null), 3e3));
984
+ }, [p, s]), w = (() => {
985
+ const v = Date.now(), m = [], g = [], b = [];
986
+ for (const y of a) {
987
+ const N = v - new Date(y.updateTime).getTime();
988
+ N < 864e5 ? m.push(y) : N < 6048e5 ? g.push(y) : b.push(y);
724
989
  }
725
- const f = [];
726
- return d.length && f.push({ label: "今天", items: d }), u.length && f.push({ label: "最近 7 天", items: u }), b.length && f.push({ label: "更早", items: b }), f;
990
+ const d = [];
991
+ return m.length && d.push({ label: "今天", items: m }), g.length && d.push({ label: "最近 7 天", items: g }), b.length && d.push({ label: "更早", items: b }), d;
727
992
  })();
728
- return i ? /* @__PURE__ */ g("div", { className: "sa-fp-sidebar sa-fp-sidebar-collapsed", children: [
729
- /* @__PURE__ */ e("button", { className: "sa-fp-sidebar-toggle", onClick: c, title: "展开", children: /* @__PURE__ */ e(C, { name: "panel-left", size: 18 }) }),
730
- /* @__PURE__ */ e("button", { className: "sa-fp-sidebar-toggle", onClick: s, title: "新会话", style: { marginTop: 4 }, children: /* @__PURE__ */ e(C, { name: "plus", size: 18 }) })
731
- ] }) : /* @__PURE__ */ g("div", { className: "sa-fp-sidebar", children: [
732
- /* @__PURE__ */ g("div", { className: "sa-fp-sidebar-header", children: [
733
- /* @__PURE__ */ g("button", { className: "sa-fp-sidebar-new", onClick: s, children: [
734
- /* @__PURE__ */ e(C, { name: "plus", size: 15 }),
993
+ return c ? /* @__PURE__ */ u("div", { className: "sa-fp-sidebar sa-fp-sidebar-collapsed", children: [
994
+ /* @__PURE__ */ e("button", { className: "sa-fp-sidebar-toggle", onClick: o, title: "展开", children: /* @__PURE__ */ e(x, { name: "panel-left", size: 18 }) }),
995
+ /* @__PURE__ */ e("button", { className: "sa-fp-sidebar-toggle", onClick: r, title: "新会话", style: { marginTop: 4 }, children: /* @__PURE__ */ e(x, { name: "plus", size: 18 }) })
996
+ ] }) : /* @__PURE__ */ u("div", { className: "sa-fp-sidebar", children: [
997
+ /* @__PURE__ */ u("div", { className: "sa-fp-sidebar-header", children: [
998
+ /* @__PURE__ */ u("button", { className: "sa-fp-sidebar-new", onClick: r, children: [
999
+ /* @__PURE__ */ e(x, { name: "plus", size: 15 }),
735
1000
  " ",
736
1001
  /* @__PURE__ */ e("span", { children: "新会话" })
737
1002
  ] }),
738
- /* @__PURE__ */ e("button", { className: "sa-fp-sidebar-toggle", onClick: c, title: "收起侧边栏", children: /* @__PURE__ */ e(C, { name: "panel-left-close", size: 18 }) })
1003
+ /* @__PURE__ */ e("button", { className: "sa-fp-sidebar-toggle", onClick: o, title: "收起侧边栏", children: /* @__PURE__ */ e(x, { name: "panel-left-close", size: 18 }) })
739
1004
  ] }),
740
- /* @__PURE__ */ g("div", { className: "sa-fp-sidebar-list", children: [
741
- t.length === 0 && /* @__PURE__ */ e("div", { className: "sa-fp-sidebar-empty", children: "开始你的第一个对话" }),
742
- v.map((x) => /* @__PURE__ */ g("div", { children: [
743
- /* @__PURE__ */ e("div", { className: "sa-fp-sidebar-group", children: x.label }),
744
- x.items.map((d) => {
745
- const u = d.sessionId === a, b = n === d.sessionId, f = h === d.sessionId;
746
- return /* @__PURE__ */ g(
1005
+ /* @__PURE__ */ u("div", { className: "sa-fp-sidebar-list", children: [
1006
+ a.length === 0 && /* @__PURE__ */ e("div", { className: "sa-fp-sidebar-empty", children: "开始你的第一个对话" }),
1007
+ w.map((v) => /* @__PURE__ */ u("div", { children: [
1008
+ /* @__PURE__ */ e("div", { className: "sa-fp-sidebar-group", children: v.label }),
1009
+ v.items.map((m) => {
1010
+ const g = m.sessionId === t, b = l === m.sessionId, d = p === m.sessionId;
1011
+ return /* @__PURE__ */ u(
747
1012
  "div",
748
1013
  {
749
- className: `sa-fp-sidebar-item ${u ? "active" : ""}`,
750
- onClick: () => l(d.sessionId),
751
- onMouseEnter: () => o(d.sessionId),
752
- onMouseLeave: () => o(null),
1014
+ className: `sa-fp-sidebar-item ${g ? "active" : ""}`,
1015
+ onClick: () => n(m.sessionId),
1016
+ onMouseEnter: () => i(m.sessionId),
1017
+ onMouseLeave: () => i(null),
753
1018
  children: [
754
- /* @__PURE__ */ e("span", { className: "sa-fp-sidebar-item-title", children: d.title || "新会话" }),
1019
+ /* @__PURE__ */ e("span", { className: "sa-fp-sidebar-item-title", children: m.title || "新会话" }),
755
1020
  b && /* @__PURE__ */ e(
756
1021
  "button",
757
1022
  {
758
- className: `sa-fp-sidebar-item-action ${f ? "danger" : ""}`,
759
- onClick: (w) => m(d.sessionId, w),
760
- title: f ? "确认删除" : "删除",
761
- children: /* @__PURE__ */ e(C, { name: f ? "x" : "trash2", size: 14 })
1023
+ className: `sa-fp-sidebar-item-action ${d ? "danger" : ""}`,
1024
+ onClick: (y) => h(m.sessionId, y),
1025
+ title: d ? "确认删除" : "删除",
1026
+ children: /* @__PURE__ */ e(x, { name: d ? "x" : "trash2", size: 14 })
762
1027
  }
763
1028
  )
764
1029
  ]
765
1030
  },
766
- d.sessionId
1031
+ m.sessionId
767
1032
  );
768
1033
  })
769
- ] }, x.label))
1034
+ ] }, v.label))
770
1035
  ] })
771
1036
  ] });
772
1037
  }
773
- function ye({ title: t, slots: a, welcomeMessage: l, suggestedPrompts: s, sidebarDefaultOpen: r = !0, onClose: i, avatar: c }) {
1038
+ function De({ title: a, slots: t, welcomeMessage: n, suggestedPrompts: r, sidebarDefaultOpen: s = !0, onClose: c, avatar: o }) {
774
1039
  const {
775
- status: n,
776
- sendMessage: o,
777
- stop: h,
778
- conversations: p,
779
- activeConversationId: m,
780
- switchConversation: v,
781
- newConversation: x,
782
- deleteConversation: d,
783
- renameConversation: u
784
- } = P(), [b, f] = I(r), w = y(() => f((O) => !O), []), N = a.ThreadList, z = a.Composer;
785
- return /* @__PURE__ */ g("div", { className: "sa-fullpage", children: [
1040
+ status: l,
1041
+ sendMessage: i,
1042
+ stop: p,
1043
+ conversations: f,
1044
+ activeConversationId: h,
1045
+ switchConversation: w,
1046
+ newConversation: v,
1047
+ deleteConversation: m,
1048
+ renameConversation: g
1049
+ } = O(), [b, d] = z(s), y = C(() => d((T) => !T), []), N = t.ThreadList, M = t.Composer;
1050
+ return /* @__PURE__ */ u("div", { className: "sa-fullpage", children: [
786
1051
  N ? /* @__PURE__ */ e("div", { className: `sa-fp-sidebar-wrapper ${b ? "" : "sa-fp-sidebar-wrapper-collapsed"}`, children: /* @__PURE__ */ e(
787
1052
  N,
788
1053
  {
789
- conversations: p,
790
- activeSessionId: m,
791
- onSwitch: v,
792
- onNew: x,
793
- onDelete: d,
794
- onRename: u
1054
+ conversations: f,
1055
+ activeSessionId: h,
1056
+ onSwitch: w,
1057
+ onNew: v,
1058
+ onDelete: m,
1059
+ onRename: g
795
1060
  }
796
1061
  ) }) : /* @__PURE__ */ e(
797
- we,
1062
+ Ae,
798
1063
  {
799
- conversations: p,
800
- activeSessionId: m,
801
- onSwitch: v,
802
- onNew: x,
803
- onDelete: d,
804
- onRename: u,
1064
+ conversations: f,
1065
+ activeSessionId: h,
1066
+ onSwitch: w,
1067
+ onNew: v,
1068
+ onDelete: m,
1069
+ onRename: g,
805
1070
  isCollapsed: !b,
806
- onToggleCollapse: w
1071
+ onToggleCollapse: y
807
1072
  }
808
1073
  ),
809
- /* @__PURE__ */ g("div", { className: "sa-fp-main", children: [
810
- /* @__PURE__ */ g("div", { className: "sa-fp-header", children: [
811
- !b && !N && /* @__PURE__ */ e("button", { className: "sa-fp-header-btn", onClick: w, title: "展开侧边栏", children: /* @__PURE__ */ e(C, { name: "panel-left", size: 18 }) }),
812
- /* @__PURE__ */ e("div", { className: "sa-fp-header-title", children: t }),
813
- /* @__PURE__ */ e("div", { className: "sa-fp-header-actions", children: i && /* @__PURE__ */ e("button", { className: "sa-fp-header-btn", onClick: i, title: "关闭", children: /* @__PURE__ */ e(C, { name: "x", size: 18 }) }) })
1074
+ /* @__PURE__ */ u("div", { className: "sa-fp-main", children: [
1075
+ /* @__PURE__ */ u("div", { className: "sa-fp-header", children: [
1076
+ !b && !N && /* @__PURE__ */ e("button", { className: "sa-fp-header-btn", onClick: y, title: "展开侧边栏", children: /* @__PURE__ */ e(x, { name: "panel-left", size: 18 }) }),
1077
+ /* @__PURE__ */ e("div", { className: "sa-fp-header-title", children: a }),
1078
+ /* @__PURE__ */ e("div", { className: "sa-fp-header-actions", children: c && /* @__PURE__ */ e("button", { className: "sa-fp-header-btn", onClick: c, title: "关闭", children: /* @__PURE__ */ e(x, { name: "x", size: 18 }) }) })
814
1079
  ] }),
815
- /* @__PURE__ */ e(J, { slots: a, welcomeMessage: l, suggestedPrompts: s, avatar: c }),
816
- z ? /* @__PURE__ */ e(z, { status: n, onSend: o, onStop: h }) : /* @__PURE__ */ e(X, {})
1080
+ /* @__PURE__ */ e(G, { slots: t, welcomeMessage: n, suggestedPrompts: r, avatar: o }),
1081
+ M ? /* @__PURE__ */ e(M, { status: l, onSend: i, onStop: p }) : /* @__PURE__ */ e(Z, {})
817
1082
  ] })
818
1083
  ] });
819
1084
  }
820
- function ke(t) {
821
- const { sdk: a, mode: l = "floating", slots: s = {}, hooks: r = {}, welcomeMessage: i, suggestedPrompts: c, title: n = "AI Assistant", initialOpen: o = !1, onOpenChange: h, sidebarDefaultOpen: p, avatar: m } = t, [v, x] = I(o);
822
- A(() => {
823
- x(o);
824
- }, [o]);
825
- const d = y(() => {
826
- var w, N;
827
- const f = !v;
828
- x(f), h == null || h(f), f ? (w = r.onOpen) == null || w.call(r) : (N = r.onClose) == null || N.call(r);
829
- }, [v, r, h]), u = y(() => {
830
- var f;
831
- x(!1), h == null || h(!1), (f = r.onClose) == null || f.call(r);
832
- }, [r, h]), b = s.Trigger ?? ne;
833
- return l === "fullpage" ? v ? /* @__PURE__ */ e(U, { sdk: a, hooks: r, children: /* @__PURE__ */ e(
834
- ye,
1085
+ function Pe(a) {
1086
+ const { sdk: t, mode: n = "floating", slots: r = {}, hooks: s = {}, welcomeMessage: c, suggestedPrompts: o, title: l = "AI Assistant", initialOpen: i = !1, onOpenChange: p, sidebarDefaultOpen: f, avatar: h } = a, [w, v] = z(i);
1087
+ j(() => {
1088
+ v(i);
1089
+ }, [i]);
1090
+ const m = C(() => {
1091
+ var y, N;
1092
+ const d = !w;
1093
+ v(d), p == null || p(d), d ? (y = s.onOpen) == null || y.call(s) : (N = s.onClose) == null || N.call(s);
1094
+ }, [w, s, p]), g = C(() => {
1095
+ var d;
1096
+ v(!1), p == null || p(!1), (d = s.onClose) == null || d.call(s);
1097
+ }, [s, p]), b = r.Trigger ?? oe;
1098
+ return n === "fullpage" ? w ? /* @__PURE__ */ e(U, { sdk: t, hooks: s, children: /* @__PURE__ */ e(
1099
+ De,
835
1100
  {
836
- title: n,
837
- slots: s,
838
- welcomeMessage: i,
839
- suggestedPrompts: c,
840
- sidebarDefaultOpen: p,
841
- onClose: u,
842
- avatar: m
1101
+ title: l,
1102
+ slots: r,
1103
+ welcomeMessage: c,
1104
+ suggestedPrompts: o,
1105
+ sidebarDefaultOpen: f,
1106
+ onClose: g,
1107
+ avatar: h
843
1108
  }
844
- ) }) : null : /* @__PURE__ */ g(U, { sdk: a, hooks: r, children: [
845
- /* @__PURE__ */ e(b, { isOpen: v, onClick: d }),
1109
+ ) }) : null : /* @__PURE__ */ u(U, { sdk: t, hooks: s, children: [
1110
+ /* @__PURE__ */ e(b, { isOpen: w, onClick: m }),
846
1111
  /* @__PURE__ */ e(
847
- ve,
1112
+ $e,
848
1113
  {
849
- isOpen: v,
850
- onClose: u,
851
- title: n,
852
- slots: s,
853
- welcomeMessage: i,
854
- suggestedPrompts: c,
855
- avatar: m
1114
+ isOpen: w,
1115
+ onClose: g,
1116
+ title: l,
1117
+ slots: r,
1118
+ welcomeMessage: c,
1119
+ suggestedPrompts: o,
1120
+ avatar: h
856
1121
  }
857
1122
  )
858
1123
  ] });
859
1124
  }
860
- const Ce = `
1125
+ const Re = `
861
1126
  [data-super-agent-widget] {
862
1127
  --sa-primary-dark: color-mix(in srgb, var(--sa-primary) 82%, #000);
863
1128
  --sa-primary-light: color-mix(in srgb, var(--sa-primary) 10%, #fff);
@@ -1516,42 +1781,55 @@ const Ce = `
1516
1781
  .sa-thread-list-header {
1517
1782
  display: flex;
1518
1783
  align-items: center;
1519
- gap: 10px;
1520
- padding: 14px 16px;
1521
- border-bottom: 1px solid var(--sa-border);
1784
+ justify-content: space-between;
1785
+ padding: 20px 20px 16px;
1522
1786
  flex-shrink: 0;
1523
1787
  }
1524
1788
 
1789
+ .sa-thread-list-title {
1790
+ font-size: 17px;
1791
+ font-weight: 700;
1792
+ color: #18181b;
1793
+ letter-spacing: -0.2px;
1794
+ }
1795
+
1796
+ .sa-thread-list-new {
1797
+ display: flex;
1798
+ align-items: center;
1799
+ gap: 6px;
1800
+ padding: 8px 16px;
1801
+ border: none;
1802
+ border-radius: 20px;
1803
+ background: #f4f4f5;
1804
+ color: #3f3f46;
1805
+ font-size: 13px;
1806
+ font-weight: 500;
1807
+ cursor: pointer;
1808
+ transition: background 0.15s;
1809
+ }
1810
+
1811
+ .sa-thread-list-new:hover {
1812
+ background: #e4e4e7;
1813
+ }
1814
+
1525
1815
  .sa-thread-list-items {
1526
1816
  flex: 1;
1527
1817
  overflow-y: auto;
1818
+ padding: 0 12px 12px;
1528
1819
  }
1529
1820
 
1530
1821
  .sa-thread-list-empty {
1531
- padding: 24px 16px;
1822
+ padding: 48px 16px;
1532
1823
  text-align: center;
1533
1824
  color: var(--sa-text-muted);
1534
- font-size: 13px;
1535
- }
1536
-
1537
- .sa-thread-list-new {
1538
- display: block;
1539
- width: calc(100% - 24px);
1540
- margin: 12px;
1541
- padding: 10px;
1542
- border: 1px dashed var(--sa-border);
1543
- border-radius: 10px;
1544
- background: transparent;
1545
- color: var(--sa-primary);
1546
1825
  font-size: 14px;
1547
- cursor: pointer;
1548
- text-align: center;
1549
- transition: background 0.15s, border-color 0.15s;
1550
1826
  }
1551
1827
 
1552
- .sa-thread-list-new:hover {
1553
- background: var(--sa-primary-light);
1554
- border-color: var(--sa-primary);
1828
+ .sa-thread-group-label {
1829
+ padding: 16px 8px 6px;
1830
+ font-size: 12px;
1831
+ font-weight: 500;
1832
+ color: #a1a1aa;
1555
1833
  }
1556
1834
 
1557
1835
  .sa-thread-item {
@@ -1559,8 +1837,9 @@ const Ce = `
1559
1837
  align-items: center;
1560
1838
  justify-content: space-between;
1561
1839
  gap: 8px;
1562
- padding: 12px 16px;
1563
- border-bottom: 1px solid #f3f4f6;
1840
+ padding: 10px 12px;
1841
+ margin: 2px 0;
1842
+ border-radius: 8px;
1564
1843
  color: #374151;
1565
1844
  font-size: 14px;
1566
1845
  cursor: pointer;
@@ -1568,7 +1847,7 @@ const Ce = `
1568
1847
  }
1569
1848
 
1570
1849
  .sa-thread-item:hover {
1571
- background: var(--sa-surface);
1850
+ background: #f9fafb;
1572
1851
  }
1573
1852
 
1574
1853
  .sa-thread-item.active {
@@ -1673,6 +1952,191 @@ const Ce = `
1673
1952
  animation: sa-blink 1s steps(2, start) infinite;
1674
1953
  }
1675
1954
 
1955
+ /* ── Interrupt cards ──────────────────────────────────────── */
1956
+
1957
+ .sa-interrupt-card {
1958
+ margin: 8px 0;
1959
+ padding: 14px;
1960
+ border: 1px solid #e0e7ff;
1961
+ border-radius: 10px;
1962
+ background: #f8faff;
1963
+ }
1964
+
1965
+ .sa-interrupt-content {
1966
+ display: flex;
1967
+ align-items: flex-start;
1968
+ gap: 8px;
1969
+ font-size: 13px;
1970
+ line-height: 1.6;
1971
+ color: var(--sa-text);
1972
+ margin-bottom: 12px;
1973
+ }
1974
+
1975
+ .sa-interrupt-actions {
1976
+ display: flex;
1977
+ gap: 8px;
1978
+ margin-top: 10px;
1979
+ }
1980
+
1981
+ .sa-interrupt-btn {
1982
+ display: inline-flex;
1983
+ align-items: center;
1984
+ gap: 5px;
1985
+ padding: 6px 14px;
1986
+ border: none;
1987
+ border-radius: 8px;
1988
+ font-size: 13px;
1989
+ font-weight: 500;
1990
+ cursor: pointer;
1991
+ transition: background 0.15s, opacity 0.15s;
1992
+ }
1993
+
1994
+ .sa-interrupt-btn:disabled {
1995
+ opacity: 0.5;
1996
+ cursor: not-allowed;
1997
+ }
1998
+
1999
+ .sa-interrupt-btn-primary {
2000
+ background: var(--sa-primary);
2001
+ color: #fff;
2002
+ }
2003
+
2004
+ .sa-interrupt-btn-primary:hover:not(:disabled) {
2005
+ opacity: 0.9;
2006
+ }
2007
+
2008
+ .sa-interrupt-btn-secondary {
2009
+ background: #f3f4f6;
2010
+ color: #374151;
2011
+ }
2012
+
2013
+ .sa-interrupt-btn-secondary:hover:not(:disabled) {
2014
+ background: #e5e7eb;
2015
+ }
2016
+
2017
+ .sa-interrupt-options {
2018
+ display: flex;
2019
+ flex-direction: column;
2020
+ gap: 6px;
2021
+ }
2022
+
2023
+ .sa-interrupt-option {
2024
+ display: flex;
2025
+ align-items: center;
2026
+ gap: 8px;
2027
+ padding: 8px 12px;
2028
+ border: 1px solid var(--sa-border);
2029
+ border-radius: 8px;
2030
+ background: #fff;
2031
+ color: var(--sa-text);
2032
+ font-size: 13px;
2033
+ cursor: pointer;
2034
+ text-align: left;
2035
+ transition: border-color 0.12s, background 0.12s;
2036
+ }
2037
+
2038
+ .sa-interrupt-option:hover {
2039
+ border-color: var(--sa-primary);
2040
+ background: #f5f3ff;
2041
+ }
2042
+
2043
+ .sa-interrupt-option-selected {
2044
+ border-color: var(--sa-primary);
2045
+ background: #ede9fe;
2046
+ color: var(--sa-primary);
2047
+ font-weight: 500;
2048
+ }
2049
+
2050
+ .sa-interrupt-option-danger {
2051
+ color: #ef4444;
2052
+ }
2053
+
2054
+ .sa-interrupt-option-danger:hover {
2055
+ border-color: #ef4444;
2056
+ background: #fef2f2;
2057
+ }
2058
+
2059
+ .sa-interrupt-option-desc {
2060
+ font-size: 11px;
2061
+ color: var(--sa-text-muted);
2062
+ margin-left: auto;
2063
+ }
2064
+
2065
+ .sa-interrupt-input-area {
2066
+ margin-top: 4px;
2067
+ }
2068
+
2069
+ .sa-interrupt-input,
2070
+ .sa-interrupt-textarea,
2071
+ .sa-interrupt-select {
2072
+ width: 100%;
2073
+ padding: 8px 12px;
2074
+ border: 1px solid var(--sa-border);
2075
+ border-radius: 8px;
2076
+ background: #fff;
2077
+ color: var(--sa-text);
2078
+ font-size: 13px;
2079
+ font-family: inherit;
2080
+ outline: none;
2081
+ transition: border-color 0.15s;
2082
+ }
2083
+
2084
+ .sa-interrupt-input:focus,
2085
+ .sa-interrupt-textarea:focus,
2086
+ .sa-interrupt-select:focus {
2087
+ border-color: var(--sa-primary);
2088
+ }
2089
+
2090
+ .sa-interrupt-textarea {
2091
+ resize: vertical;
2092
+ min-height: 60px;
2093
+ }
2094
+
2095
+ .sa-interrupt-form {
2096
+ display: flex;
2097
+ flex-direction: column;
2098
+ gap: 10px;
2099
+ margin-top: 4px;
2100
+ }
2101
+
2102
+ .sa-interrupt-form-field {
2103
+ display: flex;
2104
+ flex-direction: column;
2105
+ gap: 4px;
2106
+ }
2107
+
2108
+ .sa-interrupt-form-label {
2109
+ font-size: 12px;
2110
+ font-weight: 500;
2111
+ color: var(--sa-text);
2112
+ }
2113
+
2114
+ .sa-interrupt-form-required {
2115
+ color: #ef4444;
2116
+ margin-left: 2px;
2117
+ }
2118
+
2119
+ .sa-interrupt-resolved {
2120
+ display: flex;
2121
+ align-items: center;
2122
+ gap: 6px;
2123
+ padding: 8px 12px;
2124
+ border-radius: 8px;
2125
+ background: #ecfdf5;
2126
+ color: #065f46;
2127
+ font-size: 13px;
2128
+ margin: 6px 0;
2129
+ }
2130
+
2131
+ .sa-interrupt-unknown {
2132
+ padding: 8px 12px;
2133
+ border-radius: 8px;
2134
+ background: #fef3c7;
2135
+ color: #92400e;
2136
+ font-size: 13px;
2137
+ margin: 6px 0;
2138
+ }
2139
+
1676
2140
  /* ── Animations ──────────────────────────────────────────── */
1677
2141
 
1678
2142
  @keyframes sa-slide-up {
@@ -1978,7 +2442,7 @@ const Ce = `
1978
2442
  border-color: #d4d4d8;
1979
2443
  box-shadow: 0 0 0 3px rgba(99,102,241,0.08);
1980
2444
  }
1981
- `, Ne = {
2445
+ `, je = {
1982
2446
  primaryColor: "#6366f1",
1983
2447
  backgroundColor: "#ffffff",
1984
2448
  fontFamily: "system-ui, -apple-system, sans-serif",
@@ -1987,77 +2451,78 @@ const Ce = `
1987
2451
  panelHeight: 520,
1988
2452
  zIndex: 9999
1989
2453
  };
1990
- function ze(t) {
1991
- const a = { ...Ne, ...t };
2454
+ function Oe(a) {
2455
+ const t = { ...je, ...a };
1992
2456
  return [
1993
- `--sa-primary: ${a.primaryColor}`,
1994
- `--sa-bg: ${a.backgroundColor}`,
1995
- `--sa-font: ${a.fontFamily}`,
1996
- `--sa-radius: ${a.borderRadius}px`,
1997
- `--sa-panel-width: ${a.panelWidth}px`,
1998
- `--sa-panel-height: ${a.panelHeight}px`,
1999
- `--sa-z-index: ${a.zIndex}`
2457
+ `--sa-primary: ${t.primaryColor}`,
2458
+ `--sa-bg: ${t.backgroundColor}`,
2459
+ `--sa-font: ${t.fontFamily}`,
2460
+ `--sa-radius: ${t.borderRadius}px`,
2461
+ `--sa-panel-width: ${t.panelWidth}px`,
2462
+ `--sa-panel-height: ${t.panelHeight}px`,
2463
+ `--sa-z-index: ${t.zIndex}`
2000
2464
  ].join("; ");
2001
2465
  }
2002
- function Me(t, a) {
2003
- const l = typeof t == "string" ? document.querySelector(t) : t;
2004
- if (!l)
2005
- throw new Error(`Target element not found: ${t}`);
2006
- const s = document.createElement("div");
2007
- s.setAttribute("data-super-agent-widget", "");
2008
- const r = ze(a.theme ?? {});
2009
- if (s.setAttribute("style", r), l.appendChild(s), !document.getElementById("sa-widget-styles")) {
2010
- const o = document.createElement("style");
2011
- o.id = "sa-widget-styles", o.textContent = Ce, document.head.appendChild(o);
2012
- }
2013
- let i = ee(s), c = !1;
2014
- const n = (o) => {
2015
- i && i.render(
2016
- V.createElement(ke, {
2017
- ...a,
2018
- initialOpen: o ?? c,
2019
- onOpenChange: (h) => {
2020
- c = h;
2466
+ function _e(a, t) {
2467
+ const n = typeof a == "string" ? document.querySelector(a) : a;
2468
+ if (!n)
2469
+ throw new Error(`Target element not found: ${a}`);
2470
+ const r = document.createElement("div");
2471
+ r.setAttribute("data-super-agent-widget", "");
2472
+ const s = Oe(t.theme ?? {});
2473
+ if (r.setAttribute("style", s), n.appendChild(r), !document.getElementById("sa-widget-styles")) {
2474
+ const i = document.createElement("style");
2475
+ i.id = "sa-widget-styles", i.textContent = Re, document.head.appendChild(i);
2476
+ }
2477
+ let c = te(r), o = !1;
2478
+ const l = (i) => {
2479
+ c && c.render(
2480
+ J.createElement(Pe, {
2481
+ ...t,
2482
+ initialOpen: i ?? o,
2483
+ onOpenChange: (p) => {
2484
+ o = p;
2021
2485
  }
2022
2486
  })
2023
2487
  );
2024
2488
  };
2025
- return n(!1), {
2489
+ return l(!1), {
2026
2490
  open() {
2027
- c = !0, n(!0);
2491
+ o = !0, l(!0);
2028
2492
  },
2029
2493
  close() {
2030
- c = !1, n(!1);
2494
+ o = !1, l(!1);
2031
2495
  },
2032
2496
  destroy() {
2033
- i && (i.unmount(), i = null), s.remove();
2497
+ c && (c.unmount(), c = null), r.remove();
2034
2498
  }
2035
2499
  };
2036
2500
  }
2037
2501
  export {
2038
- ge as ActionBar,
2502
+ Me as ActionBar,
2039
2503
  U as ChatProvider,
2040
- ke as ChatWidget,
2041
- X as Composer,
2042
- me as ErrorPart,
2043
- ye as FullpageLayout,
2044
- ie as Header,
2045
- C as Icon,
2046
- xe as Message,
2047
- pe as TextPart,
2048
- fe as ThinkingPart,
2049
- J as Thread,
2050
- oe as ThreadList,
2051
- he as ToolCallPart,
2052
- ue as ToolResultPart,
2053
- ne as Trigger,
2054
- be as WelcomeScreen,
2055
- Ne as defaultTheme,
2056
- Me as mount,
2057
- ze as themeToCSSVars,
2058
- le as useAutoScroll,
2059
- te as useChat,
2060
- P as useChatContext,
2061
- se as useConversations,
2062
- Ce as widgetStyles
2504
+ Pe as ChatWidget,
2505
+ Z as Composer,
2506
+ be as ErrorPart,
2507
+ De as FullpageLayout,
2508
+ le as Header,
2509
+ x as Icon,
2510
+ Te as InterruptCard,
2511
+ Le as Message,
2512
+ me as TextPart,
2513
+ he as ThinkingPart,
2514
+ G as Thread,
2515
+ de as ThreadList,
2516
+ ge as ToolCallPart,
2517
+ xe as ToolResultPart,
2518
+ oe as Trigger,
2519
+ Ee as WelcomeScreen,
2520
+ je as defaultTheme,
2521
+ _e as mount,
2522
+ Oe as themeToCSSVars,
2523
+ pe as useAutoScroll,
2524
+ se as useChat,
2525
+ O as useChatContext,
2526
+ ie as useConversations,
2527
+ Re as widgetStyles
2063
2528
  };