aegiscode 6.8.19 → 6.8.20
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/package.json +4 -2
- package/scripts/check.mjs +50 -0
- package/scripts/predist.mjs +11 -0
- package/src/commands.js +41 -35
- package/src/devrun.js +80 -6
- package/src/panels.js +2 -1
- package/src/summarize.js +3 -1
- package/vendor/client/aegis.js +13 -0
- package/vendor/client/authorship-key.js +45 -4
- package/vendor/client/byok-catalog.js +49 -1
- package/vendor/client/hooks.js +427 -0
- package/vendor/client/platform.js +410 -0
- package/vendor/desktop/lib/local/engine.js +85 -3
- package/vendor/desktop/lib/local/shell.js +393 -39
- package/vendor/desktop/lib/local/tools.js +156 -13
- package/vendor/desktop/lib/settings.js +36 -1
- package/vendor/desktop/renderer/usage.js +30 -0
- package/vendor/tools/agent-gate.mjs +81 -13
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "aegiscode",
|
|
3
3
|
"productName": "AEGIS Code",
|
|
4
|
-
"version": "6.8.
|
|
4
|
+
"version": "6.8.20",
|
|
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",
|
|
@@ -26,7 +26,9 @@
|
|
|
26
26
|
"start": "node bin/aegiscode.js",
|
|
27
27
|
"predist": "node scripts/predist.mjs",
|
|
28
28
|
"prepublishOnly": "npm run predist",
|
|
29
|
-
"
|
|
29
|
+
"precheck": "node scripts/predist.mjs",
|
|
30
|
+
"check": "node scripts/check.mjs",
|
|
31
|
+
"pretest": "node scripts/predist.mjs",
|
|
30
32
|
"test": "node scripts/runtests.mjs"
|
|
31
33
|
},
|
|
32
34
|
"keywords": [
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Syntax-check every file `node --check` should gate on, and report all of
|
|
4
|
+
* them. Replaces the POSIX loop
|
|
5
|
+
*
|
|
6
|
+
* for f in src/*.js; do node --check "$f" || exit 1; done
|
|
7
|
+
*
|
|
8
|
+
* which npm runs through ComSpec on Windows, where `for…do…done` is not shell
|
|
9
|
+
* syntax. A Node walker keeps `npm run check` identical on every OS, and — like
|
|
10
|
+
* `runtests.mjs` — collects failures instead of stopping at the first one, so
|
|
11
|
+
* one broken file cannot hide every file after it.
|
|
12
|
+
*/
|
|
13
|
+
import { readdirSync } from 'node:fs';
|
|
14
|
+
import { spawnSync } from 'node:child_process';
|
|
15
|
+
import { dirname, join, resolve } from 'node:path';
|
|
16
|
+
import { fileURLToPath } from 'node:url';
|
|
17
|
+
|
|
18
|
+
const here = dirname(fileURLToPath(import.meta.url));
|
|
19
|
+
const cliRoot = resolve(here, '..');
|
|
20
|
+
const srcDir = join(cliRoot, 'src');
|
|
21
|
+
|
|
22
|
+
const targets = [
|
|
23
|
+
join(cliRoot, 'bin', 'aegiscode.js'),
|
|
24
|
+
...readdirSync(srcDir)
|
|
25
|
+
.filter((f) => f.endsWith('.js'))
|
|
26
|
+
.sort()
|
|
27
|
+
.map((f) => join(srcDir, f)),
|
|
28
|
+
join(here, 'predist.mjs'),
|
|
29
|
+
];
|
|
30
|
+
|
|
31
|
+
if (targets.length === 0) {
|
|
32
|
+
process.stderr.write('check: no files to check\n');
|
|
33
|
+
process.exit(1);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const failed = [];
|
|
37
|
+
for (const file of targets) {
|
|
38
|
+
const res = spawnSync(process.execPath, ['--check', file], { stdio: 'inherit' });
|
|
39
|
+
if (res.status !== 0) failed.push({ file, status: res.status });
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if (failed.length) {
|
|
43
|
+
process.stderr.write(`\ncheck failed (${failed.length}):\n`);
|
|
44
|
+
for (const { file, status } of failed) {
|
|
45
|
+
process.stderr.write(` \u2717 ${file} (exit ${status})\n`);
|
|
46
|
+
}
|
|
47
|
+
process.exit(1);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
process.stdout.write(`check ok: ${targets.length} files\n`);
|
package/scripts/predist.mjs
CHANGED
|
@@ -92,6 +92,17 @@ const FILES = [
|
|
|
92
92
|
// src/commands.js, so a package built without it throws MODULE_NOT_FOUND on
|
|
93
93
|
// the first picker or /byok listing instead of showing a short one.
|
|
94
94
|
'client/byok-catalog.js',
|
|
95
|
+
// The shared HOOK layer: the hook config reader behind /hooks and the
|
|
96
|
+
// installer for this repo guard hooks, with one implementation for the
|
|
97
|
+
// CLI, the desktop app and tools/agent-gate.mjs. src/commands.js resolves
|
|
98
|
+
// it through resolveShared, so a package staged without it loses the
|
|
99
|
+
// /hooks command at load time with MODULE_NOT_FOUND.
|
|
100
|
+
'client/hooks.js',
|
|
101
|
+
// The shared platform module (Phase 30.1): the one place that decides which
|
|
102
|
+
// OS this is. desktop/lib/local/tools.js requires it for its exec shell spec,
|
|
103
|
+
// and desktop/lib/local/tools.js is staged below, so leaving this out stages
|
|
104
|
+
// a vendor tree whose exec tool throws MODULE_NOT_FOUND on first use.
|
|
105
|
+
'client/platform.js',
|
|
95
106
|
'mcp/tools.js',
|
|
96
107
|
// The stdio MCP server itself — the process every editor config written by
|
|
97
108
|
// `aegiscode mcp install` points at. Staging the registry without it ships a
|
package/src/commands.js
CHANGED
|
@@ -670,42 +670,25 @@ async function runCloudSync(c, o = {}) {
|
|
|
670
670
|
return res;
|
|
671
671
|
}
|
|
672
672
|
|
|
673
|
-
/**
|
|
673
|
+
/**
|
|
674
|
+
* Hook config and repo-hook install come from the SHARED module
|
|
675
|
+
* (`client/hooks.js`, staged to vendor/client/hooks.js in a package), because
|
|
676
|
+
* the desktop app reads the same files and installs the same `.githooks/`.
|
|
677
|
+
*
|
|
678
|
+
* This file used to carry a private `readHooks()`/`hookStats()`. Two copies of
|
|
679
|
+
* "which settings files count" is how the terminal and the GUI end up
|
|
680
|
+
* describing one machine differently, and the private copy was joined with the
|
|
681
|
+
* HOST's separator — so a Windows path was handled correctly and could not be
|
|
682
|
+
* tested anywhere but Windows.
|
|
683
|
+
*/
|
|
684
|
+
const hooksLib = require(resolveShared(path.join('client', 'hooks.js')));
|
|
685
|
+
|
|
674
686
|
function readHooks() {
|
|
675
|
-
|
|
676
|
-
path.join(os.homedir(), '.aegis', 'settings.json'),
|
|
677
|
-
path.join(process.cwd(), '.aegis', 'settings.json'),
|
|
678
|
-
path.join(os.homedir(), '.aegiscode', 'settings.json'),
|
|
679
|
-
path.join(process.cwd(), '.aegiscode', 'settings.json'),
|
|
680
|
-
path.join(os.homedir(), '.claude', 'settings.json'),
|
|
681
|
-
];
|
|
682
|
-
const hooks = {};
|
|
683
|
-
const from = [];
|
|
684
|
-
for (const p of sources) {
|
|
685
|
-
try {
|
|
686
|
-
const j = JSON.parse(fs.readFileSync(p, 'utf8'));
|
|
687
|
-
if (j && j.hooks && typeof j.hooks === 'object') {
|
|
688
|
-
from.push(p.replace(os.homedir(), '~'));
|
|
689
|
-
for (const [ev, arr] of Object.entries(j.hooks)) {
|
|
690
|
-
hooks[ev] = [...(hooks[ev] || []), ...(Array.isArray(arr) ? arr : [])];
|
|
691
|
-
}
|
|
692
|
-
}
|
|
693
|
-
} catch {}
|
|
694
|
-
}
|
|
695
|
-
return { hooks, from };
|
|
687
|
+
return hooksLib.readHookConfig();
|
|
696
688
|
}
|
|
697
689
|
|
|
698
|
-
/** {enabled,hooks,events,byEvent} from a merged hooks map. */
|
|
699
690
|
function hookStats(hooks) {
|
|
700
|
-
|
|
701
|
-
let count = 0;
|
|
702
|
-
const byEvent = {};
|
|
703
|
-
for (const [ev, arr] of Object.entries(hooks)) {
|
|
704
|
-
const n = Array.isArray(arr) ? arr.length : 0;
|
|
705
|
-
byEvent[ev] = n;
|
|
706
|
-
count += n;
|
|
707
|
-
}
|
|
708
|
-
return { enabled: count > 0, hooks: count, events, byEvent };
|
|
691
|
+
return hooksLib.hookStats(hooks);
|
|
709
692
|
}
|
|
710
693
|
|
|
711
694
|
/** Scan the standard skill dirs for SKILL.md files. */
|
|
@@ -1557,10 +1540,33 @@ const COMMANDS = [
|
|
|
1557
1540
|
},
|
|
1558
1541
|
},
|
|
1559
1542
|
{
|
|
1560
|
-
name: 'hooks', args: ['sub'], hint: '[status|list]', category: 'model',
|
|
1561
|
-
desc: 'View hooks configuration status
|
|
1543
|
+
name: 'hooks', args: ['sub'], hint: '[status|list|install]', category: 'model',
|
|
1544
|
+
desc: 'View hooks configuration status, list configured hooks, or install this repo\'s guard hooks',
|
|
1562
1545
|
handler: async (c, args) => {
|
|
1563
1546
|
const sub = (args.sub || '').toLowerCase();
|
|
1547
|
+
if (sub === 'install') {
|
|
1548
|
+
// The one mutating branch, and the one that makes the guards real: a
|
|
1549
|
+
// fresh clone has .githooks/ present and core.hooksPath unset, so a
|
|
1550
|
+
// commit runs NO guard at all (`.githooks/lib-gate.sh` says so itself).
|
|
1551
|
+
const dryRun = /--dry-run|\bdry-?run\b/.test(String(args._rest || ''));
|
|
1552
|
+
const res = hooksLib.installRepoHooks({ cwd: process.cwd(), dryRun });
|
|
1553
|
+
if (!res.ok) {
|
|
1554
|
+
note(c, res.error);
|
|
1555
|
+
if (res.actions.length) for (const a of res.actions) note(c, ` ${a}`);
|
|
1556
|
+
} else if (dryRun) {
|
|
1557
|
+
note(c, `would install the guard hooks in ${res.status.repo}`);
|
|
1558
|
+
for (const a of res.actions) note(c, ` ${a}`);
|
|
1559
|
+
if (res.status.installed) note(c, 'core.hooksPath is already .githooks — nothing to change');
|
|
1560
|
+
} else if (!res.changed) {
|
|
1561
|
+
done(c, `guard hooks already installed (core.hooksPath = .githooks)`);
|
|
1562
|
+
} else {
|
|
1563
|
+
done(c, `installed the guard hooks — core.hooksPath = .githooks (verified)`);
|
|
1564
|
+
for (const a of res.actions) note(c, ` ${a}`);
|
|
1565
|
+
}
|
|
1566
|
+
if (res.ok) note(c, res.status.execNote);
|
|
1567
|
+
c.render();
|
|
1568
|
+
return true;
|
|
1569
|
+
}
|
|
1564
1570
|
const { hooks, from } = readHooks();
|
|
1565
1571
|
if (sub === 'list') {
|
|
1566
1572
|
panel(c, panels.buildHooksList({ hooks }, c.ctx));
|
|
@@ -1573,7 +1579,7 @@ const COMMANDS = [
|
|
|
1573
1579
|
return true;
|
|
1574
1580
|
}
|
|
1575
1581
|
note(c, `unknown subcommand: ${args.sub}`);
|
|
1576
|
-
note(c, 'available: status, list');
|
|
1582
|
+
note(c, 'available: status, list, install [--dry-run]');
|
|
1577
1583
|
c.render();
|
|
1578
1584
|
return true;
|
|
1579
1585
|
},
|
package/src/devrun.js
CHANGED
|
@@ -12,6 +12,13 @@ const { spawn } = require('node:child_process');
|
|
|
12
12
|
const fs = require('node:fs');
|
|
13
13
|
const path = require('node:path');
|
|
14
14
|
|
|
15
|
+
// The one shared module that knows which OS this is (plan Phase 30.1), staged
|
|
16
|
+
// into `cli/vendor/client/` for the published layout — same resolver every
|
|
17
|
+
// other shared client module goes through, so this file never re-derives
|
|
18
|
+
// `process.platform` on its own (that duplication is F4's complaint).
|
|
19
|
+
const { resolveClientModule } = require('./shared.js');
|
|
20
|
+
const sharedPlatform = require(resolveClientModule('platform.js'));
|
|
21
|
+
|
|
15
22
|
const MAX_STREAM_LINES = 40;
|
|
16
23
|
|
|
17
24
|
/** Detect the most likely dev command for a project, or null. */
|
|
@@ -36,11 +43,27 @@ function detectDevCommand(cwd = process.cwd()) {
|
|
|
36
43
|
/**
|
|
37
44
|
* Run a shell command, streaming stdout/stderr lines to onLine. Returns a job:
|
|
38
45
|
* { stop(), done: Promise<{ code, stopped }> }
|
|
39
|
-
* The child
|
|
46
|
+
* The child — and, via platform.killTree(), its descendants — is killed when
|
|
47
|
+
* stop() is called or `signal` aborts.
|
|
48
|
+
*
|
|
49
|
+
* Options:
|
|
50
|
+
* onLine (line) => void stream sink
|
|
51
|
+
* signal AbortSignal abort => stop
|
|
52
|
+
* cwd string
|
|
53
|
+
* onError (err, result) => void where a FAILED kill is reported
|
|
54
|
+
* platform implementation or name the test seam: pass an object with
|
|
55
|
+
* `killTree` to stub the kill, or an
|
|
56
|
+
* OS name ('win32' | 'linux' | …) to
|
|
57
|
+
* drive the real module's win32 path
|
|
58
|
+
* from a non-Windows host
|
|
59
|
+
* killOptions seams forwarded to killTree ({ platform, kill, run, signal,
|
|
60
|
+
* detached, timeout })
|
|
40
61
|
*/
|
|
41
|
-
function runDevServer(command, { onLine, signal, cwd } = {}) {
|
|
42
|
-
// detached
|
|
43
|
-
//
|
|
62
|
+
function runDevServer(command, { onLine, signal, cwd, onError, platform: platformImpl, killOptions } = {}) {
|
|
63
|
+
// detached: the child leads its own process group on posix, which is what
|
|
64
|
+
// lets killTree() take the whole tree out with kill(-pid) instead of leaking
|
|
65
|
+
// grandchildren. On win32 there is no group to signal — killTree() uses
|
|
66
|
+
// `taskkill /T` to walk the parent/child tree instead.
|
|
44
67
|
const child = spawn(command, { shell: true, cwd: cwd || process.cwd(), env: process.env, detached: true });
|
|
45
68
|
let buffer = '';
|
|
46
69
|
let stopped = false;
|
|
@@ -67,8 +90,49 @@ function runDevServer(command, { onLine, signal, cwd } = {}) {
|
|
|
67
90
|
child.stderr && child.stderr.on('data', deliver);
|
|
68
91
|
if (buffer.trim() && onLine) onLine(buffer.trim()); // trailing partial line
|
|
69
92
|
|
|
93
|
+
// ---------------------------------------------------------------------
|
|
94
|
+
// Stopping the server (plan Phase 30.2, defect F3).
|
|
95
|
+
//
|
|
96
|
+
// This used to be a bare negative-pid signal to the process group, wrapped in
|
|
97
|
+
// an empty `try {} catch {}`.
|
|
98
|
+
//
|
|
99
|
+
// A negative pid is a POSIX *process-group* kill. On win32 that call throws,
|
|
100
|
+
// and the empty catch ate the throw, so the dev server and every child it
|
|
101
|
+
// had spawned were silently orphaned with no error anywhere: not in the
|
|
102
|
+
// transcript, not on stderr. The swallow was as much the bug as the signal
|
|
103
|
+
// (the same defect class the engine fixed in its Phase 21c, src/proc.js).
|
|
104
|
+
//
|
|
105
|
+
// The stop now goes through platform.killTree() (the shared module, plan
|
|
106
|
+
// 30.1): posix keeps the detached-group kill, win32 runs
|
|
107
|
+
// `taskkill /PID <pid> /T /F`, and the result is `{ ok, error }` rather than
|
|
108
|
+
// a throw — so a failure can be *reported*. It is: onError if the caller
|
|
109
|
+
// gave one, otherwise the transcript the user is already reading, otherwise
|
|
110
|
+
// stderr. Never dropped.
|
|
111
|
+
// ---------------------------------------------------------------------
|
|
112
|
+
const killApi =
|
|
113
|
+
platformImpl && typeof platformImpl === 'object' && typeof platformImpl.killTree === 'function'
|
|
114
|
+
? platformImpl
|
|
115
|
+
: sharedPlatform;
|
|
116
|
+
const killSeams = { ...(killOptions || {}) };
|
|
117
|
+
if (typeof platformImpl === 'string' && !killSeams.platform) killSeams.platform = platformImpl;
|
|
118
|
+
|
|
119
|
+
const reportKillFailure = (err) => {
|
|
120
|
+
if (typeof onError === 'function') {
|
|
121
|
+
onError(err);
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
const text = `[run] could not stop the dev server (pid ${child.pid}): ${err && err.message} — it may still be running`;
|
|
125
|
+
if (typeof onLine === 'function') onLine(text);
|
|
126
|
+
else console.error(text);
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
let killError = null;
|
|
70
130
|
const killGroup = () => {
|
|
71
|
-
|
|
131
|
+
const res = killApi.killTree(child, killSeams);
|
|
132
|
+
if (res && res.ok) return res;
|
|
133
|
+
killError = (res && res.error) || new Error('killTree failed without an error result');
|
|
134
|
+
reportKillFailure(killError);
|
|
135
|
+
return res;
|
|
72
136
|
};
|
|
73
137
|
const onAbort = () => { stopped = true; killGroup(); };
|
|
74
138
|
if (signal) signal.addEventListener('abort', onAbort, { once: true });
|
|
@@ -92,12 +156,22 @@ function runDevServer(command, { onLine, signal, cwd } = {}) {
|
|
|
92
156
|
child.on('exit', () => setTimeout(() => settle({ code: code ?? 0, stopped }), 1000));
|
|
93
157
|
|
|
94
158
|
return {
|
|
159
|
+
// The spawned pid — the one stop() actually kills, and the value a caller
|
|
160
|
+
// (or a test, on a host that is not the OS under test) needs to reason
|
|
161
|
+
// about the kill after the fact.
|
|
162
|
+
pid: child.pid,
|
|
95
163
|
stop: () => {
|
|
96
164
|
stopped = true;
|
|
97
|
-
killGroup();
|
|
165
|
+
const res = killGroup();
|
|
98
166
|
// Pipe-holding survivors can still delay 'close' — force the job to
|
|
99
167
|
// settle so the session loop's streamJob guard can't swallow keys.
|
|
100
168
|
setTimeout(() => settle({ code: code ?? null, stopped: true }), 5000);
|
|
169
|
+
return res;
|
|
170
|
+
},
|
|
171
|
+
// The last kill failure, if any — the caller can report it after the fact
|
|
172
|
+
// instead of only through the onError callback.
|
|
173
|
+
get killError() {
|
|
174
|
+
return killError;
|
|
101
175
|
},
|
|
102
176
|
done,
|
|
103
177
|
};
|
package/src/panels.js
CHANGED
|
@@ -586,7 +586,8 @@ function buildHooksStatus(stats, ctx = {}) {
|
|
|
586
586
|
lines.push([span(t.dim, fromPaths.length
|
|
587
587
|
? `Settings: ${fromPaths.join(', ')}`
|
|
588
588
|
: 'Settings: no settings.json with hooks found (checked ~/.aegis, .aegis, ~/.aegiscode, .aegiscode, ~/.claude)')]);
|
|
589
|
-
lines.push([span(t.gray, '
|
|
589
|
+
lines.push([span(t.gray, 'Config hooks are read, not managed — edit the files above.')]);
|
|
590
|
+
lines.push([span(t.gray, 'The repo guard hooks (.githooks/) are installed by /hooks install.')]);
|
|
590
591
|
return lines;
|
|
591
592
|
}
|
|
592
593
|
|
package/src/summarize.js
CHANGED
|
@@ -4,7 +4,9 @@
|
|
|
4
4
|
* Transcript summarization for /compact and /recap.
|
|
5
5
|
*
|
|
6
6
|
* Dependency-free port of the upstream engine reference. The reference
|
|
7
|
-
* spawns `claude -p "Summarize…"` (via
|
|
7
|
+
* spawns `claude -p "Summarize…"` (via `resolveExecutable()` in
|
|
8
|
+
* client/platform.js — the shared module this repo actually ships, staged into
|
|
9
|
+
* cli/vendor/client/platform.js); here the
|
|
8
10
|
* backend is *injected* instead, so this module pulls in nothing but tokens.js:
|
|
9
11
|
*
|
|
10
12
|
* async summarizeTranscript(transcript, { callModel, model, signal } = {})
|
package/vendor/client/aegis.js
CHANGED
|
@@ -737,6 +737,8 @@ function createClient(opts = {}) {
|
|
|
737
737
|
prompt,
|
|
738
738
|
system,
|
|
739
739
|
maxTokens,
|
|
740
|
+
effort,
|
|
741
|
+
reasoningEffort,
|
|
740
742
|
stream = false,
|
|
741
743
|
onStream,
|
|
742
744
|
signal,
|
|
@@ -759,6 +761,17 @@ function createClient(opts = {}) {
|
|
|
759
761
|
provider,
|
|
760
762
|
messages: buildMessages(messages, system, prompt),
|
|
761
763
|
...(maxTokens ? { max_tokens: maxTokens } : {}),
|
|
764
|
+
// Native effort knobs, forwarded verbatim and ONLY when a caller states
|
|
765
|
+
// one — never invented here, because a made-up level overrides the
|
|
766
|
+
// vendor's own default. The field name is not portable: DeepSeek's
|
|
767
|
+
// Anthropic-compatible surface takes `effort` (low|high|max), while the
|
|
768
|
+
// OpenAI-shaped vendors take `reasoning_effort` (low|medium|high). The
|
|
769
|
+
// caller translates the rung per dialect and names the field, so neither
|
|
770
|
+
// field is ever sent blind to a strict validator — Groq answers 400 for
|
|
771
|
+
// any level outside a model's supported set, so a misfiled knob is a
|
|
772
|
+
// failed turn, not a harmless extra key.
|
|
773
|
+
...(effort ? { effort } : {}),
|
|
774
|
+
...(reasoningEffort ? { reasoning_effort: reasoningEffort } : {}),
|
|
762
775
|
};
|
|
763
776
|
if (model) body.model = model;
|
|
764
777
|
const headers = {
|
|
@@ -227,6 +227,48 @@ function resolveKey(o = {}) {
|
|
|
227
227
|
* @returns {{out: string, created: boolean, replaced: boolean,
|
|
228
228
|
* keyFingerprint: string, bytes: number, secretPrinted: false, mode: string}}
|
|
229
229
|
*/
|
|
230
|
+
/**
|
|
231
|
+
* Write a secret to `file`, creating its parent directory, and translate the
|
|
232
|
+
* filesystem errnos a user actually hits into a sentence that names the fix.
|
|
233
|
+
*
|
|
234
|
+
* `keygen` is the first command a new install runs, and its failure mode on a
|
|
235
|
+
* locked-down or full disk used to be the bare kernel message — `EACCES:
|
|
236
|
+
* permission denied, open '/home/u/.aegiscode/keys/authorship.key'`. That says
|
|
237
|
+
* what broke and not what to do, and the remedy is not guessable from it: the
|
|
238
|
+
* unwritable thing is the *directory*, which the path in the message never
|
|
239
|
+
* names. Found by the `unwritable-home` usertest profile, which reported it
|
|
240
|
+
* three times across as many commits before it was treated as a defect.
|
|
241
|
+
*
|
|
242
|
+
* Only the three errnos with an unambiguous remedy are rewritten. Everything
|
|
243
|
+
* else propagates untouched — inventing advice for an errno we do not recognise
|
|
244
|
+
* would be worse than the errno.
|
|
245
|
+
*/
|
|
246
|
+
function writeSecret(file, secret) {
|
|
247
|
+
try {
|
|
248
|
+
fs.mkdirSync(path.dirname(file), { recursive: true, mode: DIR_MODE });
|
|
249
|
+
fs.writeFileSync(file, secret + '\n', { mode: KEY_FILE_MODE });
|
|
250
|
+
} catch (e) {
|
|
251
|
+
const errno = e && e.code;
|
|
252
|
+
const dir = path.dirname(file);
|
|
253
|
+
if (errno === 'EACCES' || errno === 'EPERM') {
|
|
254
|
+
throw new Error(
|
|
255
|
+
`authorship-key: cannot write ${file} — ${dir} is not writable by this user (${errno}). ` +
|
|
256
|
+
`Fix it with: chmod u+rwx ${dir}`,
|
|
257
|
+
);
|
|
258
|
+
}
|
|
259
|
+
if (errno === 'EROFS') {
|
|
260
|
+
throw new Error(
|
|
261
|
+
`authorship-key: cannot write ${file} — ${dir} is on a read-only filesystem (EROFS). ` +
|
|
262
|
+
'Point --out (or $AEGIS_HOME) at a writable location.',
|
|
263
|
+
);
|
|
264
|
+
}
|
|
265
|
+
if (errno === 'ENOSPC') {
|
|
266
|
+
throw new Error(`authorship-key: cannot write ${file} — the disk is full (ENOSPC).`);
|
|
267
|
+
}
|
|
268
|
+
throw e;
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
|
|
230
272
|
function keygen(o = {}) {
|
|
231
273
|
const argv = o.argv || [];
|
|
232
274
|
const env = o.env || process.env;
|
|
@@ -244,8 +286,7 @@ function keygen(o = {}) {
|
|
|
244
286
|
}
|
|
245
287
|
|
|
246
288
|
const secret = crypto.randomBytes(KEY_BYTES).toString('base64url');
|
|
247
|
-
|
|
248
|
-
fs.writeFileSync(out, secret + '\n', { mode: KEY_FILE_MODE });
|
|
289
|
+
writeSecret(out, secret);
|
|
249
290
|
// writeFileSync's mode is ANDed with the complement of the umask, so a 0022
|
|
250
291
|
// umask turns 0600 into 0644 and the call still "succeeds". Set it outright.
|
|
251
292
|
fs.chmodSync(out, KEY_FILE_MODE);
|
|
@@ -311,7 +352,7 @@ function backup(o = {}) {
|
|
|
311
352
|
assertPrivate(from);
|
|
312
353
|
|
|
313
354
|
const destDir = path.resolve(to);
|
|
314
|
-
|
|
355
|
+
|
|
315
356
|
const name = flag(argv, '--name') || path.basename(from);
|
|
316
357
|
const dest = path.join(destDir, name);
|
|
317
358
|
|
|
@@ -327,7 +368,7 @@ function backup(o = {}) {
|
|
|
327
368
|
}
|
|
328
369
|
|
|
329
370
|
const secret = readSecretFile(from);
|
|
330
|
-
|
|
371
|
+
writeSecret(dest, secret);
|
|
331
372
|
fs.chmodSync(dest, KEY_FILE_MODE);
|
|
332
373
|
if (!isWin && modeOf(dest) !== KEY_FILE_MODE) {
|
|
333
374
|
throw new Error(`authorship-key: ${dest} landed mode ${modeString(modeOf(dest))}, expected 600`);
|
|
@@ -79,7 +79,55 @@ const BYOK_MODEL_ADDITIONS = Object.freeze({
|
|
|
79
79
|
// current API uses and the one this repo's rate table, token-budget and
|
|
80
80
|
// reasoning-model regexes all already key off; `deepseek-v4.1-flash` is the
|
|
81
81
|
// retired alias for the same route and is NOT listed separately.
|
|
82
|
-
deepseek: Object.freeze([
|
|
82
|
+
deepseek: Object.freeze([
|
|
83
|
+
'deepseek-flash',
|
|
84
|
+
// DeepSeek-V4-Pro — a DISTINCT, pricier Pro route (not an alias of Flash),
|
|
85
|
+
// which DeepSeek's current API serves as `deepseek-v4-pro` alongside
|
|
86
|
+
// `deepseek-flash`. The server's BYOK catalog still advertises only the
|
|
87
|
+
// legacy `deepseek-v4-flash` alias, so without this row a DeepSeek key can
|
|
88
|
+
// never pin the Pro model from the picker even though the rate table
|
|
89
|
+
// (desktop/renderer/usage.js `deepseek-v4-pro`) and the reasoning regex
|
|
90
|
+
// already know it. Added here rather than behind the server because the
|
|
91
|
+
// relay forwards whatever model the caller names.
|
|
92
|
+
'deepseek-v4-pro',
|
|
93
|
+
]),
|
|
94
|
+
// Anthropic's `anthropic` descriptor (aegis1 services/nexus_provider/
|
|
95
|
+
// catalog.py) pins exactly one default_model, `claude-sonnet-5`, and
|
|
96
|
+
// `anthropic-haiku` pins `claude-haiku-4-5` as its own provider row — so
|
|
97
|
+
// between them an Anthropic BYOK key could pin Sonnet or Haiku but never
|
|
98
|
+
// Opus or Fable, the other two members of the current Claude 5 lineup the
|
|
99
|
+
// vendor already serves. Both ids already have a priced rate row
|
|
100
|
+
// (desktop/renderer/usage.js `opus`/`fable`, matched by family substring),
|
|
101
|
+
// so the picker just had no way to offer them, not an unpriced gap. Listed
|
|
102
|
+
// under the `anthropic` provider id because that is the row the server
|
|
103
|
+
// advertises a configured Anthropic key against — the relay forwards
|
|
104
|
+
// whichever of the two names the caller actually pins.
|
|
105
|
+
anthropic: Object.freeze(['claude-opus-5', 'claude-fable-5']),
|
|
106
|
+
// xAI's `grok` descriptor still pins `grok-4.5` as default_model — current
|
|
107
|
+
// when that descriptor was written, but xAI has since shipped grok-4.6 and
|
|
108
|
+
// grok-4.7 (flagship, Sept 2026) on the same `grok-4.5`-shaped id
|
|
109
|
+
// (api.x.ai/v1, model=`grok-4.7`). A Grok BYOK key could not reach either
|
|
110
|
+
// newer model from the picker even though the relay forwards whatever name
|
|
111
|
+
// it is given. Only the current flagship is listed — 4.6 sits strictly
|
|
112
|
+
// between the already-offered 4.5 and 4.7 at the same per-token rate as 4.7,
|
|
113
|
+
// so a second row would not unlock any capability or price point 4.7 doesn't.
|
|
114
|
+
grok: Object.freeze(['grok-4.7']),
|
|
115
|
+
// Google's `gemini` descriptor pins `gemini-3.5-flash`. Google has since
|
|
116
|
+
// shipped gemini-3.6-flash, gemini-3.7-flash and gemini-3.8-flash (GA,
|
|
117
|
+
// 2026-09-02) on the same family; no Gemini 3.x Pro tier has shipped (the
|
|
118
|
+
// announced 3.5 Pro was delayed indefinitely), so Flash is the whole
|
|
119
|
+
// lineup. Only the current GA flagship is listed, for the same "one
|
|
120
|
+
// spelling per route" reason as the others above.
|
|
121
|
+
gemini: Object.freeze(['gemini-3.8-flash']),
|
|
122
|
+
// OpenAI's `openai` and `openai-gpt4o-mini` descriptors both pin
|
|
123
|
+
// `gpt-5-mini` — a cheap/fast tier, not the general-purpose flagship. An
|
|
124
|
+
// OpenAI BYOK key could pin the mini tier but never the current flagship
|
|
125
|
+
// chat model, `gpt-5.5` (api.openai.com/v1, released 2026-04-23). The two
|
|
126
|
+
// provider ids share one credential and one model, so the server's BYOK
|
|
127
|
+
// catalog already lists `gpt-5-mini` twice for one OpenAI key; listed under
|
|
128
|
+
// `openai` only, not also under `openai-gpt4o-mini`, so this addition does
|
|
129
|
+
// not compound that into two flagship rows for the same key.
|
|
130
|
+
openai: Object.freeze(['gpt-5.5']),
|
|
83
131
|
});
|
|
84
132
|
|
|
85
133
|
/** The extras to offer for one provider id (an empty array when there are none). */
|