@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,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How long the current turn has been running — and, once it finishes, how long
|
|
3
|
+
* it took (kept until the next turn starts).
|
|
4
|
+
*
|
|
5
|
+
* Three layers, use whichever fits:
|
|
6
|
+
* - `useTurnTimer(streaming, turnStartedAt?)` — just the state; render it
|
|
7
|
+
* however you like.
|
|
8
|
+
* - `<TurnTimer streaming={…} />` — the default look, placeable anywhere
|
|
9
|
+
* (header, toolbar, tab title) and styleable via className/style/format.
|
|
10
|
+
* - `ChatPanel` shows `<TurnTimer>` in its turn bar by default; override what
|
|
11
|
+
* it draws there with `renderTurnTimer`, or hide it with
|
|
12
|
+
* `showTurnTimer={false}` and place your own.
|
|
13
|
+
*
|
|
14
|
+
* Pass `driver.streaming` and `driver.turnTiming` (from useLlmdChatDriver):
|
|
15
|
+
* the driver tracks timing per session from llmd's own turn-start timestamp,
|
|
16
|
+
* so the clock is right across reloads, rejoins and session switches. Without
|
|
17
|
+
* `turnTiming` the timer falls back to timing from when `streaming` flipped,
|
|
18
|
+
* which is only correct for a single session that stays on screen.
|
|
19
|
+
*/
|
|
20
|
+
import { type CSSProperties, type ReactNode } from 'react';
|
|
21
|
+
/** `9s`, `1m 05s`, `1h 02m`. */
|
|
22
|
+
export declare function formatTurnDuration(ms: number): string;
|
|
23
|
+
/** Per-session turn timing, as kept by useLlmdChatDriver (`driver.turnTiming`). */
|
|
24
|
+
export type TurnTiming = {
|
|
25
|
+
/** The user message that started the turn, when known. */
|
|
26
|
+
userMessageId?: string;
|
|
27
|
+
/** Epoch ms the turn started (llmd's timestamp when available). */
|
|
28
|
+
startedAt?: number;
|
|
29
|
+
/** Set once the turn has ended: how long it took. */
|
|
30
|
+
durationMs?: number;
|
|
31
|
+
};
|
|
32
|
+
export type TurnTimerState = {
|
|
33
|
+
/** Elapsed ms of the running turn, or the last turn's final duration. Undefined before any turn. */
|
|
34
|
+
elapsedMs?: number;
|
|
35
|
+
/** True while the turn is running (the value is ticking). */
|
|
36
|
+
running: boolean;
|
|
37
|
+
/** Ready-made text: `"42s"` while running, `"took 42s"` once finished; `""` before any turn. */
|
|
38
|
+
label: string;
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Ticks once a second while `streaming`, then freezes at the final duration
|
|
42
|
+
* until the next turn starts.
|
|
43
|
+
*
|
|
44
|
+
* Pass a {@link TurnTiming} (`driver.turnTiming`) as the second argument and
|
|
45
|
+
* the value is derived from it entirely: nothing is remembered in the
|
|
46
|
+
* component, so it is always the timing of the session being shown.
|
|
47
|
+
*
|
|
48
|
+
* Legacy: a number (ms since epoch) overrides the start time; with neither,
|
|
49
|
+
* the turn is timed from when `streaming` turned true.
|
|
50
|
+
*/
|
|
51
|
+
export declare function useTurnTimer(streaming: boolean, turnStartedAt?: number | TurnTiming): TurnTimerState;
|
|
52
|
+
export type TurnTimerProps = {
|
|
53
|
+
/** Whether a turn is running (e.g. `driver.streaming`). */
|
|
54
|
+
streaming: boolean;
|
|
55
|
+
turnStartedAt?: number;
|
|
56
|
+
/** Per-session timing (`driver.turnTiming`); preferred over `turnStartedAt`. */
|
|
57
|
+
timing?: TurnTiming;
|
|
58
|
+
/** Custom text; defaults to `state.label`. */
|
|
59
|
+
format?: (state: TurnTimerState) => ReactNode;
|
|
60
|
+
className?: string;
|
|
61
|
+
style?: CSSProperties;
|
|
62
|
+
};
|
|
63
|
+
/** The default timer. Renders nothing before the first turn. */
|
|
64
|
+
export declare function TurnTimer({ streaming, turnStartedAt, timing, format, className, style }: TurnTimerProps): import("react").JSX.Element;
|
|
65
|
+
/** Presentational half of {@link TurnTimer}, for when the state is computed elsewhere. */
|
|
66
|
+
export declare function TurnTimerView({ state, format, className, style, }: {
|
|
67
|
+
state: TurnTimerState;
|
|
68
|
+
format?: (state: TurnTimerState) => ReactNode;
|
|
69
|
+
className?: string;
|
|
70
|
+
style?: CSSProperties;
|
|
71
|
+
}): import("react").JSX.Element | null;
|
|
72
|
+
//# sourceMappingURL=TurnTimer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TurnTimer.d.ts","sourceRoot":"","sources":["../src/TurnTimer.tsx"],"names":[],"mappings":"AAKA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAA+B,KAAK,aAAa,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAGxF,gCAAgC;AAChC,wBAAgB,kBAAkB,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAQrD;AAED,mFAAmF;AACnF,MAAM,MAAM,UAAU,GAAG;IACvB,0DAA0D;IAC1D,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,mEAAmE;IACnE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,qDAAqD;IACrD,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG;IAC3B,oGAAoG;IACpG,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,6DAA6D;IAC7D,OAAO,EAAE,OAAO,CAAC;IACjB,gGAAgG;IAChG,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF;;;;;;;;;;GAUG;AACH,wBAAgB,YAAY,CAAC,SAAS,EAAE,OAAO,EAAE,aAAa,CAAC,EAAE,MAAM,GAAG,UAAU,GAAG,cAAc,CAuDpG;AAED,MAAM,MAAM,cAAc,GAAG;IAC3B,2DAA2D;IAC3D,SAAS,EAAE,OAAO,CAAC;IACnB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,gFAAgF;IAChF,MAAM,CAAC,EAAE,UAAU,CAAC;IACpB,8CAA8C;IAC9C,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,cAAc,KAAK,SAAS,CAAC;IAC9C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,aAAa,CAAC;CACvB,CAAC;AAEF,gEAAgE;AAChE,wBAAgB,SAAS,CAAC,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,EAAE,cAAc,+BAGvG;AAED,0FAA0F;AAC1F,wBAAgB,aAAa,CAAC,EAC5B,KAAK,EACL,MAAM,EACN,SAAS,EACT,KAAK,GACN,EAAE;IACD,KAAK,EAAE,cAAc,CAAC;IACtB,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,cAAc,KAAK,SAAS,CAAC;IAC9C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,aAAa,CAAC;CACvB,sCAeA"}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright 2026 John Ewart <john@johnewart.net>
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* How long the current turn has been running — and, once it finishes, how long
|
|
8
|
+
* it took (kept until the next turn starts).
|
|
9
|
+
*
|
|
10
|
+
* Three layers, use whichever fits:
|
|
11
|
+
* - `useTurnTimer(streaming, turnStartedAt?)` — just the state; render it
|
|
12
|
+
* however you like.
|
|
13
|
+
* - `<TurnTimer streaming={…} />` — the default look, placeable anywhere
|
|
14
|
+
* (header, toolbar, tab title) and styleable via className/style/format.
|
|
15
|
+
* - `ChatPanel` shows `<TurnTimer>` in its turn bar by default; override what
|
|
16
|
+
* it draws there with `renderTurnTimer`, or hide it with
|
|
17
|
+
* `showTurnTimer={false}` and place your own.
|
|
18
|
+
*
|
|
19
|
+
* Pass `driver.streaming` and `driver.turnTiming` (from useLlmdChatDriver):
|
|
20
|
+
* the driver tracks timing per session from llmd's own turn-start timestamp,
|
|
21
|
+
* so the clock is right across reloads, rejoins and session switches. Without
|
|
22
|
+
* `turnTiming` the timer falls back to timing from when `streaming` flipped,
|
|
23
|
+
* which is only correct for a single session that stays on screen.
|
|
24
|
+
*/
|
|
25
|
+
import { useEffect, useRef, useState } from 'react';
|
|
26
|
+
import { Text } from '@mantine/core';
|
|
27
|
+
/** `9s`, `1m 05s`, `1h 02m`. */
|
|
28
|
+
export function formatTurnDuration(ms) {
|
|
29
|
+
const total = Math.max(0, Math.floor(ms / 1000));
|
|
30
|
+
const h = Math.floor(total / 3600);
|
|
31
|
+
const m = Math.floor((total % 3600) / 60);
|
|
32
|
+
const s = total % 60;
|
|
33
|
+
if (h > 0)
|
|
34
|
+
return `${h}h ${String(m).padStart(2, '0')}m`;
|
|
35
|
+
if (m > 0)
|
|
36
|
+
return `${m}m ${String(s).padStart(2, '0')}s`;
|
|
37
|
+
return `${s}s`;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Ticks once a second while `streaming`, then freezes at the final duration
|
|
41
|
+
* until the next turn starts.
|
|
42
|
+
*
|
|
43
|
+
* Pass a {@link TurnTiming} (`driver.turnTiming`) as the second argument and
|
|
44
|
+
* the value is derived from it entirely: nothing is remembered in the
|
|
45
|
+
* component, so it is always the timing of the session being shown.
|
|
46
|
+
*
|
|
47
|
+
* Legacy: a number (ms since epoch) overrides the start time; with neither,
|
|
48
|
+
* the turn is timed from when `streaming` turned true.
|
|
49
|
+
*/
|
|
50
|
+
export function useTurnTimer(streaming, turnStartedAt) {
|
|
51
|
+
const timing = typeof turnStartedAt === 'object' ? turnStartedAt : undefined;
|
|
52
|
+
const legacyStart = typeof turnStartedAt === 'number' ? turnStartedAt : undefined;
|
|
53
|
+
const controlled = timing !== undefined;
|
|
54
|
+
// Controlled: a 1s clock while the turn runs; everything else is derived.
|
|
55
|
+
const liveStart = controlled && streaming && timing.durationMs === undefined ? timing.startedAt : undefined;
|
|
56
|
+
const [nowMs, setNowMs] = useState(() => Date.now());
|
|
57
|
+
useEffect(() => {
|
|
58
|
+
if (liveStart === undefined)
|
|
59
|
+
return;
|
|
60
|
+
setNowMs(Date.now());
|
|
61
|
+
const id = setInterval(() => setNowMs(Date.now()), 1_000);
|
|
62
|
+
return () => clearInterval(id);
|
|
63
|
+
}, [liveStart]);
|
|
64
|
+
// Legacy (uncontrolled) state.
|
|
65
|
+
const startRef = useRef(undefined);
|
|
66
|
+
const [legacyElapsedMs, setElapsedMs] = useState(undefined);
|
|
67
|
+
useEffect(() => {
|
|
68
|
+
if (controlled)
|
|
69
|
+
return;
|
|
70
|
+
if (!streaming) {
|
|
71
|
+
if (startRef.current !== undefined) {
|
|
72
|
+
setElapsedMs(Date.now() - startRef.current);
|
|
73
|
+
startRef.current = undefined;
|
|
74
|
+
}
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
startRef.current = legacyStart ?? startRef.current ?? Date.now();
|
|
78
|
+
const tick = () => {
|
|
79
|
+
if (startRef.current !== undefined)
|
|
80
|
+
setElapsedMs(Date.now() - startRef.current);
|
|
81
|
+
};
|
|
82
|
+
tick();
|
|
83
|
+
const id = setInterval(tick, 1_000);
|
|
84
|
+
return () => clearInterval(id);
|
|
85
|
+
}, [controlled, streaming, legacyStart]);
|
|
86
|
+
let elapsedMs;
|
|
87
|
+
if (!controlled) {
|
|
88
|
+
elapsedMs = legacyElapsedMs;
|
|
89
|
+
}
|
|
90
|
+
else if (liveStart !== undefined) {
|
|
91
|
+
// `nowMs` only drives the 1s re-render; read the clock here so the first
|
|
92
|
+
// render after a switch is not computed from a stale tick. Clamped: the
|
|
93
|
+
// start is llmd's clock, `now` is this machine's.
|
|
94
|
+
elapsedMs = Math.max(0, Math.max(nowMs, Date.now()) - liveStart);
|
|
95
|
+
}
|
|
96
|
+
else if (!streaming) {
|
|
97
|
+
elapsedMs = timing.durationMs;
|
|
98
|
+
}
|
|
99
|
+
// (Controlled + streaming with no live start: the new turn's timing has not
|
|
100
|
+
// landed yet — show nothing for that one render rather than a stale value.)
|
|
101
|
+
const label = elapsedMs === undefined ? '' : `${streaming ? '' : 'took '}${formatTurnDuration(elapsedMs)}`;
|
|
102
|
+
return { elapsedMs, running: streaming, label };
|
|
103
|
+
}
|
|
104
|
+
/** The default timer. Renders nothing before the first turn. */
|
|
105
|
+
export function TurnTimer({ streaming, turnStartedAt, timing, format, className, style }) {
|
|
106
|
+
const state = useTurnTimer(streaming, timing ?? turnStartedAt);
|
|
107
|
+
return _jsx(TurnTimerView, { state: state, format: format, className: className, style: style });
|
|
108
|
+
}
|
|
109
|
+
/** Presentational half of {@link TurnTimer}, for when the state is computed elsewhere. */
|
|
110
|
+
export function TurnTimerView({ state, format, className, style, }) {
|
|
111
|
+
if (state.elapsedMs === undefined)
|
|
112
|
+
return null;
|
|
113
|
+
return (_jsx(Text, { className: ['llmd-turn-timer', className].filter(Boolean).join(' '), "data-testid": "llmd-turn-timer", "data-running": state.running ? 'true' : 'false', size: "xs", c: "dimmed", style: { fontVariantNumeric: 'tabular-nums', whiteSpace: 'nowrap', flexShrink: 0, ...style }, title: state.running ? 'Time this turn has been running' : 'How long the last turn took', children: format ? format(state) : state.label }));
|
|
114
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { type ReactNode, type Ref } from 'react';
|
|
2
|
+
import { type VegaDataLoader, type VegaMode } from './vegaRuntime.js';
|
|
3
|
+
export type VegaChartProps = {
|
|
4
|
+
/** The spec as JSON text (a fence body, or JSON.stringify of a card's spec). */
|
|
5
|
+
source: string;
|
|
6
|
+
mode?: VegaMode;
|
|
7
|
+
/** Header label; defaults to the spec's own title, then "Chart". */
|
|
8
|
+
title?: string;
|
|
9
|
+
caption?: string;
|
|
10
|
+
defaultView?: 'chart' | 'source';
|
|
11
|
+
/** When set, the Source view is an editable textarea and this receives each edit. Omit for the read-only view. */
|
|
12
|
+
onSourceChange?: (next: string) => void;
|
|
13
|
+
/** Disables the editable Source textarea. Only meaningful with onSourceChange. */
|
|
14
|
+
readOnly?: boolean;
|
|
15
|
+
/** Called when the editable Source textarea gains focus. */
|
|
16
|
+
onSourceFocus?: () => void;
|
|
17
|
+
/** Ref to the editable Source textarea, for callers that manage focus. */
|
|
18
|
+
sourceInputRef?: Ref<HTMLTextAreaElement>;
|
|
19
|
+
/** Extra control rendered in the footer next to the Chart/Source toggle. */
|
|
20
|
+
footerAction?: ReactNode;
|
|
21
|
+
/** Host loader for data urls. Omitted: every load is refused (chat). Keep the reference stable. */
|
|
22
|
+
loader?: VegaDataLoader;
|
|
23
|
+
};
|
|
24
|
+
export declare const VEGA_FONT_SCALES: readonly [0.8, 0.9, 1, 1.15, 1.3, 1.5, 1.75];
|
|
25
|
+
export declare function VegaChart({ source, mode, title, caption, defaultView, onSourceChange, readOnly, onSourceFocus, sourceInputRef, footerAction, loader, }: VegaChartProps): import("react").JSX.Element;
|
|
26
|
+
type BlockProps = {
|
|
27
|
+
code: string;
|
|
28
|
+
title?: string;
|
|
29
|
+
caption?: string;
|
|
30
|
+
};
|
|
31
|
+
/** Renders ```vega-lite fences, and llmd chart cards in Vega-Lite format. */
|
|
32
|
+
export declare function VegaLiteMarkdownCodeBlock({ code, title, caption }: BlockProps): import("react").JSX.Element;
|
|
33
|
+
/** Renders ```vega fences (full Vega specs), and llmd chart cards in Vega format. */
|
|
34
|
+
export declare function VegaMarkdownCodeBlock({ code, title, caption }: BlockProps): import("react").JSX.Element;
|
|
35
|
+
export {};
|
|
36
|
+
//# sourceMappingURL=VegaChart.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"VegaChart.d.ts","sourceRoot":"","sources":["../src/VegaChart.tsx"],"names":[],"mappings":"AAKA,OAAO,EAA8D,KAAK,SAAS,EAAE,KAAK,GAAG,EAAE,MAAM,OAAO,CAAC;AAG7G,OAAO,EAAqC,KAAK,cAAc,EAAE,KAAK,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAQzG,MAAM,MAAM,cAAc,GAAG;IAC3B,gFAAgF;IAChF,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,QAAQ,CAAC;IAChB,oEAAoE;IACpE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,OAAO,GAAG,QAAQ,CAAC;IACjC,kHAAkH;IAClH,cAAc,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACxC,kFAAkF;IAClF,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,4DAA4D;IAC5D,aAAa,CAAC,EAAE,MAAM,IAAI,CAAC;IAC3B,0EAA0E;IAC1E,cAAc,CAAC,EAAE,GAAG,CAAC,mBAAmB,CAAC,CAAC;IAC1C,4EAA4E;IAC5E,YAAY,CAAC,EAAE,SAAS,CAAC;IACzB,mGAAmG;IACnG,MAAM,CAAC,EAAE,cAAc,CAAC;CACzB,CAAC;AA8BF,eAAO,MAAM,gBAAgB,8CAA+C,CAAC;AA8E7E,wBAAgB,SAAS,CAAC,EACxB,MAAM,EACN,IAAkB,EAClB,KAAK,EACL,OAAO,EACP,WAAqB,EACrB,cAAc,EACd,QAAQ,EACR,aAAa,EACb,cAAc,EACd,YAAY,EACZ,MAAM,GACP,EAAE,cAAc,+BA6KhB;AAED,KAAK,UAAU,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAErE,6EAA6E;AAC7E,wBAAgB,yBAAyB,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,UAAU,+BAE7E;AAED,qFAAqF;AACrF,wBAAgB,qBAAqB,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,UAAU,+BAEzE"}
|
|
@@ -0,0 +1,180 @@
|
|
|
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, useMemo, useRef, useState, useSyncExternalStore } from 'react';
|
|
7
|
+
import { ActionIcon, Box, Group, Loader, SegmentedControl, Text, Textarea, useComputedColorScheme } from '@mantine/core';
|
|
8
|
+
import { useDebouncedValue } from '@mantine/hooks';
|
|
9
|
+
import { renderVegaChart, resolveChartFont } from './vegaRuntime.js';
|
|
10
|
+
/**
|
|
11
|
+
* Fences are re-rendered on every streamed delta, and a half-written spec is
|
|
12
|
+
* not valid JSON; wait for the text to settle before parsing and rendering.
|
|
13
|
+
*/
|
|
14
|
+
const VEGA_DEBOUNCE_MS = 320;
|
|
15
|
+
function parseSpec(source) {
|
|
16
|
+
const trimmed = source.trim();
|
|
17
|
+
if (!trimmed)
|
|
18
|
+
return { kind: 'empty' };
|
|
19
|
+
try {
|
|
20
|
+
const value = JSON.parse(trimmed);
|
|
21
|
+
if (value === null || typeof value !== 'object' || Array.isArray(value))
|
|
22
|
+
return { kind: 'invalid' };
|
|
23
|
+
return { kind: 'ok', spec: value };
|
|
24
|
+
}
|
|
25
|
+
catch {
|
|
26
|
+
return { kind: 'invalid' };
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
function specTitle(spec) {
|
|
30
|
+
const t = spec?.title;
|
|
31
|
+
if (typeof t === 'string' && t.trim())
|
|
32
|
+
return t.trim();
|
|
33
|
+
if (t && typeof t === 'object' && typeof t.text === 'string') {
|
|
34
|
+
return t.text.trim() || undefined;
|
|
35
|
+
}
|
|
36
|
+
return undefined;
|
|
37
|
+
}
|
|
38
|
+
/* ---- Chart text size: one setting shared by every chart, remembered. ---- */
|
|
39
|
+
export const VEGA_FONT_SCALES = [0.8, 0.9, 1, 1.15, 1.3, 1.5, 1.75];
|
|
40
|
+
const FONT_SCALE_KEY = 'llmd.vegaChart.fontScale';
|
|
41
|
+
const fontScaleListeners = new Set();
|
|
42
|
+
let fontScale = readStoredFontScale();
|
|
43
|
+
function readStoredFontScale() {
|
|
44
|
+
try {
|
|
45
|
+
const v = Number(globalThis.localStorage?.getItem(FONT_SCALE_KEY));
|
|
46
|
+
return VEGA_FONT_SCALES.includes(v) ? v : 1;
|
|
47
|
+
}
|
|
48
|
+
catch {
|
|
49
|
+
return 1;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
function setFontScale(next) {
|
|
53
|
+
fontScale = next;
|
|
54
|
+
try {
|
|
55
|
+
globalThis.localStorage?.setItem(FONT_SCALE_KEY, String(next));
|
|
56
|
+
}
|
|
57
|
+
catch {
|
|
58
|
+
// Storage unavailable (private mode, tests): the setting lasts the session.
|
|
59
|
+
}
|
|
60
|
+
for (const l of fontScaleListeners)
|
|
61
|
+
l();
|
|
62
|
+
}
|
|
63
|
+
function useFontScale() {
|
|
64
|
+
return useSyncExternalStore((l) => {
|
|
65
|
+
fontScaleListeners.add(l);
|
|
66
|
+
return () => fontScaleListeners.delete(l);
|
|
67
|
+
}, () => fontScale, () => 1);
|
|
68
|
+
}
|
|
69
|
+
function stepFontScale(current, dir) {
|
|
70
|
+
const scales = VEGA_FONT_SCALES;
|
|
71
|
+
const i = scales.indexOf(current);
|
|
72
|
+
const at = i < 0 ? scales.indexOf(1) : i;
|
|
73
|
+
return scales[Math.min(scales.length - 1, Math.max(0, at + dir))];
|
|
74
|
+
}
|
|
75
|
+
/* ---- Layout CSS, injected once. vega-embed puts its \`vega-embed\` class on
|
|
76
|
+
the HOST element itself (the div we hand it), so its rules are matched as
|
|
77
|
+
\`.vega-chart-embed__host.vega-embed\` (compound), never as a descendant.
|
|
78
|
+
Selectors carry extra classes so they beat vega-embed's own stylesheet,
|
|
79
|
+
which it injects later. The host is made position: static so the absolutely
|
|
80
|
+
positioned … button resolves against the card (.vega-chart-embed) and can
|
|
81
|
+
sit in the footer row at the card's bottom-right. ---- */
|
|
82
|
+
const STYLE_ID = 'llmd-vega-chart-styles';
|
|
83
|
+
const H = '.vega-chart-embed .vega-chart-embed__host.vega-embed';
|
|
84
|
+
const CHART_CSS = `
|
|
85
|
+
.vega-chart-embed { position: relative; }
|
|
86
|
+
.vega-chart-embed .vega-chart-embed__host { display: flex; justify-content: center; }
|
|
87
|
+
${H} { position: static; display: flex; justify-content: center; max-width: 100%; }
|
|
88
|
+
${H}.has-actions { padding-right: 0; }
|
|
89
|
+
${H} summary { top: auto; bottom: 0; right: 0; opacity: 0.6; }
|
|
90
|
+
.vega-chart-embed:hover ${H.slice('.vega-chart-embed '.length)} summary { opacity: 1 !important; }
|
|
91
|
+
${H} .vega-actions { top: auto; bottom: 36px; right: -9px; }
|
|
92
|
+
${H} .vega-actions a { font-family: inherit; }
|
|
93
|
+
${H} .vega-actions::before {
|
|
94
|
+
top: auto; bottom: -16px; border-bottom-color: transparent; border-top-color: #d9d9d9;
|
|
95
|
+
}
|
|
96
|
+
${H} .vega-actions::after {
|
|
97
|
+
top: auto; bottom: -14px; border-bottom-color: transparent; border-top-color: #fff;
|
|
98
|
+
}
|
|
99
|
+
.vega-chart-embed .vega-chart-embed__footer { min-height: 28px; padding-right: 36px; }
|
|
100
|
+
`;
|
|
101
|
+
function ensureChartStyles() {
|
|
102
|
+
if (typeof document === 'undefined' || document.getElementById(STYLE_ID))
|
|
103
|
+
return;
|
|
104
|
+
const style = document.createElement('style');
|
|
105
|
+
style.id = STYLE_ID;
|
|
106
|
+
style.textContent = CHART_CSS;
|
|
107
|
+
document.head.appendChild(style);
|
|
108
|
+
}
|
|
109
|
+
export function VegaChart({ source, mode = 'vega-lite', title, caption, defaultView = 'chart', onSourceChange, readOnly, onSourceFocus, sourceInputRef, footerAction, loader, }) {
|
|
110
|
+
ensureChartStyles();
|
|
111
|
+
const isDark = useComputedColorScheme('light') === 'dark';
|
|
112
|
+
const scale = useFontScale();
|
|
113
|
+
const hostRef = useRef(null);
|
|
114
|
+
const [view, setView] = useState(defaultView);
|
|
115
|
+
const [debounced] = useDebouncedValue(source, VEGA_DEBOUNCE_MS);
|
|
116
|
+
const parsed = useMemo(() => parseSpec(debounced), [debounced]);
|
|
117
|
+
const [rendering, setRendering] = useState(false);
|
|
118
|
+
const [renderError, setRenderError] = useState(null);
|
|
119
|
+
useEffect(() => {
|
|
120
|
+
const host = hostRef.current;
|
|
121
|
+
if (view !== 'chart' || !host || parsed.kind !== 'ok') {
|
|
122
|
+
setRendering(false);
|
|
123
|
+
setRenderError(null);
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
let cancelled = false;
|
|
127
|
+
let finalize;
|
|
128
|
+
setRendering(true);
|
|
129
|
+
setRenderError(null);
|
|
130
|
+
void renderVegaChart(host, parsed.spec, {
|
|
131
|
+
mode,
|
|
132
|
+
isDark,
|
|
133
|
+
downloadFileName: specTitle(parsed.spec) ?? title,
|
|
134
|
+
fontScale: scale,
|
|
135
|
+
loader,
|
|
136
|
+
}).then((result) => {
|
|
137
|
+
if (cancelled) {
|
|
138
|
+
if ('finalize' in result)
|
|
139
|
+
result.finalize();
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
if ('finalize' in result) {
|
|
143
|
+
finalize = result.finalize;
|
|
144
|
+
if (result.problems.length > 0)
|
|
145
|
+
setRenderError(result.problems.join('\n'));
|
|
146
|
+
}
|
|
147
|
+
else {
|
|
148
|
+
setRenderError(result.error);
|
|
149
|
+
}
|
|
150
|
+
setRendering(false);
|
|
151
|
+
});
|
|
152
|
+
return () => {
|
|
153
|
+
cancelled = true;
|
|
154
|
+
finalize?.();
|
|
155
|
+
host.innerHTML = '';
|
|
156
|
+
};
|
|
157
|
+
}, [parsed, mode, isDark, view, title, scale, loader]);
|
|
158
|
+
const ownTitle = specTitle(parsed.kind === 'ok' ? parsed.spec : undefined);
|
|
159
|
+
const label = title?.trim() || ownTitle || 'Chart';
|
|
160
|
+
// The chart draws its own title; repeating it in the header showed it twice.
|
|
161
|
+
const explicit = title?.trim();
|
|
162
|
+
const headerLabel = explicit && explicit !== ownTitle ? explicit : view === 'chart' && ownTitle ? undefined : explicit || ownTitle;
|
|
163
|
+
// A fence's chart replaces a code block, whose monospace font it would
|
|
164
|
+
// otherwise inherit. Same font as the chart's own labels.
|
|
165
|
+
const font = useMemo(() => resolveChartFont(), []);
|
|
166
|
+
return (_jsxs(Box, { className: "vega-chart-embed", style: { display: 'flex', flexDirection: 'column', gap: 8, minWidth: 0, fontFamily: font }, children: [headerLabel ? (_jsx(Text, { size: "sm", fw: 600, className: "vega-chart-embed__label", style: { fontFamily: font }, children: headerLabel })) : null, view === 'chart' ? (_jsxs("div", { className: "vega-chart-embed__chart", style: { minWidth: 0 }, children: [rendering ? (_jsxs(Group, { gap: "xs", className: "vega-chart-embed__loading", children: [_jsx(Loader, { size: "xs" }), _jsx(Text, { size: "xs", c: "dimmed", children: "Rendering\u2026" })] })) : null, _jsx("div", { ref: hostRef, className: "vega-chart-embed__host", role: "img", "aria-label": label, style: { width: '100%', minWidth: 0 } }), parsed.kind === 'empty' ? (_jsx(Text, { size: "sm", c: "dimmed", className: "vega-chart-embed__empty", children: "Chart source is empty." })) : null, parsed.kind === 'invalid' ? (
|
|
167
|
+
// Quiet on purpose: while a fence streams in, its JSON is incomplete.
|
|
168
|
+
_jsx(Text, { size: "sm", c: "dimmed", className: "vega-chart-embed__invalid", children: "Chart spec is not a complete JSON object." })) : null, renderError ? (_jsx(Text, { size: "xs", c: "red", className: "vega-chart-embed__error", style: { whiteSpace: 'pre-wrap' }, children: renderError })) : null] })) : onSourceChange ? (_jsx(Textarea, { ref: sourceInputRef, className: "vega-chart-embed__source", value: source, autosize: true, minRows: 3, spellCheck: false, disabled: readOnly, onChange: (e) => onSourceChange(e.currentTarget.value), onFocus: () => onSourceFocus?.(), styles: { input: { fontFamily: 'var(--mantine-font-family-monospace, monospace)' } } })) : (_jsx("pre", { className: "vega-chart-embed__source", style: { margin: 0, overflowX: 'auto', fontFamily: 'var(--mantine-font-family-monospace, monospace)' }, children: _jsx("code", { children: source }) })), caption?.trim() ? (_jsx(Text, { size: "xs", c: "dimmed", className: "vega-chart-embed__caption", children: caption })) : null, _jsxs(Group, { justify: "space-between", gap: "xs", wrap: "nowrap", className: "vega-chart-embed__footer", children: [_jsxs(Group, { gap: 4, wrap: "nowrap", className: "vega-chart-embed__font", children: [_jsx(ActionIcon, { size: "sm", variant: "subtle", color: "gray", "aria-label": "Smaller chart text", disabled: view !== 'chart' || scale <= VEGA_FONT_SCALES[0], onClick: () => setFontScale(stepFontScale(scale, -1)), children: _jsx(Text, { size: "xs", fw: 600, style: { fontFamily: font }, children: "A\u2212" }) }), _jsx(ActionIcon, { size: "sm", variant: "subtle", color: "gray", "aria-label": "Larger chart text", disabled: view !== 'chart' || scale >= VEGA_FONT_SCALES[VEGA_FONT_SCALES.length - 1], onClick: () => setFontScale(stepFontScale(scale, 1)), children: _jsx(Text, { size: "sm", fw: 600, style: { fontFamily: font }, children: "A+" }) })] }), _jsxs(Group, { gap: "xs", wrap: "nowrap", className: "vega-chart-embed__actions", children: [footerAction, _jsx(SegmentedControl, { size: "xs", value: view, onChange: (v) => setView(v), data: [
|
|
169
|
+
{ label: 'Chart', value: 'chart' },
|
|
170
|
+
{ label: 'Source', value: 'source' },
|
|
171
|
+
], classNames: { root: 'vega-chart-embed__toggle' } })] })] })] }));
|
|
172
|
+
}
|
|
173
|
+
/** Renders ```vega-lite fences, and llmd chart cards in Vega-Lite format. */
|
|
174
|
+
export function VegaLiteMarkdownCodeBlock({ code, title, caption }) {
|
|
175
|
+
return _jsx(VegaChart, { source: code, mode: "vega-lite", title: title, caption: caption });
|
|
176
|
+
}
|
|
177
|
+
/** Renders ```vega fences (full Vega specs), and llmd chart cards in Vega format. */
|
|
178
|
+
export function VegaMarkdownCodeBlock({ code, title, caption }) {
|
|
179
|
+
return _jsx(VegaChart, { source: code, mode: "vega", title: title, caption: caption });
|
|
180
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export type { ChatStreamCapableClient, LlmdChatDriver, LlmdChatDriverOptions, LlmdChatDriverConfig, OutgoingAttachment, QueueDrainCapableClient, SessionEventsSubscribableClient, ToolConversationEvent, } from './useLlmdChatDriver.js';
|
|
2
|
+
export { useLlmdChatDriver } from './useLlmdChatDriver.js';
|
|
3
|
+
export type { LlmdModelCatalog } from './useLlmdModelCatalog.js';
|
|
4
|
+
export { useLlmdModelCatalog } from './useLlmdModelCatalog.js';
|
|
5
|
+
export type { LlmdSessionModel, LlmdSessionModelSelection } from './useLlmdSessionModel.js';
|
|
6
|
+
export { useLlmdSessionModel } from './useLlmdSessionModel.js';
|
|
7
|
+
//# sourceMappingURL=browser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../src/browser.ts"],"names":[],"mappings":"AAgBA,YAAY,EACV,uBAAuB,EACvB,cAAc,EACd,qBAAqB,EACrB,oBAAoB,EACpB,kBAAkB,EAClB,uBAAuB,EACvB,+BAA+B,EAC/B,qBAAqB,GACtB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAE3D,YAAY,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAE/D,YAAY,EAAE,gBAAgB,EAAE,yBAAyB,EAAE,MAAM,0BAA0B,CAAC;AAC5F,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC"}
|
package/dist/browser.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2026 John Ewart <john@johnewart.net>
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*
|
|
5
|
+
* @pyxis-llm/react/browser — the browser-safe counterpart of ./node.
|
|
6
|
+
*
|
|
7
|
+
* Both entry points now export the SAME hooks over the SAME client type:
|
|
8
|
+
* @pyxis-llm/client serves both transports, and which one you get is decided by
|
|
9
|
+
* which binding you construct the client with ('@pyxis-llm/client/web' here,
|
|
10
|
+
* '@pyxis-llm/client/node' there), not by which hook you import. These two modules
|
|
11
|
+
* are kept only so the import site still documents the host's capability, and
|
|
12
|
+
* because ./node additionally exports useProviderAuthCommand — that one really
|
|
13
|
+
* is Node-only, since its RPC is bidi-streaming and gRPC-Web cannot carry bidi
|
|
14
|
+
* calls at all.
|
|
15
|
+
*/
|
|
16
|
+
export { useLlmdChatDriver } from './useLlmdChatDriver.js';
|
|
17
|
+
export { useLlmdModelCatalog } from './useLlmdModelCatalog.js';
|
|
18
|
+
export { useLlmdSessionModel } from './useLlmdSessionModel.js';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { CatalogTreeNode } from './modelCatalogTree.js';
|
|
2
|
+
import type { ChatModelOption } from './chatModelOptions.js';
|
|
3
|
+
export declare function optionLookupKey(providerId: string, modelId: string, multiProvider: boolean): string;
|
|
4
|
+
/** Drop leaf nodes with no matching picker option; prune empty groups. */
|
|
5
|
+
export declare function filterSelectableTreeNodes(nodes: CatalogTreeNode[], resolveOption: (modelId: string) => ChatModelOption | undefined): CatalogTreeNode[];
|
|
6
|
+
export declare function makeResolveOption(providerId: string, optionByModelId: Map<string, ChatModelOption>, multiProvider: boolean): (modelId: string) => ChatModelOption | undefined;
|
|
7
|
+
/** When multiple providers share one browser, filter each provider subtree with its own id. */
|
|
8
|
+
export declare function filterMultiProviderRoots(roots: CatalogTreeNode[], optionByModelId: Map<string, ChatModelOption>, multiProvider: boolean): CatalogTreeNode[];
|
|
9
|
+
//# sourceMappingURL=catalogColumnBrowserTree.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"catalogColumnBrowserTree.d.ts","sourceRoot":"","sources":["../src/catalogColumnBrowserTree.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAE7D,wBAAgB,eAAe,CAC7B,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,MAAM,EACf,aAAa,EAAE,OAAO,GACrB,MAAM,CAER;AAED,0EAA0E;AAC1E,wBAAgB,yBAAyB,CACvC,KAAK,EAAE,eAAe,EAAE,EACxB,aAAa,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,eAAe,GAAG,SAAS,GAC9D,eAAe,EAAE,CAenB;AAED,wBAAgB,iBAAiB,CAC/B,UAAU,EAAE,MAAM,EAClB,eAAe,EAAE,GAAG,CAAC,MAAM,EAAE,eAAe,CAAC,EAC7C,aAAa,EAAE,OAAO,GACrB,CAAC,OAAO,EAAE,MAAM,KAAK,eAAe,GAAG,SAAS,CAKlD;AAED,+FAA+F;AAC/F,wBAAgB,wBAAwB,CACtC,KAAK,EAAE,eAAe,EAAE,EACxB,eAAe,EAAE,GAAG,CAAC,MAAM,EAAE,eAAe,CAAC,EAC7C,aAAa,EAAE,OAAO,GACrB,eAAe,EAAE,CAiBnB"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2026 John Ewart <john@johnewart.net>
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
export function optionLookupKey(providerId, modelId, multiProvider) {
|
|
6
|
+
return multiProvider ? `${providerId}:${modelId}` : modelId;
|
|
7
|
+
}
|
|
8
|
+
/** Drop leaf nodes with no matching picker option; prune empty groups. */
|
|
9
|
+
export function filterSelectableTreeNodes(nodes, resolveOption) {
|
|
10
|
+
const out = [];
|
|
11
|
+
for (const node of nodes) {
|
|
12
|
+
if (node.kind === 'leaf') {
|
|
13
|
+
if (node.modelId && resolveOption(node.modelId)) {
|
|
14
|
+
out.push(node);
|
|
15
|
+
}
|
|
16
|
+
continue;
|
|
17
|
+
}
|
|
18
|
+
if (!node.children?.length)
|
|
19
|
+
continue;
|
|
20
|
+
const children = filterSelectableTreeNodes(node.children, resolveOption);
|
|
21
|
+
if (children.length === 0)
|
|
22
|
+
continue;
|
|
23
|
+
out.push({ ...node, children });
|
|
24
|
+
}
|
|
25
|
+
return out;
|
|
26
|
+
}
|
|
27
|
+
export function makeResolveOption(providerId, optionByModelId, multiProvider) {
|
|
28
|
+
return (modelId) => {
|
|
29
|
+
const key = optionLookupKey(providerId, modelId, multiProvider);
|
|
30
|
+
return optionByModelId.get(key) ?? optionByModelId.get(modelId);
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
/** When multiple providers share one browser, filter each provider subtree with its own id. */
|
|
34
|
+
export function filterMultiProviderRoots(roots, optionByModelId, multiProvider) {
|
|
35
|
+
const out = [];
|
|
36
|
+
for (const root of roots) {
|
|
37
|
+
if (root.kind !== 'group') {
|
|
38
|
+
out.push(root);
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
const resolveOption = makeResolveOption(root.id, optionByModelId, multiProvider);
|
|
42
|
+
const children = filterSelectableTreeNodes(root.children ?? [], resolveOption);
|
|
43
|
+
if (children.length === 0)
|
|
44
|
+
continue;
|
|
45
|
+
out.push({ ...root, children });
|
|
46
|
+
}
|
|
47
|
+
return out;
|
|
48
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import type { CSSProperties } from 'react';
|
|
2
|
+
/** Picker menu text size — sm (14px) for comfortable readability. */
|
|
3
|
+
export declare const CATALOG_PICKER_MENU_FONT_SIZE = "var(--mantine-font-size-sm)";
|
|
4
|
+
/** Horizontal inset for picker menu item divider lines (not full-width). */
|
|
5
|
+
export declare const CATALOG_PICKER_ITEM_DIVIDER_INSET = 10;
|
|
6
|
+
/** Finder-style selection fill for active parent rows and child panes. */
|
|
7
|
+
export declare const CATALOG_PICKER_ACTIVE_BACKGROUND = "var(--mantine-primary-color-light)";
|
|
8
|
+
/** Text on active picker rows. */
|
|
9
|
+
export declare const CATALOG_PICKER_ACTIVE_COLOR = "var(--mantine-primary-color-light-color)";
|
|
10
|
+
/** Fixed height for the column browser and filter-result lists. */
|
|
11
|
+
export declare const CATALOG_PICKER_BROWSER_HEIGHT = 280;
|
|
12
|
+
/** Single-column picker dropdown width. */
|
|
13
|
+
export declare const CATALOG_PICKER_DROPDOWN_SINGLE_COLUMN_WIDTH = 280;
|
|
14
|
+
/** Two-column picker dropdown width (double the single-column width). */
|
|
15
|
+
export declare const CATALOG_PICKER_DROPDOWN_TWO_COLUMN_WIDTH: number;
|
|
16
|
+
export declare function catalogPickerBrowserFrameStyle(): CSSProperties;
|
|
17
|
+
export declare function catalogPickerColumnScrollStyle(): CSSProperties;
|
|
18
|
+
export declare function catalogPickerSearchResultsScrollStyle(): CSSProperties;
|
|
19
|
+
/** Sticky footer row pinned to the bottom of a column browser pane (e.g. "Reload models"). */
|
|
20
|
+
export declare function catalogPickerColumnFooterStyle(): CSSProperties;
|
|
21
|
+
export declare function catalogPickerInsetDividerStyle(): CSSProperties;
|
|
22
|
+
export declare const catalogPickerMenuItemStyles: {
|
|
23
|
+
readonly item: {
|
|
24
|
+
readonly width: "100%";
|
|
25
|
+
readonly paddingTop: 5;
|
|
26
|
+
readonly paddingBottom: 5;
|
|
27
|
+
readonly borderRadius: 0;
|
|
28
|
+
readonly fontSize: "var(--mantine-font-size-sm)";
|
|
29
|
+
readonly fontWeight: 500;
|
|
30
|
+
};
|
|
31
|
+
readonly itemLabel: {
|
|
32
|
+
readonly flex: 1;
|
|
33
|
+
readonly minWidth: 0;
|
|
34
|
+
};
|
|
35
|
+
readonly itemSection: {
|
|
36
|
+
readonly marginInlineStart: 8;
|
|
37
|
+
readonly flexShrink: 0;
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
export declare function catalogPickerMenuItemStylesForState(options: {
|
|
41
|
+
selected?: boolean;
|
|
42
|
+
leafSelected?: boolean;
|
|
43
|
+
}): {
|
|
44
|
+
readonly item: {
|
|
45
|
+
readonly backgroundColor?: string | undefined;
|
|
46
|
+
readonly color?: string | undefined;
|
|
47
|
+
readonly width: "100%";
|
|
48
|
+
readonly paddingTop: 5;
|
|
49
|
+
readonly paddingBottom: 5;
|
|
50
|
+
readonly borderRadius: 0;
|
|
51
|
+
readonly fontSize: "var(--mantine-font-size-sm)";
|
|
52
|
+
readonly fontWeight: 500;
|
|
53
|
+
};
|
|
54
|
+
readonly itemLabel: {
|
|
55
|
+
readonly flex: 1;
|
|
56
|
+
readonly minWidth: 0;
|
|
57
|
+
};
|
|
58
|
+
readonly itemSection: {
|
|
59
|
+
readonly marginInlineStart: 8;
|
|
60
|
+
readonly flexShrink: 0;
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
export declare function catalogPickerActiveColumnStyle(): CSSProperties;
|
|
64
|
+
export declare function catalogPickerActiveColumnHeaderStyle(): CSSProperties;
|
|
65
|
+
export declare function catalogPickerMenuDropdownStyles(twoColumns?: boolean): {
|
|
66
|
+
readonly dropdown: {
|
|
67
|
+
readonly padding: 0;
|
|
68
|
+
readonly overflow: "hidden";
|
|
69
|
+
readonly fontSize: "var(--mantine-font-size-sm)";
|
|
70
|
+
readonly minWidth: number;
|
|
71
|
+
readonly width: number;
|
|
72
|
+
};
|
|
73
|
+
};
|
|
74
|
+
/** Mantine Menu defaults that allow typing in the filter TextInput. */
|
|
75
|
+
export declare const catalogPickerMenuBehaviorProps: {
|
|
76
|
+
readonly trapFocus: false;
|
|
77
|
+
};
|
|
78
|
+
export declare const catalogPickerMenuLabelStyle: {
|
|
79
|
+
readonly fontSize: "var(--mantine-font-size-sm)";
|
|
80
|
+
};
|
|
81
|
+
//# sourceMappingURL=catalogPickerMenuStyles.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"catalogPickerMenuStyles.d.ts","sourceRoot":"","sources":["../src/catalogPickerMenuStyles.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAE3C,qEAAqE;AACrE,eAAO,MAAM,6BAA6B,gCAAgC,CAAC;AAE3E,4EAA4E;AAC5E,eAAO,MAAM,iCAAiC,KAAK,CAAC;AAEpD,0EAA0E;AAC1E,eAAO,MAAM,gCAAgC,uCACP,CAAC;AAEvC,kCAAkC;AAClC,eAAO,MAAM,2BAA2B,6CACI,CAAC;AAE7C,mEAAmE;AACnE,eAAO,MAAM,6BAA6B,MAAM,CAAC;AAEjD,2CAA2C;AAC3C,eAAO,MAAM,2CAA2C,MAAM,CAAC;AAE/D,yEAAyE;AACzE,eAAO,MAAM,wCAAwC,QACJ,CAAC;AAElD,wBAAgB,8BAA8B,IAAI,aAAa,CAQ9D;AAED,wBAAgB,8BAA8B,IAAI,aAAa,CAQ9D;AAED,wBAAgB,qCAAqC,IAAI,aAAa,CAOrE;AAED,8FAA8F;AAC9F,wBAAgB,8BAA8B,IAAI,aAAa,CAK9D;AAED,wBAAgB,8BAA8B,IAAI,aAAa,CAS9D;AAED,eAAO,MAAM,2BAA2B;;;;;;;;;;;;;;;;;CAiB9B,CAAC;AAEX,wBAAgB,mCAAmC,CAAC,OAAO,EAAE;IAC3D,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;;;;;;;;;;;;;;;;;;;EAeA;AAED,wBAAgB,8BAA8B,IAAI,aAAa,CAI9D;AAED,wBAAgB,oCAAoC,IAAI,aAAa,CAQpE;AAED,wBAAgB,+BAA+B,CAAC,UAAU,UAAQ;;;;;;;;EAajE;AAED,uEAAuE;AACvE,eAAO,MAAM,8BAA8B;;CAEjC,CAAC;AAEX,eAAO,MAAM,2BAA2B;;CAE9B,CAAC"}
|