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