aegiscode 6.8.16 → 6.8.17
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 +1 -1
- package/vendor/hosts/openai-shim.js +70 -2
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.17",
|
|
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",
|
|
@@ -30,8 +30,30 @@
|
|
|
30
30
|
* `--allow-remote` is passed explicitly (the endpoint spends the account's
|
|
31
31
|
* tokens, so exposing it is a decision, not a default);
|
|
32
32
|
* - never logs or echoes the AEGIS key;
|
|
33
|
-
* - the key is resolved by the ordinary path (env → 0600 store →
|
|
34
|
-
* the shim holds no credential of its own.
|
|
33
|
+
* - the key is resolved by the ordinary path (env → 0600 store → legacy
|
|
34
|
+
* config.json), so the shim holds no credential of its own.
|
|
35
|
+
*
|
|
36
|
+
* THE SHARED ENV FILE — and why `run()` below reads it before anything else.
|
|
37
|
+
*
|
|
38
|
+
* `credentials.resolveApiKey()` reads the *environment*, then its own stores;
|
|
39
|
+
* it has never opened `~/.aegiscode/.env` (that is `client/env-file.js`'s job,
|
|
40
|
+
* deliberately: one reader, one contract). Every other host in this repo calls
|
|
41
|
+
* that reader at start-up — `cli/bin/aegiscode.js` before caps and a session,
|
|
42
|
+
* `desktop/main.js` before `createClient`, `mcp/server.js` at load. This file
|
|
43
|
+
* did not, so it was the one host where the documented setup
|
|
44
|
+
*
|
|
45
|
+
* AEGIS_API_KEY=aegis_… # in ~/.aegiscode/.env
|
|
46
|
+
*
|
|
47
|
+
* silently did nothing: the shim started, the editor got a 401 on the first
|
|
48
|
+
* message, and the key instruction printed in this file's own `--help` named a
|
|
49
|
+
* file the shim never read. In a shell that had also exported the variable the
|
|
50
|
+
* bug was invisible, which is exactly how it survived — a GUI-launched editor
|
|
51
|
+
* has no such export, and that is the normal way this shim is used.
|
|
52
|
+
*
|
|
53
|
+
* So `run()` loads the file, then *checks* the key and refuses to serve without
|
|
54
|
+
* one, naming where a key can come from. A shim that starts keyless is worse
|
|
55
|
+
* than one that exits: the failure surfaces later, in another program's error
|
|
56
|
+
* dialog, as an unexplained 401.
|
|
35
57
|
*/
|
|
36
58
|
|
|
37
59
|
const fs = require('node:fs');
|
|
@@ -391,6 +413,52 @@ async function main(argv) {
|
|
|
391
413
|
].join('\n'));
|
|
392
414
|
return 0;
|
|
393
415
|
}
|
|
416
|
+
|
|
417
|
+
// ── the shared env file, before any credential is resolved ───────────────
|
|
418
|
+
//
|
|
419
|
+
// Placed after the `--help` early-return so help stays instant, and before
|
|
420
|
+
// `createShimServer` — which is where `createClient(credentials.clientOptions())`
|
|
421
|
+
// runs and therefore the last point at which process.env can still decide the
|
|
422
|
+
// key. An exported `AEGIS_API_KEY` always wins: loadEnvFile() fills only names
|
|
423
|
+
// the environment does not already have. Failure is never fatal here — an
|
|
424
|
+
// absent file is the pre-existing state — because the check right below turns
|
|
425
|
+
// "no key at all" into one sentence instead of a 401 from another program.
|
|
426
|
+
// Same call, same contract as cli/bin/aegiscode.js, desktop/main.js and
|
|
427
|
+
// mcp/server.js; see this file's header for what its absence cost.
|
|
428
|
+
const out = opts.log || process.stderr;
|
|
429
|
+
try {
|
|
430
|
+
const envFile = require('../client/env-file.js');
|
|
431
|
+
const envResult = envFile.loadEnvFile();
|
|
432
|
+
if (envResult.loose) {
|
|
433
|
+
logLine(
|
|
434
|
+
out,
|
|
435
|
+
`${envResult.file} is readable by other accounts (mode ${envResult.mode.toString(8)}) — ` +
|
|
436
|
+
'consider `chmod 600` on it'
|
|
437
|
+
);
|
|
438
|
+
}
|
|
439
|
+
} catch (e) {
|
|
440
|
+
logLine(out, `could not read the shared env file: ${e && e.message}`);
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
// Refuse to serve with no account key. The shim cannot answer a single
|
|
444
|
+
// request without one, and a keyless endpoint reports that failure to the
|
|
445
|
+
// *editor*, hours later, as an opaque 401 — the exact confusion this check
|
|
446
|
+
// removes. `--no-auth` is about the caller's bearer token, not this
|
|
447
|
+
// credential, so it does not relax this.
|
|
448
|
+
const resolved = credentials.resolveApiKey();
|
|
449
|
+
if (!resolved.key) {
|
|
450
|
+
logLine(
|
|
451
|
+
out,
|
|
452
|
+
`no AEGIS account key — ${credentials.HOW_TO_SET}, ` +
|
|
453
|
+
`or set ${credentials.KEY_ENV} in ~/.aegiscode/.env`
|
|
454
|
+
);
|
|
455
|
+
return 1;
|
|
456
|
+
}
|
|
457
|
+
// Where the key came from, never the key itself: "did it pick up my .env or
|
|
458
|
+
// the file an older sign-in wrote?" is the question a user actually has, and
|
|
459
|
+
// it is unanswerable from a masked key alone.
|
|
460
|
+
logLine(out, `AEGIS key: ${credentials.sourceLabel(resolved.source)}`);
|
|
461
|
+
|
|
394
462
|
let shim;
|
|
395
463
|
try {
|
|
396
464
|
shim = createShimServer(opts);
|