@icanbwell/baileyai-chat-ui 0.4.3 → 0.5.0

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.
@@ -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, ee = (e, t, n) => {
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
- }, T = ({ 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), T = a(null), E = a(""), D = a(0), O = a([]);
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
- O.current = f;
115
+ k.current = f;
116
116
  }, [f]);
117
- let k = a(/* @__PURE__ */ new Map()), A = a(/* @__PURE__ */ new Map()), j = a(null), M = n(() => {
118
- j.current !== null && (clearTimeout(j.current), j.current = null);
119
- }, []), N = n((e) => {
120
- M(), j.current = setTimeout(() => {
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
- }, [M, d]), P = n((e, t, n) => {
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 = k.current.get(e) ?? {
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, k.current.set(e, n), A.current.set(e, o), p((t) => t.map((t) => t.id === e ? {
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 = D.current;
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 = D.current, a = e.name || "unknown_tool";
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: D.current
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: D.current
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: D.current
189
+ turnSentAt: O.current
190
190
  }), !0);
191
- }, []), F = n(async (n) => {
191
+ }, []), L = n(async (n) => {
192
192
  y("streaming"), C(null);
193
193
  let r = Date.now();
194
- D.current = r;
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
- let o = n.map((e, t) => t === 0 && e.role === "user" && l ? {
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: o,
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 d = new AbortController();
225
- T.current = d, N(d);
226
- let f = "", m = null, g = !1, v = !1, b = [], x = (e, t) => {
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
- b.push(n), h((e) => [...e, n]);
236
- }, w = (e, t) => {
235
+ w.push(n), h((e) => [...e, n]);
236
+ }, k = (e, t) => {
237
237
  e.forEach((e) => {
238
238
  if (e.type === "error") {
239
- m = e.message;
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
- b.push(t), h((e) => [...e, t]);
246
+ w.push(t), h((e) => [...e, t]);
247
247
  return;
248
248
  }
249
- e.type === "response.output_text.delta" && e.delta && (v = !0), P(a, e, b) && (g = !0);
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: l, errorMessage: p } = await e.streamChat({
256
+ let { status: n, text: o, errorMessage: l } = await e.streamChat({
257
257
  model: t,
258
258
  instructions: i,
259
- input: o,
259
+ input: f,
260
260
  tools: s,
261
261
  toolChoice: c,
262
- signal: d.signal,
262
+ signal: m.signal,
263
263
  onChunk: (e) => {
264
- N(d), f += e;
265
- let { events: t, remainder: n, done: i } = S(f);
266
- f = n, w(t, i);
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 (f.trim()) {
285
- let { events: e, done: t } = S(`${f}\n\n`);
286
- f = "", w(e, t);
284
+ if (g.trim()) {
285
+ let { events: e, done: t } = S(`${g}\n\n`);
286
+ g = "", k(e, t);
287
287
  }
288
- if (m) {
289
- y("error"), C(m);
288
+ if (v) {
289
+ y("error"), C(v);
290
290
  return;
291
291
  }
292
292
  if (n === void 0 || n >= 400) {
293
- x(ee(n, l, p), {
293
+ D(T(n, o, l), {
294
294
  httpStatus: n,
295
- rawBody: l || void 0
295
+ rawBody: o || void 0
296
296
  });
297
297
  return;
298
298
  }
299
- if (!g) {
300
- x("Bailey returned an empty response.");
299
+ if (!b) {
300
+ D("Bailey returned an empty response.");
301
301
  return;
302
302
  }
303
- if (!v) {
304
- x("Bailey ran some tools but didn't return an answer. Try asking again.");
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 h = A.current.get(a) ?? "";
308
+ let d = M.current.get(a) ?? "";
309
309
  _((e) => e && e.sentAt === r ? {
310
310
  ...e,
311
- response: { content: h }
311
+ response: { content: d }
312
312
  } : e), u && await u({
313
313
  id: a,
314
314
  role: "assistant",
315
- content: h,
315
+ content: d,
316
316
  streaming: !1
317
- }, b);
317
+ }, w);
318
318
  } catch (e) {
319
319
  let t = e;
320
320
  if (t?.name === "TimeoutError") {
321
- x(t.message, { source: "client-timeout" });
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
- x(t?.message || "Bailey request failed.");
328
+ D(t?.message || "Bailey request failed.");
329
329
  } finally {
330
- M(), k.current.delete(a), A.current.delete(a), p((e) => e.flatMap((e) => e.id === a ? e.content ? [{
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
- P,
344
- N,
345
- M
346
- ]), I = n((e) => {
347
- O.current = e, p(e);
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
- E.current = t;
359
- let n = [...O.current, {
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
- I(n), F(n);
366
- }, [F, I]),
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
- T.current?.abort();
388
+ E.current?.abort();
369
389
  }, []),
370
390
  retryLast: n(() => {
371
- if (!E.current) return;
372
- let e = O.current, t = e[e.length - 1], n = t && t.role === "assistant" ? e.slice(0, -1) : e;
373
- I(n), F(n);
374
- }, [F, I]),
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
- T.current?.abort(), I([]), h([]), _(null), y("idle"), C(null), E.current = "";
381
- }, [I])
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 E(...e) {
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 D = "call_tool", O = "a tool";
392
- function k(e, t) {
417
+ var O = "call_tool", k = "a tool";
418
+ function A(e, t) {
393
419
  let n = {
394
- name: e === D ? O : 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 === D) {
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 A = 5, j = (e) => e.type === "text" ? e.value ?? "" : (e.children ?? []).map(j).join(""), M = (e) => {
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 = M(t);
454
+ let e = N(t);
429
455
  if (e) return e;
430
456
  }
431
- }, N = (e, t) => (e.children ?? []).find((e) => e.tagName === t), P = (e) => {
432
- let t = j(e), n = M(e);
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
- }, F = (e) => (e.children ?? []).filter((e) => e.type === "element").map(P), I = (e) => {
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 = N(e, "thead"), n = t && N(t, "tr");
465
+ let t = P(e, "thead"), n = t && P(t, "tr");
440
466
  return {
441
- headers: n ? F(n).map((e) => e.text) : [],
442
- rows: (N(e, "tbody")?.children ?? []).filter((e) => e.tagName === "tr").map(F)
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
- }, te = (e) => e.length > 5, ne = "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```", re = [
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```", ee = [
445
471
  "bar",
446
472
  "line",
447
473
  "pie",
448
474
  "doughnut",
449
475
  "scatter"
450
- ], ie = 8, ae = 50, oe = 8, se = 500, ce = (e) => typeof e == "object" && !!e && typeof e.x == "number" && typeof e.y == "number", L = (e) => {
476
+ ], B = 8, V = 50, H = 8, U = 500, te = (e) => typeof e == "object" && !!e && typeof e.x == "number" && typeof e.y == "number", W = (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" || !re.includes(n.type)) return null;
485
+ if (typeof n.type != "string" || !ee.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 > ie || (r === "pie" || r === "doughnut") && a.datasets.length !== 1) return null;
491
+ if (!Array.isArray(a.datasets) || a.datasets.length < 1 || a.datasets.length > B || (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 > se || !e.data.every(ce)) return null;
495
+ for (let e of o) if (e.data.length < 1 || e.data.length > U || !e.data.every(te)) 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" ? oe : ae;
503
+ let s = a.labels, c = r === "pie" || r === "doughnut" ? H : V;
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
- }, le = {
514
+ }, G = {
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 R(e) {
498
- return e.kind !== "tool_start" && e.kind !== "tool_end" ? null : k(e.name, e.args);
523
+ function K(e) {
524
+ return e.kind !== "tool_start" && e.kind !== "tool_end" ? null : A(e.name, e.args);
499
525
  }
500
- function z(e, t = R(e)) {
526
+ function q(e, t = K(e)) {
501
527
  return e.kind === "pseudo_tool_call" ? e.name : t?.name ?? null;
502
528
  }
503
- function ue(e, t = R(e)) {
529
+ function J(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 B(e, t = R(e)) {
540
+ function Y(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 V(e) {
543
+ function X(e) {
518
544
  return e.kind === "tool_end" ? e.output ?? null : null;
519
545
  }
520
- function H(e) {
546
+ function ne(e) {
521
547
  return e.kind === "raw" ? e.raw : e.kind === "error" ? e.rawBody ?? null : null;
522
548
  }
523
- function U(e) {
549
+ function Z(e) {
524
550
  switch (e.kind) {
525
- case "tool_start": return `Calling ${k(e.name, e.args).name}...`;
551
+ case "tool_start": return `Calling ${A(e.name, e.args).name}...`;
526
552
  case "tool_end": {
527
- let t = k(e.name, e.args).name;
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 W(e) {
563
+ function re(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 G(e) {
567
+ function ie(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 K(e) {
575
+ function ae(e) {
550
576
  return e.map((t, n) => {
551
- let r = R(t), i = n === 0 ? t.turnSentAt : e[n - 1].at;
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: z(t, r),
581
+ toolName: q(t, r),
556
582
  isToolStart: t.kind === "tool_start",
557
583
  failed: t.kind === "tool_end" && t.isError === !0,
558
- time: W(t.at),
584
+ time: re(t.at),
559
585
  gapMs: t.at - i,
560
- label: t.kind === "tool_end" && t.isError === !0 ? "Tool failed" : le[t.kind],
561
- summary: ue(t, r),
562
- argsDetail: B(t, r),
563
- outputDetail: V(t),
564
- rawDetail: H(t)
586
+ label: t.kind === "tool_end" && t.isError === !0 ? "Tool failed" : G[t.kind],
587
+ summary: J(t, r),
588
+ argsDetail: Y(t, r),
589
+ outputDetail: X(t),
590
+ rawDetail: ne(t)
565
591
  };
566
592
  });
567
593
  }
568
- function q(e) {
594
+ function oe(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 J(e) {
598
+ function se(e) {
573
599
  let t = [];
574
600
  for (let n of e) {
575
601
  let e = t[t.length - 1];
@@ -588,19 +614,19 @@ function J(e) {
588
614
  }
589
615
  return t;
590
616
  }
591
- function Y(e) {
617
+ function ce(e) {
592
618
  return e.some((e) => e.kind === "tool_end" && e.isError || e.kind === "error");
593
619
  }
594
- function X(e, t) {
620
+ function le(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: U(e),
598
- toolName: z(e)
623
+ text: Z(e),
624
+ toolName: q(e)
599
625
  }));
600
626
  }
601
627
  //#endregion
602
628
  //#region src/ui/markdown.tsx
603
- function de({ renderTable: t, renderChart: n } = {}) {
629
+ function ue({ renderTable: t, renderChart: n } = {}) {
604
630
  return {
605
631
  a: ({ href: t, children: n }) => !t || !e(t) ? /* @__PURE__ */ u(l, { children: n }) : /* @__PURE__ */ u("a", {
606
632
  href: t,
@@ -609,8 +635,8 @@ function de({ renderTable: t, renderChart: n } = {}) {
609
635
  children: n
610
636
  }),
611
637
  table: ({ node: n, children: r }) => {
612
- let i = n && I(n);
613
- if (i && te(i.rows) && t) {
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
641
  return /* @__PURE__ */ u(l, { children: t({
616
642
  headers: i.headers,
@@ -622,7 +648,7 @@ function de({ renderTable: t, renderChart: n } = {}) {
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 = L(Array.isArray(e) ? e.join("") : String(e ?? ""));
651
+ let e = t?.children, r = W(Array.isArray(e) ? e.join("") : String(e ?? ""));
626
652
  if (r) return /* @__PURE__ */ u(l, { children: n(r) });
627
653
  }
628
654
  return /* @__PURE__ */ u("pre", { children: e });
@@ -631,7 +657,7 @@ function de({ renderTable: t, renderChart: n } = {}) {
631
657
  }
632
658
  //#endregion
633
659
  //#region src/ui/icons.tsx
634
- function fe({ className: e }) {
660
+ function de({ className: e }) {
635
661
  return /* @__PURE__ */ u("svg", {
636
662
  viewBox: "0 0 24 24",
637
663
  fill: "currentColor",
@@ -640,7 +666,7 @@ function fe({ className: e }) {
640
666
  children: /* @__PURE__ */ u("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 Z({ className: e }) {
669
+ function fe({ className: e }) {
644
670
  return /* @__PURE__ */ d("svg", {
645
671
  viewBox: "0 0 24 24",
646
672
  fill: "none",
@@ -705,15 +731,15 @@ function he({ className: e }) {
705
731
  //#endregion
706
732
  //#region src/ui/CopyMarkdownButton.tsx
707
733
  var ge = 1500;
708
- function _e({ markdown: e, className: t }) {
709
- let [n, i] = o(!1), [s, c] = o(!1), l = a(null);
734
+ function _e({ markdown: e, className: t, ariaLabel: n = "copy response as markdown", tooltipDefaultText: i = "Copy as markdown", tooltipCopiedText: s = "Copied!" }) {
735
+ let [c, l] = o(!1), [p, m] = o(!1), h = a(null);
710
736
  return r(() => () => {
711
- l.current !== null && clearTimeout(l.current);
737
+ h.current !== null && clearTimeout(h.current);
712
738
  }, []), /* @__PURE__ */ u(f.Provider, {
713
739
  delayDuration: 200,
714
740
  children: /* @__PURE__ */ d(f.Root, {
715
- open: n || s,
716
- onOpenChange: c,
741
+ open: c || p,
742
+ onOpenChange: m,
717
743
  children: [/* @__PURE__ */ u(f.Trigger, {
718
744
  asChild: !0,
719
745
  children: /* @__PURE__ */ u("button", {
@@ -722,16 +748,16 @@ function _e({ markdown: e, className: t }) {
722
748
  try {
723
749
  await navigator.clipboard.writeText(e);
724
750
  } catch {}
725
- i(!0), l.current !== null && clearTimeout(l.current), l.current = setTimeout(() => i(!1), ge);
751
+ l(!0), h.current !== null && clearTimeout(h.current), h.current = setTimeout(() => l(!1), ge);
726
752
  },
727
- "aria-label": "copy response as markdown",
753
+ "aria-label": n,
728
754
  className: `bailey-copy-button${t ? ` ${t}` : ""}`,
729
- children: u(n ? me : pe, { className: "bailey-copy-icon" })
755
+ children: u(c ? me : pe, { className: "bailey-copy-icon" })
730
756
  })
731
757
  }), /* @__PURE__ */ u(f.Portal, { children: /* @__PURE__ */ d(f.Content, {
732
758
  side: "top",
733
759
  className: "bailey-tooltip-content",
734
- children: [n ? "Copied!" : "Copy as markdown", /* @__PURE__ */ u(f.Arrow, { className: "bailey-tooltip-arrow" })]
760
+ children: [c ? s : i, /* @__PURE__ */ u(f.Arrow, { className: "bailey-tooltip-arrow" })]
735
761
  }) })]
736
762
  })
737
763
  });
@@ -793,7 +819,7 @@ function $({ row: e }) {
793
819
  /* @__PURE__ */ u("span", {
794
820
  className: "bailey-trace-row-gap",
795
821
  title: "Time since the previous event",
796
- children: G(e.gapMs)
822
+ children: ie(e.gapMs)
797
823
  }),
798
824
  /* @__PURE__ */ u("span", {
799
825
  className: be(e),
@@ -876,7 +902,7 @@ function Se({ request: e }) {
876
902
  });
877
903
  }
878
904
  function Ce({ events: e, lastRequest: t, onClear: n }) {
879
- let r = i(() => K(e), [e]), a = i(() => J(r), [r]), o = i(() => JSON.stringify(e, null, 2), [e]);
905
+ let r = i(() => ae(e), [e]), a = i(() => se(r), [r]), o = i(() => JSON.stringify(e, null, 2), [e]);
880
906
  return /* @__PURE__ */ d("div", {
881
907
  className: "bailey-trace-body",
882
908
  children: [
@@ -931,7 +957,7 @@ function Ce({ events: e, lastRequest: t, onClear: n }) {
931
957
  });
932
958
  }
933
959
  function we({ events: e, lastRequest: t, onClear: n }) {
934
- let [r, a] = o(!1), s = i(() => Y(e), [e]), c = i(() => q(e), [e]);
960
+ let [r, a] = o(!1), s = i(() => ce(e), [e]), c = i(() => oe(e), [e]);
935
961
  return e.length === 0 && !t ? null : /* @__PURE__ */ d("div", {
936
962
  className: "bailey-trace-panel",
937
963
  children: [/* @__PURE__ */ d("div", {
@@ -961,47 +987,78 @@ function we({ events: e, lastRequest: t, onClear: n }) {
961
987
  }
962
988
  //#endregion
963
989
  //#region src/ui/BaileyChatPanel.tsx
964
- var Te = "How can bailey AI help you today?", Ee = "Reply to bailey AI", De = [c], Oe = t(function({ content: e, components: t }) {
990
+ var Te = "How can bailey AI help you today?", Ee = "Reply to bailey AI", De = {
991
+ newChatButtonText: "New chat",
992
+ newChatAriaLabel: "new chat",
993
+ suggestionsTitle: "Suggested for you",
994
+ emptyStateMessage: "Ask Bailey a question to get started.",
995
+ youLabel: "You",
996
+ thinkingHint: "Thinking…",
997
+ retryButtonText: "Retry",
998
+ dismissErrorAriaLabel: "dismiss error",
999
+ sendAriaLabel: "send",
1000
+ stopButtonText: "Stop",
1001
+ stopAriaLabel: "stop",
1002
+ copyButtonAriaLabel: "copy response as markdown",
1003
+ copyButtonTooltipDefault: "Copy as markdown",
1004
+ copyButtonTooltipCopied: "Copied!"
1005
+ }, Oe = [c], ke = t(function({ content: e, components: t }) {
965
1006
  return /* @__PURE__ */ u("div", {
966
1007
  className: "bailey-markdown-content",
967
1008
  children: /* @__PURE__ */ u(s, {
968
- remarkPlugins: De,
1009
+ remarkPlugins: Oe,
969
1010
  components: t,
1011
+ skipHtml: !0,
970
1012
  children: e
971
1013
  })
972
1014
  });
973
1015
  });
974
- function ke(e, t, n) {
1016
+ function Ae(e, t, n) {
975
1017
  if (e !== "streaming") return;
976
1018
  let r = t.filter((e) => e.turnSentAt === n?.sentAt);
977
- if (r.length !== 0) return U(r[r.length - 1]);
1019
+ if (r.length !== 0) return Z(r[r.length - 1]);
978
1020
  }
979
- function Ae(e) {
1021
+ function je(e) {
980
1022
  let t = new Date(e), n = t.toDateString() === (/* @__PURE__ */ new Date()).toDateString(), r = t.toLocaleTimeString([], {
981
1023
  hour: "numeric",
982
1024
  minute: "2-digit"
983
1025
  });
984
1026
  return n ? `Today ${r}` : `${t.toLocaleDateString()} ${r}`;
985
1027
  }
986
- function je({ chat: e, placeholder: t, replyPlaceholder: n = Ee, suggestions: s, privacyNote: c, resolveActivityIcon: l, className: f, height: p, width: m, hideDeveloperDetails: h = !1, renderMessageActions: g, renderTable: _, renderChart: v }) {
987
- let { messages: y, traceEvents: b, lastRequest: x, status: S, error: C, send: w, stop: ee, retryLast: T, clearTrace: E, clearError: D, newChat: O } = e, [k, A] = o(""), j = a(null), M = i(() => de({
988
- renderTable: _,
989
- renderChart: v
990
- }), [_, v]), N = i(() => ke(S, b, x), [
991
- S,
992
- b,
993
- x
994
- ]), P = y.length === 0, F = t ?? (P ? Te : n);
995
- return r(() => {
996
- j.current?.scrollIntoView({
997
- behavior: "smooth",
1028
+ function Me({ chat: e, placeholder: t, replyPlaceholder: n = Ee, emptyPlaceholder: s, suggestions: c, privacyNote: l, resolveActivityIcon: f, className: p, height: m, width: h, hideDeveloperDetails: g = !1, renderMessageActions: _, renderTable: v, renderChart: y, labels: b, formatMessageTime: x }) {
1029
+ let { messages: S, traceEvents: C, lastRequest: w, status: T, error: E, send: D, stop: O, retryLast: k, clearTrace: A, clearError: j, newChat: M } = e, [N, P] = o(""), F = {
1030
+ ...De,
1031
+ ...b
1032
+ }, I = x ?? je, L = a(null), R = a(null), z = a(!0), ee = i(() => ue({
1033
+ renderTable: v,
1034
+ renderChart: y
1035
+ }), [v, y]), B = i(() => Ae(T, C, w), [
1036
+ T,
1037
+ C,
1038
+ w
1039
+ ]), V = S.length === 0, H = t ?? (V ? s ?? Te : n);
1040
+ r(() => {
1041
+ let e = R.current;
1042
+ if (!e) return;
1043
+ let t = () => {
1044
+ let t = e.scrollHeight - e.scrollTop - e.clientHeight;
1045
+ z.current = t < 60;
1046
+ };
1047
+ return e.addEventListener("scroll", t, { passive: !0 }), () => e.removeEventListener("scroll", t);
1048
+ }, []), r(() => {
1049
+ z.current && L.current?.scrollIntoView({
1050
+ behavior: T === "streaming" ? "auto" : "smooth",
998
1051
  block: "nearest"
999
1052
  });
1000
- }, [y]), /* @__PURE__ */ u("div", {
1001
- className: `bailey-chat-panel${f ? ` ${f}` : ""}`,
1002
- style: p !== void 0 || m !== void 0 ? {
1003
- height: p,
1004
- width: m
1053
+ }, [S, T]);
1054
+ let U = (e) => {
1055
+ z.current = !0, D(e);
1056
+ };
1057
+ return /* @__PURE__ */ u("div", {
1058
+ className: `bailey-chat-panel${p ? ` ${p}` : ""}`,
1059
+ style: m !== void 0 || h !== void 0 ? {
1060
+ height: m,
1061
+ width: h
1005
1062
  } : void 0,
1006
1063
  children: /* @__PURE__ */ d("div", {
1007
1064
  className: "bailey-chat-panel-inner",
@@ -1010,33 +1067,34 @@ function je({ chat: e, placeholder: t, replyPlaceholder: n = Ee, suggestions: s,
1010
1067
  className: "bailey-toolbar-row",
1011
1068
  children: /* @__PURE__ */ u("button", {
1012
1069
  type: "button",
1013
- onClick: O,
1014
- disabled: y.length === 0,
1015
- "aria-label": "new chat",
1070
+ onClick: M,
1071
+ disabled: S.length === 0,
1072
+ "aria-label": F.newChatAriaLabel,
1016
1073
  className: "bailey-new-chat-button",
1017
- children: "New chat"
1074
+ children: F.newChatButtonText
1018
1075
  })
1019
1076
  }),
1020
1077
  /* @__PURE__ */ d("div", {
1021
1078
  className: "bailey-chat-transcript",
1079
+ ref: R,
1022
1080
  children: [
1023
- P && (s && s.length > 0 ? /* @__PURE__ */ d("div", {
1081
+ V && (c && c.length > 0 ? /* @__PURE__ */ d("div", {
1024
1082
  className: "bailey-suggestions",
1025
1083
  children: [/* @__PURE__ */ u("div", {
1026
1084
  className: "bailey-suggestions-title",
1027
- children: "Suggested for you"
1028
- }), s.map((e, t) => /* @__PURE__ */ d("button", {
1085
+ children: F.suggestionsTitle
1086
+ }), c.map((e, t) => /* @__PURE__ */ d("button", {
1029
1087
  type: "button",
1030
- onClick: () => w(e.value ?? e.label),
1088
+ onClick: () => U(e.value ?? e.label),
1031
1089
  className: "bailey-suggestion-card",
1032
- children: [/* @__PURE__ */ u("span", { children: e.label }), /* @__PURE__ */ u(Z, { className: "bailey-suggestion-icon" })]
1090
+ children: [/* @__PURE__ */ u("span", { children: e.label }), /* @__PURE__ */ u(fe, { className: "bailey-suggestion-icon" })]
1033
1091
  }, `${e.label}-${t}`))]
1034
1092
  }) : /* @__PURE__ */ u("div", {
1035
1093
  className: "bailey-empty-state",
1036
- children: "Ask Bailey a question to get started."
1094
+ children: F.emptyStateMessage
1037
1095
  })),
1038
- y.map((e, t) => {
1039
- let n = e.role === "assistant" && t === y.length - 1, r = S === "streaming" && n && e.content === "", i = e.role === "assistant" && !r ? X(b, e.createdAt) : [], a = i[i.length - 1];
1096
+ S.map((e, t) => {
1097
+ let n = e.role === "assistant" && t === S.length - 1, r = T === "streaming" && n && e.content === "", i = e.role === "assistant" && !r ? le(C, e.createdAt) : [], a = i[i.length - 1];
1040
1098
  return /* @__PURE__ */ u("div", {
1041
1099
  className: e.role === "user" ? "bailey-message-row bailey-message-row-user" : "bailey-message-row",
1042
1100
  children: e.role === "user" ? /* @__PURE__ */ d("div", {
@@ -1045,15 +1103,15 @@ function je({ chat: e, placeholder: t, replyPlaceholder: n = Ee, suggestions: s,
1045
1103
  className: "bailey-message-meta",
1046
1104
  children: [/* @__PURE__ */ u("span", {
1047
1105
  className: "bailey-message-meta-name",
1048
- children: "You"
1049
- }), e.createdAt !== void 0 && /* @__PURE__ */ u("span", { children: Ae(e.createdAt) })]
1106
+ children: F.youLabel
1107
+ }), e.createdAt !== void 0 && /* @__PURE__ */ u("span", { children: I(e.createdAt) })]
1050
1108
  }), /* @__PURE__ */ u("div", {
1051
1109
  className: "bailey-user-bubble",
1052
1110
  children: e.content
1053
1111
  })]
1054
1112
  }) : r ? /* @__PURE__ */ u("div", {
1055
1113
  className: "bailey-thinking-hint",
1056
- children: N ?? "Thinking…"
1114
+ children: B ?? F.thinkingHint
1057
1115
  }) : /* @__PURE__ */ d("div", {
1058
1116
  className: "bailey-assistant-message",
1059
1117
  children: [
@@ -1061,90 +1119,95 @@ function je({ chat: e, placeholder: t, replyPlaceholder: n = Ee, suggestions: s,
1061
1119
  className: "bailey-activity-line",
1062
1120
  children: [/* @__PURE__ */ u("span", {
1063
1121
  className: "bailey-activity-icon",
1064
- children: l?.(a.toolName) ?? /* @__PURE__ */ u(he, {})
1122
+ children: f?.(a.toolName) ?? /* @__PURE__ */ u(he, {})
1065
1123
  }), /* @__PURE__ */ u("span", { children: a.text })]
1066
1124
  }),
1067
- /* @__PURE__ */ u(Oe, {
1125
+ /* @__PURE__ */ u(ke, {
1068
1126
  content: e.content,
1069
- components: M
1127
+ components: ee
1070
1128
  }),
1071
- e.streaming && N && /* @__PURE__ */ u("div", {
1129
+ e.streaming && B && /* @__PURE__ */ u("div", {
1072
1130
  className: "bailey-streaming-hint",
1073
- children: N
1131
+ children: B
1074
1132
  }),
1075
1133
  !e.streaming && /* @__PURE__ */ d("div", {
1076
1134
  className: "bailey-message-actions",
1077
- children: [/* @__PURE__ */ u(_e, { markdown: e.content }), g?.(e)]
1135
+ children: [/* @__PURE__ */ u(_e, {
1136
+ markdown: e.content,
1137
+ ariaLabel: F.copyButtonAriaLabel,
1138
+ tooltipDefaultText: F.copyButtonTooltipDefault,
1139
+ tooltipCopiedText: F.copyButtonTooltipCopied
1140
+ }), _?.(e)]
1078
1141
  })
1079
1142
  ]
1080
1143
  })
1081
1144
  }, e.id);
1082
1145
  }),
1083
- /* @__PURE__ */ u("div", { ref: j })
1146
+ /* @__PURE__ */ u("div", { ref: L })
1084
1147
  ]
1085
1148
  }),
1086
- P && c && /* @__PURE__ */ d("div", {
1149
+ V && l && /* @__PURE__ */ d("div", {
1087
1150
  className: "bailey-privacy-note",
1088
1151
  children: [
1089
- c.text,
1152
+ l.text,
1090
1153
  " ",
1091
1154
  /* @__PURE__ */ u("a", {
1092
- href: c.linkHref,
1155
+ href: l.linkHref,
1093
1156
  target: "_blank",
1094
1157
  rel: "noreferrer",
1095
- children: c.linkLabel
1158
+ children: l.linkLabel
1096
1159
  })
1097
1160
  ]
1098
1161
  }),
1099
- C && /* @__PURE__ */ d("div", {
1162
+ E && /* @__PURE__ */ d("div", {
1100
1163
  className: "bailey-error-banner",
1101
1164
  role: "alert",
1102
- children: [/* @__PURE__ */ u("span", { children: C }), /* @__PURE__ */ d("div", {
1165
+ children: [/* @__PURE__ */ u("span", { children: E }), /* @__PURE__ */ d("div", {
1103
1166
  className: "bailey-error-actions",
1104
1167
  children: [/* @__PURE__ */ u("button", {
1105
1168
  type: "button",
1106
- onClick: T,
1169
+ onClick: k,
1107
1170
  className: "bailey-retry-button",
1108
- children: "Retry"
1171
+ children: F.retryButtonText
1109
1172
  }), /* @__PURE__ */ u("button", {
1110
1173
  type: "button",
1111
- onClick: D,
1112
- "aria-label": "dismiss error",
1174
+ onClick: j,
1175
+ "aria-label": F.dismissErrorAriaLabel,
1113
1176
  className: "bailey-dismiss-button",
1114
1177
  children: "✕"
1115
1178
  })]
1116
1179
  })]
1117
1180
  }),
1118
- !h && /* @__PURE__ */ u(we, {
1119
- events: b,
1120
- lastRequest: x,
1121
- onClear: E
1181
+ !g && /* @__PURE__ */ u(we, {
1182
+ events: C,
1183
+ lastRequest: w,
1184
+ onClear: A
1122
1185
  }),
1123
1186
  /* @__PURE__ */ d("form", {
1124
1187
  onSubmit: (e) => {
1125
- e.preventDefault(), !(!k.trim() || S === "streaming") && (w(k), A(""));
1188
+ e.preventDefault(), !(!N.trim() || T === "streaming") && (U(N), P(""));
1126
1189
  },
1127
1190
  className: "bailey-input-row",
1128
1191
  children: [/* @__PURE__ */ u("input", {
1129
1192
  type: "text",
1130
- placeholder: F,
1131
- "aria-label": F,
1132
- value: k,
1133
- onChange: (e) => A(e.target.value),
1134
- disabled: S === "streaming",
1193
+ placeholder: H,
1194
+ "aria-label": H,
1195
+ value: N,
1196
+ onChange: (e) => P(e.target.value),
1197
+ disabled: T === "streaming",
1135
1198
  className: "bailey-input"
1136
- }), S === "streaming" ? /* @__PURE__ */ u("button", {
1199
+ }), T === "streaming" ? /* @__PURE__ */ u("button", {
1137
1200
  type: "button",
1138
- onClick: ee,
1139
- "aria-label": "stop",
1201
+ onClick: O,
1202
+ "aria-label": F.stopAriaLabel,
1140
1203
  className: "bailey-stop-button",
1141
- children: "Stop"
1204
+ children: F.stopButtonText
1142
1205
  }) : /* @__PURE__ */ u("button", {
1143
1206
  type: "submit",
1144
- "aria-label": "send",
1145
- disabled: !k.trim(),
1207
+ "aria-label": F.sendAriaLabel,
1208
+ disabled: !N.trim(),
1146
1209
  className: "bailey-send-button",
1147
- children: /* @__PURE__ */ u(fe, { className: "bailey-send-icon" })
1210
+ children: /* @__PURE__ */ u(de, { className: "bailey-send-icon" })
1148
1211
  })]
1149
1212
  })
1150
1213
  ]
@@ -1153,6 +1216,6 @@ function je({ chat: e, placeholder: t, replyPlaceholder: n = Ee, suggestions: s,
1153
1216
  }
1154
1217
  //#endregion
1155
1218
  //#region src/index.ts
1156
- var Me = "0.3.1-pre.2";
1219
+ var Ne = "0.3.1-pre.2";
1157
1220
  //#endregion
1158
- export { he as ActivityIcon, Z as ArrowUpRightIcon, Me as BAILEYAI_CHAT_UI_VERSION, ne as BAILEY_CHART_PROMPT_FRAGMENT, A as BAILEY_TABLE_GRID_ROW_THRESHOLD, je as BaileyChatPanel, we as BaileyTracePanel, _e as CopyMarkdownButton, fe as HeartIcon, le as TRACE_KIND_LABEL, de as createBaileyMarkdownComponents, b as extractPseudoToolCalls, I as extractTableData, G as formatTraceGap, W as formatTraceTime, Y as hasTraceFailure, e as isSafeMarkdownUrl, E as joinInstructions, L as parseBaileyChartSpec, S as parseSseFrames, k as resolveToolCall, te as shouldUseGrid, X as toActivityLines, K as toTraceRows, J as toTraceSegments, B as traceEventArgsDetail, U as traceEventHint, V as traceEventOutputDetail, H as traceEventRawDetail, ue as traceEventSummary, z as traceEventToolName, q as traceSummaryLine, T as useBaileyChat };
1221
+ export { he as ActivityIcon, fe as ArrowUpRightIcon, Ne as BAILEYAI_CHAT_UI_VERSION, z as BAILEY_CHART_PROMPT_FRAGMENT, j as BAILEY_TABLE_GRID_ROW_THRESHOLD, Me as BaileyChatPanel, we as BaileyTracePanel, _e as CopyMarkdownButton, de as HeartIcon, G as TRACE_KIND_LABEL, ue as createBaileyMarkdownComponents, b as extractPseudoToolCalls, L as extractTableData, ie as formatTraceGap, re as formatTraceTime, ce as hasTraceFailure, e as isSafeMarkdownUrl, D as joinInstructions, W as parseBaileyChartSpec, S as parseSseFrames, A as resolveToolCall, R as shouldUseGrid, le as toActivityLines, ae as toTraceRows, se as toTraceSegments, Y as traceEventArgsDetail, Z as traceEventHint, X as traceEventOutputDetail, ne as traceEventRawDetail, J as traceEventSummary, q as traceEventToolName, oe as traceSummaryLine, E as useBaileyChat };