@icanbwell/baileyai-chat-ui 1.0.0 → 1.0.1
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/baileyai-chat-ui.cjs +3 -2
- package/dist/baileyai-chat-ui.css +1 -1
- package/dist/baileyai-chat-ui.js +520 -472
- package/package.json +1 -1
package/dist/baileyai-chat-ui.js
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
import { t as e } from "./safeMarkdownUrl-xI42YYzd.js";
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import * as
|
|
6
|
-
import { Fragment as
|
|
2
|
+
import { createContext as t, memo as n, useCallback as r, useContext as i, useEffect as a, useLayoutEffect as o, useMemo as s, useRef as c, useState as l } from "react";
|
|
3
|
+
import u from "react-markdown";
|
|
4
|
+
import d from "remark-gfm";
|
|
5
|
+
import * as f from "@radix-ui/react-tooltip";
|
|
6
|
+
import { Fragment as p, jsx as m, jsxs as h } from "react/jsx-runtime";
|
|
7
7
|
//#region src/utils/pseudoToolCalls.ts
|
|
8
|
-
var
|
|
9
|
-
function
|
|
10
|
-
let t =
|
|
8
|
+
var g = /<(search_tools|call_tool|function_calls|function_result)>([\s\S]*?)<\/\1>/g, _ = /<name>([\s\S]*?)<\/name>/, v = /<arguments>([\s\S]*?)<\/arguments>/, y = /<invoke\s+name="([^"]*)"\s*>([\s\S]*?)<\/invoke>/g, b = /<parameter\s+name="([^"]*)"\s*>([\s\S]*?)<\/parameter>/g;
|
|
9
|
+
function x(e) {
|
|
10
|
+
let t = _.exec(e)?.[1]?.trim() || "unknown_tool", n = v.exec(e)?.[1]?.trim();
|
|
11
11
|
return n ? {
|
|
12
12
|
name: t,
|
|
13
13
|
args: n
|
|
14
14
|
} : { name: t };
|
|
15
15
|
}
|
|
16
|
-
function
|
|
16
|
+
function S(e) {
|
|
17
17
|
let t = [];
|
|
18
|
-
|
|
18
|
+
y.lastIndex = 0;
|
|
19
19
|
let n;
|
|
20
|
-
for (; (n =
|
|
20
|
+
for (; (n = y.exec(e)) !== null;) {
|
|
21
21
|
let [, e, r] = n, i = {};
|
|
22
|
-
|
|
22
|
+
b.lastIndex = 0;
|
|
23
23
|
let a;
|
|
24
|
-
for (; (a =
|
|
24
|
+
for (; (a = b.exec(r)) !== null;) i[a[1]] = a[2].trim();
|
|
25
25
|
let o = e.trim() || "unknown_tool";
|
|
26
26
|
t.push(Object.keys(i).length > 0 ? {
|
|
27
27
|
name: o,
|
|
@@ -30,11 +30,11 @@ function y(e) {
|
|
|
30
30
|
}
|
|
31
31
|
return t;
|
|
32
32
|
}
|
|
33
|
-
function
|
|
34
|
-
let t = [], n = e.replace(
|
|
33
|
+
function C(e) {
|
|
34
|
+
let t = [], n = e.replace(g, (e, n, r) => (n === "call_tool" ? t.push(x(r)) : n === "search_tools" ? t.push({
|
|
35
35
|
name: "search_tools",
|
|
36
36
|
args: r.trim()
|
|
37
|
-
}) : n === "function_calls" ? t.push(...
|
|
37
|
+
}) : n === "function_calls" ? t.push(...S(r)) : t.push({
|
|
38
38
|
name: "function_result",
|
|
39
39
|
args: r.trim()
|
|
40
40
|
}), ""));
|
|
@@ -48,7 +48,7 @@ function b(e) {
|
|
|
48
48
|
}
|
|
49
49
|
//#endregion
|
|
50
50
|
//#region src/logic/sse.ts
|
|
51
|
-
function
|
|
51
|
+
function w(e) {
|
|
52
52
|
if (!e.startsWith("data: ")) return e;
|
|
53
53
|
let t = "";
|
|
54
54
|
for (let n of e.split("\n")) {
|
|
@@ -62,7 +62,7 @@ function x(e) {
|
|
|
62
62
|
}
|
|
63
63
|
return t || null;
|
|
64
64
|
}
|
|
65
|
-
function
|
|
65
|
+
function T(e) {
|
|
66
66
|
let t = e.replace(/\r\n/g, "\n").split("\n\n"), n = t.pop() ?? "", r = [], i = !1;
|
|
67
67
|
for (let e of t) {
|
|
68
68
|
let t = e.split("\n").filter((e) => e.length > 0), n = "message", a = [];
|
|
@@ -87,7 +87,7 @@ function S(e) {
|
|
|
87
87
|
message: e
|
|
88
88
|
});
|
|
89
89
|
} else if (c?.type === "response.output_text.delta" && typeof c.delta == "string") {
|
|
90
|
-
let e =
|
|
90
|
+
let e = w(c.delta);
|
|
91
91
|
e && r.push({
|
|
92
92
|
type: "response.output_text.delta",
|
|
93
93
|
delta: e
|
|
@@ -105,42 +105,42 @@ function S(e) {
|
|
|
105
105
|
}
|
|
106
106
|
//#endregion
|
|
107
107
|
//#region src/logic/useBaileyChat.ts
|
|
108
|
-
var
|
|
108
|
+
var E = 200, D = 15e4, O = () => typeof crypto < "u" && typeof crypto.randomUUID == "function" ? crypto.randomUUID() : `bailey-${Date.now()}-${Math.random().toString(36).slice(2)}`, ee = (e, t, n) => {
|
|
109
109
|
if (e === 401 || e === 403) return "Bailey isn't reachable with your current login.";
|
|
110
110
|
let r = `Bailey request failed (status ${e ?? "network error"}).`, i = (n || t || "").trim();
|
|
111
|
-
return i ? `${r} ${i.length >
|
|
112
|
-
},
|
|
113
|
-
let [f, p] =
|
|
114
|
-
|
|
115
|
-
|
|
111
|
+
return i ? `${r} ${i.length > E ? `${i.slice(0, E)}…` : i}` : r;
|
|
112
|
+
}, k = ({ transport: e, model: t, instructions: n, tools: i = [], toolChoice: o, firstUserMessagePrefix: s, onAssistantMessageComplete: u, idleTimeoutMs: d = D }) => {
|
|
113
|
+
let [f, p] = l([]), [m, h] = l([]), [g, _] = l(null), [v, y] = l("idle"), [b, x] = l(null), S = c(null), w = c(""), E = c(0), k = c([]);
|
|
114
|
+
a(() => {
|
|
115
|
+
k.current = f;
|
|
116
116
|
}, [f]);
|
|
117
|
-
let
|
|
118
|
-
|
|
119
|
-
}, []),
|
|
120
|
-
|
|
117
|
+
let A = c([]), j = c(/* @__PURE__ */ new Map()), M = c(/* @__PURE__ */ new Map()), N = c(null), P = r(() => {
|
|
118
|
+
N.current !== null && (clearTimeout(N.current), N.current = null);
|
|
119
|
+
}, []), F = r((e) => {
|
|
120
|
+
P(), N.current = setTimeout(() => {
|
|
121
121
|
e.abort(new DOMException("The assistant took too long to respond. Please try again.", "TimeoutError"));
|
|
122
122
|
}, d);
|
|
123
|
-
}, [
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
}, [
|
|
127
|
-
let
|
|
123
|
+
}, [P, d]);
|
|
124
|
+
a(() => () => {
|
|
125
|
+
S.current?.abort(), P();
|
|
126
|
+
}, [P]);
|
|
127
|
+
let I = r((e, t, n) => {
|
|
128
128
|
let r = (e) => {
|
|
129
129
|
n.push(e), h((t) => [...t, e]);
|
|
130
130
|
};
|
|
131
131
|
if (t.type === "response.output_text.delta") {
|
|
132
132
|
if (!t.delta) return !1;
|
|
133
|
-
let n =
|
|
133
|
+
let n = j.current.get(e) ?? {
|
|
134
134
|
raw: "",
|
|
135
135
|
emittedCount: 0
|
|
136
136
|
};
|
|
137
137
|
n.raw += t.delta;
|
|
138
|
-
let { cleanedText: i, matches: a } =
|
|
139
|
-
if (n.emittedCount = a.length,
|
|
138
|
+
let { cleanedText: i, matches: a } = C(n.raw), o = i.trim(), s = a.slice(n.emittedCount);
|
|
139
|
+
if (n.emittedCount = a.length, j.current.set(e, n), M.current.set(e, o), p((t) => t.map((t) => t.id === e ? {
|
|
140
140
|
...t,
|
|
141
141
|
content: o
|
|
142
142
|
} : t)), s.length > 0) {
|
|
143
|
-
let e = Date.now(), t =
|
|
143
|
+
let e = Date.now(), t = E.current;
|
|
144
144
|
s.forEach((n) => r({
|
|
145
145
|
kind: "pseudo_tool_call",
|
|
146
146
|
name: n.name,
|
|
@@ -154,7 +154,7 @@ var C = 200, w = 15e4, T = () => typeof crypto < "u" && typeof crypto.randomUUID
|
|
|
154
154
|
if (t.type === "response.output_item.added" || t.type === "response.output_item.done") {
|
|
155
155
|
let e = t.item;
|
|
156
156
|
if (e.type === "function_call" || e.type === "mcp_call") {
|
|
157
|
-
let n = Date.now(), i =
|
|
157
|
+
let n = Date.now(), i = E.current, a = e.name || "unknown_tool";
|
|
158
158
|
return r(t.type === "response.output_item.added" ? {
|
|
159
159
|
kind: "tool_start",
|
|
160
160
|
name: a,
|
|
@@ -179,46 +179,46 @@ var C = 200, w = 15e4, T = () => typeof crypto < "u" && typeof crypto.randomUUID
|
|
|
179
179
|
status: t.status,
|
|
180
180
|
message: t.message,
|
|
181
181
|
at: Date.now(),
|
|
182
|
-
turnSentAt:
|
|
182
|
+
turnSentAt: E.current
|
|
183
183
|
}), !0) : t.type === "response.output_text.done" || t.type === "response.created" || t.type === "response.completed" ? !1 : t.type === "info" ? (r({
|
|
184
184
|
kind: "info",
|
|
185
185
|
message: t.message,
|
|
186
186
|
at: Date.now(),
|
|
187
|
-
turnSentAt:
|
|
187
|
+
turnSentAt: E.current
|
|
188
188
|
}), !0) : (r({
|
|
189
189
|
kind: "raw",
|
|
190
190
|
eventType: t.type,
|
|
191
191
|
raw: JSON.stringify(t),
|
|
192
192
|
at: Date.now(),
|
|
193
|
-
turnSentAt:
|
|
193
|
+
turnSentAt: E.current
|
|
194
194
|
}), !0);
|
|
195
|
-
}, []),
|
|
196
|
-
y("streaming"),
|
|
197
|
-
let
|
|
198
|
-
|
|
199
|
-
let
|
|
200
|
-
id:
|
|
195
|
+
}, []), L = r(async (r) => {
|
|
196
|
+
y("streaming"), x(null);
|
|
197
|
+
let a = Date.now();
|
|
198
|
+
E.current = a;
|
|
199
|
+
let c = O(), l = {
|
|
200
|
+
id: c,
|
|
201
201
|
role: "assistant",
|
|
202
202
|
content: "",
|
|
203
203
|
streaming: !0,
|
|
204
|
-
createdAt:
|
|
204
|
+
createdAt: a
|
|
205
205
|
};
|
|
206
|
-
p((e) => [...e,
|
|
207
|
-
let d =
|
|
206
|
+
p((e) => [...e, l]), A.current = [...r, l];
|
|
207
|
+
let d = r.findIndex((e) => e.role === "user" && !e.hidden), f = r.map((e, t) => t === d && s ? {
|
|
208
208
|
role: e.role,
|
|
209
|
-
content: `${
|
|
209
|
+
content: `${s}${e.content}`
|
|
210
210
|
} : {
|
|
211
211
|
role: e.role,
|
|
212
212
|
content: e.content
|
|
213
213
|
});
|
|
214
214
|
_({
|
|
215
215
|
model: t,
|
|
216
|
-
systemPrompt:
|
|
216
|
+
systemPrompt: n,
|
|
217
217
|
messages: f,
|
|
218
|
-
tools:
|
|
219
|
-
toolChoice:
|
|
218
|
+
tools: i,
|
|
219
|
+
toolChoice: o,
|
|
220
220
|
stream: !0,
|
|
221
|
-
sentAt:
|
|
221
|
+
sentAt: a,
|
|
222
222
|
streamStats: {
|
|
223
223
|
chunkCount: 0,
|
|
224
224
|
firstChunkAt: null,
|
|
@@ -226,18 +226,18 @@ var C = 200, w = 15e4, T = () => typeof crypto < "u" && typeof crypto.randomUUID
|
|
|
226
226
|
}
|
|
227
227
|
});
|
|
228
228
|
let m = new AbortController();
|
|
229
|
-
|
|
230
|
-
let g = "", v = null, b = !1,
|
|
231
|
-
y("error"),
|
|
229
|
+
S.current = m, F(m);
|
|
230
|
+
let g = "", v = null, b = !1, C = !1, w = [], D = (e, t) => {
|
|
231
|
+
y("error"), x(e);
|
|
232
232
|
let n = {
|
|
233
233
|
kind: "error",
|
|
234
234
|
message: e,
|
|
235
235
|
at: Date.now(),
|
|
236
|
-
turnSentAt:
|
|
236
|
+
turnSentAt: a,
|
|
237
237
|
...t
|
|
238
238
|
};
|
|
239
239
|
w.push(n), h((e) => [...e, n]);
|
|
240
|
-
},
|
|
240
|
+
}, k = (e, t) => {
|
|
241
241
|
e.forEach((e) => {
|
|
242
242
|
if (e.type === "error") {
|
|
243
243
|
v = e.message;
|
|
@@ -245,76 +245,76 @@ var C = 200, w = 15e4, T = () => typeof crypto < "u" && typeof crypto.randomUUID
|
|
|
245
245
|
kind: "error",
|
|
246
246
|
message: e.message,
|
|
247
247
|
at: Date.now(),
|
|
248
|
-
turnSentAt:
|
|
248
|
+
turnSentAt: a
|
|
249
249
|
};
|
|
250
250
|
w.push(t), h((e) => [...e, t]);
|
|
251
251
|
return;
|
|
252
252
|
}
|
|
253
|
-
e.type === "response.output_text.delta" && e.delta && (
|
|
254
|
-
}), t && p((e) => e.map((e) => e.id ===
|
|
253
|
+
e.type === "response.output_text.delta" && e.delta && (C = !0), I(c, e, w) && (b = !0);
|
|
254
|
+
}), t && p((e) => e.map((e) => e.id === c ? {
|
|
255
255
|
...e,
|
|
256
256
|
streaming: !1
|
|
257
257
|
} : e));
|
|
258
258
|
};
|
|
259
259
|
try {
|
|
260
|
-
let { status:
|
|
260
|
+
let { status: r, text: s, errorMessage: l } = await e.streamChat({
|
|
261
261
|
model: t,
|
|
262
|
-
instructions:
|
|
262
|
+
instructions: n,
|
|
263
263
|
input: f,
|
|
264
|
-
tools:
|
|
265
|
-
toolChoice:
|
|
264
|
+
tools: i,
|
|
265
|
+
toolChoice: o,
|
|
266
266
|
signal: m.signal,
|
|
267
267
|
onChunk: (e) => {
|
|
268
|
-
|
|
269
|
-
let { events: t, remainder: n, done:
|
|
270
|
-
g = n,
|
|
271
|
-
let
|
|
272
|
-
_((e) => e && e.sentAt ===
|
|
268
|
+
F(m), g += e;
|
|
269
|
+
let { events: t, remainder: n, done: r } = T(g);
|
|
270
|
+
g = n, k(t, r);
|
|
271
|
+
let i = Date.now();
|
|
272
|
+
_((e) => e && e.sentAt === a ? {
|
|
273
273
|
...e,
|
|
274
274
|
streamStats: {
|
|
275
275
|
chunkCount: e.streamStats.chunkCount + 1,
|
|
276
|
-
firstChunkAt: e.streamStats.firstChunkAt ??
|
|
277
|
-
lastChunkAt:
|
|
276
|
+
firstChunkAt: e.streamStats.firstChunkAt ?? i,
|
|
277
|
+
lastChunkAt: i
|
|
278
278
|
}
|
|
279
279
|
} : e);
|
|
280
280
|
},
|
|
281
281
|
onRequestId: (e) => {
|
|
282
|
-
_((t) => t && t.sentAt ===
|
|
282
|
+
_((t) => t && t.sentAt === a ? {
|
|
283
283
|
...t,
|
|
284
284
|
requestId: e
|
|
285
285
|
} : t);
|
|
286
286
|
}
|
|
287
287
|
});
|
|
288
288
|
if (g.trim()) {
|
|
289
|
-
let { events: e, done: t } =
|
|
290
|
-
g = "",
|
|
289
|
+
let { events: e, done: t } = T(`${g}\n\n`);
|
|
290
|
+
g = "", k(e, t);
|
|
291
291
|
}
|
|
292
292
|
if (v) {
|
|
293
|
-
y("error"),
|
|
293
|
+
y("error"), x(v);
|
|
294
294
|
return;
|
|
295
295
|
}
|
|
296
|
-
if (
|
|
297
|
-
|
|
298
|
-
httpStatus:
|
|
299
|
-
rawBody:
|
|
296
|
+
if (r === void 0 || r >= 400) {
|
|
297
|
+
D(ee(r, s, l), {
|
|
298
|
+
httpStatus: r,
|
|
299
|
+
rawBody: s || void 0
|
|
300
300
|
});
|
|
301
301
|
return;
|
|
302
302
|
}
|
|
303
303
|
if (!b) {
|
|
304
|
-
|
|
304
|
+
D("Bailey returned an empty response.");
|
|
305
305
|
return;
|
|
306
306
|
}
|
|
307
|
-
if (!
|
|
308
|
-
|
|
307
|
+
if (!C) {
|
|
308
|
+
D("Bailey ran some tools but didn't return an answer. Try asking again.");
|
|
309
309
|
return;
|
|
310
310
|
}
|
|
311
311
|
y("idle");
|
|
312
|
-
let d =
|
|
313
|
-
_((e) => e && e.sentAt ===
|
|
312
|
+
let d = M.current.get(c) ?? "";
|
|
313
|
+
_((e) => e && e.sentAt === a ? {
|
|
314
314
|
...e,
|
|
315
315
|
response: { content: d }
|
|
316
316
|
} : e), u && await u({
|
|
317
|
-
id:
|
|
317
|
+
id: c,
|
|
318
318
|
role: "assistant",
|
|
319
319
|
content: d,
|
|
320
320
|
streaming: !1
|
|
@@ -322,21 +322,21 @@ var C = 200, w = 15e4, T = () => typeof crypto < "u" && typeof crypto.randomUUID
|
|
|
322
322
|
} catch (e) {
|
|
323
323
|
let t = e;
|
|
324
324
|
if (t?.name === "TimeoutError") {
|
|
325
|
-
|
|
325
|
+
D(t.message, { source: "client-timeout" });
|
|
326
326
|
return;
|
|
327
327
|
}
|
|
328
328
|
if (t?.name === "AbortError") {
|
|
329
329
|
y("idle");
|
|
330
330
|
return;
|
|
331
331
|
}
|
|
332
|
-
|
|
332
|
+
D(t?.message || "Bailey request failed.");
|
|
333
333
|
} finally {
|
|
334
|
-
|
|
335
|
-
let e =
|
|
336
|
-
|
|
334
|
+
P();
|
|
335
|
+
let e = M.current.get(c) ?? "";
|
|
336
|
+
j.current.delete(c), M.current.delete(c), p((e) => e.flatMap((e) => e.id === c ? e.content ? [{
|
|
337
337
|
...e,
|
|
338
338
|
streaming: !1
|
|
339
|
-
}] : [] : [e])),
|
|
339
|
+
}] : [] : [e])), A.current = A.current.flatMap((t) => t.id === c ? e ? [{
|
|
340
340
|
...t,
|
|
341
341
|
content: e,
|
|
342
342
|
streaming: !1
|
|
@@ -345,83 +345,83 @@ var C = 200, w = 15e4, T = () => typeof crypto < "u" && typeof crypto.randomUUID
|
|
|
345
345
|
}, [
|
|
346
346
|
e,
|
|
347
347
|
t,
|
|
348
|
+
n,
|
|
348
349
|
i,
|
|
350
|
+
o,
|
|
349
351
|
s,
|
|
350
|
-
c,
|
|
351
|
-
l,
|
|
352
352
|
u,
|
|
353
|
-
L,
|
|
354
353
|
I,
|
|
355
|
-
F
|
|
356
|
-
|
|
357
|
-
|
|
354
|
+
F,
|
|
355
|
+
P
|
|
356
|
+
]), R = r((e) => {
|
|
357
|
+
k.current = e, p(e);
|
|
358
358
|
}, []);
|
|
359
359
|
return {
|
|
360
360
|
messages: f,
|
|
361
361
|
traceEvents: m,
|
|
362
362
|
lastRequest: g,
|
|
363
363
|
status: v,
|
|
364
|
-
error:
|
|
365
|
-
send:
|
|
364
|
+
error: b,
|
|
365
|
+
send: r((e) => {
|
|
366
366
|
let t = e.trim();
|
|
367
367
|
if (!t) return;
|
|
368
|
-
|
|
368
|
+
w.current = t;
|
|
369
369
|
let n = {
|
|
370
|
-
id:
|
|
370
|
+
id: O(),
|
|
371
371
|
role: "user",
|
|
372
372
|
content: t,
|
|
373
373
|
createdAt: Date.now()
|
|
374
|
-
}, r = [...
|
|
375
|
-
|
|
376
|
-
}, [
|
|
377
|
-
sendHidden:
|
|
374
|
+
}, r = [...A.current, n];
|
|
375
|
+
A.current = r, R([...k.current, n]), L(r);
|
|
376
|
+
}, [L, R]),
|
|
377
|
+
sendHidden: r((e) => {
|
|
378
378
|
if (v === "streaming") return;
|
|
379
379
|
let t = e.trim();
|
|
380
380
|
if (!t) return;
|
|
381
|
-
|
|
381
|
+
w.current = t;
|
|
382
382
|
let n = {
|
|
383
|
-
id:
|
|
383
|
+
id: O(),
|
|
384
384
|
role: "user",
|
|
385
385
|
content: t,
|
|
386
386
|
createdAt: Date.now(),
|
|
387
387
|
hidden: !0
|
|
388
|
-
}, r = [...
|
|
389
|
-
|
|
390
|
-
}, [
|
|
391
|
-
stop:
|
|
392
|
-
|
|
388
|
+
}, r = [...A.current, n];
|
|
389
|
+
A.current = r, L(r);
|
|
390
|
+
}, [L, v]),
|
|
391
|
+
stop: r(() => {
|
|
392
|
+
S.current?.abort();
|
|
393
393
|
}, []),
|
|
394
|
-
retryLast:
|
|
395
|
-
if (v === "streaming" || !
|
|
396
|
-
let e =
|
|
397
|
-
|
|
398
|
-
let r =
|
|
399
|
-
|
|
394
|
+
retryLast: r(() => {
|
|
395
|
+
if (v === "streaming" || !w.current) return;
|
|
396
|
+
let e = k.current, t = e[e.length - 1], n = t && t.role === "assistant" ? e.slice(0, -1) : e;
|
|
397
|
+
R(n);
|
|
398
|
+
let r = A.current, i = r[r.length - 1], a = i && i.role === "assistant" ? r.slice(0, -1) : r;
|
|
399
|
+
A.current = a, L(a);
|
|
400
400
|
}, [
|
|
401
|
+
L,
|
|
401
402
|
R,
|
|
402
|
-
z,
|
|
403
403
|
v
|
|
404
404
|
]),
|
|
405
|
-
clearTrace:
|
|
406
|
-
clearError:
|
|
407
|
-
|
|
405
|
+
clearTrace: r(() => h([]), []),
|
|
406
|
+
clearError: r(() => {
|
|
407
|
+
x(null), y((e) => e === "error" ? "idle" : e);
|
|
408
408
|
}, []),
|
|
409
|
-
newChat:
|
|
410
|
-
|
|
411
|
-
}, [
|
|
409
|
+
newChat: r(() => {
|
|
410
|
+
S.current?.abort(), R([]), A.current = [], h([]), _(null), y("idle"), x(null), w.current = "";
|
|
411
|
+
}, [R])
|
|
412
412
|
};
|
|
413
413
|
};
|
|
414
414
|
//#endregion
|
|
415
415
|
//#region src/utils/prompt.ts
|
|
416
|
-
function
|
|
416
|
+
function A(...e) {
|
|
417
417
|
return e.filter((e) => !!(e && e.trim())).join("\n\n");
|
|
418
418
|
}
|
|
419
419
|
//#endregion
|
|
420
420
|
//#region src/utils/toolCalls.ts
|
|
421
|
-
var
|
|
422
|
-
function
|
|
421
|
+
var j = "call_tool", M = "a tool";
|
|
422
|
+
function N(e, t) {
|
|
423
423
|
let n = {
|
|
424
|
-
name: e ===
|
|
424
|
+
name: e === j ? M : e,
|
|
425
425
|
args: null,
|
|
426
426
|
viaCallTool: !1
|
|
427
427
|
};
|
|
@@ -434,7 +434,7 @@ function j(e, t) {
|
|
|
434
434
|
}
|
|
435
435
|
if (typeof r != "object" || !r) return n;
|
|
436
436
|
let i = r;
|
|
437
|
-
if (e ===
|
|
437
|
+
if (e === j) {
|
|
438
438
|
let e = typeof i.name == "string" ? i.name : void 0;
|
|
439
439
|
if (!e) return n;
|
|
440
440
|
let t = i.arguments;
|
|
@@ -452,32 +452,32 @@ function j(e, t) {
|
|
|
452
452
|
}
|
|
453
453
|
//#endregion
|
|
454
454
|
//#region src/utils/table.ts
|
|
455
|
-
var
|
|
455
|
+
var P = 5, F = (e) => e.type === "text" ? e.value ?? "" : (e.children ?? []).map(F).join(""), I = (e) => {
|
|
456
456
|
if (e.tagName === "a" && e.properties?.href) return e.properties.href;
|
|
457
457
|
for (let t of e.children ?? []) {
|
|
458
|
-
let e =
|
|
458
|
+
let e = I(t);
|
|
459
459
|
if (e) return e;
|
|
460
460
|
}
|
|
461
|
-
},
|
|
462
|
-
let t =
|
|
461
|
+
}, L = (e, t) => (e.children ?? []).find((e) => e.tagName === t), R = (e) => {
|
|
462
|
+
let t = F(e), n = I(e);
|
|
463
463
|
return n ? {
|
|
464
464
|
text: t,
|
|
465
465
|
href: n
|
|
466
466
|
} : { text: t };
|
|
467
|
-
},
|
|
467
|
+
}, z = (e) => (e.children ?? []).filter((e) => e.type === "element").map(R), B = (e) => {
|
|
468
468
|
if (e.tagName !== "table") return null;
|
|
469
|
-
let t =
|
|
469
|
+
let t = L(e, "thead"), n = t && L(t, "tr");
|
|
470
470
|
return {
|
|
471
|
-
headers: n ?
|
|
472
|
-
rows: (
|
|
471
|
+
headers: n ? z(n).map((e) => e.text) : [],
|
|
472
|
+
rows: (L(e, "tbody")?.children ?? []).filter((e) => e.tagName === "tr").map(z)
|
|
473
473
|
};
|
|
474
|
-
},
|
|
474
|
+
}, V = (e) => e.length > 5, H = "When a chart would help answer a question (e.g. plotting a trend over time), include a fenced code block tagged `chartjs` containing a JSON object with this exact shape: {\"type\": \"bar\" | \"line\" | \"pie\" | \"doughnut\" | \"scatter\", \"title\"?: string, \"data\": {\"labels\": string[], \"datasets\": [{\"label\": string, \"data\": number[]}]}}. For \"scatter\" charts, omit \"labels\" and give each dataset \"data\" as an array of {\"x\": number, \"y\": number} points instead of a number array. \"pie\" and \"doughnut\" charts must have exactly one dataset. Do not include any other fields (no \"options\", no colors) — the app handles styling. Example:\n```chartjs\n{\"type\": \"line\", \"title\": \"BP readings\", \"data\": {\"labels\": [\"Jul 14\", \"Jul 21\", \"Jul 28\"], \"datasets\": [{\"label\": \"Systolic\", \"data\": [120, 118, 122]}]}}\n```", te = [
|
|
475
475
|
"bar",
|
|
476
476
|
"line",
|
|
477
477
|
"pie",
|
|
478
478
|
"doughnut",
|
|
479
479
|
"scatter"
|
|
480
|
-
],
|
|
480
|
+
], U = 8, W = 50, G = 8, K = 500, ne = (e) => typeof e == "object" && !!e && typeof e.x == "number" && typeof e.y == "number", re = (e) => {
|
|
481
481
|
let t;
|
|
482
482
|
try {
|
|
483
483
|
t = JSON.parse(e);
|
|
@@ -486,17 +486,17 @@ var M = 5, N = (e) => e.type === "text" ? e.value ?? "" : (e.children ?? []).map
|
|
|
486
486
|
}
|
|
487
487
|
if (typeof t != "object" || !t) return null;
|
|
488
488
|
let n = t;
|
|
489
|
-
if (typeof n.type != "string" || !
|
|
489
|
+
if (typeof n.type != "string" || !te.includes(n.type)) return null;
|
|
490
490
|
let r = n.type;
|
|
491
491
|
if (n.title !== void 0 && typeof n.title != "string") return null;
|
|
492
492
|
let i = n.title;
|
|
493
493
|
if (typeof n.data != "object" || n.data === null) return null;
|
|
494
494
|
let a = n.data;
|
|
495
|
-
if (!Array.isArray(a.datasets) || a.datasets.length < 1 || a.datasets.length >
|
|
495
|
+
if (!Array.isArray(a.datasets) || a.datasets.length < 1 || a.datasets.length > U || (r === "pie" || r === "doughnut") && a.datasets.length !== 1) return null;
|
|
496
496
|
for (let e of a.datasets) if (typeof e != "object" || !e || typeof e.label != "string" || !Array.isArray(e.data)) return null;
|
|
497
497
|
let o = a.datasets;
|
|
498
498
|
if (r === "scatter") {
|
|
499
|
-
for (let e of o) if (e.data.length < 1 || e.data.length >
|
|
499
|
+
for (let e of o) if (e.data.length < 1 || e.data.length > K || !e.data.every(ne)) return null;
|
|
500
500
|
return {
|
|
501
501
|
type: r,
|
|
502
502
|
title: i,
|
|
@@ -504,7 +504,7 @@ var M = 5, N = (e) => e.type === "text" ? e.value ?? "" : (e.children ?? []).map
|
|
|
504
504
|
};
|
|
505
505
|
}
|
|
506
506
|
if (!Array.isArray(a.labels) || !a.labels.every((e) => typeof e == "string")) return null;
|
|
507
|
-
let s = a.labels, c = r === "pie" || r === "doughnut" ?
|
|
507
|
+
let s = a.labels, c = r === "pie" || r === "doughnut" ? G : W;
|
|
508
508
|
if (s.length < 1 || s.length > c) return null;
|
|
509
509
|
for (let e of o) if (e.data.length !== s.length || !e.data.every((e) => typeof e == "number")) return null;
|
|
510
510
|
return {
|
|
@@ -515,7 +515,7 @@ var M = 5, N = (e) => e.type === "text" ? e.value ?? "" : (e.children ?? []).map
|
|
|
515
515
|
datasets: o
|
|
516
516
|
}
|
|
517
517
|
};
|
|
518
|
-
},
|
|
518
|
+
}, ie = {
|
|
519
519
|
tool_start: "Tool start",
|
|
520
520
|
tool_end: "Tool end",
|
|
521
521
|
pseudo_tool_call: "Narrated tool call",
|
|
@@ -524,13 +524,13 @@ var M = 5, N = (e) => e.type === "text" ? e.value ?? "" : (e.children ?? []).map
|
|
|
524
524
|
error: "Error",
|
|
525
525
|
raw: "Raw event"
|
|
526
526
|
};
|
|
527
|
-
function
|
|
528
|
-
return e.kind !== "tool_start" && e.kind !== "tool_end" ? null :
|
|
527
|
+
function q(e) {
|
|
528
|
+
return e.kind !== "tool_start" && e.kind !== "tool_end" ? null : N(e.name, e.args);
|
|
529
529
|
}
|
|
530
|
-
function
|
|
530
|
+
function J(e, t = q(e)) {
|
|
531
531
|
return e.kind === "pseudo_tool_call" ? e.name : t?.name ?? null;
|
|
532
532
|
}
|
|
533
|
-
function
|
|
533
|
+
function ae(e, t = q(e)) {
|
|
534
534
|
switch (e.kind) {
|
|
535
535
|
case "tool_start": return t.viaCallTool ? `${t.name} (via call_tool)` : t.name;
|
|
536
536
|
case "tool_end": return `${t.viaCallTool ? `${t.name} (via call_tool)` : t.name}${e.runtimeSeconds === void 0 ? "" : ` — ${e.runtimeSeconds.toFixed(2)}s`}${e.isError ? " — failed" : ""}`;
|
|
@@ -541,20 +541,20 @@ function J(e, t = K(e)) {
|
|
|
541
541
|
case "raw": return `Unrecognized event: ${e.eventType}`;
|
|
542
542
|
}
|
|
543
543
|
}
|
|
544
|
-
function
|
|
544
|
+
function oe(e, t = q(e)) {
|
|
545
545
|
return e.kind === "tool_start" || e.kind === "tool_end" ? t.args ? JSON.stringify(t.args, null, 2) : e.args ?? null : e.kind === "pseudo_tool_call" ? e.args ?? null : null;
|
|
546
546
|
}
|
|
547
|
-
function
|
|
547
|
+
function se(e) {
|
|
548
548
|
return e.kind === "tool_end" ? e.output ?? null : null;
|
|
549
549
|
}
|
|
550
|
-
function
|
|
550
|
+
function ce(e) {
|
|
551
551
|
return e.kind === "raw" ? e.raw : e.kind === "error" ? e.rawBody ?? null : null;
|
|
552
552
|
}
|
|
553
|
-
function
|
|
553
|
+
function Y(e) {
|
|
554
554
|
switch (e.kind) {
|
|
555
|
-
case "tool_start": return `Calling ${
|
|
555
|
+
case "tool_start": return `Calling ${N(e.name, e.args).name}...`;
|
|
556
556
|
case "tool_end": {
|
|
557
|
-
let t =
|
|
557
|
+
let t = N(e.name, e.args).name;
|
|
558
558
|
return e.isError ? `${t} failed` : `${t} returned`;
|
|
559
559
|
}
|
|
560
560
|
case "pseudo_tool_call": return `${e.name} (written as text, not called)`;
|
|
@@ -564,11 +564,11 @@ function X(e) {
|
|
|
564
564
|
case "raw": return `Unrecognized event: ${e.eventType}`;
|
|
565
565
|
}
|
|
566
566
|
}
|
|
567
|
-
function
|
|
567
|
+
function le(e) {
|
|
568
568
|
let t = new Date(e);
|
|
569
569
|
return `${String(t.getHours()).padStart(2, "0")}:${String(t.getMinutes()).padStart(2, "0")}:${String(t.getSeconds()).padStart(2, "0")}.${String(t.getMilliseconds()).padStart(3, "0")}`;
|
|
570
570
|
}
|
|
571
|
-
function
|
|
571
|
+
function ue(e) {
|
|
572
572
|
if (e <= 0) return "+0ms";
|
|
573
573
|
if (e < 1e3) return `+${Math.round(e)}ms`;
|
|
574
574
|
let t = e / 1e3;
|
|
@@ -576,30 +576,30 @@ function oe(e) {
|
|
|
576
576
|
let n = Math.floor(t / 60), r = Math.round(t % 60);
|
|
577
577
|
return `+${n}m${String(r).padStart(2, "0")}s`;
|
|
578
578
|
}
|
|
579
|
-
function
|
|
579
|
+
function de(e) {
|
|
580
580
|
return e.map((t, n) => {
|
|
581
|
-
let r =
|
|
581
|
+
let r = q(t), i = n === 0 ? t.turnSentAt : e[n - 1].at;
|
|
582
582
|
return {
|
|
583
583
|
key: `${t.at}-${n}`,
|
|
584
584
|
kind: t.kind,
|
|
585
|
-
toolName:
|
|
585
|
+
toolName: J(t, r),
|
|
586
586
|
isToolStart: t.kind === "tool_start",
|
|
587
587
|
failed: t.kind === "tool_end" && t.isError === !0,
|
|
588
|
-
time:
|
|
588
|
+
time: le(t.at),
|
|
589
589
|
gapMs: t.at - i,
|
|
590
|
-
label: t.kind === "tool_end" && t.isError === !0 ? "Tool failed" :
|
|
591
|
-
summary:
|
|
592
|
-
argsDetail:
|
|
593
|
-
outputDetail:
|
|
594
|
-
rawDetail:
|
|
590
|
+
label: t.kind === "tool_end" && t.isError === !0 ? "Tool failed" : ie[t.kind],
|
|
591
|
+
summary: ae(t, r),
|
|
592
|
+
argsDetail: oe(t, r),
|
|
593
|
+
outputDetail: se(t),
|
|
594
|
+
rawDetail: ce(t)
|
|
595
595
|
};
|
|
596
596
|
});
|
|
597
597
|
}
|
|
598
|
-
function
|
|
598
|
+
function fe(e) {
|
|
599
599
|
let t = e.filter((e) => e.kind === "tool_end"), n = t.filter((e) => e.kind === "tool_end" && e.isError), r = e.filter((e) => e.kind === "error"), i = [];
|
|
600
600
|
return t.length > 0 && i.push(`${t.length} tool call${t.length === 1 ? "" : "s"}` + (n.length > 0 ? `, ${n.length} failed` : "")), r.length > 0 && i.push(`${r.length} stream error${r.length === 1 ? "" : "s"}`), i.join(" · ");
|
|
601
601
|
}
|
|
602
|
-
function
|
|
602
|
+
function pe(e) {
|
|
603
603
|
let t = [];
|
|
604
604
|
for (let n of e) {
|
|
605
605
|
let e = t[t.length - 1];
|
|
@@ -618,65 +618,103 @@ function le(e) {
|
|
|
618
618
|
}
|
|
619
619
|
return t;
|
|
620
620
|
}
|
|
621
|
-
function
|
|
621
|
+
function me(e) {
|
|
622
622
|
return e.some((e) => e.kind === "tool_end" && e.isError || e.kind === "error");
|
|
623
623
|
}
|
|
624
|
-
function
|
|
624
|
+
function he(e, t) {
|
|
625
625
|
return t === void 0 ? [] : e.filter((e) => e.turnSentAt === t && (e.kind === "tool_end" || e.kind === "pseudo_tool_call" || e.kind === "progress")).map((e, t) => ({
|
|
626
626
|
key: `${e.at}-${t}`,
|
|
627
|
-
text:
|
|
628
|
-
toolName:
|
|
627
|
+
text: Y(e),
|
|
628
|
+
toolName: J(e)
|
|
629
629
|
}));
|
|
630
630
|
}
|
|
631
631
|
//#endregion
|
|
632
|
+
//#region src/styles.css?inline
|
|
633
|
+
var ge = "/*! tailwindcss v4.3.3 | MIT License | https://tailwindcss.com */\n@layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--tw-font-weight:initial;--tw-shadow:0 0 #0000;--tw-shadow-color:initial;--tw-shadow-alpha:100%;--tw-inset-shadow:0 0 #0000;--tw-inset-shadow-color:initial;--tw-inset-shadow-alpha:100%;--tw-ring-color:initial;--tw-ring-shadow:0 0 #0000;--tw-inset-ring-color:initial;--tw-inset-ring-shadow:0 0 #0000;--tw-ring-inset:initial;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-offset-shadow:0 0 #0000;--tw-border-style:solid;--tw-leading:initial;--tw-space-y-reverse:0}}}@layer theme{:root,:host{--font-sans:\"Inter\", -apple-system, \"Segoe UI\", Roboto, Arial, sans-serif;--font-mono:ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, \"Liberation Mono\", \"Courier New\", monospace;--color-red-100:oklch(93.6% .032 17.717);--color-green-100:oklch(96.2% .044 156.743);--color-green-700:oklch(52.7% .154 150.069);--color-blue-100:oklch(93.2% .032 255.585);--color-blue-700:oklch(48.8% .243 264.376);--color-purple-100:oklch(94.6% .033 307.174);--color-purple-700:oklch(49.6% .265 301.924);--color-gray-200:oklch(92.8% .006 264.531);--color-gray-400:oklch(70.7% .022 261.325);--color-gray-700:oklch(37.3% .034 259.733);--color-black:#000;--spacing:.25rem;--container-3xl:48rem;--text-xs:.75rem;--text-xs--line-height:calc(1 / .75);--text-sm:.875rem;--text-sm--line-height:calc(1.25 / .875);--text-base:1rem;--text-base--line-height:calc(1.5 / 1);--text-lg:1.125rem;--text-lg--line-height:calc(1.75 / 1.125);--text-xl:1.25rem;--text-xl--line-height:calc(1.75 / 1.25);--font-weight-medium:500;--font-weight-semibold:600;--leading-relaxed:1.625;--radius-md:.375rem;--radius-2xl:1rem;--default-transition-duration:.15s;--default-transition-timing-function:cubic-bezier(.4, 0, .2, 1);--color-bailey-accent:#4f46e5;--color-bailey-bubble-bg:#fff;--color-bailey-error:#d32f2f;--color-bailey-border:#e5e5e5;--color-bailey-surface:#fff;--color-bailey-surface-muted:#f9fafb;--color-bailey-text:#000;--color-bailey-text-secondary:#6b6b6b;--color-bailey-tooltip-bg:#000;--color-bailey-tooltip-text:#fff;--color-bailey-page-bg:#eceef4;--color-bailey-heart:#16a34a}}@layer utilities;.bailey-chat-panel{box-sizing:border-box;background-color:var(--color-bailey-page-bg);height:100%;padding:calc(var(--spacing) * 3);font-family:var(--font-sans);flex-direction:column;display:flex}.bailey-chat-panel-inner{width:100%;min-height:0;max-width:var(--container-3xl);gap:calc(var(--spacing) * 2);flex-direction:column;flex:1;margin-inline:auto;display:flex;overflow-y:auto}.bailey-toolbar-row{justify-content:flex-end;display:flex}.bailey-new-chat-button{cursor:pointer;appearance:none;--tw-border-style:none;font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height));color:var(--color-bailey-accent);background-color:#0000;border-style:none}@media (hover:hover){.bailey-new-chat-button:hover{text-decoration-line:underline}}.bailey-new-chat-button:disabled{cursor:default;opacity:.5;text-decoration-line:none}.bailey-chat-transcript{min-height:0;padding:calc(var(--spacing) * 2);padding-bottom:calc(var(--spacing) * 4);flex:1;overflow-y:auto}.bailey-message-row{margin-bottom:calc(var(--spacing) * 3);justify-content:flex-start;display:flex}.bailey-message-row-user{justify-content:flex-end}.bailey-user-message{flex-direction:column;align-items:flex-end;max-width:75%;display:flex}.bailey-message-meta{margin-bottom:var(--spacing);align-items:center;gap:calc(var(--spacing) * 2);font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height));color:var(--color-bailey-text-secondary);display:flex}.bailey-message-meta-name{--tw-font-weight:var(--font-weight-medium);font-weight:var(--font-weight-medium);color:var(--color-bailey-text)}.bailey-user-bubble{border-radius:var(--radius-2xl);background-color:var(--color-bailey-bubble-bg);max-width:100%;padding-inline:calc(var(--spacing) * 4);padding-block:calc(var(--spacing) * 2);white-space:pre-wrap;color:var(--color-bailey-text);--tw-shadow:0 1px 3px 0 var(--tw-shadow-color,#0000001a), 0 1px 2px -1px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}.bailey-assistant-message{width:100%;padding-inline:var(--spacing)}.bailey-thinking-hint{font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height));color:var(--color-bailey-text-secondary);font-style:italic}.bailey-streaming-hint{margin-top:var(--spacing);font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height));color:var(--color-bailey-text-secondary);font-style:italic;display:block}.bailey-message-actions{margin-top:var(--spacing);align-items:center;gap:var(--spacing);display:flex}.bailey-empty-state{text-align:center;height:100%;font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height));color:var(--color-bailey-text-secondary);justify-content:center;align-items:center;display:flex}.bailey-suggestions{gap:calc(var(--spacing) * 3);padding:calc(var(--spacing) * 2);flex-direction:column;display:flex}.bailey-suggestions-title{padding-inline:var(--spacing);font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height));--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold);color:var(--color-bailey-text)}.bailey-suggestion-card{cursor:pointer;appearance:none;justify-content:space-between;align-items:center;gap:calc(var(--spacing) * 2);border-radius:var(--radius-2xl);--tw-border-style:none;background-color:var(--color-bailey-surface);padding-inline:calc(var(--spacing) * 4);padding-block:calc(var(--spacing) * 3);text-align:left;font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height));color:var(--color-bailey-text);--tw-shadow:0 1px 3px 0 var(--tw-shadow-color,#0000001a), 0 1px 2px -1px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow);transition-property:box-shadow;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration));border-style:none;display:flex}@media (hover:hover){.bailey-suggestion-card:hover{--tw-shadow:0 4px 6px -1px var(--tw-shadow-color,#0000001a), 0 2px 4px -2px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}}.bailey-suggestion-icon{height:calc(var(--spacing) * 4);width:calc(var(--spacing) * 4);color:var(--color-bailey-text-secondary);flex-shrink:0}.bailey-privacy-note{border-top-style:var(--tw-border-style);border-top-width:1px;border-color:var(--color-bailey-border);padding-inline:calc(var(--spacing) * 4);padding-top:calc(var(--spacing) * 3);padding-bottom:var(--spacing);text-align:center;font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height));color:var(--color-bailey-text-secondary)}.bailey-privacy-note a{color:var(--color-bailey-text-secondary);text-decoration-line:underline}.bailey-activity-line{margin-bottom:calc(var(--spacing) * 2);align-items:center;gap:calc(var(--spacing) * 2);font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height));color:var(--color-bailey-text-secondary);display:flex}.bailey-activity-icon{height:calc(var(--spacing) * 4);width:calc(var(--spacing) * 4);color:var(--color-bailey-accent);flex-shrink:0}.bailey-error-banner{margin-bottom:calc(var(--spacing) * 2);justify-content:space-between;align-items:center;gap:calc(var(--spacing) * 2);border-radius:var(--radius-md);border-style:var(--tw-border-style);border-width:1px;border-color:var(--color-bailey-error);padding-inline:calc(var(--spacing) * 3);padding-block:calc(var(--spacing) * 2);color:var(--color-bailey-error);display:flex}.bailey-retry-button{cursor:pointer;appearance:none;--tw-border-style:none;font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height));--tw-font-weight:var(--font-weight-medium);font-weight:var(--font-weight-medium);background-color:#0000;border-style:none;text-decoration-line:underline}.bailey-error-actions{align-items:center;gap:calc(var(--spacing) * 2);display:flex}.bailey-dismiss-button{cursor:pointer;appearance:none;--tw-border-style:none;color:var(--color-bailey-error);background-color:#0000;border-style:none}@media (hover:hover){.bailey-dismiss-button:hover{opacity:.7}}.bailey-input-row{align-items:center;gap:calc(var(--spacing) * 2);border-style:var(--tw-border-style);border-width:1px;border-color:var(--color-bailey-border);background-color:var(--color-bailey-surface);padding-inline:calc(var(--spacing) * 2);padding-block:calc(var(--spacing) * 1.5);--tw-shadow:0 1px 3px 0 var(--tw-shadow-color,#0000001a), 0 1px 2px -1px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow);border-radius:2147483647px;display:flex}.bailey-input-row:focus-within{border-color:var(--color-bailey-accent)}.bailey-input{--tw-border-style:none;min-width:0;padding-inline:calc(var(--spacing) * 3);padding-block:calc(var(--spacing) * 2);--tw-outline-style:none;background-color:#0000;border-style:none;outline-style:none;flex:1}.bailey-input:disabled{opacity:.5}.bailey-send-button,.bailey-stop-button{cursor:pointer;appearance:none;background-color:#0000;border-radius:2147483647px;flex-shrink:0;justify-content:center;align-items:center;display:flex}:is(.bailey-send-button,.bailey-stop-button):disabled{cursor:default;opacity:.4}.bailey-send-button{height:calc(var(--spacing) * 9);width:calc(var(--spacing) * 9);--tw-border-style:none;color:var(--color-bailey-heart);border-style:none}@media (hover:hover){.bailey-send-button:hover{background-color:#16a34a1a}@supports (color:color-mix(in lab, red, red)){.bailey-send-button:hover{background-color:color-mix(in oklab, var(--color-bailey-heart) 10%, transparent)}}}.bailey-send-icon{height:calc(var(--spacing) * 5);width:calc(var(--spacing) * 5)}.bailey-stop-button{height:calc(var(--spacing) * 9);width:calc(var(--spacing) * 9);--tw-border-style:none;color:var(--color-bailey-error);border-style:none}@media (hover:hover){.bailey-stop-button:hover{background-color:#d32f2f1a}@supports (color:color-mix(in lab, red, red)){.bailey-stop-button:hover{background-color:color-mix(in oklab, var(--color-bailey-error) 10%, transparent)}}}.bailey-stop-icon{height:calc(var(--spacing) * 4);width:calc(var(--spacing) * 4)}.bailey-copy-button{height:calc(var(--spacing) * 7);width:calc(var(--spacing) * 7);cursor:pointer;appearance:none;--tw-border-style:none;color:var(--color-bailey-text-secondary);background-color:#0000;border-style:none;border-radius:2147483647px;justify-content:center;align-items:center;display:flex}@media (hover:hover){.bailey-copy-button:hover{background-color:#0000000d}@supports (color:color-mix(in lab, red, red)){.bailey-copy-button:hover{background-color:color-mix(in oklab, var(--color-black) 5%, transparent)}}.bailey-copy-button:hover{color:var(--color-bailey-text)}}.bailey-copy-icon{height:calc(var(--spacing) * 4);width:calc(var(--spacing) * 4)}.bailey-tooltip-content{padding-inline:calc(var(--spacing) * 2);padding-block:var(--spacing);font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height));background-color:var(--color-bailey-tooltip-bg,#000);color:var(--color-bailey-tooltip-text,#fff);border-radius:.25rem}.bailey-tooltip-arrow{fill:var(--color-bailey-tooltip-bg,#000)}.bailey-markdown-content table{border-collapse:collapse;width:100%;font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height))}.bailey-markdown-content th{background-color:var(--color-bailey-surface-muted);padding-inline:calc(var(--spacing) * 3);padding-block:calc(var(--spacing) * 2);text-align:left;--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold)}.bailey-markdown-content td{border-style:var(--tw-border-style);border-width:1px;border-color:var(--color-bailey-border);padding-inline:calc(var(--spacing) * 3);padding-block:calc(var(--spacing) * 2);vertical-align:top}.bailey-markdown-content tr:nth-child(2n){background-color:var(--color-bailey-surface-muted)}.bailey-markdown-content{font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height));--tw-leading:var(--leading-relaxed);line-height:var(--leading-relaxed)}.bailey-markdown-content>:first-child{margin-top:0}.bailey-markdown-content>:last-child{margin-bottom:0}.bailey-markdown-content p{margin-block:calc(var(--spacing) * 2)}.bailey-markdown-content h1{margin-top:calc(var(--spacing) * 4);margin-bottom:calc(var(--spacing) * 2);font-size:var(--text-xl);line-height:var(--tw-leading,var(--text-xl--line-height));--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold)}.bailey-markdown-content h2{margin-top:calc(var(--spacing) * 4);margin-bottom:calc(var(--spacing) * 2);font-size:var(--text-lg);line-height:var(--tw-leading,var(--text-lg--line-height));--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold)}.bailey-markdown-content h3{margin-top:calc(var(--spacing) * 3);margin-bottom:calc(var(--spacing) * 1.5);font-size:var(--text-base);line-height:var(--tw-leading,var(--text-base--line-height));--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold)}.bailey-markdown-content h4,.bailey-markdown-content h5,.bailey-markdown-content h6{margin-top:calc(var(--spacing) * 3);margin-bottom:calc(var(--spacing) * 1.5);font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height));--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold)}.bailey-markdown-content ul{margin-block:calc(var(--spacing) * 2);list-style-type:disc}:where(.bailey-markdown-content ul>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(var(--spacing) * var(--tw-space-y-reverse));margin-block-end:calc(var(--spacing) * calc(1 - var(--tw-space-y-reverse)))}.bailey-markdown-content ul{padding-left:calc(var(--spacing) * 5)}.bailey-markdown-content ol{margin-block:calc(var(--spacing) * 2);list-style-type:decimal}:where(.bailey-markdown-content ol>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(var(--spacing) * var(--tw-space-y-reverse));margin-block-end:calc(var(--spacing) * calc(1 - var(--tw-space-y-reverse)))}.bailey-markdown-content ol{padding-left:calc(var(--spacing) * 5)}.bailey-markdown-content a{color:var(--color-bailey-accent);text-underline-offset:2px;text-decoration-line:underline}.bailey-markdown-content code{background-color:var(--color-bailey-surface-muted);padding-inline:var(--spacing);padding-block:calc(var(--spacing) * .5);font-family:var(--font-mono);border-radius:.25rem;font-size:.85em}.bailey-markdown-content pre{margin-block:calc(var(--spacing) * 2);border-radius:var(--radius-md);background-color:var(--color-bailey-surface-muted);padding:calc(var(--spacing) * 2);overflow-x:auto}.bailey-markdown-content pre code{background-color:#0000;padding:0}.bailey-markdown-content blockquote{margin-block:calc(var(--spacing) * 2);border-left-style:var(--tw-border-style);border-left-width:2px;border-color:var(--color-bailey-border);padding-left:calc(var(--spacing) * 3);color:var(--color-bailey-text-secondary);font-style:italic}.bailey-markdown-content hr{margin-block:calc(var(--spacing) * 3);border-color:var(--color-bailey-border)}.bailey-trace-panel{margin-bottom:calc(var(--spacing) * 2)}.bailey-trace-toggle-row{align-items:center;gap:calc(var(--spacing) * 2);display:flex}.bailey-trace-toggle{cursor:pointer;appearance:none;--tw-border-style:none;font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height));color:var(--color-bailey-accent);background-color:#0000;border-style:none}@media (hover:hover){.bailey-trace-toggle:hover{text-decoration-line:underline}}.bailey-trace-toggle-error{color:var(--color-bailey-error)}.bailey-trace-summary{font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height));color:var(--color-bailey-text-secondary)}.bailey-trace-summary-error{color:var(--color-bailey-error)}.bailey-trace-body{margin-top:var(--spacing);max-height:calc(var(--spacing) * 80);overflow-y:auto}.bailey-trace-actions-row{justify-content:flex-end;gap:calc(var(--spacing) * 3);display:flex}.bailey-trace-copy-button{cursor:pointer;appearance:none;--tw-border-style:none;font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height));color:var(--color-bailey-accent);background-color:#0000;border-style:none;text-decoration-line:underline}@media (hover:hover){.bailey-trace-copy-button:hover{text-decoration-line:none}}.bailey-trace-request-details{margin-bottom:var(--spacing);border-radius:var(--radius-md);border-style:var(--tw-border-style);border-width:1px;border-color:var(--color-bailey-border);background-color:var(--color-bailey-surface);padding:calc(var(--spacing) * 2)}.bailey-trace-request-meta{font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height));color:var(--color-bailey-text-secondary);display:block}.bailey-trace-rows{gap:var(--spacing);flex-direction:column;display:flex}.bailey-trace-row{border-radius:var(--radius-md);border-style:var(--tw-border-style);border-width:1px;border-color:var(--color-bailey-border);padding-inline:calc(var(--spacing) * 2);padding-block:var(--spacing);font-family:var(--font-mono);font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height))}.bailey-trace-row-header{align-items:center;gap:calc(var(--spacing) * 2);flex-wrap:wrap;display:flex}.bailey-trace-row-time{color:var(--color-bailey-text-secondary)}.bailey-trace-row-gap{color:var(--color-gray-400)}.bailey-trace-row-summary{word-break:break-all}.bailey-trace-chip{padding-inline:calc(var(--spacing) * 1.5);padding-block:calc(var(--spacing) * .5);--tw-font-weight:var(--font-weight-semibold);font-size:.65rem;font-weight:var(--font-weight-semibold);border-radius:.25rem}.bailey-trace-chip-default{background-color:var(--color-gray-200);color:var(--color-gray-700)}.bailey-trace-chip-info{background-color:var(--color-blue-100);color:var(--color-blue-700)}.bailey-trace-chip-success{background-color:var(--color-green-100);color:var(--color-green-700)}.bailey-trace-chip-secondary{background-color:var(--color-purple-100);color:var(--color-purple-700)}.bailey-trace-chip-error{background-color:var(--color-red-100);color:var(--color-bailey-error)}.bailey-trace-disclosure{margin-top:var(--spacing)}.bailey-trace-disclosure-summary{cursor:pointer;color:var(--color-bailey-text-secondary);font-size:.7rem}.bailey-trace-disclosure-actions{margin-top:var(--spacing);justify-content:flex-end;display:flex}.bailey-trace-disclosure-content{margin-top:var(--spacing);max-height:calc(var(--spacing) * 48);border-style:var(--tw-border-style);border-width:1px;border-color:var(--color-bailey-border);background-color:var(--color-bailey-surface-muted);padding:calc(var(--spacing) * 1.5);word-break:break-all;white-space:pre-wrap;border-radius:.25rem;font-size:.7rem;overflow:auto}.bailey-trace-group{border-radius:var(--radius-md);border-style:var(--tw-border-style);border-width:1px;border-color:var(--color-bailey-border);padding-inline:calc(var(--spacing) * 2);padding-block:var(--spacing)}.bailey-trace-group-summary{cursor:pointer;font-family:var(--font-mono);font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height))}.bailey-trace-group-failed{margin-left:var(--spacing);font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height));color:var(--color-bailey-error)}@property --tw-font-weight{syntax:\"*\";inherits:false}@property --tw-shadow{syntax:\"*\";inherits:false;initial-value:0 0 #0000}@property --tw-shadow-color{syntax:\"*\";inherits:false}@property --tw-shadow-alpha{syntax:\"<percentage>\";inherits:false;initial-value:100%}@property --tw-inset-shadow{syntax:\"*\";inherits:false;initial-value:0 0 #0000}@property --tw-inset-shadow-color{syntax:\"*\";inherits:false}@property --tw-inset-shadow-alpha{syntax:\"<percentage>\";inherits:false;initial-value:100%}@property --tw-ring-color{syntax:\"*\";inherits:false}@property --tw-ring-shadow{syntax:\"*\";inherits:false;initial-value:0 0 #0000}@property --tw-inset-ring-color{syntax:\"*\";inherits:false}@property --tw-inset-ring-shadow{syntax:\"*\";inherits:false;initial-value:0 0 #0000}@property --tw-ring-inset{syntax:\"*\";inherits:false}@property --tw-ring-offset-width{syntax:\"<length>\";inherits:false;initial-value:0}@property --tw-ring-offset-color{syntax:\"*\";inherits:false;initial-value:#fff}@property --tw-ring-offset-shadow{syntax:\"*\";inherits:false;initial-value:0 0 #0000}@property --tw-border-style{syntax:\"*\";inherits:false;initial-value:solid}@property --tw-leading{syntax:\"*\";inherits:false}@property --tw-space-y-reverse{syntax:\"*\";inherits:false;initial-value:0}", _e = t(void 0), ve = /:root\s*,\s*:host\s*\{/, ye = ".bailey-chat-panel{";
|
|
634
|
+
function be(e) {
|
|
635
|
+
let t = e.match(new RegExp(ve, "g"))?.length ?? 0;
|
|
636
|
+
if (t !== 1) throw Error(`Expected exactly one ":root, :host {" rule in the compiled styles.css, found ${t}. Tailwind likely changed how @theme compiles — update this rewrite (and its sibling, scripts/scope-theme-vars.js) before shipping.`);
|
|
637
|
+
return e.replace(ve, ye);
|
|
638
|
+
}
|
|
639
|
+
var xe = be(ge), X = "data-source", Z = "baileyai-chat-ui", Q = /* @__PURE__ */ new WeakMap();
|
|
640
|
+
function Se(e) {
|
|
641
|
+
let t = e.getRootNode();
|
|
642
|
+
return t instanceof ShadowRoot ? t : document;
|
|
643
|
+
}
|
|
644
|
+
function Ce(e) {
|
|
645
|
+
let t = e instanceof ShadowRoot ? e : document.head, n = Q.get(e) ?? 0;
|
|
646
|
+
if (n === 0 && !t.querySelector(`style[${X}="${Z}"]`)) {
|
|
647
|
+
let e = document.createElement("style");
|
|
648
|
+
e.setAttribute(X, Z), e.textContent = xe, t.appendChild(e);
|
|
649
|
+
}
|
|
650
|
+
return Q.set(e, n + 1), () => {
|
|
651
|
+
let n = (Q.get(e) ?? 1) - 1;
|
|
652
|
+
n <= 0 ? (Q.delete(e), t.querySelector(`style[${X}="${Z}"]`)?.remove()) : Q.set(e, n);
|
|
653
|
+
};
|
|
654
|
+
}
|
|
655
|
+
function we(e, t = !1) {
|
|
656
|
+
let [n, r] = l(null);
|
|
657
|
+
return o(() => {
|
|
658
|
+
if (t) return;
|
|
659
|
+
let n = e.current;
|
|
660
|
+
if (!n) return;
|
|
661
|
+
let i = Se(n);
|
|
662
|
+
return r(i), Ce(i);
|
|
663
|
+
}, [t, e]), n;
|
|
664
|
+
}
|
|
665
|
+
function Te(e) {
|
|
666
|
+
let t = i(_e), n = t !== void 0, r = we(e, n);
|
|
667
|
+
return n ? t : r;
|
|
668
|
+
}
|
|
669
|
+
//#endregion
|
|
632
670
|
//#region src/ui/markdown.tsx
|
|
633
|
-
function
|
|
671
|
+
function Ee({ renderTable: t, renderChart: n } = {}) {
|
|
634
672
|
return {
|
|
635
|
-
a: ({ href: t, children: n }) => !t || !e(t) ? /* @__PURE__ */
|
|
673
|
+
a: ({ href: t, children: n }) => !t || !e(t) ? /* @__PURE__ */ m(p, { children: n }) : /* @__PURE__ */ m("a", {
|
|
636
674
|
href: t,
|
|
637
675
|
target: "_blank",
|
|
638
676
|
rel: "noopener noreferrer",
|
|
639
677
|
children: n
|
|
640
678
|
}),
|
|
641
679
|
table: ({ node: n, children: r }) => {
|
|
642
|
-
let i = n &&
|
|
643
|
-
if (i &&
|
|
680
|
+
let i = n && B(n);
|
|
681
|
+
if (i && V(i.rows) && t) {
|
|
644
682
|
let n = i.rows.map((t) => t.map((t) => t.href && !e(t.href) ? { text: t.text } : t));
|
|
645
|
-
return /* @__PURE__ */
|
|
683
|
+
return /* @__PURE__ */ m(p, { children: t({
|
|
646
684
|
headers: i.headers,
|
|
647
685
|
rows: n
|
|
648
686
|
}) });
|
|
649
687
|
}
|
|
650
|
-
return /* @__PURE__ */
|
|
688
|
+
return /* @__PURE__ */ m("table", { children: r });
|
|
651
689
|
},
|
|
652
690
|
pre: ({ children: e }) => {
|
|
653
691
|
let t = (Array.isArray(e) ? e[0] : e)?.props;
|
|
654
692
|
if ((t?.className?.split(" ") ?? []).includes("language-chartjs") && n) {
|
|
655
|
-
let e = t?.children, r =
|
|
656
|
-
if (r) return /* @__PURE__ */
|
|
693
|
+
let e = t?.children, r = re(Array.isArray(e) ? e.join("") : String(e ?? ""));
|
|
694
|
+
if (r) return /* @__PURE__ */ m(p, { children: n(r) });
|
|
657
695
|
}
|
|
658
|
-
return /* @__PURE__ */
|
|
696
|
+
return /* @__PURE__ */ m("pre", { children: e });
|
|
659
697
|
}
|
|
660
698
|
};
|
|
661
699
|
}
|
|
662
700
|
//#endregion
|
|
663
701
|
//#region src/ui/icons.tsx
|
|
664
|
-
function
|
|
665
|
-
return /* @__PURE__ */
|
|
702
|
+
function De({ className: e }) {
|
|
703
|
+
return /* @__PURE__ */ m("svg", {
|
|
666
704
|
viewBox: "0 0 24 24",
|
|
667
705
|
fill: "currentColor",
|
|
668
706
|
className: e,
|
|
669
707
|
"aria-hidden": "true",
|
|
670
|
-
children: /* @__PURE__ */
|
|
708
|
+
children: /* @__PURE__ */ m("path", { d: "M12 20.3s-7.6-4.7-10-9.4C.4 7.7 1.7 4 5.2 3.1c2.2-.6 4.4.4 5.5 2.2 1.2-1.8 3.4-2.8 5.6-2.2 3.5.9 4.8 4.6 3.2 7.8-2.4 4.7-10 9.4-10 9.4z" })
|
|
671
709
|
});
|
|
672
710
|
}
|
|
673
|
-
function
|
|
674
|
-
return /* @__PURE__ */
|
|
711
|
+
function Oe({ className: e }) {
|
|
712
|
+
return /* @__PURE__ */ m("svg", {
|
|
675
713
|
viewBox: "0 0 24 24",
|
|
676
714
|
fill: "currentColor",
|
|
677
715
|
className: e,
|
|
678
716
|
"aria-hidden": "true",
|
|
679
|
-
children: /* @__PURE__ */
|
|
717
|
+
children: /* @__PURE__ */ m("rect", {
|
|
680
718
|
x: "6",
|
|
681
719
|
y: "6",
|
|
682
720
|
width: "12",
|
|
@@ -685,8 +723,8 @@ function pe({ className: e }) {
|
|
|
685
723
|
})
|
|
686
724
|
});
|
|
687
725
|
}
|
|
688
|
-
function
|
|
689
|
-
return /* @__PURE__ */
|
|
726
|
+
function ke({ className: e }) {
|
|
727
|
+
return /* @__PURE__ */ h("svg", {
|
|
690
728
|
viewBox: "0 0 24 24",
|
|
691
729
|
fill: "none",
|
|
692
730
|
stroke: "currentColor",
|
|
@@ -695,11 +733,11 @@ function me({ className: e }) {
|
|
|
695
733
|
strokeLinejoin: "round",
|
|
696
734
|
className: e,
|
|
697
735
|
"aria-hidden": "true",
|
|
698
|
-
children: [/* @__PURE__ */
|
|
736
|
+
children: [/* @__PURE__ */ m("path", { d: "M7 17 17 7" }), /* @__PURE__ */ m("path", { d: "M9 7h8v8" })]
|
|
699
737
|
});
|
|
700
738
|
}
|
|
701
|
-
function
|
|
702
|
-
return /* @__PURE__ */
|
|
739
|
+
function Ae({ className: e }) {
|
|
740
|
+
return /* @__PURE__ */ h("svg", {
|
|
703
741
|
viewBox: "0 0 24 24",
|
|
704
742
|
fill: "none",
|
|
705
743
|
stroke: "currentColor",
|
|
@@ -708,17 +746,17 @@ function he({ className: e }) {
|
|
|
708
746
|
strokeLinejoin: "round",
|
|
709
747
|
className: e,
|
|
710
748
|
"aria-hidden": "true",
|
|
711
|
-
children: [/* @__PURE__ */
|
|
749
|
+
children: [/* @__PURE__ */ m("rect", {
|
|
712
750
|
x: "8",
|
|
713
751
|
y: "8",
|
|
714
752
|
width: "12",
|
|
715
753
|
height: "12",
|
|
716
754
|
rx: "2"
|
|
717
|
-
}), /* @__PURE__ */
|
|
755
|
+
}), /* @__PURE__ */ m("path", { d: "M16 8V6a2 2 0 0 0-2-2H6a2 2 0 0 0-2 2v8a2 2 0 0 0 2 2h2" })]
|
|
718
756
|
});
|
|
719
757
|
}
|
|
720
|
-
function
|
|
721
|
-
return /* @__PURE__ */
|
|
758
|
+
function je({ className: e }) {
|
|
759
|
+
return /* @__PURE__ */ m("svg", {
|
|
722
760
|
viewBox: "0 0 24 24",
|
|
723
761
|
fill: "none",
|
|
724
762
|
stroke: "currentColor",
|
|
@@ -727,11 +765,11 @@ function ge({ className: e }) {
|
|
|
727
765
|
strokeLinejoin: "round",
|
|
728
766
|
className: e,
|
|
729
767
|
"aria-hidden": "true",
|
|
730
|
-
children: /* @__PURE__ */
|
|
768
|
+
children: /* @__PURE__ */ m("path", { d: "M5 12.5 9.5 17 19 7" })
|
|
731
769
|
});
|
|
732
770
|
}
|
|
733
|
-
function
|
|
734
|
-
return /* @__PURE__ */
|
|
771
|
+
function Me({ className: e }) {
|
|
772
|
+
return /* @__PURE__ */ h("svg", {
|
|
735
773
|
viewBox: "0 0 24 24",
|
|
736
774
|
fill: "none",
|
|
737
775
|
stroke: "currentColor",
|
|
@@ -740,28 +778,29 @@ function _e({ className: e }) {
|
|
|
740
778
|
strokeLinejoin: "round",
|
|
741
779
|
className: e,
|
|
742
780
|
"aria-hidden": "true",
|
|
743
|
-
children: [/* @__PURE__ */
|
|
781
|
+
children: [/* @__PURE__ */ m("circle", {
|
|
744
782
|
cx: "12",
|
|
745
783
|
cy: "12",
|
|
746
784
|
r: "9"
|
|
747
|
-
}), /* @__PURE__ */
|
|
785
|
+
}), /* @__PURE__ */ m("path", { d: "M8.5 12.5 11 15l4.5-5.5" })]
|
|
748
786
|
});
|
|
749
787
|
}
|
|
750
788
|
//#endregion
|
|
751
789
|
//#region src/ui/CopyMarkdownButton.tsx
|
|
752
|
-
var
|
|
753
|
-
function
|
|
754
|
-
let [
|
|
755
|
-
return
|
|
756
|
-
|
|
757
|
-
}, []), /* @__PURE__ */
|
|
790
|
+
var Ne = 1500;
|
|
791
|
+
function Pe({ markdown: e, className: t, ariaLabel: n = "copy response as markdown", tooltipDefaultText: r = "Copy as markdown", tooltipCopiedText: i = "Copied!" }) {
|
|
792
|
+
let [o, s] = l(!1), [u, d] = l(!1), p = c(null), g = c(null), _ = Te(g);
|
|
793
|
+
return a(() => () => {
|
|
794
|
+
p.current !== null && clearTimeout(p.current);
|
|
795
|
+
}, []), /* @__PURE__ */ m(f.Provider, {
|
|
758
796
|
delayDuration: 200,
|
|
759
|
-
children: /* @__PURE__ */ f
|
|
760
|
-
open:
|
|
761
|
-
onOpenChange:
|
|
762
|
-
children: [/* @__PURE__ */
|
|
797
|
+
children: /* @__PURE__ */ h(f.Root, {
|
|
798
|
+
open: o || u,
|
|
799
|
+
onOpenChange: d,
|
|
800
|
+
children: [/* @__PURE__ */ m(f.Trigger, {
|
|
763
801
|
asChild: !0,
|
|
764
|
-
children: /* @__PURE__ */
|
|
802
|
+
children: /* @__PURE__ */ m("button", {
|
|
803
|
+
ref: g,
|
|
765
804
|
type: "button",
|
|
766
805
|
onClick: async () => {
|
|
767
806
|
try {
|
|
@@ -769,36 +808,39 @@ function ye({ markdown: e, className: t, ariaLabel: n = "copy response as markdo
|
|
|
769
808
|
} catch {
|
|
770
809
|
return;
|
|
771
810
|
}
|
|
772
|
-
|
|
811
|
+
s(!0), p.current !== null && clearTimeout(p.current), p.current = setTimeout(() => s(!1), Ne);
|
|
773
812
|
},
|
|
774
813
|
"aria-label": n,
|
|
775
814
|
className: `bailey-copy-button${t ? ` ${t}` : ""}`,
|
|
776
|
-
children:
|
|
815
|
+
children: m(o ? je : Ae, { className: "bailey-copy-icon" })
|
|
816
|
+
})
|
|
817
|
+
}), /* @__PURE__ */ m(f.Portal, {
|
|
818
|
+
container: _ instanceof ShadowRoot ? _ : void 0,
|
|
819
|
+
children: /* @__PURE__ */ h(f.Content, {
|
|
820
|
+
side: "top",
|
|
821
|
+
className: "bailey-tooltip-content",
|
|
822
|
+
children: [o ? i : r, /* @__PURE__ */ m(f.Arrow, { className: "bailey-tooltip-arrow" })]
|
|
777
823
|
})
|
|
778
|
-
})
|
|
779
|
-
side: "top",
|
|
780
|
-
className: "bailey-tooltip-content",
|
|
781
|
-
children: [c ? s : i, /* @__PURE__ */ d(l.Arrow, { className: "bailey-tooltip-arrow" })]
|
|
782
|
-
}) })]
|
|
824
|
+
})]
|
|
783
825
|
})
|
|
784
826
|
});
|
|
785
827
|
}
|
|
786
828
|
//#endregion
|
|
787
829
|
//#region src/ui/BaileyTracePanel.tsx
|
|
788
|
-
async function
|
|
830
|
+
async function Fe(e) {
|
|
789
831
|
try {
|
|
790
832
|
await navigator.clipboard.writeText(e);
|
|
791
833
|
} catch {}
|
|
792
834
|
}
|
|
793
|
-
function
|
|
794
|
-
return /* @__PURE__ */
|
|
835
|
+
function Ie({ text: e, label: t = "Copy" }) {
|
|
836
|
+
return /* @__PURE__ */ m("button", {
|
|
795
837
|
type: "button",
|
|
796
|
-
onClick: () =>
|
|
838
|
+
onClick: () => Fe(e),
|
|
797
839
|
className: "bailey-trace-copy-button",
|
|
798
840
|
children: t
|
|
799
841
|
});
|
|
800
842
|
}
|
|
801
|
-
function
|
|
843
|
+
function Le(e) {
|
|
802
844
|
if (e.failed || e.kind === "error") return "bailey-trace-chip bailey-trace-chip-error";
|
|
803
845
|
switch (e.kind) {
|
|
804
846
|
case "tool_start": return "bailey-trace-chip bailey-trace-chip-info";
|
|
@@ -807,74 +849,74 @@ function Se(e) {
|
|
|
807
849
|
default: return "bailey-trace-chip bailey-trace-chip-default";
|
|
808
850
|
}
|
|
809
851
|
}
|
|
810
|
-
function
|
|
811
|
-
return /* @__PURE__ */
|
|
852
|
+
function $({ label: e, content: t, copyable: n }) {
|
|
853
|
+
return /* @__PURE__ */ h("details", {
|
|
812
854
|
className: "bailey-trace-disclosure",
|
|
813
855
|
children: [
|
|
814
|
-
/* @__PURE__ */
|
|
856
|
+
/* @__PURE__ */ m("summary", {
|
|
815
857
|
className: "bailey-trace-disclosure-summary",
|
|
816
858
|
children: e
|
|
817
859
|
}),
|
|
818
|
-
n && /* @__PURE__ */
|
|
860
|
+
n && /* @__PURE__ */ m("div", {
|
|
819
861
|
className: "bailey-trace-disclosure-actions",
|
|
820
|
-
children: /* @__PURE__ */
|
|
862
|
+
children: /* @__PURE__ */ m(Ie, { text: t })
|
|
821
863
|
}),
|
|
822
|
-
/* @__PURE__ */
|
|
864
|
+
/* @__PURE__ */ m("pre", {
|
|
823
865
|
className: "bailey-trace-disclosure-content",
|
|
824
866
|
children: t
|
|
825
867
|
})
|
|
826
868
|
]
|
|
827
869
|
});
|
|
828
870
|
}
|
|
829
|
-
function
|
|
830
|
-
return /* @__PURE__ */
|
|
871
|
+
function Re({ row: e }) {
|
|
872
|
+
return /* @__PURE__ */ h("div", {
|
|
831
873
|
className: "bailey-trace-row",
|
|
832
874
|
children: [
|
|
833
|
-
/* @__PURE__ */
|
|
875
|
+
/* @__PURE__ */ h("div", {
|
|
834
876
|
className: "bailey-trace-row-header",
|
|
835
877
|
children: [
|
|
836
|
-
/* @__PURE__ */
|
|
878
|
+
/* @__PURE__ */ m("span", {
|
|
837
879
|
className: "bailey-trace-row-time",
|
|
838
880
|
children: e.time
|
|
839
881
|
}),
|
|
840
|
-
/* @__PURE__ */
|
|
882
|
+
/* @__PURE__ */ m("span", {
|
|
841
883
|
className: "bailey-trace-row-gap",
|
|
842
884
|
title: "Time since the previous event",
|
|
843
|
-
children:
|
|
885
|
+
children: ue(e.gapMs)
|
|
844
886
|
}),
|
|
845
|
-
/* @__PURE__ */
|
|
846
|
-
className:
|
|
887
|
+
/* @__PURE__ */ m("span", {
|
|
888
|
+
className: Le(e),
|
|
847
889
|
children: e.label
|
|
848
890
|
}),
|
|
849
|
-
/* @__PURE__ */
|
|
891
|
+
/* @__PURE__ */ m("span", {
|
|
850
892
|
className: "bailey-trace-row-summary",
|
|
851
893
|
children: e.summary
|
|
852
894
|
})
|
|
853
895
|
]
|
|
854
896
|
}),
|
|
855
|
-
e.argsDetail && /* @__PURE__ */
|
|
897
|
+
e.argsDetail && /* @__PURE__ */ m($, {
|
|
856
898
|
label: "args",
|
|
857
899
|
content: e.argsDetail
|
|
858
900
|
}),
|
|
859
|
-
e.outputDetail && /* @__PURE__ */
|
|
901
|
+
e.outputDetail && /* @__PURE__ */ m($, {
|
|
860
902
|
label: "output",
|
|
861
903
|
content: e.outputDetail
|
|
862
904
|
}),
|
|
863
|
-
e.rawDetail && /* @__PURE__ */
|
|
905
|
+
e.rawDetail && /* @__PURE__ */ m($, {
|
|
864
906
|
label: "raw",
|
|
865
907
|
content: e.rawDetail
|
|
866
908
|
})
|
|
867
909
|
]
|
|
868
910
|
});
|
|
869
911
|
}
|
|
870
|
-
function
|
|
912
|
+
function ze(e, t) {
|
|
871
913
|
if (e.chunkCount === 0) return "Streamed: no chunks received";
|
|
872
914
|
if (e.chunkCount === 1 || e.firstChunkAt === null) return "Streamed: 1 chunk (not incremental)";
|
|
873
915
|
let n = e.firstChunkAt - t, r = (e.lastChunkAt ?? e.firstChunkAt) - e.firstChunkAt;
|
|
874
916
|
return `Streamed: ${e.chunkCount} chunks · first chunk after ${n}ms · spread over ${(r / 1e3).toFixed(1)}s`;
|
|
875
917
|
}
|
|
876
|
-
function
|
|
877
|
-
let t =
|
|
918
|
+
function Be({ request: e }) {
|
|
919
|
+
let t = s(() => JSON.stringify({
|
|
878
920
|
model: e.model,
|
|
879
921
|
instructions: e.systemPrompt,
|
|
880
922
|
input: e.messages,
|
|
@@ -882,10 +924,10 @@ function we({ request: e }) {
|
|
|
882
924
|
tools: e.tools,
|
|
883
925
|
toolChoice: e.toolChoice
|
|
884
926
|
}, null, 2), [e]);
|
|
885
|
-
return /* @__PURE__ */
|
|
927
|
+
return /* @__PURE__ */ h("div", {
|
|
886
928
|
className: "bailey-trace-request-details",
|
|
887
929
|
children: [
|
|
888
|
-
/* @__PURE__ */
|
|
930
|
+
/* @__PURE__ */ h("span", {
|
|
889
931
|
className: "bailey-trace-request-meta",
|
|
890
932
|
children: [
|
|
891
933
|
"Last request — ",
|
|
@@ -895,26 +937,26 @@ function we({ request: e }) {
|
|
|
895
937
|
e.requestId ? ` · ${e.requestId}` : ""
|
|
896
938
|
]
|
|
897
939
|
}),
|
|
898
|
-
/* @__PURE__ */
|
|
940
|
+
/* @__PURE__ */ m("span", {
|
|
899
941
|
className: "bailey-trace-request-meta",
|
|
900
|
-
children:
|
|
942
|
+
children: ze(e.streamStats, e.sentAt)
|
|
901
943
|
}),
|
|
902
|
-
/* @__PURE__ */
|
|
944
|
+
/* @__PURE__ */ m($, {
|
|
903
945
|
label: `System prompt (${e.systemPrompt.length.toLocaleString()} chars)`,
|
|
904
946
|
content: e.systemPrompt,
|
|
905
947
|
copyable: !0
|
|
906
948
|
}),
|
|
907
|
-
/* @__PURE__ */
|
|
949
|
+
/* @__PURE__ */ m($, {
|
|
908
950
|
label: `Messages (${e.messages.length})`,
|
|
909
951
|
content: JSON.stringify(e.messages, null, 2),
|
|
910
952
|
copyable: !0
|
|
911
953
|
}),
|
|
912
|
-
e.response && /* @__PURE__ */
|
|
954
|
+
e.response && /* @__PURE__ */ m($, {
|
|
913
955
|
label: `Response (${e.response.content.length.toLocaleString()} chars)`,
|
|
914
956
|
content: e.response.content,
|
|
915
957
|
copyable: !0
|
|
916
958
|
}),
|
|
917
|
-
/* @__PURE__ */
|
|
959
|
+
/* @__PURE__ */ m($, {
|
|
918
960
|
label: "Full payload (JSON)",
|
|
919
961
|
content: t,
|
|
920
962
|
copyable: !0
|
|
@@ -922,43 +964,43 @@ function we({ request: e }) {
|
|
|
922
964
|
]
|
|
923
965
|
});
|
|
924
966
|
}
|
|
925
|
-
function
|
|
926
|
-
let r =
|
|
927
|
-
return /* @__PURE__ */
|
|
967
|
+
function Ve({ events: e, lastRequest: t, onClear: n }) {
|
|
968
|
+
let r = s(() => de(e), [e]), i = s(() => pe(r), [r]), a = s(() => JSON.stringify(e, null, 2), [e]);
|
|
969
|
+
return /* @__PURE__ */ h("div", {
|
|
928
970
|
className: "bailey-trace-body",
|
|
929
971
|
children: [
|
|
930
|
-
/* @__PURE__ */
|
|
972
|
+
/* @__PURE__ */ h("div", {
|
|
931
973
|
className: "bailey-trace-actions-row",
|
|
932
|
-
children: [e.length > 0 && /* @__PURE__ */
|
|
933
|
-
text:
|
|
974
|
+
children: [e.length > 0 && /* @__PURE__ */ m(Ie, {
|
|
975
|
+
text: a,
|
|
934
976
|
label: "Copy trace as JSON"
|
|
935
|
-
}), /* @__PURE__ */
|
|
977
|
+
}), /* @__PURE__ */ m("button", {
|
|
936
978
|
type: "button",
|
|
937
979
|
onClick: n,
|
|
938
980
|
className: "bailey-trace-copy-button",
|
|
939
981
|
children: "Clear"
|
|
940
982
|
})]
|
|
941
983
|
}),
|
|
942
|
-
t && /* @__PURE__ */
|
|
943
|
-
/* @__PURE__ */
|
|
984
|
+
t && /* @__PURE__ */ m(Be, { request: t }),
|
|
985
|
+
/* @__PURE__ */ m("div", {
|
|
944
986
|
className: "bailey-trace-rows",
|
|
945
|
-
children:
|
|
946
|
-
if (e.type === "single") return /* @__PURE__ */
|
|
987
|
+
children: i.map((e, t) => {
|
|
988
|
+
if (e.type === "single") return /* @__PURE__ */ m(Re, { row: e.row }, e.row.key);
|
|
947
989
|
let n = e.rows.filter((e) => e.isToolStart).length;
|
|
948
|
-
if (n <= 1) return /* @__PURE__ */
|
|
990
|
+
if (n <= 1) return /* @__PURE__ */ m("div", {
|
|
949
991
|
className: "bailey-trace-rows",
|
|
950
|
-
children: e.rows.map((e) => /* @__PURE__ */
|
|
992
|
+
children: e.rows.map((e) => /* @__PURE__ */ m(Re, { row: e }, e.key))
|
|
951
993
|
}, `group-${t}`);
|
|
952
994
|
let r = e.rows.filter((e) => e.failed).length;
|
|
953
|
-
return /* @__PURE__ */
|
|
995
|
+
return /* @__PURE__ */ h("details", {
|
|
954
996
|
className: "bailey-trace-group",
|
|
955
|
-
children: [/* @__PURE__ */
|
|
997
|
+
children: [/* @__PURE__ */ h("summary", {
|
|
956
998
|
className: "bailey-trace-group-summary",
|
|
957
999
|
children: [
|
|
958
|
-
/* @__PURE__ */
|
|
1000
|
+
/* @__PURE__ */ m("strong", { children: e.toolName }),
|
|
959
1001
|
" × ",
|
|
960
1002
|
n,
|
|
961
|
-
r > 0 && /* @__PURE__ */
|
|
1003
|
+
r > 0 && /* @__PURE__ */ h("span", {
|
|
962
1004
|
className: "bailey-trace-group-failed",
|
|
963
1005
|
children: [
|
|
964
1006
|
" ",
|
|
@@ -967,9 +1009,9 @@ function Te({ events: e, lastRequest: t, onClear: n }) {
|
|
|
967
1009
|
]
|
|
968
1010
|
})
|
|
969
1011
|
]
|
|
970
|
-
}), /* @__PURE__ */
|
|
1012
|
+
}), /* @__PURE__ */ m("div", {
|
|
971
1013
|
className: "bailey-trace-rows",
|
|
972
|
-
children: e.rows.map((e) => /* @__PURE__ */
|
|
1014
|
+
children: e.rows.map((e) => /* @__PURE__ */ m(Re, { row: e }, e.key))
|
|
973
1015
|
})]
|
|
974
1016
|
}, `group-${t}`);
|
|
975
1017
|
})
|
|
@@ -977,29 +1019,29 @@ function Te({ events: e, lastRequest: t, onClear: n }) {
|
|
|
977
1019
|
]
|
|
978
1020
|
});
|
|
979
1021
|
}
|
|
980
|
-
function
|
|
981
|
-
let [r,
|
|
982
|
-
return e.length === 0 && !t ? null : /* @__PURE__ */
|
|
1022
|
+
function He({ events: e, lastRequest: t, onClear: n }) {
|
|
1023
|
+
let [r, i] = l(!1), a = s(() => me(e), [e]), o = s(() => fe(e), [e]);
|
|
1024
|
+
return e.length === 0 && !t ? null : /* @__PURE__ */ h("div", {
|
|
983
1025
|
className: "bailey-trace-panel",
|
|
984
|
-
children: [/* @__PURE__ */
|
|
1026
|
+
children: [/* @__PURE__ */ h("div", {
|
|
985
1027
|
className: "bailey-trace-toggle-row",
|
|
986
|
-
children: [/* @__PURE__ */
|
|
1028
|
+
children: [/* @__PURE__ */ h("button", {
|
|
987
1029
|
type: "button",
|
|
988
|
-
onClick: () =>
|
|
1030
|
+
onClick: () => i((e) => !e),
|
|
989
1031
|
"aria-expanded": r,
|
|
990
|
-
className:
|
|
1032
|
+
className: a ? "bailey-trace-toggle bailey-trace-toggle-error" : "bailey-trace-toggle",
|
|
991
1033
|
children: [
|
|
992
|
-
|
|
1034
|
+
a && !r ? "⚠ " : "",
|
|
993
1035
|
r ? "Hide details" : "Show details",
|
|
994
1036
|
" (",
|
|
995
1037
|
e.length,
|
|
996
1038
|
")"
|
|
997
1039
|
]
|
|
998
|
-
}),
|
|
999
|
-
className:
|
|
1000
|
-
children:
|
|
1040
|
+
}), o && /* @__PURE__ */ m("span", {
|
|
1041
|
+
className: a ? "bailey-trace-summary bailey-trace-summary-error" : "bailey-trace-summary",
|
|
1042
|
+
children: o
|
|
1001
1043
|
})]
|
|
1002
|
-
}), r && /* @__PURE__ */
|
|
1044
|
+
}), r && /* @__PURE__ */ m(Ve, {
|
|
1003
1045
|
events: e,
|
|
1004
1046
|
lastRequest: t,
|
|
1005
1047
|
onClear: n
|
|
@@ -1008,7 +1050,7 @@ function Ee({ events: e, lastRequest: t, onClear: n }) {
|
|
|
1008
1050
|
}
|
|
1009
1051
|
//#endregion
|
|
1010
1052
|
//#region src/ui/BaileyChatPanel.tsx
|
|
1011
|
-
var
|
|
1053
|
+
var Ue = "How can bailey AI help you today?", We = "Reply to bailey AI", Ge = {
|
|
1012
1054
|
newChatButtonText: "New chat",
|
|
1013
1055
|
newChatAriaLabel: "new chat",
|
|
1014
1056
|
suggestionsTitle: "Suggested for you",
|
|
@@ -1023,229 +1065,235 @@ var De = "How can bailey AI help you today?", Oe = "Reply to bailey AI", ke = {
|
|
|
1023
1065
|
copyButtonAriaLabel: "copy response as markdown",
|
|
1024
1066
|
copyButtonTooltipDefault: "Copy as markdown",
|
|
1025
1067
|
copyButtonTooltipCopied: "Copied!"
|
|
1026
|
-
},
|
|
1027
|
-
...
|
|
1028
|
-
p: ({ children: e }) => /* @__PURE__ */
|
|
1029
|
-
},
|
|
1030
|
-
return /* @__PURE__ */
|
|
1068
|
+
}, Ke = [d], qe = {
|
|
1069
|
+
...Ee(),
|
|
1070
|
+
p: ({ children: e }) => /* @__PURE__ */ m(p, { children: e })
|
|
1071
|
+
}, Je = n(function({ content: e, components: t }) {
|
|
1072
|
+
return /* @__PURE__ */ m("div", {
|
|
1031
1073
|
className: "bailey-markdown-content",
|
|
1032
|
-
children: /* @__PURE__ */
|
|
1033
|
-
remarkPlugins:
|
|
1074
|
+
children: /* @__PURE__ */ m(u, {
|
|
1075
|
+
remarkPlugins: Ke,
|
|
1034
1076
|
components: t,
|
|
1035
1077
|
skipHtml: !0,
|
|
1036
1078
|
children: e
|
|
1037
1079
|
})
|
|
1038
1080
|
});
|
|
1039
1081
|
});
|
|
1040
|
-
function
|
|
1082
|
+
function Ye(e, t, n) {
|
|
1041
1083
|
if (e !== "streaming") return;
|
|
1042
1084
|
let r = t.filter((e) => e.turnSentAt === n?.sentAt);
|
|
1043
|
-
if (r.length !== 0) return
|
|
1085
|
+
if (r.length !== 0) return Y(r[r.length - 1]);
|
|
1044
1086
|
}
|
|
1045
|
-
function
|
|
1087
|
+
function Xe(e) {
|
|
1046
1088
|
let t = new Date(e), n = t.toDateString() === (/* @__PURE__ */ new Date()).toDateString(), r = t.toLocaleTimeString([], {
|
|
1047
1089
|
hour: "numeric",
|
|
1048
1090
|
minute: "2-digit"
|
|
1049
1091
|
});
|
|
1050
1092
|
return n ? `Today ${r}` : `${t.toLocaleDateString()} ${r}`;
|
|
1051
1093
|
}
|
|
1052
|
-
function
|
|
1053
|
-
let { messages: w, traceEvents: T, lastRequest: E, status: D, error: O, send:
|
|
1054
|
-
...
|
|
1094
|
+
function Ze({ chat: e, placeholder: t, replyPlaceholder: n = We, emptyPlaceholder: r, suggestions: i, privacyNote: o, resolveActivityIcon: d, className: p, height: g, width: _, hideDeveloperDetails: v = !1, renderMessageActions: y, renderTable: b, renderChart: x, labels: S, formatMessageTime: C }) {
|
|
1095
|
+
let { messages: w, traceEvents: T, lastRequest: E, status: D, error: O, send: ee, stop: k, retryLast: A, clearTrace: j, clearError: M, newChat: N } = e, [P, F] = l(""), I = {
|
|
1096
|
+
...Ge,
|
|
1055
1097
|
...S
|
|
1056
|
-
},
|
|
1098
|
+
}, L = C ?? Xe, R = c(null), z = we(R), B = c(null), V = c(null), H = c(!0), te = s(() => Ee({
|
|
1057
1099
|
renderTable: b,
|
|
1058
1100
|
renderChart: x
|
|
1059
|
-
}), [b, x]),
|
|
1101
|
+
}), [b, x]), U = s(() => Ye(D, T, E), [
|
|
1060
1102
|
D,
|
|
1061
1103
|
T,
|
|
1062
1104
|
E
|
|
1063
|
-
]),
|
|
1064
|
-
|
|
1065
|
-
let e =
|
|
1105
|
+
]), W = w.length === 0, G = t ?? (W ? r ?? Ue : n);
|
|
1106
|
+
a(() => {
|
|
1107
|
+
let e = V.current;
|
|
1066
1108
|
if (!e) return;
|
|
1067
1109
|
let t = () => {
|
|
1068
1110
|
let t = e.scrollHeight - e.scrollTop - e.clientHeight;
|
|
1069
|
-
|
|
1111
|
+
H.current = t < 60;
|
|
1070
1112
|
};
|
|
1071
1113
|
return e.addEventListener("scroll", t, { passive: !0 }), () => e.removeEventListener("scroll", t);
|
|
1072
|
-
}, []),
|
|
1073
|
-
|
|
1114
|
+
}, []), a(() => {
|
|
1115
|
+
H.current && B.current?.scrollIntoView({
|
|
1074
1116
|
behavior: D === "streaming" ? "auto" : "smooth",
|
|
1075
1117
|
block: "nearest"
|
|
1076
1118
|
});
|
|
1077
1119
|
}, [w, D]);
|
|
1078
|
-
let
|
|
1079
|
-
|
|
1120
|
+
let K = (e) => {
|
|
1121
|
+
H.current = !0, ee(e);
|
|
1080
1122
|
};
|
|
1081
|
-
return /* @__PURE__ */
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
"aria-label": L.newChatAriaLabel,
|
|
1097
|
-
className: "bailey-new-chat-button",
|
|
1098
|
-
children: L.newChatButtonText
|
|
1099
|
-
})
|
|
1100
|
-
}),
|
|
1101
|
-
/* @__PURE__ */ f("div", {
|
|
1102
|
-
className: "bailey-chat-transcript",
|
|
1103
|
-
ref: B,
|
|
1104
|
-
children: [
|
|
1105
|
-
U && (u && u.length > 0 ? /* @__PURE__ */ f("div", {
|
|
1106
|
-
className: "bailey-suggestions",
|
|
1107
|
-
children: [/* @__PURE__ */ d("div", {
|
|
1108
|
-
className: "bailey-suggestions-title",
|
|
1109
|
-
children: L.suggestionsTitle
|
|
1110
|
-
}), u.map((e, t) => /* @__PURE__ */ f("button", {
|
|
1111
|
-
type: "button",
|
|
1112
|
-
onClick: () => G(e.value ?? e.label),
|
|
1113
|
-
className: "bailey-suggestion-card",
|
|
1114
|
-
children: [/* @__PURE__ */ d("span", { children: e.label }), /* @__PURE__ */ d(me, { className: "bailey-suggestion-icon" })]
|
|
1115
|
-
}, `${e.label}-${t}`))]
|
|
1116
|
-
}) : /* @__PURE__ */ d("div", {
|
|
1117
|
-
className: "bailey-empty-state",
|
|
1118
|
-
children: L.emptyStateMessage
|
|
1119
|
-
})),
|
|
1120
|
-
w.map((e, t) => {
|
|
1121
|
-
let n = e.role === "assistant" && t === w.length - 1, r = D === "streaming" && n && e.content === "", i = e.role === "assistant" && !r ? de(T, e.createdAt) : [], a = i[i.length - 1];
|
|
1122
|
-
return /* @__PURE__ */ d("div", {
|
|
1123
|
-
className: e.role === "user" ? "bailey-message-row bailey-message-row-user" : "bailey-message-row",
|
|
1124
|
-
children: e.role === "user" ? /* @__PURE__ */ f("div", {
|
|
1125
|
-
className: "bailey-user-message",
|
|
1126
|
-
children: [/* @__PURE__ */ f("div", {
|
|
1127
|
-
className: "bailey-message-meta",
|
|
1128
|
-
children: [/* @__PURE__ */ d("span", {
|
|
1129
|
-
className: "bailey-message-meta-name",
|
|
1130
|
-
children: L.youLabel
|
|
1131
|
-
}), e.createdAt !== void 0 && /* @__PURE__ */ d("span", { children: R(e.createdAt) })]
|
|
1132
|
-
}), /* @__PURE__ */ d("div", {
|
|
1133
|
-
className: "bailey-user-bubble",
|
|
1134
|
-
children: e.content
|
|
1135
|
-
})]
|
|
1136
|
-
}) : r ? /* @__PURE__ */ d("div", {
|
|
1137
|
-
className: "bailey-thinking-hint",
|
|
1138
|
-
children: H ?? L.thinkingHint
|
|
1139
|
-
}) : /* @__PURE__ */ f("div", {
|
|
1140
|
-
className: "bailey-assistant-message",
|
|
1141
|
-
children: [
|
|
1142
|
-
a && /* @__PURE__ */ f("div", {
|
|
1143
|
-
className: "bailey-activity-line",
|
|
1144
|
-
children: [/* @__PURE__ */ d("span", {
|
|
1145
|
-
className: "bailey-activity-icon",
|
|
1146
|
-
children: m?.(a.toolName) ?? /* @__PURE__ */ d(_e, {})
|
|
1147
|
-
}), /* @__PURE__ */ d("span", { children: a.text })]
|
|
1148
|
-
}),
|
|
1149
|
-
/* @__PURE__ */ d(Me, {
|
|
1150
|
-
content: e.content,
|
|
1151
|
-
components: ee
|
|
1152
|
-
}),
|
|
1153
|
-
e.streaming && H && /* @__PURE__ */ d("div", {
|
|
1154
|
-
className: "bailey-streaming-hint",
|
|
1155
|
-
children: H
|
|
1156
|
-
}),
|
|
1157
|
-
!e.streaming && /* @__PURE__ */ f("div", {
|
|
1158
|
-
className: "bailey-message-actions",
|
|
1159
|
-
children: [/* @__PURE__ */ d(ye, {
|
|
1160
|
-
markdown: e.content,
|
|
1161
|
-
ariaLabel: L.copyButtonAriaLabel,
|
|
1162
|
-
tooltipDefaultText: L.copyButtonTooltipDefault,
|
|
1163
|
-
tooltipCopiedText: L.copyButtonTooltipCopied
|
|
1164
|
-
}), y?.(e)]
|
|
1165
|
-
})
|
|
1166
|
-
]
|
|
1167
|
-
})
|
|
1168
|
-
}, e.id);
|
|
1169
|
-
}),
|
|
1170
|
-
/* @__PURE__ */ d("div", { ref: z })
|
|
1171
|
-
]
|
|
1172
|
-
}),
|
|
1173
|
-
O && /* @__PURE__ */ f("div", {
|
|
1174
|
-
className: "bailey-error-banner",
|
|
1175
|
-
role: "alert",
|
|
1176
|
-
children: [/* @__PURE__ */ d("span", { children: O }), /* @__PURE__ */ f("div", {
|
|
1177
|
-
className: "bailey-error-actions",
|
|
1178
|
-
children: [/* @__PURE__ */ d("button", {
|
|
1179
|
-
type: "button",
|
|
1180
|
-
onClick: j,
|
|
1181
|
-
className: "bailey-retry-button",
|
|
1182
|
-
children: L.retryButtonText
|
|
1183
|
-
}), /* @__PURE__ */ d("button", {
|
|
1123
|
+
return /* @__PURE__ */ m(_e.Provider, {
|
|
1124
|
+
value: z,
|
|
1125
|
+
children: /* @__PURE__ */ m("div", {
|
|
1126
|
+
ref: R,
|
|
1127
|
+
className: `bailey-chat-panel${p ? ` ${p}` : ""}`,
|
|
1128
|
+
style: g !== void 0 || _ !== void 0 ? {
|
|
1129
|
+
height: g,
|
|
1130
|
+
width: _
|
|
1131
|
+
} : void 0,
|
|
1132
|
+
children: /* @__PURE__ */ h("div", {
|
|
1133
|
+
className: "bailey-chat-panel-inner",
|
|
1134
|
+
children: [
|
|
1135
|
+
/* @__PURE__ */ m("div", {
|
|
1136
|
+
className: "bailey-toolbar-row",
|
|
1137
|
+
children: !W && /* @__PURE__ */ m("button", {
|
|
1184
1138
|
type: "button",
|
|
1185
1139
|
onClick: N,
|
|
1186
|
-
"aria-label":
|
|
1187
|
-
className: "bailey-
|
|
1188
|
-
children:
|
|
1189
|
-
})
|
|
1190
|
-
})
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1140
|
+
"aria-label": I.newChatAriaLabel,
|
|
1141
|
+
className: "bailey-new-chat-button",
|
|
1142
|
+
children: I.newChatButtonText
|
|
1143
|
+
})
|
|
1144
|
+
}),
|
|
1145
|
+
/* @__PURE__ */ h("div", {
|
|
1146
|
+
className: "bailey-chat-transcript",
|
|
1147
|
+
ref: V,
|
|
1148
|
+
children: [
|
|
1149
|
+
W && (i && i.length > 0 ? /* @__PURE__ */ h("div", {
|
|
1150
|
+
className: "bailey-suggestions",
|
|
1151
|
+
children: [/* @__PURE__ */ m("div", {
|
|
1152
|
+
className: "bailey-suggestions-title",
|
|
1153
|
+
children: I.suggestionsTitle
|
|
1154
|
+
}), i.map((e, t) => /* @__PURE__ */ h("button", {
|
|
1155
|
+
type: "button",
|
|
1156
|
+
onClick: () => K(e.value ?? e.label),
|
|
1157
|
+
className: "bailey-suggestion-card",
|
|
1158
|
+
children: [/* @__PURE__ */ m("span", { children: e.label }), /* @__PURE__ */ m(ke, { className: "bailey-suggestion-icon" })]
|
|
1159
|
+
}, `${e.label}-${t}`))]
|
|
1160
|
+
}) : /* @__PURE__ */ m("div", {
|
|
1161
|
+
className: "bailey-empty-state",
|
|
1162
|
+
children: I.emptyStateMessage
|
|
1163
|
+
})),
|
|
1164
|
+
w.map((e, t) => {
|
|
1165
|
+
let n = e.role === "assistant" && t === w.length - 1, r = D === "streaming" && n && e.content === "", i = e.role === "assistant" && !r ? he(T, e.createdAt) : [], a = i[i.length - 1];
|
|
1166
|
+
return /* @__PURE__ */ m("div", {
|
|
1167
|
+
className: e.role === "user" ? "bailey-message-row bailey-message-row-user" : "bailey-message-row",
|
|
1168
|
+
children: e.role === "user" ? /* @__PURE__ */ h("div", {
|
|
1169
|
+
className: "bailey-user-message",
|
|
1170
|
+
children: [/* @__PURE__ */ h("div", {
|
|
1171
|
+
className: "bailey-message-meta",
|
|
1172
|
+
children: [/* @__PURE__ */ m("span", {
|
|
1173
|
+
className: "bailey-message-meta-name",
|
|
1174
|
+
children: I.youLabel
|
|
1175
|
+
}), e.createdAt !== void 0 && /* @__PURE__ */ m("span", { children: L(e.createdAt) })]
|
|
1176
|
+
}), /* @__PURE__ */ m("div", {
|
|
1177
|
+
className: "bailey-user-bubble",
|
|
1178
|
+
children: e.content
|
|
1179
|
+
})]
|
|
1180
|
+
}) : r ? /* @__PURE__ */ m("div", {
|
|
1181
|
+
className: "bailey-thinking-hint",
|
|
1182
|
+
children: U ?? I.thinkingHint
|
|
1183
|
+
}) : /* @__PURE__ */ h("div", {
|
|
1184
|
+
className: "bailey-assistant-message",
|
|
1185
|
+
children: [
|
|
1186
|
+
a && /* @__PURE__ */ h("div", {
|
|
1187
|
+
className: "bailey-activity-line",
|
|
1188
|
+
children: [/* @__PURE__ */ m("span", {
|
|
1189
|
+
className: "bailey-activity-icon",
|
|
1190
|
+
children: d?.(a.toolName) ?? /* @__PURE__ */ m(Me, {})
|
|
1191
|
+
}), /* @__PURE__ */ m("span", { children: a.text })]
|
|
1192
|
+
}),
|
|
1193
|
+
/* @__PURE__ */ m(Je, {
|
|
1194
|
+
content: e.content,
|
|
1195
|
+
components: te
|
|
1196
|
+
}),
|
|
1197
|
+
e.streaming && U && /* @__PURE__ */ m("div", {
|
|
1198
|
+
className: "bailey-streaming-hint",
|
|
1199
|
+
children: U
|
|
1200
|
+
}),
|
|
1201
|
+
!e.streaming && /* @__PURE__ */ h("div", {
|
|
1202
|
+
className: "bailey-message-actions",
|
|
1203
|
+
children: [/* @__PURE__ */ m(Pe, {
|
|
1204
|
+
markdown: e.content,
|
|
1205
|
+
ariaLabel: I.copyButtonAriaLabel,
|
|
1206
|
+
tooltipDefaultText: I.copyButtonTooltipDefault,
|
|
1207
|
+
tooltipCopiedText: I.copyButtonTooltipCopied
|
|
1208
|
+
}), y?.(e)]
|
|
1209
|
+
})
|
|
1210
|
+
]
|
|
1211
|
+
})
|
|
1212
|
+
}, e.id);
|
|
1213
|
+
}),
|
|
1214
|
+
/* @__PURE__ */ m("div", { ref: B })
|
|
1215
|
+
]
|
|
1216
|
+
}),
|
|
1217
|
+
O && /* @__PURE__ */ h("div", {
|
|
1218
|
+
className: "bailey-error-banner",
|
|
1219
|
+
role: "alert",
|
|
1220
|
+
children: [/* @__PURE__ */ m("span", { children: O }), /* @__PURE__ */ h("div", {
|
|
1221
|
+
className: "bailey-error-actions",
|
|
1222
|
+
children: [/* @__PURE__ */ m("button", {
|
|
1215
1223
|
type: "button",
|
|
1216
1224
|
onClick: A,
|
|
1217
|
-
"
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
})
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1225
|
+
className: "bailey-retry-button",
|
|
1226
|
+
children: I.retryButtonText
|
|
1227
|
+
}), /* @__PURE__ */ m("button", {
|
|
1228
|
+
type: "button",
|
|
1229
|
+
onClick: M,
|
|
1230
|
+
"aria-label": I.dismissErrorAriaLabel,
|
|
1231
|
+
className: "bailey-dismiss-button",
|
|
1232
|
+
children: "✕"
|
|
1233
|
+
})]
|
|
1234
|
+
})]
|
|
1235
|
+
}),
|
|
1236
|
+
!v && /* @__PURE__ */ m(He, {
|
|
1237
|
+
events: T,
|
|
1238
|
+
lastRequest: E,
|
|
1239
|
+
onClear: j
|
|
1240
|
+
}),
|
|
1241
|
+
/* @__PURE__ */ h("form", {
|
|
1242
|
+
onSubmit: (e) => {
|
|
1243
|
+
e.preventDefault(), !(!P.trim() || D === "streaming") && (K(P), F(""));
|
|
1244
|
+
},
|
|
1245
|
+
className: "bailey-input-row",
|
|
1246
|
+
children: [/* @__PURE__ */ m("input", {
|
|
1247
|
+
type: "text",
|
|
1248
|
+
placeholder: G,
|
|
1249
|
+
"aria-label": G,
|
|
1250
|
+
value: P,
|
|
1251
|
+
onChange: (e) => F(e.target.value),
|
|
1252
|
+
disabled: D === "streaming",
|
|
1253
|
+
className: "bailey-input"
|
|
1254
|
+
}), D === "streaming" ? /* @__PURE__ */ m(f.Provider, {
|
|
1255
|
+
delayDuration: 200,
|
|
1256
|
+
children: /* @__PURE__ */ h(f.Root, { children: [/* @__PURE__ */ m(f.Trigger, {
|
|
1257
|
+
asChild: !0,
|
|
1258
|
+
children: /* @__PURE__ */ m("button", {
|
|
1259
|
+
type: "button",
|
|
1260
|
+
onClick: k,
|
|
1261
|
+
"aria-label": I.stopAriaLabel,
|
|
1262
|
+
className: "bailey-stop-button",
|
|
1263
|
+
children: /* @__PURE__ */ m(Oe, { className: "bailey-stop-icon" })
|
|
1264
|
+
})
|
|
1265
|
+
}), /* @__PURE__ */ m(f.Portal, {
|
|
1266
|
+
container: z instanceof ShadowRoot ? z : void 0,
|
|
1267
|
+
children: /* @__PURE__ */ h(f.Content, {
|
|
1268
|
+
side: "top",
|
|
1269
|
+
className: "bailey-tooltip-content",
|
|
1270
|
+
children: [I.stopButtonText, /* @__PURE__ */ m(f.Arrow, { className: "bailey-tooltip-arrow" })]
|
|
1271
|
+
})
|
|
1272
|
+
})] })
|
|
1273
|
+
}) : /* @__PURE__ */ m("button", {
|
|
1274
|
+
type: "submit",
|
|
1275
|
+
"aria-label": I.sendAriaLabel,
|
|
1276
|
+
disabled: !P.trim(),
|
|
1277
|
+
className: "bailey-send-button",
|
|
1278
|
+
children: /* @__PURE__ */ m(De, { className: "bailey-send-icon" })
|
|
1279
|
+
})]
|
|
1280
|
+
}),
|
|
1281
|
+
(W || o?.alwaysVisible) && o && /* @__PURE__ */ m("div", {
|
|
1282
|
+
className: "bailey-privacy-note",
|
|
1283
|
+
children: /* @__PURE__ */ m(u, {
|
|
1284
|
+
remarkPlugins: Ke,
|
|
1285
|
+
components: qe,
|
|
1286
|
+
skipHtml: !0,
|
|
1287
|
+
children: o.markdown
|
|
1288
|
+
})
|
|
1241
1289
|
})
|
|
1242
|
-
|
|
1243
|
-
|
|
1290
|
+
]
|
|
1291
|
+
})
|
|
1244
1292
|
})
|
|
1245
1293
|
});
|
|
1246
1294
|
}
|
|
1247
1295
|
//#endregion
|
|
1248
1296
|
//#region src/index.ts
|
|
1249
|
-
var
|
|
1297
|
+
var Qe = "0.3.1-pre.2";
|
|
1250
1298
|
//#endregion
|
|
1251
|
-
export {
|
|
1299
|
+
export { Me as ActivityIcon, ke as ArrowUpRightIcon, Qe as BAILEYAI_CHAT_UI_VERSION, H as BAILEY_CHART_PROMPT_FRAGMENT, P as BAILEY_TABLE_GRID_ROW_THRESHOLD, Ze as BaileyChatPanel, He as BaileyTracePanel, Pe as CopyMarkdownButton, De as HeartIcon, ie as TRACE_KIND_LABEL, Ee as createBaileyMarkdownComponents, C as extractPseudoToolCalls, B as extractTableData, ue as formatTraceGap, le as formatTraceTime, me as hasTraceFailure, e as isSafeMarkdownUrl, A as joinInstructions, re as parseBaileyChartSpec, T as parseSseFrames, N as resolveToolCall, V as shouldUseGrid, he as toActivityLines, de as toTraceRows, pe as toTraceSegments, oe as traceEventArgsDetail, Y as traceEventHint, se as traceEventOutputDetail, ce as traceEventRawDetail, ae as traceEventSummary, J as traceEventToolName, fe as traceSummaryLine, k as useBaileyChat };
|