@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,65 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2026 John Ewart <john@johnewart.net>
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*
|
|
5
|
+
* Generic helpers for resolving/validating a provider+model pair against a
|
|
6
|
+
* catalog. Deliberately does NOT include layered resolution (session
|
|
7
|
+
* override > agent default > workspace default > catalog fallback, etc.) —
|
|
8
|
+
* that's product-specific policy a host builds on top of these primitives.
|
|
9
|
+
*/
|
|
10
|
+
export function modelOptionExists(options, providerId, modelId) {
|
|
11
|
+
return options.some((o) => o.providerId === providerId && o.modelId === modelId);
|
|
12
|
+
}
|
|
13
|
+
function normalizeModelToken(value) {
|
|
14
|
+
return value.trim().toLowerCase();
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Map a persisted provider+model to the current catalog row when possible
|
|
18
|
+
* (case drift, or a path-shaped id like "org/model" vs. just "model").
|
|
19
|
+
* Returns null when no catalog row matches; callers keep the persisted ids as-is.
|
|
20
|
+
*/
|
|
21
|
+
export function resolveCanonicalModelOption(options, stored) {
|
|
22
|
+
if (options.length === 0)
|
|
23
|
+
return null;
|
|
24
|
+
const pid = stored.providerId.trim();
|
|
25
|
+
const mid = stored.modelId.trim();
|
|
26
|
+
if (!pid || !mid)
|
|
27
|
+
return null;
|
|
28
|
+
const exact = options.find((o) => o.providerId === pid && o.modelId === mid);
|
|
29
|
+
if (exact) {
|
|
30
|
+
return { providerId: exact.providerId, modelId: exact.modelId };
|
|
31
|
+
}
|
|
32
|
+
const pidLower = normalizeModelToken(pid);
|
|
33
|
+
const midNorm = normalizeModelToken(mid);
|
|
34
|
+
const caseInsensitive = options.find((o) => normalizeModelToken(o.providerId) === pidLower &&
|
|
35
|
+
normalizeModelToken(o.modelId) === midNorm);
|
|
36
|
+
if (caseInsensitive) {
|
|
37
|
+
return {
|
|
38
|
+
providerId: caseInsensitive.providerId,
|
|
39
|
+
modelId: caseInsensitive.modelId,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
const midBase = mid.split(/[/\\]/).pop()?.trim() ?? mid;
|
|
43
|
+
const baseNorm = normalizeModelToken(midBase);
|
|
44
|
+
const baseMatch = options.find((o) => {
|
|
45
|
+
if (normalizeModelToken(o.providerId) !== pidLower)
|
|
46
|
+
return false;
|
|
47
|
+
return (normalizeModelToken(o.modelId) === baseNorm ||
|
|
48
|
+
normalizeModelToken(o.modelName) === baseNorm);
|
|
49
|
+
});
|
|
50
|
+
if (baseMatch) {
|
|
51
|
+
return { providerId: baseMatch.providerId, modelId: baseMatch.modelId };
|
|
52
|
+
}
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
export function formatEffectiveModelLabel(providerId, modelId, allModelOptions) {
|
|
56
|
+
if (allModelOptions.length === 0) {
|
|
57
|
+
if (providerId && modelId)
|
|
58
|
+
return `${providerId}: ${modelId}`;
|
|
59
|
+
return 'No model available';
|
|
60
|
+
}
|
|
61
|
+
if (!providerId || !modelId)
|
|
62
|
+
return 'No model available';
|
|
63
|
+
const opt = allModelOptions.find((o) => o.providerId === providerId && o.modelId === modelId);
|
|
64
|
+
return opt ? `${opt.providerName}: ${opt.modelName}` : `${providerId}: ${modelId}`;
|
|
65
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { type ChatModelOption } from './chatModelOptions.js';
|
|
2
|
+
export type LlmProviderSummaryLike = {
|
|
3
|
+
id: string;
|
|
4
|
+
type: string;
|
|
5
|
+
defaultModel: string;
|
|
6
|
+
catalogModelCount: number;
|
|
7
|
+
/**
|
|
8
|
+
* Last catalog discovery time in unix ms; 0 means never scanned. Optional so
|
|
9
|
+
* older callers still type-check. Use it to distinguish a provider that needs
|
|
10
|
+
* a one-time `refreshProvider(id)` from one that genuinely has no models.
|
|
11
|
+
*/
|
|
12
|
+
modelsRefreshedUnixMs?: number;
|
|
13
|
+
userRegistered: boolean;
|
|
14
|
+
stateful: boolean;
|
|
15
|
+
};
|
|
16
|
+
export type CatalogModelSummaryLike = {
|
|
17
|
+
providerId: string;
|
|
18
|
+
modelId: string;
|
|
19
|
+
displayName?: string;
|
|
20
|
+
};
|
|
21
|
+
export declare function chatModelOptionsFromCatalog(providers: LlmProviderSummaryLike[], models: CatalogModelSummaryLike[]): ChatModelOption[];
|
|
22
|
+
//# sourceMappingURL=modelCatalogSource.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"modelCatalogSource.d.ts","sourceRoot":"","sources":["../src/modelCatalogSource.ts"],"names":[],"mappings":"AAWA,OAAO,EAA+B,KAAK,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAE1F,MAAM,MAAM,sBAAsB,GAAG;IACnC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,MAAM,CAAC;IACrB,iBAAiB,EAAE,MAAM,CAAC;IAC1B;;;;OAIG;IACH,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,cAAc,EAAE,OAAO,CAAC;IACxB,QAAQ,EAAE,OAAO,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAAG;IACpC,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,wBAAgB,2BAA2B,CACzC,SAAS,EAAE,sBAAsB,EAAE,EACnC,MAAM,EAAE,uBAAuB,EAAE,GAChC,eAAe,EAAE,CAgBnB"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2026 John Ewart <john@johnewart.net>
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*
|
|
5
|
+
* Transport-agnostic conversion from llmd's provider/catalog RPC results
|
|
6
|
+
* (`LlmProviderSummary`/`CatalogModelSummary`, one shape shared by both of
|
|
7
|
+
* @pyxis-llm/client's transports) into `ChatModelOption[]` for the
|
|
8
|
+
* catalog picker components. Node/browser hooks (see useLlmdModelCatalog.js
|
|
9
|
+
* variants) both funnel through this.
|
|
10
|
+
*/
|
|
11
|
+
import { buildConfiguredModelOptions } from './chatModelOptions.js';
|
|
12
|
+
export function chatModelOptionsFromCatalog(providers, models) {
|
|
13
|
+
const modelsByProvider = new Map();
|
|
14
|
+
for (const m of models) {
|
|
15
|
+
const list = modelsByProvider.get(m.providerId) ?? [];
|
|
16
|
+
list.push({ id: m.modelId, name: (m.displayName ?? '').trim() || m.modelId });
|
|
17
|
+
modelsByProvider.set(m.providerId, list);
|
|
18
|
+
}
|
|
19
|
+
const rows = providers.map((p) => ({
|
|
20
|
+
id: p.id,
|
|
21
|
+
name: p.id,
|
|
22
|
+
defaultModel: p.defaultModel,
|
|
23
|
+
models: modelsByProvider.get(p.id) ?? [],
|
|
24
|
+
}));
|
|
25
|
+
return buildConfiguredModelOptions(rows);
|
|
26
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export type CatalogTreeNodeKind = 'group' | 'leaf';
|
|
2
|
+
export type CatalogTreeNode = {
|
|
3
|
+
id: string;
|
|
4
|
+
kind: CatalogTreeNodeKind;
|
|
5
|
+
label: string;
|
|
6
|
+
children?: CatalogTreeNode[];
|
|
7
|
+
/** leaf only */
|
|
8
|
+
modelId?: string;
|
|
9
|
+
};
|
|
10
|
+
export type CatalogTreeModelInput = {
|
|
11
|
+
id: string;
|
|
12
|
+
name: string;
|
|
13
|
+
};
|
|
14
|
+
export type CatalogTree = {
|
|
15
|
+
roots: CatalogTreeNode[];
|
|
16
|
+
};
|
|
17
|
+
/** Flat (ungrouped, alphabetical) catalog tree — the generic default. */
|
|
18
|
+
export declare function buildCatalogTree(models: CatalogTreeModelInput[]): CatalogTree;
|
|
19
|
+
export declare function flattenCatalogTreeLeaves(tree: CatalogTree, models?: CatalogTreeModelInput[]): CatalogTreeModelInput[];
|
|
20
|
+
export declare function catalogTreeBreadcrumb(tree: CatalogTree, modelId: string): string[] | null;
|
|
21
|
+
/** True when every root node is a selectable leaf (no grouping). */
|
|
22
|
+
export declare function catalogTreeIsFlat(tree: CatalogTree): boolean;
|
|
23
|
+
export declare function formatCatalogTreeBreadcrumb(parts: string[]): string;
|
|
24
|
+
//# sourceMappingURL=modelCatalogTree.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"modelCatalogTree.d.ts","sourceRoot":"","sources":["../src/modelCatalogTree.ts"],"names":[],"mappings":"AAYA,MAAM,MAAM,mBAAmB,GAAG,OAAO,GAAG,MAAM,CAAC;AAEnD,MAAM,MAAM,eAAe,GAAG;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,mBAAmB,CAAC;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,eAAe,EAAE,CAAC;IAC7B,gBAAgB;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG;IAClC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;IAAE,KAAK,EAAE,eAAe,EAAE,CAAA;CAAE,CAAC;AAEvD,yEAAyE;AACzE,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,qBAAqB,EAAE,GAAG,WAAW,CAc7E;AAYD,wBAAgB,wBAAwB,CACtC,IAAI,EAAE,WAAW,EACjB,MAAM,CAAC,EAAE,qBAAqB,EAAE,GAC/B,qBAAqB,EAAE,CAsBzB;AAED,wBAAgB,qBAAqB,CACnC,IAAI,EAAE,WAAW,EACjB,OAAO,EAAE,MAAM,GACd,MAAM,EAAE,GAAG,IAAI,CAkBjB;AAED,oEAAoE;AACpE,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,WAAW,GAAG,OAAO,CAK5D;AAED,wBAAgB,2BAA2B,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,CAEnE"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2026 John Ewart <john@johnewart.net>
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*
|
|
5
|
+
* Generic model-catalog tree: groups a flat model list into a browsable
|
|
6
|
+
* hierarchy. Only the flat (no grouping) strategy ships here — hosts with
|
|
7
|
+
* product-specific tiering (e.g. grouping Claude models by base model +
|
|
8
|
+
* effort/thinking variant) build their own `CatalogTreeNode[]` and pass it
|
|
9
|
+
* directly to `CatalogColumnBrowser`/`CatalogTreePickerOptions`, which don't
|
|
10
|
+
* care how the tree was built.
|
|
11
|
+
*/
|
|
12
|
+
/** Flat (ungrouped, alphabetical) catalog tree — the generic default. */
|
|
13
|
+
export function buildCatalogTree(models) {
|
|
14
|
+
const sorted = [...models].sort((a, b) => (a.name || a.id).localeCompare(b.name || b.id, undefined, {
|
|
15
|
+
sensitivity: 'base',
|
|
16
|
+
}));
|
|
17
|
+
return {
|
|
18
|
+
roots: sorted.map((model) => ({
|
|
19
|
+
id: model.id,
|
|
20
|
+
kind: 'leaf',
|
|
21
|
+
label: model.name.trim() || model.id,
|
|
22
|
+
modelId: model.id,
|
|
23
|
+
})),
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
const modelById = (models) => {
|
|
27
|
+
const map = new Map();
|
|
28
|
+
for (const model of models) {
|
|
29
|
+
map.set(model.id, model);
|
|
30
|
+
}
|
|
31
|
+
return map;
|
|
32
|
+
};
|
|
33
|
+
export function flattenCatalogTreeLeaves(tree, models) {
|
|
34
|
+
const byId = models ? modelById(models) : null;
|
|
35
|
+
const out = [];
|
|
36
|
+
const walk = (nodes) => {
|
|
37
|
+
for (const node of nodes) {
|
|
38
|
+
if (node.kind === 'leaf' && node.modelId) {
|
|
39
|
+
const row = byId?.get(node.modelId);
|
|
40
|
+
out.push(row ?? {
|
|
41
|
+
id: node.modelId,
|
|
42
|
+
name: node.label,
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
else if (node.children?.length) {
|
|
46
|
+
walk(node.children);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
walk(tree.roots);
|
|
51
|
+
return out;
|
|
52
|
+
}
|
|
53
|
+
export function catalogTreeBreadcrumb(tree, modelId) {
|
|
54
|
+
const path = [];
|
|
55
|
+
const walk = (nodes, ancestors) => {
|
|
56
|
+
for (const node of nodes) {
|
|
57
|
+
const next = node.kind === 'group' ? [...ancestors, node.label] : ancestors;
|
|
58
|
+
if (node.kind === 'leaf' && node.modelId === modelId) {
|
|
59
|
+
path.push(...ancestors, node.label);
|
|
60
|
+
return true;
|
|
61
|
+
}
|
|
62
|
+
if (node.children?.length && walk(node.children, next)) {
|
|
63
|
+
return true;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return false;
|
|
67
|
+
};
|
|
68
|
+
return walk(tree.roots, []) ? path : null;
|
|
69
|
+
}
|
|
70
|
+
/** True when every root node is a selectable leaf (no grouping). */
|
|
71
|
+
export function catalogTreeIsFlat(tree) {
|
|
72
|
+
return (tree.roots.length > 0 &&
|
|
73
|
+
tree.roots.every((node) => node.kind === 'leaf' && !node.children?.length));
|
|
74
|
+
}
|
|
75
|
+
export function formatCatalogTreeBreadcrumb(parts) {
|
|
76
|
+
return parts.filter((p) => p.length > 0).join(' › ');
|
|
77
|
+
}
|
package/dist/node.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
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
|
+
export type { ProviderAuthCommandState } from './useProviderAuthCommand.js';
|
|
8
|
+
export { useProviderAuthCommand } from './useProviderAuthCommand.js';
|
|
9
|
+
//# sourceMappingURL=node.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../src/node.ts"],"names":[],"mappings":"AAUA,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;AAE/D,YAAY,EAAE,wBAAwB,EAAE,MAAM,6BAA6B,CAAC;AAC5E,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC"}
|
package/dist/node.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2026 John Ewart <john@johnewart.net>
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*
|
|
5
|
+
* @pyxis-llm/react/node — the Node-capable half of this package: anything that
|
|
6
|
+
* needs @pyxis-llm/client (and therefore @grpc/grpc-js). Import from here only in
|
|
7
|
+
* a process that can actually dial gRPC; see useLlmdChatDriver's docs for
|
|
8
|
+
* the split rationale and the pattern for hosts that can't.
|
|
9
|
+
*/
|
|
10
|
+
export { useLlmdChatDriver } from './useLlmdChatDriver.js';
|
|
11
|
+
export { useLlmdModelCatalog } from './useLlmdModelCatalog.js';
|
|
12
|
+
export { useLlmdSessionModel } from './useLlmdSessionModel.js';
|
|
13
|
+
export { useProviderAuthCommand } from './useProviderAuthCommand.js';
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/** Outer fence length for sent pastes (4 ticks so inner ``` blocks stay inside). */
|
|
2
|
+
export declare const PASTE_FENCE_TICKS = 4;
|
|
3
|
+
export type PasteFenceSegment = {
|
|
4
|
+
kind: 'text';
|
|
5
|
+
text: string;
|
|
6
|
+
} | {
|
|
7
|
+
kind: 'paste';
|
|
8
|
+
number: number;
|
|
9
|
+
content: string;
|
|
10
|
+
lineCount: number;
|
|
11
|
+
};
|
|
12
|
+
/** Wrap `content` as a sendable paste fence, e.g. for a composer-side capture feature. */
|
|
13
|
+
export declare function formatPasteFence(number: number, content: string): string;
|
|
14
|
+
/** Ensure blank lines surround paste fences so chat markdown renders correctly. */
|
|
15
|
+
export declare function normalizeOutgoingPasteSpacing(text: string): string;
|
|
16
|
+
/** Split a message's content into text runs and paste-fence blocks, in order. */
|
|
17
|
+
export declare function splitMessageByPasteFences(content: string): PasteFenceSegment[];
|
|
18
|
+
export declare function messageHasPasteFences(content: string): boolean;
|
|
19
|
+
export declare function messageContainsPasteFenceForNumber(content: string, number: number): boolean;
|
|
20
|
+
//# sourceMappingURL=pasteFences.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pasteFences.d.ts","sourceRoot":"","sources":["../src/pasteFences.ts"],"names":[],"mappings":"AAgBA,oFAAoF;AACpF,eAAO,MAAM,iBAAiB,IAAI,CAAC;AAInC,MAAM,MAAM,iBAAiB,GACzB;IACE,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd,GACD;IACE,IAAI,EAAE,OAAO,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AA4FN,0FAA0F;AAC1F,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAGxE;AAED,mFAAmF;AACnF,wBAAgB,6BAA6B,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAMlE;AAED,iFAAiF;AACjF,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,MAAM,GAAG,iBAAiB,EAAE,CAiD9E;AAED,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAE9D;AAED,wBAAgB,kCAAkC,CAChD,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM,GACb,OAAO,CAET"}
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2026 John Ewart <john@johnewart.net>
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Multi-line clipboard pastes get wrapped in a distinctive fenced block
|
|
7
|
+
* (` ````Paste #N `) when sent, so a rendered message can present them as a
|
|
8
|
+
* collapsible/captioned block instead of dumping raw pasted text inline.
|
|
9
|
+
* This module is the parser for that wire format; the composer-side capture
|
|
10
|
+
* UI (turning a live paste into one of these fences) is a host concern and
|
|
11
|
+
* not part of this package (yet).
|
|
12
|
+
*/
|
|
13
|
+
import { countPasteLines } from './pasteFormat.js';
|
|
14
|
+
/** Outer fence length for sent pastes (4 ticks so inner ``` blocks stay inside). */
|
|
15
|
+
export const PASTE_FENCE_TICKS = 4;
|
|
16
|
+
const PASTE_FENCE_OPEN_RE = /(`{3,})Paste #(\d+)\n/g;
|
|
17
|
+
function isLineStart(content, index) {
|
|
18
|
+
return index === 0 || content[index - 1] === '\n';
|
|
19
|
+
}
|
|
20
|
+
function parseFenceLine(content, lineStart) {
|
|
21
|
+
const rest = content.slice(lineStart);
|
|
22
|
+
const m = rest.match(/^(`{3,})([^\n]*)(\n|$)/);
|
|
23
|
+
if (!m)
|
|
24
|
+
return null;
|
|
25
|
+
return {
|
|
26
|
+
tickCount: m[1].length,
|
|
27
|
+
info: m[2].trim(),
|
|
28
|
+
lineEnd: lineStart + m[0].length,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
function findNextFenceLineStart(content, from) {
|
|
32
|
+
for (let i = from; i < content.length; i++) {
|
|
33
|
+
if (content[i] !== '`' || !isLineStart(content, i))
|
|
34
|
+
continue;
|
|
35
|
+
const parsed = parseFenceLine(content, i);
|
|
36
|
+
if (parsed && parsed.tickCount >= 3)
|
|
37
|
+
return i;
|
|
38
|
+
}
|
|
39
|
+
return -1;
|
|
40
|
+
}
|
|
41
|
+
function findPasteFenceClose(content, bodyStart, openTickCount) {
|
|
42
|
+
let insideGenericFence = false;
|
|
43
|
+
let pos = bodyStart;
|
|
44
|
+
while (pos < content.length) {
|
|
45
|
+
const fenceStart = findNextFenceLineStart(content, pos);
|
|
46
|
+
if (fenceStart === -1)
|
|
47
|
+
return -1;
|
|
48
|
+
const line = parseFenceLine(content, fenceStart);
|
|
49
|
+
if (!line) {
|
|
50
|
+
pos = fenceStart + 1;
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
const { tickCount, info, lineEnd } = line;
|
|
54
|
+
const canClosePaste = tickCount >= openTickCount && info === '';
|
|
55
|
+
if (insideGenericFence) {
|
|
56
|
+
insideGenericFence = false;
|
|
57
|
+
pos = lineEnd;
|
|
58
|
+
continue;
|
|
59
|
+
}
|
|
60
|
+
if (canClosePaste) {
|
|
61
|
+
const afterLine = content.slice(lineEnd);
|
|
62
|
+
const nextRelative = findNextFenceLineStart(afterLine, 0);
|
|
63
|
+
const between = nextRelative === -1 ? afterLine : afterLine.slice(0, nextRelative);
|
|
64
|
+
// If the next fence opens a *new* paste block, this fence is a genuine
|
|
65
|
+
// close — never merge two distinct pastes (and the text between them)
|
|
66
|
+
// into one blob. The generic-fence lookahead below is only for keeping
|
|
67
|
+
// nested ``` code blocks inside a single paste, where the following
|
|
68
|
+
// fence is a bare (non-paste) fence.
|
|
69
|
+
const nextIsPasteOpen = nextRelative !== -1 &&
|
|
70
|
+
/^`{3,}Paste #\d+/.test(afterLine.slice(nextRelative));
|
|
71
|
+
if (nextRelative !== -1 &&
|
|
72
|
+
between.trim().length > 0 &&
|
|
73
|
+
!nextIsPasteOpen) {
|
|
74
|
+
insideGenericFence = true;
|
|
75
|
+
pos = lineEnd;
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
return fenceStart;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
else if (tickCount >= 3) {
|
|
82
|
+
insideGenericFence = true;
|
|
83
|
+
pos = lineEnd;
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
pos = lineEnd;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return -1;
|
|
90
|
+
}
|
|
91
|
+
/** Wrap `content` as a sendable paste fence, e.g. for a composer-side capture feature. */
|
|
92
|
+
export function formatPasteFence(number, content) {
|
|
93
|
+
const tick = '`'.repeat(PASTE_FENCE_TICKS);
|
|
94
|
+
return `\n\n${tick}Paste #${number}\n${content}\n${tick}\n\n`;
|
|
95
|
+
}
|
|
96
|
+
/** Ensure blank lines surround paste fences so chat markdown renders correctly. */
|
|
97
|
+
export function normalizeOutgoingPasteSpacing(text) {
|
|
98
|
+
let out = text.replace(/\r\n/g, '\n');
|
|
99
|
+
out = out.replace(/([^\n])\s*\n(`{3,}Paste #\d+\n)/g, '$1\n\n$2');
|
|
100
|
+
out = out.replace(/(`{3,})\n[ \t]*(?=\S)/g, '$1\n\n');
|
|
101
|
+
out = out.replace(/\n{4,}/g, '\n\n\n');
|
|
102
|
+
return out.replace(/[^\S\n]+$/g, '');
|
|
103
|
+
}
|
|
104
|
+
/** Split a message's content into text runs and paste-fence blocks, in order. */
|
|
105
|
+
export function splitMessageByPasteFences(content) {
|
|
106
|
+
if (!content)
|
|
107
|
+
return [{ kind: 'text', text: '' }];
|
|
108
|
+
const segments = [];
|
|
109
|
+
let last = 0;
|
|
110
|
+
const openRe = new RegExp(PASTE_FENCE_OPEN_RE.source, 'g');
|
|
111
|
+
let m;
|
|
112
|
+
while ((m = openRe.exec(content)) !== null) {
|
|
113
|
+
if (m.index > last) {
|
|
114
|
+
const t = content.slice(last, m.index);
|
|
115
|
+
if (t)
|
|
116
|
+
segments.push({ kind: 'text', text: t });
|
|
117
|
+
}
|
|
118
|
+
const openTickCount = m[1].length;
|
|
119
|
+
const pasteNum = Number.parseInt(m[2], 10);
|
|
120
|
+
const bodyStart = m.index + m[0].length;
|
|
121
|
+
const closeStart = findPasteFenceClose(content, bodyStart, openTickCount);
|
|
122
|
+
if (closeStart === -1) {
|
|
123
|
+
const body = content.slice(bodyStart);
|
|
124
|
+
segments.push({
|
|
125
|
+
kind: 'paste',
|
|
126
|
+
number: pasteNum,
|
|
127
|
+
content: body.replace(/\n$/, ''),
|
|
128
|
+
lineCount: countPasteLines(body),
|
|
129
|
+
});
|
|
130
|
+
last = content.length;
|
|
131
|
+
break;
|
|
132
|
+
}
|
|
133
|
+
const body = content.slice(bodyStart, closeStart);
|
|
134
|
+
const closeLine = parseFenceLine(content, closeStart);
|
|
135
|
+
segments.push({
|
|
136
|
+
kind: 'paste',
|
|
137
|
+
number: pasteNum,
|
|
138
|
+
content: body.replace(/\n$/, ''),
|
|
139
|
+
lineCount: countPasteLines(body),
|
|
140
|
+
});
|
|
141
|
+
last = closeLine.lineEnd;
|
|
142
|
+
openRe.lastIndex = last;
|
|
143
|
+
}
|
|
144
|
+
if (last < content.length) {
|
|
145
|
+
segments.push({ kind: 'text', text: content.slice(last) });
|
|
146
|
+
}
|
|
147
|
+
if (segments.length === 0) {
|
|
148
|
+
segments.push({ kind: 'text', text: content });
|
|
149
|
+
}
|
|
150
|
+
return segments;
|
|
151
|
+
}
|
|
152
|
+
export function messageHasPasteFences(content) {
|
|
153
|
+
return /`{3,}Paste #\d+\n/.test(content);
|
|
154
|
+
}
|
|
155
|
+
export function messageContainsPasteFenceForNumber(content, number) {
|
|
156
|
+
return new RegExp(`\`{3,}Paste #${number}\\n`, 'm').test(content);
|
|
157
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/** Number of lines in pasted text (0 for empty/whitespace-only). */
|
|
2
|
+
export declare function countPasteLines(text: string): number;
|
|
3
|
+
/** Composer placeholder token for a captured multi-line paste, e.g. `[Paste #2 · 14 lines]`. */
|
|
4
|
+
export declare function formatPastePlaceholder(number: number, lineCount: number): string;
|
|
5
|
+
//# sourceMappingURL=pasteFormat.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pasteFormat.d.ts","sourceRoot":"","sources":["../src/pasteFormat.ts"],"names":[],"mappings":"AAKA,oEAAoE;AACpE,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAKpD;AAED,gGAAgG;AAChG,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAGhF"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2026 John Ewart <john@johnewart.net>
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
/** Number of lines in pasted text (0 for empty/whitespace-only). */
|
|
6
|
+
export function countPasteLines(text) {
|
|
7
|
+
if (!text)
|
|
8
|
+
return 0;
|
|
9
|
+
const normalized = text.replace(/\r\n/g, '\n');
|
|
10
|
+
if (!normalized.trim())
|
|
11
|
+
return 0;
|
|
12
|
+
return normalized.split('\n').length;
|
|
13
|
+
}
|
|
14
|
+
/** Composer placeholder token for a captured multi-line paste, e.g. `[Paste #2 · 14 lines]`. */
|
|
15
|
+
export function formatPastePlaceholder(number, lineCount) {
|
|
16
|
+
const lines = lineCount === 1 ? '1 line' : `${lineCount} lines`;
|
|
17
|
+
return `[Paste #${number} · ${lines}]`;
|
|
18
|
+
}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* llmd's one extension point for what the chat can render. A plugin may
|
|
3
|
+
* contribute any of:
|
|
4
|
+
*
|
|
5
|
+
* - `highlighter`: syntax highlighting for fenced code (`@pyxis-llm/react/highlight`);
|
|
6
|
+
* - `languages`: a renderer for a whole fence language (```mermaid, ```vega-lite);
|
|
7
|
+
* - `displayCards`: a renderer for a display card type (@pyxis-llm/core
|
|
8
|
+
* DISPLAY_CARD_KIND, e.g. "chart" from `@pyxis-llm/react/charts`);
|
|
9
|
+
* - `attachments`: a renderer (and transcript placement) for a host's own
|
|
10
|
+
* attachment kind (e.g. a command-proposal card).
|
|
11
|
+
*
|
|
12
|
+
* Plugins reach the chat two ways, and both merge:
|
|
13
|
+
*
|
|
14
|
+
* - `registerLlmdPlugin(plugin)`: global, for the whole page. Importing
|
|
15
|
+
* `@pyxis-llm/react/charts` does this itself, so "import it" is all a host
|
|
16
|
+
* needs to do to get charts.
|
|
17
|
+
* - `<LlmdPluginProvider plugins={[...]}>`: scoped to a subtree; nested
|
|
18
|
+
* providers stack. Use it for plugins that depend on where they render.
|
|
19
|
+
*
|
|
20
|
+
* Later registrations win (a provider beats the global registry; the last
|
|
21
|
+
* plugin in a list beats earlier ones), so a host can override anything llmd
|
|
22
|
+
* ships, including the built-in image card.
|
|
23
|
+
*
|
|
24
|
+
* Renderers are components, not callbacks: one that needs host state (e.g. a
|
|
25
|
+
* "pin this" action) reads it from the host's own React context.
|
|
26
|
+
*/
|
|
27
|
+
import React from 'react';
|
|
28
|
+
import type { AttachmentKindPlugin, DisplayCard, LlmdMessageAttachment } from '@pyxis-llm/core';
|
|
29
|
+
/** Props handed to a syntax highlighter for a fenced code block. */
|
|
30
|
+
export type HighlightedCodeProps = {
|
|
31
|
+
code: string;
|
|
32
|
+
language: string;
|
|
33
|
+
/** Box styling for the block (margins/padding/wrapping), chosen by the markdown surface. */
|
|
34
|
+
customStyle: React.CSSProperties;
|
|
35
|
+
/** Must be spread onto the outermost element the highlighter renders. */
|
|
36
|
+
preTagProps: Record<string, unknown>;
|
|
37
|
+
};
|
|
38
|
+
/** Renders a whole fenced block for one language (e.g. ```mermaid). */
|
|
39
|
+
export type LanguageBlockRenderer = React.ComponentType<{
|
|
40
|
+
code: string;
|
|
41
|
+
}>;
|
|
42
|
+
/** Props a display card body renderer receives. */
|
|
43
|
+
export type DisplayCardRenderProps<Body = Record<string, unknown>> = {
|
|
44
|
+
/** The card, with `body` already decoded (see DisplayCardRenderer.decode). */
|
|
45
|
+
card: DisplayCard<Body>;
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* Renders one display card type. Unless `ownsChrome`, the card is drawn in
|
|
49
|
+
* llmd's shared frame (title above, caption below); the renderer draws only
|
|
50
|
+
* the body.
|
|
51
|
+
*/
|
|
52
|
+
export type DisplayCardRenderer<Body = Record<string, unknown>> = {
|
|
53
|
+
/** Validate / normalize the body; undefined shows "[<type> unavailable]". Default: accept as-is. */
|
|
54
|
+
decode?: (body: Record<string, unknown>) => Body | undefined;
|
|
55
|
+
render: React.ComponentType<DisplayCardRenderProps<Body>>;
|
|
56
|
+
/** The renderer draws the title and caption itself. */
|
|
57
|
+
ownsChrome?: boolean;
|
|
58
|
+
};
|
|
59
|
+
/** What a host attachment renderer receives. */
|
|
60
|
+
export type AttachmentRenderProps = {
|
|
61
|
+
attachment: LlmdMessageAttachment;
|
|
62
|
+
/** The id in the `<attachment:id/>` tag that placed it. */
|
|
63
|
+
attachmentId: string;
|
|
64
|
+
/** Id of the message the card renders in. */
|
|
65
|
+
messageId?: string;
|
|
66
|
+
/** Remove the card from the session (wired when the panel was given a dismiss handler). */
|
|
67
|
+
dismiss?: () => void;
|
|
68
|
+
};
|
|
69
|
+
/** A host attachment kind: how it renders, and (optionally) where it is placed. */
|
|
70
|
+
export type AttachmentKindRenderer = {
|
|
71
|
+
render?: React.ComponentType<AttachmentRenderProps>;
|
|
72
|
+
/** Transcript placement (own row, persistence, anchors); see @pyxis-llm/core AttachmentKindPlugin. */
|
|
73
|
+
placement?: Omit<AttachmentKindPlugin, 'kind'>;
|
|
74
|
+
};
|
|
75
|
+
export type LlmdPlugin = {
|
|
76
|
+
/** Stable id: registering the same id again replaces the earlier plugin. */
|
|
77
|
+
id: string;
|
|
78
|
+
highlighter?: React.ComponentType<HighlightedCodeProps>;
|
|
79
|
+
/** Keyed by fence language, lower-case. Takes precedence over `highlighter`. */
|
|
80
|
+
languages?: Record<string, LanguageBlockRenderer>;
|
|
81
|
+
/** Keyed by display card `type`. */
|
|
82
|
+
displayCards?: Record<string, DisplayCardRenderer<any>>;
|
|
83
|
+
/** Keyed by attachment `kind`. */
|
|
84
|
+
attachments?: Record<string, AttachmentKindRenderer>;
|
|
85
|
+
};
|
|
86
|
+
/** Every plugin merged into one lookup. */
|
|
87
|
+
export type ResolvedLlmdPlugins = {
|
|
88
|
+
highlighter?: React.ComponentType<HighlightedCodeProps>;
|
|
89
|
+
languages: Record<string, LanguageBlockRenderer>;
|
|
90
|
+
displayCards: Record<string, DisplayCardRenderer<any>>;
|
|
91
|
+
attachments: Record<string, AttachmentKindRenderer>;
|
|
92
|
+
/** Placement rules for @pyxis-llm/core's transcript functions. */
|
|
93
|
+
attachmentKindPlugins: AttachmentKindPlugin[];
|
|
94
|
+
};
|
|
95
|
+
export declare function resolveLlmdPlugins(plugins: readonly LlmdPlugin[]): ResolvedLlmdPlugins;
|
|
96
|
+
/**
|
|
97
|
+
* Register a plugin for the whole page. Re-registering an id replaces it (so
|
|
98
|
+
* hot reload and double imports are harmless). Returns an unregister function.
|
|
99
|
+
*/
|
|
100
|
+
export declare function registerLlmdPlugin(plugin: LlmdPlugin): () => void;
|
|
101
|
+
/** The globally registered plugins, in registration order. */
|
|
102
|
+
export declare function registeredLlmdPlugins(): readonly LlmdPlugin[];
|
|
103
|
+
/** Add plugins for everything below. Nested providers stack on their parent's. */
|
|
104
|
+
export declare function LlmdPluginProvider({ plugins, children }: {
|
|
105
|
+
plugins: readonly LlmdPlugin[];
|
|
106
|
+
children?: React.ReactNode;
|
|
107
|
+
}): React.JSX.Element;
|
|
108
|
+
/** Everything in effect here: llmd's built-ins, then global registrations, then providers. */
|
|
109
|
+
export declare function useLlmdPlugins(): ResolvedLlmdPlugins;
|
|
110
|
+
//# sourceMappingURL=plugins.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugins.d.ts","sourceRoot":"","sources":["../src/plugins.tsx"],"names":[],"mappings":"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"}
|