@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,314 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2026 John Ewart <john@johnewart.net>
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
/** Vega-Lite's default text sizes, so a font scale also moves unstyled text. */
|
|
6
|
+
const DEFAULT_FONT_SIZES = {
|
|
7
|
+
title: { fontSize: 13, subtitleFontSize: 10 },
|
|
8
|
+
axis: { labelFontSize: 10, titleFontSize: 11 },
|
|
9
|
+
legend: { labelFontSize: 10, titleFontSize: 11 },
|
|
10
|
+
header: { labelFontSize: 10, titleFontSize: 11 },
|
|
11
|
+
text: { fontSize: 11 },
|
|
12
|
+
};
|
|
13
|
+
const FONT_SIZE_KEY = /^(fontSize|[a-z]+FontSize)$/;
|
|
14
|
+
/** Multiply every numeric *fontSize anywhere in `node` by `scale`, in place. */
|
|
15
|
+
function scaleFontSizes(node, scale) {
|
|
16
|
+
if (Array.isArray(node)) {
|
|
17
|
+
for (const v of node)
|
|
18
|
+
scaleFontSizes(v, scale);
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
if (!isPlainObject(node))
|
|
22
|
+
return;
|
|
23
|
+
for (const key of Object.keys(node)) {
|
|
24
|
+
const v = node[key];
|
|
25
|
+
if (FONT_SIZE_KEY.test(key) && typeof v === 'number')
|
|
26
|
+
node[key] = Math.round(v * scale * 10) / 10;
|
|
27
|
+
else if (key !== 'data' && key !== 'datasets')
|
|
28
|
+
scaleFontSizes(v, scale);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
const FALLBACK_CHART_FONT = '-apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif';
|
|
32
|
+
/**
|
|
33
|
+
* The font charts use: `explicit`, else the page body's computed font. Vega
|
|
34
|
+
* draws labels as SVG text with their own font attribute, so the CSS font of
|
|
35
|
+
* the container (which may be a monospace code-block style) never applies;
|
|
36
|
+
* the body is the app's UI font.
|
|
37
|
+
*/
|
|
38
|
+
export function resolveChartFont(explicit) {
|
|
39
|
+
const given = explicit?.trim();
|
|
40
|
+
if (given)
|
|
41
|
+
return given;
|
|
42
|
+
if (typeof document !== 'undefined' && document.body && typeof getComputedStyle === 'function') {
|
|
43
|
+
const body = getComputedStyle(document.body).fontFamily?.trim();
|
|
44
|
+
if (body)
|
|
45
|
+
return body;
|
|
46
|
+
}
|
|
47
|
+
return FALLBACK_CHART_FONT;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Every config slot Vega / Vega-Lite reads a font from, set to `font`, with
|
|
51
|
+
* the default text sizes multiplied by `scale`.
|
|
52
|
+
*/
|
|
53
|
+
export function chartFontConfig(font, scale = 1) {
|
|
54
|
+
const s = (n) => Math.round(n * scale * 10) / 10;
|
|
55
|
+
const d = DEFAULT_FONT_SIZES;
|
|
56
|
+
return {
|
|
57
|
+
font,
|
|
58
|
+
title: { font, subtitleFont: font, fontSize: s(d.title.fontSize), subtitleFontSize: s(d.title.subtitleFontSize) },
|
|
59
|
+
axis: { labelFont: font, titleFont: font, labelFontSize: s(d.axis.labelFontSize), titleFontSize: s(d.axis.titleFontSize) },
|
|
60
|
+
legend: { labelFont: font, titleFont: font, labelFontSize: s(d.legend.labelFontSize), titleFontSize: s(d.legend.titleFontSize) },
|
|
61
|
+
header: { labelFont: font, titleFont: font, labelFontSize: s(d.header.labelFontSize), titleFontSize: s(d.header.titleFontSize) },
|
|
62
|
+
mark: { font },
|
|
63
|
+
text: { font, fontSize: s(d.text.fontSize) },
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
const FONT_KEY = /^(font|labelFont|titleFont|subtitleFont)$/;
|
|
67
|
+
/** Drop font choices from a spec's config (recursively) and its mark, so the app font wins. */
|
|
68
|
+
function stripFonts(node) {
|
|
69
|
+
if (!isPlainObject(node))
|
|
70
|
+
return;
|
|
71
|
+
for (const key of Object.keys(node)) {
|
|
72
|
+
if (FONT_KEY.test(key))
|
|
73
|
+
delete node[key];
|
|
74
|
+
else
|
|
75
|
+
stripFonts(node[key]);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
export const VEGA_EXTERNAL_RESOURCE_ERROR = 'Charts in chat cannot load external resources. Put the data inline under "data": {"values": [...]}.';
|
|
79
|
+
const refuse = async () => {
|
|
80
|
+
throw new Error(VEGA_EXTERNAL_RESOURCE_ERROR);
|
|
81
|
+
};
|
|
82
|
+
const BLOCKED_LOADER = {
|
|
83
|
+
load: refuse,
|
|
84
|
+
sanitize: refuse,
|
|
85
|
+
http: refuse,
|
|
86
|
+
file: refuse,
|
|
87
|
+
};
|
|
88
|
+
/** A Vega loader that sends data loads to `dataLoader`; everything else is refused. */
|
|
89
|
+
function loaderFor(dataLoader, problems) {
|
|
90
|
+
// Vega swallows a refused href (it only fires on click), so sanitize also
|
|
91
|
+
// reports the refusal to the caller.
|
|
92
|
+
const refuseAndReport = async () => {
|
|
93
|
+
if (!problems.includes(VEGA_EXTERNAL_RESOURCE_ERROR))
|
|
94
|
+
problems.push(VEGA_EXTERNAL_RESOURCE_ERROR);
|
|
95
|
+
return refuse();
|
|
96
|
+
};
|
|
97
|
+
if (!dataLoader)
|
|
98
|
+
return { ...BLOCKED_LOADER, sanitize: refuseAndReport };
|
|
99
|
+
return {
|
|
100
|
+
// Vega calls load() directly only for dataflow requests; images and
|
|
101
|
+
// hrefs go through sanitize() first, which stays refused.
|
|
102
|
+
load: async (uri, options) => {
|
|
103
|
+
if (options?.context !== 'dataflow')
|
|
104
|
+
return refuse();
|
|
105
|
+
return dataLoader(uri);
|
|
106
|
+
},
|
|
107
|
+
sanitize: refuseAndReport,
|
|
108
|
+
http: refuse,
|
|
109
|
+
file: refuse,
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
let embedPromise = null;
|
|
113
|
+
function loadVegaEmbed() {
|
|
114
|
+
if (!embedPromise) {
|
|
115
|
+
embedPromise = import('vega-embed').then((mod) => mod.default, (err) => {
|
|
116
|
+
// Don't cache a failed import (e.g. the optional peer isn't installed
|
|
117
|
+
// yet during dev); the next chart retries.
|
|
118
|
+
embedPromise = null;
|
|
119
|
+
throw err;
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
return embedPromise;
|
|
123
|
+
}
|
|
124
|
+
function isPlainObject(value) {
|
|
125
|
+
return value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
126
|
+
}
|
|
127
|
+
const FACET_CHANNELS = ['row', 'column', 'facet'];
|
|
128
|
+
/**
|
|
129
|
+
* A deep copy of `spec` that is safe to hand to vega-embed: spec-supplied
|
|
130
|
+
* embed options removed, and a single-view Vega-Lite chart with no explicit
|
|
131
|
+
* width sized to its container (chat bubbles vary in width). Never mutates
|
|
132
|
+
* the input.
|
|
133
|
+
*/
|
|
134
|
+
export function prepareVegaSpec(spec, mode, fontScale = 1) {
|
|
135
|
+
const out = JSON.parse(JSON.stringify(spec));
|
|
136
|
+
if (isPlainObject(out.usermeta)) {
|
|
137
|
+
delete out.usermeta.embedOptions;
|
|
138
|
+
}
|
|
139
|
+
// Charts use the app's font, whatever the spec asks for (models like
|
|
140
|
+
// "monospace"). Config-level and mark-level choices are dropped; the font
|
|
141
|
+
// comes from renderVegaChart's embed config.
|
|
142
|
+
stripFonts(out.config);
|
|
143
|
+
if (isPlainObject(out.mark)) {
|
|
144
|
+
delete out.mark.font;
|
|
145
|
+
}
|
|
146
|
+
if (isPlainObject(out.title)) {
|
|
147
|
+
delete out.title.font;
|
|
148
|
+
delete out.title.subtitleFont;
|
|
149
|
+
}
|
|
150
|
+
// Sizes the spec sets itself scale too, or A−/A+ would skip them.
|
|
151
|
+
if (fontScale !== 1)
|
|
152
|
+
scaleFontSizes(out, fontScale);
|
|
153
|
+
if (mode === 'vega-lite' && out.width === undefined && ('mark' in out || 'layer' in out)) {
|
|
154
|
+
const encoding = isPlainObject(out.encoding) ? out.encoding : {};
|
|
155
|
+
const faceted = FACET_CHANNELS.some((ch) => ch in encoding);
|
|
156
|
+
if (!faceted)
|
|
157
|
+
out.width = 'container';
|
|
158
|
+
}
|
|
159
|
+
return out;
|
|
160
|
+
}
|
|
161
|
+
function stringifyForTooltip(value) {
|
|
162
|
+
try {
|
|
163
|
+
return JSON.stringify(value) ?? String(value);
|
|
164
|
+
}
|
|
165
|
+
catch {
|
|
166
|
+
return String(value);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* vega-tooltip's default formatter minus the `image` special case: every
|
|
171
|
+
* field renders as escaped text through `valueToHtml` (vega-tooltip's HTML
|
|
172
|
+
* escaper), so a tooltip never fetches anything.
|
|
173
|
+
*/
|
|
174
|
+
export function formatTooltip(value, valueToHtml, _maxDepth, _baseURL) {
|
|
175
|
+
if (Array.isArray(value)) {
|
|
176
|
+
return `[${value
|
|
177
|
+
.map((v) => valueToHtml(typeof v === 'string' ? v : stringifyForTooltip(v)))
|
|
178
|
+
.join(', ')}]`;
|
|
179
|
+
}
|
|
180
|
+
if (isPlainObject(value)) {
|
|
181
|
+
const { title, ...rest } = value;
|
|
182
|
+
let html = title !== undefined && title !== null && title !== '' ? `<h2>${valueToHtml(title)}</h2>` : '';
|
|
183
|
+
const keys = Object.keys(rest).filter((k) => rest[k] !== undefined);
|
|
184
|
+
if (keys.length > 0) {
|
|
185
|
+
html += '<table>';
|
|
186
|
+
for (const key of keys) {
|
|
187
|
+
const raw = rest[key];
|
|
188
|
+
const cell = raw !== null && typeof raw === 'object' ? stringifyForTooltip(raw) : raw;
|
|
189
|
+
html += `<tr><td class="key">${valueToHtml(key)}</td><td class="value">${valueToHtml(cell)}</td></tr>`;
|
|
190
|
+
}
|
|
191
|
+
html += '</table>';
|
|
192
|
+
}
|
|
193
|
+
return html || '{}';
|
|
194
|
+
}
|
|
195
|
+
return valueToHtml(value);
|
|
196
|
+
}
|
|
197
|
+
function logArgText(arg) {
|
|
198
|
+
if (arg instanceof Error)
|
|
199
|
+
return arg.message;
|
|
200
|
+
return typeof arg === 'string' ? arg : stringifyForTooltip(arg);
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* A Vega logger that records errors, and warnings that carry an Error (failed
|
|
204
|
+
* loads / ingestion), instead of printing them. Vega's dataflow calls these
|
|
205
|
+
* with `this` bound to itself, so nothing here may rely on `this`.
|
|
206
|
+
*/
|
|
207
|
+
function collectingLogger(problems) {
|
|
208
|
+
let currentLevel = 1;
|
|
209
|
+
const record = (args) => {
|
|
210
|
+
const blocked = args.some((a) => a instanceof Error && a.message === VEGA_EXTERNAL_RESOURCE_ERROR);
|
|
211
|
+
const text = blocked ? VEGA_EXTERNAL_RESOURCE_ERROR : args.map(logArgText).join(' ');
|
|
212
|
+
if (!problems.includes(text))
|
|
213
|
+
problems.push(text);
|
|
214
|
+
};
|
|
215
|
+
const logger = {
|
|
216
|
+
level(level) {
|
|
217
|
+
if (level === undefined)
|
|
218
|
+
return currentLevel;
|
|
219
|
+
currentLevel = level;
|
|
220
|
+
return logger;
|
|
221
|
+
},
|
|
222
|
+
error(...args) {
|
|
223
|
+
record(args);
|
|
224
|
+
return logger;
|
|
225
|
+
},
|
|
226
|
+
warn(...args) {
|
|
227
|
+
if (args.some((a) => a instanceof Error))
|
|
228
|
+
record(args);
|
|
229
|
+
return logger;
|
|
230
|
+
},
|
|
231
|
+
info() {
|
|
232
|
+
return logger;
|
|
233
|
+
},
|
|
234
|
+
debug() {
|
|
235
|
+
return logger;
|
|
236
|
+
},
|
|
237
|
+
};
|
|
238
|
+
return logger;
|
|
239
|
+
}
|
|
240
|
+
/** The locked-down embed options shared by on-screen and headless rendering. */
|
|
241
|
+
function lockedEmbedOptions(options, scale, problems) {
|
|
242
|
+
return {
|
|
243
|
+
mode: options.mode,
|
|
244
|
+
renderer: 'svg',
|
|
245
|
+
ast: true, // expression interpreter, never `new Function`
|
|
246
|
+
loader: loaderFor(options.loader, problems),
|
|
247
|
+
config: { background: 'transparent', ...chartFontConfig(resolveChartFont(options.fontFamily), scale) },
|
|
248
|
+
// Problems surface to the caller, not the console.
|
|
249
|
+
logger: collectingLogger(problems),
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* Render `spec` to a static SVG string (light theme) under the same lockdown
|
|
254
|
+
* as renderVegaChart. Never throws.
|
|
255
|
+
*/
|
|
256
|
+
export async function renderVegaSvg(spec, options) {
|
|
257
|
+
const problems = [];
|
|
258
|
+
let finalize;
|
|
259
|
+
try {
|
|
260
|
+
const embed = await loadVegaEmbed();
|
|
261
|
+
const prepared = prepareVegaSpec(spec, options.mode);
|
|
262
|
+
if (prepared.width === 'container') {
|
|
263
|
+
prepared.width = options.width && options.width > 0 ? options.width : 640;
|
|
264
|
+
}
|
|
265
|
+
const host = document.createElement('div');
|
|
266
|
+
const result = await embed(host, prepared, {
|
|
267
|
+
...lockedEmbedOptions(options, 1, problems),
|
|
268
|
+
actions: false,
|
|
269
|
+
tooltip: false,
|
|
270
|
+
});
|
|
271
|
+
finalize = result.finalize;
|
|
272
|
+
const svg = await result.view.toSVG();
|
|
273
|
+
return { svg, problems };
|
|
274
|
+
}
|
|
275
|
+
catch (e) {
|
|
276
|
+
return { error: e instanceof Error ? e.message : String(e) };
|
|
277
|
+
}
|
|
278
|
+
finally {
|
|
279
|
+
try {
|
|
280
|
+
finalize?.();
|
|
281
|
+
}
|
|
282
|
+
catch (e) {
|
|
283
|
+
problems.push(`finalize failed: ${e instanceof Error ? e.message : String(e)}`);
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
/**
|
|
288
|
+
* Render `spec` into `el` (whose children vega-embed owns from here on).
|
|
289
|
+
* Never throws: failures come back as `{ error }` with `el` cleared.
|
|
290
|
+
*/
|
|
291
|
+
export async function renderVegaChart(el, spec, options) {
|
|
292
|
+
const problems = [];
|
|
293
|
+
try {
|
|
294
|
+
const embed = await loadVegaEmbed();
|
|
295
|
+
const scale = options.fontScale && options.fontScale > 0 ? options.fontScale : 1;
|
|
296
|
+
const prepared = prepareVegaSpec(spec, options.mode, scale);
|
|
297
|
+
const result = await embed(el, prepared, {
|
|
298
|
+
...lockedEmbedOptions(options, scale, problems),
|
|
299
|
+
actions: { export: { svg: true, png: true }, source: false, compiled: false, editor: false },
|
|
300
|
+
...(options.isDark ? { theme: 'dark' } : {}),
|
|
301
|
+
tooltip: { formatTooltip, theme: options.isDark ? 'dark' : 'light' },
|
|
302
|
+
downloadFileName: options.downloadFileName || 'chart',
|
|
303
|
+
});
|
|
304
|
+
return { finalize: result.finalize, problems };
|
|
305
|
+
}
|
|
306
|
+
catch (e) {
|
|
307
|
+
el.innerHTML = '';
|
|
308
|
+
return { error: e instanceof Error ? e.message : String(e) };
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
/** Drop the cached vega-embed import (tests / hot reload). */
|
|
312
|
+
export function resetVegaRuntimeForTests() {
|
|
313
|
+
embedPromise = null;
|
|
314
|
+
}
|
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
import type { QueuedMessage } from "./sessionQueue.js";
|
|
2
|
+
/**
|
|
3
|
+
* Wire schema version for conversation stream frames (matches llmd / ai-library).
|
|
4
|
+
*/
|
|
5
|
+
export declare const CONVERSATION_EVENT_SCHEMA_VERSION: 2;
|
|
6
|
+
/** Discriminant string values match the conversation_events wire contract. */
|
|
7
|
+
export declare enum ConversationEventType {
|
|
8
|
+
UserTurnCommitted = "user_turn_committed",
|
|
9
|
+
AssistantTurnStarted = "assistant_turn_started",
|
|
10
|
+
AssistantThinkingDelta = "assistant_thinking_delta",
|
|
11
|
+
AssistantActivitySnapshot = "assistant_activity_snapshot",
|
|
12
|
+
AssistantTextDelta = "assistant_text_delta",
|
|
13
|
+
ToolCallStreamStarted = "tool_call_stream_started",
|
|
14
|
+
ToolCallArgsDelta = "tool_call_args_delta",
|
|
15
|
+
ToolCallStreamFinished = "tool_call_stream_finished",
|
|
16
|
+
ToolExecutionStarted = "tool_execution_started",
|
|
17
|
+
ToolExecutionFinished = "tool_execution_finished",
|
|
18
|
+
AssistantTurnFinished = "assistant_turn_finished",
|
|
19
|
+
AssistantTurnFailed = "assistant_turn_failed",
|
|
20
|
+
ConversationAborted = "conversation_aborted",
|
|
21
|
+
/** Agent-authored status headline (set_status tool); session-scoped, not turn-scoped. */
|
|
22
|
+
SessionStatus = "session_status",
|
|
23
|
+
/** Session title set via the set_session_title tool. */
|
|
24
|
+
SessionTitleChanged = "session_title_changed",
|
|
25
|
+
/** Session todo list changed via add_todo/update_todo. */
|
|
26
|
+
TodosUpdated = "todos_updated",
|
|
27
|
+
/**
|
|
28
|
+
* The session's message queue changed — enqueued, removed, reordered, claimed,
|
|
29
|
+
* retired, paused or resumed. Carries the whole queue rather than a delta, so a
|
|
30
|
+
* window that missed an event still converges.
|
|
31
|
+
*/
|
|
32
|
+
QueueChanged = "queue_changed",
|
|
33
|
+
/**
|
|
34
|
+
* A session attachment (e.g. an ask_card from the ask_user tool) was created
|
|
35
|
+
* or updated. Carries the whole attachment so it can render without a refetch.
|
|
36
|
+
*/
|
|
37
|
+
AttachmentUpserted = "attachment_upserted",
|
|
38
|
+
/** A session attachment was deleted. */
|
|
39
|
+
AttachmentDeleted = "attachment_deleted",
|
|
40
|
+
/**
|
|
41
|
+
* Only on a ChatStream sent with `queueIfBusy`: llmd found the session busy
|
|
42
|
+
* and put the message in the session queue instead of running it. The
|
|
43
|
+
* stream ends after this event (no turn, no `complete`).
|
|
44
|
+
*/
|
|
45
|
+
TurnQueued = "turn_queued"
|
|
46
|
+
}
|
|
47
|
+
/** One entry in the JSON array carried by a TodosUpdated event's todosJson (see store.TodoItem). */
|
|
48
|
+
export type SessionTodoItem = {
|
|
49
|
+
id: string;
|
|
50
|
+
description: string;
|
|
51
|
+
status: "pending" | "in_progress" | "completed";
|
|
52
|
+
createdTurnSeq?: number;
|
|
53
|
+
startedTurnSeq?: number;
|
|
54
|
+
completedTurnSeq?: number;
|
|
55
|
+
};
|
|
56
|
+
/** Parses a TodosUpdated frame's `todosJson` payload. */
|
|
57
|
+
export declare function safeTodosJson(s: string): SessionTodoItem[];
|
|
58
|
+
/**
|
|
59
|
+
* Parses an `argumentsJson` payload (ToolCallStreamFinished or
|
|
60
|
+
* ToolExecutionStarted). Yields `{}` for absent, unparseable or non-object
|
|
61
|
+
* input rather than throwing — these arrive from a model.
|
|
62
|
+
*/
|
|
63
|
+
export declare function safeArgsJson(s: string): Record<string, unknown>;
|
|
64
|
+
/**
|
|
65
|
+
* Turn timing a session reports with its status (llmd's server clock, epoch
|
|
66
|
+
* ms), so any client can show a turn's clock and how long the last one took
|
|
67
|
+
* without having watched it. Absent from older llmd.
|
|
68
|
+
*/
|
|
69
|
+
export type SessionTurnTiming = {
|
|
70
|
+
/** When a turn is in progress: when it started. */
|
|
71
|
+
turnStartedAtMs?: number;
|
|
72
|
+
/** The session's most recently finished turn, if one finished since llmd started. */
|
|
73
|
+
lastTurn?: {
|
|
74
|
+
startedAtMs: number;
|
|
75
|
+
endedAtMs: number;
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
export type AssistantTurnCapabilities = {
|
|
79
|
+
thinking?: boolean;
|
|
80
|
+
streamingToolCalls?: boolean;
|
|
81
|
+
};
|
|
82
|
+
export type ConversationEvent = {
|
|
83
|
+
type: ConversationEventType.UserTurnCommitted;
|
|
84
|
+
schemaVersion?: typeof CONVERSATION_EVENT_SCHEMA_VERSION;
|
|
85
|
+
userMessageId: string;
|
|
86
|
+
textPreview?: string;
|
|
87
|
+
/** Server wall-clock ms the user turn started; time the turn from this. Absent from older llmd. */
|
|
88
|
+
committedAtMs?: number;
|
|
89
|
+
} | {
|
|
90
|
+
type: ConversationEventType.AssistantTurnStarted;
|
|
91
|
+
schemaVersion?: typeof CONVERSATION_EVENT_SCHEMA_VERSION;
|
|
92
|
+
turnId: string;
|
|
93
|
+
/** Session-scoped, gap-free monotonic turn sequence minted by llmd's TurnRegister. */
|
|
94
|
+
turnSeq?: number;
|
|
95
|
+
capabilities?: AssistantTurnCapabilities;
|
|
96
|
+
parentTurnGroupId?: string;
|
|
97
|
+
} | {
|
|
98
|
+
type: ConversationEventType.AssistantThinkingDelta;
|
|
99
|
+
schemaVersion?: typeof CONVERSATION_EVENT_SCHEMA_VERSION;
|
|
100
|
+
turnId: string;
|
|
101
|
+
delta: string;
|
|
102
|
+
} | {
|
|
103
|
+
type: ConversationEventType.AssistantActivitySnapshot;
|
|
104
|
+
schemaVersion?: typeof CONVERSATION_EVENT_SCHEMA_VERSION;
|
|
105
|
+
turnId: string;
|
|
106
|
+
headline: string;
|
|
107
|
+
} | {
|
|
108
|
+
type: ConversationEventType.AssistantTextDelta;
|
|
109
|
+
schemaVersion?: typeof CONVERSATION_EVENT_SCHEMA_VERSION;
|
|
110
|
+
turnId: string;
|
|
111
|
+
delta: string;
|
|
112
|
+
} | {
|
|
113
|
+
type: ConversationEventType.ToolCallStreamStarted;
|
|
114
|
+
schemaVersion?: typeof CONVERSATION_EVENT_SCHEMA_VERSION;
|
|
115
|
+
turnId: string;
|
|
116
|
+
id: string;
|
|
117
|
+
name?: string;
|
|
118
|
+
} | {
|
|
119
|
+
type: ConversationEventType.ToolCallArgsDelta;
|
|
120
|
+
schemaVersion?: typeof CONVERSATION_EVENT_SCHEMA_VERSION;
|
|
121
|
+
turnId: string;
|
|
122
|
+
id: string;
|
|
123
|
+
argsDelta: string;
|
|
124
|
+
} | {
|
|
125
|
+
type: ConversationEventType.ToolCallStreamFinished;
|
|
126
|
+
schemaVersion?: typeof CONVERSATION_EVENT_SCHEMA_VERSION;
|
|
127
|
+
turnId: string;
|
|
128
|
+
id: string;
|
|
129
|
+
name: string;
|
|
130
|
+
arguments: Record<string, unknown>;
|
|
131
|
+
} | {
|
|
132
|
+
type: ConversationEventType.ToolExecutionStarted;
|
|
133
|
+
schemaVersion?: typeof CONVERSATION_EVENT_SCHEMA_VERSION;
|
|
134
|
+
turnId: string;
|
|
135
|
+
toolCallId: string;
|
|
136
|
+
name: string;
|
|
137
|
+
clientWaitNonce?: string;
|
|
138
|
+
/**
|
|
139
|
+
* Arguments the tool was invoked with, for rendering a descriptive label
|
|
140
|
+
* ("Reading lines 15-200 of foo.go") instead of a bare tool name.
|
|
141
|
+
*
|
|
142
|
+
* Present on every transport. For MCP-dispatched tools (Claude Code /
|
|
143
|
+
* Cursor CLI) this is the ONLY event carrying arguments — those calls
|
|
144
|
+
* never produce a ToolCallStreamFinished, because the model-side call
|
|
145
|
+
* happened inside the CLI.
|
|
146
|
+
*
|
|
147
|
+
* `{}` when llmd sent nothing or the payload could not be parsed —
|
|
148
|
+
* never a throw.
|
|
149
|
+
*/
|
|
150
|
+
arguments: Record<string, unknown>;
|
|
151
|
+
/**
|
|
152
|
+
* True when llmd shortened the arguments to bound its event log.
|
|
153
|
+
* Oversized values are elided (a file body becomes a short marker) while
|
|
154
|
+
* keys and small scalars survive, so `arguments` still parses and still
|
|
155
|
+
* has the identifying fields — a path or line range is intact even when
|
|
156
|
+
* this is true. Read session history if you need exact values.
|
|
157
|
+
*/
|
|
158
|
+
argumentsTruncated?: boolean;
|
|
159
|
+
/** Raw arguments payload as llmd sent it, for display fallback. */
|
|
160
|
+
argumentsText?: string;
|
|
161
|
+
} | {
|
|
162
|
+
type: ConversationEventType.ToolExecutionFinished;
|
|
163
|
+
schemaVersion?: typeof CONVERSATION_EVENT_SCHEMA_VERSION;
|
|
164
|
+
turnId: string;
|
|
165
|
+
toolCallId: string;
|
|
166
|
+
name: string;
|
|
167
|
+
success: boolean;
|
|
168
|
+
errorMessage?: string;
|
|
169
|
+
} | {
|
|
170
|
+
type: ConversationEventType.AssistantTurnFinished;
|
|
171
|
+
schemaVersion?: typeof CONVERSATION_EVENT_SCHEMA_VERSION;
|
|
172
|
+
turnId: string;
|
|
173
|
+
assistantMessageId?: string;
|
|
174
|
+
finishReason?: string;
|
|
175
|
+
usage?: {
|
|
176
|
+
inputTokens?: number;
|
|
177
|
+
outputTokens?: number;
|
|
178
|
+
cacheReadTokens?: number;
|
|
179
|
+
cacheWriteTokens?: number;
|
|
180
|
+
reasoningTokens?: number;
|
|
181
|
+
};
|
|
182
|
+
/** Wall time of the model call that produced this message, in ms; absent when not measured. */
|
|
183
|
+
modelDurationMs?: number;
|
|
184
|
+
} | {
|
|
185
|
+
type: ConversationEventType.AssistantTurnFailed;
|
|
186
|
+
schemaVersion?: typeof CONVERSATION_EVENT_SCHEMA_VERSION;
|
|
187
|
+
turnId: string;
|
|
188
|
+
error: string;
|
|
189
|
+
} | {
|
|
190
|
+
type: ConversationEventType.ConversationAborted;
|
|
191
|
+
schemaVersion?: typeof CONVERSATION_EVENT_SCHEMA_VERSION;
|
|
192
|
+
reason?: string;
|
|
193
|
+
} | {
|
|
194
|
+
type: ConversationEventType.SessionStatus;
|
|
195
|
+
schemaVersion?: typeof CONVERSATION_EVENT_SCHEMA_VERSION;
|
|
196
|
+
sessionId: string;
|
|
197
|
+
headline: string;
|
|
198
|
+
} | {
|
|
199
|
+
type: ConversationEventType.SessionTitleChanged;
|
|
200
|
+
schemaVersion?: typeof CONVERSATION_EVENT_SCHEMA_VERSION;
|
|
201
|
+
sessionId: string;
|
|
202
|
+
title: string;
|
|
203
|
+
} | {
|
|
204
|
+
type: ConversationEventType.TodosUpdated;
|
|
205
|
+
schemaVersion?: typeof CONVERSATION_EVENT_SCHEMA_VERSION;
|
|
206
|
+
sessionId: string;
|
|
207
|
+
todos: SessionTodoItem[];
|
|
208
|
+
} | {
|
|
209
|
+
type: ConversationEventType.QueueChanged;
|
|
210
|
+
schemaVersion?: typeof CONVERSATION_EVENT_SCHEMA_VERSION;
|
|
211
|
+
sessionId: string;
|
|
212
|
+
queue: QueuedMessage[];
|
|
213
|
+
paused: boolean;
|
|
214
|
+
} | {
|
|
215
|
+
type: ConversationEventType.AttachmentUpserted;
|
|
216
|
+
schemaVersion?: typeof CONVERSATION_EVENT_SCHEMA_VERSION;
|
|
217
|
+
sessionId: string;
|
|
218
|
+
/** Message the attachment hangs off; undefined for tool-created (anchorless) cards. */
|
|
219
|
+
messageId?: string;
|
|
220
|
+
attachment: {
|
|
221
|
+
id: string;
|
|
222
|
+
kind: string;
|
|
223
|
+
payloadJson: string;
|
|
224
|
+
afterToolCallId?: string;
|
|
225
|
+
};
|
|
226
|
+
} | {
|
|
227
|
+
type: ConversationEventType.AttachmentDeleted;
|
|
228
|
+
schemaVersion?: typeof CONVERSATION_EVENT_SCHEMA_VERSION;
|
|
229
|
+
sessionId: string;
|
|
230
|
+
attachmentId: string;
|
|
231
|
+
} | {
|
|
232
|
+
type: ConversationEventType.TurnQueued;
|
|
233
|
+
schemaVersion?: typeof CONVERSATION_EVENT_SCHEMA_VERSION;
|
|
234
|
+
sessionId: string;
|
|
235
|
+
/** The queue entry the message became. */
|
|
236
|
+
entry: QueuedMessage;
|
|
237
|
+
};
|
|
238
|
+
//# sourceMappingURL=conversationEvents.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conversationEvents.d.ts","sourceRoot":"","sources":["../../../src/vendor/llmd-types/conversationEvents.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAEvD;;GAEG;AACH,eAAO,MAAM,iCAAiC,EAAG,CAAU,CAAC;AAE5D,8EAA8E;AAC9E,oBAAY,qBAAqB;IAC/B,iBAAiB,wBAAwB;IACzC,oBAAoB,2BAA2B;IAC/C,sBAAsB,6BAA6B;IACnD,yBAAyB,gCAAgC;IACzD,kBAAkB,yBAAyB;IAC3C,qBAAqB,6BAA6B;IAClD,iBAAiB,yBAAyB;IAC1C,sBAAsB,8BAA8B;IACpD,oBAAoB,2BAA2B;IAC/C,qBAAqB,4BAA4B;IACjD,qBAAqB,4BAA4B;IACjD,mBAAmB,0BAA0B;IAC7C,mBAAmB,yBAAyB;IAC5C,yFAAyF;IACzF,aAAa,mBAAmB;IAChC,wDAAwD;IACxD,mBAAmB,0BAA0B;IAC7C,0DAA0D;IAC1D,YAAY,kBAAkB;IAC9B;;;;OAIG;IACH,YAAY,kBAAkB;IAC9B;;;OAGG;IACH,kBAAkB,wBAAwB;IAC1C,wCAAwC;IACxC,iBAAiB,uBAAuB;IACxC;;;;OAIG;IACH,UAAU,gBAAgB;CAC3B;AAED,oGAAoG;AACpG,MAAM,MAAM,eAAe,GAAG;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,SAAS,GAAG,aAAa,GAAG,WAAW,CAAC;IAChD,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B,CAAC;AAEF,yDAAyD;AACzD,wBAAgB,aAAa,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
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2026 John Ewart <john@johnewart.net>
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*
|
|
5
|
+
* Conversation-event types: the event discriminant enum, the ConversationEvent
|
|
6
|
+
* union, and the JSON parsing helpers the frame mapper uses.
|
|
7
|
+
*
|
|
8
|
+
* One codegen serves both transports, so the frame->event mapper is shared
|
|
9
|
+
* too and lives in ./events.ts next to these types.
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* Wire schema version for conversation stream frames (matches llmd / ai-library).
|
|
13
|
+
*/
|
|
14
|
+
export const CONVERSATION_EVENT_SCHEMA_VERSION = 2;
|
|
15
|
+
/** Discriminant string values match the conversation_events wire contract. */
|
|
16
|
+
export var ConversationEventType;
|
|
17
|
+
(function (ConversationEventType) {
|
|
18
|
+
ConversationEventType["UserTurnCommitted"] = "user_turn_committed";
|
|
19
|
+
ConversationEventType["AssistantTurnStarted"] = "assistant_turn_started";
|
|
20
|
+
ConversationEventType["AssistantThinkingDelta"] = "assistant_thinking_delta";
|
|
21
|
+
ConversationEventType["AssistantActivitySnapshot"] = "assistant_activity_snapshot";
|
|
22
|
+
ConversationEventType["AssistantTextDelta"] = "assistant_text_delta";
|
|
23
|
+
ConversationEventType["ToolCallStreamStarted"] = "tool_call_stream_started";
|
|
24
|
+
ConversationEventType["ToolCallArgsDelta"] = "tool_call_args_delta";
|
|
25
|
+
ConversationEventType["ToolCallStreamFinished"] = "tool_call_stream_finished";
|
|
26
|
+
ConversationEventType["ToolExecutionStarted"] = "tool_execution_started";
|
|
27
|
+
ConversationEventType["ToolExecutionFinished"] = "tool_execution_finished";
|
|
28
|
+
ConversationEventType["AssistantTurnFinished"] = "assistant_turn_finished";
|
|
29
|
+
ConversationEventType["AssistantTurnFailed"] = "assistant_turn_failed";
|
|
30
|
+
ConversationEventType["ConversationAborted"] = "conversation_aborted";
|
|
31
|
+
/** Agent-authored status headline (set_status tool); session-scoped, not turn-scoped. */
|
|
32
|
+
ConversationEventType["SessionStatus"] = "session_status";
|
|
33
|
+
/** Session title set via the set_session_title tool. */
|
|
34
|
+
ConversationEventType["SessionTitleChanged"] = "session_title_changed";
|
|
35
|
+
/** Session todo list changed via add_todo/update_todo. */
|
|
36
|
+
ConversationEventType["TodosUpdated"] = "todos_updated";
|
|
37
|
+
/**
|
|
38
|
+
* The session's message queue changed — enqueued, removed, reordered, claimed,
|
|
39
|
+
* retired, paused or resumed. Carries the whole queue rather than a delta, so a
|
|
40
|
+
* window that missed an event still converges.
|
|
41
|
+
*/
|
|
42
|
+
ConversationEventType["QueueChanged"] = "queue_changed";
|
|
43
|
+
/**
|
|
44
|
+
* A session attachment (e.g. an ask_card from the ask_user tool) was created
|
|
45
|
+
* or updated. Carries the whole attachment so it can render without a refetch.
|
|
46
|
+
*/
|
|
47
|
+
ConversationEventType["AttachmentUpserted"] = "attachment_upserted";
|
|
48
|
+
/** A session attachment was deleted. */
|
|
49
|
+
ConversationEventType["AttachmentDeleted"] = "attachment_deleted";
|
|
50
|
+
/**
|
|
51
|
+
* Only on a ChatStream sent with `queueIfBusy`: llmd found the session busy
|
|
52
|
+
* and put the message in the session queue instead of running it. The
|
|
53
|
+
* stream ends after this event (no turn, no `complete`).
|
|
54
|
+
*/
|
|
55
|
+
ConversationEventType["TurnQueued"] = "turn_queued";
|
|
56
|
+
})(ConversationEventType || (ConversationEventType = {}));
|
|
57
|
+
/** Parses a TodosUpdated frame's `todosJson` payload. */
|
|
58
|
+
export function safeTodosJson(s) {
|
|
59
|
+
if (!s?.trim())
|
|
60
|
+
return [];
|
|
61
|
+
try {
|
|
62
|
+
const v = JSON.parse(s);
|
|
63
|
+
if (!Array.isArray(v))
|
|
64
|
+
return [];
|
|
65
|
+
return v.map((raw) => {
|
|
66
|
+
const r = raw;
|
|
67
|
+
return {
|
|
68
|
+
id: String(r.id ?? ""),
|
|
69
|
+
description: String(r.description ?? ""),
|
|
70
|
+
status: r.status ?? "pending",
|
|
71
|
+
createdTurnSeq: r.created_turn_seq !== undefined ? Number(r.created_turn_seq) : undefined,
|
|
72
|
+
startedTurnSeq: r.started_turn_seq !== undefined ? Number(r.started_turn_seq) : undefined,
|
|
73
|
+
completedTurnSeq: r.completed_turn_seq !== undefined ? Number(r.completed_turn_seq) : undefined,
|
|
74
|
+
};
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
catch {
|
|
78
|
+
return [];
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Parses an `argumentsJson` payload (ToolCallStreamFinished or
|
|
83
|
+
* ToolExecutionStarted). Yields `{}` for absent, unparseable or non-object
|
|
84
|
+
* input rather than throwing — these arrive from a model.
|
|
85
|
+
*/
|
|
86
|
+
export function safeArgsJson(s) {
|
|
87
|
+
if (!s?.trim())
|
|
88
|
+
return {};
|
|
89
|
+
try {
|
|
90
|
+
const v = JSON.parse(s);
|
|
91
|
+
return v !== null && typeof v === "object" && !Array.isArray(v)
|
|
92
|
+
? v
|
|
93
|
+
: {};
|
|
94
|
+
}
|
|
95
|
+
catch {
|
|
96
|
+
return {};
|
|
97
|
+
}
|
|
98
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/vendor/llmd-types/index.ts"],"names":[],"mappings":"AAEA,cAAc,eAAe,CAAC;AAC9B,cAAc,mBAAmB,CAAC;AAClC,cAAc,yBAAyB,CAAC"}
|