aegiscode 6.8.35 → 6.8.37
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 +4 -3
- package/bin/aegiscode.js +15 -3
- package/package.json +1 -1
- package/src/app.js +113 -36
- package/src/chatflow.js +285 -39
- package/src/commands.js +79 -29
- package/src/config.js +41 -11
- package/src/engine.js +33 -4
- package/src/entitlement.js +30 -1
- package/src/format.js +175 -3
- package/src/overlays.js +13 -9
- package/src/panels.js +19 -6
- package/src/render.js +49 -14
- package/src/screen.js +12 -1
- package/src/screens.js +118 -25
- package/src/todos.js +7 -4
- package/src/tokens.js +31 -1
- package/vendor/desktop/lib/local/engine.js +113 -2
- package/vendor/desktop/renderer/usage.js +206 -20
- package/vendor/mcp/tools.js +1 -1
package/src/chatflow.js
CHANGED
|
@@ -44,13 +44,13 @@ const {
|
|
|
44
44
|
KEY, STREAM_END, attachKeyStream, nextKey, nextKeyTimeout, requeueKeys, resetKeyStream,
|
|
45
45
|
markSessionStart, isKeyStreamSuspended,
|
|
46
46
|
} = require('./events.js');
|
|
47
|
-
const { GLYPH, VERBS, DONE_VERBS, BOLD, BOLD_OFF, themeOf } = require('./theme.js');
|
|
47
|
+
const { GLYPH, VERBS, DONE_VERBS, BOLD, BOLD_OFF, themeOf, RGB } = require('./theme.js');
|
|
48
48
|
const { LineEditor } = require('./input.js');
|
|
49
49
|
const { renderMarkdown } = require('./markdown.js');
|
|
50
50
|
const overlays = require('./overlays.js');
|
|
51
51
|
const models = require('./models.js');
|
|
52
52
|
const fuzzy = require('./fuzzy.js');
|
|
53
|
-
const { fmtTokens, fmtEur, fmtElapsed, pathName } = require('./format.js');
|
|
53
|
+
const { fmtTokens, fmtEur, fmtElapsed, fmtUsageSplit, displayTokens, pathName, feeBillable } = require('./format.js');
|
|
54
54
|
const { editPreview } = require('./diff.js');
|
|
55
55
|
const { renderDiffBlock, defaultOpen } = require('./diffview.js');
|
|
56
56
|
const { copyToClipboard, describeCopy, readClipboardText, readClipboardImage } = require('./clipboard.js');
|
|
@@ -58,6 +58,14 @@ const { transcriptToMarkdown } = require('./export.js');
|
|
|
58
58
|
const fs = require('node:fs');
|
|
59
59
|
const path = require('node:path');
|
|
60
60
|
const { aegisDir, loadConfig } = require('./config.js');
|
|
61
|
+
const { effortRung } = require('./engine.js');
|
|
62
|
+
// The shared usage normaliser, reached through the CLI's own accounting module
|
|
63
|
+
// rather than by hand-rolling `input_tokens ?? prompt_tokens` at each render
|
|
64
|
+
// site (see the meta row's comment). tokens.js re-exports it, so chatflow does
|
|
65
|
+
// not have to resolve the desktop bundle itself — and deps.js, which already
|
|
66
|
+
// carries it, would pull the engine, the client and the tool registry into the
|
|
67
|
+
// renderer's require graph.
|
|
68
|
+
const { usageBuckets, estimateTokensFromCells } = require('./tokens.js');
|
|
61
69
|
// /ping — the terminal's half of the desktop's "reply ready" alert. Pure, so
|
|
62
70
|
// the loop only has to supply the stream and the elapsed time.
|
|
63
71
|
const { pingTurn } = require('./ping.js');
|
|
@@ -148,6 +156,22 @@ function resolveToolDone(transcript, t) {
|
|
|
148
156
|
return m;
|
|
149
157
|
}
|
|
150
158
|
|
|
159
|
+
/**
|
|
160
|
+
* Tool names whose `file_path` means the file was WRITTEN, not read.
|
|
161
|
+
*
|
|
162
|
+
* The summary used to collect `args.file_path || args.path || args.notebook_path`
|
|
163
|
+
* from every tool, so any read-only call that names a file counted as a change:
|
|
164
|
+
* a turn that only looked at the home folder (`Read`, `Grep`, `Glob`, `List`)
|
|
165
|
+
* ended with "N files changed" under an answer that wrote nothing. The reader
|
|
166
|
+
* is asked to trust that line, so it may only fire on a tool that can mutate a
|
|
167
|
+
* file. `editFile`/`writeFile` are this host's spellings; `Write`/`Edit`/
|
|
168
|
+
* `MultiEdit`/`NotebookEdit` are the engine's — `cli/src/diff.js` accepts both,
|
|
169
|
+
* and this list must stay in step with it.
|
|
170
|
+
*/
|
|
171
|
+
const MUTATING_FILES = new Set([
|
|
172
|
+
'Edit', 'Write', 'MultiEdit', 'NotebookEdit', 'editFile', 'writeFile',
|
|
173
|
+
]);
|
|
174
|
+
|
|
151
175
|
/**
|
|
152
176
|
* Fold one turn's tool events into the counts the end-of-turn summary prints.
|
|
153
177
|
*
|
|
@@ -171,7 +195,8 @@ function summarizeTurnTools(tools, { maxNames = 3 } = {}) {
|
|
|
171
195
|
if (tool.ok === false) failed += 1;
|
|
172
196
|
const args = tool.args;
|
|
173
197
|
if (!args || typeof args !== 'object') continue;
|
|
174
|
-
const
|
|
198
|
+
const writes = MUTATING_FILES.has(tool.name);
|
|
199
|
+
const file = writes ? args.file_path || args.path || args.notebook_path : null;
|
|
175
200
|
if (typeof file === 'string' && file && !files.includes(file)) files.push(file);
|
|
176
201
|
const cmd = args.command;
|
|
177
202
|
if (typeof cmd === 'string' && cmd.trim()) {
|
|
@@ -247,17 +272,38 @@ function headerLine(version, cols, ctx) {
|
|
|
247
272
|
|
|
248
273
|
const separatorLine = (cols, ctx) => [span(themeOf(ctx).dim, '─'.repeat(cols))];
|
|
249
274
|
|
|
250
|
-
/** The idle bottom-left line: which effort level the next turn runs at.
|
|
275
|
+
/** The idle bottom-left line: which effort level the next turn runs at.
|
|
276
|
+
* Always one of the three rungs — `high` when the session has no stored rung,
|
|
277
|
+
* which is the value the request will actually carry (see effortRung). */
|
|
251
278
|
function effortLine(ctx, cols) {
|
|
252
279
|
const t = themeOf(ctx);
|
|
253
|
-
const txt = `● ${ctx.effort
|
|
280
|
+
const txt = `● ${effortRung(ctx.effort)} · /effort`;
|
|
254
281
|
const pad = ' '.repeat(Math.max(0, cols - [...txt].length - 4));
|
|
255
282
|
return [span(t.gray, pad + txt)];
|
|
256
283
|
}
|
|
257
284
|
|
|
285
|
+
/**
|
|
286
|
+
* The non-peak colour of the shimmer that runs through the working verb,
|
|
287
|
+
* taken verbatim from the reference engine's spinner
|
|
288
|
+
* (`aegiscodex-dev/src/main.js`: `(i + frame) % 3 === 0 ? C.coral :
|
|
289
|
+
* RGB2(235, 159, 127)`).
|
|
290
|
+
*
|
|
291
|
+
* It is deliberately NOT a palette role, because the reference does not make it
|
|
292
|
+
* one either: `test/cli-conformance.test.mjs` pins this theme's roles to exactly
|
|
293
|
+
* the reference's set, so adding a `salmon` role would fail that guard for a
|
|
294
|
+
* colour the palette never owned.
|
|
295
|
+
*
|
|
296
|
+
* The previous value here was `gray`, and that is what made the live spinner
|
|
297
|
+
* read as washed out: two of every three shimmering characters were the same
|
|
298
|
+
* dim grey as finished output, so the one row that means "a turn is in flight"
|
|
299
|
+
* was painted in the colour of settled chrome. The tint is a warm salmon, one
|
|
300
|
+
* step lighter than `coral`, so the shimmer reads as motion at a glance.
|
|
301
|
+
*/
|
|
302
|
+
const SPINNER_TINT = RGB(235, 159, 127);
|
|
303
|
+
|
|
258
304
|
/**
|
|
259
305
|
* The working line: the `✻`-family spinner with a shimmering verb, the elapsed
|
|
260
|
-
* time and a token
|
|
306
|
+
* time and a token count — the reference's
|
|
261
307
|
* `✻ Tempering… (3s · ↓412 tokens)`.
|
|
262
308
|
*/
|
|
263
309
|
function spinnerLine(state, ctx) {
|
|
@@ -266,11 +312,18 @@ function spinnerLine(state, ctx) {
|
|
|
266
312
|
const shimmer = [...(state.verb || VERBS[0])];
|
|
267
313
|
const frame = Math.floor((state.frame || 0) / 2) % 3;
|
|
268
314
|
const tinted = shimmer.map((ch, i) =>
|
|
269
|
-
span((i + frame) % 3 === 0 ? t.coral :
|
|
315
|
+
span((i + frame) % 3 === 0 ? t.coral : SPINNER_TINT, ch)
|
|
270
316
|
);
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
317
|
+
// The tail is keyed on the thinking flag, NOT on whether anything has
|
|
318
|
+
// streamed yet. The reference branches the same way
|
|
319
|
+
// (`aegiscodex-dev/src/main.js`: `if (ctx.thinking) … else … ↓N tokens`).
|
|
320
|
+
// Gating on `state.streamed` instead meant every turn opened on
|
|
321
|
+
// `(0s · thinking)` — a tokenless tail that announced reasoning whether or not
|
|
322
|
+
// extended thinking was on — which is why the live token count was missing
|
|
323
|
+
// from the spinner while the model was working.
|
|
324
|
+
const tail = ctx && ctx.thinking
|
|
325
|
+
? span(t.gray, ` (${secs}s · thinking)`)
|
|
326
|
+
: span(t.gray, ` (${secs}s · ↓${fmtTokens(state.streamed || 0)} tokens)`);
|
|
274
327
|
const glyph = GLYPH.spin[(state.frame || 0) % GLYPH.spin.length];
|
|
275
328
|
return [span(t.coral, glyph), ...tinted, span(t.white, '… '), tail];
|
|
276
329
|
}
|
|
@@ -296,7 +349,7 @@ function statusLine(state, cols, ctx) {
|
|
|
296
349
|
} else if (state.streamJob) {
|
|
297
350
|
left = [span(t.gray, `${GLYPH.bullet} esc to stop`)];
|
|
298
351
|
} else if (state.yolo) {
|
|
299
|
-
left = [span(t.gray, `${GLYPH.bullet}
|
|
352
|
+
left = [span(t.gray, `${GLYPH.bullet} automode on ${GLYPH.bullet} ${autoContinueLimit()} rounds then it asks ${GLYPH.bullet} ? for shortcuts ${GLYPH.bullet} ${GLYPH.rightarrow} for manual mode`)];
|
|
300
353
|
} else {
|
|
301
354
|
left = [span(t.gray, `${GLYPH.pause} manual mode on ${GLYPH.bullet} ? for shortcuts ${GLYPH.bullet} ${GLYPH.rightarrow} for auto mode`)];
|
|
302
355
|
}
|
|
@@ -382,6 +435,66 @@ function confirmLines(overlay, cols, ctx) {
|
|
|
382
435
|
return lines;
|
|
383
436
|
}
|
|
384
437
|
|
|
438
|
+
/**
|
|
439
|
+
* Automatic round-budget continuations automode may take before it has to
|
|
440
|
+
* ask for real — mirrors the upstream engine's `autoContinuePlan`
|
|
441
|
+
* (aegiscodex-dev's src/autonomous.js). Not "run forever": after `limit`
|
|
442
|
+
* silent yeses the real dialog is shown, so a turn that is genuinely stuck
|
|
443
|
+
* still puts a human in the loop. Pure, and exported, so the policy itself
|
|
444
|
+
* (not just the dialog it feeds) is directly testable.
|
|
445
|
+
*
|
|
446
|
+
* { auto: true, used: n } → answer the ask with "continue", no dialog
|
|
447
|
+
* { auto: false, used: 0 } → show the real dialog (allowance just spent)
|
|
448
|
+
* { auto: false, used: n } → show the real dialog (automode is off)
|
|
449
|
+
*/
|
|
450
|
+
const AUTO_CONTINUE_LIMIT = 3;
|
|
451
|
+
/**
|
|
452
|
+
* The allowance, honouring `AEGIS_AUTO_CONTINUE_MAX` exactly as the upstream
|
|
453
|
+
* engine's `autoContinueLimit` does (aegiscodex-dev's src/autonomous.js). Read
|
|
454
|
+
* per call, not frozen at module load, so a test or a wrapper can move the
|
|
455
|
+
* allowance without a reload — and so the number the status line advertises
|
|
456
|
+
* ("N rounds then it asks") is the number the plan will actually spend.
|
|
457
|
+
*/
|
|
458
|
+
function autoContinueLimit(env = process.env) {
|
|
459
|
+
const n = Number.parseInt(env && env.AEGIS_AUTO_CONTINUE_MAX, 10);
|
|
460
|
+
return Number.isFinite(n) && n > 0 ? n : AUTO_CONTINUE_LIMIT;
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
function autoContinuePlan({ on = false, used = 0, limit = autoContinueLimit() } = {}) {
|
|
464
|
+
const cap = Number.isFinite(limit) && limit > 0 ? Math.floor(limit) : AUTO_CONTINUE_LIMIT;
|
|
465
|
+
const spent = Number.isFinite(used) && used > 0 ? Math.floor(used) : 0;
|
|
466
|
+
if (!on) return { auto: false, used: spent, cap };
|
|
467
|
+
if (spent >= cap) return { auto: false, used: 0, cap };
|
|
468
|
+
return { auto: true, used: spent + 1, cap };
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
/** The round-budget extension dialog body — same shape as confirmLines, but
|
|
472
|
+
* the subject is a round budget rather than a tool call. */
|
|
473
|
+
function roundsLines(overlay, cols, ctx) {
|
|
474
|
+
const t = themeOf(ctx);
|
|
475
|
+
const lines = [];
|
|
476
|
+
lines.push([span(t.gray, '─'.repeat(Math.min(Math.max(10, cols - 4), 80)))]);
|
|
477
|
+
lines.push([span(t.white, `${overlay.spent}-round tool limit reached`)]);
|
|
478
|
+
lines.push([span('', '')]);
|
|
479
|
+
for (const l of wrapBlock(
|
|
480
|
+
'The turn is still working — it ended its last round on a tool call instead of an answer.',
|
|
481
|
+
Math.max(8, cols - 4)
|
|
482
|
+
)) {
|
|
483
|
+
lines.push([span(t.gray, l)]);
|
|
484
|
+
}
|
|
485
|
+
lines.push([span('', '')]);
|
|
486
|
+
const opt = (i, label) => {
|
|
487
|
+
const active = overlay.sel === i;
|
|
488
|
+
const left = active ? span(t.lavender, GLYPH.cursor) : span('', ' ');
|
|
489
|
+
return [left, span(t.gray, ` ${i + 1}. `), span(active ? t.lavender : t.white, label)];
|
|
490
|
+
};
|
|
491
|
+
lines.push(opt(0, `Yes, continue with ${overlay.size} more rounds`));
|
|
492
|
+
lines.push(opt(1, 'No, stop here and answer with what I have'));
|
|
493
|
+
lines.push([span('', '')]);
|
|
494
|
+
lines.push([span(t.gray, `extension ${overlay.extensions} of ${overlay.max} · Esc to stop`)]);
|
|
495
|
+
return lines;
|
|
496
|
+
}
|
|
497
|
+
|
|
385
498
|
/**
|
|
386
499
|
* The accounting bits for a turn — model, tokens, the in/out split, €, elapsed
|
|
387
500
|
* and call count. Shared by the standalone `meta` row and the folded footer, so
|
|
@@ -394,11 +507,26 @@ function confirmLines(overlay, cols, ctx) {
|
|
|
394
507
|
function metaBits(m, t, { omitMs = false } = {}) {
|
|
395
508
|
const bits = [];
|
|
396
509
|
if (m.model) bits.push(span(t.blue, m.model));
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
510
|
+
// Same figure as the standalone meta row, from the one helper both call:
|
|
511
|
+
// OUTPUT only, in `white`, the token the total used to get. The
|
|
512
|
+
// input-inclusive total is not printed beside it — on a cached turn it is the
|
|
513
|
+
// prompt restated, and showing `156,189 tok` next to `5,014 tokens` is what made
|
|
514
|
+
// the row read as a runaway. When no output figure arrived the row states
|
|
515
|
+
// NOTHING rather than the total: `m.tokens` is input + output, so falling back
|
|
516
|
+
// to it put the input half back under an unlabelled figure — the leak the
|
|
517
|
+
// desktop closed in `displayTokens`, closed here the same way. A row with no
|
|
518
|
+
// measurable output is better empty than stating a total the reader cannot tell
|
|
519
|
+
// from the answer's size.
|
|
520
|
+
const parts = fmtUsageSplit(m);
|
|
521
|
+
if (parts) bits.push(span(t.white, parts.output));
|
|
522
|
+
else {
|
|
523
|
+
const produced = displayTokens(m);
|
|
524
|
+
if (produced != null) bits.push(span(t.white, `${fmtTokens(produced)} tokens`));
|
|
400
525
|
}
|
|
401
|
-
|
|
526
|
+
// No money on a tier AEGIS bills no fee to, nor from an unproven snapshot
|
|
527
|
+
// (`feeBillable`) — the desktop's rule, and the same one the standalone meta
|
|
528
|
+
// row uses, so the two renderers of this row cannot disagree about a fee.
|
|
529
|
+
if (m.eur != null && feeBillable()) bits.push(span(m.eur > 0 ? t.coral : t.green, fmtEur(m.eur)));
|
|
402
530
|
if (m.ms != null && !omitMs) bits.push(span(t.gray, fmtElapsed(m.ms)));
|
|
403
531
|
if (m.calls > 1) bits.push(span(t.gray, `${m.calls} calls`));
|
|
404
532
|
return bits;
|
|
@@ -448,10 +576,12 @@ function rowLines(msg, cols, ctx, now = Date.now()) {
|
|
|
448
576
|
const where = msg.cwd ? ` · ${shortDir(msg.cwd)}` : '';
|
|
449
577
|
if (msg.phase === 'run') {
|
|
450
578
|
const secs = msg.start ? Math.max(1, Math.round((now - msg.start) / 1000)) : 0;
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
579
|
+
// No leading `●` bullet on a running-command row: the label plus its
|
|
580
|
+
// elapsed seconds already say what is happening, and the bullet made a
|
|
581
|
+
// live turn read as a list of bullets. It also kept the running row one
|
|
582
|
+
// column right of the finished row it collapses into, so the transcript
|
|
583
|
+
// shifted sideways the moment the command completed.
|
|
584
|
+
out.push([span(t.gray, `${label}${GLYPH.ellipse} · ${secs}s${where}`)]);
|
|
455
585
|
} else {
|
|
456
586
|
out.push([span(t.gray, `${label}${where}`)]);
|
|
457
587
|
}
|
|
@@ -563,15 +693,16 @@ function rowLines(msg, cols, ctx, now = Date.now()) {
|
|
|
563
693
|
if (i === 0) line.unshift(span(t.white, GLYPH.block), span('', ' '));
|
|
564
694
|
out.push(line);
|
|
565
695
|
}
|
|
566
|
-
//
|
|
567
|
-
//
|
|
568
|
-
//
|
|
569
|
-
//
|
|
570
|
-
//
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
696
|
+
// No trailing cursor glyph. This used to append a second `●` to the last line
|
|
697
|
+
// of a still-growing answer whenever the message occupied more than one row,
|
|
698
|
+
// which made the glyph count a function of how the text WRAPPED: a one-line
|
|
699
|
+
// answer was `● Working`, a two-line answer was `● Working●`. Two dots where
|
|
700
|
+
// the reader expects one, and the asymmetry landed on exactly the long answers
|
|
701
|
+
// a person is most likely to read — the marker is the message's opening
|
|
702
|
+
// gutter, not a bracket. A streaming turn is already advertised by the working
|
|
703
|
+
// line below (`renderWorking`) and by the head marker being the same one the
|
|
704
|
+
// finished row keeps, so the tail glyph carried no information the reader did
|
|
705
|
+
// not already have.
|
|
575
706
|
return out;
|
|
576
707
|
}
|
|
577
708
|
|
|
@@ -770,6 +901,12 @@ async function runSession(host) {
|
|
|
770
901
|
const lineCache = new WeakMap();
|
|
771
902
|
|
|
772
903
|
let overlay = null;
|
|
904
|
+
// Automode's running tally of silent "continue" answers to the round-budget
|
|
905
|
+
// dialog (see autoContinuePlan above). Cleared whenever the human is
|
|
906
|
+
// actually asked (autoContinuePlan resets it once the allowance is spent),
|
|
907
|
+
// so it is "N automatic continuations per block", never a life-of-session
|
|
908
|
+
// total that a long build could quietly exhaust.
|
|
909
|
+
let autoContinues = 0;
|
|
773
910
|
let working = false;
|
|
774
911
|
let abort = null;
|
|
775
912
|
let spinnerFrame = 0;
|
|
@@ -962,7 +1099,17 @@ async function runSession(host) {
|
|
|
962
1099
|
if (working) {
|
|
963
1100
|
lines.push(
|
|
964
1101
|
spinnerLine(
|
|
965
|
-
{
|
|
1102
|
+
{
|
|
1103
|
+
verb,
|
|
1104
|
+
frame: spinnerFrame,
|
|
1105
|
+
elapsedMs: Date.now() - startedAt,
|
|
1106
|
+
// `streamedChars` is a display width — the accumulated `w(delta)` of
|
|
1107
|
+
// the stream — so it is converted to tokens HERE, at the producer.
|
|
1108
|
+
// Both spinner renderers label this field `tokens`, so handing them
|
|
1109
|
+
// cells printed the character count as a token count and the live
|
|
1110
|
+
// figure read ~4x high.
|
|
1111
|
+
streamed: estimateTokensFromCells(streamedCells()),
|
|
1112
|
+
},
|
|
966
1113
|
ctx
|
|
967
1114
|
)
|
|
968
1115
|
);
|
|
@@ -1043,6 +1190,8 @@ async function runSession(host) {
|
|
|
1043
1190
|
ol = shortcutsGrid(cols, ctx);
|
|
1044
1191
|
} else if (overlay.type === 'confirm') {
|
|
1045
1192
|
ol = confirmLines(overlay, cols, ctx);
|
|
1193
|
+
} else if (overlay.type === 'rounds') {
|
|
1194
|
+
ol = roundsLines(overlay, cols, ctx);
|
|
1046
1195
|
} else if (overlay.type === 'panel') {
|
|
1047
1196
|
ol = overlay.lines || [];
|
|
1048
1197
|
}
|
|
@@ -1099,6 +1248,12 @@ async function runSession(host) {
|
|
|
1099
1248
|
|
|
1100
1249
|
const note = (text) => push({ role: 'note', text }, { follow: false });
|
|
1101
1250
|
|
|
1251
|
+
// The live figure's input: the display width of what the turn has PRODUCED so
|
|
1252
|
+
// far — the answer's deltas AND the thinking trace's — because that is the
|
|
1253
|
+
// billed output and the quantity the desktop's bubble reports (see the
|
|
1254
|
+
// `reasoning` presenter below). It feeds the spinner and nothing else: it is
|
|
1255
|
+
// reset per turn and never reaches the accounting row, which is built from
|
|
1256
|
+
// what the provider measured.
|
|
1102
1257
|
let streamedChars = 0;
|
|
1103
1258
|
const streamedCells = () => streamedChars;
|
|
1104
1259
|
// ── the turn ──
|
|
@@ -1137,6 +1292,73 @@ async function runSession(host) {
|
|
|
1137
1292
|
})();
|
|
1138
1293
|
});
|
|
1139
1294
|
|
|
1295
|
+
// The round-budget extension dialog (engine.js requestRoundsAsk, surfaced
|
|
1296
|
+
// here as `chunk.rounds` → `presenter.rounds`). Same own-nextKey-loop shape
|
|
1297
|
+
// as confirmTool above. The cursor starts on "No" deliberately: an Enter on
|
|
1298
|
+
// an untouched dialog must not spend another block of rounds, so a
|
|
1299
|
+
// declined dialog is bit-for-bit the engine's own hard stop.
|
|
1300
|
+
const confirmRoundsExtension = (info) =>
|
|
1301
|
+
new Promise((resolve) => {
|
|
1302
|
+
// ── automode: the first AUTO_CONTINUE_LIMIT asks are answered for the
|
|
1303
|
+
// human ───────────────────────────────────────────────────────────────
|
|
1304
|
+
// This is the "fund a few blocks automatically, then ask for real"
|
|
1305
|
+
// contract: with automode on, a turn that reaches its horizon is
|
|
1306
|
+
// extended silently a few times, and the ask after that is the real
|
|
1307
|
+
// dialog again — so automode is "don't make me answer the same budget
|
|
1308
|
+
// question every time", not "run forever with no one watching".
|
|
1309
|
+
const yolo = Boolean(host.isYolo && host.isYolo());
|
|
1310
|
+
const plan = autoContinuePlan({ on: yolo, used: autoContinues });
|
|
1311
|
+
autoContinues = plan.used;
|
|
1312
|
+
if (plan.auto) {
|
|
1313
|
+
note(
|
|
1314
|
+
`auto: ${info.spent}-round limit reached — continuing automatically` +
|
|
1315
|
+
` (${plan.used}/${plan.cap}, then it asks).`
|
|
1316
|
+
);
|
|
1317
|
+
render();
|
|
1318
|
+
resolve(true);
|
|
1319
|
+
return;
|
|
1320
|
+
}
|
|
1321
|
+
if (yolo) {
|
|
1322
|
+
// The allowance is spent: this IS the ask. Say so, or the dialog reads
|
|
1323
|
+
// as automode having silently switched itself off.
|
|
1324
|
+
note(`auto: ${plan.cap} automatic continuations used — asking you now (answering restarts the block).`);
|
|
1325
|
+
render();
|
|
1326
|
+
}
|
|
1327
|
+
overlay = {
|
|
1328
|
+
type: 'rounds',
|
|
1329
|
+
spent: Number(info.spent) || 0,
|
|
1330
|
+
extensions: Number(info.extensions) || 1,
|
|
1331
|
+
max: Number(info.max) || 8,
|
|
1332
|
+
size: Number(info.size) || Number(info.spent) || 0,
|
|
1333
|
+
sel: 1,
|
|
1334
|
+
};
|
|
1335
|
+
render();
|
|
1336
|
+
(async () => {
|
|
1337
|
+
const choose = (yes) => {
|
|
1338
|
+
overlay = null;
|
|
1339
|
+
render();
|
|
1340
|
+
resolve(yes);
|
|
1341
|
+
};
|
|
1342
|
+
for (;;) {
|
|
1343
|
+
const key = await nextKey();
|
|
1344
|
+
if (key.name === KEY.UP || key.name === KEY.DOWN || key.name === KEY.TAB) {
|
|
1345
|
+
overlay.sel = 1 - overlay.sel;
|
|
1346
|
+
render();
|
|
1347
|
+
} else if (key.name === KEY.ENTER) {
|
|
1348
|
+
choose(overlay.sel === 0);
|
|
1349
|
+
return;
|
|
1350
|
+
} else if (key.name === KEY.ESC || key.name === KEY.CTRL_C) {
|
|
1351
|
+
choose(false);
|
|
1352
|
+
return;
|
|
1353
|
+
} else if (key.name === 'char') {
|
|
1354
|
+
const c = String(key.ch).trim();
|
|
1355
|
+
if (c === '1') { choose(true); return; }
|
|
1356
|
+
if (c === '2') { choose(false); return; }
|
|
1357
|
+
}
|
|
1358
|
+
}
|
|
1359
|
+
})();
|
|
1360
|
+
});
|
|
1361
|
+
|
|
1140
1362
|
const startResponse = async (prompt) => {
|
|
1141
1363
|
working = true;
|
|
1142
1364
|
spinnerFrame = 0;
|
|
@@ -1170,10 +1392,19 @@ async function runSession(host) {
|
|
|
1170
1392
|
streamedChars += w(delta);
|
|
1171
1393
|
scheduleRender();
|
|
1172
1394
|
},
|
|
1173
|
-
// Not rendered (deliberation is not an answer), but
|
|
1174
|
-
//
|
|
1175
|
-
//
|
|
1176
|
-
|
|
1395
|
+
// Not rendered (deliberation is not an answer), but counted and recorded.
|
|
1396
|
+
// Counted, because the live figure is the turn's BILLED output — the
|
|
1397
|
+
// answer plus the thinking trace it is charged for — which is the same
|
|
1398
|
+
// quantity the desktop's bubble reports (`desktop/renderer/app.js` sums
|
|
1399
|
+
// reply AND reasoning cells at this same 4:1 ratio). Consuming the delta
|
|
1400
|
+
// here without adding it left the counter at 0 for the whole thinking
|
|
1401
|
+
// phase, so the spinner read `↓0 tokens` while a reasoning model — the
|
|
1402
|
+
// default in this build — thought: the one row that means "a turn is in
|
|
1403
|
+
// flight" reported nothing happening.
|
|
1404
|
+
// Recorded separately, because a turn that reasoned and then produced
|
|
1405
|
+
// nothing needs a different explanation from one that produced nothing at
|
|
1406
|
+
// all.
|
|
1407
|
+
reasoning: (delta) => { sawReasoning = true; streamedChars += w(delta); },
|
|
1177
1408
|
tool: (tool) => {
|
|
1178
1409
|
// One entry per tool call, not one per frame. The engine opens a `run`
|
|
1179
1410
|
// frame before the tool executes and closes it with a `done` frame
|
|
@@ -1230,6 +1461,7 @@ async function runSession(host) {
|
|
|
1230
1461
|
scheduleRender();
|
|
1231
1462
|
},
|
|
1232
1463
|
approval: (info) => confirmTool(info),
|
|
1464
|
+
rounds: (info) => confirmRoundsExtension(info),
|
|
1233
1465
|
};
|
|
1234
1466
|
|
|
1235
1467
|
let result = null;
|
|
@@ -1323,14 +1555,24 @@ async function runSession(host) {
|
|
|
1323
1555
|
}
|
|
1324
1556
|
const usage = result && result.usage;
|
|
1325
1557
|
const tokens = host.tokensFor ? host.tokensFor(usage) : null;
|
|
1558
|
+
// The in/out split on this row is the miss/hit split the ledger row,
|
|
1559
|
+
// /cost, /context and the desktop roll all carry — not the raw wire
|
|
1560
|
+
// fields. `usage.input_tokens ?? usage.prompt_tokens` is not a spelling
|
|
1561
|
+
// preference: Anthropic's `input_tokens` EXCLUDES cached reads while
|
|
1562
|
+
// OpenAI's and DeepSeek's `prompt_tokens` INCLUDES the hit, so reading
|
|
1563
|
+
// the raw field printed the entire prompt as fresh input on a cached
|
|
1564
|
+
// turn. On a resumed session that is most of the prompt, which is why
|
|
1565
|
+
// this row's token figure ran so far above the engine's for the same
|
|
1566
|
+
// turn. `usageBuckets` resolves both to the miss half.
|
|
1567
|
+
const buckets = usage ? usageBuckets(usage) : null;
|
|
1326
1568
|
push(
|
|
1327
1569
|
{
|
|
1328
1570
|
role: 'meta',
|
|
1329
1571
|
meta: {
|
|
1330
1572
|
model: result && result.model,
|
|
1331
1573
|
tokens,
|
|
1332
|
-
input:
|
|
1333
|
-
output:
|
|
1574
|
+
input: buckets ? buckets.input : null,
|
|
1575
|
+
output: buckets ? buckets.output : null,
|
|
1334
1576
|
eur: lastCost,
|
|
1335
1577
|
ms: result && result.ms,
|
|
1336
1578
|
calls: (result && result.calls) || 1,
|
|
@@ -1833,9 +2075,9 @@ async function runSession(host) {
|
|
|
1833
2075
|
// resolved through different lists.
|
|
1834
2076
|
const chosen = overlays.EFFORT_VALUES[overlay.sel || 0];
|
|
1835
2077
|
overlay = null;
|
|
1836
|
-
ctx.effort = chosen;
|
|
1837
|
-
host.updateConfig({ effort:
|
|
1838
|
-
note(`effort: ${
|
|
2078
|
+
ctx.effort = chosen || 'high';
|
|
2079
|
+
host.updateConfig({ effort: ctx.effort });
|
|
2080
|
+
note(`effort: ${ctx.effort}`);
|
|
1839
2081
|
render();
|
|
1840
2082
|
return;
|
|
1841
2083
|
}
|
|
@@ -2032,7 +2274,7 @@ async function runSession(host) {
|
|
|
2032
2274
|
// at column 0, so `editor.right()` was a no-op there: the binding costs no
|
|
2033
2275
|
// editing behaviour, and a line with text keeps plain cursor movement.
|
|
2034
2276
|
if (key.name === KEY.RIGHT && !editor.buf) {
|
|
2035
|
-
await dispatch(!(host.isYolo && host.isYolo()) ? '/
|
|
2277
|
+
await dispatch(!(host.isYolo && host.isYolo()) ? '/automode on' : '/automode off');
|
|
2036
2278
|
return;
|
|
2037
2279
|
}
|
|
2038
2280
|
if (key.name === KEY.RIGHT || key.name === KEY.CTRL_RIGHT) {
|
|
@@ -2377,6 +2619,10 @@ module.exports = {
|
|
|
2377
2619
|
// answers with tokens the engine actually honours (see APPROVAL_CHOICES).
|
|
2378
2620
|
APPROVAL_CHOICES,
|
|
2379
2621
|
APPROVAL_DECISIONS,
|
|
2622
|
+
roundsLines,
|
|
2623
|
+
autoContinuePlan,
|
|
2624
|
+
autoContinueLimit,
|
|
2625
|
+
AUTO_CONTINUE_LIMIT,
|
|
2380
2626
|
rowLines,
|
|
2381
2627
|
transcriptLines,
|
|
2382
2628
|
inputPreviewText,
|