aegiscode 6.8.37 → 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 (110) hide show
  1. package/README.md +39 -1
  2. package/bin/aegiscode.js +137 -0
  3. package/package.json +1 -1
  4. package/scripts/check.mjs +5 -0
  5. package/scripts/demo.mjs +5 -0
  6. package/scripts/predist.mjs +29 -2
  7. package/scripts/runtests.mjs +5 -0
  8. package/scripts/seal-gate.mjs +76 -0
  9. package/src/agents.js +5 -0
  10. package/src/app.js +59 -1
  11. package/src/art.js +5 -0
  12. package/src/autonomous.js +23 -0
  13. package/src/caps.js +5 -0
  14. package/src/chatflow.js +104 -31
  15. package/src/checkpoint.js +5 -0
  16. package/src/clipboard.js +5 -0
  17. package/src/cloudsync.js +5 -0
  18. package/src/commands.js +487 -4
  19. package/src/config.js +5 -0
  20. package/src/credentials.js +5 -0
  21. package/src/deps.js +5 -0
  22. package/src/devrun.js +5 -0
  23. package/src/diff.js +5 -0
  24. package/src/diffview.js +5 -0
  25. package/src/engine.js +5 -0
  26. package/src/entitlement.js +5 -0
  27. package/src/events.js +15 -0
  28. package/src/export.js +5 -0
  29. package/src/fingerprint.js +5 -0
  30. package/src/format.js +5 -0
  31. package/src/fuzzy.js +5 -0
  32. package/src/gate.js +12 -0
  33. package/src/history.js +5 -0
  34. package/src/init.js +5 -0
  35. package/src/input.js +5 -0
  36. package/src/keys.js +29 -2
  37. package/src/limits.js +192 -0
  38. package/src/markdown.js +5 -0
  39. package/src/mcp.js +13 -0
  40. package/src/models.js +5 -0
  41. package/src/naming.js +5 -0
  42. package/src/overlays.js +7 -2
  43. package/src/panels.js +5 -0
  44. package/src/permissions.js +56 -1
  45. package/src/ping.js +5 -0
  46. package/src/presence.js +5 -0
  47. package/src/provenance.js +238 -0
  48. package/src/provenance.lock.json +36 -0
  49. package/src/render.js +5 -0
  50. package/src/screen.js +5 -0
  51. package/src/screens.js +48 -37
  52. package/src/secret.js +5 -0
  53. package/src/securefs.js +5 -0
  54. package/src/settings.js +5 -0
  55. package/src/shared.js +5 -0
  56. package/src/sharedpaths.js +5 -0
  57. package/src/signup.js +5 -0
  58. package/src/summarize.js +5 -0
  59. package/src/sysdiag.js +582 -0
  60. package/src/system.js +5 -0
  61. package/src/theme.js +5 -0
  62. package/src/title.js +5 -0
  63. package/src/todos.js +5 -0
  64. package/src/tokens.js +5 -0
  65. package/src/topup.js +5 -0
  66. package/src/update.js +5 -0
  67. package/vendor/client/aegis.js +27 -0
  68. package/vendor/client/attest.js +5 -0
  69. package/vendor/client/authorship-key.js +5 -0
  70. package/vendor/client/auto-provision.js +5 -0
  71. package/vendor/client/brain-catalog.js +5 -0
  72. package/vendor/client/byok-catalog.js +48 -8
  73. package/vendor/client/credentials.js +5 -0
  74. package/vendor/client/device-fingerprint.js +5 -0
  75. package/vendor/client/env-file.js +5 -0
  76. package/vendor/client/fingerprint.js +5 -0
  77. package/vendor/client/foreign-memory.js +5 -0
  78. package/vendor/client/hooks.js +5 -0
  79. package/vendor/client/model-discovery.js +332 -0
  80. package/vendor/client/platform.js +5 -0
  81. package/vendor/client/prefs.js +5 -0
  82. package/vendor/client/presence-constants.js +5 -0
  83. package/vendor/client/presence.js +5 -0
  84. package/vendor/client/record-vault.js +5 -0
  85. package/vendor/client/session-store.js +5 -0
  86. package/vendor/client/topup.js +5 -0
  87. package/vendor/client/touch.js +5 -0
  88. package/vendor/client/update.js +5 -0
  89. package/vendor/client/user-models.js +383 -0
  90. package/vendor/desktop/lib/local/aegis-seal.mjs +5 -0
  91. package/vendor/desktop/lib/local/agents.js +5 -0
  92. package/vendor/desktop/lib/local/autonomous.js +86 -0
  93. package/vendor/desktop/lib/local/context.js +5 -0
  94. package/vendor/desktop/lib/local/covenant.js +5 -0
  95. package/vendor/desktop/lib/local/engine.js +463 -12
  96. package/vendor/desktop/lib/local/entitlement.js +5 -0
  97. package/vendor/desktop/lib/local/git-scope.js +5 -0
  98. package/vendor/desktop/lib/local/local.js +5 -0
  99. package/vendor/desktop/lib/local/prompt.js +5 -0
  100. package/vendor/desktop/lib/local/queue.js +5 -0
  101. package/vendor/desktop/lib/local/session-rounds.js +5 -0
  102. package/vendor/desktop/lib/local/shell.js +88 -9
  103. package/vendor/desktop/lib/local/tools.js +13 -6
  104. package/vendor/desktop/lib/local/turn-guard.js +5 -0
  105. package/vendor/desktop/lib/local/worktree-lock.js +5 -0
  106. package/vendor/desktop/lib/settings.js +5 -0
  107. package/vendor/desktop/renderer/usage.js +73 -1
  108. package/vendor/mcp/server.js +5 -0
  109. package/vendor/mcp/tools.js +5 -0
  110. package/vendor/tools/agent-gate.mjs +23 -0
package/README.md CHANGED
@@ -255,7 +255,7 @@ command for command — 87 entries across nine categories:
255
255
  |---|---|
256
256
  | Session & context | `/schedule` `/clear` `/compact` `/context` `/todos` `/config` `/exit` `/recap` `/resume` `/rewind` `/agents` `/status` `/teleport` `/version` `/new` `/skills` `/multiyolo` `/multi` `/research` `/debate` |
257
257
  | Workspace | `/run` `/build` `/cd` `/init` `/clone` |
258
- | Model & behavior | `/ping` `/effort` `/model` `/theme` `/terminal` `/vim` `/permissions` `/hooks` `/credentials` `/install-github-app` `/thinking` `/mcp` `/memory` `/memory-deep` `/confirm` `/automode` *(alias `/yolo`)* `/router` `/class` `/models` |
258
+ | Model & behavior | `/ping` `/effort` `/model` `/models` `/model-add` `/model-rm` `/theme` `/terminal` `/vim` `/permissions` `/hooks` `/credentials` `/install-github-app` `/thinking` `/mcp` `/memory` `/memory-deep` `/confirm` `/automode` *(alias `/yolo`)* `/router` `/class` |
259
259
  | Data | `/copy` `/cost` `/export` `/tokens` `/sync` |
260
260
  | Auth | `/login` `/logout` `/key` `/byok` `/byok-set` `/byok-rm` `/byok-key` `/byok-rm-key` |
261
261
  | Support | `/help` `/doctor` `/upgrade` `/troubleshooting` `/feedback` `/bug` `/issue` `/onboarding` `/shell-completion` `/terminal-setup` `/pr-comments` `/prs` `/review` `/benchmark` `/billing` `/topup` `/cloud` `/gmail` `/release-notes` |
@@ -338,6 +338,44 @@ Selecting it switches the class to `aegis` first (this is the one row that is
338
338
  not a `provider:model` id); pinning it *without* switching is not offered,
339
339
  because the relay would read `nexus-brain` as a provider name.
340
340
 
341
+ **3. Adding a model nobody has released yet.**
342
+
343
+ Vendors ship models faster than any client can be updated, and the BYOK relay is
344
+ a pass-through: your own vendor key authenticates upstream and AEGIS forwards the
345
+ model string it is handed. So an id your provider serves is callable the moment
346
+ your machine offers it as a row — which is what these do:
347
+
348
+ ```bash
349
+ /model-add deepseek deepseek-v4.2-preview # offer it on this machine
350
+ /model-rm deepseek deepseek-v4.2-preview # forget it
351
+ /model-add deepseek # prompt for the id instead
352
+ ```
353
+
354
+ `/model-add` resolves the provider against the relay's catalogue first, so a
355
+ provider the relay takes no key for is **refused** rather than stored — a
356
+ declaration for a slug the relay does not accept would appear in no picker at
357
+ all, and the failure would land on your first turn. The id itself is shape
358
+ checked (no spaces, no colon — `provider:model` is the id a pin uses) but never
359
+ checked against a vendor list: reaching a model the catalogue has not caught up
360
+ with is the entire point.
361
+
362
+ The declaration lives in **`~/.aegiscode/models.json`** (`$AEGISCODE_HOME` if you
363
+ set it), which is also the file the desktop's Settings pane writes and reads. Add
364
+ a model in the terminal and it is in the window's picker on its next refresh,
365
+ with no restart; add one in the window and `/models` shows it immediately. The
366
+ file is plain JSON and 0600, so a bulk edit is an editor away:
367
+
368
+ ```json
369
+ {
370
+ "deepseek": ["deepseek-v4.2-preview"],
371
+ "anthropic": ["claude-opus-9-1"]
372
+ }
373
+ ```
374
+
375
+ Nothing here is validated against a vendor on read, so a hand-typed row that the
376
+ vendor does not serve will 404 on your first turn — that is the one cost of the
377
+ escape hatch, and it is why the commands validate what they store.
378
+
341
379
  ```bash
342
380
  aegiscode -m nexus-brain -p "…" # pin at launch
343
381
  aegiscode -m anthropic:claude-sonnet-4-5 -p "…" # a BYOK id at launch
package/bin/aegiscode.js CHANGED
@@ -1,4 +1,9 @@
1
1
  #!/usr/bin/env node
2
+ // SPDX-License-Identifier: AGPL-3.0-or-later
3
+ // Copyright (C) 2026 Niklas Borneklint — AEGIS Code (aegiscode) / Aegiscloud.
4
+ // AEGIS Code (aegiscode) — source: https://github.com/aegisinfo/aegiscode-plugin
5
+ // Conveying a modified copy, or running one as a network service, owes the
6
+ // corresponding source under this licence (§5/§13) — see LICENSING.md.
2
7
  'use strict';
3
8
 
4
9
  /**
@@ -76,6 +81,12 @@ Code protection (the agent-key gate on aegiscodex-dev / aegiscode-plugin):
76
81
  aegiscode gate lock-status the server-side half of the lock
77
82
  aegiscode gate help all subcommands and their flags
78
83
 
84
+ Provenance (this binary, and whether it is still the published one):
85
+ aegiscode provenance licence, source, and a self-check of
86
+ this build against the published seal
87
+ (--json for scripts; exit 1 if a
88
+ sealed unit has moved)
89
+
79
90
  Options:
80
91
  -m, --model <id> pin a model id (see /models; default: server choice)
81
92
  --base <url> API base (default $AEGIS_API_BASE or aegiscloud.org)
@@ -191,6 +202,13 @@ function parseArgs(argv) {
191
202
  opts.commandArg = sub;
192
203
  opts.commandArgv = argv.slice(argv[1] && !argv[1].startsWith('-') ? 2 : 1);
193
204
  argv = [];
205
+ } else if (head === 'provenance') {
206
+ // Same position-0 rule and the same reason as `gate`: it is a one-shot
207
+ // question about THIS BINARY, not a prompt that happens to start with the
208
+ // word. Unlike `gate` the tail needs no passthrough — the only flag it
209
+ // takes is `--json`, which this parser already owns.
210
+ opts.command = 'provenance';
211
+ argv = argv.slice(1);
194
212
  } else if (head === 'topup') {
195
213
  // Same position-0 rule and the same reason as `gate`: the one argument is
196
214
  // the amount (`aegiscode topup 20`), never a prompt whose text happens to
@@ -291,6 +309,53 @@ function parseArgs(argv) {
291
309
  return opts;
292
310
  }
293
311
 
312
+ /**
313
+ * `aegiscode provenance` — what this binary is, and whether its safety files are
314
+ * the ones that were published.
315
+ *
316
+ * The use case is a user (or an auditor, or a script) holding an install they
317
+ * did not build: `npm i -g aegiscode`, a tarball mailed to them, a rebuilt fork.
318
+ * It answers with the licence, the copyright holder, the source URL, and the
319
+ * result of the startup self-check against `src/provenance.lock.json`.
320
+ *
321
+ * Exit codes: 0 = identity intact and safety files verified; 1 = a safety file
322
+ * has moved, or the manifest is missing and the install therefore cannot be
323
+ * verified at all (absence is a failure — see src/provenance.js for why the
324
+ * cheap attack must be the loud one). A fork that has deliberately rebuilt is
325
+ * expected to regenerate the manifest and exit 0 naming itself; one that has
326
+ * not now says so instead of staying silent.
327
+ */
328
+ function runProvenance(opts = {}) {
329
+ const pkg = require(path.join(__dirname, '..', 'package.json'));
330
+ const provenance = require('../src/provenance.js');
331
+ const described = provenance.describe({ version: pkg.version });
332
+ if (opts.json) {
333
+ process.stdout.write(
334
+ JSON.stringify(
335
+ {
336
+ product: provenance.IDENTITY.product,
337
+ bin: provenance.IDENTITY.bin,
338
+ version: pkg.version,
339
+ license: provenance.IDENTITY.license,
340
+ source: provenance.IDENTITY.source,
341
+ homepage: provenance.IDENTITY.homepage,
342
+ copyright: provenance.IDENTITY.copyright,
343
+ safety: {
344
+ ok: described.report.ok,
345
+ checked: described.report.checked,
346
+ problems: described.report.problems,
347
+ },
348
+ },
349
+ null,
350
+ 2
351
+ ) + '\n'
352
+ );
353
+ return described.ok ? 0 : 1;
354
+ }
355
+ process.stdout.write(described.text);
356
+ return described.ok ? 0 : 1;
357
+ }
358
+
294
359
  /**
295
360
  * Account subcommands: the in-band way to give this host a key.
296
361
  *
@@ -450,6 +515,42 @@ async function main(argv = process.argv.slice(2)) {
450
515
  return 0;
451
516
  }
452
517
 
518
+ // ── interlock (see src/limits.js) ────────────────────────────────────────
519
+ //
520
+ // The second gate, and it runs before every subcommand dispatch below — gate,
521
+ // mcp, autonomous, provenance, the session — because a check that ran after
522
+ // the dispatch it is supposed to stop is a check that reports instead of
523
+ // gating.
524
+ //
525
+ // It asks whether the safety files are still the sealed set *as a whole*, and
526
+ // when they are not it says exactly one bland thing — naming no file, no cause
527
+ // and no remedy — and refuses the privileged subcommands (`gate`,
528
+ // `provenance`, `mcp`), so the build that failed the check cannot use the
529
+ // gate's own key management or report on itself. Sessions still start, marked
530
+ // `AEGIS_REDUCED_MODE=1` for modules that opt-in.
531
+ //
532
+ // Deliberately NOT switchable by environment variable: a gate with a
533
+ // documented off switch is a gate the manipulator reads about in the same file
534
+ // as the gate. Re-sealing is a manual act —
535
+ // `node tools/provenance.mjs lock --write` — and a tree that is mid-edit trips
536
+ // this on purpose.
537
+ //
538
+ // This call site is the EARLIEST refusal, not the only one. `armed()` is
539
+ // asked again, independently, by each module that owns one of these
540
+ // privileges — src/gate.js, src/mcp.js, src/autonomous.js,
541
+ // src/permissions.js — because a check invoked from exactly one place is
542
+ // removed by deleting one line, and this is the file a manipulator is already
543
+ // editing. Deleting the block below leaves four refusals behind, in four files
544
+ // the sealed set covers.
545
+ let interlockFired = false;
546
+ try {
547
+ const limits = require('../src/limits.js');
548
+ interlockFired = limits.armed();
549
+ if (interlockFired && limits.isPrivileged(opts.command)) return limits.refuse();
550
+ } catch {
551
+ /* a gate must never be the reason the program fails to start */
552
+ }
553
+
453
554
  // ── the shared env file, before any credential is resolved ───────────────
454
555
  //
455
556
  // `~/.aegiscode/.env` read into process.env once. This is what makes key
@@ -618,8 +719,44 @@ async function main(argv = process.argv.slice(2)) {
618
719
  });
619
720
  }
620
721
 
722
+ // What this binary is, and whether its safety files are the published ones.
723
+ // Dispatched before a session is built, like `gate`/`fingerprint`: it is a
724
+ // question about this install, it must work with no terminal at all (an audit
725
+ // script), and it must not depend on a credential being configured. It is NOT
726
+ // part of the startup path — the runtime self-check that warns on stderr is in
727
+ // src/provenance.js and runs below, for sessions.
728
+ //
729
+ // The interlock below runs first and can make `provenance` unavailable, which
730
+ // is not an oversight: a build that fails the silent gate does not get to
731
+ // report on itself.
732
+ if (opts.command === 'provenance' && !interlockFired) {
733
+ return runProvenance({ json: opts.json });
734
+ }
735
+
621
736
  const { createApp } = require('../src/app.js');
622
737
 
738
+ // ── provenance self-check (one stderr line, never fatal) ─────────────────
739
+ //
740
+ // A build whose gate, permission evaluator, approval classes or runner were
741
+ // edited announces it, once, before the session starts — instead of importing
742
+ // the neutered file and saying nothing. Never throws and never blocks: a
743
+ // diagnostic that can stop the program it reports on is worse than none (see
744
+ // src/provenance.js, which also records why a MISSING manifest is a failure
745
+ // rather than a pass). A development tree silences it with
746
+ // AEGIS_NO_PROVENANCE_CHECK=1 — and the silence is printed at the time, so it
747
+ // is a fact on the record rather than a quiet default.
748
+ //
749
+ // Skipped when the interlock has already fired: that path emits exactly one
750
+ // bland line, and following it with a more descriptive one would hand back
751
+ // everything the bland line withheld.
752
+ if (!interlockFired) try {
753
+ const provenance = require('../src/provenance.js');
754
+ const line = provenance.warning(provenance.selfCheck());
755
+ if (line) process.stderr.write(line);
756
+ } catch {
757
+ /* a diagnostic must never be the reason a session fails to start */
758
+ }
759
+
623
760
  // ── presence beacon (aegis1 /api/v1/heartbeat) ───────────────────────────
624
761
  //
625
762
  // "Who is running aegiscode right now" — the admin panel's presence card.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "aegiscode",
3
3
  "productName": "AEGIS Code",
4
- "version": "6.8.37",
4
+ "version": "7.0.1",
5
5
  "description": "aegiscode — the command-line version of AEGIS Desktop. The shared tool surface in your shell, over the same thin transport and tool registry as the MCP plugin and the desktop app. Ships transport + UI only; no brain.",
6
6
  "author": {
7
7
  "name": "AEGIS Code",
package/scripts/check.mjs CHANGED
@@ -1,4 +1,9 @@
1
1
  #!/usr/bin/env node
2
+ // SPDX-License-Identifier: AGPL-3.0-or-later
3
+ // Copyright (C) 2026 Niklas Borneklint — AEGIS Code (aegiscode) / Aegiscloud.
4
+ // AEGIS Code (aegiscode) — source: https://github.com/aegisinfo/aegiscode-plugin
5
+ // Conveying a modified copy, or running one as a network service, owes the
6
+ // corresponding source under this licence (§5/§13) — see LICENSING.md.
2
7
  /**
3
8
  * Syntax-check every file `node --check` should gate on, and report all of
4
9
  * them. Replaces the POSIX loop
package/scripts/demo.mjs CHANGED
@@ -1,4 +1,9 @@
1
1
  #!/usr/bin/env node
2
+ // SPDX-License-Identifier: AGPL-3.0-or-later
3
+ // Copyright (C) 2026 Niklas Borneklint — AEGIS Code (aegiscode) / Aegiscloud.
4
+ // AEGIS Code (aegiscode) — source: https://github.com/aegisinfo/aegiscode-plugin
5
+ // Conveying a modified copy, or running one as a network service, owes the
6
+ // corresponding source under this licence (§5/§13) — see LICENSING.md.
2
7
  /**
3
8
  * Renders a canned session to stdout — banner, a prompt, a streamed answer with
4
9
  * markdown, the accounting line, and the status bar.
@@ -1,4 +1,9 @@
1
1
  #!/usr/bin/env node
2
+ // SPDX-License-Identifier: AGPL-3.0-or-later
3
+ // Copyright (C) 2026 Niklas Borneklint — AEGIS Code (aegiscode) / Aegiscloud.
4
+ // AEGIS Code (aegiscode) — source: https://github.com/aegisinfo/aegiscode-plugin
5
+ // Conveying a modified copy, or running one as a network service, owes the
6
+ // corresponding source under this licence (§5/§13) — see LICENSING.md.
2
7
  /**
3
8
  * Pre-publish staging for the `aegiscode` package — a THIN WRAPPER.
4
9
  *
@@ -6,7 +11,8 @@
6
11
  * `one/scripts/predist.mjs` in AEGISONE's phase ON2 (plan D6): one manifest,
7
12
  * two shapes. This file used to hold its own list of forty repo-relative
8
13
  * modules, kept in sync with `desktop/scripts/predist.mjs` by discipline alone.
9
- * It now holds no list at all.
14
+ * It now holds no list at all, and its length is a test
15
+ * (`test/one-vendor.test.mjs`: wrappers stay under eighty lines).
10
16
  *
11
17
  * Everything the CLI needs is unchanged as seen from outside: `npm run predist`,
12
18
  * `prepublishOnly`, `precheck` and `pretest` still run this file, it still
@@ -14,6 +20,11 @@
14
20
  * same proof lines (the staged registry loads standalone, the editor layer
15
21
  * resolves the STAGED server, the staged gate module loads).
16
22
  *
23
+ * It also REFUSES to stage from a tree whose safety files are not the sealed
24
+ * ones — the publish gate, which lives beside this file (`./seal-gate.mjs`)
25
+ * because a gate is not a manifest and this file has a line budget. That is the
26
+ * one moment the question can be asked from outside the artifact.
27
+ *
17
28
  * If the shared stager is not reachable the file is missing — this directory is
18
29
  * inside the published tarball, where `one/` is not shipped, and running predist
19
30
  * there is meaningless anyway (the vendor tree it would build is already in the
@@ -21,11 +32,27 @@
21
32
  */
22
33
  import path from 'node:path';
23
34
  import { fileURLToPath, pathToFileURL } from 'node:url';
35
+ import { sealGate } from './seal-gate.mjs';
24
36
 
25
37
  const HERE = path.dirname(fileURLToPath(import.meta.url));
26
38
  const SHARED = path.join(HERE, '..', '..', 'one', 'scripts', 'predist.mjs');
27
39
 
28
40
  async function main() {
41
+ const gate = sealGate();
42
+ if (!gate.ok && !process.env.AEGIS_ALLOW_UNSEALED) {
43
+ process.stderr.write(
44
+ `${gate.line}\n` +
45
+ `cut: refusing to stage a package from it. Reseal the tree deliberately, or set ` +
46
+ `AEGIS_ALLOW_UNSEALED=1 to stage a build that is known not to be the published one.\n`
47
+ );
48
+ return 1;
49
+ }
50
+ process.stderr.write(
51
+ gate.ok
52
+ ? `${gate.line}\n`
53
+ : `${gate.line}\ncut: AEGIS_ALLOW_UNSEALED is set — staging anyway; this artifact will ` +
54
+ `not match the published manifest.\n`
55
+ );
29
56
  let shared;
30
57
  try {
31
58
  shared = await import(pathToFileURL(SHARED).href);
@@ -45,4 +72,4 @@ if (process.argv[1] && path.resolve(process.argv[1]) === fileURLToPath(import.me
45
72
  process.exitCode = await main();
46
73
  }
47
74
 
48
- export { main };
75
+ export { main, sealGate };
@@ -1,4 +1,9 @@
1
1
  #!/usr/bin/env node
2
+ // SPDX-License-Identifier: AGPL-3.0-or-later
3
+ // Copyright (C) 2026 Niklas Borneklint — AEGIS Code (aegiscode) / Aegiscloud.
4
+ // AEGIS Code (aegiscode) — source: https://github.com/aegisinfo/aegiscode-plugin
5
+ // Conveying a modified copy, or running one as a network service, owes the
6
+ // corresponding source under this licence (§5/§13) — see LICENSING.md.
2
7
  /**
3
8
  * Run every `test/cli-*.test.mjs` and report all of them.
4
9
  *
@@ -0,0 +1,76 @@
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.
6
+ /**
7
+ * The publish gate — the half of the provenance story that is a control rather
8
+ * than a deterrent.
9
+ *
10
+ * `cli/src/limits.js` and `cli/src/provenance.js` live INSIDE the package they
11
+ * guard, so whoever edits the safety files can also delete the lines that would
12
+ * have noticed. That is not fixable from within the package, and pretending
13
+ * otherwise is the mistake both gates already refuse to make in their own
14
+ * headers. Staging a tarball is the one moment the question can be asked from
15
+ * OUTSIDE the artifact — on the maintainer's machine, before the bytes are
16
+ * copied — which makes this the only point at which a modified tree is STOPPED
17
+ * instead of merely reported on.
18
+ *
19
+ * Both gates are asked, and separately on purpose: the interlock's set covers
20
+ * `src/limits.js` itself while the manifest does not, and the manifest covers
21
+ * the entry point while the interlock lists a different set. A tree has to
22
+ * satisfy both to be staged.
23
+ *
24
+ * It lives in its own file rather than inline in `predist.mjs` because that
25
+ * file is a THIN WRAPPER by contract — `test/one-vendor.test.mjs` fails it
26
+ * above eighty lines, and the manifest it used to hold is exactly the
27
+ * duplication that rule exists to prevent. A gate is not a manifest, but the
28
+ * rule is a line count, and the honest way to satisfy it is to move the gate
29
+ * out rather than to raise the limit for it.
30
+ *
31
+ * Importing this file stages nothing.
32
+ */
33
+
34
+ import path from 'node:path';
35
+ import { createRequire } from 'node:module';
36
+ import { fileURLToPath } from 'node:url';
37
+
38
+ const HERE = path.dirname(fileURLToPath(import.meta.url));
39
+ const CLI_ROOT = path.join(HERE, '..');
40
+ const require = createRequire(import.meta.url);
41
+
42
+ /**
43
+ * Ask both gates about the tree that is about to be staged.
44
+ *
45
+ * @returns {{ ok: boolean, line: string }} `line` is what the maintainer reads;
46
+ * it may name files, because a maintainer is who it is talking to. The RUNTIME
47
+ * reports are the ones that must not (see cli/src/provenance.js).
48
+ */
49
+ function sealGate() {
50
+ let limits;
51
+ let provenance;
52
+ try {
53
+ limits = require(path.join(CLI_ROOT, 'src', 'limits.js'));
54
+ provenance = require(path.join(CLI_ROOT, 'src', 'provenance.js'));
55
+ } catch (error) {
56
+ return {
57
+ ok: false,
58
+ line: `cut: the safety modules are unreadable (${(error && error.message) || error}).`,
59
+ };
60
+ }
61
+ const interlock = limits.check();
62
+ if (interlock.tripped) {
63
+ return {
64
+ ok: false,
65
+ line: `cut: the sealed set has moved (${interlock.code}) — this tree is not the published one.`,
66
+ };
67
+ }
68
+ const report = provenance.selfCheck();
69
+ if (!report.ok) return { ok: false, line: `cut: ${report.problems.join('; ')}` };
70
+ return {
71
+ ok: true,
72
+ line: `cut: ${report.checked} sealed units verified — this tree is the published one.`,
73
+ };
74
+ }
75
+
76
+ export { sealGate };
package/src/agents.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/app.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
  /**
@@ -21,7 +26,7 @@
21
26
  const readline = require('node:readline');
22
27
  const os = require('node:os');
23
28
  const { randomUUID } = require('node:crypto');
24
- const { createTools, createClient, usageTokens, usageBuckets, buildSystemPrompt, autoProvisionApiKey, hostEnv } = require('./deps.js');
29
+ const { createTools, createClient, usageTokens, usageBuckets, buildSystemPrompt, autoProvisionApiKey, hostEnv, autonomous } = require('./deps.js');
25
30
  const { createEngine, HOST_CLASSES, DEFAULT_CLASS, byokNamespace, effortRung } = require('./engine.js');
26
31
  const { GLYPH, VERBS, themeOf, RESET, THEME_TABLE, AUTO_THEME_INDEX, themeIsLight, reconcileThemeIndex } = require('./theme.js');
27
32
  const { probeTerminalBackground } = require('./caps.js');
@@ -174,6 +179,32 @@ function createApp(options = {}) {
174
179
  // `/automode` and `/confirm` write the store, so a captured flag made both
175
180
  // commands cosmetic — the panel changed while the engine kept asking.
176
181
  let confirmMode = options.confirmMode !== false;
182
+ // ── Auto mode's session start state ────────────────────────────────────────
183
+ // The upstream engine (aegiscodex-dev src/autonomous.js) starts an attended
184
+ // session in auto mode unless AEGIS_AUTO_ROUNDS=0 (false/off/no), and the
185
+ // `←`/`→` chord toggles it freely from there: the env var is a STARTING
186
+ // POINT, not a veto. Same contract here, held in a local rather than
187
+ // re-derived per call, because the two are not the same statement:
188
+ //
189
+ // · re-deriving the env var on every read (a `!autoRoundsDefault(env)`
190
+ // guard inside isYolo) makes the opt-out absolute — `/automode on`,
191
+ // the `→` chord and the window's switch all become no-ops that still
192
+ // write the shared posture OFF, so the CLI chip reads "manual mode on"
193
+ // while the desktop's approvals are off. That is the three-surfaces
194
+ // drift (command, store, engine) this file exists to prevent,
195
+ // reintroduced by an environment variable.
196
+ // · a session flag honours the operator's "start me in manual" without
197
+ // disarming the toggle.
198
+ //
199
+ // `/automode on|off` moves it (commands.js writes `setAutoRounds`), so the
200
+ // chord stays live in both directions and the posture keeps exactly one home.
201
+ let autoRoundsSession = (() => {
202
+ try {
203
+ return autonomous.autoRoundsDefault(process.env);
204
+ } catch {
205
+ return true;
206
+ }
207
+ })();
177
208
  const engine =
178
209
  options.engine ||
179
210
  createEngine({
@@ -1390,6 +1421,16 @@ function createApp(options = {}) {
1390
1421
  render: () => {},
1391
1422
  openOverlay: (o) => openOverlay(o),
1392
1423
  closeOverlay: () => {},
1424
+ // Auto mode's session switch, written by `/automode on|off` (commands.js)
1425
+ // and read by makeHost's isYolo. It lives on the context for the same
1426
+ // reason `switchClass` does: the command must move the fact the status
1427
+ // line, the round-budget allowance and the approval gate all read, or the
1428
+ // command is cosmetic. See the session flag's comment near createApp's
1429
+ // gate wiring for why AEGIS_AUTO_ROUNDS=0 is a starting point and not a
1430
+ // veto.
1431
+ setAutoRounds: (v) => {
1432
+ autoRoundsSession = Boolean(v);
1433
+ },
1393
1434
  askInput: () => Promise.resolve(null),
1394
1435
  withWorking: (fn) => withWorking(fn),
1395
1436
  runPrompt: (text) => runPrompt(text),
@@ -1412,6 +1453,11 @@ function createApp(options = {}) {
1412
1453
  // The class surface: /class switches, /models lists for whichever class
1413
1454
  // is live (the frozen state carries the current one as c.ctx.modelClass).
1414
1455
  listModelsFor: (cls) => listModelsFor(cls),
1456
+ // Re-read the byok rows NOW, past the 5-minute cache. `/model-add` writes
1457
+ // the user-model file and then asks for this, because a picker that
1458
+ // answers from a cache older than the file it just wrote would report the
1459
+ // model it was told to add as missing — for five minutes.
1460
+ refreshByokModels: () => loadByokModels({ force: true }),
1415
1461
  switchClass: (cls) => switchClass(cls),
1416
1462
  classLabel: (cls) => classLabelOf(cls),
1417
1463
  classes: () => (typeof engine.listClasses === 'function' ? engine.listClasses() : []),
@@ -1953,6 +1999,12 @@ function createApp(options = {}) {
1953
1999
  },
1954
2000
  wantsExit: () => wantExit,
1955
2001
  isYolo: () => {
2002
+ // Both halves, in the order the desktop host reads them
2003
+ // (main.js autoRoundsOn): "this session runs auto mode" AND "the
2004
+ // stored posture says don't ask". The first is the session flag above
2005
+ // — `AEGIS_AUTO_ROUNDS=0` starts manual, and `/automode on` (or the
2006
+ // `→` chord, which dispatches exactly that) turns it back on.
2007
+ if (!autoRoundsSession) return false;
1956
2008
  try {
1957
2009
  // The posture, not the rule file: since ON8 the window's switch is the
1958
2010
  // same fact, so a switch turned off there lights this chip too.
@@ -1961,6 +2013,12 @@ function createApp(options = {}) {
1961
2013
  return false;
1962
2014
  }
1963
2015
  },
2016
+ // `/automode on|off` moves the session flag the predicate above reads, so
2017
+ // the command and the chip can never disagree — and an env opt-out is
2018
+ // escapable at the prompt instead of for the life of the process.
2019
+ setAutoRounds: (v) => {
2020
+ autoRoundsSession = Boolean(v);
2021
+ },
1964
2022
  };
1965
2023
  }
1966
2024
 
package/src/art.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
  const { caps, detect, cells, padCells } = require('./caps.js');
package/src/autonomous.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
  /**
@@ -30,11 +35,20 @@ const path = require('node:path');
30
35
  const { queue, autonomous } = require('./deps.js');
31
36
  const { createEngine } = require('./engine.js');
32
37
  const { fmtElapsed } = require('./format.js');
38
+ const limits = require('./limits.js');
33
39
 
34
40
  const SUBCOMMANDS = new Set([
35
41
  'add', 'list', 'run', 'proceed', 'reconcile', 'clear', 'retry', 'help',
36
42
  ]);
37
43
 
44
+ /**
45
+ * The verbs that RUN something. `add`, `list` and `clear` decide nothing and
46
+ * stay available on a build that failed the interlock; these four act — `retry`
47
+ * re-arms a failed task, `reconcile` can chain straight into a drain, and
48
+ * `run`/`proceed` are the drain. See the guard in `runQueueCommand`.
49
+ */
50
+ const EXECUTES = new Set(['run', 'proceed', 'retry', 'reconcile']);
51
+
38
52
  /**
39
53
  * Parse the subcommand's own argv. Deliberately its own tiny parser rather than
40
54
  * bin/aegiscode.js's: the top-level parser owns the one-shot/session flags, and
@@ -228,6 +242,15 @@ async function runQueueCommand(command, argv, io = {}) {
228
242
  return command === 'help' ? 0 : 2;
229
243
  }
230
244
 
245
+ // The interlock, asked here as well as at the entry point, and it is asked
246
+ // about the verbs that EXECUTE. This is the one surface where a machine acts
247
+ // with nobody answering: no prompt, no human to refuse a tool call, stdin on
248
+ // /dev/null under a timer. A build that is not the published one does not get
249
+ // to run a queue through it — it may still read `list` and append with `add`,
250
+ // because those decide nothing, but `run`/`proceed`/`retry` and installing the
251
+ // timer that repeats them are refused. See src/limits.js.
252
+ if (EXECUTES.has(command) && limits.armed()) return limits.refuse();
253
+
231
254
  const cwd = args.flags.cwd ? path.resolve(String(args.flags.cwd)) : process.cwd();
232
255
 
233
256
  if (command === 'add') {
package/src/caps.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
  /**