aegiscode 7.0.0 → 7.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (109) hide show
  1. package/bin/aegiscode.js +137 -0
  2. package/package.json +1 -1
  3. package/scripts/check.mjs +5 -0
  4. package/scripts/demo.mjs +5 -0
  5. package/scripts/predist.mjs +29 -2
  6. package/scripts/runtests.mjs +5 -0
  7. package/scripts/seal-gate.mjs +76 -0
  8. package/src/agents.js +5 -0
  9. package/src/app.js +5 -0
  10. package/src/art.js +5 -0
  11. package/src/autonomous.js +23 -0
  12. package/src/caps.js +5 -0
  13. package/src/chatflow.js +104 -31
  14. package/src/checkpoint.js +5 -0
  15. package/src/clipboard.js +5 -0
  16. package/src/cloudsync.js +5 -0
  17. package/src/commands.js +326 -14
  18. package/src/config.js +5 -0
  19. package/src/credentials.js +5 -0
  20. package/src/deps.js +5 -0
  21. package/src/devrun.js +5 -0
  22. package/src/diff.js +5 -0
  23. package/src/diffview.js +5 -0
  24. package/src/engine.js +5 -0
  25. package/src/entitlement.js +5 -0
  26. package/src/events.js +15 -0
  27. package/src/export.js +5 -0
  28. package/src/fingerprint.js +5 -0
  29. package/src/format.js +5 -0
  30. package/src/fuzzy.js +5 -0
  31. package/src/gate.js +12 -0
  32. package/src/history.js +5 -0
  33. package/src/init.js +5 -0
  34. package/src/input.js +5 -0
  35. package/src/keys.js +29 -2
  36. package/src/limits.js +192 -0
  37. package/src/markdown.js +5 -0
  38. package/src/mcp.js +13 -0
  39. package/src/models.js +5 -0
  40. package/src/naming.js +5 -0
  41. package/src/overlays.js +7 -2
  42. package/src/panels.js +5 -0
  43. package/src/permissions.js +56 -1
  44. package/src/ping.js +5 -0
  45. package/src/presence.js +5 -0
  46. package/src/provenance.js +238 -0
  47. package/src/provenance.lock.json +36 -0
  48. package/src/render.js +5 -0
  49. package/src/screen.js +5 -0
  50. package/src/screens.js +48 -37
  51. package/src/secret.js +5 -0
  52. package/src/securefs.js +5 -0
  53. package/src/settings.js +5 -0
  54. package/src/shared.js +5 -0
  55. package/src/sharedpaths.js +5 -0
  56. package/src/signup.js +5 -0
  57. package/src/summarize.js +5 -0
  58. package/src/sysdiag.js +582 -0
  59. package/src/system.js +5 -0
  60. package/src/theme.js +5 -0
  61. package/src/title.js +5 -0
  62. package/src/todos.js +5 -0
  63. package/src/tokens.js +5 -0
  64. package/src/topup.js +5 -0
  65. package/src/update.js +5 -0
  66. package/vendor/client/aegis.js +5 -0
  67. package/vendor/client/attest.js +5 -0
  68. package/vendor/client/authorship-key.js +5 -0
  69. package/vendor/client/auto-provision.js +5 -0
  70. package/vendor/client/brain-catalog.js +5 -0
  71. package/vendor/client/byok-catalog.js +5 -0
  72. package/vendor/client/credentials.js +5 -0
  73. package/vendor/client/device-fingerprint.js +5 -0
  74. package/vendor/client/env-file.js +5 -0
  75. package/vendor/client/fingerprint.js +5 -0
  76. package/vendor/client/foreign-memory.js +5 -0
  77. package/vendor/client/hooks.js +5 -0
  78. package/vendor/client/model-discovery.js +332 -0
  79. package/vendor/client/platform.js +5 -0
  80. package/vendor/client/prefs.js +5 -0
  81. package/vendor/client/presence-constants.js +5 -0
  82. package/vendor/client/presence.js +5 -0
  83. package/vendor/client/record-vault.js +5 -0
  84. package/vendor/client/session-store.js +5 -0
  85. package/vendor/client/topup.js +5 -0
  86. package/vendor/client/touch.js +5 -0
  87. package/vendor/client/update.js +5 -0
  88. package/vendor/client/user-models.js +5 -0
  89. package/vendor/desktop/lib/local/aegis-seal.mjs +5 -0
  90. package/vendor/desktop/lib/local/agents.js +5 -0
  91. package/vendor/desktop/lib/local/autonomous.js +5 -0
  92. package/vendor/desktop/lib/local/context.js +5 -0
  93. package/vendor/desktop/lib/local/covenant.js +5 -0
  94. package/vendor/desktop/lib/local/engine.js +129 -0
  95. package/vendor/desktop/lib/local/entitlement.js +5 -0
  96. package/vendor/desktop/lib/local/git-scope.js +5 -0
  97. package/vendor/desktop/lib/local/local.js +5 -0
  98. package/vendor/desktop/lib/local/prompt.js +5 -0
  99. package/vendor/desktop/lib/local/queue.js +5 -0
  100. package/vendor/desktop/lib/local/session-rounds.js +5 -0
  101. package/vendor/desktop/lib/local/shell.js +88 -9
  102. package/vendor/desktop/lib/local/tools.js +13 -6
  103. package/vendor/desktop/lib/local/turn-guard.js +5 -0
  104. package/vendor/desktop/lib/local/worktree-lock.js +5 -0
  105. package/vendor/desktop/lib/settings.js +5 -0
  106. package/vendor/desktop/renderer/usage.js +5 -0
  107. package/vendor/mcp/server.js +5 -0
  108. package/vendor/mcp/tools.js +5 -0
  109. package/vendor/tools/agent-gate.mjs +23 -0
package/src/commands.js CHANGED
@@ -1,3 +1,8 @@
1
+ // SPDX-License-Identifier: AGPL-3.0-or-later
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.
1
6
  'use strict';
2
7
 
3
8
  /**
@@ -93,6 +98,9 @@ const { pickerEntries } = require('./models.js');
93
98
  const { resolveShared } = require('./sharedpaths.js');
94
99
  const { createCliEntitlement, paymentView, probeFee } = require('./entitlement.js');
95
100
  const { openUrl, URLS } = require('./system.js');
101
+ // The machine checks behind `/doctor system` — see cli/src/sysdiag.js for why
102
+ // they exist and why they never mutate anything.
103
+ const sysdiag = require('./sysdiag.js');
96
104
  const { sniffProject, buildAegisMd } = require('./init.js');
97
105
  const { upgradeAdvice, latestPublishedVersion } = require('./update.js');
98
106
  const {
@@ -410,8 +418,120 @@ const {
410
418
  withUserModels,
411
419
  addUserModel,
412
420
  removeUserModel,
421
+ userModelIdsFor,
422
+ userModelsPath,
413
423
  } = require(resolveShared(path.join('client', 'user-models.js')));
414
424
 
425
+ /**
426
+ * Ask the VENDOR what it serves (`client/model-discovery.js`), so `/model-add`
427
+ * can offer a list instead of asking the user to recall an id.
428
+ *
429
+ * Same `resolveShared` resolution as its two siblings above: one implementation
430
+ * of "what does this provider's key actually reach", read by both faces. It is
431
+ * loaded at module scope rather than lazily inside the handler because the
432
+ * command needs it to decide what to PROMPT with — a discovery module that
433
+ * loads only after discovery was decided to be possible would be circular.
434
+ *
435
+ * The module does no I/O at load (no key store, no network), so pulling it in
436
+ * with `/help` costs a `require` and nothing else.
437
+ */
438
+ const {
439
+ discoverModels: discoverVendorModels,
440
+ endpointFor: vendorEndpointFor,
441
+ discoverableProviders,
442
+ } = require(resolveShared(path.join('client', 'model-discovery.js')));
443
+
444
+ /**
445
+ * The vendor key for a provider, resolved the way the engine resolves it:
446
+ * the saved provider-key row first, then `~/.aegiscode/.env` (and the shell).
447
+ *
448
+ * Deliberately the same ORDER as `desktop/lib/local/engine.js`'s
449
+ * `providerKeyFromEnv` + `byok:<provider>` lookup, because discovery must use
450
+ * the key the NEXT TURN will use — a listing fetched with a different key than
451
+ * the one the call runs on is a listing of somebody else's catalog. This is
452
+ * read-only: it never writes a key, never logs one, and returns '' when the
453
+ * machine has none, which the caller reports as "no key to ask with".
454
+ */
455
+ function byokKeyForProvider(c, provider) {
456
+ const id = String(provider || '').trim().toLowerCase();
457
+ if (!id) return '';
458
+ try {
459
+ const store = c && c.settings && c.settings();
460
+ if (store && typeof store.rawKey === 'function' && typeof c.byokNamespace === 'function') {
461
+ const saved = store.rawKey(c.byokNamespace(id));
462
+ if (typeof saved === 'string' && saved.trim()) return saved.trim();
463
+ }
464
+ } catch {
465
+ /* a store that throws is a store with no key, not a reason to stop */
466
+ }
467
+ try {
468
+ const { providerKeyFromEnv } = require(resolveShared(path.join('client', 'env-file.js')));
469
+ return (providerKeyFromEnv(id) || {}).key || '';
470
+ } catch {
471
+ return '';
472
+ }
473
+ }
474
+
475
+ /**
476
+ * Ask the provider's own list endpoint, if this machine can. Never throws.
477
+ *
478
+ * `fetchImpl` is injectable through the context so the CLI tests drive a stub
479
+ * and never open a socket; `c.fetchImpl` is undefined in a real run, which is
480
+ * the module's normal `fetch`.
481
+ */
482
+ async function discoverProviderModels(c, provider, key) {
483
+ try {
484
+ return await discoverVendorModels(provider, { key, fetchImpl: c && c.fetchImpl });
485
+ } catch (err) {
486
+ return { ok: false, provider, supported: true, error: (err && err.message) || String(err) };
487
+ }
488
+ }
489
+
490
+ /**
491
+ * The provider's own catalog, best-effort, as `[ids]`. Undefined when the
492
+ * vendor could not be asked — the caller then falls back to a free-form id
493
+ * prompt, because that path works and must keep working offline.
494
+ */
495
+ async function offeredModelIds(c, provider, key) {
496
+ const res = await discoverProviderModels(c, provider, key);
497
+ return res && res.ok && Array.isArray(res.ids) && res.ids.length ? res.ids : undefined;
498
+ }
499
+
500
+ /**
501
+ * Declare ids into the store, skipping the ones already there. Returns the
502
+ * count added, plus what was skipped and WHY, so the caller can say
503
+ * "3 added, 2 already declared" instead of claiming work it did not do.
504
+ *
505
+ * The cap matters here more than anywhere else: a vendor's list endpoint
506
+ * answers with everything it serves — OpenAI currently returns 100 ids — and
507
+ * the store holds at most 32 per provider by design. Without this the bulk
508
+ * path would report sixty-eight "refused" models, which reads as sixty-eight
509
+ * broken ids rather than one deliberate ceiling. So the cap ends the batch and
510
+ * is reported as itself.
511
+ */
512
+ function addManyUserModels(provider, ids) {
513
+ let added = 0;
514
+ let capped = 0;
515
+ const already = [];
516
+ const failed = [];
517
+ for (const id of ids) {
518
+ try {
519
+ if (addUserModel(provider, id).added) added += 1;
520
+ else already.push(id);
521
+ } catch (err) {
522
+ const message = (err && err.message) || String(err);
523
+ if (/the cap/.test(message)) {
524
+ // Every remaining id would hit the same wall, so stop rather than
525
+ // loop sixty more times to collect sixty copies of one message.
526
+ capped = ids.length - added - already.length - failed.length;
527
+ break;
528
+ }
529
+ failed.push({ id, reason: message });
530
+ }
531
+ }
532
+ return { added, already, failed, capped };
533
+ }
534
+
415
535
  /**
416
536
  * The server's BYOK provider catalog, or null when it cannot be reached.
417
537
  *
@@ -1630,12 +1750,12 @@ const COMMANDS = [
1630
1750
  },
1631
1751
  },
1632
1752
  {
1633
- name: 'doctor', args: ['action'], hint: '[fix]', category: 'support',
1753
+ name: 'doctor', args: ['action'], hint: '[fix|system]', category: 'support',
1634
1754
  desc: 'Run diagnostic checks on this environment',
1635
1755
  handler: async (c, args) => {
1636
1756
  const action = ((args && args.action) || '').toLowerCase();
1637
- if (action && action !== 'fix') {
1638
- note(c, 'Usage: /doctor [fix] — "fix" re-tightens the data dir to 0700/0600');
1757
+ if (action && action !== 'fix' && action !== 'system') {
1758
+ note(c, 'Usage: /doctor [fix|system] — "fix" re-tightens the data dir to 0700/0600, "system" checks the machine itself');
1639
1759
  c.render();
1640
1760
  return true;
1641
1761
  }
@@ -1710,6 +1830,29 @@ const COMMANDS = [
1710
1830
  repaired.failed.map((f) => `${f.rel}: ${f.reason}`).join(', ')
1711
1831
  );
1712
1832
  }
1833
+ // `/doctor system` — the machine, not the checkout. Read-only by design:
1834
+ // cli/src/sysdiag.js holds the nine checks and each one's remedy, and
1835
+ // nothing here executes a remedy, because all of them need elevation and
1836
+ // the ordering matters (VSS has to survive DoSnapshotSet before a restore
1837
+ // point can exist). An unread probe is its own state, never a ✔.
1838
+ let systemReport = null;
1839
+ if (action === 'system') {
1840
+ const probe = sysdiag.collect();
1841
+ if (!probe.ok) {
1842
+ ok(
1843
+ 'machine checks',
1844
+ false,
1845
+ probe.reason === 'not-windows'
1846
+ ? 'not available on this platform — the machine audit is Windows-only (cli/src/sysdiag.js)'
1847
+ : `could not run: ${probe.reason}`,
1848
+ );
1849
+ } else {
1850
+ systemReport = sysdiag.assess(probe.data);
1851
+ for (const f of systemReport.findings) ok(`${f.title} (${f.severity})`, false, `${f.detail} → ${f.remedyText}`);
1852
+ for (const p of systemReport.clean) ok(p.title, true, p.detail);
1853
+ for (const u of systemReport.unassessed) ok(`${u.title} (unassessed)`, false, u.reason);
1854
+ }
1855
+ }
1713
1856
  const lines = [[span(C.gold + BOLD, 'Doctor'), span(BOLD_OFF, '')], [span(C.gray, '─'.repeat(30))]];
1714
1857
  for (const [good, label, detail] of checks) {
1715
1858
  lines.push([
@@ -1718,6 +1861,15 @@ const COMMANDS = [
1718
1861
  span(C.gray, String(detail)),
1719
1862
  ]);
1720
1863
  }
1864
+ if (systemReport && systemReport.findings.length) {
1865
+ const s = systemReport.summary;
1866
+ lines.push([
1867
+ span(C.gold, ' Remedy'),
1868
+ span(C.gray, ` — ${s.findings} finding(s) across ${s.assessed}/${s.total} measured checks.`),
1869
+ ]);
1870
+ lines.push([span(C.gray, ' Run in an ELEVATED PowerShell. AEGIS diagnoses this; it does not change your machine.')]);
1871
+ for (const line of sysdiag.remedyScript().split('\n')) lines.push([span(C.gray, ` ${line}`)]);
1872
+ }
1721
1873
  panel(c, lines);
1722
1874
  c.render();
1723
1875
  return true;
@@ -3010,9 +3162,9 @@ const COMMANDS = [
3010
3162
  // the next refresh and the window shows it on ITS next refresh. The file is
3011
3163
  // printed on success, because a hand-edit is the bulk path and a store the
3012
3164
  // user cannot find is a store they will not use.
3013
- name: 'model-add', aliases: ['add-model'], args: ['provider'], hint: '<provider> <model-id>',
3165
+ name: 'model-add', aliases: ['add-model'], args: ['provider'], hint: '<provider> [model-id|*]',
3014
3166
  category: 'model',
3015
- desc: 'Offer a model id the AEGIS catalog does not name (your key, both faces)',
3167
+ desc: 'Offer a model id the AEGIS catalog does not name (asks the vendor when it can)',
3016
3168
  handler: async (c, a) => {
3017
3169
  const args = a || {};
3018
3170
  const typed = String(args.provider || '').trim();
@@ -3023,15 +3175,6 @@ const COMMANDS = [
3023
3175
  const rest = String(args._rest || '').trim();
3024
3176
  const sp = rest.indexOf(' ');
3025
3177
  let model = sp === -1 ? '' : rest.slice(sp + 1).trim();
3026
- if (!model) {
3027
- // Plain inline input, NOT readSecret: a model id is not a secret, and
3028
- // hiding it would make a typo unreviewable before it is stored.
3029
- model = String((await c.askInput(`model id for ${typed}: `)) || '').trim();
3030
- }
3031
- if (!model) {
3032
- c.push({ role: 'note', text: 'nothing saved.' });
3033
- return true;
3034
- }
3035
3178
  // Resolve the provider against the relay's catalog first. A slug the
3036
3179
  // server does not list can never be attached to a key, so storing it
3037
3180
  // would produce a declaration that is invisible in every picker — the
@@ -3052,6 +3195,76 @@ const COMMANDS = [
3052
3195
  return true;
3053
3196
  }
3054
3197
  const id = (match && match.provider && match.provider.id) || typed.toLowerCase();
3198
+ // ── what the vendor says, before we ask the user to remember it ──────
3199
+ //
3200
+ // The whole cost of this feature used to be "know the vendor's model id",
3201
+ // which is the release-lag problem handed to the user instead of solved.
3202
+ // When this machine holds a key for the provider, its own list endpoint
3203
+ // answers that in one request. Best-effort by construction: no key, no
3204
+ // endpoint, no network or an unparseable reply all fall through to the
3205
+ // free-form prompt below, which is the path that already worked offline.
3206
+ const key = byokKeyForProvider(c, id);
3207
+ const offered = await offeredModelIds(c, id, key);
3208
+
3209
+ // `*` is the bulk path: declare everything the vendor currently serves.
3210
+ // Only the CHAT rows are declared (an embeddings or TTS id in a model
3211
+ // picker is a row nobody can run), and only after the vendor answered —
3212
+ // with no list there is nothing to take all of, and saying so is the
3213
+ // honest outcome rather than an empty success.
3214
+ if (model === '*') {
3215
+ if (!offered) {
3216
+ const why = await discoverProviderModels(c, id, key);
3217
+ c.push({
3218
+ role: 'error',
3219
+ text: `cannot list ${id}: ${(why && why.error) || 'no list available'} — type the ids instead: /model-add ${id} <model-id>`,
3220
+ });
3221
+ return true;
3222
+ }
3223
+ const bulk = addManyUserModels(id, offered);
3224
+ if (typeof c.refreshByokModels === 'function') {
3225
+ try { await c.refreshByokModels(); } catch { /* the next refresh reads the file anyway */ }
3226
+ }
3227
+ c.push({
3228
+ role: 'done',
3229
+ text: `added ${bulk.added} of the ${offered.length} model ids ${id} serves${bulk.already.length ? ` (${bulk.already.length} were already declared)` : ''}.`,
3230
+ });
3231
+ if (bulk.capped) {
3232
+ // The store's per-provider ceiling, named as a ceiling. A vendor list
3233
+ // is a hundred rows; this is one deliberate limit, not sixty broken
3234
+ // ids, and the two must not read the same in the transcript.
3235
+ c.push({
3236
+ role: 'note',
3237
+ text: `stopped at the store's per-provider cap (32) — ${bulk.capped} more id(s) were left out; /model-add ${id} <model-id> stores a specific one, /model-rm frees a slot.`,
3238
+ });
3239
+ }
3240
+ if (bulk.failed.length) {
3241
+ c.push({ role: 'note', text: `${bulk.failed.length} id(s) were refused: ${bulk.failed.map((f) => f.id).join(', ')}` });
3242
+ }
3243
+ c.push({ role: 'note', text: `stored in ${userModelsPath()} — the desktop reads the same file. /model-discover ${id} lists what the vendor serves.` });
3244
+ return true;
3245
+ }
3246
+
3247
+ if (!model) {
3248
+ // Plain inline input, NOT readSecret: a model id is not a secret, and
3249
+ // hiding it would make a typo unreviewable before it is stored.
3250
+ if (offered) {
3251
+ c.push({ role: 'note', text: `${id} serves ${offered.length} model ids — ${offered.slice(0, 12).join(', ')}${offered.length > 12 ? ', …' : ''}` });
3252
+ }
3253
+ const typedId = String((await c.askInput(
3254
+ offered
3255
+ ? `model id for ${id} (1-${offered.length}, or type one): `
3256
+ : `model id for ${id}: `
3257
+ )) || '').trim();
3258
+ // A bare number picks the row it is listed under. Only an in-range
3259
+ // integer is read that way, so an id that happens to start with a digit
3260
+ // is still stored verbatim unless it is exactly a listed position.
3261
+ const n = /^\d+$/.test(typedId) ? Number(typedId) : 0;
3262
+ model = n >= 1 && n <= offered.length ? offered[n - 1] : typedId;
3263
+ }
3264
+ if (!model) {
3265
+ c.push({ role: 'note', text: 'nothing saved.' });
3266
+ return true;
3267
+ }
3055
3268
  let res;
3056
3269
  try {
3057
3270
  res = addUserModel(id, model);
@@ -3090,10 +3303,109 @@ const COMMANDS = [
3090
3303
  text: `saved, but no row will be offered for "${id}" yet — the relay lists no provider of that id (or that provider lists no models).`,
3091
3304
  });
3092
3305
  }
3306
+ if (res.added && offered) {
3307
+ // The vendor was asked and it lists more than the one id just stored.
3308
+ // Naming the size of that list is the difference between "the picker has
3309
+ // four models" and "this vendor ships forty and you have one of them".
3310
+ c.push({
3311
+ role: 'note',
3312
+ text: `${id} currently serves ${offered.length} model ids — /model-discover ${id} lists them, /model-add ${id} '*' takes them all.`,
3313
+ });
3314
+ }
3093
3315
  c.push({ role: 'note', text: `stored in ${res.file} — the desktop reads the same file.` });
3094
3316
  return true;
3095
3317
  },
3096
3318
  },
3319
+ {
3320
+ // ── what the vendor serves, right now ─────────────────────────────────
3321
+ //
3322
+ // `/model-add` answers "store THIS id"; this answers "which ids are there",
3323
+ // which is the question a user actually has when a vendor ships something
3324
+ // on a Tuesday. It reads the same key `client/env-file.js` and the provider
3325
+ // CRUD share (saved row first, `~/.aegiscode/.env` second) and hits the
3326
+ // vendor's own list endpoint, so the answer cannot be stale by
3327
+ // construction — that is the whole point of asking instead of shipping
3328
+ // another hand-copied list.
3329
+ //
3330
+ // Offline, keyless and shape-changed are all REPORTED, never thrown: this
3331
+ // command sits beside a manual path that works, so its worst case has to be
3332
+ // a sentence, not a stack trace.
3333
+ name: 'model-discover', aliases: ['discover-models', 'vendor-models'], args: ['provider'], hint: '<provider>',
3334
+ category: 'model',
3335
+ desc: "List the model ids your provider's own API serves",
3336
+ handler: async (c, a) => {
3337
+ const args = a || {};
3338
+ const typed = String(args.provider || '').trim();
3339
+ if (!typed) {
3340
+ c.push({
3341
+ role: 'error',
3342
+ text: `Usage: /model-discover <provider> — this client can ask: ${discoverableProviders().join(', ')}`,
3343
+ });
3344
+ return true;
3345
+ }
3346
+ // Resolve the alias against the relay's catalog when it is reachable, so
3347
+ // `/model-discover xai` and `/model-discover grok` are one request.
3348
+ const providers = await byokCatalog(c.client);
3349
+ const match = providers ? findByokProvider(providers, typed) : null;
3350
+ const id = ((match && match.provider && match.provider.id) || typed).toLowerCase();
3351
+ const entry = vendorEndpointFor(id);
3352
+ if (!entry) {
3353
+ c.push({
3354
+ role: 'error',
3355
+ text: `no list endpoint for "${id}" in this client — /model-add ${id} <model-id> stores an id you already know. Providers it can ask: ${discoverableProviders().join(', ')}`,
3356
+ });
3357
+ return true;
3358
+ }
3359
+ const key = byokKeyForProvider(c, id);
3360
+ if (!key) {
3361
+ c.push({
3362
+ role: 'error',
3363
+ text: `no ${id} key on this machine — /byok-key ${id} saves one (or put it in ~/.aegiscode/.env), then this lists what the key reaches.`,
3364
+ });
3365
+ return true;
3366
+ }
3367
+ const res = await discoverProviderModels(c, id, key);
3368
+ if (!res || !res.ok) {
3369
+ c.push({ role: 'error', text: `could not list ${id}: ${(res && res.error) || 'no answer'}` });
3370
+ return true;
3371
+ }
3372
+ // Where the user stands: which of these are already offered here.
3373
+ const declared = new Set(userModelIdsFor(id));
3374
+ const known = new Set(
3375
+ ((match && match.provider && match.provider.models) || []).map((m) => String(m))
3376
+ );
3377
+ c.push({ role: 'note', text: `${id} at ${entry.url}${entry.note ? ` (${entry.note})` : ''}` });
3378
+ c.push({
3379
+ role: 'note',
3380
+ text: `${res.count} chat model id(s) the vendor serves — mark: [seen] the relay already lists it, [your] you declared it, [new] this machine does not offer it yet.`,
3381
+ });
3382
+ const lines = res.ids.map((m, i) => {
3383
+ const mark = declared.has(m) ? '[your]' : known.has(m) ? '[seen]' : '[new]';
3384
+ return `${String(i + 1).padStart(3)}. ${mark} ${m}`;
3385
+ });
3386
+ if (lines.length) c.push({ role: 'panel', lines });
3387
+ if (!lines.length) {
3388
+ c.push({ role: 'note', text: `the vendor answered with no chat models — /model-add ${id} <model-id> stores one by hand.` });
3389
+ }
3390
+ if (res.others.length) {
3391
+ // Named, not hidden. "the vendor lists 60 and you were shown 12" is a
3392
+ // fact the user is owed; a silent filter is how a picker looks empty
3393
+ // for a reason nobody can see.
3394
+ c.push({
3395
+ role: 'note',
3396
+ text: `${res.others.length} id(s) are not chat models (embeddings, audio, moderation or an unsupported method) and are left out: ${res.others.slice(0, 8).join(', ')}${res.others.length > 8 ? ', …' : ''}`,
3397
+ });
3398
+ }
3399
+ const fresh = res.ids.filter((m) => !declared.has(m) && !known.has(m));
3400
+ if (fresh.length) {
3401
+ c.push({
3402
+ role: 'note',
3403
+ text: `${fresh.length} of them are not offered on this machine yet — /model-add ${id} '<model-id>' stores one, /model-add ${id} '*' stores every chat model the vendor serves.`,
3404
+ });
3405
+ }
3406
+ return true;
3407
+ },
3408
+ },
3097
3409
  {
3098
3410
  name: 'model-rm', aliases: ['rm-model'], args: ['provider'], hint: '<provider> <model-id>',
3099
3411
  category: 'model',
package/src/config.js CHANGED
@@ -1,3 +1,8 @@
1
+ // SPDX-License-Identifier: AGPL-3.0-or-later
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.
1
6
  'use strict';
2
7
 
3
8
  /**
@@ -1,3 +1,8 @@
1
+ // SPDX-License-Identifier: AGPL-3.0-or-later
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.
1
6
  'use strict';
2
7
 
3
8
  /**
package/src/deps.js CHANGED
@@ -1,3 +1,8 @@
1
+ // SPDX-License-Identifier: AGPL-3.0-or-later
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.
1
6
  'use strict';
2
7
 
3
8
  /**
package/src/devrun.js CHANGED
@@ -1,3 +1,8 @@
1
+ // SPDX-License-Identifier: AGPL-3.0-or-later
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.
1
6
  'use strict';
2
7
 
3
8
  /**
package/src/diff.js CHANGED
@@ -1,3 +1,8 @@
1
+ // SPDX-License-Identifier: AGPL-3.0-or-later
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.
1
6
  'use strict';
2
7
 
3
8
  /**
package/src/diffview.js CHANGED
@@ -1,3 +1,8 @@
1
+ // SPDX-License-Identifier: AGPL-3.0-or-later
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.
1
6
  'use strict';
2
7
 
3
8
  /**
package/src/engine.js CHANGED
@@ -1,3 +1,8 @@
1
+ // SPDX-License-Identifier: AGPL-3.0-or-later
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.
1
6
  'use strict';
2
7
 
3
8
  /**
@@ -1,3 +1,8 @@
1
+ // SPDX-License-Identifier: AGPL-3.0-or-later
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.
1
6
  'use strict';
2
7
 
3
8
  /**
package/src/events.js CHANGED
@@ -1,3 +1,8 @@
1
+ // SPDX-License-Identifier: AGPL-3.0-or-later
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.
1
6
  'use strict';
2
7
 
3
8
  /**
@@ -405,6 +410,16 @@ function feed(c) {
405
410
  }
406
411
  clearTimeout(escTimer);
407
412
  seq = '';
413
+ // ESC followed by CR is the legacy spelling of shift+Enter, and it is the
414
+ // only spelling some terminals have. Without this it fell through to the
415
+ // generic Alt chord ({name:'alt', ch:'\r'}), which nothing handled — so the
416
+ // chord the palette advertises was dead on exactly the terminals that need
417
+ // it. The kitty/modifyOtherKeys spelling (`CSI 13;2 u`) is decoded in
418
+ // keys.js; both have to land on the same key name.
419
+ if (c === '\r' || c === '\n') {
420
+ dispatch({ name: 'shift-enter' });
421
+ return;
422
+ }
408
423
  dispatch({ name: 'alt', ch: c });
409
424
  return;
410
425
  }
package/src/export.js CHANGED
@@ -1,3 +1,8 @@
1
+ // SPDX-License-Identifier: AGPL-3.0-or-later
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.
1
6
  'use strict';
2
7
 
3
8
  /**
@@ -1,3 +1,8 @@
1
+ // SPDX-License-Identifier: AGPL-3.0-or-later
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.
1
6
  'use strict';
2
7
 
3
8
  /**
package/src/format.js CHANGED
@@ -1,3 +1,8 @@
1
+ // SPDX-License-Identifier: AGPL-3.0-or-later
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.
1
6
  'use strict';
2
7
 
3
8
  /**
package/src/fuzzy.js CHANGED
@@ -1,3 +1,8 @@
1
+ // SPDX-License-Identifier: AGPL-3.0-or-later
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.
1
6
  'use strict';
2
7
 
3
8
  // Fuzzy command matching for the "/" palette (and anything else that needs it).
package/src/gate.js CHANGED
@@ -1,3 +1,8 @@
1
+ // SPDX-License-Identifier: AGPL-3.0-or-later
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.
1
6
  'use strict';
2
7
 
3
8
  /**
@@ -22,6 +27,7 @@
22
27
  const path = require('node:path');
23
28
  const { pathToFileURL } = require('node:url');
24
29
  const { resolveShared } = require('./sharedpaths.js');
30
+ const limits = require('./limits.js');
25
31
 
26
32
  /** @returns {Promise<typeof import('../../tools/agent-gate.mjs')>} */
27
33
  async function loadGate() {
@@ -38,6 +44,12 @@ async function loadGate() {
38
44
  * @returns {Promise<number>} exit code (0 allowed, 3 denied, 4 misconfigured)
39
45
  */
40
46
  async function runGate(sub, argv = []) {
47
+ // The interlock, asked here as well as at the entry point — this module owns
48
+ // the privilege (it decides who may edit a gated tree), so it is the module
49
+ // that has to refuse when the tree it is running from is not the published
50
+ // one. Asked BEFORE the gate module is resolved and imported, so a refused
51
+ // build does not even load the thing it is being denied. See src/limits.js.
52
+ if (limits.armed()) return limits.refuse();
41
53
  const { run } = await loadGate();
42
54
  return run([String(sub || 'status'), ...argv]);
43
55
  }
package/src/history.js CHANGED
@@ -1,3 +1,8 @@
1
+ // SPDX-License-Identifier: AGPL-3.0-or-later
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.
1
6
  'use strict';
2
7
 
3
8
  /**
package/src/init.js CHANGED
@@ -1,3 +1,8 @@
1
+ // SPDX-License-Identifier: AGPL-3.0-or-later
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.
1
6
  'use strict';
2
7
 
3
8
  /**
package/src/input.js CHANGED
@@ -1,3 +1,8 @@
1
+ // SPDX-License-Identifier: AGPL-3.0-or-later
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.
1
6
  'use strict';
2
7
 
3
8
  /**