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