aegiscode 7.0.10 → 7.0.12
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/bin/aegiscode.js +29 -0
- package/package.json +1 -1
- package/src/app.js +335 -24
- package/src/autonomous.js +19 -2
- package/src/chatflow.js +77 -4
- package/src/commands.js +175 -5
- package/src/config.js +21 -0
- package/src/connect.js +351 -0
- package/src/deps.js +97 -1
- package/src/engine.js +98 -8
- package/src/fingerprint.js +46 -16
- package/src/limits.js +1 -1
- package/src/overlays.js +54 -0
- package/src/provenance.lock.json +3 -3
- package/src/screens.js +14 -1
- package/vendor/client/credentials.js +9 -2
- package/vendor/client/google-signin.js +127 -0
- package/vendor/client/record-vault.js +431 -113
- package/vendor/client/update.js +266 -0
- package/vendor/desktop/lib/local/claude-pro.js +134 -11
- package/vendor/desktop/lib/local/engine.js +47 -25
- package/vendor/desktop/lib/settings.js +65 -24
package/src/chatflow.js
CHANGED
|
@@ -284,6 +284,9 @@ const PRO_ALIAS_KEYWORDS = Object.freeze(['opus', 'haiku', 'sonnet']);
|
|
|
284
284
|
* @param {boolean} o.hasStored the byok provider store already holds an
|
|
285
285
|
* anthropic key (desktop Provider settings / `/byok-key anthropic`)
|
|
286
286
|
* @param {boolean} o.proLoggedIn this machine is signed into Claude Code Pro
|
|
287
|
+
* @param {boolean} o.proEnabled the `pro` class is enabled for this install
|
|
288
|
+
* (`/class pro on`); anything but `true` leaves the byok row untouched, so a
|
|
289
|
+
* disabled subscription can never be reached by this reroute
|
|
287
290
|
* @param {Array<{id:string,label:string,note:string}>} o.proModels
|
|
288
291
|
* `claudePro.PRO_MODELS`, injected rather than required here
|
|
289
292
|
* @returns {{row:object, message:string|null}} the row to actually pin (the
|
|
@@ -299,6 +302,14 @@ function overrideAnthropicByokWithPro(chosen, o = {}) {
|
|
|
299
302
|
}
|
|
300
303
|
if (!o.needsKey) return { row: chosen, message: null }; // a real console key is already usable
|
|
301
304
|
if (!o.proLoggedIn) return { row: chosen, message: null }; // no subscription either — the normal prompt stands
|
|
305
|
+
// The `pro` class ships disabled (config.js `proEnabled`, `/class pro on`).
|
|
306
|
+
// This override silently MOVES a byok pick onto the subscription, so it must
|
|
307
|
+
// obey the same gate the picker and `/class` do — otherwise the one path a
|
|
308
|
+
// user never asked for is the path that still routes turns onto a
|
|
309
|
+
// subscription whose Claude Code access may be revoked, failing the turn with
|
|
310
|
+
// `oauth_org_not_allowed` after the pick already looked successful. Absent
|
|
311
|
+
// means "not stated" and is treated as disabled: fail closed.
|
|
312
|
+
if (o.proEnabled !== true) return { row: chosen, message: null };
|
|
302
313
|
const modelPart = id.slice(colon + 1).toLowerCase();
|
|
303
314
|
const proModels = Array.isArray(o.proModels) && o.proModels.length ? o.proModels : [{ id: 'default', label: 'Default', note: '' }];
|
|
304
315
|
const aliasId = PRO_ALIAS_KEYWORDS.find((kw) => modelPart.includes(kw)) || 'default';
|
|
@@ -1271,6 +1282,14 @@ async function runSession(host) {
|
|
|
1271
1282
|
overlay.items || [], overlay.sel || 0, cols, overlay.current || ctx.modelClass,
|
|
1272
1283
|
typeof host.classLabel === 'function' ? host.classLabel : null
|
|
1273
1284
|
);
|
|
1285
|
+
} else if (overlay.type === 'provider') {
|
|
1286
|
+
// The BYOK provider picker (/byok-set with no argument, /byok-key with
|
|
1287
|
+
// no argument). Same overlay machinery as /model and /class — arrow or
|
|
1288
|
+
// Tab to move, Enter to pick — so choosing WHICH vendor a key belongs to
|
|
1289
|
+
// is a highlight rather than a provider id retyped from memory.
|
|
1290
|
+
ol = overlays.renderProviderPicker(
|
|
1291
|
+
overlay.items || [], overlay.sel || 0, cols, overlay.current, overlay.hint
|
|
1292
|
+
);
|
|
1274
1293
|
} else if (overlay.type === 'resume') {
|
|
1275
1294
|
ol = overlays.renderResumeList(overlay.items || [], overlay.sel || 0, cols, termRows);
|
|
1276
1295
|
} else if (overlay.type === 'shortcuts') {
|
|
@@ -2028,7 +2047,7 @@ async function runSession(host) {
|
|
|
2028
2047
|
(c) => c.aliases || []
|
|
2029
2048
|
).length;
|
|
2030
2049
|
}
|
|
2031
|
-
if (overlay.type === 'model' || overlay.type === 'resume' || overlay.type === 'class') return (overlay.items || []).length;
|
|
2050
|
+
if (overlay.type === 'model' || overlay.type === 'resume' || overlay.type === 'class' || overlay.type === 'provider') return (overlay.items || []).length;
|
|
2032
2051
|
if (overlay.type === 'effort') return overlays.EFFORT_VALUES.length;
|
|
2033
2052
|
return 0;
|
|
2034
2053
|
};
|
|
@@ -2163,6 +2182,15 @@ async function runSession(host) {
|
|
|
2163
2182
|
const { row, message } = overrideAnthropicByokWithPro(chosen, {
|
|
2164
2183
|
needsKey: !!(plan && plan.needed),
|
|
2165
2184
|
proLoggedIn: models.claudeProLoggedIn(),
|
|
2185
|
+
// The same gate `/class pro on` writes: a disabled subscription is not
|
|
2186
|
+
// reachable by this reroute either.
|
|
2187
|
+
proEnabled: (() => {
|
|
2188
|
+
try {
|
|
2189
|
+
return loadConfig().proEnabled === true;
|
|
2190
|
+
} catch {
|
|
2191
|
+
return false;
|
|
2192
|
+
}
|
|
2193
|
+
})(),
|
|
2166
2194
|
proModels: claudePro.PRO_MODELS,
|
|
2167
2195
|
});
|
|
2168
2196
|
chosen = row;
|
|
@@ -2239,14 +2267,14 @@ async function runSession(host) {
|
|
|
2239
2267
|
}
|
|
2240
2268
|
return;
|
|
2241
2269
|
}
|
|
2242
|
-
if (key.name === KEY.TAB && (type === 'model' || type === 'effort' || type === 'class')) {
|
|
2270
|
+
if (key.name === KEY.TAB && (type === 'model' || type === 'effort' || type === 'class' || type === 'provider')) {
|
|
2243
2271
|
// Reference parity (aegiscodex-dev/src/main.js's model overlay cycles on
|
|
2244
2272
|
// Tab). It is also the one way to walk either picker that survives a link
|
|
2245
2273
|
// where arrow escapes are eaten, since Tab is a single control byte.
|
|
2246
2274
|
// Both lists are addressed the one way each of them can be: the catalogue
|
|
2247
2275
|
// lives in `overlay.items`, while the rungs are the picker's own table —
|
|
2248
2276
|
// the same table Enter and shift+enter resolve through.
|
|
2249
|
-
const n = type === 'model' || type === 'class'
|
|
2277
|
+
const n = type === 'model' || type === 'class' || type === 'provider'
|
|
2250
2278
|
? (overlay.items || []).length
|
|
2251
2279
|
: overlays.EFFORT_VALUES.length;
|
|
2252
2280
|
if (n) {
|
|
@@ -2292,6 +2320,21 @@ async function runSession(host) {
|
|
|
2292
2320
|
render();
|
|
2293
2321
|
return;
|
|
2294
2322
|
}
|
|
2323
|
+
if (type === 'provider') {
|
|
2324
|
+
// The BYOK provider pick: run the command that opened this picker with
|
|
2325
|
+
// the highlighted provider's own catalog id, so the id that reaches the
|
|
2326
|
+
// store is the id the relay is asked for — never a hand-retyped alias
|
|
2327
|
+
// (the `findByokProvider` loose match this replaces could land on the
|
|
2328
|
+
// wrong vendor, which is the failure the whole path exists to prevent).
|
|
2329
|
+
// `overlay.command` names the command to re-enter: /byok-key stores on
|
|
2330
|
+
// this machine, /byok-set stores on the account.
|
|
2331
|
+
const chosen = (overlay.items || [])[overlay.sel || 0];
|
|
2332
|
+
const cmd = overlay.command || 'byok-key';
|
|
2333
|
+
overlay = null;
|
|
2334
|
+
render();
|
|
2335
|
+
if (chosen && chosen.id) await dispatch(`/${cmd} ${chosen.id}`);
|
|
2336
|
+
return;
|
|
2337
|
+
}
|
|
2295
2338
|
if (type === 'resume') {
|
|
2296
2339
|
const chosen = (overlay.items || [])[overlay.sel || 0];
|
|
2297
2340
|
overlay = null;
|
|
@@ -2330,6 +2373,21 @@ async function runSession(host) {
|
|
|
2330
2373
|
render();
|
|
2331
2374
|
return;
|
|
2332
2375
|
}
|
|
2376
|
+
if (type === 'provider') {
|
|
2377
|
+
// The BYOK provider pick: run the command that opened this picker with
|
|
2378
|
+
// the highlighted provider's own catalog id, so the id that reaches the
|
|
2379
|
+
// store is the id the relay is asked for — never a hand-retyped alias
|
|
2380
|
+
// (the `findByokProvider` loose match this replaces could land on the
|
|
2381
|
+
// wrong vendor, which is the failure the whole path exists to prevent).
|
|
2382
|
+
// `overlay.command` names the command to re-enter: /byok-key stores on
|
|
2383
|
+
// this machine, /byok-set stores on the account.
|
|
2384
|
+
const chosen = (overlay.items || [])[overlay.sel || 0];
|
|
2385
|
+
const cmd = overlay.command || 'byok-key';
|
|
2386
|
+
overlay = null;
|
|
2387
|
+
render();
|
|
2388
|
+
if (chosen && chosen.id) await dispatch(`/${cmd} ${chosen.id}`);
|
|
2389
|
+
return;
|
|
2390
|
+
}
|
|
2333
2391
|
if (type === 'effort') {
|
|
2334
2392
|
applyEffortRow(overlay.sel || 0);
|
|
2335
2393
|
return;
|
|
@@ -2366,6 +2424,21 @@ async function runSession(host) {
|
|
|
2366
2424
|
render();
|
|
2367
2425
|
return;
|
|
2368
2426
|
}
|
|
2427
|
+
if (type === 'provider') {
|
|
2428
|
+
// The BYOK provider pick: run the command that opened this picker with
|
|
2429
|
+
// the highlighted provider's own catalog id, so the id that reaches the
|
|
2430
|
+
// store is the id the relay is asked for — never a hand-retyped alias
|
|
2431
|
+
// (the `findByokProvider` loose match this replaces could land on the
|
|
2432
|
+
// wrong vendor, which is the failure the whole path exists to prevent).
|
|
2433
|
+
// `overlay.command` names the command to re-enter: /byok-key stores on
|
|
2434
|
+
// this machine, /byok-set stores on the account.
|
|
2435
|
+
const chosen = (overlay.items || [])[overlay.sel || 0];
|
|
2436
|
+
const cmd = overlay.command || 'byok-key';
|
|
2437
|
+
overlay = null;
|
|
2438
|
+
render();
|
|
2439
|
+
if (chosen && chosen.id) await dispatch(`/${cmd} ${chosen.id}`);
|
|
2440
|
+
return;
|
|
2441
|
+
}
|
|
2369
2442
|
if (type === 'effort') {
|
|
2370
2443
|
applyEffortRow(overlay.sel || 0);
|
|
2371
2444
|
return;
|
|
@@ -2414,7 +2487,7 @@ async function runSession(host) {
|
|
|
2414
2487
|
}
|
|
2415
2488
|
return;
|
|
2416
2489
|
}
|
|
2417
|
-
if (type === 'effort' || type === 'resume' || type === 'class') {
|
|
2490
|
+
if (type === 'effort' || type === 'resume' || type === 'class' || type === 'provider') {
|
|
2418
2491
|
// Bounded by the same row count every other mover is bounded by. A row
|
|
2419
2492
|
// number past the end used to be accepted unseen (`sel = idx - 1` with
|
|
2420
2493
|
// no upper clamp), so '9' in /effort parked the highlight off the list
|
package/src/commands.js
CHANGED
|
@@ -3004,7 +3004,11 @@ const COMMANDS = [
|
|
|
3004
3004
|
[span(C.gray, '─'.repeat(34))],
|
|
3005
3005
|
[
|
|
3006
3006
|
span(set ? C.green : C.gray, ` ${set} of ${providers.length} providers set`),
|
|
3007
|
-
|
|
3007
|
+
// Name the PICKER first: the id is the one thing this screen was
|
|
3008
|
+
// asking the reader to copy by eye, and `/byok-list` removes that
|
|
3009
|
+
// step. The typed form stays beside it for scripts and for anyone who
|
|
3010
|
+
// already knows the id.
|
|
3011
|
+
span(C.gray, ' — /byok-list picks one, or /byok-key <provider>'),
|
|
3008
3012
|
],
|
|
3009
3013
|
'',
|
|
3010
3014
|
...byokProviderLines(providers),
|
|
@@ -3077,13 +3081,48 @@ const COMMANDS = [
|
|
|
3077
3081
|
build: (arg) => ({ provider: String(arg || '').trim() }),
|
|
3078
3082
|
},
|
|
3079
3083
|
{
|
|
3080
|
-
name: 'class', args: ['class'], hint: '[aegis|byok]', category: 'model',
|
|
3081
|
-
desc: 'Show or switch which class turns run on
|
|
3084
|
+
name: 'class', args: ['class', 'mode'], hint: '[aegis|byok|local|pro [on|off]]', category: 'model',
|
|
3085
|
+
desc: 'Show or switch which class turns run on; pro (your Claude subscription) needs a one-time "on"',
|
|
3082
3086
|
handler: async (c, a) => {
|
|
3083
3087
|
const args = a || {};
|
|
3084
3088
|
const cur = (c.ctx && c.ctx.modelClass) || 'aegis';
|
|
3085
3089
|
const label = (id) => (c.classLabel ? c.classLabel(id) : id);
|
|
3086
3090
|
const want = String(args.class || '').trim().toLowerCase();
|
|
3091
|
+
// `/class pro on|off` — the one-time opt-in for the subscription class.
|
|
3092
|
+
//
|
|
3093
|
+
// `pro` spends a real Claude Code Pro/Max subscription by spawning the
|
|
3094
|
+
// `claude` CLI, and an account whose organization has disabled Claude
|
|
3095
|
+
// Code answers every such turn with `oauth_org_not_allowed`, which this
|
|
3096
|
+
// repo cannot fix. So `pro` ships DISABLED (config.js `proEnabled: false`)
|
|
3097
|
+
// and this is the only way in: an explicit, deliberate word from the
|
|
3098
|
+
// user. Written through saveConfig so it survives a restart — an opt-in
|
|
3099
|
+
// that reverted on the next launch would put the class back out of reach
|
|
3100
|
+
// with no way to tell why.
|
|
3101
|
+
if (want === 'pro' && args.mode) {
|
|
3102
|
+
const mode = String(args.mode).trim().toLowerCase();
|
|
3103
|
+
if (mode !== 'on' && mode !== 'off') {
|
|
3104
|
+
c.push({ role: 'error', text: `usage: /class pro [on|off] — got "${args.mode}"` });
|
|
3105
|
+
return true;
|
|
3106
|
+
}
|
|
3107
|
+
const on = mode === 'on';
|
|
3108
|
+
c.saveConfig({ proEnabled: on });
|
|
3109
|
+
c.push({
|
|
3110
|
+
role: on ? 'done' : 'note',
|
|
3111
|
+
text: on
|
|
3112
|
+
? 'pro class enabled — /class pro switches to your Claude Code subscription. ' +
|
|
3113
|
+
'It runs only if that subscription has Claude Code access.'
|
|
3114
|
+
: 'pro class disabled — it is no longer offered by /class or the model picker.',
|
|
3115
|
+
});
|
|
3116
|
+
// Turning it off while sitting on it would leave the session pointing
|
|
3117
|
+
// at a class that can no longer run: fall back to the default class
|
|
3118
|
+
// through the same path `/class aegis` takes, so the pin rules and the
|
|
3119
|
+
// stored config are updated rather than only the panel.
|
|
3120
|
+
if (!on && cur === 'pro') {
|
|
3121
|
+
const back = c.switchClass('aegis');
|
|
3122
|
+
if (back.ok) c.push({ role: 'note', text: `class: ${back.class} — ${label(back.class)}` });
|
|
3123
|
+
}
|
|
3124
|
+
return true;
|
|
3125
|
+
}
|
|
3087
3126
|
if (!want) {
|
|
3088
3127
|
// Awaited: the engine's listClasses() is async (it probes for a local
|
|
3089
3128
|
// Ollama before answering), and a context that offers no class surface
|
|
@@ -3176,6 +3215,45 @@ const COMMANDS = [
|
|
|
3176
3215
|
return true;
|
|
3177
3216
|
},
|
|
3178
3217
|
},
|
|
3218
|
+
{
|
|
3219
|
+
// `/byok-list` — pick a provider from the catalog and store its key on THIS
|
|
3220
|
+
// machine, the same route `/byok-key` takes once a provider is named. The
|
|
3221
|
+
// picker is the point: the provider id was the one thing this flow asked
|
|
3222
|
+
// the user to recall and retype, and a retyped or alias-matched id either
|
|
3223
|
+
// matched nothing or matched another vendor. Arrow or Tab moves the
|
|
3224
|
+
// highlight, Enter picks, and the id dispatched is the catalog's own — so
|
|
3225
|
+
// the key lands under the id the relay will be asked for, and that
|
|
3226
|
+
// provider's models then show up in `/model`.
|
|
3227
|
+
name: 'byok-list', aliases: ['byok-pick'], hint: '', category: 'auth',
|
|
3228
|
+
desc: 'Pick a provider to set a key for, then its models appear in /model',
|
|
3229
|
+
handler: async (c) => {
|
|
3230
|
+
const providers = await byokCatalog(c.client);
|
|
3231
|
+
if (!providers || !providers.length) {
|
|
3232
|
+
c.push({
|
|
3233
|
+
role: 'error',
|
|
3234
|
+
text: 'Could not read the provider catalog (offline, or no AEGIS key) — /byok lists what is known.',
|
|
3235
|
+
});
|
|
3236
|
+
return true;
|
|
3237
|
+
}
|
|
3238
|
+
if (typeof c.openOverlay !== 'function') {
|
|
3239
|
+
// No interactive host: fall back to the printable list rather than a
|
|
3240
|
+
// picker nothing can draw.
|
|
3241
|
+
c.push({ role: 'note', text: '/byok-key <provider> — /byok lists the providers.' });
|
|
3242
|
+
return true;
|
|
3243
|
+
}
|
|
3244
|
+
const cur = (providers.find((p) => p.configured) || {}).id || null;
|
|
3245
|
+
const sel = Math.max(0, providers.findIndex((p) => p.configured));
|
|
3246
|
+
c.openOverlay({
|
|
3247
|
+
type: 'provider',
|
|
3248
|
+
command: 'byok-key',
|
|
3249
|
+
items: providers,
|
|
3250
|
+
sel,
|
|
3251
|
+
current: cur,
|
|
3252
|
+
hint: '↑↓ or tab move · enter picks · the key is stored on this machine',
|
|
3253
|
+
});
|
|
3254
|
+
return true;
|
|
3255
|
+
},
|
|
3256
|
+
},
|
|
3179
3257
|
{
|
|
3180
3258
|
name: 'byok-key', args: ['provider'], hint: '<provider> [key]', category: 'auth',
|
|
3181
3259
|
desc: 'Save YOUR provider key on THIS MACHINE — the key the byok class sends',
|
|
@@ -3183,7 +3261,33 @@ const COMMANDS = [
|
|
|
3183
3261
|
const args = a || {};
|
|
3184
3262
|
const typed = String(args.provider || '').trim().toLowerCase();
|
|
3185
3263
|
if (!typed) {
|
|
3186
|
-
|
|
3264
|
+
// No provider typed: open the picker instead of printing a usage line.
|
|
3265
|
+
// The id was the one thing this flow asked the user to RECALL, and a
|
|
3266
|
+
// mistyped or alias-matched id either matched nothing or — worse —
|
|
3267
|
+
// matched another vendor's row. Arrow or Tab moves, Enter picks, and
|
|
3268
|
+
// the id Enter dispatches is the catalog's own, so the key lands under
|
|
3269
|
+
// the id the relay will actually be asked for.
|
|
3270
|
+
const providers = await byokCatalog(c.client);
|
|
3271
|
+
if (!providers || !providers.length) {
|
|
3272
|
+
c.push({ role: 'error', text: 'Usage: /byok-key <provider> — /byok lists the providers.' });
|
|
3273
|
+
return true;
|
|
3274
|
+
}
|
|
3275
|
+
if (typeof c.openOverlay !== 'function') {
|
|
3276
|
+
// No interactive host (a piped run): the old usage line, which at
|
|
3277
|
+
// least names the command that lists the ids.
|
|
3278
|
+
c.push({ role: 'error', text: 'Usage: /byok-key <provider> — /byok lists the providers.' });
|
|
3279
|
+
return true;
|
|
3280
|
+
}
|
|
3281
|
+
const cur = (providers.find((p) => p.configured) || {}).id || null;
|
|
3282
|
+
const sel = Math.max(0, providers.findIndex((p) => p.configured));
|
|
3283
|
+
c.openOverlay({
|
|
3284
|
+
type: 'provider',
|
|
3285
|
+
command: 'byok-key',
|
|
3286
|
+
items: providers,
|
|
3287
|
+
sel,
|
|
3288
|
+
current: cur,
|
|
3289
|
+
hint: '↑↓ or tab move · enter picks · the key is stored on this machine',
|
|
3290
|
+
});
|
|
3187
3291
|
return true;
|
|
3188
3292
|
}
|
|
3189
3293
|
const store = c.settings && c.settings();
|
|
@@ -3237,9 +3341,75 @@ const COMMANDS = [
|
|
|
3237
3341
|
c.push({ role: 'note', text: `heads up: ${id} keys normally start with "${p.key_prefix}" — saved anyway.` });
|
|
3238
3342
|
}
|
|
3239
3343
|
store.set(c.byokNamespace(id), { key });
|
|
3344
|
+
|
|
3345
|
+
// MIRROR IT INTO ~/.aegiscode/.env — the file every host (this CLI, the
|
|
3346
|
+
// desktop, the MCP plugin) loads at start-up, and the one the shared
|
|
3347
|
+
// engine's `providerKeyFromEnv` reads. The settings store alone made the
|
|
3348
|
+
// key a private fact of this process's data dir: the next launch of the
|
|
3349
|
+
// SAME host found it, but nothing else did, and the byok model list is
|
|
3350
|
+
// built from a key the engine resolves through both. `/model-add` writes
|
|
3351
|
+
// both stores for this exact reason (see its `setEnvValue` call), and a
|
|
3352
|
+
// key entered here must not be the one row that behaves differently.
|
|
3353
|
+
// Best-effort: the store row above is the row of record, so a failure to
|
|
3354
|
+
// write the file is reported and never undoes the save.
|
|
3355
|
+
let envWritten = '';
|
|
3356
|
+
try {
|
|
3357
|
+
const { envVarFor, setEnvValue } = require(resolveShared(path.join('client', 'env-file.js')));
|
|
3358
|
+
const name = envVarFor(id);
|
|
3359
|
+
if (name) {
|
|
3360
|
+
const res = setEnvValue(name, key);
|
|
3361
|
+
if (res.ok) envWritten = name;
|
|
3362
|
+
else c.push({ role: 'note', text: `heads up: could not write ${name} to ~/.aegiscode/.env (${res.error}).` });
|
|
3363
|
+
}
|
|
3364
|
+
} catch {
|
|
3365
|
+
/* the settings-store save is the row of record; this mirror is best-effort */
|
|
3366
|
+
}
|
|
3367
|
+
|
|
3368
|
+
// Then make the models it unlocks VISIBLE where the user asked for them:
|
|
3369
|
+
// the byok model list is cached for five minutes (app.js MODEL_CACHE_MS),
|
|
3370
|
+
// so without this the key is saved and `/model` keeps offering the list
|
|
3371
|
+
// computed before it existed — the "I set a key and nothing new appeared"
|
|
3372
|
+
// report. The refresh is forced, and its rows are what get pinned below.
|
|
3373
|
+
let rows = [];
|
|
3374
|
+
if (typeof c.refreshByokModels === 'function') {
|
|
3375
|
+
try { rows = (await c.refreshByokModels()) || []; } catch { rows = []; }
|
|
3376
|
+
}
|
|
3377
|
+
if (!rows.length && typeof c.listModelsFor === 'function') {
|
|
3378
|
+
// Hosts that expose the class surface but not the cache invalidation
|
|
3379
|
+
// (an embedding) still get an answer: ask for the byok class directly.
|
|
3380
|
+
try {
|
|
3381
|
+
rows = ((await c.listModelsFor('byok')) || []).filter((m) => !m.cls || m.cls === 'byok');
|
|
3382
|
+
} catch { rows = []; }
|
|
3383
|
+
}
|
|
3384
|
+
const mine = rows.filter((m) => m && (m.provider === id || String(m.id || '').startsWith(`${id}:`)));
|
|
3385
|
+
|
|
3386
|
+
// Move onto the byok class — the key just saved can only be spent there,
|
|
3387
|
+
// and a session sitting on `aegis` would show these rows in /model and
|
|
3388
|
+
// then send the pinned `provider:model` id to the pool. Before the pin,
|
|
3389
|
+
// so switchClass's own pin rules run on the id we are about to store.
|
|
3390
|
+
let onByok = ((c.ctx && c.ctx.modelClass) || '') === 'byok';
|
|
3391
|
+
if (!onByok && typeof c.switchClass === 'function') {
|
|
3392
|
+
const sw = c.switchClass('byok');
|
|
3393
|
+
if (sw && sw.ok) {
|
|
3394
|
+
onByok = true;
|
|
3395
|
+
c.push({ role: 'note', text: `class: byok — ${c.classLabel ? c.classLabel('byok') : 'your own key'}` });
|
|
3396
|
+
}
|
|
3397
|
+
}
|
|
3398
|
+
|
|
3399
|
+
// Pin it and PERSIST it, which is what makes the pick survive a restart:
|
|
3400
|
+
// app.js's restorePrefs() reads config.model/modelClass back. Only on
|
|
3401
|
+
// success — this whole block is the success path, after the key landed.
|
|
3402
|
+
const pickId = mine.length ? String(mine[0].id) : '';
|
|
3403
|
+
if (pickId && c.ctx) {
|
|
3404
|
+
c.ctx.model = pickId;
|
|
3405
|
+
c.saveConfig({ model: pickId, currentModelId: pickId, ...(onByok ? { modelClass: 'byok' } : {}) });
|
|
3406
|
+
}
|
|
3407
|
+
|
|
3240
3408
|
c.push({
|
|
3241
3409
|
role: 'done',
|
|
3242
|
-
text:
|
|
3410
|
+
text: pickId
|
|
3411
|
+
? `saved a ${id} key on this machine${envWritten ? ` (${envWritten} in ~/.aegiscode/.env, so it is there next time)` : ''} — model ${pickId} pinned, /model lists the rest.`
|
|
3412
|
+
: `saved a ${id} key on this machine${envWritten ? ` (${envWritten} in ~/.aegiscode/.env, so it is there next time)` : ''} — /models lists its models, /class byok runs on it.`,
|
|
3243
3413
|
});
|
|
3244
3414
|
return true;
|
|
3245
3415
|
},
|
package/src/config.js
CHANGED
|
@@ -70,6 +70,13 @@ const DEFAULT_CONFIG = {
|
|
|
70
70
|
// src/update.js). Persisted so a launch reports what the LAST run learned
|
|
71
71
|
// and never waits on the network to draw its own welcome box.
|
|
72
72
|
updateCheck: null,
|
|
73
|
+
// Cached `{ checkedAt, behind, required, latest, downloadUrl }` from the
|
|
74
|
+
// once-a-day SERVER check (/api/v1/version, see src/update.js). Separate
|
|
75
|
+
// from `updateCheck` because it answers a different question: the registry
|
|
76
|
+
// says what was published, the server says what it will still serve. A
|
|
77
|
+
// build can be merely superseded (a suggestion) or refused (an outage), and
|
|
78
|
+
// collapsing the two would report the wrong urgency.
|
|
79
|
+
updateCheckServer: null,
|
|
73
80
|
// No pinned model. This host runs on AEGIS Cloud, whose pinnable ids are the
|
|
74
81
|
// server's (`/models`) — a client-side default here would have to name one,
|
|
75
82
|
// and the one it named (`sonnet`) is not advertised by the platform at all:
|
|
@@ -89,6 +96,20 @@ const DEFAULT_CONFIG = {
|
|
|
89
96
|
// back to. Defaulted to the pooled class, which is the only one an account
|
|
90
97
|
// key alone can run.
|
|
91
98
|
modelClass: 'aegis',
|
|
99
|
+
// Whether the `pro` class may be selected at all. OFF by default, and it
|
|
100
|
+
// takes a deliberate `/class pro on` to turn it on — this is a one-time
|
|
101
|
+
// opt-in, not a preference that drifts back.
|
|
102
|
+
//
|
|
103
|
+
// The reason is the failure this flag exists to prevent: `pro` spends a real
|
|
104
|
+
// Claude Code Pro/Max subscription by spawning the `claude` CLI, and an
|
|
105
|
+
// account whose organization has disabled Claude Code access answers every
|
|
106
|
+
// such turn with `oauth_org_not_allowed` ("Your organization has disabled
|
|
107
|
+
// Claude subscription access"). Nothing in this repo can re-enable that, so
|
|
108
|
+
// a default of "offered" meant the Class picker, the `/model` list and the
|
|
109
|
+
// anthropic→pro override all steered users into turns that could only fail.
|
|
110
|
+
// Off by default means a machine that never asked for the subscription route
|
|
111
|
+
// never lands on it; `/class pro on` is the single, explicit way in.
|
|
112
|
+
proEnabled: false,
|
|
92
113
|
// The full model table (seeded from src/models.js MODELS on first
|
|
93
114
|
// read by pickerModels()). 'currentModelId' mirrors `model` under the
|
|
94
115
|
// aegiscode- name so /model add/remove/switch stay compatible both ways.
|