aegisone 1.0.6 → 1.0.9

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 (222) hide show
  1. package/README.md +2 -2
  2. package/bin/aegis.js +5 -0
  3. package/install.ps1 +5 -0
  4. package/install.sh +5 -0
  5. package/package.json +1 -1
  6. package/scripts/bump.mjs +5 -0
  7. package/scripts/bundle.js +5 -0
  8. package/scripts/predist.mjs +9 -0
  9. package/src/child.js +5 -0
  10. package/src/dispatch.js +5 -0
  11. package/src/doctor.js +5 -0
  12. package/src/host.js +5 -0
  13. package/src/permissions.js +5 -0
  14. package/src/probes.js +5 -0
  15. package/src/release.js +19 -5
  16. package/vendor/cli/README.md +39 -1
  17. package/vendor/cli/bin/aegiscode.js +137 -0
  18. package/vendor/cli/package.json +1 -1
  19. package/vendor/cli/scripts/check.mjs +5 -0
  20. package/vendor/cli/scripts/demo.mjs +5 -0
  21. package/vendor/cli/scripts/predist.mjs +29 -2
  22. package/vendor/cli/scripts/runtests.mjs +5 -0
  23. package/vendor/cli/scripts/seal-gate.mjs +76 -0
  24. package/vendor/cli/src/agents.js +5 -0
  25. package/vendor/cli/src/app.js +79 -1
  26. package/vendor/cli/src/art.js +5 -0
  27. package/vendor/cli/src/autonomous.js +23 -0
  28. package/vendor/cli/src/caps.js +5 -0
  29. package/vendor/cli/src/chatflow.js +245 -32
  30. package/vendor/cli/src/checkpoint.js +5 -0
  31. package/vendor/cli/src/clipboard.js +5 -0
  32. package/vendor/cli/src/cloudsync.js +5 -0
  33. package/vendor/cli/src/commands.js +487 -4
  34. package/vendor/cli/src/config.js +5 -0
  35. package/vendor/cli/src/credentials.js +5 -0
  36. package/vendor/cli/src/deps.js +5 -0
  37. package/vendor/cli/src/devrun.js +5 -0
  38. package/vendor/cli/src/diff.js +5 -0
  39. package/vendor/cli/src/diffview.js +5 -0
  40. package/vendor/cli/src/engine.js +9 -2
  41. package/vendor/cli/src/entitlement.js +5 -0
  42. package/vendor/cli/src/events.js +15 -0
  43. package/vendor/cli/src/export.js +5 -0
  44. package/vendor/cli/src/fingerprint.js +5 -0
  45. package/vendor/cli/src/format.js +5 -0
  46. package/vendor/cli/src/fuzzy.js +5 -0
  47. package/vendor/cli/src/gate.js +12 -0
  48. package/vendor/cli/src/history.js +5 -0
  49. package/vendor/cli/src/init.js +5 -0
  50. package/vendor/cli/src/input.js +5 -0
  51. package/vendor/cli/src/keys.js +29 -2
  52. package/vendor/cli/src/limits.js +192 -0
  53. package/vendor/cli/src/markdown.js +5 -0
  54. package/vendor/cli/src/mcp.js +13 -0
  55. package/vendor/cli/src/models.js +5 -0
  56. package/vendor/cli/src/naming.js +5 -0
  57. package/vendor/cli/src/overlays.js +7 -2
  58. package/vendor/cli/src/panels.js +5 -0
  59. package/vendor/cli/src/permissions.js +56 -1
  60. package/vendor/cli/src/ping.js +5 -0
  61. package/vendor/cli/src/presence.js +5 -0
  62. package/vendor/cli/src/provenance.js +238 -0
  63. package/vendor/cli/src/provenance.lock.json +36 -0
  64. package/vendor/cli/src/render.js +5 -0
  65. package/vendor/cli/src/screen.js +5 -0
  66. package/vendor/cli/src/screens.js +166 -62
  67. package/vendor/cli/src/secret.js +5 -0
  68. package/vendor/cli/src/securefs.js +5 -0
  69. package/vendor/cli/src/settings.js +5 -0
  70. package/vendor/cli/src/shared.js +5 -0
  71. package/vendor/cli/src/sharedpaths.js +5 -0
  72. package/vendor/cli/src/signup.js +5 -0
  73. package/vendor/cli/src/summarize.js +5 -0
  74. package/vendor/cli/src/sysdiag.js +582 -0
  75. package/vendor/cli/src/system.js +5 -0
  76. package/vendor/cli/src/theme.js +5 -0
  77. package/vendor/cli/src/title.js +5 -0
  78. package/vendor/cli/src/todos.js +5 -0
  79. package/vendor/cli/src/tokens.js +5 -0
  80. package/vendor/cli/src/topup.js +5 -0
  81. package/vendor/cli/src/update.js +5 -0
  82. package/vendor/cli/vendor/client/aegis.js +27 -0
  83. package/vendor/cli/vendor/client/attest.js +5 -0
  84. package/vendor/cli/vendor/client/authorship-key.js +5 -0
  85. package/vendor/cli/vendor/client/auto-provision.js +5 -0
  86. package/vendor/cli/vendor/client/brain-catalog.js +5 -0
  87. package/vendor/cli/vendor/client/byok-catalog.js +48 -8
  88. package/vendor/cli/vendor/client/credentials.js +5 -0
  89. package/vendor/cli/vendor/client/device-fingerprint.js +5 -0
  90. package/vendor/cli/vendor/client/env-file.js +5 -0
  91. package/vendor/cli/vendor/client/fingerprint.js +5 -0
  92. package/vendor/cli/vendor/client/foreign-memory.js +5 -0
  93. package/vendor/cli/vendor/client/hooks.js +5 -0
  94. package/vendor/cli/vendor/client/model-discovery.js +332 -0
  95. package/vendor/cli/vendor/client/platform.js +5 -0
  96. package/vendor/cli/vendor/client/prefs.js +5 -0
  97. package/vendor/cli/vendor/client/presence-constants.js +5 -0
  98. package/vendor/cli/vendor/client/presence.js +5 -0
  99. package/vendor/cli/vendor/client/record-vault.js +5 -0
  100. package/vendor/cli/vendor/client/session-store.js +5 -0
  101. package/vendor/cli/vendor/client/topup.js +5 -0
  102. package/vendor/cli/vendor/client/touch.js +5 -0
  103. package/vendor/cli/vendor/client/update.js +5 -0
  104. package/vendor/cli/vendor/client/user-models.js +383 -0
  105. package/vendor/cli/vendor/desktop/lib/local/aegis-seal.mjs +5 -0
  106. package/vendor/cli/vendor/desktop/lib/local/agents.js +5 -0
  107. package/vendor/cli/vendor/desktop/lib/local/autonomous.js +86 -0
  108. package/vendor/cli/vendor/desktop/lib/local/context.js +5 -0
  109. package/vendor/cli/vendor/desktop/lib/local/covenant.js +5 -0
  110. package/vendor/cli/vendor/desktop/lib/local/engine.js +576 -14
  111. package/vendor/cli/vendor/desktop/lib/local/entitlement.js +5 -0
  112. package/vendor/cli/vendor/desktop/lib/local/git-scope.js +5 -0
  113. package/vendor/cli/vendor/desktop/lib/local/local.js +5 -0
  114. package/vendor/cli/vendor/desktop/lib/local/prompt.js +5 -0
  115. package/vendor/cli/vendor/desktop/lib/local/queue.js +5 -0
  116. package/vendor/cli/vendor/desktop/lib/local/session-rounds.js +5 -0
  117. package/vendor/cli/vendor/desktop/lib/local/shell.js +88 -9
  118. package/vendor/cli/vendor/desktop/lib/local/tools.js +13 -6
  119. package/vendor/cli/vendor/desktop/lib/local/turn-guard.js +5 -0
  120. package/vendor/cli/vendor/desktop/lib/local/worktree-lock.js +5 -0
  121. package/vendor/cli/vendor/desktop/lib/settings.js +5 -0
  122. package/vendor/cli/vendor/desktop/renderer/usage.js +73 -1
  123. package/vendor/cli/vendor/mcp/server.js +5 -0
  124. package/vendor/cli/vendor/mcp/tools.js +5 -0
  125. package/vendor/cli/vendor/tools/agent-gate.mjs +23 -0
  126. package/vendor/desktop/README.md +11 -0
  127. package/vendor/desktop/bin/aegis.js +5 -0
  128. package/vendor/desktop/lib/auto.js +5 -0
  129. package/vendor/desktop/lib/avatar/companion.js +5 -0
  130. package/vendor/desktop/lib/avatar/cosmetics.js +5 -0
  131. package/vendor/desktop/lib/avatar/events.js +5 -0
  132. package/vendor/desktop/lib/avatar/holder-turn.js +5 -0
  133. package/vendor/desktop/lib/avatar/holders.js +5 -0
  134. package/vendor/desktop/lib/avatar/identity.js +5 -0
  135. package/vendor/desktop/lib/avatar/level.js +5 -0
  136. package/vendor/desktop/lib/avatar/mirror.js +5 -0
  137. package/vendor/desktop/lib/avatar/persona.js +5 -0
  138. package/vendor/desktop/lib/avatar/profile.js +5 -0
  139. package/vendor/desktop/lib/avatar/register.js +5 -0
  140. package/vendor/desktop/lib/avatar/store.js +5 -0
  141. package/vendor/desktop/lib/avatar/tiers.js +5 -0
  142. package/vendor/desktop/lib/avatar/transfer.js +5 -0
  143. package/vendor/desktop/lib/avatar/turn.js +5 -0
  144. package/vendor/desktop/lib/avatar/voice.js +5 -0
  145. package/vendor/desktop/lib/avatar/xp.js +5 -0
  146. package/vendor/desktop/lib/deep-link.js +40 -1
  147. package/vendor/desktop/lib/fingerprint.js +5 -0
  148. package/vendor/desktop/lib/local/aegis-seal.mjs +5 -0
  149. package/vendor/desktop/lib/local/agents.js +5 -0
  150. package/vendor/desktop/lib/local/autonomous.js +86 -0
  151. package/vendor/desktop/lib/local/context.js +5 -0
  152. package/vendor/desktop/lib/local/covenant.js +5 -0
  153. package/vendor/desktop/lib/local/engine.js +576 -14
  154. package/vendor/desktop/lib/local/entitlement.js +5 -0
  155. package/vendor/desktop/lib/local/git-scope.js +5 -0
  156. package/vendor/desktop/lib/local/local.js +5 -0
  157. package/vendor/desktop/lib/local/prompt.js +5 -0
  158. package/vendor/desktop/lib/local/queue.js +5 -0
  159. package/vendor/desktop/lib/local/session-rounds.js +5 -0
  160. package/vendor/desktop/lib/local/shell.js +88 -9
  161. package/vendor/desktop/lib/local/telemetry.js +5 -0
  162. package/vendor/desktop/lib/local/tools.js +13 -6
  163. package/vendor/desktop/lib/local/turn-guard.js +5 -0
  164. package/vendor/desktop/lib/local/worktree-lock.js +5 -0
  165. package/vendor/desktop/lib/provider-key-mirror.js +5 -0
  166. package/vendor/desktop/lib/quick-launcher.js +5 -0
  167. package/vendor/desktop/lib/settings.js +5 -0
  168. package/vendor/desktop/lib/sync/memory-queue.js +5 -0
  169. package/vendor/desktop/lib/sync/persist-gate.js +5 -0
  170. package/vendor/desktop/lib/sync/sessions.js +5 -0
  171. package/vendor/desktop/lib/window-state.js +5 -0
  172. package/vendor/desktop/main.js +293 -6
  173. package/vendor/desktop/package.json +1 -1
  174. package/vendor/desktop/preload.js +32 -0
  175. package/vendor/desktop/renderer/app.js +506 -12
  176. package/vendor/desktop/renderer/avatar/assemble.js +5 -0
  177. package/vendor/desktop/renderer/avatar/avatar.css +7 -0
  178. package/vendor/desktop/renderer/avatar/avatar.js +5 -0
  179. package/vendor/desktop/renderer/avatar/cards.js +5 -0
  180. package/vendor/desktop/renderer/avatar/hud.js +5 -0
  181. package/vendor/desktop/renderer/avatar/machine.js +5 -0
  182. package/vendor/desktop/renderer/avatar/pane.js +5 -0
  183. package/vendor/desktop/renderer/avatar/parts.js +5 -0
  184. package/vendor/desktop/renderer/budget.js +5 -0
  185. package/vendor/desktop/renderer/diff.js +5 -0
  186. package/vendor/desktop/renderer/diffview.js +5 -0
  187. package/vendor/desktop/renderer/fingerprint.css +7 -0
  188. package/vendor/desktop/renderer/fingerprint.js +5 -0
  189. package/vendor/desktop/renderer/fonts/fonts.css +7 -0
  190. package/vendor/desktop/renderer/index.html +9 -2
  191. package/vendor/desktop/renderer/markdown.js +5 -0
  192. package/vendor/desktop/renderer/quick.css +7 -0
  193. package/vendor/desktop/renderer/quick.html +7 -0
  194. package/vendor/desktop/renderer/quick.js +5 -0
  195. package/vendor/desktop/renderer/stream-policy.js +5 -0
  196. package/vendor/desktop/renderer/style.css +39 -0
  197. package/vendor/desktop/renderer/transcript-view.js +5 -0
  198. package/vendor/desktop/renderer/usage.js +73 -1
  199. package/vendor/desktop/vendor/aegis.js +27 -0
  200. package/vendor/desktop/vendor/agent-gate.mjs +23 -0
  201. package/vendor/desktop/vendor/attest.js +5 -0
  202. package/vendor/desktop/vendor/authorship-key.js +5 -0
  203. package/vendor/desktop/vendor/auto-provision.js +5 -0
  204. package/vendor/desktop/vendor/brain-catalog.js +5 -0
  205. package/vendor/desktop/vendor/byok-catalog.js +48 -8
  206. package/vendor/desktop/vendor/credentials.js +5 -0
  207. package/vendor/desktop/vendor/device-fingerprint.js +5 -0
  208. package/vendor/desktop/vendor/env-file.js +5 -0
  209. package/vendor/desktop/vendor/fingerprint.js +5 -0
  210. package/vendor/desktop/vendor/foreign-memory.js +5 -0
  211. package/vendor/desktop/vendor/hooks.js +5 -0
  212. package/vendor/desktop/vendor/model-discovery.js +332 -0
  213. package/vendor/desktop/vendor/platform.js +5 -0
  214. package/vendor/desktop/vendor/prefs.js +5 -0
  215. package/vendor/desktop/vendor/presence-constants.js +5 -0
  216. package/vendor/desktop/vendor/presence.js +5 -0
  217. package/vendor/desktop/vendor/record-vault.js +5 -0
  218. package/vendor/desktop/vendor/session-store.js +5 -0
  219. package/vendor/desktop/vendor/topup.js +5 -0
  220. package/vendor/desktop/vendor/touch.js +5 -0
  221. package/vendor/desktop/vendor/update.js +5 -0
  222. package/vendor/desktop/vendor/user-models.js +383 -0
@@ -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({
@@ -938,6 +969,13 @@ function createApp(options = {}) {
938
969
  return Promise.resolve('deny');
939
970
  };
940
971
 
972
+ // The round-horizon ask's own no-one-to-answer fallback. Unreachable in
973
+ // practice — `roundsAsk` below is only sent `true` when `p.rounds` exists,
974
+ // so the engine never raises the ask without a prompter — but kept so a
975
+ // future caller that forgets the guard fails safe (stop) instead of
976
+ // hanging the tool loop on an unanswerable promise.
977
+ const denyRoundsNoPrompter = () => Promise.resolve(false);
978
+
941
979
  // Vocabulary bridging lives at module scope (see normalizeDecision) so the
942
980
  // same function the tests import is the one the live path calls.
943
981
  const onDelta = (chunk) => {
@@ -970,6 +1008,14 @@ function createApp(options = {}) {
970
1008
  .catch(() => 'deny')
971
1009
  .then((decision) => engine.respondApproval(info.id, normalizeDecision(decision)));
972
1010
  }
1011
+ if (chunk.rounds) {
1012
+ const info = chunk.rounds;
1013
+ if (live) live.clear();
1014
+ const decide = p.rounds || denyRoundsNoPrompter;
1015
+ Promise.resolve(decide(info))
1016
+ .catch(() => false)
1017
+ .then((decision) => engine.respondRoundsAsk(info.id, decision === true));
1018
+ }
973
1019
  };
974
1020
 
975
1021
  try {
@@ -1004,6 +1050,11 @@ function createApp(options = {}) {
1004
1050
  // `--no-stream` and piped runs get a single body rather than SSE.
1005
1051
  stream: commandCtx.stream !== false,
1006
1052
  sessionId,
1053
+ // Opt-in to the round-horizon dialog (see engine.js requestRoundsAsk)
1054
+ // only when there is actually a `rounds` prompter to answer it — a
1055
+ // one-shot `-p` run or any other caller with no presenter keeps the
1056
+ // engine's old stop-and-record-session behaviour untouched.
1057
+ roundsAsk: Boolean(p.rounds),
1007
1058
  },
1008
1059
  onDelta
1009
1060
  );
@@ -1370,6 +1421,16 @@ function createApp(options = {}) {
1370
1421
  render: () => {},
1371
1422
  openOverlay: (o) => openOverlay(o),
1372
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
+ },
1373
1434
  askInput: () => Promise.resolve(null),
1374
1435
  withWorking: (fn) => withWorking(fn),
1375
1436
  runPrompt: (text) => runPrompt(text),
@@ -1392,6 +1453,11 @@ function createApp(options = {}) {
1392
1453
  // The class surface: /class switches, /models lists for whichever class
1393
1454
  // is live (the frozen state carries the current one as c.ctx.modelClass).
1394
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 }),
1395
1461
  switchClass: (cls) => switchClass(cls),
1396
1462
  classLabel: (cls) => classLabelOf(cls),
1397
1463
  classes: () => (typeof engine.listClasses === 'function' ? engine.listClasses() : []),
@@ -1933,6 +1999,12 @@ function createApp(options = {}) {
1933
1999
  },
1934
2000
  wantsExit: () => wantExit,
1935
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;
1936
2008
  try {
1937
2009
  // The posture, not the rule file: since ON8 the window's switch is the
1938
2010
  // same fact, so a switch turned off there lights this chip too.
@@ -1941,6 +2013,12 @@ function createApp(options = {}) {
1941
2013
  return false;
1942
2014
  }
1943
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
+ },
1944
2022
  };
1945
2023
  }
1946
2024
 
@@ -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');
@@ -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') {
@@ -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
  /**
@@ -349,7 +349,7 @@ function statusLine(state, cols, ctx) {
349
349
  } else if (state.streamJob) {
350
350
  left = [span(t.gray, `${GLYPH.bullet} esc to stop`)];
351
351
  } else if (state.yolo) {
352
- left = [span(t.gray, `${GLYPH.bullet} automode on ${GLYPH.bullet} ? for shortcuts ${GLYPH.bullet} ${GLYPH.rightarrow} for auto mode`)];
352
+ left = [span(t.gray, `${GLYPH.bullet} automode on ${GLYPH.bullet} ${autoContinueLimit()} rounds then it asks ${GLYPH.bullet} ? for shortcuts ${GLYPH.bullet} ${GLYPH.rightarrow} for manual mode`)];
353
353
  } else {
354
354
  left = [span(t.gray, `${GLYPH.pause} manual mode on ${GLYPH.bullet} ? for shortcuts ${GLYPH.bullet} ${GLYPH.rightarrow} for auto mode`)];
355
355
  }
@@ -372,6 +372,10 @@ function shortcutsGrid(cols, ctx) {
372
372
  cell('/', 'for commands', '?', 'for shortcuts'),
373
373
  cell('ctrl + c', 'to quit', 'ctrl + o', 'for permissions'),
374
374
  cell('alt + p', 'to switch model', 'alt + t', 'to toggle thinking'),
375
+ // The shift chords the two pickers commit with. They are on the sheet for
376
+ // the same reason every other row is: `handleOverlayKey` handles them now,
377
+ // and a key a user cannot read about is a key that does not exist.
378
+ cell('shift + ↑/↓', 'pins as it moves', 'shift + enter', 'runs the row'),
375
379
  cell('esc', 'to interrupt a turn', 'ctrl + l', 'to clear the screen'),
376
380
  cell('ctrl + t', 'to show tokens', 'ctrl + r', 'to resume a session'),
377
381
  cell('↑ / ↓', 'for history', 'tab', 'to complete a command'),
@@ -435,6 +439,66 @@ function confirmLines(overlay, cols, ctx) {
435
439
  return lines;
436
440
  }
437
441
 
442
+ /**
443
+ * Automatic round-budget continuations automode may take before it has to
444
+ * ask for real — mirrors the upstream engine's `autoContinuePlan`
445
+ * (aegiscodex-dev's src/autonomous.js). Not "run forever": after `limit`
446
+ * silent yeses the real dialog is shown, so a turn that is genuinely stuck
447
+ * still puts a human in the loop. Pure, and exported, so the policy itself
448
+ * (not just the dialog it feeds) is directly testable.
449
+ *
450
+ * { auto: true, used: n } → answer the ask with "continue", no dialog
451
+ * { auto: false, used: 0 } → show the real dialog (allowance just spent)
452
+ * { auto: false, used: n } → show the real dialog (automode is off)
453
+ */
454
+ const AUTO_CONTINUE_LIMIT = 3;
455
+ /**
456
+ * The allowance, honouring `AEGIS_AUTO_CONTINUE_MAX` exactly as the upstream
457
+ * engine's `autoContinueLimit` does (aegiscodex-dev's src/autonomous.js). Read
458
+ * per call, not frozen at module load, so a test or a wrapper can move the
459
+ * allowance without a reload — and so the number the status line advertises
460
+ * ("N rounds then it asks") is the number the plan will actually spend.
461
+ */
462
+ function autoContinueLimit(env = process.env) {
463
+ const n = Number.parseInt(env && env.AEGIS_AUTO_CONTINUE_MAX, 10);
464
+ return Number.isFinite(n) && n > 0 ? n : AUTO_CONTINUE_LIMIT;
465
+ }
466
+
467
+ function autoContinuePlan({ on = false, used = 0, limit = autoContinueLimit() } = {}) {
468
+ const cap = Number.isFinite(limit) && limit > 0 ? Math.floor(limit) : AUTO_CONTINUE_LIMIT;
469
+ const spent = Number.isFinite(used) && used > 0 ? Math.floor(used) : 0;
470
+ if (!on) return { auto: false, used: spent, cap };
471
+ if (spent >= cap) return { auto: false, used: 0, cap };
472
+ return { auto: true, used: spent + 1, cap };
473
+ }
474
+
475
+ /** The round-budget extension dialog body — same shape as confirmLines, but
476
+ * the subject is a round budget rather than a tool call. */
477
+ function roundsLines(overlay, cols, ctx) {
478
+ const t = themeOf(ctx);
479
+ const lines = [];
480
+ lines.push([span(t.gray, '─'.repeat(Math.min(Math.max(10, cols - 4), 80)))]);
481
+ lines.push([span(t.white, `${overlay.spent}-round tool limit reached`)]);
482
+ lines.push([span('', '')]);
483
+ for (const l of wrapBlock(
484
+ 'The turn is still working — it ended its last round on a tool call instead of an answer.',
485
+ Math.max(8, cols - 4)
486
+ )) {
487
+ lines.push([span(t.gray, l)]);
488
+ }
489
+ lines.push([span('', '')]);
490
+ const opt = (i, label) => {
491
+ const active = overlay.sel === i;
492
+ const left = active ? span(t.lavender, GLYPH.cursor) : span('', ' ');
493
+ return [left, span(t.gray, ` ${i + 1}. `), span(active ? t.lavender : t.white, label)];
494
+ };
495
+ lines.push(opt(0, `Yes, continue with ${overlay.size} more rounds`));
496
+ lines.push(opt(1, 'No, stop here and answer with what I have'));
497
+ lines.push([span('', '')]);
498
+ lines.push([span(t.gray, `extension ${overlay.extensions} of ${overlay.max} · Esc to stop`)]);
499
+ return lines;
500
+ }
501
+
438
502
  /**
439
503
  * The accounting bits for a turn — model, tokens, the in/out split, €, elapsed
440
504
  * and call count. Shared by the standalone `meta` row and the folded footer, so
@@ -841,6 +905,24 @@ async function runSession(host) {
841
905
  const lineCache = new WeakMap();
842
906
 
843
907
  let overlay = null;
908
+
909
+ /**
910
+ * The palette's rows: the ONE ranking the frame draws and the key handlers
911
+ * act on. Tab and Enter each wrote this expression out in full, which is two
912
+ * chances for the row that is completed or run to be a different row than the
913
+ * one highlighted. A function declaration so `render`'s closure can call it
914
+ * whatever order the definitions are initialised in.
915
+ */
916
+ function paletteRows(query) {
917
+ const q = paletteQuery(query == null ? (overlay && overlay.query) || '' : query);
918
+ return fuzzy.fuzzyRankWithAliases(q, host.visibleCommands(), (c) => c.name, (c) => c.aliases || []);
919
+ }
920
+ // Automode's running tally of silent "continue" answers to the round-budget
921
+ // dialog (see autoContinuePlan above). Cleared whenever the human is
922
+ // actually asked (autoContinuePlan resets it once the allowance is spent),
923
+ // so it is "N automatic continuations per block", never a life-of-session
924
+ // total that a long build could quietly exhaust.
925
+ let autoContinues = 0;
844
926
  let working = false;
845
927
  let abort = null;
846
928
  let spinnerFrame = 0;
@@ -1124,6 +1206,8 @@ async function runSession(host) {
1124
1206
  ol = shortcutsGrid(cols, ctx);
1125
1207
  } else if (overlay.type === 'confirm') {
1126
1208
  ol = confirmLines(overlay, cols, ctx);
1209
+ } else if (overlay.type === 'rounds') {
1210
+ ol = roundsLines(overlay, cols, ctx);
1127
1211
  } else if (overlay.type === 'panel') {
1128
1212
  ol = overlay.lines || [];
1129
1213
  }
@@ -1224,6 +1308,73 @@ async function runSession(host) {
1224
1308
  })();
1225
1309
  });
1226
1310
 
1311
+ // The round-budget extension dialog (engine.js requestRoundsAsk, surfaced
1312
+ // here as `chunk.rounds` → `presenter.rounds`). Same own-nextKey-loop shape
1313
+ // as confirmTool above. The cursor starts on "No" deliberately: an Enter on
1314
+ // an untouched dialog must not spend another block of rounds, so a
1315
+ // declined dialog is bit-for-bit the engine's own hard stop.
1316
+ const confirmRoundsExtension = (info) =>
1317
+ new Promise((resolve) => {
1318
+ // ── automode: the first AUTO_CONTINUE_LIMIT asks are answered for the
1319
+ // human ───────────────────────────────────────────────────────────────
1320
+ // This is the "fund a few blocks automatically, then ask for real"
1321
+ // contract: with automode on, a turn that reaches its horizon is
1322
+ // extended silently a few times, and the ask after that is the real
1323
+ // dialog again — so automode is "don't make me answer the same budget
1324
+ // question every time", not "run forever with no one watching".
1325
+ const yolo = Boolean(host.isYolo && host.isYolo());
1326
+ const plan = autoContinuePlan({ on: yolo, used: autoContinues });
1327
+ autoContinues = plan.used;
1328
+ if (plan.auto) {
1329
+ note(
1330
+ `auto: ${info.spent}-round limit reached — continuing automatically` +
1331
+ ` (${plan.used}/${plan.cap}, then it asks).`
1332
+ );
1333
+ render();
1334
+ resolve(true);
1335
+ return;
1336
+ }
1337
+ if (yolo) {
1338
+ // The allowance is spent: this IS the ask. Say so, or the dialog reads
1339
+ // as automode having silently switched itself off.
1340
+ note(`auto: ${plan.cap} automatic continuations used — asking you now (answering restarts the block).`);
1341
+ render();
1342
+ }
1343
+ overlay = {
1344
+ type: 'rounds',
1345
+ spent: Number(info.spent) || 0,
1346
+ extensions: Number(info.extensions) || 1,
1347
+ max: Number(info.max) || 8,
1348
+ size: Number(info.size) || Number(info.spent) || 0,
1349
+ sel: 1,
1350
+ };
1351
+ render();
1352
+ (async () => {
1353
+ const choose = (yes) => {
1354
+ overlay = null;
1355
+ render();
1356
+ resolve(yes);
1357
+ };
1358
+ for (;;) {
1359
+ const key = await nextKey();
1360
+ if (key.name === KEY.UP || key.name === KEY.DOWN || key.name === KEY.TAB) {
1361
+ overlay.sel = 1 - overlay.sel;
1362
+ render();
1363
+ } else if (key.name === KEY.ENTER) {
1364
+ choose(overlay.sel === 0);
1365
+ return;
1366
+ } else if (key.name === KEY.ESC || key.name === KEY.CTRL_C) {
1367
+ choose(false);
1368
+ return;
1369
+ } else if (key.name === 'char') {
1370
+ const c = String(key.ch).trim();
1371
+ if (c === '1') { choose(true); return; }
1372
+ if (c === '2') { choose(false); return; }
1373
+ }
1374
+ }
1375
+ })();
1376
+ });
1377
+
1227
1378
  const startResponse = async (prompt) => {
1228
1379
  working = true;
1229
1380
  spinnerFrame = 0;
@@ -1326,6 +1477,7 @@ async function runSession(host) {
1326
1477
  scheduleRender();
1327
1478
  },
1328
1479
  approval: (info) => confirmTool(info),
1480
+ rounds: (info) => confirmRoundsExtension(info),
1329
1481
  };
1330
1482
 
1331
1483
  let result = null;
@@ -1862,6 +2014,24 @@ async function runSession(host) {
1862
2014
  }
1863
2015
  };
1864
2016
 
2017
+ /**
2018
+ * Pin a model row — the ONE path a row is applied through, shared by Enter,
2019
+ * shift+enter and the shift+arrow chord. Written out once because applying a
2020
+ * model is not just a config write: it may have to move the class first and
2021
+ * it may have to collect the provider key the row needs. A second apply path
2022
+ * would eventually skip one of those (the reference's own picker pinned the
2023
+ * id and left the class behind), and the user would be running on a model
2024
+ * whose key this machine does not hold.
2025
+ */
2026
+ const applyModelRow = async (chosen) => {
2027
+ if (!chosen) return;
2028
+ if (chosen.cls === 'byok' && ctx.modelClass !== 'byok') await dispatch('/class byok');
2029
+ ctx.model = chosen.id;
2030
+ host.updateConfig({ model: chosen.id, currentModelId: chosen.id, modelClass: ctx.modelClass });
2031
+ note(`model: ${chosen.id}${chosen.cls === 'byok' ? ' (byok)' : ''}`);
2032
+ await collectKeyFor(chosen);
2033
+ };
2034
+
1865
2035
  const handleOverlayKey = async (key) => {
1866
2036
  const type = overlay.type;
1867
2037
  if (key.name === KEY.ESC || key.name === KEY.CTRL_C) {
@@ -1875,16 +2045,11 @@ async function runSession(host) {
1875
2045
  return;
1876
2046
  }
1877
2047
  if (key.name === KEY.TAB && type === 'palette') {
1878
- // Tab completes the query to the highlighted command, ranking with the
1879
- // same function the palette rendered with so the row completed is the
1880
- // row Enter would run. Nothing highlighted (no matches) → do nothing.
1881
- const list = fuzzy.fuzzyRankWithAliases(
1882
- paletteQuery(overlay.query),
1883
- host.visibleCommands(),
1884
- (c) => c.name,
1885
- (c) => c.aliases || []
1886
- );
1887
- const chosen = list[overlay.sel || 0];
2048
+ // Tab completes the query to the highlighted command. The ranking is
2049
+ // `paletteRows()`, the same list the frame drew and Enter runs, so the
2050
+ // row completed is the row highlighted. Nothing highlighted (no matches)
2051
+ // → do nothing.
2052
+ const chosen = paletteRows()[overlay.sel || 0];
1888
2053
  if (chosen) {
1889
2054
  overlay.query = chosen.name;
1890
2055
  overlay.sel = 0;
@@ -1896,13 +2061,7 @@ async function runSession(host) {
1896
2061
  if (type === 'palette') {
1897
2062
  // Rank with the same function the palette rendered with, so the row
1898
2063
  // highlighted is the row Enter runs.
1899
- const list = fuzzy.fuzzyRankWithAliases(
1900
- paletteQuery(overlay.query),
1901
- host.visibleCommands(),
1902
- (c) => c.name,
1903
- (c) => c.aliases || []
1904
- );
1905
- const chosen = list[overlay.sel || 0];
2064
+ const chosen = paletteRows()[overlay.sel || 0];
1906
2065
  const arg = String(overlay.query || '').trim().split(/\s+/).slice(1).join(' ');
1907
2066
  overlay = null;
1908
2067
  render();
@@ -1915,20 +2074,7 @@ async function runSession(host) {
1915
2074
  const chosen = (overlay.items || [])[overlay.sel || 0];
1916
2075
  overlay = null;
1917
2076
  render();
1918
- if (chosen) {
1919
- // A direct-provider (byok) row needs the class the id actually
1920
- // belongs to before the pin can route anywhere.
1921
- if (chosen.cls === 'byok' && ctx.modelClass !== 'byok') await dispatch('/class byok');
1922
- ctx.model = chosen.id;
1923
- host.updateConfig({ model: chosen.id, currentModelId: chosen.id, modelClass: ctx.modelClass });
1924
- note(`model: ${chosen.id}${chosen.cls === 'byok' ? ' (byok)' : ''}`);
1925
- // Then the key, if this row needs one this machine does not have —
1926
- // collected here rather than as a warning to run some command
1927
- // afterward. See collectKeyFor: the decision comes from the shared
1928
- // env-file module, so the variable a key is written to is the same
1929
- // one the desktop reads, instead of each host keeping a private copy.
1930
- await collectKeyFor(chosen);
1931
- }
2077
+ await applyModelRow(chosen);
1932
2078
  render();
1933
2079
  return;
1934
2080
  }
@@ -1956,6 +2102,69 @@ async function runSession(host) {
1956
2102
  render();
1957
2103
  return;
1958
2104
  }
2105
+ if (key.name === KEY.SHIFT_UP || key.name === KEY.SHIFT_DOWN) {
2106
+ // Shift is the one-keystroke commit in the two pickers that write a
2107
+ // setting: it moves the highlight one row in the pressed direction and
2108
+ // applies THAT row immediately, so changing the model is a single key
2109
+ // instead of point-then-Enter. It routes into the same apply paths Enter
2110
+ // uses, so the chord cannot pin a model Enter would refuse to pin, skip
2111
+ // the provider-key prompt a byok row needs, or store an effort level the
2112
+ // picker's own table does not contain.
2113
+ const step = key.name === KEY.SHIFT_UP ? -1 : 1;
2114
+ const max = Math.max(0, overlayRowCount() - 1);
2115
+ overlay.sel = Math.min(max, Math.max(0, (overlay.sel || 0) + step));
2116
+ if (type === 'model') {
2117
+ const chosen = (overlay.items || [])[overlay.sel || 0];
2118
+ overlay = null;
2119
+ render();
2120
+ await applyModelRow(chosen);
2121
+ render();
2122
+ return;
2123
+ }
2124
+ if (type === 'effort') {
2125
+ const chosen = overlays.EFFORT_VALUES[overlay.sel || 0];
2126
+ overlay = null;
2127
+ ctx.effort = chosen || 'high';
2128
+ host.updateConfig({ effort: ctx.effort });
2129
+ note(`effort: ${ctx.effort}`);
2130
+ render();
2131
+ return;
2132
+ }
2133
+ render();
2134
+ return;
2135
+ }
2136
+ if (key.name === KEY.SHIFT_ENTER) {
2137
+ // The same commit as Enter, in the spelling terminals that have no other
2138
+ // way to send it: on the palette it runs the highlighted command without
2139
+ // the user reaching for the Enter key proper, and in a picker it applies
2140
+ // the highlighted row. Both read the same sel/items every other path
2141
+ // reads, so the chord cannot run a different row than the frame drew.
2142
+ if (type === 'palette') {
2143
+ const chosen = paletteRows()[overlay.sel || 0];
2144
+ overlay = null;
2145
+ render();
2146
+ if (chosen) await dispatch(`/${chosen.name}`);
2147
+ return;
2148
+ }
2149
+ if (type === 'model') {
2150
+ const chosen = (overlay.items || [])[overlay.sel || 0];
2151
+ overlay = null;
2152
+ render();
2153
+ await applyModelRow(chosen);
2154
+ render();
2155
+ return;
2156
+ }
2157
+ if (type === 'effort') {
2158
+ const chosen = overlays.EFFORT_VALUES[overlay.sel || 0];
2159
+ overlay = null;
2160
+ ctx.effort = chosen || 'high';
2161
+ host.updateConfig({ effort: ctx.effort });
2162
+ note(`effort: ${ctx.effort}`);
2163
+ render();
2164
+ return;
2165
+ }
2166
+ return;
2167
+ }
1959
2168
  if (key.name === KEY.UP) {
1960
2169
  overlay.sel = Math.max(0, (overlay.sel || 0) - 1);
1961
2170
  render();
@@ -2483,6 +2692,10 @@ module.exports = {
2483
2692
  // answers with tokens the engine actually honours (see APPROVAL_CHOICES).
2484
2693
  APPROVAL_CHOICES,
2485
2694
  APPROVAL_DECISIONS,
2695
+ roundsLines,
2696
+ autoContinuePlan,
2697
+ autoContinueLimit,
2698
+ AUTO_CONTINUE_LIMIT,
2486
2699
  rowLines,
2487
2700
  transcriptLines,
2488
2701
  inputPreviewText,
@@ -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
  /**
@@ -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
  /**