@burdenoff/fe-libs 2026.1029.1 → 2026.1029.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/shared/assistant/turnTimeline.js +1 -1
- package/dist/shared/assistant/turnTimingReporter.d.ts +11 -0
- package/dist/shared/assistant/turnTimingReporter.js +73 -56
- package/dist/shared/assistant/ui/AssistantChatArea.js +129 -129
- package/dist/shared/assistant/ui/AssistantSpeechProvider.js +134 -129
- package/dist/shared/assistant/ui/useVoiceSession.js +201 -177
- package/dist/shared/assistant/voice/voiceSession.d.ts +7 -0
- package/dist/shared/assistant/voice/voiceSession.js +10 -1
- package/dist/shared/components/assistantWidget/AssistantWidget.js +177 -176
- package/dist/shared/components/assistantWidget/assistantWidgetPosition.d.ts +32 -0
- package/dist/shared/components/assistantWidget/assistantWidgetPosition.js +4 -0
- package/dist/shared-assistant.js +210 -210
- package/package.json +1 -1
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { cn as e } from "../../utils/cn.js";
|
|
2
2
|
import { useVoiceInput as t } from "./useVoiceInput.js";
|
|
3
3
|
import { MessageContent as n } from "./MessageContent.js";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
4
|
+
import { ASSISTANT_WIDGET_LAUNCHER_BOTTOM_CLASS as r, ASSISTANT_WIDGET_WINDOW_BOTTOM_CLASS as i, ASSISTANT_WIDGET_WINDOW_MAX_HEIGHT_CLASS as ee } from "./assistantWidgetPosition.js";
|
|
5
|
+
import { useCallback as a, useEffect as o, useMemo as te, useRef as s, useState as c } from "react";
|
|
6
|
+
import { Download as ne, FileArchive as re, History as ie, Link2 as ae, Loader2 as l, MessageCircle as oe, Mic as se, PanelLeftClose as ce, PanelLeftOpen as le, Paperclip as ue, Plus as de, Send as fe, Sparkles as pe, Trash2 as me, X as u } from "lucide-react";
|
|
7
|
+
import { Fragment as he, jsx as d, jsxs as f } from "react/jsx-runtime";
|
|
7
8
|
//#region src/shared/components/assistantWidget/AssistantWidget.tsx
|
|
8
|
-
var
|
|
9
|
-
function
|
|
9
|
+
var ge = "bf:toggle-assistant-widget", p = "bf:assistant-widget:isOpen", m = "bf:assistant-widget:railOpen";
|
|
10
|
+
function _e() {
|
|
10
11
|
if (typeof window > "u") return !0;
|
|
11
12
|
try {
|
|
12
13
|
return window.sessionStorage.getItem(m) !== "0";
|
|
@@ -14,12 +15,12 @@ function me() {
|
|
|
14
15
|
return !0;
|
|
15
16
|
}
|
|
16
17
|
}
|
|
17
|
-
function
|
|
18
|
+
function ve(e) {
|
|
18
19
|
if (!(typeof window > "u")) try {
|
|
19
20
|
window.sessionStorage.setItem(m, e ? "1" : "0");
|
|
20
21
|
} catch {}
|
|
21
22
|
}
|
|
22
|
-
function
|
|
23
|
+
function ye() {
|
|
23
24
|
if (typeof window > "u") return !1;
|
|
24
25
|
try {
|
|
25
26
|
return window.sessionStorage.getItem(p) === "1";
|
|
@@ -32,10 +33,10 @@ function h(e) {
|
|
|
32
33
|
window.sessionStorage.setItem(p, e ? "1" : "0");
|
|
33
34
|
} catch {}
|
|
34
35
|
}
|
|
35
|
-
function
|
|
36
|
+
function be() {
|
|
36
37
|
return `${Date.now()}-${Math.random().toString(36).slice(2, 9)}`;
|
|
37
38
|
}
|
|
38
|
-
function
|
|
39
|
+
function xe(e) {
|
|
39
40
|
if (!Number.isFinite(e) || e <= 0) return "";
|
|
40
41
|
let t = [
|
|
41
42
|
"B",
|
|
@@ -46,8 +47,8 @@ function ve(e) {
|
|
|
46
47
|
for (; n >= 1024 && r < t.length - 1;) n /= 1024, r += 1;
|
|
47
48
|
return `${n >= 10 || r === 0 ? Math.round(n) : n.toFixed(1)} ${t[r]}`;
|
|
48
49
|
}
|
|
49
|
-
var
|
|
50
|
-
let b =
|
|
50
|
+
var Se = ({ transport: p, modes: m, defaultModeId: Se, title: g = "AI Assistant", subtitle: _ = "Ask me to do things on this screen — I can run them for you.", placeholder: v = "Ask anything, or describe what to create…", launcherClassName: Ce, voiceLang: we = "en-US", layout: Te = "floating", showSessionPanel: Ee = !1, onNavigate: De, topOffsetPx: Oe = 0, enableAttachments: y = !1, attachmentAccept: ke = ".json,.csv,.xlsx,.xls,.pdf,application/json,text/csv,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/pdf", enableConnectSource: Ae = !1, connectSourceHref: je = "/integrations/connections" }) => {
|
|
51
|
+
let b = te(() => m && m.length > 0 ? m : [{
|
|
51
52
|
id: "__default__",
|
|
52
53
|
label: g,
|
|
53
54
|
transport: p,
|
|
@@ -60,52 +61,52 @@ var ye = ({ transport: p, modes: m, defaultModeId: ye, title: g = "AI Assistant"
|
|
|
60
61
|
g,
|
|
61
62
|
_,
|
|
62
63
|
v
|
|
63
|
-
]), [x,
|
|
64
|
-
|
|
65
|
-
b.some((e) => e.id === x) ||
|
|
64
|
+
]), [x, Me] = c(() => Se ?? b[0]?.id ?? "__default__"), S = b.find((e) => e.id === x) ?? b[0], C = S.transport, Ne = S.title ?? g, Pe = S.subtitle ?? _, Fe = S.placeholder ?? v;
|
|
65
|
+
o(() => {
|
|
66
|
+
b.some((e) => e.id === x) || Me(b[0]?.id ?? "__default__");
|
|
66
67
|
}, [b, x]);
|
|
67
68
|
let w = !!C;
|
|
68
|
-
|
|
69
|
+
o(() => {
|
|
69
70
|
w || console.error("[AssistantWidget] No transport available — supply `transport`, or a non-empty `modes` where each entry has a transport.");
|
|
70
71
|
}, [w]);
|
|
71
|
-
let [T, E] =
|
|
72
|
-
|
|
72
|
+
let [T, E] = c(() => ye()), [D, O] = c([]), [k, A] = c(""), [j, M] = c([]), [N, P] = c(!1), [Ie, F] = c(!1), [I, L] = c([]), [R, z] = c(!1), [Le, Re] = c(!1), [ze, Be] = c(() => _e()), [Ve, B] = c([]), [V, He] = c(null), [Ue, H] = c(!1), U = s(null), W = s(null), G = s(null), K = s(!1), We = s(null), q = Te === "sidebar", Ge = Ee && !!C?.newSession, Ke = a(() => {
|
|
73
|
+
Be((e) => {
|
|
73
74
|
let t = !e;
|
|
74
|
-
return
|
|
75
|
+
return ve(t), t;
|
|
75
76
|
});
|
|
76
|
-
}, []), J = t(
|
|
77
|
+
}, []), J = t(we), qe = a(() => {
|
|
77
78
|
h(!0), E(!0), C.prewarm?.("full");
|
|
78
|
-
}, [C]),
|
|
79
|
+
}, [C]), Je = a(() => {
|
|
79
80
|
h(!1), E(!1), C.suspend?.();
|
|
80
|
-
}, [C]),
|
|
81
|
+
}, [C]), Y = a(() => {
|
|
81
82
|
E((e) => {
|
|
82
83
|
let t = !e;
|
|
83
84
|
return h(t), t ? C.prewarm?.("full") : C.suspend?.(), t;
|
|
84
85
|
});
|
|
85
86
|
}, [C]);
|
|
86
|
-
|
|
87
|
+
o(() => {
|
|
87
88
|
let e = (e) => {
|
|
88
89
|
let t = e.detail;
|
|
89
|
-
t?.open === !0 ?
|
|
90
|
+
t?.open === !0 ? qe() : t?.open === !1 ? Je() : Y();
|
|
90
91
|
};
|
|
91
|
-
return window.addEventListener(
|
|
92
|
+
return window.addEventListener(ge, e), () => window.removeEventListener(ge, e);
|
|
92
93
|
}, [
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
]),
|
|
94
|
+
qe,
|
|
95
|
+
Je,
|
|
96
|
+
Y
|
|
97
|
+
]), o(() => {
|
|
97
98
|
J.isListening && J.transcript && A(J.transcript);
|
|
98
99
|
}, [J.transcript, J.isListening]);
|
|
99
|
-
let
|
|
100
|
+
let X = a(async () => {
|
|
100
101
|
if (C.listArtifacts) try {
|
|
101
102
|
B(await C.listArtifacts());
|
|
102
103
|
} catch {
|
|
103
104
|
B([]);
|
|
104
105
|
}
|
|
105
|
-
}, [C]),
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
}, [x]),
|
|
106
|
+
}, [C]), Ye = s(x);
|
|
107
|
+
o(() => {
|
|
108
|
+
Ye.current !== x && (Ye.current = x, G.current?.abort(), G.current = null, P(!1), O([]), A(""), L([]), z(!1), F(!1), B([]), K.current = !1);
|
|
109
|
+
}, [x]), o(() => {
|
|
109
110
|
if (!T || K.current) return;
|
|
110
111
|
let e = C.loadHistory;
|
|
111
112
|
if (!e) {
|
|
@@ -117,7 +118,7 @@ var ye = ({ transport: p, modes: m, defaultModeId: ye, title: g = "AI Assistant"
|
|
|
117
118
|
return F(!0), (async () => {
|
|
118
119
|
try {
|
|
119
120
|
let n = await e();
|
|
120
|
-
!t && n.length > 0 && (O((e) => e.length === 0 ? n : e),
|
|
121
|
+
!t && n.length > 0 && (O((e) => e.length === 0 ? n : e), X());
|
|
121
122
|
} catch {} finally {
|
|
122
123
|
t || F(!1);
|
|
123
124
|
}
|
|
@@ -127,57 +128,57 @@ var ye = ({ transport: p, modes: m, defaultModeId: ye, title: g = "AI Assistant"
|
|
|
127
128
|
}, [
|
|
128
129
|
T,
|
|
129
130
|
C,
|
|
130
|
-
|
|
131
|
-
]),
|
|
131
|
+
X
|
|
132
|
+
]), o(() => {
|
|
132
133
|
T && W.current && (W.current.scrollTop = W.current.scrollHeight);
|
|
133
134
|
}, [D, T]);
|
|
134
|
-
let
|
|
135
|
+
let Z = a((e, t) => {
|
|
135
136
|
O((n) => n.map((n) => n.id === e ? {
|
|
136
137
|
...n,
|
|
137
138
|
...t
|
|
138
139
|
} : n));
|
|
139
|
-
}, []),
|
|
140
|
+
}, []), Q = a(async () => {
|
|
140
141
|
if (C.listSessions) {
|
|
141
|
-
|
|
142
|
+
Re(!0);
|
|
142
143
|
try {
|
|
143
144
|
L(await C.listSessions());
|
|
144
145
|
} catch {
|
|
145
146
|
L([]);
|
|
146
147
|
} finally {
|
|
147
|
-
|
|
148
|
+
Re(!1);
|
|
148
149
|
}
|
|
149
150
|
}
|
|
150
|
-
}, [C]),
|
|
151
|
+
}, [C]), Xe = a(async (e) => {
|
|
151
152
|
if (!(!C.downloadArtifact || V)) {
|
|
152
|
-
|
|
153
|
+
He(e.path);
|
|
153
154
|
try {
|
|
154
155
|
await C.downloadArtifact(e);
|
|
155
156
|
} catch {} finally {
|
|
156
|
-
|
|
157
|
+
He(null);
|
|
157
158
|
}
|
|
158
159
|
}
|
|
159
|
-
}, [C, V]),
|
|
160
|
+
}, [C, V]), Ze = a(async () => {
|
|
160
161
|
!C.newSession || N || (O([]), A(""), z(!1), B([]), await C.newSession());
|
|
161
|
-
}, [C, N]),
|
|
162
|
+
}, [C, N]), Qe = a(async (e, t) => {
|
|
162
163
|
if (!(!C.deleteSession || N)) {
|
|
163
164
|
L((t) => t.filter((t) => t.id !== e)), t && (O([]), A(""));
|
|
164
165
|
try {
|
|
165
166
|
await C.deleteSession(e);
|
|
166
167
|
} finally {
|
|
167
|
-
|
|
168
|
+
Q();
|
|
168
169
|
}
|
|
169
170
|
}
|
|
170
171
|
}, [
|
|
171
172
|
C,
|
|
172
173
|
N,
|
|
173
|
-
|
|
174
|
-
]),
|
|
175
|
-
z((e) => (e ||
|
|
176
|
-
}, [
|
|
174
|
+
Q
|
|
175
|
+
]), $e = a(() => {
|
|
176
|
+
z((e) => (e || Q(), !e));
|
|
177
|
+
}, [Q]), et = a(async (e) => {
|
|
177
178
|
if (!(!C.selectSession || N)) {
|
|
178
179
|
F(!0);
|
|
179
180
|
try {
|
|
180
|
-
O(await C.selectSession(e)), z(!1),
|
|
181
|
+
O(await C.selectSession(e)), z(!1), Q(), X();
|
|
181
182
|
} catch {} finally {
|
|
182
183
|
F(!1);
|
|
183
184
|
}
|
|
@@ -185,17 +186,17 @@ var ye = ({ transport: p, modes: m, defaultModeId: ye, title: g = "AI Assistant"
|
|
|
185
186
|
}, [
|
|
186
187
|
C,
|
|
187
188
|
N,
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
]),
|
|
189
|
+
Q,
|
|
190
|
+
X
|
|
191
|
+
]), $ = a(async () => {
|
|
191
192
|
let e = k.trim(), t = j;
|
|
192
193
|
if (!e && t.length === 0 || N) return;
|
|
193
194
|
J.isListening && J.stop(), J.reset(), A(""), M([]), U.current && (U.current.style.height = "auto");
|
|
194
195
|
let n = t.length > 0 ? `📎 ${t.map((e) => e.name).join(", ")}` : "", r = {
|
|
195
|
-
id:
|
|
196
|
+
id: be(),
|
|
196
197
|
role: "user",
|
|
197
198
|
content: [e, n].filter(Boolean).join("\n")
|
|
198
|
-
}, i =
|
|
199
|
+
}, i = be();
|
|
199
200
|
O((e) => [
|
|
200
201
|
...e,
|
|
201
202
|
r,
|
|
@@ -206,180 +207,180 @@ var ye = ({ transport: p, modes: m, defaultModeId: ye, title: g = "AI Assistant"
|
|
|
206
207
|
pending: !0
|
|
207
208
|
}
|
|
208
209
|
]), P(!0);
|
|
209
|
-
let
|
|
210
|
-
G.current =
|
|
210
|
+
let ee = new AbortController();
|
|
211
|
+
G.current = ee;
|
|
211
212
|
try {
|
|
212
213
|
let { text: n } = await C.sendPrompt({
|
|
213
214
|
prompt: e,
|
|
214
215
|
attachments: t.length > 0 ? t : void 0,
|
|
215
|
-
signal:
|
|
216
|
-
onProgress: (e) =>
|
|
216
|
+
signal: ee.signal,
|
|
217
|
+
onProgress: (e) => Z(i, { content: e })
|
|
217
218
|
});
|
|
218
|
-
|
|
219
|
+
Z(i, {
|
|
219
220
|
content: n,
|
|
220
221
|
pending: !1
|
|
221
|
-
}),
|
|
222
|
+
}), X();
|
|
222
223
|
} catch (e) {
|
|
223
|
-
|
|
224
|
+
Z(i, {
|
|
224
225
|
content: `Sorry, I couldn't complete that: ${e instanceof Error ? e.message : "Something went wrong. Please try again."}`,
|
|
225
226
|
pending: !1,
|
|
226
227
|
error: !0
|
|
227
228
|
});
|
|
228
229
|
} finally {
|
|
229
|
-
P(!1), G.current = null, R &&
|
|
230
|
+
P(!1), G.current = null, R && Q();
|
|
230
231
|
}
|
|
231
232
|
}, [
|
|
232
233
|
k,
|
|
233
234
|
j,
|
|
234
235
|
N,
|
|
235
|
-
|
|
236
|
+
Z,
|
|
236
237
|
C,
|
|
237
238
|
J,
|
|
238
239
|
R,
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
]),
|
|
242
|
-
e.key === "Enter" && !e.shiftKey && (e.preventDefault(),
|
|
243
|
-
}, [
|
|
240
|
+
Q,
|
|
241
|
+
X
|
|
242
|
+
]), tt = a((e) => {
|
|
243
|
+
e.key === "Enter" && !e.shiftKey && (e.preventDefault(), $());
|
|
244
|
+
}, [$]), nt = a(() => {
|
|
244
245
|
let e = U.current;
|
|
245
246
|
e && (e.style.height = "auto", e.style.height = `${Math.min(e.scrollHeight, 120)}px`);
|
|
246
|
-
}, []),
|
|
247
|
+
}, []), rt = a(() => {
|
|
247
248
|
J.isListening ? J.stop() : J.start();
|
|
248
|
-
}, [J]),
|
|
249
|
+
}, [J]), it = te(() => /* @__PURE__ */ d("button", {
|
|
249
250
|
type: "button",
|
|
250
|
-
onClick:
|
|
251
|
+
onClick: Y,
|
|
251
252
|
onMouseEnter: () => !T && C.prewarm?.("probe"),
|
|
252
253
|
onFocus: () => !T && C.prewarm?.("probe"),
|
|
253
254
|
"aria-label": T ? "Close AI assistant" : "Open AI assistant",
|
|
254
255
|
"aria-expanded": T,
|
|
255
256
|
"data-testid": "assistant-widget-launcher",
|
|
256
|
-
className: e("fixed
|
|
257
|
-
children:
|
|
257
|
+
className: e("fixed right-6 z-[100] inline-flex size-14 items-center justify-center rounded-full", r, "bg-action-primary-bg text-action-primary-text shadow-xl transition-transform duration-200", "hover:scale-105 hover:bg-action-primary-bg-hover focus:outline-none focus-visible:ring-2 focus-visible:ring-border-strong cursor-pointer", Ce),
|
|
258
|
+
children: d(T ? u : pe, { className: "size-6" })
|
|
258
259
|
}), [
|
|
259
260
|
T,
|
|
260
|
-
|
|
261
|
-
|
|
261
|
+
Y,
|
|
262
|
+
Ce,
|
|
262
263
|
C
|
|
263
264
|
]);
|
|
264
|
-
return w ? /* @__PURE__ */
|
|
265
|
-
|
|
266
|
-
T ? /* @__PURE__ */
|
|
265
|
+
return w ? /* @__PURE__ */ f(he, { children: [
|
|
266
|
+
it,
|
|
267
|
+
T ? /* @__PURE__ */ f("div", {
|
|
267
268
|
role: "dialog",
|
|
268
|
-
"aria-label":
|
|
269
|
+
"aria-label": Ne,
|
|
269
270
|
"data-testid": "assistant-widget-window",
|
|
270
|
-
"data-layout":
|
|
271
|
+
"data-layout": Te,
|
|
271
272
|
style: q ? {
|
|
272
|
-
top:
|
|
273
|
-
height: `calc(100vh - ${String(
|
|
273
|
+
top: Oe,
|
|
274
|
+
height: `calc(100vh - ${String(Oe)}px)`
|
|
274
275
|
} : void 0,
|
|
275
|
-
className: e("fixed z-[100] flex overflow-hidden border-border-default bg-bg-surface shadow-2xl", q ? "bottom-0 right-0 w-full border-l sm:w-[480px] lg:w-[560px] animate-in slide-in-from-right duration-200" : "flex-col rounded-xl border
|
|
276
|
-
children: [q &&
|
|
276
|
+
className: e("fixed z-[100] flex overflow-hidden border-border-default bg-bg-surface shadow-2xl", q ? "bottom-0 right-0 w-full border-l sm:w-[480px] lg:w-[560px] animate-in slide-in-from-right duration-200" : e("flex-col rounded-xl border right-6 h-[560px] w-[calc(100vw-3rem)] sm:w-[400px] animate-in slide-in-from-bottom-2 fade-in duration-200", i, ee)),
|
|
277
|
+
children: [q && Ge && ze ? /* @__PURE__ */ f("aside", {
|
|
277
278
|
"data-testid": "assistant-session-panel",
|
|
278
279
|
className: "flex w-[168px] shrink-0 flex-col gap-1 border-r border-border-subtle bg-bg-sunken p-2",
|
|
279
280
|
children: [
|
|
280
|
-
/* @__PURE__ */
|
|
281
|
+
/* @__PURE__ */ f("button", {
|
|
281
282
|
type: "button",
|
|
282
|
-
onClick:
|
|
283
|
+
onClick: Ke,
|
|
283
284
|
"aria-label": "Hide chats",
|
|
284
285
|
"aria-expanded": !0,
|
|
285
286
|
title: "Hide chats",
|
|
286
287
|
"data-testid": "assistant-rail-toggle",
|
|
287
288
|
className: "mb-1 flex items-center gap-2 rounded-md px-2 py-2 text-xs font-medium text-text-secondary transition-colors hover:bg-bg-surface hover:text-text-primary focus:outline-none focus-visible:ring-2 focus-visible:ring-border-strong cursor-pointer",
|
|
288
|
-
children: [/* @__PURE__ */
|
|
289
|
+
children: [/* @__PURE__ */ d(ce, { className: "size-4 shrink-0" }), "Hide chats"]
|
|
289
290
|
}),
|
|
290
|
-
/* @__PURE__ */
|
|
291
|
+
/* @__PURE__ */ f("button", {
|
|
291
292
|
type: "button",
|
|
292
|
-
onClick: () => void
|
|
293
|
+
onClick: () => void Ze(),
|
|
293
294
|
disabled: N,
|
|
294
295
|
"data-testid": "assistant-new-chat",
|
|
295
296
|
className: "flex items-center gap-2 rounded-md px-2 py-2 text-xs font-medium text-text-primary transition-colors hover:bg-bg-surface disabled:opacity-50 cursor-pointer",
|
|
296
|
-
children: [/* @__PURE__ */
|
|
297
|
+
children: [/* @__PURE__ */ d(de, { className: "size-4 shrink-0" }), "New chat"]
|
|
297
298
|
}),
|
|
298
|
-
/* @__PURE__ */
|
|
299
|
+
/* @__PURE__ */ f("button", {
|
|
299
300
|
type: "button",
|
|
300
|
-
onClick:
|
|
301
|
+
onClick: $e,
|
|
301
302
|
"aria-expanded": R,
|
|
302
303
|
"data-testid": "assistant-history-toggle",
|
|
303
304
|
className: "flex items-center gap-2 rounded-md px-2 py-2 text-xs font-medium text-text-primary transition-colors hover:bg-bg-surface cursor-pointer",
|
|
304
|
-
children: [/* @__PURE__ */
|
|
305
|
+
children: [/* @__PURE__ */ d(ie, { className: "size-4 shrink-0" }), "History"]
|
|
305
306
|
}),
|
|
306
|
-
R ? /* @__PURE__ */
|
|
307
|
+
R ? /* @__PURE__ */ d("div", {
|
|
307
308
|
"data-testid": "assistant-history-list",
|
|
308
309
|
className: "mt-1 flex-1 space-y-0.5 overflow-y-auto border-t border-border-subtle pt-2",
|
|
309
|
-
children:
|
|
310
|
+
children: Le && I.length === 0 ? /* @__PURE__ */ f("p", {
|
|
310
311
|
className: "flex items-center gap-1.5 px-2 py-1 text-[11px] text-text-muted",
|
|
311
|
-
children: [/* @__PURE__ */
|
|
312
|
-
}) : I.length === 0 ? /* @__PURE__ */
|
|
312
|
+
children: [/* @__PURE__ */ d(l, { className: "size-3 animate-spin" }), "Loading…"]
|
|
313
|
+
}) : I.length === 0 ? /* @__PURE__ */ d("p", {
|
|
313
314
|
className: "px-2 py-1 text-[11px] leading-relaxed text-text-muted",
|
|
314
315
|
children: "No past chats yet."
|
|
315
|
-
}) : I.map((t) => /* @__PURE__ */
|
|
316
|
+
}) : I.map((t) => /* @__PURE__ */ f("div", {
|
|
316
317
|
"data-testid": "assistant-history-row",
|
|
317
318
|
className: e("group flex items-center gap-1 rounded pr-1 transition-colors", t.active ? "bg-bg-surface" : "hover:bg-bg-surface"),
|
|
318
|
-
children: [/* @__PURE__ */
|
|
319
|
+
children: [/* @__PURE__ */ d("button", {
|
|
319
320
|
type: "button",
|
|
320
|
-
onClick: () => void
|
|
321
|
+
onClick: () => void et(t.id),
|
|
321
322
|
title: t.title,
|
|
322
323
|
"data-testid": "assistant-history-item",
|
|
323
324
|
className: e("min-w-0 flex-1 truncate rounded px-2 py-1.5 text-left text-[11px] leading-relaxed cursor-pointer", t.active ? "font-medium text-text-primary" : "text-text-secondary group-hover:text-text-primary"),
|
|
324
325
|
children: t.title
|
|
325
|
-
}), C.deleteSession ? /* @__PURE__ */
|
|
326
|
+
}), C.deleteSession ? /* @__PURE__ */ d("button", {
|
|
326
327
|
type: "button",
|
|
327
|
-
onClick: () => void
|
|
328
|
+
onClick: () => void Qe(t.id, !!t.active),
|
|
328
329
|
disabled: N,
|
|
329
330
|
"aria-label": `Delete chat: ${t.title}`,
|
|
330
331
|
title: "Delete this chat",
|
|
331
332
|
"data-testid": "assistant-delete-chat",
|
|
332
333
|
className: "inline-flex size-6 shrink-0 items-center justify-center rounded text-text-muted opacity-0 transition-opacity hover:text-status-error-bg focus-visible:opacity-100 group-hover:opacity-100 disabled:opacity-30 cursor-pointer",
|
|
333
|
-
children: /* @__PURE__ */
|
|
334
|
+
children: /* @__PURE__ */ d(me, { className: "size-3.5" })
|
|
334
335
|
}) : null]
|
|
335
336
|
}, t.id))
|
|
336
337
|
}) : null
|
|
337
338
|
]
|
|
338
|
-
}) : null, /* @__PURE__ */
|
|
339
|
+
}) : null, /* @__PURE__ */ f("div", {
|
|
339
340
|
className: "flex min-h-0 min-w-0 flex-1 flex-col",
|
|
340
341
|
children: [
|
|
341
|
-
/* @__PURE__ */
|
|
342
|
+
/* @__PURE__ */ f("div", {
|
|
342
343
|
className: "flex shrink-0 items-center justify-between gap-2 border-b border-border-subtle bg-bg-surface px-4 py-3",
|
|
343
|
-
children: [/* @__PURE__ */
|
|
344
|
+
children: [/* @__PURE__ */ f("div", {
|
|
344
345
|
className: "flex min-w-0 items-center gap-2",
|
|
345
|
-
children: [q &&
|
|
346
|
+
children: [q && Ge && !ze ? /* @__PURE__ */ f("button", {
|
|
346
347
|
type: "button",
|
|
347
|
-
onClick:
|
|
348
|
+
onClick: Ke,
|
|
348
349
|
"aria-label": "Show chats",
|
|
349
350
|
"aria-expanded": !1,
|
|
350
351
|
title: "Show chats",
|
|
351
352
|
"data-testid": "assistant-rail-toggle",
|
|
352
353
|
className: "inline-flex shrink-0 items-center gap-1.5 rounded-md border border-border-subtle px-2 py-1.5 text-xs font-medium text-text-secondary transition-colors hover:bg-bg-sunken hover:text-text-primary focus:outline-none focus-visible:ring-2 focus-visible:ring-border-strong cursor-pointer",
|
|
353
|
-
children: [/* @__PURE__ */
|
|
354
|
-
}) : /* @__PURE__ */
|
|
354
|
+
children: [/* @__PURE__ */ d(le, { className: "size-4" }), "Chats"]
|
|
355
|
+
}) : /* @__PURE__ */ d("span", {
|
|
355
356
|
className: "inline-flex size-7 shrink-0 items-center justify-center rounded-full bg-action-primary-bg/10 text-action-primary-bg",
|
|
356
|
-
children: /* @__PURE__ */
|
|
357
|
-
}), /* @__PURE__ */
|
|
357
|
+
children: /* @__PURE__ */ d(pe, { className: "size-4" })
|
|
358
|
+
}), /* @__PURE__ */ d("h2", {
|
|
358
359
|
className: "truncate text-sm font-semibold text-text-primary",
|
|
359
|
-
children:
|
|
360
|
+
children: Ne
|
|
360
361
|
})]
|
|
361
|
-
}), /* @__PURE__ */
|
|
362
|
+
}), /* @__PURE__ */ d("button", {
|
|
362
363
|
type: "button",
|
|
363
|
-
onClick:
|
|
364
|
+
onClick: Je,
|
|
364
365
|
"aria-label": "Close AI assistant",
|
|
365
366
|
"data-testid": "assistant-widget-close",
|
|
366
367
|
className: "inline-flex size-8 shrink-0 items-center justify-center rounded-md text-text-secondary transition-colors hover:bg-bg-sunken hover:text-text-primary focus:outline-none focus-visible:ring-2 focus-visible:ring-border-strong cursor-pointer",
|
|
367
|
-
children: /* @__PURE__ */ u
|
|
368
|
+
children: /* @__PURE__ */ d(u, { className: "size-4" })
|
|
368
369
|
})]
|
|
369
370
|
}),
|
|
370
|
-
b.length > 1 ? /* @__PURE__ */
|
|
371
|
+
b.length > 1 ? /* @__PURE__ */ d("div", {
|
|
371
372
|
role: "tablist",
|
|
372
373
|
"aria-label": "Assistant mode",
|
|
373
374
|
"data-testid": "assistant-mode-switcher",
|
|
374
375
|
className: "flex shrink-0 items-center gap-1 border-b border-border-subtle bg-bg-surface px-3 py-2",
|
|
375
376
|
children: b.map((t) => {
|
|
376
377
|
let n = t.id === x;
|
|
377
|
-
return /* @__PURE__ */
|
|
378
|
+
return /* @__PURE__ */ d("button", {
|
|
378
379
|
type: "button",
|
|
379
380
|
role: "tab",
|
|
380
381
|
"aria-selected": n,
|
|
381
382
|
tabIndex: n ? 0 : -1,
|
|
382
|
-
onClick: () =>
|
|
383
|
+
onClick: () => Me(t.id),
|
|
383
384
|
disabled: N,
|
|
384
385
|
title: N ? "Finish the current turn before switching" : t.label,
|
|
385
386
|
"data-testid": `assistant-mode-${t.id}`,
|
|
@@ -388,173 +389,173 @@ var ye = ({ transport: p, modes: m, defaultModeId: ye, title: g = "AI Assistant"
|
|
|
388
389
|
}, t.id);
|
|
389
390
|
})
|
|
390
391
|
}) : null,
|
|
391
|
-
/* @__PURE__ */
|
|
392
|
+
/* @__PURE__ */ d("div", {
|
|
392
393
|
ref: W,
|
|
393
394
|
className: "min-h-0 flex-1 space-y-3 overflow-y-auto px-4 py-4",
|
|
394
395
|
"data-testid": "assistant-widget-messages",
|
|
395
|
-
children: D.length === 0 &&
|
|
396
|
+
children: D.length === 0 && Ie ? /* @__PURE__ */ f("div", {
|
|
396
397
|
"data-testid": "assistant-widget-restoring",
|
|
397
398
|
className: "flex h-full flex-col items-center justify-center gap-3 text-center",
|
|
398
|
-
children: [/* @__PURE__ */
|
|
399
|
+
children: [/* @__PURE__ */ d(l, { className: "size-5 animate-spin text-text-secondary" }), /* @__PURE__ */ d("p", {
|
|
399
400
|
className: "text-xs leading-relaxed text-text-secondary",
|
|
400
401
|
children: "Restoring your conversation…"
|
|
401
402
|
})]
|
|
402
|
-
}) : D.length === 0 ? /* @__PURE__ */
|
|
403
|
+
}) : D.length === 0 ? /* @__PURE__ */ f("div", {
|
|
403
404
|
className: "flex h-full flex-col items-center justify-center gap-3 text-center",
|
|
404
|
-
children: [/* @__PURE__ */
|
|
405
|
+
children: [/* @__PURE__ */ d("span", {
|
|
405
406
|
className: "inline-flex size-12 items-center justify-center rounded-full bg-bg-sunken text-action-primary-bg",
|
|
406
|
-
children: /* @__PURE__ */
|
|
407
|
-
}), /* @__PURE__ */
|
|
407
|
+
children: /* @__PURE__ */ d(oe, { className: "size-6" })
|
|
408
|
+
}), /* @__PURE__ */ d("p", {
|
|
408
409
|
className: "max-w-[16rem] text-xs leading-relaxed text-text-secondary",
|
|
409
|
-
children:
|
|
410
|
+
children: Pe
|
|
410
411
|
})]
|
|
411
|
-
}) : D.map((t) => /* @__PURE__ */
|
|
412
|
+
}) : D.map((t) => /* @__PURE__ */ d("div", {
|
|
412
413
|
className: e("flex", t.role === "user" ? "justify-end" : "justify-start"),
|
|
413
|
-
children: /* @__PURE__ */
|
|
414
|
+
children: /* @__PURE__ */ f("div", {
|
|
414
415
|
"data-testid": `assistant-widget-message-${t.role}`,
|
|
415
416
|
className: e("whitespace-pre-wrap break-words rounded-lg px-3 py-2 text-xs leading-relaxed", q ? "max-w-[92%]" : "max-w-[85%]", t.role === "user" ? "bg-action-primary-bg text-action-primary-text" : t.error ? "bg-status-error-bg/10 text-status-error-bg" : "bg-bg-sunken text-text-primary"),
|
|
416
|
-
children: [t.content ? /* @__PURE__ */
|
|
417
|
+
children: [t.content ? /* @__PURE__ */ d(n, {
|
|
417
418
|
content: t.content,
|
|
418
|
-
onNavigate:
|
|
419
|
-
}) : null, t.pending ? /* @__PURE__ */
|
|
419
|
+
onNavigate: De
|
|
420
|
+
}) : null, t.pending ? /* @__PURE__ */ f("span", {
|
|
420
421
|
"data-testid": "assistant-widget-working",
|
|
421
422
|
className: e("inline-flex items-center gap-1 text-text-secondary", t.content ? "mt-1" : ""),
|
|
422
|
-
children: [/* @__PURE__ */
|
|
423
|
+
children: [/* @__PURE__ */ d(l, { className: "size-3 animate-spin" }), t.content ? null : /* @__PURE__ */ d("span", { children: "Working on it…" })]
|
|
423
424
|
}) : null]
|
|
424
425
|
})
|
|
425
426
|
}, t.id))
|
|
426
427
|
}),
|
|
427
|
-
C.downloadArtifact &&
|
|
428
|
+
C.downloadArtifact && Ve.length > 0 ? /* @__PURE__ */ d("div", {
|
|
428
429
|
"data-testid": "assistant-widget-artifacts",
|
|
429
430
|
className: "flex shrink-0 flex-wrap gap-1.5 border-t border-border-subtle bg-bg-sunken px-3 py-2",
|
|
430
|
-
children:
|
|
431
|
+
children: Ve.map((e) => {
|
|
431
432
|
let t = V === e.path;
|
|
432
|
-
return /* @__PURE__ */
|
|
433
|
+
return /* @__PURE__ */ f("button", {
|
|
433
434
|
type: "button",
|
|
434
|
-
onClick: () => void
|
|
435
|
+
onClick: () => void Xe(e),
|
|
435
436
|
disabled: !!V,
|
|
436
|
-
title: `Download ${e.name}${e.size ? ` (${
|
|
437
|
+
title: `Download ${e.name}${e.size ? ` (${xe(e.size)})` : ""}`,
|
|
437
438
|
"data-testid": "assistant-widget-artifact",
|
|
438
439
|
className: "inline-flex max-w-full items-center gap-1.5 rounded-md border border-border-default bg-bg-surface px-2 py-1 text-[11px] font-medium text-text-primary transition-colors hover:bg-bg-sunken focus:outline-none focus-visible:ring-2 focus-visible:ring-border-strong disabled:opacity-50 cursor-pointer",
|
|
439
|
-
children: [t ? /* @__PURE__ */
|
|
440
|
+
children: [t ? /* @__PURE__ */ d(l, { className: "size-3.5 shrink-0 animate-spin" }) : e.type === "directory" ? /* @__PURE__ */ d(re, { className: "size-3.5 shrink-0 text-action-primary-bg" }) : /* @__PURE__ */ d(ne, { className: "size-3.5 shrink-0 text-action-primary-bg" }), /* @__PURE__ */ d("span", {
|
|
440
441
|
className: "truncate",
|
|
441
442
|
children: e.name
|
|
442
443
|
})]
|
|
443
444
|
}, e.path);
|
|
444
445
|
})
|
|
445
446
|
}) : null,
|
|
446
|
-
y && j.length > 0 ? /* @__PURE__ */
|
|
447
|
+
y && j.length > 0 ? /* @__PURE__ */ d("div", {
|
|
447
448
|
className: "flex flex-wrap gap-1.5 border-t border-border-default bg-bg-surface px-3 pt-2",
|
|
448
|
-
children: j.map((e, t) => /* @__PURE__ */
|
|
449
|
+
children: j.map((e, t) => /* @__PURE__ */ f("span", {
|
|
449
450
|
"data-testid": "assistant-widget-attachment",
|
|
450
451
|
className: "flex items-center gap-1 rounded-md bg-bg-sunken px-2 py-1 text-[11px] text-text-secondary",
|
|
451
452
|
children: [
|
|
452
|
-
/* @__PURE__ */
|
|
453
|
-
/* @__PURE__ */
|
|
453
|
+
/* @__PURE__ */ d(ue, { className: "size-3" }),
|
|
454
|
+
/* @__PURE__ */ d("span", {
|
|
454
455
|
className: "max-w-[140px] truncate",
|
|
455
456
|
children: e.name
|
|
456
457
|
}),
|
|
457
|
-
/* @__PURE__ */
|
|
458
|
+
/* @__PURE__ */ d("button", {
|
|
458
459
|
type: "button",
|
|
459
460
|
onClick: () => M((e) => e.filter((e, n) => n !== t)),
|
|
460
461
|
"aria-label": `Remove ${e.name}`,
|
|
461
462
|
className: "text-text-muted hover:text-text-primary cursor-pointer",
|
|
462
|
-
children: /* @__PURE__ */ u
|
|
463
|
+
children: /* @__PURE__ */ d(u, { className: "size-3" })
|
|
463
464
|
})
|
|
464
465
|
]
|
|
465
466
|
}, `${e.name}-${t}`))
|
|
466
467
|
}) : null,
|
|
467
|
-
/* @__PURE__ */
|
|
468
|
+
/* @__PURE__ */ f("div", {
|
|
468
469
|
className: e("flex shrink-0 items-end gap-2 bg-bg-surface px-3 py-2.5", y && j.length > 0 ? "" : "border-t border-border-default"),
|
|
469
470
|
children: [
|
|
470
|
-
y ? /* @__PURE__ */
|
|
471
|
-
ref:
|
|
471
|
+
y ? /* @__PURE__ */ f(he, { children: [/* @__PURE__ */ d("input", {
|
|
472
|
+
ref: We,
|
|
472
473
|
type: "file",
|
|
473
|
-
accept:
|
|
474
|
+
accept: ke,
|
|
474
475
|
multiple: !0,
|
|
475
476
|
className: "hidden",
|
|
476
477
|
onChange: (e) => {
|
|
477
478
|
let t = Array.from(e.target.files ?? []);
|
|
478
479
|
t.length > 0 && M((e) => [...e, ...t]), e.target.value = "";
|
|
479
480
|
}
|
|
480
|
-
}), /* @__PURE__ */
|
|
481
|
+
}), /* @__PURE__ */ d("button", {
|
|
481
482
|
type: "button",
|
|
482
|
-
onClick: () =>
|
|
483
|
+
onClick: () => We.current?.click(),
|
|
483
484
|
"aria-label": "Attach a data file",
|
|
484
485
|
"data-testid": "assistant-widget-upload",
|
|
485
486
|
className: "flex size-9 shrink-0 items-center justify-center rounded-lg bg-bg-sunken text-text-secondary transition-colors hover:text-text-primary focus:outline-none focus-visible:ring-2 focus-visible:ring-border-strong cursor-pointer",
|
|
486
|
-
children: /* @__PURE__ */
|
|
487
|
+
children: /* @__PURE__ */ d(ue, { className: "size-4" })
|
|
487
488
|
})] }) : null,
|
|
488
|
-
|
|
489
|
+
Ae ? /* @__PURE__ */ d("button", {
|
|
489
490
|
type: "button",
|
|
490
491
|
onClick: () => H(!0),
|
|
491
492
|
"aria-label": "Connect a data source",
|
|
492
493
|
title: "Connect a source (REST API / connection)",
|
|
493
494
|
"data-testid": "assistant-widget-connect-source",
|
|
494
495
|
className: "flex size-9 shrink-0 items-center justify-center rounded-lg bg-bg-sunken text-text-secondary transition-colors hover:text-text-primary focus:outline-none focus-visible:ring-2 focus-visible:ring-border-strong cursor-pointer",
|
|
495
|
-
children: /* @__PURE__ */
|
|
496
|
+
children: /* @__PURE__ */ d(ae, { className: "size-4" })
|
|
496
497
|
}) : null,
|
|
497
|
-
J.isSupported ? /* @__PURE__ */
|
|
498
|
+
J.isSupported ? /* @__PURE__ */ d("button", {
|
|
498
499
|
type: "button",
|
|
499
|
-
onClick:
|
|
500
|
+
onClick: rt,
|
|
500
501
|
"aria-label": J.isListening ? "Stop voice input" : "Start voice input",
|
|
501
502
|
"aria-pressed": J.isListening,
|
|
502
503
|
"data-testid": "assistant-widget-mic",
|
|
503
504
|
className: e("flex size-9 shrink-0 items-center justify-center rounded-lg transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-border-strong cursor-pointer", J.isListening ? "animate-pulse bg-status-error-bg text-action-primary-text" : "bg-bg-sunken text-text-secondary hover:text-text-primary"),
|
|
504
|
-
children: /* @__PURE__ */
|
|
505
|
+
children: /* @__PURE__ */ d(se, { className: "size-4" })
|
|
505
506
|
}) : null,
|
|
506
|
-
/* @__PURE__ */
|
|
507
|
+
/* @__PURE__ */ d("textarea", {
|
|
507
508
|
ref: U,
|
|
508
509
|
value: k,
|
|
509
510
|
onChange: (e) => A(e.target.value),
|
|
510
|
-
onKeyDown:
|
|
511
|
-
onInput:
|
|
511
|
+
onKeyDown: tt,
|
|
512
|
+
onInput: nt,
|
|
512
513
|
rows: 1,
|
|
513
|
-
placeholder:
|
|
514
|
+
placeholder: Fe,
|
|
514
515
|
"aria-label": "Message the assistant",
|
|
515
516
|
"data-testid": "assistant-widget-input",
|
|
516
517
|
className: "flex-1 resize-none rounded-lg border border-border-default bg-bg-sunken px-3 py-2 text-xs leading-relaxed text-text-primary placeholder:text-text-muted focus:border-action-primary-bg focus:outline-none"
|
|
517
518
|
}),
|
|
518
|
-
/* @__PURE__ */
|
|
519
|
+
/* @__PURE__ */ d("button", {
|
|
519
520
|
type: "button",
|
|
520
|
-
onClick: () => void
|
|
521
|
+
onClick: () => void $(),
|
|
521
522
|
disabled: N || k.trim().length === 0 && j.length === 0,
|
|
522
523
|
"aria-label": "Send message",
|
|
523
524
|
"data-testid": "assistant-widget-send",
|
|
524
525
|
className: "flex size-9 shrink-0 items-center justify-center rounded-lg bg-action-primary-bg text-action-primary-text transition-colors hover:bg-action-primary-bg-hover focus:outline-none focus-visible:ring-2 focus-visible:ring-border-strong disabled:opacity-50 cursor-pointer",
|
|
525
|
-
children: N ? /* @__PURE__ */
|
|
526
|
+
children: N ? /* @__PURE__ */ d(l, { className: "size-4 animate-spin" }) : /* @__PURE__ */ d(fe, { className: "size-4" })
|
|
526
527
|
})
|
|
527
528
|
]
|
|
528
529
|
})
|
|
529
530
|
]
|
|
530
531
|
})]
|
|
531
532
|
}) : null,
|
|
532
|
-
|
|
533
|
+
Ue ? /* @__PURE__ */ d("div", {
|
|
533
534
|
role: "dialog",
|
|
534
535
|
"aria-modal": "true",
|
|
535
536
|
"aria-label": "Connect a source",
|
|
536
537
|
"data-testid": "assistant-connect-source-modal",
|
|
537
538
|
className: "fixed inset-0 z-[110] flex items-center justify-center bg-black/50 p-4 animate-in fade-in duration-150",
|
|
538
539
|
onClick: () => H(!1),
|
|
539
|
-
children: /* @__PURE__ */
|
|
540
|
+
children: /* @__PURE__ */ f("div", {
|
|
540
541
|
className: "flex h-[80vh] max-h-[720px] w-full max-w-4xl flex-col overflow-hidden rounded-xl border border-border-default bg-bg-surface shadow-2xl animate-in zoom-in-95 duration-150",
|
|
541
542
|
onClick: (e) => e.stopPropagation(),
|
|
542
|
-
children: [/* @__PURE__ */
|
|
543
|
+
children: [/* @__PURE__ */ f("div", {
|
|
543
544
|
className: "flex shrink-0 items-center justify-between border-b border-border-subtle px-4 py-3",
|
|
544
|
-
children: [/* @__PURE__ */
|
|
545
|
+
children: [/* @__PURE__ */ f("div", {
|
|
545
546
|
className: "flex items-center gap-2 text-sm font-medium text-text-primary",
|
|
546
|
-
children: [/* @__PURE__ */
|
|
547
|
-
}), /* @__PURE__ */
|
|
547
|
+
children: [/* @__PURE__ */ d(ae, { className: "size-4 shrink-0" }), "Connect a source"]
|
|
548
|
+
}), /* @__PURE__ */ d("button", {
|
|
548
549
|
type: "button",
|
|
549
550
|
onClick: () => H(!1),
|
|
550
551
|
"aria-label": "Close",
|
|
551
552
|
title: "Close",
|
|
552
553
|
"data-testid": "assistant-connect-source-close",
|
|
553
554
|
className: "flex size-8 items-center justify-center rounded-lg text-text-secondary transition-colors hover:bg-bg-sunken hover:text-text-primary focus:outline-none focus-visible:ring-2 focus-visible:ring-border-strong cursor-pointer",
|
|
554
|
-
children: /* @__PURE__ */ u
|
|
555
|
+
children: /* @__PURE__ */ d(u, { className: "size-4" })
|
|
555
556
|
})]
|
|
556
|
-
}), /* @__PURE__ */
|
|
557
|
-
src:
|
|
557
|
+
}), /* @__PURE__ */ d("iframe", {
|
|
558
|
+
src: je,
|
|
558
559
|
title: "Connected Systems",
|
|
559
560
|
"data-testid": "assistant-connect-source-frame",
|
|
560
561
|
className: "min-h-0 w-full flex-1 border-0 bg-bg-surface"
|
|
@@ -564,4 +565,4 @@ var ye = ({ transport: p, modes: m, defaultModeId: ye, title: g = "AI Assistant"
|
|
|
564
565
|
] }) : null;
|
|
565
566
|
};
|
|
566
567
|
//#endregion
|
|
567
|
-
export {
|
|
568
|
+
export { ge as ASSISTANT_WIDGET_TOGGLE_EVENT, Se as AssistantWidget };
|