@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.
- package/dist/AgentProfileEditor.d.ts +48 -0
- package/dist/AgentProfileEditor.d.ts.map +1 -0
- package/dist/AgentProfileEditor.js +122 -0
- package/dist/AgentProfileList.d.ts +17 -0
- package/dist/AgentProfileList.d.ts.map +1 -0
- package/dist/AgentProfileList.js +46 -0
- package/dist/AskCardAnswerChip.d.ts +8 -0
- package/dist/AskCardAnswerChip.d.ts.map +1 -0
- package/dist/AskCardAnswerChip.js +21 -0
- package/dist/AskCardView.d.ts +85 -0
- package/dist/AskCardView.d.ts.map +1 -0
- package/dist/AskCardView.js +158 -0
- package/dist/CatalogColumnBrowser.d.ts +33 -0
- package/dist/CatalogColumnBrowser.d.ts.map +1 -0
- package/dist/CatalogColumnBrowser.js +219 -0
- package/dist/CatalogModelPicker.d.ts +68 -0
- package/dist/CatalogModelPicker.d.ts.map +1 -0
- package/dist/CatalogModelPicker.js +119 -0
- package/dist/CatalogModelPickerMenuContent.d.ts +17 -0
- package/dist/CatalogModelPickerMenuContent.d.ts.map +1 -0
- package/dist/CatalogModelPickerMenuContent.js +103 -0
- package/dist/CatalogPickerMenuItem.d.ts +17 -0
- package/dist/CatalogPickerMenuItem.d.ts.map +1 -0
- package/dist/CatalogPickerMenuItem.js +15 -0
- package/dist/CatalogTreePickerOptions.d.ts +52 -0
- package/dist/CatalogTreePickerOptions.d.ts.map +1 -0
- package/dist/CatalogTreePickerOptions.js +248 -0
- package/dist/ChatMessage.d.ts +172 -0
- package/dist/ChatMessage.d.ts.map +1 -0
- package/dist/ChatMessage.js +295 -0
- package/dist/ChatPanel.d.ts +252 -0
- package/dist/ChatPanel.d.ts.map +1 -0
- package/dist/ChatPanel.js +247 -0
- package/dist/ChatTranscriptFind.d.ts +19 -0
- package/dist/ChatTranscriptFind.d.ts.map +1 -0
- package/dist/ChatTranscriptFind.js +224 -0
- package/dist/ChatTranscriptFindBar.d.ts +15 -0
- package/dist/ChatTranscriptFindBar.d.ts.map +1 -0
- package/dist/ChatTranscriptFindBar.js +22 -0
- package/dist/Composer.d.ts +43 -0
- package/dist/Composer.d.ts.map +1 -0
- package/dist/Composer.js +45 -0
- package/dist/ComposerAttachments.d.ts +101 -0
- package/dist/ComposerAttachments.d.ts.map +1 -0
- package/dist/ComposerAttachments.js +126 -0
- package/dist/DisplayCards.d.ts +18 -0
- package/dist/DisplayCards.d.ts.map +1 -0
- package/dist/DisplayCards.js +72 -0
- package/dist/ErrorBoundary.d.ts +27 -0
- package/dist/ErrorBoundary.d.ts.map +1 -0
- package/dist/ErrorBoundary.js +107 -0
- package/dist/ImageDisplayCard.d.ts +6 -0
- package/dist/ImageDisplayCard.d.ts.map +1 -0
- package/dist/ImageDisplayCard.js +57 -0
- package/dist/MarkdownCodeComponents.d.ts +23 -0
- package/dist/MarkdownCodeComponents.d.ts.map +1 -0
- package/dist/MarkdownCodeComponents.js +256 -0
- package/dist/MermaidDiagram.d.ts +18 -0
- package/dist/MermaidDiagram.d.ts.map +1 -0
- package/dist/MermaidDiagram.js +66 -0
- package/dist/MessageContentWithPastes.d.ts +14 -0
- package/dist/MessageContentWithPastes.d.ts.map +1 -0
- package/dist/MessageContentWithPastes.js +44 -0
- package/dist/PastePill.d.ts +16 -0
- package/dist/PastePill.d.ts.map +1 -0
- package/dist/PastePill.js +43 -0
- package/dist/ProviderAuthTerminal.d.ts +12 -0
- package/dist/ProviderAuthTerminal.d.ts.map +1 -0
- package/dist/ProviderAuthTerminal.js +50 -0
- package/dist/ProviderConnectForm.d.ts +62 -0
- package/dist/ProviderConnectForm.d.ts.map +1 -0
- package/dist/ProviderConnectForm.js +206 -0
- package/dist/ProviderList.d.ts +18 -0
- package/dist/ProviderList.d.ts.map +1 -0
- package/dist/ProviderList.js +67 -0
- package/dist/QueueStrip.d.ts +17 -0
- package/dist/QueueStrip.d.ts.map +1 -0
- package/dist/QueueStrip.js +60 -0
- package/dist/SettingsScreen.d.ts +10 -0
- package/dist/SettingsScreen.d.ts.map +1 -0
- package/dist/SettingsScreen.js +26 -0
- package/dist/StreamingMarkdown.d.ts +47 -0
- package/dist/StreamingMarkdown.d.ts.map +1 -0
- package/dist/StreamingMarkdown.js +103 -0
- package/dist/TurnTimer.d.ts +72 -0
- package/dist/TurnTimer.d.ts.map +1 -0
- package/dist/TurnTimer.js +114 -0
- package/dist/VegaChart.d.ts +36 -0
- package/dist/VegaChart.d.ts.map +1 -0
- package/dist/VegaChart.js +180 -0
- package/dist/browser.d.ts +7 -0
- package/dist/browser.d.ts.map +1 -0
- package/dist/browser.js +18 -0
- package/dist/catalogColumnBrowserTree.d.ts +9 -0
- package/dist/catalogColumnBrowserTree.d.ts.map +1 -0
- package/dist/catalogColumnBrowserTree.js +48 -0
- package/dist/catalogPickerMenuStyles.d.ts +81 -0
- package/dist/catalogPickerMenuStyles.d.ts.map +1 -0
- package/dist/catalogPickerMenuStyles.js +130 -0
- package/dist/charts.d.ts +12 -0
- package/dist/charts.d.ts.map +1 -0
- package/dist/charts.js +45 -0
- package/dist/chatMessageScroll.d.ts +40 -0
- package/dist/chatMessageScroll.d.ts.map +1 -0
- package/dist/chatMessageScroll.js +62 -0
- package/dist/chatModelOptions.d.ts +28 -0
- package/dist/chatModelOptions.d.ts.map +1 -0
- package/dist/chatModelOptions.js +59 -0
- package/dist/chatTranscriptFindHighlights.d.ts +9 -0
- package/dist/chatTranscriptFindHighlights.d.ts.map +1 -0
- package/dist/chatTranscriptFindHighlights.js +88 -0
- package/dist/draftStore.d.ts +13 -0
- package/dist/draftStore.d.ts.map +1 -0
- package/dist/draftStore.js +38 -0
- package/dist/highlight.d.ts +4 -0
- package/dist/highlight.d.ts.map +1 -0
- package/dist/highlight.js +47 -0
- package/dist/index.d.ts +74 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +48 -0
- package/dist/keyboardShortcuts.d.ts +5 -0
- package/dist/keyboardShortcuts.d.ts.map +1 -0
- package/dist/keyboardShortcuts.js +19 -0
- package/dist/markdownClipboard.d.ts +22 -0
- package/dist/markdownClipboard.d.ts.map +1 -0
- package/dist/markdownClipboard.js +98 -0
- package/dist/markdownPlugins.d.ts +31 -0
- package/dist/markdownPlugins.d.ts.map +1 -0
- package/dist/markdownPlugins.js +32 -0
- package/dist/mermaid.d.ts +17 -0
- package/dist/mermaid.d.ts.map +1 -0
- package/dist/mermaid.js +11 -0
- package/dist/mermaidRuntime.d.ts +21 -0
- package/dist/mermaidRuntime.d.ts.map +1 -0
- package/dist/mermaidRuntime.js +140 -0
- package/dist/modelCatalogHelpers.d.ts +14 -0
- package/dist/modelCatalogHelpers.d.ts.map +1 -0
- package/dist/modelCatalogHelpers.js +65 -0
- package/dist/modelCatalogSource.d.ts +22 -0
- package/dist/modelCatalogSource.d.ts.map +1 -0
- package/dist/modelCatalogSource.js +26 -0
- package/dist/modelCatalogTree.d.ts +24 -0
- package/dist/modelCatalogTree.d.ts.map +1 -0
- package/dist/modelCatalogTree.js +77 -0
- package/dist/node.d.ts +9 -0
- package/dist/node.d.ts.map +1 -0
- package/dist/node.js +13 -0
- package/dist/pasteFences.d.ts +20 -0
- package/dist/pasteFences.d.ts.map +1 -0
- package/dist/pasteFences.js +157 -0
- package/dist/pasteFormat.d.ts +5 -0
- package/dist/pasteFormat.d.ts.map +1 -0
- package/dist/pasteFormat.js +18 -0
- package/dist/plugins.d.ts +110 -0
- package/dist/plugins.d.ts.map +1 -0
- package/dist/plugins.js +98 -0
- package/dist/remarkAlerts.d.ts +12 -0
- package/dist/remarkAlerts.d.ts.map +1 -0
- package/dist/remarkAlerts.js +52 -0
- package/dist/sendMode.d.ts +69 -0
- package/dist/sendMode.d.ts.map +1 -0
- package/dist/sendMode.js +66 -0
- package/dist/useLlmdChatDriver.d.ts +367 -0
- package/dist/useLlmdChatDriver.d.ts.map +1 -0
- package/dist/useLlmdChatDriver.js +1739 -0
- package/dist/useLlmdModelCatalog.d.ts +23 -0
- package/dist/useLlmdModelCatalog.d.ts.map +1 -0
- package/dist/useLlmdModelCatalog.js +89 -0
- package/dist/useLlmdSessionModel.d.ts +34 -0
- package/dist/useLlmdSessionModel.d.ts.map +1 -0
- package/dist/useLlmdSessionModel.js +79 -0
- package/dist/useProviderAuthCommand.d.ts +26 -0
- package/dist/useProviderAuthCommand.d.ts.map +1 -0
- package/dist/useProviderAuthCommand.js +80 -0
- package/dist/vegaRuntime.d.ts +83 -0
- package/dist/vegaRuntime.d.ts.map +1 -0
- package/dist/vegaRuntime.js +314 -0
- package/dist/vendor/llmd-types/conversationEvents.d.ts +238 -0
- package/dist/vendor/llmd-types/conversationEvents.d.ts.map +1 -0
- package/dist/vendor/llmd-types/conversationEvents.js +98 -0
- package/dist/vendor/llmd-types/index.d.ts +4 -0
- package/dist/vendor/llmd-types/index.d.ts.map +1 -0
- package/dist/vendor/llmd-types/index.js +5 -0
- package/dist/vendor/llmd-types/messages.d.ts +67 -0
- package/dist/vendor/llmd-types/messages.d.ts.map +1 -0
- package/dist/vendor/llmd-types/messages.js +71 -0
- package/dist/vendor/llmd-types/sessionQueue.d.ts +54 -0
- package/dist/vendor/llmd-types/sessionQueue.d.ts.map +1 -0
- package/dist/vendor/llmd-types/sessionQueue.js +40 -0
- package/package.json +120 -4
- package/styles.css +389 -0
- package/README.md +0 -3
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, 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 React, { startTransition, useEffect, useRef, useState } from 'react';
|
|
7
|
+
import { useLlmdPlugins } from './plugins.js';
|
|
8
|
+
const SYNTAX_BLOCK_ATTR = 'data-syntax-highlight-block';
|
|
9
|
+
/** Plain text of a React node tree: the fence's source as markdown gave it. */
|
|
10
|
+
function nodeText(node) {
|
|
11
|
+
if (node == null || typeof node === 'boolean')
|
|
12
|
+
return '';
|
|
13
|
+
if (typeof node === 'string' || typeof node === 'number')
|
|
14
|
+
return String(node);
|
|
15
|
+
if (Array.isArray(node))
|
|
16
|
+
return node.map(nodeText).join('');
|
|
17
|
+
if (React.isValidElement(node)) {
|
|
18
|
+
return nodeText(node.props.children);
|
|
19
|
+
}
|
|
20
|
+
return '';
|
|
21
|
+
}
|
|
22
|
+
const COPY_RESET_MS = 1500;
|
|
23
|
+
/** Failures stay up longer so they are actually read. */
|
|
24
|
+
const COPY_FAILED_RESET_MS = 5000;
|
|
25
|
+
/**
|
|
26
|
+
* Puts text on the clipboard; false when the page may not.
|
|
27
|
+
*
|
|
28
|
+
* The async Clipboard API is refused in an iframe that was not granted
|
|
29
|
+
* clipboard-write (host apps often render chat in one) and is absent outside a
|
|
30
|
+
* secure context. The legacy path - select a hidden textarea and
|
|
31
|
+
* execCommand('copy') - has no such restriction, but only while the click's
|
|
32
|
+
* user activation is live, so it runs first and synchronously.
|
|
33
|
+
*/
|
|
34
|
+
async function copyText(text) {
|
|
35
|
+
const ta = document.createElement('textarea');
|
|
36
|
+
ta.value = text;
|
|
37
|
+
ta.setAttribute('readonly', '');
|
|
38
|
+
ta.style.position = 'fixed';
|
|
39
|
+
ta.style.top = '0';
|
|
40
|
+
ta.style.left = '0';
|
|
41
|
+
ta.style.opacity = '0';
|
|
42
|
+
document.body.appendChild(ta);
|
|
43
|
+
ta.select();
|
|
44
|
+
let ok = false;
|
|
45
|
+
try {
|
|
46
|
+
ok = document.execCommand('copy');
|
|
47
|
+
}
|
|
48
|
+
catch {
|
|
49
|
+
ok = false;
|
|
50
|
+
}
|
|
51
|
+
document.body.removeChild(ta);
|
|
52
|
+
if (ok)
|
|
53
|
+
return true;
|
|
54
|
+
try {
|
|
55
|
+
if (navigator.clipboard?.writeText) {
|
|
56
|
+
await navigator.clipboard.writeText(text);
|
|
57
|
+
return true;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
catch {
|
|
61
|
+
// Refused as well.
|
|
62
|
+
}
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
/** 16px stroke icons (tabler shapes), inline: this package has no icon dependency. */
|
|
66
|
+
function CopyIcon({ state }) {
|
|
67
|
+
const paths = state === 'copied' ? (_jsx("path", { d: "M5 12l5 5l10 -10" })) : state === 'failed' ? (_jsxs(_Fragment, { children: [_jsx("path", { d: "M12 9v4" }), _jsx("path", { d: "M10.363 3.591l-8.106 13.534a1.914 1.914 0 0 0 1.636 2.871h16.214a1.914 1.914 0 0 0 1.636 -2.87l-8.106 -13.536a1.914 1.914 0 0 0 -3.274 0z" }), _jsx("path", { d: "M12 16h.01" })] })) : (_jsxs(_Fragment, { children: [_jsx("path", { d: "M7 7m0 2.667a2.667 2.667 0 0 1 2.667 -2.667h8.666a2.667 2.667 0 0 1 2.667 2.667v8.666a2.667 2.667 0 0 1 -2.667 2.667h-8.666a2.667 2.667 0 0 1 -2.667 -2.667z" }), _jsx("path", { d: "M4.012 16.737a2.005 2.005 0 0 1 -1.012 -1.737v-10c0 -1.1 .9 -2 2 -2h10c.75 0 1.158 .385 1.5 1" })] }));
|
|
68
|
+
return (_jsx("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", style: { display: 'block' }, children: paths }));
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Copies the fence's raw source (not the rendered DOM, which carries
|
|
72
|
+
* highlighter markup, escapes and soft wraps).
|
|
73
|
+
*/
|
|
74
|
+
function CopyCodeButton({ text, visible }) {
|
|
75
|
+
const [state, setState] = useState('idle');
|
|
76
|
+
useEffect(() => {
|
|
77
|
+
if (state === 'idle')
|
|
78
|
+
return;
|
|
79
|
+
const id = window.setTimeout(() => setState('idle'), state === 'failed' ? COPY_FAILED_RESET_MS : COPY_RESET_MS);
|
|
80
|
+
return () => clearTimeout(id);
|
|
81
|
+
}, [state]);
|
|
82
|
+
const onClick = async (e) => {
|
|
83
|
+
e.preventDefault();
|
|
84
|
+
e.stopPropagation();
|
|
85
|
+
setState((await copyText(text)) ? 'copied' : 'failed');
|
|
86
|
+
};
|
|
87
|
+
const failed = state === 'failed';
|
|
88
|
+
const label = state === 'copied'
|
|
89
|
+
? 'Copied'
|
|
90
|
+
: failed
|
|
91
|
+
? 'Copy failed: the browser refused clipboard access'
|
|
92
|
+
: 'Copy code to clipboard';
|
|
93
|
+
return (_jsx("button", { type: "button", onClick: onClick, "aria-label": label, title: label, role: failed ? 'alert' : undefined, style: {
|
|
94
|
+
position: 'absolute',
|
|
95
|
+
// Inner blocks carry a 1em/1.25em margin; sit inside their corner.
|
|
96
|
+
top: 'calc(1em + 4px)',
|
|
97
|
+
right: 'calc(1.25em + 4px)',
|
|
98
|
+
zIndex: 1,
|
|
99
|
+
display: 'flex',
|
|
100
|
+
alignItems: 'center',
|
|
101
|
+
justifyContent: 'center',
|
|
102
|
+
padding: 4,
|
|
103
|
+
lineHeight: 0,
|
|
104
|
+
// Icon only, on a transparent ground. The code-text color is the
|
|
105
|
+
// theme's readable foreground: dark in light themes, light in dark.
|
|
106
|
+
color: failed ? '#e03131' : 'var(--app-code-text, currentColor)',
|
|
107
|
+
background: 'transparent',
|
|
108
|
+
border: 'none',
|
|
109
|
+
borderRadius: '4px',
|
|
110
|
+
cursor: 'pointer',
|
|
111
|
+
opacity: failed ? 1 : visible || state !== 'idle' ? 0.75 : 0,
|
|
112
|
+
transition: 'opacity 120ms ease-in-out',
|
|
113
|
+
}, children: _jsx(CopyIcon, { state: state }) }));
|
|
114
|
+
}
|
|
115
|
+
function Pre({ children, ...props }) {
|
|
116
|
+
const [hovered, setHovered] = useState(false);
|
|
117
|
+
const child = React.Children.only(children);
|
|
118
|
+
const childProps = child?.props;
|
|
119
|
+
const text = nodeText(childProps?.children).replace(/\n$/, '');
|
|
120
|
+
const body = childProps?.[SYNTAX_BLOCK_ATTR] ? _jsx(_Fragment, { children: children }) : _jsx("pre", { ...props, children: children });
|
|
121
|
+
return (_jsxs("div", { style: { position: 'relative' }, onMouseEnter: () => setHovered(true), onMouseLeave: () => setHovered(false), onFocus: () => setHovered(true), onBlur: () => setHovered(false), children: [body, _jsx(CopyCodeButton, { text: text, visible: hovered })] }));
|
|
122
|
+
}
|
|
123
|
+
const PLAIN_FENCE_BASE = {
|
|
124
|
+
margin: '1em 1.25em 2.25em 1.25em',
|
|
125
|
+
padding: '10px 12px',
|
|
126
|
+
borderRadius: '6px',
|
|
127
|
+
fontSize: '1.0em',
|
|
128
|
+
background: 'var(--app-code-bg)',
|
|
129
|
+
color: 'var(--app-code-text)',
|
|
130
|
+
fontFamily: 'var(--mono-font)',
|
|
131
|
+
};
|
|
132
|
+
const PLAIN_FENCE_DEFAULT = {
|
|
133
|
+
...PLAIN_FENCE_BASE,
|
|
134
|
+
overflowX: 'auto',
|
|
135
|
+
};
|
|
136
|
+
/** Narrow thinking panel: wrap instead of horizontal scroll (SyntaxHighlighter uses PreTag="div"). */
|
|
137
|
+
const PLAIN_FENCE_THINKING_STREAM = {
|
|
138
|
+
...PLAIN_FENCE_BASE,
|
|
139
|
+
overflowX: 'hidden',
|
|
140
|
+
maxWidth: '100%',
|
|
141
|
+
whiteSpace: 'pre-wrap',
|
|
142
|
+
overflowWrap: 'anywhere',
|
|
143
|
+
wordBreak: 'break-word',
|
|
144
|
+
};
|
|
145
|
+
const HIGHLIGHTER_CUSTOM_BASE = {
|
|
146
|
+
margin: '1em 1.25em 2.25em 1.25em',
|
|
147
|
+
padding: '10px 12px',
|
|
148
|
+
borderRadius: '6px',
|
|
149
|
+
fontSize: '1.0em',
|
|
150
|
+
};
|
|
151
|
+
const HIGHLIGHTER_CUSTOM_THINKING_STREAM = {
|
|
152
|
+
...HIGHLIGHTER_CUSTOM_BASE,
|
|
153
|
+
overflowX: 'hidden',
|
|
154
|
+
maxWidth: '100%',
|
|
155
|
+
whiteSpace: 'pre-wrap',
|
|
156
|
+
overflowWrap: 'anywhere',
|
|
157
|
+
wordBreak: 'break-word',
|
|
158
|
+
};
|
|
159
|
+
/** After the first paint, wait this long once `code` stops changing before running Prism. */
|
|
160
|
+
const SYNTAX_STABLE_MS = 220;
|
|
161
|
+
function createCodeComponent(plainFenceStyle, highlighterCustom) {
|
|
162
|
+
return function Code({ node: _node, inline, className, children, ...props }) {
|
|
163
|
+
const { highlighter: Highlighter, languages } = useLlmdPlugins();
|
|
164
|
+
// [\w-]: hyphenated fence languages (```vega-lite, ```shell-session) must
|
|
165
|
+
// reach the language/highlighter lookup whole, not truncated at the dash.
|
|
166
|
+
const match = /language-([\w-]+)/.exec(className || '');
|
|
167
|
+
const code = String(children).replace(/\n$/, '');
|
|
168
|
+
const LanguageBlock = !inline && match ? languages?.[match[1].toLowerCase()] : undefined;
|
|
169
|
+
const [syntaxReady, setSyntaxReady] = useState(true);
|
|
170
|
+
const prevCodeRef = useRef(code);
|
|
171
|
+
useEffect(() => {
|
|
172
|
+
if (inline || !match || LanguageBlock || !Highlighter)
|
|
173
|
+
return;
|
|
174
|
+
if (prevCodeRef.current === code)
|
|
175
|
+
return;
|
|
176
|
+
prevCodeRef.current = code;
|
|
177
|
+
startTransition(() => {
|
|
178
|
+
setSyntaxReady(false);
|
|
179
|
+
});
|
|
180
|
+
const id = window.setTimeout(() => {
|
|
181
|
+
setSyntaxReady(true);
|
|
182
|
+
}, SYNTAX_STABLE_MS);
|
|
183
|
+
return () => clearTimeout(id);
|
|
184
|
+
}, [code, inline, LanguageBlock, Highlighter, match]);
|
|
185
|
+
if (LanguageBlock) {
|
|
186
|
+
return _jsx(LanguageBlock, { code: code });
|
|
187
|
+
}
|
|
188
|
+
if (!inline && match) {
|
|
189
|
+
const lang = match[1];
|
|
190
|
+
if (!syntaxReady || !Highlighter) {
|
|
191
|
+
return (_jsx("pre", { style: plainFenceStyle, children: _jsx("code", { className: className, ...props, children: code }) }));
|
|
192
|
+
}
|
|
193
|
+
return (_jsx(Highlighter, { code: code, language: lang, customStyle: highlighterCustom, preTagProps: { [SYNTAX_BLOCK_ATTR]: true } }));
|
|
194
|
+
}
|
|
195
|
+
return (_jsx("code", { className: className, ...props, children: children }));
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Schemes that are internal machinery, never destinations.
|
|
200
|
+
*
|
|
201
|
+
* `attachment:` is the one that bites. Inline cards are positioned in assistant
|
|
202
|
+
* prose with an `<attachment:id/>` tag (see @pyxis-llm/core's `messageContentTags`),
|
|
203
|
+
* and GFM treats `<scheme:rest>` as AUTOLINK syntax — so any surface that
|
|
204
|
+
* renders that prose as markdown turns the tag into `<a href="attachment:id/">`.
|
|
205
|
+
* Only a message-rendering surface that has already stripped/consumed the tags
|
|
206
|
+
* should ever see clean prose; every other markdown surface (run transcript,
|
|
207
|
+
* activity stream, report, thinking panel) renders the raw content and would
|
|
208
|
+
* otherwise produce a clickable link to a scheme no browser can resolve.
|
|
209
|
+
* Clicking it did nothing at best, and in an Electron shell a navigation to an
|
|
210
|
+
* unknown scheme is not harmless.
|
|
211
|
+
*
|
|
212
|
+
* Rendering these inert (plain text, not an anchor) is the safety net.
|
|
213
|
+
*/
|
|
214
|
+
const INERT_LINK_SCHEMES = ['attachment:'];
|
|
215
|
+
function isInertHref(href) {
|
|
216
|
+
if (!href)
|
|
217
|
+
return false;
|
|
218
|
+
const normalized = href.trim().toLowerCase();
|
|
219
|
+
return INERT_LINK_SCHEMES.some((scheme) => normalized.startsWith(scheme));
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* Lets a host render markdown links its own way (e.g. as chips with an icon
|
|
223
|
+
* for the thing linked to) everywhere this package renders markdown - chat
|
|
224
|
+
* messages, streaming text, transcripts - without threading a prop through
|
|
225
|
+
* each of them. Unset (the default) renders a plain anchor. Inert schemes
|
|
226
|
+
* (see below) never reach the renderer.
|
|
227
|
+
*/
|
|
228
|
+
export const MarkdownLinkRendererContext = React.createContext(null);
|
|
229
|
+
function Anchor({ href, children, ...props }) {
|
|
230
|
+
const Renderer = React.useContext(MarkdownLinkRendererContext);
|
|
231
|
+
if (isInertHref(href)) {
|
|
232
|
+
return _jsx("span", { style: { opacity: 0.6 }, children: children });
|
|
233
|
+
}
|
|
234
|
+
if (Renderer) {
|
|
235
|
+
return (_jsx(Renderer, { href: href, ...props, children: children }));
|
|
236
|
+
}
|
|
237
|
+
return (_jsx("a", { href: href, ...props, children: children }));
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* Components to pass to ReactMarkdown so fenced code blocks (e.g. ```js, ```python)
|
|
241
|
+
* are rendered with syntax highlighting. Inline code is left as plain <code>.
|
|
242
|
+
*/
|
|
243
|
+
export const markdownCodeComponents = {
|
|
244
|
+
pre: Pre,
|
|
245
|
+
a: Anchor,
|
|
246
|
+
code: createCodeComponent(PLAIN_FENCE_DEFAULT, { ...HIGHLIGHTER_CUSTOM_BASE }),
|
|
247
|
+
};
|
|
248
|
+
/**
|
|
249
|
+
* Same as {@link markdownCodeComponents} but code fences wrap instead of scrolling horizontally,
|
|
250
|
+
* for a narrow live-streaming markdown surface.
|
|
251
|
+
*/
|
|
252
|
+
export const markdownThinkingStreamCodeComponents = {
|
|
253
|
+
pre: Pre,
|
|
254
|
+
a: Anchor,
|
|
255
|
+
code: createCodeComponent(PLAIN_FENCE_THINKING_STREAM, HIGHLIGHTER_CUSTOM_THINKING_STREAM),
|
|
256
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export type MermaidDiagramProps = {
|
|
2
|
+
code: string;
|
|
3
|
+
/** When true, source view uses a textarea (MDXEditor block). */
|
|
4
|
+
editable?: boolean;
|
|
5
|
+
onCodeChange?: (next: string) => void;
|
|
6
|
+
readOnly?: boolean;
|
|
7
|
+
onSourceFocus?: () => void;
|
|
8
|
+
sourceTextareaRef?: React.RefObject<HTMLTextAreaElement | null>;
|
|
9
|
+
/** Optional trailing control (e.g. delete block in the editor). */
|
|
10
|
+
trailingControl?: React.ReactNode;
|
|
11
|
+
defaultView?: 'chart' | 'source';
|
|
12
|
+
};
|
|
13
|
+
export declare function MermaidDiagram({ code, editable, onCodeChange, readOnly, onSourceFocus, sourceTextareaRef, trailingControl, defaultView, }: MermaidDiagramProps): import("react").JSX.Element;
|
|
14
|
+
/** ReactMarkdown helper: render ```mermaid fences with the shared embed. */
|
|
15
|
+
export declare function MermaidMarkdownCodeBlock({ code }: {
|
|
16
|
+
code: string;
|
|
17
|
+
}): import("react").JSX.Element;
|
|
18
|
+
//# sourceMappingURL=MermaidDiagram.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MermaidDiagram.d.ts","sourceRoot":"","sources":["../src/MermaidDiagram.tsx"],"names":[],"mappings":"AAoBA,MAAM,MAAM,mBAAmB,GAAG;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,gEAAgE;IAChE,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACtC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,aAAa,CAAC,EAAE,MAAM,IAAI,CAAC;IAC3B,iBAAiB,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,mBAAmB,GAAG,IAAI,CAAC,CAAC;IAChE,mEAAmE;IACnE,eAAe,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAClC,WAAW,CAAC,EAAE,OAAO,GAAG,QAAQ,CAAC;CAClC,CAAC;AAEF,wBAAgB,cAAc,CAAC,EAC7B,IAAI,EACJ,QAAgB,EAChB,YAAY,EACZ,QAAgB,EAChB,aAAa,EACb,iBAAiB,EACjB,eAAe,EACf,WAAqB,GACtB,EAAE,mBAAmB,+BA6HrB;AAED,4EAA4E;AAC5E,wBAAgB,wBAAwB,CAAC,EAAE,IAAI,EAAE,EAAE;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,+BAElE"}
|
|
@@ -0,0 +1,66 @@
|
|
|
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 { useEffect, useId, useRef, useState } from 'react';
|
|
7
|
+
import { Box, Group, Loader, SegmentedControl, Text, Textarea, useComputedColorScheme, } from '@mantine/core';
|
|
8
|
+
import { useDebouncedValue } from '@mantine/hooks';
|
|
9
|
+
import { renderMermaidDiagram } from './mermaidRuntime.js';
|
|
10
|
+
const MERMAID_DEBOUNCE_MS = 320;
|
|
11
|
+
export function MermaidDiagram({ code, editable = false, onCodeChange, readOnly = false, onSourceFocus, sourceTextareaRef, trailingControl, defaultView = 'chart', }) {
|
|
12
|
+
const reactId = useId().replace(/:/g, '');
|
|
13
|
+
const colorScheme = useComputedColorScheme('light');
|
|
14
|
+
const isDark = colorScheme === 'dark';
|
|
15
|
+
const chartHostRef = useRef(null);
|
|
16
|
+
const textareaRef = useRef(null);
|
|
17
|
+
const [view, setView] = useState(defaultView);
|
|
18
|
+
const [renderError, setRenderError] = useState(null);
|
|
19
|
+
const [rendering, setRendering] = useState(false);
|
|
20
|
+
const [debouncedCode] = useDebouncedValue(code, MERMAID_DEBOUNCE_MS);
|
|
21
|
+
useEffect(() => {
|
|
22
|
+
if (view !== 'chart')
|
|
23
|
+
return;
|
|
24
|
+
let cancelled = false;
|
|
25
|
+
const host = chartHostRef.current;
|
|
26
|
+
const run = async () => {
|
|
27
|
+
setRendering(true);
|
|
28
|
+
setRenderError(null);
|
|
29
|
+
if (host)
|
|
30
|
+
host.innerHTML = '';
|
|
31
|
+
const result = await renderMermaidDiagram(debouncedCode, isDark);
|
|
32
|
+
if (cancelled)
|
|
33
|
+
return;
|
|
34
|
+
if ('svg' in result) {
|
|
35
|
+
if (host) {
|
|
36
|
+
host.innerHTML = result.svg;
|
|
37
|
+
result.bindFunctions?.(host);
|
|
38
|
+
}
|
|
39
|
+
setRenderError(null);
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
setRenderError(result.error);
|
|
43
|
+
if (host)
|
|
44
|
+
host.innerHTML = '';
|
|
45
|
+
}
|
|
46
|
+
setRendering(false);
|
|
47
|
+
};
|
|
48
|
+
void run();
|
|
49
|
+
return () => {
|
|
50
|
+
cancelled = true;
|
|
51
|
+
};
|
|
52
|
+
}, [debouncedCode, isDark, view, reactId]);
|
|
53
|
+
return (_jsxs(Box, { className: "mermaid-diagram-embed", "data-mermaid-code-block": editable ? '' : undefined, style: { display: 'flex', flexDirection: 'column', gap: 8, minWidth: 0 }, children: [_jsxs(Group, { justify: "space-between", gap: "xs", wrap: "wrap", children: [_jsx(Text, { size: "sm", fw: 600, className: "mermaid-diagram-embed__label", children: "Diagram" }), _jsxs(Group, { gap: "xs", wrap: "nowrap", children: [_jsx(SegmentedControl, { size: "xs", value: view, onChange: (v) => setView(v), data: [
|
|
54
|
+
{ label: 'Chart', value: 'chart' },
|
|
55
|
+
{ label: 'Source', value: 'source' },
|
|
56
|
+
], classNames: { root: 'mermaid-diagram-embed__toggle' } }), trailingControl] })] }), view === 'chart' ? (_jsxs("div", { className: "mermaid-container mermaid-container--chart", children: [rendering ? (_jsxs(Group, { gap: "xs", className: "mermaid-diagram-embed__loading", children: [_jsx(Loader, { size: "xs" }), _jsx(Text, { size: "xs", c: "dimmed", children: "Rendering\u2026" })] })) : null, _jsx("div", { ref: chartHostRef, className: "mermaid-diagram-embed__chart-host", "aria-label": "Mermaid diagram" }), !rendering && !renderError && !debouncedCode.trim() ? (_jsx(Text, { size: "sm", c: "dimmed", className: "mermaid-diagram-embed__empty", children: "Switch to Source to add diagram code." })) : null, renderError ? (_jsx(Text, { size: "xs", c: "red", className: "mermaid-diagram-embed__error", children: renderError })) : null] })) : editable ? (_jsx(Textarea, { ref: (el) => {
|
|
57
|
+
textareaRef.current = el;
|
|
58
|
+
if (sourceTextareaRef) {
|
|
59
|
+
sourceTextareaRef.current = el;
|
|
60
|
+
}
|
|
61
|
+
}, value: code, readOnly: readOnly, onChange: (ev) => onCodeChange?.(ev.currentTarget.value), onFocus: onSourceFocus, minRows: 5, maxRows: 18, autosize: true, spellCheck: false, classNames: { input: 'mermaid-diagram-embed__source-input' }, placeholder: 'flowchart LR\n A[Start] --> B[End]' })) : (_jsx("pre", { className: "mermaid-diagram-embed__source-readonly", children: _jsx("code", { children: code.trim().length ? code : '# No diagram source yet' }) }))] }));
|
|
62
|
+
}
|
|
63
|
+
/** ReactMarkdown helper: render ```mermaid fences with the shared embed. */
|
|
64
|
+
export function MermaidMarkdownCodeBlock({ code }) {
|
|
65
|
+
return _jsx(MermaidDiagram, { code: code, defaultView: "chart" });
|
|
66
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Components } from 'react-markdown';
|
|
2
|
+
/** Inline-friendly markdown (paragraphs as spans) for composer preview and paste messages. */
|
|
3
|
+
export declare const inlineMarkdownComponents: Components;
|
|
4
|
+
/**
|
|
5
|
+
* Renders message content that may contain paste fences as captioned blocks
|
|
6
|
+
* (multi-line) or inline chips (single-line), with the surrounding prose
|
|
7
|
+
* rendered as normal markdown. Falls back to plain markdown when there are
|
|
8
|
+
* no paste fences at all.
|
|
9
|
+
*/
|
|
10
|
+
export declare function MessageContentWithPastes({ content, markdownComponents, }: {
|
|
11
|
+
content: string;
|
|
12
|
+
markdownComponents?: Components;
|
|
13
|
+
}): import("react").JSX.Element;
|
|
14
|
+
//# sourceMappingURL=MessageContentWithPastes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MessageContentWithPastes.d.ts","sourceRoot":"","sources":["../src/MessageContentWithPastes.tsx"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAQjD,8FAA8F;AAC9F,eAAO,MAAM,wBAAwB,EAAE,UAKtC,CAAC;AAkCF;;;;;GAKG;AACH,wBAAgB,wBAAwB,CAAC,EACvC,OAAO,EACP,kBAA2C,GAC5C,EAAE;IACD,OAAO,EAAE,MAAM,CAAC;IAChB,kBAAkB,CAAC,EAAE,UAAU,CAAC;CACjC,+BA+CA"}
|
|
@@ -0,0 +1,44 @@
|
|
|
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 { useMemo } from 'react';
|
|
7
|
+
import ReactMarkdown from 'react-markdown';
|
|
8
|
+
import { useMarkdownPlugins } from './markdownPlugins.js';
|
|
9
|
+
import { pastePillLabel } from './PastePill.js';
|
|
10
|
+
import { messageHasPasteFences, splitMessageByPasteFences, } from './pasteFences.js';
|
|
11
|
+
import { markdownCodeComponents } from './MarkdownCodeComponents.js';
|
|
12
|
+
/** Inline-friendly markdown (paragraphs as spans) for composer preview and paste messages. */
|
|
13
|
+
export const inlineMarkdownComponents = {
|
|
14
|
+
...markdownCodeComponents,
|
|
15
|
+
p: ({ children }) => (_jsx("span", { className: "message-content-with-pastes__md", children: children })),
|
|
16
|
+
};
|
|
17
|
+
function MessagePasteBlock({ number, lineCount, content, }) {
|
|
18
|
+
if (lineCount <= 1) {
|
|
19
|
+
return (_jsxs("span", { className: "message-paste-inline", children: [_jsxs("span", { className: "message-paste-inline__caption", children: ["Pasted content \u00B7 ", pastePillLabel(number, lineCount)] }), ' ', _jsx("code", { className: "message-paste-inline__content", children: content })] }));
|
|
20
|
+
}
|
|
21
|
+
return (_jsxs("figure", { className: "message-paste-block", children: [_jsxs("figcaption", { className: "message-paste-block__caption", children: ["Pasted content \u00B7 ", pastePillLabel(number, lineCount)] }), _jsx("blockquote", { className: "message-paste-block__quote", children: _jsx("pre", { className: "message-paste-block__content", children: content }) })] }));
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Renders message content that may contain paste fences as captioned blocks
|
|
25
|
+
* (multi-line) or inline chips (single-line), with the surrounding prose
|
|
26
|
+
* rendered as normal markdown. Falls back to plain markdown when there are
|
|
27
|
+
* no paste fences at all.
|
|
28
|
+
*/
|
|
29
|
+
export function MessageContentWithPastes({ content, markdownComponents = markdownCodeComponents, }) {
|
|
30
|
+
const segments = useMemo(() => splitMessageByPasteFences(content), [content]);
|
|
31
|
+
const hasPastes = messageHasPasteFences(content);
|
|
32
|
+
const { remarkPlugins, rehypePlugins } = useMarkdownPlugins();
|
|
33
|
+
if (!hasPastes) {
|
|
34
|
+
return (_jsx(ReactMarkdown, { remarkPlugins: remarkPlugins, rehypePlugins: rehypePlugins, components: markdownComponents, children: content }));
|
|
35
|
+
}
|
|
36
|
+
return (_jsx("div", { className: "message-content-with-pastes", children: segments.map((seg, i) => {
|
|
37
|
+
if (seg.kind === 'paste') {
|
|
38
|
+
return (_jsx(MessagePasteBlock, { number: seg.number, lineCount: seg.lineCount, content: seg.content }, `paste-${seg.number}-${i}`));
|
|
39
|
+
}
|
|
40
|
+
if (!seg.text.trim())
|
|
41
|
+
return null;
|
|
42
|
+
return (_jsx(ReactMarkdown, { remarkPlugins: remarkPlugins, rehypePlugins: rehypePlugins, components: inlineMarkdownComponents, children: seg.text }, `text-${i}`));
|
|
43
|
+
}) }));
|
|
44
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export declare function pastePillLabel(number: number, lineCount: number): string;
|
|
2
|
+
/**
|
|
3
|
+
* A small chip representing one captured multi-line clipboard paste, used
|
|
4
|
+
* both in the composer (removable, optionally clickable to edit) and inline
|
|
5
|
+
* in a rendered message (static or clickable). Purely presentational —
|
|
6
|
+
* hosts own the paste content/state; this just renders the label + controls.
|
|
7
|
+
*/
|
|
8
|
+
export declare function PastePill({ number, lineCount, onClick, onRemove, className, title, }: {
|
|
9
|
+
number: number;
|
|
10
|
+
lineCount: number;
|
|
11
|
+
onClick?: () => void;
|
|
12
|
+
onRemove?: () => void;
|
|
13
|
+
className?: string;
|
|
14
|
+
title?: string;
|
|
15
|
+
}): import("react").JSX.Element;
|
|
16
|
+
//# sourceMappingURL=PastePill.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PastePill.d.ts","sourceRoot":"","sources":["../src/PastePill.tsx"],"names":[],"mappings":"AAOA,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAIxE;AAiBD;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,EACxB,MAAM,EACN,SAAS,EACT,OAAO,EACP,QAAQ,EACR,SAAS,EACT,KAAK,GACN,EAAE;IACD,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,+BAoEA"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
export function pastePillLabel(number, lineCount) {
|
|
3
|
+
const lines = lineCount === 1 ? '1 line' : `${Math.max(lineCount, 1)} lines`;
|
|
4
|
+
return `Paste #${number} · ${lines}`;
|
|
5
|
+
}
|
|
6
|
+
function pastePillClassName(className, extra) {
|
|
7
|
+
return ['paste-pill', extra, className].filter(Boolean).join(' ');
|
|
8
|
+
}
|
|
9
|
+
function activateOnEnterOrSpace(event, action) {
|
|
10
|
+
if (!action)
|
|
11
|
+
return;
|
|
12
|
+
if (event.key === 'Enter' || event.key === ' ') {
|
|
13
|
+
event.preventDefault();
|
|
14
|
+
action();
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* A small chip representing one captured multi-line clipboard paste, used
|
|
19
|
+
* both in the composer (removable, optionally clickable to edit) and inline
|
|
20
|
+
* in a rendered message (static or clickable). Purely presentational —
|
|
21
|
+
* hosts own the paste content/state; this just renders the label + controls.
|
|
22
|
+
*/
|
|
23
|
+
export function PastePill({ number, lineCount, onClick, onRemove, className, title, }) {
|
|
24
|
+
const label = pastePillLabel(number, lineCount);
|
|
25
|
+
const resolvedTitle = title ?? (onClick ? `Edit ${label}` : label);
|
|
26
|
+
const removeControl = onRemove ? (_jsx("span", { role: "button", tabIndex: 0, className: "paste-pill__remove", "aria-label": `Remove ${label}`, onClick: (e) => {
|
|
27
|
+
e.stopPropagation();
|
|
28
|
+
e.preventDefault();
|
|
29
|
+
onRemove();
|
|
30
|
+
}, onKeyDown: (e) => activateOnEnterOrSpace(e, onRemove), children: "\u00D7" })) : null;
|
|
31
|
+
if (onRemove) {
|
|
32
|
+
return (_jsxs("span", { className: pastePillClassName(className, 'paste-pill--chip'), title: resolvedTitle, children: [_jsx("span", { className: [
|
|
33
|
+
'paste-pill__label',
|
|
34
|
+
onClick ? 'paste-pill__label--clickable' : null,
|
|
35
|
+
]
|
|
36
|
+
.filter(Boolean)
|
|
37
|
+
.join(' '), role: onClick ? 'button' : undefined, tabIndex: onClick ? 0 : undefined, title: resolvedTitle, onClick: onClick, onKeyDown: (e) => activateOnEnterOrSpace(e, onClick), children: label }), removeControl] }));
|
|
38
|
+
}
|
|
39
|
+
if (onClick) {
|
|
40
|
+
return (_jsx("button", { type: "button", className: pastePillClassName(className), title: resolvedTitle, onClick: onClick, children: _jsx("span", { className: "paste-pill__label", children: label }) }));
|
|
41
|
+
}
|
|
42
|
+
return (_jsx("span", { className: pastePillClassName(className, 'paste-pill--static'), title: resolvedTitle, children: _jsx("span", { className: "paste-pill__label", children: label }) }));
|
|
43
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export type ProviderAuthTerminalProps = {
|
|
2
|
+
output: string;
|
|
3
|
+
running: boolean;
|
|
4
|
+
exitCode: number | null;
|
|
5
|
+
error?: Error | null;
|
|
6
|
+
onSendLine: (line: string) => void;
|
|
7
|
+
onCancel?: () => void;
|
|
8
|
+
/** Fixed height for the scrollback pane. */
|
|
9
|
+
height?: number;
|
|
10
|
+
};
|
|
11
|
+
export declare function ProviderAuthTerminal({ output, running, exitCode, error, onSendLine, onCancel, height, }: ProviderAuthTerminalProps): import("react").JSX.Element;
|
|
12
|
+
//# sourceMappingURL=ProviderAuthTerminal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ProviderAuthTerminal.d.ts","sourceRoot":"","sources":["../src/ProviderAuthTerminal.tsx"],"names":[],"mappings":"AAkBA,MAAM,MAAM,yBAAyB,GAAG;IACtC,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,KAAK,CAAC,EAAE,KAAK,GAAG,IAAI,CAAC;IACrB,UAAU,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;IACtB,4CAA4C;IAC5C,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,wBAAgB,oBAAoB,CAAC,EACnC,MAAM,EACN,OAAO,EACP,QAAQ,EACR,KAAK,EACL,UAAU,EACV,QAAQ,EACR,MAAY,GACb,EAAE,yBAAyB,+BAsE3B"}
|
|
@@ -0,0 +1,50 @@
|
|
|
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
|
+
* Minimal terminal UI for an interactive provider auth command (e.g.
|
|
7
|
+
* `claude login`) driven server-side over gRPC — see useProviderAuthCommand
|
|
8
|
+
* (./node.js). Deliberately simple (a scrollback <pre> + a line input, not a
|
|
9
|
+
* full ANSI/cursor-aware terminal): most auth flows only print a URL and
|
|
10
|
+
* wait for confirmation, so a full xterm.js integration is unnecessary for
|
|
11
|
+
* the common case. Hosts that need real terminal fidelity (cursor movement,
|
|
12
|
+
* color, in-place redraws) can build their own xterm.js view against the
|
|
13
|
+
* same `write`/`resize` primitives useProviderAuthCommand exposes — this
|
|
14
|
+
* component is a slot-free reference implementation, not the only option.
|
|
15
|
+
*/
|
|
16
|
+
import { useEffect, useRef, useState } from 'react';
|
|
17
|
+
import { Box, Button, Group, Loader, Text, TextInput } from '@mantine/core';
|
|
18
|
+
export function ProviderAuthTerminal({ output, running, exitCode, error, onSendLine, onCancel, height = 320, }) {
|
|
19
|
+
const [line, setLine] = useState('');
|
|
20
|
+
const scrollRef = useRef(null);
|
|
21
|
+
useEffect(() => {
|
|
22
|
+
const el = scrollRef.current;
|
|
23
|
+
if (el)
|
|
24
|
+
el.scrollTop = el.scrollHeight;
|
|
25
|
+
}, [output]);
|
|
26
|
+
const submitLine = () => {
|
|
27
|
+
if (!running)
|
|
28
|
+
return;
|
|
29
|
+
onSendLine(line + '\n');
|
|
30
|
+
setLine('');
|
|
31
|
+
};
|
|
32
|
+
return (_jsxs(Box, { children: [_jsx(Box, { component: "pre", ref: scrollRef, style: {
|
|
33
|
+
height,
|
|
34
|
+
overflowY: 'auto',
|
|
35
|
+
overflowX: 'hidden',
|
|
36
|
+
whiteSpace: 'pre-wrap',
|
|
37
|
+
wordBreak: 'break-word',
|
|
38
|
+
background: 'var(--mantine-color-dark-8)',
|
|
39
|
+
color: 'var(--mantine-color-gray-2)',
|
|
40
|
+
padding: 8,
|
|
41
|
+
borderRadius: 4,
|
|
42
|
+
fontSize: 'var(--mantine-font-size-xs)',
|
|
43
|
+
margin: 0,
|
|
44
|
+
}, children: output || (running ? '' : 'Not started.') }), _jsxs(Group, { gap: "xs", mt: "xs", align: "center", children: [running ? _jsx(Loader, { size: "xs" }) : null, _jsx(TextInput, { flex: 1, size: "xs", placeholder: "Type a response and press Enter\u2026", disabled: !running, value: line, onChange: (e) => setLine(e.currentTarget.value), onKeyDown: (e) => {
|
|
45
|
+
if (e.key === 'Enter') {
|
|
46
|
+
e.preventDefault();
|
|
47
|
+
submitLine();
|
|
48
|
+
}
|
|
49
|
+
} }), running && onCancel ? (_jsx(Button, { size: "xs", color: "red", variant: "light", onClick: onCancel, children: "Cancel" })) : null] }), !running && exitCode !== null ? (_jsxs(Text, { size: "xs", c: exitCode === 0 ? 'dimmed' : 'red', mt: 4, children: ["Exited with code ", exitCode, "."] })) : null, error ? (_jsx(Text, { size: "xs", c: "red", mt: 4, children: error.message })) : null] }));
|
|
50
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
import type { LlmdClient, RegisterProviderConfig } from '@pyxis-llm/client';
|
|
3
|
+
/**
|
|
4
|
+
* The form edits an `@pyxis-llm/client` provider config directly.
|
|
5
|
+
*
|
|
6
|
+
* This relies on `RegisterProviderConfig` being a discriminated union with ONE
|
|
7
|
+
* literal `type` per provider kind (llmd's short_code). The `update<Extract<…,
|
|
8
|
+
* { type: 'cursor_cli' }>>()` calls below and the exhaustive
|
|
9
|
+
* `Record<ProviderConnectConfigType, …>` / `switch` both break if a member's
|
|
10
|
+
* `type` is ever widened to a union of spellings — `Extract` collapses to
|
|
11
|
+
* `never` and every field editor starts erroring. See the note on
|
|
12
|
+
* `RegisterProviderConfig`.
|
|
13
|
+
*/
|
|
14
|
+
export type ProviderConnectConfig = RegisterProviderConfig;
|
|
15
|
+
export type ProviderConnectConfigType = ProviderConnectConfig['type'];
|
|
16
|
+
/** API-backed provider types (everything except the CLI-backed ones). */
|
|
17
|
+
export declare function isApiProviderType(type: ProviderConnectConfigType): boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Result of testing an unsaved config; the same shape `LlmdClient.checkProviderConnection`
|
|
20
|
+
* returns, so a host can pass that result straight through.
|
|
21
|
+
*/
|
|
22
|
+
export type ProviderConnectionTestResult = Awaited<ReturnType<LlmdClient['checkProviderConnection']>>;
|
|
23
|
+
export type ProviderConnectFormProps = {
|
|
24
|
+
/**
|
|
25
|
+
* Enables the "Test connection" button. Called with the current, unsaved config; wire it to
|
|
26
|
+
* `client.checkProviderConnection(config.type, { config })`. May make real model calls, so
|
|
27
|
+
* it only runs on button click.
|
|
28
|
+
*/
|
|
29
|
+
onTestConnection?: (config: ProviderConnectConfig) => Promise<ProviderConnectionTestResult>;
|
|
30
|
+
/** 'create' registers a brand-new provider; 'edit' updates an existing one. Defaults to 'create'. */
|
|
31
|
+
mode?: 'create' | 'edit';
|
|
32
|
+
providerId: string;
|
|
33
|
+
onProviderIdChange: (id: string) => void;
|
|
34
|
+
/**
|
|
35
|
+
* Called with the assembled config on submit. In 'create' mode wire this to
|
|
36
|
+
* `registerProvider`; in 'edit' mode wire it to `updateProviderConfig`.
|
|
37
|
+
*/
|
|
38
|
+
onSubmit: (config: ProviderConnectConfig) => Promise<void> | void;
|
|
39
|
+
/**
|
|
40
|
+
* 'edit' mode only: the config loaded via `getProviderConfig`, used to seed
|
|
41
|
+
* the form's initial field values. Also fixes the provider type (can't
|
|
42
|
+
* change a provider's type once created).
|
|
43
|
+
*/
|
|
44
|
+
initialConfig?: ProviderConnectConfig;
|
|
45
|
+
submitting?: boolean;
|
|
46
|
+
error?: Error | null;
|
|
47
|
+
/** Provider types to offer; defaults to all types this form supports. Ignored in 'edit' mode. */
|
|
48
|
+
allowedTypes?: ProviderConnectConfigType[];
|
|
49
|
+
/** Rendered after a successful submit, e.g. a "saved!" banner slot. */
|
|
50
|
+
successMessage?: ReactNode;
|
|
51
|
+
/**
|
|
52
|
+
* @deprecated use {@link onSubmit}. Kept as an alias so existing 'create'-only
|
|
53
|
+
* callers keep working; if both are provided, `onSubmit` wins.
|
|
54
|
+
*/
|
|
55
|
+
onRegister?: (config: ProviderConnectConfig) => Promise<void> | void;
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* A single config form covering every llmd provider type, for both creating
|
|
59
|
+
* a new provider and editing an existing one's config.
|
|
60
|
+
*/
|
|
61
|
+
export declare function ProviderConnectForm({ mode, providerId, onProviderIdChange, onSubmit, onRegister, onTestConnection, initialConfig, submitting, error, allowedTypes, successMessage, }: ProviderConnectFormProps): import("react").JSX.Element;
|
|
62
|
+
//# sourceMappingURL=ProviderConnectForm.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ProviderConnectForm.d.ts","sourceRoot":"","sources":["../src/ProviderConnectForm.tsx"],"names":[],"mappings":"AAgBA,OAAO,EAAgC,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAarE,OAAO,KAAK,EACV,UAAU,EAGV,sBAAsB,EACvB,MAAM,mBAAmB,CAAC;AAE3B;;;;;;;;;;GAUG;AACH,MAAM,MAAM,qBAAqB,GAAG,sBAAsB,CAAC;AAC3D,MAAM,MAAM,yBAAyB,GAAG,qBAAqB,CAAC,MAAM,CAAC,CAAC;AA4BtE,yEAAyE;AACzE,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,yBAAyB,GAAG,OAAO,CAE1E;AA8ED;;;GAGG;AACH,MAAM,MAAM,4BAA4B,GAAG,OAAO,CAChD,UAAU,CAAC,UAAU,CAAC,yBAAyB,CAAC,CAAC,CAClD,CAAC;AAwCF,MAAM,MAAM,wBAAwB,GAAG;IACrC;;;;OAIG;IACH,gBAAgB,CAAC,EAAE,CAAC,MAAM,EAAE,qBAAqB,KAAK,OAAO,CAAC,4BAA4B,CAAC,CAAC;IAC5F,qGAAqG;IACrG,IAAI,CAAC,EAAE,QAAQ,GAAG,MAAM,CAAC;IACzB,UAAU,EAAE,MAAM,CAAC;IACnB,kBAAkB,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IACzC;;;OAGG;IACH,QAAQ,EAAE,CAAC,MAAM,EAAE,qBAAqB,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;IAClE;;;;OAIG;IACH,aAAa,CAAC,EAAE,qBAAqB,CAAC;IACtC,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,KAAK,CAAC,EAAE,KAAK,GAAG,IAAI,CAAC;IACrB,iGAAiG;IACjG,YAAY,CAAC,EAAE,yBAAyB,EAAE,CAAC;IAC3C,uEAAuE;IACvE,cAAc,CAAC,EAAE,SAAS,CAAC;IAC3B;;;OAGG;IACH,UAAU,CAAC,EAAE,CAAC,MAAM,EAAE,qBAAqB,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;CACtE,CAAC;AAEF;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,EAClC,IAAe,EACf,UAAU,EACV,kBAAkB,EAClB,QAAQ,EACR,UAAU,EACV,gBAAgB,EAChB,aAAa,EACb,UAAkB,EAClB,KAAY,EACZ,YAAiC,EACjC,cAAc,GACf,EAAE,wBAAwB,+BAqa1B"}
|