@btst/stack 4.2.0 → 4.4.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.
Files changed (72) hide show
  1. package/README.md +2 -2
  2. package/dist/packages/stack/src/plugins/ai-chat/api/compaction.cjs +249 -0
  3. package/dist/packages/stack/src/plugins/ai-chat/api/compaction.mjs +241 -0
  4. package/dist/packages/stack/src/plugins/ai-chat/api/operations.cjs +20 -0
  5. package/dist/packages/stack/src/plugins/ai-chat/api/operations.mjs +20 -0
  6. package/dist/packages/stack/src/plugins/ai-chat/api/plugin.cjs +5 -0
  7. package/dist/packages/stack/src/plugins/ai-chat/api/plugin.mjs +5 -0
  8. package/dist/packages/stack/src/plugins/ai-chat/client/components/chat-interface.cjs +38 -3
  9. package/dist/packages/stack/src/plugins/ai-chat/client/components/chat-interface.mjs +38 -3
  10. package/dist/packages/stack/src/plugins/ai-chat/client/components/chat-layout.cjs +173 -72
  11. package/dist/packages/stack/src/plugins/ai-chat/client/components/chat-layout.mjs +176 -75
  12. package/dist/packages/stack/src/plugins/ai-chat/client/context-checkpoint.cjs +30 -0
  13. package/dist/packages/stack/src/plugins/ai-chat/client/context-checkpoint.mjs +27 -0
  14. package/dist/packages/stack/src/plugins/ai-chat/schemas.cjs +2 -0
  15. package/dist/packages/stack/src/plugins/ai-chat/schemas.mjs +2 -0
  16. package/dist/packages/ui/src/components/markdown-content.cjs +9 -9
  17. package/dist/packages/ui/src/components/markdown-content.mjs +9 -9
  18. package/dist/plugins/ai-chat/api/index.d.cts +2 -2
  19. package/dist/plugins/ai-chat/api/index.d.mts +2 -2
  20. package/dist/plugins/ai-chat/api/index.d.ts +2 -2
  21. package/dist/plugins/ai-chat/client/components/index.d.cts +1 -1
  22. package/dist/plugins/ai-chat/client/components/index.d.mts +1 -1
  23. package/dist/plugins/ai-chat/client/components/index.d.ts +1 -1
  24. package/dist/plugins/ai-chat/client/hooks/index.d.cts +2 -2
  25. package/dist/plugins/ai-chat/client/hooks/index.d.mts +2 -2
  26. package/dist/plugins/ai-chat/client/hooks/index.d.ts +2 -2
  27. package/dist/plugins/ai-chat/client/index.d.cts +3 -3
  28. package/dist/plugins/ai-chat/client/index.d.mts +3 -3
  29. package/dist/plugins/ai-chat/client/index.d.ts +3 -3
  30. package/dist/plugins/ai-chat/query-keys.d.cts +1 -1
  31. package/dist/plugins/ai-chat/query-keys.d.mts +1 -1
  32. package/dist/plugins/ai-chat/query-keys.d.ts +1 -1
  33. package/dist/plugins/blog/api/index.d.cts +2 -2
  34. package/dist/plugins/blog/api/index.d.mts +2 -2
  35. package/dist/plugins/blog/api/index.d.ts +2 -2
  36. package/dist/plugins/blog/client/hooks/index.d.cts +2 -2
  37. package/dist/plugins/blog/client/hooks/index.d.mts +2 -2
  38. package/dist/plugins/blog/client/hooks/index.d.ts +2 -2
  39. package/dist/plugins/blog/client/index.d.cts +2 -2
  40. package/dist/plugins/blog/client/index.d.mts +2 -2
  41. package/dist/plugins/blog/client/index.d.ts +2 -2
  42. package/dist/plugins/blog/query-keys.d.cts +2 -2
  43. package/dist/plugins/blog/query-keys.d.mts +2 -2
  44. package/dist/plugins/blog/query-keys.d.ts +2 -2
  45. package/dist/shared/{stack.BTStHVTy.d.cts → stack.BGzgFx3R.d.cts} +5 -5
  46. package/dist/shared/{stack.DBH1Bjko.d.ts → stack.C4zspX0T.d.ts} +13 -2
  47. package/dist/shared/{stack.94kN3pEK.d.mts → stack.CjCSDfWy.d.mts} +5 -5
  48. package/dist/shared/{stack.D5b9l24t.d.ts → stack.Clil75lW.d.ts} +35 -35
  49. package/dist/shared/{stack.xAiy2VtO.d.cts → stack.DDQlE2Pm.d.cts} +10 -3
  50. package/dist/shared/{stack.Ce6V7eDj.d.cts → stack.DNw6Hv5o.d.cts} +35 -35
  51. package/dist/shared/{stack.CTneIW0u.d.mts → stack.DhZtP2JZ.d.mts} +35 -35
  52. package/dist/shared/{stack.C-eQN_Jt.d.ts → stack.DlehgNZZ.d.ts} +10 -3
  53. package/dist/shared/{stack.DfrRYOIl.d.ts → stack.Dpg_JjIo.d.ts} +5 -5
  54. package/dist/shared/{stack.B7Mj74BQ.d.mts → stack.Ps3MDhTC.d.mts} +13 -2
  55. package/dist/shared/{stack.C5FZr-jJ.d.mts → stack.tAUeRAtd.d.mts} +10 -3
  56. package/dist/shared/{stack.Dgt3MCtW.d.cts → stack.ymWsP4HZ.d.cts} +13 -2
  57. package/package.json +2 -2
  58. package/src/__tests__/markdown-link-navigation.test.tsx +29 -0
  59. package/src/plugins/ai-chat/__tests__/classnames-overrides.test.tsx +22 -2
  60. package/src/plugins/ai-chat/__tests__/compaction.test.ts +272 -0
  61. package/src/plugins/ai-chat/__tests__/page-widget.test.tsx +103 -1
  62. package/src/plugins/ai-chat/api/compaction.ts +310 -0
  63. package/src/plugins/ai-chat/api/operations.ts +25 -0
  64. package/src/plugins/ai-chat/api/plugin.ts +14 -0
  65. package/src/plugins/ai-chat/client/components/chat-interface.tsx +58 -3
  66. package/src/plugins/ai-chat/client/components/chat-layout.tsx +197 -72
  67. package/src/plugins/ai-chat/client/context-checkpoint.ts +47 -0
  68. package/src/plugins/ai-chat/client/localization/index.ts +5 -0
  69. package/src/plugins/ai-chat/schemas.ts +2 -0
  70. package/dist/shared/{stack.CKc_Bais.d.cts → stack.Csi-4Mgz.d.cts} +7 -7
  71. package/dist/shared/{stack.CKc_Bais.d.mts → stack.Csi-4Mgz.d.mts} +7 -7
  72. package/dist/shared/{stack.CKc_Bais.d.ts → stack.Csi-4Mgz.d.ts} +7 -7
@@ -1,10 +1,12 @@
1
1
  "use client";
2
- import { jsx, jsxs } from 'react/jsx-runtime';
3
- import { useState, useRef, useCallback, useEffect } from 'react';
2
+ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
3
+ import { useState, useEffect, useRef, useCallback } from 'react';
4
+ import { createPortal } from 'react-dom';
5
+ import { Dialog, DialogContent, DialogTitle } from '../../../../../../ui/src/components/dialog.mjs';
4
6
  import { Button } from '../../../../../../ui/src/components/button.mjs';
5
7
  import { Badge } from '../../../../../../ui/src/components/badge.mjs';
6
8
  import { Sheet, SheetTrigger, SheetContent } from '../../../../../../ui/src/components/sheet.mjs';
7
- import { X, Sparkles, Trash2, Menu, PanelLeftClose, PanelLeft } from 'lucide-react';
9
+ import { X, Sparkles, Minimize2, Maximize2, Trash2, Menu, PanelLeftClose, PanelLeft } from 'lucide-react';
8
10
  import { cn } from '../../../../../../ui/src/lib/utils.mjs';
9
11
  import { ChatSidebar } from './chat-sidebar.mjs';
10
12
  import { ChatInterface } from './chat-interface.mjs';
@@ -34,14 +36,44 @@ function ChatLayoutContent(props) {
34
36
  const resolvedMode = resolveAiChatMode(plugins?.aiChat?.config);
35
37
  const showSidebar = requestedShowSidebar && resolvedMode !== "public";
36
38
  const tr = useAiChatTranslation(localization);
37
- const widgetHeight = props.layout === "widget" ? props.widgetHeight ?? "min(600px, calc(100dvh - 112px))" : void 0;
38
- const widgetWidth = props.layout === "widget" ? props.widgetWidth ?? "min(380px, calc(100vw - 32px))" : void 0;
39
+ const widgetHeight = props.layout === "widget" ? props.widgetHeight ?? "min(640px, calc(100dvh - 112px))" : void 0;
40
+ const widgetWidth = props.layout === "widget" ? props.widgetWidth ?? "min(440px, calc(100vw - 32px))" : void 0;
39
41
  const defaultOpen = props.layout === "widget" ? props.defaultOpen ?? false : false;
40
42
  const showTrigger = props.layout === "widget" ? props.showTrigger ?? true : true;
43
+ const triggerIcon = props.layout === "widget" ? props.triggerIcon : void 0;
41
44
  const [sidebarOpen, setSidebarOpen] = useState(true);
42
45
  const [mobileSidebarOpen, setMobileSidebarOpen] = useState(false);
43
46
  const [chatResetKey, setChatResetKey] = useState(0);
44
47
  const [widgetOpen, setWidgetOpen] = useState(defaultOpen);
48
+ const [expanded, setExpanded] = useState(false);
49
+ const expandable = props.layout === "widget" && props.expandable === true;
50
+ const widgetExpanded = expandable && expanded && widgetOpen;
51
+ useEffect(() => {
52
+ if (!expandable) setExpanded(false);
53
+ }, [expandable]);
54
+ const compactPanelRef = useRef(null);
55
+ const triggerRef = useRef(null);
56
+ const expandRef = useRef(null);
57
+ const [panelContainer, setPanelContainer] = useState(
58
+ null
59
+ );
60
+ const expandLabel = widgetExpanded ? tr("A11Y_COLLAPSE_CHAT", "aiChat.a11y.collapseChat", "Collapse chat") : tr("A11Y_EXPAND_CHAT", "aiChat.a11y.expandChat", "Expand chat");
61
+ useEffect(() => {
62
+ if (layout !== "widget") return;
63
+ const container = document.createElement("div");
64
+ container.className = "flex h-full min-h-0 flex-col";
65
+ compactPanelRef.current?.appendChild(container);
66
+ setPanelContainer(container);
67
+ return () => container.remove();
68
+ }, [layout]);
69
+ const mountExpandedPanel = useCallback(
70
+ (node) => {
71
+ if (panelContainer) {
72
+ (node ?? compactPanelRef.current)?.appendChild(panelContainer);
73
+ }
74
+ },
75
+ [panelContainer]
76
+ );
45
77
  const [widgetResetKey, setWidgetResetKey] = useState(0);
46
78
  const [widgetEverOpened, setWidgetEverOpened] = useState(defaultOpen);
47
79
  const [tipDismissed, setTipDismissed] = useState(defaultOpen);
@@ -119,97 +151,166 @@ function ChatLayoutContent(props) {
119
151
  ]
120
152
  }
121
153
  ),
122
- /* @__PURE__ */ jsxs(
154
+ /* @__PURE__ */ jsx(
123
155
  "div",
124
156
  {
157
+ ref: compactPanelRef,
158
+ role: "dialog",
159
+ tabIndex: -1,
160
+ "aria-label": tr("A11Y_CHAT_TITLE", "aiChat.a11y.title", "AI Chat"),
161
+ className: cn(
162
+ "overflow-hidden rounded-xl border bg-background shadow-xl",
163
+ (!widgetOpen || widgetExpanded) && "hidden"
164
+ ),
165
+ style: { height: widgetHeight, width: widgetWidth }
166
+ }
167
+ ),
168
+ /* @__PURE__ */ jsx(Dialog, { open: widgetExpanded, onOpenChange: setExpanded, children: /* @__PURE__ */ jsxs(
169
+ DialogContent,
170
+ {
171
+ showCloseButton: false,
172
+ style: {
173
+ ...style,
174
+ position: "fixed",
175
+ inset: 0,
176
+ top: 0,
177
+ right: 0,
178
+ bottom: 0,
179
+ left: 0,
180
+ width: "100vw",
181
+ height: "100dvh",
182
+ minWidth: 0,
183
+ minHeight: 0,
184
+ maxWidth: "none",
185
+ maxHeight: "none",
186
+ margin: 0,
187
+ transform: "none",
188
+ translate: "none",
189
+ zIndex: 50,
190
+ animation: "none"
191
+ },
192
+ "aria-describedby": void 0,
125
193
  className: cn(
126
- "flex flex-col border rounded-xl overflow-hidden bg-background shadow-xl",
127
- widgetOpen ? "flex" : "hidden"
194
+ className,
195
+ classNames?.container,
196
+ "fixed inset-0 z-50 flex h-dvh w-screen max-w-none translate-x-0 translate-y-0 flex-col gap-0 rounded-none border-0 p-0 sm:max-w-none pt-[env(safe-area-inset-top)] pb-[env(safe-area-inset-bottom)] pl-[env(safe-area-inset-left)] pr-[env(safe-area-inset-right)]"
128
197
  ),
129
- style: { height: widgetHeight, width: widgetWidth },
198
+ onCloseAutoFocus: (event) => {
199
+ const target = widgetOpen ? expandRef.current ?? compactPanelRef.current : triggerRef.current;
200
+ if (target) {
201
+ event.preventDefault();
202
+ target.focus();
203
+ }
204
+ },
130
205
  children: [
131
- /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1.5 px-3 py-1.5 border-b bg-muted/40", children: [
132
- /* @__PURE__ */ jsx(Sparkles, { className: "h-3 w-3 text-muted-foreground" }),
133
- pageAIContext ? /* @__PURE__ */ jsx(
134
- Badge,
135
- {
136
- variant: "secondary",
137
- className: "text-xs",
138
- "data-testid": "page-context-badge",
139
- children: pageAIContext.routeName
140
- }
141
- ) : /* @__PURE__ */ jsx("span", { className: "text-xs text-muted-foreground font-medium", children: tr("A11Y_CHAT_TITLE", "aiChat.a11y.title", "AI Chat") }),
142
- /* @__PURE__ */ jsx("div", { className: "flex-1" }),
143
- /* @__PURE__ */ jsx(
144
- Button,
145
- {
146
- variant: "ghost",
147
- size: "icon",
148
- className: "h-5 w-5",
149
- onClick: () => {
150
- track({ type: "conversation_cleared" });
151
- onClear?.();
152
- setWidgetResetKey((prev) => prev + 1);
153
- },
154
- "aria-label": tr(
155
- "A11Y_CLEAR_CHAT",
156
- "aiChat.a11y.clearChat",
157
- "Clear chat"
158
- ),
159
- title: tr(
160
- "A11Y_CLEAR_CHAT",
161
- "aiChat.a11y.clearChat",
162
- "Clear chat"
163
- ),
164
- children: /* @__PURE__ */ jsx(Trash2, { className: "h-3.5 w-3.5" })
165
- }
166
- ),
167
- /* @__PURE__ */ jsx(
168
- Button,
169
- {
170
- variant: "ghost",
171
- size: "icon",
172
- className: "h-5 w-5",
173
- onClick: () => {
174
- setWidgetOpen(false);
175
- track({ type: "widget_closed" });
176
- },
177
- "aria-label": tr(
178
- "A11Y_CLOSE_CHAT",
179
- "aiChat.a11y.closeChat",
180
- "Close chat"
181
- ),
182
- children: /* @__PURE__ */ jsx(X, { className: "h-3.5 w-3.5" })
183
- }
184
- )
185
- ] }),
186
- widgetEverOpened && /* @__PURE__ */ jsx(
187
- ChatInterface,
188
- {
189
- id: conversationId,
190
- variant: "widget",
191
- initialMessages,
192
- onMessagesChange
193
- },
194
- `widget-${conversationId ?? "new"}-${widgetResetKey}`
195
- )
206
+ /* @__PURE__ */ jsx(DialogTitle, { className: "sr-only", children: tr("A11Y_CHAT_TITLE", "aiChat.a11y.title", "AI Chat") }),
207
+ /* @__PURE__ */ jsx("div", { ref: mountExpandedPanel, className: "min-h-0 flex-1" })
196
208
  ]
197
209
  }
210
+ ) }),
211
+ panelContainer && createPortal(
212
+ /* @__PURE__ */ jsxs(Fragment, { children: [
213
+ /* @__PURE__ */ jsxs("div", { className: "flex shrink-0 items-center gap-1.5 px-3 py-1.5 border-b bg-muted/40", children: [
214
+ /* @__PURE__ */ jsx(Sparkles, { className: "h-3 w-3 text-muted-foreground" }),
215
+ pageAIContext ? /* @__PURE__ */ jsx(
216
+ Badge,
217
+ {
218
+ variant: "secondary",
219
+ className: "text-xs",
220
+ "data-testid": "page-context-badge",
221
+ children: pageAIContext.routeName
222
+ }
223
+ ) : /* @__PURE__ */ jsx("span", { className: "text-xs text-muted-foreground font-medium", children: tr("A11Y_CHAT_TITLE", "aiChat.a11y.title", "AI Chat") }),
224
+ /* @__PURE__ */ jsx("div", { className: "flex-1" }),
225
+ expandable && /* @__PURE__ */ jsx(
226
+ Button,
227
+ {
228
+ type: "button",
229
+ variant: "ghost",
230
+ size: "icon",
231
+ className: "h-7 w-7",
232
+ ref: expandRef,
233
+ onClick: () => setExpanded((prev) => !prev),
234
+ "aria-label": expandLabel,
235
+ title: expandLabel,
236
+ "aria-expanded": widgetExpanded,
237
+ children: widgetExpanded ? /* @__PURE__ */ jsx(Minimize2, { className: "h-3.5 w-3.5", "aria-hidden": "true" }) : /* @__PURE__ */ jsx(Maximize2, { className: "h-3.5 w-3.5", "aria-hidden": "true" })
238
+ }
239
+ ),
240
+ /* @__PURE__ */ jsx(
241
+ Button,
242
+ {
243
+ variant: "ghost",
244
+ size: "icon",
245
+ className: "h-5 w-5",
246
+ onClick: () => {
247
+ track({ type: "conversation_cleared" });
248
+ onClear?.();
249
+ setWidgetResetKey((prev) => prev + 1);
250
+ },
251
+ "aria-label": tr(
252
+ "A11Y_CLEAR_CHAT",
253
+ "aiChat.a11y.clearChat",
254
+ "Clear chat"
255
+ ),
256
+ title: tr(
257
+ "A11Y_CLEAR_CHAT",
258
+ "aiChat.a11y.clearChat",
259
+ "Clear chat"
260
+ ),
261
+ children: /* @__PURE__ */ jsx(Trash2, { className: "h-3.5 w-3.5" })
262
+ }
263
+ ),
264
+ /* @__PURE__ */ jsx(
265
+ Button,
266
+ {
267
+ variant: "ghost",
268
+ size: "icon",
269
+ className: "h-5 w-5",
270
+ onClick: () => {
271
+ setWidgetOpen(false);
272
+ setExpanded(false);
273
+ triggerRef.current?.focus();
274
+ track({ type: "widget_closed" });
275
+ },
276
+ "aria-label": tr(
277
+ "A11Y_CLOSE_CHAT",
278
+ "aiChat.a11y.closeChat",
279
+ "Close chat"
280
+ ),
281
+ children: /* @__PURE__ */ jsx(X, { className: "h-3.5 w-3.5" })
282
+ }
283
+ )
284
+ ] }),
285
+ widgetEverOpened && /* @__PURE__ */ jsx(
286
+ ChatInterface,
287
+ {
288
+ id: conversationId,
289
+ variant: "widget",
290
+ initialMessages,
291
+ onMessagesChange
292
+ },
293
+ `widget-${conversationId ?? "new"}-${widgetResetKey}`
294
+ )
295
+ ] }),
296
+ panelContainer
198
297
  ),
199
298
  showTrigger && /* @__PURE__ */ jsx(
200
299
  Button,
201
300
  {
301
+ ref: triggerRef,
202
302
  size: "icon",
203
303
  className: "h-12 w-12 rounded-full shadow-lg",
204
304
  onClick: () => {
205
305
  dismissTip("open");
206
306
  track({ type: widgetOpen ? "widget_closed" : "widget_opened" });
207
307
  setWidgetOpen((prev) => !prev);
308
+ setExpanded(false);
208
309
  setWidgetEverOpened(true);
209
310
  },
210
311
  "aria-label": widgetOpen ? tr("A11Y_CLOSE_CHAT", "aiChat.a11y.closeChat", "Close chat") : tr("A11Y_OPEN_CHAT", "aiChat.a11y.openChat", "Open chat"),
211
312
  "data-testid": "widget-trigger",
212
- children: widgetOpen ? /* @__PURE__ */ jsx(X, { className: "h-5 w-5" }) : /* @__PURE__ */ jsx(Sparkles, { className: "h-5 w-5" })
313
+ children: widgetOpen ? /* @__PURE__ */ jsx(X, { className: "h-5 w-5" }) : triggerIcon ?? /* @__PURE__ */ jsx(Sparkles, { className: "h-5 w-5" })
213
314
  }
214
315
  )
215
316
  ]
@@ -0,0 +1,30 @@
1
+ 'use strict';
2
+
3
+ function captureContextCheckpoint(messages, summary, throughMessageId) {
4
+ const index = messages.findIndex(
5
+ (message) => message.id === throughMessageId
6
+ );
7
+ if (index < 0) return void 0;
8
+ return {
9
+ summary,
10
+ throughMessageId,
11
+ prefix: JSON.stringify(messages.slice(0, index + 1))
12
+ };
13
+ }
14
+ function contextRequest(messages, checkpoint) {
15
+ if (checkpoint) {
16
+ const index = messages.findIndex(
17
+ (message) => message.id === checkpoint.throughMessageId
18
+ );
19
+ if (index >= 0 && JSON.stringify(messages.slice(0, index + 1)) === checkpoint.prefix) {
20
+ return {
21
+ messages: messages.slice(index + 1),
22
+ contextSummary: checkpoint.summary
23
+ };
24
+ }
25
+ }
26
+ return { messages };
27
+ }
28
+
29
+ exports.captureContextCheckpoint = captureContextCheckpoint;
30
+ exports.contextRequest = contextRequest;
@@ -0,0 +1,27 @@
1
+ function captureContextCheckpoint(messages, summary, throughMessageId) {
2
+ const index = messages.findIndex(
3
+ (message) => message.id === throughMessageId
4
+ );
5
+ if (index < 0) return void 0;
6
+ return {
7
+ summary,
8
+ throughMessageId,
9
+ prefix: JSON.stringify(messages.slice(0, index + 1))
10
+ };
11
+ }
12
+ function contextRequest(messages, checkpoint) {
13
+ if (checkpoint) {
14
+ const index = messages.findIndex(
15
+ (message) => message.id === checkpoint.throughMessageId
16
+ );
17
+ if (index >= 0 && JSON.stringify(messages.slice(0, index + 1)) === checkpoint.prefix) {
18
+ return {
19
+ messages: messages.slice(index + 1),
20
+ contextSummary: checkpoint.summary
21
+ };
22
+ }
23
+ }
24
+ return { messages };
25
+ }
26
+
27
+ export { captureContextCheckpoint, contextRequest };
@@ -34,6 +34,8 @@ const chatRequestSchema = z.z.object({
34
34
  ])
35
35
  ),
36
36
  conversationId: z.z.string().optional(),
37
+ /** Untrusted continuation summary for opt-in public context compaction. */
38
+ contextSummary: z.z.string().max(32e3).optional(),
37
39
  model: z.z.string().optional(),
38
40
  /**
39
41
  * Description of the current page context, injected into the AI system prompt.
@@ -32,6 +32,8 @@ const chatRequestSchema = z.object({
32
32
  ])
33
33
  ),
34
34
  conversationId: z.string().optional(),
35
+ /** Untrusted continuation summary for opt-in public context compaction. */
36
+ contextSummary: z.string().max(32e3).optional(),
35
37
  model: z.string().optional(),
36
38
  /**
37
39
  * Description of the current page context, injected into the AI system prompt.
@@ -77,7 +77,7 @@ function createTaskListItemRenderer() {
77
77
  ] });
78
78
  };
79
79
  }
80
- function createHeadingRenderer(tag) {
80
+ function createHeadingRenderer(tag, LinkComponent) {
81
81
  return function HeadingRenderer(props) {
82
82
  const { children, ...rest } = props;
83
83
  const text = getNodeText(children);
@@ -87,7 +87,7 @@ function createHeadingRenderer(tag) {
87
87
  { id, ...rest },
88
88
  children,
89
89
  text ? /* @__PURE__ */ jsxRuntime.jsx(
90
- "a",
90
+ LinkComponent,
91
91
  {
92
92
  className: "heading-anchor",
93
93
  href: `#${id}`,
@@ -276,15 +276,15 @@ function MarkdownContent({
276
276
  ),
277
277
  code: CodeRenderer,
278
278
  pre: PreRenderer,
279
- h1: createHeadingRenderer("h1"),
280
- h2: createHeadingRenderer("h2"),
281
- h3: createHeadingRenderer("h3"),
282
- h4: createHeadingRenderer("h4"),
283
- h5: createHeadingRenderer("h5"),
284
- h6: createHeadingRenderer("h6"),
279
+ h1: createHeadingRenderer("h1", LinkComponent),
280
+ h2: createHeadingRenderer("h2", LinkComponent),
281
+ h3: createHeadingRenderer("h3", LinkComponent),
282
+ h4: createHeadingRenderer("h4", LinkComponent),
283
+ h5: createHeadingRenderer("h5", LinkComponent),
284
+ h6: createHeadingRenderer("h6", LinkComponent),
285
285
  li: createTaskListItemRenderer()
286
286
  };
287
- }, [AnchorRenderer, ImgRenderer]);
287
+ }, [AnchorRenderer, ImgRenderer, LinkComponent]);
288
288
  const remarkPlugins = React.useMemo(() => {
289
289
  const plugins = [remarkGfm__default];
290
290
  if (hasMath && mathPlugins?.remarkMath) {
@@ -68,7 +68,7 @@ function createTaskListItemRenderer() {
68
68
  ] });
69
69
  };
70
70
  }
71
- function createHeadingRenderer(tag) {
71
+ function createHeadingRenderer(tag, LinkComponent) {
72
72
  return function HeadingRenderer(props) {
73
73
  const { children, ...rest } = props;
74
74
  const text = getNodeText(children);
@@ -78,7 +78,7 @@ function createHeadingRenderer(tag) {
78
78
  { id, ...rest },
79
79
  children,
80
80
  text ? /* @__PURE__ */ jsx(
81
- "a",
81
+ LinkComponent,
82
82
  {
83
83
  className: "heading-anchor",
84
84
  href: `#${id}`,
@@ -267,15 +267,15 @@ function MarkdownContent({
267
267
  ),
268
268
  code: CodeRenderer,
269
269
  pre: PreRenderer,
270
- h1: createHeadingRenderer("h1"),
271
- h2: createHeadingRenderer("h2"),
272
- h3: createHeadingRenderer("h3"),
273
- h4: createHeadingRenderer("h4"),
274
- h5: createHeadingRenderer("h5"),
275
- h6: createHeadingRenderer("h6"),
270
+ h1: createHeadingRenderer("h1", LinkComponent),
271
+ h2: createHeadingRenderer("h2", LinkComponent),
272
+ h3: createHeadingRenderer("h3", LinkComponent),
273
+ h4: createHeadingRenderer("h4", LinkComponent),
274
+ h5: createHeadingRenderer("h5", LinkComponent),
275
+ h6: createHeadingRenderer("h6", LinkComponent),
276
276
  li: createTaskListItemRenderer()
277
277
  };
278
- }, [AnchorRenderer, ImgRenderer]);
278
+ }, [AnchorRenderer, ImgRenderer, LinkComponent]);
279
279
  const remarkPlugins = useMemo(() => {
280
280
  const plugins = [remarkGfm];
281
281
  if (hasMath && mathPlugins?.remarkMath) {
@@ -1,5 +1,5 @@
1
- import { c as Conversation, M as Message } from '../../../shared/stack.Dgt3MCtW.cjs';
2
- export { o as AI_CHAT_OPERATION_INVENTORY, p as AI_CHAT_RAW_ESCAPE_HATCH_INVENTORY, l as AiChatAccess, j as AiChatApiRouter, h as AiChatBackendConfig, m as AiChatBackendHooks, A as AiChatIdentityPartition, q as AiChatOperationError, k as AiChatPageContentConfig, g as AiChatQueryKeys, n as ChatApiContext, r as ChatOperationInputSchema, s as ConversationOperationInputSchema, C as ConversationWithMessages, b as CreateConversationInput, R as RenameConversationInput, U as UpdateConversationOperationInputSchema, i as aiChatBackendPlugin, d as aiChatIdentityKey, e as aiChatResources, f as createAiChatQueryKeys } from '../../../shared/stack.Dgt3MCtW.cjs';
1
+ import { c as Conversation, M as Message } from '../../../shared/stack.ymWsP4HZ.cjs';
2
+ export { p as AI_CHAT_OPERATION_INVENTORY, q as AI_CHAT_RAW_ESCAPE_HATCH_INVENTORY, m as AiChatAccess, j as AiChatApiRouter, h as AiChatBackendConfig, n as AiChatBackendHooks, k as AiChatCompactionConfig, A as AiChatIdentityPartition, r as AiChatOperationError, l as AiChatPageContentConfig, g as AiChatQueryKeys, o as ChatApiContext, s as ChatOperationInputSchema, t as ConversationOperationInputSchema, C as ConversationWithMessages, b as CreateConversationInput, R as RenameConversationInput, U as UpdateConversationOperationInputSchema, i as aiChatBackendPlugin, d as aiChatIdentityKey, e as aiChatResources, f as createAiChatQueryKeys } from '../../../shared/stack.ymWsP4HZ.cjs';
3
3
  import { DBAdapter } from '@btst/db';
4
4
  import '@btst/stack/plugins/client';
5
5
  import '@btst/stack/plugins/api';
@@ -1,5 +1,5 @@
1
- import { c as Conversation, M as Message } from '../../../shared/stack.B7Mj74BQ.mjs';
2
- export { o as AI_CHAT_OPERATION_INVENTORY, p as AI_CHAT_RAW_ESCAPE_HATCH_INVENTORY, l as AiChatAccess, j as AiChatApiRouter, h as AiChatBackendConfig, m as AiChatBackendHooks, A as AiChatIdentityPartition, q as AiChatOperationError, k as AiChatPageContentConfig, g as AiChatQueryKeys, n as ChatApiContext, r as ChatOperationInputSchema, s as ConversationOperationInputSchema, C as ConversationWithMessages, b as CreateConversationInput, R as RenameConversationInput, U as UpdateConversationOperationInputSchema, i as aiChatBackendPlugin, d as aiChatIdentityKey, e as aiChatResources, f as createAiChatQueryKeys } from '../../../shared/stack.B7Mj74BQ.mjs';
1
+ import { c as Conversation, M as Message } from '../../../shared/stack.Ps3MDhTC.mjs';
2
+ export { p as AI_CHAT_OPERATION_INVENTORY, q as AI_CHAT_RAW_ESCAPE_HATCH_INVENTORY, m as AiChatAccess, j as AiChatApiRouter, h as AiChatBackendConfig, n as AiChatBackendHooks, k as AiChatCompactionConfig, A as AiChatIdentityPartition, r as AiChatOperationError, l as AiChatPageContentConfig, g as AiChatQueryKeys, o as ChatApiContext, s as ChatOperationInputSchema, t as ConversationOperationInputSchema, C as ConversationWithMessages, b as CreateConversationInput, R as RenameConversationInput, U as UpdateConversationOperationInputSchema, i as aiChatBackendPlugin, d as aiChatIdentityKey, e as aiChatResources, f as createAiChatQueryKeys } from '../../../shared/stack.Ps3MDhTC.mjs';
3
3
  import { DBAdapter } from '@btst/db';
4
4
  import '@btst/stack/plugins/client';
5
5
  import '@btst/stack/plugins/api';
@@ -1,5 +1,5 @@
1
- import { c as Conversation, M as Message } from '../../../shared/stack.DBH1Bjko.js';
2
- export { o as AI_CHAT_OPERATION_INVENTORY, p as AI_CHAT_RAW_ESCAPE_HATCH_INVENTORY, l as AiChatAccess, j as AiChatApiRouter, h as AiChatBackendConfig, m as AiChatBackendHooks, A as AiChatIdentityPartition, q as AiChatOperationError, k as AiChatPageContentConfig, g as AiChatQueryKeys, n as ChatApiContext, r as ChatOperationInputSchema, s as ConversationOperationInputSchema, C as ConversationWithMessages, b as CreateConversationInput, R as RenameConversationInput, U as UpdateConversationOperationInputSchema, i as aiChatBackendPlugin, d as aiChatIdentityKey, e as aiChatResources, f as createAiChatQueryKeys } from '../../../shared/stack.DBH1Bjko.js';
1
+ import { c as Conversation, M as Message } from '../../../shared/stack.C4zspX0T.js';
2
+ export { p as AI_CHAT_OPERATION_INVENTORY, q as AI_CHAT_RAW_ESCAPE_HATCH_INVENTORY, m as AiChatAccess, j as AiChatApiRouter, h as AiChatBackendConfig, n as AiChatBackendHooks, k as AiChatCompactionConfig, A as AiChatIdentityPartition, r as AiChatOperationError, l as AiChatPageContentConfig, g as AiChatQueryKeys, o as ChatApiContext, s as ChatOperationInputSchema, t as ConversationOperationInputSchema, C as ConversationWithMessages, b as CreateConversationInput, R as RenameConversationInput, U as UpdateConversationOperationInputSchema, i as aiChatBackendPlugin, d as aiChatIdentityKey, e as aiChatResources, f as createAiChatQueryKeys } from '../../../shared/stack.C4zspX0T.js';
3
3
  import { DBAdapter } from '@btst/db';
4
4
  import '@btst/stack/plugins/client';
5
5
  import '@btst/stack/plugins/api';
@@ -1,4 +1,4 @@
1
- export { j as ChatInput, C as ChatInterface, f as ChatLayout, g as ChatLayoutProps, i as ChatMessage, h as ChatSidebar, k as ToolCallDisplay } from '../../../../shared/stack.xAiy2VtO.cjs';
1
+ export { j as ChatInput, C as ChatInterface, f as ChatLayout, g as ChatLayoutProps, i as ChatMessage, h as ChatSidebar, k as ToolCallDisplay } from '../../../../shared/stack.DDQlE2Pm.cjs';
2
2
  import * as react_jsx_runtime from 'react/jsx-runtime';
3
3
  import { FallbackProps } from 'react-error-boundary';
4
4
  import 'ai';
@@ -1,4 +1,4 @@
1
- export { j as ChatInput, C as ChatInterface, f as ChatLayout, g as ChatLayoutProps, i as ChatMessage, h as ChatSidebar, k as ToolCallDisplay } from '../../../../shared/stack.C5FZr-jJ.mjs';
1
+ export { j as ChatInput, C as ChatInterface, f as ChatLayout, g as ChatLayoutProps, i as ChatMessage, h as ChatSidebar, k as ToolCallDisplay } from '../../../../shared/stack.tAUeRAtd.mjs';
2
2
  import * as react_jsx_runtime from 'react/jsx-runtime';
3
3
  import { FallbackProps } from 'react-error-boundary';
4
4
  import 'ai';
@@ -1,4 +1,4 @@
1
- export { j as ChatInput, C as ChatInterface, f as ChatLayout, g as ChatLayoutProps, i as ChatMessage, h as ChatSidebar, k as ToolCallDisplay } from '../../../../shared/stack.C-eQN_Jt.js';
1
+ export { j as ChatInput, C as ChatInterface, f as ChatLayout, g as ChatLayoutProps, i as ChatMessage, h as ChatSidebar, k as ToolCallDisplay } from '../../../../shared/stack.DlehgNZZ.js';
2
2
  import * as react_jsx_runtime from 'react/jsx-runtime';
3
3
  import { FallbackProps } from 'react-error-boundary';
4
4
  import 'ai';
@@ -1,7 +1,7 @@
1
1
  import { UseMutationResult } from '@tanstack/react-query';
2
2
  import { ResourceFormResult } from '@btst/stack/plugins/client/hooks';
3
- import { A as AiChatIdentityPartition, S as SerializedConversation, C as ConversationWithMessages, b as CreateConversationInput, R as RenameConversationInput } from '../../../../shared/stack.Dgt3MCtW.cjs';
4
- export { a as SerializedMessage } from '../../../../shared/stack.Dgt3MCtW.cjs';
3
+ import { A as AiChatIdentityPartition, S as SerializedConversation, C as ConversationWithMessages, b as CreateConversationInput, R as RenameConversationInput } from '../../../../shared/stack.ymWsP4HZ.cjs';
4
+ export { a as SerializedMessage } from '../../../../shared/stack.ymWsP4HZ.cjs';
5
5
  import '@btst/stack/plugins/client';
6
6
  import '@btst/stack/plugins/api';
7
7
  import '@btst/stack/authorization';
@@ -1,7 +1,7 @@
1
1
  import { UseMutationResult } from '@tanstack/react-query';
2
2
  import { ResourceFormResult } from '@btst/stack/plugins/client/hooks';
3
- import { A as AiChatIdentityPartition, S as SerializedConversation, C as ConversationWithMessages, b as CreateConversationInput, R as RenameConversationInput } from '../../../../shared/stack.B7Mj74BQ.mjs';
4
- export { a as SerializedMessage } from '../../../../shared/stack.B7Mj74BQ.mjs';
3
+ import { A as AiChatIdentityPartition, S as SerializedConversation, C as ConversationWithMessages, b as CreateConversationInput, R as RenameConversationInput } from '../../../../shared/stack.Ps3MDhTC.mjs';
4
+ export { a as SerializedMessage } from '../../../../shared/stack.Ps3MDhTC.mjs';
5
5
  import '@btst/stack/plugins/client';
6
6
  import '@btst/stack/plugins/api';
7
7
  import '@btst/stack/authorization';
@@ -1,7 +1,7 @@
1
1
  import { UseMutationResult } from '@tanstack/react-query';
2
2
  import { ResourceFormResult } from '@btst/stack/plugins/client/hooks';
3
- import { A as AiChatIdentityPartition, S as SerializedConversation, C as ConversationWithMessages, b as CreateConversationInput, R as RenameConversationInput } from '../../../../shared/stack.DBH1Bjko.js';
4
- export { a as SerializedMessage } from '../../../../shared/stack.DBH1Bjko.js';
3
+ import { A as AiChatIdentityPartition, S as SerializedConversation, C as ConversationWithMessages, b as CreateConversationInput, R as RenameConversationInput } from '../../../../shared/stack.C4zspX0T.js';
4
+ export { a as SerializedMessage } from '../../../../shared/stack.C4zspX0T.js';
5
5
  import '@btst/stack/plugins/client';
6
6
  import '@btst/stack/plugins/api';
7
7
  import '@btst/stack/authorization';
@@ -2,9 +2,9 @@ import * as _btst_stack_plugins_client from '@btst/stack/plugins/client';
2
2
  import * as _btst_yar from '@btst/yar';
3
3
  import * as react_jsx_runtime from 'react/jsx-runtime';
4
4
  import { ComponentType } from 'react';
5
- import { S as SerializedConversation, a as SerializedMessage, A as AiChatIdentityPartition } from '../../../shared/stack.Dgt3MCtW.cjs';
6
- import { A as AiChatMode, a as AiChatPluginOverrides } from '../../../shared/stack.xAiy2VtO.cjs';
7
- export { l as AiChatAnalyticsEvent, b as AiChatProviderConfig, c as AllowedFileType, j as ChatInput, C as ChatInterface, f as ChatLayout, g as ChatLayoutProps, i as ChatMessage, h as ChatSidebar, D as DEFAULT_ALLOWED_FILE_TYPES, k as ToolCallDisplay, T as ToolCallProps, e as ToolCallRenderer, d as ToolCallState } from '../../../shared/stack.xAiy2VtO.cjs';
5
+ import { S as SerializedConversation, a as SerializedMessage, A as AiChatIdentityPartition } from '../../../shared/stack.ymWsP4HZ.cjs';
6
+ import { A as AiChatMode, a as AiChatPluginOverrides } from '../../../shared/stack.DDQlE2Pm.cjs';
7
+ export { l as AiChatAnalyticsEvent, b as AiChatProviderConfig, c as AllowedFileType, j as ChatInput, C as ChatInterface, f as ChatLayout, g as ChatLayoutProps, i as ChatMessage, h as ChatSidebar, D as DEFAULT_ALLOWED_FILE_TYPES, k as ToolCallDisplay, T as ToolCallProps, e as ToolCallRenderer, d as ToolCallState } from '../../../shared/stack.DDQlE2Pm.cjs';
8
8
  export { UIMessage } from 'ai';
9
9
  import '@btst/stack/plugins/api';
10
10
  import '@btst/stack/authorization';
@@ -2,9 +2,9 @@ import * as _btst_stack_plugins_client from '@btst/stack/plugins/client';
2
2
  import * as _btst_yar from '@btst/yar';
3
3
  import * as react_jsx_runtime from 'react/jsx-runtime';
4
4
  import { ComponentType } from 'react';
5
- import { S as SerializedConversation, a as SerializedMessage, A as AiChatIdentityPartition } from '../../../shared/stack.B7Mj74BQ.mjs';
6
- import { A as AiChatMode, a as AiChatPluginOverrides } from '../../../shared/stack.C5FZr-jJ.mjs';
7
- export { l as AiChatAnalyticsEvent, b as AiChatProviderConfig, c as AllowedFileType, j as ChatInput, C as ChatInterface, f as ChatLayout, g as ChatLayoutProps, i as ChatMessage, h as ChatSidebar, D as DEFAULT_ALLOWED_FILE_TYPES, k as ToolCallDisplay, T as ToolCallProps, e as ToolCallRenderer, d as ToolCallState } from '../../../shared/stack.C5FZr-jJ.mjs';
5
+ import { S as SerializedConversation, a as SerializedMessage, A as AiChatIdentityPartition } from '../../../shared/stack.Ps3MDhTC.mjs';
6
+ import { A as AiChatMode, a as AiChatPluginOverrides } from '../../../shared/stack.tAUeRAtd.mjs';
7
+ export { l as AiChatAnalyticsEvent, b as AiChatProviderConfig, c as AllowedFileType, j as ChatInput, C as ChatInterface, f as ChatLayout, g as ChatLayoutProps, i as ChatMessage, h as ChatSidebar, D as DEFAULT_ALLOWED_FILE_TYPES, k as ToolCallDisplay, T as ToolCallProps, e as ToolCallRenderer, d as ToolCallState } from '../../../shared/stack.tAUeRAtd.mjs';
8
8
  export { UIMessage } from 'ai';
9
9
  import '@btst/stack/plugins/api';
10
10
  import '@btst/stack/authorization';
@@ -2,9 +2,9 @@ import * as _btst_stack_plugins_client from '@btst/stack/plugins/client';
2
2
  import * as _btst_yar from '@btst/yar';
3
3
  import * as react_jsx_runtime from 'react/jsx-runtime';
4
4
  import { ComponentType } from 'react';
5
- import { S as SerializedConversation, a as SerializedMessage, A as AiChatIdentityPartition } from '../../../shared/stack.DBH1Bjko.js';
6
- import { A as AiChatMode, a as AiChatPluginOverrides } from '../../../shared/stack.C-eQN_Jt.js';
7
- export { l as AiChatAnalyticsEvent, b as AiChatProviderConfig, c as AllowedFileType, j as ChatInput, C as ChatInterface, f as ChatLayout, g as ChatLayoutProps, i as ChatMessage, h as ChatSidebar, D as DEFAULT_ALLOWED_FILE_TYPES, k as ToolCallDisplay, T as ToolCallProps, e as ToolCallRenderer, d as ToolCallState } from '../../../shared/stack.C-eQN_Jt.js';
5
+ import { S as SerializedConversation, a as SerializedMessage, A as AiChatIdentityPartition } from '../../../shared/stack.C4zspX0T.js';
6
+ import { A as AiChatMode, a as AiChatPluginOverrides } from '../../../shared/stack.DlehgNZZ.js';
7
+ export { l as AiChatAnalyticsEvent, b as AiChatProviderConfig, c as AllowedFileType, j as ChatInput, C as ChatInterface, f as ChatLayout, g as ChatLayoutProps, i as ChatMessage, h as ChatSidebar, D as DEFAULT_ALLOWED_FILE_TYPES, k as ToolCallDisplay, T as ToolCallProps, e as ToolCallRenderer, d as ToolCallState } from '../../../shared/stack.DlehgNZZ.js';
8
8
  export { UIMessage } from 'ai';
9
9
  import '@btst/stack/plugins/api';
10
10
  import '@btst/stack/authorization';
@@ -1,5 +1,5 @@
1
1
  import '@btst/stack/plugins/client';
2
- export { A as AiChatIdentityPartition, g as AiChatQueryKeys, C as ConversationWithMessages, b as CreateConversationInput, R as RenameConversationInput, d as aiChatIdentityKey, e as aiChatResources, f as createAiChatQueryKeys } from '../../shared/stack.Dgt3MCtW.cjs';
2
+ export { A as AiChatIdentityPartition, g as AiChatQueryKeys, C as ConversationWithMessages, b as CreateConversationInput, R as RenameConversationInput, d as aiChatIdentityKey, e as aiChatResources, f as createAiChatQueryKeys } from '../../shared/stack.ymWsP4HZ.cjs';
3
3
  import '@btst/stack/context';
4
4
  import '@btst/stack/plugins/api';
5
5
  import '@btst/stack/authorization';
@@ -1,5 +1,5 @@
1
1
  import '@btst/stack/plugins/client';
2
- export { A as AiChatIdentityPartition, g as AiChatQueryKeys, C as ConversationWithMessages, b as CreateConversationInput, R as RenameConversationInput, d as aiChatIdentityKey, e as aiChatResources, f as createAiChatQueryKeys } from '../../shared/stack.B7Mj74BQ.mjs';
2
+ export { A as AiChatIdentityPartition, g as AiChatQueryKeys, C as ConversationWithMessages, b as CreateConversationInput, R as RenameConversationInput, d as aiChatIdentityKey, e as aiChatResources, f as createAiChatQueryKeys } from '../../shared/stack.Ps3MDhTC.mjs';
3
3
  import '@btst/stack/context';
4
4
  import '@btst/stack/plugins/api';
5
5
  import '@btst/stack/authorization';
@@ -1,5 +1,5 @@
1
1
  import '@btst/stack/plugins/client';
2
- export { A as AiChatIdentityPartition, g as AiChatQueryKeys, C as ConversationWithMessages, b as CreateConversationInput, R as RenameConversationInput, d as aiChatIdentityKey, e as aiChatResources, f as createAiChatQueryKeys } from '../../shared/stack.DBH1Bjko.js';
2
+ export { A as AiChatIdentityPartition, g as AiChatQueryKeys, C as ConversationWithMessages, b as CreateConversationInput, R as RenameConversationInput, d as aiChatIdentityKey, e as aiChatResources, f as createAiChatQueryKeys } from '../../shared/stack.C4zspX0T.js';
3
3
  import '@btst/stack/context';
4
4
  import '@btst/stack/plugins/api';
5
5
  import '@btst/stack/authorization';