aegiscode 6.7.8 → 6.8.1
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 +51 -97
- package/bin/aegiscode.js +24 -0
- package/package.json +1 -1
- package/scripts/predist.mjs +11 -16
- package/src/app.js +8 -63
- package/src/commands.js +24 -189
- package/src/config.js +0 -14
- package/src/deps.js +3 -16
- package/src/engine.js +14 -105
- package/src/screens.js +51 -0
- package/src/sharedpaths.js +4 -7
- package/vendor/client/aegis.js +45 -2
- package/vendor/client/env-file.js +182 -0
- package/vendor/desktop/lib/local/engine.js +225 -188
- package/vendor/desktop/lib/local/local.js +433 -0
- package/vendor/desktop/lib/local/tools.js +7 -56
- package/vendor/desktop/lib/settings.js +28 -31
- package/vendor/desktop/renderer/usage.js +4 -4
- package/src/custommodels.js +0 -258
- package/vendor/desktop/lib/local/endpoints.js +0 -228
- package/vendor/desktop/lib/local/providers.js +0 -679
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
|
-
|
|
94
|
-
|
|
95
|
-
|
|
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
|
|
|
@@ -153,7 +180,7 @@ The same axes are settable by environment for scripts and CI: `AEGIS_ART`,
|
|
|
153
180
|
## First run
|
|
154
181
|
|
|
155
182
|
A genuine first run walks the reference's onboarding before the session starts —
|
|
156
|
-
the order is
|
|
183
|
+
the order is the reference's:
|
|
157
184
|
|
|
158
185
|
```
|
|
159
186
|
────────────────────────────────────────────────────────────────────────────────
|
|
@@ -188,7 +215,7 @@ launch, and an explicit flag (`-m`, `--light`) always outranks the stored value.
|
|
|
188
215
|
## Commands
|
|
189
216
|
|
|
190
217
|
In a session, plain text is a prompt. `/help` lists commands, grouped by
|
|
191
|
-
category, the way
|
|
218
|
+
category, the way the reference does. The registry is that client's, ported
|
|
192
219
|
command for command — 75 entries across nine categories:
|
|
193
220
|
|
|
194
221
|
| Category | Commands |
|
|
@@ -224,7 +251,7 @@ 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
|
|
254
|
+
/class local # a model on your own machine or network (free)
|
|
228
255
|
```
|
|
229
256
|
|
|
230
257
|
A class is *whose credential pays and who talks to the vendor*, not a model.
|
|
@@ -236,7 +263,15 @@ restart.
|
|
|
236
263
|
|---|---|---|
|
|
237
264
|
| `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
265
|
| `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
|
-
| `
|
|
266
|
+
| `local` | a model on your own machine or network — your Ollama daemon at `http://localhost:11434` by default, keyless; any OpenAI-compatible server on that box works | nobody — free; there is no vendor to bill |
|
|
267
|
+
|
|
268
|
+
`local` never leaves your own network: it dials a model on your machine or your
|
|
269
|
+
LAN, and is refused fail-closed if the endpoint is not local — the check runs
|
|
270
|
+
when the base URL is saved and again before a request is dialled
|
|
271
|
+
(`desktop/lib/local/local.js` → `remoteRefusal`). The generic *remote*
|
|
272
|
+
custom-endpoint lanes (an arbitrary remote OpenAI- or Anthropic-compatible URL)
|
|
273
|
+
do not exist here; any OpenAI-compatible server on that box — llama.cpp, LM
|
|
274
|
+
Studio, vLLM — works by pointing the base URL at it.
|
|
240
275
|
|
|
241
276
|
**2. The model id — what to pin.**
|
|
242
277
|
|
|
@@ -247,10 +282,10 @@ restart.
|
|
|
247
282
|
/model - # clear the pin, back to the class default
|
|
248
283
|
```
|
|
249
284
|
|
|
250
|
-
`/models` is class-aware: it answers from the pool catalogue under `aegis`,
|
|
251
|
-
the models your saved keys actually unlock under `byok
|
|
252
|
-
|
|
253
|
-
|
|
285
|
+
`/models` is class-aware: it answers from the pool catalogue under `aegis`, and
|
|
286
|
+
from the models your saved keys actually unlock under `byok`. A pin is
|
|
287
|
+
**cleared with a reason** if you switch to a class it does not belong to,
|
|
288
|
+
instead of failing later at the route.
|
|
254
289
|
|
|
255
290
|
Under `byok` every id is compound — `provider:model`:
|
|
256
291
|
|
|
@@ -259,17 +294,9 @@ Under `byok` every id is compound — `provider:model`:
|
|
|
259
294
|
/model anthropic:claude-sonnet-4-5
|
|
260
295
|
```
|
|
261
296
|
|
|
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
297
|
```bash
|
|
270
298
|
aegiscode -m nexus-brain -p "…" # pin at launch
|
|
271
299
|
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
300
|
```
|
|
274
301
|
|
|
275
302
|
**3. Effort — how hard it reasons.**
|
|
@@ -286,77 +313,7 @@ the per-provider mechanics).
|
|
|
286
313
|
> **A `byok` turn is single-shot.** The relay takes no `tools` parameter, so the
|
|
287
314
|
> agentic tool loop is off by construction — no file edits, no shell, no
|
|
288
315
|
> subagents, no approval cards. `/class` says so rather than letting you discover
|
|
289
|
-
> it mid-task.
|
|
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.
|
|
316
|
+
> it mid-task.
|
|
360
317
|
|
|
361
318
|
## Bring your own key
|
|
362
319
|
|
|
@@ -463,9 +420,6 @@ echo "why is the sky blue" | aegiscode -p -
|
|
|
463
420
|
/models # what that key unlocks
|
|
464
421
|
/model openai:gpt-4o # pin one
|
|
465
422
|
/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
423
|
```
|
|
470
424
|
|
|
471
425
|
### Control the budget
|
|
@@ -566,7 +520,7 @@ either runs or is a real handler that says honestly what it cannot do.
|
|
|
566
520
|
|
|
567
521
|
## The chatflow
|
|
568
522
|
|
|
569
|
-
The session is
|
|
523
|
+
The session is the reference's loop, ported rather than approximated: an
|
|
570
524
|
alternate-screen frame of header rule, transcript viewport, spinner/effort line,
|
|
571
525
|
input line and status line, driven by a raw key stream.
|
|
572
526
|
|
|
@@ -640,9 +594,9 @@ node cli/scripts/demo.mjs # from a source checkout
|
|
|
640
594
|
|
|
641
595
|
## Design notes
|
|
642
596
|
|
|
643
|
-
**It looks like
|
|
597
|
+
**It looks like the reference on purpose.** The gold/coral/lavender palette,
|
|
644
598
|
the `✦`-studded welcome mark (mascot, crescent moon and diving whale), the `❯`
|
|
645
|
-
prompt, the `⎿` hook rows and the `✻` spinner line are the
|
|
599
|
+
prompt, the `⎿` hook rows and the `✻` spinner line are the reference's
|
|
646
600
|
design system, adopted wholesale rather than approximated: the palette, glyphs,
|
|
647
601
|
welcome art, working verbs and command vocabulary all come from it, and
|
|
648
602
|
`test/cli-conformance.test.mjs` pins every RGB triple, glyph, spinner frame, verb
|
|
@@ -657,7 +611,7 @@ Anywhere else — a pipe, `-p`, CI — turns are written once to the scrollback
|
|
|
657
611
|
instead, so output stays selectable, searchable and pipeable. A tool you script
|
|
658
612
|
should not become un-scriptable because the interactive mode got nicer.
|
|
659
613
|
|
|
660
|
-
**The command registry is
|
|
614
|
+
**The command registry is the reference's, ported.** Names, aliases,
|
|
661
615
|
categories, the palette grouping and the handlers themselves come from it, with
|
|
662
616
|
`test/cli-commands.test.mjs` asserting the full name list so a silent drop
|
|
663
617
|
fails the build. Local capability that the reference has — a dev-server runner,
|
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.
|
|
4
|
+
"version": "6.8.1",
|
|
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/scripts/predist.mjs
CHANGED
|
@@ -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`;
|
|
520
|
-
*
|
|
521
|
-
*
|
|
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
|
-
|
|
527
|
-
|
|
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
|
|
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.
|
|
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
|
-
|
|
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: [],
|