super-agent-sdk 1.0.3 → 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 q, { useState as I, useRef as R, useCallback as y, useEffect as A, createContext as Z, useContext as Q, useMemo as ee } from "react";
2
- import { createRoot as ae } from "react-dom/client";
3
- import { jsx as a, jsxs as x, Fragment as te } from "react/jsx-runtime";
4
- function se(t) {
5
- const { sdk: e, sessionId: l, onSessionCreated: r, onStreamStart: s, onStreamEnd: i, onError: c, onMessageSend: n } = t, [o, f] = I([]), [p, m] = I("ready"), [v, b] = I(null), h = R(null), g = R(!1), u = R(l);
6
- u.current = l;
7
- const d = y((z) => {
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
8
  if (g.current) return;
9
- g.current = !0, n == null || n(z);
10
- const O = {
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
- f((T) => [...T, O, G]), m("submitted"), b(null);
22
- const F = (T) => {
23
- let H = "", E = "", D = [], W = !1;
24
- const B = () => {
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
- f(
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
- h.current = e.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,813 +63,1066 @@ function se(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
- B();
74
+ q();
68
75
  },
69
76
  onDone: (k) => {
70
- (E || D.length > 0 || H) && B(), k.sessionId && k.sessionId !== u.current && (r == null || r(k.sessionId)), i == null || i(k.sessionId || T), m("ready"), g.current = !1, h.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 }), B(), b(k), m("error"), c == null || c(k), g.current = !1, h.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
- }), s == null || s(T);
82
+ }), s == null || s(I);
76
83
  };
77
- u.current ? F(u.current) : e.createSession().then((T) => {
78
- u.current = T, r == null || r(T), F(T);
79
- }).catch((T) => {
80
- b(T instanceof Error ? T : new Error(String(T))), m("error"), c == null || c(T instanceof Error ? T : new Error(String(T))), g.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;
81
88
  });
82
- }, [e, r, s, i, c, n]), w = y(() => {
83
- var z;
84
- (z = h.current) == null || z.abort(), h.current = null, m("ready"), g.current = !1;
85
- }, []), N = y(() => {
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(() => {
86
93
  if (g.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
- f((S) => S.slice(0, z)), d(O);
91
- }, [o, d]);
92
- return { messages: o, status: p, error: v, sendMessage: d, stop: w, regenerate: N, setMessages: f };
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)));
110
+ });
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 _ = "sa_active_conversation";
95
- function K() {
114
+ const W = "sa_active_conversation";
115
+ function V() {
96
116
  try {
97
- return localStorage.getItem(_);
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(_, t) : localStorage.removeItem(_);
124
+ a ? localStorage.setItem(W, a) : localStorage.removeItem(W);
105
125
  } catch {
106
126
  }
107
127
  }
108
- function ne(t) {
109
- const { sdk: e, onConversationChange: l } = t, [r, s] = I([]), [i, c] = I(
110
- () => K()
111
- ), [n, o] = I(!1), f = R(!0);
112
- A(() => () => {
113
- f.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((d) => {
116
- c(d), re(d), d && (l == null || l(d));
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 d = await e.listConversations({ page: 1, size: 100 });
121
- if (!f.current) return;
140
+ const d = await t.listConversations({ page: 1, size: 100 });
141
+ if (!p.current) return;
122
142
  s(d.items);
123
- const w = K();
124
- w && !d.items.find((N) => N.sessionId === w) && p(null);
143
+ const y = V();
144
+ y && !d.items.find((N) => N.sessionId === y) && f(null);
125
145
  } catch {
126
146
  } finally {
127
- f.current && o(!1);
147
+ p.current && i(!1);
128
148
  }
129
- }, [e, p]), v = y(async (d) => (p(d), await e.getMessages(d)), [e, p]), b = y(() => {
130
- p(null);
131
- }, [p]), h = y(async (d) => {
132
- await e.deleteConversation(d), s((w) => w.filter((N) => N.sessionId !== d)), i === d && p(null);
133
- }, [e, i, p]), g = y(async (d, w) => {
134
- await e.renameConversation(d, w), s(
135
- (N) => N.map((z) => z.sessionId === d ? { ...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
- }, [e]), { enabled: u = !0 } = t;
138
- return A(() => {
139
- u && m();
140
- }, [u, m]), {
157
+ }, [t]), { enabled: b = !0 } = a;
158
+ return j(() => {
159
+ b && h();
160
+ }, [b, h]), {
141
161
  conversations: r,
142
- activeConversationId: i,
143
- loading: n,
144
- loadConversations: m,
145
- switchConversation: v,
146
- newConversation: b,
147
- deleteConversation: h,
162
+ activeConversationId: c,
163
+ loading: l,
164
+ loadConversations: h,
165
+ switchConversation: w,
166
+ newConversation: v,
167
+ deleteConversation: m,
148
168
  renameConversation: g,
149
- setActiveConversationId: p
169
+ setActiveConversationId: f
150
170
  };
151
171
  }
152
- const V = Z(null);
153
- function P() {
154
- const t = Q(V);
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: e, children: l }) {
159
- const [r, s] = 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 = ne({
168
- sdk: t,
169
- onConversationChange: e == null ? void 0 : e.onConversationChange,
170
- enabled: i
171
- }), o = se({
172
- sdk: t,
173
- sessionId: n.activeConversationId,
174
- onSessionCreated: (h) => {
175
- n.setActiveConversationId(h), 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: e == null ? void 0 : e.onStreamStart,
178
- onStreamEnd: (h) => {
197
+ onStreamStart: t == null ? void 0 : t.onStreamStart,
198
+ onStreamEnd: (m) => {
179
199
  var g;
180
- (g = e == null ? void 0 : e.onStreamEnd) == null || g.call(e, h), n.loadConversations();
200
+ (g = t == null ? void 0 : t.onStreamEnd) == null || g.call(t, m), l.loadConversations();
181
201
  },
182
- onError: e == null ? void 0 : e.onError,
183
- onMessageSend: e == null ? void 0 : e.onMessageSend
184
- }), f = y(async (h) => {
185
- const g = await n.switchConversation(h);
186
- o.setMessages(g), s(!1);
187
- }, [n, o]), p = y(() => {
188
- n.newConversation(), o.setMessages([]), s(!1);
189
- }, [n, o]), m = y(async (h) => {
190
- await n.deleteConversation(h), n.activeConversationId === h && o.setMessages([]);
191
- }, [n, o]);
192
- A(() => {
193
- n.activeConversationId && o.messages.length === 0 && t.getMessages(n.activeConversationId).then((h) => {
194
- o.setMessages(h);
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
- s((h) => !h);
200
- }, []), b = {
201
- status: o.status,
202
- error: o.error,
203
- messages: o.messages,
204
- conversations: n.conversations,
205
- activeConversationId: n.activeConversationId,
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,
206
226
  isThreadListOpen: r,
207
- sendMessage: o.sendMessage,
208
- stop: o.stop,
209
- regenerate: o.regenerate,
210
- switchConversation: f,
211
- newConversation: p,
212
- deleteConversation: m,
213
- renameConversation: n.renameConversation,
214
- toggleThreadList: v,
215
- feedback: (h, g) => {
216
- t.feedback(h, g);
217
- }
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__ */ a(V.Provider, { value: b, children: l });
240
+ return /* @__PURE__ */ e(X.Provider, { value: v, children: n });
220
241
  }
221
- function C({ name: t, size: e = 16, color: l = "currentColor", className: r, style: s }) {
222
- return /* @__PURE__ */ a(
242
+ function x({ name: a, size: t = 16, color: n = "currentColor", className: r, style: s }) {
243
+ return /* @__PURE__ */ e(
223
244
  "svg",
224
245
  {
225
246
  className: r,
226
- style: { width: e, height: e, fill: l, verticalAlign: "middle", ...s },
247
+ style: { width: t, height: t, fill: n, verticalAlign: "middle", ...s },
227
248
  "aria-hidden": "true",
228
- children: /* @__PURE__ */ a("use", { href: `#icon-${t}` })
249
+ children: /* @__PURE__ */ e("use", { href: `#icon-${a}` })
229
250
  }
230
251
  );
231
252
  }
232
- function ie({ isOpen: t, onClick: e }) {
233
- return /* @__PURE__ */ a("button", { className: `sa-trigger ${t ? "sa-trigger-open" : ""}`, onClick: e, children: t ? /* @__PURE__ */ a(C, { name: "x", size: 24, color: "#fff" }) : /* @__PURE__ */ a(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 oe({ title: t, onClose: e, onToggleThreadList: l, showClose: r = !0 }) {
236
- return /* @__PURE__ */ x("div", { className: "sa-header", children: [
237
- /* @__PURE__ */ x("div", { className: "sa-header-left", children: [
238
- /* @__PURE__ */ a("div", { className: "sa-header-avatar", children: "A" }),
239
- /* @__PURE__ */ x("div", { className: "sa-header-info", children: [
240
- /* @__PURE__ */ a("div", { className: "sa-header-title", children: t }),
241
- /* @__PURE__ */ a("div", { className: "sa-header-status", children: "● Online" })
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: [
259
+ /* @__PURE__ */ e("div", { className: "sa-header-avatar", children: "A" }),
260
+ /* @__PURE__ */ u("div", { className: "sa-header-info", children: [
261
+ /* @__PURE__ */ e("div", { className: "sa-header-title", children: a }),
262
+ /* @__PURE__ */ e("div", { className: "sa-header-status", children: "● Online" })
242
263
  ] })
243
264
  ] }),
244
- /* @__PURE__ */ x("div", { className: "sa-header-actions", children: [
245
- /* @__PURE__ */ a("button", { className: "sa-header-btn", onClick: l, title: "会话列表", children: /* @__PURE__ */ a(C, { name: "menu", size: 16 }) }),
246
- r && /* @__PURE__ */ a("button", { className: "sa-header-btn", onClick: e, title: "关闭", children: /* @__PURE__ */ a(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 le(t) {
251
- const e = /* @__PURE__ */ new Date(), l = new Date(e.getFullYear(), e.getMonth(), e.getDate()).getTime(), r = l - 6 * 864e5, s = [], i = [], c = [];
252
- for (const o of t) {
253
- const f = new Date(o.updateTime).getTime();
254
- f >= l ? s.push(o) : f >= r ? i.push(o) : c.push(o);
255
- }
256
- const n = [];
257
- return s.length && n.push({ label: "今天", items: s }), i.length && n.push({ label: "最近 7 天", items: i }), c.length && n.push({ label: "更早", items: c }), n;
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;
258
279
  }
259
- function ce() {
280
+ function de() {
260
281
  const {
261
- conversations: t,
262
- activeConversationId: e,
263
- switchConversation: l,
282
+ conversations: a,
283
+ activeConversationId: t,
284
+ switchConversation: n,
264
285
  newConversation: r,
265
286
  deleteConversation: s,
266
- renameConversation: i,
267
- isThreadListOpen: c,
268
- toggleThreadList: n
269
- } = P(), [o, f] = I(null), [p, m] = I(""), v = y((g, u) => {
270
- f(g), m(u ?? "");
271
- }, []), b = y((g) => {
272
- p.trim() && i(g, p.trim()), f(null);
273
- }, [p, i]), h = ee(() => le(t), [t]);
274
- return c ? /* @__PURE__ */ x(te, { children: [
275
- /* @__PURE__ */ a("div", { className: "sa-thread-list-overlay", onClick: n }),
276
- /* @__PURE__ */ x("div", { className: "sa-thread-list", children: [
277
- /* @__PURE__ */ x("div", { className: "sa-thread-list-header", children: [
278
- /* @__PURE__ */ a("span", { className: "sa-thread-list-title", children: "会话记录" }),
279
- /* @__PURE__ */ x("button", { className: "sa-thread-list-new", onClick: r, children: [
280
- /* @__PURE__ */ a(C, { name: "plus", size: 14 }),
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 }),
281
302
  " 新会话"
282
303
  ] })
283
304
  ] }),
284
- /* @__PURE__ */ x("div", { className: "sa-thread-list-items", children: [
285
- t.length === 0 && /* @__PURE__ */ a("div", { className: "sa-thread-list-empty", children: "暂无会话" }),
286
- h.map((g) => /* @__PURE__ */ x("div", { className: "sa-thread-group", children: [
287
- /* @__PURE__ */ a("div", { className: "sa-thread-group-label", children: g.label }),
288
- g.items.map((u) => /* @__PURE__ */ x(
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(
289
310
  "div",
290
311
  {
291
- className: `sa-thread-item ${u.sessionId === e ? "active" : ""}`,
292
- onClick: () => l(u.sessionId),
312
+ className: `sa-thread-item ${b.sessionId === t ? "active" : ""}`,
313
+ onClick: () => n(b.sessionId),
293
314
  children: [
294
- o === u.sessionId ? /* @__PURE__ */ a(
315
+ i === b.sessionId ? /* @__PURE__ */ e(
295
316
  "input",
296
317
  {
297
318
  className: "sa-thread-item-edit",
298
- value: p,
299
- onChange: (d) => m(d.target.value),
300
- onBlur: () => b(u.sessionId),
319
+ value: f,
320
+ onChange: (d) => h(d.target.value),
321
+ onBlur: () => v(b.sessionId),
301
322
  onKeyDown: (d) => {
302
- d.key === "Enter" && b(u.sessionId), d.key === "Escape" && f(null);
323
+ d.key === "Enter" && v(b.sessionId), d.key === "Escape" && p(null);
303
324
  },
304
325
  onClick: (d) => d.stopPropagation(),
305
326
  autoFocus: !0
306
327
  }
307
- ) : /* @__PURE__ */ a(
328
+ ) : /* @__PURE__ */ e(
308
329
  "span",
309
330
  {
310
331
  className: "sa-thread-item-title",
311
332
  onDoubleClick: (d) => {
312
- d.stopPropagation(), v(u.sessionId, u.title);
333
+ d.stopPropagation(), w(b.sessionId, b.title);
313
334
  },
314
- children: u.title || "新会话"
335
+ children: b.title || "新会话"
315
336
  }
316
337
  ),
317
- /* @__PURE__ */ a(
338
+ /* @__PURE__ */ e(
318
339
  "button",
319
340
  {
320
341
  className: "sa-thread-item-delete",
321
342
  onClick: (d) => {
322
- d.stopPropagation(), s(u.sessionId);
343
+ d.stopPropagation(), s(b.sessionId);
323
344
  },
324
345
  title: "删除",
325
- children: /* @__PURE__ */ a(C, { name: "trash2", size: 14 })
346
+ children: /* @__PURE__ */ e(x, { name: "trash2", size: 14 })
326
347
  }
327
348
  )
328
349
  ]
329
350
  },
330
- u.sessionId
351
+ b.sessionId
331
352
  ))
332
353
  ] }, g.label))
333
354
  ] })
334
355
  ] })
335
356
  ] }) : null;
336
357
  }
337
- function de(t) {
338
- const e = R(null), l = R(!1), r = R(0), s = y(() => {
339
- const c = e.current;
340
- if (!c) return;
341
- const { scrollTop: n, scrollHeight: o, clientHeight: f } = c, p = o - n - f < 40;
342
- n < r.current && !p && (l.current = !0), p && (l.current = !1), r.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;
343
364
  }, []);
344
- A(() => {
345
- const c = e.current;
346
- if (c)
347
- return c.addEventListener("scroll", s, { passive: !0 }), () => c.removeEventListener("scroll", s);
348
- }, [s]), A(() => {
349
- if (l.current) return;
350
- const c = e.current;
351
- c && requestAnimationFrame(() => {
352
- 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;
353
374
  });
354
- }, t);
355
- const i = y(() => {
356
- l.current = !1;
357
- const c = e.current;
358
- 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);
359
380
  }, []);
360
- return { containerRef: e, scrollToBottom: i };
381
+ return { containerRef: t, scrollToBottom: c };
361
382
  }
362
- function M(t) {
363
- return t.value++;
383
+ function L(a) {
384
+ return a.value++;
364
385
  }
365
- function j(t, e) {
366
- const l = [], r = [], s = () => {
367
- r.length > 0 && (l.push(r.join("")), r.length = 0);
386
+ function B(a, t) {
387
+ const n = [], r = [], s = () => {
388
+ r.length > 0 && (n.push(r.join("")), r.length = 0);
368
389
  };
369
- let i = 0;
370
- for (; i < t.length; ) {
371
- const c = t[i];
372
- if (c === "`") {
373
- const n = t.indexOf("`", i + 1);
374
- if (n !== -1) {
375
- s(), l.push(
376
- /* @__PURE__ */ a("code", { className: "sa-inline-code", children: t.slice(i + 1, n) }, M(e))
377
- ), 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;
378
399
  continue;
379
400
  }
380
- } else if (c === "*" && t[i + 1] === "*") {
381
- const n = t.indexOf("**", i + 2);
382
- if (n !== -1) {
383
- s(), l.push(
384
- /* @__PURE__ */ a("strong", { children: j(t.slice(i + 2, n), e) }, M(e))
385
- ), 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;
386
407
  continue;
387
408
  }
388
- } else if (c === "*") {
389
- const n = t.indexOf("*", i + 1);
390
- if (n !== -1) {
391
- s(), l.push(
392
- /* @__PURE__ */ a("em", { children: j(t.slice(i + 1, n), e) }, M(e))
393
- ), 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;
394
415
  continue;
395
416
  }
396
- } else if (c === "[") {
397
- const n = t.indexOf("]", i + 1);
398
- if (n !== -1 && t[n + 1] === "(") {
399
- const o = t.indexOf(")", n + 2);
400
- if (o !== -1) {
401
- const f = t.slice(i + 1, n), p = t.slice(n + 2, o);
402
- s(), l.push(
403
- /* @__PURE__ */ a(
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(
424
+ /* @__PURE__ */ e(
404
425
  "a",
405
426
  {
406
- href: p,
427
+ href: f,
407
428
  target: "_blank",
408
429
  rel: "noreferrer",
409
- children: j(f, e)
430
+ children: B(p, t)
410
431
  },
411
- M(e)
432
+ L(t)
412
433
  )
413
- ), i = o + 1;
434
+ ), c = i + 1;
414
435
  continue;
415
436
  }
416
437
  }
417
438
  }
418
- r.push(c), i++;
439
+ r.push(o), c++;
419
440
  }
420
- return s(), l;
441
+ return s(), n;
421
442
  }
422
- function pe(t, e) {
423
- const l = [], r = t.split(`
443
+ function ue(a, t) {
444
+ const n = [], r = a.split(`
424
445
  `);
425
446
  let s = 0;
426
- const i = (o) => o.trim() === "", c = (o) => /^#{1,6}\s+\S/.test(o.trim()), n = (o) => /^(?:[-*+]|\d+[.)])\s+\S/.test(o.trim());
447
+ const c = (i) => i.trim() === "", o = (i) => /^#{1,6}\s+\S/.test(i.trim()), l = (i) => /^(?:[-*+]|\d+[.)])\s+\S/.test(i.trim());
427
448
  for (; s < r.length; ) {
428
- const o = r[s], f = o.trim();
429
- if (i(o)) {
449
+ const i = r[s], p = i.trim();
450
+ if (c(i)) {
430
451
  s++;
431
452
  continue;
432
453
  }
433
- if (c(o)) {
434
- const m = f.match(/^(#{1,6})\s+(.*)$/);
435
- if (m) {
436
- const b = `h${Math.min(m[1].length, 6)}`;
437
- l.push(
438
- q.createElement(
439
- b,
440
- { key: M(e) },
441
- j(m[2], e)
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)
442
463
  )
443
464
  );
444
465
  }
445
466
  s++;
446
467
  continue;
447
468
  }
448
- if (n(o)) {
449
- const m = /^\d+[.)]/.test(f), v = [];
450
- for (; s < r.length && n(r[s]); ) {
451
- const b = r[s].trim().match(/^(?:[-*+]|\d+[.)])\s+(.*)$/);
452
- b && v.push(
453
- /* @__PURE__ */ a("li", { children: j(b[1], e) }, M(e))
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))
454
475
  ), s++;
455
476
  }
456
- l.push(
457
- m ? /* @__PURE__ */ a("ol", { className: "sa-list", children: v }, M(e)) : /* @__PURE__ */ a("ul", { className: "sa-list", children: v }, M(e))
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))
458
479
  );
459
480
  continue;
460
481
  }
461
- const p = [];
462
- for (; s < r.length && !i(r[s]) && !c(r[s]) && !n(r[s]); )
463
- p.push(r[s]), s++;
464
- l.push(
465
- /* @__PURE__ */ a("p", { className: "sa-text-paragraph", children: j(p.join(" "), e) }, M(e))
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))
466
487
  );
467
488
  }
468
- return l;
489
+ return n;
469
490
  }
470
- function fe(t) {
471
- const e = { value: 0 }, l = [], r = t.split("```");
491
+ function fe(a) {
492
+ const t = { value: 0 }, n = [], r = a.split("```");
472
493
  for (let s = 0; s < r.length; s++)
473
494
  if (s % 2 === 0)
474
- l.push(...pe(r[s], e));
495
+ n.push(...ue(r[s], t));
475
496
  else if (r[s].trim() !== "") {
476
- let i = r[s].replace(/^\r?\n/, "");
477
- i = i.replace(/^[a-zA-Z0-9_+#.-]+\r?\n/, ""), i = i.replace(/\r?\n$/, ""), l.push(
478
- /* @__PURE__ */ a("pre", { className: "sa-code-block", children: /* @__PURE__ */ a("code", { children: i }) }, M(e))
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))
479
500
  );
480
501
  }
481
- return l;
502
+ return n;
482
503
  }
483
- function he({ content: t }) {
484
- return /* @__PURE__ */ a("div", { className: "sa-text-part", children: fe(t) });
504
+ function me({ content: a }) {
505
+ return /* @__PURE__ */ e("div", { className: "sa-text-part", children: fe(a) });
485
506
  }
486
- function ue({ content: t }) {
487
- const [e, l] = I(!1);
488
- return /* @__PURE__ */ x("div", { className: "sa-thinking-part", onClick: () => l(!e), children: [
489
- /* @__PURE__ */ x("div", { className: "sa-thinking-header", children: [
490
- /* @__PURE__ */ a("span", { className: "sa-thinking-icon", children: /* @__PURE__ */ a(C, { name: "brain", size: 14 }) }),
491
- /* @__PURE__ */ a("span", { className: "sa-thinking-label", children: "思考过程" }),
492
- /* @__PURE__ */ a("span", { className: `sa-thinking-arrow ${e ? "expanded" : ""}`, children: /* @__PURE__ */ a(C, { name: "chevron-right", size: 12 }) })
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 }) }),
512
+ /* @__PURE__ */ e("span", { className: "sa-thinking-label", children: "思考过程" }),
513
+ /* @__PURE__ */ e("span", { className: `sa-thinking-arrow ${t ? "expanded" : ""}`, children: /* @__PURE__ */ e(x, { name: "chevron-right", size: 12 }) })
493
514
  ] }),
494
- e && /* @__PURE__ */ a("div", { className: "sa-thinking-content", children: t })
515
+ t && /* @__PURE__ */ e("div", { className: "sa-thinking-content", children: a })
495
516
  ] });
496
517
  }
497
- function me({ toolName: t, toolCallId: e, args: l }) {
498
- const [r, s] = I(!1);
499
- let i = l;
518
+ function ge({ toolName: a, toolCallId: t, args: n }) {
519
+ const [r, s] = z(!1);
520
+ let c = n;
500
521
  try {
501
- i = JSON.stringify(JSON.parse(l), null, 2);
522
+ c = JSON.stringify(JSON.parse(n), null, 2);
502
523
  } catch {
503
524
  }
504
- return /* @__PURE__ */ x("div", { className: "sa-tool-call-part", children: [
505
- /* @__PURE__ */ x("div", { className: "sa-tool-call-header", onClick: () => s(!r), children: [
506
- /* @__PURE__ */ a("span", { className: "sa-tool-icon", children: /* @__PURE__ */ a(C, { name: "zap", size: 14 }) }),
507
- /* @__PURE__ */ x("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: [
508
529
  "调用工具: ",
509
- t
530
+ a
510
531
  ] }),
511
- /* @__PURE__ */ a("span", { className: `sa-thinking-arrow ${r ? "expanded" : ""}`, children: /* @__PURE__ */ a(C, { name: "chevron-right", size: 12 }) })
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
568
+ ] }),
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 })
512
586
  ] }),
513
- r && /* @__PURE__ */ a("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
+ )) })
514
600
  ] });
515
601
  }
516
- function ge({ toolName: t, toolCallId: e, content: l }) {
517
- return /* @__PURE__ */ x("div", { className: "sa-tool-result-part", children: [
518
- /* @__PURE__ */ x("div", { className: "sa-tool-result-header", children: [
519
- /* @__PURE__ */ a("span", { className: "sa-tool-icon", children: /* @__PURE__ */ a(C, { name: "circle-check", size: 14, color: "#10b981" }) }),
520
- /* @__PURE__ */ a("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 })
521
616
  ] }),
522
- /* @__PURE__ */ a("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
+ ) })
643
+ ] });
644
+ }
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 })
653
+ ] }),
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
+ ) })
523
688
  ] });
524
689
  }
525
- function xe({ content: t, onRetry: e }) {
526
- return /* @__PURE__ */ x("div", { className: "sa-error-part", children: [
527
- /* @__PURE__ */ x("div", { className: "sa-error-content", children: [
528
- /* @__PURE__ */ a("span", { className: "sa-error-icon", children: /* @__PURE__ */ a(C, { name: "triangle-alert", size: 14 }) }),
529
- /* @__PURE__ */ a("span", { children: t })
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 })
530
705
  ] }),
531
- e && /* @__PURE__ */ a("button", { className: "sa-error-retry", onClick: e, children: "重试" })
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
+ ] })
532
720
  ] });
533
721
  }
534
- function be({ message: t, onCopy: e, onRegenerate: l, onFeedback: r }) {
535
- const { status: s } = P(), [i, c] = I(null), [n, o] = I(!1);
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);
536
778
  if (s !== "ready" && s !== "error") return null;
537
- const f = y(() => {
538
- e(), o(!0), setTimeout(() => o(!1), 2e3);
539
- }, [e]), p = y((m) => {
540
- const v = i === m ? null : m;
541
- c(v), v && (r == null || r(t.id, v));
542
- }, [i, t.id, r]);
543
- return /* @__PURE__ */ x("div", { className: "sa-action-bar", children: [
544
- /* @__PURE__ */ x("button", { className: "sa-action-btn", onClick: f, title: "复制", children: [
545
- /* @__PURE__ */ a(C, { name: n ? "circle-check" : "copy", size: 14 }),
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 }),
546
788
  " ",
547
- n ? "已复制" : "复制"
789
+ l ? "已复制" : "复制"
548
790
  ] }),
549
- /* @__PURE__ */ x("button", { className: "sa-action-btn", onClick: l, title: "重新生成", children: [
550
- /* @__PURE__ */ a(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 }),
551
793
  " 重新生成"
552
794
  ] }),
553
- /* @__PURE__ */ a("span", { className: "sa-action-divider" }),
554
- /* @__PURE__ */ a(
795
+ /* @__PURE__ */ e("span", { className: "sa-action-divider" }),
796
+ /* @__PURE__ */ e(
555
797
  "button",
556
798
  {
557
- className: `sa-action-btn ${i === "like" ? "sa-action-btn-active" : ""}`,
558
- onClick: () => p("like"),
799
+ className: `sa-action-btn ${c === "like" ? "sa-action-btn-active" : ""}`,
800
+ onClick: () => f("like"),
559
801
  title: "有用",
560
- children: /* @__PURE__ */ a(C, { name: "thumbs-up", size: 14 })
802
+ children: /* @__PURE__ */ e(x, { name: "thumbs-up", size: 14 })
561
803
  }
562
804
  ),
563
- /* @__PURE__ */ a(
805
+ /* @__PURE__ */ e(
564
806
  "button",
565
807
  {
566
- className: `sa-action-btn ${i === "dislike" ? "sa-action-btn-active" : ""}`,
567
- onClick: () => p("dislike"),
808
+ className: `sa-action-btn ${c === "dislike" ? "sa-action-btn-active" : ""}`,
809
+ onClick: () => f("dislike"),
568
810
  title: "无用",
569
- children: /* @__PURE__ */ a(C, { name: "thumbs-down", size: 14 })
811
+ children: /* @__PURE__ */ e(x, { name: "thumbs-down", size: 14 })
570
812
  }
571
813
  )
572
814
  ] });
573
815
  }
574
- function Y({ src: t, role: e }) {
575
- const l = e === "assistant" ? "A" : "U";
576
- return t ? t.startsWith("http") || t.startsWith("/") || t.startsWith("data:") ? /* @__PURE__ */ a("div", { className: `sa-avatar sa-avatar-${e}`, children: /* @__PURE__ */ a("img", { src: t, alt: e, style: { width: "100%", height: "100%", borderRadius: "inherit", objectFit: "cover" } }) }) : /* @__PURE__ */ a("div", { className: `sa-avatar sa-avatar-${e}`, children: t }) : /* @__PURE__ */ a("div", { className: `sa-avatar sa-avatar-${e}`, 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 });
577
819
  }
578
- function ve({ message: t, isStreaming: e, isLast: l, slots: r, avatar: s }) {
579
- const { regenerate: i, feedback: c } = P(), n = y(() => {
580
- var d;
581
- const u = 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(`
582
824
  `);
583
- (d = navigator.clipboard) == null || d.writeText(u).catch(() => {
825
+ (y = navigator.clipboard) == null || y.writeText(d).catch(() => {
584
826
  });
585
- }, [t]), o = t.role === "user", f = r.Message;
827
+ }, [a]), p = a.role === "user", f = r.Message;
586
828
  if (f)
587
- return /* @__PURE__ */ a(
829
+ return /* @__PURE__ */ e(
588
830
  f,
589
831
  {
590
- message: t,
591
- isStreaming: e,
592
- isLast: l,
832
+ message: a,
833
+ isStreaming: t,
834
+ isLast: n,
593
835
  avatar: s,
594
836
  slots: r,
595
- onCopy: n,
596
- onRegenerate: i,
597
- onFeedback: c
837
+ onCopy: i,
838
+ onRegenerate: c,
839
+ onFeedback: o
598
840
  }
599
841
  );
600
- const p = r.TextPart ?? he, m = r.ThinkingPart ?? ue, v = r.ToolCallPart ?? me, b = r.ToolResultPart ?? ge, h = r.ErrorPart ?? xe, g = r.ActionBar ?? be;
601
- return /* @__PURE__ */ x("div", { className: `sa-message ${o ? "sa-message-user" : "sa-message-assistant"}`, children: [
602
- !o && /* @__PURE__ */ a(Y, { src: s == null ? void 0 : s.assistant, role: "assistant" }),
603
- /* @__PURE__ */ x("div", { className: "sa-message-body", children: [
604
- t.parts.map((u, d) => {
605
- switch (u.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) {
606
848
  case "text":
607
- return /* @__PURE__ */ a(p, { content: u.content }, d);
849
+ return /* @__PURE__ */ e(h, { content: d.content }, y);
608
850
  case "thinking":
609
- return /* @__PURE__ */ a(m, { content: u.content }, d);
851
+ return /* @__PURE__ */ e(w, { content: d.content }, y);
610
852
  case "tool_call":
611
- return /* @__PURE__ */ a(v, { toolName: u.toolName, toolCallId: u.toolCallId, args: u.args }, d);
853
+ return /* @__PURE__ */ e(v, { toolName: d.toolName, toolCallId: d.toolCallId, args: d.args }, y);
612
854
  case "tool_result":
613
- return /* @__PURE__ */ a(b, { toolName: u.toolName, toolCallId: u.toolCallId, content: u.content }, d);
855
+ return /* @__PURE__ */ e(m, { toolName: d.toolName, toolCallId: d.toolCallId, content: d.content }, y);
614
856
  case "error":
615
- return /* @__PURE__ */ a(h, { content: u.content, onRetry: i }, d);
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
+ );
616
869
  default:
617
870
  return null;
618
871
  }
619
872
  }),
620
- e && l && !o && /* @__PURE__ */ a("span", { className: "sa-streaming-cursor", children: "|" }),
621
- !o && !e && t.parts.length > 0 && /* @__PURE__ */ a(g, { 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 })
622
875
  ] }),
623
- o && /* @__PURE__ */ a(Y, { src: s == null ? void 0 : s.user, role: "user" })
876
+ p && /* @__PURE__ */ e(Y, { src: s == null ? void 0 : s.user, role: "user" })
624
877
  ] });
625
878
  }
626
- function we({ message: t, suggestedPrompts: e, onPromptClick: l }) {
627
- return /* @__PURE__ */ x("div", { className: "sa-welcome", children: [
628
- /* @__PURE__ */ a("div", { className: "sa-welcome-icon", children: /* @__PURE__ */ a(C, { name: "sparkles", size: 40 }) }),
629
- /* @__PURE__ */ a("p", { className: "sa-welcome-message", children: t || "你好!有什么可以帮你的?" }),
630
- e && e.length > 0 && /* @__PURE__ */ a("div", { className: "sa-welcome-prompts", children: e.map((r, s) => /* @__PURE__ */ a(
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(
631
884
  "button",
632
885
  {
633
886
  className: "sa-welcome-prompt",
634
- onClick: () => l(r),
887
+ onClick: () => n(r),
635
888
  children: r
636
889
  },
637
890
  s
638
891
  )) })
639
892
  ] });
640
893
  }
641
- function J({ slots: t, welcomeMessage: e, suggestedPrompts: l, avatar: r }) {
642
- const { messages: s, status: i, sendMessage: c } = P(), { containerRef: n } = de([s]), o = i === "streaming", f = t.WelcomeScreen ?? we;
643
- return s.length === 0 ? /* @__PURE__ */ a("div", { className: "sa-thread", ref: n, children: /* @__PURE__ */ a(
644
- f,
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,
645
898
  {
646
- message: e,
647
- suggestedPrompts: l,
648
- onPromptClick: c
899
+ message: t,
900
+ suggestedPrompts: n,
901
+ onPromptClick: o
649
902
  }
650
- ) }) : /* @__PURE__ */ a("div", { className: "sa-thread", ref: n, children: s.map((p, m) => /* @__PURE__ */ a(
651
- ve,
903
+ ) }) : /* @__PURE__ */ e("div", { className: "sa-thread", ref: l, children: s.map((f, h) => /* @__PURE__ */ e(
904
+ Le,
652
905
  {
653
- message: p,
654
- isStreaming: o,
655
- isLast: m === s.length - 1,
656
- slots: t,
906
+ message: f,
907
+ isStreaming: i,
908
+ isLast: h === s.length - 1,
909
+ slots: a,
657
910
  avatar: r
658
911
  },
659
- p.id
912
+ f.id
660
913
  )) });
661
914
  }
662
- function X() {
663
- const { status: t, sendMessage: e, stop: l } = P(), [r, s] = I(""), i = R(null), c = t === "streaming" || t === "submitted", n = y(() => {
664
- const p = r.trim();
665
- !p || c || (e(p), s(""), i.current && (i.current.style.height = "auto"));
666
- }, [r, c, e]), o = y((p) => {
667
- p.key === "Enter" && !p.shiftKey && (p.preventDefault(), n());
668
- }, [n]), f = y((p) => {
669
- s(p.target.value);
670
- const m = p.target;
671
- 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";
672
925
  }, []);
673
- return /* @__PURE__ */ x("div", { className: "sa-composer", children: [
674
- /* @__PURE__ */ a(
926
+ return /* @__PURE__ */ u("div", { className: "sa-composer", children: [
927
+ /* @__PURE__ */ e(
675
928
  "textarea",
676
929
  {
677
- ref: i,
930
+ ref: c,
678
931
  className: "sa-composer-input",
679
932
  value: r,
680
- onChange: f,
681
- onKeyDown: o,
933
+ onChange: p,
934
+ onKeyDown: i,
682
935
  placeholder: "输入消息...",
683
936
  rows: 1,
684
- disabled: t === "submitted"
937
+ disabled: a === "submitted"
685
938
  }
686
939
  ),
687
- c ? /* @__PURE__ */ a("button", { className: "sa-composer-stop", onClick: l, title: "停止", children: /* @__PURE__ */ a(C, { name: "circle-stop", size: 16, color: "#fff" }) }) : /* @__PURE__ */ a(
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(
688
941
  "button",
689
942
  {
690
943
  className: "sa-composer-send",
691
- onClick: n,
944
+ onClick: l,
692
945
  disabled: !r.trim(),
693
946
  title: "发送",
694
- children: /* @__PURE__ */ a(C, { name: "arrow-up", size: 16, color: "#fff" })
947
+ children: /* @__PURE__ */ e(x, { name: "arrow-up", size: 16, color: "#fff" })
695
948
  }
696
949
  )
697
950
  ] });
698
951
  }
699
- function ye({ isOpen: t, onClose: e, title: l, slots: r, welcomeMessage: s, suggestedPrompts: i, avatar: c }) {
700
- const { status: n, sendMessage: o, stop: f, toggleThreadList: p, conversations: m, activeConversationId: v, switchConversation: b, newConversation: h, deleteConversation: g, renameConversation: u, isThreadListOpen: d } = P();
701
- if (!t) return null;
702
- const w = r.Header, N = r.Composer, z = r.ThreadList;
703
- return /* @__PURE__ */ x("div", { className: "sa-panel", children: [
704
- w ? /* @__PURE__ */ a(w, { title: l, onClose: e, onToggleThreadList: p }) : /* @__PURE__ */ a(oe, { title: l, onClose: e, onToggleThreadList: p }),
705
- z && d ? /* @__PURE__ */ a(
706
- 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,
707
960
  {
708
- conversations: m,
709
- activeSessionId: v,
710
- onSwitch: b,
711
- onNew: h,
961
+ conversations: h,
962
+ activeSessionId: w,
963
+ onSwitch: v,
964
+ onNew: m,
712
965
  onDelete: g,
713
- onRename: u
966
+ onRename: b
714
967
  }
715
- ) : /* @__PURE__ */ a(ce, {}),
716
- /* @__PURE__ */ a(J, { slots: r, welcomeMessage: s, suggestedPrompts: i, avatar: c }),
717
- N ? /* @__PURE__ */ a(N, { status: n, onSend: o, onStop: f }) : /* @__PURE__ */ a(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, {})
718
971
  ] });
719
972
  }
720
- function ke({
721
- conversations: t,
722
- activeSessionId: e,
723
- onSwitch: l,
973
+ function Ae({
974
+ conversations: a,
975
+ activeSessionId: t,
976
+ onSwitch: n,
724
977
  onNew: r,
725
978
  onDelete: s,
726
- isCollapsed: i,
727
- onToggleCollapse: c
979
+ isCollapsed: c,
980
+ onToggleCollapse: o
728
981
  }) {
729
- const [n, o] = I(null), [f, p] = I(null), m = y((b, h) => {
730
- h.stopPropagation(), f === b ? (s(b), p(null)) : (p(b), setTimeout(() => p(null), 3e3));
731
- }, [f, s]), v = (() => {
732
- const b = Date.now(), h = [], g = [], u = [];
733
- for (const w of t) {
734
- const N = b - new Date(w.updateTime).getTime();
735
- N < 864e5 ? h.push(w) : N < 6048e5 ? g.push(w) : u.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);
736
989
  }
737
990
  const d = [];
738
- return h.length && d.push({ label: "今天", items: h }), g.length && d.push({ label: "最近 7 天", items: g }), u.length && d.push({ label: "更早", items: u }), 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;
739
992
  })();
740
- return i ? /* @__PURE__ */ x("div", { className: "sa-fp-sidebar sa-fp-sidebar-collapsed", children: [
741
- /* @__PURE__ */ a("button", { className: "sa-fp-sidebar-toggle", onClick: c, title: "展开", children: /* @__PURE__ */ a(C, { name: "panel-left", size: 18 }) }),
742
- /* @__PURE__ */ a("button", { className: "sa-fp-sidebar-toggle", onClick: r, title: "新会话", style: { marginTop: 4 }, children: /* @__PURE__ */ a(C, { name: "plus", size: 18 }) })
743
- ] }) : /* @__PURE__ */ x("div", { className: "sa-fp-sidebar", children: [
744
- /* @__PURE__ */ x("div", { className: "sa-fp-sidebar-header", children: [
745
- /* @__PURE__ */ x("button", { className: "sa-fp-sidebar-new", onClick: r, children: [
746
- /* @__PURE__ */ a(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 }),
747
1000
  " ",
748
- /* @__PURE__ */ a("span", { children: "新会话" })
1001
+ /* @__PURE__ */ e("span", { children: "新会话" })
749
1002
  ] }),
750
- /* @__PURE__ */ a("button", { className: "sa-fp-sidebar-toggle", onClick: c, title: "收起侧边栏", children: /* @__PURE__ */ a(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 }) })
751
1004
  ] }),
752
- /* @__PURE__ */ x("div", { className: "sa-fp-sidebar-list", children: [
753
- t.length === 0 && /* @__PURE__ */ a("div", { className: "sa-fp-sidebar-empty", children: "开始你的第一个对话" }),
754
- v.map((b) => /* @__PURE__ */ x("div", { children: [
755
- /* @__PURE__ */ a("div", { className: "sa-fp-sidebar-group", children: b.label }),
756
- b.items.map((h) => {
757
- const g = h.sessionId === e, u = n === h.sessionId, d = f === h.sessionId;
758
- return /* @__PURE__ */ x(
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(
759
1012
  "div",
760
1013
  {
761
1014
  className: `sa-fp-sidebar-item ${g ? "active" : ""}`,
762
- onClick: () => l(h.sessionId),
763
- onMouseEnter: () => o(h.sessionId),
764
- onMouseLeave: () => o(null),
1015
+ onClick: () => n(m.sessionId),
1016
+ onMouseEnter: () => i(m.sessionId),
1017
+ onMouseLeave: () => i(null),
765
1018
  children: [
766
- /* @__PURE__ */ a("span", { className: "sa-fp-sidebar-item-title", children: h.title || "新会话" }),
767
- u && /* @__PURE__ */ a(
1019
+ /* @__PURE__ */ e("span", { className: "sa-fp-sidebar-item-title", children: m.title || "新会话" }),
1020
+ b && /* @__PURE__ */ e(
768
1021
  "button",
769
1022
  {
770
1023
  className: `sa-fp-sidebar-item-action ${d ? "danger" : ""}`,
771
- onClick: (w) => m(h.sessionId, w),
1024
+ onClick: (y) => h(m.sessionId, y),
772
1025
  title: d ? "确认删除" : "删除",
773
- children: /* @__PURE__ */ a(C, { name: d ? "x" : "trash2", size: 14 })
1026
+ children: /* @__PURE__ */ e(x, { name: d ? "x" : "trash2", size: 14 })
774
1027
  }
775
1028
  )
776
1029
  ]
777
1030
  },
778
- h.sessionId
1031
+ m.sessionId
779
1032
  );
780
1033
  })
781
- ] }, b.label))
1034
+ ] }, v.label))
782
1035
  ] })
783
1036
  ] });
784
1037
  }
785
- function Ce({ title: t, slots: e, welcomeMessage: l, suggestedPrompts: r, sidebarDefaultOpen: s = !0, onClose: i, avatar: c }) {
1038
+ function De({ title: a, slots: t, welcomeMessage: n, suggestedPrompts: r, sidebarDefaultOpen: s = !0, onClose: c, avatar: o }) {
786
1039
  const {
787
- status: n,
788
- sendMessage: o,
789
- stop: f,
790
- conversations: p,
791
- activeConversationId: m,
792
- switchConversation: v,
793
- newConversation: b,
794
- deleteConversation: h,
1040
+ status: l,
1041
+ sendMessage: i,
1042
+ stop: p,
1043
+ conversations: f,
1044
+ activeConversationId: h,
1045
+ switchConversation: w,
1046
+ newConversation: v,
1047
+ deleteConversation: m,
795
1048
  renameConversation: g
796
- } = P(), [u, d] = I(s), w = y(() => d((O) => !O), []), N = e.ThreadList, z = e.Composer;
797
- return /* @__PURE__ */ x("div", { className: "sa-fullpage", children: [
798
- N ? /* @__PURE__ */ a("div", { className: `sa-fp-sidebar-wrapper ${u ? "" : "sa-fp-sidebar-wrapper-collapsed"}`, children: /* @__PURE__ */ a(
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: [
1051
+ N ? /* @__PURE__ */ e("div", { className: `sa-fp-sidebar-wrapper ${b ? "" : "sa-fp-sidebar-wrapper-collapsed"}`, children: /* @__PURE__ */ e(
799
1052
  N,
800
1053
  {
801
- conversations: p,
802
- activeSessionId: m,
803
- onSwitch: v,
804
- onNew: b,
805
- onDelete: h,
1054
+ conversations: f,
1055
+ activeSessionId: h,
1056
+ onSwitch: w,
1057
+ onNew: v,
1058
+ onDelete: m,
806
1059
  onRename: g
807
1060
  }
808
- ) }) : /* @__PURE__ */ a(
809
- ke,
1061
+ ) }) : /* @__PURE__ */ e(
1062
+ Ae,
810
1063
  {
811
- conversations: p,
812
- activeSessionId: m,
813
- onSwitch: v,
814
- onNew: b,
815
- onDelete: h,
1064
+ conversations: f,
1065
+ activeSessionId: h,
1066
+ onSwitch: w,
1067
+ onNew: v,
1068
+ onDelete: m,
816
1069
  onRename: g,
817
- isCollapsed: !u,
818
- onToggleCollapse: w
1070
+ isCollapsed: !b,
1071
+ onToggleCollapse: y
819
1072
  }
820
1073
  ),
821
- /* @__PURE__ */ x("div", { className: "sa-fp-main", children: [
822
- /* @__PURE__ */ x("div", { className: "sa-fp-header", children: [
823
- !u && !N && /* @__PURE__ */ a("button", { className: "sa-fp-header-btn", onClick: w, title: "展开侧边栏", children: /* @__PURE__ */ a(C, { name: "panel-left", size: 18 }) }),
824
- /* @__PURE__ */ a("div", { className: "sa-fp-header-title", children: t }),
825
- /* @__PURE__ */ a("div", { className: "sa-fp-header-actions", children: i && /* @__PURE__ */ a("button", { className: "sa-fp-header-btn", onClick: i, title: "关闭", children: /* @__PURE__ */ a(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 }) }) })
826
1079
  ] }),
827
- /* @__PURE__ */ a(J, { slots: e, welcomeMessage: l, suggestedPrompts: r, avatar: c }),
828
- z ? /* @__PURE__ */ a(z, { status: n, onSend: o, onStop: f }) : /* @__PURE__ */ a(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, {})
829
1082
  ] })
830
1083
  ] });
831
1084
  }
832
- function Ne(t) {
833
- const { sdk: e, mode: l = "floating", slots: r = {}, hooks: s = {}, welcomeMessage: i, suggestedPrompts: c, title: n = "AI Assistant", initialOpen: o = !1, onOpenChange: f, sidebarDefaultOpen: p, avatar: m } = t, [v, b] = I(o);
834
- A(() => {
835
- b(o);
836
- }, [o]);
837
- const h = y(() => {
838
- var w, N;
839
- const d = !v;
840
- b(d), f == null || f(d), d ? (w = s.onOpen) == null || w.call(s) : (N = s.onClose) == null || N.call(s);
841
- }, [v, s, f]), g = y(() => {
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(() => {
842
1095
  var d;
843
- b(!1), f == null || f(!1), (d = s.onClose) == null || d.call(s);
844
- }, [s, f]), u = r.Trigger ?? ie;
845
- return l === "fullpage" ? v ? /* @__PURE__ */ a(U, { sdk: e, hooks: s, children: /* @__PURE__ */ a(
846
- Ce,
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,
847
1100
  {
848
- title: n,
1101
+ title: l,
849
1102
  slots: r,
850
- welcomeMessage: i,
851
- suggestedPrompts: c,
852
- sidebarDefaultOpen: p,
1103
+ welcomeMessage: c,
1104
+ suggestedPrompts: o,
1105
+ sidebarDefaultOpen: f,
853
1106
  onClose: g,
854
- avatar: m
1107
+ avatar: h
855
1108
  }
856
- ) }) : null : /* @__PURE__ */ x(U, { sdk: e, hooks: s, children: [
857
- /* @__PURE__ */ a(u, { isOpen: v, onClick: h }),
858
- /* @__PURE__ */ a(
859
- ye,
1109
+ ) }) : null : /* @__PURE__ */ u(U, { sdk: t, hooks: s, children: [
1110
+ /* @__PURE__ */ e(b, { isOpen: w, onClick: m }),
1111
+ /* @__PURE__ */ e(
1112
+ $e,
860
1113
  {
861
- isOpen: v,
1114
+ isOpen: w,
862
1115
  onClose: g,
863
- title: n,
1116
+ title: l,
864
1117
  slots: r,
865
- welcomeMessage: i,
866
- suggestedPrompts: c,
867
- avatar: m
1118
+ welcomeMessage: c,
1119
+ suggestedPrompts: o,
1120
+ avatar: h
868
1121
  }
869
1122
  )
870
1123
  ] });
871
1124
  }
872
- const ze = `
1125
+ const Re = `
873
1126
  [data-super-agent-widget] {
874
1127
  --sa-primary-dark: color-mix(in srgb, var(--sa-primary) 82%, #000);
875
1128
  --sa-primary-light: color-mix(in srgb, var(--sa-primary) 10%, #fff);
@@ -1699,6 +1952,191 @@ const ze = `
1699
1952
  animation: sa-blink 1s steps(2, start) infinite;
1700
1953
  }
1701
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
+
1702
2140
  /* ── Animations ──────────────────────────────────────────── */
1703
2141
 
1704
2142
  @keyframes sa-slide-up {
@@ -2004,7 +2442,7 @@ const ze = `
2004
2442
  border-color: #d4d4d8;
2005
2443
  box-shadow: 0 0 0 3px rgba(99,102,241,0.08);
2006
2444
  }
2007
- `, Ie = {
2445
+ `, je = {
2008
2446
  primaryColor: "#6366f1",
2009
2447
  backgroundColor: "#ffffff",
2010
2448
  fontFamily: "system-ui, -apple-system, sans-serif",
@@ -2013,77 +2451,78 @@ const ze = `
2013
2451
  panelHeight: 520,
2014
2452
  zIndex: 9999
2015
2453
  };
2016
- function Te(t) {
2017
- const e = { ...Ie, ...t };
2454
+ function Oe(a) {
2455
+ const t = { ...je, ...a };
2018
2456
  return [
2019
- `--sa-primary: ${e.primaryColor}`,
2020
- `--sa-bg: ${e.backgroundColor}`,
2021
- `--sa-font: ${e.fontFamily}`,
2022
- `--sa-radius: ${e.borderRadius}px`,
2023
- `--sa-panel-width: ${e.panelWidth}px`,
2024
- `--sa-panel-height: ${e.panelHeight}px`,
2025
- `--sa-z-index: ${e.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}`
2026
2464
  ].join("; ");
2027
2465
  }
2028
- function Re(t, e) {
2029
- const l = typeof t == "string" ? document.querySelector(t) : t;
2030
- if (!l)
2031
- throw new Error(`Target element not found: ${t}`);
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}`);
2032
2470
  const r = document.createElement("div");
2033
2471
  r.setAttribute("data-super-agent-widget", "");
2034
- const s = Te(e.theme ?? {});
2035
- if (r.setAttribute("style", s), l.appendChild(r), !document.getElementById("sa-widget-styles")) {
2036
- const o = document.createElement("style");
2037
- o.id = "sa-widget-styles", o.textContent = ze, document.head.appendChild(o);
2038
- }
2039
- let i = ae(r), c = !1;
2040
- const n = (o) => {
2041
- i && i.render(
2042
- q.createElement(Ne, {
2043
- ...e,
2044
- initialOpen: o ?? c,
2045
- onOpenChange: (f) => {
2046
- c = f;
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;
2047
2485
  }
2048
2486
  })
2049
2487
  );
2050
2488
  };
2051
- return n(!1), {
2489
+ return l(!1), {
2052
2490
  open() {
2053
- c = !0, n(!0);
2491
+ o = !0, l(!0);
2054
2492
  },
2055
2493
  close() {
2056
- c = !1, n(!1);
2494
+ o = !1, l(!1);
2057
2495
  },
2058
2496
  destroy() {
2059
- i && (i.unmount(), i = null), r.remove();
2497
+ c && (c.unmount(), c = null), r.remove();
2060
2498
  }
2061
2499
  };
2062
2500
  }
2063
2501
  export {
2064
- be as ActionBar,
2502
+ Me as ActionBar,
2065
2503
  U as ChatProvider,
2066
- Ne as ChatWidget,
2067
- X as Composer,
2068
- xe as ErrorPart,
2069
- Ce as FullpageLayout,
2070
- oe as Header,
2071
- C as Icon,
2072
- ve as Message,
2073
- he as TextPart,
2074
- ue as ThinkingPart,
2075
- J as Thread,
2076
- ce as ThreadList,
2077
- me as ToolCallPart,
2078
- ge as ToolResultPart,
2079
- ie as Trigger,
2080
- we as WelcomeScreen,
2081
- Ie as defaultTheme,
2082
- Re as mount,
2083
- Te as themeToCSSVars,
2084
- de as useAutoScroll,
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,
2085
2524
  se as useChat,
2086
- P as useChatContext,
2087
- ne as useConversations,
2088
- ze as widgetStyles
2525
+ O as useChatContext,
2526
+ ie as useConversations,
2527
+ Re as widgetStyles
2089
2528
  };