aegiscode 6.7.8 → 6.8.0

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 CHANGED
@@ -90,9 +90,36 @@ older AEGIS CLI left in `~/.aegiscode/config.json` is picked up and copied into
90
90
  the 0600 store automatically — `/cloud status` says so if the plaintext copy is
91
91
  still there.
92
92
 
93
- That one file is shared: the MCP plugin and AEGIS Desktop read the same store, so
94
- signing in here signs you in everywhere (see [One memory, shared with AEGIS
95
- Desktop](#one-memory-shared-with-aegis-desktop)).
93
+ ## One file for every key
94
+
95
+ `~/.aegiscode/.env` is read into the environment once at startup by the CLI, the
96
+ desktop app and the MCP server. It is the shortest way to configure the account
97
+ key *and* every BYOK provider at the same time:
98
+
99
+ ```bash
100
+ # ~/.aegiscode/.env
101
+ AEGIS_API_KEY=aegis_...
102
+ ANTHROPIC_API_KEY=sk-ant-...
103
+ OPENAI_API_KEY=sk-...
104
+ DEEPSEEK_API_KEY=sk-...
105
+ ```
106
+
107
+ That file alone is enough — no `login`, no `/byok-key <provider>` prompt per
108
+ provider. Both resolution paths already read these names out of the environment;
109
+ the file is just what fills it. `AEGIS_API_KEY` is entry one in the credential
110
+ order below, and a BYOK provider resolves `<PROVIDER>_API_KEY` (upper snake case,
111
+ with a short alias table for the ids that would spell it differently — `google`
112
+ and `gemini` → `GEMINI_API_KEY`, `xai` → `XAI_API_KEY`, `huggingface` →
113
+ `HF_TOKEN`).
114
+
115
+ Two rules it obeys: a variable **already exported in the launching shell always
116
+ wins**, so a stale file can never shadow `AEGIS_API_KEY=… aegiscode` in CI; and
117
+ the loader only ever reads. If the file is group- or world-readable you are told,
118
+ not silently fixed — the 0600 store stays the only secret this repo writes.
119
+
120
+ That one file is shared: the MCP plugin and AEGIS Desktop read the same store and
121
+ the same `.env`, so signing in here signs you in everywhere (see [One memory,
122
+ shared with AEGIS Desktop](#one-memory-shared-with-aegis-desktop)).
96
123
 
97
124
  ## Launch options
98
125
 
@@ -224,7 +251,6 @@ Three layers, from broadest to narrowest. You only need the first one.
224
251
  /class # show the picker
225
252
  /class aegis # pooled AEGIS Cloud (the default)
226
253
  /class byok # your own provider key, relayed by AEGIS
227
- /class custom # a LOCAL endpoint of yours (Ollama, llama.cpp, a LAN box), called directly
228
254
  ```
229
255
 
230
256
  A class is *whose credential pays and who talks to the vendor*, not a model.
@@ -236,7 +262,6 @@ restart.
236
262
  |---|---|---|
237
263
  | `aegis` *(default)* | the AEGIS pool — one id, `nexus-brain` (alias `aegis-brain`), auto-routed server-side across whichever providers are live | your AEGIS account balance |
238
264
  | `byok` | your provider key, relayed via `POST /api/v1/byok/chat/completions` | your provider direct, **plus** a small AEGIS handling fee on your account |
239
- | `custom` | a **local** base URL (localhost, a LAN address, `*.local`, a dotless host name) called **directly** by aegiscode — nothing is relayed | nobody. No vendor is involved, so there is no cost, no AEGIS fee and no margin. Remote endpoints are refused here — use `byok` |
240
265
 
241
266
  **2. The model id — what to pin.**
242
267
 
@@ -247,10 +272,10 @@ restart.
247
272
  /model - # clear the pin, back to the class default
248
273
  ```
249
274
 
250
- `/models` is class-aware: it answers from the pool catalogue under `aegis`, from
251
- the models your saved keys actually unlock under `byok`, and from the entries you
252
- added with `/model add` under `custom`. A pin is **cleared with a reason** if you
253
- switch to a class it does not belong to, instead of failing later at the route.
275
+ `/models` is class-aware: it answers from the pool catalogue under `aegis`, and
276
+ from the models your saved keys actually unlock under `byok`. A pin is
277
+ **cleared with a reason** if you switch to a class it does not belong to,
278
+ instead of failing later at the route.
254
279
 
255
280
  Under `byok` every id is compound — `provider:model`:
256
281
 
@@ -259,17 +284,9 @@ Under `byok` every id is compound — `provider:model`:
259
284
  /model anthropic:claude-sonnet-4-5
260
285
  ```
261
286
 
262
- Under `custom` the id is whatever you named the entry:
263
-
264
- ```bash
265
- /models # e.g. local-llama, lan-box
266
- /model local-llama
267
- ```
268
-
269
287
  ```bash
270
288
  aegiscode -m nexus-brain -p "…" # pin at launch
271
289
  aegiscode -m anthropic:claude-sonnet-4-5 -p "…" # a BYOK id at launch
272
- aegiscode -m local-llama -p "…" # a custom id at launch
273
290
  ```
274
291
 
275
292
  **3. Effort — how hard it reasons.**
@@ -286,77 +303,7 @@ the per-provider mechanics).
286
303
  > **A `byok` turn is single-shot.** The relay takes no `tools` parameter, so the
287
304
  > agentic tool loop is off by construction — no file edits, no shell, no
288
305
  > subagents, no approval cards. `/class` says so rather than letting you discover
289
- > it mid-task. **`custom` does not have this limit** — aegiscode calls the local
290
- > endpoint itself, so the full tool loop works normally.
291
-
292
- ## Custom models — your local endpoint, called directly
293
-
294
- `/model add` teaches aegiscode about an endpoint on **your own machine** — an
295
- Ollama or llama.cpp server, a box on your LAN. There is no relay, no handling fee
296
- and no margin: the request goes straight from your machine to the base URL you
297
- gave, with the key you gave, and no vendor is paid because no vendor is
298
- involved.
299
-
300
- **Local only, by policy.** Remote endpoints are *not offered* on this lane. Every
301
- other class bills — `aegis` the pooled route, `byok` the AEGIS handling fee on
302
- the relay — and this lane bills nothing, so it is free for exactly one kind of
303
- traffic: traffic that never leaves your machine. A remote base URL is refused at
304
- the moment you add it, with a pointer at the lane that can serve it:
305
-
306
- ```console
307
- $ /model add work-gw "Work gateway" gpt-4o https://gw.corp/v1
308
- couldn't add "work-gw": custom endpoints must be LOCAL — remote base URL "https://gw.corp/v1"
309
- is not offered on this lane. Allowed: localhost, 127.0.0.1, a private/LAN address
310
- (10.x, 172.16-31.x, 192.168.x), *.local/.internal/.lan, or a dotless host like "ollama".
311
- Remote providers are billed, so use /class byok with /byok-key <provider> (the AEGIS
312
- relay charges the handling fee there), or point this entry at a local address.
313
- ```
314
-
315
- There is no flag, env var or override that re-opens the remote direct lane: such
316
- a switch would be a billing bypass. The refusal is enforced twice — in the add
317
- path, and again in the dispatch gate before any network call — so an entry left
318
- in `config.json` from an older build is still refused rather than dialled.
319
-
320
- ```bash
321
- /model add local-llama "Local Llama" llama-3.3-70b http://localhost:11434/v1
322
- /model add lan-box "LAN box" qwen3:32b http://192.168.1.40:8080/v1
323
- /model key local-llama # set or replace the key later (prompted, masked)
324
- /class custom # route turns through these
325
- /model local-llama # pin one
326
- /model remove local-llama # drop the entry and its key
327
- ```
328
-
329
- Remote providers are a `byok` concern, and that lane bills:
330
-
331
- ```bash
332
- /class byok
333
- /byok-key openai # …or anthropic, groq, deepseek, …
334
- /model openai:gpt-4o
335
- ```
336
-
337
- A local base URL counts as local when it is a loopback address (`localhost`,
338
- `127.0.0.0/8`, `::1`), a private range (`10/8`, `172.16/12`, `192.168/16`,
339
- `fc00::/7`), link-local (`169.254/16`, `fe80::/10`), a reserved local suffix
340
- (`.local`, `.internal`, `.lan`) or a bare dotless host name (`ollama`). Anything
341
- else — including an address that does not parse — is treated as remote and
342
- refused: the classifier fails closed, so an ambiguity costs you a retry, never an
343
- unpaid remote turn.
344
-
345
- The wire protocol is inferred from the base URL — anything that is not
346
- `anthropic.com` speaks the OpenAI-compatible shape, which is what a local
347
- inference server (Ollama, llama.cpp, vLLM, LM Studio) does — or you can pass
348
- `openai` / `anthropic` explicitly to override it, which is how you point the
349
- Messages API at a local gateway.
350
-
351
- Where things are stored, and why it is split:
352
-
353
- | What | Where | Why |
354
- |---|---|---|
355
- | name, model, base URL, wire | `~/.aegiscode/config.json` | it is configuration, and it is not secret |
356
- | the API key | `~/.aegiscode/settings.json` (mode `0600`) | secrets belong in the file we chmod, keyed `custom:<id>` |
357
-
358
- The key is never written into `config.json`. A local endpoint that needs no key
359
- is fine — omit it and no `Authorization` header is sent.
306
+ > it mid-task.
360
307
 
361
308
  ## Bring your own key
362
309
 
@@ -463,9 +410,6 @@ echo "why is the sky blue" | aegiscode -p -
463
410
  /models # what that key unlocks
464
411
  /model openai:gpt-4o # pin one
465
412
  /class aegis # back to the pool
466
-
467
- /model add local-llama "Local Llama" llama-3.3-70b http://localhost:11434/v1
468
- /class custom # or call a LOCAL endpoint directly (remote URLs are refused — use byok)
469
413
  ```
470
414
 
471
415
  ### Control the budget
package/bin/aegiscode.js CHANGED
@@ -376,6 +376,30 @@ async function main(argv = process.argv.slice(2)) {
376
376
  return 0;
377
377
  }
378
378
 
379
+ // ── the shared env file, before any credential is resolved ───────────────
380
+ //
381
+ // `~/.aegiscode/.env` read into process.env once. This is what makes key
382
+ // setup ONE instruction in every host — "put it in ~/.aegiscode/.env" —
383
+ // instead of a `login` plus a `/byok-key <provider>` prompt per provider:
384
+ // both resolution paths already read AEGIS_API_KEY and <PROVIDER>_API_KEY
385
+ // out of the environment (src/credentials.js, the byok class in the shared
386
+ // engine), they simply had nothing filling it. A variable already exported
387
+ // in the launching shell always wins. Placed AFTER the help/version
388
+ // early-exits so those stay instant, and before caps because everything
389
+ // below this point may resolve a credential.
390
+ try {
391
+ const { resolveClientModule } = require('../src/shared.js');
392
+ const envResult = require(resolveClientModule('env-file.js')).loadEnvFile();
393
+ if (envResult.loose) {
394
+ process.stderr.write(
395
+ `aegiscode: ${envResult.file} is readable by other accounts ` +
396
+ `(mode ${envResult.mode.toString(8)}) — consider \`chmod 600\` on it.\n`
397
+ );
398
+ }
399
+ } catch (e) {
400
+ process.stderr.write(`aegiscode: could not read ~/.aegiscode/.env: ${e && e.message}\n`);
401
+ }
402
+
379
403
  // ── terminal capabilities, resolved before anything else is loaded ────────
380
404
  //
381
405
  // Ordering is the whole point. `theme.js` materialises its palettes and its
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "aegiscode",
3
3
  "productName": "AEGIS Code",
4
- "version": "6.7.8",
4
+ "version": "6.8.0",
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",
@@ -44,6 +44,12 @@ const FILES = [
44
44
  // list; `src/shared.js` resolves them from here in an installed package.
45
45
  'client/credentials.js',
46
46
  'client/session-store.js',
47
+ // The shared `~/.aegiscode/.env` loader. bin/aegiscode.js resolves it through
48
+ // resolveClientModule in src/shared.js and calls it before any credential is
49
+ // read, so a key lives in ONE file for every host. (No apostrophes in the
50
+ // comments in this array: test/packaging.test.mjs parses it by pairing single
51
+ // quotes, and one stray one silently swallows the next real entry.)
52
+ 'client/env-file.js',
47
53
  'mcp/tools.js',
48
54
  'desktop/renderer/usage.js',
49
55
  // The agent-loop engine (persistent shell, editFile/grep/exec, Task
@@ -51,6 +57,11 @@ const FILES = [
51
57
  // reuses it as-is, scoped to the 'aegis' class only (see src/engine.js) —
52
58
  // one tool loop implementation, not a second one drifting alongside it.
53
59
  'desktop/lib/local/engine.js',
60
+ // engine.js and settings.js both require this at load time: it is the local
61
+ // model transport, and the module that owns the fail-closed check deciding
62
+ // whether a base URL is on this machine. Leaving it out stages a vendor tree
63
+ // whose engine throws MODULE_NOT_FOUND before it can answer anything.
64
+ 'desktop/lib/local/local.js',
54
65
  // engine.js requires this at load time to hold a turn cut off at its tool
55
66
  // horizon: the interruption is filed against the session and the next turn
56
67
  // resumes it instead of starting cold. Staging engine.js without it ships a
@@ -61,22 +72,6 @@ const FILES = [
61
72
  'desktop/lib/local/shell.js',
62
73
  'desktop/lib/local/agents.js',
63
74
  'desktop/lib/local/prompt.js',
64
- // The direct-provider transport (openaiCompatible + anthropicMessages) the
65
- // desktop injects into the engine for its custom-endpoint classes. The CLI's
66
- // `custom` class (src/engine.js, the /model add catalog) now injects the same
67
- // real transport instead of the throwing stub it used to, so a user's own
68
- // base URL + key is called directly with the full tool loop — so this file
69
- // must ship. Pure node builtins (fetch), stages cleanly.
70
- 'desktop/lib/local/providers.js',
71
- // The direct-dial policy the transports above are gated by: which base URLs
72
- // may reach them at all (local endpoints only — a remote one has nothing to
73
- // bill against, see the module). BOTH hosts read it: the desktop engine and
74
- // settings store require it relatively, and this package reaches it through
75
- // src/sharedpaths.js from src/custommodels.js. Leaving it out of the staged
76
- // tree is a MODULE_NOT_FOUND at CLI start-up — which is also why it must be
77
- // listed before the settings store, whose `set()` refuses a remote URL for a
78
- // direct-dial row (settings.js -> ./local/endpoints.js).
79
- 'desktop/lib/local/endpoints.js',
80
75
  // The provider-config store: one row per provider (base URL + key), and the
81
76
  // row the 'byok' class reads for a per-provider key. The CLI now selects that
82
77
  // class (src/engine.js), so it needs the same store the desktop writes —
package/src/app.js CHANGED
@@ -40,7 +40,6 @@ const {
40
40
  const credentials = require('./credentials.js');
41
41
  const cloudsync = require('./cloudsync.js');
42
42
  const { readSecret } = require('./secret.js');
43
- const customModelsCatalog = require('./custommodels.js');
44
43
  const { normalizeModelCatalog, pickerEntries, catalogIds } = require('./models.js');
45
44
  const { appendHistory, readSessionTranscript, readOwnSessions } = require('./history.js');
46
45
  const { snapshotCheckpoint } = require('./checkpoint.js');
@@ -494,20 +493,10 @@ function createApp(options = {}) {
494
493
  * offer": a catalog is a convenience, and an offline client must still be
495
494
  * able to chat on the server's own default.
496
495
  */
497
- async function loadCustomModels() {
498
- // The `custom` catalog is local (config.json + the 0600 key store), so this
499
- // never touches the network and needs no cache. The engine already returns
500
- // the picker/`/models` shape ({id, label, note, configured, wire}).
501
- if (typeof engine.listModels !== 'function') return [];
502
- const res = await engine.listModels('custom');
503
- return (res && res.models) || [];
504
- }
505
-
506
496
  async function listModelsFor(cls) {
507
497
  const want = HOST_CLASSES.includes(cls) ? cls : commandCtx.modelClass;
508
498
  try {
509
499
  if (want === 'byok') return await loadByokModels();
510
- if (want === 'custom') return await loadCustomModels();
511
500
  return await loadModels();
512
501
  } catch {
513
502
  return [];
@@ -516,30 +505,27 @@ function createApp(options = {}) {
516
505
 
517
506
  /**
518
507
  * Whether a pinned id can run on `cls`, decided synchronously (switchClass is
519
- * not async). byok ids are `provider:model`; custom ids are the catalog's
520
- * own (config.json, read sync); aegis takes anything that is neither — the
521
- * pooled catalog is validated separately, at launch, by validatePinnedModel.
508
+ * not async). byok ids are `provider:model`; aegis takes anything that is
509
+ * not — the pooled catalog is validated separately, at launch, by
510
+ * validatePinnedModel.
522
511
  */
523
512
  function pinBelongsToClass(cls, id) {
524
513
  const s = String(id == null ? '' : id);
525
514
  if (cls === 'byok') return s.includes(':');
526
- if (cls === 'custom') return Boolean(customModelsCatalog.getCustom(s));
527
- // aegis: not a byok id and not a custom-catalog id.
528
- return !s.includes(':') && !customModelsCatalog.getCustom(s);
515
+ // aegis: not a byok id.
516
+ return !s.includes(':');
529
517
  }
530
518
 
531
519
  /**
532
520
  * Switch the live class. Refuses anything this host cannot run (engine.js's
533
- * HOST_CLASSES is the authority — the local/custom classes stay stubs).
521
+ * HOST_CLASSES is the authority).
534
522
  *
535
523
  * A pin is cleared when it does not belong to the class being entered: a
536
524
  * pooled id pinned under byok would be parsed as provider `<pooled id>` and
537
525
  * fail at the relay with a confusing "no key saved for …" instead of here,
538
526
  * with a reason. Symmetrically, `anthropic:claude-…` under aegis is an id the
539
527
  * pooled catalog does not advertise, which is the silent-fallback case
540
- * validatePinnedModel exists to prevent. The `custom` class owns its own id
541
- * space (the /model add catalog, resolvable synchronously from config.json),
542
- * so a pin belongs to it exactly when it is one of those ids.
528
+ * validatePinnedModel exists to prevent.
543
529
  */
544
530
  function switchClass(next) {
545
531
  const want = String(next == null ? '' : next).trim().toLowerCase();
@@ -610,31 +596,6 @@ function createApp(options = {}) {
610
596
  );
611
597
  return pinned;
612
598
  }
613
- // A custom pin is validated against the local catalog, never the pooled one:
614
- // its ids are the user's own (from /model add) and the pool has never heard
615
- // of them, so checking the pooled catalog would clear every custom pin on
616
- // launch. An empty catalog clears nothing (offline-safe like the pooled path).
617
- if (commandCtx.modelClass === 'custom') {
618
- let customModels;
619
- try {
620
- customModels = await loadCustomModels();
621
- } catch {
622
- return null;
623
- }
624
- if (!customModels.length) return null;
625
- if (customModels.some((m) => m.id === pinned)) return null;
626
- commandCtx.model = null;
627
- updateConfig({ model: null, currentModelId: null });
628
- emit(
629
- render.renderNotice(
630
- ctx(),
631
- 'warn',
632
- `pinned model "${pinned}" is not in your custom catalog — pin cleared; ` +
633
- '/models lists your endpoints, /model add registers one.'
634
- )
635
- );
636
- return pinned;
637
- }
638
599
  let models;
639
600
  try {
640
601
  models = await loadModels();
@@ -1082,23 +1043,7 @@ function createApp(options = {}) {
1082
1043
  // dropped, live ids only (see models.js pickerEntries).
1083
1044
  // Whichever class is live decides what is pinnable — the pooled ids the
1084
1045
  // server advertises, or the `provider:model` ids this machine can relay.
1085
- // The rows the picker/overlay offers. Class-scoped, because each class
1086
- // owns a different id space: pool-advertised ids on aegis, this machine's
1087
- // `provider:model` ids on byok, and the /model add catalog on custom.
1088
- // The custom half is read synchronously from config.json (+ the 0600 key
1089
- // store for the `configured` flag) because buildState() cannot await, and
1090
- // it is the reason the picker used to fail on that class: the ternary
1091
- // here was two-way, so `custom` fell through to the pooled modelCache,
1092
- // which is never populated on a class that never asks the pool.
1093
- // `listCustomModels` is the same builder /models and the engine use, so
1094
- // the rows cannot drift from what the class will actually accept.
1095
- models: pickerEntries(
1096
- commandCtx.modelClass === 'byok'
1097
- ? byokCache.models
1098
- : commandCtx.modelClass === 'custom'
1099
- ? customModelsCatalog.listCustomModels(engine.settings)
1100
- : modelCache.models
1101
- ),
1046
+ models: pickerEntries(commandCtx.modelClass === 'byok' ? byokCache.models : modelCache.models),
1102
1047
  commands: visibleCommands(),
1103
1048
  transcript: transcript.slice(),
1104
1049
  sessions: [],