aegisone 1.0.10 → 1.0.16
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 +1 -1
- package/package.json +1 -1
- package/scripts/predist.mjs +19 -0
- package/src/child.js +121 -2
- package/vendor/cli/package.json +3 -2
- package/vendor/cli/src/app.js +176 -13
- package/vendor/cli/src/chatflow.js +193 -38
- package/vendor/cli/src/commands.js +82 -4
- package/vendor/cli/src/deps.js +29 -2
- package/vendor/cli/src/engine.js +8 -1
- package/vendor/cli/src/models.js +78 -3
- package/vendor/cli/src/overlays.js +20 -7
- package/vendor/cli/src/topup.js +1 -1
- package/vendor/cli/vendor/client/aegis.js +119 -5
- package/vendor/cli/vendor/client/auto-provision.js +89 -17
- package/vendor/cli/vendor/client/credentials.js +8 -2
- package/vendor/cli/vendor/client/device-fingerprint.js +1 -8
- package/vendor/cli/vendor/client/env-file.js +262 -8
- package/vendor/cli/vendor/desktop/lib/local/claude-pro.js +755 -0
- package/vendor/cli/vendor/desktop/lib/local/engine.js +329 -12
- package/vendor/cli/vendor/mcp/server.js +1 -1
- package/vendor/cli/vendor/one/src/child.js +287 -0
- package/vendor/cli/vendor/one/src/permissions.js +371 -0
- package/vendor/desktop/lib/account-key.js +60 -0
- package/vendor/desktop/lib/local/claude-pro.js +755 -0
- package/vendor/desktop/lib/local/engine.js +329 -12
- package/vendor/desktop/main.js +109 -33
- package/vendor/desktop/package.json +4 -3
- package/vendor/desktop/preload.js +8 -0
- package/vendor/desktop/renderer/app.js +50 -0
- package/vendor/desktop/renderer/index.html +11 -0
- package/vendor/desktop/vendor/aegis.js +119 -5
- package/vendor/desktop/vendor/auto-provision.js +89 -17
- package/vendor/desktop/vendor/credentials.js +8 -2
- package/vendor/desktop/vendor/device-fingerprint.js +1 -8
- package/vendor/desktop/vendor/env-file.js +262 -8
|
@@ -54,6 +54,9 @@ const { LineEditor } = require('./input.js');
|
|
|
54
54
|
const { renderMarkdown } = require('./markdown.js');
|
|
55
55
|
const overlays = require('./overlays.js');
|
|
56
56
|
const models = require('./models.js');
|
|
57
|
+
const { resolveShared } = require('./sharedpaths.js');
|
|
58
|
+
const { validateApiKey } = require(resolveShared(require('node:path').join('client', 'credentials.js')));
|
|
59
|
+
const claudePro = require(resolveShared(require('node:path').join('desktop', 'lib', 'local', 'claude-pro.js')));
|
|
57
60
|
const fuzzy = require('./fuzzy.js');
|
|
58
61
|
const { fmtTokens, fmtEur, fmtElapsed, fmtUsageSplit, displayTokens, pathName, feeBillable } = require('./format.js');
|
|
59
62
|
const { editPreview } = require('./diff.js');
|
|
@@ -254,6 +257,61 @@ function historyPairs(rows) {
|
|
|
254
257
|
.map((m) => ({ role: m.role, content: m.text }));
|
|
255
258
|
}
|
|
256
259
|
|
|
260
|
+
// A byok "anthropic:<model>" id's model half → the PRO_MODELS alias it reads
|
|
261
|
+
// closest to. 'default' when nothing matches, which is every dated/snapshot
|
|
262
|
+
// id (`claude-sonnet-4-20250514`) as much as a name this table has not been
|
|
263
|
+
// taught — the subscription's own default is a safer landing than guessing
|
|
264
|
+
// wrong.
|
|
265
|
+
const PRO_ALIAS_KEYWORDS = Object.freeze(['opus', 'haiku', 'sonnet']);
|
|
266
|
+
|
|
267
|
+
/**
|
|
268
|
+
* A picked "anthropic:<model>" byok row this machine has no console key for,
|
|
269
|
+
* but IS already signed into Claude Code Pro/Max for, is better served by the
|
|
270
|
+
* subscription it already pays for than by a prompt for a second credential
|
|
271
|
+
* it does not have — `engine.js`'s own refusal message for this exact state
|
|
272
|
+
* already says so ("Use the subscription instead: /class pro"); this is that
|
|
273
|
+
* suggestion applied at pick time instead of left for the user to notice in
|
|
274
|
+
* an error and type a second command.
|
|
275
|
+
*
|
|
276
|
+
* A row with a real console key already stored takes that key, unchanged —
|
|
277
|
+
* the override only fires when `modelKeyPlan` would otherwise have to ask for
|
|
278
|
+
* one. Pure and unit-testable: every fact it needs (whether a key is already
|
|
279
|
+
* stored, whether the subscription is signed in, the PRO_MODELS table) is
|
|
280
|
+
* injected rather than read from a live host/environment.
|
|
281
|
+
*
|
|
282
|
+
* @param {object} chosen a picker row ({id, cls, ...})
|
|
283
|
+
* @param {object} o
|
|
284
|
+
* @param {boolean} o.hasStored the byok provider store already holds an
|
|
285
|
+
* anthropic key (desktop Provider settings / `/byok-key anthropic`)
|
|
286
|
+
* @param {boolean} o.proLoggedIn this machine is signed into Claude Code Pro
|
|
287
|
+
* @param {Array<{id:string,label:string,note:string}>} o.proModels
|
|
288
|
+
* `claudePro.PRO_MODELS`, injected rather than required here
|
|
289
|
+
* @returns {{row:object, message:string|null}} the row to actually pin (the
|
|
290
|
+
* original, unchanged, when the override does not apply) and a note to
|
|
291
|
+
* surface when it does
|
|
292
|
+
*/
|
|
293
|
+
function overrideAnthropicByokWithPro(chosen, o = {}) {
|
|
294
|
+
if (!chosen || chosen.cls !== 'byok') return { row: chosen, message: null };
|
|
295
|
+
const id = String(chosen.id || '');
|
|
296
|
+
const colon = id.indexOf(':');
|
|
297
|
+
if (colon < 0 || id.slice(0, colon).trim().toLowerCase() !== 'anthropic') {
|
|
298
|
+
return { row: chosen, message: null };
|
|
299
|
+
}
|
|
300
|
+
if (!o.needsKey) return { row: chosen, message: null }; // a real console key is already usable
|
|
301
|
+
if (!o.proLoggedIn) return { row: chosen, message: null }; // no subscription either — the normal prompt stands
|
|
302
|
+
const modelPart = id.slice(colon + 1).toLowerCase();
|
|
303
|
+
const proModels = Array.isArray(o.proModels) && o.proModels.length ? o.proModels : [{ id: 'default', label: 'Default', note: '' }];
|
|
304
|
+
const aliasId = PRO_ALIAS_KEYWORDS.find((kw) => modelPart.includes(kw)) || 'default';
|
|
305
|
+
const row = proModels.find((m) => m.id === aliasId) || proModels[0];
|
|
306
|
+
return {
|
|
307
|
+
row: { id: row.id, label: row.label, note: row.note, cls: 'pro' },
|
|
308
|
+
message:
|
|
309
|
+
`${id} has no Anthropic console key on this machine, but Claude Code Pro is signed in — ` +
|
|
310
|
+
`using the subscription instead (claude --model ${row.id}). Add a real console key any ` +
|
|
311
|
+
`time with /byok-key anthropic <key> to run this row directly.`,
|
|
312
|
+
};
|
|
313
|
+
}
|
|
314
|
+
|
|
257
315
|
/**
|
|
258
316
|
* Palette ranking query for a typed command line: "/memory tiers" must keep
|
|
259
317
|
* ranking on "memory" so the command stays listed while the user finishes the
|
|
@@ -353,6 +411,8 @@ function statusLine(state, cols, ctx) {
|
|
|
353
411
|
left = [span(t.gray, ` ${GLYPH.bullet} esc to interrupt`)];
|
|
354
412
|
} else if (state.streamJob) {
|
|
355
413
|
left = [span(t.gray, `${GLYPH.bullet} esc to stop`)];
|
|
414
|
+
} else if (state.keyNotice) {
|
|
415
|
+
left = [span(t.gray, ` ${GLYPH.bullet} no AEGIS key: ${state.keyNotice} ${GLYPH.bullet} /key register to retry`)];
|
|
356
416
|
} else if (state.yolo) {
|
|
357
417
|
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
418
|
} else {
|
|
@@ -1150,7 +1210,7 @@ async function runSession(host) {
|
|
|
1150
1210
|
);
|
|
1151
1211
|
lines.push(inp.line);
|
|
1152
1212
|
lines.push(separatorLine(cols, ctx));
|
|
1153
|
-
lines.push(statusLine({ working, inputPrompt, streamJob, yolo: host.isYolo && host.isYolo() }, cols, ctx));
|
|
1213
|
+
lines.push(statusLine({ working, inputPrompt, streamJob, yolo: host.isYolo && host.isYolo(), keyNotice: host.keyNotice && host.keyNotice() }, cols, ctx));
|
|
1154
1214
|
return { lines, inputCol: inp.cursorCol, rows, inputRow: rows - 2 };
|
|
1155
1215
|
};
|
|
1156
1216
|
|
|
@@ -1935,7 +1995,7 @@ async function runSession(host) {
|
|
|
1935
1995
|
).length;
|
|
1936
1996
|
}
|
|
1937
1997
|
if (overlay.type === 'model' || overlay.type === 'resume') return (overlay.items || []).length;
|
|
1938
|
-
if (overlay.type === 'effort') return
|
|
1998
|
+
if (overlay.type === 'effort') return overlays.EFFORT_VALUES.length;
|
|
1939
1999
|
return 0;
|
|
1940
2000
|
};
|
|
1941
2001
|
|
|
@@ -1992,10 +2052,15 @@ async function runSession(host) {
|
|
|
1992
2052
|
return;
|
|
1993
2053
|
}
|
|
1994
2054
|
for (const step of queue) {
|
|
1995
|
-
// Pooled rows bill the account; a vendor step names its provider
|
|
1996
|
-
//
|
|
1997
|
-
//
|
|
1998
|
-
|
|
2055
|
+
// Pooled rows bill the account; a vendor step names its provider; the
|
|
2056
|
+
// Claude Code Pro step has neither — it is the subscription's own OAuth
|
|
2057
|
+
// token, minted with `claude setup-token` (or lifted from wherever it is
|
|
2058
|
+
// already set aside). The label says WHICH key is wanted, because two
|
|
2059
|
+
// prompts in a row for the same row must not read as the same question
|
|
2060
|
+
// asked twice.
|
|
2061
|
+
const label = step.role === 'account' ? 'AEGIS account key'
|
|
2062
|
+
: step.role === 'claude-pro' ? 'Claude Code OAuth token (`claude setup-token` mints one)'
|
|
2063
|
+
: `${step.provider} key`;
|
|
1999
2064
|
const key = String(
|
|
2000
2065
|
(await c.readSecret(`${label} → ${step.env} (kept off screen, Enter to skip): `)) || ''
|
|
2001
2066
|
).trim();
|
|
@@ -2006,15 +2071,38 @@ async function runSession(host) {
|
|
|
2006
2071
|
note(`no key given — ${step.env} is still unset, so ${chosen.id} will fail until it is.`);
|
|
2007
2072
|
continue;
|
|
2008
2073
|
}
|
|
2074
|
+
// Shape check before it ever touches disk: this is the same structural
|
|
2075
|
+
// check the account-key login flow has always had (empty / whitespace /
|
|
2076
|
+
// under 16 chars), now applied here too. Without it a truncated paste
|
|
2077
|
+
// (a 2-char clipboard miss, once landed as a literal ANTHROPIC_API_KEY)
|
|
2078
|
+
// writes straight to .env, reads as "configured" to every status check
|
|
2079
|
+
// that only asks `inFile`, and the row fails upstream on every real turn
|
|
2080
|
+
// with an opaque provider error — "key needed" never shows again because
|
|
2081
|
+
// the picker believes it already has one.
|
|
2082
|
+
const shapeLabel = step.role === 'account' ? 'AEGIS'
|
|
2083
|
+
: step.role === 'claude-pro' ? 'Claude Code OAuth'
|
|
2084
|
+
: step.provider || 'that provider';
|
|
2085
|
+
const shape = validateApiKey(key, { label: shapeLabel });
|
|
2086
|
+
if (!shape.ok) {
|
|
2087
|
+
note(`not saved — ${shape.message}. ${step.env} is still unset.`);
|
|
2088
|
+
continue;
|
|
2089
|
+
}
|
|
2009
2090
|
// `env: step.env` is what makes a per-step store possible at all: the row
|
|
2010
2091
|
// alone cannot say which of its two keys this value is for.
|
|
2011
|
-
const res = models.storeModelKey(chosen, key, { env: step.env });
|
|
2092
|
+
const res = models.storeModelKey(chosen, shape.key, { env: step.env });
|
|
2012
2093
|
if (!res.ok) {
|
|
2013
2094
|
note(`could not save the key: ${res.error || 'unknown error'}`);
|
|
2014
2095
|
continue;
|
|
2015
2096
|
}
|
|
2097
|
+
// A foreign secret (CLAUDE_CODE_OAUTH_TOKEN) lands in secrets.env, which
|
|
2098
|
+
// is read explicitly by the one transport that needs it — not loaded
|
|
2099
|
+
// ambiently at start-up the way `.env` is — so it gets its own wording
|
|
2100
|
+
// rather than the "both hosts read that file" line, which is true of
|
|
2101
|
+
// `.env` and would overstate what secrets.env actually does.
|
|
2016
2102
|
note(res.changed
|
|
2017
|
-
?
|
|
2103
|
+
? res.foreign
|
|
2104
|
+
? `${step.env} saved to ${res.file} (0600) — read only by the Claude Code Pro transport, never exported.`
|
|
2105
|
+
: `${step.env} saved to ${res.file} (0600) — both hosts read that file; nothing to export.`
|
|
2018
2106
|
: `${step.env} was already set in ${res.file}.`);
|
|
2019
2107
|
}
|
|
2020
2108
|
};
|
|
@@ -2030,13 +2118,57 @@ async function runSession(host) {
|
|
|
2030
2118
|
*/
|
|
2031
2119
|
const applyModelRow = async (chosen) => {
|
|
2032
2120
|
if (!chosen) return;
|
|
2033
|
-
|
|
2121
|
+
{
|
|
2122
|
+
// Swap an anthropic byok row for the equivalent Claude Code Pro alias
|
|
2123
|
+
// when this machine is signed into the subscription and holds no real
|
|
2124
|
+
// console key — see `overrideAnthropicByokWithPro` (module scope, pure)
|
|
2125
|
+
// for the full reasoning.
|
|
2126
|
+
const plan = models.modelKeyPlan(chosen, {
|
|
2127
|
+
hasStored: host.hasProviderKey ? !!host.hasProviderKey('anthropic') : false,
|
|
2128
|
+
});
|
|
2129
|
+
const { row, message } = overrideAnthropicByokWithPro(chosen, {
|
|
2130
|
+
needsKey: !!(plan && plan.needed),
|
|
2131
|
+
proLoggedIn: models.claudeProLoggedIn(),
|
|
2132
|
+
proModels: claudePro.PRO_MODELS,
|
|
2133
|
+
});
|
|
2134
|
+
chosen = row;
|
|
2135
|
+
if (message) note(message);
|
|
2136
|
+
}
|
|
2137
|
+
// A row that belongs to another class moves the session to that class
|
|
2138
|
+
// BEFORE the pin is stored, for the same reason byok's row does (and it is
|
|
2139
|
+
// the same one-line rule, not a second copy of it): a pro alias pinned while
|
|
2140
|
+
// the session sits on aegis would be sent to the pool as an AEGIS id, and
|
|
2141
|
+
// an AEGIS id pinned under pro would be handed to `claude --model`. Both
|
|
2142
|
+
// fail on the next turn, with a message about a model rather than the class.
|
|
2143
|
+
if (chosen.cls && chosen.cls !== 'aegis' && ctx.modelClass !== chosen.cls) {
|
|
2144
|
+
await dispatch(`/class ${chosen.cls}`);
|
|
2145
|
+
}
|
|
2034
2146
|
ctx.model = chosen.id;
|
|
2035
2147
|
host.updateConfig({ model: chosen.id, currentModelId: chosen.id, modelClass: ctx.modelClass });
|
|
2036
|
-
note(`model: ${chosen.id}${chosen.cls === 'byok' ? ' (byok)' : ''}`);
|
|
2148
|
+
note(`model: ${chosen.id}${chosen.cls === 'byok' ? ' (byok)' : chosen.cls === 'pro' ? ' (Claude Code Pro)' : ''}`);
|
|
2037
2149
|
await collectKeyFor(chosen);
|
|
2038
2150
|
};
|
|
2039
2151
|
|
|
2152
|
+
/**
|
|
2153
|
+
* Pin an effort rung — the ONE path a rung is applied through, shared by
|
|
2154
|
+
* Enter, shift+enter and the shift+arrow chords.
|
|
2155
|
+
*
|
|
2156
|
+
* It resolves the row through the picker's OWN table (overlays.EFFORT_VALUES),
|
|
2157
|
+
* which is the point: this used to re-declare ['low','medium','high'] at each
|
|
2158
|
+
* commit site while the picker drew its own list, so the row a user picked and
|
|
2159
|
+
* the value the session stored came from two different lists. A rung the
|
|
2160
|
+
* picker does not draw can no longer be stored, and a row it does draw can no
|
|
2161
|
+
* longer store a different value than the one it painted.
|
|
2162
|
+
*/
|
|
2163
|
+
const applyEffortRow = (sel) => {
|
|
2164
|
+
const chosen = overlays.EFFORT_VALUES[sel || 0];
|
|
2165
|
+
overlay = null;
|
|
2166
|
+
ctx.effort = chosen || 'high';
|
|
2167
|
+
host.updateConfig({ effort: ctx.effort });
|
|
2168
|
+
note(`effort: ${ctx.effort}`);
|
|
2169
|
+
render();
|
|
2170
|
+
};
|
|
2171
|
+
|
|
2040
2172
|
const handleOverlayKey = async (key) => {
|
|
2041
2173
|
const type = overlay.type;
|
|
2042
2174
|
if (key.name === KEY.ESC || key.name === KEY.CTRL_C) {
|
|
@@ -2062,6 +2194,22 @@ async function runSession(host) {
|
|
|
2062
2194
|
}
|
|
2063
2195
|
return;
|
|
2064
2196
|
}
|
|
2197
|
+
if (key.name === KEY.TAB && (type === 'model' || type === 'effort')) {
|
|
2198
|
+
// Reference parity (aegiscodex-dev/src/main.js's model overlay cycles on
|
|
2199
|
+
// Tab). It is also the one way to walk either picker that survives a link
|
|
2200
|
+
// where arrow escapes are eaten, since Tab is a single control byte.
|
|
2201
|
+
// Both lists are addressed the one way each of them can be: the catalogue
|
|
2202
|
+
// lives in `overlay.items`, while the rungs are the picker's own table —
|
|
2203
|
+
// the same table Enter and shift+enter resolve through.
|
|
2204
|
+
const n = type === 'model'
|
|
2205
|
+
? (overlay.items || []).length
|
|
2206
|
+
: overlays.EFFORT_VALUES.length;
|
|
2207
|
+
if (n) {
|
|
2208
|
+
overlay.sel = ((overlay.sel || 0) + 1) % n;
|
|
2209
|
+
render();
|
|
2210
|
+
}
|
|
2211
|
+
return;
|
|
2212
|
+
}
|
|
2065
2213
|
if (key.name === KEY.ENTER) {
|
|
2066
2214
|
if (type === 'palette') {
|
|
2067
2215
|
// Rank with the same function the palette rendered with, so the row
|
|
@@ -2087,13 +2235,8 @@ async function runSession(host) {
|
|
|
2087
2235
|
// The picker's own order, not a second copy of the level names: this
|
|
2088
2236
|
// used to re-declare ['low','medium','high'] here while the picker drew
|
|
2089
2237
|
// its own table, so the row a user picked and the value it stored were
|
|
2090
|
-
// resolved through different lists.
|
|
2091
|
-
|
|
2092
|
-
overlay = null;
|
|
2093
|
-
ctx.effort = chosen || 'high';
|
|
2094
|
-
host.updateConfig({ effort: ctx.effort });
|
|
2095
|
-
note(`effort: ${ctx.effort}`);
|
|
2096
|
-
render();
|
|
2238
|
+
// resolved through different lists. (See applyEffortRow.)
|
|
2239
|
+
applyEffortRow(overlay.sel || 0);
|
|
2097
2240
|
return;
|
|
2098
2241
|
}
|
|
2099
2242
|
if (type === 'resume') {
|
|
@@ -2127,12 +2270,7 @@ async function runSession(host) {
|
|
|
2127
2270
|
return;
|
|
2128
2271
|
}
|
|
2129
2272
|
if (type === 'effort') {
|
|
2130
|
-
|
|
2131
|
-
overlay = null;
|
|
2132
|
-
ctx.effort = chosen || 'high';
|
|
2133
|
-
host.updateConfig({ effort: ctx.effort });
|
|
2134
|
-
note(`effort: ${ctx.effort}`);
|
|
2135
|
-
render();
|
|
2273
|
+
applyEffortRow(overlay.sel || 0);
|
|
2136
2274
|
return;
|
|
2137
2275
|
}
|
|
2138
2276
|
render();
|
|
@@ -2160,24 +2298,24 @@ async function runSession(host) {
|
|
|
2160
2298
|
return;
|
|
2161
2299
|
}
|
|
2162
2300
|
if (type === 'effort') {
|
|
2163
|
-
|
|
2164
|
-
overlay = null;
|
|
2165
|
-
ctx.effort = chosen || 'high';
|
|
2166
|
-
host.updateConfig({ effort: ctx.effort });
|
|
2167
|
-
note(`effort: ${ctx.effort}`);
|
|
2168
|
-
render();
|
|
2301
|
+
applyEffortRow(overlay.sel || 0);
|
|
2169
2302
|
return;
|
|
2170
2303
|
}
|
|
2171
2304
|
return;
|
|
2172
2305
|
}
|
|
2173
|
-
if (key.name === KEY.UP) {
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
|
|
2306
|
+
if (key.name === KEY.UP || key.name === KEY.DOWN) {
|
|
2307
|
+
// NAVIGATION ONLY — this is the reference's binding and it has to stay
|
|
2308
|
+
// that way. A plain arrow that applies the row it lands on cannot browse:
|
|
2309
|
+
// the overlay closes on the first press, the model is already changed,
|
|
2310
|
+
// and the other fifteen rows are unreachable. The reference moves the
|
|
2311
|
+
// highlight here and commits on Enter (aegiscodex-dev/src/main.js
|
|
2312
|
+
// navList + the KEY.ENTER branch of its model overlay); the one-keystroke
|
|
2313
|
+
// commit belongs to the shift chords below, which are additive and
|
|
2314
|
+
// explicit, not to the arrow every picker in the app uses to point.
|
|
2315
|
+
// Bounds come from the list being drawn, exactly as navList does it.
|
|
2316
|
+
const n = (overlay.items || []).length || overlayRowCount();
|
|
2317
|
+
const step = key.name === KEY.UP ? -1 : 1;
|
|
2318
|
+
overlay.sel = Math.min(Math.max(0, n - 1), Math.max(0, (overlay.sel || 0) + step));
|
|
2181
2319
|
render();
|
|
2182
2320
|
return;
|
|
2183
2321
|
}
|
|
@@ -2188,6 +2326,16 @@ async function runSession(host) {
|
|
|
2188
2326
|
render();
|
|
2189
2327
|
return;
|
|
2190
2328
|
}
|
|
2329
|
+
// There is deliberately NO shift+w / shift+s chord here. It existed (it
|
|
2330
|
+
// arrived as the bare chars 'W'/'S' — a real signal that survives links
|
|
2331
|
+
// which eat CSI arrow escapes) and it was removed on request: one
|
|
2332
|
+
// navigation binding is all these pickers need, and Tab already is that
|
|
2333
|
+
// binding — a single control byte, so it survives the same transports the
|
|
2334
|
+
// letter chord was there for, without a second way to move that then has
|
|
2335
|
+
// to be kept in step with the first. Tab cycles (above), Enter pins,
|
|
2336
|
+
// shift+↑/↓ pins as it moves for terminals that send CSI modifier 2, and
|
|
2337
|
+
// a plain uppercase letter in a picker now does nothing at all — it falls
|
|
2338
|
+
// through to the row-number branch below, which correctly ignores it.
|
|
2191
2339
|
if (type === 'model') {
|
|
2192
2340
|
const idx = parseInt(key.ch, 10);
|
|
2193
2341
|
const items = overlay.items || [];
|
|
@@ -2198,8 +2346,14 @@ async function runSession(host) {
|
|
|
2198
2346
|
return;
|
|
2199
2347
|
}
|
|
2200
2348
|
if (type === 'effort' || type === 'resume') {
|
|
2349
|
+
// Bounded by the same row count every other mover is bounded by. A row
|
|
2350
|
+
// number past the end used to be accepted unseen (`sel = idx - 1` with
|
|
2351
|
+
// no upper clamp), so '9' in /effort parked the highlight off the list
|
|
2352
|
+
// and Enter then stored the 'high' fallback for a row that was never
|
|
2353
|
+
// drawn — silently, since nothing was highlighted to contradict it.
|
|
2201
2354
|
const idx = parseInt(key.ch, 10);
|
|
2202
|
-
|
|
2355
|
+
const n = overlayRowCount();
|
|
2356
|
+
if (Number.isFinite(idx) && idx >= 1 && idx <= n) {
|
|
2203
2357
|
overlay.sel = idx - 1;
|
|
2204
2358
|
render();
|
|
2205
2359
|
}
|
|
@@ -2685,6 +2839,7 @@ module.exports = {
|
|
|
2685
2839
|
summarizeTurnTools,
|
|
2686
2840
|
finalizeTurnText,
|
|
2687
2841
|
historyPairs,
|
|
2842
|
+
overrideAnthropicByokWithPro,
|
|
2688
2843
|
paletteQuery,
|
|
2689
2844
|
headerLine,
|
|
2690
2845
|
separatorLine,
|
|
@@ -339,8 +339,42 @@ async function loadModels(c) {
|
|
|
339
339
|
async function mergedPickerModels(c) {
|
|
340
340
|
const live = (c.ctx && c.ctx.modelClass) || 'aegis';
|
|
341
341
|
const aegis = pickerEntries(await loadModelsFor(c, 'aegis', live)).map((m) => ({ ...m, cls: 'aegis' }));
|
|
342
|
-
|
|
343
|
-
|
|
342
|
+
// `m.cls ||` and not `cls:`: the byok list carries rows that belong to
|
|
343
|
+
// another class (the pooled lane's, prepended by classScopedModels), and
|
|
344
|
+
// their own tag is the truth about where a pick of them runs.
|
|
345
|
+
const byok = pickerEntries(await loadModelsFor(c, 'byok', live)).map((m) => ({ ...m, cls: m.cls || 'byok' }));
|
|
346
|
+
// The Pro class' aliases are a third disjoint id space — `claude --model`
|
|
347
|
+
// resolves them, the pooled catalog and the relay do not — so they are merged
|
|
348
|
+
// into the same list for the same reason byok's are: a class the picker omits
|
|
349
|
+
// is a class the user cannot switch to from the surface that exists to switch
|
|
350
|
+
// models. Each row carries its own `cls`, exactly as the other two do, which
|
|
351
|
+
// is what ENTER reads to move the session BEFORE the pin applies.
|
|
352
|
+
const pro = pickerEntries(await loadModelsFor(c, 'pro', live)).map((m) => ({ ...m, cls: 'pro' }));
|
|
353
|
+
|
|
354
|
+
// One row per id, and a row's OWN class tag wins over the group it arrived
|
|
355
|
+
// in. Both halves are corrections, not tidying:
|
|
356
|
+
//
|
|
357
|
+
// - The byok group is not all byok. `classScopedModels` prepends the pooled
|
|
358
|
+
// rows to it on purpose, so that a session sitting on byok can still see
|
|
359
|
+
// the way back to the pooled lane — and this function's per-group
|
|
360
|
+
// `.map(m => ({...m, cls}))` overwrote that tag, so the SAME Nexus row
|
|
361
|
+
// arrived twice (the pooled group's, and a copy tagged `byok`). ENTER
|
|
362
|
+
// reads `cls` to decide which class to switch to before the pin applies,
|
|
363
|
+
// so the copy was not merely a duplicate line: picking it pinned a pooled
|
|
364
|
+
// id while leaving the session on byok, where the relay parses a bare id
|
|
365
|
+
// as a provider name and 400s.
|
|
366
|
+
// - Deduping by id (first wins, so the class-scoped groups lead) is what
|
|
367
|
+
// keeps that copy off the screen, and what stops any other id being
|
|
368
|
+
// offered twice when two classes advertise it.
|
|
369
|
+
const out = [];
|
|
370
|
+
const seen = new Set();
|
|
371
|
+
for (const row of [...aegis, ...byok, ...pro]) {
|
|
372
|
+
const id = String((row && row.id) || '');
|
|
373
|
+
if (!id || seen.has(id)) continue;
|
|
374
|
+
seen.add(id);
|
|
375
|
+
out.push(row);
|
|
376
|
+
}
|
|
377
|
+
return out;
|
|
344
378
|
}
|
|
345
379
|
|
|
346
380
|
/**
|
|
@@ -988,6 +1022,12 @@ const COMMANDS = [
|
|
|
988
1022
|
c.transcript.length = 0;
|
|
989
1023
|
// Prune the session's history rows so /cost resets with /clear.
|
|
990
1024
|
pruneSessionHistory(c.sessionId);
|
|
1025
|
+
// Emptying the transcript is only half a clear: a transport that keeps
|
|
1026
|
+
// its own memory of this conversation (the Pro class's `claude` child
|
|
1027
|
+
// session) still holds the turns that were just erased, and would answer
|
|
1028
|
+
// from them on the next turn. Clearing the transcript our loop reads is
|
|
1029
|
+
// exactly the case where the other half must be dropped too.
|
|
1030
|
+
if (typeof c.clearConversationMemory === 'function') c.clearConversationMemory();
|
|
991
1031
|
note(c, 'Session cleared — transcript empty.');
|
|
992
1032
|
c.render();
|
|
993
1033
|
return true;
|
|
@@ -1400,7 +1440,10 @@ const COMMANDS = [
|
|
|
1400
1440
|
// Say why, and what unblocks it: an unreachable catalog is almost
|
|
1401
1441
|
// always a missing key or no network, and "no models advertised"
|
|
1402
1442
|
// read as "the platform has none" rather than "this client could not
|
|
1403
|
-
// ask".
|
|
1443
|
+
// ask". Reachable only when even Claude Code Pro's static alias rows
|
|
1444
|
+
// are absent — PRO_MODELS is a non-empty constant, so in practice
|
|
1445
|
+
// this is the full-outage fallback, not the common "no AEGIS key"
|
|
1446
|
+
// case that used to land here (see the branch just below).
|
|
1404
1447
|
note(c, c.state().online
|
|
1405
1448
|
? 'Could not read the model catalog (offline, or the server refused it) — /models retries.'
|
|
1406
1449
|
: // The key travels in the environment only (client/aegis.js reads
|
|
@@ -1410,6 +1453,16 @@ const COMMANDS = [
|
|
|
1410
1453
|
c.render();
|
|
1411
1454
|
return true;
|
|
1412
1455
|
}
|
|
1456
|
+
// AEGIS Cloud and byok both need a key this machine does not have:
|
|
1457
|
+
// almost always a missing AEGIS_API_KEY or no network. Claude Code Pro
|
|
1458
|
+
// needs neither (it is the subscription's own OAuth token, collected
|
|
1459
|
+
// when a pro row is picked), so its rows still show — the picker opens
|
|
1460
|
+
// with what IS available rather than blocking on what is not.
|
|
1461
|
+
if (!models.some((m) => m.cls === 'aegis' || m.cls === 'byok')) {
|
|
1462
|
+
note(c, c.state().online
|
|
1463
|
+
? 'Could not read the AEGIS Cloud catalog (offline, or the server refused it) — showing Claude Code Pro only; /models retries.'
|
|
1464
|
+
: `No AEGIS API key set, so the AEGIS Cloud catalog cannot be read (free key: ${signupUrl('model_blocked')}) — showing Claude Code Pro only.`);
|
|
1465
|
+
}
|
|
1413
1466
|
// A pin that is not in the catalog is not honoured — the pool answers
|
|
1414
1467
|
// from its own default with no error. Say so where the pin is visible
|
|
1415
1468
|
// rather than letting the reply look like the pinned model. On byok the
|
|
@@ -2155,6 +2208,11 @@ const COMMANDS = [
|
|
|
2155
2208
|
desc: 'Start a new session (clears the transcript, fresh session id)',
|
|
2156
2209
|
handler: async (c) => {
|
|
2157
2210
|
c.transcript.length = 0;
|
|
2211
|
+
// Release the conversation being left behind BEFORE the id changes — a
|
|
2212
|
+
// new session id is a new key, so the old entry would otherwise sit in
|
|
2213
|
+
// the engine's map for the life of the process, holding a `claude` child
|
|
2214
|
+
// session nobody can reach or clear again.
|
|
2215
|
+
if (typeof c.clearConversationMemory === 'function') c.clearConversationMemory();
|
|
2158
2216
|
const id = 'aegis-' + Math.random().toString(36).slice(2, 10);
|
|
2159
2217
|
c.sessionId = id;
|
|
2160
2218
|
c.ctx.sessionId = id;
|
|
@@ -2695,7 +2753,7 @@ const COMMANDS = [
|
|
|
2695
2753
|
},
|
|
2696
2754
|
},
|
|
2697
2755
|
{
|
|
2698
|
-
name: 'key', aliases: ['apikey', 'api-key'], args: ['value'], hint: '[<api_key>|status|clear]', category: 'auth',
|
|
2756
|
+
name: 'key', aliases: ['apikey', 'api-key'], args: ['value'], hint: '[<api_key>|status|clear|register]', category: 'auth',
|
|
2699
2757
|
desc: 'Save or show the AEGIS account key',
|
|
2700
2758
|
handler: async (c, args) => {
|
|
2701
2759
|
const arg = String(args.value || args._rest || '').trim();
|
|
@@ -2705,6 +2763,26 @@ const COMMANDS = [
|
|
|
2705
2763
|
c.render();
|
|
2706
2764
|
return true;
|
|
2707
2765
|
}
|
|
2766
|
+
if (lower === 'register') {
|
|
2767
|
+
const res = await c.registerAccount();
|
|
2768
|
+
if (res.alreadyKeyed) {
|
|
2769
|
+
// Registration is per machine fingerprint and the welcome trial is
|
|
2770
|
+
// granted once per machine, ever, so this branch can never produce a
|
|
2771
|
+
// new trial however many times it is run — and a user who wiped their
|
|
2772
|
+
// credential store lands here precisely expecting one. Say so, and
|
|
2773
|
+
// name the two paths that actually do something, rather than a
|
|
2774
|
+
// no-op notice that reads like a refusal for no reason.
|
|
2775
|
+
note(c, 'this machine already has an AEGIS key — /key status shows it. Re-registering cannot mint a new welcome trial: that is granted once per machine, ever. For a fresh trial, sign up at aegiscloud.org; to point this session at a different key, /key clear first.');
|
|
2776
|
+
} else if (res.key && res.ok) {
|
|
2777
|
+
done(c, 'AEGIS account key provisioned and saved');
|
|
2778
|
+
} else if (res.key) {
|
|
2779
|
+
note(c, 'the account was created but its key could not be saved — run /key <api_key> with the key from aegiscloud.org');
|
|
2780
|
+
} else {
|
|
2781
|
+
note(c, `could not register this machine: ${res.error ? res.error.message : 'the server returned no account key'}`);
|
|
2782
|
+
}
|
|
2783
|
+
c.render();
|
|
2784
|
+
return true;
|
|
2785
|
+
}
|
|
2708
2786
|
if (lower === 'clear' || lower === 'remove' || lower === 'rm') {
|
|
2709
2787
|
const res = c.forgetApiKey();
|
|
2710
2788
|
done(c, res.cleared ? `key removed from ${res.path}` : 'there was no saved key to remove');
|
package/vendor/cli/src/deps.js
CHANGED
|
@@ -58,6 +58,16 @@ const agentsPath = resolveShared(path.join('desktop', 'lib', 'local', 'agents.js
|
|
|
58
58
|
// running shell commands. Same file as the GUI, for the same reason engine.js
|
|
59
59
|
// is: two personas would drift, and only one of them would get fixed.
|
|
60
60
|
const promptPath = resolveShared(path.join('desktop', 'lib', 'local', 'prompt.js'));
|
|
61
|
+
// The Claude Code Pro class' transport — the user's own subscription, spent by
|
|
62
|
+
// spawning the `claude` CLI (desktop/lib/local/claude-pro.js). Shared with the
|
|
63
|
+
// desktop host rather than re-implemented, for the reason engine.js is: one
|
|
64
|
+
// module owns the child argv, the credential read and the stream-json parser,
|
|
65
|
+
// so the GUI and the terminal cannot disagree about what a Pro turn was allowed
|
|
66
|
+
// to do or which models the subscription can address. The CLI needs it for the
|
|
67
|
+
// picker's rows and the pin rules, which must read the SAME alias list the
|
|
68
|
+
// transport does — a second copy here is exactly the drift this file exists to
|
|
69
|
+
// prevent.
|
|
70
|
+
const claudeProPath = resolveShared(path.join('desktop', 'lib', 'local', 'claude-pro.js'));
|
|
61
71
|
// The npm update checker, shared with the desktop host: two package names, one
|
|
62
72
|
// implementation, so a fix to the check reaches both.
|
|
63
73
|
const updatePath = resolveShared(path.join('client', 'update.js'));
|
|
@@ -80,10 +90,19 @@ const { createLocalEngine, hostEnv } = require(enginePath);
|
|
|
80
90
|
const { createSettingsStore, isReservedNamespace } = require(settingsPath);
|
|
81
91
|
const { agentRoles, agentRoleLabel } = require(agentsPath);
|
|
82
92
|
const { buildSystemPrompt } = require(promptPath);
|
|
93
|
+
const claudePro = require(claudeProPath);
|
|
83
94
|
const updater = require(updatePath);
|
|
84
95
|
const queue = require(queuePath);
|
|
85
96
|
const autonomous = require(autonomousPath);
|
|
86
|
-
const { autoProvisionApiKey } = require(autoProvisionPath);
|
|
97
|
+
const { autoProvisionApiKey, provisionFailureText, trialOutcomeNote } = require(autoProvisionPath);
|
|
98
|
+
|
|
99
|
+
// The trial clause is shared so the CLI's two notice sites and the desktop
|
|
100
|
+
// cannot word the same outcome differently — but a staged/vendored copy of
|
|
101
|
+
// client/auto-provision.js can lag the canonical one (desktop/vendor and
|
|
102
|
+
// cli/vendor are generated, and a shipped tree may predate trialOutcomeNote).
|
|
103
|
+
// Missing it must degrade to silence, not to a TypeError on the very path that
|
|
104
|
+
// has just successfully provisioned a key.
|
|
105
|
+
const trialNote = typeof trialOutcomeNote === 'function' ? trialOutcomeNote : () => '';
|
|
87
106
|
|
|
88
107
|
module.exports = {
|
|
89
108
|
resolveShared,
|
|
@@ -102,10 +121,18 @@ module.exports = {
|
|
|
102
121
|
agentRoles,
|
|
103
122
|
agentRoleLabel,
|
|
104
123
|
buildSystemPrompt,
|
|
124
|
+
claudePro,
|
|
105
125
|
updater,
|
|
106
126
|
queue,
|
|
107
127
|
autonomous,
|
|
108
128
|
autoProvisionApiKey,
|
|
109
|
-
|
|
129
|
+
provisionFailureText,
|
|
130
|
+
// The shared welcome-trial clause ('' when there is nothing to say, and ''
|
|
131
|
+
// rather than a throw when a staged copy predates it). Exported so app.js
|
|
132
|
+
// does not re-implement the three-way outcome inline — the inline version
|
|
133
|
+
// only knew about `trialGranted`, which is why a re-registered machine got a
|
|
134
|
+
// first-install notice and no word about the trial it did not receive.
|
|
135
|
+
trialNote,
|
|
136
|
+
paths: { client: clientPath, tools: toolsPath, usage: usagePath, engine: enginePath, settings: settingsPath, agents: agentsPath, prompt: promptPath, claudePro: claudeProPath, update: updatePath, queue: queuePath, autonomous: autonomousPath, autoProvision: autoProvisionPath },
|
|
110
137
|
roots,
|
|
111
138
|
};
|
package/vendor/cli/src/engine.js
CHANGED
|
@@ -22,6 +22,9 @@
|
|
|
22
22
|
* turn, which is exactly what makes BYOK billable traffic instead of a
|
|
23
23
|
* free ride — and why the key must never be handed to a direct provider
|
|
24
24
|
* call from here.
|
|
25
|
+
* pro the user's own Claude Code Pro/Max subscription, spent by spawning
|
|
26
|
+
* the `claude` CLI. Unchanged from the tunnel repo's claude-pro.js: no
|
|
27
|
+
* relay, no AEGIS key, no vendor key, and therefore nothing to bill.
|
|
25
28
|
*
|
|
26
29
|
* Ollama stays a stub that throws if the engine ever calls it: it needs an
|
|
27
30
|
* endpoint surface this host does not offer, and a stub is proof that a code
|
|
@@ -51,8 +54,11 @@ const VERSION = require('../package.json').version;
|
|
|
51
54
|
* local — a model on hardware you own, over loopback. Bills nobody because
|
|
52
55
|
* there is no vendor; refused outright if the base URL is not local
|
|
53
56
|
* (desktop/lib/local/local.js remoteRefusal, fail-closed).
|
|
57
|
+
* pro — your own Claude Code Pro/Max subscription, spent by spawning the
|
|
58
|
+
* `claude` CLI (desktop/lib/local/claude-pro.js). Bills nobody:
|
|
59
|
+
* no relay is involved and no AEGIS endpoint is called.
|
|
54
60
|
*/
|
|
55
|
-
const HOST_CLASSES = Object.freeze(['aegis', 'byok', 'local']);
|
|
61
|
+
const HOST_CLASSES = Object.freeze(['aegis', 'byok', 'local', 'pro']);
|
|
56
62
|
|
|
57
63
|
/** The class a turn runs on when nothing else is said. */
|
|
58
64
|
const DEFAULT_CLASS = 'aegis';
|
|
@@ -62,6 +68,7 @@ const CLASS_LABELS = Object.freeze({
|
|
|
62
68
|
aegis: 'AEGIS Cloud (pooled)',
|
|
63
69
|
byok: 'Bring your own key (relayed, billed)',
|
|
64
70
|
local: 'Local model (your own machine, free)',
|
|
71
|
+
pro: 'Claude Code Pro (your own subscription)',
|
|
65
72
|
});
|
|
66
73
|
|
|
67
74
|
/**
|