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,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
  * AEGIS Desktop — thin Electron main shell (host 2).
4
9
  *
@@ -182,6 +187,14 @@ const localTools = require('./lib/local/tools.js');
182
187
  // the `queue:` IPC surface registered by registerQueueIpc() below.
183
188
  const queueModule = require('./lib/local/queue.js');
184
189
  const autonomousModule = require('./lib/local/autonomous.js');
190
+ // Auto mode's round-horizon half: the same arithmetic the upstream engine
191
+ // (aegiscodex-dev src/autonomous.js) and the CLI's presenter use, read here by
192
+ // the one host that owns this face's policy. See createModelDispatch.
193
+ const {
194
+ autoContinuePlan,
195
+ autoContinueLimit,
196
+ autoRoundsDefault,
197
+ } = require('./lib/local/autonomous.js');
185
198
 
186
199
  // The Pro boundary for the autonomous queue (Phase 4 of
187
200
  // docs/upgrade-conversion-plan.md). MAIN-process only, no Electron inside, so
@@ -1078,7 +1091,34 @@ function createConfirmModeDispatch(settings) {
1078
1091
  };
1079
1092
  }
1080
1093
 
1081
- /** Register getConfirmMode/setConfirmMode as `aegis:<name>` on ipcMain —
1094
+ /**
1095
+ * Auto mode's other switch: a posture of "don't ask" IS auto mode on this face,
1096
+ * so an explicit setConfirmMode must move the model dispatch's session state
1097
+ * with it. Otherwise the two halves of the mode can be told different things —
1098
+ * the engine stops asking, the round horizon keeps raising its card, and the
1099
+ * chip in the composer claims auto mode is on.
1100
+ *
1101
+ * OFF starts auto mode for this sitting (`setAutoRounds(true)`, which also
1102
+ * retires a boot-time AEGIS_AUTO_ROUNDS=0), ON ends it. A malformed payload
1103
+ * changes nothing, exactly as in createConfirmModeDispatch — including the
1104
+ * session state, so the two cannot drift on a bad message.
1105
+ */
1106
+ function withAutoRoundsSwitch(confirmDispatch, modelDispatch) {
1107
+ const setConfirmMode = confirmDispatch.setConfirmMode;
1108
+ return {
1109
+ ...confirmDispatch,
1110
+ setConfirmMode: (payload) => {
1111
+ const res = setConfirmMode(payload);
1112
+ if (payload && typeof payload.enabled === 'boolean' && modelDispatch && typeof modelDispatch.setAutoRounds === 'function') {
1113
+ modelDispatch.setAutoRounds(payload.enabled === false);
1114
+ }
1115
+ return res;
1116
+ },
1117
+ };
1118
+ }
1119
+
1120
+ /**
1121
+ * Register getConfirmMode/setConfirmMode as `aegis:<name>` on ipcMain —
1082
1122
  * the same ${IPC_PREFIX}<method> convention registerIpc uses for the rest of
1083
1123
  * the renderer's aegis.* bridge (their handlers need nothing but the
1084
1124
  * payload, so the event is dropped exactly like every non-chatCompletion
@@ -1398,11 +1438,149 @@ function readTextFileForPreview(payload) {
1398
1438
  /**
1399
1439
  * Pure mapping: model:<name> -> LocalEngine call (unit-testable in Node).
1400
1440
  */
1401
- function createModelDispatch(engine) {
1402
- return {
1441
+ function createModelDispatch(engine, { env = process.env, settings } = {}) {
1442
+ // ── Auto mode's second half: the round horizon ────────────────────────────
1443
+ //
1444
+ // autoContinuePlan/autoContinueLimit (lib/local/autonomous.js) answer "may
1445
+ // this horizon ask be answered for the user?" — the arithmetic the engine
1446
+ // defines in src/autonomous.js and the ONLY thing separating auto mode in
1447
+ // aegiscodex-dev from auto mode here. The desktop wired the first half (no
1448
+ // approval cards, via the Tool-approvals switch) and nothing at all for this
1449
+ // one, so a desktop turn that hit its round horizon raised the blocking card
1450
+ // on the first hit and every hit after it. That is the exact question auto
1451
+ // mode exists to stop asking: same answer, same click, once per horizon.
1452
+ //
1453
+ // The policy lives HERE rather than in the engine on purpose — the engine's
1454
+ // own comment states the contract ("the hook is optional and the caller owns
1455
+ // the policy"), so the engine keeps asking and each host decides. This host's
1456
+ // answer is the posture the user already set in one place: confirmations OFF
1457
+ // (the same boolean behind the settings switch and the composer's "auto mode"
1458
+ // chip) means auto mode is on, and the tally is per session because that is
1459
+ // the lifetime of the turn it is funding.
1460
+ const autoUsed = new Map(); // sessionId -> automatic continuations spent
1461
+
1462
+ // Auto mode's session START state — the engine's AEGIS_AUTO_ROUNDS=0 opt-out
1463
+ // (src/autonomous.js autoRoundsDefault), read once here rather than on every
1464
+ // call. Re-derived per call it is a VETO, not a start state: with the variable
1465
+ // exported in the environment that launched the app, the Tool-approvals switch
1466
+ // and any `/automode on` from the CLI sharing the store would write the
1467
+ // posture and change nothing — the chip lit, the round card still every
1468
+ // horizon, and no way back to auto mode short of restarting the app. The
1469
+ // engine's own contract is the other one: the env var picks where the session
1470
+ // STARTS, and the toggle moves it freely from there.
1471
+ //
1472
+ // The opt-out is retired by an explicit act, of which there are two here:
1473
+ // setAutoRounds (the switch and the IPC, wired at bootstrap) and a stored
1474
+ // posture that differs from the one this process booted with (a flip made by
1475
+ // another face — the CLI's `/automode` writes the same key).
1476
+ let autoRoundsSession = autoRoundsDefault(env);
1477
+ let bootPosture;
1478
+ let autoRoundsRetired = false;
1479
+
1480
+ /** True only when auto mode is on: the session state AND a posture that says
1481
+ * don't ask. Read per call, never captured: the settings
1482
+ * switch and `/automode` in the CLI both write the same shared key, so a
1483
+ * flip takes effect on the next horizon without a restart.
1484
+ *
1485
+ * `undefined` from every accessor means "this store cannot answer" — and an
1486
+ * unknown posture must NOT be read as auto mode ON: silently extending turns
1487
+ * (and spending billed rounds) on a store we cannot read is the worse
1488
+ * failure, and the pre-change behaviour (show the card) is the safe default.
1489
+ * AEGIS_AUTO_ROUNDS=0 turns it off session-wide, exactly as in the engine. */
1490
+ const autoRoundsOn = () => {
1491
+ const store = settings || (engine && engine.settings) || null;
1492
+ const bool = (v) => (typeof v === 'boolean' ? v : undefined);
1493
+ let posture;
1494
+ try {
1495
+ if (store && typeof store.confirmModeState === 'function') {
1496
+ const st = store.confirmModeState();
1497
+ posture = bool(st && st.enabled);
1498
+ }
1499
+ if (posture === undefined && store && typeof store.getConfirmMode === 'function') {
1500
+ posture = bool(store.getConfirmMode());
1501
+ }
1502
+ } catch {
1503
+ /* an unreadable store is not auto mode — the card stays up */
1504
+ }
1505
+ // A posture that moved since boot means somebody acted (another face wrote
1506
+ // the same key), so the env opt-out has been answered and no longer applies.
1507
+ if (!autoRoundsRetired && posture !== undefined) {
1508
+ if (bootPosture === undefined) bootPosture = posture;
1509
+ else if (posture !== bootPosture) {
1510
+ autoRoundsRetired = true;
1511
+ autoRoundsSession = true;
1512
+ }
1513
+ }
1514
+ if (!autoRoundsSession || !store || posture === undefined) return false;
1515
+ return posture === false;
1516
+ };
1517
+
1518
+ /** Move the session state — the switch (via setConfirmMode at bootstrap) and
1519
+ * any explicit auto-mode request. Turns OFF means the operator asked for
1520
+ * manual NOW, so it sticks against the boot-time opt-out in both
1521
+ * directions. */
1522
+ const setAutoRounds = (v) => {
1523
+ autoRoundsSession = Boolean(v);
1524
+ autoRoundsRetired = true;
1525
+ };
1526
+
1527
+ /**
1528
+ * Wrap the renderer's stream so a round-horizon ask can be answered for the
1529
+ * human while auto mode is on, and forwarded untouched otherwise.
1530
+ *
1531
+ * Three things are load-bearing:
1532
+ *
1533
+ * · the ENGINE is what answers (`respondRoundsAsk`), not a synthetic frame
1534
+ * — the turn is held open on that promise, so the only honest way to skip
1535
+ * the dialog is to resolve it;
1536
+ * · `{ note }` reaches the renderer, because a budget that grew invisibly
1537
+ * is the "why is it still running?" report, and the CLI announces this
1538
+ * same continuation through its transcript note;
1539
+ * · a declined/failed answer FALLS THROUGH to the card. The allowance is
1540
+ * spent, so this is the real ask — the same "then it asks" contract the
1541
+ * CLI and the engine's status line advertise.
1542
+ */
1543
+ const chatWithAutoRounds = (payload) => {
1544
+ const forward = payload && payload.onStream;
1545
+ if (typeof forward !== 'function') return engine.chat(payload, forward);
1546
+ const sessionId = (payload && payload.sessionId) || '';
1547
+ const onStream = (chunk) => {
1548
+ if (chunk && chunk.rounds && chunk.rounds.id && autoRoundsOn()) {
1549
+ const plan = autoContinuePlan({
1550
+ on: true,
1551
+ used: autoUsed.get(sessionId) || 0,
1552
+ limit: autoContinueLimit(env),
1553
+ });
1554
+ autoUsed.set(sessionId, plan.used);
1555
+ if (plan.auto) {
1556
+ const answered =
1557
+ typeof engine.respondRoundsAsk === 'function'
1558
+ ? engine.respondRoundsAsk(chunk.rounds.id, true)
1559
+ : { ok: false };
1560
+ if (answered && answered.ok) {
1561
+ const spent = Number(chunk.rounds.spent) || 0;
1562
+ forward({
1563
+ note:
1564
+ `auto mode: the ${spent}-round limit was reached — continuing automatically ` +
1565
+ `(${plan.used}/${plan.cap}, then it asks).`,
1566
+ });
1567
+ return;
1568
+ }
1569
+ }
1570
+ // Not auto (allowance spent, or the engine could not take an answer):
1571
+ // show the real card. plan.used is 0 in the spent case, so the next
1572
+ // horizon starts a fresh block of automatic continuations — the same
1573
+ // reset the CLI's presenter applies once the human is actually asked.
1574
+ }
1575
+ forward(chunk);
1576
+ };
1577
+ return engine.chat(payload, onStream);
1578
+ };
1579
+
1580
+ const dispatch = {
1403
1581
  listClasses: () => engine.listClasses(),
1404
1582
  listModels: (payload) => engine.listModels(payload && payload.class),
1405
- chat: (payload) => engine.chat(payload, payload && payload.onStream),
1583
+ chat: chatWithAutoRounds,
1406
1584
  // The AEGIS key lives in a reserved namespace the store refuses to expose
1407
1585
  // or delete through this surface; the filter is belt-and-braces so a
1408
1586
  // mis-wired store can never hand the renderer a removable AEGIS entry.
@@ -1415,6 +1593,37 @@ function createModelDispatch(engine) {
1415
1593
  }),
1416
1594
  'settings.remove': (payload) =>
1417
1595
  engine.settings.remove(payload && payload.provider),
1596
+ // The USER's own model declarations (`client/user-models.js`, the file the
1597
+ // CLI's `/model-add` writes). Settings is the only place a desktop user can
1598
+ // add a model the server's catalog does not name, and until this existed the
1599
+ // only ways were a release or hand-editing a JSON file the app never named.
1600
+ //
1601
+ // These three go through the ENGINE rather than the settings store: the
1602
+ // engine's `listModels('byok')` is what applies them, so the write and the
1603
+ // read share one implementation and cannot disagree about the file. Add and
1604
+ // remove THROW on a malformed provider/model id — the renderer shows the
1605
+ // message, which is the honest outcome for a string that would otherwise be
1606
+ // forwarded to a vendor and 404 there.
1607
+ 'userModels.get': () => engine.userModels(),
1608
+ 'userModels.add': (payload) =>
1609
+ engine.addUserModel(payload && payload.provider, payload && payload.model),
1610
+ 'userModels.remove': (payload) =>
1611
+ engine.removeUserModel(payload && payload.provider, payload && payload.model),
1612
+ // Ask the provider's OWN API which models its key reaches — the end of
1613
+ // "type the vendor's model id from memory". The key stays in the main
1614
+ // process: the renderer passes a provider id and gets back ids, never a
1615
+ // credential, which is the same posture as the provider CRUD above.
1616
+ //
1617
+ // `userModels.addAll` is the bulk write the list makes possible (`/model-add
1618
+ // <provider> '*'` in the CLI): a batch where one refused row does not abort
1619
+ // the rest, and where the counts are returned so the row can say what
1620
+ // actually happened.
1621
+ 'userModels.discover': (payload) => engine.discoverModels(payload && payload.provider),
1622
+ 'userModels.addAll': (payload) =>
1623
+ engine.addUserModels(payload && payload.provider, payload && payload.ids),
1624
+ 'userModels.canDiscover': (payload) =>
1625
+ Boolean(engine.canDiscoverModels(payload && payload.provider)),
1626
+ 'userModels.discoverable': () => engine.discoverableProviders(),
1418
1627
  // Persisting memory ("sync finished turns to cloud memory automatically").
1419
1628
  // Reserved namespace, so it is invisible to the provider CRUD above — but
1420
1629
  // unlike a provider it IS reachable deliberately, through these two. The
@@ -1430,9 +1639,44 @@ function createModelDispatch(engine) {
1430
1639
  // session" grants so a fresh thread never inherits a prior one's.
1431
1640
  respondApproval: (payload) =>
1432
1641
  engine.respondApproval(payload && payload.approvalId, payload && payload.decision),
1642
+ // Round-horizon gate (desktop/lib/local/engine.js requestRoundsAsk): the
1643
+ // renderer's rounds card answers a pending "fund another block of tool
1644
+ // rounds?" ask here. The ask itself arrives as a `{ rounds }` chunk on the
1645
+ // same chat() delta stream the approval card rides — see
1646
+ // desktop/renderer/app.js renderRoundsCard. An unanswered id is a no-op,
1647
+ // same contract as respondApproval.
1648
+ //
1649
+ // Guarded on the method's existence rather than assuming it: an engine
1650
+ // without the ask can never emit a `{ rounds }` chunk, so this branch is
1651
+ // unreachable there — but a renderer/window pair that is newer than the
1652
+ // engine it drives must get an honest `{ ok: false }` instead of a
1653
+ // TypeError inside the IPC handler.
1654
+ respondRoundsAsk: (payload) =>
1655
+ typeof engine.respondRoundsAsk === 'function'
1656
+ ? engine.respondRoundsAsk(payload && payload.roundsAskId, payload && payload.decision)
1657
+ : { ok: false },
1433
1658
  clearApprovals: (payload) =>
1434
1659
  engine.clearSessionApprovals(payload && payload.sessionId),
1435
1660
  };
1661
+
1662
+ // Auto mode's session state is read and moved DIRECTLY, never over IPC.
1663
+ // Two reasons, and both are load-bearing:
1664
+ //
1665
+ // · every ENUMERABLE key of this object becomes an `aegis:<name>` channel
1666
+ // (registerModelIpc iterates Object.entries), so exporting these would
1667
+ // hand the renderer a way to move auto mode's round half without moving
1668
+ // the posture — the exact two-answers-one-question drift this file's
1669
+ // dispatch exists to prevent. The renderer's switch reaches both halves
1670
+ // through aegis:setConfirmMode (withAutoRoundsSwitch), which is the one
1671
+ // act that means "auto mode" on this face;
1672
+ //
1673
+ // · a signature change to the bridge has to be visible where the bridge is
1674
+ // described, so the count in test/model-dispatch.mjs stays a real check.
1675
+ Object.defineProperties(dispatch, {
1676
+ autoRoundsOn: { value: autoRoundsOn, enumerable: false },
1677
+ setAutoRounds: { value: setAutoRounds, enumerable: false },
1678
+ });
1679
+ return dispatch;
1436
1680
  }
1437
1681
 
1438
1682
  /**
@@ -1879,11 +2123,30 @@ function queueEngineWithDeniedApprovals(engine) {
1879
2123
  /* the turn's own error path reports a gate that cannot be answered */
1880
2124
  }
1881
2125
  };
2126
+ // The third net under the same rule, for the round-horizon ask. A queued task
2127
+ // is unattended, so nobody can fund another block and the answer is always
2128
+ // "no" — which is precisely the engine's own non-interactive behaviour (it
2129
+ // stops, files the session hold, and names the env knob). Answering `false`
2130
+ // rather than leaving the promise pending is what keeps a worker from parking
2131
+ // on a card nobody will ever click: an unanswered ask does resolve false
2132
+ // (requestRoundsAsk fails safe), but waiting for the abort instead would look
2133
+ // like a hung task in the queue for however long the turn ran.
2134
+ const stopRounds = (chunk) => {
2135
+ const ask = chunk && chunk.rounds;
2136
+ if (!ask || !ask.id) return;
2137
+ if (typeof engine.respondRoundsAsk !== 'function') return;
2138
+ try {
2139
+ engine.respondRoundsAsk(ask.id, false);
2140
+ } catch {
2141
+ /* as above: the turn reports a gate that cannot be answered */
2142
+ }
2143
+ };
1882
2144
  return {
1883
2145
  ...engine,
1884
2146
  chat(payload, onDelta) {
1885
2147
  return engine.chat(payload, (chunk) => {
1886
2148
  deny(chunk);
2149
+ stopRounds(chunk);
1887
2150
  if (typeof onDelta === 'function') onDelta(chunk);
1888
2151
  });
1889
2152
  },
@@ -3106,7 +3369,7 @@ function bootstrap() {
3106
3369
  handleReplyFinished,
3107
3370
  () => providerRouteConfigured(engine)
3108
3371
  );
3109
- registerModelIpc(
3372
+ const modelIpc = registerModelIpc(
3110
3373
  ipcMain,
3111
3374
  engine,
3112
3375
  sessionsDir,
@@ -3121,7 +3384,16 @@ function bootstrap() {
3121
3384
  // is where the settings store lands — the exact tool gate it controls lives
3122
3385
  // in the engine created alongside it (lib/local/engine.js gatedExecuteTool
3123
3386
  // reads settings.getConfirmMode() on every mutating tool call).
3124
- registerConfirmModeIpc(ipcMain, createConfirmModeDispatch(settings));
3387
+ //
3388
+ // …and it is also auto mode's OTHER switch: a posture of "don't ask" is what
3389
+ // auto mode means on this face, so flipping the switch off is an explicit
3390
+ // request for it and must move the session state with it. Without this, an
3391
+ // app launched with AEGIS_AUTO_ROUNDS=0 (a start-manual opt-out, per the
3392
+ // engine) could be switched to auto mode in the UI — approvals off, chip lit
3393
+ // — while the round horizon kept raising its card, because the env var was
3394
+ // re-read as a veto on every horizon. Same escape hatch as `/automode on` in
3395
+ // the CLI, which shares this store.
3396
+ registerConfirmModeIpc(ipcMain, withAutoRoundsSwitch(createConfirmModeDispatch(settings), modelIpc.modelDispatch));
3125
3397
 
3126
3398
  // Funnel instrumentation (Phase 2 of docs/upgrade-conversion-plan.md):
3127
3399
  // aegis:telemetryEvent / aegis:telemetryReport, backed by
@@ -3569,6 +3841,20 @@ function bootstrap() {
3569
3841
  // again.
3570
3842
  const result = await autoProvision.autoProvisionApiKey(aegis, credentials);
3571
3843
  if (result.key) settings.setAegisKey(result.key);
3844
+ else {
3845
+ // Swallowing this was how a machine could sit keyless — and therefore
3846
+ // absent from the admin panel's user list AND its presence card —
3847
+ // with no trace anywhere: the app just opened in its normal
3848
+ // signed-out state, and the next launch retried with the same
3849
+ // invisible outcome. The server now logs every registration attempt;
3850
+ // this closes the other half so one launch is diagnosable. A 429 here
3851
+ // is not fatal (aegis1 creates the account and withholds the trial),
3852
+ // so it must read as "retry", not as a broken install.
3853
+ const reason =
3854
+ (result.error && (result.error.status || result.error.message || String(result.error))) ||
3855
+ 'no key returned';
3856
+ console.warn(`auto-provision: no account key from register-device (${reason})`);
3857
+ }
3572
3858
  }
3573
3859
  }
3574
3860
  // ── presence beacon ───────────────────────────────────────────────────
@@ -3720,6 +4006,7 @@ module.exports = {
3720
4006
  createQuickLauncherDispatch,
3721
4007
  registerQuickLauncherIpc,
3722
4008
  createConfirmModeDispatch,
4009
+ withAutoRoundsSwitch,
3723
4010
  createTelemetryDispatch,
3724
4011
  registerTelemetryIpc,
3725
4012
  createCovenantDispatch,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "aegis-desktop",
3
3
  "productName": "AEGIS Desktop",
4
- "version": "0.8.34",
4
+ "version": "1.0.1",
5
5
  "description": "Thin Electron host for AEGIS — a local chat UI over the shared client/aegis.js transport. Ships transport + UI only; engine logic stays server-side.",
6
6
  "author": {
7
7
  "name": "AEGIS Code",
@@ -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,6 +354,27 @@ const models = {
349
354
  }),
350
355
  remove: (provider) => invokeModel('settings.remove', { provider }),
351
356
  },
357
+ // The user's OWN model declarations (client/user-models.js): the file the
358
+ // CLI's `/model-add` writes, reached here so a model the server's catalog
359
+ // does not name can be added from Settings instead of by hand. `get()`
360
+ // resolves `{ dir, file, map, invalid }` — `file` is shown in the UI so the
361
+ // remaining escape hatch (an editor) is discoverable, and `invalid` names any
362
+ // hand-edited row that was skipped. `add`/`remove` reject with the validation
363
+ // message for a malformed provider or model id.
364
+ userModels: {
365
+ get: () => invokeModel('userModels.get'),
366
+ add: (provider, model) => invokeModel('userModels.add', { provider, model }),
367
+ remove: (provider, model) => invokeModel('userModels.remove', { provider, model }),
368
+ // Discovery: the renderer names a provider, the MAIN process resolves the
369
+ // key and asks the vendor's list API. No key crosses this bridge in either
370
+ // direction — `discover` returns ids (or an error string to print) and
371
+ // `addAll` returns counts, so a compromised renderer cannot read a
372
+ // credential out of the discovery path.
373
+ discover: (provider) => invokeModel('userModels.discover', { provider }),
374
+ addAll: (provider, ids) => invokeModel('userModels.addAll', { provider, ids }),
375
+ canDiscover: (provider) => invokeModel('userModels.canDiscover', { provider }),
376
+ discoverable: () => invokeModel('userModels.discoverable'),
377
+ },
352
378
  cancel: (sessionId) => invokeModel('cancel', { sessionId }),
353
379
  // Tool-call approval gate: the renderer's approval card calls this to
354
380
  // answer a pending exec/writeFile/editFile request (the approval itself
@@ -357,6 +383,12 @@ const models = {
357
383
  // this session" grants; newChat() calls it so a fresh thread starts clean.
358
384
  respondApproval: (approvalId, decision) =>
359
385
  invokeModel('respondApproval', { approvalId, decision }),
386
+ // Round-horizon gate: answers a pending `{ rounds }` ask raised by the engine
387
+ // when a turn has used every tool round it was allowed (see app.js
388
+ // renderRoundsCard, and requestRoundsAsk in lib/local/engine.js). Same shape
389
+ // and same channel as respondApproval above.
390
+ respondRoundsAsk: (roundsAskId, decision) =>
391
+ invokeModel('respondRoundsAsk', { roundsAskId, decision }),
360
392
  clearApprovals: (sessionId) => invokeModel('clearApprovals', { sessionId }),
361
393
  };
362
394