aegiscode 7.0.14 → 7.0.15
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/SOURCE-OFFER.txt +9 -0
- package/package.json +3 -2
- package/scripts/check.mjs +1 -52
- package/scripts/demo.mjs +1 -94
- package/scripts/predist.mjs +1 -75
- package/scripts/runtests.mjs +1 -56
- package/scripts/seal-gate.mjs +1 -74
- package/src/agents.js +1 -139
- package/src/app.js +1 -2932
- package/src/art.js +1 -289
- package/src/chatflow.js +1 -3020
- package/src/checkpoint.js +1 -90
- package/src/clipboard.js +1 -424
- package/src/cloudsync.js +1 -528
- package/src/commands.js +1 -4003
- package/src/config.js +1 -581
- package/src/connect.js +1 -349
- package/src/credentials.js +1 -33
- package/src/deps.js +1 -232
- package/src/devrun.js +1 -187
- package/src/diff.js +1 -333
- package/src/diffview.js +1 -296
- package/src/engine.js +1 -297
- package/src/entitlement.js +1 -355
- package/src/events.js +1 -707
- package/src/export.js +1 -67
- package/src/fingerprint.js +1 -592
- package/src/format.js +1 -259
- package/src/fuzzy.js +1 -119
- package/src/history.js +1 -401
- package/src/init.js +1 -175
- package/src/input.js +1 -139
- package/src/keys.js +1 -183
- package/src/markdown.js +1 -306
- package/src/models.js +1 -487
- package/src/naming.js +1 -229
- package/src/overlays.js +1 -461
- package/src/panels.js +1 -1418
- package/src/ping.js +1 -226
- package/src/presence.js +1 -238
- package/src/render.js +1 -515
- package/src/screen.js +1 -518
- package/src/screens.js +1 -896
- package/src/secret.js +1 -59
- package/src/securefs.js +1 -359
- package/src/settings.js +1 -155
- package/src/shared.js +1 -52
- package/src/sharedpaths.js +1 -53
- package/src/signup.js +1 -156
- package/src/summarize.js +1 -95
- package/src/sysdiag.js +1 -585
- package/src/system.js +1 -40
- package/src/theme.js +1 -570
- package/src/title.js +1 -220
- package/src/todos.js +1 -115
- package/src/tokens.js +1 -263
- package/src/topup.js +1 -210
- package/src/update.js +1 -181
- package/vendor/client/aegis.js +1 -2179
- package/vendor/client/attest.js +1 -442
- package/vendor/client/authorship-key.js +1 -410
- package/vendor/client/auto-provision.js +1 -134
- package/vendor/client/brain-catalog.js +1 -268
- package/vendor/client/byok-catalog.js +1 -230
- package/vendor/client/credentials.js +1 -494
- package/vendor/client/device-fingerprint.js +1 -141
- package/vendor/client/drive-connect.js +1 -110
- package/vendor/client/drive-upload.js +1 -174
- package/vendor/client/env-file.js +1 -1273
- package/vendor/client/fingerprint.js +1 -1064
- package/vendor/client/foreign-memory.js +1 -669
- package/vendor/client/google-signin.js +1 -133
- package/vendor/client/hooks.js +1 -430
- package/vendor/client/model-discovery.js +1 -373
- package/vendor/client/platform.js +1 -937
- package/vendor/client/prefs.js +1 -351
- package/vendor/client/presence-constants.js +1 -107
- package/vendor/client/presence.js +1 -438
- package/vendor/client/record-vault.js +3 -1055
- package/vendor/client/session-store.js +1 -548
- package/vendor/client/topup.js +1 -297
- package/vendor/client/touch.js +1 -458
- package/vendor/client/update.js +1 -704
- package/vendor/client/user-models.js +1 -381
- package/vendor/desktop/lib/local/agents.js +1 -105
- package/vendor/desktop/lib/local/autonomous.js +1 -1045
- package/vendor/desktop/lib/local/claude-pro.js +1 -993
- package/vendor/desktop/lib/local/context.js +1 -95
- package/vendor/desktop/lib/local/engine.js +1 -3301
- package/vendor/desktop/lib/local/entitlement.js +1 -660
- package/vendor/desktop/lib/local/git-scope.js +1 -228
- package/vendor/desktop/lib/local/local.js +1 -2135
- package/vendor/desktop/lib/local/prompt.js +1 -275
- package/vendor/desktop/lib/local/queue.js +1 -560
- package/vendor/desktop/lib/local/session-rounds.js +1 -208
- package/vendor/desktop/lib/local/shell.js +1 -680
- package/vendor/desktop/lib/local/tools.js +1 -1238
- package/vendor/desktop/lib/local/turn-guard.js +1 -300
- package/vendor/desktop/lib/local/worktree-lock.js +1 -235
- package/vendor/desktop/lib/settings.js +1 -890
- package/vendor/desktop/renderer/usage.js +1 -1239
- package/vendor/hosts/install.js +1 -638
- package/vendor/hosts/openai-shim.js +1 -515
- package/vendor/hosts/spec.js +1 -164
- package/vendor/hosts/targets.js +1 -346
- package/vendor/mcp/server.js +1 -221
- package/vendor/mcp/tools.js +1 -408
- package/vendor/one/src/child.js +1 -285
- package/vendor/one/src/permissions.js +1 -369
|
@@ -1,270 +1,3 @@
|
|
|
1
1
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
2
2
|
// Copyright (C) 2026 Niklas Borneklint — AEGIS Code (aegiscode) / Aegiscloud.
|
|
3
|
-
|
|
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
|
-
};
|
|
3
|
+
"use strict";const NEXUS_BRAIN_IDS=Object.freeze(["nexus-brain","aegis-brain"]),AEGIS_CLOUD_MODEL_IDS=Object.freeze(["nexus-brain","aegis-brain","nexus-brain-smart","aegis-brain-smart","nexus-brain-neo","aegis-brain-neo"]),AEGIS_CLOUD_MODEL_RE=/^(?:nexus|aegis)-brain(?:-(?:smart|neo))?$/,NEXUS_LABEL="Nexus";function aliasOfEntry(e){if(!e||"object"!=typeof e)return null;for(const i of[e.alias_of,e.aliasOf])if("string"==typeof i&&i.trim())return i.trim();return null}function isHiddenEntry(e){return Boolean(e)&&!0===e.hidden}function selectBrainEntry(e){const i=Array.isArray(e)?e.filter(Boolean):[];return i.find((e=>NEXUS_BRAIN_IDS.includes(e.id)&&!isHiddenEntry(e)&&null===aliasOfEntry(e)))||i.find((e=>NEXUS_BRAIN_IDS.includes(e.id)))||i.find((e=>NEXUS_BRAIN_IDS.includes(aliasOfEntry(e))))||null}function filterAegisCatalog(e){const i=selectBrainEntry(e);if(!i)return[];const{hidden:n,alias_of:t,aliasOf:r,...s}=i;return[{...s,label:"Nexus"}]}function isAegisCloudModel(e){const i="string"==typeof e?e.trim():e&&"object"==typeof e&&"string"==typeof e.id?e.id.trim():"";return!!AEGIS_CLOUD_MODEL_IDS.includes(i)||!!AEGIS_CLOUD_MODEL_RE.test(i)||NEXUS_BRAIN_IDS.includes(aliasOfEntry(e))}function omitAegisCloudModels(e){return(Array.isArray(e)?e:[]).filter((e=>{if(!e)return!1;if("string"==typeof e)return!isAegisCloudModel(e);const i="string"==typeof e.id?e.id.trim():"";return Boolean(i)&&!isAegisCloudModel(e)}))}function offerableCatalog(e){const i=Array.isArray(e)?e.filter(Boolean):[];if(!i.length)return[];const n=selectBrainEntry(i),t=[],r=new Set;if(n){const{hidden:e,alias_of:i,aliasOf:s,...o}=n;t.push({...o,label:"Nexus"});for(const e of NEXUS_BRAIN_IDS)r.add(e);"string"==typeof n.id&&r.add(n.id)}const s=new Set(i.map((e=>"string"==typeof e.id?e.id.trim():"")).filter(Boolean)),o=new Set(i.map((e=>aliasOfEntry(e))).filter((e=>e&&s.has(e))));for(const e of i){const i="string"==typeof e.id?e.id.trim():"";i&&!r.has(i)&&(aliasOfEntry(e)&&o.has(aliasOfEntry(e))||(r.add(i),t.push(e)))}return t}module.exports={NEXUS_BRAIN_IDS:NEXUS_BRAIN_IDS,NEXUS_LABEL:"Nexus",AEGIS_CLOUD_MODEL_IDS:AEGIS_CLOUD_MODEL_IDS,isAegisCloudModel:isAegisCloudModel,omitAegisCloudModels:omitAegisCloudModels,selectBrainEntry:selectBrainEntry,filterAegisCatalog:filterAegisCatalog,offerableCatalog:offerableCatalog};
|
|
@@ -1,232 +1,3 @@
|
|
|
1
1
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
2
2
|
// Copyright (C) 2026 Niklas Borneklint — AEGIS Code (aegiscode) / Aegiscloud.
|
|
3
|
-
|
|
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
|
-
* ── what was actually missing ──────────────────────────────────────────────
|
|
30
|
-
*
|
|
31
|
-
* The server derives each provider's `models` from MODEL_CATALOG, and for
|
|
32
|
-
* `deepseek` that catalog holds one descriptor (`default_model
|
|
33
|
-
* "deepseek-v4-flash"`, services/nexus_provider/catalog.py). Verified live
|
|
34
|
-
* 2026-09-18: `GET https://aegiscloud.org/api/v1/byok/providers` answers
|
|
35
|
-
* `deepseek` with `models: ["deepseek-v4-flash"]` and nothing else.
|
|
36
|
-
*
|
|
37
|
-
* So a user who brought a DeepSeek key saw exactly one pinnable model, and the
|
|
38
|
-
* 4.1 Flash — `deepseek-flash`, the spelling whose rate row, reasoning-token
|
|
39
|
-
* budget and effort rung this repo ALREADY carries (desktop/renderer/
|
|
40
|
-
* budget.js, desktop/lib/local/engine.js DEEPSEEK_REASONING_MODEL_RE, and the
|
|
41
|
-
* rate table in desktop/renderer/usage.js: "deepseek-flash, i.e. Flash 4.1")
|
|
42
|
-
* — was unreachable from the picker, with no hint that the key they had just
|
|
43
|
-
* pasted could call it.
|
|
44
|
-
*
|
|
45
|
-
* ── the rules this module keeps ────────────────────────────────────────────
|
|
46
|
-
*
|
|
47
|
-
* - ONE spelling per route. `deepseek-v4.1-flash` is the legacy alias the
|
|
48
|
-
* same regexes accept; listing both would paint two rows that pin one
|
|
49
|
-
* model, which is the "five spellings of one brain" defect the sibling
|
|
50
|
-
* brain-catalog module exists to end. The canonical 4.1 id is
|
|
51
|
-
* `deepseek-flash`, so that is the one added.
|
|
52
|
-
* - NEVER invent a provider. Only a provider the payload already lists is
|
|
53
|
-
* augmented. A provider row is a slot that accepts a vendor key; a row a
|
|
54
|
-
* client fabricated would invite a key for a slug the relay may not accept,
|
|
55
|
-
* and the failure would land on the user's first turn.
|
|
56
|
-
* - Idempotent and non-mutating. A payload that already carries the id comes
|
|
57
|
-
* back with the same provider objects untouched, so this is safe to apply
|
|
58
|
-
* twice (a caller that adds at fetch time and again before rendering cannot
|
|
59
|
-
* double-list) and safe to apply to a shared payload.
|
|
60
|
-
* - The server's order is preserved and additions are APPENDED, so the
|
|
61
|
-
* server's `default_model` keeps its first position — the default is what a
|
|
62
|
-
* bare provider id runs, and a client that reordered it would silently
|
|
63
|
-
* change which model a user gets for typing nothing.
|
|
64
|
-
*
|
|
65
|
-
* Pure: no I/O, no node builtins, no dependencies — requireable from a
|
|
66
|
-
* renderer, the CLI start-up path, the desktop main process, or an MCP host.
|
|
67
|
-
* Shared by the CLI and the desktop through one file for the same reason
|
|
68
|
-
* brain-catalog.js is: two copies is how those two hosts came to show one
|
|
69
|
-
* account two different model lists.
|
|
70
|
-
*/
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* provider id → extra models to offer, in the order to append them.
|
|
74
|
-
*
|
|
75
|
-
* Frozen, and deliberately tiny: every entry here is a claim that the vendor
|
|
76
|
-
* serves an id the AEGIS catalog does not advertise. The durable fix for any of
|
|
77
|
-
* them is the server's MODEL_CATALOG (aegis1 services/nexus_provider/
|
|
78
|
-
* catalog.py) — this map is what keeps the two clients useful until that
|
|
79
|
-
* lands, and an entry must be deleted once the server lists the id itself
|
|
80
|
-
* (`withByokAdditions` then no longer reports it as an addition).
|
|
81
|
-
*/
|
|
82
|
-
const BYOK_MODEL_ADDITIONS = Object.freeze({
|
|
83
|
-
// DeepSeek's 4.1 Flash. `deepseek-flash` is the spelling DeepSeek's own
|
|
84
|
-
// current API uses and the one this repo's rate table, token-budget and
|
|
85
|
-
// reasoning-model regexes all already key off; `deepseek-v4.1-flash` is the
|
|
86
|
-
// retired alias for the same route and is NOT listed separately.
|
|
87
|
-
deepseek: Object.freeze([
|
|
88
|
-
'deepseek-flash',
|
|
89
|
-
// DeepSeek-V4-Pro — a DISTINCT, pricier Pro route (not an alias of Flash),
|
|
90
|
-
// which DeepSeek's current API serves as `deepseek-v4-pro` alongside
|
|
91
|
-
// `deepseek-flash`. The server's BYOK catalog still advertises only the
|
|
92
|
-
// legacy `deepseek-v4-flash` alias, so without this row a DeepSeek key can
|
|
93
|
-
// never pin the Pro model from the picker even though the rate table
|
|
94
|
-
// (desktop/renderer/usage.js `deepseek-v4-pro`) and the reasoning regex
|
|
95
|
-
// already know it. Added here rather than behind the server because the
|
|
96
|
-
// relay forwards whatever model the caller names.
|
|
97
|
-
'deepseek-v4-pro',
|
|
98
|
-
]),
|
|
99
|
-
// Anthropic's `anthropic` descriptor (aegis1 services/nexus_provider/
|
|
100
|
-
// catalog.py) pins exactly one default_model, `claude-sonnet-5`, and
|
|
101
|
-
// `anthropic-haiku` pins `claude-haiku-4-5` as its own provider row — so
|
|
102
|
-
// between them an Anthropic BYOK key could pin Sonnet or Haiku but never
|
|
103
|
-
// Opus or Fable, the other two members of the Claude 5 lineup the vendor
|
|
104
|
-
// already serves. Listed under the `anthropic` provider id because that is
|
|
105
|
-
// the row the server advertises a configured Anthropic key against — the
|
|
106
|
-
// relay forwards whichever of these names the caller actually pins.
|
|
107
|
-
//
|
|
108
|
-
// Verified live 2026-10-11 against `GET https://api.anthropic.com/v1/models`
|
|
109
|
-
// (14 ids, `has_more: false`), which is where every id below is copied from
|
|
110
|
-
// rather than from memory:
|
|
111
|
-
//
|
|
112
|
-
// claude-haiku-5-5, claude-sonnet-5-5, claude-opus-5-5, claude-fable-5-1,
|
|
113
|
-
// claude-opus-5, claude-sonnet-5, claude-fable-5, claude-opus-4-8,
|
|
114
|
-
// claude-opus-4-7, claude-sonnet-4-6, claude-opus-4-6,
|
|
115
|
-
// claude-opus-4-5-20251101, claude-haiku-4-5-20251001,
|
|
116
|
-
// claude-sonnet-4-5-20250929
|
|
117
|
-
//
|
|
118
|
-
// The server's two defaults cover `claude-sonnet-5` and `claude-haiku-4-5`;
|
|
119
|
-
// the five below are the CURRENT members of the lineup it does not name —
|
|
120
|
-
// the 5.5 generation (Haiku, Sonnet, Opus) plus Fable 5.1, and the older
|
|
121
|
-
// Opus 5 / Fable 5 that were already listed. Every one has a priced rate row
|
|
122
|
-
// (desktop/renderer/usage.js, the Claude 5 block), so the picker was missing
|
|
123
|
-
// the ability to OFFER them, not a rate.
|
|
124
|
-
//
|
|
125
|
-
// What is deliberately NOT here, and why it matters more than what is:
|
|
126
|
-
// `claude-opus-4-1` (and its dated form `claude-opus-4-1-20250805`) is
|
|
127
|
-
// RETIRED upstream. Probed live 2026-10-11, `POST /v1/messages` with that
|
|
128
|
-
// model answers HTTP 404 `not_found_error` — the same probe answers
|
|
129
|
-
// `rate_limit_error` (i.e. the model resolved) for every id listed above,
|
|
130
|
-
// which is what makes 404 mean "no such model" rather than "no credit".
|
|
131
|
-
// The engine's own MODELS table still carries a legacy `claude-opus-4-1`
|
|
132
|
-
// row for saved configs, and that is fine — it is a local label that
|
|
133
|
-
// RESOLVES; a client-side catalog addition is a promise the picker will pin
|
|
134
|
-
// and the relay will forward, and this module's whole reason for existing is
|
|
135
|
-
// that a fabricated id "would pin, look accepted, and 404 on the first
|
|
136
|
-
// turn". So Opus 4.1 stays out of the offered list until Anthropic serves
|
|
137
|
-
// it again.
|
|
138
|
-
anthropic: Object.freeze([
|
|
139
|
-
'claude-opus-5',
|
|
140
|
-
'claude-fable-5',
|
|
141
|
-
'claude-opus-5-5',
|
|
142
|
-
'claude-sonnet-5-5',
|
|
143
|
-
'claude-haiku-5-5',
|
|
144
|
-
'claude-fable-5-1',
|
|
145
|
-
]),
|
|
146
|
-
// xAI's `grok` descriptor still pins `grok-4.5` as default_model — current
|
|
147
|
-
// when that descriptor was written, but xAI has since shipped grok-4.6 and
|
|
148
|
-
// grok-4.7 (flagship, Sept 2026) on the same `grok-4.5`-shaped id
|
|
149
|
-
// (api.x.ai/v1, model=`grok-4.7`). A Grok BYOK key could not reach either
|
|
150
|
-
// newer model from the picker even though the relay forwards whatever name
|
|
151
|
-
// it is given. Only the current flagship is listed — 4.6 sits strictly
|
|
152
|
-
// between the already-offered 4.5 and 4.7 at the same per-token rate as 4.7,
|
|
153
|
-
// so a second row would not unlock any capability or price point 4.7 doesn't.
|
|
154
|
-
grok: Object.freeze(['grok-4.7']),
|
|
155
|
-
// Google's `gemini` descriptor pins `gemini-3.5-flash`. Google has since
|
|
156
|
-
// shipped gemini-3.6-flash, gemini-3.7-flash and gemini-3.8-flash (GA,
|
|
157
|
-
// 2026-09-02) on the same family; no Gemini 3.x Pro tier has shipped (the
|
|
158
|
-
// announced 3.5 Pro was delayed indefinitely), so Flash is the whole
|
|
159
|
-
// lineup. Only the current GA flagship is listed, for the same "one
|
|
160
|
-
// spelling per route" reason as the others above.
|
|
161
|
-
gemini: Object.freeze(['gemini-3.8-flash']),
|
|
162
|
-
// OpenAI's `openai` and `openai-gpt4o-mini` descriptors both pin
|
|
163
|
-
// `gpt-5-mini` — a cheap/fast tier, not the general-purpose flagship. An
|
|
164
|
-
// OpenAI BYOK key could pin the mini tier but never the current flagship
|
|
165
|
-
// chat model, `gpt-5.5` (api.openai.com/v1, released 2026-04-23). The two
|
|
166
|
-
// provider ids share one credential and one model, so the server's BYOK
|
|
167
|
-
// catalog already lists `gpt-5-mini` twice for one OpenAI key; listed under
|
|
168
|
-
// `openai` only, not also under `openai-gpt4o-mini`, so this addition does
|
|
169
|
-
// not compound that into two flagship rows for the same key.
|
|
170
|
-
openai: Object.freeze(['gpt-5.5']),
|
|
171
|
-
});
|
|
172
|
-
|
|
173
|
-
/** The extras to offer for one provider id (an empty array when there are none). */
|
|
174
|
-
function addedModelsFor(providerId) {
|
|
175
|
-
const id = typeof providerId === 'string' ? providerId.trim() : '';
|
|
176
|
-
const extra = id ? BYOK_MODEL_ADDITIONS[id] : null;
|
|
177
|
-
return Array.isArray(extra) ? extra.slice() : [];
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
/** The model ids an entry names, tolerating the server's two shapes. */
|
|
181
|
-
function modelIdsOf(provider) {
|
|
182
|
-
return (Array.isArray(provider && provider.models) ? provider.models : [])
|
|
183
|
-
.map((m) => (typeof m === 'string' ? m : m && m.id))
|
|
184
|
-
.map((m) => (typeof m === 'string' ? m.trim() : ''))
|
|
185
|
-
.filter(Boolean);
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
/**
|
|
189
|
-
* The server's BYOK provider catalog with the additions above applied.
|
|
190
|
-
*
|
|
191
|
-
* @param {Array<object>|object} providers the `providers` array from
|
|
192
|
-
* `GET /api/v1/byok/providers`, or the whole `{providers: [...]}` payload.
|
|
193
|
-
* @returns {Array<object>} a new array; provider objects are shared unless the
|
|
194
|
-
* row actually gained a model, and an empty/absent payload returns `[]`
|
|
195
|
-
* rather than a fabricated catalog.
|
|
196
|
-
*/
|
|
197
|
-
function withByokAdditions(providers) {
|
|
198
|
-
const raw = Array.isArray(providers)
|
|
199
|
-
? providers
|
|
200
|
-
: Array.isArray(providers && providers.providers)
|
|
201
|
-
? providers.providers
|
|
202
|
-
: null;
|
|
203
|
-
if (!raw) return [];
|
|
204
|
-
|
|
205
|
-
const out = [];
|
|
206
|
-
for (const p of raw) {
|
|
207
|
-
if (!p || typeof p !== 'object') continue;
|
|
208
|
-
const id = typeof p.id === 'string' ? p.id.trim() : '';
|
|
209
|
-
const extra = id ? BYOK_MODEL_ADDITIONS[id] : null;
|
|
210
|
-
if (!Array.isArray(extra) || !extra.length) {
|
|
211
|
-
out.push(p);
|
|
212
|
-
continue;
|
|
213
|
-
}
|
|
214
|
-
const have = new Set(modelIdsOf(p));
|
|
215
|
-
const missing = extra.filter((m) => !have.has(m));
|
|
216
|
-
// Nothing to add: hand back the SAME object, so an already-complete payload
|
|
217
|
-
// is byte-identical after this pass and callers cannot tell it ran.
|
|
218
|
-
if (!missing.length) {
|
|
219
|
-
out.push(p);
|
|
220
|
-
continue;
|
|
221
|
-
}
|
|
222
|
-
const models = Array.isArray(p.models) ? p.models : [];
|
|
223
|
-
out.push({ ...p, models: [...models, ...missing] });
|
|
224
|
-
}
|
|
225
|
-
return out;
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
module.exports = {
|
|
229
|
-
BYOK_MODEL_ADDITIONS,
|
|
230
|
-
addedModelsFor,
|
|
231
|
-
withByokAdditions,
|
|
232
|
-
};
|
|
3
|
+
"use strict";const BYOK_MODEL_ADDITIONS=Object.freeze({deepseek:Object.freeze(["deepseek-flash","deepseek-v4-pro"]),anthropic:Object.freeze(["claude-opus-5","claude-fable-5","claude-opus-5-5","claude-sonnet-5-5","claude-haiku-5-5","claude-fable-5-1"]),grok:Object.freeze(["grok-4.7"]),gemini:Object.freeze(["gemini-3.8-flash"]),openai:Object.freeze(["gpt-5.5"])});function addedModelsFor(e){const r="string"==typeof e?e.trim():"",o=r?BYOK_MODEL_ADDITIONS[r]:null;return Array.isArray(o)?o.slice():[]}function modelIdsOf(e){return(Array.isArray(e&&e.models)?e.models:[]).map((e=>"string"==typeof e?e:e&&e.id)).map((e=>"string"==typeof e?e.trim():"")).filter(Boolean)}function withByokAdditions(e){const r=Array.isArray(e)?e:Array.isArray(e&&e.providers)?e.providers:null;if(!r)return[];const o=[];for(const e of r){if(!e||"object"!=typeof e)continue;const r="string"==typeof e.id?e.id.trim():"",t=r?BYOK_MODEL_ADDITIONS[r]:null;if(!Array.isArray(t)||!t.length){o.push(e);continue}const s=new Set(modelIdsOf(e)),i=t.filter((e=>!s.has(e)));if(!i.length){o.push(e);continue}const n=Array.isArray(e.models)?e.models:[];o.push({...e,models:[...n,...i]})}return o}module.exports={BYOK_MODEL_ADDITIONS:BYOK_MODEL_ADDITIONS,addedModelsFor:addedModelsFor,withByokAdditions:withByokAdditions};
|