aegiscode 7.0.25 → 7.0.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +7 -3
- package/scripts/check.mjs +52 -1
- package/scripts/demo.mjs +94 -1
- package/scripts/predist.mjs +75 -1
- package/scripts/runtests.mjs +56 -1
- package/scripts/seal-gate.mjs +74 -1
- package/src/agents.js +139 -1
- package/src/app.js +2957 -1
- package/src/art.js +289 -1
- package/src/chatflow.js +3023 -1
- package/src/checkpoint.js +90 -1
- package/src/clipboard.js +424 -1
- package/src/cloudsync.js +528 -1
- package/src/commands.js +4089 -1
- package/src/config.js +581 -1
- package/src/connect.js +349 -1
- package/src/credentials.js +33 -1
- package/src/deps.js +232 -1
- package/src/devrun.js +187 -1
- package/src/diff.js +333 -1
- package/src/diffview.js +296 -1
- package/src/engine.js +297 -1
- package/src/entitlement.js +355 -1
- package/src/events.js +707 -1
- package/src/export.js +67 -1
- package/src/filepreview.js +153 -1
- package/src/fingerprint.js +592 -1
- package/src/format.js +259 -1
- package/src/fuzzy.js +119 -1
- package/src/history.js +423 -1
- package/src/init.js +175 -1
- package/src/input.js +139 -1
- package/src/keys.js +183 -1
- package/src/markdown.js +306 -1
- package/src/models.js +507 -1
- package/src/naming.js +57 -1
- package/src/overlays.js +462 -1
- package/src/panels.js +1418 -1
- package/src/ping.js +226 -1
- package/src/presence.js +238 -1
- package/src/render.js +516 -1
- package/src/screen.js +518 -1
- package/src/screens.js +896 -1
- package/src/secret.js +59 -1
- package/src/securefs.js +359 -1
- package/src/settings.js +155 -1
- package/src/shared.js +52 -1
- package/src/sharedpaths.js +53 -1
- package/src/signup.js +156 -1
- package/src/summarize.js +95 -1
- package/src/sysdiag.js +585 -1
- package/src/system.js +40 -1
- package/src/theme.js +570 -1
- package/src/title.js +220 -1
- package/src/todos.js +115 -1
- package/src/tokens.js +263 -1
- package/src/topup.js +210 -1
- package/src/update.js +191 -1
- package/vendor/client/aegis.js +2441 -1
- package/vendor/client/attest.js +518 -1
- package/vendor/client/authorship-key.js +410 -1
- package/vendor/client/auto-provision.js +134 -1
- package/vendor/client/brain-catalog.js +268 -1
- package/vendor/client/byok-catalog.js +199 -1
- package/vendor/client/catalog-client.js +487 -1
- package/vendor/client/conversation-export.js +177 -1
- package/vendor/client/credentials.js +494 -1
- package/vendor/client/device-fingerprint.js +141 -1
- package/vendor/client/drive-connect.js +110 -1
- package/vendor/client/drive-upload.js +234 -1
- package/vendor/client/env-file.js +1273 -1
- package/vendor/client/fingerprint.js +1064 -1
- package/vendor/client/foreign-memory.js +669 -1
- package/vendor/client/google-signin.js +133 -1
- package/vendor/client/hooks.js +430 -1
- package/vendor/client/model-discovery.js +373 -1
- package/vendor/client/naming.js +283 -1
- package/vendor/client/platform.js +937 -1
- package/vendor/client/prefs.js +351 -1
- package/vendor/client/presence-constants.js +107 -1
- package/vendor/client/presence.js +438 -1
- package/vendor/client/record-vault.js +1055 -3
- package/vendor/client/session-store.js +575 -1
- package/vendor/client/topup.js +297 -1
- package/vendor/client/touch.js +458 -1
- package/vendor/client/update.js +763 -1
- package/vendor/client/user-models.js +381 -1
- package/vendor/desktop/lib/local/agents.js +105 -1
- package/vendor/desktop/lib/local/attachments.js +276 -1
- package/vendor/desktop/lib/local/autonomous.js +1045 -1
- package/vendor/desktop/lib/local/claude-pro.js +1028 -1
- package/vendor/desktop/lib/local/context.js +125 -1
- package/vendor/desktop/lib/local/engine.js +3666 -1
- package/vendor/desktop/lib/local/entitlement.js +660 -1
- package/vendor/desktop/lib/local/git-scope.js +228 -1
- package/vendor/desktop/lib/local/local.js +2145 -1
- package/vendor/desktop/lib/local/prompt.js +280 -1
- package/vendor/desktop/lib/local/queue.js +560 -1
- package/vendor/desktop/lib/local/session-rounds.js +238 -1
- package/vendor/desktop/lib/local/spill.js +75 -1
- package/vendor/desktop/lib/local/turn-guard.js +300 -1
- package/vendor/desktop/lib/local/worktree-lock.js +235 -1
- package/vendor/desktop/lib/settings.js +890 -1
- package/vendor/desktop/renderer/usage.js +1239 -1
- package/vendor/hosts/install.js +638 -1
- package/vendor/hosts/openai-shim.js +515 -1
- package/vendor/hosts/spec.js +164 -1
- package/vendor/hosts/targets.js +346 -1
- package/vendor/mcp/server.js +221 -1
- package/vendor/mcp/tools.js +408 -1
- package/vendor/one/src/child.js +285 -1
- package/vendor/one/src/permissions.js +383 -1
- package/SOURCE-OFFER.txt +0 -9
|
@@ -1,3 +1,270 @@
|
|
|
1
1
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
2
2
|
// Copyright (C) 2026 Niklas Borneklint — AEGIS Code (aegiscode) / Aegiscloud.
|
|
3
|
-
|
|
3
|
+
// AEGIS Code (aegiscode) — source: https://github.com/aegisinfo/aegiscode-plugin
|
|
4
|
+
// Conveying a modified copy, or running one as a network service, owes the
|
|
5
|
+
// corresponding source under this licence (§5/§13) — see LICENSING.md.
|
|
6
|
+
'use strict';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* The pooled-brain entry, defined ONCE for every host.
|
|
10
|
+
*
|
|
11
|
+
* The platform's `/api/v1/models` payload lists the brain tier under five
|
|
12
|
+
* spellings (`nexus-brain` canonical; `aegis-brain`, `nexus-brain-smart`,
|
|
13
|
+
* `aegis-brain-smart`, `nexus-brain-neo` each sent as `hidden: true,
|
|
14
|
+
* alias_of: "nexus-brain"`). A host that showed all five painted five models
|
|
15
|
+
* where the server routes one, and a host that showed none (or a different one
|
|
16
|
+
* per release) left users comparing two clients that disagree about the same
|
|
17
|
+
* account.
|
|
18
|
+
*
|
|
19
|
+
* This module exists because that disagreement was real: the desktop collapsed
|
|
20
|
+
* the class to a single "Nexus" entry (desktop/lib/local/engine.js) while the
|
|
21
|
+
* CLI kept every distinct id, so the same account saw a different model list in
|
|
22
|
+
* each host. Two copies of the selection rule is the drift; one shared function
|
|
23
|
+
* is the fix, which is why both hosts require THIS file — the desktop from
|
|
24
|
+
* `desktop/lib/local/engine.js` (repo-relative `client/brain-catalog.js`, or
|
|
25
|
+
* `desktop/vendor/brain-catalog.js` in the packaged app) and the CLI from
|
|
26
|
+
* `cli/src/models.js` (through `src/sharedpaths.js`: repo-relative
|
|
27
|
+
* `client/brain-catalog.js`, or `vendor/client/brain-catalog.js` installed).
|
|
28
|
+
*
|
|
29
|
+
* The two hosts do NOT hand this module the same entry shape and must not have
|
|
30
|
+
* to: the desktop passes the relay's raw payload (`hidden`, `alias_of`), the
|
|
31
|
+
* CLI passes its own normalised entries (`hidden`, `aliasOf`). So the readers
|
|
32
|
+
* below accept either spelling — one rule, two shapes — instead of each host
|
|
33
|
+
* keeping a private copy of the rule to match its own shape, which is the drift
|
|
34
|
+
* this module exists to end.
|
|
35
|
+
*
|
|
36
|
+
* Pure: no I/O, no node builtins, no dependencies — safe to require from a
|
|
37
|
+
* renderer, a CLI start-up path, or an MCP host.
|
|
38
|
+
*/
|
|
39
|
+
|
|
40
|
+
/** Every id the server uses for the pooled brain, canonical spelling first. */
|
|
41
|
+
const NEXUS_BRAIN_IDS = Object.freeze(['nexus-brain', 'aegis-brain']);
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Every id the AEGIS Cloud (aegiscloud) lane serves that is NOT a per-provider
|
|
45
|
+
* id: the pooled brain and the `-smart`/`-neo` tier spellings the server sends
|
|
46
|
+
* as aliases of it. Verified against the live catalog 2026-09-30 —
|
|
47
|
+
* `GET /api/v1/models` answers exactly `deepseek`, `nexus-brain`, `aegis-brain`,
|
|
48
|
+
* `nexus-brain-smart`, `aegis-brain-smart`, `nexus-brain-neo`, `aegis-brain-neo`.
|
|
49
|
+
*
|
|
50
|
+
* A host that must not OFFER the aegiscloud lane needs this list rather than a
|
|
51
|
+
* bare `NEXUS_BRAIN_IDS` check: four of the six spellings are not in that array,
|
|
52
|
+
* and a filter written against it alone would leave `nexus-brain-neo` on screen
|
|
53
|
+
* — the "five spellings of one brain" defect again, one host at a time. The
|
|
54
|
+
* spelling is kept here, next to the ids, because this module is the one place
|
|
55
|
+
* both hosts already agree about what the pooled lane is called.
|
|
56
|
+
*/
|
|
57
|
+
const AEGIS_CLOUD_MODEL_IDS = Object.freeze([
|
|
58
|
+
'nexus-brain',
|
|
59
|
+
'aegis-brain',
|
|
60
|
+
'nexus-brain-smart',
|
|
61
|
+
'aegis-brain-smart',
|
|
62
|
+
'nexus-brain-neo',
|
|
63
|
+
'aegis-brain-neo',
|
|
64
|
+
]);
|
|
65
|
+
|
|
66
|
+
/** The tier-family shape, for a spelling the server adds after this release. */
|
|
67
|
+
const AEGIS_CLOUD_MODEL_RE = /^(?:nexus|aegis)-brain(?:-(?:smart|neo))?$/;
|
|
68
|
+
|
|
69
|
+
/** The name users see for the collapsed entry. */
|
|
70
|
+
const NEXUS_LABEL = 'Nexus';
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* The id this entry is an alias OF, or `null`. Reads the relay's `alias_of` and
|
|
74
|
+
* the CLI's normalised `aliasOf`, so callers may pass either shape.
|
|
75
|
+
*/
|
|
76
|
+
function aliasOfEntry(m) {
|
|
77
|
+
if (!m || typeof m !== 'object') return null;
|
|
78
|
+
for (const value of [m.alias_of, m.aliasOf]) {
|
|
79
|
+
if (typeof value === 'string' && value.trim()) return value.trim();
|
|
80
|
+
}
|
|
81
|
+
return null;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/** Whether the entry is marked display-hidden, in either shape. */
|
|
85
|
+
function isHiddenEntry(m) {
|
|
86
|
+
return Boolean(m) && m.hidden === true;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Pick the one entry standing in for the pooled brain. The server serves
|
|
91
|
+
* `nexus-brain` as the canonical tier (`hidden: false`, no `alias_of`) and
|
|
92
|
+
* marks every other spelling — `aegis-brain` and the `-smart`/`-neo` tiers —
|
|
93
|
+
* as `hidden: true, alias_of: "nexus-brain"`. Prefer the canonical id so the
|
|
94
|
+
* request travels on the name the server owns; fall back to the alias, then to
|
|
95
|
+
* any tier whose `alias_of` names the brain, so a renamed or trimmed catalog
|
|
96
|
+
* still resolves to something selectable instead of silently emptying the
|
|
97
|
+
* dropdown (the previous fixed-id lookup returned [] if `aegis-brain` was ever
|
|
98
|
+
* retired, leaving the class with no model to choose).
|
|
99
|
+
*
|
|
100
|
+
* @param {Array<object>} models normalized or raw catalog entries.
|
|
101
|
+
* @returns {object|null}
|
|
102
|
+
*/
|
|
103
|
+
function selectBrainEntry(models) {
|
|
104
|
+
const list = Array.isArray(models) ? models.filter(Boolean) : [];
|
|
105
|
+
return (
|
|
106
|
+
list.find((m) => NEXUS_BRAIN_IDS.includes(m.id) && !isHiddenEntry(m) && aliasOfEntry(m) === null)
|
|
107
|
+
|| list.find((m) => NEXUS_BRAIN_IDS.includes(m.id))
|
|
108
|
+
|| list.find((m) => NEXUS_BRAIN_IDS.includes(aliasOfEntry(m)))
|
|
109
|
+
|| null
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* The Aegis-class catalog as a host must OFFER it: exactly one entry, the
|
|
115
|
+
* collapsed brain — never the raw provider list, and never the alias tiers.
|
|
116
|
+
*
|
|
117
|
+
* Offering this shape is not the same as accepting only this shape: the ids the
|
|
118
|
+
* server advertises still route (a pin on `deepseek` still runs), so callers
|
|
119
|
+
* keep the full catalog for validation and use this for what they show.
|
|
120
|
+
*
|
|
121
|
+
* Returns `[]` when the payload names no brain tier at all — which is the
|
|
122
|
+
* caller's signal that this is not a pooled-brain catalog (the BYOK listing is
|
|
123
|
+
* per-provider models and must be offered in full, not collapsed to nothing).
|
|
124
|
+
*
|
|
125
|
+
* @param {Array<object>} models the server's catalog (any shape).
|
|
126
|
+
* @returns {Array<object>} `[]` when the payload names no brain tier at all.
|
|
127
|
+
*/
|
|
128
|
+
function filterAegisCatalog(models) {
|
|
129
|
+
const nexus = selectBrainEntry(models);
|
|
130
|
+
if (!nexus) return [];
|
|
131
|
+
// Drop the alias bookkeeping in BOTH spellings: this entry *is* the
|
|
132
|
+
// selection, so a renderer must never treat it as a hidden alias and filter
|
|
133
|
+
// it back out — which is exactly what happens if `aliasOf` survives here and
|
|
134
|
+
// the consumer re-runs its own "drop aliases" pass over the result.
|
|
135
|
+
const { hidden, alias_of, aliasOf, ...rest } = nexus;
|
|
136
|
+
return [{ ...rest, label: NEXUS_LABEL }];
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Whether an entry is a model of the AEGIS CLOUD (aegiscloud) lane — the pooled
|
|
141
|
+
* brain under any of its spellings, whether it is the canonical id, a
|
|
142
|
+
* `-smart`/`-neo` tier, or a row that aliases the brain (`alias_of` in the
|
|
143
|
+
* relay's shape, `aliasOf` in the CLI's).
|
|
144
|
+
*
|
|
145
|
+
* Accepts an id string or an entry object, like the rest of this module.
|
|
146
|
+
*
|
|
147
|
+
* @param {string|object} entry
|
|
148
|
+
* @returns {boolean}
|
|
149
|
+
*/
|
|
150
|
+
function isAegisCloudModel(entry) {
|
|
151
|
+
const id = typeof entry === 'string'
|
|
152
|
+
? entry.trim()
|
|
153
|
+
: entry && typeof entry === 'object' && typeof entry.id === 'string'
|
|
154
|
+
? entry.id.trim()
|
|
155
|
+
: '';
|
|
156
|
+
if (AEGIS_CLOUD_MODEL_IDS.includes(id)) return true;
|
|
157
|
+
if (AEGIS_CLOUD_MODEL_RE.test(id)) return true;
|
|
158
|
+
return NEXUS_BRAIN_IDS.includes(aliasOfEntry(entry));
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* The same list with the AEGIS Cloud (aegiscloud) models omitted.
|
|
163
|
+
*
|
|
164
|
+
* A host that keeps the cloud lane's *credential* (the account key BYOK billing
|
|
165
|
+
* rides on) without offering its *models* needs a filter that is one rule and
|
|
166
|
+
* survives a renamed tier — which is why this is here and not a regex spelled
|
|
167
|
+
* again inside a host: a second copy is how this repo's two clients came to show
|
|
168
|
+
* one account two different model lists in the first place.
|
|
169
|
+
*
|
|
170
|
+
* Pure and non-mutating; a non-array yields `[]`, and an entry with no usable id
|
|
171
|
+
* is dropped rather than passed through, because "a row we cannot name" is not a
|
|
172
|
+
* row a picker may paint.
|
|
173
|
+
*
|
|
174
|
+
* @param {Array<object|string>} models
|
|
175
|
+
* @returns {Array} a new array, order preserved
|
|
176
|
+
*/
|
|
177
|
+
function omitAegisCloudModels(models) {
|
|
178
|
+
const list = Array.isArray(models) ? models : [];
|
|
179
|
+
return list.filter((m) => {
|
|
180
|
+
if (!m) return false;
|
|
181
|
+
if (typeof m === 'string') return !isAegisCloudModel(m);
|
|
182
|
+
const id = typeof m.id === 'string' ? m.id.trim() : '';
|
|
183
|
+
return Boolean(id) && !isAegisCloudModel(m);
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* The Aegis-class catalog as a host must OFFER it: the FULL list the server
|
|
189
|
+
* advertises — the pooled brain first, under its one name, then every other
|
|
190
|
+
* model the account can pin.
|
|
191
|
+
*
|
|
192
|
+
* `filterAegisCatalog` above collapses the class to the single brain row, and
|
|
193
|
+
* that was shipped: the desktop's dropdown and the terminal's alt+p picker both
|
|
194
|
+
* showed one entry, "Nexus", because collapsing was implemented to end a real
|
|
195
|
+
* disagreement (seven rows in one host, one in the other). Ending the
|
|
196
|
+
* disagreement by removing the choice was the wrong fix, and a user with a
|
|
197
|
+
* funded account could see no way to pin the deepseek or anthropic models the
|
|
198
|
+
* same catalogue advertises — the model was chosen for them, with no lever.
|
|
199
|
+
*
|
|
200
|
+
* So this is the rule both hosts now share: offer everything, collapse only the
|
|
201
|
+
* *aliases*.
|
|
202
|
+
*
|
|
203
|
+
* - The brain tier stays ONE row, labelled `NEXUS_LABEL`, first. The server
|
|
204
|
+
* lists it under five spellings (`nexus-brain` canonical, `aegis-brain` and
|
|
205
|
+
* the `-smart`/`-neo` tiers as `hidden: true, alias_of: "nexus-brain"`);
|
|
206
|
+
* those name one route, so they are folded into that one row rather than
|
|
207
|
+
* painted as five models — which is what `filterAegisCatalog` was for, and
|
|
208
|
+
* that half of it is kept.
|
|
209
|
+
* - Every other entry is offered as the server advertises it, INCLUDING
|
|
210
|
+
* entries the payload marks `hidden`, because "hidden" in this payload means
|
|
211
|
+
* "not the canonical spelling", not "do not offer".
|
|
212
|
+
* - An entry that is an alias OF another entry in the same payload is dropped
|
|
213
|
+
* only when its target is present — a pure duplicate row that would pin the
|
|
214
|
+
* id it points at, which is the `models.js` defect the CLI already guarded
|
|
215
|
+
* against. When the payload is nothing but aliases, they are all offered:
|
|
216
|
+
* an empty list is not a better answer than a list of aliases.
|
|
217
|
+
*
|
|
218
|
+
* Pure, like the rest of this file, and shape-tolerant (raw relay payload or
|
|
219
|
+
* the CLI's normalised entries) so both hosts can call it with what they hold.
|
|
220
|
+
* Returns `[]` for an empty payload; never invents an entry.
|
|
221
|
+
*
|
|
222
|
+
* @param {Array<object>} models the server's catalog (any shape).
|
|
223
|
+
* @returns {Array<object>} the entries to show, brain first (a new array).
|
|
224
|
+
*/
|
|
225
|
+
function offerableCatalog(models) {
|
|
226
|
+
const list = Array.isArray(models) ? models.filter(Boolean) : [];
|
|
227
|
+
if (!list.length) return [];
|
|
228
|
+
|
|
229
|
+
const brain = selectBrainEntry(list);
|
|
230
|
+
const out = [];
|
|
231
|
+
const seen = new Set();
|
|
232
|
+
|
|
233
|
+
if (brain) {
|
|
234
|
+
// Same de-aliasing as filterAegisCatalog: this row IS the selection, so no
|
|
235
|
+
// renderer may filter it back out as a hidden alias.
|
|
236
|
+
const { hidden, alias_of, aliasOf, ...rest } = brain;
|
|
237
|
+
out.push({ ...rest, label: NEXUS_LABEL });
|
|
238
|
+
for (const id of NEXUS_BRAIN_IDS) seen.add(id);
|
|
239
|
+
if (typeof brain.id === 'string') seen.add(brain.id);
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
const ids = new Set(
|
|
243
|
+
list.map((m) => (typeof m.id === 'string' ? m.id.trim() : '')).filter(Boolean)
|
|
244
|
+
);
|
|
245
|
+
const aliasTargets = new Set(
|
|
246
|
+
list.map((m) => aliasOfEntry(m)).filter((t) => t && ids.has(t))
|
|
247
|
+
);
|
|
248
|
+
|
|
249
|
+
for (const m of list) {
|
|
250
|
+
const id = typeof m.id === 'string' ? m.id.trim() : '';
|
|
251
|
+
if (!id || seen.has(id)) continue;
|
|
252
|
+
// A row whose target is present is a duplicate pin, not a second model.
|
|
253
|
+
// Dropped here rather than per host, so the two hosts cannot disagree.
|
|
254
|
+
if (aliasOfEntry(m) && aliasTargets.has(aliasOfEntry(m))) continue;
|
|
255
|
+
seen.add(id);
|
|
256
|
+
out.push(m);
|
|
257
|
+
}
|
|
258
|
+
return out;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
module.exports = {
|
|
262
|
+
NEXUS_BRAIN_IDS,
|
|
263
|
+
NEXUS_LABEL,
|
|
264
|
+
AEGIS_CLOUD_MODEL_IDS,
|
|
265
|
+
isAegisCloudModel,
|
|
266
|
+
omitAegisCloudModels,
|
|
267
|
+
selectBrainEntry,
|
|
268
|
+
filterAegisCatalog,
|
|
269
|
+
offerableCatalog,
|
|
270
|
+
};
|
|
@@ -1,3 +1,201 @@
|
|
|
1
1
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
2
2
|
// Copyright (C) 2026 Niklas Borneklint — AEGIS Code (aegiscode) / Aegiscloud.
|
|
3
|
-
|
|
3
|
+
// AEGIS Code (aegiscode) — source: https://github.com/aegisinfo/aegiscode-plugin
|
|
4
|
+
// Conveying a modified copy, or running one as a network service, owes the
|
|
5
|
+
// corresponding source under this licence (§5/§13) — see LICENSING.md.
|
|
6
|
+
'use strict';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* BYOK model additions — the models a host OFFERS for a provider that the
|
|
10
|
+
* server's own catalog does not list.
|
|
11
|
+
*
|
|
12
|
+
* ── why a client-side addition is legitimate here, and only here ────────────
|
|
13
|
+
*
|
|
14
|
+
* For the POOLED class it would not be. `client/brain-catalog.js` exists
|
|
15
|
+
* precisely because a host may not invent an id: the pool can only address what
|
|
16
|
+
* it advertises, so an id a client made up would pin, look accepted, and 404 on
|
|
17
|
+
* the first turn. `/api/v1/models` is the whole list, and the rule is "offer
|
|
18
|
+
* what the server sends".
|
|
19
|
+
*
|
|
20
|
+
* BYOK is the opposite shape, and the server says so itself
|
|
21
|
+
* (services/byok_service.py, `byok_provider_catalog`): "the pooled route cannot
|
|
22
|
+
* address it, but BYOK relays whatever model the caller names, so it stays
|
|
23
|
+
* usable and stays listed". The relay is a stateless pass-through — the
|
|
24
|
+
* caller's own vendor key authenticates upstream, and AEGIS forwards the model
|
|
25
|
+
* string it was given. So for a provider the account holds a key for, an id the
|
|
26
|
+
* *vendor* serves is callable whether or not AEGIS's catalog happens to name
|
|
27
|
+
* it. That is the whole reason this file is allowed to exist.
|
|
28
|
+
*
|
|
29
|
+
* ── currently empty, and why that is the intended end state ────────────────
|
|
30
|
+
*
|
|
31
|
+
* Every entry this map ever carried (DeepSeek Flash/Pro, four Claude 5.5-era
|
|
32
|
+
* ids, grok-4.7, gemini-3.8-flash, gpt-5.5) existed because the server derived
|
|
33
|
+
* each provider's `models` from one hand-maintained `default_model` per
|
|
34
|
+
* descriptor (services/nexus_provider/catalog.py) — so the picker trailed
|
|
35
|
+
* whatever the vendor had shipped since that descriptor was last touched.
|
|
36
|
+
*
|
|
37
|
+
* aegis1 commit 208bc9a (2026-10-24) added a database-backed catalog fed by
|
|
38
|
+
* the vendor's own `/v1/models`, OpenRouter, models.dev and LiteLLM, and it
|
|
39
|
+
* was flipped live (`CATALOG_SOURCE=db`) 2026-10-25 — verified against
|
|
40
|
+
* production: `GET /api/v1/byok/providers` now lists every id this map used
|
|
41
|
+
* to hand-add, for all five providers. Deleting them here rather than leaving
|
|
42
|
+
* them as a now-redundant no-op keeps the promise in the comment below
|
|
43
|
+
* (`BYOK_MODEL_ADDITIONS` is deliberately tiny): an entry that merge
|
|
44
|
+
* would silently fold away forever is worse than no entry, because nobody
|
|
45
|
+
* notices a no-op and the next real gap gets lost in it.
|
|
46
|
+
*
|
|
47
|
+
* ── the rules this module keeps ────────────────────────────────────────────
|
|
48
|
+
*
|
|
49
|
+
* - ONE spelling per route. `deepseek-v4.1-flash` is the legacy alias the
|
|
50
|
+
* same regexes accept; listing both would paint two rows that pin one
|
|
51
|
+
* model, which is the "five spellings of one brain" defect the sibling
|
|
52
|
+
* brain-catalog module exists to end. The canonical 4.1 id is
|
|
53
|
+
* `deepseek-flash`, so that is the one added.
|
|
54
|
+
* - NEVER invent a provider. Only a provider the payload already lists is
|
|
55
|
+
* augmented. A provider row is a slot that accepts a vendor key; a row a
|
|
56
|
+
* client fabricated would invite a key for a slug the relay may not accept,
|
|
57
|
+
* and the failure would land on the user's first turn.
|
|
58
|
+
* - Idempotent and non-mutating. A payload that already carries the id comes
|
|
59
|
+
* back with the same provider objects untouched, so this is safe to apply
|
|
60
|
+
* twice (a caller that adds at fetch time and again before rendering cannot
|
|
61
|
+
* double-list) and safe to apply to a shared payload.
|
|
62
|
+
* - The server's order is preserved and additions are APPENDED, so the
|
|
63
|
+
* server's `default_model` keeps its first position — the default is what a
|
|
64
|
+
* bare provider id runs, and a client that reordered it would silently
|
|
65
|
+
* change which model a user gets for typing nothing.
|
|
66
|
+
*
|
|
67
|
+
* Pure: no I/O, no node builtins, no dependencies — requireable from a
|
|
68
|
+
* renderer, the CLI start-up path, the desktop main process, or an MCP host.
|
|
69
|
+
* Shared by the CLI and the desktop through one file for the same reason
|
|
70
|
+
* brain-catalog.js is: two copies is how those two hosts came to show one
|
|
71
|
+
* account two different model lists.
|
|
72
|
+
*/
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* provider id → extra models to offer, in the order to append them.
|
|
76
|
+
*
|
|
77
|
+
* Frozen, and deliberately tiny: every entry here is a claim that the vendor
|
|
78
|
+
* serves an id the AEGIS catalog does not advertise. The durable fix for any of
|
|
79
|
+
* them is the server's MODEL_CATALOG (aegis1 services/nexus_provider/
|
|
80
|
+
* catalog.py) — this map is what keeps the two clients useful until that
|
|
81
|
+
* lands, and an entry must be deleted once the server lists the id itself
|
|
82
|
+
* (`withByokAdditions` then no longer reports it as an addition).
|
|
83
|
+
*/
|
|
84
|
+
const BYOK_MODEL_ADDITIONS = Object.freeze({});
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* provider id → { picker id → the id that provider actually serves }.
|
|
88
|
+
*
|
|
89
|
+
* These are NOT missing models; they are ids that no longer exist on the wire.
|
|
90
|
+
* DeepSeek's `GET /models` returns exactly two ids — `deepseek-flash` (displayed
|
|
91
|
+
* as "DeepSeek-V4.1-Flash") and `deepseek-v4-pro` — and every other spelling
|
|
92
|
+
* 400s with "The supported API model names are deepseek-flash, deepseek-v4-pro".
|
|
93
|
+
* Verified against `POST /v1/chat/completions` on 2026-10-25: the ids below all
|
|
94
|
+
* fail that check.
|
|
95
|
+
*
|
|
96
|
+
* Repairing them HERE, at the moment a model id is put on the wire, is what
|
|
97
|
+
* keeps `deepseek-v4.1-flash` usable as a picker label: "V4.1 Flash" is a real
|
|
98
|
+
* model with a real display name, it is simply reached under a different id.
|
|
99
|
+
* The alternative — deleting the entry — takes a working model away from users
|
|
100
|
+
* over a naming mismatch, and the other alternative — sending it unchanged —
|
|
101
|
+
* fails the user's first turn. Both are worse than one alias table.
|
|
102
|
+
*
|
|
103
|
+
* Only ids that actually 400 are listed. Spelling variants DeepSeek still
|
|
104
|
+
* accepts (`deepseek-v4-flash`, `deepseek-reasoner`, `deepseek-chat`) answer
|
|
105
|
+
* normally and are deliberately absent: rewriting a live id would be a
|
|
106
|
+
* behaviour change nobody asked for, and would hide the day DeepSeek drops it.
|
|
107
|
+
*/
|
|
108
|
+
const WIRE_MODEL_ALIASES = Object.freeze({
|
|
109
|
+
deepseek: Object.freeze({
|
|
110
|
+
'deepseek-v4.1-flash': 'deepseek-flash',
|
|
111
|
+
'deepseek-flash-41': 'deepseek-flash',
|
|
112
|
+
'deepseek-flash-0731': 'deepseek-flash',
|
|
113
|
+
'deepseek-v4-flash-0731': 'deepseek-flash',
|
|
114
|
+
'deepseek-pro': 'deepseek-v4-pro',
|
|
115
|
+
'deepseek-v4-pro-latest': 'deepseek-v4-pro',
|
|
116
|
+
}),
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* The id to send for one provider, given the id the user picked.
|
|
121
|
+
*
|
|
122
|
+
* Returns the input unchanged whenever there is nothing to repair — an unknown
|
|
123
|
+
* provider, an id absent from the table, a non-string, or the canonical id
|
|
124
|
+
* itself — so this is safe to call unconditionally on every request and is
|
|
125
|
+
* idempotent (mapping a canonical id yields that same id).
|
|
126
|
+
*
|
|
127
|
+
* @param {string} providerId the provider the model is being sent to.
|
|
128
|
+
* @param {string} model the model id as selected or configured.
|
|
129
|
+
* @returns {string} the id to put on the wire.
|
|
130
|
+
*/
|
|
131
|
+
function canonicalModelId(providerId, model) {
|
|
132
|
+
const modelId = typeof model === 'string' ? model.trim() : '';
|
|
133
|
+
if (!modelId) return modelId;
|
|
134
|
+
const pid = typeof providerId === 'string' ? providerId.trim() : '';
|
|
135
|
+
const table = pid ? WIRE_MODEL_ALIASES[pid] : null;
|
|
136
|
+
if (!table) return modelId;
|
|
137
|
+
return Object.prototype.hasOwnProperty.call(table, modelId) ? table[modelId] : modelId;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/** The extras to offer for one provider id (an empty array when there are none). */
|
|
141
|
+
function addedModelsFor(providerId) {
|
|
142
|
+
const id = typeof providerId === 'string' ? providerId.trim() : '';
|
|
143
|
+
const extra = id ? BYOK_MODEL_ADDITIONS[id] : null;
|
|
144
|
+
return Array.isArray(extra) ? extra.slice() : [];
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/** The model ids an entry names, tolerating the server's two shapes. */
|
|
148
|
+
function modelIdsOf(provider) {
|
|
149
|
+
return (Array.isArray(provider && provider.models) ? provider.models : [])
|
|
150
|
+
.map((m) => (typeof m === 'string' ? m : m && m.id))
|
|
151
|
+
.map((m) => (typeof m === 'string' ? m.trim() : ''))
|
|
152
|
+
.filter(Boolean);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* The server's BYOK provider catalog with the additions above applied.
|
|
157
|
+
*
|
|
158
|
+
* @param {Array<object>|object} providers the `providers` array from
|
|
159
|
+
* `GET /api/v1/byok/providers`, or the whole `{providers: [...]}` payload.
|
|
160
|
+
* @returns {Array<object>} a new array; provider objects are shared unless the
|
|
161
|
+
* row actually gained a model, and an empty/absent payload returns `[]`
|
|
162
|
+
* rather than a fabricated catalog.
|
|
163
|
+
*/
|
|
164
|
+
function withByokAdditions(providers) {
|
|
165
|
+
const raw = Array.isArray(providers)
|
|
166
|
+
? providers
|
|
167
|
+
: Array.isArray(providers && providers.providers)
|
|
168
|
+
? providers.providers
|
|
169
|
+
: null;
|
|
170
|
+
if (!raw) return [];
|
|
171
|
+
|
|
172
|
+
const out = [];
|
|
173
|
+
for (const p of raw) {
|
|
174
|
+
if (!p || typeof p !== 'object') continue;
|
|
175
|
+
const id = typeof p.id === 'string' ? p.id.trim() : '';
|
|
176
|
+
const extra = id ? BYOK_MODEL_ADDITIONS[id] : null;
|
|
177
|
+
if (!Array.isArray(extra) || !extra.length) {
|
|
178
|
+
out.push(p);
|
|
179
|
+
continue;
|
|
180
|
+
}
|
|
181
|
+
const have = new Set(modelIdsOf(p));
|
|
182
|
+
const missing = extra.filter((m) => !have.has(m));
|
|
183
|
+
// Nothing to add: hand back the SAME object, so an already-complete payload
|
|
184
|
+
// is byte-identical after this pass and callers cannot tell it ran.
|
|
185
|
+
if (!missing.length) {
|
|
186
|
+
out.push(p);
|
|
187
|
+
continue;
|
|
188
|
+
}
|
|
189
|
+
const models = Array.isArray(p.models) ? p.models : [];
|
|
190
|
+
out.push({ ...p, models: [...models, ...missing] });
|
|
191
|
+
}
|
|
192
|
+
return out;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
module.exports = {
|
|
196
|
+
BYOK_MODEL_ADDITIONS,
|
|
197
|
+
WIRE_MODEL_ALIASES,
|
|
198
|
+
addedModelsFor,
|
|
199
|
+
canonicalModelId,
|
|
200
|
+
withByokAdditions,
|
|
201
|
+
};
|