agent-nuvira 3.5.0 → 3.5.2
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/README.md +13 -13
- package/dist/agent-sdk/src/scaffold.d.ts +1 -1
- package/dist/agent-sdk/src/scaffold.js +1 -1
- package/dist/cli/chat.d.ts +159 -6
- package/dist/cli/chat.d.ts.map +1 -1
- package/dist/cli/chat.js +583 -35
- package/dist/cli/chat.js.map +1 -1
- package/dist/cli/duties.d.ts +11 -0
- package/dist/cli/duties.d.ts.map +1 -1
- package/dist/cli/duties.js +31 -0
- package/dist/cli/duties.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/models.d.ts.map +1 -1
- package/dist/cli/models.js +55 -0
- package/dist/cli/models.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 +38 -1
- package/dist/learning/auto-router.d.ts.map +1 -1
- package/dist/learning/auto-router.js +139 -8
- package/dist/learning/auto-router.js.map +1 -1
- package/dist/learning/duty-lease.d.ts +163 -0
- package/dist/learning/duty-lease.d.ts.map +1 -0
- package/dist/learning/duty-lease.js +301 -0
- package/dist/learning/duty-lease.js.map +1 -0
- package/dist/learning/model-first-router.d.ts +14 -0
- package/dist/learning/model-first-router.d.ts.map +1 -1
- package/dist/learning/model-first-router.js +54 -17
- package/dist/learning/model-first-router.js.map +1 -1
- package/dist/learning/model-warmup.d.ts +92 -0
- package/dist/learning/model-warmup.d.ts.map +1 -1
- package/dist/learning/model-warmup.js +137 -2
- package/dist/learning/model-warmup.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/learning/retry-patience.d.ts +139 -0
- package/dist/learning/retry-patience.d.ts.map +1 -0
- package/dist/learning/retry-patience.js +169 -0
- package/dist/learning/retry-patience.js.map +1 -0
- 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 +544 -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 +87 -3
- package/dist/tools/tool-loop.d.ts.map +1 -1
- package/dist/tools/tool-loop.js +375 -6
- 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 +505 -14
- package/dist/web-dashboard/task-runner.js.map +1 -1
- package/package.json +4 -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-yky0dw5e.js +0 -236
- package/src/web-dashboard/public/assets/index-yky0dw5e.js.map +0 -1
|
@@ -0,0 +1,313 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Presenter — decides HOW a model answer reaches the terminal, and owns the
|
|
3
|
+
* streaming lifecycle.
|
|
4
|
+
*
|
|
5
|
+
* THE ONE RULE: rich rendering is a TTY-only affordance. Pipes, CI, `--json-events`
|
|
6
|
+
* and `NUVIRA_UI=plain` all keep the historical plain-text behaviour, so a
|
|
7
|
+
* script consuming stdout is never handed escape codes or reflowed borders.
|
|
8
|
+
* That mirrors the fallback `PipelineBoard` already implements for its board.
|
|
9
|
+
*
|
|
10
|
+
* STREAMING. `AnswerStream` mounts Ink while tokens arrive. Ink's frame is
|
|
11
|
+
* transient, so `finish()` UNMOUNTS Ink and writes the final frame with the ANSI
|
|
12
|
+
* renderer — the same "unmount then write the final frame" step the board uses.
|
|
13
|
+
* The answer therefore survives in the transcript instead of being erased.
|
|
14
|
+
*/
|
|
15
|
+
import { createElement } from 'react';
|
|
16
|
+
import { render } from 'ink';
|
|
17
|
+
import { renderMarkdown, renderCard } from './render.js';
|
|
18
|
+
import { attachShellCards, gitDiffCard, toolCallCard } from './cards.js';
|
|
19
|
+
import { resolveTheme } from './theme.js';
|
|
20
|
+
import { LiveAnswer } from './answer-view.js';
|
|
21
|
+
import { isJsonLogMode } from '../../enterprise/log.js';
|
|
22
|
+
/** True when the rich presentation layer may be used for this stream. */
|
|
23
|
+
export function shouldUseRichUi(opts = {}) {
|
|
24
|
+
const env = opts.env ?? process.env;
|
|
25
|
+
if (isJsonLogMode())
|
|
26
|
+
return false;
|
|
27
|
+
const mode = (env.NUVIRA_UI || '').trim().toLowerCase();
|
|
28
|
+
if (mode === 'plain' || mode === 'text' || mode === 'off')
|
|
29
|
+
return false;
|
|
30
|
+
if (opts.tty !== undefined)
|
|
31
|
+
return opts.tty;
|
|
32
|
+
const stream = opts.stream ?? process.stdout;
|
|
33
|
+
return stream.isTTY === true;
|
|
34
|
+
}
|
|
35
|
+
function resolve(opts) {
|
|
36
|
+
const env = opts.env ?? process.env;
|
|
37
|
+
const stream = opts.stream ?? process.stdout;
|
|
38
|
+
const { name, theme } = resolveTheme(env);
|
|
39
|
+
const width = opts.width ?? stream.columns ?? 80;
|
|
40
|
+
const rich = shouldUseRichUi(opts);
|
|
41
|
+
const color = opts.color ?? (name !== 'none' && !('NO_COLOR' in env));
|
|
42
|
+
return { rich, theme: opts.theme ?? theme, themeName: name, width, color, stream };
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Render a complete markdown answer to the string that would be printed.
|
|
46
|
+
*
|
|
47
|
+
* The non-rich path is a BYTE-IDENTICAL passthrough: a piped or CI consumer
|
|
48
|
+
* must receive exactly what it received before this layer existed, so the
|
|
49
|
+
* markdown is never rewritten on the way out.
|
|
50
|
+
*/
|
|
51
|
+
export function renderAnswer(markdown, opts = {}) {
|
|
52
|
+
if (!markdown)
|
|
53
|
+
return '';
|
|
54
|
+
const r = resolve(opts);
|
|
55
|
+
if (!r.rich)
|
|
56
|
+
return markdown;
|
|
57
|
+
return renderMarkdown(markdown, { theme: r.theme, width: r.width, color: r.color });
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Print a complete answer. Returns the written string so callers (and tests)
|
|
61
|
+
* can assert on exactly what a surface produced.
|
|
62
|
+
*
|
|
63
|
+
* The non-rich path deliberately goes through `console.log` when no stream was
|
|
64
|
+
* injected: that is the channel this CLI has always used for answers, and both
|
|
65
|
+
* the test suite and any log-capturing wrapper depend on it. Rich output is
|
|
66
|
+
* written straight to the stream because it is a composed frame, not a line.
|
|
67
|
+
*/
|
|
68
|
+
export function presentAnswer(markdown, opts = {}) {
|
|
69
|
+
if (!markdown)
|
|
70
|
+
return '';
|
|
71
|
+
const r = resolve(opts);
|
|
72
|
+
if (!r.rich) {
|
|
73
|
+
if (opts.stream)
|
|
74
|
+
r.stream.write(markdown + (markdown.endsWith('\n') ? '' : '\n'));
|
|
75
|
+
else
|
|
76
|
+
console.log(markdown);
|
|
77
|
+
return markdown;
|
|
78
|
+
}
|
|
79
|
+
const out = renderMarkdown(markdown, { theme: r.theme, width: r.width, color: r.color });
|
|
80
|
+
r.stream.write(out + (out.endsWith('\n') ? '' : '\n'));
|
|
81
|
+
return out;
|
|
82
|
+
}
|
|
83
|
+
/** Print a structured card (tool call, shell, diff, plan). */
|
|
84
|
+
export function presentCard(card, opts = {}) {
|
|
85
|
+
const r = resolve(opts);
|
|
86
|
+
const out = renderCard(card, { theme: r.theme, width: r.width, color: r.color });
|
|
87
|
+
r.stream.write(out + '\n');
|
|
88
|
+
return out;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* A card sink for a surface with NO live Ink frame (the `execute` loop arm).
|
|
92
|
+
*
|
|
93
|
+
* Cards are written straight to the transcript as they arrive — no pause/resume
|
|
94
|
+
* is needed because nothing else owns the terminal. The finished tool call is
|
|
95
|
+
* the one that gets a card; `started` is ignored because the outcome is what a
|
|
96
|
+
* reader needs and a card that is replaced a moment later is noise.
|
|
97
|
+
*
|
|
98
|
+
* Off a real terminal this is INERT (no overrides, nothing written), so a piped
|
|
99
|
+
* or CI `execute` keeps the exact bytes it produced before cards existed.
|
|
100
|
+
*/
|
|
101
|
+
export function createCardSink(opts = {}) {
|
|
102
|
+
if (!shouldUseRichUi(opts))
|
|
103
|
+
return { overrides: {}, stop: () => { } };
|
|
104
|
+
const write = (card) => {
|
|
105
|
+
presentCard(card, opts);
|
|
106
|
+
};
|
|
107
|
+
return {
|
|
108
|
+
overrides: {
|
|
109
|
+
onToolCall: (phase, info) => {
|
|
110
|
+
if (phase === 'called')
|
|
111
|
+
write(toolCallCard(info));
|
|
112
|
+
},
|
|
113
|
+
onGitDiff: (payload) => write(gitDiffCard(payload)),
|
|
114
|
+
},
|
|
115
|
+
stop: attachShellCards(write),
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Live-streaming answer view.
|
|
120
|
+
*
|
|
121
|
+
* Usage:
|
|
122
|
+
* const stream = new AnswerStream({ header: 'nuvira · groq/llama-3.3-70b' });
|
|
123
|
+
* stream.begin();
|
|
124
|
+
* // ... onToken: (t) => stream.append(t) ...
|
|
125
|
+
* const final = stream.finish();
|
|
126
|
+
*/
|
|
127
|
+
export class AnswerStream {
|
|
128
|
+
r;
|
|
129
|
+
text = '';
|
|
130
|
+
meta;
|
|
131
|
+
ink = null;
|
|
132
|
+
flushTimer = null;
|
|
133
|
+
pending = false;
|
|
134
|
+
closed = false;
|
|
135
|
+
constructor(meta = {}, opts = {}) {
|
|
136
|
+
this.r = resolve(opts);
|
|
137
|
+
this.meta = meta;
|
|
138
|
+
}
|
|
139
|
+
/** Begin the live view (mounts Ink on a TTY; a no-op otherwise). */
|
|
140
|
+
begin(meta = {}) {
|
|
141
|
+
this.meta = { ...this.meta, ...meta };
|
|
142
|
+
if (this.r.rich)
|
|
143
|
+
this.mount();
|
|
144
|
+
return this;
|
|
145
|
+
}
|
|
146
|
+
/** Append streamed text. Safe to call with empty/undefined deltas. */
|
|
147
|
+
append(delta) {
|
|
148
|
+
if (delta)
|
|
149
|
+
this.text += delta;
|
|
150
|
+
this.scheduleFlush();
|
|
151
|
+
return this;
|
|
152
|
+
}
|
|
153
|
+
/** Replace the inline note (e.g. "thinking…" → "writing…"). */
|
|
154
|
+
setNote(note) {
|
|
155
|
+
this.meta = { ...this.meta, note };
|
|
156
|
+
this.scheduleFlush();
|
|
157
|
+
return this;
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Discard the text accumulated so far.
|
|
161
|
+
*
|
|
162
|
+
* Needed because `onToken` fires for EVERY model call in the tool loop, not
|
|
163
|
+
* only the final answer: without this, the next step's answer would be
|
|
164
|
+
* appended onto the previous step's preamble.
|
|
165
|
+
*/
|
|
166
|
+
reset() {
|
|
167
|
+
this.text = '';
|
|
168
|
+
this.scheduleFlush();
|
|
169
|
+
return this;
|
|
170
|
+
}
|
|
171
|
+
/** The text accumulated so far. */
|
|
172
|
+
get current() {
|
|
173
|
+
return this.text;
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Suspend the live view so static output can be written below it.
|
|
177
|
+
*
|
|
178
|
+
* Ink owns the frame, so anything printed while it is mounted collides with
|
|
179
|
+
* the next repaint. Cards are archived output (they must survive), so the
|
|
180
|
+
* frame is unmounted, the card written, then the frame remounted — the same
|
|
181
|
+
* stop/start discipline `PipelineBoard` uses around interactive prompts.
|
|
182
|
+
*/
|
|
183
|
+
pause() {
|
|
184
|
+
if (this.flushTimer) {
|
|
185
|
+
clearTimeout(this.flushTimer);
|
|
186
|
+
this.flushTimer = null;
|
|
187
|
+
this.pending = false;
|
|
188
|
+
}
|
|
189
|
+
if (this.ink) {
|
|
190
|
+
try {
|
|
191
|
+
this.ink.unmount();
|
|
192
|
+
}
|
|
193
|
+
catch {
|
|
194
|
+
/* best-effort */
|
|
195
|
+
}
|
|
196
|
+
this.ink = null;
|
|
197
|
+
}
|
|
198
|
+
return this;
|
|
199
|
+
}
|
|
200
|
+
/** Remount the live view after {@link pause} (no-op when nothing was mounted). */
|
|
201
|
+
resume() {
|
|
202
|
+
if (!this.r.rich || this.closed)
|
|
203
|
+
return this;
|
|
204
|
+
this.mount();
|
|
205
|
+
this.repaint();
|
|
206
|
+
return this;
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Print a card into the transcript, above the live view.
|
|
210
|
+
*
|
|
211
|
+
* Rich terminals only: a piped or CI stream keeps the exact bytes it produced
|
|
212
|
+
* before cards existed, which is also why the card is not attempted at all
|
|
213
|
+
* when rich output is unavailable.
|
|
214
|
+
*/
|
|
215
|
+
card(card) {
|
|
216
|
+
if (!this.r.rich)
|
|
217
|
+
return;
|
|
218
|
+
const wasMounted = this.ink !== null;
|
|
219
|
+
if (wasMounted)
|
|
220
|
+
this.pause();
|
|
221
|
+
const out = renderCard(card, { theme: this.r.theme, width: this.r.width, color: this.r.color });
|
|
222
|
+
this.r.stream.write(out + '\n');
|
|
223
|
+
if (wasMounted)
|
|
224
|
+
this.resume();
|
|
225
|
+
}
|
|
226
|
+
mount() {
|
|
227
|
+
try {
|
|
228
|
+
this.ink = render(this.element(), {
|
|
229
|
+
stdout: this.r.stream,
|
|
230
|
+
patchConsole: false,
|
|
231
|
+
// The CLI owns SIGINT (the REPL installs its own handler); letting Ink
|
|
232
|
+
// also grab Ctrl+C would race that handler and can exit the process.
|
|
233
|
+
exitOnCtrlC: false,
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
catch {
|
|
237
|
+
// Rendering must never break a turn — fall back to no live view.
|
|
238
|
+
this.ink = null;
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
element(note) {
|
|
242
|
+
return createElement(LiveAnswer, {
|
|
243
|
+
text: this.text,
|
|
244
|
+
theme: this.r.theme,
|
|
245
|
+
header: this.meta.header,
|
|
246
|
+
headerColor: this.meta.headerColor,
|
|
247
|
+
note: note ?? this.meta.note,
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
/** Coalesce high-frequency token updates into ~20fps repaints. */
|
|
251
|
+
scheduleFlush() {
|
|
252
|
+
if (!this.ink || this.closed)
|
|
253
|
+
return;
|
|
254
|
+
if (this.pending)
|
|
255
|
+
return;
|
|
256
|
+
this.pending = true;
|
|
257
|
+
this.flushTimer = setTimeout(() => {
|
|
258
|
+
this.pending = false;
|
|
259
|
+
this.flushTimer = null;
|
|
260
|
+
this.repaint();
|
|
261
|
+
}, 50);
|
|
262
|
+
this.flushTimer.unref?.();
|
|
263
|
+
}
|
|
264
|
+
repaint() {
|
|
265
|
+
if (!this.ink)
|
|
266
|
+
return;
|
|
267
|
+
try {
|
|
268
|
+
this.ink.rerender(this.element());
|
|
269
|
+
}
|
|
270
|
+
catch {
|
|
271
|
+
/* a repaint failure must not break the stream */
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* Finish the stream: unmount the transient Ink frame, then write the final
|
|
276
|
+
* archival frame. Returns the final rendered string.
|
|
277
|
+
*
|
|
278
|
+
* `archive: false` unmounts WITHOUT printing a frame. A caller that will
|
|
279
|
+
* print the authoritative answer itself (the REPL, which renders the final
|
|
280
|
+
* `answer.content` rather than the raw token stream) must use it, or the
|
|
281
|
+
* answer would be printed twice.
|
|
282
|
+
*/
|
|
283
|
+
finish(opts = {}) {
|
|
284
|
+
const archive = opts.archive ?? true;
|
|
285
|
+
if (this.closed)
|
|
286
|
+
return '';
|
|
287
|
+
this.closed = true;
|
|
288
|
+
if (this.flushTimer) {
|
|
289
|
+
clearTimeout(this.flushTimer);
|
|
290
|
+
this.flushTimer = null;
|
|
291
|
+
}
|
|
292
|
+
if (this.ink) {
|
|
293
|
+
try {
|
|
294
|
+
this.ink.unmount();
|
|
295
|
+
}
|
|
296
|
+
catch {
|
|
297
|
+
/* best-effort */
|
|
298
|
+
}
|
|
299
|
+
this.ink = null;
|
|
300
|
+
}
|
|
301
|
+
if (!archive)
|
|
302
|
+
return '';
|
|
303
|
+
// The final frame is the archival output and is always printed. Non-rich
|
|
304
|
+
// streams get the raw markdown, byte-identical to the pre-layer behaviour.
|
|
305
|
+
const out = this.r.rich
|
|
306
|
+
? renderMarkdown(this.text, { theme: this.r.theme, width: this.r.width, color: this.r.color })
|
|
307
|
+
: this.text;
|
|
308
|
+
if (out)
|
|
309
|
+
this.r.stream.write(out + (out.endsWith('\n') ? '' : '\n'));
|
|
310
|
+
return out;
|
|
311
|
+
}
|
|
312
|
+
}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AC;QAClB,CAAC;QACD,IAAI,CAAC,OAAO;YAAE,OAAO,EAAE,CAAC;QACxB,yEAAyE;QACzE,2EAA2E;QAC3E,MAAM,GAAG,GAAG,IAAI,CAAC,CAAC,CAAC,IAAI;YACrB,CAAC,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC;YAC9F,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;QACd,IAAI,GAAG;YAAE,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,GAAG,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;QACrE,OAAO,GAAG,CAAC;IACb,CAAC;CACF"}
|
|
@@ -0,0 +1,52 @@
|
|
|
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 { type Block } from './markdown.js';
|
|
15
|
+
import { type Theme, type ThemeRole } from './theme.js';
|
|
16
|
+
export interface RenderOptions {
|
|
17
|
+
theme?: Theme;
|
|
18
|
+
/** Terminal width (columns). Defaults to 80. */
|
|
19
|
+
width?: number;
|
|
20
|
+
/** Emit ANSI colour. Defaults to true (chalk still honours its own level). */
|
|
21
|
+
color?: boolean;
|
|
22
|
+
}
|
|
23
|
+
/** Visible width of a string: ANSI stripped, wide glyphs counted as two. */
|
|
24
|
+
export declare function visibleWidth(s: string): number;
|
|
25
|
+
/** Render the block AST to a string. */
|
|
26
|
+
export declare function renderBlocks(blocks: readonly Block[], opts?: RenderOptions): string;
|
|
27
|
+
/**
|
|
28
|
+
* A card body line. A bare string is rendered muted; the object form lets a
|
|
29
|
+
* caller colour one line — which is what makes a git diff readable (added /
|
|
30
|
+
* removed / hunk lines each take their own role).
|
|
31
|
+
*/
|
|
32
|
+
export interface CardLine {
|
|
33
|
+
text: string;
|
|
34
|
+
role?: ThemeRole;
|
|
35
|
+
}
|
|
36
|
+
export interface CardOptions {
|
|
37
|
+
icon?: string;
|
|
38
|
+
title: string;
|
|
39
|
+
lines?: Array<string | CardLine>;
|
|
40
|
+
/** Accent role for the title. */
|
|
41
|
+
role?: ThemeRole;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* A bordered card for structured events (tool call, shell, diff, plan).
|
|
45
|
+
*
|
|
46
|
+
* Kept separate from block rendering because a card is a single visual unit
|
|
47
|
+
* whose height is computable before it is placed in a live view.
|
|
48
|
+
*/
|
|
49
|
+
export declare function renderCard(card: CardOptions, opts?: RenderOptions): string;
|
|
50
|
+
/** Render a markdown string to an ANSI string. */
|
|
51
|
+
export declare function renderMarkdown(md: string, opts?: RenderOptions): string;
|
|
52
|
+
//# sourceMappingURL=render.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../../../src/cli/ui/render.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAIH,OAAO,EAAiB,KAAK,KAAK,EAA8B,MAAM,eAAe,CAAC;AACtF,OAAO,EAAc,KAAK,KAAK,EAAE,KAAK,SAAS,EAAE,MAAM,YAAY,CAAC;AAGpE,MAAM,WAAW,aAAa;IAC5B,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,gDAAgD;IAChD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,8EAA8E;IAC9E,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AASD,4EAA4E;AAC5E,wBAAgB,YAAY,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAqB9C;AA0QD,wCAAwC;AACxC,wBAAgB,YAAY,CAAC,MAAM,EAAE,SAAS,KAAK,EAAE,EAAE,IAAI,GAAE,aAAkB,GAAG,MAAM,CAkDvF;AAED;;;;GAIG;AACH,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,SAAS,CAAC;CAClB;AAED,MAAM,WAAW,WAAW;IAC1B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,KAAK,CAAC,MAAM,GAAG,QAAQ,CAAC,CAAC;IACjC,iCAAiC;IACjC,IAAI,CAAC,EAAE,SAAS,CAAC;CAClB;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,WAAW,EAAE,IAAI,GAAE,aAAkB,GAAG,MAAM,CAwB9E;AAeD,kDAAkD;AAClD,wBAAgB,cAAc,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,GAAE,aAAkB,GAAG,MAAM,CAE3E"}
|