aegiscode 7.0.26 → 7.0.28

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.
Files changed (118) hide show
  1. package/SOURCE-OFFER.txt +9 -0
  2. package/package.json +4 -7
  3. package/scripts/check.mjs +1 -52
  4. package/scripts/demo.mjs +1 -94
  5. package/scripts/predist.mjs +1 -75
  6. package/scripts/runtests.mjs +1 -56
  7. package/scripts/seal-gate.mjs +1 -74
  8. package/src/agents.js +1 -139
  9. package/src/app.js +1 -2957
  10. package/src/art.js +1 -289
  11. package/src/chatflow.js +1 -3023
  12. package/src/checkpoint.js +1 -90
  13. package/src/clipboard.js +1 -424
  14. package/src/cloudsync.js +1 -528
  15. package/src/commands.js +1 -4089
  16. package/src/config.js +1 -581
  17. package/src/connect.js +1 -349
  18. package/src/credentials.js +1 -33
  19. package/src/deps.js +1 -232
  20. package/src/devrun.js +1 -187
  21. package/src/diff.js +1 -333
  22. package/src/diffview.js +1 -296
  23. package/src/engine.js +1 -297
  24. package/src/entitlement.js +1 -355
  25. package/src/events.js +1 -707
  26. package/src/export.js +1 -67
  27. package/src/filepreview.js +1 -153
  28. package/src/fingerprint.js +1 -592
  29. package/src/format.js +1 -259
  30. package/src/fuzzy.js +1 -119
  31. package/src/history.js +1 -423
  32. package/src/init.js +1 -175
  33. package/src/input.js +1 -139
  34. package/src/keys.js +1 -183
  35. package/src/markdown.js +1 -306
  36. package/src/models.js +1 -507
  37. package/src/naming.js +1 -57
  38. package/src/overlays.js +1 -462
  39. package/src/panels.js +1 -1418
  40. package/src/ping.js +1 -226
  41. package/src/presence.js +1 -238
  42. package/src/render.js +1 -516
  43. package/src/screen.js +1 -518
  44. package/src/screens.js +1 -896
  45. package/src/secret.js +1 -59
  46. package/src/securefs.js +1 -359
  47. package/src/settings.js +1 -155
  48. package/src/shared.js +1 -52
  49. package/src/sharedpaths.js +1 -53
  50. package/src/signup.js +1 -156
  51. package/src/summarize.js +1 -95
  52. package/src/sysdiag.js +1 -585
  53. package/src/system.js +1 -40
  54. package/src/theme.js +1 -570
  55. package/src/title.js +1 -220
  56. package/src/todos.js +1 -115
  57. package/src/tokens.js +1 -263
  58. package/src/topup.js +1 -210
  59. package/src/update.js +1 -191
  60. package/vendor/client/aegis.js +1 -2441
  61. package/vendor/client/attest.js +1 -518
  62. package/vendor/client/authorship-key.js +1 -410
  63. package/vendor/client/auto-provision.js +1 -134
  64. package/vendor/client/brain-catalog.js +1 -268
  65. package/vendor/client/byok-catalog.js +1 -199
  66. package/vendor/client/catalog-client.js +1 -487
  67. package/vendor/client/conversation-export.js +1 -177
  68. package/vendor/client/credentials.js +1 -494
  69. package/vendor/client/device-fingerprint.js +1 -141
  70. package/vendor/client/drive-connect.js +1 -110
  71. package/vendor/client/drive-upload.js +1 -234
  72. package/vendor/client/env-file.js +1 -1273
  73. package/vendor/client/fingerprint.js +1 -1064
  74. package/vendor/client/foreign-memory.js +1 -669
  75. package/vendor/client/google-signin.js +1 -133
  76. package/vendor/client/hooks.js +1 -430
  77. package/vendor/client/model-discovery.js +1 -373
  78. package/vendor/client/naming.js +1 -283
  79. package/vendor/client/platform.js +1 -937
  80. package/vendor/client/prefs.js +1 -351
  81. package/vendor/client/presence-constants.js +1 -107
  82. package/vendor/client/presence.js +1 -438
  83. package/vendor/client/record-vault.js +3 -1055
  84. package/vendor/client/session-store.js +1 -575
  85. package/vendor/client/topup.js +1 -297
  86. package/vendor/client/touch.js +1 -458
  87. package/vendor/client/update.js +1 -763
  88. package/vendor/client/user-models.js +1 -381
  89. package/vendor/desktop/lib/local/agents.js +1 -105
  90. package/vendor/desktop/lib/local/attachments.js +1 -276
  91. package/vendor/desktop/lib/local/autonomous.js +1 -1045
  92. package/vendor/desktop/lib/local/claude-pro.js +1 -1028
  93. package/vendor/desktop/lib/local/context.js +1 -125
  94. package/vendor/desktop/lib/local/engine.js +1 -3666
  95. package/vendor/desktop/lib/local/entitlement.js +1 -660
  96. package/vendor/desktop/lib/local/exec-plan.js +1 -269
  97. package/vendor/desktop/lib/local/git-scope.js +1 -228
  98. package/vendor/desktop/lib/local/integrity.js +1 -163
  99. package/vendor/desktop/lib/local/local.js +1 -2145
  100. package/vendor/desktop/lib/local/prompt.js +1 -280
  101. package/vendor/desktop/lib/local/queue.js +1 -560
  102. package/vendor/desktop/lib/local/session-rounds.js +1 -238
  103. package/vendor/desktop/lib/local/shell.js +1 -712
  104. package/vendor/desktop/lib/local/spill.js +1 -75
  105. package/vendor/desktop/lib/local/tools.js +1 -1328
  106. package/vendor/desktop/lib/local/turn-guard.js +1 -300
  107. package/vendor/desktop/lib/local/worktree-lock.js +1 -235
  108. package/vendor/desktop/lib/settings.js +1 -890
  109. package/vendor/desktop/main.js +1 -4890
  110. package/vendor/desktop/renderer/usage.js +1 -1239
  111. package/vendor/hosts/install.js +1 -638
  112. package/vendor/hosts/openai-shim.js +1 -515
  113. package/vendor/hosts/spec.js +1 -164
  114. package/vendor/hosts/targets.js +1 -346
  115. package/vendor/mcp/server.js +1 -221
  116. package/vendor/mcp/tools.js +1 -408
  117. package/vendor/one/src/child.js +1 -285
  118. package/vendor/one/src/permissions.js +1 -383
@@ -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
- // 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
- };
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,201 +1,3 @@
1
1
  // SPDX-License-Identifier: AGPL-3.0-or-later
2
2
  // Copyright (C) 2026 Niklas Borneklint — AEGIS Code (aegiscode) / Aegiscloud.
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
- };
3
+ "use strict";const BYOK_MODEL_ADDITIONS=Object.freeze({}),WIRE_MODEL_ALIASES=Object.freeze({deepseek:Object.freeze({"deepseek-v4.1-flash":"deepseek-flash","deepseek-flash-41":"deepseek-flash","deepseek-flash-0731":"deepseek-flash","deepseek-v4-flash-0731":"deepseek-flash","deepseek-pro":"deepseek-v4-pro","deepseek-v4-pro-latest":"deepseek-v4-pro"})});function canonicalModelId(e,r){const s="string"==typeof r?r.trim():"";if(!s)return s;const o="string"==typeof e?e.trim():"",t=o?WIRE_MODEL_ALIASES[o]:null;return t&&Object.prototype.hasOwnProperty.call(t,s)?t[s]:s}function addedModelsFor(e){const r="string"==typeof e?e.trim():"",s=r?BYOK_MODEL_ADDITIONS[r]:null;return Array.isArray(s)?s.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 s=[];for(const e of r){if(!e||"object"!=typeof e)continue;const r="string"==typeof e.id?e.id.trim():"",o=r?BYOK_MODEL_ADDITIONS[r]:null;if(!Array.isArray(o)||!o.length){s.push(e);continue}const t=new Set(modelIdsOf(e)),n=o.filter((e=>!t.has(e)));if(!n.length){s.push(e);continue}const d=Array.isArray(e.models)?e.models:[];s.push({...e,models:[...d,...n]})}return s}module.exports={BYOK_MODEL_ADDITIONS:BYOK_MODEL_ADDITIONS,WIRE_MODEL_ALIASES:WIRE_MODEL_ALIASES,addedModelsFor:addedModelsFor,canonicalModelId:canonicalModelId,withByokAdditions:withByokAdditions};