@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,248 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright 2026 John Ewart <john@johnewart.net>
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { memo, useMemo } from 'react';
|
|
7
|
+
import { Combobox, Menu, Text } from '@mantine/core';
|
|
8
|
+
import { buildCatalogTree, catalogTreeBreadcrumb, catalogTreeIsFlat, formatCatalogTreeBreadcrumb, } from './modelCatalogTree.js';
|
|
9
|
+
import { encodeChatModelOptionValue, } from './chatModelOptions.js';
|
|
10
|
+
import { CatalogColumnBrowser } from './CatalogColumnBrowser.js';
|
|
11
|
+
import { CatalogPickerMenuItem } from './CatalogPickerMenuItem.js';
|
|
12
|
+
import { catalogPickerMenuLabelStyle } from './catalogPickerMenuStyles.js';
|
|
13
|
+
function groupOptionsByProvider(options) {
|
|
14
|
+
const groups = [];
|
|
15
|
+
const indexById = new Map();
|
|
16
|
+
for (const opt of options) {
|
|
17
|
+
const existing = indexById.get(opt.providerId);
|
|
18
|
+
if (existing != null) {
|
|
19
|
+
groups[existing].options.push(opt);
|
|
20
|
+
continue;
|
|
21
|
+
}
|
|
22
|
+
indexById.set(opt.providerId, groups.length);
|
|
23
|
+
groups.push({
|
|
24
|
+
providerId: opt.providerId,
|
|
25
|
+
providerName: opt.providerName,
|
|
26
|
+
options: [opt],
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
return groups;
|
|
30
|
+
}
|
|
31
|
+
function normalizeSearchQuery(raw) {
|
|
32
|
+
return (raw ?? '').trim().toLowerCase();
|
|
33
|
+
}
|
|
34
|
+
function leafMatchesSearch(opt, breadcrumb, query) {
|
|
35
|
+
if (!query)
|
|
36
|
+
return true;
|
|
37
|
+
const haystack = [
|
|
38
|
+
opt.providerName,
|
|
39
|
+
opt.modelName,
|
|
40
|
+
opt.modelId,
|
|
41
|
+
breadcrumb ? formatCatalogTreeBreadcrumb(breadcrumb) : '',
|
|
42
|
+
]
|
|
43
|
+
.join(' ')
|
|
44
|
+
.toLowerCase();
|
|
45
|
+
return haystack.includes(query);
|
|
46
|
+
}
|
|
47
|
+
function buildProviderTreeRoots(group, buildTree) {
|
|
48
|
+
const tree = buildTree
|
|
49
|
+
? buildTree(group.options)
|
|
50
|
+
: buildCatalogTree(group.options.map((opt) => ({
|
|
51
|
+
id: opt.modelId,
|
|
52
|
+
name: opt.modelName,
|
|
53
|
+
})));
|
|
54
|
+
const optionByModelId = new Map(group.options.map((opt) => [opt.modelId, opt]));
|
|
55
|
+
return { tree, optionByModelId };
|
|
56
|
+
}
|
|
57
|
+
function wrapProviderRoots(providerGroups, buildTree) {
|
|
58
|
+
const multiProvider = providerGroups.length > 1;
|
|
59
|
+
const optionByModelId = new Map();
|
|
60
|
+
const roots = [];
|
|
61
|
+
for (const group of providerGroups) {
|
|
62
|
+
for (const opt of group.options) {
|
|
63
|
+
const key = multiProvider
|
|
64
|
+
? `${group.providerId}:${opt.modelId}`
|
|
65
|
+
: opt.modelId;
|
|
66
|
+
optionByModelId.set(key, opt);
|
|
67
|
+
}
|
|
68
|
+
const { tree } = buildProviderTreeRoots(group, buildTree);
|
|
69
|
+
if (!multiProvider) {
|
|
70
|
+
return { roots: tree.roots, optionByModelId, multiProvider: false };
|
|
71
|
+
}
|
|
72
|
+
roots.push({
|
|
73
|
+
id: group.providerId,
|
|
74
|
+
kind: 'group',
|
|
75
|
+
label: group.providerName,
|
|
76
|
+
children: tree.roots,
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
return { roots, optionByModelId, multiProvider: true };
|
|
80
|
+
}
|
|
81
|
+
/** Flat filtered list with breadcrumb labels (used for combobox and menu search). */
|
|
82
|
+
function renderTreeNodesFlat(nodes, depth, ctx) {
|
|
83
|
+
const out = [];
|
|
84
|
+
for (const node of nodes) {
|
|
85
|
+
if (node.kind === 'leaf' && node.modelId) {
|
|
86
|
+
const opt = ctx.optionByModelId.get(node.modelId);
|
|
87
|
+
if (!opt)
|
|
88
|
+
continue;
|
|
89
|
+
const breadcrumb = catalogTreeBreadcrumb(ctx.tree, node.modelId);
|
|
90
|
+
if (!leafMatchesSearch(opt, breadcrumb, ctx.searchQuery))
|
|
91
|
+
continue;
|
|
92
|
+
const itemIndex = ctx.flatIndexRef.current++;
|
|
93
|
+
const isActive = ctx.activeIndex != null && itemIndex === ctx.activeIndex;
|
|
94
|
+
const selected = ctx.isOptionSelected?.(opt) ?? false;
|
|
95
|
+
const label = ctx.searchQuery && breadcrumb?.length
|
|
96
|
+
? formatCatalogTreeBreadcrumb(breadcrumb)
|
|
97
|
+
: ctx.showProviderPrefix === false
|
|
98
|
+
? node.label
|
|
99
|
+
: `${ctx.providerName}: ${node.label}`;
|
|
100
|
+
if (ctx.variant === 'combobox') {
|
|
101
|
+
out.push(_jsx(Combobox.Option, { value: encodeChatModelOptionValue(opt), style: {
|
|
102
|
+
fontWeight: selected ? 600 : undefined,
|
|
103
|
+
paddingLeft: 12 + depth * 12,
|
|
104
|
+
}, children: label }, encodeChatModelOptionValue(opt)));
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
out.push(_jsx(CatalogPickerMenuItem, { onClick: () => ctx.onSelect(opt.providerId, opt.modelId), fw: selected ? 600 : undefined, paddingLeft: 12 + depth * 12, active: isActive, children: label }, `${opt.providerId}:${opt.modelId}`));
|
|
108
|
+
}
|
|
109
|
+
continue;
|
|
110
|
+
}
|
|
111
|
+
if (node.kind !== 'group' || !node.children?.length)
|
|
112
|
+
continue;
|
|
113
|
+
const childNodes = renderTreeNodesFlat(node.children, depth + 1, ctx);
|
|
114
|
+
if (childNodes.length === 0)
|
|
115
|
+
continue;
|
|
116
|
+
if (ctx.variant === 'combobox') {
|
|
117
|
+
out.push(_jsx(Combobox.Group, { label: _jsx(Text, { size: "xs", c: "dimmed", pl: depth * 12, children: node.label }), children: childNodes }, node.id));
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
out.push(_jsx(Menu.Label, { style: { paddingLeft: 8 + depth * 12, ...catalogPickerMenuLabelStyle }, children: node.label }, node.id));
|
|
121
|
+
out.push(...childNodes);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
return out;
|
|
125
|
+
}
|
|
126
|
+
function renderFlatProviderOptions(providerName, providerOptions, ctx) {
|
|
127
|
+
const matched = providerOptions.filter((opt) => leafMatchesSearch(opt, null, ctx.searchQuery) || ctx.searchQuery.length === 0);
|
|
128
|
+
const out = [];
|
|
129
|
+
for (let index = 0; index < matched.length; index += 1) {
|
|
130
|
+
const opt = matched[index];
|
|
131
|
+
const itemIndex = ctx.flatIndexRef.current++;
|
|
132
|
+
const isActive = ctx.activeIndex != null && itemIndex === ctx.activeIndex;
|
|
133
|
+
const selected = ctx.isOptionSelected?.(opt) ?? false;
|
|
134
|
+
const label = ctx.showProviderPrefix === false
|
|
135
|
+
? opt.modelName
|
|
136
|
+
: `${providerName}: ${opt.modelName}`;
|
|
137
|
+
if (ctx.variant === 'combobox') {
|
|
138
|
+
out.push(_jsx(Combobox.Option, { value: encodeChatModelOptionValue(opt), style: { fontWeight: selected ? 600 : undefined }, children: label }, encodeChatModelOptionValue(opt)));
|
|
139
|
+
}
|
|
140
|
+
else {
|
|
141
|
+
out.push(_jsx(CatalogPickerMenuItem, { onClick: () => ctx.onSelect(opt.providerId, opt.modelId), fw: selected ? 600 : undefined, showDivider: index < matched.length - 1, active: isActive, children: label }, `${opt.providerId}:${opt.modelId}`));
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
return out;
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Returns the flat ordered list of ChatModelOption leaves that match `rawQuery`,
|
|
148
|
+
* in the same order they are rendered by CatalogTreePickerOptions (search mode).
|
|
149
|
+
* Used by CatalogModelPickerMenuContent to drive keyboard activeIndex.
|
|
150
|
+
*/
|
|
151
|
+
export function getFilteredFlatOptions(options, rawQuery, buildTree) {
|
|
152
|
+
const query = normalizeSearchQuery(rawQuery);
|
|
153
|
+
if (!query)
|
|
154
|
+
return [];
|
|
155
|
+
const providerGroups = groupOptionsByProvider(options);
|
|
156
|
+
const result = [];
|
|
157
|
+
for (const group of providerGroups) {
|
|
158
|
+
const { tree, optionByModelId } = buildProviderTreeRoots(group, buildTree);
|
|
159
|
+
if (catalogTreeIsFlat(tree)) {
|
|
160
|
+
for (const opt of group.options) {
|
|
161
|
+
if (leafMatchesSearch(opt, null, query))
|
|
162
|
+
result.push(opt);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
else {
|
|
166
|
+
collectMatchedLeaves(tree.roots, tree, query, optionByModelId, result);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
return result;
|
|
170
|
+
}
|
|
171
|
+
function collectMatchedLeaves(nodes, tree, query, optionByModelId, result) {
|
|
172
|
+
for (const node of nodes) {
|
|
173
|
+
if (node.kind === 'leaf' && node.modelId) {
|
|
174
|
+
const opt = optionByModelId.get(node.modelId);
|
|
175
|
+
if (!opt)
|
|
176
|
+
continue;
|
|
177
|
+
const breadcrumb = catalogTreeBreadcrumb(tree, node.modelId);
|
|
178
|
+
if (leafMatchesSearch(opt, breadcrumb, query))
|
|
179
|
+
result.push(opt);
|
|
180
|
+
}
|
|
181
|
+
else if (node.kind === 'group' && node.children?.length) {
|
|
182
|
+
collectMatchedLeaves(node.children, tree, query, optionByModelId, result);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
const CatalogTreePickerOptionsComponent = ({ options, buildTree, keepOrder, onSelect, variant, searchQuery, menuOpenKey, onColumnLayoutChange, isOptionSelected, activeIndex, browserRef, onReloadProvider, layout = 'columns', }) => {
|
|
187
|
+
const normalizedSearch = normalizeSearchQuery(searchQuery);
|
|
188
|
+
const providerGroups = useMemo(() => groupOptionsByProvider(options), [options]);
|
|
189
|
+
const browserData = useMemo(() => wrapProviderRoots(providerGroups, buildTree), [providerGroups, buildTree]);
|
|
190
|
+
const fallbackProviderId = providerGroups[0]?.providerId ?? '';
|
|
191
|
+
if (variant === 'menu' && normalizedSearch.length === 0 && layout !== 'flat') {
|
|
192
|
+
return (_jsx(CatalogColumnBrowser, { ref: browserRef, roots: browserData.roots, optionByModelId: browserData.optionByModelId, providerId: fallbackProviderId, multiProvider: browserData.multiProvider, onSelect: onSelect, isOptionSelected: isOptionSelected, resetKey: menuOpenKey ?? options.map((o) => encodeChatModelOptionValue(o)).join('|'), onColumnLayoutChange: onColumnLayoutChange, onReloadProvider: onReloadProvider, keepOrder: keepOrder }));
|
|
193
|
+
}
|
|
194
|
+
// Shared mutable counter — must be reset each render so indices are stable.
|
|
195
|
+
const flatIndexRef = { current: 0 };
|
|
196
|
+
// In the flat layout each provider gets its own label row, so the model rows
|
|
197
|
+
// themselves are named for the model alone.
|
|
198
|
+
const showProviderPrefix = !(layout === 'flat' && normalizedSearch.length === 0);
|
|
199
|
+
const providerLabel = (group) => layout === 'flat' &&
|
|
200
|
+
normalizedSearch.length === 0 &&
|
|
201
|
+
variant === 'menu' &&
|
|
202
|
+
providerGroups.length > 1
|
|
203
|
+
? [
|
|
204
|
+
_jsx(Menu.Label, { style: catalogPickerMenuLabelStyle, children: group.providerName }, `label-${group.providerId}`),
|
|
205
|
+
]
|
|
206
|
+
: [];
|
|
207
|
+
const rendered = providerGroups.flatMap((group) => {
|
|
208
|
+
const { tree, optionByModelId } = buildProviderTreeRoots(group, buildTree);
|
|
209
|
+
if (catalogTreeIsFlat(tree)) {
|
|
210
|
+
return [
|
|
211
|
+
...providerLabel(group),
|
|
212
|
+
...renderFlatProviderOptions(group.providerName, group.options, {
|
|
213
|
+
searchQuery: normalizedSearch,
|
|
214
|
+
isOptionSelected,
|
|
215
|
+
onSelect,
|
|
216
|
+
variant,
|
|
217
|
+
flatIndexRef,
|
|
218
|
+
activeIndex,
|
|
219
|
+
showProviderPrefix,
|
|
220
|
+
}),
|
|
221
|
+
];
|
|
222
|
+
}
|
|
223
|
+
const ctx = {
|
|
224
|
+
providerId: group.providerId,
|
|
225
|
+
providerName: group.providerName,
|
|
226
|
+
tree,
|
|
227
|
+
optionByModelId,
|
|
228
|
+
searchQuery: normalizedSearch,
|
|
229
|
+
isOptionSelected,
|
|
230
|
+
onSelect,
|
|
231
|
+
variant,
|
|
232
|
+
flatIndexRef,
|
|
233
|
+
activeIndex,
|
|
234
|
+
showProviderPrefix,
|
|
235
|
+
};
|
|
236
|
+
const nodes = renderTreeNodesFlat(tree.roots, 0, ctx);
|
|
237
|
+
if (nodes.length === 0)
|
|
238
|
+
return [];
|
|
239
|
+
if (variant === 'combobox' && providerGroups.length > 1) {
|
|
240
|
+
return [
|
|
241
|
+
_jsx(Combobox.Group, { label: group.providerName, children: nodes }, group.providerId),
|
|
242
|
+
];
|
|
243
|
+
}
|
|
244
|
+
return [...providerLabel(group), ...nodes];
|
|
245
|
+
});
|
|
246
|
+
return _jsx(_Fragment, { children: rendered });
|
|
247
|
+
};
|
|
248
|
+
export const CatalogTreePickerOptions = memo(CatalogTreePickerOptionsComponent);
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Renders one transcript message: role-tagged bubble, markdown/paste-aware
|
|
3
|
+
* content, tracked-context badges, and an optional footer row (decoration
|
|
4
|
+
* chips + token usage). This is intentionally NOT a 1:1 port of any host's
|
|
5
|
+
* chat bubble — it owns only what every llmd-backed chat surface needs
|
|
6
|
+
* (markdown, attachment placement tags, paste fences, raw/clean toggle,
|
|
7
|
+
* token usage) and exposes slots for everything host-specific:
|
|
8
|
+
*
|
|
9
|
+
* - `renderCustomMessage`: a message that should replace the whole bubble
|
|
10
|
+
* (e.g. a host's embedded-run card keyed off message.metadata).
|
|
11
|
+
* - cards at inline `<attachment:id/>` tags: ask cards are built in;
|
|
12
|
+
* everything else (display cards, a host's own kinds) renders through the
|
|
13
|
+
* plugin registered for it (see plugins.tsx). This component only owns
|
|
14
|
+
* placement (see @pyxis-llm/core's messageContentTags/messageAttachments).
|
|
15
|
+
* - `renderDecorations`: how per-turn TurnDecorationView[] (e.g. a host's
|
|
16
|
+
* graph-provenance badges) render in the footer, next to token usage.
|
|
17
|
+
* - `transformVisibleContent`: last-mile cleanup of assistant content
|
|
18
|
+
* beyond the generic control-tag stripping this component always does
|
|
19
|
+
* (e.g. a host-specific tag-pinning convention).
|
|
20
|
+
*
|
|
21
|
+
* A host that supplies none of these gets a plain, fully-functional bubble
|
|
22
|
+
* with attachments rendered as an inert placeholder — which is the "vanilla
|
|
23
|
+
* + attachments" baseline a minimal host can ship as-is.
|
|
24
|
+
*/
|
|
25
|
+
import React, { type ReactNode } from 'react';
|
|
26
|
+
import { type AskCardResponse, type LlmdMessageAttachment, type TrackedDocumentRefView, type TurnDecorationView } from '@pyxis-llm/core';
|
|
27
|
+
import { type AskCardSubmitOptions } from './AskCardView.js';
|
|
28
|
+
/** Library (SerializedMessage) or legacy shape — the minimal fields this component reads. */
|
|
29
|
+
/** One text segment of an assistant turn, split at tool calls (opt-in `segmentedTurns`). */
|
|
30
|
+
export type ChatMessageSegment = {
|
|
31
|
+
text: string;
|
|
32
|
+
/** The tool calls that followed this segment. */
|
|
33
|
+
toolCalls?: Array<{
|
|
34
|
+
id?: string;
|
|
35
|
+
name?: string;
|
|
36
|
+
}>;
|
|
37
|
+
};
|
|
38
|
+
export type ChatMessageData = {
|
|
39
|
+
/** Assistant rows, only with the driver's `segmentedTurns` option: the turn's text segments. */
|
|
40
|
+
segments?: ChatMessageSegment[];
|
|
41
|
+
role: string;
|
|
42
|
+
content: string;
|
|
43
|
+
id?: string;
|
|
44
|
+
metadata?: Record<string, unknown>;
|
|
45
|
+
/** On `tool` rows: the call this result answers. */
|
|
46
|
+
toolCallId?: string;
|
|
47
|
+
/**
|
|
48
|
+
* On assistant rows: the tool calls the turn made (ids/names only). Not
|
|
49
|
+
* rendered; it lets the transcript place a card a tool produced right
|
|
50
|
+
* after that tool's result (see @pyxis-llm/core's appendAnchorlessCardMessages).
|
|
51
|
+
*/
|
|
52
|
+
toolCalls?: Array<{
|
|
53
|
+
id?: string;
|
|
54
|
+
name?: string;
|
|
55
|
+
}>;
|
|
56
|
+
providerId?: string;
|
|
57
|
+
};
|
|
58
|
+
export type ChatMessageUsage = {
|
|
59
|
+
inputTokens: number;
|
|
60
|
+
outputTokens: number;
|
|
61
|
+
cacheReadTokens: number;
|
|
62
|
+
cacheWriteTokens: number;
|
|
63
|
+
/** Reasoning/thinking tokens (TokenUsage.reasoning_tokens); absent when unreported. */
|
|
64
|
+
reasoningTokens?: number;
|
|
65
|
+
/** Upstream provider that served the turn (AssistantReply.served_by); absent when unknown. */
|
|
66
|
+
servedBy?: string;
|
|
67
|
+
/** Pre-compression token count; 0 if no compression this turn. */
|
|
68
|
+
originalTokens: number;
|
|
69
|
+
/** Post-compression wire count; 0 if no compression this turn. */
|
|
70
|
+
compressedTokens: number;
|
|
71
|
+
/** Wall time of the model call(s) that produced the message, in ms; absent when unknown. */
|
|
72
|
+
modelDurationMs?: number;
|
|
73
|
+
};
|
|
74
|
+
/**
|
|
75
|
+
* Reads the usage llmd recorded for a message from `metadata.usage` (where
|
|
76
|
+
* @pyxis-llm/client's history mapping and useLlmdChatDriver put it; the key is
|
|
77
|
+
* @pyxis-llm/client's MESSAGE_USAGE_METADATA_KEY). Undefined when there is none.
|
|
78
|
+
*/
|
|
79
|
+
export declare function usageFromMessageMetadata(metadata: Record<string, unknown> | undefined): ChatMessageUsage | undefined;
|
|
80
|
+
/** 14.2s under a minute, 1m 05s above. */
|
|
81
|
+
export declare function fmtModelDuration(ms: number): string;
|
|
82
|
+
export type ChatMessageProps = {
|
|
83
|
+
message: ChatMessageData;
|
|
84
|
+
compact?: boolean;
|
|
85
|
+
/** While the assistant tail is streaming, skip markdown/GFM and Prism for lower CPU. */
|
|
86
|
+
streamPlainContent?: boolean;
|
|
87
|
+
onDelete?: () => void;
|
|
88
|
+
deleteDisabled?: boolean;
|
|
89
|
+
deleteTooltip?: string;
|
|
90
|
+
attachmentIndex?: Map<string, LlmdMessageAttachment>;
|
|
91
|
+
/**
|
|
92
|
+
* Per-turn token usage to show as a badge at the bottom of the bubble.
|
|
93
|
+
* Omitted (undefined): read from the message's `metadata.usage`, which
|
|
94
|
+
* useLlmdChatDriver and @pyxis-llm/client's history mapping fill in. `null`:
|
|
95
|
+
* show no usage.
|
|
96
|
+
*/
|
|
97
|
+
usage?: ChatMessageUsage | null;
|
|
98
|
+
/**
|
|
99
|
+
* Decorations attached to this message (e.g. graph provenance, a host's
|
|
100
|
+
* pin or review comment) — rendering is entirely up to `renderDecorations`.
|
|
101
|
+
* Shown for every role, including user messages; `kind`/`uri` are opaque to
|
|
102
|
+
* llmd, so what a decoration *means* is the emitter's business.
|
|
103
|
+
*/
|
|
104
|
+
decorations?: TurnDecorationView[] | null;
|
|
105
|
+
/** Tracked-document versions attached to THIS user message (badges). */
|
|
106
|
+
trackedDocuments?: TrackedDocumentRefView[];
|
|
107
|
+
/** First-turn session seed, passed only for the first user message. */
|
|
108
|
+
initialSeed?: string;
|
|
109
|
+
/**
|
|
110
|
+
* Replace the entire bubble for this message (e.g. a host's embedded-run
|
|
111
|
+
* card). Return `undefined`/nothing to fall through to normal rendering.
|
|
112
|
+
*/
|
|
113
|
+
renderCustomMessage?: (message: ChatMessageData) => ReactNode | undefined;
|
|
114
|
+
/**
|
|
115
|
+
* Chip for a host attachment SENT ON a user message (anchored to it), drawn
|
|
116
|
+
* beside the ask-card answer chips. Return null/undefined for kinds the host
|
|
117
|
+
* does not show this way. Unlike inline `<attachment:id/>` tags this needs no
|
|
118
|
+
* marker in the message text, so nothing tag-like reaches the model.
|
|
119
|
+
*/
|
|
120
|
+
renderUserAttachment?: (attachment: LlmdMessageAttachment, ctx: {
|
|
121
|
+
message: ChatMessageData;
|
|
122
|
+
}) => ReactNode;
|
|
123
|
+
/** Render this message's decorations in the footer (left of the token badge). */
|
|
124
|
+
renderDecorations?: (decorations: TurnDecorationView[]) => ReactNode;
|
|
125
|
+
/**
|
|
126
|
+
* Ask-card responses, keyed by the AskCard.id they answer (build with
|
|
127
|
+
* `indexAskCardResponses` from @pyxis-llm/core). Present ⇒ that card renders
|
|
128
|
+
* as answered/read-only; absent ⇒ interactive.
|
|
129
|
+
*/
|
|
130
|
+
askCardResponses?: Map<string, AskCardResponse>;
|
|
131
|
+
/**
|
|
132
|
+
* Called when the user submits an ask card's interactive form. The host
|
|
133
|
+
* owns persisting the response (UpsertSessionAttachment); omit to render
|
|
134
|
+
* ask cards read-only/disabled. `options.continueWithTools` says which
|
|
135
|
+
* button was used ("Answer & continue" vs "Answer & stop").
|
|
136
|
+
*/
|
|
137
|
+
onAskCardSubmit?: (response: AskCardResponse, options: AskCardSubmitOptions) => void;
|
|
138
|
+
/**
|
|
139
|
+
* Called with a card's id when the user dismisses it (the ✕ on an
|
|
140
|
+
* unanswered card, and on a card that cannot be shown). The host deletes the
|
|
141
|
+
* card; omit to hide the ✕. Also handed to plugin attachment renderers as
|
|
142
|
+
* `dismiss()`, whatever their kind.
|
|
143
|
+
*/
|
|
144
|
+
onAskCardDismiss?: (cardId: string) => void;
|
|
145
|
+
/**
|
|
146
|
+
* Last-mile cleanup of assistant content beyond the generic `<activity>`/
|
|
147
|
+
* `<thinking>` stripping this component always applies (e.g. a
|
|
148
|
+
* host-specific tag-pinning convention). Identity by default.
|
|
149
|
+
*/
|
|
150
|
+
transformVisibleContent?: (content: string, message: ChatMessageData) => string;
|
|
151
|
+
/**
|
|
152
|
+
* Let the browser skip layout/paint for this row while it is off screen
|
|
153
|
+
* (`content-visibility: auto`). Without it a long transcript is laid out in
|
|
154
|
+
* full whenever anything forces layout (composer autosize, scroll-to-bottom
|
|
155
|
+
* reading scrollHeight), so typing lags in proportion to conversation length.
|
|
156
|
+
* ChatPanel leaves the newest rows uncontained: until a row has been laid out
|
|
157
|
+
* once it reports the intrinsic-size placeholder, so scroll-to-bottom would
|
|
158
|
+
* stop short. `contain-intrinsic-size: auto` remembers measured heights.
|
|
159
|
+
*/
|
|
160
|
+
containOffscreen?: boolean;
|
|
161
|
+
/**
|
|
162
|
+
* Render prose as plain pre-wrap text (no markdown parse) until the row
|
|
163
|
+
* comes near the viewport, then upgrade to markdown for good. Keeps opening
|
|
164
|
+
* a long transcript cheap while every message stays in the DOM, so the
|
|
165
|
+
* browser's find-in-page still searches the whole conversation. Only read at
|
|
166
|
+
* mount: a row that already rendered markdown never downgrades when newer
|
|
167
|
+
* messages push it out of the tail.
|
|
168
|
+
*/
|
|
169
|
+
deferMarkdown?: boolean;
|
|
170
|
+
};
|
|
171
|
+
export declare const ChatMessage: React.NamedExoticComponent<ChatMessageProps>;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