aegiscode 6.8.6 → 6.8.8
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 +2 -2
- package/scripts/predist.mjs +12 -0
- package/scripts/runtests.mjs +54 -0
- package/src/app.js +115 -3
- package/src/art.js +26 -19
- package/src/caps.js +106 -158
- package/src/chatflow.js +29 -15
- package/src/checkpoint.js +4 -2
- package/src/clipboard.js +89 -13
- package/src/commands.js +47 -3
- package/src/config.js +8 -9
- package/src/deps.js +7 -1
- package/src/diffview.js +10 -3
- package/src/events.js +27 -1
- package/src/history.js +5 -3
- package/src/models.js +46 -12
- package/src/securefs.js +319 -0
- package/src/theme.js +23 -21
- package/vendor/client/aegis.js +16 -1
- package/vendor/client/auto-provision.js +52 -0
- package/vendor/client/brain-catalog.js +113 -0
- package/vendor/client/device-fingerprint.js +63 -0
- package/vendor/desktop/lib/local/engine.js +37 -31
- package/vendor/mcp/server.js +33 -2
|
@@ -76,6 +76,34 @@ try {
|
|
|
76
76
|
}
|
|
77
77
|
}
|
|
78
78
|
|
|
79
|
+
/**
|
|
80
|
+
* The shared pooled-brain selection rule (`client/brain-catalog.js`), resolved
|
|
81
|
+
* the same two ways as every other shared module: repo-relative from a source
|
|
82
|
+
* checkout, and this app's own staged tree (`desktop/vendor/brain-catalog.js`,
|
|
83
|
+
* flattened by scripts/predist.mjs because a packaged app cannot reach outside
|
|
84
|
+
* its own directory). The CLI resolves the same file its own way, through
|
|
85
|
+
* `cli/src/sharedpaths.js`. Both hosts must agree on which entry stands for the
|
|
86
|
+
* pool, so there is deliberately no fallback implementation here — a silently
|
|
87
|
+
* divergent local copy is the exact bug this module removes. When neither
|
|
88
|
+
* layout has it, require() throws at load time naming the file, rather than the
|
|
89
|
+
* host quietly offering a different model list than its sibling.
|
|
90
|
+
*/
|
|
91
|
+
function requireSharedBrain() {
|
|
92
|
+
const candidates = [
|
|
93
|
+
() => require('../../../client/brain-catalog.js'),
|
|
94
|
+
() => require('../../vendor/brain-catalog.js'),
|
|
95
|
+
];
|
|
96
|
+
let last = null;
|
|
97
|
+
for (const load of candidates) {
|
|
98
|
+
try {
|
|
99
|
+
return load();
|
|
100
|
+
} catch (err) {
|
|
101
|
+
last = err;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
throw last;
|
|
105
|
+
}
|
|
106
|
+
|
|
79
107
|
/**
|
|
80
108
|
* How long a turn waits for the working-tree lock before running anyway.
|
|
81
109
|
*
|
|
@@ -254,38 +282,16 @@ function normalizeCatalog(models) {
|
|
|
254
282
|
* The pool already auto-routes across whichever providers are live, so the
|
|
255
283
|
* desktop dropdown offers exactly one entry for the "aegis" class: the
|
|
256
284
|
* collapsed "Nexus" brain — never the raw provider list.
|
|
285
|
+
*
|
|
286
|
+
* The selection rule itself now lives in `client/brain-catalog.js`, shared with
|
|
287
|
+
* the CLI: this host and the terminal were offering the same account two
|
|
288
|
+
* different model lists (one collapsed entry vs. every distinct provider id),
|
|
289
|
+
* and two copies of the rule is precisely how that drift happened. Resolved the
|
|
290
|
+
* two ways this repo resolves every shared module — repo-relative in a
|
|
291
|
+
* checkout, and this app's staged vendor/ tree — with the selection itself
|
|
292
|
+
* unchanged.
|
|
257
293
|
*/
|
|
258
|
-
const
|
|
259
|
-
const NEXUS_LABEL = 'Nexus';
|
|
260
|
-
|
|
261
|
-
/**
|
|
262
|
-
* Pick the one entry standing in for the pooled brain. The server serves
|
|
263
|
-
* `nexus-brain` as the canonical tier (`hidden: false`, no `alias_of`) and
|
|
264
|
-
* marks every other spelling — `aegis-brain` and the `-smart`/`-neo` tiers —
|
|
265
|
-
* as `hidden: true, alias_of: "nexus-brain"`. Prefer the canonical id so the
|
|
266
|
-
* request travels on the name the server owns; fall back to the alias, then to
|
|
267
|
-
* any tier whose `alias_of` names the brain, so a renamed or trimmed catalog
|
|
268
|
-
* still resolves to something selectable instead of silently emptying the
|
|
269
|
-
* dropdown (the previous fixed-id lookup returned [] if `aegis-brain` was ever
|
|
270
|
-
* retired, leaving the class with no model to choose).
|
|
271
|
-
*/
|
|
272
|
-
function selectBrainEntry(models) {
|
|
273
|
-
return (
|
|
274
|
-
models.find((m) => NEXUS_BRAIN_IDS.includes(m.id) && !m.hidden && m.alias_of === undefined)
|
|
275
|
-
|| models.find((m) => NEXUS_BRAIN_IDS.includes(m.id))
|
|
276
|
-
|| models.find((m) => m.alias_of && NEXUS_BRAIN_IDS.includes(m.alias_of))
|
|
277
|
-
|| null
|
|
278
|
-
);
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
function filterAegisCatalog(models) {
|
|
282
|
-
const nexus = selectBrainEntry(models);
|
|
283
|
-
if (!nexus) return [];
|
|
284
|
-
// Drop the alias bookkeeping: this entry *is* the selection, so the renderer
|
|
285
|
-
// must never treat it as a hidden alias and filter it back out.
|
|
286
|
-
const { hidden, alias_of, ...rest } = nexus;
|
|
287
|
-
return [{ ...rest, label: NEXUS_LABEL }];
|
|
288
|
-
}
|
|
294
|
+
const { filterAegisCatalog } = requireSharedBrain();
|
|
289
295
|
|
|
290
296
|
// ── Agent-loop helpers ──────────────────────────────────────────────────────
|
|
291
297
|
|
package/vendor/mcp/server.js
CHANGED
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
|
|
14
14
|
const { createClient } = require('../client/aegis.js');
|
|
15
15
|
const credentials = require('../client/credentials.js');
|
|
16
|
+
const { autoProvisionApiKey } = require('../client/auto-provision.js');
|
|
16
17
|
const { createTools } = require('./tools.js');
|
|
17
18
|
|
|
18
19
|
// `~/.aegiscode/.env` read into process.env once, before anything resolves a
|
|
@@ -46,7 +47,6 @@ const aegis = createClient(credentials.clientOptions());
|
|
|
46
47
|
// (cli/) so the two hosts cannot drift apart. This file owns the JSON-RPC
|
|
47
48
|
// plumbing and nothing else.
|
|
48
49
|
const { TOOLS, toolList } = createTools(aegis);
|
|
49
|
-
const API_KEY = aegis.apiKey;
|
|
50
50
|
const API_BASE = aegis.apiBase;
|
|
51
51
|
const SERVER_NAME = 'aegis';
|
|
52
52
|
// Keep in sync with .claude-plugin/plugin.json "version".
|
|
@@ -67,6 +67,36 @@ function missingKeyText() {
|
|
|
67
67
|
].join('\n');
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
+
// A tool call with no key configured anywhere gets ONE auto-provision attempt
|
|
71
|
+
// per process, not one per call: `register-device` is rate-limited server-side
|
|
72
|
+
// at 5/hour/IP, and a session that fires several tool calls before the user
|
|
73
|
+
// notices the failure message must not burn through that budget on retries
|
|
74
|
+
// that would fail the same way. Success or failure, this only ever runs once.
|
|
75
|
+
// The provisioning itself (endpoint, fingerprint, timeout) is shared with the
|
|
76
|
+
// desktop app and the CLI — see client/auto-provision.js.
|
|
77
|
+
let provisionAttempted = false;
|
|
78
|
+
async function ensureApiKey() {
|
|
79
|
+
if (aegis.apiKey || provisionAttempted) return;
|
|
80
|
+
provisionAttempted = true;
|
|
81
|
+
const result = await autoProvisionApiKey(aegis, credentials);
|
|
82
|
+
if (result.error) {
|
|
83
|
+
process.stderr.write(`aegis: device auto-registration failed (${result.error.message}) — falling back to manual setup.\n`);
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
if (!result.key) {
|
|
87
|
+
process.stderr.write('aegis: device auto-registration returned no usable key — falling back to manual setup.\n');
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
// Starts at zero token-bank balance by design (see registerDevice()'s doc in
|
|
91
|
+
// client/aegis.js) — this grants an account, not free inference, so the
|
|
92
|
+
// very next call still 402s until the account is funded.
|
|
93
|
+
process.stderr.write(
|
|
94
|
+
'aegis: no API key was configured — auto-provisioned a free AEGIS account' +
|
|
95
|
+
(result.ok ? ` (key saved to ${credentials.keyStatus().path}).\n` : ' (could not save it — see above).\n') +
|
|
96
|
+
`Fund it at ${aegis.promptUrl('topup', 'device_autoprovision')} or set your own BYOK key with aegis_byok_set.\n`
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
|
|
70
100
|
// ---------------------------------------------------------------------------
|
|
71
101
|
// JSON-RPC / MCP plumbing
|
|
72
102
|
// ---------------------------------------------------------------------------
|
|
@@ -126,7 +156,8 @@ async function handleMessage(msg) {
|
|
|
126
156
|
});
|
|
127
157
|
return;
|
|
128
158
|
}
|
|
129
|
-
if (!
|
|
159
|
+
if (!aegis.apiKey) await ensureApiKey();
|
|
160
|
+
if (!aegis.apiKey) {
|
|
130
161
|
reply(id, {
|
|
131
162
|
content: [{ type: 'text', text: missingKeyText() }],
|
|
132
163
|
isError: true,
|