agent-nuvira 3.5.1 → 3.5.5
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/cli/chat.d.ts +42 -0
- package/dist/cli/chat.d.ts.map +1 -1
- package/dist/cli/chat.js +240 -16
- package/dist/cli/chat.js.map +1 -1
- package/dist/cli/edit.d.ts.map +1 -1
- package/dist/cli/edit.js +3 -2
- package/dist/cli/edit.js.map +1 -1
- package/dist/cli/execute.d.ts.map +1 -1
- package/dist/cli/execute.js +10 -3
- package/dist/cli/execute.js.map +1 -1
- package/dist/cli/loop-executor.d.ts +16 -0
- package/dist/cli/loop-executor.d.ts.map +1 -1
- package/dist/cli/loop-executor.js +9 -0
- package/dist/cli/loop-executor.js.map +1 -1
- package/dist/cli/plan.d.ts.map +1 -1
- package/dist/cli/plan.js +18 -6
- package/dist/cli/plan.js.map +1 -1
- package/dist/cli/run.d.ts.map +1 -1
- package/dist/cli/run.js +23 -8
- package/dist/cli/run.js.map +1 -1
- package/dist/cli/ui/answer-view.d.ts +38 -0
- package/dist/cli/ui/answer-view.d.ts.map +1 -0
- package/dist/cli/ui/answer-view.js +72 -0
- package/dist/cli/ui/answer-view.js.map +1 -0
- package/dist/cli/ui/cards.d.ts +61 -0
- package/dist/cli/ui/cards.d.ts.map +1 -0
- package/dist/cli/ui/cards.js +141 -0
- package/dist/cli/ui/cards.js.map +1 -0
- package/dist/cli/ui/highlight.d.ts +32 -0
- package/dist/cli/ui/highlight.d.ts.map +1 -0
- package/dist/cli/ui/highlight.js +261 -0
- package/dist/cli/ui/highlight.js.map +1 -0
- package/dist/cli/ui/index.d.ts +21 -0
- package/dist/cli/ui/index.d.ts.map +1 -0
- package/dist/cli/ui/index.js +14 -0
- package/dist/cli/ui/index.js.map +1 -0
- package/dist/cli/ui/markdown.d.ts +90 -0
- package/dist/cli/ui/markdown.d.ts.map +1 -0
- package/dist/cli/ui/markdown.js +292 -0
- package/dist/cli/ui/markdown.js.map +1 -0
- package/dist/cli/ui/presenter.d.ts +147 -0
- package/dist/cli/ui/presenter.d.ts.map +1 -0
- package/dist/cli/ui/presenter.js +313 -0
- package/dist/cli/ui/presenter.js.map +1 -0
- package/dist/cli/ui/render.d.ts +52 -0
- package/dist/cli/ui/render.d.ts.map +1 -0
- package/dist/cli/ui/render.js +384 -0
- package/dist/cli/ui/render.js.map +1 -0
- package/dist/cli/ui/theme.d.ts +36 -0
- package/dist/cli/ui/theme.d.ts.map +1 -0
- package/dist/cli/ui/theme.js +92 -0
- package/dist/cli/ui/theme.js.map +1 -0
- package/dist/inference/model-entitlement.d.ts +10 -0
- package/dist/inference/model-entitlement.d.ts.map +1 -1
- package/dist/inference/model-entitlement.js +1 -1
- package/dist/inference/model-entitlement.js.map +1 -1
- package/dist/learning/auto-router.d.ts +10 -1
- package/dist/learning/auto-router.d.ts.map +1 -1
- package/dist/learning/auto-router.js +63 -11
- package/dist/learning/auto-router.js.map +1 -1
- package/dist/learning/reasoning-trace.d.ts +21 -1
- package/dist/learning/reasoning-trace.d.ts.map +1 -1
- package/dist/learning/reasoning-trace.js.map +1 -1
- package/dist/learning/resilient-call.d.ts.map +1 -1
- package/dist/learning/resilient-call.js +70 -4
- package/dist/learning/resilient-call.js.map +1 -1
- package/dist/tools/process-liveness.d.ts +227 -0
- package/dist/tools/process-liveness.d.ts.map +1 -0
- package/dist/tools/process-liveness.js +486 -0
- package/dist/tools/process-liveness.js.map +1 -0
- package/dist/tools/registry.d.ts.map +1 -1
- package/dist/tools/registry.js +4 -2
- package/dist/tools/registry.js.map +1 -1
- package/dist/tools/run-registry.d.ts +282 -0
- package/dist/tools/run-registry.d.ts.map +1 -0
- package/dist/tools/run-registry.js +557 -0
- package/dist/tools/run-registry.js.map +1 -0
- package/dist/tools/run-terminal.d.ts +100 -2
- package/dist/tools/run-terminal.d.ts.map +1 -1
- package/dist/tools/run-terminal.js +841 -67
- package/dist/tools/run-terminal.js.map +1 -1
- package/dist/tools/tool-loop.d.ts +46 -0
- package/dist/tools/tool-loop.d.ts.map +1 -1
- package/dist/tools/tool-loop.js +115 -2
- package/dist/tools/tool-loop.js.map +1 -1
- package/dist/web-dashboard/chat-console.d.ts +25 -0
- package/dist/web-dashboard/chat-console.d.ts.map +1 -1
- package/dist/web-dashboard/chat-console.js +16 -1
- package/dist/web-dashboard/chat-console.js.map +1 -1
- package/dist/web-dashboard/server.d.ts.map +1 -1
- package/dist/web-dashboard/server.js +7 -1
- package/dist/web-dashboard/server.js.map +1 -1
- package/dist/web-dashboard/src/types.d.ts +32 -1
- package/dist/web-dashboard/src/types.d.ts.map +1 -1
- package/dist/web-dashboard/task-registry.d.ts +98 -0
- package/dist/web-dashboard/task-registry.d.ts.map +1 -0
- package/dist/web-dashboard/task-registry.js +159 -0
- package/dist/web-dashboard/task-registry.js.map +1 -0
- package/dist/web-dashboard/task-runner.d.ts +155 -5
- package/dist/web-dashboard/task-runner.d.ts.map +1 -1
- package/dist/web-dashboard/task-runner.js +544 -14
- package/dist/web-dashboard/task-runner.js.map +1 -1
- package/package.json +1 -1
- package/src/web-dashboard/public/assets/index-DycGBWwy.js +236 -0
- package/src/web-dashboard/public/assets/index-DycGBWwy.js.map +1 -0
- package/src/web-dashboard/public/index.html +1 -1
- package/src/web-dashboard/public/assets/index-Bik91KJh.js +0 -236
- package/src/web-dashboard/public/assets/index-Bik91KJh.js.map +0 -1
|
@@ -0,0 +1,384 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ANSI renderer — turns the shared markdown AST into a styled terminal string.
|
|
3
|
+
*
|
|
4
|
+
* This is the workhorse for two paths:
|
|
5
|
+
* - the FINAL frame of a streamed answer (the presenter unmounts Ink, then
|
|
6
|
+
* writes this string, exactly as `PipelineBoard.finish()` writes its final
|
|
7
|
+
* frame — so the answer is not erased by Ink's unmount)
|
|
8
|
+
* - NON-TTY output (pipes, CI, `--json-events`), where Ink must not mount
|
|
9
|
+
*
|
|
10
|
+
* It is intentionally a PURE function of (blocks, options): no globals, no
|
|
11
|
+
* terminal probing. Width and colour are passed in, so tests assert on plain
|
|
12
|
+
* strings with `color: false`.
|
|
13
|
+
*/
|
|
14
|
+
import chalk from 'chalk';
|
|
15
|
+
import { parseMarkdown } from './markdown.js';
|
|
16
|
+
import { DARK_THEME } from './theme.js';
|
|
17
|
+
const ANSI_RE = /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g;
|
|
18
|
+
/** Visible width of a string: ANSI stripped, wide glyphs counted as two. */
|
|
19
|
+
export function visibleWidth(s) {
|
|
20
|
+
const plain = s.replace(ANSI_RE, '');
|
|
21
|
+
let w = 0;
|
|
22
|
+
for (const ch of plain) {
|
|
23
|
+
const cp = ch.codePointAt(0);
|
|
24
|
+
if ((cp >= 0x1100 && cp <= 0x115f) ||
|
|
25
|
+
(cp >= 0x2e80 && cp <= 0xa4cf) ||
|
|
26
|
+
(cp >= 0xac00 && cp <= 0xd7a3) ||
|
|
27
|
+
(cp >= 0xf900 && cp <= 0xfaff) ||
|
|
28
|
+
(cp >= 0xfe30 && cp <= 0xfe4f) ||
|
|
29
|
+
(cp >= 0xff00 && cp <= 0xff60) ||
|
|
30
|
+
(cp >= 0xffe0 && cp <= 0xffe6) ||
|
|
31
|
+
(cp >= 0x1f300 && cp <= 0x1faff)) {
|
|
32
|
+
w += 2;
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
w += 1;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return w;
|
|
39
|
+
}
|
|
40
|
+
class Painter {
|
|
41
|
+
theme;
|
|
42
|
+
color;
|
|
43
|
+
width;
|
|
44
|
+
constructor(opts = {}) {
|
|
45
|
+
this.theme = opts.theme ?? DARK_THEME;
|
|
46
|
+
this.width = Math.max(20, opts.width ?? 80);
|
|
47
|
+
this.color = (opts.color ?? true) && this.theme.name !== 'none';
|
|
48
|
+
}
|
|
49
|
+
paint(role, s) {
|
|
50
|
+
if (!this.color)
|
|
51
|
+
return s;
|
|
52
|
+
return chalk.hex(this.theme.color[role])(s);
|
|
53
|
+
}
|
|
54
|
+
bold(s) {
|
|
55
|
+
return this.color ? chalk.bold(s) : s;
|
|
56
|
+
}
|
|
57
|
+
italic(s) {
|
|
58
|
+
return this.color ? chalk.italic(s) : s;
|
|
59
|
+
}
|
|
60
|
+
dim(s) {
|
|
61
|
+
return this.color ? chalk.dim(s) : s;
|
|
62
|
+
}
|
|
63
|
+
underline(s) {
|
|
64
|
+
return this.color ? chalk.underline(s) : s;
|
|
65
|
+
}
|
|
66
|
+
repeat(ch, n) {
|
|
67
|
+
return ch.repeat(Math.max(0, n));
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
const TOKEN_ROLE = {
|
|
71
|
+
plain: 'code',
|
|
72
|
+
keyword: 'keyword',
|
|
73
|
+
boolean: 'number',
|
|
74
|
+
string: 'string',
|
|
75
|
+
number: 'number',
|
|
76
|
+
comment: 'comment',
|
|
77
|
+
func: 'func',
|
|
78
|
+
type: 'type',
|
|
79
|
+
punct: 'punct',
|
|
80
|
+
operator: 'punct',
|
|
81
|
+
};
|
|
82
|
+
/** Render inline runs to styled segments. */
|
|
83
|
+
function inlineSegments(inlines, p, wrap) {
|
|
84
|
+
const out = [];
|
|
85
|
+
const box = (s) => (wrap ? wrap(s) : s);
|
|
86
|
+
for (const inl of inlines) {
|
|
87
|
+
switch (inl.kind) {
|
|
88
|
+
case 'text':
|
|
89
|
+
out.push({ text: inl.text, style: (s) => box(p.paint('text', s)) });
|
|
90
|
+
break;
|
|
91
|
+
case 'code':
|
|
92
|
+
out.push({ text: inl.text, style: (s) => box(p.paint('code', s)) });
|
|
93
|
+
break;
|
|
94
|
+
case 'strong':
|
|
95
|
+
out.push(...inlineSegments(inl.children, p, (s) => box(p.bold(s))));
|
|
96
|
+
break;
|
|
97
|
+
case 'em':
|
|
98
|
+
out.push(...inlineSegments(inl.children, p, (s) => box(p.italic(s))));
|
|
99
|
+
break;
|
|
100
|
+
case 'link':
|
|
101
|
+
out.push({ text: inl.text, style: (s) => box(p.underline(p.paint('link', s))) });
|
|
102
|
+
if (inl.href && inl.href !== inl.text) {
|
|
103
|
+
out.push({ text: ` (${inl.href})`, style: (s) => box(p.dim(s)) });
|
|
104
|
+
}
|
|
105
|
+
break;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
return out;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Greedy wrap over styled segments.
|
|
112
|
+
*
|
|
113
|
+
* Works on PIECES, preserving the original whitespace rather than rejoining
|
|
114
|
+
* words with a single space. That matters for markdown fidelity: a link
|
|
115
|
+
* followed by a period (`[x](y).`) is three runs — `x`, ` (y)`, `.` — and
|
|
116
|
+
* re-inserting a separator between every run would print `x (y) .`. Whitespace
|
|
117
|
+
* runs are the only break opportunities, and a break strips the trailing space.
|
|
118
|
+
*/
|
|
119
|
+
function wrapSegments(segs, width, indent, restIndent = indent) {
|
|
120
|
+
const pieces = [];
|
|
121
|
+
for (const seg of segs) {
|
|
122
|
+
for (const part of seg.text.split(/(\s+)/)) {
|
|
123
|
+
if (part === '')
|
|
124
|
+
continue;
|
|
125
|
+
pieces.push({ text: part, style: seg.style, space: /^\s+$/.test(part) });
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
if (pieces.length === 0)
|
|
129
|
+
return [indent.trimEnd()];
|
|
130
|
+
// Group pieces joined WITHOUT whitespace into atomic chunks, so a period (or
|
|
131
|
+
// any punctuation run) can never be stranded on a line by itself: the whole
|
|
132
|
+
// `(https://example.com).` unit moves together.
|
|
133
|
+
const chunks = [];
|
|
134
|
+
let current = [];
|
|
135
|
+
for (const pc of pieces) {
|
|
136
|
+
if (pc.space) {
|
|
137
|
+
if (current.length)
|
|
138
|
+
chunks.push(current);
|
|
139
|
+
current = [];
|
|
140
|
+
chunks.push([pc]);
|
|
141
|
+
}
|
|
142
|
+
else {
|
|
143
|
+
current.push(pc);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
if (current.length)
|
|
147
|
+
chunks.push(current);
|
|
148
|
+
const restLen = visibleWidth(restIndent);
|
|
149
|
+
const lines = [];
|
|
150
|
+
let line = indent;
|
|
151
|
+
let len = visibleWidth(indent);
|
|
152
|
+
const flush = () => {
|
|
153
|
+
lines.push(line.replace(/\s+$/, ''));
|
|
154
|
+
line = restIndent;
|
|
155
|
+
len = restLen;
|
|
156
|
+
};
|
|
157
|
+
for (const chunk of chunks) {
|
|
158
|
+
const text = chunk.map((c) => c.style(c.text)).join('');
|
|
159
|
+
const w = chunk.reduce((a, c) => a + visibleWidth(c.text), 0);
|
|
160
|
+
if (chunk[0].space) {
|
|
161
|
+
line += text;
|
|
162
|
+
len += w;
|
|
163
|
+
continue;
|
|
164
|
+
}
|
|
165
|
+
if (len + w > width && len > restLen)
|
|
166
|
+
flush();
|
|
167
|
+
line += text;
|
|
168
|
+
len += w;
|
|
169
|
+
}
|
|
170
|
+
if (line.trim())
|
|
171
|
+
lines.push(line.replace(/\s+$/, ''));
|
|
172
|
+
return lines;
|
|
173
|
+
}
|
|
174
|
+
/** Render a code block as a bordered, highlighted box. */
|
|
175
|
+
function renderCodeBox(lang, tokens, p, indent) {
|
|
176
|
+
const inner = Math.max(10, p.width - visibleWidth(indent) - 4);
|
|
177
|
+
const rendered = [];
|
|
178
|
+
for (const line of tokens) {
|
|
179
|
+
const runs = line.map((t) => ({ text: t.text, style: (s) => p.paint(TOKEN_ROLE[t.kind], s) }));
|
|
180
|
+
rendered.push(...wrapCodeLine(runs, inner));
|
|
181
|
+
}
|
|
182
|
+
if (rendered.length === 0)
|
|
183
|
+
rendered.push([]);
|
|
184
|
+
const label = lang ? ` ${lang} ` : '';
|
|
185
|
+
const topFill = p.repeat('─', inner - visibleWidth(label));
|
|
186
|
+
const dim = (s) => p.paint('codeBorder', s);
|
|
187
|
+
const lines = [];
|
|
188
|
+
lines.push(indent + dim('┌') + (lang ? p.paint('accent', label) : '') + dim(topFill + '┐'));
|
|
189
|
+
for (const runs of rendered) {
|
|
190
|
+
const content = runs.map((r) => r.style(r.text)).join('');
|
|
191
|
+
const used = runs.reduce((a, r) => a + visibleWidth(r.text), 0);
|
|
192
|
+
lines.push(indent + dim('│') + content + p.repeat(' ', inner - used) + dim('│'));
|
|
193
|
+
}
|
|
194
|
+
lines.push(indent + dim('└' + p.repeat('─', inner) + '┘'));
|
|
195
|
+
return lines;
|
|
196
|
+
}
|
|
197
|
+
function wrapCodeLine(runs, width) {
|
|
198
|
+
const out = [];
|
|
199
|
+
let cur = [];
|
|
200
|
+
let len = 0;
|
|
201
|
+
const pushChar = (ch, style) => {
|
|
202
|
+
if (len >= width) {
|
|
203
|
+
out.push(cur);
|
|
204
|
+
cur = [];
|
|
205
|
+
len = 0;
|
|
206
|
+
}
|
|
207
|
+
const last = cur[cur.length - 1];
|
|
208
|
+
if (last && last.style === style)
|
|
209
|
+
last.text += ch;
|
|
210
|
+
else
|
|
211
|
+
cur.push({ text: ch, style });
|
|
212
|
+
len += 1;
|
|
213
|
+
};
|
|
214
|
+
for (const run of runs)
|
|
215
|
+
for (const ch of run.text)
|
|
216
|
+
pushChar(ch, run.style);
|
|
217
|
+
out.push(cur);
|
|
218
|
+
return out;
|
|
219
|
+
}
|
|
220
|
+
function inlineToPlain(inl) {
|
|
221
|
+
switch (inl.kind) {
|
|
222
|
+
case 'text':
|
|
223
|
+
case 'code':
|
|
224
|
+
return inl.text;
|
|
225
|
+
case 'link':
|
|
226
|
+
return inl.text;
|
|
227
|
+
case 'strong':
|
|
228
|
+
case 'em':
|
|
229
|
+
return inl.children.map(inlineToPlain).join('');
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
/** Render a pipe table with box-drawing borders. */
|
|
233
|
+
function renderTable(block, p, indent) {
|
|
234
|
+
const cols = Math.max(block.header.length, ...block.rows.map((r) => r.length), 1);
|
|
235
|
+
const widths = new Array(cols).fill(1);
|
|
236
|
+
const cellText = (inl) => inl.map((x) => (x.kind === 'code' ? x.text : inlineToPlain(x))).join('');
|
|
237
|
+
block.header.forEach((cell, idx) => {
|
|
238
|
+
widths[idx] = Math.max(widths[idx], visibleWidth(cellText(cell)));
|
|
239
|
+
});
|
|
240
|
+
for (const row of block.rows) {
|
|
241
|
+
row.forEach((cell, idx) => {
|
|
242
|
+
if (idx < cols)
|
|
243
|
+
widths[idx] = Math.max(widths[idx], visibleWidth(cellText(cell)));
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
const overhead = indent.length + cols * 3 + 1;
|
|
247
|
+
let total = widths.reduce((a, b) => a + b, 0) + overhead;
|
|
248
|
+
while (total > p.width) {
|
|
249
|
+
let widest = 0;
|
|
250
|
+
for (let c = 1; c < cols; c++)
|
|
251
|
+
if (widths[c] > widths[widest])
|
|
252
|
+
widest = c;
|
|
253
|
+
if (widths[widest] <= 1)
|
|
254
|
+
break;
|
|
255
|
+
widths[widest]--;
|
|
256
|
+
total--;
|
|
257
|
+
}
|
|
258
|
+
const border = (left, mid, right) => indent + p.paint('border', left + widths.map((w) => '─'.repeat(w + 2)).join(mid) + right);
|
|
259
|
+
const rowLine = (cells) => {
|
|
260
|
+
const parts = [];
|
|
261
|
+
for (let c = 0; c < cols; c++) {
|
|
262
|
+
const cell = cells[c] ?? [];
|
|
263
|
+
const text = inlineSegments(cell, p).map((s) => s.style(s.text)).join('');
|
|
264
|
+
const pad = Math.max(0, widths[c] - visibleWidth(cellText(cell)));
|
|
265
|
+
parts.push(' ' + text + ' '.repeat(pad) + ' ');
|
|
266
|
+
}
|
|
267
|
+
return indent + p.paint('border', '│') + parts.join(p.paint('border', '│')) + p.paint('border', '│');
|
|
268
|
+
};
|
|
269
|
+
const lines = [border('┌', '┬', '┐'), rowLine(block.header), border('├', '┼', '┤')];
|
|
270
|
+
for (const row of block.rows)
|
|
271
|
+
lines.push(rowLine(row));
|
|
272
|
+
lines.push(border('└', '┴', '┘'));
|
|
273
|
+
return lines;
|
|
274
|
+
}
|
|
275
|
+
function renderList(block, p, indent) {
|
|
276
|
+
const lines = [];
|
|
277
|
+
block.items.forEach((item, idx) => {
|
|
278
|
+
const base = indent + ' '.repeat(item.depth);
|
|
279
|
+
// Each item carries its OWN marker kind, so a bullet nested under an
|
|
280
|
+
// ordered list keeps its bullet instead of inheriting the numbering.
|
|
281
|
+
const marker = item.ordered ? `${item.index || block.start + idx}. ` : '• ';
|
|
282
|
+
const markerWidth = visibleWidth(marker);
|
|
283
|
+
const segs = inlineSegments(item.inlines, p);
|
|
284
|
+
const wrapped = wrapSegments(segs, p.width, base + p.paint('accent', marker), base + ' '.repeat(markerWidth));
|
|
285
|
+
lines.push(...wrapped);
|
|
286
|
+
});
|
|
287
|
+
return lines;
|
|
288
|
+
}
|
|
289
|
+
/** Render the block AST to a string. */
|
|
290
|
+
export function renderBlocks(blocks, opts = {}) {
|
|
291
|
+
const p = new Painter(opts);
|
|
292
|
+
const indent = ' ';
|
|
293
|
+
const out = [];
|
|
294
|
+
let prev;
|
|
295
|
+
for (const block of blocks) {
|
|
296
|
+
switch (block.type) {
|
|
297
|
+
case 'heading': {
|
|
298
|
+
if (out.length && prev !== 'heading')
|
|
299
|
+
out.push('');
|
|
300
|
+
const text = inlineSegments(block.inlines, p).map((s) => s.style(s.text)).join('');
|
|
301
|
+
const bar = block.level === 1 ? '▍ ' : block.level === 2 ? '▎ ' : '';
|
|
302
|
+
out.push(indent + p.bold(p.paint('heading', bar + text)));
|
|
303
|
+
out.push('');
|
|
304
|
+
break;
|
|
305
|
+
}
|
|
306
|
+
case 'paragraph': {
|
|
307
|
+
out.push(...wrapSegments(inlineSegments(block.inlines, p), p.width, indent));
|
|
308
|
+
out.push('');
|
|
309
|
+
break;
|
|
310
|
+
}
|
|
311
|
+
case 'code':
|
|
312
|
+
out.push(...renderCodeBox(block.lang, block.tokens, p, indent));
|
|
313
|
+
out.push('');
|
|
314
|
+
break;
|
|
315
|
+
case 'list':
|
|
316
|
+
out.push(...renderList(block, p, indent));
|
|
317
|
+
out.push('');
|
|
318
|
+
break;
|
|
319
|
+
case 'quote': {
|
|
320
|
+
const inner = renderBlocks(block.blocks, { ...opts, width: p.width - 2 });
|
|
321
|
+
for (const line of inner.replace(/\n+$/, '').split('\n')) {
|
|
322
|
+
out.push(indent + p.paint('muted', '▏ ') + p.italic(p.paint('muted', line.trim())));
|
|
323
|
+
}
|
|
324
|
+
out.push('');
|
|
325
|
+
break;
|
|
326
|
+
}
|
|
327
|
+
case 'table':
|
|
328
|
+
out.push(...renderTable(block, p, indent));
|
|
329
|
+
out.push('');
|
|
330
|
+
break;
|
|
331
|
+
case 'hr':
|
|
332
|
+
out.push(indent + p.paint('faint', '─'.repeat(Math.max(4, p.width - 4))));
|
|
333
|
+
out.push('');
|
|
334
|
+
break;
|
|
335
|
+
}
|
|
336
|
+
prev = block.type;
|
|
337
|
+
}
|
|
338
|
+
return out.join('\n').replace(/\n{3,}/g, '\n\n').replace(/\n+$/, '\n');
|
|
339
|
+
}
|
|
340
|
+
/**
|
|
341
|
+
* A bordered card for structured events (tool call, shell, diff, plan).
|
|
342
|
+
*
|
|
343
|
+
* Kept separate from block rendering because a card is a single visual unit
|
|
344
|
+
* whose height is computable before it is placed in a live view.
|
|
345
|
+
*/
|
|
346
|
+
export function renderCard(card, opts = {}) {
|
|
347
|
+
const p = new Painter(opts);
|
|
348
|
+
const role = card.role ?? 'accent';
|
|
349
|
+
const indent = ' ';
|
|
350
|
+
const head = `${card.icon ? card.icon + ' ' : ''}${card.title}`;
|
|
351
|
+
const body = (card.lines ?? []).map((l) => (typeof l === 'string' ? { text: l } : l));
|
|
352
|
+
const content = Math.max(visibleWidth(head), ...body.map((l) => visibleWidth(l.text)), 1);
|
|
353
|
+
const inner = Math.min(content + 2, Math.max(4, p.width - indent.length - 2));
|
|
354
|
+
const lines = [];
|
|
355
|
+
const border = (s) => p.paint('border', s);
|
|
356
|
+
lines.push(indent + border('╭' + '─'.repeat(inner) + '╮'));
|
|
357
|
+
const headClipped = clip(head, inner - 2);
|
|
358
|
+
lines.push(indent + border('│') + ' ' + p.bold(p.paint(role, headClipped)) + ' '.repeat(Math.max(0, inner - 1 - visibleWidth(headClipped))) + border('│'));
|
|
359
|
+
for (const b of body) {
|
|
360
|
+
const clipped = clip(b.text, inner - 2);
|
|
361
|
+
lines.push(indent + border('│') + ' ' + p.paint(b.role ?? 'muted', clipped) + ' '.repeat(Math.max(0, inner - 1 - visibleWidth(clipped))) + border('│'));
|
|
362
|
+
}
|
|
363
|
+
lines.push(indent + border('╰' + '─'.repeat(inner) + '╯'));
|
|
364
|
+
return lines.join('\n');
|
|
365
|
+
}
|
|
366
|
+
/** Clip a plain string to a visible width, appending an ellipsis when cut. */
|
|
367
|
+
function clip(s, width) {
|
|
368
|
+
if (visibleWidth(s) <= width)
|
|
369
|
+
return s;
|
|
370
|
+
let out = '';
|
|
371
|
+
let w = 0;
|
|
372
|
+
for (const ch of s) {
|
|
373
|
+
if (w + 1 > Math.max(0, width - 1))
|
|
374
|
+
break;
|
|
375
|
+
out += ch;
|
|
376
|
+
w += 1;
|
|
377
|
+
}
|
|
378
|
+
return out + '…';
|
|
379
|
+
}
|
|
380
|
+
/** Render a markdown string to an ANSI string. */
|
|
381
|
+
export function renderMarkdown(md, opts = {}) {
|
|
382
|
+
return renderBlocks(parseMarkdown(md), opts);
|
|
383
|
+
}
|
|
384
|
+
//# sourceMappingURL=render.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"render.js","sourceRoot":"","sources":["../../../src/cli/ui/render.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,aAAa,EAA0C,MAAM,eAAe,CAAC;AACtF,OAAO,EAAE,UAAU,EAA8B,MAAM,YAAY,CAAC;AAgBpE,MAAM,OAAO,GAAG,6EAA6E,CAAC;AAE9F,4EAA4E;AAC5E,MAAM,UAAU,YAAY,CAAC,CAAS;IACpC,MAAM,KAAK,GAAG,CAAC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ACJ,CAAC;IACD,KAAK,CAAC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,GAAG,GAAG,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC;IAC3D,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC;AAED,8EAA8E;AAC9E,SAAS,IAAI,CAAC,CAAS,EAAE,KAAa;IACpC,IAAI,YAAY,CAAC,CAAC,CAAC,IAAI,KAAK;QAAE,OAAO,CAAC,CAAC;IACvC,IAAI,GAAG,GAAG,EAAE,CAAC;IACb,IAAI,CAAC,GAAG,CAAC,CAAC;IACV,KAAK,MAAM,EAAE,IAAI,CAAC,EAAE,CAAC;QACnB,IAAI,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,GAAG,CAAC,CAAC;YAAE,MAAM;QAC1C,GAAG,IAAI,EAAE,CAAC;QACV,CAAC,IAAI,CAAC,CAAC;IACT,CAAC;IACD,OAAO,GAAG,GAAG,GAAG,CAAC;AACnB,CAAC;AAED,kDAAkD;AAClD,MAAM,UAAU,cAAc,CAAC,EAAU,EAAE,OAAsB,EAAE;IACjE,OAAO,YAAY,CAAC,aAAa,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,CAAC;AAC/C,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Theme — semantic colour tokens for the CLI presentation layer.
|
|
3
|
+
*
|
|
4
|
+
* WHY TOKENS, NOT LITERAL COLOURS. The renderers (markdown, code, cards, status
|
|
5
|
+
* lines) must be able to answer "what colour is a heading?" in exactly one
|
|
6
|
+
* place. Call sites ask for a ROLE (`heading`, `keyword`, `error`) and never a
|
|
7
|
+
* hex value, so the whole CLI can be re-themed — dark, light, or a user theme —
|
|
8
|
+
* without touching a single renderer.
|
|
9
|
+
*
|
|
10
|
+
* The same token map feeds BOTH surfaces:
|
|
11
|
+
* - the ANSI string renderer (`render.ts`) via `chalk.hex(...)`
|
|
12
|
+
* - the Ink view (`answer-view.tsx`) via `<Text color={...}>`
|
|
13
|
+
* because Ink accepts a hex string as `color` and chalk accepts one via
|
|
14
|
+
* `chalk.hex`. One palette, two outputs — they cannot drift.
|
|
15
|
+
*
|
|
16
|
+
* Selection: `NUVIRA_THEME=dark|light|none` (default `dark`). `none` means the
|
|
17
|
+
* renderer should not colour at all (handled by the caller / chalk's own level
|
|
18
|
+
* detection). The theme never reaches into `process.stdout.isTTY` — that is the
|
|
19
|
+
* presenter's decision.
|
|
20
|
+
*/
|
|
21
|
+
export type ThemeRole = 'accent' | 'heading' | 'text' | 'muted' | 'faint' | 'success' | 'error' | 'warn' | 'info' | 'link' | 'code' | 'codeBorder' | 'keyword' | 'string' | 'number' | 'comment' | 'func' | 'type' | 'punct' | 'border' | 'user' | 'assistant' | 'diffAdd' | 'diffDel' | 'diffHunk';
|
|
22
|
+
export interface Theme {
|
|
23
|
+
name: string;
|
|
24
|
+
color: Record<ThemeRole, string>;
|
|
25
|
+
}
|
|
26
|
+
/** Dark palette — tuned for a terminal on a dark background. */
|
|
27
|
+
export declare const DARK_THEME: Theme;
|
|
28
|
+
/** Light palette — for a light-background terminal. */
|
|
29
|
+
export declare const LIGHT_THEME: Theme;
|
|
30
|
+
export type ThemeName = 'dark' | 'light' | 'none';
|
|
31
|
+
/** Resolve the active theme from the environment (default: dark). */
|
|
32
|
+
export declare function resolveTheme(env?: NodeJS.ProcessEnv): {
|
|
33
|
+
name: ThemeName;
|
|
34
|
+
theme: Theme;
|
|
35
|
+
};
|
|
36
|
+
//# sourceMappingURL=theme.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../../src/cli/ui/theme.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,MAAM,MAAM,SAAS,GACjB,QAAQ,GACR,SAAS,GACT,MAAM,GACN,OAAO,GACP,OAAO,GACP,SAAS,GACT,OAAO,GACP,MAAM,GACN,MAAM,GACN,MAAM,GACN,MAAM,GACN,YAAY,GACZ,SAAS,GACT,QAAQ,GACR,QAAQ,GACR,SAAS,GACT,MAAM,GACN,MAAM,GACN,OAAO,GACP,QAAQ,GACR,MAAM,GACN,WAAW,GACX,SAAS,GACT,SAAS,GACT,UAAU,CAAC;AAEf,MAAM,WAAW,KAAK;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;CAClC;AAED,gEAAgE;AAChE,eAAO,MAAM,UAAU,EAAE,KA6BxB,CAAC;AAEF,uDAAuD;AACvD,eAAO,MAAM,WAAW,EAAE,KA6BzB,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,CAAC;AAElD,qEAAqE;AACrE,wBAAgB,YAAY,CAAC,GAAG,GAAE,MAAM,CAAC,UAAwB,GAAG;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,KAAK,EAAE,KAAK,CAAA;CAAE,CAKpG"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Theme — semantic colour tokens for the CLI presentation layer.
|
|
3
|
+
*
|
|
4
|
+
* WHY TOKENS, NOT LITERAL COLOURS. The renderers (markdown, code, cards, status
|
|
5
|
+
* lines) must be able to answer "what colour is a heading?" in exactly one
|
|
6
|
+
* place. Call sites ask for a ROLE (`heading`, `keyword`, `error`) and never a
|
|
7
|
+
* hex value, so the whole CLI can be re-themed — dark, light, or a user theme —
|
|
8
|
+
* without touching a single renderer.
|
|
9
|
+
*
|
|
10
|
+
* The same token map feeds BOTH surfaces:
|
|
11
|
+
* - the ANSI string renderer (`render.ts`) via `chalk.hex(...)`
|
|
12
|
+
* - the Ink view (`answer-view.tsx`) via `<Text color={...}>`
|
|
13
|
+
* because Ink accepts a hex string as `color` and chalk accepts one via
|
|
14
|
+
* `chalk.hex`. One palette, two outputs — they cannot drift.
|
|
15
|
+
*
|
|
16
|
+
* Selection: `NUVIRA_THEME=dark|light|none` (default `dark`). `none` means the
|
|
17
|
+
* renderer should not colour at all (handled by the caller / chalk's own level
|
|
18
|
+
* detection). The theme never reaches into `process.stdout.isTTY` — that is the
|
|
19
|
+
* presenter's decision.
|
|
20
|
+
*/
|
|
21
|
+
/** Dark palette — tuned for a terminal on a dark background. */
|
|
22
|
+
export const DARK_THEME = {
|
|
23
|
+
name: 'dark',
|
|
24
|
+
color: {
|
|
25
|
+
accent: '#7aa2f7',
|
|
26
|
+
heading: '#89b4fa',
|
|
27
|
+
text: '#c0caf5',
|
|
28
|
+
muted: '#7f8ea3',
|
|
29
|
+
faint: '#4a5568',
|
|
30
|
+
success: '#9ece6a',
|
|
31
|
+
error: '#f7768e',
|
|
32
|
+
warn: '#e0af68',
|
|
33
|
+
info: '#7dcfff',
|
|
34
|
+
link: '#7dcfff',
|
|
35
|
+
code: '#e6c07b',
|
|
36
|
+
codeBorder: '#3b4261',
|
|
37
|
+
keyword: '#bb9af7',
|
|
38
|
+
string: '#9ece6a',
|
|
39
|
+
number: '#ff9e64',
|
|
40
|
+
comment: '#565f89',
|
|
41
|
+
func: '#7aa2f7',
|
|
42
|
+
type: '#2ac3de',
|
|
43
|
+
punct: '#9aa5ce',
|
|
44
|
+
border: '#3b4261',
|
|
45
|
+
user: '#7aa2f7',
|
|
46
|
+
assistant: '#bb9af7',
|
|
47
|
+
diffAdd: '#9ece6a',
|
|
48
|
+
diffDel: '#f7768e',
|
|
49
|
+
diffHunk: '#7dcfff',
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
/** Light palette — for a light-background terminal. */
|
|
53
|
+
export const LIGHT_THEME = {
|
|
54
|
+
name: 'light',
|
|
55
|
+
color: {
|
|
56
|
+
accent: '#2f5fd0',
|
|
57
|
+
heading: '#1f4fbf',
|
|
58
|
+
text: '#24292f',
|
|
59
|
+
muted: '#57606a',
|
|
60
|
+
faint: '#8c959f',
|
|
61
|
+
success: '#1a7f37',
|
|
62
|
+
error: '#cf222e',
|
|
63
|
+
warn: '#9a6700',
|
|
64
|
+
info: '#0969da',
|
|
65
|
+
link: '#0969da',
|
|
66
|
+
code: '#7a3e00',
|
|
67
|
+
codeBorder: '#d0d7de',
|
|
68
|
+
keyword: '#8250df',
|
|
69
|
+
string: '#0a3069',
|
|
70
|
+
number: '#953800',
|
|
71
|
+
comment: '#6e7781',
|
|
72
|
+
func: '#2f5fd0',
|
|
73
|
+
type: '#116329',
|
|
74
|
+
punct: '#57606a',
|
|
75
|
+
border: '#d0d7de',
|
|
76
|
+
user: '#0969da',
|
|
77
|
+
assistant: '#8250df',
|
|
78
|
+
diffAdd: '#1a7f37',
|
|
79
|
+
diffDel: '#cf222e',
|
|
80
|
+
diffHunk: '#0969da',
|
|
81
|
+
},
|
|
82
|
+
};
|
|
83
|
+
/** Resolve the active theme from the environment (default: dark). */
|
|
84
|
+
export function resolveTheme(env = process.env) {
|
|
85
|
+
const raw = (env.NUVIRA_THEME || '').trim().toLowerCase();
|
|
86
|
+
if (raw === 'light')
|
|
87
|
+
return { name: 'light', theme: LIGHT_THEME };
|
|
88
|
+
if (raw === 'none' || raw === 'plain')
|
|
89
|
+
return { name: 'none', theme: { ...DARK_THEME, name: 'none' } };
|
|
90
|
+
return { name: 'dark', theme: DARK_THEME };
|
|
91
|
+
}
|
|
92
|
+
//# sourceMappingURL=theme.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"theme.js","sourceRoot":"","sources":["../../../src/cli/ui/theme.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAkCH,gEAAgE;AAChE,MAAM,CAAC,MAAM,UAAU,GAAU;IAC/B,IAAI,EAAE,MAAM;IACZ,KAAK,EAAE;QACL,MAAM,EAAE,SAAS;QACjB,OAAO,EAAE,SAAS;QAClB,IAAI,EAAE,SAAS;QACf,KAAK,EAAE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AqE;AACrE,MAAM,UAAU,YAAY,CAAC,MAAyB,OAAO,CAAC,GAAG;IAC/D,MAAM,GAAG,GAAG,CAAC,GAAG,CAAC,YAAY,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IAC1D,IAAI,GAAG,KAAK,OAAO;QAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,CAAC;IAClE,IAAI,GAAG,KAAK,MAAM,IAAI,GAAG,KAAK,OAAO;QAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE,GAAG,UAAU,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,CAAC;IACvG,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,EAAE,CAAC;AAC7C,CAAC"}
|
|
@@ -35,6 +35,16 @@ export interface ModelEntitlement {
|
|
|
35
35
|
*/
|
|
36
36
|
basis: string;
|
|
37
37
|
}
|
|
38
|
+
/**
|
|
39
|
+
* Keyless providers that are genuine LOCAL RUNNERS — inference happens on this
|
|
40
|
+
* machine, so a call cannot bill anyone.
|
|
41
|
+
*
|
|
42
|
+
* `nuvira` is deliberately NOT here even though it is also keyless and also
|
|
43
|
+
* localhost: it is the GATEWAY, whose whole job is forwarding to other
|
|
44
|
+
* providers. A call through it costs whatever the provider behind it costs, so
|
|
45
|
+
* labelling it free would be wrong in the most expensive direction.
|
|
46
|
+
*/
|
|
47
|
+
export declare const LOCAL_RUNTIME_IDS: readonly string[];
|
|
38
48
|
/**
|
|
39
49
|
* Classify one provider × model pair. Pure and total — always returns a tier,
|
|
40
50
|
* never throws, never returns undefined (an unlabelled cell is what made the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model-entitlement.d.ts","sourceRoot":"","sources":["../../src/inference/model-entitlement.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAIH,iDAAiD;AACjD,MAAM,MAAM,eAAe,GAAG,MAAM,GAAG,SAAS,GAAG,SAAS,CAAC;AAE7D,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,eAAe,CAAC;IACtB;;;OAGG;IACH,KAAK,EAAE,MAAM,CAAC;CACf;
|
|
1
|
+
{"version":3,"file":"model-entitlement.d.ts","sourceRoot":"","sources":["../../src/inference/model-entitlement.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAIH,iDAAiD;AACjD,MAAM,MAAM,eAAe,GAAG,MAAM,GAAG,SAAS,GAAG,SAAS,CAAC;AAE7D,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,eAAe,CAAC;IACtB;;;OAGG;IACH,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,iBAAiB,EAAE,SAAS,MAAM,EAA4C,CAAC;AAU5F;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,gBAAgB,CAiD7F;AAED,uDAAuD;AACvD,eAAO,MAAM,gBAAgB,EAAE,MAAM,CAAC,eAAe,EAAE,MAAM,CAI5D,CAAC"}
|
|
@@ -35,7 +35,7 @@ import { getCatalogProvider, isCatalogKeyless } from './provider-catalog.js';
|
|
|
35
35
|
* providers. A call through it costs whatever the provider behind it costs, so
|
|
36
36
|
* labelling it free would be wrong in the most expensive direction.
|
|
37
37
|
*/
|
|
38
|
-
const LOCAL_RUNTIME_IDS = ['local', 'lmstudio', 'vllm', 'ollama'];
|
|
38
|
+
export const LOCAL_RUNTIME_IDS = ['local', 'lmstudio', 'vllm', 'ollama'];
|
|
39
39
|
/** The suffix OpenRouter uses for ids the provider declares free to serve. */
|
|
40
40
|
const PROVIDER_FREE_SUFFIX = ':free';
|
|
41
41
|
/** Format a per-1K-token price for a tooltip (4 significant decimals, trimmed). */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model-entitlement.js","sourceRoot":"","sources":["../../src/inference/model-entitlement.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAc7E;;;;;;;;GAQG;AACH,MAAM,iBAAiB,
|
|
1
|
+
{"version":3,"file":"model-entitlement.js","sourceRoot":"","sources":["../../src/inference/model-entitlement.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAc7E;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAsB,CAAC,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC;AAE5F,8EAA8E;AAC9E,MAAM,oBAAoB,GAAG,OAAO,CAAC;AAErC,mFAAmF;AACnF,SAAS,QAAQ,CAAC,CAAS;IACzB,OAAO,IAAI,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;AACpC,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,wBAAwB,CAAC,QAAgB,EAAE,OAAgB;IACzE,MAAM,EAAE,GAAG,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;IAElC,yEAAyE;IACzE,qEAAqE;IACrE,IAAI,EAAE,CAAC,QAAQ,CAAC,oBAAoB,CAAC,EAAE,CAAC;QACtC,OAAO;YACL,IAAI,EAAE,MAAM;YACZ,KAAK,EAAE,oCAAoC,oBAAoB,WAAW;SAC3E,CAAC;IACJ,CAAC;IAED,kEAAkE;IAClE,IAAI,iBAAiB,CAAC,QAAQ,CAAC,QAA8C,CAAC,EAAE,CAAC;QAC/E,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,yCAAyC,EAAE,CAAC;IAC5E,CAAC;IAED,MAAM,KAAK,GAAG,kBAAkB,CAAC,QAAQ,CAAC,CAAC;IAE3C,yEAAyE;IACzE,wBAAwB;IACxB,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,sDAAsD,EAAE,CAAC;IAC5F,CAAC;IAED,MAAM,EAAE,UAAU,EAAE,WAAW,EAAE,GAAG,KAAK,CAAC,OAAO,CAAC;IAElD,8EAA8E;IAC9E,kDAAkD;IAClD,IAAI,UAAU,GAAG,CAAC,IAAI,WAAW,GAAG,CAAC,EAAE,CAAC;QACtC,OAAO;YACL,IAAI,EAAE,SAAS;YACf,KAAK,EAAE,cAAc,QAAQ,CAAC,UAAU,CAAC,IAAI,QAAQ,CAAC,WAAW,CAAC,+EAA+E;SAClJ,CAAC;IACJ,CAAC;IAED,4EAA4E;IAC5E,2EAA2E;IAC3E,IAAI,gBAAgB,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC/B,OAAO;YACL,IAAI,EAAE,SAAS;YACf,KAAK,EAAE,2EAA2E;SACnF,CAAC;IACJ,CAAC;IAED,OAAO;QACL,IAAI,EAAE,SAAS;QACf,KAAK,EAAE,oFAAoF;KAC5F,CAAC;AACJ,CAAC;AAED,uDAAuD;AACvD,MAAM,CAAC,MAAM,gBAAgB,GAAoC;IAC/D,IAAI,EAAE,SAAS;IACf,OAAO,EAAE,YAAY;IACrB,OAAO,EAAE,gBAAgB;CAC1B,CAAC"}
|
|
@@ -966,7 +966,16 @@ export declare class AutoModelRouter {
|
|
|
966
966
|
* - best-effort: a registry failure returns the original pick unchanged.
|
|
967
967
|
*/
|
|
968
968
|
private capabilityGuardedPick;
|
|
969
|
-
resolveModel(provider: string, agentType: string, configManager?: ConfigManager, taskDescription?: string
|
|
969
|
+
resolveModel(provider: string, agentType: string, configManager?: ConfigManager, taskDescription?: string,
|
|
970
|
+
/**
|
|
971
|
+
* Does this ask need capacity (see `isAgenticTask`)? Optional and default
|
|
972
|
+
* false, so every existing caller keeps the health-first pick: only a caller
|
|
973
|
+
* that KNOWS the ask is agentic (chat's route and handoff do) can ask for the
|
|
974
|
+
* stronger sibling.
|
|
975
|
+
*/
|
|
976
|
+
opts?: {
|
|
977
|
+
agenticAsk?: boolean;
|
|
978
|
+
}): string;
|
|
970
979
|
/**
|
|
971
980
|
* Pick the best model within the selected provider, given a list of model
|
|
972
981
|
* descriptors (e.g., from provider.listModels()). Keeps the configured model
|