@pyxis-llm/react 0.0.0-stage → 0.5.3

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 (192) hide show
  1. package/dist/AgentProfileEditor.d.ts +48 -0
  2. package/dist/AgentProfileEditor.d.ts.map +1 -0
  3. package/dist/AgentProfileEditor.js +122 -0
  4. package/dist/AgentProfileList.d.ts +17 -0
  5. package/dist/AgentProfileList.d.ts.map +1 -0
  6. package/dist/AgentProfileList.js +46 -0
  7. package/dist/AskCardAnswerChip.d.ts +8 -0
  8. package/dist/AskCardAnswerChip.d.ts.map +1 -0
  9. package/dist/AskCardAnswerChip.js +21 -0
  10. package/dist/AskCardView.d.ts +85 -0
  11. package/dist/AskCardView.d.ts.map +1 -0
  12. package/dist/AskCardView.js +158 -0
  13. package/dist/CatalogColumnBrowser.d.ts +33 -0
  14. package/dist/CatalogColumnBrowser.d.ts.map +1 -0
  15. package/dist/CatalogColumnBrowser.js +219 -0
  16. package/dist/CatalogModelPicker.d.ts +68 -0
  17. package/dist/CatalogModelPicker.d.ts.map +1 -0
  18. package/dist/CatalogModelPicker.js +119 -0
  19. package/dist/CatalogModelPickerMenuContent.d.ts +17 -0
  20. package/dist/CatalogModelPickerMenuContent.d.ts.map +1 -0
  21. package/dist/CatalogModelPickerMenuContent.js +103 -0
  22. package/dist/CatalogPickerMenuItem.d.ts +17 -0
  23. package/dist/CatalogPickerMenuItem.d.ts.map +1 -0
  24. package/dist/CatalogPickerMenuItem.js +15 -0
  25. package/dist/CatalogTreePickerOptions.d.ts +52 -0
  26. package/dist/CatalogTreePickerOptions.d.ts.map +1 -0
  27. package/dist/CatalogTreePickerOptions.js +248 -0
  28. package/dist/ChatMessage.d.ts +172 -0
  29. package/dist/ChatMessage.d.ts.map +1 -0
  30. package/dist/ChatMessage.js +295 -0
  31. package/dist/ChatPanel.d.ts +252 -0
  32. package/dist/ChatPanel.d.ts.map +1 -0
  33. package/dist/ChatPanel.js +247 -0
  34. package/dist/ChatTranscriptFind.d.ts +19 -0
  35. package/dist/ChatTranscriptFind.d.ts.map +1 -0
  36. package/dist/ChatTranscriptFind.js +224 -0
  37. package/dist/ChatTranscriptFindBar.d.ts +15 -0
  38. package/dist/ChatTranscriptFindBar.d.ts.map +1 -0
  39. package/dist/ChatTranscriptFindBar.js +22 -0
  40. package/dist/Composer.d.ts +43 -0
  41. package/dist/Composer.d.ts.map +1 -0
  42. package/dist/Composer.js +45 -0
  43. package/dist/ComposerAttachments.d.ts +101 -0
  44. package/dist/ComposerAttachments.d.ts.map +1 -0
  45. package/dist/ComposerAttachments.js +126 -0
  46. package/dist/DisplayCards.d.ts +18 -0
  47. package/dist/DisplayCards.d.ts.map +1 -0
  48. package/dist/DisplayCards.js +72 -0
  49. package/dist/ErrorBoundary.d.ts +27 -0
  50. package/dist/ErrorBoundary.d.ts.map +1 -0
  51. package/dist/ErrorBoundary.js +107 -0
  52. package/dist/ImageDisplayCard.d.ts +6 -0
  53. package/dist/ImageDisplayCard.d.ts.map +1 -0
  54. package/dist/ImageDisplayCard.js +57 -0
  55. package/dist/MarkdownCodeComponents.d.ts +23 -0
  56. package/dist/MarkdownCodeComponents.d.ts.map +1 -0
  57. package/dist/MarkdownCodeComponents.js +256 -0
  58. package/dist/MermaidDiagram.d.ts +18 -0
  59. package/dist/MermaidDiagram.d.ts.map +1 -0
  60. package/dist/MermaidDiagram.js +66 -0
  61. package/dist/MessageContentWithPastes.d.ts +14 -0
  62. package/dist/MessageContentWithPastes.d.ts.map +1 -0
  63. package/dist/MessageContentWithPastes.js +44 -0
  64. package/dist/PastePill.d.ts +16 -0
  65. package/dist/PastePill.d.ts.map +1 -0
  66. package/dist/PastePill.js +43 -0
  67. package/dist/ProviderAuthTerminal.d.ts +12 -0
  68. package/dist/ProviderAuthTerminal.d.ts.map +1 -0
  69. package/dist/ProviderAuthTerminal.js +50 -0
  70. package/dist/ProviderConnectForm.d.ts +62 -0
  71. package/dist/ProviderConnectForm.d.ts.map +1 -0
  72. package/dist/ProviderConnectForm.js +206 -0
  73. package/dist/ProviderList.d.ts +18 -0
  74. package/dist/ProviderList.d.ts.map +1 -0
  75. package/dist/ProviderList.js +67 -0
  76. package/dist/QueueStrip.d.ts +17 -0
  77. package/dist/QueueStrip.d.ts.map +1 -0
  78. package/dist/QueueStrip.js +60 -0
  79. package/dist/SettingsScreen.d.ts +10 -0
  80. package/dist/SettingsScreen.d.ts.map +1 -0
  81. package/dist/SettingsScreen.js +26 -0
  82. package/dist/StreamingMarkdown.d.ts +47 -0
  83. package/dist/StreamingMarkdown.d.ts.map +1 -0
  84. package/dist/StreamingMarkdown.js +103 -0
  85. package/dist/TurnTimer.d.ts +72 -0
  86. package/dist/TurnTimer.d.ts.map +1 -0
  87. package/dist/TurnTimer.js +114 -0
  88. package/dist/VegaChart.d.ts +36 -0
  89. package/dist/VegaChart.d.ts.map +1 -0
  90. package/dist/VegaChart.js +180 -0
  91. package/dist/browser.d.ts +7 -0
  92. package/dist/browser.d.ts.map +1 -0
  93. package/dist/browser.js +18 -0
  94. package/dist/catalogColumnBrowserTree.d.ts +9 -0
  95. package/dist/catalogColumnBrowserTree.d.ts.map +1 -0
  96. package/dist/catalogColumnBrowserTree.js +48 -0
  97. package/dist/catalogPickerMenuStyles.d.ts +81 -0
  98. package/dist/catalogPickerMenuStyles.d.ts.map +1 -0
  99. package/dist/catalogPickerMenuStyles.js +130 -0
  100. package/dist/charts.d.ts +12 -0
  101. package/dist/charts.d.ts.map +1 -0
  102. package/dist/charts.js +45 -0
  103. package/dist/chatMessageScroll.d.ts +40 -0
  104. package/dist/chatMessageScroll.d.ts.map +1 -0
  105. package/dist/chatMessageScroll.js +62 -0
  106. package/dist/chatModelOptions.d.ts +28 -0
  107. package/dist/chatModelOptions.d.ts.map +1 -0
  108. package/dist/chatModelOptions.js +59 -0
  109. package/dist/chatTranscriptFindHighlights.d.ts +9 -0
  110. package/dist/chatTranscriptFindHighlights.d.ts.map +1 -0
  111. package/dist/chatTranscriptFindHighlights.js +88 -0
  112. package/dist/draftStore.d.ts +13 -0
  113. package/dist/draftStore.d.ts.map +1 -0
  114. package/dist/draftStore.js +38 -0
  115. package/dist/highlight.d.ts +4 -0
  116. package/dist/highlight.d.ts.map +1 -0
  117. package/dist/highlight.js +47 -0
  118. package/dist/index.d.ts +74 -0
  119. package/dist/index.d.ts.map +1 -0
  120. package/dist/index.js +48 -0
  121. package/dist/keyboardShortcuts.d.ts +5 -0
  122. package/dist/keyboardShortcuts.d.ts.map +1 -0
  123. package/dist/keyboardShortcuts.js +19 -0
  124. package/dist/markdownClipboard.d.ts +22 -0
  125. package/dist/markdownClipboard.d.ts.map +1 -0
  126. package/dist/markdownClipboard.js +98 -0
  127. package/dist/markdownPlugins.d.ts +31 -0
  128. package/dist/markdownPlugins.d.ts.map +1 -0
  129. package/dist/markdownPlugins.js +32 -0
  130. package/dist/mermaid.d.ts +17 -0
  131. package/dist/mermaid.d.ts.map +1 -0
  132. package/dist/mermaid.js +11 -0
  133. package/dist/mermaidRuntime.d.ts +21 -0
  134. package/dist/mermaidRuntime.d.ts.map +1 -0
  135. package/dist/mermaidRuntime.js +140 -0
  136. package/dist/modelCatalogHelpers.d.ts +14 -0
  137. package/dist/modelCatalogHelpers.d.ts.map +1 -0
  138. package/dist/modelCatalogHelpers.js +65 -0
  139. package/dist/modelCatalogSource.d.ts +22 -0
  140. package/dist/modelCatalogSource.d.ts.map +1 -0
  141. package/dist/modelCatalogSource.js +26 -0
  142. package/dist/modelCatalogTree.d.ts +24 -0
  143. package/dist/modelCatalogTree.d.ts.map +1 -0
  144. package/dist/modelCatalogTree.js +77 -0
  145. package/dist/node.d.ts +9 -0
  146. package/dist/node.d.ts.map +1 -0
  147. package/dist/node.js +13 -0
  148. package/dist/pasteFences.d.ts +20 -0
  149. package/dist/pasteFences.d.ts.map +1 -0
  150. package/dist/pasteFences.js +157 -0
  151. package/dist/pasteFormat.d.ts +5 -0
  152. package/dist/pasteFormat.d.ts.map +1 -0
  153. package/dist/pasteFormat.js +18 -0
  154. package/dist/plugins.d.ts +110 -0
  155. package/dist/plugins.d.ts.map +1 -0
  156. package/dist/plugins.js +98 -0
  157. package/dist/remarkAlerts.d.ts +12 -0
  158. package/dist/remarkAlerts.d.ts.map +1 -0
  159. package/dist/remarkAlerts.js +52 -0
  160. package/dist/sendMode.d.ts +69 -0
  161. package/dist/sendMode.d.ts.map +1 -0
  162. package/dist/sendMode.js +66 -0
  163. package/dist/useLlmdChatDriver.d.ts +367 -0
  164. package/dist/useLlmdChatDriver.d.ts.map +1 -0
  165. package/dist/useLlmdChatDriver.js +1739 -0
  166. package/dist/useLlmdModelCatalog.d.ts +23 -0
  167. package/dist/useLlmdModelCatalog.d.ts.map +1 -0
  168. package/dist/useLlmdModelCatalog.js +89 -0
  169. package/dist/useLlmdSessionModel.d.ts +34 -0
  170. package/dist/useLlmdSessionModel.d.ts.map +1 -0
  171. package/dist/useLlmdSessionModel.js +79 -0
  172. package/dist/useProviderAuthCommand.d.ts +26 -0
  173. package/dist/useProviderAuthCommand.d.ts.map +1 -0
  174. package/dist/useProviderAuthCommand.js +80 -0
  175. package/dist/vegaRuntime.d.ts +83 -0
  176. package/dist/vegaRuntime.d.ts.map +1 -0
  177. package/dist/vegaRuntime.js +314 -0
  178. package/dist/vendor/llmd-types/conversationEvents.d.ts +238 -0
  179. package/dist/vendor/llmd-types/conversationEvents.d.ts.map +1 -0
  180. package/dist/vendor/llmd-types/conversationEvents.js +98 -0
  181. package/dist/vendor/llmd-types/index.d.ts +4 -0
  182. package/dist/vendor/llmd-types/index.d.ts.map +1 -0
  183. package/dist/vendor/llmd-types/index.js +5 -0
  184. package/dist/vendor/llmd-types/messages.d.ts +67 -0
  185. package/dist/vendor/llmd-types/messages.d.ts.map +1 -0
  186. package/dist/vendor/llmd-types/messages.js +71 -0
  187. package/dist/vendor/llmd-types/sessionQueue.d.ts +54 -0
  188. package/dist/vendor/llmd-types/sessionQueue.d.ts.map +1 -0
  189. package/dist/vendor/llmd-types/sessionQueue.js +40 -0
  190. package/package.json +120 -4
  191. package/styles.css +389 -0
  192. package/README.md +0 -3
@@ -0,0 +1,101 @@
1
+ /**
2
+ * Extra context a user attaches to an outgoing message (e.g. a plan/design
3
+ * document, or an arbitrary text snippet) — appended as a fenced block when
4
+ * the message is sent, and shown as removable chips in the composer.
5
+ *
6
+ * Generic: no assumptions about what "plan"/"design" mean beyond "named
7
+ * content the host can list". A host wires `PlanDesignListItemForAttachment[]`
8
+ * lists from its own data (plans/designs/whatever it has) into
9
+ * `AddAttachmentModal`; this module never fetches anything itself.
10
+ */
11
+ import type { Dispatch, SetStateAction } from 'react';
12
+ /** Extra context appended to outgoing user messages (plans, designs, or pasted text). */
13
+ export type ComposerAttachment = {
14
+ type: 'plan';
15
+ name: string;
16
+ content: string;
17
+ } | {
18
+ type: 'text';
19
+ name: string;
20
+ content: string;
21
+ };
22
+ export type PlanDesignListItemForAttachment = {
23
+ name: string;
24
+ path: string;
25
+ label?: string | null;
26
+ };
27
+ export declare function composerAttachmentSignature(a: ComposerAttachment): string;
28
+ /** Attachment kind llmd stores composer attachments under. */
29
+ export declare const COMPOSER_ATTACHMENT_KIND = "composer_attachment";
30
+ /**
31
+ * A composer attachment as a real message attachment (structurally the
32
+ * driver's `OutgoingAttachment`): `content` is exactly the fenced block that
33
+ * used to be appended to the message text, so the model sees the same thing;
34
+ * `payloadJson` keeps the structured {type, name} for display.
35
+ */
36
+ export type ComposerOutgoingAttachment = {
37
+ id: string;
38
+ kind: string;
39
+ payloadJson: string;
40
+ content: string;
41
+ };
42
+ /** Converts composer attachments into message attachments for `driver.send(text, behavior, attachments)`. */
43
+ export declare function composerAttachmentsToMessageAttachments(attachments: ComposerAttachment[]): ComposerOutgoingAttachment[];
44
+ /**
45
+ * @deprecated Inlines attachments into the message text. Send them as real
46
+ * attachments instead: `composerAttachmentsToMessageAttachments` (or the
47
+ * session hook's `outgoingAttachments`).
48
+ */
49
+ export declare function appendComposerAttachmentsToMessage(text: string, attachments: ComposerAttachment[]): string;
50
+ export declare function AddAttachmentModal({ plansList, designsList, onClose, onAddPlan, onAddDesign, onAddNew, newAttachmentName, setNewAttachmentName, newAttachmentContent, setNewAttachmentContent, attachmentAddingId, }: {
51
+ plansList: PlanDesignListItemForAttachment[];
52
+ designsList: PlanDesignListItemForAttachment[];
53
+ onClose: () => void;
54
+ onAddPlan: (plan: PlanDesignListItemForAttachment) => Promise<void>;
55
+ onAddDesign: (design: PlanDesignListItemForAttachment) => Promise<void>;
56
+ onAddNew: (name: string, content: string) => void;
57
+ newAttachmentName: string;
58
+ setNewAttachmentName: (v: string) => void;
59
+ newAttachmentContent: string;
60
+ setNewAttachmentContent: (v: string) => void;
61
+ attachmentAddingId: string | null;
62
+ }): import("react").JSX.Element;
63
+ export type ComposerAttachmentUnifiedPanelProps = {
64
+ composerAttachments: Array<{
65
+ key: string;
66
+ label: string;
67
+ index: number;
68
+ }>;
69
+ onComposerAttachmentAdd: () => void;
70
+ onComposerAttachmentRemove: (index: number) => void;
71
+ composerAttachmentAddDisabled: boolean;
72
+ };
73
+ /**
74
+ * Session-scoped composer attachments (badges + modal) for any surface that uses `sessionId`.
75
+ */
76
+ export declare function useComposerAttachmentsSessionState(sessionId: string | null): {
77
+ attachmentsBySession: Record<string, ComposerAttachment[]>;
78
+ setAttachmentsBySession: Dispatch<SetStateAction<Record<string, ComposerAttachment[]>>>;
79
+ attachments: ComposerAttachment[];
80
+ setAttachments: (update: ComposerAttachment[] | ((prev: ComposerAttachment[]) => ComposerAttachment[])) => void;
81
+ addAttachmentModalOpen: boolean;
82
+ setAddAttachmentModalOpen: (v: boolean) => void;
83
+ newAttachmentName: string;
84
+ setNewAttachmentName: (v: string) => void;
85
+ newAttachmentContent: string;
86
+ setNewAttachmentContent: (v: string) => void;
87
+ attachmentAddingId: string | null;
88
+ setAttachmentAddingId: (v: string | null) => void;
89
+ /** @deprecated Inlines attachments into the text; pass `outgoingAttachments` to `driver.send` instead. */
90
+ transformContent: (text: string) => string;
91
+ /**
92
+ * The not-yet-sent attachments as real message attachments: pass to
93
+ * `driver.send(text, behavior, outgoingAttachments)`, then call
94
+ * `markComposerAttachmentsSent()`.
95
+ */
96
+ outgoingAttachments: ComposerOutgoingAttachment[];
97
+ /** Call after a message is sent so attachments are not re-sent on follow-up turns. */
98
+ markComposerAttachmentsSent: () => void;
99
+ unifiedComposerAttachmentProps: ComposerAttachmentUnifiedPanelProps;
100
+ };
101
+ //# sourceMappingURL=ComposerAttachments.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ComposerAttachments.d.ts","sourceRoot":"","sources":["../src/ComposerAttachments.tsx"],"names":[],"mappings":"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"}
@@ -0,0 +1,126 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useCallback, useMemo, useState } from 'react';
3
+ import { ActionIcon, Button, Tabs, Text, Textarea, TextInput, } from '@mantine/core';
4
+ export function composerAttachmentSignature(a) {
5
+ return `${a.type}:${a.name}:${a.content.length}`;
6
+ }
7
+ /** Attachment kind llmd stores composer attachments under. */
8
+ export const COMPOSER_ATTACHMENT_KIND = 'composer_attachment';
9
+ function composerAttachmentBlock(a) {
10
+ const label = a.type === 'plan' ? `Plan: ${a.name}` : a.name;
11
+ return `\`\`\`${label}\n${a.content}\n\`\`\``;
12
+ }
13
+ /** Converts composer attachments into message attachments for `driver.send(text, behavior, attachments)`. */
14
+ export function composerAttachmentsToMessageAttachments(attachments) {
15
+ return attachments.map((a) => ({
16
+ id: `composer-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 10)}`,
17
+ kind: COMPOSER_ATTACHMENT_KIND,
18
+ payloadJson: JSON.stringify({ type: a.type, name: a.name }),
19
+ content: composerAttachmentBlock(a),
20
+ }));
21
+ }
22
+ /**
23
+ * @deprecated Inlines attachments into the message text. Send them as real
24
+ * attachments instead: `composerAttachmentsToMessageAttachments` (or the
25
+ * session hook's `outgoingAttachments`).
26
+ */
27
+ export function appendComposerAttachmentsToMessage(text, attachments) {
28
+ if (attachments.length === 0)
29
+ return text;
30
+ let out = text;
31
+ for (const a of attachments) {
32
+ const label = a.type === 'plan' ? `Plan: ${a.name}` : a.name;
33
+ out += `\n\n\`\`\`${label}\n${a.content}\n\`\`\`\n`;
34
+ }
35
+ return out;
36
+ }
37
+ export function AddAttachmentModal({ plansList, designsList, onClose, onAddPlan, onAddDesign, onAddNew, newAttachmentName, setNewAttachmentName, newAttachmentContent, setNewAttachmentContent, attachmentAddingId, }) {
38
+ return (_jsx("div", { className: "context-modal-overlay add-attachment-modal-overlay", role: "dialog", "aria-modal": "true", "aria-labelledby": "add-attachment-modal-title", onClick: (e) => e.target === e.currentTarget && onClose(), children: _jsxs("div", { className: "context-modal add-attachment-modal", children: [_jsxs("div", { className: "context-modal__header", children: [_jsx("h2", { id: "add-attachment-modal-title", children: "Add attachment" }), _jsx(ActionIcon, { type: "button", variant: "subtle", size: "sm", onClick: onClose, "aria-label": "Close", children: "\u00D7" })] }), _jsx("div", { className: "context-modal__body add-attachment-modal__body", children: _jsxs(Tabs, { defaultValue: "plans", className: "add-attachment-modal__tabs", children: [_jsxs(Tabs.List, { children: [_jsx(Tabs.Tab, { value: "plans", children: "Plans" }), _jsx(Tabs.Tab, { value: "designs", children: "Designs" }), _jsx(Tabs.Tab, { value: "new", children: "New attachment" })] }), _jsx(Tabs.Panel, { value: "plans", className: "add-attachment-modal__panel", children: _jsx("div", { className: "add-attachment-modal__list", children: plansList.length === 0 ? (_jsx(Text, { size: "sm", c: "dimmed", p: "md", children: "No plans yet." })) : (_jsx("ul", { className: "add-attachment-modal__ul", children: plansList.map((p) => {
39
+ const id = `plan:${p.name}`;
40
+ const loading = attachmentAddingId === id;
41
+ return (_jsx("li", { children: _jsxs("button", { type: "button", className: "add-attachment-modal__item", onClick: () => onAddPlan(p), disabled: !!attachmentAddingId, children: [_jsx(Text, { size: "sm", truncate: true, style: { flex: 1, minWidth: 0 }, children: p.label ?? p.name }), loading && (_jsx(Text, { size: "xs", c: "dimmed", children: "Adding\u2026" }))] }) }, p.name));
42
+ }) })) }) }), _jsx(Tabs.Panel, { value: "designs", className: "add-attachment-modal__panel", children: _jsx("div", { className: "add-attachment-modal__list", children: designsList.length === 0 ? (_jsx(Text, { size: "sm", c: "dimmed", p: "md", children: "No designs yet." })) : (_jsx("ul", { className: "add-attachment-modal__ul", children: designsList.map((d) => {
43
+ const id = `design:${d.name}`;
44
+ const loading = attachmentAddingId === id;
45
+ return (_jsx("li", { children: _jsxs("button", { type: "button", className: "add-attachment-modal__item", onClick: () => onAddDesign(d), disabled: !!attachmentAddingId, children: [_jsx(Text, { size: "sm", truncate: true, style: { flex: 1, minWidth: 0 }, children: d.label ?? d.name }), loading && (_jsx(Text, { size: "xs", c: "dimmed", children: "Adding\u2026" }))] }) }, d.name));
46
+ }) })) }) }), _jsx(Tabs.Panel, { value: "new", className: "add-attachment-modal__panel", children: _jsxs("div", { className: "add-attachment-modal__form", children: [_jsxs("div", { className: "add-attachment-modal__field", children: [_jsx("label", { htmlFor: "attachment-name", children: "Name" }), _jsx(TextInput, { id: "attachment-name", placeholder: "e.g. Example response", value: newAttachmentName, onChange: (e) => setNewAttachmentName(e.currentTarget.value), size: "sm" })] }), _jsxs("div", { className: "add-attachment-modal__field add-attachment-modal__content-wrap", children: [_jsx("label", { htmlFor: "attachment-content", children: "Content" }), _jsx(Textarea, { id: "attachment-content", value: newAttachmentContent, onChange: (e) => setNewAttachmentContent(e.currentTarget.value), placeholder: "Paste or type content to attach. Included with your messages.", minRows: 6, maxRows: 12, autosize: true, styles: { input: { fontFamily: 'inherit' } }, className: "add-attachment-modal__textarea" })] }), _jsxs("div", { className: "add-attachment-modal__actions", children: [_jsx(Button, { type: "button", variant: "subtle", onClick: onClose, children: "Cancel" }), _jsx(Button, { type: "button", disabled: !newAttachmentName.trim(), onClick: () => {
47
+ const name = newAttachmentName.trim();
48
+ if (!name)
49
+ return;
50
+ onAddNew(name, newAttachmentContent);
51
+ }, children: "Add" })] })] }) })] }) })] }) }));
52
+ }
53
+ /**
54
+ * Session-scoped composer attachments (badges + modal) for any surface that uses `sessionId`.
55
+ */
56
+ export function useComposerAttachmentsSessionState(sessionId) {
57
+ const [attachmentsBySession, setAttachmentsBySession] = useState({});
58
+ const [sentAttachmentSigsBySession, setSentAttachmentSigsBySession] = useState({});
59
+ const [addAttachmentModalOpen, setAddAttachmentModalOpen] = useState(false);
60
+ const [newAttachmentName, setNewAttachmentName] = useState('');
61
+ const [newAttachmentContent, setNewAttachmentContent] = useState('');
62
+ const [attachmentAddingId, setAttachmentAddingId] = useState(null);
63
+ const attachments = sessionId
64
+ ? (attachmentsBySession[sessionId] ?? [])
65
+ : [];
66
+ const sentAttachmentSigs = useMemo(() => {
67
+ if (!sessionId)
68
+ return new Set();
69
+ return new Set(sentAttachmentSigsBySession[sessionId] ?? []);
70
+ }, [sentAttachmentSigsBySession, sessionId]);
71
+ const unsentAttachments = useMemo(() => attachments.filter((a) => !sentAttachmentSigs.has(composerAttachmentSignature(a))), [attachments, sentAttachmentSigs]);
72
+ const setAttachments = useCallback((update) => {
73
+ if (!sessionId)
74
+ return;
75
+ setAttachmentsBySession((prev) => {
76
+ const current = prev[sessionId] ?? [];
77
+ const next = typeof update === 'function' ? update(current) : update;
78
+ return { ...prev, [sessionId]: next };
79
+ });
80
+ }, [sessionId]);
81
+ const transformContent = useCallback((text) => appendComposerAttachmentsToMessage(text, unsentAttachments), [unsentAttachments]);
82
+ const outgoingAttachments = useMemo(() => composerAttachmentsToMessageAttachments(unsentAttachments), [unsentAttachments]);
83
+ const markComposerAttachmentsSent = useCallback(() => {
84
+ if (!sessionId || unsentAttachments.length === 0)
85
+ return;
86
+ setSentAttachmentSigsBySession((prev) => {
87
+ const existing = new Set(prev[sessionId] ?? []);
88
+ for (const a of unsentAttachments) {
89
+ existing.add(composerAttachmentSignature(a));
90
+ }
91
+ return { ...prev, [sessionId]: [...existing] };
92
+ });
93
+ }, [sessionId, unsentAttachments]);
94
+ const unifiedComposerAttachmentProps = useMemo(() => ({
95
+ composerAttachments: attachments.map((a, i) => ({
96
+ key: `${a.type}-${a.name}-${i}`,
97
+ label: a.type === 'plan' ? `Plan: ${a.name}` : a.name,
98
+ index: i,
99
+ })),
100
+ onComposerAttachmentAdd: () => {
101
+ setNewAttachmentName('');
102
+ setNewAttachmentContent('');
103
+ setAddAttachmentModalOpen(true);
104
+ },
105
+ onComposerAttachmentRemove: (index) => setAttachments((prev) => prev.filter((_, idx) => idx !== index)),
106
+ composerAttachmentAddDisabled: !sessionId || attachmentAddingId != null,
107
+ }), [attachments, sessionId, attachmentAddingId, setAttachments]);
108
+ return {
109
+ attachmentsBySession,
110
+ setAttachmentsBySession,
111
+ attachments,
112
+ setAttachments,
113
+ addAttachmentModalOpen,
114
+ setAddAttachmentModalOpen,
115
+ newAttachmentName,
116
+ setNewAttachmentName,
117
+ newAttachmentContent,
118
+ setNewAttachmentContent,
119
+ attachmentAddingId,
120
+ setAttachmentAddingId,
121
+ transformContent,
122
+ outgoingAttachments,
123
+ markComposerAttachmentsSent,
124
+ unifiedComposerAttachmentProps,
125
+ };
126
+ }
@@ -0,0 +1,18 @@
1
+ import { type LlmdMessageAttachment } from '@pyxis-llm/core';
2
+ import { type AttachmentRenderProps } from './plugins.js';
3
+ /**
4
+ * A display card. Decoding (a JSON parse of up to a few MB, plus the type's
5
+ * validation) is memoized on the payload, so re-rendering the message does
6
+ * not repeat it.
7
+ */
8
+ export declare function DisplayCardAttachment({ attachment }: {
9
+ attachment: LlmdMessageAttachment;
10
+ }): import("react").JSX.Element;
11
+ /**
12
+ * Any non-ask attachment: a display card, or a host kind with a registered
13
+ * renderer. Returns the muted placeholder for anything else.
14
+ */
15
+ export declare function PluginAttachment(props: Omit<AttachmentRenderProps, 'attachmentId'> & {
16
+ attachmentId: string;
17
+ }): import("react").JSX.Element;
18
+ //# sourceMappingURL=DisplayCards.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DisplayCards.d.ts","sourceRoot":"","sources":["../src/DisplayCards.tsx"],"names":[],"mappings":"AAgBA,OAAO,EAAwC,KAAK,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AACnG,OAAO,EAAkB,KAAK,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAkC1E;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,EAAE,UAAU,EAAE,EAAE;IAAE,UAAU,EAAE,qBAAqB,CAAA;CAAE,+BAqD1F;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,IAAI,CAAC,qBAAqB,EAAE,cAAc,CAAC,GAAG;IAAE,YAAY,EAAE,MAAM,CAAA;CAAE,+BAa7G"}
@@ -0,0 +1,72 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ /*
3
+ * Copyright 2026 John Ewart <john@johnewart.net>
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ /**
7
+ * How ChatMessage renders every non-ask attachment: display cards
8
+ * (@pyxis-llm/core DISPLAY_CARD_KIND) through the renderer a plugin registered
9
+ * for their `type`, inside llmd's shared frame; host kinds through the
10
+ * plugin registered for their `kind`. Nothing here knows a type or kind by
11
+ * name. Anything without a renderer degrades to a muted placeholder that
12
+ * says what is missing — never to nothing.
13
+ */
14
+ import { Component, useMemo } from 'react';
15
+ import { Box, Text } from '@mantine/core';
16
+ import { DISPLAY_CARD_KIND, decodeDisplayCard } from '@pyxis-llm/core';
17
+ import { useLlmdPlugins } from './plugins.js';
18
+ function Unavailable({ id, label, detail }) {
19
+ return (_jsx("span", { title: detail ?? `Attachment ${id}`, "data-testid": `card-${id}-unavailable`, className: "llmd-card-unavailable", style: { opacity: 0.6, fontStyle: 'italic' }, children: label }));
20
+ }
21
+ /** One broken card must not take down the transcript. */
22
+ class CardErrorBoundary extends Component {
23
+ state = { failed: false };
24
+ static getDerivedStateFromError() {
25
+ return { failed: true };
26
+ }
27
+ componentDidCatch(error, info) {
28
+ // eslint-disable-next-line no-console
29
+ console.error(`llmd card: attachment ${this.props.id} failed to render`, error, info.componentStack);
30
+ }
31
+ render() {
32
+ if (this.state.failed)
33
+ return _jsx(Unavailable, { id: this.props.id, label: this.props.label });
34
+ return this.props.children;
35
+ }
36
+ }
37
+ /**
38
+ * A display card. Decoding (a JSON parse of up to a few MB, plus the type's
39
+ * validation) is memoized on the payload, so re-rendering the message does
40
+ * not repeat it.
41
+ */
42
+ export function DisplayCardAttachment({ attachment }) {
43
+ const { displayCards } = useLlmdPlugins();
44
+ const envelope = useMemo(() => decodeDisplayCard(attachment.payloadJson), [attachment.payloadJson]);
45
+ const renderer = envelope ? displayCards[envelope.type] : undefined;
46
+ const body = useMemo(() => (envelope && renderer ? (renderer.decode ? renderer.decode(envelope.body) : envelope.body) : undefined), [envelope, renderer]);
47
+ if (!envelope)
48
+ return _jsx(Unavailable, { id: attachment.id, label: "[card unavailable]" });
49
+ if (!renderer) {
50
+ return (_jsxs(Box, { className: "llmd-display-card llmd-display-card--no-renderer", "data-testid": `display-card-${envelope.id}`, children: [envelope.title?.trim() ? (_jsx(Text, { size: "sm", fw: 600, children: envelope.title })) : null, _jsxs(Text, { size: "xs", c: "dimmed", children: ["This ", envelope.type, " can't be shown here: no renderer for \"", envelope.type, "\" cards is installed."] })] }));
51
+ }
52
+ if (body === undefined)
53
+ return _jsx(Unavailable, { id: attachment.id, label: `[${envelope.type} unavailable]` });
54
+ const card = { ...envelope, body };
55
+ const Render = renderer.render;
56
+ return (_jsx(CardErrorBoundary, { id: attachment.id, label: `[this ${envelope.type} failed to render]`, children: _jsx("div", { className: `llmd-display-card llmd-display-card--${envelope.type}`, "data-testid": `display-card-${envelope.id}`, "data-card-type": envelope.type, children: renderer.ownsChrome ? (_jsx(Render, { card: card })) : (_jsxs(Box, { style: { display: 'flex', flexDirection: 'column', gap: 6, minWidth: 0 }, children: [envelope.title?.trim() ? (_jsx(Text, { size: "sm", fw: 600, className: "llmd-display-card__title", children: envelope.title })) : null, _jsx(Render, { card: card }), envelope.caption?.trim() ? (_jsx(Text, { size: "xs", c: "dimmed", className: "llmd-display-card__caption", children: envelope.caption })) : null] })) }) }));
57
+ }
58
+ /**
59
+ * Any non-ask attachment: a display card, or a host kind with a registered
60
+ * renderer. Returns the muted placeholder for anything else.
61
+ */
62
+ export function PluginAttachment(props) {
63
+ const { attachments } = useLlmdPlugins();
64
+ const { attachment } = props;
65
+ if (attachment.kind === DISPLAY_CARD_KIND)
66
+ return _jsx(DisplayCardAttachment, { attachment: attachment });
67
+ const Render = attachments[attachment.kind]?.render;
68
+ if (!Render) {
69
+ return _jsx(Unavailable, { id: attachment.id, label: "[card unavailable]", detail: `No renderer for ${attachment.kind}` });
70
+ }
71
+ return (_jsx(CardErrorBoundary, { id: attachment.id, label: "[this card failed to render]", children: _jsx(Render, { ...props }) }));
72
+ }
@@ -0,0 +1,27 @@
1
+ import { Component, type ErrorInfo, type ReactNode } from 'react';
2
+ interface ErrorBoundaryProps {
3
+ children: ReactNode;
4
+ /** Optional fallback when no custom fallback is rendered (error is still shown above it). */
5
+ fallback?: ReactNode;
6
+ /** Called once per caught error (e.g. to forward to a host's telemetry/reporting). */
7
+ onError?: (error: Error, errorInfo: ErrorInfo) => void;
8
+ }
9
+ interface ErrorBoundaryState {
10
+ hasError: boolean;
11
+ error: Error | null;
12
+ errorInfo: ErrorInfo | null;
13
+ }
14
+ /**
15
+ * Catches React rendering errors in the subtree and shows a safe fallback UI
16
+ * instead of a blank screen. Does not catch errors in event handlers or async code.
17
+ */
18
+ export declare class ErrorBoundary extends Component<ErrorBoundaryProps, ErrorBoundaryState> {
19
+ constructor(props: ErrorBoundaryProps);
20
+ static getDerivedStateFromError(error: Error): Partial<ErrorBoundaryState>;
21
+ componentDidCatch(error: Error, errorInfo: ErrorInfo): void;
22
+ handleReload: () => void;
23
+ handleCopyError: () => void;
24
+ render(): ReactNode;
25
+ }
26
+ export {};
27
+ //# sourceMappingURL=ErrorBoundary.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ErrorBoundary.d.ts","sourceRoot":"","sources":["../src/ErrorBoundary.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAE,SAAS,EAAE,KAAK,SAAS,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAIlE,UAAU,kBAAkB;IAC1B,QAAQ,EAAE,SAAS,CAAC;IACpB,6FAA6F;IAC7F,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,sFAAsF;IACtF,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,SAAS,KAAK,IAAI,CAAC;CACxD;AAED,UAAU,kBAAkB;IAC1B,QAAQ,EAAE,OAAO,CAAC;IAClB,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IACpB,SAAS,EAAE,SAAS,GAAG,IAAI,CAAC;CAC7B;AAED;;;GAGG;AACH,qBAAa,aAAc,SAAQ,SAAS,CAC1C,kBAAkB,EAClB,kBAAkB,CACnB;gBACa,KAAK,EAAE,kBAAkB;IASrC,MAAM,CAAC,wBAAwB,CAAC,KAAK,EAAE,KAAK,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAI1E,iBAAiB,CAAC,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,SAAS,GAAG,IAAI;IAM3D,YAAY,QAAO,IAAI,CAGrB;IAEF,eAAe,QAAO,IAAI,CAaxB;IAEF,MAAM,IAAI,SAAS;CAsHpB"}
@@ -0,0 +1,107 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ /*
3
+ * Copyright 2026 John Ewart <john@johnewart.net>
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import { Component } from 'react';
7
+ import { Box, Button, Code, Paper, Stack, Text, Group } from '@mantine/core';
8
+ import { IconRefresh, IconCopy } from '@tabler/icons-react';
9
+ /**
10
+ * Catches React rendering errors in the subtree and shows a safe fallback UI
11
+ * instead of a blank screen. Does not catch errors in event handlers or async code.
12
+ */
13
+ export class ErrorBoundary extends Component {
14
+ constructor(props) {
15
+ super(props);
16
+ this.state = {
17
+ hasError: false,
18
+ error: null,
19
+ errorInfo: null,
20
+ };
21
+ }
22
+ static getDerivedStateFromError(error) {
23
+ return { hasError: true, error };
24
+ }
25
+ componentDidCatch(error, errorInfo) {
26
+ this.setState((s) => ({ ...s, errorInfo }));
27
+ console.error('[ErrorBoundary] Caught rendering error:', error, errorInfo);
28
+ this.props.onError?.(error, errorInfo);
29
+ }
30
+ handleReload = () => {
31
+ this.setState({ hasError: false, error: null, errorInfo: null });
32
+ window.location.reload();
33
+ };
34
+ handleCopyError = () => {
35
+ const { error, errorInfo } = this.state;
36
+ if (!error)
37
+ return;
38
+ const parts = [
39
+ error.name && error.name !== 'Error'
40
+ ? `${error.name}: ${error.message}`
41
+ : error.message,
42
+ error.stack ?? '',
43
+ errorInfo?.componentStack
44
+ ? `\nComponent stack:\n${errorInfo.componentStack}`
45
+ : '',
46
+ ].filter(Boolean);
47
+ void navigator.clipboard.writeText(parts.join('\n'));
48
+ };
49
+ render() {
50
+ if (this.state.hasError && this.state.error) {
51
+ const { error } = this.state;
52
+ const message = error?.message ?? 'Unknown error';
53
+ const stack = this.state.errorInfo?.componentStack ?? error?.stack ?? null;
54
+ const errorBlock = (_jsx(Paper, { p: "md", radius: 0, withBorder: true, style: {
55
+ borderLeft: 0,
56
+ borderRight: 0,
57
+ borderTop: 0,
58
+ backgroundColor: 'var(--mantine-color-red-0)',
59
+ flexShrink: 0,
60
+ maxHeight: '40vh',
61
+ minHeight: 80,
62
+ display: 'flex',
63
+ flexDirection: 'column',
64
+ overflow: 'hidden',
65
+ }, children: _jsxs(Stack, { gap: "xs", style: { flex: 1, minHeight: 0 }, children: [_jsxs(Group, { justify: "space-between", wrap: "nowrap", children: [_jsx(Text, { size: "sm", fw: 600, c: "red", children: "Error (copy to report)" }), _jsx(Button, { size: "xs", variant: "light", leftSection: _jsx(IconCopy, { size: 14 }), onClick: this.handleCopyError, children: "Copy error" })] }), _jsx(Code, { block: true, style: {
66
+ whiteSpace: 'pre-wrap',
67
+ wordBreak: 'break-word',
68
+ fontSize: 12,
69
+ flex: 1,
70
+ minHeight: 0,
71
+ overflow: 'auto',
72
+ }, children: [message, stack, this.state.errorInfo?.componentStack]
73
+ .filter(Boolean)
74
+ .join('\n\n') })] }) }));
75
+ if (this.props.fallback) {
76
+ return (_jsxs(Box, { style: {
77
+ height: '100vh',
78
+ display: 'flex',
79
+ flexDirection: 'column',
80
+ background: 'var(--mantine-color-default)',
81
+ overflow: 'hidden',
82
+ }, children: [errorBlock, _jsx(Box, { style: { flex: 1, minHeight: 0, overflow: 'hidden' }, children: this.props.fallback })] }));
83
+ }
84
+ return (_jsx(Box, { p: "xl", style: {
85
+ minHeight: '100vh',
86
+ display: 'flex',
87
+ alignItems: 'center',
88
+ justifyContent: 'center',
89
+ background: 'var(--mantine-color-default)',
90
+ }, children: _jsx(Paper, { p: "xl", shadow: "md", radius: "md", withBorder: true, maw: 560, children: _jsxs(Stack, { gap: "md", children: [_jsx(Text, { size: "lg", fw: 600, c: "red", children: "Something went wrong" }), _jsx(Text, { size: "sm", c: "dimmed", children: "A rendering error was caught. You can reload the page to try again." }), _jsx(Code, { block: true, style: { whiteSpace: 'pre-wrap', wordBreak: 'break-word' }, children: message }), stack && _jsx(Details, { label: "Component stack", content: stack }), _jsx(Button, { leftSection: _jsx(IconRefresh, { size: 16 }), onClick: this.handleReload, variant: "light", children: "Reload page" })] }) }) }));
91
+ }
92
+ return this.props.children;
93
+ }
94
+ }
95
+ function Details({ label, content }) {
96
+ return (_jsxs("details", { children: [_jsx("summary", { style: {
97
+ cursor: 'pointer',
98
+ fontSize: 'var(--mantine-font-size-sm)',
99
+ color: 'var(--mantine-color-dimmed)',
100
+ }, children: label }), _jsx(Code, { block: true, mt: "xs", style: {
101
+ whiteSpace: 'pre-wrap',
102
+ wordBreak: 'break-word',
103
+ fontSize: 11,
104
+ maxHeight: 200,
105
+ overflow: 'auto',
106
+ }, children: content })] }));
107
+ }
@@ -0,0 +1,6 @@
1
+ import { type ImageBody } from '@pyxis-llm/core';
2
+ import type { DisplayCardRenderProps, LlmdPlugin } from './plugins.js';
3
+ export declare function ImageCardView({ card }: DisplayCardRenderProps<ImageBody>): import("react").JSX.Element;
4
+ /** Built in: every chat gets image cards without registering anything. */
5
+ export declare const imageCardPlugin: LlmdPlugin;
6
+ //# sourceMappingURL=ImageDisplayCard.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ImageDisplayCard.d.ts","sourceRoot":"","sources":["../src/ImageDisplayCard.tsx"],"names":[],"mappings":"AAkBA,OAAO,EAAoC,KAAK,SAAS,EAAkB,MAAM,iBAAiB,CAAC;AACnG,OAAO,KAAK,EAAE,sBAAsB,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAoBvE,wBAAgB,aAAa,CAAC,EAAE,IAAI,EAAE,EAAE,sBAAsB,CAAC,SAAS,CAAC,+BAkExE;AAED,0EAA0E;AAC1E,eAAO,MAAM,eAAe,EAAE,UAK7B,CAAC"}
@@ -0,0 +1,57 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ /*
3
+ * Copyright 2026 John Ewart <john@johnewart.net>
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ /**
7
+ * The built-in `image` display card (@pyxis-llm/core IMAGE_CARD_TYPE): an inline
8
+ * image (capped height, click to enlarge) with a download button. Always an
9
+ * `<img>`: SVG scripts do not run there, and `src` is a data: URL (enforced by
10
+ * decodeImageBody), so showing it fetches nothing.
11
+ *
12
+ * Imports only types from plugins.tsx, which imports this module: keep it
13
+ * that way, or the two form a runtime import cycle.
14
+ */
15
+ import { useState } from 'react';
16
+ import { ActionIcon, Box, Group, Modal, Text, Tooltip, UnstyledButton } from '@mantine/core';
17
+ import { IconDownload } from '@tabler/icons-react';
18
+ import { IMAGE_CARD_TYPE, decodeImageBody } from '@pyxis-llm/core';
19
+ const IMAGE_EXTENSIONS = {
20
+ 'image/png': 'png',
21
+ 'image/jpeg': 'jpg',
22
+ 'image/gif': 'gif',
23
+ 'image/webp': 'webp',
24
+ 'image/svg+xml': 'svg',
25
+ };
26
+ function downloadNameFor(card) {
27
+ if (card.body.fileName?.trim())
28
+ return card.body.fileName.trim();
29
+ const base = (card.title ?? '')
30
+ .trim()
31
+ .toLowerCase()
32
+ .replace(/[^a-z0-9]+/g, '-')
33
+ .replace(/^-+|-+$/g, '');
34
+ return `${base || 'image'}.${IMAGE_EXTENSIONS[card.body.mimeType]}`;
35
+ }
36
+ export function ImageCardView({ card }) {
37
+ const [enlarged, setEnlarged] = useState(false);
38
+ const { body } = card;
39
+ const label = card.title?.trim() || body.fileName?.trim() || 'Image';
40
+ const alt = body.alt?.trim() || card.title?.trim() || card.caption?.trim() || 'Image';
41
+ const downloadName = downloadNameFor(card);
42
+ return (_jsxs(Box, { className: "llmd-image-card", "data-testid": `image-card-${card.id}`, style: { display: 'flex', flexDirection: 'column', gap: 6, minWidth: 0 }, children: [_jsxs(Group, { justify: "space-between", gap: "xs", wrap: "nowrap", children: [_jsx(Text, { size: "sm", fw: 600, className: "llmd-image-card__label", truncate: true, children: label }), _jsx(Tooltip, { label: `Download ${downloadName}`, withArrow: true, children: _jsx(ActionIcon, { component: "a", href: body.src, download: downloadName, variant: "subtle", color: "gray", size: "sm", "aria-label": `Download ${downloadName}`, children: _jsx(IconDownload, { size: 14, stroke: 1.6 }) }) })] }), _jsx(UnstyledButton, { onClick: () => setEnlarged(true), "aria-label": `Enlarge: ${alt}`, style: { alignSelf: 'flex-start', maxWidth: '100%', cursor: 'zoom-in' }, children: _jsx("img", { src: body.src, alt: alt, width: body.width, height: body.height, loading: "lazy", className: "llmd-image-card__img", style: {
43
+ display: 'block',
44
+ maxWidth: '100%',
45
+ maxHeight: 480,
46
+ height: 'auto',
47
+ objectFit: 'contain',
48
+ borderRadius: 6,
49
+ } }) }), card.caption?.trim() ? (_jsx(Text, { size: "xs", c: "dimmed", className: "llmd-image-card__caption", children: card.caption })) : null, _jsx(Modal, { opened: enlarged, onClose: () => setEnlarged(false), title: label, size: "auto", centered: true, children: _jsx("img", { src: body.src, alt: alt, style: { display: 'block', maxWidth: '90vw', maxHeight: '80vh', objectFit: 'contain' } }) })] }));
50
+ }
51
+ /** Built in: every chat gets image cards without registering anything. */
52
+ export const imageCardPlugin = {
53
+ id: 'llmd.image',
54
+ displayCards: {
55
+ [IMAGE_CARD_TYPE]: { decode: decodeImageBody, render: ImageCardView, ownsChrome: true },
56
+ },
57
+ };
@@ -0,0 +1,23 @@
1
+ import React from 'react';
2
+ import type { Components } from 'react-markdown';
3
+ /** What a host's link renderer receives: the link as markdown produced it. */
4
+ export type MarkdownLinkRendererProps = React.ComponentPropsWithoutRef<'a'>;
5
+ /**
6
+ * Lets a host render markdown links its own way (e.g. as chips with an icon
7
+ * for the thing linked to) everywhere this package renders markdown - chat
8
+ * messages, streaming text, transcripts - without threading a prop through
9
+ * each of them. Unset (the default) renders a plain anchor. Inert schemes
10
+ * (see below) never reach the renderer.
11
+ */
12
+ export declare const MarkdownLinkRendererContext: React.Context<React.ComponentType<Omit<React.DetailedHTMLProps<React.AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement>, "ref">> | null>;
13
+ /**
14
+ * Components to pass to ReactMarkdown so fenced code blocks (e.g. ```js, ```python)
15
+ * are rendered with syntax highlighting. Inline code is left as plain <code>.
16
+ */
17
+ export declare const markdownCodeComponents: Components;
18
+ /**
19
+ * Same as {@link markdownCodeComponents} but code fences wrap instead of scrolling horizontally,
20
+ * for a narrow live-streaming markdown surface.
21
+ */
22
+ export declare const markdownThinkingStreamCodeComponents: Components;
23
+ //# sourceMappingURL=MarkdownCodeComponents.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MarkdownCodeComponents.d.ts","sourceRoot":"","sources":["../src/MarkdownCodeComponents.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAuD,MAAM,OAAO,CAAC;AAC5E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAsTjD,8EAA8E;AAC9E,MAAM,MAAM,yBAAyB,GAAG,KAAK,CAAC,wBAAwB,CAAC,GAAG,CAAC,CAAC;AAE5E;;;;;;GAMG;AACH,eAAO,MAAM,2BAA2B,mJAEjC,CAAC;AAqBR;;;GAGG;AACH,eAAO,MAAM,sBAAsB,EAAE,UAIpC,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,oCAAoC,EAAE,UAIlD,CAAC"}