@icanbwell/baileyai-chat-ui 0.4.4 → 0.5.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/README.md +42 -0
- package/dist/baileyai-chat-ui.cjs +3 -3
- package/dist/baileyai-chat-ui.css +1 -1
- package/dist/baileyai-chat-ui.js +403 -315
- package/dist/chart.d.ts +2 -2
- package/dist/index.d.ts +69 -7
- package/dist/table.d.ts +2 -2
- package/package.json +9 -9
package/dist/baileyai-chat-ui.js
CHANGED
|
@@ -2,8 +2,8 @@ import { t as e } from "./safeMarkdownUrl-xI42YYzd.js";
|
|
|
2
2
|
import { memo as t, useCallback as n, useEffect as r, useMemo as i, useRef as a, useState as o } from "react";
|
|
3
3
|
import s from "react-markdown";
|
|
4
4
|
import c from "remark-gfm";
|
|
5
|
-
import
|
|
6
|
-
import
|
|
5
|
+
import * as l from "@radix-ui/react-tooltip";
|
|
6
|
+
import { Fragment as u, jsx as d, jsxs as f } from "react/jsx-runtime";
|
|
7
7
|
//#region src/utils/pseudoToolCalls.ts
|
|
8
8
|
var p = /<(search_tools|call_tool|function_calls|function_result)>([\s\S]*?)<\/\1>/g, m = /<name>([\s\S]*?)<\/name>/, h = /<arguments>([\s\S]*?)<\/arguments>/, g = /<invoke\s+name="([^"]*)"\s*>([\s\S]*?)<\/invoke>/g, _ = /<parameter\s+name="([^"]*)"\s*>([\s\S]*?)<\/parameter>/g;
|
|
9
9
|
function v(e) {
|
|
@@ -105,38 +105,38 @@ function S(e) {
|
|
|
105
105
|
}
|
|
106
106
|
//#endregion
|
|
107
107
|
//#region src/logic/useBaileyChat.ts
|
|
108
|
-
var C = 200, w = 15e4,
|
|
108
|
+
var C = 200, w = 15e4, T = (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
111
|
return i ? `${r} ${i.length > C ? `${i.slice(0, C)}…` : i}` : r;
|
|
112
|
-
},
|
|
113
|
-
let [f, p] = o([]), [m, h] = o([]), [g, _] = o(null), [v, y] = o("idle"), [x, C] = o(null),
|
|
112
|
+
}, E = ({ transport: e, model: t, instructions: i, tools: s = [], toolChoice: c, firstUserMessagePrefix: l, onAssistantMessageComplete: u, idleTimeoutMs: d = w }) => {
|
|
113
|
+
let [f, p] = o([]), [m, h] = o([]), [g, _] = o(null), [v, y] = o("idle"), [x, C] = o(null), E = a(null), D = a(""), O = a(0), k = a([]);
|
|
114
114
|
r(() => {
|
|
115
|
-
|
|
115
|
+
k.current = f;
|
|
116
116
|
}, [f]);
|
|
117
|
-
let
|
|
118
|
-
|
|
119
|
-
}, []),
|
|
120
|
-
|
|
117
|
+
let A = a([]), j = a(/* @__PURE__ */ new Map()), M = a(/* @__PURE__ */ new Map()), N = a(null), P = n(() => {
|
|
118
|
+
N.current !== null && (clearTimeout(N.current), N.current = null);
|
|
119
|
+
}, []), F = n((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
|
-
}, [
|
|
123
|
+
}, [P, d]), I = n((e, t, n) => {
|
|
124
124
|
let r = (e) => {
|
|
125
125
|
n.push(e), h((t) => [...t, e]);
|
|
126
126
|
};
|
|
127
127
|
if (t.type === "response.output_text.delta") {
|
|
128
128
|
if (!t.delta) return !1;
|
|
129
|
-
let n =
|
|
129
|
+
let n = j.current.get(e) ?? {
|
|
130
130
|
raw: "",
|
|
131
131
|
emittedCount: 0
|
|
132
132
|
};
|
|
133
133
|
n.raw += t.delta;
|
|
134
134
|
let { cleanedText: i, matches: a } = b(n.raw), o = i.trim(), s = a.slice(n.emittedCount);
|
|
135
|
-
if (n.emittedCount = a.length,
|
|
135
|
+
if (n.emittedCount = a.length, j.current.set(e, n), M.current.set(e, o), p((t) => t.map((t) => t.id === e ? {
|
|
136
136
|
...t,
|
|
137
137
|
content: o
|
|
138
138
|
} : t)), s.length > 0) {
|
|
139
|
-
let e = Date.now(), t =
|
|
139
|
+
let e = Date.now(), t = O.current;
|
|
140
140
|
s.forEach((n) => r({
|
|
141
141
|
kind: "pseudo_tool_call",
|
|
142
142
|
name: n.name,
|
|
@@ -150,7 +150,7 @@ var C = 200, w = 15e4, ee = (e, t, n) => {
|
|
|
150
150
|
if (t.type === "response.output_item.added" || t.type === "response.output_item.done") {
|
|
151
151
|
let e = t.item;
|
|
152
152
|
if (e.type === "function_call" || e.type === "mcp_call") {
|
|
153
|
-
let n = Date.now(), i =
|
|
153
|
+
let n = Date.now(), i = O.current, a = e.name || "unknown_tool";
|
|
154
154
|
return r(t.type === "response.output_item.added" ? {
|
|
155
155
|
kind: "tool_start",
|
|
156
156
|
name: a,
|
|
@@ -175,32 +175,32 @@ var C = 200, w = 15e4, ee = (e, t, n) => {
|
|
|
175
175
|
status: t.status,
|
|
176
176
|
message: t.message,
|
|
177
177
|
at: Date.now(),
|
|
178
|
-
turnSentAt:
|
|
178
|
+
turnSentAt: O.current
|
|
179
179
|
}), !0) : t.type === "response.output_text.done" || t.type === "response.created" || t.type === "response.completed" ? !1 : t.type === "info" ? (r({
|
|
180
180
|
kind: "info",
|
|
181
181
|
message: t.message,
|
|
182
182
|
at: Date.now(),
|
|
183
|
-
turnSentAt:
|
|
183
|
+
turnSentAt: O.current
|
|
184
184
|
}), !0) : (r({
|
|
185
185
|
kind: "raw",
|
|
186
186
|
eventType: t.type,
|
|
187
187
|
raw: JSON.stringify(t),
|
|
188
188
|
at: Date.now(),
|
|
189
|
-
turnSentAt:
|
|
189
|
+
turnSentAt: O.current
|
|
190
190
|
}), !0);
|
|
191
|
-
}, []),
|
|
191
|
+
}, []), L = n(async (n) => {
|
|
192
192
|
y("streaming"), C(null);
|
|
193
193
|
let r = Date.now();
|
|
194
|
-
|
|
195
|
-
let a = crypto.randomUUID()
|
|
196
|
-
p((e) => [...e, {
|
|
194
|
+
O.current = r;
|
|
195
|
+
let a = crypto.randomUUID(), o = {
|
|
197
196
|
id: a,
|
|
198
197
|
role: "assistant",
|
|
199
198
|
content: "",
|
|
200
199
|
streaming: !0,
|
|
201
200
|
createdAt: r
|
|
202
|
-
}
|
|
203
|
-
|
|
201
|
+
};
|
|
202
|
+
p((e) => [...e, o]), A.current = [...n, o];
|
|
203
|
+
let d = n.findIndex((e) => e.role === "user" && !e.hidden), f = n.map((e, t) => t === d && l ? {
|
|
204
204
|
role: e.role,
|
|
205
205
|
content: `${l}${e.content}`
|
|
206
206
|
} : {
|
|
@@ -210,7 +210,7 @@ var C = 200, w = 15e4, ee = (e, t, n) => {
|
|
|
210
210
|
_({
|
|
211
211
|
model: t,
|
|
212
212
|
systemPrompt: i,
|
|
213
|
-
messages:
|
|
213
|
+
messages: f,
|
|
214
214
|
tools: s,
|
|
215
215
|
toolChoice: c,
|
|
216
216
|
stream: !0,
|
|
@@ -221,9 +221,9 @@ var C = 200, w = 15e4, ee = (e, t, n) => {
|
|
|
221
221
|
lastChunkAt: null
|
|
222
222
|
}
|
|
223
223
|
});
|
|
224
|
-
let
|
|
225
|
-
|
|
226
|
-
let
|
|
224
|
+
let m = new AbortController();
|
|
225
|
+
E.current = m, F(m);
|
|
226
|
+
let g = "", v = null, b = !1, x = !1, w = [], D = (e, t) => {
|
|
227
227
|
y("error"), C(e);
|
|
228
228
|
let n = {
|
|
229
229
|
kind: "error",
|
|
@@ -232,38 +232,38 @@ var C = 200, w = 15e4, ee = (e, t, n) => {
|
|
|
232
232
|
turnSentAt: r,
|
|
233
233
|
...t
|
|
234
234
|
};
|
|
235
|
-
|
|
236
|
-
},
|
|
235
|
+
w.push(n), h((e) => [...e, n]);
|
|
236
|
+
}, k = (e, t) => {
|
|
237
237
|
e.forEach((e) => {
|
|
238
238
|
if (e.type === "error") {
|
|
239
|
-
|
|
239
|
+
v = e.message;
|
|
240
240
|
let t = {
|
|
241
241
|
kind: "error",
|
|
242
242
|
message: e.message,
|
|
243
243
|
at: Date.now(),
|
|
244
244
|
turnSentAt: r
|
|
245
245
|
};
|
|
246
|
-
|
|
246
|
+
w.push(t), h((e) => [...e, t]);
|
|
247
247
|
return;
|
|
248
248
|
}
|
|
249
|
-
e.type === "response.output_text.delta" && e.delta && (
|
|
249
|
+
e.type === "response.output_text.delta" && e.delta && (x = !0), I(a, e, w) && (b = !0);
|
|
250
250
|
}), t && p((e) => e.map((e) => e.id === a ? {
|
|
251
251
|
...e,
|
|
252
252
|
streaming: !1
|
|
253
253
|
} : e));
|
|
254
254
|
};
|
|
255
255
|
try {
|
|
256
|
-
let { status: n, text:
|
|
256
|
+
let { status: n, text: o, errorMessage: l } = await e.streamChat({
|
|
257
257
|
model: t,
|
|
258
258
|
instructions: i,
|
|
259
|
-
input:
|
|
259
|
+
input: f,
|
|
260
260
|
tools: s,
|
|
261
261
|
toolChoice: c,
|
|
262
|
-
signal:
|
|
262
|
+
signal: m.signal,
|
|
263
263
|
onChunk: (e) => {
|
|
264
|
-
|
|
265
|
-
let { events: t, remainder: n, done: i } = S(
|
|
266
|
-
|
|
264
|
+
F(m), g += e;
|
|
265
|
+
let { events: t, remainder: n, done: i } = S(g);
|
|
266
|
+
g = n, k(t, i);
|
|
267
267
|
let a = Date.now();
|
|
268
268
|
_((e) => e && e.sentAt === r ? {
|
|
269
269
|
...e,
|
|
@@ -281,56 +281,62 @@ var C = 200, w = 15e4, ee = (e, t, n) => {
|
|
|
281
281
|
} : t);
|
|
282
282
|
}
|
|
283
283
|
});
|
|
284
|
-
if (
|
|
285
|
-
let { events: e, done: t } = S(`${
|
|
286
|
-
|
|
284
|
+
if (g.trim()) {
|
|
285
|
+
let { events: e, done: t } = S(`${g}\n\n`);
|
|
286
|
+
g = "", k(e, t);
|
|
287
287
|
}
|
|
288
|
-
if (
|
|
289
|
-
y("error"), C(
|
|
288
|
+
if (v) {
|
|
289
|
+
y("error"), C(v);
|
|
290
290
|
return;
|
|
291
291
|
}
|
|
292
292
|
if (n === void 0 || n >= 400) {
|
|
293
|
-
|
|
293
|
+
D(T(n, o, l), {
|
|
294
294
|
httpStatus: n,
|
|
295
|
-
rawBody:
|
|
295
|
+
rawBody: o || void 0
|
|
296
296
|
});
|
|
297
297
|
return;
|
|
298
298
|
}
|
|
299
|
-
if (!
|
|
300
|
-
|
|
299
|
+
if (!b) {
|
|
300
|
+
D("Bailey returned an empty response.");
|
|
301
301
|
return;
|
|
302
302
|
}
|
|
303
|
-
if (!
|
|
304
|
-
|
|
303
|
+
if (!x) {
|
|
304
|
+
D("Bailey ran some tools but didn't return an answer. Try asking again.");
|
|
305
305
|
return;
|
|
306
306
|
}
|
|
307
307
|
y("idle");
|
|
308
|
-
let
|
|
308
|
+
let d = M.current.get(a) ?? "";
|
|
309
309
|
_((e) => e && e.sentAt === r ? {
|
|
310
310
|
...e,
|
|
311
|
-
response: { content:
|
|
311
|
+
response: { content: d }
|
|
312
312
|
} : e), u && await u({
|
|
313
313
|
id: a,
|
|
314
314
|
role: "assistant",
|
|
315
|
-
content:
|
|
315
|
+
content: d,
|
|
316
316
|
streaming: !1
|
|
317
|
-
},
|
|
317
|
+
}, w);
|
|
318
318
|
} catch (e) {
|
|
319
319
|
let t = e;
|
|
320
320
|
if (t?.name === "TimeoutError") {
|
|
321
|
-
|
|
321
|
+
D(t.message, { source: "client-timeout" });
|
|
322
322
|
return;
|
|
323
323
|
}
|
|
324
324
|
if (t?.name === "AbortError") {
|
|
325
325
|
y("idle");
|
|
326
326
|
return;
|
|
327
327
|
}
|
|
328
|
-
|
|
328
|
+
D(t?.message || "Bailey request failed.");
|
|
329
329
|
} finally {
|
|
330
|
-
|
|
330
|
+
P();
|
|
331
|
+
let e = M.current.get(a) ?? "";
|
|
332
|
+
j.current.delete(a), M.current.delete(a), p((e) => e.flatMap((e) => e.id === a ? e.content ? [{
|
|
331
333
|
...e,
|
|
332
334
|
streaming: !1
|
|
333
|
-
}] : [] : [e]))
|
|
335
|
+
}] : [] : [e])), A.current = A.current.flatMap((t) => t.id === a ? e ? [{
|
|
336
|
+
...t,
|
|
337
|
+
content: e,
|
|
338
|
+
streaming: !1
|
|
339
|
+
}] : [] : [t]);
|
|
334
340
|
}
|
|
335
341
|
}, [
|
|
336
342
|
e,
|
|
@@ -340,11 +346,11 @@ var C = 200, w = 15e4, ee = (e, t, n) => {
|
|
|
340
346
|
c,
|
|
341
347
|
l,
|
|
342
348
|
u,
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
]),
|
|
347
|
-
|
|
349
|
+
I,
|
|
350
|
+
F,
|
|
351
|
+
P
|
|
352
|
+
]), R = n((e) => {
|
|
353
|
+
k.current = e, p(e);
|
|
348
354
|
}, []);
|
|
349
355
|
return {
|
|
350
356
|
messages: f,
|
|
@@ -355,43 +361,63 @@ var C = 200, w = 15e4, ee = (e, t, n) => {
|
|
|
355
361
|
send: n((e) => {
|
|
356
362
|
let t = e.trim();
|
|
357
363
|
if (!t) return;
|
|
358
|
-
|
|
359
|
-
let n =
|
|
364
|
+
D.current = t;
|
|
365
|
+
let n = {
|
|
360
366
|
id: crypto.randomUUID(),
|
|
361
367
|
role: "user",
|
|
362
368
|
content: t,
|
|
363
369
|
createdAt: Date.now()
|
|
364
|
-
}];
|
|
365
|
-
|
|
366
|
-
}, [
|
|
370
|
+
}, r = [...A.current, n];
|
|
371
|
+
A.current = r, R([...k.current, n]), L(r);
|
|
372
|
+
}, [L, R]),
|
|
373
|
+
sendHidden: n((e) => {
|
|
374
|
+
if (v === "streaming") return;
|
|
375
|
+
let t = e.trim();
|
|
376
|
+
if (!t) return;
|
|
377
|
+
D.current = t;
|
|
378
|
+
let n = {
|
|
379
|
+
id: crypto.randomUUID(),
|
|
380
|
+
role: "user",
|
|
381
|
+
content: t,
|
|
382
|
+
createdAt: Date.now(),
|
|
383
|
+
hidden: !0
|
|
384
|
+
}, r = [...A.current, n];
|
|
385
|
+
A.current = r, L(r);
|
|
386
|
+
}, [L, v]),
|
|
367
387
|
stop: n(() => {
|
|
368
|
-
|
|
388
|
+
E.current?.abort();
|
|
369
389
|
}, []),
|
|
370
390
|
retryLast: n(() => {
|
|
371
|
-
if (!
|
|
372
|
-
let e =
|
|
373
|
-
|
|
374
|
-
|
|
391
|
+
if (v === "streaming" || !D.current) return;
|
|
392
|
+
let e = k.current, t = e[e.length - 1], n = t && t.role === "assistant" ? e.slice(0, -1) : e;
|
|
393
|
+
R(n);
|
|
394
|
+
let r = A.current, i = r[r.length - 1], a = i && i.role === "assistant" ? r.slice(0, -1) : r;
|
|
395
|
+
A.current = a, L(a);
|
|
396
|
+
}, [
|
|
397
|
+
L,
|
|
398
|
+
R,
|
|
399
|
+
v
|
|
400
|
+
]),
|
|
375
401
|
clearTrace: n(() => h([]), []),
|
|
376
402
|
clearError: n(() => {
|
|
377
403
|
C(null), y((e) => e === "error" ? "idle" : e);
|
|
378
404
|
}, []),
|
|
379
405
|
newChat: n(() => {
|
|
380
|
-
|
|
381
|
-
}, [
|
|
406
|
+
E.current?.abort(), R([]), A.current = [], h([]), _(null), y("idle"), C(null), D.current = "";
|
|
407
|
+
}, [R])
|
|
382
408
|
};
|
|
383
409
|
};
|
|
384
410
|
//#endregion
|
|
385
411
|
//#region src/utils/prompt.ts
|
|
386
|
-
function
|
|
412
|
+
function D(...e) {
|
|
387
413
|
return e.filter((e) => !!(e && e.trim())).join("\n\n");
|
|
388
414
|
}
|
|
389
415
|
//#endregion
|
|
390
416
|
//#region src/utils/toolCalls.ts
|
|
391
|
-
var
|
|
392
|
-
function
|
|
417
|
+
var O = "call_tool", k = "a tool";
|
|
418
|
+
function A(e, t) {
|
|
393
419
|
let n = {
|
|
394
|
-
name: e ===
|
|
420
|
+
name: e === O ? k : e,
|
|
395
421
|
args: null,
|
|
396
422
|
viaCallTool: !1
|
|
397
423
|
};
|
|
@@ -404,7 +430,7 @@ function k(e, t) {
|
|
|
404
430
|
}
|
|
405
431
|
if (typeof r != "object" || !r) return n;
|
|
406
432
|
let i = r;
|
|
407
|
-
if (e ===
|
|
433
|
+
if (e === O) {
|
|
408
434
|
let e = typeof i.name == "string" ? i.name : void 0;
|
|
409
435
|
if (!e) return n;
|
|
410
436
|
let t = i.arguments;
|
|
@@ -422,32 +448,32 @@ function k(e, t) {
|
|
|
422
448
|
}
|
|
423
449
|
//#endregion
|
|
424
450
|
//#region src/utils/table.ts
|
|
425
|
-
var
|
|
451
|
+
var j = 5, M = (e) => e.type === "text" ? e.value ?? "" : (e.children ?? []).map(M).join(""), N = (e) => {
|
|
426
452
|
if (e.tagName === "a" && e.properties?.href) return e.properties.href;
|
|
427
453
|
for (let t of e.children ?? []) {
|
|
428
|
-
let e =
|
|
454
|
+
let e = N(t);
|
|
429
455
|
if (e) return e;
|
|
430
456
|
}
|
|
431
|
-
},
|
|
432
|
-
let t =
|
|
457
|
+
}, P = (e, t) => (e.children ?? []).find((e) => e.tagName === t), F = (e) => {
|
|
458
|
+
let t = M(e), n = N(e);
|
|
433
459
|
return n ? {
|
|
434
460
|
text: t,
|
|
435
461
|
href: n
|
|
436
462
|
} : { text: t };
|
|
437
|
-
},
|
|
463
|
+
}, I = (e) => (e.children ?? []).filter((e) => e.type === "element").map(F), L = (e) => {
|
|
438
464
|
if (e.tagName !== "table") return null;
|
|
439
|
-
let t =
|
|
465
|
+
let t = P(e, "thead"), n = t && P(t, "tr");
|
|
440
466
|
return {
|
|
441
|
-
headers: n ?
|
|
442
|
-
rows: (
|
|
467
|
+
headers: n ? I(n).map((e) => e.text) : [],
|
|
468
|
+
rows: (P(e, "tbody")?.children ?? []).filter((e) => e.tagName === "tr").map(I)
|
|
443
469
|
};
|
|
444
|
-
},
|
|
470
|
+
}, R = (e) => e.length > 5, z = "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```", B = [
|
|
445
471
|
"bar",
|
|
446
472
|
"line",
|
|
447
473
|
"pie",
|
|
448
474
|
"doughnut",
|
|
449
475
|
"scatter"
|
|
450
|
-
],
|
|
476
|
+
], V = 8, H = 50, U = 8, W = 500, G = (e) => typeof e == "object" && !!e && typeof e.x == "number" && typeof e.y == "number", ee = (e) => {
|
|
451
477
|
let t;
|
|
452
478
|
try {
|
|
453
479
|
t = JSON.parse(e);
|
|
@@ -456,17 +482,17 @@ var A = 5, j = (e) => e.type === "text" ? e.value ?? "" : (e.children ?? []).map
|
|
|
456
482
|
}
|
|
457
483
|
if (typeof t != "object" || !t) return null;
|
|
458
484
|
let n = t;
|
|
459
|
-
if (typeof n.type != "string" || !
|
|
485
|
+
if (typeof n.type != "string" || !B.includes(n.type)) return null;
|
|
460
486
|
let r = n.type;
|
|
461
487
|
if (n.title !== void 0 && typeof n.title != "string") return null;
|
|
462
488
|
let i = n.title;
|
|
463
489
|
if (typeof n.data != "object" || n.data === null) return null;
|
|
464
490
|
let a = n.data;
|
|
465
|
-
if (!Array.isArray(a.datasets) || a.datasets.length < 1 || a.datasets.length >
|
|
491
|
+
if (!Array.isArray(a.datasets) || a.datasets.length < 1 || a.datasets.length > V || (r === "pie" || r === "doughnut") && a.datasets.length !== 1) return null;
|
|
466
492
|
for (let e of a.datasets) if (typeof e != "object" || !e || typeof e.label != "string" || !Array.isArray(e.data)) return null;
|
|
467
493
|
let o = a.datasets;
|
|
468
494
|
if (r === "scatter") {
|
|
469
|
-
for (let e of o) if (e.data.length < 1 || e.data.length >
|
|
495
|
+
for (let e of o) if (e.data.length < 1 || e.data.length > W || !e.data.every(G)) return null;
|
|
470
496
|
return {
|
|
471
497
|
type: r,
|
|
472
498
|
title: i,
|
|
@@ -474,7 +500,7 @@ var A = 5, j = (e) => e.type === "text" ? e.value ?? "" : (e.children ?? []).map
|
|
|
474
500
|
};
|
|
475
501
|
}
|
|
476
502
|
if (!Array.isArray(a.labels) || !a.labels.every((e) => typeof e == "string")) return null;
|
|
477
|
-
let s = a.labels, c = r === "pie" || r === "doughnut" ?
|
|
503
|
+
let s = a.labels, c = r === "pie" || r === "doughnut" ? U : H;
|
|
478
504
|
if (s.length < 1 || s.length > c) return null;
|
|
479
505
|
for (let e of o) if (e.data.length !== s.length || !e.data.every((e) => typeof e == "number")) return null;
|
|
480
506
|
return {
|
|
@@ -485,7 +511,7 @@ var A = 5, j = (e) => e.type === "text" ? e.value ?? "" : (e.children ?? []).map
|
|
|
485
511
|
datasets: o
|
|
486
512
|
}
|
|
487
513
|
};
|
|
488
|
-
},
|
|
514
|
+
}, te = {
|
|
489
515
|
tool_start: "Tool start",
|
|
490
516
|
tool_end: "Tool end",
|
|
491
517
|
pseudo_tool_call: "Narrated tool call",
|
|
@@ -494,13 +520,13 @@ var A = 5, j = (e) => e.type === "text" ? e.value ?? "" : (e.children ?? []).map
|
|
|
494
520
|
error: "Error",
|
|
495
521
|
raw: "Raw event"
|
|
496
522
|
};
|
|
497
|
-
function
|
|
498
|
-
return e.kind !== "tool_start" && e.kind !== "tool_end" ? null :
|
|
523
|
+
function K(e) {
|
|
524
|
+
return e.kind !== "tool_start" && e.kind !== "tool_end" ? null : A(e.name, e.args);
|
|
499
525
|
}
|
|
500
|
-
function
|
|
526
|
+
function q(e, t = K(e)) {
|
|
501
527
|
return e.kind === "pseudo_tool_call" ? e.name : t?.name ?? null;
|
|
502
528
|
}
|
|
503
|
-
function
|
|
529
|
+
function ne(e, t = K(e)) {
|
|
504
530
|
switch (e.kind) {
|
|
505
531
|
case "tool_start": return t.viaCallTool ? `${t.name} (via call_tool)` : t.name;
|
|
506
532
|
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" : ""}`;
|
|
@@ -511,20 +537,20 @@ function ue(e, t = R(e)) {
|
|
|
511
537
|
case "raw": return `Unrecognized event: ${e.eventType}`;
|
|
512
538
|
}
|
|
513
539
|
}
|
|
514
|
-
function
|
|
540
|
+
function re(e, t = K(e)) {
|
|
515
541
|
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;
|
|
516
542
|
}
|
|
517
|
-
function
|
|
543
|
+
function J(e) {
|
|
518
544
|
return e.kind === "tool_end" ? e.output ?? null : null;
|
|
519
545
|
}
|
|
520
|
-
function
|
|
546
|
+
function Y(e) {
|
|
521
547
|
return e.kind === "raw" ? e.raw : e.kind === "error" ? e.rawBody ?? null : null;
|
|
522
548
|
}
|
|
523
|
-
function
|
|
549
|
+
function X(e) {
|
|
524
550
|
switch (e.kind) {
|
|
525
|
-
case "tool_start": return `Calling ${
|
|
551
|
+
case "tool_start": return `Calling ${A(e.name, e.args).name}...`;
|
|
526
552
|
case "tool_end": {
|
|
527
|
-
let t =
|
|
553
|
+
let t = A(e.name, e.args).name;
|
|
528
554
|
return e.isError ? `${t} failed` : `${t} returned`;
|
|
529
555
|
}
|
|
530
556
|
case "pseudo_tool_call": return `${e.name} (written as text, not called)`;
|
|
@@ -534,11 +560,11 @@ function U(e) {
|
|
|
534
560
|
case "raw": return `Unrecognized event: ${e.eventType}`;
|
|
535
561
|
}
|
|
536
562
|
}
|
|
537
|
-
function
|
|
563
|
+
function ie(e) {
|
|
538
564
|
let t = new Date(e);
|
|
539
565
|
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")}`;
|
|
540
566
|
}
|
|
541
|
-
function
|
|
567
|
+
function ae(e) {
|
|
542
568
|
if (e <= 0) return "+0ms";
|
|
543
569
|
if (e < 1e3) return `+${Math.round(e)}ms`;
|
|
544
570
|
let t = e / 1e3;
|
|
@@ -546,30 +572,30 @@ function G(e) {
|
|
|
546
572
|
let n = Math.floor(t / 60), r = Math.round(t % 60);
|
|
547
573
|
return `+${n}m${String(r).padStart(2, "0")}s`;
|
|
548
574
|
}
|
|
549
|
-
function
|
|
575
|
+
function oe(e) {
|
|
550
576
|
return e.map((t, n) => {
|
|
551
|
-
let r =
|
|
577
|
+
let r = K(t), i = n === 0 ? t.turnSentAt : e[n - 1].at;
|
|
552
578
|
return {
|
|
553
579
|
key: `${t.at}-${n}`,
|
|
554
580
|
kind: t.kind,
|
|
555
|
-
toolName:
|
|
581
|
+
toolName: q(t, r),
|
|
556
582
|
isToolStart: t.kind === "tool_start",
|
|
557
583
|
failed: t.kind === "tool_end" && t.isError === !0,
|
|
558
|
-
time:
|
|
584
|
+
time: ie(t.at),
|
|
559
585
|
gapMs: t.at - i,
|
|
560
|
-
label: t.kind === "tool_end" && t.isError === !0 ? "Tool failed" :
|
|
561
|
-
summary:
|
|
562
|
-
argsDetail:
|
|
563
|
-
outputDetail:
|
|
564
|
-
rawDetail:
|
|
586
|
+
label: t.kind === "tool_end" && t.isError === !0 ? "Tool failed" : te[t.kind],
|
|
587
|
+
summary: ne(t, r),
|
|
588
|
+
argsDetail: re(t, r),
|
|
589
|
+
outputDetail: J(t),
|
|
590
|
+
rawDetail: Y(t)
|
|
565
591
|
};
|
|
566
592
|
});
|
|
567
593
|
}
|
|
568
|
-
function
|
|
594
|
+
function se(e) {
|
|
569
595
|
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 = [];
|
|
570
596
|
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(" · ");
|
|
571
597
|
}
|
|
572
|
-
function
|
|
598
|
+
function ce(e) {
|
|
573
599
|
let t = [];
|
|
574
600
|
for (let n of e) {
|
|
575
601
|
let e = t[t.length - 1];
|
|
@@ -588,60 +614,75 @@ function J(e) {
|
|
|
588
614
|
}
|
|
589
615
|
return t;
|
|
590
616
|
}
|
|
591
|
-
function
|
|
617
|
+
function le(e) {
|
|
592
618
|
return e.some((e) => e.kind === "tool_end" && e.isError || e.kind === "error");
|
|
593
619
|
}
|
|
594
|
-
function
|
|
620
|
+
function ue(e, t) {
|
|
595
621
|
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) => ({
|
|
596
622
|
key: `${e.at}-${t}`,
|
|
597
|
-
text:
|
|
598
|
-
toolName:
|
|
623
|
+
text: X(e),
|
|
624
|
+
toolName: q(e)
|
|
599
625
|
}));
|
|
600
626
|
}
|
|
601
627
|
//#endregion
|
|
602
628
|
//#region src/ui/markdown.tsx
|
|
603
629
|
function de({ renderTable: t, renderChart: n } = {}) {
|
|
604
630
|
return {
|
|
605
|
-
a: ({ href: t, children: n }) => !t || !e(t) ? /* @__PURE__ */ u
|
|
631
|
+
a: ({ href: t, children: n }) => !t || !e(t) ? /* @__PURE__ */ d(u, { children: n }) : /* @__PURE__ */ d("a", {
|
|
606
632
|
href: t,
|
|
607
633
|
target: "_blank",
|
|
608
634
|
rel: "noopener noreferrer",
|
|
609
635
|
children: n
|
|
610
636
|
}),
|
|
611
637
|
table: ({ node: n, children: r }) => {
|
|
612
|
-
let i = n &&
|
|
613
|
-
if (i &&
|
|
638
|
+
let i = n && L(n);
|
|
639
|
+
if (i && R(i.rows) && t) {
|
|
614
640
|
let n = i.rows.map((t) => t.map((t) => t.href && !e(t.href) ? { text: t.text } : t));
|
|
615
|
-
return /* @__PURE__ */ u
|
|
641
|
+
return /* @__PURE__ */ d(u, { children: t({
|
|
616
642
|
headers: i.headers,
|
|
617
643
|
rows: n
|
|
618
644
|
}) });
|
|
619
645
|
}
|
|
620
|
-
return /* @__PURE__ */
|
|
646
|
+
return /* @__PURE__ */ d("table", { children: r });
|
|
621
647
|
},
|
|
622
648
|
pre: ({ children: e }) => {
|
|
623
649
|
let t = (Array.isArray(e) ? e[0] : e)?.props;
|
|
624
650
|
if ((t?.className?.split(" ") ?? []).includes("language-chartjs") && n) {
|
|
625
|
-
let e = t?.children, r =
|
|
626
|
-
if (r) return /* @__PURE__ */ u
|
|
651
|
+
let e = t?.children, r = ee(Array.isArray(e) ? e.join("") : String(e ?? ""));
|
|
652
|
+
if (r) return /* @__PURE__ */ d(u, { children: n(r) });
|
|
627
653
|
}
|
|
628
|
-
return /* @__PURE__ */
|
|
654
|
+
return /* @__PURE__ */ d("pre", { children: e });
|
|
629
655
|
}
|
|
630
656
|
};
|
|
631
657
|
}
|
|
632
658
|
//#endregion
|
|
633
659
|
//#region src/ui/icons.tsx
|
|
634
660
|
function fe({ className: e }) {
|
|
635
|
-
return /* @__PURE__ */
|
|
661
|
+
return /* @__PURE__ */ d("svg", {
|
|
636
662
|
viewBox: "0 0 24 24",
|
|
637
663
|
fill: "currentColor",
|
|
638
664
|
className: e,
|
|
639
665
|
"aria-hidden": "true",
|
|
640
|
-
children: /* @__PURE__ */
|
|
666
|
+
children: /* @__PURE__ */ d("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" })
|
|
641
667
|
});
|
|
642
668
|
}
|
|
643
|
-
function
|
|
669
|
+
function pe({ className: e }) {
|
|
644
670
|
return /* @__PURE__ */ d("svg", {
|
|
671
|
+
viewBox: "0 0 24 24",
|
|
672
|
+
fill: "currentColor",
|
|
673
|
+
className: e,
|
|
674
|
+
"aria-hidden": "true",
|
|
675
|
+
children: /* @__PURE__ */ d("rect", {
|
|
676
|
+
x: "6",
|
|
677
|
+
y: "6",
|
|
678
|
+
width: "12",
|
|
679
|
+
height: "12",
|
|
680
|
+
rx: "2"
|
|
681
|
+
})
|
|
682
|
+
});
|
|
683
|
+
}
|
|
684
|
+
function Z({ className: e }) {
|
|
685
|
+
return /* @__PURE__ */ f("svg", {
|
|
645
686
|
viewBox: "0 0 24 24",
|
|
646
687
|
fill: "none",
|
|
647
688
|
stroke: "currentColor",
|
|
@@ -650,11 +691,11 @@ function Z({ className: e }) {
|
|
|
650
691
|
strokeLinejoin: "round",
|
|
651
692
|
className: e,
|
|
652
693
|
"aria-hidden": "true",
|
|
653
|
-
children: [/* @__PURE__ */
|
|
694
|
+
children: [/* @__PURE__ */ d("path", { d: "M7 17 17 7" }), /* @__PURE__ */ d("path", { d: "M9 7h8v8" })]
|
|
654
695
|
});
|
|
655
696
|
}
|
|
656
|
-
function
|
|
657
|
-
return /* @__PURE__ */
|
|
697
|
+
function me({ className: e }) {
|
|
698
|
+
return /* @__PURE__ */ f("svg", {
|
|
658
699
|
viewBox: "0 0 24 24",
|
|
659
700
|
fill: "none",
|
|
660
701
|
stroke: "currentColor",
|
|
@@ -663,17 +704,17 @@ function pe({ className: e }) {
|
|
|
663
704
|
strokeLinejoin: "round",
|
|
664
705
|
className: e,
|
|
665
706
|
"aria-hidden": "true",
|
|
666
|
-
children: [/* @__PURE__ */
|
|
707
|
+
children: [/* @__PURE__ */ d("rect", {
|
|
667
708
|
x: "8",
|
|
668
709
|
y: "8",
|
|
669
710
|
width: "12",
|
|
670
711
|
height: "12",
|
|
671
712
|
rx: "2"
|
|
672
|
-
}), /* @__PURE__ */
|
|
713
|
+
}), /* @__PURE__ */ d("path", { d: "M16 8V6a2 2 0 0 0-2-2H6a2 2 0 0 0-2 2v8a2 2 0 0 0 2 2h2" })]
|
|
673
714
|
});
|
|
674
715
|
}
|
|
675
|
-
function
|
|
676
|
-
return /* @__PURE__ */
|
|
716
|
+
function he({ className: e }) {
|
|
717
|
+
return /* @__PURE__ */ d("svg", {
|
|
677
718
|
viewBox: "0 0 24 24",
|
|
678
719
|
fill: "none",
|
|
679
720
|
stroke: "currentColor",
|
|
@@ -682,11 +723,11 @@ function me({ className: e }) {
|
|
|
682
723
|
strokeLinejoin: "round",
|
|
683
724
|
className: e,
|
|
684
725
|
"aria-hidden": "true",
|
|
685
|
-
children: /* @__PURE__ */
|
|
726
|
+
children: /* @__PURE__ */ d("path", { d: "M5 12.5 9.5 17 19 7" })
|
|
686
727
|
});
|
|
687
728
|
}
|
|
688
|
-
function
|
|
689
|
-
return /* @__PURE__ */
|
|
729
|
+
function ge({ className: e }) {
|
|
730
|
+
return /* @__PURE__ */ f("svg", {
|
|
690
731
|
viewBox: "0 0 24 24",
|
|
691
732
|
fill: "none",
|
|
692
733
|
stroke: "currentColor",
|
|
@@ -695,63 +736,63 @@ function he({ className: e }) {
|
|
|
695
736
|
strokeLinejoin: "round",
|
|
696
737
|
className: e,
|
|
697
738
|
"aria-hidden": "true",
|
|
698
|
-
children: [/* @__PURE__ */
|
|
739
|
+
children: [/* @__PURE__ */ d("circle", {
|
|
699
740
|
cx: "12",
|
|
700
741
|
cy: "12",
|
|
701
742
|
r: "9"
|
|
702
|
-
}), /* @__PURE__ */
|
|
743
|
+
}), /* @__PURE__ */ d("path", { d: "M8.5 12.5 11 15l4.5-5.5" })]
|
|
703
744
|
});
|
|
704
745
|
}
|
|
705
746
|
//#endregion
|
|
706
747
|
//#region src/ui/CopyMarkdownButton.tsx
|
|
707
|
-
var
|
|
708
|
-
function
|
|
709
|
-
let [
|
|
748
|
+
var _e = 1500;
|
|
749
|
+
function ve({ markdown: e, className: t, ariaLabel: n = "copy response as markdown", tooltipDefaultText: i = "Copy as markdown", tooltipCopiedText: s = "Copied!" }) {
|
|
750
|
+
let [c, u] = o(!1), [p, m] = o(!1), h = a(null);
|
|
710
751
|
return r(() => () => {
|
|
711
|
-
|
|
712
|
-
}, []), /* @__PURE__ */
|
|
752
|
+
h.current !== null && clearTimeout(h.current);
|
|
753
|
+
}, []), /* @__PURE__ */ d(l.Provider, {
|
|
713
754
|
delayDuration: 200,
|
|
714
|
-
children: /* @__PURE__ */
|
|
715
|
-
open:
|
|
716
|
-
onOpenChange:
|
|
717
|
-
children: [/* @__PURE__ */
|
|
755
|
+
children: /* @__PURE__ */ f(l.Root, {
|
|
756
|
+
open: c || p,
|
|
757
|
+
onOpenChange: m,
|
|
758
|
+
children: [/* @__PURE__ */ d(l.Trigger, {
|
|
718
759
|
asChild: !0,
|
|
719
|
-
children: /* @__PURE__ */
|
|
760
|
+
children: /* @__PURE__ */ d("button", {
|
|
720
761
|
type: "button",
|
|
721
762
|
onClick: async () => {
|
|
722
763
|
try {
|
|
723
764
|
await navigator.clipboard.writeText(e);
|
|
724
765
|
} catch {}
|
|
725
|
-
|
|
766
|
+
u(!0), h.current !== null && clearTimeout(h.current), h.current = setTimeout(() => u(!1), _e);
|
|
726
767
|
},
|
|
727
|
-
"aria-label":
|
|
768
|
+
"aria-label": n,
|
|
728
769
|
className: `bailey-copy-button${t ? ` ${t}` : ""}`,
|
|
729
|
-
children:
|
|
770
|
+
children: d(c ? he : me, { className: "bailey-copy-icon" })
|
|
730
771
|
})
|
|
731
|
-
}), /* @__PURE__ */
|
|
772
|
+
}), /* @__PURE__ */ d(l.Portal, { children: /* @__PURE__ */ f(l.Content, {
|
|
732
773
|
side: "top",
|
|
733
774
|
className: "bailey-tooltip-content",
|
|
734
|
-
children: [
|
|
775
|
+
children: [c ? s : i, /* @__PURE__ */ d(l.Arrow, { className: "bailey-tooltip-arrow" })]
|
|
735
776
|
}) })]
|
|
736
777
|
})
|
|
737
778
|
});
|
|
738
779
|
}
|
|
739
780
|
//#endregion
|
|
740
781
|
//#region src/ui/BaileyTracePanel.tsx
|
|
741
|
-
async function
|
|
782
|
+
async function ye(e) {
|
|
742
783
|
try {
|
|
743
784
|
await navigator.clipboard.writeText(e);
|
|
744
785
|
} catch {}
|
|
745
786
|
}
|
|
746
|
-
function
|
|
747
|
-
return /* @__PURE__ */
|
|
787
|
+
function be({ text: e, label: t = "Copy" }) {
|
|
788
|
+
return /* @__PURE__ */ d("button", {
|
|
748
789
|
type: "button",
|
|
749
|
-
onClick: () =>
|
|
790
|
+
onClick: () => ye(e),
|
|
750
791
|
className: "bailey-trace-copy-button",
|
|
751
792
|
children: t
|
|
752
793
|
});
|
|
753
794
|
}
|
|
754
|
-
function
|
|
795
|
+
function xe(e) {
|
|
755
796
|
if (e.failed || e.kind === "error") return "bailey-trace-chip bailey-trace-chip-error";
|
|
756
797
|
switch (e.kind) {
|
|
757
798
|
case "tool_start": return "bailey-trace-chip bailey-trace-chip-info";
|
|
@@ -761,18 +802,18 @@ function be(e) {
|
|
|
761
802
|
}
|
|
762
803
|
}
|
|
763
804
|
function Q({ label: e, content: t, copyable: n }) {
|
|
764
|
-
return /* @__PURE__ */
|
|
805
|
+
return /* @__PURE__ */ f("details", {
|
|
765
806
|
className: "bailey-trace-disclosure",
|
|
766
807
|
children: [
|
|
767
|
-
/* @__PURE__ */
|
|
808
|
+
/* @__PURE__ */ d("summary", {
|
|
768
809
|
className: "bailey-trace-disclosure-summary",
|
|
769
810
|
children: e
|
|
770
811
|
}),
|
|
771
|
-
n && /* @__PURE__ */
|
|
812
|
+
n && /* @__PURE__ */ d("div", {
|
|
772
813
|
className: "bailey-trace-disclosure-actions",
|
|
773
|
-
children: /* @__PURE__ */
|
|
814
|
+
children: /* @__PURE__ */ d(be, { text: t })
|
|
774
815
|
}),
|
|
775
|
-
/* @__PURE__ */
|
|
816
|
+
/* @__PURE__ */ d("pre", {
|
|
776
817
|
className: "bailey-trace-disclosure-content",
|
|
777
818
|
children: t
|
|
778
819
|
})
|
|
@@ -780,53 +821,53 @@ function Q({ label: e, content: t, copyable: n }) {
|
|
|
780
821
|
});
|
|
781
822
|
}
|
|
782
823
|
function $({ row: e }) {
|
|
783
|
-
return /* @__PURE__ */
|
|
824
|
+
return /* @__PURE__ */ f("div", {
|
|
784
825
|
className: "bailey-trace-row",
|
|
785
826
|
children: [
|
|
786
|
-
/* @__PURE__ */
|
|
827
|
+
/* @__PURE__ */ f("div", {
|
|
787
828
|
className: "bailey-trace-row-header",
|
|
788
829
|
children: [
|
|
789
|
-
/* @__PURE__ */
|
|
830
|
+
/* @__PURE__ */ d("span", {
|
|
790
831
|
className: "bailey-trace-row-time",
|
|
791
832
|
children: e.time
|
|
792
833
|
}),
|
|
793
|
-
/* @__PURE__ */
|
|
834
|
+
/* @__PURE__ */ d("span", {
|
|
794
835
|
className: "bailey-trace-row-gap",
|
|
795
836
|
title: "Time since the previous event",
|
|
796
|
-
children:
|
|
837
|
+
children: ae(e.gapMs)
|
|
797
838
|
}),
|
|
798
|
-
/* @__PURE__ */
|
|
799
|
-
className:
|
|
839
|
+
/* @__PURE__ */ d("span", {
|
|
840
|
+
className: xe(e),
|
|
800
841
|
children: e.label
|
|
801
842
|
}),
|
|
802
|
-
/* @__PURE__ */
|
|
843
|
+
/* @__PURE__ */ d("span", {
|
|
803
844
|
className: "bailey-trace-row-summary",
|
|
804
845
|
children: e.summary
|
|
805
846
|
})
|
|
806
847
|
]
|
|
807
848
|
}),
|
|
808
|
-
e.argsDetail && /* @__PURE__ */
|
|
849
|
+
e.argsDetail && /* @__PURE__ */ d(Q, {
|
|
809
850
|
label: "args",
|
|
810
851
|
content: e.argsDetail
|
|
811
852
|
}),
|
|
812
|
-
e.outputDetail && /* @__PURE__ */
|
|
853
|
+
e.outputDetail && /* @__PURE__ */ d(Q, {
|
|
813
854
|
label: "output",
|
|
814
855
|
content: e.outputDetail
|
|
815
856
|
}),
|
|
816
|
-
e.rawDetail && /* @__PURE__ */
|
|
857
|
+
e.rawDetail && /* @__PURE__ */ d(Q, {
|
|
817
858
|
label: "raw",
|
|
818
859
|
content: e.rawDetail
|
|
819
860
|
})
|
|
820
861
|
]
|
|
821
862
|
});
|
|
822
863
|
}
|
|
823
|
-
function
|
|
864
|
+
function Se(e, t) {
|
|
824
865
|
if (e.chunkCount === 0) return "Streamed: no chunks received";
|
|
825
866
|
if (e.chunkCount === 1 || e.firstChunkAt === null) return "Streamed: 1 chunk (not incremental)";
|
|
826
867
|
let n = e.firstChunkAt - t, r = (e.lastChunkAt ?? e.firstChunkAt) - e.firstChunkAt;
|
|
827
868
|
return `Streamed: ${e.chunkCount} chunks · first chunk after ${n}ms · spread over ${(r / 1e3).toFixed(1)}s`;
|
|
828
869
|
}
|
|
829
|
-
function
|
|
870
|
+
function Ce({ request: e }) {
|
|
830
871
|
let t = i(() => JSON.stringify({
|
|
831
872
|
model: e.model,
|
|
832
873
|
instructions: e.systemPrompt,
|
|
@@ -835,10 +876,10 @@ function Se({ request: e }) {
|
|
|
835
876
|
tools: e.tools,
|
|
836
877
|
toolChoice: e.toolChoice
|
|
837
878
|
}, null, 2), [e]);
|
|
838
|
-
return /* @__PURE__ */
|
|
879
|
+
return /* @__PURE__ */ f("div", {
|
|
839
880
|
className: "bailey-trace-request-details",
|
|
840
881
|
children: [
|
|
841
|
-
/* @__PURE__ */
|
|
882
|
+
/* @__PURE__ */ f("span", {
|
|
842
883
|
className: "bailey-trace-request-meta",
|
|
843
884
|
children: [
|
|
844
885
|
"Last request — ",
|
|
@@ -848,26 +889,26 @@ function Se({ request: e }) {
|
|
|
848
889
|
e.requestId ? ` · ${e.requestId}` : ""
|
|
849
890
|
]
|
|
850
891
|
}),
|
|
851
|
-
/* @__PURE__ */
|
|
892
|
+
/* @__PURE__ */ d("span", {
|
|
852
893
|
className: "bailey-trace-request-meta",
|
|
853
|
-
children:
|
|
894
|
+
children: Se(e.streamStats, e.sentAt)
|
|
854
895
|
}),
|
|
855
|
-
/* @__PURE__ */
|
|
896
|
+
/* @__PURE__ */ d(Q, {
|
|
856
897
|
label: `System prompt (${e.systemPrompt.length.toLocaleString()} chars)`,
|
|
857
898
|
content: e.systemPrompt,
|
|
858
899
|
copyable: !0
|
|
859
900
|
}),
|
|
860
|
-
/* @__PURE__ */
|
|
901
|
+
/* @__PURE__ */ d(Q, {
|
|
861
902
|
label: `Messages (${e.messages.length})`,
|
|
862
903
|
content: JSON.stringify(e.messages, null, 2),
|
|
863
904
|
copyable: !0
|
|
864
905
|
}),
|
|
865
|
-
e.response && /* @__PURE__ */
|
|
906
|
+
e.response && /* @__PURE__ */ d(Q, {
|
|
866
907
|
label: `Response (${e.response.content.length.toLocaleString()} chars)`,
|
|
867
908
|
content: e.response.content,
|
|
868
909
|
copyable: !0
|
|
869
910
|
}),
|
|
870
|
-
/* @__PURE__ */
|
|
911
|
+
/* @__PURE__ */ d(Q, {
|
|
871
912
|
label: "Full payload (JSON)",
|
|
872
913
|
content: t,
|
|
873
914
|
copyable: !0
|
|
@@ -875,43 +916,43 @@ function Se({ request: e }) {
|
|
|
875
916
|
]
|
|
876
917
|
});
|
|
877
918
|
}
|
|
878
|
-
function
|
|
879
|
-
let r = i(() =>
|
|
880
|
-
return /* @__PURE__ */
|
|
919
|
+
function we({ events: e, lastRequest: t, onClear: n }) {
|
|
920
|
+
let r = i(() => oe(e), [e]), a = i(() => ce(r), [r]), o = i(() => JSON.stringify(e, null, 2), [e]);
|
|
921
|
+
return /* @__PURE__ */ f("div", {
|
|
881
922
|
className: "bailey-trace-body",
|
|
882
923
|
children: [
|
|
883
|
-
/* @__PURE__ */
|
|
924
|
+
/* @__PURE__ */ f("div", {
|
|
884
925
|
className: "bailey-trace-actions-row",
|
|
885
|
-
children: [e.length > 0 && /* @__PURE__ */
|
|
926
|
+
children: [e.length > 0 && /* @__PURE__ */ d(be, {
|
|
886
927
|
text: o,
|
|
887
928
|
label: "Copy trace as JSON"
|
|
888
|
-
}), /* @__PURE__ */
|
|
929
|
+
}), /* @__PURE__ */ d("button", {
|
|
889
930
|
type: "button",
|
|
890
931
|
onClick: n,
|
|
891
932
|
className: "bailey-trace-copy-button",
|
|
892
933
|
children: "Clear"
|
|
893
934
|
})]
|
|
894
935
|
}),
|
|
895
|
-
t && /* @__PURE__ */
|
|
896
|
-
/* @__PURE__ */
|
|
936
|
+
t && /* @__PURE__ */ d(Ce, { request: t }),
|
|
937
|
+
/* @__PURE__ */ d("div", {
|
|
897
938
|
className: "bailey-trace-rows",
|
|
898
939
|
children: a.map((e, t) => {
|
|
899
|
-
if (e.type === "single") return /* @__PURE__ */
|
|
940
|
+
if (e.type === "single") return /* @__PURE__ */ d($, { row: e.row }, e.row.key);
|
|
900
941
|
let n = e.rows.filter((e) => e.isToolStart).length;
|
|
901
|
-
if (n <= 1) return /* @__PURE__ */
|
|
942
|
+
if (n <= 1) return /* @__PURE__ */ d("div", {
|
|
902
943
|
className: "bailey-trace-rows",
|
|
903
|
-
children: e.rows.map((e) => /* @__PURE__ */
|
|
944
|
+
children: e.rows.map((e) => /* @__PURE__ */ d($, { row: e }, e.key))
|
|
904
945
|
}, `group-${t}`);
|
|
905
946
|
let r = e.rows.filter((e) => e.failed).length;
|
|
906
|
-
return /* @__PURE__ */
|
|
947
|
+
return /* @__PURE__ */ f("details", {
|
|
907
948
|
className: "bailey-trace-group",
|
|
908
|
-
children: [/* @__PURE__ */
|
|
949
|
+
children: [/* @__PURE__ */ f("summary", {
|
|
909
950
|
className: "bailey-trace-group-summary",
|
|
910
951
|
children: [
|
|
911
|
-
/* @__PURE__ */
|
|
952
|
+
/* @__PURE__ */ d("strong", { children: e.toolName }),
|
|
912
953
|
" × ",
|
|
913
954
|
n,
|
|
914
|
-
r > 0 && /* @__PURE__ */
|
|
955
|
+
r > 0 && /* @__PURE__ */ f("span", {
|
|
915
956
|
className: "bailey-trace-group-failed",
|
|
916
957
|
children: [
|
|
917
958
|
" ",
|
|
@@ -920,9 +961,9 @@ function Ce({ events: e, lastRequest: t, onClear: n }) {
|
|
|
920
961
|
]
|
|
921
962
|
})
|
|
922
963
|
]
|
|
923
|
-
}), /* @__PURE__ */
|
|
964
|
+
}), /* @__PURE__ */ d("div", {
|
|
924
965
|
className: "bailey-trace-rows",
|
|
925
|
-
children: e.rows.map((e) => /* @__PURE__ */
|
|
966
|
+
children: e.rows.map((e) => /* @__PURE__ */ d($, { row: e }, e.key))
|
|
926
967
|
})]
|
|
927
968
|
}, `group-${t}`);
|
|
928
969
|
})
|
|
@@ -930,13 +971,13 @@ function Ce({ events: e, lastRequest: t, onClear: n }) {
|
|
|
930
971
|
]
|
|
931
972
|
});
|
|
932
973
|
}
|
|
933
|
-
function
|
|
934
|
-
let [r, a] = o(!1), s = i(() =>
|
|
935
|
-
return e.length === 0 && !t ? null : /* @__PURE__ */
|
|
974
|
+
function Te({ events: e, lastRequest: t, onClear: n }) {
|
|
975
|
+
let [r, a] = o(!1), s = i(() => le(e), [e]), c = i(() => se(e), [e]);
|
|
976
|
+
return e.length === 0 && !t ? null : /* @__PURE__ */ f("div", {
|
|
936
977
|
className: "bailey-trace-panel",
|
|
937
|
-
children: [/* @__PURE__ */
|
|
978
|
+
children: [/* @__PURE__ */ f("div", {
|
|
938
979
|
className: "bailey-trace-toggle-row",
|
|
939
|
-
children: [/* @__PURE__ */
|
|
980
|
+
children: [/* @__PURE__ */ f("button", {
|
|
940
981
|
type: "button",
|
|
941
982
|
onClick: () => a((e) => !e),
|
|
942
983
|
"aria-expanded": r,
|
|
@@ -948,11 +989,11 @@ function we({ events: e, lastRequest: t, onClear: n }) {
|
|
|
948
989
|
e.length,
|
|
949
990
|
")"
|
|
950
991
|
]
|
|
951
|
-
}), c && /* @__PURE__ */
|
|
992
|
+
}), c && /* @__PURE__ */ d("span", {
|
|
952
993
|
className: s ? "bailey-trace-summary bailey-trace-summary-error" : "bailey-trace-summary",
|
|
953
994
|
children: c
|
|
954
995
|
})]
|
|
955
|
-
}), r && /* @__PURE__ */
|
|
996
|
+
}), r && /* @__PURE__ */ d(we, {
|
|
956
997
|
events: e,
|
|
957
998
|
lastRequest: t,
|
|
958
999
|
onClear: n
|
|
@@ -961,190 +1002,237 @@ function we({ events: e, lastRequest: t, onClear: n }) {
|
|
|
961
1002
|
}
|
|
962
1003
|
//#endregion
|
|
963
1004
|
//#region src/ui/BaileyChatPanel.tsx
|
|
964
|
-
var
|
|
965
|
-
|
|
1005
|
+
var Ee = "How can bailey AI help you today?", De = "Reply to bailey AI", Oe = {
|
|
1006
|
+
newChatButtonText: "New chat",
|
|
1007
|
+
newChatAriaLabel: "new chat",
|
|
1008
|
+
suggestionsTitle: "Suggested for you",
|
|
1009
|
+
emptyStateMessage: "Ask Bailey a question to get started.",
|
|
1010
|
+
youLabel: "You",
|
|
1011
|
+
thinkingHint: "Thinking…",
|
|
1012
|
+
retryButtonText: "Retry",
|
|
1013
|
+
dismissErrorAriaLabel: "dismiss error",
|
|
1014
|
+
sendAriaLabel: "send",
|
|
1015
|
+
stopButtonText: "Stop",
|
|
1016
|
+
stopAriaLabel: "stop",
|
|
1017
|
+
copyButtonAriaLabel: "copy response as markdown",
|
|
1018
|
+
copyButtonTooltipDefault: "Copy as markdown",
|
|
1019
|
+
copyButtonTooltipCopied: "Copied!"
|
|
1020
|
+
}, ke = [c], Ae = t(function({ content: e, components: t }) {
|
|
1021
|
+
return /* @__PURE__ */ d("div", {
|
|
966
1022
|
className: "bailey-markdown-content",
|
|
967
|
-
children: /* @__PURE__ */
|
|
968
|
-
remarkPlugins:
|
|
1023
|
+
children: /* @__PURE__ */ d(s, {
|
|
1024
|
+
remarkPlugins: ke,
|
|
969
1025
|
components: t,
|
|
1026
|
+
skipHtml: !0,
|
|
970
1027
|
children: e
|
|
971
1028
|
})
|
|
972
1029
|
});
|
|
973
1030
|
});
|
|
974
|
-
function
|
|
1031
|
+
function je(e, t, n) {
|
|
975
1032
|
if (e !== "streaming") return;
|
|
976
1033
|
let r = t.filter((e) => e.turnSentAt === n?.sentAt);
|
|
977
|
-
if (r.length !== 0) return
|
|
1034
|
+
if (r.length !== 0) return X(r[r.length - 1]);
|
|
978
1035
|
}
|
|
979
|
-
function
|
|
1036
|
+
function Me(e) {
|
|
980
1037
|
let t = new Date(e), n = t.toDateString() === (/* @__PURE__ */ new Date()).toDateString(), r = t.toLocaleTimeString([], {
|
|
981
1038
|
hour: "numeric",
|
|
982
1039
|
minute: "2-digit"
|
|
983
1040
|
});
|
|
984
1041
|
return n ? `Today ${r}` : `${t.toLocaleDateString()} ${r}`;
|
|
985
1042
|
}
|
|
986
|
-
function
|
|
987
|
-
let { messages:
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
}
|
|
991
|
-
|
|
992
|
-
b
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
1043
|
+
function Ne({ chat: e, placeholder: t, replyPlaceholder: n = De, emptyPlaceholder: s, suggestions: c, privacyNote: u, resolveActivityIcon: p, className: m, height: h, width: g, hideDeveloperDetails: _ = !1, renderMessageActions: v, renderTable: y, renderChart: b, labels: x, formatMessageTime: S }) {
|
|
1044
|
+
let { messages: C, traceEvents: w, lastRequest: T, status: E, error: D, send: O, stop: k, retryLast: A, clearTrace: j, clearError: M, newChat: N } = e, [P, F] = o(""), I = {
|
|
1045
|
+
...Oe,
|
|
1046
|
+
...x
|
|
1047
|
+
}, L = S ?? Me, R = a(null), z = a(null), B = a(!0), V = i(() => de({
|
|
1048
|
+
renderTable: y,
|
|
1049
|
+
renderChart: b
|
|
1050
|
+
}), [y, b]), H = i(() => je(E, w, T), [
|
|
1051
|
+
E,
|
|
1052
|
+
w,
|
|
1053
|
+
T
|
|
1054
|
+
]), U = C.length === 0, W = t ?? (U ? s ?? Ee : n);
|
|
1055
|
+
r(() => {
|
|
1056
|
+
let e = z.current;
|
|
1057
|
+
if (!e) return;
|
|
1058
|
+
let t = () => {
|
|
1059
|
+
let t = e.scrollHeight - e.scrollTop - e.clientHeight;
|
|
1060
|
+
B.current = t < 60;
|
|
1061
|
+
};
|
|
1062
|
+
return e.addEventListener("scroll", t, { passive: !0 }), () => e.removeEventListener("scroll", t);
|
|
1063
|
+
}, []), r(() => {
|
|
1064
|
+
B.current && R.current?.scrollIntoView({
|
|
1065
|
+
behavior: E === "streaming" ? "auto" : "smooth",
|
|
998
1066
|
block: "nearest"
|
|
999
1067
|
});
|
|
1000
|
-
}, [
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1068
|
+
}, [C, E]);
|
|
1069
|
+
let G = (e) => {
|
|
1070
|
+
B.current = !0, O(e);
|
|
1071
|
+
};
|
|
1072
|
+
return /* @__PURE__ */ d("div", {
|
|
1073
|
+
className: `bailey-chat-panel${m ? ` ${m}` : ""}`,
|
|
1074
|
+
style: h !== void 0 || g !== void 0 ? {
|
|
1075
|
+
height: h,
|
|
1076
|
+
width: g
|
|
1005
1077
|
} : void 0,
|
|
1006
|
-
children: /* @__PURE__ */
|
|
1078
|
+
children: /* @__PURE__ */ f("div", {
|
|
1007
1079
|
className: "bailey-chat-panel-inner",
|
|
1008
1080
|
children: [
|
|
1009
|
-
/* @__PURE__ */
|
|
1081
|
+
/* @__PURE__ */ d("div", {
|
|
1010
1082
|
className: "bailey-toolbar-row",
|
|
1011
|
-
children: /* @__PURE__ */
|
|
1083
|
+
children: /* @__PURE__ */ d("button", {
|
|
1012
1084
|
type: "button",
|
|
1013
|
-
onClick:
|
|
1014
|
-
disabled:
|
|
1015
|
-
"aria-label":
|
|
1085
|
+
onClick: N,
|
|
1086
|
+
disabled: C.length === 0,
|
|
1087
|
+
"aria-label": I.newChatAriaLabel,
|
|
1016
1088
|
className: "bailey-new-chat-button",
|
|
1017
|
-
children:
|
|
1089
|
+
children: I.newChatButtonText
|
|
1018
1090
|
})
|
|
1019
1091
|
}),
|
|
1020
|
-
/* @__PURE__ */
|
|
1092
|
+
/* @__PURE__ */ f("div", {
|
|
1021
1093
|
className: "bailey-chat-transcript",
|
|
1094
|
+
ref: z,
|
|
1022
1095
|
children: [
|
|
1023
|
-
|
|
1096
|
+
U && (c && c.length > 0 ? /* @__PURE__ */ f("div", {
|
|
1024
1097
|
className: "bailey-suggestions",
|
|
1025
|
-
children: [/* @__PURE__ */
|
|
1098
|
+
children: [/* @__PURE__ */ d("div", {
|
|
1026
1099
|
className: "bailey-suggestions-title",
|
|
1027
|
-
children:
|
|
1028
|
-
}),
|
|
1100
|
+
children: I.suggestionsTitle
|
|
1101
|
+
}), c.map((e, t) => /* @__PURE__ */ f("button", {
|
|
1029
1102
|
type: "button",
|
|
1030
|
-
onClick: () =>
|
|
1103
|
+
onClick: () => G(e.value ?? e.label),
|
|
1031
1104
|
className: "bailey-suggestion-card",
|
|
1032
|
-
children: [/* @__PURE__ */
|
|
1105
|
+
children: [/* @__PURE__ */ d("span", { children: e.label }), /* @__PURE__ */ d(Z, { className: "bailey-suggestion-icon" })]
|
|
1033
1106
|
}, `${e.label}-${t}`))]
|
|
1034
|
-
}) : /* @__PURE__ */
|
|
1107
|
+
}) : /* @__PURE__ */ d("div", {
|
|
1035
1108
|
className: "bailey-empty-state",
|
|
1036
|
-
children:
|
|
1109
|
+
children: I.emptyStateMessage
|
|
1037
1110
|
})),
|
|
1038
|
-
|
|
1039
|
-
let n = e.role === "assistant" && t ===
|
|
1040
|
-
return /* @__PURE__ */
|
|
1111
|
+
C.map((e, t) => {
|
|
1112
|
+
let n = e.role === "assistant" && t === C.length - 1, r = E === "streaming" && n && e.content === "", i = e.role === "assistant" && !r ? ue(w, e.createdAt) : [], a = i[i.length - 1];
|
|
1113
|
+
return /* @__PURE__ */ d("div", {
|
|
1041
1114
|
className: e.role === "user" ? "bailey-message-row bailey-message-row-user" : "bailey-message-row",
|
|
1042
|
-
children: e.role === "user" ? /* @__PURE__ */
|
|
1115
|
+
children: e.role === "user" ? /* @__PURE__ */ f("div", {
|
|
1043
1116
|
className: "bailey-user-message",
|
|
1044
|
-
children: [/* @__PURE__ */
|
|
1117
|
+
children: [/* @__PURE__ */ f("div", {
|
|
1045
1118
|
className: "bailey-message-meta",
|
|
1046
|
-
children: [/* @__PURE__ */
|
|
1119
|
+
children: [/* @__PURE__ */ d("span", {
|
|
1047
1120
|
className: "bailey-message-meta-name",
|
|
1048
|
-
children:
|
|
1049
|
-
}), e.createdAt !== void 0 && /* @__PURE__ */
|
|
1050
|
-
}), /* @__PURE__ */
|
|
1121
|
+
children: I.youLabel
|
|
1122
|
+
}), e.createdAt !== void 0 && /* @__PURE__ */ d("span", { children: L(e.createdAt) })]
|
|
1123
|
+
}), /* @__PURE__ */ d("div", {
|
|
1051
1124
|
className: "bailey-user-bubble",
|
|
1052
1125
|
children: e.content
|
|
1053
1126
|
})]
|
|
1054
|
-
}) : r ? /* @__PURE__ */
|
|
1127
|
+
}) : r ? /* @__PURE__ */ d("div", {
|
|
1055
1128
|
className: "bailey-thinking-hint",
|
|
1056
|
-
children:
|
|
1057
|
-
}) : /* @__PURE__ */
|
|
1129
|
+
children: H ?? I.thinkingHint
|
|
1130
|
+
}) : /* @__PURE__ */ f("div", {
|
|
1058
1131
|
className: "bailey-assistant-message",
|
|
1059
1132
|
children: [
|
|
1060
|
-
a && /* @__PURE__ */
|
|
1133
|
+
a && /* @__PURE__ */ f("div", {
|
|
1061
1134
|
className: "bailey-activity-line",
|
|
1062
|
-
children: [/* @__PURE__ */
|
|
1135
|
+
children: [/* @__PURE__ */ d("span", {
|
|
1063
1136
|
className: "bailey-activity-icon",
|
|
1064
|
-
children:
|
|
1065
|
-
}), /* @__PURE__ */
|
|
1137
|
+
children: p?.(a.toolName) ?? /* @__PURE__ */ d(ge, {})
|
|
1138
|
+
}), /* @__PURE__ */ d("span", { children: a.text })]
|
|
1066
1139
|
}),
|
|
1067
|
-
/* @__PURE__ */
|
|
1140
|
+
/* @__PURE__ */ d(Ae, {
|
|
1068
1141
|
content: e.content,
|
|
1069
|
-
components:
|
|
1142
|
+
components: V
|
|
1070
1143
|
}),
|
|
1071
|
-
e.streaming &&
|
|
1144
|
+
e.streaming && H && /* @__PURE__ */ d("div", {
|
|
1072
1145
|
className: "bailey-streaming-hint",
|
|
1073
|
-
children:
|
|
1146
|
+
children: H
|
|
1074
1147
|
}),
|
|
1075
|
-
!e.streaming && /* @__PURE__ */
|
|
1148
|
+
!e.streaming && /* @__PURE__ */ f("div", {
|
|
1076
1149
|
className: "bailey-message-actions",
|
|
1077
|
-
children: [/* @__PURE__ */
|
|
1150
|
+
children: [/* @__PURE__ */ d(ve, {
|
|
1151
|
+
markdown: e.content,
|
|
1152
|
+
ariaLabel: I.copyButtonAriaLabel,
|
|
1153
|
+
tooltipDefaultText: I.copyButtonTooltipDefault,
|
|
1154
|
+
tooltipCopiedText: I.copyButtonTooltipCopied
|
|
1155
|
+
}), v?.(e)]
|
|
1078
1156
|
})
|
|
1079
1157
|
]
|
|
1080
1158
|
})
|
|
1081
1159
|
}, e.id);
|
|
1082
1160
|
}),
|
|
1083
|
-
/* @__PURE__ */
|
|
1161
|
+
/* @__PURE__ */ d("div", { ref: R })
|
|
1084
1162
|
]
|
|
1085
1163
|
}),
|
|
1086
|
-
|
|
1164
|
+
U && u && /* @__PURE__ */ f("div", {
|
|
1087
1165
|
className: "bailey-privacy-note",
|
|
1088
1166
|
children: [
|
|
1089
|
-
|
|
1167
|
+
u.text,
|
|
1090
1168
|
" ",
|
|
1091
|
-
/* @__PURE__ */
|
|
1092
|
-
href:
|
|
1169
|
+
/* @__PURE__ */ d("a", {
|
|
1170
|
+
href: u.linkHref,
|
|
1093
1171
|
target: "_blank",
|
|
1094
1172
|
rel: "noreferrer",
|
|
1095
|
-
children:
|
|
1173
|
+
children: u.linkLabel
|
|
1096
1174
|
})
|
|
1097
1175
|
]
|
|
1098
1176
|
}),
|
|
1099
|
-
|
|
1177
|
+
D && /* @__PURE__ */ f("div", {
|
|
1100
1178
|
className: "bailey-error-banner",
|
|
1101
1179
|
role: "alert",
|
|
1102
|
-
children: [/* @__PURE__ */
|
|
1180
|
+
children: [/* @__PURE__ */ d("span", { children: D }), /* @__PURE__ */ f("div", {
|
|
1103
1181
|
className: "bailey-error-actions",
|
|
1104
|
-
children: [/* @__PURE__ */
|
|
1182
|
+
children: [/* @__PURE__ */ d("button", {
|
|
1105
1183
|
type: "button",
|
|
1106
|
-
onClick:
|
|
1184
|
+
onClick: A,
|
|
1107
1185
|
className: "bailey-retry-button",
|
|
1108
|
-
children:
|
|
1109
|
-
}), /* @__PURE__ */
|
|
1186
|
+
children: I.retryButtonText
|
|
1187
|
+
}), /* @__PURE__ */ d("button", {
|
|
1110
1188
|
type: "button",
|
|
1111
|
-
onClick:
|
|
1112
|
-
"aria-label":
|
|
1189
|
+
onClick: M,
|
|
1190
|
+
"aria-label": I.dismissErrorAriaLabel,
|
|
1113
1191
|
className: "bailey-dismiss-button",
|
|
1114
1192
|
children: "✕"
|
|
1115
1193
|
})]
|
|
1116
1194
|
})]
|
|
1117
1195
|
}),
|
|
1118
|
-
!
|
|
1119
|
-
events:
|
|
1120
|
-
lastRequest:
|
|
1121
|
-
onClear:
|
|
1196
|
+
!_ && /* @__PURE__ */ d(Te, {
|
|
1197
|
+
events: w,
|
|
1198
|
+
lastRequest: T,
|
|
1199
|
+
onClear: j
|
|
1122
1200
|
}),
|
|
1123
|
-
/* @__PURE__ */
|
|
1201
|
+
/* @__PURE__ */ f("form", {
|
|
1124
1202
|
onSubmit: (e) => {
|
|
1125
|
-
e.preventDefault(), !(!
|
|
1203
|
+
e.preventDefault(), !(!P.trim() || E === "streaming") && (G(P), F(""));
|
|
1126
1204
|
},
|
|
1127
1205
|
className: "bailey-input-row",
|
|
1128
|
-
children: [/* @__PURE__ */
|
|
1206
|
+
children: [/* @__PURE__ */ d("input", {
|
|
1129
1207
|
type: "text",
|
|
1130
|
-
placeholder:
|
|
1131
|
-
"aria-label":
|
|
1132
|
-
value:
|
|
1133
|
-
onChange: (e) =>
|
|
1134
|
-
disabled:
|
|
1208
|
+
placeholder: W,
|
|
1209
|
+
"aria-label": W,
|
|
1210
|
+
value: P,
|
|
1211
|
+
onChange: (e) => F(e.target.value),
|
|
1212
|
+
disabled: E === "streaming",
|
|
1135
1213
|
className: "bailey-input"
|
|
1136
|
-
}),
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1214
|
+
}), E === "streaming" ? /* @__PURE__ */ d(l.Provider, {
|
|
1215
|
+
delayDuration: 200,
|
|
1216
|
+
children: /* @__PURE__ */ f(l.Root, { children: [/* @__PURE__ */ d(l.Trigger, {
|
|
1217
|
+
asChild: !0,
|
|
1218
|
+
children: /* @__PURE__ */ d("button", {
|
|
1219
|
+
type: "button",
|
|
1220
|
+
onClick: k,
|
|
1221
|
+
"aria-label": I.stopAriaLabel,
|
|
1222
|
+
className: "bailey-stop-button",
|
|
1223
|
+
children: /* @__PURE__ */ d(pe, { className: "bailey-stop-icon" })
|
|
1224
|
+
})
|
|
1225
|
+
}), /* @__PURE__ */ d(l.Portal, { children: /* @__PURE__ */ f(l.Content, {
|
|
1226
|
+
side: "top",
|
|
1227
|
+
className: "bailey-tooltip-content",
|
|
1228
|
+
children: [I.stopButtonText, /* @__PURE__ */ d(l.Arrow, { className: "bailey-tooltip-arrow" })]
|
|
1229
|
+
}) })] })
|
|
1230
|
+
}) : /* @__PURE__ */ d("button", {
|
|
1143
1231
|
type: "submit",
|
|
1144
|
-
"aria-label":
|
|
1145
|
-
disabled: !
|
|
1232
|
+
"aria-label": I.sendAriaLabel,
|
|
1233
|
+
disabled: !P.trim(),
|
|
1146
1234
|
className: "bailey-send-button",
|
|
1147
|
-
children: /* @__PURE__ */
|
|
1235
|
+
children: /* @__PURE__ */ d(fe, { className: "bailey-send-icon" })
|
|
1148
1236
|
})]
|
|
1149
1237
|
})
|
|
1150
1238
|
]
|
|
@@ -1153,6 +1241,6 @@ function je({ chat: e, placeholder: t, replyPlaceholder: n = Ee, suggestions: s,
|
|
|
1153
1241
|
}
|
|
1154
1242
|
//#endregion
|
|
1155
1243
|
//#region src/index.ts
|
|
1156
|
-
var
|
|
1244
|
+
var Pe = "0.3.1-pre.2";
|
|
1157
1245
|
//#endregion
|
|
1158
|
-
export {
|
|
1246
|
+
export { ge as ActivityIcon, Z as ArrowUpRightIcon, Pe as BAILEYAI_CHAT_UI_VERSION, z as BAILEY_CHART_PROMPT_FRAGMENT, j as BAILEY_TABLE_GRID_ROW_THRESHOLD, Ne as BaileyChatPanel, Te as BaileyTracePanel, ve as CopyMarkdownButton, fe as HeartIcon, te as TRACE_KIND_LABEL, de as createBaileyMarkdownComponents, b as extractPseudoToolCalls, L as extractTableData, ae as formatTraceGap, ie as formatTraceTime, le as hasTraceFailure, e as isSafeMarkdownUrl, D as joinInstructions, ee as parseBaileyChartSpec, S as parseSseFrames, A as resolveToolCall, R as shouldUseGrid, ue as toActivityLines, oe as toTraceRows, ce as toTraceSegments, re as traceEventArgsDetail, X as traceEventHint, J as traceEventOutputDetail, Y as traceEventRawDetail, ne as traceEventSummary, q as traceEventToolName, se as traceSummaryLine, E as useBaileyChat };
|