@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,23 @@
|
|
|
1
|
+
import type { LlmdClient } from '@pyxis-llm/client';
|
|
2
|
+
import type { ChatModelOption } from './chatModelOptions.js';
|
|
3
|
+
export type LlmdModelCatalog = {
|
|
4
|
+
options: ChatModelOption[];
|
|
5
|
+
loading: boolean;
|
|
6
|
+
error: Error | null;
|
|
7
|
+
refresh: () => void;
|
|
8
|
+
/**
|
|
9
|
+
* Re-scans a single provider's model catalog (RefreshLlmProviderModels) and
|
|
10
|
+
* refetches options. Scoped to one provider so a host can wire this to a
|
|
11
|
+
* "reload models" affordance on a per-provider nav item without paying for
|
|
12
|
+
* the auto-refresh-everything cost `refresh()`/the initial load avoids.
|
|
13
|
+
*/
|
|
14
|
+
refreshProvider: (providerId: string) => Promise<void>;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Loads the model catalog (providers + their catalog models) for `client`'s
|
|
18
|
+
* workspace and exposes it as `ChatModelOption[]` ready for
|
|
19
|
+
* `CatalogModelPicker`'s `options` prop. `client` may be `null`/`undefined`
|
|
20
|
+
* while a host is still setting up its connection.
|
|
21
|
+
*/
|
|
22
|
+
export declare function useLlmdModelCatalog(client: LlmdClient | null | undefined): LlmdModelCatalog;
|
|
23
|
+
//# sourceMappingURL=useLlmdModelCatalog.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useLlmdModelCatalog.d.ts","sourceRoot":"","sources":["../src/useLlmdModelCatalog.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAEpD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAE7D,MAAM,MAAM,gBAAgB,GAAG;IAC7B,OAAO,EAAE,eAAe,EAAE,CAAC;IAC3B,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IACpB,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB;;;;;OAKG;IACH,eAAe,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACxD,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI,GAAG,SAAS,GAAG,gBAAgB,CAiE3F"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2026 John Ewart <john@johnewart.net>
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*
|
|
5
|
+
* Node-capable model-catalog hook (see ./node.js). Fetches llmd's
|
|
6
|
+
* registered providers + catalog models via @pyxis-llm/client and converts them
|
|
7
|
+
* to ChatModelOption[] for CatalogModelPicker. Lives here (not the main
|
|
8
|
+
* entry) for the same reason useLlmdChatDriver does: @pyxis-llm/client pulls in
|
|
9
|
+
* @grpc/grpc-js.
|
|
10
|
+
*/
|
|
11
|
+
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
12
|
+
import { chatModelOptionsFromCatalog } from './modelCatalogSource.js';
|
|
13
|
+
/**
|
|
14
|
+
* Loads the model catalog (providers + their catalog models) for `client`'s
|
|
15
|
+
* workspace and exposes it as `ChatModelOption[]` ready for
|
|
16
|
+
* `CatalogModelPicker`'s `options` prop. `client` may be `null`/`undefined`
|
|
17
|
+
* while a host is still setting up its connection.
|
|
18
|
+
*/
|
|
19
|
+
export function useLlmdModelCatalog(client) {
|
|
20
|
+
const [options, setOptions] = useState([]);
|
|
21
|
+
const [loading, setLoading] = useState(false);
|
|
22
|
+
const [error, setError] = useState(null);
|
|
23
|
+
const generationRef = useRef(0);
|
|
24
|
+
const refresh = useCallback(() => {
|
|
25
|
+
if (!client)
|
|
26
|
+
return;
|
|
27
|
+
const generation = ++generationRef.current;
|
|
28
|
+
setLoading(true);
|
|
29
|
+
setError(null);
|
|
30
|
+
void (async () => {
|
|
31
|
+
try {
|
|
32
|
+
const providers = await client.listProviders();
|
|
33
|
+
// ListLlmCatalogModels never scans (see providers.Entry.CatalogLen), but
|
|
34
|
+
// llmd now PERSISTS each successful scan and rehydrates it, so a provider
|
|
35
|
+
// scanned once stays populated across llmd restarts — this load is both
|
|
36
|
+
// cheap and stable. Still deliberately NOT auto-refreshing: a scan costs
|
|
37
|
+
// a network round-trip / CLI spawn per provider and made initial load
|
|
38
|
+
// very slow. Wire `refreshProvider(id)` to an explicit "refresh models"
|
|
39
|
+
// affordance for when a provider's models have actually changed.
|
|
40
|
+
//
|
|
41
|
+
// A provider with no models has genuinely never been scanned
|
|
42
|
+
// successfully (check its modelsRefreshedUnixMs === 0), and falls back to
|
|
43
|
+
// a single "provider id as model" row below so it stays selectable.
|
|
44
|
+
if (generationRef.current !== generation)
|
|
45
|
+
return;
|
|
46
|
+
const models = await client.listCatalogModels();
|
|
47
|
+
if (generationRef.current !== generation)
|
|
48
|
+
return;
|
|
49
|
+
setOptions(chatModelOptionsFromCatalog(providers, models));
|
|
50
|
+
}
|
|
51
|
+
catch (err) {
|
|
52
|
+
if (generationRef.current !== generation)
|
|
53
|
+
return;
|
|
54
|
+
setError(err instanceof Error ? err : new Error(String(err)));
|
|
55
|
+
}
|
|
56
|
+
finally {
|
|
57
|
+
if (generationRef.current === generation)
|
|
58
|
+
setLoading(false);
|
|
59
|
+
}
|
|
60
|
+
})();
|
|
61
|
+
}, [client]);
|
|
62
|
+
useEffect(() => {
|
|
63
|
+
refresh();
|
|
64
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps -- refresh already depends on client
|
|
65
|
+
}, [client]);
|
|
66
|
+
const refreshProvider = useCallback(async (providerId) => {
|
|
67
|
+
if (!client)
|
|
68
|
+
return;
|
|
69
|
+
const generation = generationRef.current;
|
|
70
|
+
try {
|
|
71
|
+
await client.refreshProviderModels(providerId);
|
|
72
|
+
if (generationRef.current !== generation)
|
|
73
|
+
return;
|
|
74
|
+
const [providers, models] = await Promise.all([
|
|
75
|
+
client.listProviders(),
|
|
76
|
+
client.listCatalogModels(),
|
|
77
|
+
]);
|
|
78
|
+
if (generationRef.current !== generation)
|
|
79
|
+
return;
|
|
80
|
+
setOptions(chatModelOptionsFromCatalog(providers, models));
|
|
81
|
+
}
|
|
82
|
+
catch (err) {
|
|
83
|
+
if (generationRef.current !== generation)
|
|
84
|
+
return;
|
|
85
|
+
setError(err instanceof Error ? err : new Error(String(err)));
|
|
86
|
+
}
|
|
87
|
+
}, [client]);
|
|
88
|
+
return { options, loading, error, refresh, refreshProvider };
|
|
89
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { LlmdClient } from '@pyxis-llm/client';
|
|
2
|
+
export type LlmdSessionModelSelection = {
|
|
3
|
+
providerId: string;
|
|
4
|
+
modelId: string;
|
|
5
|
+
};
|
|
6
|
+
export type LlmdSessionModel = {
|
|
7
|
+
/** The session's provider + model; null until loaded or when none is set. */
|
|
8
|
+
selected: LlmdSessionModelSelection | null;
|
|
9
|
+
/** True while the session's current selection is being read. */
|
|
10
|
+
loading: boolean;
|
|
11
|
+
/** Last load/select failure. */
|
|
12
|
+
error: Error | null;
|
|
13
|
+
/**
|
|
14
|
+
* Persists a new provider + model on the session. Optimistic: `selected`
|
|
15
|
+
* changes at once and reverts (with `error` set) if llmd rejects it. Pass
|
|
16
|
+
* straight to CatalogModelPicker's `onSelect`.
|
|
17
|
+
*/
|
|
18
|
+
select: (providerId: string, modelId: string) => Promise<void>;
|
|
19
|
+
};
|
|
20
|
+
type SessionModelClient = Pick<LlmdClient, 'getSessionModel' | 'setSessionModel'>;
|
|
21
|
+
/**
|
|
22
|
+
* Reads and sets the provider/model of `client`'s session. Wire to the picker:
|
|
23
|
+
*
|
|
24
|
+
* const model = useLlmdSessionModel(client)
|
|
25
|
+
* <CatalogModelPicker
|
|
26
|
+
* selectedProviderId={model.selected?.providerId ?? null}
|
|
27
|
+
* selectedModelId={model.selected?.modelId ?? null}
|
|
28
|
+
* onSelect={model.select} … />
|
|
29
|
+
*
|
|
30
|
+
* `client` may be null/undefined while a host is still connecting.
|
|
31
|
+
*/
|
|
32
|
+
export declare function useLlmdSessionModel(client: SessionModelClient | null | undefined): LlmdSessionModel;
|
|
33
|
+
export {};
|
|
34
|
+
//# sourceMappingURL=useLlmdSessionModel.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useLlmdSessionModel.d.ts","sourceRoot":"","sources":["../src/useLlmdSessionModel.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAEpD,MAAM,MAAM,yBAAyB,GAAG;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC;AAEhF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,6EAA6E;IAC7E,QAAQ,EAAE,yBAAyB,GAAG,IAAI,CAAC;IAC3C,gEAAgE;IAChE,OAAO,EAAE,OAAO,CAAC;IACjB,gCAAgC;IAChC,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IACpB;;;;OAIG;IACH,MAAM,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CAChE,CAAC;AAEF,KAAK,kBAAkB,GAAG,IAAI,CAAC,UAAU,EAAE,iBAAiB,GAAG,iBAAiB,CAAC,CAAC;AAElF;;;;;;;;;;GAUG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,kBAAkB,GAAG,IAAI,GAAG,SAAS,GAC5C,gBAAgB,CAkDlB"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2026 John Ewart <john@johnewart.net>
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*
|
|
5
|
+
* Binds CatalogModelPicker to a session's model. Lives beside
|
|
6
|
+
* useLlmdModelCatalog (browser/node entries, not the main one) because it
|
|
7
|
+
* takes an @pyxis-llm/client LlmdClient.
|
|
8
|
+
*
|
|
9
|
+
* Why this exists: a chat turn only carries a model NAME; the provider is
|
|
10
|
+
* session state (UpdateSessionLlm). A picker that only keeps its selection in
|
|
11
|
+
* host state looks right but leaves the session's provider unset, and every
|
|
12
|
+
* send then fails with `unknown or unavailable llm provider ""`.
|
|
13
|
+
*/
|
|
14
|
+
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
15
|
+
/**
|
|
16
|
+
* Reads and sets the provider/model of `client`'s session. Wire to the picker:
|
|
17
|
+
*
|
|
18
|
+
* const model = useLlmdSessionModel(client)
|
|
19
|
+
* <CatalogModelPicker
|
|
20
|
+
* selectedProviderId={model.selected?.providerId ?? null}
|
|
21
|
+
* selectedModelId={model.selected?.modelId ?? null}
|
|
22
|
+
* onSelect={model.select} … />
|
|
23
|
+
*
|
|
24
|
+
* `client` may be null/undefined while a host is still connecting.
|
|
25
|
+
*/
|
|
26
|
+
export function useLlmdSessionModel(client) {
|
|
27
|
+
const [selected, setSelected] = useState(null);
|
|
28
|
+
const [loading, setLoading] = useState(false);
|
|
29
|
+
const [error, setError] = useState(null);
|
|
30
|
+
// Bumped per client and per select, so a slow load cannot overwrite a newer
|
|
31
|
+
// selection, and a stale select cannot revert one made after it.
|
|
32
|
+
const generationRef = useRef(0);
|
|
33
|
+
const selectedRef = useRef(selected);
|
|
34
|
+
selectedRef.current = selected;
|
|
35
|
+
useEffect(() => {
|
|
36
|
+
const generation = ++generationRef.current;
|
|
37
|
+
setSelected(null);
|
|
38
|
+
setError(null);
|
|
39
|
+
if (!client)
|
|
40
|
+
return;
|
|
41
|
+
setLoading(true);
|
|
42
|
+
void (async () => {
|
|
43
|
+
try {
|
|
44
|
+
const cur = await client.getSessionModel();
|
|
45
|
+
if (generationRef.current !== generation)
|
|
46
|
+
return;
|
|
47
|
+
setSelected(cur.providerId && cur.modelId ? cur : null);
|
|
48
|
+
}
|
|
49
|
+
catch (err) {
|
|
50
|
+
if (generationRef.current !== generation)
|
|
51
|
+
return;
|
|
52
|
+
setError(err instanceof Error ? err : new Error(String(err)));
|
|
53
|
+
}
|
|
54
|
+
finally {
|
|
55
|
+
if (generationRef.current === generation)
|
|
56
|
+
setLoading(false);
|
|
57
|
+
}
|
|
58
|
+
})();
|
|
59
|
+
}, [client]);
|
|
60
|
+
const select = useCallback(async (providerId, modelId) => {
|
|
61
|
+
if (!client)
|
|
62
|
+
return;
|
|
63
|
+
const generation = ++generationRef.current;
|
|
64
|
+
const previous = selectedRef.current;
|
|
65
|
+
setSelected({ providerId, modelId });
|
|
66
|
+
setError(null);
|
|
67
|
+
setLoading(false);
|
|
68
|
+
try {
|
|
69
|
+
await client.setSessionModel(providerId, modelId);
|
|
70
|
+
}
|
|
71
|
+
catch (err) {
|
|
72
|
+
if (generationRef.current !== generation)
|
|
73
|
+
return;
|
|
74
|
+
setSelected(previous);
|
|
75
|
+
setError(err instanceof Error ? err : new Error(String(err)));
|
|
76
|
+
}
|
|
77
|
+
}, [client]);
|
|
78
|
+
return { selected, loading, error, select };
|
|
79
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { LlmdClient, LlmProviderType, ProviderAuthCommandStartOptions } from '@pyxis-llm/client';
|
|
2
|
+
export type ProviderAuthCommandState = {
|
|
3
|
+
/** Accumulated PTY output, decoded as UTF-8 text (best-effort across chunk boundaries). */
|
|
4
|
+
output: string;
|
|
5
|
+
running: boolean;
|
|
6
|
+
exitCode: number | null;
|
|
7
|
+
error: Error | null;
|
|
8
|
+
start: (providerType: LlmProviderType, options?: ProviderAuthCommandStartOptions) => void;
|
|
9
|
+
/** Sends keystrokes to the running command's stdin. */
|
|
10
|
+
write: (data: string) => void;
|
|
11
|
+
resize: (cols: number, rows: number) => void;
|
|
12
|
+
/** Closes the client's send side; the command keeps streaming output until it exits. */
|
|
13
|
+
end: () => void;
|
|
14
|
+
/** Aborts immediately, tearing down the underlying gRPC call. */
|
|
15
|
+
cancel: () => void;
|
|
16
|
+
/** Clears output/exitCode/error without starting a new run. */
|
|
17
|
+
reset: () => void;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Drives an interactive provider auth command (e.g. `claude login`) via
|
|
21
|
+
* `client.runProviderAuthCommand`. `client` may be `null`/`undefined` while
|
|
22
|
+
* a host is still setting up its connection — `start` is a no-op until it's
|
|
23
|
+
* provided.
|
|
24
|
+
*/
|
|
25
|
+
export declare function useProviderAuthCommand(client: LlmdClient | null | undefined): ProviderAuthCommandState;
|
|
26
|
+
//# sourceMappingURL=useProviderAuthCommand.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useProviderAuthCommand.d.ts","sourceRoot":"","sources":["../src/useProviderAuthCommand.ts"],"names":[],"mappings":"AAoBA,OAAO,KAAK,EACV,UAAU,EACV,eAAe,EAEf,+BAA+B,EAChC,MAAM,mBAAmB,CAAC;AAE3B,MAAM,MAAM,wBAAwB,GAAG;IACrC,2FAA2F;IAC3F,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IACpB,KAAK,EAAE,CAAC,YAAY,EAAE,eAAe,EAAE,OAAO,CAAC,EAAE,+BAA+B,KAAK,IAAI,CAAC;IAC1F,uDAAuD;IACvD,KAAK,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAC9B,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAC7C,wFAAwF;IACxF,GAAG,EAAE,MAAM,IAAI,CAAC;IAChB,iEAAiE;IACjE,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB,+DAA+D;IAC/D,KAAK,EAAE,MAAM,IAAI,CAAC;CACnB,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,UAAU,GAAG,IAAI,GAAG,SAAS,GACpC,wBAAwB,CA+D1B"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2026 John Ewart <john@johnewart.net>
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*
|
|
5
|
+
* Node-capable hook driving llmd's RunProviderAuthCommand RPC (see
|
|
6
|
+
* ./node.js). Runs an interactive CLI auth command (e.g. `claude login`) in
|
|
7
|
+
* a server-side PTY, streamed over gRPC via @pyxis-llm/client's
|
|
8
|
+
* ProviderAuthCommandSession — useful when the CLI is only reachable on the
|
|
9
|
+
* machine running llmd (a remote/server deployment), not the operator's own
|
|
10
|
+
* machine. Lives here (not the main entry) for the same reason
|
|
11
|
+
* useLlmdChatDriver does: @pyxis-llm/client pulls in @grpc/grpc-js.
|
|
12
|
+
*
|
|
13
|
+
* Pairs with ProviderAuthTerminal (in the main entry) for a minimal
|
|
14
|
+
* terminal UI; hosts wanting full xterm.js fidelity (cursor movement, ANSI
|
|
15
|
+
* color, resize-aware reflow) can wire their own xterm.js instance to
|
|
16
|
+
* `write`/`resize` here instead — this hook's job is state management, not
|
|
17
|
+
* terminal rendering.
|
|
18
|
+
*/
|
|
19
|
+
import { useCallback, useRef, useState } from 'react';
|
|
20
|
+
/**
|
|
21
|
+
* Drives an interactive provider auth command (e.g. `claude login`) via
|
|
22
|
+
* `client.runProviderAuthCommand`. `client` may be `null`/`undefined` while
|
|
23
|
+
* a host is still setting up its connection — `start` is a no-op until it's
|
|
24
|
+
* provided.
|
|
25
|
+
*/
|
|
26
|
+
export function useProviderAuthCommand(client) {
|
|
27
|
+
const [output, setOutput] = useState('');
|
|
28
|
+
const [running, setRunning] = useState(false);
|
|
29
|
+
const [exitCode, setExitCode] = useState(null);
|
|
30
|
+
const [error, setError] = useState(null);
|
|
31
|
+
const sessionRef = useRef(null);
|
|
32
|
+
const decoderRef = useRef(new TextDecoder());
|
|
33
|
+
const reset = useCallback(() => {
|
|
34
|
+
setOutput('');
|
|
35
|
+
setExitCode(null);
|
|
36
|
+
setError(null);
|
|
37
|
+
}, []);
|
|
38
|
+
const start = useCallback((providerType, options) => {
|
|
39
|
+
if (!client || running)
|
|
40
|
+
return;
|
|
41
|
+
reset();
|
|
42
|
+
setRunning(true);
|
|
43
|
+
decoderRef.current = new TextDecoder();
|
|
44
|
+
const session = client.runProviderAuthCommand(providerType, options);
|
|
45
|
+
sessionRef.current = session;
|
|
46
|
+
void (async () => {
|
|
47
|
+
try {
|
|
48
|
+
for await (const ev of session) {
|
|
49
|
+
if (ev.kind === 'output') {
|
|
50
|
+
const text = decoderRef.current.decode(ev.data, { stream: true });
|
|
51
|
+
setOutput((prev) => prev + text);
|
|
52
|
+
}
|
|
53
|
+
else if (ev.kind === 'exit') {
|
|
54
|
+
setExitCode(ev.code);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
catch (err) {
|
|
59
|
+
setError(err instanceof Error ? err : new Error(String(err)));
|
|
60
|
+
}
|
|
61
|
+
finally {
|
|
62
|
+
setRunning(false);
|
|
63
|
+
sessionRef.current = null;
|
|
64
|
+
}
|
|
65
|
+
})();
|
|
66
|
+
}, [client, running, reset]);
|
|
67
|
+
const write = useCallback((data) => {
|
|
68
|
+
sessionRef.current?.write(data);
|
|
69
|
+
}, []);
|
|
70
|
+
const resize = useCallback((cols, rows) => {
|
|
71
|
+
sessionRef.current?.resize(cols, rows);
|
|
72
|
+
}, []);
|
|
73
|
+
const end = useCallback(() => {
|
|
74
|
+
sessionRef.current?.end();
|
|
75
|
+
}, []);
|
|
76
|
+
const cancel = useCallback(() => {
|
|
77
|
+
sessionRef.current?.cancel();
|
|
78
|
+
}, []);
|
|
79
|
+
return { output, running, exitCode, error, start, write, resize, end, cancel, reset };
|
|
80
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
export type VegaMode = 'vega-lite' | 'vega';
|
|
2
|
+
export type RenderVegaOptions = {
|
|
3
|
+
mode: VegaMode;
|
|
4
|
+
isDark: boolean;
|
|
5
|
+
/** Base name for exported SVG/PNG files. */
|
|
6
|
+
downloadFileName?: string;
|
|
7
|
+
/**
|
|
8
|
+
* CSS font-family for every chart label. Default: the page body's computed
|
|
9
|
+
* font (the host app's UI font, including a user-chosen one).
|
|
10
|
+
*/
|
|
11
|
+
fontFamily?: string;
|
|
12
|
+
/** Multiplier for every text size in the chart (the card's A−/A+). Default 1. */
|
|
13
|
+
fontScale?: number;
|
|
14
|
+
/**
|
|
15
|
+
* Host-supplied loader for DATA loads (`data.url`) only. Omitted: every
|
|
16
|
+
* load is refused. Image marks and link hrefs stay refused either way.
|
|
17
|
+
*/
|
|
18
|
+
loader?: VegaDataLoader;
|
|
19
|
+
};
|
|
20
|
+
/** Returns the text of a data url, or throws to refuse it. */
|
|
21
|
+
export type VegaDataLoader = (url: string) => Promise<string>;
|
|
22
|
+
/**
|
|
23
|
+
* The font charts use: `explicit`, else the page body's computed font. Vega
|
|
24
|
+
* draws labels as SVG text with their own font attribute, so the CSS font of
|
|
25
|
+
* the container (which may be a monospace code-block style) never applies;
|
|
26
|
+
* the body is the app's UI font.
|
|
27
|
+
*/
|
|
28
|
+
export declare function resolveChartFont(explicit?: string): string;
|
|
29
|
+
/**
|
|
30
|
+
* Every config slot Vega / Vega-Lite reads a font from, set to `font`, with
|
|
31
|
+
* the default text sizes multiplied by `scale`.
|
|
32
|
+
*/
|
|
33
|
+
export declare function chartFontConfig(font: string, scale?: number): Record<string, unknown>;
|
|
34
|
+
/**
|
|
35
|
+
* `problems`: things the user should know about a chart that DID render —
|
|
36
|
+
* chiefly a blocked external load, which Vega only logs (as a warning) and
|
|
37
|
+
* then draws the chart with no data.
|
|
38
|
+
*/
|
|
39
|
+
export type RenderVegaResult = {
|
|
40
|
+
finalize: () => void;
|
|
41
|
+
problems: string[];
|
|
42
|
+
} | {
|
|
43
|
+
error: string;
|
|
44
|
+
};
|
|
45
|
+
export declare const VEGA_EXTERNAL_RESOURCE_ERROR = "Charts in chat cannot load external resources. Put the data inline under \"data\": {\"values\": [...]}.";
|
|
46
|
+
/**
|
|
47
|
+
* A deep copy of `spec` that is safe to hand to vega-embed: spec-supplied
|
|
48
|
+
* embed options removed, and a single-view Vega-Lite chart with no explicit
|
|
49
|
+
* width sized to its container (chat bubbles vary in width). Never mutates
|
|
50
|
+
* the input.
|
|
51
|
+
*/
|
|
52
|
+
export declare function prepareVegaSpec(spec: Record<string, unknown>, mode: VegaMode, fontScale?: number): Record<string, unknown>;
|
|
53
|
+
/**
|
|
54
|
+
* vega-tooltip's default formatter minus the `image` special case: every
|
|
55
|
+
* field renders as escaped text through `valueToHtml` (vega-tooltip's HTML
|
|
56
|
+
* escaper), so a tooltip never fetches anything.
|
|
57
|
+
*/
|
|
58
|
+
export declare function formatTooltip(value: unknown, valueToHtml: (value: unknown) => string, _maxDepth?: number, _baseURL?: string): string;
|
|
59
|
+
export type RenderVegaSvgOptions = {
|
|
60
|
+
mode: VegaMode;
|
|
61
|
+
/** Fixed chart width replacing "container". Default 640. */
|
|
62
|
+
width?: number;
|
|
63
|
+
fontFamily?: string;
|
|
64
|
+
};
|
|
65
|
+
export type RenderVegaSvgResult = {
|
|
66
|
+
svg: string;
|
|
67
|
+
problems: string[];
|
|
68
|
+
} | {
|
|
69
|
+
error: string;
|
|
70
|
+
};
|
|
71
|
+
/**
|
|
72
|
+
* Render `spec` to a static SVG string (light theme) under the same lockdown
|
|
73
|
+
* as renderVegaChart. Never throws.
|
|
74
|
+
*/
|
|
75
|
+
export declare function renderVegaSvg(spec: Record<string, unknown>, options: RenderVegaSvgOptions): Promise<RenderVegaSvgResult>;
|
|
76
|
+
/**
|
|
77
|
+
* Render `spec` into `el` (whose children vega-embed owns from here on).
|
|
78
|
+
* Never throws: failures come back as `{ error }` with `el` cleared.
|
|
79
|
+
*/
|
|
80
|
+
export declare function renderVegaChart(el: HTMLElement, spec: Record<string, unknown>, options: RenderVegaOptions): Promise<RenderVegaResult>;
|
|
81
|
+
/** Drop the cached vega-embed import (tests / hot reload). */
|
|
82
|
+
export declare function resetVegaRuntimeForTests(): void;
|
|
83
|
+
//# sourceMappingURL=vegaRuntime.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vegaRuntime.d.ts","sourceRoot":"","sources":["../src/vegaRuntime.ts"],"names":[],"mappings":"AAuCA,MAAM,MAAM,QAAQ,GAAG,WAAW,GAAG,MAAM,CAAC;AAE5C,MAAM,MAAM,iBAAiB,GAAG;IAC9B,IAAI,EAAE,QAAQ,CAAC;IACf,MAAM,EAAE,OAAO,CAAC;IAChB,4CAA4C;IAC5C,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,iFAAiF;IACjF,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,MAAM,CAAC,EAAE,cAAc,CAAC;CACzB,CAAC;AAEF,8DAA8D;AAC9D,MAAM,MAAM,cAAc,GAAG,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;AA6B9D;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAQ1D;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,SAAI,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAYhF;AAaD;;;;GAIG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAAE,QAAQ,EAAE,MAAM,IAAI,CAAC;IAAC,QAAQ,EAAE,MAAM,EAAE,CAAA;CAAE,GAAG;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAEhG,eAAO,MAAM,4BAA4B,4GAC8D,CAAC;AA0DxG;;;;;GAKG;AACH,wBAAgB,eAAe,CAC7B,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,IAAI,EAAE,QAAQ,EACd,SAAS,SAAI,GACZ,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAwBzB;AAUD;;;;GAIG;AACH,wBAAgB,aAAa,CAC3B,KAAK,EAAE,OAAO,EACd,WAAW,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,MAAM,EACvC,SAAS,CAAC,EAAE,MAAM,EAClB,QAAQ,CAAC,EAAE,MAAM,GAChB,MAAM,CAsBR;AA4DD,MAAM,MAAM,oBAAoB,GAAG;IACjC,IAAI,EAAE,QAAQ,CAAC;IACf,4DAA4D;IAC5D,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,EAAE,CAAA;CAAE,GAAG;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAE1F;;;GAGG;AACH,wBAAsB,aAAa,CACjC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,OAAO,EAAE,oBAAoB,GAC5B,OAAO,CAAC,mBAAmB,CAAC,CA2B9B;AAED;;;GAGG;AACH,wBAAsB,eAAe,CACnC,EAAE,EAAE,WAAW,EACf,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,OAAO,EAAE,iBAAiB,GACzB,OAAO,CAAC,gBAAgB,CAAC,CAkB3B;AAED,8DAA8D;AAC9D,wBAAgB,wBAAwB,IAAI,IAAI,CAE/C"}
|