aegiscode 7.0.8 → 7.0.10

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 CHANGED
@@ -18,7 +18,7 @@ Routing, model tiers, memory and billing all stay behind aegiscloud.org.
18
18
  Four steps, in order. Everything past this section is the fuller reference for
19
19
  each one.
20
20
 
21
- **1. Install** — requires Node 18+.
21
+ **1. Install** — requires Node 22+.
22
22
 
23
23
  ```bash
24
24
  npm install -g aegiscode
@@ -74,7 +74,7 @@ npm install -g aegiscode
74
74
  node cli/bin/aegiscode.js
75
75
  ```
76
76
 
77
- Requires Node 18+. Save your key once — it goes to `~/.aegiscode/credentials.json`
77
+ Requires Node 22+. Save your key once — it goes to `~/.aegiscode/credentials.json`
78
78
  (mode `0600`) and is then picked up by every later launch, script and shell:
79
79
 
80
80
  ```bash
@@ -461,7 +461,7 @@ Copy-paste, in the order you actually need them.
461
461
  ### Install and sign in
462
462
 
463
463
  ```bash
464
- npm install -g aegiscode # requires Node 18+
464
+ npm install -g aegiscode # requires Node 22+
465
465
  aegiscode login # prompts for your AEGIS key, no echo
466
466
  aegiscode key status # verify: masked key + which source is in use
467
467
  aegiscode # start a session
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "aegiscode",
3
3
  "productName": "AEGIS Code",
4
- "version": "7.0.8",
4
+ "version": "7.0.10",
5
5
  "description": "aegiscode — the command-line version of AEGIS Desktop. The shared tool surface in your shell, over the same thin transport and tool registry as the MCP plugin and the desktop app. Ships transport + UI only; no brain.",
6
6
  "author": {
7
7
  "name": "AEGIS Code",
@@ -21,7 +21,7 @@
21
21
  "README.md"
22
22
  ],
23
23
  "engines": {
24
- "node": ">=18.0.0"
24
+ "node": ">=22.0.0"
25
25
  },
26
26
  "scripts": {
27
27
  "start": "node bin/aegiscode.js",
package/src/app.js CHANGED
@@ -982,6 +982,13 @@ function createApp(options = {}) {
982
982
  let chars = 0;
983
983
  let partial = '';
984
984
  let reasoning = 0;
985
+ // Thinking tokens the PROVIDER measured, added verbatim. A subscription
986
+ // turn withholds its deliberation text (`thinking_delta.thinking` is the
987
+ // empty string), so the `reasoning` char count above stays 0 for the whole
988
+ // thinking phase and the spinner read `↓0 tokens` while thousands of
989
+ // thinking tokens were billed. Not routed through `w()`/4: this is already
990
+ // a token count, and dividing it would print a quarter of the truth.
991
+ let thinkingTokens = 0;
985
992
  let verb = VERBS[Math.floor(Math.random() * VERBS.length)];
986
993
  let sawReasoning = false;
987
994
  let usedTools = false;
@@ -1005,7 +1012,10 @@ function createApp(options = {}) {
1005
1012
  // distinguishable — but leaving it out of the figure here stalled the
1006
1013
  // spinner on `↓0 tokens` for the whole thinking phase of every turn,
1007
1014
  // which is the row that exists to show the turn is moving.
1008
- streamed: estimateTokensFromCells(chars + reasoning),
1015
+ streamed: estimateTokensFromCells(chars + reasoning) + thinkingTokens,
1016
+ // See render.js: any contribution from `thinkingTokens` is Anthropic's
1017
+ // own under-counting running estimate, not the real billed figure.
1018
+ streamedFloor: thinkingTokens > 0,
1009
1019
  }),
1010
1020
  ]);
1011
1021
  };
@@ -1043,6 +1053,13 @@ function createApp(options = {}) {
1043
1053
  if (p.reasoning) return p.reasoning(r);
1044
1054
  return undefined;
1045
1055
  },
1056
+ // Token-count channel, distinct from `reasoning` above (which is text).
1057
+ // A presenter drives its own spinner, so it must receive this or the live
1058
+ // figure stays at 0 for the whole thinking phase of a subscription turn.
1059
+ thinkingTokens: (n) => {
1060
+ if (p.thinkingTokens) return p.thinkingTokens(n);
1061
+ return undefined;
1062
+ },
1046
1063
  tool: (tool) => {
1047
1064
  if (p.tool) return p.tool(tool);
1048
1065
  if (live) live.clear();
@@ -1099,6 +1116,19 @@ function createApp(options = {}) {
1099
1116
  // same function the tests import is the one the live path calls.
1100
1117
  const onDelta = (chunk) => {
1101
1118
  if (!chunk) return;
1119
+ // Provider-measured thinking progress — the ONLY live signal on a
1120
+ // subscription turn, whose deliberation text is withheld. Counted and
1121
+ // repainted, but never handed to `present.reasoning`: that channel is
1122
+ // text and its consumers accumulate display width from it.
1123
+ if (chunk.thinkingTokens) {
1124
+ thinkingTokens += chunk.thinkingTokens;
1125
+ if (!sawReasoning) {
1126
+ sawReasoning = true;
1127
+ verb = 'Reasoning';
1128
+ }
1129
+ present.thinkingTokens(chunk.thinkingTokens);
1130
+ paint();
1131
+ }
1102
1132
  if (chunk.reasoning) {
1103
1133
  reasoning += w(chunk.reasoning);
1104
1134
  // The pool's worker findings arrive on the reasoning channel before
@@ -1110,8 +1140,7 @@ function createApp(options = {}) {
1110
1140
  }
1111
1141
  present.reasoning(chunk.reasoning);
1112
1142
  }
1113
- if (chunk.delta) {
1114
- chars += w(chunk.delta);
1143
+ if (chunk.delta) { chars += w(chunk.delta);
1115
1144
  partial += chunk.delta;
1116
1145
  present.text(chunk.delta);
1117
1146
  }
@@ -1488,6 +1517,7 @@ function createApp(options = {}) {
1488
1517
  else if (o.type === 'palette') lines = overlays.renderPalette(visibleCommands(), { query: o.query || '', sel: o.sel || 0 }, W, rows);
1489
1518
  else if (o.type === 'model') lines = overlays.renderModelPicker(o.items || [], o.sel || 0, W, rows, o.current != null ? o.current : commandCtx.model, o.cls || commandCtx.modelClass, classLabelOf);
1490
1519
  else if (o.type === 'effort') lines = overlays.renderEffortPicker(o.sel || 0, W, commandCtx.effort);
1520
+ else if (o.type === 'class') lines = overlays.renderClassPicker(o.items || [], o.sel || 0, W, o.current || commandCtx.modelClass, classLabelOf);
1491
1521
  else if (o.type === 'resume') lines = overlays.renderResumeList(o.items || [], o.sel || 0, W, rows);
1492
1522
  else if (o.type === 'confirm') lines = render.renderApproval(ctx(), o.info || {}, W).map((s) => [spanRow(s)]);
1493
1523
  if (!lines) return;
@@ -1713,6 +1743,17 @@ function createApp(options = {}) {
1713
1743
  // leave a working prompt rather than aborting the command.
1714
1744
  const spec = await describeSecret(cmd, args);
1715
1745
  if (spec && spec.note) emit(render.renderNotice(ctx(), 'info', spec.note));
1746
+ // An explicit `prompt: null` is a refusal, not a missing description.
1747
+ // Reading it as "no description" and falling through to the generic
1748
+ // prompt is how `/byok-set <typo>` printed "unknown provider … Nothing
1749
+ // was sent" and then asked for the key anyway and sent it: the command
1750
+ // had decided this must not be stored, and the dispatcher overrode it.
1751
+ if (spec && spec.prompt === null) return true;
1752
+ // The command may have resolved the typed word to a canonical id
1753
+ // (`together-ai` → `together`). Send that. Otherwise the prompt names
1754
+ // the real provider while the request carries the alias the server does
1755
+ // not know, and the save fails after the user has already pasted a key.
1756
+ if (spec && spec.provider) args = { ...args, provider: spec.provider };
1716
1757
  const key = await askSecret((spec && spec.prompt) || `provider key for ${args.provider}: `);
1717
1758
  if (!key) {
1718
1759
  emit(render.renderNotice(ctx(), 'warn', 'empty key — nothing sent'));
@@ -2129,11 +2170,21 @@ function createApp(options = {}) {
2129
2170
  // Without these two the picker would re-prompt for a key the machine
2130
2171
  // demonstrably holds, which is how the same key got saved twice.
2131
2172
  accountConfigured: () => !!(credentials.keyStatus() || {}).configured,
2173
+ // `get()` is the MASKED read — it returns {provider, baseURL, configured,
2174
+ // keyMask} and never carries a `.key` field. Reading `row.key` here made
2175
+ // this predicate permanently false, so the picker re-prompted for a key
2176
+ // the machine demonstrably held: the exact bug the comment above says it
2177
+ // exists to prevent. `rawKey()` is the reader that returns the plaintext;
2178
+ // `configured` is the fallback for a store that offers only `get()`.
2132
2179
  hasProviderKey: (provider) => {
2133
2180
  const store = engine.settings;
2134
- if (!store || typeof store.get !== 'function' || !provider) return false;
2135
- const row = (store.get(byokNamespace(provider)) || {});
2136
- return !!String(row.key || '').trim();
2181
+ if (!store || !provider) return false;
2182
+ const row = byokNamespace(provider);
2183
+ if (typeof store.rawKey === 'function') {
2184
+ return !!String(store.rawKey(row) || '').trim();
2185
+ }
2186
+ if (typeof store.get !== 'function') return false;
2187
+ return !!((store.get(row) || {}).configured);
2137
2188
  },
2138
2189
  loadModels: (o) => loadModels(o),
2139
2190
  buildState: () => buildState(),
@@ -2444,11 +2495,18 @@ function createApp(options = {}) {
2444
2495
  cloudsync,
2445
2496
  keyStatus: () => credentials.keyStatus(),
2446
2497
  accountConfigured: () => !!(credentials.keyStatus() || {}).configured,
2498
+ // Same masked-read defect as the host binding above — see the comment
2499
+ // there. Kept identical so the two hosts cannot disagree about whether a
2500
+ // key is stored.
2447
2501
  hasProviderKey: (provider) => {
2448
2502
  const store = engine.settings;
2449
- if (!store || typeof store.get !== 'function' || !provider) return false;
2450
- const row = (store.get(byokNamespace(provider)) || {});
2451
- return !!String(row.key || '').trim();
2503
+ if (!store || !provider) return false;
2504
+ const row = byokNamespace(provider);
2505
+ if (typeof store.rawKey === 'function') {
2506
+ return !!String(store.rawKey(row) || '').trim();
2507
+ }
2508
+ if (typeof store.get !== 'function') return false;
2509
+ return !!((store.get(row) || {}).configured);
2452
2510
  },
2453
2511
  sessionId: () => commandCtx.sessionId,
2454
2512
  tokenSummary,
package/src/autonomous.js CHANGED
@@ -57,7 +57,7 @@ const EXECUTES = new Set(['run', 'proceed', 'retry', 'reconcile']);
57
57
  */
58
58
  function parseFlags(argv) {
59
59
  const opts = { terms: [], json: false, flags: {} };
60
- const takesValue = new Set(['cwd', 'model', 'effort', 'workers', 'max', 'max-rounds', 'source']);
60
+ const takesValue = new Set(['cwd', 'model', 'effort', 'workers', 'max', 'max-rounds', 'source', 'class']);
61
61
  for (let i = 0; i < argv.length; i++) {
62
62
  const a = argv[i];
63
63
  if (a === '--json') {
@@ -264,6 +264,13 @@ async function runQueueCommand(command, argv, io = {}) {
264
264
  item = queue.addTask(process.env, {
265
265
  task,
266
266
  cwd,
267
+ // WHICH TRANSPORT THIS TASK RUNS ON. Omitted means 'aegis' (queue.js
268
+ // normalizes a blank class, and every pre-existing task means the
269
+ // pooled brain). The flag exists so a Pro subscription — the class the
270
+ // desktop has had since claude-pro.js and the queue never did — can be
271
+ // queued from a timer: `--class pro` with no --model lets the claude
272
+ // CLI pick, `--class pro --model opus` pins one of its aliases.
273
+ class: args.flags.class || null,
267
274
  model: args.flags.model || null,
268
275
  effort: args.flags.effort || null,
269
276
  workers: intFlag(args.flags, 'workers'),
@@ -471,8 +478,10 @@ function usageText() {
471
478
  'aegiscode autonomous <command> — the unattended work queue',
472
479
  '',
473
480
  'Commands:',
474
- ' add "<task>" queue a task (--cwd, --model, --effort, --commit,',
481
+ ' add "<task>" queue a task (--cwd, --class, --model, --effort, --commit,',
475
482
  ' --single-pass, --workers N, --max-rounds N)',
483
+ ' --class aegis|byok|local|pro (default aegis); --model must',
484
+ ' match the class (pro takes a claude alias, or none at all)',
476
485
  ' list show queued tasks and the tail of the runs log',
477
486
  ' run drain ONE task, then stop',
478
487
  ' proceed drain every pending task (--max N, --stop-on-error, --commit)',
package/src/chatflow.js CHANGED
@@ -386,7 +386,7 @@ function spinnerLine(state, ctx) {
386
386
  // from the spinner while the model was working.
387
387
  const tail = ctx && ctx.thinking
388
388
  ? span(t.gray, ` (${secs}s · thinking)`)
389
- : span(t.gray, ` (${secs}s · ↓${fmtTokens(state.streamed || 0)} tokens)`);
389
+ : span(t.gray, ` (${secs}s · ↓${state.streamedFloor ? '≥' : ''}${fmtTokens(state.streamed || 0)} tokens)`);
390
390
  const glyph = GLYPH.spin[(state.frame || 0) % GLYPH.spin.length];
391
391
  return [span(t.coral, glyph), ...tinted, span(t.white, '… '), tail];
392
392
  }
@@ -1189,7 +1189,8 @@ async function runSession(host) {
1189
1189
  // Both spinner renderers label this field `tokens`, so handing them
1190
1190
  // cells printed the character count as a token count and the live
1191
1191
  // figure read ~4x high.
1192
- streamed: estimateTokensFromCells(streamedCells()),
1192
+ streamed: estimateTokensFromCells(streamedCells()) + thinkingTokens,
1193
+ streamedFloor: thinkingTokens > 0,
1193
1194
  },
1194
1195
  ctx
1195
1196
  )
@@ -1265,6 +1266,11 @@ async function runSession(host) {
1265
1266
  );
1266
1267
  } else if (overlay.type === 'effort') {
1267
1268
  ol = overlays.renderEffortPicker(overlay.sel || 0, cols, ctx.effort);
1269
+ } else if (overlay.type === 'class') {
1270
+ ol = overlays.renderClassPicker(
1271
+ overlay.items || [], overlay.sel || 0, cols, overlay.current || ctx.modelClass,
1272
+ typeof host.classLabel === 'function' ? host.classLabel : null
1273
+ );
1268
1274
  } else if (overlay.type === 'resume') {
1269
1275
  ol = overlays.renderResumeList(overlay.items || [], overlay.sel || 0, cols, termRows);
1270
1276
  } else if (overlay.type === 'shortcuts') {
@@ -1336,6 +1342,12 @@ async function runSession(host) {
1336
1342
  // reset per turn and never reaches the accounting row, which is built from
1337
1343
  // what the provider measured.
1338
1344
  let streamedChars = 0;
1345
+ // Thinking tokens the PROVIDER measured, added verbatim. `streamedChars` is a
1346
+ // display width that becomes tokens at 4:1, which cannot express this: a
1347
+ // subscription turn sends `thinking_delta.thinking` as the empty string and
1348
+ // reports progress in `estimated_tokens` instead, so the char counter stayed
1349
+ // at 0 for the entire thinking phase while thousands of tokens were billed.
1350
+ let thinkingTokens = 0;
1339
1351
  const streamedCells = () => streamedChars;
1340
1352
  // ── the turn ──
1341
1353
 
@@ -1445,6 +1457,7 @@ async function runSession(host) {
1445
1457
  spinnerFrame = 0;
1446
1458
  startedAt = Date.now();
1447
1459
  streamedChars = 0;
1460
+ thinkingTokens = 0;
1448
1461
  toolSeq = 0;
1449
1462
  turnTools = [];
1450
1463
  verb = VERBS[turnCount % VERBS.length];
@@ -1486,6 +1499,12 @@ async function runSession(host) {
1486
1499
  // nothing needs a different explanation from one that produced nothing at
1487
1500
  // all.
1488
1501
  reasoning: (delta) => { sawReasoning = true; streamedChars += w(delta); },
1502
+ // Provider-measured thinking progress, in tokens. Separate from
1503
+ // `reasoning` above because that one is TEXT (accumulated as display
1504
+ // width, converted at 4:1) and this is already a token count. On a
1505
+ // subscription turn this is the only live signal that arrives during the
1506
+ // thinking phase — the text channel sends empty strings throughout.
1507
+ thinkingTokens: (n) => { sawReasoning = true; thinkingTokens += n; scheduleRender(); },
1489
1508
  tool: (tool) => {
1490
1509
  // One entry per tool call, not one per frame. The engine opens a `run`
1491
1510
  // frame before the tool executes and closes it with a `done` frame
@@ -1504,6 +1523,12 @@ async function runSession(host) {
1504
1523
  if (tool.phase === 'run') {
1505
1524
  const n = ++toolSeq;
1506
1525
  const prefix = tool.agent ? `${tool.agent} ▸ ` : '';
1526
+ // Built on the `run` frame, before the executor writes — a writeFile
1527
+ // preview built any later would diff the file against itself. The
1528
+ // row this lands on persists through resolveToolDone (same object,
1529
+ // found by id), so the diff set here is still there once the tool
1530
+ // reports `done` and the row repaints.
1531
+ const diff = editPreview(tool.name, tool.args, { cwd: tool.cwd });
1507
1532
  pushToolRow(
1508
1533
  {
1509
1534
  role: 'tool',
@@ -1514,6 +1539,8 @@ async function runSession(host) {
1514
1539
  id: tool.id,
1515
1540
  label: `Running ${n} ${prefix}${toolLabel(tool.name, n)}…`,
1516
1541
  start: Date.now(),
1542
+ diff,
1543
+ diffOpen: defaultOpen(diff),
1517
1544
  },
1518
1545
  msg
1519
1546
  );
@@ -1524,7 +1551,12 @@ async function runSession(host) {
1524
1551
  // post-execution). Falling through left the row unwritten, so the
1525
1552
  // turn silently showed no tool activity at all. Record the finished
1526
1553
  // tool directly instead.
1554
+ // No `run` frame means no pre-write read either, so a writeFile's
1555
+ // diff here can only compare the file against its own post-write
1556
+ // content (reads clean) — a limitation of this fallback, not of the
1557
+ // normal run→done path above.
1527
1558
  const n = ++toolSeq;
1559
+ const diff = editPreview(tool.name, tool.args, { cwd: tool.cwd });
1528
1560
  pushToolRow(
1529
1561
  {
1530
1562
  role: 'tool',
@@ -1535,6 +1567,8 @@ async function runSession(host) {
1535
1567
  id: tool.id,
1536
1568
  ok: tool.ok,
1537
1569
  label: `Ran ${n} ${tool.agent ? `${tool.agent} ▸ ` : ''}${toolLabel(tool.name, n)}`,
1570
+ diff,
1571
+ diffOpen: defaultOpen(diff),
1538
1572
  },
1539
1573
  msg
1540
1574
  );
@@ -1994,7 +2028,7 @@ async function runSession(host) {
1994
2028
  (c) => c.aliases || []
1995
2029
  ).length;
1996
2030
  }
1997
- if (overlay.type === 'model' || overlay.type === 'resume') return (overlay.items || []).length;
2031
+ if (overlay.type === 'model' || overlay.type === 'resume' || overlay.type === 'class') return (overlay.items || []).length;
1998
2032
  if (overlay.type === 'effort') return overlays.EFFORT_VALUES.length;
1999
2033
  return 0;
2000
2034
  };
@@ -2149,6 +2183,17 @@ async function runSession(host) {
2149
2183
  await collectKeyFor(chosen);
2150
2184
  };
2151
2185
 
2186
+ /**
2187
+ * Switch class from a /class picker row — routed through the `/class`
2188
+ * command itself (not a second copy of switchClass + the byok auto-pin
2189
+ * fallback) so the picker and `/class <id>` typed by hand can never
2190
+ * disagree about what picking a class does.
2191
+ */
2192
+ const applyClassRow = async (chosen) => {
2193
+ if (!chosen || !chosen.class) return;
2194
+ await dispatch(`/class ${chosen.class}`);
2195
+ };
2196
+
2152
2197
  /**
2153
2198
  * Pin an effort rung — the ONE path a rung is applied through, shared by
2154
2199
  * Enter, shift+enter and the shift+arrow chords.
@@ -2194,14 +2239,14 @@ async function runSession(host) {
2194
2239
  }
2195
2240
  return;
2196
2241
  }
2197
- if (key.name === KEY.TAB && (type === 'model' || type === 'effort')) {
2242
+ if (key.name === KEY.TAB && (type === 'model' || type === 'effort' || type === 'class')) {
2198
2243
  // Reference parity (aegiscodex-dev/src/main.js's model overlay cycles on
2199
2244
  // Tab). It is also the one way to walk either picker that survives a link
2200
2245
  // where arrow escapes are eaten, since Tab is a single control byte.
2201
2246
  // Both lists are addressed the one way each of them can be: the catalogue
2202
2247
  // lives in `overlay.items`, while the rungs are the picker's own table —
2203
2248
  // the same table Enter and shift+enter resolve through.
2204
- const n = type === 'model'
2249
+ const n = type === 'model' || type === 'class'
2205
2250
  ? (overlay.items || []).length
2206
2251
  : overlays.EFFORT_VALUES.length;
2207
2252
  if (n) {
@@ -2239,6 +2284,14 @@ async function runSession(host) {
2239
2284
  applyEffortRow(overlay.sel || 0);
2240
2285
  return;
2241
2286
  }
2287
+ if (type === 'class') {
2288
+ const chosen = (overlay.items || [])[overlay.sel || 0];
2289
+ overlay = null;
2290
+ render();
2291
+ await applyClassRow(chosen);
2292
+ render();
2293
+ return;
2294
+ }
2242
2295
  if (type === 'resume') {
2243
2296
  const chosen = (overlay.items || [])[overlay.sel || 0];
2244
2297
  overlay = null;
@@ -2269,6 +2322,14 @@ async function runSession(host) {
2269
2322
  render();
2270
2323
  return;
2271
2324
  }
2325
+ if (type === 'class') {
2326
+ const chosen = (overlay.items || [])[overlay.sel || 0];
2327
+ overlay = null;
2328
+ render();
2329
+ await applyClassRow(chosen);
2330
+ render();
2331
+ return;
2332
+ }
2272
2333
  if (type === 'effort') {
2273
2334
  applyEffortRow(overlay.sel || 0);
2274
2335
  return;
@@ -2297,6 +2358,14 @@ async function runSession(host) {
2297
2358
  render();
2298
2359
  return;
2299
2360
  }
2361
+ if (type === 'class') {
2362
+ const chosen = (overlay.items || [])[overlay.sel || 0];
2363
+ overlay = null;
2364
+ render();
2365
+ await applyClassRow(chosen);
2366
+ render();
2367
+ return;
2368
+ }
2300
2369
  if (type === 'effort') {
2301
2370
  applyEffortRow(overlay.sel || 0);
2302
2371
  return;
@@ -2345,7 +2414,7 @@ async function runSession(host) {
2345
2414
  }
2346
2415
  return;
2347
2416
  }
2348
- if (type === 'effort' || type === 'resume') {
2417
+ if (type === 'effort' || type === 'resume' || type === 'class') {
2349
2418
  // Bounded by the same row count every other mover is bounded by. A row
2350
2419
  // number past the end used to be accepted unseen (`sel = idx - 1` with
2351
2420
  // no upper clamp), so '9' in /effort parked the highlight off the list