aegiscode 7.0.9 → 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.9",
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
@@ -1517,6 +1517,7 @@ function createApp(options = {}) {
1517
1517
  else if (o.type === 'palette') lines = overlays.renderPalette(visibleCommands(), { query: o.query || '', sel: o.sel || 0 }, W, rows);
1518
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);
1519
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);
1520
1521
  else if (o.type === 'resume') lines = overlays.renderResumeList(o.items || [], o.sel || 0, W, rows);
1521
1522
  else if (o.type === 'confirm') lines = render.renderApproval(ctx(), o.info || {}, W).map((s) => [spanRow(s)]);
1522
1523
  if (!lines) return;
@@ -1742,6 +1743,17 @@ function createApp(options = {}) {
1742
1743
  // leave a working prompt rather than aborting the command.
1743
1744
  const spec = await describeSecret(cmd, args);
1744
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 };
1745
1757
  const key = await askSecret((spec && spec.prompt) || `provider key for ${args.provider}: `);
1746
1758
  if (!key) {
1747
1759
  emit(render.renderNotice(ctx(), 'warn', 'empty key — nothing sent'));
@@ -2158,11 +2170,21 @@ function createApp(options = {}) {
2158
2170
  // Without these two the picker would re-prompt for a key the machine
2159
2171
  // demonstrably holds, which is how the same key got saved twice.
2160
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()`.
2161
2179
  hasProviderKey: (provider) => {
2162
2180
  const store = engine.settings;
2163
- if (!store || typeof store.get !== 'function' || !provider) return false;
2164
- const row = (store.get(byokNamespace(provider)) || {});
2165
- 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);
2166
2188
  },
2167
2189
  loadModels: (o) => loadModels(o),
2168
2190
  buildState: () => buildState(),
@@ -2473,11 +2495,18 @@ function createApp(options = {}) {
2473
2495
  cloudsync,
2474
2496
  keyStatus: () => credentials.keyStatus(),
2475
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.
2476
2501
  hasProviderKey: (provider) => {
2477
2502
  const store = engine.settings;
2478
- if (!store || typeof store.get !== 'function' || !provider) return false;
2479
- const row = (store.get(byokNamespace(provider)) || {});
2480
- 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);
2481
2510
  },
2482
2511
  sessionId: () => commandCtx.sessionId,
2483
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
@@ -1266,6 +1266,11 @@ async function runSession(host) {
1266
1266
  );
1267
1267
  } else if (overlay.type === 'effort') {
1268
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
+ );
1269
1274
  } else if (overlay.type === 'resume') {
1270
1275
  ol = overlays.renderResumeList(overlay.items || [], overlay.sel || 0, cols, termRows);
1271
1276
  } else if (overlay.type === 'shortcuts') {
@@ -1518,6 +1523,12 @@ async function runSession(host) {
1518
1523
  if (tool.phase === 'run') {
1519
1524
  const n = ++toolSeq;
1520
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 });
1521
1532
  pushToolRow(
1522
1533
  {
1523
1534
  role: 'tool',
@@ -1528,6 +1539,8 @@ async function runSession(host) {
1528
1539
  id: tool.id,
1529
1540
  label: `Running ${n} ${prefix}${toolLabel(tool.name, n)}…`,
1530
1541
  start: Date.now(),
1542
+ diff,
1543
+ diffOpen: defaultOpen(diff),
1531
1544
  },
1532
1545
  msg
1533
1546
  );
@@ -1538,7 +1551,12 @@ async function runSession(host) {
1538
1551
  // post-execution). Falling through left the row unwritten, so the
1539
1552
  // turn silently showed no tool activity at all. Record the finished
1540
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.
1541
1558
  const n = ++toolSeq;
1559
+ const diff = editPreview(tool.name, tool.args, { cwd: tool.cwd });
1542
1560
  pushToolRow(
1543
1561
  {
1544
1562
  role: 'tool',
@@ -1549,6 +1567,8 @@ async function runSession(host) {
1549
1567
  id: tool.id,
1550
1568
  ok: tool.ok,
1551
1569
  label: `Ran ${n} ${tool.agent ? `${tool.agent} ▸ ` : ''}${toolLabel(tool.name, n)}`,
1570
+ diff,
1571
+ diffOpen: defaultOpen(diff),
1552
1572
  },
1553
1573
  msg
1554
1574
  );
@@ -2008,7 +2028,7 @@ async function runSession(host) {
2008
2028
  (c) => c.aliases || []
2009
2029
  ).length;
2010
2030
  }
2011
- 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;
2012
2032
  if (overlay.type === 'effort') return overlays.EFFORT_VALUES.length;
2013
2033
  return 0;
2014
2034
  };
@@ -2163,6 +2183,17 @@ async function runSession(host) {
2163
2183
  await collectKeyFor(chosen);
2164
2184
  };
2165
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
+
2166
2197
  /**
2167
2198
  * Pin an effort rung — the ONE path a rung is applied through, shared by
2168
2199
  * Enter, shift+enter and the shift+arrow chords.
@@ -2208,14 +2239,14 @@ async function runSession(host) {
2208
2239
  }
2209
2240
  return;
2210
2241
  }
2211
- if (key.name === KEY.TAB && (type === 'model' || type === 'effort')) {
2242
+ if (key.name === KEY.TAB && (type === 'model' || type === 'effort' || type === 'class')) {
2212
2243
  // Reference parity (aegiscodex-dev/src/main.js's model overlay cycles on
2213
2244
  // Tab). It is also the one way to walk either picker that survives a link
2214
2245
  // where arrow escapes are eaten, since Tab is a single control byte.
2215
2246
  // Both lists are addressed the one way each of them can be: the catalogue
2216
2247
  // lives in `overlay.items`, while the rungs are the picker's own table —
2217
2248
  // the same table Enter and shift+enter resolve through.
2218
- const n = type === 'model'
2249
+ const n = type === 'model' || type === 'class'
2219
2250
  ? (overlay.items || []).length
2220
2251
  : overlays.EFFORT_VALUES.length;
2221
2252
  if (n) {
@@ -2253,6 +2284,14 @@ async function runSession(host) {
2253
2284
  applyEffortRow(overlay.sel || 0);
2254
2285
  return;
2255
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
+ }
2256
2295
  if (type === 'resume') {
2257
2296
  const chosen = (overlay.items || [])[overlay.sel || 0];
2258
2297
  overlay = null;
@@ -2283,6 +2322,14 @@ async function runSession(host) {
2283
2322
  render();
2284
2323
  return;
2285
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
+ }
2286
2333
  if (type === 'effort') {
2287
2334
  applyEffortRow(overlay.sel || 0);
2288
2335
  return;
@@ -2311,6 +2358,14 @@ async function runSession(host) {
2311
2358
  render();
2312
2359
  return;
2313
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
+ }
2314
2369
  if (type === 'effort') {
2315
2370
  applyEffortRow(overlay.sel || 0);
2316
2371
  return;
@@ -2359,7 +2414,7 @@ async function runSession(host) {
2359
2414
  }
2360
2415
  return;
2361
2416
  }
2362
- if (type === 'effort' || type === 'resume') {
2417
+ if (type === 'effort' || type === 'resume' || type === 'class') {
2363
2418
  // Bounded by the same row count every other mover is bounded by. A row
2364
2419
  // number past the end used to be accepted unseen (`sel = idx - 1` with
2365
2420
  // no upper clamp), so '9' in /effort parked the highlight off the list
package/src/commands.js CHANGED
@@ -3057,6 +3057,7 @@ const COMMANDS = [
3057
3057
  return {
3058
3058
  note: `${p.id} already has a key${p.masked ? ` (${p.masked})` : ''} — pasting a new one replaces it.`,
3059
3059
  prompt: `new ${p.label || p.id} key: `,
3060
+ provider: p.id,
3060
3061
  };
3061
3062
  }
3062
3063
  const bits = [`${p.label || p.id}`];
@@ -3066,7 +3067,7 @@ const COMMANDS = [
3066
3067
  if (models.length) bits.push(`unlocks ${models.join(', ')}`);
3067
3068
  if (p.key_prefix) bits.push(`key starts with ${p.key_prefix}`);
3068
3069
  if (p.key_url) bits.push(`create one at ${p.key_url}`);
3069
- return { note: bits.join(' · '), prompt: `${p.id} key: ` };
3070
+ return { note: bits.join(' · '), prompt: `${p.id} key: `, provider: p.id };
3070
3071
  },
3071
3072
  },
3072
3073
  {
@@ -3089,30 +3090,12 @@ const COMMANDS = [
3089
3090
  // at all falls back to the two static rows below.
3090
3091
  const classes = await Promise.resolve(c.classes ? c.classes() : []).catch(() => []);
3091
3092
  const rows = classes.length ? classes : [{ class: 'aegis' }, { class: 'byok' }];
3092
- const lines = [
3093
- [span(C.gold + BOLD, 'Class'), span(BOLD_OFF, ' — which route the next turn takes')],
3094
- [span(C.gray, '─'.repeat(52))],
3095
- ];
3096
- for (const k of rows) {
3097
- const id = k.class;
3098
- const on = id === cur;
3099
- // The distinction that matters to a user: who pays, and with which
3100
- // credential. Stated per class rather than in a footnote.
3101
- const note =
3102
- id === 'byok'
3103
- ? k.configured
3104
- ? 'your key, relayed by AEGIS — billed a handling fee'
3105
- : 'needs a provider key: /byok-key <provider>'
3106
- : 'the pool — your AEGIS account key pays for it';
3107
- lines.push([
3108
- span(on ? C.green : C.gray, ` ${on ? '●' : '○'} ${String(id).padEnd(6)}`),
3109
- span(on ? C.green : C.gray, label(id)),
3110
- span(C.gray, ` ${note}`),
3111
- ]);
3112
- }
3113
- lines.push('', [span(C.gray, ' switch with /class byok or /class aegis')]);
3114
- panel(c, lines);
3115
- c.render();
3093
+ const sel = rows.findIndex((k) => k.class === cur);
3094
+ // An interactive picker, not a static panel — the same tab/arrow/enter
3095
+ // overlay machinery /model already uses (chatflow.js handleOverlayKey),
3096
+ // so a class is switched by moving the highlight and hitting enter
3097
+ // rather than retyping its name after reading it off this list.
3098
+ c.openOverlay({ type: 'class', items: rows, sel: sel < 0 ? 0 : sel, current: cur });
3116
3099
  return true;
3117
3100
  }
3118
3101
  const res = c.switchClass(want);
@@ -3163,45 +3146,33 @@ const COMMANDS = [
3163
3146
  },
3164
3147
  {
3165
3148
  name: 'models', aliases: ['model-list'], hint: '', category: 'model',
3166
- desc: 'List the model ids you can pin with /model, for the class you are on',
3149
+ desc: 'Pick a model to pin, for the class you are on — opens the same picker as /model',
3167
3150
  handler: async (c) => {
3168
3151
  const cls = (c.ctx && c.ctx.modelClass) || 'aegis';
3169
3152
  const models = (await c.listModelsFor(cls)) || [];
3170
- const lines = [
3171
- [span(C.gold + BOLD, 'Models'), span(BOLD_OFF, ` — ${c.classLabel ? c.classLabel(cls) : cls}`)],
3172
- [span(C.gray, '─'.repeat(52))],
3173
- ];
3174
3153
  if (!models.length) {
3175
- lines.push('', [
3176
- span(
3177
- C.gray,
3178
- cls === 'byok'
3179
- ? ' nothing to relay yet — save a provider key with /byok-key <provider>'
3180
- : ' no models advertised — check the account with /status, then retry'
3181
- ),
3182
- ]);
3183
- } else {
3184
- const pinned = c.ctx && c.ctx.model;
3185
- for (const m of models) {
3186
- const on = pinned === m.id;
3187
- // A row from the OTHER class rides on this list on purpose — the
3188
- // pooled Nexus row is what makes the byok list able to show a way
3189
- // back to the pooled lane (app.js classScopedModels). It is not
3190
- // pinnable here, so it says which class it runs on instead of
3191
- // looking like a byok id that would 400 at the relay.
3192
- const other = m.cls && m.cls !== cls;
3193
- lines.push([
3194
- span(on ? C.green : C.gray, ` ${on ? '●' : '○'} `),
3195
- span(on ? C.green : C.gray, String(m.id).padEnd(30)),
3196
- span(C.gray, other
3197
- ? `${m.note || m.label || ''} · pooled lane — /class ${m.cls}`
3198
- : m.note || m.label || ''),
3199
- ]);
3200
- }
3201
- lines.push('', [span(C.gray, ' pin one with /model <id> — /model alone opens the picker')]);
3154
+ note(c, cls === 'byok'
3155
+ ? 'nothing to relay yet — save a provider key with /byok-key <provider>'
3156
+ : 'no models advertised — check the account with /status, then retry');
3157
+ c.render();
3158
+ return true;
3202
3159
  }
3203
- panel(c, lines);
3204
- c.render();
3160
+ const pinned = c.ctx && c.ctx.model;
3161
+ // A row from the OTHER class rides on this list on purpose — the pooled
3162
+ // Nexus row is what makes the byok list able to show a way back to the
3163
+ // pooled lane (app.js classScopedModels). It is not a row of THIS
3164
+ // class's own ids, so its note says which class it actually runs on
3165
+ // instead of looking like a byok id that would 400 at the relay.
3166
+ const items = models.map((m) => (m.cls && m.cls !== cls
3167
+ ? { ...m, note: `${m.note || m.label || ''} · pooled lane — /class ${m.cls}` }
3168
+ : m));
3169
+ const sel = items.findIndex((m) => m.id === pinned);
3170
+ // Same overlay /model opens (tab/arrow to move, enter to pin — see
3171
+ // chatflow.js handleOverlayKey), just scoped to this class's own rows
3172
+ // rather than /model's merged cross-class catalog. Picking the other
3173
+ // class's row switches class first, the same cross-class pin
3174
+ // applyModelRow already does for /model's own rows.
3175
+ c.openOverlay({ type: 'model', items, sel: sel < 0 ? 0 : sel, current: pinned, cls });
3205
3176
  return true;
3206
3177
  },
3207
3178
  },
@@ -3229,6 +3200,24 @@ const COMMANDS = [
3229
3200
  c.push({ role: 'error', text: `"${typed}" matches ${match.ambiguous.join(', ')} — retype the exact id.` });
3230
3201
  return true;
3231
3202
  }
3203
+ // A key written under a provider the relay does not serve is unusable and
3204
+ // invisible: the catalog never lists the row it created, so the user sees
3205
+ // "saved" and then no models, with nothing naming the typo. `byok-set`
3206
+ // already refuses this; the command it redirects users TO must refuse it
3207
+ // too, or the redirect trades one silent failure for another.
3208
+ //
3209
+ // Only refused when the catalog actually answered. `byokCatalog` returns
3210
+ // null on an unreachable server, and refusing on null would turn a
3211
+ // network blip into "unknown provider" — a wrong reason for a right-looking
3212
+ // stop. With no catalog the typed id is trusted, as before.
3213
+ if (providers && !match?.provider) {
3214
+ const ids = providers.map((x) => x.id).join(', ');
3215
+ c.push({
3216
+ role: 'error',
3217
+ text: `unknown provider "${typed}". Known ids: ${ids} — nothing was saved.`,
3218
+ });
3219
+ return true;
3220
+ }
3232
3221
  const p = match && match.provider;
3233
3222
  const id = (p && p.id) || typed;
3234
3223
  // A second token is the scriptable path (`/byok-key openai sk-…`); with
package/src/engine.js CHANGED
@@ -116,10 +116,36 @@ function createEngine({ client, getConfirmMode, getClass, settings: injectedSett
116
116
  }
117
117
 
118
118
  function chat(payload, onDelta) {
119
- const cls = currentClass();
120
119
  // `class` is stamped here rather than sent by every caller, so the class a
121
120
  // turn runs on has exactly one source of truth (the live session state) and
122
121
  // a caller cannot accidentally pin a stale one.
122
+ //
123
+ // …WHEN THERE IS A LIVE SESSION TO STAMP FROM. `getClass` is the
124
+ // interactive surface's `/class` state; a payload that NAMES a class is
125
+ // stating its own, and the only such caller is the autonomous queue, whose
126
+ // tasks each carry the class they were queued on (autonomous.js runTask).
127
+ // The drain builds this engine through buildEngine() below, which supplies
128
+ // no `getClass` at all — deliberately, because a drain has no interactive
129
+ // session to read.
130
+ //
131
+ // Reading `currentClass()` unconditionally was therefore not a clamp but an
132
+ // OVERWRITE: every queued task went out as `class: 'aegis'` regardless of
133
+ // what it was queued as, so a byok or local task (feature from 9eeef09) was
134
+ // billed to the pooled route it did not ask for, on a model id the pool
135
+ // does not serve. Verified against this tree: a payload `{class:'pro'}` was
136
+ // observed arriving at the shared engine as `{class:'aegis'}`.
137
+ //
138
+ // Precedence is unchanged for the interactive path, which always supplies
139
+ // `getClass`: a live class wins over anything a payload carries, so a stale
140
+ // value still cannot pin a turn. Only an ABSENT live class lets the
141
+ // payload's own class through, and then only one this host can run.
142
+ const live = typeof getClass === 'function' ? getClass() : null;
143
+ const stated = payload && payload.class;
144
+ const cls = HOST_CLASSES.includes(live)
145
+ ? live
146
+ : HOST_CLASSES.includes(stated)
147
+ ? stated
148
+ : DEFAULT_CLASS;
123
149
  return local.chat({ ...payload, class: cls }, onDelta);
124
150
  }
125
151
 
package/src/limits.js CHANGED
@@ -101,7 +101,7 @@ const UNITS = Object.freeze([
101
101
  * The masked digest of the sealed set. Rewritten ONLY by
102
102
  * `node tools/provenance.mjs seal --write`, never by hand.
103
103
  */
104
- const SEALED = '400c9a8d7deb897b43ba3d993b4fff04d8d11e9426fef06141898b320ecff365';
104
+ const SEALED = '32ce3ebb806e116aefc6be2e3a8e6fbc04503cedf85e4460c78baf761c3b92c6';
105
105
 
106
106
  /** Subcommands that a build failing this check does not get to run. */
107
107
  const PRIVILEGED = Object.freeze(['gate', 'provenance', 'mcp']);
package/src/overlays.js CHANGED
@@ -285,6 +285,49 @@ function renderEffortPicker(sel = 0, width = 80, current = null, levels = EFFORT
285
285
  return fit(lines, width);
286
286
  }
287
287
 
288
+ // ── Class picker overlay (/class) ────────────────────────────────────────────
289
+
290
+ /**
291
+ * @param {Array} classes entries ({class, configured?})
292
+ * @param {number} sel selected index
293
+ * @param {number} width
294
+ * @param {string|null} current the live class id
295
+ * @param {(cls: string) => string} [classLabel] the caller's label table, so
296
+ * the class is named one way in every surface rather than re-spelled here.
297
+ */
298
+ function renderClassPicker(classes, sel = 0, width = 80, current = null, classLabel = null) {
299
+ const list = Array.isArray(classes) ? classes : [];
300
+ const label = (id) => (typeof classLabel === 'function' ? classLabel(id) : id) || id;
301
+ const lines = [];
302
+ lines.push(blank(width));
303
+ lines.push([span('', ' '), span(C.white + BOLD, 'Select class'), span(BOLD_OFF, '')]);
304
+ lines.push([span('', ' '), span(C.gray, 'Which route the next turn takes — who pays, and with which credential.')]);
305
+ lines.push(blank(width));
306
+ for (let i = 0; i < list.length; i++) {
307
+ const k = list[i] || {};
308
+ const id = k.class;
309
+ const active = i === sel;
310
+ const cur = current != null && id === current;
311
+ const left = active ? span(C.lavender, GLYPH.cursor) : span('', ' ');
312
+ const name = label(id);
313
+ const nameSpan = active ? span(C.lavender, name) : span(C.white, name);
314
+ const mark = cur ? span(C.green, ' ' + GLYPH.check) : span('', '');
315
+ const pad = ' '.repeat(Math.max(1, 14 - [...name].length));
316
+ // Same distinction /class's static panel used to draw: who pays, and with
317
+ // which credential, so the picker says exactly what the printed table did.
318
+ const note =
319
+ id === 'byok'
320
+ ? k.configured
321
+ ? 'your key, relayed by AEGIS — billed a handling fee'
322
+ : 'needs a provider key: /byok-key <provider>'
323
+ : 'the pool — your AEGIS account key pays for it';
324
+ lines.push([span('', ' '), left, span('', ' '), nameSpan, mark, span(C.gray, pad + note)]);
325
+ }
326
+ lines.push(blank(width));
327
+ lines.push([span('', ' '), span(C.gray, PICKER_HINT)]);
328
+ return fit(lines, width);
329
+ }
330
+
288
331
  // ── Resume-list overlay (/resume) ────────────────────────────────────────────
289
332
 
290
333
  /**
@@ -358,6 +401,7 @@ module.exports = {
358
401
  renderPalette,
359
402
  renderModelPicker,
360
403
  renderEffortPicker,
404
+ renderClassPicker,
361
405
  renderResumeList,
362
406
  EFFORT_LEVELS,
363
407
  EFFORT_VALUES,
@@ -29,8 +29,8 @@
29
29
  "p3": "ff962ac8dbf42cecb2477e2f77bf5ec61f88aa1751b0d4e506bf030fbc5fc6c6",
30
30
  "p4": "2e8385c3a653a2af324050b4b92aeb9d142fc6765c91a13ccc928c5d4a2dbedb",
31
31
  "p5": "408d67f78f31f6d637a26d2852e0c809a260544e613afdc64b731401c0ba3801",
32
- "p6": "2a934a1b76e1321457d0a2e7ebf91dcc9520097d6b62f7d5a99af0bd69c2cf97",
33
- "p7": "904efedb3101cca9d7b81009dfe72216ce773e7ab8f5bc603327b2f76da356be",
32
+ "p6": "50da0fa70ab4210f5fd6358c174009e91f481870136075f623a8592b1f19bd90",
33
+ "p7": "227117377da48ae003c4b971d242d579bfc8156c61d7719a2d3b331022a9b570",
34
34
  "p8": "3cc054d06715e065fe635b37b7d1bb98bf7989d64453a572ddbb77cec5b830e7"
35
35
  }
36
36
  }
@@ -209,8 +209,15 @@ const DEFAULT_MODEL = 'nexus-brain';
209
209
  * depends on what the user's own daemon happens to have. Both REQUIRE an
210
210
  * explicit model, refused by name instead of silently resolving to
211
211
  * something nobody chose.
212
+ * - 'pro' DOES have a default, but not one this app chooses: a blank model
213
+ * means "the `claude` CLI picks for the subscription", which is what
214
+ * `--model` omitted says (engine.js sends no flag for `default`). Once a
215
+ * model IS stated it must be one of claude-pro.js's PRO_MODELS aliases —
216
+ * the same list the model picker offers — because the child accepts only
217
+ * those four spellings, and a `provider:model` id copied from a byok task
218
+ * would otherwise be handed to `claude --model` and fail there.
212
219
  */
213
- const MODEL_CLASSES = Object.freeze(['aegis', 'byok', 'local']);
220
+ const MODEL_CLASSES = Object.freeze(['aegis', 'byok', 'local', 'pro']);
214
221
 
215
222
  const AEGIS_MODEL_RE = /^(?:nexus|aegis)-brain(?:-(?:smart|neo))?$/;
216
223
  const AEGIS_MODEL_IDS = Object.freeze(['nexus-brain', 'aegis-brain']);
@@ -270,6 +277,34 @@ function modelRefusal(id, cls) {
270
277
  }
271
278
  return '';
272
279
  }
280
+ if (normalized === 'pro') {
281
+ // The subscription route. A blank model is legal and meaningful: engine.js
282
+ // sends no `--model` at all for 'default', so the child resolves the pick
283
+ // itself. Anything STATED must be a PRO_MODELS alias, because those four
284
+ // spellings are exactly what `claude --model` accepts — a byok-style
285
+ // "provider:model" copied between tasks would be handed to the child and
286
+ // fail there, three stages into a drain, with the queue's own file naming
287
+ // something the queue never validated.
288
+ if (!stated) return '';
289
+ // Required lazily: claude-pro.js is a heavy sibling (child spawn, session
290
+ // files) and this module is loaded by queue.js at every CLI start. The
291
+ // require is a plain sibling path with no back-require, so there is no
292
+ // cycle to guard — this is about load cost, not correctness.
293
+ let aliases;
294
+ try {
295
+ aliases = require('./claude-pro.js').PRO_MODELS;
296
+ } catch {
297
+ // If the alias list cannot be read we cannot validate a stated model, and
298
+ // accepting it unvalidated is the exact failure this arm exists to stop.
299
+ return `a pro task's model cannot be checked right now — queue it with no --model to let the claude CLI pick`;
300
+ }
301
+ const ids = (Array.isArray(aliases) ? aliases : []).map((m) => String(m && m.id).trim());
302
+ if (ids.includes(stated.toLowerCase())) return '';
303
+ return (
304
+ `the autonomous queue's Pro class runs the subscription through the claude CLI, ` +
305
+ `which accepts only its own model aliases (${ids.join('/')}); "${stated}" is not one`
306
+ );
307
+ }
273
308
  // normalized === 'local'
274
309
  if (!stated) return 'a local task needs a model — the tag of whatever is pulled into the local daemon';
275
310
  return '';
@@ -594,13 +629,18 @@ function createQueueWorker({
594
629
  */
595
630
  async function runTask(item, { carry = '', commit } = {}) {
596
631
  const cwd = item.cwd || process.cwd();
597
- // Aegis Cloud or nothing — checked BEFORE the turn, not at the server. An
598
- // item whose model is not a pooled tier (a hand-edited queue file, a
599
- // `--model` the CLI accepted before this rule existed, another host's
600
- // older build) would otherwise go out as `class: 'aegis'` with an id the
601
- // pool does not serve: billed work if it happens to be a per-provider
602
- // spelling, an opaque server error otherwise. Failing here names the model
603
- // and the allowed ones, and costs nothing.
632
+ // The task's own (model, class) pair checked BEFORE the turn, not at the
633
+ // server. An item whose model does not belong to its class (a hand-edited
634
+ // queue file, a `--model` the CLI accepted before this rule existed,
635
+ // another host's older build) would otherwise go out under a transport
636
+ // that does not serve it: billed work if it happens to be a per-provider
637
+ // spelling, an opaque server error otherwise, and for 'pro' a `claude
638
+ // --model` that the child rejects. Failing here names the model and the
639
+ // spellings that class accepts, and costs nothing.
640
+ //
641
+ // "Aegis Cloud or nothing" was this comment's old claim, and it stopped
642
+ // being true when byok/local were added (9eeef09) — modelRefusal is what
643
+ // actually enforces the rule now, per class, and it runs for all four.
604
644
  const cls = normalizeClass(item.class);
605
645
  const refusal = modelRefusal(item.model, cls);
606
646
  if (refusal) {