@kevinwang15/byok-ai 0.1.0 → 0.1.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.
Files changed (47) hide show
  1. package/README.md +10 -0
  2. package/dist/lib/AskAI.js +383 -0
  3. package/dist/lib/AskAIHistory.js +120 -0
  4. package/dist/lib/AskAIProvider.js +255 -0
  5. package/dist/lib/Markdown.js +111 -0
  6. package/dist/lib/PageElements.js +127 -0
  7. package/dist/lib/agent.js +223 -0
  8. package/dist/lib/answer-components.js +49 -0
  9. package/dist/lib/connection.d.ts +15 -0
  10. package/dist/lib/connection.js +32 -0
  11. package/dist/lib/context.js +9 -0
  12. package/dist/lib/conversation-files.js +164 -0
  13. package/dist/lib/entries/agent.d.ts +9 -0
  14. package/dist/lib/entries/agent.js +5 -0
  15. package/dist/lib/entries/connection.d.ts +2 -0
  16. package/dist/lib/entries/connection.js +1 -0
  17. package/dist/lib/entries/script-engine.d.ts +3 -0
  18. package/dist/lib/entries/script-engine.js +5 -0
  19. package/dist/lib/history.js +16 -0
  20. package/dist/lib/images.js +79 -0
  21. package/dist/lib/index.d.ts +6 -2
  22. package/dist/lib/index.js +18 -2326
  23. package/dist/lib/local-storage.d.ts +8 -0
  24. package/dist/lib/local-storage.js +23 -0
  25. package/dist/lib/mcp-result.js +11 -0
  26. package/dist/lib/mount.js +9 -0
  27. package/dist/lib/node_modules/@jitl/quickjs-ffi-types/dist/index.js +46 -0
  28. package/dist/lib/node_modules/@jitl/quickjs-wasmfile-release-sync/dist/emscripten-module.browser.js +330 -0
  29. package/dist/lib/node_modules/@jitl/quickjs-wasmfile-release-sync/dist/ffi.js +76 -0
  30. package/dist/lib/node_modules/@jitl/quickjs-wasmfile-release-sync/dist/index.js +7 -0
  31. package/dist/lib/node_modules/quickjs-emscripten-core/dist/chunk-V2S4ZYJR.js +1142 -0
  32. package/dist/lib/node_modules/quickjs-emscripten-core/dist/index.js +21 -0
  33. package/dist/lib/node_modules/quickjs-emscripten-core/dist/module-ES6BEMUI.js +1 -0
  34. package/dist/lib/page-context.js +168 -0
  35. package/dist/lib/page-picker.js +119 -0
  36. package/dist/lib/providers.js +84 -0
  37. package/dist/lib/rendering-context.js +4 -0
  38. package/dist/lib/sandbox.js +102 -0
  39. package/dist/lib/script-runner.js +26 -0
  40. package/dist/lib/script.js +9 -0
  41. package/dist/lib/storage.d.ts +0 -13
  42. package/dist/lib/storage.js +67 -0
  43. package/dist/lib/useAskAIImage.js +26 -0
  44. package/dist/lib/usePanelLayout.js +168 -0
  45. package/dist/lib/workspace-tools.js +182 -0
  46. package/package.json +14 -1
  47. /package/dist/lib/{sandbox-worker-BdFlhTIS.js → sandbox-worker.js} +0 -0
package/README.md CHANGED
@@ -34,6 +34,16 @@ export function Page() {
34
34
  }
35
35
  ```
36
36
 
37
+ The package has three more entries, for code that runs the assistant's parts without its React UI:
38
+
39
+ | Import | Holds |
40
+ | --- | --- |
41
+ | `@kevinwang15/byok-ai/agent` | The agent loop without React: `createBrowserAdapter`, `answerComponentInstructions`, `memoryConversationFiles` (a workspace kept in memory), the limits and the types. For a job in the page that answers without a chat, a worker, or Node (evaluations, tests). Outside a page, give MCP servers absolute URLs. |
42
+ | `@kevinwang15/byok-ai/connection` | The saved provider connection, to read and follow without loading React or the agent: `loadConnection(key)`, `subscribeConnection(key, listener)`, `sameConnection(a, b)` and `defaultConnectionKey(storageKey)`. |
43
+ | `@kevinwang15/byok-ai/script-engine` | `inProcessScriptRunner`, which runs workspace scripts in the calling thread, for Node, where there are no workers. Pass it as `workspace.run` to `createBrowserAdapter`. The engine is bundled into this entry alone. A run ends at the time limit, but Stop can't end it sooner. |
44
+
45
+ The main entry also exports the `agent` and `connection` names (not `inProcessScriptRunner`, to keep the engine out of it), and code shared between entries is loaded once: a connection change saved by an assistant reaches `subscribeConnection` from either entry.
46
+
37
47
  `AskAI` renders a trigger button and a modal dialog with provider setup, chat, history and a tools list. On a page that does not otherwise use React, mount it into an element:
38
48
 
39
49
  ```ts
@@ -0,0 +1,383 @@
1
+ import { AskAIProvider as e } from "./AskAIProvider.js";
2
+ import { useAskAI as t } from "./context.js";
3
+ import { MarkdownText as n } from "./Markdown.js";
4
+ import { AskAIHistory as r } from "./AskAIHistory.js";
5
+ import { MessageRenderingContext as i } from "./rendering-context.js";
6
+ import { useAskAIImage as a } from "./useAskAIImage.js";
7
+ import { AskAIAddFromPage as o, AskAIComposerElements as s, AskAIMessageElements as c } from "./PageElements.js";
8
+ import { useContext as l, useEffect as u, useId as d, useState as f } from "react";
9
+ import { ActionBarPrimitive as p, AttachmentPrimitive as m, ComposerPrimitive as h, MessagePrimitive as g, ThreadPrimitive as _, useAuiState as v } from "@assistant-ui/react";
10
+ import { Button as y, Dialog as b, DialogPanel as x, DialogTitle as S, Disclosure as C, DisclosureButton as w, DisclosurePanel as T, Field as ee, Fieldset as E, Input as D, Label as O, Legend as k } from "@headlessui/react";
11
+ import { Fragment as A, jsx as j, jsxs as M } from "react/jsx-runtime";
12
+ // frontend/byok/AskAI.tsx
13
+ var N = {
14
+ running: "Running…",
15
+ "requires-action": "Running…",
16
+ incomplete: "Stopped",
17
+ complete: "Done"
18
+ }, P = ({ toolName: e, result: t, argsText: n, isError: r, status: i }) => /* @__PURE__ */ M(C, {
19
+ as: "div",
20
+ "data-byok": "tool",
21
+ children: [/* @__PURE__ */ M(w, { children: [
22
+ e,
23
+ ": ",
24
+ r ? "Failed" : N[i.type]
25
+ ] }), /* @__PURE__ */ M(T, { children: [/* @__PURE__ */ j("pre", { children: n }), t !== void 0 && /* @__PURE__ */ j("pre", { children: JSON.stringify(t, null, 2) })] })]
26
+ });
27
+ function F() {
28
+ return /* @__PURE__ */ j(n, {});
29
+ }
30
+ function I() {
31
+ let e = l(i);
32
+ return /* @__PURE__ */ j(g.Content, { components: {
33
+ Text: e?.Text ?? F,
34
+ tools: { Fallback: e?.ToolFallback ?? P }
35
+ } });
36
+ }
37
+ function L({ copy: e = "Copy response", copied: n = "Copied", regenerate: r = "Regenerate response", style: i, ...a }) {
38
+ let { connection: o } = t(), s = v((e) => e.message.isCopied), c = v((e) => e.thread.isRunning || !e.message.isLast && !e.message.isHovering);
39
+ return /* @__PURE__ */ M(p.Root, {
40
+ "data-byok": "message-actions",
41
+ "data-hidden": c || void 0,
42
+ ...a,
43
+ style: c ? {
44
+ ...i,
45
+ visibility: "hidden"
46
+ } : i,
47
+ children: [/* @__PURE__ */ j(p.Copy, {
48
+ "data-byok": "message-copy",
49
+ children: s ? n : e
50
+ }), /* @__PURE__ */ j(p.Reload, {
51
+ "data-byok": "message-regenerate",
52
+ disabled: !o,
53
+ children: r
54
+ })]
55
+ });
56
+ }
57
+ function R() {
58
+ let { src: e, name: t, missing: n } = a(), r = v((e) => e.attachment.status.type === "complete");
59
+ return /* @__PURE__ */ M(m.Root, {
60
+ "data-byok": "image",
61
+ "data-missing": n || void 0,
62
+ children: [e ? /* @__PURE__ */ j("img", {
63
+ src: e,
64
+ alt: t
65
+ }) : /* @__PURE__ */ j("span", { children: n ? `${t} (no longer stored)` : t }), !r && /* @__PURE__ */ j(m.Remove, {
66
+ "data-byok": "image-remove",
67
+ "aria-label": `Remove ${t}`,
68
+ children: "Remove"
69
+ })]
70
+ });
71
+ }
72
+ var z = { Image: R };
73
+ function B() {
74
+ return /* @__PURE__ */ j("div", {
75
+ "data-byok": "composer-images",
76
+ children: /* @__PURE__ */ j(h.Attachments, { components: z })
77
+ });
78
+ }
79
+ function V() {
80
+ return /* @__PURE__ */ j("div", {
81
+ "data-byok": "message-images",
82
+ children: /* @__PURE__ */ j(g.Attachments, { components: z })
83
+ });
84
+ }
85
+ function H({ children: e = "Attach image", ...n }) {
86
+ let { images: r, connection: i } = t();
87
+ return r ? /* @__PURE__ */ j(h.AddAttachment, {
88
+ "data-byok": "add-image",
89
+ disabled: !i,
90
+ ...n,
91
+ children: e
92
+ }) : null;
93
+ }
94
+ function U() {
95
+ let e = v((e) => e.message.role);
96
+ return /* @__PURE__ */ M(g.Root, {
97
+ "data-byok": "message",
98
+ "data-role": e,
99
+ children: [
100
+ e === "user" && /* @__PURE__ */ M(A, { children: [/* @__PURE__ */ j(V, {}), /* @__PURE__ */ j(c, {})] }),
101
+ /* @__PURE__ */ j(I, {}),
102
+ e === "assistant" && /* @__PURE__ */ j(L, {})
103
+ ]
104
+ });
105
+ }
106
+ function W() {
107
+ return /* @__PURE__ */ j("p", { children: "Start a conversation." });
108
+ }
109
+ function G() {
110
+ let { connection: e, images: n } = t();
111
+ return /* @__PURE__ */ M(h.Root, {
112
+ "data-byok": "composer",
113
+ children: [
114
+ /* @__PURE__ */ M(h.AttachmentDropzone, {
115
+ "data-byok": "composer-dropzone",
116
+ disabled: !n,
117
+ children: [
118
+ /* @__PURE__ */ j(B, {}),
119
+ /* @__PURE__ */ j(s, {}),
120
+ /* @__PURE__ */ j(h.Input, {
121
+ placeholder: "Ask anything…",
122
+ "aria-label": "Message",
123
+ disabled: !e
124
+ })
125
+ ]
126
+ }),
127
+ /* @__PURE__ */ j(H, {}),
128
+ /* @__PURE__ */ j(o, {}),
129
+ /* @__PURE__ */ j(_.If, {
130
+ running: !1,
131
+ children: /* @__PURE__ */ j(h.Send, {
132
+ disabled: !e,
133
+ children: "Send message"
134
+ })
135
+ }),
136
+ /* @__PURE__ */ j(_.If, {
137
+ running: !0,
138
+ children: /* @__PURE__ */ j(h.Cancel, { children: "Stop response" })
139
+ })
140
+ ]
141
+ });
142
+ }
143
+ function K({ components: e } = {}) {
144
+ let { error: n } = t(), r = e?.Empty ?? W, a = e?.Composer ?? G;
145
+ return /* @__PURE__ */ j(i.Provider, {
146
+ value: e,
147
+ children: /* @__PURE__ */ M(_.Root, {
148
+ "data-byok": "chat",
149
+ children: [
150
+ /* @__PURE__ */ M(_.Viewport, {
151
+ "data-byok": "messages",
152
+ children: [/* @__PURE__ */ j(_.Empty, { children: /* @__PURE__ */ j(r, {}) }), /* @__PURE__ */ j(_.Messages, { components: {
153
+ UserMessage: e?.UserMessage ?? U,
154
+ AssistantMessage: e?.AssistantMessage ?? U
155
+ } })]
156
+ }),
157
+ n && /* @__PURE__ */ j("p", {
158
+ role: "alert",
159
+ children: n
160
+ }),
161
+ /* @__PURE__ */ j(a, {})
162
+ ]
163
+ })
164
+ });
165
+ }
166
+ function q() {
167
+ let { providers: e, connection: n, connect: r, setPage: i, busy: a } = t(), [o, s] = f(n?.provider), [c, l] = f(n?.values ?? {}), [u, d] = f(""), p = o?.Form;
168
+ return /* @__PURE__ */ M("section", {
169
+ "data-byok": "setup",
170
+ children: [
171
+ /* @__PURE__ */ j("h2", { children: o ? o.name : "Choose an AI provider" }),
172
+ o ? /* @__PURE__ */ M("form", {
173
+ onSubmit: (e) => {
174
+ e.preventDefault(), d(r(o, c) ?? "");
175
+ },
176
+ children: [
177
+ /* @__PURE__ */ j("p", { children: o.description }),
178
+ /* @__PURE__ */ j(y, {
179
+ type: "button",
180
+ onClick: () => {
181
+ s(void 0), l({}), d("");
182
+ },
183
+ children: "All providers"
184
+ }),
185
+ /* @__PURE__ */ M(E, {
186
+ disabled: a,
187
+ children: [/* @__PURE__ */ j(k, { children: "Provider configuration" }), p ? /* @__PURE__ */ j(p, {
188
+ values: c,
189
+ onChange: l
190
+ }) : o.fields?.map((e) => /* @__PURE__ */ M(ee, { children: [/* @__PURE__ */ j(O, { children: e.label }), /* @__PURE__ */ j(D, {
191
+ autoComplete: "off",
192
+ type: e.type ?? "text",
193
+ required: e.required,
194
+ placeholder: e.placeholder,
195
+ value: c[e.name] ?? "",
196
+ onChange: (t) => l({
197
+ ...c,
198
+ [e.name]: t.target.value
199
+ })
200
+ })] }, e.name))]
201
+ }),
202
+ u && /* @__PURE__ */ j("p", {
203
+ role: "alert",
204
+ children: u
205
+ }),
206
+ /* @__PURE__ */ j("p", { children: "Keys and provider settings are saved in localStorage on this browser. Disconnect to remove the saved key." }),
207
+ /* @__PURE__ */ j(y, {
208
+ type: "submit",
209
+ disabled: a,
210
+ children: "Start chatting"
211
+ })
212
+ ]
213
+ }) : /* @__PURE__ */ j("ul", { children: e.map((e) => /* @__PURE__ */ M("li", { children: [/* @__PURE__ */ j(y, {
214
+ type: "button",
215
+ onClick: () => {
216
+ s(e), l({ ...e.defaultValues }), d("");
217
+ },
218
+ children: e.name
219
+ }), /* @__PURE__ */ j("p", { children: e.description })] }, e.id)) }),
220
+ n && /* @__PURE__ */ j(y, {
221
+ type: "button",
222
+ onClick: () => i("chat"),
223
+ children: "Return to conversation"
224
+ })
225
+ ]
226
+ });
227
+ }
228
+ function J() {
229
+ let { mcpServers: e, clientTools: n, workspace: r } = t();
230
+ return /* @__PURE__ */ M("section", {
231
+ "data-byok": "tools",
232
+ children: [
233
+ /* @__PURE__ */ j("h2", { children: "MCP servers" }),
234
+ /* @__PURE__ */ j("ul", { children: e.map((e) => /* @__PURE__ */ M("li", { children: [
235
+ e.name,
236
+ " ",
237
+ /* @__PURE__ */ j("code", { children: e.url })
238
+ ] }, e.id)) }),
239
+ !e.length && /* @__PURE__ */ j("p", { children: "No MCP servers configured." }),
240
+ n.length > 0 && /* @__PURE__ */ M(A, { children: [/* @__PURE__ */ j("h2", { children: "Page tools" }), /* @__PURE__ */ j("ul", { children: n.map((e) => /* @__PURE__ */ j("li", { children: /* @__PURE__ */ j("code", { children: e }) }, e)) })] }),
241
+ r && /* @__PURE__ */ j(X, { workspace: r })
242
+ ]
243
+ });
244
+ }
245
+ var Y = (e) => e < 1024 ? `${e} B` : e < 1048576 ? `${(e / 1024).toFixed(1)} KB` : `${(e / 1024 / 1024).toFixed(1)} MB`;
246
+ function X({ workspace: e }) {
247
+ let [t, n] = f();
248
+ return u(() => {
249
+ let t = !0;
250
+ return e.list().then((e) => {
251
+ t && n(e);
252
+ }, (e) => {
253
+ t && n(e instanceof Error ? e.message : "The workspace could not be read.");
254
+ }), () => {
255
+ t = !1;
256
+ };
257
+ }, [e]), /* @__PURE__ */ M(A, { children: [
258
+ /* @__PURE__ */ j("h2", { children: "Workspace" }),
259
+ /* @__PURE__ */ j("p", { children: "Files the assistant keeps with this conversation, in this browser only, and computes over in a sandbox." }),
260
+ typeof t == "string" ? /* @__PURE__ */ j("p", {
261
+ role: "alert",
262
+ children: t
263
+ }) : t && (t.length ? /* @__PURE__ */ j("ul", { children: t.map((e) => /* @__PURE__ */ M("li", { children: [
264
+ /* @__PURE__ */ j("code", { children: e.name }),
265
+ " ",
266
+ Y(e.size)
267
+ ] }, e.name)) }) : /* @__PURE__ */ j("p", { children: "No files yet." }))
268
+ ] });
269
+ }
270
+ function Z({ children: e, onClick: n, ...r }) {
271
+ let { open: i, setOpen: a } = t();
272
+ return /* @__PURE__ */ j(y, {
273
+ type: "button",
274
+ "data-byok": "trigger",
275
+ "aria-expanded": i,
276
+ "aria-label": i ? "Close Ask AI" : "Open Ask AI",
277
+ ...r,
278
+ onClick: (e) => {
279
+ n?.(e), e.defaultPrevented || a(!i);
280
+ },
281
+ children: e ?? "ASK AI"
282
+ });
283
+ }
284
+ function Q({ children: e, ...n }) {
285
+ let { open: r, setOpen: i, title: a, picking: o } = t();
286
+ return /* @__PURE__ */ j(b, {
287
+ open: r && !o,
288
+ onClose: i,
289
+ "aria-label": a,
290
+ "data-byok": "dialog",
291
+ children: /* @__PURE__ */ j(x, {
292
+ "data-byok": "panel",
293
+ ...n,
294
+ children: e
295
+ })
296
+ });
297
+ }
298
+ function $({ components: e } = {}) {
299
+ let { title: n, connection: i, page: a, setPage: o, setOpen: s, newConversation: c, disconnect: l, busy: u, storageError: f } = t(), p = d();
300
+ return /* @__PURE__ */ M("div", {
301
+ "data-byok": "root",
302
+ children: [/* @__PURE__ */ M(Q, {
303
+ id: p,
304
+ children: [
305
+ /* @__PURE__ */ M("header", { children: [
306
+ /* @__PURE__ */ j(S, { children: n }),
307
+ i && /* @__PURE__ */ M("span", { children: [" — ", i.provider.name] }),
308
+ /* @__PURE__ */ M("nav", {
309
+ "aria-label": "Assistant",
310
+ children: [
311
+ /* @__PURE__ */ j(y, {
312
+ type: "button",
313
+ disabled: u,
314
+ onClick: () => o("history"),
315
+ children: "Conversation history"
316
+ }),
317
+ /* @__PURE__ */ j(y, {
318
+ type: "button",
319
+ disabled: u,
320
+ onClick: () => o("settings"),
321
+ children: "Provider settings"
322
+ }),
323
+ /* @__PURE__ */ j(y, {
324
+ type: "button",
325
+ onClick: () => s(!1),
326
+ children: "Close assistant"
327
+ })
328
+ ]
329
+ })
330
+ ] }),
331
+ f && /* @__PURE__ */ j("p", {
332
+ role: "alert",
333
+ children: "Could not read or save browser data. Keys, settings, and conversations may not be restored or removed after reload."
334
+ }),
335
+ (!i || a === "settings") && /* @__PURE__ */ j(q, {}, i?.provider.id ?? "disconnected"),
336
+ i && /* @__PURE__ */ M(A, { children: [
337
+ /* @__PURE__ */ M("nav", {
338
+ "aria-label": "Conversation",
339
+ children: [
340
+ /* @__PURE__ */ j(y, {
341
+ type: "button",
342
+ disabled: u,
343
+ onClick: c,
344
+ children: "New chat"
345
+ }),
346
+ /* @__PURE__ */ j(y, {
347
+ type: "button",
348
+ disabled: u,
349
+ onClick: () => o("chat"),
350
+ children: "Chat"
351
+ }),
352
+ /* @__PURE__ */ j(y, {
353
+ type: "button",
354
+ disabled: u,
355
+ onClick: () => o("tools"),
356
+ children: "Tools"
357
+ }),
358
+ /* @__PURE__ */ j(y, {
359
+ type: "button",
360
+ disabled: u,
361
+ onClick: l,
362
+ children: "Disconnect provider"
363
+ })
364
+ ]
365
+ }),
366
+ /* @__PURE__ */ j("div", {
367
+ hidden: a !== "chat",
368
+ children: /* @__PURE__ */ j(K, { components: e })
369
+ }),
370
+ a === "history" && /* @__PURE__ */ j(r, {}),
371
+ a === "tools" && /* @__PURE__ */ j(J, {})
372
+ ] })
373
+ ]
374
+ }), /* @__PURE__ */ j(Z, { "aria-controls": p })]
375
+ });
376
+ }
377
+ function te({ children: t, components: n, ...r }) {
378
+ return /* @__PURE__ */ j(e, {
379
+ ...r,
380
+ children: t ?? /* @__PURE__ */ j($, { components: n })
381
+ });
382
+ }
383
+ export { te as AskAI, o as AskAIAddFromPage, H as AskAIAddImage, K as AskAIChat, s as AskAIComposerElements, B as AskAIComposerImages, r as AskAIHistory, L as AskAIMessageActions, I as AskAIMessageContent, c as AskAIMessageElements, V as AskAIMessageImages, Q as AskAIPanel, q as AskAISetup, J as AskAITools, Z as AskAITrigger, $ as AskAIWidget };
@@ -0,0 +1,120 @@
1
+ import { useAskAI as e } from "./context.js";
2
+ import { conversationPreview as t, relativeConversationTime as n } from "./history.js";
3
+ import { useEffect as r, useRef as i, useState as a } from "react";
4
+ import { Button as o, Description as s, Dialog as c, DialogBackdrop as l, DialogPanel as u, DialogTitle as d } from "@headlessui/react";
5
+ import { jsx as f, jsxs as p } from "react/jsx-runtime";
6
+ // frontend/byok/AskAIHistory.tsx
7
+ function m({ title: m = "Conversations", description: h = "Pick up where you left off. Most recently updated first.", empty: g = "Your saved conversations will appear here." } = {}) {
8
+ let { conversations: _, activeConversation: v, selectConversation: y, deleteConversation: b, busy: x } = e(), [S, C] = a(Date.now), [w, T] = a(), E = i(null), D = i(!1), O = _.find((e) => e.id === w);
9
+ r(() => {
10
+ if (w || !D.current) return;
11
+ let e = requestAnimationFrame(() => {
12
+ D.current = !1, E.current?.focus();
13
+ });
14
+ return () => cancelAnimationFrame(e);
15
+ }, [w]), r(() => {
16
+ let e = setInterval(() => C(Date.now()), 3e4);
17
+ return () => clearInterval(e);
18
+ }, []);
19
+ let k = [..._].sort((e, t) => t.updatedAt - e.updatedAt);
20
+ return /* @__PURE__ */ p("section", {
21
+ "data-byok": "history",
22
+ children: [
23
+ /* @__PURE__ */ f("h2", {
24
+ ref: E,
25
+ tabIndex: -1,
26
+ children: m
27
+ }),
28
+ /* @__PURE__ */ f("p", {
29
+ "data-byok": "history-description",
30
+ children: _.length ? h : g
31
+ }),
32
+ /* @__PURE__ */ f("ul", { children: k.map((e) => {
33
+ let r = new Date(e.updatedAt), i = e.id === v.id, a = e.messages.filter((e) => e.role !== "system").length;
34
+ return /* @__PURE__ */ p("li", {
35
+ "data-current": i || void 0,
36
+ children: [/* @__PURE__ */ p(o, {
37
+ type: "button",
38
+ "data-byok": "history-select",
39
+ "aria-current": i ? "true" : void 0,
40
+ disabled: x,
41
+ onClick: () => y(e.id),
42
+ children: [
43
+ /* @__PURE__ */ f("span", {
44
+ "data-byok": "history-title",
45
+ children: e.title
46
+ }),
47
+ /* @__PURE__ */ f("span", {
48
+ "data-byok": "history-preview",
49
+ children: t(e)
50
+ }),
51
+ /* @__PURE__ */ p("span", {
52
+ "data-byok": "history-meta",
53
+ children: [
54
+ /* @__PURE__ */ f("time", {
55
+ dateTime: r.toISOString(),
56
+ title: r.toLocaleString(),
57
+ children: n(e.updatedAt, S)
58
+ }),
59
+ /* @__PURE__ */ p("span", { children: [
60
+ a,
61
+ " ",
62
+ a === 1 ? "message" : "messages"
63
+ ] }),
64
+ i && /* @__PURE__ */ f("span", {
65
+ "data-byok": "history-current",
66
+ children: "Current"
67
+ })
68
+ ]
69
+ })
70
+ ]
71
+ }), /* @__PURE__ */ f(o, {
72
+ type: "button",
73
+ "data-byok": "history-delete",
74
+ disabled: x,
75
+ "aria-label": "Delete " + e.title,
76
+ onClick: () => T(e.id),
77
+ children: "Delete"
78
+ })]
79
+ }, e.id);
80
+ }) }),
81
+ /* @__PURE__ */ p(c, {
82
+ open: !!O,
83
+ onClose: () => T(void 0),
84
+ "data-byok": "history-confirmation",
85
+ children: [/* @__PURE__ */ f(l, { "data-byok": "history-confirmation-backdrop" }), /* @__PURE__ */ f("div", {
86
+ "data-byok": "history-confirmation-position",
87
+ children: /* @__PURE__ */ p(u, {
88
+ "data-byok": "history-confirmation-panel",
89
+ children: [
90
+ /* @__PURE__ */ f(d, { children: "Delete conversation?" }),
91
+ /* @__PURE__ */ p(s, { children: [
92
+ "“",
93
+ O?.title,
94
+ "” and its messages and draft will be removed from this browser. This cannot be undone."
95
+ ] }),
96
+ /* @__PURE__ */ p("div", {
97
+ "data-byok": "history-confirmation-actions",
98
+ children: [/* @__PURE__ */ f(o, {
99
+ type: "button",
100
+ autoFocus: !0,
101
+ onClick: () => T(void 0),
102
+ children: "Keep conversation"
103
+ }), /* @__PURE__ */ f(o, {
104
+ type: "button",
105
+ "data-byok": "history-confirm-delete",
106
+ disabled: x,
107
+ onClick: () => {
108
+ O && !x && (D.current = !0, b(O.id), T(void 0));
109
+ },
110
+ children: "Delete conversation"
111
+ })]
112
+ })
113
+ ]
114
+ })
115
+ })]
116
+ })
117
+ ]
118
+ });
119
+ }
120
+ export { m as AskAIHistory };