@pyxis-llm/react 0.0.0-stage → 0.5.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (192) hide show
  1. package/dist/AgentProfileEditor.d.ts +48 -0
  2. package/dist/AgentProfileEditor.d.ts.map +1 -0
  3. package/dist/AgentProfileEditor.js +122 -0
  4. package/dist/AgentProfileList.d.ts +17 -0
  5. package/dist/AgentProfileList.d.ts.map +1 -0
  6. package/dist/AgentProfileList.js +46 -0
  7. package/dist/AskCardAnswerChip.d.ts +8 -0
  8. package/dist/AskCardAnswerChip.d.ts.map +1 -0
  9. package/dist/AskCardAnswerChip.js +21 -0
  10. package/dist/AskCardView.d.ts +85 -0
  11. package/dist/AskCardView.d.ts.map +1 -0
  12. package/dist/AskCardView.js +158 -0
  13. package/dist/CatalogColumnBrowser.d.ts +33 -0
  14. package/dist/CatalogColumnBrowser.d.ts.map +1 -0
  15. package/dist/CatalogColumnBrowser.js +219 -0
  16. package/dist/CatalogModelPicker.d.ts +68 -0
  17. package/dist/CatalogModelPicker.d.ts.map +1 -0
  18. package/dist/CatalogModelPicker.js +119 -0
  19. package/dist/CatalogModelPickerMenuContent.d.ts +17 -0
  20. package/dist/CatalogModelPickerMenuContent.d.ts.map +1 -0
  21. package/dist/CatalogModelPickerMenuContent.js +103 -0
  22. package/dist/CatalogPickerMenuItem.d.ts +17 -0
  23. package/dist/CatalogPickerMenuItem.d.ts.map +1 -0
  24. package/dist/CatalogPickerMenuItem.js +15 -0
  25. package/dist/CatalogTreePickerOptions.d.ts +52 -0
  26. package/dist/CatalogTreePickerOptions.d.ts.map +1 -0
  27. package/dist/CatalogTreePickerOptions.js +248 -0
  28. package/dist/ChatMessage.d.ts +172 -0
  29. package/dist/ChatMessage.d.ts.map +1 -0
  30. package/dist/ChatMessage.js +295 -0
  31. package/dist/ChatPanel.d.ts +252 -0
  32. package/dist/ChatPanel.d.ts.map +1 -0
  33. package/dist/ChatPanel.js +247 -0
  34. package/dist/ChatTranscriptFind.d.ts +19 -0
  35. package/dist/ChatTranscriptFind.d.ts.map +1 -0
  36. package/dist/ChatTranscriptFind.js +224 -0
  37. package/dist/ChatTranscriptFindBar.d.ts +15 -0
  38. package/dist/ChatTranscriptFindBar.d.ts.map +1 -0
  39. package/dist/ChatTranscriptFindBar.js +22 -0
  40. package/dist/Composer.d.ts +43 -0
  41. package/dist/Composer.d.ts.map +1 -0
  42. package/dist/Composer.js +45 -0
  43. package/dist/ComposerAttachments.d.ts +101 -0
  44. package/dist/ComposerAttachments.d.ts.map +1 -0
  45. package/dist/ComposerAttachments.js +126 -0
  46. package/dist/DisplayCards.d.ts +18 -0
  47. package/dist/DisplayCards.d.ts.map +1 -0
  48. package/dist/DisplayCards.js +72 -0
  49. package/dist/ErrorBoundary.d.ts +27 -0
  50. package/dist/ErrorBoundary.d.ts.map +1 -0
  51. package/dist/ErrorBoundary.js +107 -0
  52. package/dist/ImageDisplayCard.d.ts +6 -0
  53. package/dist/ImageDisplayCard.d.ts.map +1 -0
  54. package/dist/ImageDisplayCard.js +57 -0
  55. package/dist/MarkdownCodeComponents.d.ts +23 -0
  56. package/dist/MarkdownCodeComponents.d.ts.map +1 -0
  57. package/dist/MarkdownCodeComponents.js +256 -0
  58. package/dist/MermaidDiagram.d.ts +18 -0
  59. package/dist/MermaidDiagram.d.ts.map +1 -0
  60. package/dist/MermaidDiagram.js +66 -0
  61. package/dist/MessageContentWithPastes.d.ts +14 -0
  62. package/dist/MessageContentWithPastes.d.ts.map +1 -0
  63. package/dist/MessageContentWithPastes.js +44 -0
  64. package/dist/PastePill.d.ts +16 -0
  65. package/dist/PastePill.d.ts.map +1 -0
  66. package/dist/PastePill.js +43 -0
  67. package/dist/ProviderAuthTerminal.d.ts +12 -0
  68. package/dist/ProviderAuthTerminal.d.ts.map +1 -0
  69. package/dist/ProviderAuthTerminal.js +50 -0
  70. package/dist/ProviderConnectForm.d.ts +62 -0
  71. package/dist/ProviderConnectForm.d.ts.map +1 -0
  72. package/dist/ProviderConnectForm.js +206 -0
  73. package/dist/ProviderList.d.ts +18 -0
  74. package/dist/ProviderList.d.ts.map +1 -0
  75. package/dist/ProviderList.js +67 -0
  76. package/dist/QueueStrip.d.ts +17 -0
  77. package/dist/QueueStrip.d.ts.map +1 -0
  78. package/dist/QueueStrip.js +60 -0
  79. package/dist/SettingsScreen.d.ts +10 -0
  80. package/dist/SettingsScreen.d.ts.map +1 -0
  81. package/dist/SettingsScreen.js +26 -0
  82. package/dist/StreamingMarkdown.d.ts +47 -0
  83. package/dist/StreamingMarkdown.d.ts.map +1 -0
  84. package/dist/StreamingMarkdown.js +103 -0
  85. package/dist/TurnTimer.d.ts +72 -0
  86. package/dist/TurnTimer.d.ts.map +1 -0
  87. package/dist/TurnTimer.js +114 -0
  88. package/dist/VegaChart.d.ts +36 -0
  89. package/dist/VegaChart.d.ts.map +1 -0
  90. package/dist/VegaChart.js +180 -0
  91. package/dist/browser.d.ts +7 -0
  92. package/dist/browser.d.ts.map +1 -0
  93. package/dist/browser.js +18 -0
  94. package/dist/catalogColumnBrowserTree.d.ts +9 -0
  95. package/dist/catalogColumnBrowserTree.d.ts.map +1 -0
  96. package/dist/catalogColumnBrowserTree.js +48 -0
  97. package/dist/catalogPickerMenuStyles.d.ts +81 -0
  98. package/dist/catalogPickerMenuStyles.d.ts.map +1 -0
  99. package/dist/catalogPickerMenuStyles.js +130 -0
  100. package/dist/charts.d.ts +12 -0
  101. package/dist/charts.d.ts.map +1 -0
  102. package/dist/charts.js +45 -0
  103. package/dist/chatMessageScroll.d.ts +40 -0
  104. package/dist/chatMessageScroll.d.ts.map +1 -0
  105. package/dist/chatMessageScroll.js +62 -0
  106. package/dist/chatModelOptions.d.ts +28 -0
  107. package/dist/chatModelOptions.d.ts.map +1 -0
  108. package/dist/chatModelOptions.js +59 -0
  109. package/dist/chatTranscriptFindHighlights.d.ts +9 -0
  110. package/dist/chatTranscriptFindHighlights.d.ts.map +1 -0
  111. package/dist/chatTranscriptFindHighlights.js +88 -0
  112. package/dist/draftStore.d.ts +13 -0
  113. package/dist/draftStore.d.ts.map +1 -0
  114. package/dist/draftStore.js +38 -0
  115. package/dist/highlight.d.ts +4 -0
  116. package/dist/highlight.d.ts.map +1 -0
  117. package/dist/highlight.js +47 -0
  118. package/dist/index.d.ts +74 -0
  119. package/dist/index.d.ts.map +1 -0
  120. package/dist/index.js +48 -0
  121. package/dist/keyboardShortcuts.d.ts +5 -0
  122. package/dist/keyboardShortcuts.d.ts.map +1 -0
  123. package/dist/keyboardShortcuts.js +19 -0
  124. package/dist/markdownClipboard.d.ts +22 -0
  125. package/dist/markdownClipboard.d.ts.map +1 -0
  126. package/dist/markdownClipboard.js +98 -0
  127. package/dist/markdownPlugins.d.ts +31 -0
  128. package/dist/markdownPlugins.d.ts.map +1 -0
  129. package/dist/markdownPlugins.js +32 -0
  130. package/dist/mermaid.d.ts +17 -0
  131. package/dist/mermaid.d.ts.map +1 -0
  132. package/dist/mermaid.js +11 -0
  133. package/dist/mermaidRuntime.d.ts +21 -0
  134. package/dist/mermaidRuntime.d.ts.map +1 -0
  135. package/dist/mermaidRuntime.js +140 -0
  136. package/dist/modelCatalogHelpers.d.ts +14 -0
  137. package/dist/modelCatalogHelpers.d.ts.map +1 -0
  138. package/dist/modelCatalogHelpers.js +65 -0
  139. package/dist/modelCatalogSource.d.ts +22 -0
  140. package/dist/modelCatalogSource.d.ts.map +1 -0
  141. package/dist/modelCatalogSource.js +26 -0
  142. package/dist/modelCatalogTree.d.ts +24 -0
  143. package/dist/modelCatalogTree.d.ts.map +1 -0
  144. package/dist/modelCatalogTree.js +77 -0
  145. package/dist/node.d.ts +9 -0
  146. package/dist/node.d.ts.map +1 -0
  147. package/dist/node.js +13 -0
  148. package/dist/pasteFences.d.ts +20 -0
  149. package/dist/pasteFences.d.ts.map +1 -0
  150. package/dist/pasteFences.js +157 -0
  151. package/dist/pasteFormat.d.ts +5 -0
  152. package/dist/pasteFormat.d.ts.map +1 -0
  153. package/dist/pasteFormat.js +18 -0
  154. package/dist/plugins.d.ts +110 -0
  155. package/dist/plugins.d.ts.map +1 -0
  156. package/dist/plugins.js +98 -0
  157. package/dist/remarkAlerts.d.ts +12 -0
  158. package/dist/remarkAlerts.d.ts.map +1 -0
  159. package/dist/remarkAlerts.js +52 -0
  160. package/dist/sendMode.d.ts +69 -0
  161. package/dist/sendMode.d.ts.map +1 -0
  162. package/dist/sendMode.js +66 -0
  163. package/dist/useLlmdChatDriver.d.ts +367 -0
  164. package/dist/useLlmdChatDriver.d.ts.map +1 -0
  165. package/dist/useLlmdChatDriver.js +1739 -0
  166. package/dist/useLlmdModelCatalog.d.ts +23 -0
  167. package/dist/useLlmdModelCatalog.d.ts.map +1 -0
  168. package/dist/useLlmdModelCatalog.js +89 -0
  169. package/dist/useLlmdSessionModel.d.ts +34 -0
  170. package/dist/useLlmdSessionModel.d.ts.map +1 -0
  171. package/dist/useLlmdSessionModel.js +79 -0
  172. package/dist/useProviderAuthCommand.d.ts +26 -0
  173. package/dist/useProviderAuthCommand.d.ts.map +1 -0
  174. package/dist/useProviderAuthCommand.js +80 -0
  175. package/dist/vegaRuntime.d.ts +83 -0
  176. package/dist/vegaRuntime.d.ts.map +1 -0
  177. package/dist/vegaRuntime.js +314 -0
  178. package/dist/vendor/llmd-types/conversationEvents.d.ts +238 -0
  179. package/dist/vendor/llmd-types/conversationEvents.d.ts.map +1 -0
  180. package/dist/vendor/llmd-types/conversationEvents.js +98 -0
  181. package/dist/vendor/llmd-types/index.d.ts +4 -0
  182. package/dist/vendor/llmd-types/index.d.ts.map +1 -0
  183. package/dist/vendor/llmd-types/index.js +5 -0
  184. package/dist/vendor/llmd-types/messages.d.ts +67 -0
  185. package/dist/vendor/llmd-types/messages.d.ts.map +1 -0
  186. package/dist/vendor/llmd-types/messages.js +71 -0
  187. package/dist/vendor/llmd-types/sessionQueue.d.ts +54 -0
  188. package/dist/vendor/llmd-types/sessionQueue.d.ts.map +1 -0
  189. package/dist/vendor/llmd-types/sessionQueue.js +40 -0
  190. package/package.json +120 -4
  191. package/styles.css +389 -0
  192. package/README.md +0 -3
@@ -0,0 +1,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"}