super-agent-sdk 1.0.1 → 1.0.3
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.cjs +43 -29
- package/dist/widget.d.ts +1 -1
- package/dist/widget.mjs +556 -544
- package/package.json +1 -1
package/dist/widget.mjs
CHANGED
|
@@ -1,68 +1,54 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import { jsx as
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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 = {
|
|
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) => {
|
|
8
|
+
if (g.current) return;
|
|
9
|
+
g.current = !0, n == null || n(z);
|
|
10
|
+
const O = {
|
|
25
11
|
id: `user_${Date.now()}`,
|
|
26
12
|
role: "user",
|
|
27
13
|
parts: [{ type: "text", content: z }],
|
|
28
14
|
timestamp: Date.now()
|
|
29
|
-
}, S = `assistant_${Date.now()}`,
|
|
15
|
+
}, S = `assistant_${Date.now()}`, G = {
|
|
30
16
|
id: S,
|
|
31
17
|
role: "assistant",
|
|
32
18
|
parts: [],
|
|
33
19
|
timestamp: Date.now()
|
|
34
20
|
};
|
|
35
|
-
|
|
36
|
-
const
|
|
37
|
-
let
|
|
21
|
+
f((T) => [...T, O, G]), m("submitted"), b(null);
|
|
22
|
+
const F = (T) => {
|
|
23
|
+
let H = "", E = "", D = [], W = !1;
|
|
38
24
|
const B = () => {
|
|
39
|
-
const k = [...
|
|
40
|
-
if (
|
|
41
|
-
const
|
|
42
|
-
|
|
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 });
|
|
43
29
|
}
|
|
44
|
-
if (
|
|
45
|
-
const
|
|
46
|
-
|
|
30
|
+
if (E) {
|
|
31
|
+
const $ = k.findLastIndex((L) => L.type === "text");
|
|
32
|
+
$ >= 0 ? k[$] = { type: "text", content: E } : k.push({ type: "text", content: E });
|
|
47
33
|
}
|
|
48
|
-
|
|
49
|
-
(
|
|
34
|
+
f(
|
|
35
|
+
($) => $.map((L) => L.id === S ? { ...L, parts: k } : L)
|
|
50
36
|
);
|
|
51
37
|
};
|
|
52
|
-
|
|
38
|
+
h.current = e.chat({
|
|
53
39
|
sessionId: T,
|
|
54
40
|
message: z,
|
|
55
41
|
stream: !0,
|
|
56
42
|
onMessage: (k) => {
|
|
57
|
-
switch (
|
|
43
|
+
switch (W || (W = !0, m("streaming")), k.type) {
|
|
58
44
|
case "thinking":
|
|
59
|
-
|
|
45
|
+
H += k.content;
|
|
60
46
|
break;
|
|
61
47
|
case "ai":
|
|
62
|
-
|
|
48
|
+
E += k.content;
|
|
63
49
|
break;
|
|
64
50
|
case "tool_call":
|
|
65
|
-
|
|
51
|
+
D.push({
|
|
66
52
|
type: "tool_call",
|
|
67
53
|
toolName: k.toolName,
|
|
68
54
|
toolCallId: k.toolCallId,
|
|
@@ -70,303 +56,315 @@ function ne(t) {
|
|
|
70
56
|
});
|
|
71
57
|
break;
|
|
72
58
|
case "tool_result":
|
|
73
|
-
|
|
59
|
+
D.push({
|
|
74
60
|
type: "tool_result",
|
|
75
61
|
toolName: k.toolName ?? "",
|
|
76
62
|
toolCallId: k.toolCallId,
|
|
77
63
|
content: k.content
|
|
78
|
-
}),
|
|
64
|
+
}), E && (D.push({ type: "text", content: E }), E = "");
|
|
79
65
|
break;
|
|
80
66
|
}
|
|
81
67
|
B();
|
|
82
68
|
},
|
|
83
69
|
onDone: (k) => {
|
|
84
|
-
(
|
|
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;
|
|
85
71
|
},
|
|
86
72
|
onError: (k) => {
|
|
87
|
-
|
|
73
|
+
D.push({ type: "error", content: k.message }), B(), b(k), m("error"), c == null || c(k), g.current = !1, h.current = null;
|
|
88
74
|
}
|
|
89
|
-
}),
|
|
75
|
+
}), s == null || s(T);
|
|
90
76
|
};
|
|
91
|
-
|
|
92
|
-
|
|
77
|
+
u.current ? F(u.current) : e.createSession().then((T) => {
|
|
78
|
+
u.current = T, r == null || r(T), F(T);
|
|
93
79
|
}).catch((T) => {
|
|
94
|
-
|
|
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;
|
|
95
81
|
});
|
|
96
|
-
}, [
|
|
82
|
+
}, [e, r, s, i, c, n]), w = y(() => {
|
|
97
83
|
var z;
|
|
98
|
-
(z =
|
|
99
|
-
}, []), N =
|
|
100
|
-
if (
|
|
84
|
+
(z = h.current) == null || z.abort(), h.current = null, m("ready"), g.current = !1;
|
|
85
|
+
}, []), N = y(() => {
|
|
86
|
+
if (g.current) return;
|
|
101
87
|
const z = o.findLastIndex((S) => S.role === "user");
|
|
102
88
|
if (z < 0) return;
|
|
103
|
-
const
|
|
104
|
-
|
|
105
|
-
}, [o,
|
|
106
|
-
return { messages: o, status: p, error: v, sendMessage:
|
|
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 };
|
|
107
93
|
}
|
|
108
|
-
const
|
|
109
|
-
function
|
|
94
|
+
const _ = "sa_active_conversation";
|
|
95
|
+
function K() {
|
|
110
96
|
try {
|
|
111
|
-
return localStorage.getItem(
|
|
97
|
+
return localStorage.getItem(_);
|
|
112
98
|
} catch {
|
|
113
99
|
return null;
|
|
114
100
|
}
|
|
115
101
|
}
|
|
116
|
-
function
|
|
102
|
+
function re(t) {
|
|
117
103
|
try {
|
|
118
|
-
t ? localStorage.setItem(
|
|
104
|
+
t ? localStorage.setItem(_, t) : localStorage.removeItem(_);
|
|
119
105
|
} catch {
|
|
120
106
|
}
|
|
121
107
|
}
|
|
122
|
-
function
|
|
123
|
-
const { sdk:
|
|
124
|
-
() =>
|
|
125
|
-
), [n, o] = I(!1),
|
|
126
|
-
|
|
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
114
|
}, []);
|
|
129
|
-
const p =
|
|
130
|
-
c(
|
|
131
|
-
}, [l]), m =
|
|
115
|
+
const p = y((d) => {
|
|
116
|
+
c(d), re(d), d && (l == null || l(d));
|
|
117
|
+
}, [l]), m = y(async () => {
|
|
132
118
|
o(!0);
|
|
133
119
|
try {
|
|
134
|
-
const
|
|
135
|
-
if (!
|
|
136
|
-
|
|
137
|
-
const
|
|
138
|
-
|
|
120
|
+
const d = await e.listConversations({ page: 1, size: 100 });
|
|
121
|
+
if (!f.current) return;
|
|
122
|
+
s(d.items);
|
|
123
|
+
const w = K();
|
|
124
|
+
w && !d.items.find((N) => N.sessionId === w) && p(null);
|
|
139
125
|
} catch {
|
|
140
126
|
} finally {
|
|
141
|
-
|
|
127
|
+
f.current && o(!1);
|
|
142
128
|
}
|
|
143
|
-
}, [
|
|
129
|
+
}, [e, p]), v = y(async (d) => (p(d), await e.getMessages(d)), [e, p]), b = y(() => {
|
|
144
130
|
p(null);
|
|
145
|
-
}, [p]),
|
|
146
|
-
await
|
|
147
|
-
}, [
|
|
148
|
-
await
|
|
149
|
-
(N) => N.map((z) => z.sessionId ===
|
|
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)
|
|
150
136
|
);
|
|
151
|
-
}, [
|
|
152
|
-
return
|
|
153
|
-
|
|
154
|
-
}, [
|
|
155
|
-
conversations:
|
|
137
|
+
}, [e]), { enabled: u = !0 } = t;
|
|
138
|
+
return A(() => {
|
|
139
|
+
u && m();
|
|
140
|
+
}, [u, m]), {
|
|
141
|
+
conversations: r,
|
|
156
142
|
activeConversationId: i,
|
|
157
143
|
loading: n,
|
|
158
144
|
loadConversations: m,
|
|
159
145
|
switchConversation: v,
|
|
160
|
-
newConversation:
|
|
161
|
-
deleteConversation:
|
|
162
|
-
renameConversation:
|
|
146
|
+
newConversation: b,
|
|
147
|
+
deleteConversation: h,
|
|
148
|
+
renameConversation: g,
|
|
163
149
|
setActiveConversationId: p
|
|
164
150
|
};
|
|
165
151
|
}
|
|
166
|
-
const
|
|
167
|
-
function
|
|
168
|
-
const t =
|
|
152
|
+
const V = Z(null);
|
|
153
|
+
function P() {
|
|
154
|
+
const t = Q(V);
|
|
169
155
|
if (!t) throw new Error("useChatContext must be used within ChatProvider");
|
|
170
156
|
return t;
|
|
171
157
|
}
|
|
172
|
-
function
|
|
173
|
-
const [
|
|
174
|
-
|
|
158
|
+
function U({ sdk: t, hooks: e, children: l }) {
|
|
159
|
+
const [r, s] = I(!1), [i, c] = I(!1);
|
|
160
|
+
A(() => {
|
|
175
161
|
t.getToken().then(() => {
|
|
176
162
|
c(!0);
|
|
177
163
|
}).catch(() => {
|
|
178
164
|
c(!0);
|
|
179
165
|
});
|
|
180
166
|
}, [t]);
|
|
181
|
-
const n =
|
|
167
|
+
const n = ne({
|
|
182
168
|
sdk: t,
|
|
183
|
-
onConversationChange:
|
|
169
|
+
onConversationChange: e == null ? void 0 : e.onConversationChange,
|
|
184
170
|
enabled: i
|
|
185
|
-
}), o =
|
|
171
|
+
}), o = se({
|
|
186
172
|
sdk: t,
|
|
187
173
|
sessionId: n.activeConversationId,
|
|
188
|
-
onSessionCreated: (
|
|
189
|
-
n.setActiveConversationId(
|
|
174
|
+
onSessionCreated: (h) => {
|
|
175
|
+
n.setActiveConversationId(h), n.loadConversations();
|
|
190
176
|
},
|
|
191
|
-
onStreamStart:
|
|
192
|
-
onStreamEnd: (
|
|
193
|
-
var
|
|
194
|
-
(
|
|
177
|
+
onStreamStart: e == null ? void 0 : e.onStreamStart,
|
|
178
|
+
onStreamEnd: (h) => {
|
|
179
|
+
var g;
|
|
180
|
+
(g = e == null ? void 0 : e.onStreamEnd) == null || g.call(e, h), n.loadConversations();
|
|
195
181
|
},
|
|
196
|
-
onError:
|
|
197
|
-
onMessageSend:
|
|
198
|
-
}),
|
|
199
|
-
const
|
|
200
|
-
o.setMessages(
|
|
201
|
-
}, [n, o]), p =
|
|
202
|
-
n.newConversation(), o.setMessages([]),
|
|
203
|
-
}, [n, o]), m =
|
|
204
|
-
await n.deleteConversation(
|
|
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([]);
|
|
205
191
|
}, [n, o]);
|
|
206
|
-
|
|
207
|
-
n.activeConversationId && o.messages.length === 0 && t.getMessages(n.activeConversationId).then((
|
|
208
|
-
o.setMessages(
|
|
192
|
+
A(() => {
|
|
193
|
+
n.activeConversationId && o.messages.length === 0 && t.getMessages(n.activeConversationId).then((h) => {
|
|
194
|
+
o.setMessages(h);
|
|
209
195
|
}).catch(() => {
|
|
210
196
|
});
|
|
211
197
|
}, []);
|
|
212
|
-
const v =
|
|
213
|
-
|
|
214
|
-
}, []),
|
|
198
|
+
const v = y(() => {
|
|
199
|
+
s((h) => !h);
|
|
200
|
+
}, []), b = {
|
|
215
201
|
status: o.status,
|
|
216
202
|
error: o.error,
|
|
217
203
|
messages: o.messages,
|
|
218
204
|
conversations: n.conversations,
|
|
219
205
|
activeConversationId: n.activeConversationId,
|
|
220
|
-
isThreadListOpen:
|
|
206
|
+
isThreadListOpen: r,
|
|
221
207
|
sendMessage: o.sendMessage,
|
|
222
208
|
stop: o.stop,
|
|
223
209
|
regenerate: o.regenerate,
|
|
224
|
-
switchConversation:
|
|
210
|
+
switchConversation: f,
|
|
225
211
|
newConversation: p,
|
|
226
212
|
deleteConversation: m,
|
|
227
213
|
renameConversation: n.renameConversation,
|
|
228
214
|
toggleThreadList: v,
|
|
229
|
-
feedback: (
|
|
230
|
-
t.feedback(
|
|
215
|
+
feedback: (h, g) => {
|
|
216
|
+
t.feedback(h, g);
|
|
231
217
|
}
|
|
232
218
|
};
|
|
233
|
-
return /* @__PURE__ */
|
|
219
|
+
return /* @__PURE__ */ a(V.Provider, { value: b, children: l });
|
|
234
220
|
}
|
|
235
|
-
function C({ name: t, size:
|
|
236
|
-
return /* @__PURE__ */
|
|
221
|
+
function C({ name: t, size: e = 16, color: l = "currentColor", className: r, style: s }) {
|
|
222
|
+
return /* @__PURE__ */ a(
|
|
237
223
|
"svg",
|
|
238
224
|
{
|
|
239
|
-
className:
|
|
240
|
-
style: { width:
|
|
225
|
+
className: r,
|
|
226
|
+
style: { width: e, height: e, fill: l, verticalAlign: "middle", ...s },
|
|
241
227
|
"aria-hidden": "true",
|
|
242
|
-
children: /* @__PURE__ */
|
|
228
|
+
children: /* @__PURE__ */ a("use", { href: `#icon-${t}` })
|
|
243
229
|
}
|
|
244
230
|
);
|
|
245
231
|
}
|
|
246
|
-
function
|
|
247
|
-
return /* @__PURE__ */
|
|
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" }) });
|
|
248
234
|
}
|
|
249
|
-
function
|
|
250
|
-
return /* @__PURE__ */
|
|
251
|
-
/* @__PURE__ */
|
|
252
|
-
/* @__PURE__ */
|
|
253
|
-
/* @__PURE__ */
|
|
254
|
-
/* @__PURE__ */
|
|
255
|
-
/* @__PURE__ */
|
|
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
242
|
] })
|
|
257
243
|
] }),
|
|
258
|
-
/* @__PURE__ */
|
|
259
|
-
/* @__PURE__ */
|
|
260
|
-
|
|
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 }) })
|
|
261
247
|
] })
|
|
262
248
|
] });
|
|
263
249
|
}
|
|
264
|
-
function
|
|
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;
|
|
258
|
+
}
|
|
259
|
+
function ce() {
|
|
265
260
|
const {
|
|
266
261
|
conversations: t,
|
|
267
|
-
activeConversationId:
|
|
262
|
+
activeConversationId: e,
|
|
268
263
|
switchConversation: l,
|
|
269
|
-
newConversation:
|
|
270
|
-
deleteConversation:
|
|
264
|
+
newConversation: r,
|
|
265
|
+
deleteConversation: s,
|
|
271
266
|
renameConversation: i,
|
|
272
267
|
isThreadListOpen: c,
|
|
273
268
|
toggleThreadList: n
|
|
274
|
-
} =
|
|
275
|
-
|
|
276
|
-
}, []),
|
|
277
|
-
p.trim() && i(
|
|
278
|
-
}, [p, i]);
|
|
279
|
-
return c ? /* @__PURE__ */
|
|
280
|
-
/* @__PURE__ */
|
|
281
|
-
/* @__PURE__ */
|
|
282
|
-
/* @__PURE__ */
|
|
283
|
-
/* @__PURE__ */
|
|
284
|
-
/* @__PURE__ */
|
|
285
|
-
/* @__PURE__ */
|
|
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 }),
|
|
286
281
|
" 新会话"
|
|
287
282
|
] })
|
|
288
283
|
] }),
|
|
289
|
-
/* @__PURE__ */
|
|
290
|
-
t.length === 0 && /* @__PURE__ */
|
|
291
|
-
|
|
292
|
-
"div",
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
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(
|
|
289
|
+
"div",
|
|
290
|
+
{
|
|
291
|
+
className: `sa-thread-item ${u.sessionId === e ? "active" : ""}`,
|
|
292
|
+
onClick: () => l(u.sessionId),
|
|
293
|
+
children: [
|
|
294
|
+
o === u.sessionId ? /* @__PURE__ */ a(
|
|
295
|
+
"input",
|
|
296
|
+
{
|
|
297
|
+
className: "sa-thread-item-edit",
|
|
298
|
+
value: p,
|
|
299
|
+
onChange: (d) => m(d.target.value),
|
|
300
|
+
onBlur: () => b(u.sessionId),
|
|
301
|
+
onKeyDown: (d) => {
|
|
302
|
+
d.key === "Enter" && b(u.sessionId), d.key === "Escape" && f(null);
|
|
303
|
+
},
|
|
304
|
+
onClick: (d) => d.stopPropagation(),
|
|
305
|
+
autoFocus: !0
|
|
306
|
+
}
|
|
307
|
+
) : /* @__PURE__ */ a(
|
|
308
|
+
"span",
|
|
309
|
+
{
|
|
310
|
+
className: "sa-thread-item-title",
|
|
311
|
+
onDoubleClick: (d) => {
|
|
312
|
+
d.stopPropagation(), v(u.sessionId, u.title);
|
|
313
|
+
},
|
|
314
|
+
children: u.title || "新会话"
|
|
315
|
+
}
|
|
316
|
+
),
|
|
317
|
+
/* @__PURE__ */ a(
|
|
318
|
+
"button",
|
|
319
|
+
{
|
|
320
|
+
className: "sa-thread-item-delete",
|
|
321
|
+
onClick: (d) => {
|
|
322
|
+
d.stopPropagation(), s(u.sessionId);
|
|
323
|
+
},
|
|
324
|
+
title: "删除",
|
|
325
|
+
children: /* @__PURE__ */ a(C, { name: "trash2", size: 14 })
|
|
326
|
+
}
|
|
327
|
+
)
|
|
328
|
+
]
|
|
329
|
+
},
|
|
330
|
+
u.sessionId
|
|
331
|
+
))
|
|
332
|
+
] }, g.label))
|
|
335
333
|
] })
|
|
336
334
|
] })
|
|
337
335
|
] }) : null;
|
|
338
336
|
}
|
|
339
|
-
function
|
|
340
|
-
const
|
|
341
|
-
const c =
|
|
337
|
+
function de(t) {
|
|
338
|
+
const e = R(null), l = R(!1), r = R(0), s = y(() => {
|
|
339
|
+
const c = e.current;
|
|
342
340
|
if (!c) return;
|
|
343
|
-
const { scrollTop: n, scrollHeight: o, clientHeight:
|
|
344
|
-
n <
|
|
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;
|
|
345
343
|
}, []);
|
|
346
|
-
|
|
347
|
-
const c =
|
|
344
|
+
A(() => {
|
|
345
|
+
const c = e.current;
|
|
348
346
|
if (c)
|
|
349
|
-
return c.addEventListener("scroll",
|
|
350
|
-
}, [
|
|
347
|
+
return c.addEventListener("scroll", s, { passive: !0 }), () => c.removeEventListener("scroll", s);
|
|
348
|
+
}, [s]), A(() => {
|
|
351
349
|
if (l.current) return;
|
|
352
|
-
const c =
|
|
350
|
+
const c = e.current;
|
|
353
351
|
c && requestAnimationFrame(() => {
|
|
354
352
|
c.scrollTop = c.scrollHeight;
|
|
355
353
|
});
|
|
356
354
|
}, t);
|
|
357
|
-
const i =
|
|
355
|
+
const i = y(() => {
|
|
358
356
|
l.current = !1;
|
|
359
|
-
const c =
|
|
357
|
+
const c = e.current;
|
|
360
358
|
c && (c.scrollTop = c.scrollHeight);
|
|
361
359
|
}, []);
|
|
362
|
-
return { containerRef:
|
|
360
|
+
return { containerRef: e, scrollToBottom: i };
|
|
363
361
|
}
|
|
364
|
-
function
|
|
362
|
+
function M(t) {
|
|
365
363
|
return t.value++;
|
|
366
364
|
}
|
|
367
|
-
function
|
|
368
|
-
const l = [],
|
|
369
|
-
|
|
365
|
+
function j(t, e) {
|
|
366
|
+
const l = [], r = [], s = () => {
|
|
367
|
+
r.length > 0 && (l.push(r.join("")), r.length = 0);
|
|
370
368
|
};
|
|
371
369
|
let i = 0;
|
|
372
370
|
for (; i < t.length; ) {
|
|
@@ -374,24 +372,24 @@ function O(t, a) {
|
|
|
374
372
|
if (c === "`") {
|
|
375
373
|
const n = t.indexOf("`", i + 1);
|
|
376
374
|
if (n !== -1) {
|
|
377
|
-
|
|
378
|
-
/* @__PURE__ */
|
|
375
|
+
s(), l.push(
|
|
376
|
+
/* @__PURE__ */ a("code", { className: "sa-inline-code", children: t.slice(i + 1, n) }, M(e))
|
|
379
377
|
), i = n + 1;
|
|
380
378
|
continue;
|
|
381
379
|
}
|
|
382
380
|
} else if (c === "*" && t[i + 1] === "*") {
|
|
383
381
|
const n = t.indexOf("**", i + 2);
|
|
384
382
|
if (n !== -1) {
|
|
385
|
-
|
|
386
|
-
/* @__PURE__ */
|
|
383
|
+
s(), l.push(
|
|
384
|
+
/* @__PURE__ */ a("strong", { children: j(t.slice(i + 2, n), e) }, M(e))
|
|
387
385
|
), i = n + 2;
|
|
388
386
|
continue;
|
|
389
387
|
}
|
|
390
388
|
} else if (c === "*") {
|
|
391
389
|
const n = t.indexOf("*", i + 1);
|
|
392
390
|
if (n !== -1) {
|
|
393
|
-
|
|
394
|
-
/* @__PURE__ */
|
|
391
|
+
s(), l.push(
|
|
392
|
+
/* @__PURE__ */ a("em", { children: j(t.slice(i + 1, n), e) }, M(e))
|
|
395
393
|
), i = n + 1;
|
|
396
394
|
continue;
|
|
397
395
|
}
|
|
@@ -400,470 +398,470 @@ function O(t, a) {
|
|
|
400
398
|
if (n !== -1 && t[n + 1] === "(") {
|
|
401
399
|
const o = t.indexOf(")", n + 2);
|
|
402
400
|
if (o !== -1) {
|
|
403
|
-
const
|
|
404
|
-
|
|
405
|
-
/* @__PURE__ */
|
|
401
|
+
const f = t.slice(i + 1, n), p = t.slice(n + 2, o);
|
|
402
|
+
s(), l.push(
|
|
403
|
+
/* @__PURE__ */ a(
|
|
406
404
|
"a",
|
|
407
405
|
{
|
|
408
406
|
href: p,
|
|
409
407
|
target: "_blank",
|
|
410
408
|
rel: "noreferrer",
|
|
411
|
-
children:
|
|
409
|
+
children: j(f, e)
|
|
412
410
|
},
|
|
413
|
-
|
|
411
|
+
M(e)
|
|
414
412
|
)
|
|
415
413
|
), i = o + 1;
|
|
416
414
|
continue;
|
|
417
415
|
}
|
|
418
416
|
}
|
|
419
417
|
}
|
|
420
|
-
|
|
418
|
+
r.push(c), i++;
|
|
421
419
|
}
|
|
422
|
-
return
|
|
420
|
+
return s(), l;
|
|
423
421
|
}
|
|
424
|
-
function
|
|
425
|
-
const l = [],
|
|
422
|
+
function pe(t, e) {
|
|
423
|
+
const l = [], r = t.split(`
|
|
426
424
|
`);
|
|
427
|
-
let
|
|
425
|
+
let s = 0;
|
|
428
426
|
const i = (o) => o.trim() === "", c = (o) => /^#{1,6}\s+\S/.test(o.trim()), n = (o) => /^(?:[-*+]|\d+[.)])\s+\S/.test(o.trim());
|
|
429
|
-
for (;
|
|
430
|
-
const o = s
|
|
427
|
+
for (; s < r.length; ) {
|
|
428
|
+
const o = r[s], f = o.trim();
|
|
431
429
|
if (i(o)) {
|
|
432
|
-
|
|
430
|
+
s++;
|
|
433
431
|
continue;
|
|
434
432
|
}
|
|
435
433
|
if (c(o)) {
|
|
436
|
-
const m =
|
|
434
|
+
const m = f.match(/^(#{1,6})\s+(.*)$/);
|
|
437
435
|
if (m) {
|
|
438
|
-
const
|
|
436
|
+
const b = `h${Math.min(m[1].length, 6)}`;
|
|
439
437
|
l.push(
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
{ key:
|
|
443
|
-
|
|
438
|
+
q.createElement(
|
|
439
|
+
b,
|
|
440
|
+
{ key: M(e) },
|
|
441
|
+
j(m[2], e)
|
|
444
442
|
)
|
|
445
443
|
);
|
|
446
444
|
}
|
|
447
|
-
|
|
445
|
+
s++;
|
|
448
446
|
continue;
|
|
449
447
|
}
|
|
450
448
|
if (n(o)) {
|
|
451
|
-
const m = /^\d+[.)]/.test(
|
|
452
|
-
for (;
|
|
453
|
-
const
|
|
454
|
-
|
|
455
|
-
/* @__PURE__ */
|
|
456
|
-
),
|
|
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))
|
|
454
|
+
), s++;
|
|
457
455
|
}
|
|
458
456
|
l.push(
|
|
459
|
-
m ? /* @__PURE__ */
|
|
457
|
+
m ? /* @__PURE__ */ a("ol", { className: "sa-list", children: v }, M(e)) : /* @__PURE__ */ a("ul", { className: "sa-list", children: v }, M(e))
|
|
460
458
|
);
|
|
461
459
|
continue;
|
|
462
460
|
}
|
|
463
461
|
const p = [];
|
|
464
|
-
for (;
|
|
465
|
-
p.push(s
|
|
462
|
+
for (; s < r.length && !i(r[s]) && !c(r[s]) && !n(r[s]); )
|
|
463
|
+
p.push(r[s]), s++;
|
|
466
464
|
l.push(
|
|
467
|
-
/* @__PURE__ */
|
|
465
|
+
/* @__PURE__ */ a("p", { className: "sa-text-paragraph", children: j(p.join(" "), e) }, M(e))
|
|
468
466
|
);
|
|
469
467
|
}
|
|
470
468
|
return l;
|
|
471
469
|
}
|
|
472
|
-
function
|
|
473
|
-
const
|
|
474
|
-
for (let
|
|
475
|
-
if (
|
|
476
|
-
l.push(...
|
|
477
|
-
else if (s
|
|
478
|
-
let i = s
|
|
470
|
+
function fe(t) {
|
|
471
|
+
const e = { value: 0 }, l = [], r = t.split("```");
|
|
472
|
+
for (let s = 0; s < r.length; s++)
|
|
473
|
+
if (s % 2 === 0)
|
|
474
|
+
l.push(...pe(r[s], e));
|
|
475
|
+
else if (r[s].trim() !== "") {
|
|
476
|
+
let i = r[s].replace(/^\r?\n/, "");
|
|
479
477
|
i = i.replace(/^[a-zA-Z0-9_+#.-]+\r?\n/, ""), i = i.replace(/\r?\n$/, ""), l.push(
|
|
480
|
-
/* @__PURE__ */
|
|
478
|
+
/* @__PURE__ */ a("pre", { className: "sa-code-block", children: /* @__PURE__ */ a("code", { children: i }) }, M(e))
|
|
481
479
|
);
|
|
482
480
|
}
|
|
483
481
|
return l;
|
|
484
482
|
}
|
|
485
483
|
function he({ content: t }) {
|
|
486
|
-
return /* @__PURE__ */
|
|
484
|
+
return /* @__PURE__ */ a("div", { className: "sa-text-part", children: fe(t) });
|
|
487
485
|
}
|
|
488
|
-
function
|
|
489
|
-
const [
|
|
490
|
-
return /* @__PURE__ */
|
|
491
|
-
/* @__PURE__ */
|
|
492
|
-
/* @__PURE__ */
|
|
493
|
-
/* @__PURE__ */
|
|
494
|
-
/* @__PURE__ */
|
|
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 }) })
|
|
495
493
|
] }),
|
|
496
|
-
|
|
494
|
+
e && /* @__PURE__ */ a("div", { className: "sa-thinking-content", children: t })
|
|
497
495
|
] });
|
|
498
496
|
}
|
|
499
|
-
function
|
|
500
|
-
const [
|
|
497
|
+
function me({ toolName: t, toolCallId: e, args: l }) {
|
|
498
|
+
const [r, s] = I(!1);
|
|
501
499
|
let i = l;
|
|
502
500
|
try {
|
|
503
501
|
i = JSON.stringify(JSON.parse(l), null, 2);
|
|
504
502
|
} catch {
|
|
505
503
|
}
|
|
506
|
-
return /* @__PURE__ */
|
|
507
|
-
/* @__PURE__ */
|
|
508
|
-
/* @__PURE__ */
|
|
509
|
-
/* @__PURE__ */
|
|
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: [
|
|
510
508
|
"调用工具: ",
|
|
511
509
|
t
|
|
512
510
|
] }),
|
|
513
|
-
/* @__PURE__ */
|
|
511
|
+
/* @__PURE__ */ a("span", { className: `sa-thinking-arrow ${r ? "expanded" : ""}`, children: /* @__PURE__ */ a(C, { name: "chevron-right", size: 12 }) })
|
|
514
512
|
] }),
|
|
515
|
-
|
|
513
|
+
r && /* @__PURE__ */ a("pre", { className: "sa-tool-args", children: i })
|
|
516
514
|
] });
|
|
517
515
|
}
|
|
518
|
-
function
|
|
519
|
-
return /* @__PURE__ */
|
|
520
|
-
/* @__PURE__ */
|
|
521
|
-
/* @__PURE__ */
|
|
522
|
-
/* @__PURE__ */
|
|
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 || "工具返回" })
|
|
523
521
|
] }),
|
|
524
|
-
/* @__PURE__ */
|
|
522
|
+
/* @__PURE__ */ a("div", { className: "sa-tool-result-content", children: l })
|
|
525
523
|
] });
|
|
526
524
|
}
|
|
527
|
-
function
|
|
528
|
-
return /* @__PURE__ */
|
|
529
|
-
/* @__PURE__ */
|
|
530
|
-
/* @__PURE__ */
|
|
531
|
-
/* @__PURE__ */
|
|
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 })
|
|
532
530
|
] }),
|
|
533
|
-
|
|
531
|
+
e && /* @__PURE__ */ a("button", { className: "sa-error-retry", onClick: e, children: "重试" })
|
|
534
532
|
] });
|
|
535
533
|
}
|
|
536
|
-
function
|
|
537
|
-
const { status:
|
|
538
|
-
if (
|
|
539
|
-
const
|
|
540
|
-
|
|
541
|
-
}, [
|
|
534
|
+
function be({ message: t, onCopy: e, onRegenerate: l, onFeedback: r }) {
|
|
535
|
+
const { status: s } = P(), [i, c] = I(null), [n, o] = I(!1);
|
|
536
|
+
if (s !== "ready" && s !== "error") return null;
|
|
537
|
+
const f = y(() => {
|
|
538
|
+
e(), o(!0), setTimeout(() => o(!1), 2e3);
|
|
539
|
+
}, [e]), p = y((m) => {
|
|
542
540
|
const v = i === m ? null : m;
|
|
543
|
-
c(v), v && (
|
|
544
|
-
}, [i, t.id,
|
|
545
|
-
return /* @__PURE__ */
|
|
546
|
-
/* @__PURE__ */
|
|
547
|
-
/* @__PURE__ */
|
|
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 }),
|
|
548
546
|
" ",
|
|
549
547
|
n ? "已复制" : "复制"
|
|
550
548
|
] }),
|
|
551
|
-
/* @__PURE__ */
|
|
552
|
-
/* @__PURE__ */
|
|
549
|
+
/* @__PURE__ */ x("button", { className: "sa-action-btn", onClick: l, title: "重新生成", children: [
|
|
550
|
+
/* @__PURE__ */ a(C, { name: "refresh-cw", size: 14 }),
|
|
553
551
|
" 重新生成"
|
|
554
552
|
] }),
|
|
555
|
-
/* @__PURE__ */
|
|
556
|
-
/* @__PURE__ */
|
|
553
|
+
/* @__PURE__ */ a("span", { className: "sa-action-divider" }),
|
|
554
|
+
/* @__PURE__ */ a(
|
|
557
555
|
"button",
|
|
558
556
|
{
|
|
559
557
|
className: `sa-action-btn ${i === "like" ? "sa-action-btn-active" : ""}`,
|
|
560
558
|
onClick: () => p("like"),
|
|
561
559
|
title: "有用",
|
|
562
|
-
children: /* @__PURE__ */
|
|
560
|
+
children: /* @__PURE__ */ a(C, { name: "thumbs-up", size: 14 })
|
|
563
561
|
}
|
|
564
562
|
),
|
|
565
|
-
/* @__PURE__ */
|
|
563
|
+
/* @__PURE__ */ a(
|
|
566
564
|
"button",
|
|
567
565
|
{
|
|
568
566
|
className: `sa-action-btn ${i === "dislike" ? "sa-action-btn-active" : ""}`,
|
|
569
567
|
onClick: () => p("dislike"),
|
|
570
568
|
title: "无用",
|
|
571
|
-
children: /* @__PURE__ */
|
|
569
|
+
children: /* @__PURE__ */ a(C, { name: "thumbs-down", size: 14 })
|
|
572
570
|
}
|
|
573
571
|
)
|
|
574
572
|
] });
|
|
575
573
|
}
|
|
576
|
-
function
|
|
577
|
-
const l =
|
|
578
|
-
return t ? t.startsWith("http") || t.startsWith("/") || t.startsWith("data:") ? /* @__PURE__ */
|
|
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 });
|
|
579
577
|
}
|
|
580
|
-
function
|
|
581
|
-
const { regenerate: i, feedback: c } =
|
|
582
|
-
var
|
|
583
|
-
const
|
|
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(`
|
|
584
582
|
`);
|
|
585
|
-
(
|
|
583
|
+
(d = navigator.clipboard) == null || d.writeText(u).catch(() => {
|
|
586
584
|
});
|
|
587
|
-
}, [t]), o = t.role === "user",
|
|
588
|
-
if (
|
|
589
|
-
return /* @__PURE__ */
|
|
590
|
-
|
|
585
|
+
}, [t]), o = t.role === "user", f = r.Message;
|
|
586
|
+
if (f)
|
|
587
|
+
return /* @__PURE__ */ a(
|
|
588
|
+
f,
|
|
591
589
|
{
|
|
592
590
|
message: t,
|
|
593
|
-
isStreaming:
|
|
591
|
+
isStreaming: e,
|
|
594
592
|
isLast: l,
|
|
595
|
-
avatar:
|
|
596
|
-
slots:
|
|
593
|
+
avatar: s,
|
|
594
|
+
slots: r,
|
|
597
595
|
onCopy: n,
|
|
598
596
|
onRegenerate: i,
|
|
599
597
|
onFeedback: c
|
|
600
598
|
}
|
|
601
599
|
);
|
|
602
|
-
const p =
|
|
603
|
-
return /* @__PURE__ */
|
|
604
|
-
!o && /* @__PURE__ */
|
|
605
|
-
/* @__PURE__ */
|
|
606
|
-
t.parts.map((
|
|
607
|
-
switch (
|
|
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) {
|
|
608
606
|
case "text":
|
|
609
|
-
return /* @__PURE__ */
|
|
607
|
+
return /* @__PURE__ */ a(p, { content: u.content }, d);
|
|
610
608
|
case "thinking":
|
|
611
|
-
return /* @__PURE__ */
|
|
609
|
+
return /* @__PURE__ */ a(m, { content: u.content }, d);
|
|
612
610
|
case "tool_call":
|
|
613
|
-
return /* @__PURE__ */
|
|
611
|
+
return /* @__PURE__ */ a(v, { toolName: u.toolName, toolCallId: u.toolCallId, args: u.args }, d);
|
|
614
612
|
case "tool_result":
|
|
615
|
-
return /* @__PURE__ */
|
|
613
|
+
return /* @__PURE__ */ a(b, { toolName: u.toolName, toolCallId: u.toolCallId, content: u.content }, d);
|
|
616
614
|
case "error":
|
|
617
|
-
return /* @__PURE__ */
|
|
615
|
+
return /* @__PURE__ */ a(h, { content: u.content, onRetry: i }, d);
|
|
618
616
|
default:
|
|
619
617
|
return null;
|
|
620
618
|
}
|
|
621
619
|
}),
|
|
622
|
-
|
|
623
|
-
!o && !
|
|
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 })
|
|
624
622
|
] }),
|
|
625
|
-
o && /* @__PURE__ */
|
|
623
|
+
o && /* @__PURE__ */ a(Y, { src: s == null ? void 0 : s.user, role: "user" })
|
|
626
624
|
] });
|
|
627
625
|
}
|
|
628
|
-
function we({ message: t, suggestedPrompts:
|
|
629
|
-
return /* @__PURE__ */
|
|
630
|
-
/* @__PURE__ */
|
|
631
|
-
/* @__PURE__ */
|
|
632
|
-
|
|
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(
|
|
633
631
|
"button",
|
|
634
632
|
{
|
|
635
633
|
className: "sa-welcome-prompt",
|
|
636
|
-
onClick: () => l(
|
|
637
|
-
children:
|
|
634
|
+
onClick: () => l(r),
|
|
635
|
+
children: r
|
|
638
636
|
},
|
|
639
|
-
|
|
637
|
+
s
|
|
640
638
|
)) })
|
|
641
639
|
] });
|
|
642
640
|
}
|
|
643
|
-
function
|
|
644
|
-
const { messages:
|
|
645
|
-
return
|
|
646
|
-
|
|
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,
|
|
647
645
|
{
|
|
648
|
-
message:
|
|
646
|
+
message: e,
|
|
649
647
|
suggestedPrompts: l,
|
|
650
648
|
onPromptClick: c
|
|
651
649
|
}
|
|
652
|
-
) }) : /* @__PURE__ */
|
|
653
|
-
|
|
650
|
+
) }) : /* @__PURE__ */ a("div", { className: "sa-thread", ref: n, children: s.map((p, m) => /* @__PURE__ */ a(
|
|
651
|
+
ve,
|
|
654
652
|
{
|
|
655
653
|
message: p,
|
|
656
654
|
isStreaming: o,
|
|
657
|
-
isLast: m ===
|
|
655
|
+
isLast: m === s.length - 1,
|
|
658
656
|
slots: t,
|
|
659
|
-
avatar:
|
|
657
|
+
avatar: r
|
|
660
658
|
},
|
|
661
659
|
p.id
|
|
662
660
|
)) });
|
|
663
661
|
}
|
|
664
|
-
function
|
|
665
|
-
const { status: t, sendMessage:
|
|
666
|
-
const p =
|
|
667
|
-
!p || c || (
|
|
668
|
-
}, [
|
|
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) => {
|
|
669
667
|
p.key === "Enter" && !p.shiftKey && (p.preventDefault(), n());
|
|
670
|
-
}, [n]),
|
|
671
|
-
|
|
668
|
+
}, [n]), f = y((p) => {
|
|
669
|
+
s(p.target.value);
|
|
672
670
|
const m = p.target;
|
|
673
671
|
m.style.height = "auto", m.style.height = Math.min(m.scrollHeight, 120) + "px";
|
|
674
672
|
}, []);
|
|
675
|
-
return /* @__PURE__ */
|
|
676
|
-
/* @__PURE__ */
|
|
673
|
+
return /* @__PURE__ */ x("div", { className: "sa-composer", children: [
|
|
674
|
+
/* @__PURE__ */ a(
|
|
677
675
|
"textarea",
|
|
678
676
|
{
|
|
679
677
|
ref: i,
|
|
680
678
|
className: "sa-composer-input",
|
|
681
|
-
value:
|
|
682
|
-
onChange:
|
|
679
|
+
value: r,
|
|
680
|
+
onChange: f,
|
|
683
681
|
onKeyDown: o,
|
|
684
682
|
placeholder: "输入消息...",
|
|
685
683
|
rows: 1,
|
|
686
684
|
disabled: t === "submitted"
|
|
687
685
|
}
|
|
688
686
|
),
|
|
689
|
-
c ? /* @__PURE__ */
|
|
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(
|
|
690
688
|
"button",
|
|
691
689
|
{
|
|
692
690
|
className: "sa-composer-send",
|
|
693
691
|
onClick: n,
|
|
694
|
-
disabled: !
|
|
692
|
+
disabled: !r.trim(),
|
|
695
693
|
title: "发送",
|
|
696
|
-
children: /* @__PURE__ */
|
|
694
|
+
children: /* @__PURE__ */ a(C, { name: "arrow-up", size: 16, color: "#fff" })
|
|
697
695
|
}
|
|
698
696
|
)
|
|
699
697
|
] });
|
|
700
698
|
}
|
|
701
|
-
function
|
|
702
|
-
const { status: n, sendMessage: o, stop:
|
|
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();
|
|
703
701
|
if (!t) return null;
|
|
704
|
-
const
|
|
705
|
-
return /* @__PURE__ */
|
|
706
|
-
|
|
707
|
-
z &&
|
|
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(
|
|
708
706
|
z,
|
|
709
707
|
{
|
|
710
708
|
conversations: m,
|
|
711
709
|
activeSessionId: v,
|
|
712
|
-
onSwitch:
|
|
713
|
-
onNew:
|
|
714
|
-
onDelete:
|
|
715
|
-
onRename:
|
|
710
|
+
onSwitch: b,
|
|
711
|
+
onNew: h,
|
|
712
|
+
onDelete: g,
|
|
713
|
+
onRename: u
|
|
716
714
|
}
|
|
717
|
-
) : /* @__PURE__ */
|
|
718
|
-
/* @__PURE__ */
|
|
719
|
-
N ? /* @__PURE__ */
|
|
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, {})
|
|
720
718
|
] });
|
|
721
719
|
}
|
|
722
|
-
function
|
|
720
|
+
function ke({
|
|
723
721
|
conversations: t,
|
|
724
|
-
activeSessionId:
|
|
722
|
+
activeSessionId: e,
|
|
725
723
|
onSwitch: l,
|
|
726
|
-
onNew:
|
|
727
|
-
onDelete:
|
|
724
|
+
onNew: r,
|
|
725
|
+
onDelete: s,
|
|
728
726
|
isCollapsed: i,
|
|
729
727
|
onToggleCollapse: c
|
|
730
728
|
}) {
|
|
731
|
-
const [n, o] = I(null), [
|
|
732
|
-
|
|
733
|
-
}, [
|
|
734
|
-
const
|
|
735
|
-
for (const
|
|
736
|
-
const N =
|
|
737
|
-
N < 864e5 ?
|
|
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);
|
|
738
736
|
}
|
|
739
|
-
const
|
|
740
|
-
return
|
|
737
|
+
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;
|
|
741
739
|
})();
|
|
742
|
-
return i ? /* @__PURE__ */
|
|
743
|
-
/* @__PURE__ */
|
|
744
|
-
/* @__PURE__ */
|
|
745
|
-
] }) : /* @__PURE__ */
|
|
746
|
-
/* @__PURE__ */
|
|
747
|
-
/* @__PURE__ */
|
|
748
|
-
/* @__PURE__ */
|
|
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 }),
|
|
749
747
|
" ",
|
|
750
|
-
/* @__PURE__ */
|
|
748
|
+
/* @__PURE__ */ a("span", { children: "新会话" })
|
|
751
749
|
] }),
|
|
752
|
-
/* @__PURE__ */
|
|
750
|
+
/* @__PURE__ */ a("button", { className: "sa-fp-sidebar-toggle", onClick: c, title: "收起侧边栏", children: /* @__PURE__ */ a(C, { name: "panel-left-close", size: 18 }) })
|
|
753
751
|
] }),
|
|
754
|
-
/* @__PURE__ */
|
|
755
|
-
t.length === 0 && /* @__PURE__ */
|
|
756
|
-
v.map((
|
|
757
|
-
/* @__PURE__ */
|
|
758
|
-
|
|
759
|
-
const
|
|
760
|
-
return /* @__PURE__ */
|
|
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(
|
|
761
759
|
"div",
|
|
762
760
|
{
|
|
763
|
-
className: `sa-fp-sidebar-item ${
|
|
764
|
-
onClick: () => l(
|
|
765
|
-
onMouseEnter: () => o(
|
|
761
|
+
className: `sa-fp-sidebar-item ${g ? "active" : ""}`,
|
|
762
|
+
onClick: () => l(h.sessionId),
|
|
763
|
+
onMouseEnter: () => o(h.sessionId),
|
|
766
764
|
onMouseLeave: () => o(null),
|
|
767
765
|
children: [
|
|
768
|
-
/* @__PURE__ */
|
|
769
|
-
|
|
766
|
+
/* @__PURE__ */ a("span", { className: "sa-fp-sidebar-item-title", children: h.title || "新会话" }),
|
|
767
|
+
u && /* @__PURE__ */ a(
|
|
770
768
|
"button",
|
|
771
769
|
{
|
|
772
|
-
className: `sa-fp-sidebar-item-action ${
|
|
773
|
-
onClick: (
|
|
774
|
-
title:
|
|
775
|
-
children: /* @__PURE__ */
|
|
770
|
+
className: `sa-fp-sidebar-item-action ${d ? "danger" : ""}`,
|
|
771
|
+
onClick: (w) => m(h.sessionId, w),
|
|
772
|
+
title: d ? "确认删除" : "删除",
|
|
773
|
+
children: /* @__PURE__ */ a(C, { name: d ? "x" : "trash2", size: 14 })
|
|
776
774
|
}
|
|
777
775
|
)
|
|
778
776
|
]
|
|
779
777
|
},
|
|
780
|
-
|
|
778
|
+
h.sessionId
|
|
781
779
|
);
|
|
782
780
|
})
|
|
783
|
-
] },
|
|
781
|
+
] }, b.label))
|
|
784
782
|
] })
|
|
785
783
|
] });
|
|
786
784
|
}
|
|
787
|
-
function
|
|
785
|
+
function Ce({ title: t, slots: e, welcomeMessage: l, suggestedPrompts: r, sidebarDefaultOpen: s = !0, onClose: i, avatar: c }) {
|
|
788
786
|
const {
|
|
789
787
|
status: n,
|
|
790
788
|
sendMessage: o,
|
|
791
|
-
stop:
|
|
789
|
+
stop: f,
|
|
792
790
|
conversations: p,
|
|
793
791
|
activeConversationId: m,
|
|
794
792
|
switchConversation: v,
|
|
795
|
-
newConversation:
|
|
796
|
-
deleteConversation:
|
|
797
|
-
renameConversation:
|
|
798
|
-
} =
|
|
799
|
-
return /* @__PURE__ */
|
|
800
|
-
N ? /* @__PURE__ */
|
|
793
|
+
newConversation: b,
|
|
794
|
+
deleteConversation: h,
|
|
795
|
+
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(
|
|
801
799
|
N,
|
|
802
800
|
{
|
|
803
801
|
conversations: p,
|
|
804
802
|
activeSessionId: m,
|
|
805
803
|
onSwitch: v,
|
|
806
|
-
onNew:
|
|
807
|
-
onDelete:
|
|
808
|
-
onRename:
|
|
804
|
+
onNew: b,
|
|
805
|
+
onDelete: h,
|
|
806
|
+
onRename: g
|
|
809
807
|
}
|
|
810
|
-
) }) : /* @__PURE__ */
|
|
811
|
-
|
|
808
|
+
) }) : /* @__PURE__ */ a(
|
|
809
|
+
ke,
|
|
812
810
|
{
|
|
813
811
|
conversations: p,
|
|
814
812
|
activeSessionId: m,
|
|
815
813
|
onSwitch: v,
|
|
816
|
-
onNew:
|
|
817
|
-
onDelete:
|
|
818
|
-
onRename:
|
|
819
|
-
isCollapsed: !
|
|
820
|
-
onToggleCollapse:
|
|
814
|
+
onNew: b,
|
|
815
|
+
onDelete: h,
|
|
816
|
+
onRename: g,
|
|
817
|
+
isCollapsed: !u,
|
|
818
|
+
onToggleCollapse: w
|
|
821
819
|
}
|
|
822
820
|
),
|
|
823
|
-
/* @__PURE__ */
|
|
824
|
-
/* @__PURE__ */
|
|
825
|
-
!
|
|
826
|
-
/* @__PURE__ */
|
|
827
|
-
/* @__PURE__ */
|
|
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 }) }) })
|
|
828
826
|
] }),
|
|
829
|
-
/* @__PURE__ */
|
|
830
|
-
z ? /* @__PURE__ */
|
|
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, {})
|
|
831
829
|
] })
|
|
832
830
|
] });
|
|
833
831
|
}
|
|
834
|
-
function
|
|
835
|
-
const { sdk:
|
|
836
|
-
|
|
837
|
-
|
|
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);
|
|
838
836
|
}, [o]);
|
|
839
|
-
const
|
|
840
|
-
var
|
|
841
|
-
const
|
|
842
|
-
|
|
843
|
-
}, [v,
|
|
844
|
-
var
|
|
845
|
-
|
|
846
|
-
}, [
|
|
847
|
-
return l === "fullpage" ? v ? /* @__PURE__ */
|
|
848
|
-
|
|
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(() => {
|
|
842
|
+
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,
|
|
849
847
|
{
|
|
850
848
|
title: n,
|
|
851
|
-
slots:
|
|
849
|
+
slots: r,
|
|
852
850
|
welcomeMessage: i,
|
|
853
851
|
suggestedPrompts: c,
|
|
854
852
|
sidebarDefaultOpen: p,
|
|
855
|
-
onClose:
|
|
853
|
+
onClose: g,
|
|
856
854
|
avatar: m
|
|
857
855
|
}
|
|
858
|
-
) }) : null : /* @__PURE__ */
|
|
859
|
-
/* @__PURE__ */
|
|
860
|
-
/* @__PURE__ */
|
|
861
|
-
|
|
856
|
+
) }) : null : /* @__PURE__ */ x(U, { sdk: e, hooks: s, children: [
|
|
857
|
+
/* @__PURE__ */ a(u, { isOpen: v, onClick: h }),
|
|
858
|
+
/* @__PURE__ */ a(
|
|
859
|
+
ye,
|
|
862
860
|
{
|
|
863
861
|
isOpen: v,
|
|
864
|
-
onClose:
|
|
862
|
+
onClose: g,
|
|
865
863
|
title: n,
|
|
866
|
-
slots:
|
|
864
|
+
slots: r,
|
|
867
865
|
welcomeMessage: i,
|
|
868
866
|
suggestedPrompts: c,
|
|
869
867
|
avatar: m
|
|
@@ -871,7 +869,7 @@ function ze(t) {
|
|
|
871
869
|
)
|
|
872
870
|
] });
|
|
873
871
|
}
|
|
874
|
-
const
|
|
872
|
+
const ze = `
|
|
875
873
|
[data-super-agent-widget] {
|
|
876
874
|
--sa-primary-dark: color-mix(in srgb, var(--sa-primary) 82%, #000);
|
|
877
875
|
--sa-primary-light: color-mix(in srgb, var(--sa-primary) 10%, #fff);
|
|
@@ -1530,42 +1528,55 @@ const Ie = `
|
|
|
1530
1528
|
.sa-thread-list-header {
|
|
1531
1529
|
display: flex;
|
|
1532
1530
|
align-items: center;
|
|
1533
|
-
|
|
1534
|
-
padding:
|
|
1535
|
-
border-bottom: 1px solid var(--sa-border);
|
|
1531
|
+
justify-content: space-between;
|
|
1532
|
+
padding: 20px 20px 16px;
|
|
1536
1533
|
flex-shrink: 0;
|
|
1537
1534
|
}
|
|
1538
1535
|
|
|
1536
|
+
.sa-thread-list-title {
|
|
1537
|
+
font-size: 17px;
|
|
1538
|
+
font-weight: 700;
|
|
1539
|
+
color: #18181b;
|
|
1540
|
+
letter-spacing: -0.2px;
|
|
1541
|
+
}
|
|
1542
|
+
|
|
1543
|
+
.sa-thread-list-new {
|
|
1544
|
+
display: flex;
|
|
1545
|
+
align-items: center;
|
|
1546
|
+
gap: 6px;
|
|
1547
|
+
padding: 8px 16px;
|
|
1548
|
+
border: none;
|
|
1549
|
+
border-radius: 20px;
|
|
1550
|
+
background: #f4f4f5;
|
|
1551
|
+
color: #3f3f46;
|
|
1552
|
+
font-size: 13px;
|
|
1553
|
+
font-weight: 500;
|
|
1554
|
+
cursor: pointer;
|
|
1555
|
+
transition: background 0.15s;
|
|
1556
|
+
}
|
|
1557
|
+
|
|
1558
|
+
.sa-thread-list-new:hover {
|
|
1559
|
+
background: #e4e4e7;
|
|
1560
|
+
}
|
|
1561
|
+
|
|
1539
1562
|
.sa-thread-list-items {
|
|
1540
1563
|
flex: 1;
|
|
1541
1564
|
overflow-y: auto;
|
|
1565
|
+
padding: 0 12px 12px;
|
|
1542
1566
|
}
|
|
1543
1567
|
|
|
1544
1568
|
.sa-thread-list-empty {
|
|
1545
|
-
padding:
|
|
1569
|
+
padding: 48px 16px;
|
|
1546
1570
|
text-align: center;
|
|
1547
1571
|
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
1572
|
font-size: 14px;
|
|
1561
|
-
cursor: pointer;
|
|
1562
|
-
text-align: center;
|
|
1563
|
-
transition: background 0.15s, border-color 0.15s;
|
|
1564
1573
|
}
|
|
1565
1574
|
|
|
1566
|
-
.sa-thread-
|
|
1567
|
-
|
|
1568
|
-
|
|
1575
|
+
.sa-thread-group-label {
|
|
1576
|
+
padding: 16px 8px 6px;
|
|
1577
|
+
font-size: 12px;
|
|
1578
|
+
font-weight: 500;
|
|
1579
|
+
color: #a1a1aa;
|
|
1569
1580
|
}
|
|
1570
1581
|
|
|
1571
1582
|
.sa-thread-item {
|
|
@@ -1573,8 +1584,9 @@ const Ie = `
|
|
|
1573
1584
|
align-items: center;
|
|
1574
1585
|
justify-content: space-between;
|
|
1575
1586
|
gap: 8px;
|
|
1576
|
-
padding: 12px
|
|
1577
|
-
|
|
1587
|
+
padding: 10px 12px;
|
|
1588
|
+
margin: 2px 0;
|
|
1589
|
+
border-radius: 8px;
|
|
1578
1590
|
color: #374151;
|
|
1579
1591
|
font-size: 14px;
|
|
1580
1592
|
cursor: pointer;
|
|
@@ -1582,7 +1594,7 @@ const Ie = `
|
|
|
1582
1594
|
}
|
|
1583
1595
|
|
|
1584
1596
|
.sa-thread-item:hover {
|
|
1585
|
-
background:
|
|
1597
|
+
background: #f9fafb;
|
|
1586
1598
|
}
|
|
1587
1599
|
|
|
1588
1600
|
.sa-thread-item.active {
|
|
@@ -1992,7 +2004,7 @@ const Ie = `
|
|
|
1992
2004
|
border-color: #d4d4d8;
|
|
1993
2005
|
box-shadow: 0 0 0 3px rgba(99,102,241,0.08);
|
|
1994
2006
|
}
|
|
1995
|
-
`,
|
|
2007
|
+
`, Ie = {
|
|
1996
2008
|
primaryColor: "#6366f1",
|
|
1997
2009
|
backgroundColor: "#ffffff",
|
|
1998
2010
|
fontFamily: "system-ui, -apple-system, sans-serif",
|
|
@@ -2001,37 +2013,37 @@ const Ie = `
|
|
|
2001
2013
|
panelHeight: 520,
|
|
2002
2014
|
zIndex: 9999
|
|
2003
2015
|
};
|
|
2004
|
-
function
|
|
2005
|
-
const
|
|
2016
|
+
function Te(t) {
|
|
2017
|
+
const e = { ...Ie, ...t };
|
|
2006
2018
|
return [
|
|
2007
|
-
`--sa-primary: ${
|
|
2008
|
-
`--sa-bg: ${
|
|
2009
|
-
`--sa-font: ${
|
|
2010
|
-
`--sa-radius: ${
|
|
2011
|
-
`--sa-panel-width: ${
|
|
2012
|
-
`--sa-panel-height: ${
|
|
2013
|
-
`--sa-z-index: ${
|
|
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}`
|
|
2014
2026
|
].join("; ");
|
|
2015
2027
|
}
|
|
2016
|
-
function
|
|
2028
|
+
function Re(t, e) {
|
|
2017
2029
|
const l = typeof t == "string" ? document.querySelector(t) : t;
|
|
2018
2030
|
if (!l)
|
|
2019
2031
|
throw new Error(`Target element not found: ${t}`);
|
|
2020
|
-
const
|
|
2021
|
-
|
|
2022
|
-
const
|
|
2023
|
-
if (
|
|
2032
|
+
const r = document.createElement("div");
|
|
2033
|
+
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")) {
|
|
2024
2036
|
const o = document.createElement("style");
|
|
2025
|
-
o.id = "sa-widget-styles", o.textContent =
|
|
2037
|
+
o.id = "sa-widget-styles", o.textContent = ze, document.head.appendChild(o);
|
|
2026
2038
|
}
|
|
2027
|
-
let i =
|
|
2039
|
+
let i = ae(r), c = !1;
|
|
2028
2040
|
const n = (o) => {
|
|
2029
2041
|
i && i.render(
|
|
2030
|
-
|
|
2031
|
-
...
|
|
2042
|
+
q.createElement(Ne, {
|
|
2043
|
+
...e,
|
|
2032
2044
|
initialOpen: o ?? c,
|
|
2033
|
-
onOpenChange: (
|
|
2034
|
-
c =
|
|
2045
|
+
onOpenChange: (f) => {
|
|
2046
|
+
c = f;
|
|
2035
2047
|
}
|
|
2036
2048
|
})
|
|
2037
2049
|
);
|
|
@@ -2044,34 +2056,34 @@ function Le(t, a) {
|
|
|
2044
2056
|
c = !1, n(!1);
|
|
2045
2057
|
},
|
|
2046
2058
|
destroy() {
|
|
2047
|
-
i && (i.unmount(), i = null),
|
|
2059
|
+
i && (i.unmount(), i = null), r.remove();
|
|
2048
2060
|
}
|
|
2049
2061
|
};
|
|
2050
2062
|
}
|
|
2051
2063
|
export {
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2064
|
+
be as ActionBar,
|
|
2065
|
+
U as ChatProvider,
|
|
2066
|
+
Ne as ChatWidget,
|
|
2067
|
+
X as Composer,
|
|
2068
|
+
xe as ErrorPart,
|
|
2069
|
+
Ce as FullpageLayout,
|
|
2070
|
+
oe as Header,
|
|
2059
2071
|
C as Icon,
|
|
2060
|
-
|
|
2072
|
+
ve as Message,
|
|
2061
2073
|
he as TextPart,
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2074
|
+
ue as ThinkingPart,
|
|
2075
|
+
J as Thread,
|
|
2076
|
+
ce as ThreadList,
|
|
2077
|
+
me as ToolCallPart,
|
|
2078
|
+
ge as ToolResultPart,
|
|
2079
|
+
ie as Trigger,
|
|
2068
2080
|
we as WelcomeScreen,
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2081
|
+
Ie as defaultTheme,
|
|
2082
|
+
Re as mount,
|
|
2083
|
+
Te as themeToCSSVars,
|
|
2084
|
+
de as useAutoScroll,
|
|
2085
|
+
se as useChat,
|
|
2086
|
+
P as useChatContext,
|
|
2087
|
+
ne as useConversations,
|
|
2088
|
+
ze as widgetStyles
|
|
2077
2089
|
};
|