aegiscode 7.0.4 → 7.0.7
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/src/app.js +25 -8
- package/src/chatflow.js +53 -43
- package/src/commands.js +15 -1
- package/src/deps.js +2 -1
- package/src/overlays.js +20 -7
- package/src/topup.js +1 -1
- package/vendor/client/aegis.js +3 -2
- package/vendor/client/auto-provision.js +50 -17
- package/vendor/client/device-fingerprint.js +1 -8
- package/vendor/mcp/server.js +1 -1
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "aegiscode",
|
|
3
3
|
"productName": "AEGIS Code",
|
|
4
|
-
"version": "7.0.
|
|
4
|
+
"version": "7.0.7",
|
|
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
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
const readline = require('node:readline');
|
|
27
27
|
const os = require('node:os');
|
|
28
28
|
const { randomUUID } = require('node:crypto');
|
|
29
|
-
const { createTools, createClient, usageTokens, usageBuckets, buildSystemPrompt, autoProvisionApiKey, hostEnv, autonomous } = require('./deps.js');
|
|
29
|
+
const { createTools, createClient, usageTokens, usageBuckets, buildSystemPrompt, autoProvisionApiKey, provisionFailureText, hostEnv, autonomous } = require('./deps.js');
|
|
30
30
|
const { createEngine, HOST_CLASSES, DEFAULT_CLASS, byokNamespace, effortRung } = require('./engine.js');
|
|
31
31
|
const { GLYPH, VERBS, themeOf, RESET, THEME_TABLE, AUTO_THEME_INDEX, themeIsLight, reconcileThemeIndex } = require('./theme.js');
|
|
32
32
|
const { probeTerminalBackground } = require('./caps.js');
|
|
@@ -145,27 +145,35 @@ function createApp(options = {}) {
|
|
|
145
145
|
// With no key configured anywhere, ask aegis1 for a free device key before
|
|
146
146
|
// ever showing "no key" — same shared helper (client/auto-provision.js) the
|
|
147
147
|
// MCP plugin and the desktop app use, so all three ask for the same account
|
|
148
|
-
// on the same machine. One
|
|
149
|
-
// call: register-device is rate-limited server-side, and a session that
|
|
148
|
+
// on the same machine. One provisioning per `createApp()` instance, not one
|
|
149
|
+
// per call: register-device is rate-limited server-side, and a session that
|
|
150
150
|
// fires several turns before noticing a failure must not retry the same
|
|
151
|
-
// failing call each time. A
|
|
151
|
+
// failing call each time. A transient failure gets a few bounded retries
|
|
152
|
+
// inside that one provisioning. A brand-new fingerprint comes back with aegis1's
|
|
152
153
|
// one-time 30-day welcome-trial `unlimited` entitlement (token-bank credit
|
|
153
154
|
// plus a `subscriptions` row) granted in the same request — aegis1 commit
|
|
154
155
|
// 4372830 — so the account is usable pooled right away rather than starting
|
|
155
156
|
// at zero. The credit is finite: once it is spent or the trial lapses, the
|
|
156
157
|
// usual plan/balance gate applies.
|
|
157
158
|
let provisionAttempted = false;
|
|
159
|
+
let keyFailure = '';
|
|
160
|
+
async function provisionDeviceKey() {
|
|
161
|
+
const result = await autoProvisionApiKey(client, credentials, { app: 'cli' });
|
|
162
|
+
keyFailure = result.key ? '' : provisionFailureText(result);
|
|
163
|
+
return result;
|
|
164
|
+
}
|
|
158
165
|
async function ensureApiKey() {
|
|
159
166
|
if (client.apiKey || provisionAttempted) return;
|
|
160
167
|
provisionAttempted = true;
|
|
161
|
-
const result = await
|
|
168
|
+
const result = await provisionDeviceKey();
|
|
162
169
|
if (result.key) {
|
|
163
170
|
emit(
|
|
164
171
|
render.renderNotice(
|
|
165
172
|
ctx(),
|
|
166
173
|
'info',
|
|
167
|
-
`
|
|
174
|
+
`auto-provisioned a free account` +
|
|
168
175
|
(result.ok ? ` (saved to ${credentials.credentialsPath()})` : ' (could not save it — reconfigure with /key)') +
|
|
176
|
+
(result.trialGranted === false ? '. The welcome trial was withheld this hour (too many new devices from this network)' : '') +
|
|
169
177
|
`. Fund it at ${client.promptUrl('topup', 'device_autoprovision')} or run /byok to use your own key.`
|
|
170
178
|
)
|
|
171
179
|
);
|
|
@@ -543,6 +551,12 @@ function createApp(options = {}) {
|
|
|
543
551
|
return res;
|
|
544
552
|
}
|
|
545
553
|
|
|
554
|
+
/** Explicit `/key register`: unlike the automatic path, this runs again after a failure. */
|
|
555
|
+
async function registerAccount() {
|
|
556
|
+
if (client.apiKey) return { alreadyKeyed: true };
|
|
557
|
+
return provisionDeviceKey();
|
|
558
|
+
}
|
|
559
|
+
|
|
546
560
|
/**
|
|
547
561
|
* The persisting-memory gate — the WRITE half of aegis_memory, and now ON by
|
|
548
562
|
* default for every account (see config.js `memoryPersistState` for the
|
|
@@ -1475,6 +1489,7 @@ function createApp(options = {}) {
|
|
|
1475
1489
|
keyStatus: () => credentials.keyStatus(),
|
|
1476
1490
|
setApiKey: (raw, o) => setApiKey(raw, o),
|
|
1477
1491
|
forgetApiKey: () => forgetApiKey(),
|
|
1492
|
+
registerAccount: () => registerAccount(),
|
|
1478
1493
|
readSecret: (text) => readSecret(text, { stdin: process.stdin, stdout: out }),
|
|
1479
1494
|
cloudsync,
|
|
1480
1495
|
cloudSyncEnabled: () => cloudSyncEnabled(),
|
|
@@ -1678,11 +1693,12 @@ function createApp(options = {}) {
|
|
|
1678
1693
|
// always goes to `err` regardless of `json`.
|
|
1679
1694
|
if (!client.apiKey && !provisionAttempted) {
|
|
1680
1695
|
provisionAttempted = true;
|
|
1681
|
-
const result = await autoProvisionApiKey(client, credentials);
|
|
1696
|
+
const result = await autoProvisionApiKey(client, credentials, { app: 'cli' });
|
|
1682
1697
|
if (result.key) {
|
|
1683
1698
|
err.write(
|
|
1684
|
-
`aegiscode:
|
|
1699
|
+
`aegiscode: auto-provisioned a free account` +
|
|
1685
1700
|
(result.ok ? ` (saved to ${credentials.credentialsPath()})` : ' (could not save it — reconfigure with /key)') +
|
|
1701
|
+
(result.trialGranted === false ? '. The welcome trial was withheld this hour (too many new devices from this network)' : '') +
|
|
1686
1702
|
`. Fund it at ${client.promptUrl('topup', 'device_autoprovision')} or run /byok to use your own key.\n`
|
|
1687
1703
|
);
|
|
1688
1704
|
}
|
|
@@ -2022,6 +2038,7 @@ function createApp(options = {}) {
|
|
|
2022
2038
|
wantExit = true;
|
|
2023
2039
|
},
|
|
2024
2040
|
wantsExit: () => wantExit,
|
|
2041
|
+
keyNotice: () => (client.apiKey ? '' : keyFailure),
|
|
2025
2042
|
isYolo: () => {
|
|
2026
2043
|
// Both halves, in the order the desktop host reads them
|
|
2027
2044
|
// (main.js autoRoundsOn): "this session runs auto mode" AND "the
|
package/src/chatflow.js
CHANGED
|
@@ -353,6 +353,8 @@ function statusLine(state, cols, ctx) {
|
|
|
353
353
|
left = [span(t.gray, ` ${GLYPH.bullet} esc to interrupt`)];
|
|
354
354
|
} else if (state.streamJob) {
|
|
355
355
|
left = [span(t.gray, `${GLYPH.bullet} esc to stop`)];
|
|
356
|
+
} else if (state.keyNotice) {
|
|
357
|
+
left = [span(t.gray, ` ${GLYPH.bullet} no AEGIS key: ${state.keyNotice} ${GLYPH.bullet} /key register to retry`)];
|
|
356
358
|
} else if (state.yolo) {
|
|
357
359
|
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`)];
|
|
358
360
|
} else {
|
|
@@ -1150,7 +1152,7 @@ async function runSession(host) {
|
|
|
1150
1152
|
);
|
|
1151
1153
|
lines.push(inp.line);
|
|
1152
1154
|
lines.push(separatorLine(cols, ctx));
|
|
1153
|
-
lines.push(statusLine({ working, inputPrompt, streamJob, yolo: host.isYolo && host.isYolo() }, cols, ctx));
|
|
1155
|
+
lines.push(statusLine({ working, inputPrompt, streamJob, yolo: host.isYolo && host.isYolo(), keyNotice: host.keyNotice && host.keyNotice() }, cols, ctx));
|
|
1154
1156
|
return { lines, inputCol: inp.cursorCol, rows, inputRow: rows - 2 };
|
|
1155
1157
|
};
|
|
1156
1158
|
|
|
@@ -1935,7 +1937,7 @@ async function runSession(host) {
|
|
|
1935
1937
|
).length;
|
|
1936
1938
|
}
|
|
1937
1939
|
if (overlay.type === 'model' || overlay.type === 'resume') return (overlay.items || []).length;
|
|
1938
|
-
if (overlay.type === 'effort') return
|
|
1940
|
+
if (overlay.type === 'effort') return overlays.EFFORT_VALUES.length;
|
|
1939
1941
|
return 0;
|
|
1940
1942
|
};
|
|
1941
1943
|
|
|
@@ -2037,6 +2039,26 @@ async function runSession(host) {
|
|
|
2037
2039
|
await collectKeyFor(chosen);
|
|
2038
2040
|
};
|
|
2039
2041
|
|
|
2042
|
+
/**
|
|
2043
|
+
* Pin an effort rung — the ONE path a rung is applied through, shared by
|
|
2044
|
+
* Enter, shift+enter and the shift+arrow chords.
|
|
2045
|
+
*
|
|
2046
|
+
* It resolves the row through the picker's OWN table (overlays.EFFORT_VALUES),
|
|
2047
|
+
* which is the point: this used to re-declare ['low','medium','high'] at each
|
|
2048
|
+
* commit site while the picker drew its own list, so the row a user picked and
|
|
2049
|
+
* the value the session stored came from two different lists. A rung the
|
|
2050
|
+
* picker does not draw can no longer be stored, and a row it does draw can no
|
|
2051
|
+
* longer store a different value than the one it painted.
|
|
2052
|
+
*/
|
|
2053
|
+
const applyEffortRow = (sel) => {
|
|
2054
|
+
const chosen = overlays.EFFORT_VALUES[sel || 0];
|
|
2055
|
+
overlay = null;
|
|
2056
|
+
ctx.effort = chosen || 'high';
|
|
2057
|
+
host.updateConfig({ effort: ctx.effort });
|
|
2058
|
+
note(`effort: ${ctx.effort}`);
|
|
2059
|
+
render();
|
|
2060
|
+
};
|
|
2061
|
+
|
|
2040
2062
|
const handleOverlayKey = async (key) => {
|
|
2041
2063
|
const type = overlay.type;
|
|
2042
2064
|
if (key.name === KEY.ESC || key.name === KEY.CTRL_C) {
|
|
@@ -2062,11 +2084,16 @@ async function runSession(host) {
|
|
|
2062
2084
|
}
|
|
2063
2085
|
return;
|
|
2064
2086
|
}
|
|
2065
|
-
if (key.name === KEY.TAB && type === 'model') {
|
|
2087
|
+
if (key.name === KEY.TAB && (type === 'model' || type === 'effort')) {
|
|
2066
2088
|
// Reference parity (aegiscodex-dev/src/main.js's model overlay cycles on
|
|
2067
|
-
// Tab). It is also the one way to walk
|
|
2089
|
+
// Tab). It is also the one way to walk either picker that survives a link
|
|
2068
2090
|
// where arrow escapes are eaten, since Tab is a single control byte.
|
|
2069
|
-
|
|
2091
|
+
// Both lists are addressed the one way each of them can be: the catalogue
|
|
2092
|
+
// lives in `overlay.items`, while the rungs are the picker's own table —
|
|
2093
|
+
// the same table Enter and shift+enter resolve through.
|
|
2094
|
+
const n = type === 'model'
|
|
2095
|
+
? (overlay.items || []).length
|
|
2096
|
+
: overlays.EFFORT_VALUES.length;
|
|
2070
2097
|
if (n) {
|
|
2071
2098
|
overlay.sel = ((overlay.sel || 0) + 1) % n;
|
|
2072
2099
|
render();
|
|
@@ -2098,13 +2125,8 @@ async function runSession(host) {
|
|
|
2098
2125
|
// The picker's own order, not a second copy of the level names: this
|
|
2099
2126
|
// used to re-declare ['low','medium','high'] here while the picker drew
|
|
2100
2127
|
// its own table, so the row a user picked and the value it stored were
|
|
2101
|
-
// resolved through different lists.
|
|
2102
|
-
|
|
2103
|
-
overlay = null;
|
|
2104
|
-
ctx.effort = chosen || 'high';
|
|
2105
|
-
host.updateConfig({ effort: ctx.effort });
|
|
2106
|
-
note(`effort: ${ctx.effort}`);
|
|
2107
|
-
render();
|
|
2128
|
+
// resolved through different lists. (See applyEffortRow.)
|
|
2129
|
+
applyEffortRow(overlay.sel || 0);
|
|
2108
2130
|
return;
|
|
2109
2131
|
}
|
|
2110
2132
|
if (type === 'resume') {
|
|
@@ -2138,12 +2160,7 @@ async function runSession(host) {
|
|
|
2138
2160
|
return;
|
|
2139
2161
|
}
|
|
2140
2162
|
if (type === 'effort') {
|
|
2141
|
-
|
|
2142
|
-
overlay = null;
|
|
2143
|
-
ctx.effort = chosen || 'high';
|
|
2144
|
-
host.updateConfig({ effort: ctx.effort });
|
|
2145
|
-
note(`effort: ${ctx.effort}`);
|
|
2146
|
-
render();
|
|
2163
|
+
applyEffortRow(overlay.sel || 0);
|
|
2147
2164
|
return;
|
|
2148
2165
|
}
|
|
2149
2166
|
render();
|
|
@@ -2171,12 +2188,7 @@ async function runSession(host) {
|
|
|
2171
2188
|
return;
|
|
2172
2189
|
}
|
|
2173
2190
|
if (type === 'effort') {
|
|
2174
|
-
|
|
2175
|
-
overlay = null;
|
|
2176
|
-
ctx.effort = chosen || 'high';
|
|
2177
|
-
host.updateConfig({ effort: ctx.effort });
|
|
2178
|
-
note(`effort: ${ctx.effort}`);
|
|
2179
|
-
render();
|
|
2191
|
+
applyEffortRow(overlay.sel || 0);
|
|
2180
2192
|
return;
|
|
2181
2193
|
}
|
|
2182
2194
|
return;
|
|
@@ -2204,25 +2216,17 @@ async function runSession(host) {
|
|
|
2204
2216
|
render();
|
|
2205
2217
|
return;
|
|
2206
2218
|
}
|
|
2219
|
+
// There is deliberately NO shift+w / shift+s chord here. It existed (it
|
|
2220
|
+
// arrived as the bare chars 'W'/'S' — a real signal that survives links
|
|
2221
|
+
// which eat CSI arrow escapes) and it was removed on request: one
|
|
2222
|
+
// navigation binding is all these pickers need, and Tab already is that
|
|
2223
|
+
// binding — a single control byte, so it survives the same transports the
|
|
2224
|
+
// letter chord was there for, without a second way to move that then has
|
|
2225
|
+
// to be kept in step with the first. Tab cycles (above), Enter pins,
|
|
2226
|
+
// shift+↑/↓ pins as it moves for terminals that send CSI modifier 2, and
|
|
2227
|
+
// a plain uppercase letter in a picker now does nothing at all — it falls
|
|
2228
|
+
// through to the row-number branch below, which correctly ignores it.
|
|
2207
2229
|
if (type === 'model') {
|
|
2208
|
-
// Shift+W / Shift+S arrive as the plain chars 'W'/'S' — unlike a bare
|
|
2209
|
-
// Shift press, shift+letter is a real, universally-sent terminal
|
|
2210
|
-
// signal (the terminal just sends the uppercase letter), so this is
|
|
2211
|
-
// the one "shift + something" chord that works everywhere arrow keys
|
|
2212
|
-
// might not (e.g. over some remote links/multiplexers that eat CSI
|
|
2213
|
-
// arrow sequences but pass plain chars through fine). Routes through
|
|
2214
|
-
// the same move-and-pin step the arrow keys use.
|
|
2215
|
-
if (key.ch === 'W' || key.ch === 'S') {
|
|
2216
|
-
const step = key.ch === 'W' ? -1 : 1;
|
|
2217
|
-
const max = Math.max(0, overlayRowCount() - 1);
|
|
2218
|
-
overlay.sel = Math.min(max, Math.max(0, (overlay.sel || 0) + step));
|
|
2219
|
-
const chosen = (overlay.items || [])[overlay.sel || 0];
|
|
2220
|
-
overlay = null;
|
|
2221
|
-
render();
|
|
2222
|
-
await applyModelRow(chosen);
|
|
2223
|
-
render();
|
|
2224
|
-
return;
|
|
2225
|
-
}
|
|
2226
2230
|
const idx = parseInt(key.ch, 10);
|
|
2227
2231
|
const items = overlay.items || [];
|
|
2228
2232
|
if (Number.isFinite(idx) && idx >= 1 && idx <= items.length) {
|
|
@@ -2232,8 +2236,14 @@ async function runSession(host) {
|
|
|
2232
2236
|
return;
|
|
2233
2237
|
}
|
|
2234
2238
|
if (type === 'effort' || type === 'resume') {
|
|
2239
|
+
// Bounded by the same row count every other mover is bounded by. A row
|
|
2240
|
+
// number past the end used to be accepted unseen (`sel = idx - 1` with
|
|
2241
|
+
// no upper clamp), so '9' in /effort parked the highlight off the list
|
|
2242
|
+
// and Enter then stored the 'high' fallback for a row that was never
|
|
2243
|
+
// drawn — silently, since nothing was highlighted to contradict it.
|
|
2235
2244
|
const idx = parseInt(key.ch, 10);
|
|
2236
|
-
|
|
2245
|
+
const n = overlayRowCount();
|
|
2246
|
+
if (Number.isFinite(idx) && idx >= 1 && idx <= n) {
|
|
2237
2247
|
overlay.sel = idx - 1;
|
|
2238
2248
|
render();
|
|
2239
2249
|
}
|
package/src/commands.js
CHANGED
|
@@ -2695,7 +2695,7 @@ const COMMANDS = [
|
|
|
2695
2695
|
},
|
|
2696
2696
|
},
|
|
2697
2697
|
{
|
|
2698
|
-
name: 'key', aliases: ['apikey', 'api-key'], args: ['value'], hint: '[<api_key>|status|clear]', category: 'auth',
|
|
2698
|
+
name: 'key', aliases: ['apikey', 'api-key'], args: ['value'], hint: '[<api_key>|status|clear|register]', category: 'auth',
|
|
2699
2699
|
desc: 'Save or show the AEGIS account key',
|
|
2700
2700
|
handler: async (c, args) => {
|
|
2701
2701
|
const arg = String(args.value || args._rest || '').trim();
|
|
@@ -2705,6 +2705,20 @@ const COMMANDS = [
|
|
|
2705
2705
|
c.render();
|
|
2706
2706
|
return true;
|
|
2707
2707
|
}
|
|
2708
|
+
if (lower === 'register') {
|
|
2709
|
+
const res = await c.registerAccount();
|
|
2710
|
+
if (res.alreadyKeyed) {
|
|
2711
|
+
note(c, 'this machine already has an AEGIS key — /key status shows it');
|
|
2712
|
+
} else if (res.key && res.ok) {
|
|
2713
|
+
done(c, 'AEGIS account key provisioned and saved');
|
|
2714
|
+
} else if (res.key) {
|
|
2715
|
+
note(c, 'the account was created but its key could not be saved — run /key <api_key> with the key from aegiscloud.org');
|
|
2716
|
+
} else {
|
|
2717
|
+
note(c, `could not register this machine: ${res.error ? res.error.message : 'the server returned no account key'}`);
|
|
2718
|
+
}
|
|
2719
|
+
c.render();
|
|
2720
|
+
return true;
|
|
2721
|
+
}
|
|
2708
2722
|
if (lower === 'clear' || lower === 'remove' || lower === 'rm') {
|
|
2709
2723
|
const res = c.forgetApiKey();
|
|
2710
2724
|
done(c, res.cleared ? `key removed from ${res.path}` : 'there was no saved key to remove');
|
package/src/deps.js
CHANGED
|
@@ -83,7 +83,7 @@ const { buildSystemPrompt } = require(promptPath);
|
|
|
83
83
|
const updater = require(updatePath);
|
|
84
84
|
const queue = require(queuePath);
|
|
85
85
|
const autonomous = require(autonomousPath);
|
|
86
|
-
const { autoProvisionApiKey } = require(autoProvisionPath);
|
|
86
|
+
const { autoProvisionApiKey, provisionFailureText } = require(autoProvisionPath);
|
|
87
87
|
|
|
88
88
|
module.exports = {
|
|
89
89
|
resolveShared,
|
|
@@ -106,6 +106,7 @@ module.exports = {
|
|
|
106
106
|
queue,
|
|
107
107
|
autonomous,
|
|
108
108
|
autoProvisionApiKey,
|
|
109
|
+
provisionFailureText,
|
|
109
110
|
paths: { client: clientPath, tools: toolsPath, usage: usagePath, engine: enginePath, settings: settingsPath, agents: agentsPath, prompt: promptPath, update: updatePath, queue: queuePath, autonomous: autonomousPath, autoProvision: autoProvisionPath },
|
|
110
111
|
roots,
|
|
111
112
|
};
|
package/src/overlays.js
CHANGED
|
@@ -139,6 +139,23 @@ function renderPalette(commands, state = {}, width = 80, height = 24) {
|
|
|
139
139
|
|
|
140
140
|
// ── Model picker overlay (alt+p) ─────────────────────────────────────────────
|
|
141
141
|
|
|
142
|
+
// The one hint line the two setting-writing pickers (/model and /effort) share.
|
|
143
|
+
//
|
|
144
|
+
// It is ONE string reused, not a line typed twice, because a hint that
|
|
145
|
+
// advertises a binding the other picker does not have is how /effort ended up
|
|
146
|
+
// with no chord at all while /model had three: nothing forced the two to say
|
|
147
|
+
// the same thing, so they didn't. Both handlers consume these bindings now
|
|
148
|
+
// (chatflow.js handleOverlayKey), and both paint this sentence.
|
|
149
|
+
//
|
|
150
|
+
// Length is load-bearing: padLine() truncates at the terminal width with no
|
|
151
|
+
// ellipsis, and a longer wording loses its second half at 80 columns — exactly
|
|
152
|
+
// the half naming the chords — so the clause explaining the pin-as-you-move
|
|
153
|
+
// chord gets cut to "…pins" and the sentence is worse than useless. The
|
|
154
|
+
// removed shift+w/s chord was dropped from this string for the same reason it
|
|
155
|
+
// was dropped from the handler: Tab is the single arrow-free binding. Keep the
|
|
156
|
+
// whole line under 78 cells, plus the leading space.
|
|
157
|
+
const PICKER_HINT = `↑↓ or tab move ${GLYPH.bullet} enter pins ${GLYPH.bullet} shift+↑↓ pins at once ${GLYPH.bullet} esc cancels`;
|
|
158
|
+
|
|
142
159
|
/**
|
|
143
160
|
* @param {Array} models entries ({id, label?, name?, note?, model?})
|
|
144
161
|
* @param {number} sel selected index
|
|
@@ -214,12 +231,7 @@ function renderModelPicker(models, sel = 0, width = 80, height = 24, current = n
|
|
|
214
231
|
}
|
|
215
232
|
if (end < count) lines.push([span('', ' '), span(C.gray, `↓ ${count - end} more below`)]);
|
|
216
233
|
lines.push(blank(width));
|
|
217
|
-
|
|
218
|
-
// binding (aegiscodex-dev/src/main.js navList: arrows point, Enter commits),
|
|
219
|
-
// and the two chords that DO apply as they move are spelled out separately:
|
|
220
|
-
// shift+↑/↓ for terminals that send CSI modifier 2, and shift+w/shift+s as
|
|
221
|
-
// plain chars ('W'/'S') for links that eat arrow escapes but pass letters.
|
|
222
|
-
lines.push([span('', ' '), span(C.gray, `↑↓ or tab move ${GLYPH.bullet} enter pins ${GLYPH.bullet} shift+↑↓/shift+w/s pins at once ${GLYPH.bullet} esc cancels`)]);
|
|
234
|
+
lines.push([span('', ' '), span(C.gray, PICKER_HINT)]);
|
|
223
235
|
return fit(lines, width);
|
|
224
236
|
}
|
|
225
237
|
|
|
@@ -269,7 +281,7 @@ function renderEffortPicker(sel = 0, width = 80, current = null, levels = EFFORT
|
|
|
269
281
|
lines.push([span('', ' '), left, span('', ' '), nameSpan, mark, span(C.gray, pad + lv.note)]);
|
|
270
282
|
}
|
|
271
283
|
lines.push(blank(width));
|
|
272
|
-
lines.push([span('', ' '), span(C.gray,
|
|
284
|
+
lines.push([span('', ' '), span(C.gray, PICKER_HINT)]);
|
|
273
285
|
return fit(lines, width);
|
|
274
286
|
}
|
|
275
287
|
|
|
@@ -349,4 +361,5 @@ module.exports = {
|
|
|
349
361
|
renderResumeList,
|
|
350
362
|
EFFORT_LEVELS,
|
|
351
363
|
EFFORT_VALUES,
|
|
364
|
+
PICKER_HINT,
|
|
352
365
|
};
|
package/src/topup.js
CHANGED
|
@@ -68,7 +68,7 @@ async function ensureKey(client, store) {
|
|
|
68
68
|
const mod = loadShared('client/auto-provision.js');
|
|
69
69
|
const provision = mod.autoProvisionApiKey || mod.default;
|
|
70
70
|
if (typeof provision === 'function') {
|
|
71
|
-
const res = await provision(client, store);
|
|
71
|
+
const res = await provision(client, store, { app: 'cli' });
|
|
72
72
|
if (res && res.key && typeof client.setApiKey === 'function') client.setApiKey(res.key);
|
|
73
73
|
}
|
|
74
74
|
} catch {
|
package/vendor/client/aegis.js
CHANGED
|
@@ -855,10 +855,11 @@ function createClient(opts = {}) {
|
|
|
855
855
|
* zero balance. Re-registering an already-known fingerprint does NOT
|
|
856
856
|
* re-grant it; the pool balance gate still applies once the allowance is
|
|
857
857
|
* spent or the 30 days lapse. Sends no API key of its own — there isn't
|
|
858
|
-
* one yet.
|
|
858
|
+
* one yet. `opts.app` names the host ('cli' | 'desktop' | 'mcp') so the
|
|
859
|
+
* server files this machine under its real name, not 'other'.
|
|
859
860
|
*/
|
|
860
861
|
async function registerDevice(fingerprint, opts) {
|
|
861
|
-
return apiPost('/api/v1/auth/register-device', { fingerprint }, undefined, opts);
|
|
862
|
+
return apiPost('/api/v1/auth/register-device', { fingerprint, app: opts && opts.app }, undefined, opts);
|
|
862
863
|
}
|
|
863
864
|
|
|
864
865
|
/** Build the OpenAI-style messages array from either a full history or the
|
|
@@ -33,32 +33,65 @@
|
|
|
33
33
|
const { machineFingerprint } = require('./device-fingerprint.js');
|
|
34
34
|
|
|
35
35
|
const DEVICE_REGISTER_TIMEOUT_MS = 8000;
|
|
36
|
+
const DEVICE_REGISTER_RETRY_DELAYS_MS = [1000, 3000];
|
|
37
|
+
|
|
38
|
+
// Network failure, timeout (status 0), 408, or 5xx. A 4xx — including 429, the
|
|
39
|
+
// server's per-IP registration cap — is a refusal, and retrying it only spends
|
|
40
|
+
// more of that cap.
|
|
41
|
+
function isTransientRegisterError(err) {
|
|
42
|
+
const status = err && err.status;
|
|
43
|
+
return !status || status === 408 || status >= 500;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// Why automatic registration gave up, in words a host can show the user.
|
|
47
|
+
function provisionFailureText(result) {
|
|
48
|
+
const err = result && result.error;
|
|
49
|
+
if (!err) return 'the server returned no account key';
|
|
50
|
+
if (err.status === 429) return 'too many sign-ups from this network — try again later';
|
|
51
|
+
if (err.status >= 500) return `aegiscloud.org failed to register this device: ${err.message}`;
|
|
52
|
+
if (isTransientRegisterError(err)) return 'could not reach aegiscloud.org';
|
|
53
|
+
return `the server refused the request (HTTP ${err.status})`;
|
|
54
|
+
}
|
|
36
55
|
|
|
37
56
|
/**
|
|
38
57
|
* @param {object} aegisClient A client from client/aegis.js (createClient()).
|
|
39
58
|
* @param {object} credentials client/credentials.js (or a compatible double).
|
|
40
|
-
* @
|
|
59
|
+
* @param {{app?: string, retryDelaysMs?: number[]}} [options] `app` names the host
|
|
60
|
+
* for the server's presence panel; `retryDelaysMs` waits before each retry of a
|
|
61
|
+
* transient failure.
|
|
62
|
+
* @returns {Promise<{ok: boolean, key: string, trialGranted?: boolean, error?: Error}>}
|
|
41
63
|
* `ok` is true only when a usable key was obtained AND persisted to the
|
|
42
64
|
* shared store; `aegisClient.setApiKey()` has already been called on
|
|
43
65
|
* success, so the caller's client is immediately usable either way it
|
|
44
|
-
* inspects `ok`.
|
|
66
|
+
* inspects `ok`. `trialGranted` is false when the server withheld the
|
|
67
|
+
* welcome trial (the account and key are still valid).
|
|
45
68
|
*/
|
|
46
|
-
async function autoProvisionApiKey(aegisClient, credentials) {
|
|
69
|
+
async function autoProvisionApiKey(aegisClient, credentials, options = {}) {
|
|
70
|
+
if (Array.isArray(options)) {
|
|
71
|
+
throw new TypeError('autoProvisionApiKey takes { app, retryDelaysMs }; a bare retry array is no longer accepted');
|
|
72
|
+
}
|
|
47
73
|
if (aegisClient.apiKey) return { ok: true, key: aegisClient.apiKey };
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
74
|
+
const { app, retryDelaysMs = DEVICE_REGISTER_RETRY_DELAYS_MS } = options;
|
|
75
|
+
let lastError = null;
|
|
76
|
+
for (let attempt = 0; attempt <= retryDelaysMs.length; attempt++) {
|
|
77
|
+
if (attempt > 0) await new Promise((resolve) => setTimeout(resolve, retryDelaysMs[attempt - 1]));
|
|
78
|
+
const controller = new AbortController();
|
|
79
|
+
const timer = setTimeout(() => controller.abort(), DEVICE_REGISTER_TIMEOUT_MS);
|
|
80
|
+
try {
|
|
81
|
+
const data = await aegisClient.registerDevice(machineFingerprint(), { app, signal: controller.signal });
|
|
82
|
+
const key = data && typeof data.api_key === 'string' ? data.api_key.trim() : '';
|
|
83
|
+
if (!key) return { ok: false, key: '' };
|
|
84
|
+
const saved = credentials.saveApiKey(key);
|
|
85
|
+
aegisClient.setApiKey(key);
|
|
86
|
+
return { ok: !!saved.ok, key, trialGranted: data.trial_granted };
|
|
87
|
+
} catch (err) {
|
|
88
|
+
lastError = err;
|
|
89
|
+
if (!isTransientRegisterError(err)) break;
|
|
90
|
+
} finally {
|
|
91
|
+
clearTimeout(timer);
|
|
92
|
+
}
|
|
61
93
|
}
|
|
94
|
+
return { ok: false, key: '', error: lastError };
|
|
62
95
|
}
|
|
63
96
|
|
|
64
|
-
module.exports = { autoProvisionApiKey, DEVICE_REGISTER_TIMEOUT_MS };
|
|
97
|
+
module.exports = { autoProvisionApiKey, provisionFailureText, DEVICE_REGISTER_TIMEOUT_MS, DEVICE_REGISTER_RETRY_DELAYS_MS };
|
|
@@ -111,8 +111,7 @@ function persistedInstallId() {
|
|
|
111
111
|
* 4. `hostname:platform:arch` — last resort, kept only so this never throws.
|
|
112
112
|
*
|
|
113
113
|
* Only step 4 is guessable by a third party; steps 2 and 3 are both per-host
|
|
114
|
-
* unique.
|
|
115
|
-
* abuse review can tell a genuine re-registration from a forged one.
|
|
114
|
+
* unique.
|
|
116
115
|
*
|
|
117
116
|
* @param {string} [overrideId] - test-only override for the raw machine identity.
|
|
118
117
|
*/
|
|
@@ -136,15 +135,9 @@ function machineIdentity(overrideId) {
|
|
|
136
135
|
};
|
|
137
136
|
}
|
|
138
137
|
|
|
139
|
-
/** Which identity class the fingerprint on THIS host is derived from. */
|
|
140
|
-
function machineIdentityKind() {
|
|
141
|
-
return machineIdentity().kind;
|
|
142
|
-
}
|
|
143
|
-
|
|
144
138
|
module.exports = {
|
|
145
139
|
machineFingerprint,
|
|
146
140
|
machineIdentity,
|
|
147
|
-
machineIdentityKind,
|
|
148
141
|
readMachineId,
|
|
149
142
|
persistedInstallId,
|
|
150
143
|
};
|
package/vendor/mcp/server.js
CHANGED
|
@@ -83,7 +83,7 @@ let provisionAttempted = false;
|
|
|
83
83
|
async function ensureApiKey() {
|
|
84
84
|
if (aegis.apiKey || provisionAttempted) return;
|
|
85
85
|
provisionAttempted = true;
|
|
86
|
-
const result = await autoProvisionApiKey(aegis, credentials);
|
|
86
|
+
const result = await autoProvisionApiKey(aegis, credentials, { app: 'mcp' });
|
|
87
87
|
if (result.error) {
|
|
88
88
|
process.stderr.write(`aegis: device auto-registration failed (${result.error.message}) — falling back to manual setup.\n`);
|
|
89
89
|
return;
|