aegiscode 6.8.36 → 7.0.0
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 +39 -1
- package/package.json +1 -1
- package/src/app.js +74 -1
- package/src/chatflow.js +141 -1
- package/src/commands.js +172 -1
- package/src/engine.js +4 -2
- package/src/screens.js +118 -25
- package/vendor/client/aegis.js +22 -0
- package/vendor/client/byok-catalog.js +43 -8
- package/vendor/client/user-models.js +378 -0
- package/vendor/desktop/lib/local/autonomous.js +81 -0
- package/vendor/desktop/lib/local/engine.js +447 -14
- package/vendor/desktop/renderer/usage.js +68 -1
package/README.md
CHANGED
|
@@ -255,7 +255,7 @@ command for command — 87 entries across nine categories:
|
|
|
255
255
|
|---|---|
|
|
256
256
|
| Session & context | `/schedule` `/clear` `/compact` `/context` `/todos` `/config` `/exit` `/recap` `/resume` `/rewind` `/agents` `/status` `/teleport` `/version` `/new` `/skills` `/multiyolo` `/multi` `/research` `/debate` |
|
|
257
257
|
| Workspace | `/run` `/build` `/cd` `/init` `/clone` |
|
|
258
|
-
| Model & behavior | `/ping` `/effort` `/model` `/theme` `/terminal` `/vim` `/permissions` `/hooks` `/credentials` `/install-github-app` `/thinking` `/mcp` `/memory` `/memory-deep` `/confirm` `/automode` *(alias `/yolo`)* `/router` `/class`
|
|
258
|
+
| Model & behavior | `/ping` `/effort` `/model` `/models` `/model-add` `/model-rm` `/theme` `/terminal` `/vim` `/permissions` `/hooks` `/credentials` `/install-github-app` `/thinking` `/mcp` `/memory` `/memory-deep` `/confirm` `/automode` *(alias `/yolo`)* `/router` `/class` |
|
|
259
259
|
| Data | `/copy` `/cost` `/export` `/tokens` `/sync` |
|
|
260
260
|
| Auth | `/login` `/logout` `/key` `/byok` `/byok-set` `/byok-rm` `/byok-key` `/byok-rm-key` |
|
|
261
261
|
| Support | `/help` `/doctor` `/upgrade` `/troubleshooting` `/feedback` `/bug` `/issue` `/onboarding` `/shell-completion` `/terminal-setup` `/pr-comments` `/prs` `/review` `/benchmark` `/billing` `/topup` `/cloud` `/gmail` `/release-notes` |
|
|
@@ -338,6 +338,44 @@ Selecting it switches the class to `aegis` first (this is the one row that is
|
|
|
338
338
|
not a `provider:model` id); pinning it *without* switching is not offered,
|
|
339
339
|
because the relay would read `nexus-brain` as a provider name.
|
|
340
340
|
|
|
341
|
+
**3. Adding a model nobody has released yet.**
|
|
342
|
+
|
|
343
|
+
Vendors ship models faster than any client can be updated, and the BYOK relay is
|
|
344
|
+
a pass-through: your own vendor key authenticates upstream and AEGIS forwards the
|
|
345
|
+
model string it is handed. So an id your provider serves is callable the moment
|
|
346
|
+
your machine offers it as a row — which is what these do:
|
|
347
|
+
|
|
348
|
+
```bash
|
|
349
|
+
/model-add deepseek deepseek-v4.2-preview # offer it on this machine
|
|
350
|
+
/model-rm deepseek deepseek-v4.2-preview # forget it
|
|
351
|
+
/model-add deepseek # prompt for the id instead
|
|
352
|
+
```
|
|
353
|
+
|
|
354
|
+
`/model-add` resolves the provider against the relay's catalogue first, so a
|
|
355
|
+
provider the relay takes no key for is **refused** rather than stored — a
|
|
356
|
+
declaration for a slug the relay does not accept would appear in no picker at
|
|
357
|
+
all, and the failure would land on your first turn. The id itself is shape
|
|
358
|
+
checked (no spaces, no colon — `provider:model` is the id a pin uses) but never
|
|
359
|
+
checked against a vendor list: reaching a model the catalogue has not caught up
|
|
360
|
+
with is the entire point.
|
|
361
|
+
|
|
362
|
+
The declaration lives in **`~/.aegiscode/models.json`** (`$AEGISCODE_HOME` if you
|
|
363
|
+
set it), which is also the file the desktop's Settings pane writes and reads. Add
|
|
364
|
+
a model in the terminal and it is in the window's picker on its next refresh,
|
|
365
|
+
with no restart; add one in the window and `/models` shows it immediately. The
|
|
366
|
+
file is plain JSON and 0600, so a bulk edit is an editor away:
|
|
367
|
+
|
|
368
|
+
```json
|
|
369
|
+
{
|
|
370
|
+
"deepseek": ["deepseek-v4.2-preview"],
|
|
371
|
+
"anthropic": ["claude-opus-9-1"]
|
|
372
|
+
}
|
|
373
|
+
```
|
|
374
|
+
|
|
375
|
+
Nothing here is validated against a vendor on read, so a hand-typed row that the
|
|
376
|
+
vendor does not serve will 404 on your first turn — that is the one cost of the
|
|
377
|
+
escape hatch, and it is why the commands validate what they store.
|
|
378
|
+
|
|
341
379
|
```bash
|
|
342
380
|
aegiscode -m nexus-brain -p "…" # pin at launch
|
|
343
381
|
aegiscode -m anthropic:claude-sonnet-4-5 -p "…" # a BYOK id at launch
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "aegiscode",
|
|
3
3
|
"productName": "AEGIS Code",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "7.0.0",
|
|
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",
|
package/src/app.js
CHANGED
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
const readline = require('node:readline');
|
|
22
22
|
const os = require('node:os');
|
|
23
23
|
const { randomUUID } = require('node:crypto');
|
|
24
|
-
const { createTools, createClient, usageTokens, usageBuckets, buildSystemPrompt, autoProvisionApiKey, hostEnv } = require('./deps.js');
|
|
24
|
+
const { createTools, createClient, usageTokens, usageBuckets, buildSystemPrompt, autoProvisionApiKey, hostEnv, autonomous } = require('./deps.js');
|
|
25
25
|
const { createEngine, HOST_CLASSES, DEFAULT_CLASS, byokNamespace, effortRung } = require('./engine.js');
|
|
26
26
|
const { GLYPH, VERBS, themeOf, RESET, THEME_TABLE, AUTO_THEME_INDEX, themeIsLight, reconcileThemeIndex } = require('./theme.js');
|
|
27
27
|
const { probeTerminalBackground } = require('./caps.js');
|
|
@@ -174,6 +174,32 @@ function createApp(options = {}) {
|
|
|
174
174
|
// `/automode` and `/confirm` write the store, so a captured flag made both
|
|
175
175
|
// commands cosmetic — the panel changed while the engine kept asking.
|
|
176
176
|
let confirmMode = options.confirmMode !== false;
|
|
177
|
+
// ── Auto mode's session start state ────────────────────────────────────────
|
|
178
|
+
// The upstream engine (aegiscodex-dev src/autonomous.js) starts an attended
|
|
179
|
+
// session in auto mode unless AEGIS_AUTO_ROUNDS=0 (false/off/no), and the
|
|
180
|
+
// `←`/`→` chord toggles it freely from there: the env var is a STARTING
|
|
181
|
+
// POINT, not a veto. Same contract here, held in a local rather than
|
|
182
|
+
// re-derived per call, because the two are not the same statement:
|
|
183
|
+
//
|
|
184
|
+
// · re-deriving the env var on every read (a `!autoRoundsDefault(env)`
|
|
185
|
+
// guard inside isYolo) makes the opt-out absolute — `/automode on`,
|
|
186
|
+
// the `→` chord and the window's switch all become no-ops that still
|
|
187
|
+
// write the shared posture OFF, so the CLI chip reads "manual mode on"
|
|
188
|
+
// while the desktop's approvals are off. That is the three-surfaces
|
|
189
|
+
// drift (command, store, engine) this file exists to prevent,
|
|
190
|
+
// reintroduced by an environment variable.
|
|
191
|
+
// · a session flag honours the operator's "start me in manual" without
|
|
192
|
+
// disarming the toggle.
|
|
193
|
+
//
|
|
194
|
+
// `/automode on|off` moves it (commands.js writes `setAutoRounds`), so the
|
|
195
|
+
// chord stays live in both directions and the posture keeps exactly one home.
|
|
196
|
+
let autoRoundsSession = (() => {
|
|
197
|
+
try {
|
|
198
|
+
return autonomous.autoRoundsDefault(process.env);
|
|
199
|
+
} catch {
|
|
200
|
+
return true;
|
|
201
|
+
}
|
|
202
|
+
})();
|
|
177
203
|
const engine =
|
|
178
204
|
options.engine ||
|
|
179
205
|
createEngine({
|
|
@@ -938,6 +964,13 @@ function createApp(options = {}) {
|
|
|
938
964
|
return Promise.resolve('deny');
|
|
939
965
|
};
|
|
940
966
|
|
|
967
|
+
// The round-horizon ask's own no-one-to-answer fallback. Unreachable in
|
|
968
|
+
// practice — `roundsAsk` below is only sent `true` when `p.rounds` exists,
|
|
969
|
+
// so the engine never raises the ask without a prompter — but kept so a
|
|
970
|
+
// future caller that forgets the guard fails safe (stop) instead of
|
|
971
|
+
// hanging the tool loop on an unanswerable promise.
|
|
972
|
+
const denyRoundsNoPrompter = () => Promise.resolve(false);
|
|
973
|
+
|
|
941
974
|
// Vocabulary bridging lives at module scope (see normalizeDecision) so the
|
|
942
975
|
// same function the tests import is the one the live path calls.
|
|
943
976
|
const onDelta = (chunk) => {
|
|
@@ -970,6 +1003,14 @@ function createApp(options = {}) {
|
|
|
970
1003
|
.catch(() => 'deny')
|
|
971
1004
|
.then((decision) => engine.respondApproval(info.id, normalizeDecision(decision)));
|
|
972
1005
|
}
|
|
1006
|
+
if (chunk.rounds) {
|
|
1007
|
+
const info = chunk.rounds;
|
|
1008
|
+
if (live) live.clear();
|
|
1009
|
+
const decide = p.rounds || denyRoundsNoPrompter;
|
|
1010
|
+
Promise.resolve(decide(info))
|
|
1011
|
+
.catch(() => false)
|
|
1012
|
+
.then((decision) => engine.respondRoundsAsk(info.id, decision === true));
|
|
1013
|
+
}
|
|
973
1014
|
};
|
|
974
1015
|
|
|
975
1016
|
try {
|
|
@@ -1004,6 +1045,11 @@ function createApp(options = {}) {
|
|
|
1004
1045
|
// `--no-stream` and piped runs get a single body rather than SSE.
|
|
1005
1046
|
stream: commandCtx.stream !== false,
|
|
1006
1047
|
sessionId,
|
|
1048
|
+
// Opt-in to the round-horizon dialog (see engine.js requestRoundsAsk)
|
|
1049
|
+
// only when there is actually a `rounds` prompter to answer it — a
|
|
1050
|
+
// one-shot `-p` run or any other caller with no presenter keeps the
|
|
1051
|
+
// engine's old stop-and-record-session behaviour untouched.
|
|
1052
|
+
roundsAsk: Boolean(p.rounds),
|
|
1007
1053
|
},
|
|
1008
1054
|
onDelta
|
|
1009
1055
|
);
|
|
@@ -1370,6 +1416,16 @@ function createApp(options = {}) {
|
|
|
1370
1416
|
render: () => {},
|
|
1371
1417
|
openOverlay: (o) => openOverlay(o),
|
|
1372
1418
|
closeOverlay: () => {},
|
|
1419
|
+
// Auto mode's session switch, written by `/automode on|off` (commands.js)
|
|
1420
|
+
// and read by makeHost's isYolo. It lives on the context for the same
|
|
1421
|
+
// reason `switchClass` does: the command must move the fact the status
|
|
1422
|
+
// line, the round-budget allowance and the approval gate all read, or the
|
|
1423
|
+
// command is cosmetic. See the session flag's comment near createApp's
|
|
1424
|
+
// gate wiring for why AEGIS_AUTO_ROUNDS=0 is a starting point and not a
|
|
1425
|
+
// veto.
|
|
1426
|
+
setAutoRounds: (v) => {
|
|
1427
|
+
autoRoundsSession = Boolean(v);
|
|
1428
|
+
},
|
|
1373
1429
|
askInput: () => Promise.resolve(null),
|
|
1374
1430
|
withWorking: (fn) => withWorking(fn),
|
|
1375
1431
|
runPrompt: (text) => runPrompt(text),
|
|
@@ -1392,6 +1448,11 @@ function createApp(options = {}) {
|
|
|
1392
1448
|
// The class surface: /class switches, /models lists for whichever class
|
|
1393
1449
|
// is live (the frozen state carries the current one as c.ctx.modelClass).
|
|
1394
1450
|
listModelsFor: (cls) => listModelsFor(cls),
|
|
1451
|
+
// Re-read the byok rows NOW, past the 5-minute cache. `/model-add` writes
|
|
1452
|
+
// the user-model file and then asks for this, because a picker that
|
|
1453
|
+
// answers from a cache older than the file it just wrote would report the
|
|
1454
|
+
// model it was told to add as missing — for five minutes.
|
|
1455
|
+
refreshByokModels: () => loadByokModels({ force: true }),
|
|
1395
1456
|
switchClass: (cls) => switchClass(cls),
|
|
1396
1457
|
classLabel: (cls) => classLabelOf(cls),
|
|
1397
1458
|
classes: () => (typeof engine.listClasses === 'function' ? engine.listClasses() : []),
|
|
@@ -1933,6 +1994,12 @@ function createApp(options = {}) {
|
|
|
1933
1994
|
},
|
|
1934
1995
|
wantsExit: () => wantExit,
|
|
1935
1996
|
isYolo: () => {
|
|
1997
|
+
// Both halves, in the order the desktop host reads them
|
|
1998
|
+
// (main.js autoRoundsOn): "this session runs auto mode" AND "the
|
|
1999
|
+
// stored posture says don't ask". The first is the session flag above
|
|
2000
|
+
// — `AEGIS_AUTO_ROUNDS=0` starts manual, and `/automode on` (or the
|
|
2001
|
+
// `→` chord, which dispatches exactly that) turns it back on.
|
|
2002
|
+
if (!autoRoundsSession) return false;
|
|
1936
2003
|
try {
|
|
1937
2004
|
// The posture, not the rule file: since ON8 the window's switch is the
|
|
1938
2005
|
// same fact, so a switch turned off there lights this chip too.
|
|
@@ -1941,6 +2008,12 @@ function createApp(options = {}) {
|
|
|
1941
2008
|
return false;
|
|
1942
2009
|
}
|
|
1943
2010
|
},
|
|
2011
|
+
// `/automode on|off` moves the session flag the predicate above reads, so
|
|
2012
|
+
// the command and the chip can never disagree — and an env opt-out is
|
|
2013
|
+
// escapable at the prompt instead of for the life of the process.
|
|
2014
|
+
setAutoRounds: (v) => {
|
|
2015
|
+
autoRoundsSession = Boolean(v);
|
|
2016
|
+
},
|
|
1944
2017
|
};
|
|
1945
2018
|
}
|
|
1946
2019
|
|
package/src/chatflow.js
CHANGED
|
@@ -349,7 +349,7 @@ function statusLine(state, cols, ctx) {
|
|
|
349
349
|
} else if (state.streamJob) {
|
|
350
350
|
left = [span(t.gray, `${GLYPH.bullet} esc to stop`)];
|
|
351
351
|
} else if (state.yolo) {
|
|
352
|
-
left = [span(t.gray, `${GLYPH.bullet} automode on ${GLYPH.bullet} ? for shortcuts ${GLYPH.bullet} ${GLYPH.rightarrow} for
|
|
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`)];
|
|
353
353
|
} else {
|
|
354
354
|
left = [span(t.gray, `${GLYPH.pause} manual mode on ${GLYPH.bullet} ? for shortcuts ${GLYPH.bullet} ${GLYPH.rightarrow} for auto mode`)];
|
|
355
355
|
}
|
|
@@ -435,6 +435,66 @@ function confirmLines(overlay, cols, ctx) {
|
|
|
435
435
|
return lines;
|
|
436
436
|
}
|
|
437
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
|
+
|
|
438
498
|
/**
|
|
439
499
|
* The accounting bits for a turn — model, tokens, the in/out split, €, elapsed
|
|
440
500
|
* and call count. Shared by the standalone `meta` row and the folded footer, so
|
|
@@ -841,6 +901,12 @@ async function runSession(host) {
|
|
|
841
901
|
const lineCache = new WeakMap();
|
|
842
902
|
|
|
843
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;
|
|
844
910
|
let working = false;
|
|
845
911
|
let abort = null;
|
|
846
912
|
let spinnerFrame = 0;
|
|
@@ -1124,6 +1190,8 @@ async function runSession(host) {
|
|
|
1124
1190
|
ol = shortcutsGrid(cols, ctx);
|
|
1125
1191
|
} else if (overlay.type === 'confirm') {
|
|
1126
1192
|
ol = confirmLines(overlay, cols, ctx);
|
|
1193
|
+
} else if (overlay.type === 'rounds') {
|
|
1194
|
+
ol = roundsLines(overlay, cols, ctx);
|
|
1127
1195
|
} else if (overlay.type === 'panel') {
|
|
1128
1196
|
ol = overlay.lines || [];
|
|
1129
1197
|
}
|
|
@@ -1224,6 +1292,73 @@ async function runSession(host) {
|
|
|
1224
1292
|
})();
|
|
1225
1293
|
});
|
|
1226
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
|
+
|
|
1227
1362
|
const startResponse = async (prompt) => {
|
|
1228
1363
|
working = true;
|
|
1229
1364
|
spinnerFrame = 0;
|
|
@@ -1326,6 +1461,7 @@ async function runSession(host) {
|
|
|
1326
1461
|
scheduleRender();
|
|
1327
1462
|
},
|
|
1328
1463
|
approval: (info) => confirmTool(info),
|
|
1464
|
+
rounds: (info) => confirmRoundsExtension(info),
|
|
1329
1465
|
};
|
|
1330
1466
|
|
|
1331
1467
|
let result = null;
|
|
@@ -2483,6 +2619,10 @@ module.exports = {
|
|
|
2483
2619
|
// answers with tokens the engine actually honours (see APPROVAL_CHOICES).
|
|
2484
2620
|
APPROVAL_CHOICES,
|
|
2485
2621
|
APPROVAL_DECISIONS,
|
|
2622
|
+
roundsLines,
|
|
2623
|
+
autoContinuePlan,
|
|
2624
|
+
autoContinueLimit,
|
|
2625
|
+
AUTO_CONTINUE_LIMIT,
|
|
2486
2626
|
rowLines,
|
|
2487
2627
|
transcriptLines,
|
|
2488
2628
|
inputPreviewText,
|
package/src/commands.js
CHANGED
|
@@ -396,6 +396,22 @@ const cloudReady = () => credentials.hasApiKey();
|
|
|
396
396
|
*/
|
|
397
397
|
const { withByokAdditions } = require(resolveShared(path.join('client', 'byok-catalog.js')));
|
|
398
398
|
|
|
399
|
+
/**
|
|
400
|
+
* The models the USER declares (`client/user-models.js`) — the same file the
|
|
401
|
+
* desktop's Settings row writes, resolved by existence through the same
|
|
402
|
+
* `resolveShared` path and for the same reason: one store, three writers.
|
|
403
|
+
*
|
|
404
|
+
* `/byok` and `/models` read it here, and the CLI's own engine
|
|
405
|
+
* (`desktop/lib/local/engine.js` `listModels('byok')`, vendored into this
|
|
406
|
+
* package) applies it too, so the terminal's listing and the terminal's picker
|
|
407
|
+
* cannot disagree about which ids this machine offers.
|
|
408
|
+
*/
|
|
409
|
+
const {
|
|
410
|
+
withUserModels,
|
|
411
|
+
addUserModel,
|
|
412
|
+
removeUserModel,
|
|
413
|
+
} = require(resolveShared(path.join('client', 'user-models.js')));
|
|
414
|
+
|
|
399
415
|
/**
|
|
400
416
|
* The server's BYOK provider catalog, or null when it cannot be reached.
|
|
401
417
|
*
|
|
@@ -410,7 +426,13 @@ async function byokCatalog(client) {
|
|
|
410
426
|
if (!client || typeof client.byokProviders !== 'function') return null;
|
|
411
427
|
try {
|
|
412
428
|
const data = await client.byokProviders();
|
|
413
|
-
|
|
429
|
+
// Two layers, in this order and for the same reason both exist: the
|
|
430
|
+
// shipped additions this repo maintains (`withByokAdditions`) and then the
|
|
431
|
+
// USER's own declarations (`withUserModels`). The user's layer is applied
|
|
432
|
+
// last because it is the most specific opinion — and because a user who
|
|
433
|
+
// declares an id the shipped list also carries still gets ONE row (both
|
|
434
|
+
// functions append only what is missing).
|
|
435
|
+
const providers = withUserModels(withByokAdditions((data && data.providers) || []));
|
|
414
436
|
return providers.length ? providers : null;
|
|
415
437
|
} catch {
|
|
416
438
|
return null;
|
|
@@ -2159,6 +2181,17 @@ const COMMANDS = [
|
|
|
2159
2181
|
// through the one writer, so the window's switch shows it and the two
|
|
2160
2182
|
// faces cannot disagree.
|
|
2161
2183
|
setConfirmPosture(!want);
|
|
2184
|
+
// …and the SESSION's own half. The posture answers "does the window's
|
|
2185
|
+
// switch say don't ask"; the session flag answers "did this sitting start
|
|
2186
|
+
// in auto mode". They are two facts (the upstream engine keeps them apart:
|
|
2187
|
+
// AEGIS_AUTO_ROUNDS=0 starts manual without touching any stored posture),
|
|
2188
|
+
// and with an env opt-out standing, writing only the posture made this
|
|
2189
|
+
// command — and the `→` chord that dispatches it — a no-op that reported
|
|
2190
|
+
// success: the store said "off", the chip still read "manual mode on", and
|
|
2191
|
+
// the tool gate in app.js's isYolo kept asking. Moving both here is what
|
|
2192
|
+
// makes the opt-out escapable at the prompt instead of for the life of the
|
|
2193
|
+
// process. Guarded because an injected/older context may not carry it.
|
|
2194
|
+
if (typeof c.setAutoRounds === 'function') c.setAutoRounds(want);
|
|
2162
2195
|
if (want) panel(c, panels.buildAutomode(c.state(), c.ctx));
|
|
2163
2196
|
else note(c, 'automode off — confirmations restored.');
|
|
2164
2197
|
c.render();
|
|
@@ -2960,6 +2993,144 @@ const COMMANDS = [
|
|
|
2960
2993
|
return true;
|
|
2961
2994
|
},
|
|
2962
2995
|
},
|
|
2996
|
+
{
|
|
2997
|
+
// ── the user's own model declarations ──────────────────────────────────
|
|
2998
|
+
//
|
|
2999
|
+
// The ONE thing this repo could not do before: a provider ships a model on
|
|
3000
|
+
// Tuesday and the user can call it from a BYOK key that same day. The BYOK
|
|
3001
|
+
// relay is a stateless pass-through — the caller's own vendor key
|
|
3002
|
+
// authenticates upstream and AEGIS forwards whatever model string it was
|
|
3003
|
+
// given — so any id the vendor serves is callable the moment this machine
|
|
3004
|
+
// offers it as a row, and this command is how it becomes one without a
|
|
3005
|
+
// release.
|
|
3006
|
+
//
|
|
3007
|
+
// Written through `client/user-models.js`, which is also what the desktop's
|
|
3008
|
+
// Settings row writes and what the shared engine applies to
|
|
3009
|
+
// `listModels('byok')`, so `/models` and the alt+p picker show the row on
|
|
3010
|
+
// the next refresh and the window shows it on ITS next refresh. The file is
|
|
3011
|
+
// printed on success, because a hand-edit is the bulk path and a store the
|
|
3012
|
+
// user cannot find is a store they will not use.
|
|
3013
|
+
name: 'model-add', aliases: ['add-model'], args: ['provider'], hint: '<provider> <model-id>',
|
|
3014
|
+
category: 'model',
|
|
3015
|
+
desc: 'Offer a model id the AEGIS catalog does not name (your key, both faces)',
|
|
3016
|
+
handler: async (c, a) => {
|
|
3017
|
+
const args = a || {};
|
|
3018
|
+
const typed = String(args.provider || '').trim();
|
|
3019
|
+
if (!typed) {
|
|
3020
|
+
c.push({ role: 'error', text: 'Usage: /model-add <provider> <model-id> — /byok lists the providers.' });
|
|
3021
|
+
return true;
|
|
3022
|
+
}
|
|
3023
|
+
const rest = String(args._rest || '').trim();
|
|
3024
|
+
const sp = rest.indexOf(' ');
|
|
3025
|
+
let model = sp === -1 ? '' : rest.slice(sp + 1).trim();
|
|
3026
|
+
if (!model) {
|
|
3027
|
+
// Plain inline input, NOT readSecret: a model id is not a secret, and
|
|
3028
|
+
// hiding it would make a typo unreviewable before it is stored.
|
|
3029
|
+
model = String((await c.askInput(`model id for ${typed}: `)) || '').trim();
|
|
3030
|
+
}
|
|
3031
|
+
if (!model) {
|
|
3032
|
+
c.push({ role: 'note', text: 'nothing saved.' });
|
|
3033
|
+
return true;
|
|
3034
|
+
}
|
|
3035
|
+
// Resolve the provider against the relay's catalog first. A slug the
|
|
3036
|
+
// server does not list can never be attached to a key, so storing it
|
|
3037
|
+
// would produce a declaration that is invisible in every picker — the
|
|
3038
|
+
// silent no-op this whole path is meant to avoid. When the catalog is
|
|
3039
|
+
// unreachable the declaration is kept and SAID to be unverified, because
|
|
3040
|
+
// refusing to work offline is worse than a row that appears later.
|
|
3041
|
+
const providers = await byokCatalog(c.client);
|
|
3042
|
+
const match = providers ? findByokProvider(providers, typed) : null;
|
|
3043
|
+
if (match && match.ambiguous) {
|
|
3044
|
+
c.push({ role: 'error', text: `"${typed}" matches ${match.ambiguous.join(', ')} — retype the exact id.` });
|
|
3045
|
+
return true;
|
|
3046
|
+
}
|
|
3047
|
+
if (providers && !(match && match.provider)) {
|
|
3048
|
+
c.push({
|
|
3049
|
+
role: 'error',
|
|
3050
|
+
text: `no provider "${typed}" in the relay's catalog — /byok lists the ones it takes a key for.`,
|
|
3051
|
+
});
|
|
3052
|
+
return true;
|
|
3053
|
+
}
|
|
3054
|
+
const id = (match && match.provider && match.provider.id) || typed.toLowerCase();
|
|
3055
|
+
let res;
|
|
3056
|
+
try {
|
|
3057
|
+
res = addUserModel(id, model);
|
|
3058
|
+
} catch (err) {
|
|
3059
|
+
c.push({ role: 'error', text: (err && err.message) || String(err) });
|
|
3060
|
+
return true;
|
|
3061
|
+
}
|
|
3062
|
+
// The picker's cache (app.js `byokCache`, 5 minutes) is older than the
|
|
3063
|
+
// file the instant it is written, so refresh it here: a user who adds a
|
|
3064
|
+
// model and types `/models` must see it, not "already listed" five
|
|
3065
|
+
// minutes later.
|
|
3066
|
+
if (typeof c.refreshByokModels === 'function') {
|
|
3067
|
+
try {
|
|
3068
|
+
await c.refreshByokModels();
|
|
3069
|
+
} catch {
|
|
3070
|
+
/* the next refresh reads the file anyway */
|
|
3071
|
+
}
|
|
3072
|
+
}
|
|
3073
|
+
const rows = (typeof c.listModelsFor === 'function' ? (await c.listModelsFor('byok')) : []) || [];
|
|
3074
|
+
const row = rows.find((m) => m && m.id === `${id}:${model}`);
|
|
3075
|
+
c.push({
|
|
3076
|
+
role: res.added ? 'done' : 'note',
|
|
3077
|
+
text: res.added
|
|
3078
|
+
? `added ${id}:${model} — offered on this machine now, in the CLI and the desktop.`
|
|
3079
|
+
: `${id}:${model} was already declared.`,
|
|
3080
|
+
});
|
|
3081
|
+
if (!providers) {
|
|
3082
|
+
c.push({
|
|
3083
|
+
role: 'note',
|
|
3084
|
+
text: `the relay's catalog could not be read, so "${id}" is unverified — if it does not appear in /models, /byok lists the provider ids it takes.`,
|
|
3085
|
+
});
|
|
3086
|
+
}
|
|
3087
|
+
if (res.added && !row) {
|
|
3088
|
+
c.push({
|
|
3089
|
+
role: 'note',
|
|
3090
|
+
text: `saved, but no row will be offered for "${id}" yet — the relay lists no provider of that id (or that provider lists no models).`,
|
|
3091
|
+
});
|
|
3092
|
+
}
|
|
3093
|
+
c.push({ role: 'note', text: `stored in ${res.file} — the desktop reads the same file.` });
|
|
3094
|
+
return true;
|
|
3095
|
+
},
|
|
3096
|
+
},
|
|
3097
|
+
{
|
|
3098
|
+
name: 'model-rm', aliases: ['rm-model'], args: ['provider'], hint: '<provider> <model-id>',
|
|
3099
|
+
category: 'model',
|
|
3100
|
+
desc: 'Forget a model id you added with /model-add',
|
|
3101
|
+
handler: async (c, a) => {
|
|
3102
|
+
const args = a || {};
|
|
3103
|
+
const typed = String(args.provider || '').trim();
|
|
3104
|
+
const rest = String(args._rest || '').trim();
|
|
3105
|
+
const sp = rest.indexOf(' ');
|
|
3106
|
+
const model = sp === -1 ? '' : rest.slice(sp + 1).trim();
|
|
3107
|
+
if (!typed || !model) {
|
|
3108
|
+
c.push({ role: 'error', text: 'Usage: /model-rm <provider> <model-id> — /model-add lists what you added.' });
|
|
3109
|
+
return true;
|
|
3110
|
+
}
|
|
3111
|
+
let res;
|
|
3112
|
+
try {
|
|
3113
|
+
res = removeUserModel(typed, model);
|
|
3114
|
+
} catch (err) {
|
|
3115
|
+
c.push({ role: 'error', text: (err && err.message) || String(err) });
|
|
3116
|
+
return true;
|
|
3117
|
+
}
|
|
3118
|
+
if (typeof c.refreshByokModels === 'function') {
|
|
3119
|
+
try {
|
|
3120
|
+
await c.refreshByokModels();
|
|
3121
|
+
} catch {
|
|
3122
|
+
/* the next refresh reads the file anyway */
|
|
3123
|
+
}
|
|
3124
|
+
}
|
|
3125
|
+
c.push({
|
|
3126
|
+
role: res.removed ? 'done' : 'note',
|
|
3127
|
+
text: res.removed
|
|
3128
|
+
? `removed ${res.provider}:${res.model} — the picker stops offering it on the next refresh.`
|
|
3129
|
+
: `${res.provider}:${res.model} was not declared on this machine.`,
|
|
3130
|
+
});
|
|
3131
|
+
return true;
|
|
3132
|
+
},
|
|
3133
|
+
},
|
|
2963
3134
|
{
|
|
2964
3135
|
name: 'tool', args: ['name', 'json'], hint: '<name> [json]', category: 'aegis',
|
|
2965
3136
|
desc: 'Call any registry tool directly (escape hatch for new tools)',
|
package/src/engine.js
CHANGED
|
@@ -71,8 +71,9 @@ const CLASS_LABELS = Object.freeze({
|
|
|
71
71
|
* (and by app.js, so one store serves both the engine and the commands);
|
|
72
72
|
* otherwise created against the CLI's data dir.
|
|
73
73
|
* @returns {{chat: Function, cancel: Function, respondApproval: Function,
|
|
74
|
-
*
|
|
75
|
-
* classLabel: Function, getClass: Function, setClass: Function,
|
|
74
|
+
* respondRoundsAsk: Function, clearSessionApprovals: Function, listClasses: Function,
|
|
75
|
+
* listModels: Function, classLabel: Function, getClass: Function, setClass: Function,
|
|
76
|
+
* settings: object}}
|
|
76
77
|
*/
|
|
77
78
|
function createEngine({ client, getConfirmMode, getClass, settings: injectedSettings } = {}) {
|
|
78
79
|
const settings = injectedSettings || createSettingsStore({ dir: credentials.aegisHome() });
|
|
@@ -114,6 +115,7 @@ function createEngine({ client, getConfirmMode, getClass, settings: injectedSett
|
|
|
114
115
|
chat,
|
|
115
116
|
cancel: local.cancel,
|
|
116
117
|
respondApproval: local.respondApproval,
|
|
118
|
+
respondRoundsAsk: local.respondRoundsAsk,
|
|
117
119
|
clearSessionApprovals: local.clearSessionApprovals,
|
|
118
120
|
// The engine's own class table, narrowed to the ones this host runs — so a
|
|
119
121
|
// UI built from listClasses() can never offer a class that would throw.
|