super-agent-sdk 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1316 -0
- package/dist/index.cjs +5 -0
- package/dist/index.d.ts +96 -0
- package/dist/index.mjs +345 -0
- package/dist/widget.cjs +1124 -0
- package/dist/widget.d.ts +394 -0
- package/dist/widget.mjs +2077 -0
- package/package.json +50 -0
package/dist/widget.mjs
ADDED
|
@@ -0,0 +1,2077 @@
|
|
|
1
|
+
import X, { useState as I, useRef as M, useCallback as w, useEffect as P, createContext as ae, useContext as te } from "react";
|
|
2
|
+
import re from "react-dom";
|
|
3
|
+
import { jsx as e, jsxs as g, Fragment as se } from "react/jsx-runtime";
|
|
4
|
+
var F, H = re;
|
|
5
|
+
if (process.env.NODE_ENV === "production")
|
|
6
|
+
F = H.createRoot, H.hydrateRoot;
|
|
7
|
+
else {
|
|
8
|
+
var q = H.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
|
|
9
|
+
F = function(t, a) {
|
|
10
|
+
q.usingClientEntryPoint = !0;
|
|
11
|
+
try {
|
|
12
|
+
return H.createRoot(t, a);
|
|
13
|
+
} finally {
|
|
14
|
+
q.usingClientEntryPoint = !1;
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
function ne(t) {
|
|
19
|
+
const { sdk: a, sessionId: l, onSessionCreated: s, onStreamStart: r, onStreamEnd: i, onError: c, onMessageSend: n } = t, [o, u] = I([]), [p, m] = I("ready"), [v, x] = I(null), d = M(null), h = M(!1), b = M(l);
|
|
20
|
+
b.current = l;
|
|
21
|
+
const f = w((z) => {
|
|
22
|
+
if (h.current) return;
|
|
23
|
+
h.current = !0, n == null || n(z);
|
|
24
|
+
const D = {
|
|
25
|
+
id: `user_${Date.now()}`,
|
|
26
|
+
role: "user",
|
|
27
|
+
parts: [{ type: "text", content: z }],
|
|
28
|
+
timestamp: Date.now()
|
|
29
|
+
}, S = `assistant_${Date.now()}`, ee = {
|
|
30
|
+
id: S,
|
|
31
|
+
role: "assistant",
|
|
32
|
+
parts: [],
|
|
33
|
+
timestamp: Date.now()
|
|
34
|
+
};
|
|
35
|
+
u((T) => [...T, D, ee]), m("submitted"), x(null);
|
|
36
|
+
const U = (T) => {
|
|
37
|
+
let j = "", R = "", _ = [], K = !1;
|
|
38
|
+
const B = () => {
|
|
39
|
+
const k = [..._];
|
|
40
|
+
if (j) {
|
|
41
|
+
const L = k.findIndex(($) => $.type === "thinking");
|
|
42
|
+
L >= 0 ? k[L] = { type: "thinking", content: j } : k.unshift({ type: "thinking", content: j });
|
|
43
|
+
}
|
|
44
|
+
if (R) {
|
|
45
|
+
const L = k.findLastIndex(($) => $.type === "text");
|
|
46
|
+
L >= 0 ? k[L] = { type: "text", content: R } : k.push({ type: "text", content: R });
|
|
47
|
+
}
|
|
48
|
+
u(
|
|
49
|
+
(L) => L.map(($) => $.id === S ? { ...$, parts: k } : $)
|
|
50
|
+
);
|
|
51
|
+
};
|
|
52
|
+
d.current = a.chat({
|
|
53
|
+
sessionId: T,
|
|
54
|
+
message: z,
|
|
55
|
+
stream: !0,
|
|
56
|
+
onMessage: (k) => {
|
|
57
|
+
switch (K || (K = !0, m("streaming")), k.type) {
|
|
58
|
+
case "thinking":
|
|
59
|
+
j += k.content;
|
|
60
|
+
break;
|
|
61
|
+
case "ai":
|
|
62
|
+
R += k.content;
|
|
63
|
+
break;
|
|
64
|
+
case "tool_call":
|
|
65
|
+
_.push({
|
|
66
|
+
type: "tool_call",
|
|
67
|
+
toolName: k.toolName,
|
|
68
|
+
toolCallId: k.toolCallId,
|
|
69
|
+
args: k.args ?? "{}"
|
|
70
|
+
});
|
|
71
|
+
break;
|
|
72
|
+
case "tool_result":
|
|
73
|
+
_.push({
|
|
74
|
+
type: "tool_result",
|
|
75
|
+
toolName: k.toolName ?? "",
|
|
76
|
+
toolCallId: k.toolCallId,
|
|
77
|
+
content: k.content
|
|
78
|
+
}), R && (_.push({ type: "text", content: R }), R = "");
|
|
79
|
+
break;
|
|
80
|
+
}
|
|
81
|
+
B();
|
|
82
|
+
},
|
|
83
|
+
onDone: (k) => {
|
|
84
|
+
(R || _.length > 0 || j) && B(), k.sessionId && k.sessionId !== b.current && (s == null || s(k.sessionId)), i == null || i(k.sessionId || T), m("ready"), h.current = !1, d.current = null;
|
|
85
|
+
},
|
|
86
|
+
onError: (k) => {
|
|
87
|
+
_.push({ type: "error", content: k.message }), B(), x(k), m("error"), c == null || c(k), h.current = !1, d.current = null;
|
|
88
|
+
}
|
|
89
|
+
}), r == null || r(T);
|
|
90
|
+
};
|
|
91
|
+
b.current ? U(b.current) : a.createSession().then((T) => {
|
|
92
|
+
b.current = T, s == null || s(T), U(T);
|
|
93
|
+
}).catch((T) => {
|
|
94
|
+
x(T instanceof Error ? T : new Error(String(T))), m("error"), c == null || c(T instanceof Error ? T : new Error(String(T))), h.current = !1;
|
|
95
|
+
});
|
|
96
|
+
}, [a, s, r, i, c, n]), y = w(() => {
|
|
97
|
+
var z;
|
|
98
|
+
(z = d.current) == null || z.abort(), d.current = null, m("ready"), h.current = !1;
|
|
99
|
+
}, []), N = w(() => {
|
|
100
|
+
if (h.current) return;
|
|
101
|
+
const z = o.findLastIndex((S) => S.role === "user");
|
|
102
|
+
if (z < 0) return;
|
|
103
|
+
const D = o[z].parts.filter((S) => S.type === "text").map((S) => S.content).join("");
|
|
104
|
+
u((S) => S.slice(0, z)), f(D);
|
|
105
|
+
}, [o, f]);
|
|
106
|
+
return { messages: o, status: p, error: v, sendMessage: f, stop: y, regenerate: N, setMessages: u };
|
|
107
|
+
}
|
|
108
|
+
const W = "sa_active_conversation";
|
|
109
|
+
function V() {
|
|
110
|
+
try {
|
|
111
|
+
return localStorage.getItem(W);
|
|
112
|
+
} catch {
|
|
113
|
+
return null;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
function ie(t) {
|
|
117
|
+
try {
|
|
118
|
+
t ? localStorage.setItem(W, t) : localStorage.removeItem(W);
|
|
119
|
+
} catch {
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
function oe(t) {
|
|
123
|
+
const { sdk: a, onConversationChange: l } = t, [s, r] = I([]), [i, c] = I(
|
|
124
|
+
() => V()
|
|
125
|
+
), [n, o] = I(!1), u = M(!0);
|
|
126
|
+
P(() => () => {
|
|
127
|
+
u.current = !1;
|
|
128
|
+
}, []);
|
|
129
|
+
const p = w((f) => {
|
|
130
|
+
c(f), ie(f), f && (l == null || l(f));
|
|
131
|
+
}, [l]), m = w(async () => {
|
|
132
|
+
o(!0);
|
|
133
|
+
try {
|
|
134
|
+
const f = await a.listConversations({ page: 1, size: 100 });
|
|
135
|
+
if (!u.current) return;
|
|
136
|
+
r(f.items);
|
|
137
|
+
const y = V();
|
|
138
|
+
y && !f.items.find((N) => N.sessionId === y) && p(null);
|
|
139
|
+
} catch {
|
|
140
|
+
} finally {
|
|
141
|
+
u.current && o(!1);
|
|
142
|
+
}
|
|
143
|
+
}, [a, p]), v = w(async (f) => (p(f), await a.getMessages(f)), [a, p]), x = w(() => {
|
|
144
|
+
p(null);
|
|
145
|
+
}, [p]), d = w(async (f) => {
|
|
146
|
+
await a.deleteConversation(f), r((y) => y.filter((N) => N.sessionId !== f)), i === f && p(null);
|
|
147
|
+
}, [a, i, p]), h = w(async (f, y) => {
|
|
148
|
+
await a.renameConversation(f, y), r(
|
|
149
|
+
(N) => N.map((z) => z.sessionId === f ? { ...z, title: y } : z)
|
|
150
|
+
);
|
|
151
|
+
}, [a]), { enabled: b = !0 } = t;
|
|
152
|
+
return P(() => {
|
|
153
|
+
b && m();
|
|
154
|
+
}, [b, m]), {
|
|
155
|
+
conversations: s,
|
|
156
|
+
activeConversationId: i,
|
|
157
|
+
loading: n,
|
|
158
|
+
loadConversations: m,
|
|
159
|
+
switchConversation: v,
|
|
160
|
+
newConversation: x,
|
|
161
|
+
deleteConversation: d,
|
|
162
|
+
renameConversation: h,
|
|
163
|
+
setActiveConversationId: p
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
const G = ae(null);
|
|
167
|
+
function A() {
|
|
168
|
+
const t = te(G);
|
|
169
|
+
if (!t) throw new Error("useChatContext must be used within ChatProvider");
|
|
170
|
+
return t;
|
|
171
|
+
}
|
|
172
|
+
function Y({ sdk: t, hooks: a, children: l }) {
|
|
173
|
+
const [s, r] = I(!1), [i, c] = I(!1);
|
|
174
|
+
P(() => {
|
|
175
|
+
t.getToken().then(() => {
|
|
176
|
+
c(!0);
|
|
177
|
+
}).catch(() => {
|
|
178
|
+
c(!0);
|
|
179
|
+
});
|
|
180
|
+
}, [t]);
|
|
181
|
+
const n = oe({
|
|
182
|
+
sdk: t,
|
|
183
|
+
onConversationChange: a == null ? void 0 : a.onConversationChange,
|
|
184
|
+
enabled: i
|
|
185
|
+
}), o = ne({
|
|
186
|
+
sdk: t,
|
|
187
|
+
sessionId: n.activeConversationId,
|
|
188
|
+
onSessionCreated: (d) => {
|
|
189
|
+
n.setActiveConversationId(d), n.loadConversations();
|
|
190
|
+
},
|
|
191
|
+
onStreamStart: a == null ? void 0 : a.onStreamStart,
|
|
192
|
+
onStreamEnd: (d) => {
|
|
193
|
+
var h;
|
|
194
|
+
(h = a == null ? void 0 : a.onStreamEnd) == null || h.call(a, d), n.loadConversations();
|
|
195
|
+
},
|
|
196
|
+
onError: a == null ? void 0 : a.onError,
|
|
197
|
+
onMessageSend: a == null ? void 0 : a.onMessageSend
|
|
198
|
+
}), u = w(async (d) => {
|
|
199
|
+
const h = await n.switchConversation(d);
|
|
200
|
+
o.setMessages(h), r(!1);
|
|
201
|
+
}, [n, o]), p = w(() => {
|
|
202
|
+
n.newConversation(), o.setMessages([]), r(!1);
|
|
203
|
+
}, [n, o]), m = w(async (d) => {
|
|
204
|
+
await n.deleteConversation(d), n.activeConversationId === d && o.setMessages([]);
|
|
205
|
+
}, [n, o]);
|
|
206
|
+
P(() => {
|
|
207
|
+
n.activeConversationId && o.messages.length === 0 && t.getMessages(n.activeConversationId).then((d) => {
|
|
208
|
+
o.setMessages(d);
|
|
209
|
+
}).catch(() => {
|
|
210
|
+
});
|
|
211
|
+
}, []);
|
|
212
|
+
const v = w(() => {
|
|
213
|
+
r((d) => !d);
|
|
214
|
+
}, []), x = {
|
|
215
|
+
status: o.status,
|
|
216
|
+
error: o.error,
|
|
217
|
+
messages: o.messages,
|
|
218
|
+
conversations: n.conversations,
|
|
219
|
+
activeConversationId: n.activeConversationId,
|
|
220
|
+
isThreadListOpen: s,
|
|
221
|
+
sendMessage: o.sendMessage,
|
|
222
|
+
stop: o.stop,
|
|
223
|
+
regenerate: o.regenerate,
|
|
224
|
+
switchConversation: u,
|
|
225
|
+
newConversation: p,
|
|
226
|
+
deleteConversation: m,
|
|
227
|
+
renameConversation: n.renameConversation,
|
|
228
|
+
toggleThreadList: v,
|
|
229
|
+
feedback: (d, h) => {
|
|
230
|
+
t.feedback(d, h);
|
|
231
|
+
}
|
|
232
|
+
};
|
|
233
|
+
return /* @__PURE__ */ e(G.Provider, { value: x, children: l });
|
|
234
|
+
}
|
|
235
|
+
function C({ name: t, size: a = 16, color: l = "currentColor", className: s, style: r }) {
|
|
236
|
+
return /* @__PURE__ */ e(
|
|
237
|
+
"svg",
|
|
238
|
+
{
|
|
239
|
+
className: s,
|
|
240
|
+
style: { width: a, height: a, fill: l, verticalAlign: "middle", ...r },
|
|
241
|
+
"aria-hidden": "true",
|
|
242
|
+
children: /* @__PURE__ */ e("use", { href: `#icon-${t}` })
|
|
243
|
+
}
|
|
244
|
+
);
|
|
245
|
+
}
|
|
246
|
+
function le({ isOpen: t, onClick: a }) {
|
|
247
|
+
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" }) });
|
|
248
|
+
}
|
|
249
|
+
function ce({ title: t, onClose: a, onToggleThreadList: l, showClose: s = !0 }) {
|
|
250
|
+
return /* @__PURE__ */ g("div", { className: "sa-header", children: [
|
|
251
|
+
/* @__PURE__ */ g("div", { className: "sa-header-left", children: [
|
|
252
|
+
/* @__PURE__ */ e("div", { className: "sa-header-avatar", children: "A" }),
|
|
253
|
+
/* @__PURE__ */ g("div", { className: "sa-header-info", children: [
|
|
254
|
+
/* @__PURE__ */ e("div", { className: "sa-header-title", children: t }),
|
|
255
|
+
/* @__PURE__ */ e("div", { className: "sa-header-status", children: "● Online" })
|
|
256
|
+
] })
|
|
257
|
+
] }),
|
|
258
|
+
/* @__PURE__ */ g("div", { className: "sa-header-actions", children: [
|
|
259
|
+
/* @__PURE__ */ e("button", { className: "sa-header-btn", onClick: l, title: "会话列表", children: /* @__PURE__ */ e(C, { name: "menu", size: 16 }) }),
|
|
260
|
+
s && /* @__PURE__ */ e("button", { className: "sa-header-btn", onClick: a, title: "关闭", children: /* @__PURE__ */ e(C, { name: "x", size: 16 }) })
|
|
261
|
+
] })
|
|
262
|
+
] });
|
|
263
|
+
}
|
|
264
|
+
function de() {
|
|
265
|
+
const {
|
|
266
|
+
conversations: t,
|
|
267
|
+
activeConversationId: a,
|
|
268
|
+
switchConversation: l,
|
|
269
|
+
newConversation: s,
|
|
270
|
+
deleteConversation: r,
|
|
271
|
+
renameConversation: i,
|
|
272
|
+
isThreadListOpen: c,
|
|
273
|
+
toggleThreadList: n
|
|
274
|
+
} = A(), [o, u] = I(null), [p, m] = I(""), v = w((d, h) => {
|
|
275
|
+
u(d), m(h ?? "");
|
|
276
|
+
}, []), x = w((d) => {
|
|
277
|
+
p.trim() && i(d, p.trim()), u(null);
|
|
278
|
+
}, [p, i]);
|
|
279
|
+
return c ? /* @__PURE__ */ g(se, { children: [
|
|
280
|
+
/* @__PURE__ */ e("div", { className: "sa-thread-list-overlay", onClick: n }),
|
|
281
|
+
/* @__PURE__ */ g("div", { className: "sa-thread-list", children: [
|
|
282
|
+
/* @__PURE__ */ g("div", { className: "sa-thread-list-header", children: [
|
|
283
|
+
/* @__PURE__ */ e("span", { children: "会话列表" }),
|
|
284
|
+
/* @__PURE__ */ g("button", { className: "sa-thread-list-new", onClick: s, children: [
|
|
285
|
+
/* @__PURE__ */ e(C, { name: "plus", size: 14 }),
|
|
286
|
+
" 新会话"
|
|
287
|
+
] })
|
|
288
|
+
] }),
|
|
289
|
+
/* @__PURE__ */ g("div", { className: "sa-thread-list-items", children: [
|
|
290
|
+
t.length === 0 && /* @__PURE__ */ e("div", { className: "sa-thread-list-empty", children: "暂无会话" }),
|
|
291
|
+
t.map((d) => /* @__PURE__ */ g(
|
|
292
|
+
"div",
|
|
293
|
+
{
|
|
294
|
+
className: `sa-thread-item ${d.sessionId === a ? "active" : ""}`,
|
|
295
|
+
onClick: () => l(d.sessionId),
|
|
296
|
+
children: [
|
|
297
|
+
o === d.sessionId ? /* @__PURE__ */ e(
|
|
298
|
+
"input",
|
|
299
|
+
{
|
|
300
|
+
className: "sa-thread-item-edit",
|
|
301
|
+
value: p,
|
|
302
|
+
onChange: (h) => m(h.target.value),
|
|
303
|
+
onBlur: () => x(d.sessionId),
|
|
304
|
+
onKeyDown: (h) => {
|
|
305
|
+
h.key === "Enter" && x(d.sessionId), h.key === "Escape" && u(null);
|
|
306
|
+
},
|
|
307
|
+
onClick: (h) => h.stopPropagation(),
|
|
308
|
+
autoFocus: !0
|
|
309
|
+
}
|
|
310
|
+
) : /* @__PURE__ */ e(
|
|
311
|
+
"span",
|
|
312
|
+
{
|
|
313
|
+
className: "sa-thread-item-title",
|
|
314
|
+
onDoubleClick: (h) => {
|
|
315
|
+
h.stopPropagation(), v(d.sessionId, d.title);
|
|
316
|
+
},
|
|
317
|
+
children: d.title || "新会话"
|
|
318
|
+
}
|
|
319
|
+
),
|
|
320
|
+
/* @__PURE__ */ e(
|
|
321
|
+
"button",
|
|
322
|
+
{
|
|
323
|
+
className: "sa-thread-item-delete",
|
|
324
|
+
onClick: (h) => {
|
|
325
|
+
h.stopPropagation(), r(d.sessionId);
|
|
326
|
+
},
|
|
327
|
+
title: "删除",
|
|
328
|
+
children: /* @__PURE__ */ e(C, { name: "trash2", size: 14 })
|
|
329
|
+
}
|
|
330
|
+
)
|
|
331
|
+
]
|
|
332
|
+
},
|
|
333
|
+
d.sessionId
|
|
334
|
+
))
|
|
335
|
+
] })
|
|
336
|
+
] })
|
|
337
|
+
] }) : null;
|
|
338
|
+
}
|
|
339
|
+
function pe(t) {
|
|
340
|
+
const a = M(null), l = M(!1), s = M(0), r = w(() => {
|
|
341
|
+
const c = a.current;
|
|
342
|
+
if (!c) return;
|
|
343
|
+
const { scrollTop: n, scrollHeight: o, clientHeight: u } = c, p = o - n - u < 40;
|
|
344
|
+
n < s.current && !p && (l.current = !0), p && (l.current = !1), s.current = n;
|
|
345
|
+
}, []);
|
|
346
|
+
P(() => {
|
|
347
|
+
const c = a.current;
|
|
348
|
+
if (c)
|
|
349
|
+
return c.addEventListener("scroll", r, { passive: !0 }), () => c.removeEventListener("scroll", r);
|
|
350
|
+
}, [r]), P(() => {
|
|
351
|
+
if (l.current) return;
|
|
352
|
+
const c = a.current;
|
|
353
|
+
c && requestAnimationFrame(() => {
|
|
354
|
+
c.scrollTop = c.scrollHeight;
|
|
355
|
+
});
|
|
356
|
+
}, t);
|
|
357
|
+
const i = w(() => {
|
|
358
|
+
l.current = !1;
|
|
359
|
+
const c = a.current;
|
|
360
|
+
c && (c.scrollTop = c.scrollHeight);
|
|
361
|
+
}, []);
|
|
362
|
+
return { containerRef: a, scrollToBottom: i };
|
|
363
|
+
}
|
|
364
|
+
function E(t) {
|
|
365
|
+
return t.value++;
|
|
366
|
+
}
|
|
367
|
+
function O(t, a) {
|
|
368
|
+
const l = [], s = [], r = () => {
|
|
369
|
+
s.length > 0 && (l.push(s.join("")), s.length = 0);
|
|
370
|
+
};
|
|
371
|
+
let i = 0;
|
|
372
|
+
for (; i < t.length; ) {
|
|
373
|
+
const c = t[i];
|
|
374
|
+
if (c === "`") {
|
|
375
|
+
const n = t.indexOf("`", i + 1);
|
|
376
|
+
if (n !== -1) {
|
|
377
|
+
r(), l.push(
|
|
378
|
+
/* @__PURE__ */ e("code", { className: "sa-inline-code", children: t.slice(i + 1, n) }, E(a))
|
|
379
|
+
), i = n + 1;
|
|
380
|
+
continue;
|
|
381
|
+
}
|
|
382
|
+
} else if (c === "*" && t[i + 1] === "*") {
|
|
383
|
+
const n = t.indexOf("**", i + 2);
|
|
384
|
+
if (n !== -1) {
|
|
385
|
+
r(), l.push(
|
|
386
|
+
/* @__PURE__ */ e("strong", { children: O(t.slice(i + 2, n), a) }, E(a))
|
|
387
|
+
), i = n + 2;
|
|
388
|
+
continue;
|
|
389
|
+
}
|
|
390
|
+
} else if (c === "*") {
|
|
391
|
+
const n = t.indexOf("*", i + 1);
|
|
392
|
+
if (n !== -1) {
|
|
393
|
+
r(), l.push(
|
|
394
|
+
/* @__PURE__ */ e("em", { children: O(t.slice(i + 1, n), a) }, E(a))
|
|
395
|
+
), i = n + 1;
|
|
396
|
+
continue;
|
|
397
|
+
}
|
|
398
|
+
} else if (c === "[") {
|
|
399
|
+
const n = t.indexOf("]", i + 1);
|
|
400
|
+
if (n !== -1 && t[n + 1] === "(") {
|
|
401
|
+
const o = t.indexOf(")", n + 2);
|
|
402
|
+
if (o !== -1) {
|
|
403
|
+
const u = t.slice(i + 1, n), p = t.slice(n + 2, o);
|
|
404
|
+
r(), l.push(
|
|
405
|
+
/* @__PURE__ */ e(
|
|
406
|
+
"a",
|
|
407
|
+
{
|
|
408
|
+
href: p,
|
|
409
|
+
target: "_blank",
|
|
410
|
+
rel: "noreferrer",
|
|
411
|
+
children: O(u, a)
|
|
412
|
+
},
|
|
413
|
+
E(a)
|
|
414
|
+
)
|
|
415
|
+
), i = o + 1;
|
|
416
|
+
continue;
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
s.push(c), i++;
|
|
421
|
+
}
|
|
422
|
+
return r(), l;
|
|
423
|
+
}
|
|
424
|
+
function fe(t, a) {
|
|
425
|
+
const l = [], s = t.split(`
|
|
426
|
+
`);
|
|
427
|
+
let r = 0;
|
|
428
|
+
const i = (o) => o.trim() === "", c = (o) => /^#{1,6}\s+\S/.test(o.trim()), n = (o) => /^(?:[-*+]|\d+[.)])\s+\S/.test(o.trim());
|
|
429
|
+
for (; r < s.length; ) {
|
|
430
|
+
const o = s[r], u = o.trim();
|
|
431
|
+
if (i(o)) {
|
|
432
|
+
r++;
|
|
433
|
+
continue;
|
|
434
|
+
}
|
|
435
|
+
if (c(o)) {
|
|
436
|
+
const m = u.match(/^(#{1,6})\s+(.*)$/);
|
|
437
|
+
if (m) {
|
|
438
|
+
const x = `h${Math.min(m[1].length, 6)}`;
|
|
439
|
+
l.push(
|
|
440
|
+
X.createElement(
|
|
441
|
+
x,
|
|
442
|
+
{ key: E(a) },
|
|
443
|
+
O(m[2], a)
|
|
444
|
+
)
|
|
445
|
+
);
|
|
446
|
+
}
|
|
447
|
+
r++;
|
|
448
|
+
continue;
|
|
449
|
+
}
|
|
450
|
+
if (n(o)) {
|
|
451
|
+
const m = /^\d+[.)]/.test(u), v = [];
|
|
452
|
+
for (; r < s.length && n(s[r]); ) {
|
|
453
|
+
const x = s[r].trim().match(/^(?:[-*+]|\d+[.)])\s+(.*)$/);
|
|
454
|
+
x && v.push(
|
|
455
|
+
/* @__PURE__ */ e("li", { children: O(x[1], a) }, E(a))
|
|
456
|
+
), r++;
|
|
457
|
+
}
|
|
458
|
+
l.push(
|
|
459
|
+
m ? /* @__PURE__ */ e("ol", { className: "sa-list", children: v }, E(a)) : /* @__PURE__ */ e("ul", { className: "sa-list", children: v }, E(a))
|
|
460
|
+
);
|
|
461
|
+
continue;
|
|
462
|
+
}
|
|
463
|
+
const p = [];
|
|
464
|
+
for (; r < s.length && !i(s[r]) && !c(s[r]) && !n(s[r]); )
|
|
465
|
+
p.push(s[r]), r++;
|
|
466
|
+
l.push(
|
|
467
|
+
/* @__PURE__ */ e("p", { className: "sa-text-paragraph", children: O(p.join(" "), a) }, E(a))
|
|
468
|
+
);
|
|
469
|
+
}
|
|
470
|
+
return l;
|
|
471
|
+
}
|
|
472
|
+
function ue(t) {
|
|
473
|
+
const a = { value: 0 }, l = [], s = t.split("```");
|
|
474
|
+
for (let r = 0; r < s.length; r++)
|
|
475
|
+
if (r % 2 === 0)
|
|
476
|
+
l.push(...fe(s[r], a));
|
|
477
|
+
else if (s[r].trim() !== "") {
|
|
478
|
+
let i = s[r].replace(/^\r?\n/, "");
|
|
479
|
+
i = i.replace(/^[a-zA-Z0-9_+#.-]+\r?\n/, ""), i = i.replace(/\r?\n$/, ""), l.push(
|
|
480
|
+
/* @__PURE__ */ e("pre", { className: "sa-code-block", children: /* @__PURE__ */ e("code", { children: i }) }, E(a))
|
|
481
|
+
);
|
|
482
|
+
}
|
|
483
|
+
return l;
|
|
484
|
+
}
|
|
485
|
+
function he({ content: t }) {
|
|
486
|
+
return /* @__PURE__ */ e("div", { className: "sa-text-part", children: ue(t) });
|
|
487
|
+
}
|
|
488
|
+
function me({ content: t }) {
|
|
489
|
+
const [a, l] = I(!1);
|
|
490
|
+
return /* @__PURE__ */ g("div", { className: "sa-thinking-part", onClick: () => l(!a), children: [
|
|
491
|
+
/* @__PURE__ */ g("div", { className: "sa-thinking-header", children: [
|
|
492
|
+
/* @__PURE__ */ e("span", { className: "sa-thinking-icon", children: /* @__PURE__ */ e(C, { name: "brain", size: 14 }) }),
|
|
493
|
+
/* @__PURE__ */ e("span", { className: "sa-thinking-label", children: "思考过程" }),
|
|
494
|
+
/* @__PURE__ */ e("span", { className: `sa-thinking-arrow ${a ? "expanded" : ""}`, children: /* @__PURE__ */ e(C, { name: "chevron-right", size: 12 }) })
|
|
495
|
+
] }),
|
|
496
|
+
a && /* @__PURE__ */ e("div", { className: "sa-thinking-content", children: t })
|
|
497
|
+
] });
|
|
498
|
+
}
|
|
499
|
+
function ge({ toolName: t, toolCallId: a, args: l }) {
|
|
500
|
+
const [s, r] = I(!1);
|
|
501
|
+
let i = l;
|
|
502
|
+
try {
|
|
503
|
+
i = JSON.stringify(JSON.parse(l), null, 2);
|
|
504
|
+
} catch {
|
|
505
|
+
}
|
|
506
|
+
return /* @__PURE__ */ g("div", { className: "sa-tool-call-part", children: [
|
|
507
|
+
/* @__PURE__ */ g("div", { className: "sa-tool-call-header", onClick: () => r(!s), children: [
|
|
508
|
+
/* @__PURE__ */ e("span", { className: "sa-tool-icon", children: /* @__PURE__ */ e(C, { name: "zap", size: 14 }) }),
|
|
509
|
+
/* @__PURE__ */ g("span", { className: "sa-tool-name", children: [
|
|
510
|
+
"调用工具: ",
|
|
511
|
+
t
|
|
512
|
+
] }),
|
|
513
|
+
/* @__PURE__ */ e("span", { className: `sa-thinking-arrow ${s ? "expanded" : ""}`, children: /* @__PURE__ */ e(C, { name: "chevron-right", size: 12 }) })
|
|
514
|
+
] }),
|
|
515
|
+
s && /* @__PURE__ */ e("pre", { className: "sa-tool-args", children: i })
|
|
516
|
+
] });
|
|
517
|
+
}
|
|
518
|
+
function xe({ toolName: t, toolCallId: a, content: l }) {
|
|
519
|
+
return /* @__PURE__ */ g("div", { className: "sa-tool-result-part", children: [
|
|
520
|
+
/* @__PURE__ */ g("div", { className: "sa-tool-result-header", children: [
|
|
521
|
+
/* @__PURE__ */ e("span", { className: "sa-tool-icon", children: /* @__PURE__ */ e(C, { name: "circle-check", size: 14, color: "#10b981" }) }),
|
|
522
|
+
/* @__PURE__ */ e("span", { className: "sa-tool-result-label", children: t || "工具返回" })
|
|
523
|
+
] }),
|
|
524
|
+
/* @__PURE__ */ e("div", { className: "sa-tool-result-content", children: l })
|
|
525
|
+
] });
|
|
526
|
+
}
|
|
527
|
+
function be({ content: t, onRetry: a }) {
|
|
528
|
+
return /* @__PURE__ */ g("div", { className: "sa-error-part", children: [
|
|
529
|
+
/* @__PURE__ */ g("div", { className: "sa-error-content", children: [
|
|
530
|
+
/* @__PURE__ */ e("span", { className: "sa-error-icon", children: /* @__PURE__ */ e(C, { name: "triangle-alert", size: 14 }) }),
|
|
531
|
+
/* @__PURE__ */ e("span", { children: t })
|
|
532
|
+
] }),
|
|
533
|
+
a && /* @__PURE__ */ e("button", { className: "sa-error-retry", onClick: a, children: "重试" })
|
|
534
|
+
] });
|
|
535
|
+
}
|
|
536
|
+
function ve({ message: t, onCopy: a, onRegenerate: l, onFeedback: s }) {
|
|
537
|
+
const { status: r } = A(), [i, c] = I(null), [n, o] = I(!1);
|
|
538
|
+
if (r !== "ready" && r !== "error") return null;
|
|
539
|
+
const u = w(() => {
|
|
540
|
+
a(), o(!0), setTimeout(() => o(!1), 2e3);
|
|
541
|
+
}, [a]), p = w((m) => {
|
|
542
|
+
const v = i === m ? null : m;
|
|
543
|
+
c(v), v && (s == null || s(t.id, v));
|
|
544
|
+
}, [i, t.id, s]);
|
|
545
|
+
return /* @__PURE__ */ g("div", { className: "sa-action-bar", children: [
|
|
546
|
+
/* @__PURE__ */ g("button", { className: "sa-action-btn", onClick: u, title: "复制", children: [
|
|
547
|
+
/* @__PURE__ */ e(C, { name: n ? "circle-check" : "copy", size: 14 }),
|
|
548
|
+
" ",
|
|
549
|
+
n ? "已复制" : "复制"
|
|
550
|
+
] }),
|
|
551
|
+
/* @__PURE__ */ g("button", { className: "sa-action-btn", onClick: l, title: "重新生成", children: [
|
|
552
|
+
/* @__PURE__ */ e(C, { name: "refresh-cw", size: 14 }),
|
|
553
|
+
" 重新生成"
|
|
554
|
+
] }),
|
|
555
|
+
/* @__PURE__ */ e("span", { className: "sa-action-divider" }),
|
|
556
|
+
/* @__PURE__ */ e(
|
|
557
|
+
"button",
|
|
558
|
+
{
|
|
559
|
+
className: `sa-action-btn ${i === "like" ? "sa-action-btn-active" : ""}`,
|
|
560
|
+
onClick: () => p("like"),
|
|
561
|
+
title: "有用",
|
|
562
|
+
children: /* @__PURE__ */ e(C, { name: "thumbs-up", size: 14 })
|
|
563
|
+
}
|
|
564
|
+
),
|
|
565
|
+
/* @__PURE__ */ e(
|
|
566
|
+
"button",
|
|
567
|
+
{
|
|
568
|
+
className: `sa-action-btn ${i === "dislike" ? "sa-action-btn-active" : ""}`,
|
|
569
|
+
onClick: () => p("dislike"),
|
|
570
|
+
title: "无用",
|
|
571
|
+
children: /* @__PURE__ */ e(C, { name: "thumbs-down", size: 14 })
|
|
572
|
+
}
|
|
573
|
+
)
|
|
574
|
+
] });
|
|
575
|
+
}
|
|
576
|
+
function J({ src: t, role: a }) {
|
|
577
|
+
const l = a === "assistant" ? "A" : "U";
|
|
578
|
+
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 });
|
|
579
|
+
}
|
|
580
|
+
function ye({ message: t, isStreaming: a, isLast: l, slots: s, avatar: r }) {
|
|
581
|
+
const { regenerate: i, feedback: c } = A(), n = w(() => {
|
|
582
|
+
var f;
|
|
583
|
+
const b = t.parts.filter((y) => y.type === "text").map((y) => y.content).join(`
|
|
584
|
+
`);
|
|
585
|
+
(f = navigator.clipboard) == null || f.writeText(b).catch(() => {
|
|
586
|
+
});
|
|
587
|
+
}, [t]), o = t.role === "user", u = s.Message;
|
|
588
|
+
if (u)
|
|
589
|
+
return /* @__PURE__ */ e(
|
|
590
|
+
u,
|
|
591
|
+
{
|
|
592
|
+
message: t,
|
|
593
|
+
isStreaming: a,
|
|
594
|
+
isLast: l,
|
|
595
|
+
avatar: r,
|
|
596
|
+
slots: s,
|
|
597
|
+
onCopy: n,
|
|
598
|
+
onRegenerate: i,
|
|
599
|
+
onFeedback: c
|
|
600
|
+
}
|
|
601
|
+
);
|
|
602
|
+
const p = s.TextPart ?? he, m = s.ThinkingPart ?? me, v = s.ToolCallPart ?? ge, x = s.ToolResultPart ?? xe, d = s.ErrorPart ?? be, h = s.ActionBar ?? ve;
|
|
603
|
+
return /* @__PURE__ */ g("div", { className: `sa-message ${o ? "sa-message-user" : "sa-message-assistant"}`, children: [
|
|
604
|
+
!o && /* @__PURE__ */ e(J, { src: r == null ? void 0 : r.assistant, role: "assistant" }),
|
|
605
|
+
/* @__PURE__ */ g("div", { className: "sa-message-body", children: [
|
|
606
|
+
t.parts.map((b, f) => {
|
|
607
|
+
switch (b.type) {
|
|
608
|
+
case "text":
|
|
609
|
+
return /* @__PURE__ */ e(p, { content: b.content }, f);
|
|
610
|
+
case "thinking":
|
|
611
|
+
return /* @__PURE__ */ e(m, { content: b.content }, f);
|
|
612
|
+
case "tool_call":
|
|
613
|
+
return /* @__PURE__ */ e(v, { toolName: b.toolName, toolCallId: b.toolCallId, args: b.args }, f);
|
|
614
|
+
case "tool_result":
|
|
615
|
+
return /* @__PURE__ */ e(x, { toolName: b.toolName, toolCallId: b.toolCallId, content: b.content }, f);
|
|
616
|
+
case "error":
|
|
617
|
+
return /* @__PURE__ */ e(d, { content: b.content, onRetry: i }, f);
|
|
618
|
+
default:
|
|
619
|
+
return null;
|
|
620
|
+
}
|
|
621
|
+
}),
|
|
622
|
+
a && l && !o && /* @__PURE__ */ e("span", { className: "sa-streaming-cursor", children: "|" }),
|
|
623
|
+
!o && !a && t.parts.length > 0 && /* @__PURE__ */ e(h, { message: t, onCopy: n, onRegenerate: i, onFeedback: c })
|
|
624
|
+
] }),
|
|
625
|
+
o && /* @__PURE__ */ e(J, { src: r == null ? void 0 : r.user, role: "user" })
|
|
626
|
+
] });
|
|
627
|
+
}
|
|
628
|
+
function we({ message: t, suggestedPrompts: a, onPromptClick: l }) {
|
|
629
|
+
return /* @__PURE__ */ g("div", { className: "sa-welcome", children: [
|
|
630
|
+
/* @__PURE__ */ e("div", { className: "sa-welcome-icon", children: /* @__PURE__ */ e(C, { name: "sparkles", size: 40 }) }),
|
|
631
|
+
/* @__PURE__ */ e("p", { className: "sa-welcome-message", children: t || "你好!有什么可以帮你的?" }),
|
|
632
|
+
a && a.length > 0 && /* @__PURE__ */ e("div", { className: "sa-welcome-prompts", children: a.map((s, r) => /* @__PURE__ */ e(
|
|
633
|
+
"button",
|
|
634
|
+
{
|
|
635
|
+
className: "sa-welcome-prompt",
|
|
636
|
+
onClick: () => l(s),
|
|
637
|
+
children: s
|
|
638
|
+
},
|
|
639
|
+
r
|
|
640
|
+
)) })
|
|
641
|
+
] });
|
|
642
|
+
}
|
|
643
|
+
function Z({ slots: t, welcomeMessage: a, suggestedPrompts: l, avatar: s }) {
|
|
644
|
+
const { messages: r, status: i, sendMessage: c } = A(), { containerRef: n } = pe([r]), o = i === "streaming", u = t.WelcomeScreen ?? we;
|
|
645
|
+
return r.length === 0 ? /* @__PURE__ */ e("div", { className: "sa-thread", ref: n, children: /* @__PURE__ */ e(
|
|
646
|
+
u,
|
|
647
|
+
{
|
|
648
|
+
message: a,
|
|
649
|
+
suggestedPrompts: l,
|
|
650
|
+
onPromptClick: c
|
|
651
|
+
}
|
|
652
|
+
) }) : /* @__PURE__ */ e("div", { className: "sa-thread", ref: n, children: r.map((p, m) => /* @__PURE__ */ e(
|
|
653
|
+
ye,
|
|
654
|
+
{
|
|
655
|
+
message: p,
|
|
656
|
+
isStreaming: o,
|
|
657
|
+
isLast: m === r.length - 1,
|
|
658
|
+
slots: t,
|
|
659
|
+
avatar: s
|
|
660
|
+
},
|
|
661
|
+
p.id
|
|
662
|
+
)) });
|
|
663
|
+
}
|
|
664
|
+
function Q() {
|
|
665
|
+
const { status: t, sendMessage: a, stop: l } = A(), [s, r] = I(""), i = M(null), c = t === "streaming" || t === "submitted", n = w(() => {
|
|
666
|
+
const p = s.trim();
|
|
667
|
+
!p || c || (a(p), r(""), i.current && (i.current.style.height = "auto"));
|
|
668
|
+
}, [s, c, a]), o = w((p) => {
|
|
669
|
+
p.key === "Enter" && !p.shiftKey && (p.preventDefault(), n());
|
|
670
|
+
}, [n]), u = w((p) => {
|
|
671
|
+
r(p.target.value);
|
|
672
|
+
const m = p.target;
|
|
673
|
+
m.style.height = "auto", m.style.height = Math.min(m.scrollHeight, 120) + "px";
|
|
674
|
+
}, []);
|
|
675
|
+
return /* @__PURE__ */ g("div", { className: "sa-composer", children: [
|
|
676
|
+
/* @__PURE__ */ e(
|
|
677
|
+
"textarea",
|
|
678
|
+
{
|
|
679
|
+
ref: i,
|
|
680
|
+
className: "sa-composer-input",
|
|
681
|
+
value: s,
|
|
682
|
+
onChange: u,
|
|
683
|
+
onKeyDown: o,
|
|
684
|
+
placeholder: "输入消息...",
|
|
685
|
+
rows: 1,
|
|
686
|
+
disabled: t === "submitted"
|
|
687
|
+
}
|
|
688
|
+
),
|
|
689
|
+
c ? /* @__PURE__ */ e("button", { className: "sa-composer-stop", onClick: l, title: "停止", children: /* @__PURE__ */ e(C, { name: "circle-stop", size: 16, color: "#fff" }) }) : /* @__PURE__ */ e(
|
|
690
|
+
"button",
|
|
691
|
+
{
|
|
692
|
+
className: "sa-composer-send",
|
|
693
|
+
onClick: n,
|
|
694
|
+
disabled: !s.trim(),
|
|
695
|
+
title: "发送",
|
|
696
|
+
children: /* @__PURE__ */ e(C, { name: "arrow-up", size: 16, color: "#fff" })
|
|
697
|
+
}
|
|
698
|
+
)
|
|
699
|
+
] });
|
|
700
|
+
}
|
|
701
|
+
function ke({ isOpen: t, onClose: a, title: l, slots: s, welcomeMessage: r, suggestedPrompts: i, avatar: c }) {
|
|
702
|
+
const { status: n, sendMessage: o, stop: u, toggleThreadList: p, conversations: m, activeConversationId: v, switchConversation: x, newConversation: d, deleteConversation: h, renameConversation: b, isThreadListOpen: f } = A();
|
|
703
|
+
if (!t) return null;
|
|
704
|
+
const y = s.Header, N = s.Composer, z = s.ThreadList;
|
|
705
|
+
return /* @__PURE__ */ g("div", { className: "sa-panel", children: [
|
|
706
|
+
y ? /* @__PURE__ */ e(y, { title: l, onClose: a, onToggleThreadList: p }) : /* @__PURE__ */ e(ce, { title: l, onClose: a, onToggleThreadList: p }),
|
|
707
|
+
z && f ? /* @__PURE__ */ e(
|
|
708
|
+
z,
|
|
709
|
+
{
|
|
710
|
+
conversations: m,
|
|
711
|
+
activeSessionId: v,
|
|
712
|
+
onSwitch: x,
|
|
713
|
+
onNew: d,
|
|
714
|
+
onDelete: h,
|
|
715
|
+
onRename: b
|
|
716
|
+
}
|
|
717
|
+
) : /* @__PURE__ */ e(de, {}),
|
|
718
|
+
/* @__PURE__ */ e(Z, { slots: s, welcomeMessage: r, suggestedPrompts: i, avatar: c }),
|
|
719
|
+
N ? /* @__PURE__ */ e(N, { status: n, onSend: o, onStop: u }) : /* @__PURE__ */ e(Q, {})
|
|
720
|
+
] });
|
|
721
|
+
}
|
|
722
|
+
function Ce({
|
|
723
|
+
conversations: t,
|
|
724
|
+
activeSessionId: a,
|
|
725
|
+
onSwitch: l,
|
|
726
|
+
onNew: s,
|
|
727
|
+
onDelete: r,
|
|
728
|
+
isCollapsed: i,
|
|
729
|
+
onToggleCollapse: c
|
|
730
|
+
}) {
|
|
731
|
+
const [n, o] = I(null), [u, p] = I(null), m = w((x, d) => {
|
|
732
|
+
d.stopPropagation(), u === x ? (r(x), p(null)) : (p(x), setTimeout(() => p(null), 3e3));
|
|
733
|
+
}, [u, r]), v = (() => {
|
|
734
|
+
const x = Date.now(), d = [], h = [], b = [];
|
|
735
|
+
for (const y of t) {
|
|
736
|
+
const N = x - new Date(y.updateTime).getTime();
|
|
737
|
+
N < 864e5 ? d.push(y) : N < 6048e5 ? h.push(y) : b.push(y);
|
|
738
|
+
}
|
|
739
|
+
const f = [];
|
|
740
|
+
return d.length && f.push({ label: "今天", items: d }), h.length && f.push({ label: "最近 7 天", items: h }), b.length && f.push({ label: "更早", items: b }), f;
|
|
741
|
+
})();
|
|
742
|
+
return i ? /* @__PURE__ */ g("div", { className: "sa-fp-sidebar sa-fp-sidebar-collapsed", children: [
|
|
743
|
+
/* @__PURE__ */ e("button", { className: "sa-fp-sidebar-toggle", onClick: c, title: "展开", children: /* @__PURE__ */ e(C, { name: "panel-left", size: 18 }) }),
|
|
744
|
+
/* @__PURE__ */ e("button", { className: "sa-fp-sidebar-toggle", onClick: s, title: "新会话", style: { marginTop: 4 }, children: /* @__PURE__ */ e(C, { name: "plus", size: 18 }) })
|
|
745
|
+
] }) : /* @__PURE__ */ g("div", { className: "sa-fp-sidebar", children: [
|
|
746
|
+
/* @__PURE__ */ g("div", { className: "sa-fp-sidebar-header", children: [
|
|
747
|
+
/* @__PURE__ */ g("button", { className: "sa-fp-sidebar-new", onClick: s, children: [
|
|
748
|
+
/* @__PURE__ */ e(C, { name: "plus", size: 15 }),
|
|
749
|
+
" ",
|
|
750
|
+
/* @__PURE__ */ e("span", { children: "新会话" })
|
|
751
|
+
] }),
|
|
752
|
+
/* @__PURE__ */ e("button", { className: "sa-fp-sidebar-toggle", onClick: c, title: "收起侧边栏", children: /* @__PURE__ */ e(C, { name: "panel-left-close", size: 18 }) })
|
|
753
|
+
] }),
|
|
754
|
+
/* @__PURE__ */ g("div", { className: "sa-fp-sidebar-list", children: [
|
|
755
|
+
t.length === 0 && /* @__PURE__ */ e("div", { className: "sa-fp-sidebar-empty", children: "开始你的第一个对话" }),
|
|
756
|
+
v.map((x) => /* @__PURE__ */ g("div", { children: [
|
|
757
|
+
/* @__PURE__ */ e("div", { className: "sa-fp-sidebar-group", children: x.label }),
|
|
758
|
+
x.items.map((d) => {
|
|
759
|
+
const h = d.sessionId === a, b = n === d.sessionId, f = u === d.sessionId;
|
|
760
|
+
return /* @__PURE__ */ g(
|
|
761
|
+
"div",
|
|
762
|
+
{
|
|
763
|
+
className: `sa-fp-sidebar-item ${h ? "active" : ""}`,
|
|
764
|
+
onClick: () => l(d.sessionId),
|
|
765
|
+
onMouseEnter: () => o(d.sessionId),
|
|
766
|
+
onMouseLeave: () => o(null),
|
|
767
|
+
children: [
|
|
768
|
+
/* @__PURE__ */ e("span", { className: "sa-fp-sidebar-item-title", children: d.title || "新会话" }),
|
|
769
|
+
b && /* @__PURE__ */ e(
|
|
770
|
+
"button",
|
|
771
|
+
{
|
|
772
|
+
className: `sa-fp-sidebar-item-action ${f ? "danger" : ""}`,
|
|
773
|
+
onClick: (y) => m(d.sessionId, y),
|
|
774
|
+
title: f ? "确认删除" : "删除",
|
|
775
|
+
children: /* @__PURE__ */ e(C, { name: f ? "x" : "trash2", size: 14 })
|
|
776
|
+
}
|
|
777
|
+
)
|
|
778
|
+
]
|
|
779
|
+
},
|
|
780
|
+
d.sessionId
|
|
781
|
+
);
|
|
782
|
+
})
|
|
783
|
+
] }, x.label))
|
|
784
|
+
] })
|
|
785
|
+
] });
|
|
786
|
+
}
|
|
787
|
+
function Ne({ title: t, slots: a, welcomeMessage: l, suggestedPrompts: s, sidebarDefaultOpen: r = !0, onClose: i, avatar: c }) {
|
|
788
|
+
const {
|
|
789
|
+
status: n,
|
|
790
|
+
sendMessage: o,
|
|
791
|
+
stop: u,
|
|
792
|
+
conversations: p,
|
|
793
|
+
activeConversationId: m,
|
|
794
|
+
switchConversation: v,
|
|
795
|
+
newConversation: x,
|
|
796
|
+
deleteConversation: d,
|
|
797
|
+
renameConversation: h
|
|
798
|
+
} = A(), [b, f] = I(r), y = w(() => f((D) => !D), []), N = a.ThreadList, z = a.Composer;
|
|
799
|
+
return /* @__PURE__ */ g("div", { className: "sa-fullpage", children: [
|
|
800
|
+
N ? /* @__PURE__ */ e("div", { className: `sa-fp-sidebar-wrapper ${b ? "" : "sa-fp-sidebar-wrapper-collapsed"}`, children: /* @__PURE__ */ e(
|
|
801
|
+
N,
|
|
802
|
+
{
|
|
803
|
+
conversations: p,
|
|
804
|
+
activeSessionId: m,
|
|
805
|
+
onSwitch: v,
|
|
806
|
+
onNew: x,
|
|
807
|
+
onDelete: d,
|
|
808
|
+
onRename: h
|
|
809
|
+
}
|
|
810
|
+
) }) : /* @__PURE__ */ e(
|
|
811
|
+
Ce,
|
|
812
|
+
{
|
|
813
|
+
conversations: p,
|
|
814
|
+
activeSessionId: m,
|
|
815
|
+
onSwitch: v,
|
|
816
|
+
onNew: x,
|
|
817
|
+
onDelete: d,
|
|
818
|
+
onRename: h,
|
|
819
|
+
isCollapsed: !b,
|
|
820
|
+
onToggleCollapse: y
|
|
821
|
+
}
|
|
822
|
+
),
|
|
823
|
+
/* @__PURE__ */ g("div", { className: "sa-fp-main", children: [
|
|
824
|
+
/* @__PURE__ */ g("div", { className: "sa-fp-header", children: [
|
|
825
|
+
!b && !N && /* @__PURE__ */ e("button", { className: "sa-fp-header-btn", onClick: y, title: "展开侧边栏", children: /* @__PURE__ */ e(C, { name: "panel-left", size: 18 }) }),
|
|
826
|
+
/* @__PURE__ */ e("div", { className: "sa-fp-header-title", children: t }),
|
|
827
|
+
/* @__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 }) }) })
|
|
828
|
+
] }),
|
|
829
|
+
/* @__PURE__ */ e(Z, { slots: a, welcomeMessage: l, suggestedPrompts: s, avatar: c }),
|
|
830
|
+
z ? /* @__PURE__ */ e(z, { status: n, onSend: o, onStop: u }) : /* @__PURE__ */ e(Q, {})
|
|
831
|
+
] })
|
|
832
|
+
] });
|
|
833
|
+
}
|
|
834
|
+
function ze(t) {
|
|
835
|
+
const { sdk: a, mode: l = "floating", slots: s = {}, hooks: r = {}, welcomeMessage: i, suggestedPrompts: c, title: n = "AI Assistant", initialOpen: o = !1, onOpenChange: u, sidebarDefaultOpen: p, avatar: m } = t, [v, x] = I(o);
|
|
836
|
+
P(() => {
|
|
837
|
+
x(o);
|
|
838
|
+
}, [o]);
|
|
839
|
+
const d = w(() => {
|
|
840
|
+
var y, N;
|
|
841
|
+
const f = !v;
|
|
842
|
+
x(f), u == null || u(f), f ? (y = r.onOpen) == null || y.call(r) : (N = r.onClose) == null || N.call(r);
|
|
843
|
+
}, [v, r, u]), h = w(() => {
|
|
844
|
+
var f;
|
|
845
|
+
x(!1), u == null || u(!1), (f = r.onClose) == null || f.call(r);
|
|
846
|
+
}, [r, u]), b = s.Trigger ?? le;
|
|
847
|
+
return l === "fullpage" ? v ? /* @__PURE__ */ e(Y, { sdk: a, hooks: r, children: /* @__PURE__ */ e(
|
|
848
|
+
Ne,
|
|
849
|
+
{
|
|
850
|
+
title: n,
|
|
851
|
+
slots: s,
|
|
852
|
+
welcomeMessage: i,
|
|
853
|
+
suggestedPrompts: c,
|
|
854
|
+
sidebarDefaultOpen: p,
|
|
855
|
+
onClose: h,
|
|
856
|
+
avatar: m
|
|
857
|
+
}
|
|
858
|
+
) }) : null : /* @__PURE__ */ g(Y, { sdk: a, hooks: r, children: [
|
|
859
|
+
/* @__PURE__ */ e(b, { isOpen: v, onClick: d }),
|
|
860
|
+
/* @__PURE__ */ e(
|
|
861
|
+
ke,
|
|
862
|
+
{
|
|
863
|
+
isOpen: v,
|
|
864
|
+
onClose: h,
|
|
865
|
+
title: n,
|
|
866
|
+
slots: s,
|
|
867
|
+
welcomeMessage: i,
|
|
868
|
+
suggestedPrompts: c,
|
|
869
|
+
avatar: m
|
|
870
|
+
}
|
|
871
|
+
)
|
|
872
|
+
] });
|
|
873
|
+
}
|
|
874
|
+
const Ie = `
|
|
875
|
+
[data-super-agent-widget] {
|
|
876
|
+
--sa-primary-dark: color-mix(in srgb, var(--sa-primary) 82%, #000);
|
|
877
|
+
--sa-primary-light: color-mix(in srgb, var(--sa-primary) 10%, #fff);
|
|
878
|
+
--sa-text: #1f2937;
|
|
879
|
+
--sa-text-muted: #6b7280;
|
|
880
|
+
--sa-border: #e5e7eb;
|
|
881
|
+
--sa-surface: #f9fafb;
|
|
882
|
+
|
|
883
|
+
font-family: var(--sa-font);
|
|
884
|
+
color: var(--sa-text);
|
|
885
|
+
line-height: 1.5;
|
|
886
|
+
-webkit-font-smoothing: antialiased;
|
|
887
|
+
text-rendering: optimizeLegibility;
|
|
888
|
+
}
|
|
889
|
+
|
|
890
|
+
[data-super-agent-widget] *,
|
|
891
|
+
[data-super-agent-widget] *::before,
|
|
892
|
+
[data-super-agent-widget] *::after {
|
|
893
|
+
box-sizing: border-box;
|
|
894
|
+
margin: 0;
|
|
895
|
+
padding: 0;
|
|
896
|
+
}
|
|
897
|
+
|
|
898
|
+
[data-super-agent-widget] button {
|
|
899
|
+
font-family: inherit;
|
|
900
|
+
}
|
|
901
|
+
|
|
902
|
+
/* ── Trigger ─────────────────────────────────────────────── */
|
|
903
|
+
|
|
904
|
+
.sa-trigger {
|
|
905
|
+
position: fixed;
|
|
906
|
+
bottom: 24px;
|
|
907
|
+
right: 24px;
|
|
908
|
+
width: 56px;
|
|
909
|
+
height: 56px;
|
|
910
|
+
border: none;
|
|
911
|
+
border-radius: 50%;
|
|
912
|
+
cursor: pointer;
|
|
913
|
+
display: flex;
|
|
914
|
+
align-items: center;
|
|
915
|
+
justify-content: center;
|
|
916
|
+
background: linear-gradient(135deg, var(--sa-primary), var(--sa-primary-dark));
|
|
917
|
+
color: #ffffff;
|
|
918
|
+
font-size: 24px;
|
|
919
|
+
box-shadow: 0 8px 24px color-mix(in srgb, var(--sa-primary) 35%, transparent);
|
|
920
|
+
z-index: var(--sa-z-index, 9999);
|
|
921
|
+
transition: transform 0.2s ease, box-shadow 0.2s ease;
|
|
922
|
+
}
|
|
923
|
+
|
|
924
|
+
.sa-trigger:hover {
|
|
925
|
+
transform: scale(1.08);
|
|
926
|
+
box-shadow: 0 12px 32px color-mix(in srgb, var(--sa-primary) 45%, transparent);
|
|
927
|
+
}
|
|
928
|
+
|
|
929
|
+
.sa-trigger:active {
|
|
930
|
+
transform: scale(0.94);
|
|
931
|
+
}
|
|
932
|
+
|
|
933
|
+
.sa-trigger-open {
|
|
934
|
+
transform: rotate(90deg);
|
|
935
|
+
}
|
|
936
|
+
|
|
937
|
+
/* ── Panel ───────────────────────────────────────────────── */
|
|
938
|
+
|
|
939
|
+
.sa-panel {
|
|
940
|
+
position: fixed;
|
|
941
|
+
bottom: 96px;
|
|
942
|
+
right: 24px;
|
|
943
|
+
width: var(--sa-panel-width, 380px);
|
|
944
|
+
height: var(--sa-panel-height, 520px);
|
|
945
|
+
max-height: calc(100vh - 120px);
|
|
946
|
+
display: flex;
|
|
947
|
+
flex-direction: column;
|
|
948
|
+
overflow: hidden;
|
|
949
|
+
background: var(--sa-bg);
|
|
950
|
+
border: 1px solid var(--sa-border);
|
|
951
|
+
border-radius: var(--sa-radius, 16px);
|
|
952
|
+
box-shadow: 0 20px 60px rgba(0, 0, 0, 0.18);
|
|
953
|
+
z-index: var(--sa-z-index, 9999);
|
|
954
|
+
animation: sa-slide-up 0.25s cubic-bezier(0.16, 1, 0.3, 1);
|
|
955
|
+
}
|
|
956
|
+
|
|
957
|
+
/* ── Header ──────────────────────────────────────────────── */
|
|
958
|
+
|
|
959
|
+
.sa-header {
|
|
960
|
+
display: flex;
|
|
961
|
+
align-items: center;
|
|
962
|
+
gap: 10px;
|
|
963
|
+
padding: 14px 16px;
|
|
964
|
+
color: #ffffff;
|
|
965
|
+
background: linear-gradient(135deg, var(--sa-primary), var(--sa-primary-dark));
|
|
966
|
+
flex-shrink: 0;
|
|
967
|
+
}
|
|
968
|
+
|
|
969
|
+
.sa-header-left {
|
|
970
|
+
display: flex;
|
|
971
|
+
align-items: center;
|
|
972
|
+
gap: 10px;
|
|
973
|
+
flex: 1;
|
|
974
|
+
}
|
|
975
|
+
|
|
976
|
+
.sa-header-avatar {
|
|
977
|
+
width: 28px;
|
|
978
|
+
height: 28px;
|
|
979
|
+
border-radius: 50%;
|
|
980
|
+
background: rgba(255,255,255,0.2);
|
|
981
|
+
display: flex;
|
|
982
|
+
align-items: center;
|
|
983
|
+
justify-content: center;
|
|
984
|
+
font-size: 12px;
|
|
985
|
+
font-weight: 600;
|
|
986
|
+
}
|
|
987
|
+
|
|
988
|
+
.sa-header-info {
|
|
989
|
+
display: flex;
|
|
990
|
+
flex-direction: column;
|
|
991
|
+
}
|
|
992
|
+
|
|
993
|
+
.sa-header-status {
|
|
994
|
+
font-size: 11px;
|
|
995
|
+
opacity: 0.8;
|
|
996
|
+
color: #a5f3a6;
|
|
997
|
+
}
|
|
998
|
+
|
|
999
|
+
.sa-header-actions {
|
|
1000
|
+
display: flex;
|
|
1001
|
+
gap: 4px;
|
|
1002
|
+
}
|
|
1003
|
+
|
|
1004
|
+
.sa-header-title {
|
|
1005
|
+
flex: 1;
|
|
1006
|
+
font-size: 16px;
|
|
1007
|
+
font-weight: 600;
|
|
1008
|
+
white-space: nowrap;
|
|
1009
|
+
overflow: hidden;
|
|
1010
|
+
text-overflow: ellipsis;
|
|
1011
|
+
}
|
|
1012
|
+
|
|
1013
|
+
.sa-header-btn {
|
|
1014
|
+
width: 30px;
|
|
1015
|
+
height: 30px;
|
|
1016
|
+
border: none;
|
|
1017
|
+
border-radius: 8px;
|
|
1018
|
+
background: transparent;
|
|
1019
|
+
color: #ffffff;
|
|
1020
|
+
font-size: 16px;
|
|
1021
|
+
cursor: pointer;
|
|
1022
|
+
display: flex;
|
|
1023
|
+
align-items: center;
|
|
1024
|
+
justify-content: center;
|
|
1025
|
+
transition: background 0.15s ease;
|
|
1026
|
+
}
|
|
1027
|
+
|
|
1028
|
+
.sa-header-btn:hover {
|
|
1029
|
+
background: rgba(255, 255, 255, 0.18);
|
|
1030
|
+
}
|
|
1031
|
+
|
|
1032
|
+
/* ── Thread / messages ───────────────────────────────────── */
|
|
1033
|
+
|
|
1034
|
+
.sa-thread {
|
|
1035
|
+
flex: 1;
|
|
1036
|
+
display: flex;
|
|
1037
|
+
flex-direction: column;
|
|
1038
|
+
gap: 14px;
|
|
1039
|
+
overflow-y: auto;
|
|
1040
|
+
padding: 16px;
|
|
1041
|
+
background: var(--sa-surface);
|
|
1042
|
+
scroll-behavior: smooth;
|
|
1043
|
+
}
|
|
1044
|
+
|
|
1045
|
+
.sa-thread::-webkit-scrollbar {
|
|
1046
|
+
width: 6px;
|
|
1047
|
+
}
|
|
1048
|
+
|
|
1049
|
+
.sa-thread::-webkit-scrollbar-thumb {
|
|
1050
|
+
background: rgba(0, 0, 0, 0.14);
|
|
1051
|
+
border-radius: 3px;
|
|
1052
|
+
}
|
|
1053
|
+
|
|
1054
|
+
.sa-thread::-webkit-scrollbar-thumb:hover {
|
|
1055
|
+
background: rgba(0, 0, 0, 0.24);
|
|
1056
|
+
}
|
|
1057
|
+
|
|
1058
|
+
.sa-message {
|
|
1059
|
+
display: flex;
|
|
1060
|
+
align-items: flex-start;
|
|
1061
|
+
gap: 10px;
|
|
1062
|
+
width: 100%;
|
|
1063
|
+
}
|
|
1064
|
+
|
|
1065
|
+
.sa-message-user {
|
|
1066
|
+
justify-content: flex-end;
|
|
1067
|
+
}
|
|
1068
|
+
|
|
1069
|
+
.sa-message-body {
|
|
1070
|
+
max-width: 78%;
|
|
1071
|
+
display: flex;
|
|
1072
|
+
flex-direction: column;
|
|
1073
|
+
gap: 4px;
|
|
1074
|
+
}
|
|
1075
|
+
|
|
1076
|
+
.sa-message-user .sa-message-body {
|
|
1077
|
+
padding: 10px 14px;
|
|
1078
|
+
border-radius: 16px;
|
|
1079
|
+
border-bottom-right-radius: 4px;
|
|
1080
|
+
background: var(--sa-primary);
|
|
1081
|
+
color: #ffffff;
|
|
1082
|
+
font-size: 14px;
|
|
1083
|
+
line-height: 1.55;
|
|
1084
|
+
word-break: break-word;
|
|
1085
|
+
}
|
|
1086
|
+
|
|
1087
|
+
.sa-message-assistant .sa-message-body {
|
|
1088
|
+
padding: 10px 14px;
|
|
1089
|
+
border-radius: 16px;
|
|
1090
|
+
border-bottom-left-radius: 4px;
|
|
1091
|
+
background: #ffffff;
|
|
1092
|
+
color: var(--sa-text);
|
|
1093
|
+
font-size: 14px;
|
|
1094
|
+
line-height: 1.55;
|
|
1095
|
+
word-break: break-word;
|
|
1096
|
+
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
|
|
1097
|
+
}
|
|
1098
|
+
|
|
1099
|
+
.sa-avatar {
|
|
1100
|
+
width: 28px;
|
|
1101
|
+
height: 28px;
|
|
1102
|
+
flex-shrink: 0;
|
|
1103
|
+
border-radius: 50%;
|
|
1104
|
+
display: flex;
|
|
1105
|
+
align-items: center;
|
|
1106
|
+
justify-content: center;
|
|
1107
|
+
color: #ffffff;
|
|
1108
|
+
font-size: 12px;
|
|
1109
|
+
font-weight: 600;
|
|
1110
|
+
overflow: hidden;
|
|
1111
|
+
}
|
|
1112
|
+
|
|
1113
|
+
.sa-avatar-assistant {
|
|
1114
|
+
background: linear-gradient(135deg, var(--sa-primary), var(--sa-primary-dark));
|
|
1115
|
+
}
|
|
1116
|
+
|
|
1117
|
+
.sa-avatar-user {
|
|
1118
|
+
background: linear-gradient(135deg, #64748b, #475569);
|
|
1119
|
+
}
|
|
1120
|
+
|
|
1121
|
+
/* ── Text part (markdown) ────────────────────────────────── */
|
|
1122
|
+
|
|
1123
|
+
.sa-text-part {
|
|
1124
|
+
font-size: 14px;
|
|
1125
|
+
line-height: 1.6;
|
|
1126
|
+
word-break: break-word;
|
|
1127
|
+
}
|
|
1128
|
+
|
|
1129
|
+
.sa-text-part p {
|
|
1130
|
+
margin: 0 0 8px;
|
|
1131
|
+
}
|
|
1132
|
+
|
|
1133
|
+
.sa-text-part p:last-child {
|
|
1134
|
+
margin-bottom: 0;
|
|
1135
|
+
}
|
|
1136
|
+
|
|
1137
|
+
.sa-text-part strong {
|
|
1138
|
+
font-weight: 600;
|
|
1139
|
+
}
|
|
1140
|
+
|
|
1141
|
+
.sa-text-part em {
|
|
1142
|
+
font-style: italic;
|
|
1143
|
+
}
|
|
1144
|
+
|
|
1145
|
+
.sa-text-part h1,
|
|
1146
|
+
.sa-text-part h2,
|
|
1147
|
+
.sa-text-part h3,
|
|
1148
|
+
.sa-text-part h4,
|
|
1149
|
+
.sa-text-part h5,
|
|
1150
|
+
.sa-text-part h6 {
|
|
1151
|
+
margin: 12px 0 6px;
|
|
1152
|
+
font-weight: 600;
|
|
1153
|
+
line-height: 1.3;
|
|
1154
|
+
}
|
|
1155
|
+
|
|
1156
|
+
.sa-text-part h1 {
|
|
1157
|
+
font-size: 1.4em;
|
|
1158
|
+
}
|
|
1159
|
+
|
|
1160
|
+
.sa-text-part h2 {
|
|
1161
|
+
font-size: 1.25em;
|
|
1162
|
+
}
|
|
1163
|
+
|
|
1164
|
+
.sa-text-part h3 {
|
|
1165
|
+
font-size: 1.1em;
|
|
1166
|
+
}
|
|
1167
|
+
|
|
1168
|
+
.sa-text-part h4,
|
|
1169
|
+
.sa-text-part h5,
|
|
1170
|
+
.sa-text-part h6 {
|
|
1171
|
+
font-size: 1em;
|
|
1172
|
+
}
|
|
1173
|
+
|
|
1174
|
+
.sa-text-part a {
|
|
1175
|
+
color: var(--sa-primary);
|
|
1176
|
+
text-decoration: underline;
|
|
1177
|
+
text-underline-offset: 2px;
|
|
1178
|
+
}
|
|
1179
|
+
|
|
1180
|
+
.sa-text-part a:hover {
|
|
1181
|
+
color: var(--sa-primary-dark);
|
|
1182
|
+
}
|
|
1183
|
+
|
|
1184
|
+
.sa-inline-code {
|
|
1185
|
+
padding: 2px 5px;
|
|
1186
|
+
border-radius: 4px;
|
|
1187
|
+
background: rgba(0, 0, 0, 0.06);
|
|
1188
|
+
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
|
|
1189
|
+
font-size: 0.9em;
|
|
1190
|
+
}
|
|
1191
|
+
|
|
1192
|
+
.sa-code-block {
|
|
1193
|
+
margin: 8px 0;
|
|
1194
|
+
padding: 12px 14px;
|
|
1195
|
+
border-radius: 10px;
|
|
1196
|
+
background: #1e293b;
|
|
1197
|
+
color: #e2e8f0;
|
|
1198
|
+
overflow-x: auto;
|
|
1199
|
+
font-size: 13px;
|
|
1200
|
+
line-height: 1.55;
|
|
1201
|
+
}
|
|
1202
|
+
|
|
1203
|
+
.sa-code-block code {
|
|
1204
|
+
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
|
|
1205
|
+
white-space: pre;
|
|
1206
|
+
}
|
|
1207
|
+
|
|
1208
|
+
.sa-list {
|
|
1209
|
+
margin: 6px 0;
|
|
1210
|
+
padding-left: 22px;
|
|
1211
|
+
}
|
|
1212
|
+
|
|
1213
|
+
.sa-list li {
|
|
1214
|
+
margin: 3px 0;
|
|
1215
|
+
line-height: 1.5;
|
|
1216
|
+
}
|
|
1217
|
+
|
|
1218
|
+
ul.sa-list {
|
|
1219
|
+
list-style: disc;
|
|
1220
|
+
}
|
|
1221
|
+
|
|
1222
|
+
ol.sa-list {
|
|
1223
|
+
list-style: decimal;
|
|
1224
|
+
}
|
|
1225
|
+
|
|
1226
|
+
/* ── Thinking part ───────────────────────────────────────── */
|
|
1227
|
+
|
|
1228
|
+
.sa-thinking-part {
|
|
1229
|
+
margin: 6px 0;
|
|
1230
|
+
padding: 8px 12px;
|
|
1231
|
+
border-left: 3px solid var(--sa-primary);
|
|
1232
|
+
border-radius: 8px;
|
|
1233
|
+
background: var(--sa-primary-light);
|
|
1234
|
+
cursor: pointer;
|
|
1235
|
+
font-size: 13px;
|
|
1236
|
+
}
|
|
1237
|
+
|
|
1238
|
+
.sa-thinking-header {
|
|
1239
|
+
display: flex;
|
|
1240
|
+
align-items: center;
|
|
1241
|
+
gap: 6px;
|
|
1242
|
+
color: var(--sa-primary-dark);
|
|
1243
|
+
font-weight: 500;
|
|
1244
|
+
user-select: none;
|
|
1245
|
+
}
|
|
1246
|
+
|
|
1247
|
+
.sa-thinking-icon {
|
|
1248
|
+
font-size: 14px;
|
|
1249
|
+
line-height: 1;
|
|
1250
|
+
}
|
|
1251
|
+
|
|
1252
|
+
.sa-thinking-label {
|
|
1253
|
+
flex: 1;
|
|
1254
|
+
}
|
|
1255
|
+
|
|
1256
|
+
.sa-thinking-arrow {
|
|
1257
|
+
font-size: 12px;
|
|
1258
|
+
transition: transform 0.2s ease;
|
|
1259
|
+
}
|
|
1260
|
+
|
|
1261
|
+
.sa-thinking-arrow.expanded {
|
|
1262
|
+
transform: rotate(90deg);
|
|
1263
|
+
}
|
|
1264
|
+
|
|
1265
|
+
.sa-thinking-content {
|
|
1266
|
+
margin-top: 8px;
|
|
1267
|
+
color: #4b5563;
|
|
1268
|
+
white-space: pre-wrap;
|
|
1269
|
+
line-height: 1.55;
|
|
1270
|
+
}
|
|
1271
|
+
|
|
1272
|
+
/* ── Tool call / result ──────────────────────────────────── */
|
|
1273
|
+
|
|
1274
|
+
.sa-tool-call-part {
|
|
1275
|
+
margin: 6px 0;
|
|
1276
|
+
border: 1px solid var(--sa-border);
|
|
1277
|
+
border-radius: 10px;
|
|
1278
|
+
overflow: hidden;
|
|
1279
|
+
background: #ffffff;
|
|
1280
|
+
}
|
|
1281
|
+
|
|
1282
|
+
.sa-tool-call-header {
|
|
1283
|
+
display: flex;
|
|
1284
|
+
align-items: center;
|
|
1285
|
+
gap: 8px;
|
|
1286
|
+
padding: 8px 12px;
|
|
1287
|
+
cursor: pointer;
|
|
1288
|
+
font-size: 13px;
|
|
1289
|
+
user-select: none;
|
|
1290
|
+
}
|
|
1291
|
+
|
|
1292
|
+
.sa-tool-call-header:hover {
|
|
1293
|
+
background: var(--sa-surface);
|
|
1294
|
+
}
|
|
1295
|
+
|
|
1296
|
+
.sa-tool-icon {
|
|
1297
|
+
font-size: 14px;
|
|
1298
|
+
line-height: 1;
|
|
1299
|
+
}
|
|
1300
|
+
|
|
1301
|
+
.sa-tool-name {
|
|
1302
|
+
flex: 1;
|
|
1303
|
+
color: #374151;
|
|
1304
|
+
font-weight: 500;
|
|
1305
|
+
overflow: hidden;
|
|
1306
|
+
white-space: nowrap;
|
|
1307
|
+
text-overflow: ellipsis;
|
|
1308
|
+
}
|
|
1309
|
+
|
|
1310
|
+
.sa-tool-args {
|
|
1311
|
+
margin: 0;
|
|
1312
|
+
padding: 10px 12px;
|
|
1313
|
+
border-top: 1px solid var(--sa-border);
|
|
1314
|
+
background: var(--sa-surface);
|
|
1315
|
+
color: #374151;
|
|
1316
|
+
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
|
|
1317
|
+
font-size: 12px;
|
|
1318
|
+
line-height: 1.5;
|
|
1319
|
+
white-space: pre;
|
|
1320
|
+
overflow-x: auto;
|
|
1321
|
+
}
|
|
1322
|
+
|
|
1323
|
+
.sa-tool-result-part {
|
|
1324
|
+
margin: 6px 0;
|
|
1325
|
+
border: 1px solid var(--sa-border);
|
|
1326
|
+
border-radius: 10px;
|
|
1327
|
+
overflow: hidden;
|
|
1328
|
+
background: #ffffff;
|
|
1329
|
+
}
|
|
1330
|
+
|
|
1331
|
+
.sa-tool-result-header {
|
|
1332
|
+
display: flex;
|
|
1333
|
+
align-items: center;
|
|
1334
|
+
gap: 8px;
|
|
1335
|
+
padding: 8px 12px;
|
|
1336
|
+
border-bottom: 1px solid var(--sa-border);
|
|
1337
|
+
background: var(--sa-surface);
|
|
1338
|
+
color: #374151;
|
|
1339
|
+
font-size: 13px;
|
|
1340
|
+
font-weight: 500;
|
|
1341
|
+
}
|
|
1342
|
+
|
|
1343
|
+
.sa-tool-result-content {
|
|
1344
|
+
padding: 10px 12px;
|
|
1345
|
+
color: #4b5563;
|
|
1346
|
+
font-size: 13px;
|
|
1347
|
+
line-height: 1.55;
|
|
1348
|
+
white-space: pre-wrap;
|
|
1349
|
+
word-break: break-word;
|
|
1350
|
+
}
|
|
1351
|
+
|
|
1352
|
+
/* ── Error part ──────────────────────────────────────────── */
|
|
1353
|
+
|
|
1354
|
+
.sa-error-part {
|
|
1355
|
+
margin: 6px 0;
|
|
1356
|
+
padding: 10px 12px;
|
|
1357
|
+
border: 1px solid #fecaca;
|
|
1358
|
+
border-radius: 10px;
|
|
1359
|
+
background: #fef2f2;
|
|
1360
|
+
color: #b91c1c;
|
|
1361
|
+
}
|
|
1362
|
+
|
|
1363
|
+
.sa-error-content {
|
|
1364
|
+
display: flex;
|
|
1365
|
+
align-items: flex-start;
|
|
1366
|
+
gap: 8px;
|
|
1367
|
+
font-size: 13px;
|
|
1368
|
+
line-height: 1.5;
|
|
1369
|
+
}
|
|
1370
|
+
|
|
1371
|
+
.sa-error-icon {
|
|
1372
|
+
font-size: 14px;
|
|
1373
|
+
line-height: 1.4;
|
|
1374
|
+
}
|
|
1375
|
+
|
|
1376
|
+
.sa-error-retry {
|
|
1377
|
+
margin-top: 8px;
|
|
1378
|
+
padding: 6px 14px;
|
|
1379
|
+
border: none;
|
|
1380
|
+
border-radius: 8px;
|
|
1381
|
+
background: #ef4444;
|
|
1382
|
+
color: #ffffff;
|
|
1383
|
+
font-size: 13px;
|
|
1384
|
+
cursor: pointer;
|
|
1385
|
+
transition: background 0.2s ease;
|
|
1386
|
+
}
|
|
1387
|
+
|
|
1388
|
+
.sa-error-retry:hover {
|
|
1389
|
+
background: #dc2626;
|
|
1390
|
+
}
|
|
1391
|
+
|
|
1392
|
+
/* ── Action bar ──────────────────────────────────────────── */
|
|
1393
|
+
|
|
1394
|
+
.sa-action-bar {
|
|
1395
|
+
display: flex;
|
|
1396
|
+
gap: 6px;
|
|
1397
|
+
margin-top: 6px;
|
|
1398
|
+
}
|
|
1399
|
+
|
|
1400
|
+
.sa-action-btn {
|
|
1401
|
+
padding: 4px 10px;
|
|
1402
|
+
border: none;
|
|
1403
|
+
border-radius: 6px;
|
|
1404
|
+
background: transparent;
|
|
1405
|
+
color: var(--sa-text-muted);
|
|
1406
|
+
font-size: 12px;
|
|
1407
|
+
cursor: pointer;
|
|
1408
|
+
transition: color 0.15s ease, background 0.15s ease;
|
|
1409
|
+
}
|
|
1410
|
+
|
|
1411
|
+
.sa-action-btn:hover {
|
|
1412
|
+
color: var(--sa-text);
|
|
1413
|
+
background: rgba(0, 0, 0, 0.05);
|
|
1414
|
+
}
|
|
1415
|
+
|
|
1416
|
+
.sa-action-btn-active {
|
|
1417
|
+
color: var(--sa-primary) !important;
|
|
1418
|
+
background: var(--sa-primary-light) !important;
|
|
1419
|
+
}
|
|
1420
|
+
|
|
1421
|
+
.sa-action-divider {
|
|
1422
|
+
width: 1px;
|
|
1423
|
+
height: 16px;
|
|
1424
|
+
background: var(--sa-border);
|
|
1425
|
+
margin: 0 2px;
|
|
1426
|
+
align-self: center;
|
|
1427
|
+
}
|
|
1428
|
+
|
|
1429
|
+
/* ── Composer ────────────────────────────────────────────── */
|
|
1430
|
+
|
|
1431
|
+
.sa-composer {
|
|
1432
|
+
display: flex;
|
|
1433
|
+
align-items: flex-end;
|
|
1434
|
+
gap: 10px;
|
|
1435
|
+
padding: 12px 14px;
|
|
1436
|
+
border-top: 1px solid var(--sa-border);
|
|
1437
|
+
background: var(--sa-bg);
|
|
1438
|
+
flex-shrink: 0;
|
|
1439
|
+
}
|
|
1440
|
+
|
|
1441
|
+
.sa-composer-input {
|
|
1442
|
+
flex: 1;
|
|
1443
|
+
min-height: 38px;
|
|
1444
|
+
max-height: 120px;
|
|
1445
|
+
padding: 9px 14px;
|
|
1446
|
+
border: 1px solid var(--sa-border);
|
|
1447
|
+
border-radius: 19px;
|
|
1448
|
+
background: var(--sa-surface);
|
|
1449
|
+
color: var(--sa-text);
|
|
1450
|
+
font-family: var(--sa-font);
|
|
1451
|
+
font-size: 14px;
|
|
1452
|
+
line-height: 1.5;
|
|
1453
|
+
resize: none;
|
|
1454
|
+
outline: none;
|
|
1455
|
+
transition: border-color 0.2s ease, background 0.2s ease;
|
|
1456
|
+
}
|
|
1457
|
+
|
|
1458
|
+
.sa-composer-input::placeholder {
|
|
1459
|
+
color: #9ca3af;
|
|
1460
|
+
}
|
|
1461
|
+
|
|
1462
|
+
.sa-composer-input:focus {
|
|
1463
|
+
border-color: var(--sa-primary);
|
|
1464
|
+
background: #ffffff;
|
|
1465
|
+
}
|
|
1466
|
+
|
|
1467
|
+
.sa-composer-send,
|
|
1468
|
+
.sa-composer-stop {
|
|
1469
|
+
width: 38px;
|
|
1470
|
+
height: 38px;
|
|
1471
|
+
flex-shrink: 0;
|
|
1472
|
+
border: none;
|
|
1473
|
+
border-radius: 50%;
|
|
1474
|
+
cursor: pointer;
|
|
1475
|
+
display: flex;
|
|
1476
|
+
align-items: center;
|
|
1477
|
+
justify-content: center;
|
|
1478
|
+
color: #ffffff;
|
|
1479
|
+
font-size: 16px;
|
|
1480
|
+
transition: transform 0.15s ease, background 0.2s ease;
|
|
1481
|
+
}
|
|
1482
|
+
|
|
1483
|
+
.sa-composer-send {
|
|
1484
|
+
background: var(--sa-primary);
|
|
1485
|
+
}
|
|
1486
|
+
|
|
1487
|
+
.sa-composer-send:hover {
|
|
1488
|
+
background: var(--sa-primary-dark);
|
|
1489
|
+
transform: scale(1.05);
|
|
1490
|
+
}
|
|
1491
|
+
|
|
1492
|
+
.sa-composer-send:disabled {
|
|
1493
|
+
opacity: 0.5;
|
|
1494
|
+
cursor: not-allowed;
|
|
1495
|
+
transform: none;
|
|
1496
|
+
}
|
|
1497
|
+
|
|
1498
|
+
.sa-composer-stop {
|
|
1499
|
+
background: #ef4444;
|
|
1500
|
+
}
|
|
1501
|
+
|
|
1502
|
+
.sa-composer-stop:hover {
|
|
1503
|
+
background: #dc2626;
|
|
1504
|
+
transform: scale(1.05);
|
|
1505
|
+
}
|
|
1506
|
+
|
|
1507
|
+
/* ── Thread list ─────────────────────────────────────────── */
|
|
1508
|
+
|
|
1509
|
+
.sa-thread-list-overlay {
|
|
1510
|
+
position: absolute;
|
|
1511
|
+
inset: 0;
|
|
1512
|
+
background: rgba(0,0,0,0.3);
|
|
1513
|
+
z-index: 19;
|
|
1514
|
+
}
|
|
1515
|
+
|
|
1516
|
+
.sa-thread-list {
|
|
1517
|
+
position: absolute;
|
|
1518
|
+
top: 0;
|
|
1519
|
+
left: 0;
|
|
1520
|
+
bottom: 0;
|
|
1521
|
+
width: 100%;
|
|
1522
|
+
display: flex;
|
|
1523
|
+
flex-direction: column;
|
|
1524
|
+
background: #ffffff;
|
|
1525
|
+
z-index: 20;
|
|
1526
|
+
box-shadow: 0 0 40px rgba(0, 0, 0, 0.15);
|
|
1527
|
+
animation: sa-slide-in-left 0.25s cubic-bezier(0.16, 1, 0.3, 1);
|
|
1528
|
+
}
|
|
1529
|
+
|
|
1530
|
+
.sa-thread-list-header {
|
|
1531
|
+
display: flex;
|
|
1532
|
+
align-items: center;
|
|
1533
|
+
gap: 10px;
|
|
1534
|
+
padding: 14px 16px;
|
|
1535
|
+
border-bottom: 1px solid var(--sa-border);
|
|
1536
|
+
flex-shrink: 0;
|
|
1537
|
+
}
|
|
1538
|
+
|
|
1539
|
+
.sa-thread-list-items {
|
|
1540
|
+
flex: 1;
|
|
1541
|
+
overflow-y: auto;
|
|
1542
|
+
}
|
|
1543
|
+
|
|
1544
|
+
.sa-thread-list-empty {
|
|
1545
|
+
padding: 24px 16px;
|
|
1546
|
+
text-align: center;
|
|
1547
|
+
color: var(--sa-text-muted);
|
|
1548
|
+
font-size: 13px;
|
|
1549
|
+
}
|
|
1550
|
+
|
|
1551
|
+
.sa-thread-list-new {
|
|
1552
|
+
display: block;
|
|
1553
|
+
width: calc(100% - 24px);
|
|
1554
|
+
margin: 12px;
|
|
1555
|
+
padding: 10px;
|
|
1556
|
+
border: 1px dashed var(--sa-border);
|
|
1557
|
+
border-radius: 10px;
|
|
1558
|
+
background: transparent;
|
|
1559
|
+
color: var(--sa-primary);
|
|
1560
|
+
font-size: 14px;
|
|
1561
|
+
cursor: pointer;
|
|
1562
|
+
text-align: center;
|
|
1563
|
+
transition: background 0.15s, border-color 0.15s;
|
|
1564
|
+
}
|
|
1565
|
+
|
|
1566
|
+
.sa-thread-list-new:hover {
|
|
1567
|
+
background: var(--sa-primary-light);
|
|
1568
|
+
border-color: var(--sa-primary);
|
|
1569
|
+
}
|
|
1570
|
+
|
|
1571
|
+
.sa-thread-item {
|
|
1572
|
+
display: flex;
|
|
1573
|
+
align-items: center;
|
|
1574
|
+
justify-content: space-between;
|
|
1575
|
+
gap: 8px;
|
|
1576
|
+
padding: 12px 16px;
|
|
1577
|
+
border-bottom: 1px solid #f3f4f6;
|
|
1578
|
+
color: #374151;
|
|
1579
|
+
font-size: 14px;
|
|
1580
|
+
cursor: pointer;
|
|
1581
|
+
transition: background 0.15s ease;
|
|
1582
|
+
}
|
|
1583
|
+
|
|
1584
|
+
.sa-thread-item:hover {
|
|
1585
|
+
background: var(--sa-surface);
|
|
1586
|
+
}
|
|
1587
|
+
|
|
1588
|
+
.sa-thread-item.active {
|
|
1589
|
+
background: var(--sa-primary-light);
|
|
1590
|
+
color: var(--sa-primary-dark);
|
|
1591
|
+
font-weight: 500;
|
|
1592
|
+
}
|
|
1593
|
+
|
|
1594
|
+
.sa-thread-item-title {
|
|
1595
|
+
flex: 1;
|
|
1596
|
+
overflow: hidden;
|
|
1597
|
+
white-space: nowrap;
|
|
1598
|
+
text-overflow: ellipsis;
|
|
1599
|
+
}
|
|
1600
|
+
|
|
1601
|
+
.sa-thread-item-edit {
|
|
1602
|
+
width: 100%;
|
|
1603
|
+
padding: 4px 8px;
|
|
1604
|
+
border: 1px solid var(--sa-primary);
|
|
1605
|
+
border-radius: 6px;
|
|
1606
|
+
font-size: 13px;
|
|
1607
|
+
outline: none;
|
|
1608
|
+
background: var(--sa-bg);
|
|
1609
|
+
color: var(--sa-text);
|
|
1610
|
+
}
|
|
1611
|
+
|
|
1612
|
+
.sa-thread-item-delete {
|
|
1613
|
+
border: none;
|
|
1614
|
+
background: transparent;
|
|
1615
|
+
color: var(--sa-text-muted);
|
|
1616
|
+
font-size: 14px;
|
|
1617
|
+
cursor: pointer;
|
|
1618
|
+
opacity: 0;
|
|
1619
|
+
transition: opacity 0.15s ease, color 0.15s ease;
|
|
1620
|
+
}
|
|
1621
|
+
|
|
1622
|
+
.sa-thread-item:hover .sa-thread-item-delete {
|
|
1623
|
+
opacity: 1;
|
|
1624
|
+
}
|
|
1625
|
+
|
|
1626
|
+
.sa-thread-item-delete:hover {
|
|
1627
|
+
color: #ef4444;
|
|
1628
|
+
}
|
|
1629
|
+
|
|
1630
|
+
/* ── Welcome ─────────────────────────────────────────────── */
|
|
1631
|
+
|
|
1632
|
+
.sa-welcome {
|
|
1633
|
+
flex: 1;
|
|
1634
|
+
display: flex;
|
|
1635
|
+
flex-direction: column;
|
|
1636
|
+
align-items: center;
|
|
1637
|
+
justify-content: center;
|
|
1638
|
+
padding: 24px;
|
|
1639
|
+
text-align: center;
|
|
1640
|
+
}
|
|
1641
|
+
|
|
1642
|
+
.sa-welcome-icon {
|
|
1643
|
+
font-size: 40px;
|
|
1644
|
+
margin-bottom: 12px;
|
|
1645
|
+
}
|
|
1646
|
+
|
|
1647
|
+
.sa-welcome-message {
|
|
1648
|
+
margin-bottom: 20px;
|
|
1649
|
+
font-size: 14px;
|
|
1650
|
+
color: var(--sa-text-muted);
|
|
1651
|
+
line-height: 1.6;
|
|
1652
|
+
}
|
|
1653
|
+
|
|
1654
|
+
.sa-welcome-prompts {
|
|
1655
|
+
display: flex;
|
|
1656
|
+
flex-direction: column;
|
|
1657
|
+
gap: 8px;
|
|
1658
|
+
width: 100%;
|
|
1659
|
+
}
|
|
1660
|
+
|
|
1661
|
+
.sa-welcome-prompt {
|
|
1662
|
+
padding: 10px 16px;
|
|
1663
|
+
border: 1px solid var(--sa-border);
|
|
1664
|
+
border-radius: 999px;
|
|
1665
|
+
background: #ffffff;
|
|
1666
|
+
color: #374151;
|
|
1667
|
+
font-size: 13px;
|
|
1668
|
+
cursor: pointer;
|
|
1669
|
+
transition: border-color 0.2s ease, background 0.2s ease, color 0.2s ease;
|
|
1670
|
+
}
|
|
1671
|
+
|
|
1672
|
+
.sa-welcome-prompt:hover {
|
|
1673
|
+
border-color: var(--sa-primary);
|
|
1674
|
+
background: var(--sa-primary-light);
|
|
1675
|
+
color: var(--sa-primary-dark);
|
|
1676
|
+
}
|
|
1677
|
+
|
|
1678
|
+
/* ── Streaming cursor ────────────────────────────────────── */
|
|
1679
|
+
|
|
1680
|
+
.sa-streaming-cursor {
|
|
1681
|
+
display: inline-block;
|
|
1682
|
+
width: 2px;
|
|
1683
|
+
height: 1em;
|
|
1684
|
+
margin-left: 2px;
|
|
1685
|
+
background: var(--sa-primary);
|
|
1686
|
+
vertical-align: text-bottom;
|
|
1687
|
+
animation: sa-blink 1s steps(2, start) infinite;
|
|
1688
|
+
}
|
|
1689
|
+
|
|
1690
|
+
/* ── Animations ──────────────────────────────────────────── */
|
|
1691
|
+
|
|
1692
|
+
@keyframes sa-slide-up {
|
|
1693
|
+
from {
|
|
1694
|
+
opacity: 0;
|
|
1695
|
+
transform: translateY(16px) scale(0.98);
|
|
1696
|
+
}
|
|
1697
|
+
to {
|
|
1698
|
+
opacity: 1;
|
|
1699
|
+
transform: translateY(0) scale(1);
|
|
1700
|
+
}
|
|
1701
|
+
}
|
|
1702
|
+
|
|
1703
|
+
@keyframes sa-blink {
|
|
1704
|
+
0%,
|
|
1705
|
+
100% {
|
|
1706
|
+
opacity: 1;
|
|
1707
|
+
}
|
|
1708
|
+
50% {
|
|
1709
|
+
opacity: 0;
|
|
1710
|
+
}
|
|
1711
|
+
}
|
|
1712
|
+
|
|
1713
|
+
@keyframes sa-slide-in-left {
|
|
1714
|
+
from {
|
|
1715
|
+
opacity: 0;
|
|
1716
|
+
transform: translateX(-100%);
|
|
1717
|
+
}
|
|
1718
|
+
to {
|
|
1719
|
+
opacity: 1;
|
|
1720
|
+
transform: translateX(0);
|
|
1721
|
+
}
|
|
1722
|
+
}
|
|
1723
|
+
|
|
1724
|
+
/* ── Fullpage Layout (DeepSeek-style) ────────────────────────── */
|
|
1725
|
+
|
|
1726
|
+
.sa-fullpage {
|
|
1727
|
+
position: fixed;
|
|
1728
|
+
inset: 0;
|
|
1729
|
+
width: 100vw;
|
|
1730
|
+
height: 100vh;
|
|
1731
|
+
display: flex;
|
|
1732
|
+
background: #f7f7f8;
|
|
1733
|
+
z-index: var(--sa-z-index, 9999);
|
|
1734
|
+
}
|
|
1735
|
+
|
|
1736
|
+
/* Sidebar */
|
|
1737
|
+
.sa-fp-sidebar {
|
|
1738
|
+
width: 260px;
|
|
1739
|
+
display: flex;
|
|
1740
|
+
flex-direction: column;
|
|
1741
|
+
background: #f2f2f3;
|
|
1742
|
+
flex-shrink: 0;
|
|
1743
|
+
transition: width 0.2s cubic-bezier(0.16,1,0.3,1);
|
|
1744
|
+
overflow: hidden;
|
|
1745
|
+
border-right: 1px solid #e8e8ea;
|
|
1746
|
+
}
|
|
1747
|
+
|
|
1748
|
+
.sa-fp-sidebar-collapsed {
|
|
1749
|
+
width: 52px;
|
|
1750
|
+
align-items: center;
|
|
1751
|
+
padding-top: 12px;
|
|
1752
|
+
gap: 4px;
|
|
1753
|
+
border-right: 1px solid #e8e8ea;
|
|
1754
|
+
}
|
|
1755
|
+
|
|
1756
|
+
.sa-fp-sidebar-header {
|
|
1757
|
+
display: flex;
|
|
1758
|
+
align-items: center;
|
|
1759
|
+
gap: 8px;
|
|
1760
|
+
padding: 12px 12px 8px;
|
|
1761
|
+
flex-shrink: 0;
|
|
1762
|
+
}
|
|
1763
|
+
|
|
1764
|
+
.sa-fp-sidebar-toggle {
|
|
1765
|
+
width: 32px;
|
|
1766
|
+
height: 32px;
|
|
1767
|
+
border: none;
|
|
1768
|
+
border-radius: 8px;
|
|
1769
|
+
background: transparent;
|
|
1770
|
+
color: #71717a;
|
|
1771
|
+
cursor: pointer;
|
|
1772
|
+
display: flex;
|
|
1773
|
+
align-items: center;
|
|
1774
|
+
justify-content: center;
|
|
1775
|
+
transition: background 0.12s, color 0.12s;
|
|
1776
|
+
flex-shrink: 0;
|
|
1777
|
+
}
|
|
1778
|
+
|
|
1779
|
+
.sa-fp-sidebar-toggle:hover {
|
|
1780
|
+
background: #e4e4e7;
|
|
1781
|
+
color: #18181b;
|
|
1782
|
+
}
|
|
1783
|
+
|
|
1784
|
+
.sa-fp-sidebar-new {
|
|
1785
|
+
flex: 1;
|
|
1786
|
+
padding: 7px 12px;
|
|
1787
|
+
border: 1px solid #d4d4d8;
|
|
1788
|
+
border-radius: 8px;
|
|
1789
|
+
background: #fff;
|
|
1790
|
+
color: #3f3f46;
|
|
1791
|
+
font-size: 13px;
|
|
1792
|
+
font-weight: 500;
|
|
1793
|
+
cursor: pointer;
|
|
1794
|
+
display: flex;
|
|
1795
|
+
align-items: center;
|
|
1796
|
+
gap: 6px;
|
|
1797
|
+
transition: border-color 0.12s, box-shadow 0.12s;
|
|
1798
|
+
}
|
|
1799
|
+
|
|
1800
|
+
.sa-fp-sidebar-new:hover {
|
|
1801
|
+
border-color: #a1a1aa;
|
|
1802
|
+
box-shadow: 0 1px 3px rgba(0,0,0,0.06);
|
|
1803
|
+
}
|
|
1804
|
+
|
|
1805
|
+
.sa-fp-sidebar-new span {
|
|
1806
|
+
font-size: 13px;
|
|
1807
|
+
}
|
|
1808
|
+
|
|
1809
|
+
.sa-fp-sidebar-list {
|
|
1810
|
+
flex: 1;
|
|
1811
|
+
overflow-y: auto;
|
|
1812
|
+
padding: 4px 8px 12px;
|
|
1813
|
+
}
|
|
1814
|
+
|
|
1815
|
+
.sa-fp-sidebar-list::-webkit-scrollbar {
|
|
1816
|
+
width: 4px;
|
|
1817
|
+
}
|
|
1818
|
+
|
|
1819
|
+
.sa-fp-sidebar-list::-webkit-scrollbar-thumb {
|
|
1820
|
+
background: rgba(0,0,0,0.08);
|
|
1821
|
+
border-radius: 2px;
|
|
1822
|
+
}
|
|
1823
|
+
|
|
1824
|
+
.sa-fp-sidebar-list::-webkit-scrollbar-thumb:hover {
|
|
1825
|
+
background: rgba(0,0,0,0.15);
|
|
1826
|
+
}
|
|
1827
|
+
|
|
1828
|
+
.sa-fp-sidebar-group {
|
|
1829
|
+
padding: 12px 8px 4px;
|
|
1830
|
+
font-size: 11px;
|
|
1831
|
+
font-weight: 500;
|
|
1832
|
+
color: #a1a1aa;
|
|
1833
|
+
letter-spacing: 0.3px;
|
|
1834
|
+
}
|
|
1835
|
+
|
|
1836
|
+
.sa-fp-sidebar-item {
|
|
1837
|
+
display: flex;
|
|
1838
|
+
align-items: center;
|
|
1839
|
+
gap: 8px;
|
|
1840
|
+
padding: 8px 10px;
|
|
1841
|
+
margin: 1px 0;
|
|
1842
|
+
border-radius: 8px;
|
|
1843
|
+
cursor: pointer;
|
|
1844
|
+
color: #3f3f46;
|
|
1845
|
+
font-size: 13px;
|
|
1846
|
+
line-height: 1.4;
|
|
1847
|
+
transition: background 0.1s;
|
|
1848
|
+
}
|
|
1849
|
+
|
|
1850
|
+
.sa-fp-sidebar-item:hover {
|
|
1851
|
+
background: #e8e8ea;
|
|
1852
|
+
}
|
|
1853
|
+
|
|
1854
|
+
.sa-fp-sidebar-item.active {
|
|
1855
|
+
background: #e4e4e7;
|
|
1856
|
+
color: #18181b;
|
|
1857
|
+
font-weight: 500;
|
|
1858
|
+
}
|
|
1859
|
+
|
|
1860
|
+
.sa-fp-sidebar-item-title {
|
|
1861
|
+
flex: 1;
|
|
1862
|
+
overflow: hidden;
|
|
1863
|
+
white-space: nowrap;
|
|
1864
|
+
text-overflow: ellipsis;
|
|
1865
|
+
}
|
|
1866
|
+
|
|
1867
|
+
.sa-fp-sidebar-item-action {
|
|
1868
|
+
width: 24px;
|
|
1869
|
+
height: 24px;
|
|
1870
|
+
border: none;
|
|
1871
|
+
border-radius: 6px;
|
|
1872
|
+
background: transparent;
|
|
1873
|
+
color: #a1a1aa;
|
|
1874
|
+
cursor: pointer;
|
|
1875
|
+
display: flex;
|
|
1876
|
+
align-items: center;
|
|
1877
|
+
justify-content: center;
|
|
1878
|
+
flex-shrink: 0;
|
|
1879
|
+
transition: color 0.1s, background 0.1s;
|
|
1880
|
+
}
|
|
1881
|
+
|
|
1882
|
+
.sa-fp-sidebar-item-action:hover {
|
|
1883
|
+
color: #71717a;
|
|
1884
|
+
background: rgba(0,0,0,0.05);
|
|
1885
|
+
}
|
|
1886
|
+
|
|
1887
|
+
.sa-fp-sidebar-item-action.danger {
|
|
1888
|
+
color: #ef4444;
|
|
1889
|
+
}
|
|
1890
|
+
|
|
1891
|
+
.sa-fp-sidebar-item-action.danger:hover {
|
|
1892
|
+
color: #dc2626;
|
|
1893
|
+
background: rgba(239,68,68,0.08);
|
|
1894
|
+
}
|
|
1895
|
+
|
|
1896
|
+
.sa-fp-sidebar-empty {
|
|
1897
|
+
padding: 32px 12px;
|
|
1898
|
+
text-align: center;
|
|
1899
|
+
color: #a1a1aa;
|
|
1900
|
+
font-size: 13px;
|
|
1901
|
+
}
|
|
1902
|
+
|
|
1903
|
+
/* Sidebar wrapper (for custom ThreadList slot) */
|
|
1904
|
+
.sa-fp-sidebar-wrapper {
|
|
1905
|
+
width: 260px;
|
|
1906
|
+
flex-shrink: 0;
|
|
1907
|
+
overflow: hidden;
|
|
1908
|
+
border-right: 1px solid #e8e8ea;
|
|
1909
|
+
background: #f2f2f3;
|
|
1910
|
+
transition: width 0.2s cubic-bezier(0.16,1,0.3,1);
|
|
1911
|
+
}
|
|
1912
|
+
|
|
1913
|
+
.sa-fp-sidebar-wrapper-collapsed {
|
|
1914
|
+
width: 0;
|
|
1915
|
+
}
|
|
1916
|
+
|
|
1917
|
+
/* Main area */
|
|
1918
|
+
.sa-fp-main {
|
|
1919
|
+
flex: 1;
|
|
1920
|
+
display: flex;
|
|
1921
|
+
flex-direction: column;
|
|
1922
|
+
min-width: 0;
|
|
1923
|
+
background: #fff;
|
|
1924
|
+
}
|
|
1925
|
+
|
|
1926
|
+
.sa-fp-header {
|
|
1927
|
+
display: flex;
|
|
1928
|
+
align-items: center;
|
|
1929
|
+
gap: 12px;
|
|
1930
|
+
padding: 10px 16px;
|
|
1931
|
+
border-bottom: 1px solid #f0f0f0;
|
|
1932
|
+
background: #fff;
|
|
1933
|
+
flex-shrink: 0;
|
|
1934
|
+
min-height: 52px;
|
|
1935
|
+
}
|
|
1936
|
+
|
|
1937
|
+
.sa-fp-header-title {
|
|
1938
|
+
flex: 1;
|
|
1939
|
+
font-size: 15px;
|
|
1940
|
+
font-weight: 500;
|
|
1941
|
+
color: #18181b;
|
|
1942
|
+
letter-spacing: -0.2px;
|
|
1943
|
+
}
|
|
1944
|
+
|
|
1945
|
+
.sa-fp-header-actions {
|
|
1946
|
+
display: flex;
|
|
1947
|
+
gap: 4px;
|
|
1948
|
+
}
|
|
1949
|
+
|
|
1950
|
+
.sa-fp-header-btn {
|
|
1951
|
+
width: 34px;
|
|
1952
|
+
height: 34px;
|
|
1953
|
+
border: none;
|
|
1954
|
+
border-radius: 8px;
|
|
1955
|
+
background: transparent;
|
|
1956
|
+
color: #71717a;
|
|
1957
|
+
cursor: pointer;
|
|
1958
|
+
display: flex;
|
|
1959
|
+
align-items: center;
|
|
1960
|
+
justify-content: center;
|
|
1961
|
+
transition: background 0.12s, color 0.12s;
|
|
1962
|
+
}
|
|
1963
|
+
|
|
1964
|
+
.sa-fp-header-btn:hover {
|
|
1965
|
+
background: #f4f4f5;
|
|
1966
|
+
color: #18181b;
|
|
1967
|
+
}
|
|
1968
|
+
|
|
1969
|
+
/* Fullpage thread/composer override */
|
|
1970
|
+
.sa-fp-main .sa-thread {
|
|
1971
|
+
margin: 0 auto;
|
|
1972
|
+
width: 100%;
|
|
1973
|
+
padding: 24px 24px;
|
|
1974
|
+
}
|
|
1975
|
+
|
|
1976
|
+
.sa-fp-main .sa-composer {
|
|
1977
|
+
margin: 0 auto;
|
|
1978
|
+
width: 100%;
|
|
1979
|
+
padding: 12px 24px 20px;
|
|
1980
|
+
border-top: none;
|
|
1981
|
+
background: transparent;
|
|
1982
|
+
}
|
|
1983
|
+
|
|
1984
|
+
.sa-fp-main .sa-composer-input {
|
|
1985
|
+
background: #f7f7f8;
|
|
1986
|
+
border: 1px solid #e4e4e7;
|
|
1987
|
+
box-shadow: none;
|
|
1988
|
+
}
|
|
1989
|
+
|
|
1990
|
+
.sa-fp-main .sa-composer-input:focus {
|
|
1991
|
+
background: #fff;
|
|
1992
|
+
border-color: #d4d4d8;
|
|
1993
|
+
box-shadow: 0 0 0 3px rgba(99,102,241,0.08);
|
|
1994
|
+
}
|
|
1995
|
+
`, Te = {
|
|
1996
|
+
primaryColor: "#6366f1",
|
|
1997
|
+
backgroundColor: "#ffffff",
|
|
1998
|
+
fontFamily: "system-ui, -apple-system, sans-serif",
|
|
1999
|
+
borderRadius: 16,
|
|
2000
|
+
panelWidth: 380,
|
|
2001
|
+
panelHeight: 520,
|
|
2002
|
+
zIndex: 9999
|
|
2003
|
+
};
|
|
2004
|
+
function Se(t) {
|
|
2005
|
+
const a = { ...Te, ...t };
|
|
2006
|
+
return [
|
|
2007
|
+
`--sa-primary: ${a.primaryColor}`,
|
|
2008
|
+
`--sa-bg: ${a.backgroundColor}`,
|
|
2009
|
+
`--sa-font: ${a.fontFamily}`,
|
|
2010
|
+
`--sa-radius: ${a.borderRadius}px`,
|
|
2011
|
+
`--sa-panel-width: ${a.panelWidth}px`,
|
|
2012
|
+
`--sa-panel-height: ${a.panelHeight}px`,
|
|
2013
|
+
`--sa-z-index: ${a.zIndex}`
|
|
2014
|
+
].join("; ");
|
|
2015
|
+
}
|
|
2016
|
+
function Le(t, a) {
|
|
2017
|
+
const l = typeof t == "string" ? document.querySelector(t) : t;
|
|
2018
|
+
if (!l)
|
|
2019
|
+
throw new Error(`Target element not found: ${t}`);
|
|
2020
|
+
const s = document.createElement("div");
|
|
2021
|
+
s.setAttribute("data-super-agent-widget", "");
|
|
2022
|
+
const r = Se(a.theme ?? {});
|
|
2023
|
+
if (s.setAttribute("style", r), l.appendChild(s), !document.getElementById("sa-widget-styles")) {
|
|
2024
|
+
const o = document.createElement("style");
|
|
2025
|
+
o.id = "sa-widget-styles", o.textContent = Ie, document.head.appendChild(o);
|
|
2026
|
+
}
|
|
2027
|
+
let i = F(s), c = !1;
|
|
2028
|
+
const n = (o) => {
|
|
2029
|
+
i && i.render(
|
|
2030
|
+
X.createElement(ze, {
|
|
2031
|
+
...a,
|
|
2032
|
+
initialOpen: o ?? c,
|
|
2033
|
+
onOpenChange: (u) => {
|
|
2034
|
+
c = u;
|
|
2035
|
+
}
|
|
2036
|
+
})
|
|
2037
|
+
);
|
|
2038
|
+
};
|
|
2039
|
+
return n(!1), {
|
|
2040
|
+
open() {
|
|
2041
|
+
c = !0, n(!0);
|
|
2042
|
+
},
|
|
2043
|
+
close() {
|
|
2044
|
+
c = !1, n(!1);
|
|
2045
|
+
},
|
|
2046
|
+
destroy() {
|
|
2047
|
+
i && (i.unmount(), i = null), s.remove();
|
|
2048
|
+
}
|
|
2049
|
+
};
|
|
2050
|
+
}
|
|
2051
|
+
export {
|
|
2052
|
+
ve as ActionBar,
|
|
2053
|
+
Y as ChatProvider,
|
|
2054
|
+
ze as ChatWidget,
|
|
2055
|
+
Q as Composer,
|
|
2056
|
+
be as ErrorPart,
|
|
2057
|
+
Ne as FullpageLayout,
|
|
2058
|
+
ce as Header,
|
|
2059
|
+
C as Icon,
|
|
2060
|
+
ye as Message,
|
|
2061
|
+
he as TextPart,
|
|
2062
|
+
me as ThinkingPart,
|
|
2063
|
+
Z as Thread,
|
|
2064
|
+
de as ThreadList,
|
|
2065
|
+
ge as ToolCallPart,
|
|
2066
|
+
xe as ToolResultPart,
|
|
2067
|
+
le as Trigger,
|
|
2068
|
+
we as WelcomeScreen,
|
|
2069
|
+
Te as defaultTheme,
|
|
2070
|
+
Le as mount,
|
|
2071
|
+
Se as themeToCSSVars,
|
|
2072
|
+
pe as useAutoScroll,
|
|
2073
|
+
ne as useChat,
|
|
2074
|
+
A as useChatContext,
|
|
2075
|
+
oe as useConversations,
|
|
2076
|
+
Ie as widgetStyles
|
|
2077
|
+
};
|