aegisone 1.0.64 → 1.0.66

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 (374) hide show
  1. package/README.md +1 -1
  2. package/bin/aegis.js +1 -1
  3. package/package.json +1 -1
  4. package/scripts/bump.mjs +1 -1
  5. package/scripts/bundle.js +1 -1
  6. package/scripts/postinstall.mjs +1 -1
  7. package/scripts/predist.mjs +1 -1
  8. package/src/child.js +1 -1
  9. package/src/dispatch.js +1 -1
  10. package/src/doctor.js +1 -1
  11. package/src/probes.js +1 -1
  12. package/src/productupdate.js +1 -1
  13. package/src/protocol.js +1 -1
  14. package/src/release.js +1 -1
  15. package/src/selfhost.js +1 -1
  16. package/vendor/cli/bin/aegiscode.js +47 -5
  17. package/vendor/cli/package.json +1 -1
  18. package/vendor/cli/scripts/check.mjs +1 -1
  19. package/vendor/cli/scripts/demo.mjs +1 -1
  20. package/vendor/cli/scripts/postinstall.mjs +1 -1
  21. package/vendor/cli/scripts/predist.mjs +1 -1
  22. package/vendor/cli/scripts/runtests.mjs +1 -1
  23. package/vendor/cli/src/app.js +1 -1
  24. package/vendor/cli/src/art.js +1 -1
  25. package/vendor/cli/src/autonomous.js +574 -10
  26. package/vendor/cli/src/chatflow.js +1 -1
  27. package/vendor/cli/src/checkpoint.js +1 -1
  28. package/vendor/cli/src/clipboard.js +1 -1
  29. package/vendor/cli/src/cloudsync.js +1 -1
  30. package/vendor/cli/src/commands.js +2 -2
  31. package/vendor/cli/src/config.js +1 -1
  32. package/vendor/cli/src/connect.js +1 -1
  33. package/vendor/cli/src/devrun.js +1 -1
  34. package/vendor/cli/src/diff.js +1 -1
  35. package/vendor/cli/src/diffview.js +1 -1
  36. package/vendor/cli/src/dream-cmd.js +3 -0
  37. package/vendor/cli/src/dream.js +1 -1
  38. package/vendor/cli/src/engine.js +1 -1
  39. package/vendor/cli/src/events.js +1 -1
  40. package/vendor/cli/src/export.js +1 -1
  41. package/vendor/cli/src/fingerprint.js +1 -1
  42. package/vendor/cli/src/format.js +1 -1
  43. package/vendor/cli/src/fuzzy.js +1 -1
  44. package/vendor/cli/src/history.js +1 -1
  45. package/vendor/cli/src/init.js +1 -1
  46. package/vendor/cli/src/limits.js +1 -1
  47. package/vendor/cli/src/markdown.js +1 -1
  48. package/vendor/cli/src/models.js +1 -1
  49. package/vendor/cli/src/overlays.js +1 -1
  50. package/vendor/cli/src/panels.js +1 -1
  51. package/vendor/cli/src/ping.js +1 -1
  52. package/vendor/cli/src/presence.js +1 -1
  53. package/vendor/cli/src/provenance.lock.json +3 -3
  54. package/vendor/cli/src/render.js +1 -1
  55. package/vendor/cli/src/screen.js +1 -1
  56. package/vendor/cli/src/screens.js +1 -1
  57. package/vendor/cli/src/secret.js +1 -1
  58. package/vendor/cli/src/securefs.js +1 -1
  59. package/vendor/cli/src/settings.js +1 -1
  60. package/vendor/cli/src/signup.js +1 -1
  61. package/vendor/cli/src/summarize.js +1 -1
  62. package/vendor/cli/src/sysdiag.js +1 -1
  63. package/vendor/cli/src/theme.js +1 -1
  64. package/vendor/cli/src/title.js +1 -1
  65. package/vendor/cli/src/todos.js +1 -1
  66. package/vendor/cli/src/tokens.js +1 -1
  67. package/vendor/cli/src/topup.js +1 -1
  68. package/vendor/cli/src/update.js +1 -1
  69. package/vendor/cli/vendor/client/aegis.js +1 -1
  70. package/vendor/cli/vendor/client/attest.js +1 -1
  71. package/vendor/cli/vendor/client/authorship-key.js +1 -1
  72. package/vendor/cli/vendor/client/auto-provision.js +1 -1
  73. package/vendor/cli/vendor/client/brain-catalog.js +1 -1
  74. package/vendor/cli/vendor/client/byok-catalog.js +1 -1
  75. package/vendor/cli/vendor/client/catalog-client.js +1 -1
  76. package/vendor/cli/vendor/client/conversation-export.js +1 -1
  77. package/vendor/cli/vendor/client/credentials.js +1 -1
  78. package/vendor/cli/vendor/client/credits.js +1 -1
  79. package/vendor/cli/vendor/client/drive-connect.js +1 -1
  80. package/vendor/cli/vendor/client/env-file.js +1 -1
  81. package/vendor/cli/vendor/client/fingerprint.js +1 -1
  82. package/vendor/cli/vendor/client/foreign-memory.js +1 -1
  83. package/vendor/cli/vendor/client/foreign-sessions.js +1 -1
  84. package/vendor/cli/vendor/client/google-signin.js +1 -1
  85. package/vendor/cli/vendor/client/hooks.js +1 -1
  86. package/vendor/cli/vendor/client/model-discovery.js +1 -1
  87. package/vendor/cli/vendor/client/model-sync.js +1 -1
  88. package/vendor/cli/vendor/client/naming.js +1 -1
  89. package/vendor/cli/vendor/client/platform.js +1 -1
  90. package/vendor/cli/vendor/client/prefs.js +1 -1
  91. package/vendor/cli/vendor/client/presence.js +1 -1
  92. package/vendor/cli/vendor/client/record-vault.js +2 -2
  93. package/vendor/cli/vendor/client/session-search.js +1 -1
  94. package/vendor/cli/vendor/client/session-store.js +1 -1
  95. package/vendor/cli/vendor/client/skills.js +1 -1
  96. package/vendor/cli/vendor/client/topup.js +1 -1
  97. package/vendor/cli/vendor/client/touch.js +1 -1
  98. package/vendor/cli/vendor/client/update.js +1 -1
  99. package/vendor/cli/vendor/client/user-models.js +1 -1
  100. package/vendor/cli/vendor/desktop/lib/local/attachments.js +1 -1
  101. package/vendor/cli/vendor/desktop/lib/local/autonomous.js +1 -1
  102. package/vendor/cli/vendor/desktop/lib/local/claude-pro.js +1 -1
  103. package/vendor/cli/vendor/desktop/lib/local/context.js +1 -1
  104. package/vendor/cli/vendor/desktop/lib/local/engine.js +1 -1
  105. package/vendor/cli/vendor/desktop/lib/local/entitlement.js +1 -1
  106. package/vendor/cli/vendor/desktop/lib/local/integrity.js +1 -1
  107. package/vendor/cli/vendor/desktop/lib/local/local.js +1 -1
  108. package/vendor/cli/vendor/desktop/lib/local/perm-rules.js +5 -0
  109. package/vendor/cli/vendor/desktop/lib/local/perm-store.js +5 -0
  110. package/vendor/cli/vendor/desktop/lib/local/perm-write.js +5 -0
  111. package/vendor/cli/vendor/desktop/lib/local/pro-sessions.js +3 -1
  112. package/vendor/cli/vendor/desktop/lib/local/prompt.js +1 -1
  113. package/vendor/cli/vendor/desktop/lib/local/queue.js +1 -1
  114. package/vendor/cli/vendor/desktop/lib/local/repeat-guard.js +1 -1
  115. package/vendor/cli/vendor/desktop/lib/local/session-rounds.js +1 -1
  116. package/vendor/cli/vendor/desktop/lib/local/spill.js +1 -1
  117. package/vendor/cli/vendor/desktop/lib/local/turn-guard.js +1 -1
  118. package/vendor/cli/vendor/desktop/lib/local/verify-stop.js +1 -1
  119. package/vendor/cli/vendor/desktop/lib/local/worktree-lock.js +1 -1
  120. package/vendor/cli/vendor/desktop/lib/settings.js +1 -1
  121. package/vendor/cli/vendor/desktop/main.js +82 -1
  122. package/vendor/cli/vendor/desktop/renderer/usage.js +1 -1
  123. package/vendor/cli/vendor/hosts/install.js +1 -1
  124. package/vendor/cli/vendor/hosts/openai-shim.js +1 -1
  125. package/vendor/cli/vendor/hosts/spec.js +1 -1
  126. package/vendor/cli/vendor/hosts/targets.js +1 -1
  127. package/vendor/cli/vendor/mcp/admission.js +1 -1
  128. package/vendor/cli/vendor/mcp/server.js +1 -1
  129. package/vendor/cli/vendor/mcp/tools.js +1 -1
  130. package/vendor/cli/vendor/one/src/child.js +1 -1
  131. package/vendor/cli/vendor/one/src/protocol.js +1 -1
  132. package/vendor/cli/vendor/one/src/selfhost.js +1 -1
  133. package/vendor/desktop/bin/aegis.js +1 -1
  134. package/vendor/desktop/lib/auto.js +1 -1
  135. package/vendor/desktop/lib/avatar/companion.js +1 -1
  136. package/vendor/desktop/lib/avatar/cosmetics.js +1 -1
  137. package/vendor/desktop/lib/avatar/holder-turn.js +1 -1
  138. package/vendor/desktop/lib/avatar/holders.js +1 -1
  139. package/vendor/desktop/lib/avatar/identity.js +1 -1
  140. package/vendor/desktop/lib/avatar/level.js +1 -1
  141. package/vendor/desktop/lib/avatar/mirror.js +1 -1
  142. package/vendor/desktop/lib/avatar/persona.js +1 -1
  143. package/vendor/desktop/lib/avatar/profile.js +1 -1
  144. package/vendor/desktop/lib/avatar/register.js +1 -1
  145. package/vendor/desktop/lib/avatar/store.js +1 -1
  146. package/vendor/desktop/lib/avatar/transfer.js +1 -1
  147. package/vendor/desktop/lib/avatar/turn.js +1 -1
  148. package/vendor/desktop/lib/avatar/voice.js +1 -1
  149. package/vendor/desktop/lib/avatar/xp.js +1 -1
  150. package/vendor/desktop/lib/deep-link.js +1 -1
  151. package/vendor/desktop/lib/local/attachments.js +1 -1
  152. package/vendor/desktop/lib/local/autonomous.js +1 -1
  153. package/vendor/desktop/lib/local/claude-pro.js +1 -1
  154. package/vendor/desktop/lib/local/cli-face.js +1 -1
  155. package/vendor/desktop/lib/local/context.js +1 -1
  156. package/vendor/desktop/lib/local/engine.js +1 -1
  157. package/vendor/desktop/lib/local/entitlement.js +1 -1
  158. package/vendor/desktop/lib/local/integrity.js +1 -1
  159. package/vendor/desktop/lib/local/local.js +1 -1
  160. package/vendor/desktop/lib/local/perm-rules.js +5 -0
  161. package/vendor/desktop/lib/local/perm-store.js +5 -0
  162. package/vendor/desktop/lib/local/perm-write.js +5 -0
  163. package/vendor/desktop/lib/local/pro-sessions.js +3 -1
  164. package/vendor/desktop/lib/local/prompt.js +1 -1
  165. package/vendor/desktop/lib/local/pty-host.js +1 -1
  166. package/vendor/desktop/lib/local/queue.js +1 -1
  167. package/vendor/desktop/lib/local/repeat-guard.js +1 -1
  168. package/vendor/desktop/lib/local/session-rounds.js +1 -1
  169. package/vendor/desktop/lib/local/spill.js +1 -1
  170. package/vendor/desktop/lib/local/telemetry.js +1 -1
  171. package/vendor/desktop/lib/local/turn-guard.js +1 -1
  172. package/vendor/desktop/lib/local/verify-stop.js +1 -1
  173. package/vendor/desktop/lib/local/worktree-lock.js +1 -1
  174. package/vendor/desktop/lib/provider-key-mirror.js +1 -1
  175. package/vendor/desktop/lib/quick-launcher.js +1 -1
  176. package/vendor/desktop/lib/settings.js +1 -1
  177. package/vendor/desktop/lib/skills-host.js +1 -1
  178. package/vendor/desktop/lib/speech-host.js +1 -1
  179. package/vendor/desktop/lib/sync/memory-store.js +1 -1
  180. package/vendor/desktop/lib/sync/persist-gate.js +1 -1
  181. package/vendor/desktop/lib/window-state.js +1 -1
  182. package/vendor/desktop/main.js +82 -1
  183. package/vendor/desktop/package.json +1 -1
  184. package/vendor/desktop/preload.js +3 -1
  185. package/vendor/desktop/renderer/app.js +3 -3
  186. package/vendor/desktop/renderer/avatar/assemble.js +1 -1
  187. package/vendor/desktop/renderer/avatar/avatar.js +1 -1
  188. package/vendor/desktop/renderer/avatar/cards.js +1 -1
  189. package/vendor/desktop/renderer/avatar/hud.js +1 -1
  190. package/vendor/desktop/renderer/avatar/pane.js +1 -1
  191. package/vendor/desktop/renderer/avatar/parts.js +1 -1
  192. package/vendor/desktop/renderer/commands.js +1 -1
  193. package/vendor/desktop/renderer/companion.js +1 -1
  194. package/vendor/desktop/renderer/composer-triggers.js +1 -1
  195. package/vendor/desktop/renderer/dictation.js +1 -1
  196. package/vendor/desktop/renderer/diff.js +1 -1
  197. package/vendor/desktop/renderer/diffview.js +1 -1
  198. package/vendor/desktop/renderer/fingerprint.js +2 -2
  199. package/vendor/desktop/renderer/index.html +10 -4
  200. package/vendor/desktop/renderer/library.js +1 -1
  201. package/vendor/desktop/renderer/markdown.js +1 -1
  202. package/vendor/desktop/renderer/palette-filter.js +1 -1
  203. package/vendor/desktop/renderer/provider-toolbar.js +1 -1
  204. package/vendor/desktop/renderer/providers.js +1 -1
  205. package/vendor/desktop/renderer/pty-frame.css +35 -0
  206. package/vendor/desktop/renderer/pty-frame.html +47 -0
  207. package/vendor/desktop/renderer/pty-panel.js +1 -1
  208. package/vendor/desktop/renderer/pty-window.html +72 -0
  209. package/vendor/desktop/renderer/pty-window.js +3 -0
  210. package/vendor/desktop/renderer/quick.js +1 -1
  211. package/vendor/desktop/renderer/settings-skills.js +1 -1
  212. package/vendor/desktop/renderer/shortcuts.js +1 -1
  213. package/vendor/desktop/renderer/stream-policy.js +1 -1
  214. package/vendor/desktop/renderer/style.css +77 -3
  215. package/vendor/desktop/renderer/transcript-view.js +1 -1
  216. package/vendor/desktop/renderer/usage.js +1 -1
  217. package/vendor/desktop/renderer/welcome-rows.js +1 -1
  218. package/vendor/desktop/vendor/aegis.js +1 -1
  219. package/vendor/desktop/vendor/attest.js +1 -1
  220. package/vendor/desktop/vendor/authorship-key.js +1 -1
  221. package/vendor/desktop/vendor/auto-provision.js +1 -1
  222. package/vendor/desktop/vendor/brain-catalog.js +1 -1
  223. package/vendor/desktop/vendor/byok-catalog.js +1 -1
  224. package/vendor/desktop/vendor/catalog-client.js +1 -1
  225. package/vendor/desktop/vendor/conversation-export.js +1 -1
  226. package/vendor/desktop/vendor/credentials.js +1 -1
  227. package/vendor/desktop/vendor/credits.js +1 -1
  228. package/vendor/desktop/vendor/drive-connect.js +1 -1
  229. package/vendor/desktop/vendor/env-file.js +1 -1
  230. package/vendor/desktop/vendor/faces/cli/bin/aegiscode.js +2 -2
  231. package/vendor/desktop/vendor/faces/cli/package.json +1 -1
  232. package/vendor/desktop/vendor/faces/cli/scripts/check.mjs +1 -1
  233. package/vendor/desktop/vendor/faces/cli/scripts/demo.mjs +1 -1
  234. package/vendor/desktop/vendor/faces/cli/scripts/postinstall.mjs +1 -1
  235. package/vendor/desktop/vendor/faces/cli/scripts/predist.mjs +1 -1
  236. package/vendor/desktop/vendor/faces/cli/scripts/runtests.mjs +1 -1
  237. package/vendor/desktop/vendor/faces/cli/src/app.js +1 -1
  238. package/vendor/desktop/vendor/faces/cli/src/art.js +1 -1
  239. package/vendor/desktop/vendor/faces/cli/src/autonomous.js +1 -1
  240. package/vendor/desktop/vendor/faces/cli/src/caps.js +1 -1
  241. package/vendor/desktop/vendor/faces/cli/src/chatflow.js +1 -1
  242. package/vendor/desktop/vendor/faces/cli/src/checkpoint.js +1 -1
  243. package/vendor/desktop/vendor/faces/cli/src/clipboard.js +1 -1
  244. package/vendor/desktop/vendor/faces/cli/src/cloudsync.js +1 -1
  245. package/vendor/desktop/vendor/faces/cli/src/commands.js +2 -2
  246. package/vendor/desktop/vendor/faces/cli/src/config.js +1 -1
  247. package/vendor/desktop/vendor/faces/cli/src/connect.js +1 -1
  248. package/vendor/desktop/vendor/faces/cli/src/devrun.js +1 -1
  249. package/vendor/desktop/vendor/faces/cli/src/diff.js +1 -1
  250. package/vendor/desktop/vendor/faces/cli/src/diffview.js +1 -1
  251. package/vendor/desktop/vendor/faces/cli/src/dream-cmd.js +3 -0
  252. package/vendor/desktop/vendor/faces/cli/src/dream.js +1 -1
  253. package/vendor/desktop/vendor/faces/cli/src/engine.js +1 -1
  254. package/vendor/desktop/vendor/faces/cli/src/events.js +1 -1
  255. package/vendor/desktop/vendor/faces/cli/src/export.js +1 -1
  256. package/vendor/desktop/vendor/faces/cli/src/fingerprint.js +1 -1
  257. package/vendor/desktop/vendor/faces/cli/src/format.js +1 -1
  258. package/vendor/desktop/vendor/faces/cli/src/fuzzy.js +1 -1
  259. package/vendor/desktop/vendor/faces/cli/src/history.js +1 -1
  260. package/vendor/desktop/vendor/faces/cli/src/init.js +1 -1
  261. package/vendor/desktop/vendor/faces/cli/src/limits.js +1 -1
  262. package/vendor/desktop/vendor/faces/cli/src/markdown.js +1 -1
  263. package/vendor/desktop/vendor/faces/cli/src/mcp.js +1 -1
  264. package/vendor/desktop/vendor/faces/cli/src/models.js +1 -1
  265. package/vendor/desktop/vendor/faces/cli/src/overlays.js +1 -1
  266. package/vendor/desktop/vendor/faces/cli/src/panels.js +1 -1
  267. package/vendor/desktop/vendor/faces/cli/src/permissions.js +1 -1
  268. package/vendor/desktop/vendor/faces/cli/src/ping.js +1 -1
  269. package/vendor/desktop/vendor/faces/cli/src/presence.js +1 -1
  270. package/vendor/desktop/vendor/faces/cli/src/provenance.js +1 -1
  271. package/vendor/desktop/vendor/faces/cli/src/provenance.lock.json +3 -3
  272. package/vendor/desktop/vendor/faces/cli/src/render.js +1 -1
  273. package/vendor/desktop/vendor/faces/cli/src/screen.js +1 -1
  274. package/vendor/desktop/vendor/faces/cli/src/screens.js +1 -1
  275. package/vendor/desktop/vendor/faces/cli/src/secret.js +1 -1
  276. package/vendor/desktop/vendor/faces/cli/src/securefs.js +1 -1
  277. package/vendor/desktop/vendor/faces/cli/src/settings.js +1 -1
  278. package/vendor/desktop/vendor/faces/cli/src/signup.js +1 -1
  279. package/vendor/desktop/vendor/faces/cli/src/summarize.js +1 -1
  280. package/vendor/desktop/vendor/faces/cli/src/sysdiag.js +1 -1
  281. package/vendor/desktop/vendor/faces/cli/src/theme.js +1 -1
  282. package/vendor/desktop/vendor/faces/cli/src/title.js +1 -1
  283. package/vendor/desktop/vendor/faces/cli/src/todos.js +1 -1
  284. package/vendor/desktop/vendor/faces/cli/src/tokens.js +1 -1
  285. package/vendor/desktop/vendor/faces/cli/src/topup.js +1 -1
  286. package/vendor/desktop/vendor/faces/cli/src/update.js +1 -1
  287. package/vendor/desktop/vendor/faces/cli/vendor/client/aegis.js +1 -1
  288. package/vendor/desktop/vendor/faces/cli/vendor/client/attest.js +1 -1
  289. package/vendor/desktop/vendor/faces/cli/vendor/client/authorship-key.js +1 -1
  290. package/vendor/desktop/vendor/faces/cli/vendor/client/auto-provision.js +1 -1
  291. package/vendor/desktop/vendor/faces/cli/vendor/client/brain-catalog.js +1 -1
  292. package/vendor/desktop/vendor/faces/cli/vendor/client/byok-catalog.js +1 -1
  293. package/vendor/desktop/vendor/faces/cli/vendor/client/catalog-client.js +1 -1
  294. package/vendor/desktop/vendor/faces/cli/vendor/client/conversation-export.js +1 -1
  295. package/vendor/desktop/vendor/faces/cli/vendor/client/credentials.js +1 -1
  296. package/vendor/desktop/vendor/faces/cli/vendor/client/credits.js +1 -1
  297. package/vendor/desktop/vendor/faces/cli/vendor/client/drive-connect.js +1 -1
  298. package/vendor/desktop/vendor/faces/cli/vendor/client/env-file.js +1 -1
  299. package/vendor/desktop/vendor/faces/cli/vendor/client/fingerprint.js +1 -1
  300. package/vendor/desktop/vendor/faces/cli/vendor/client/foreign-memory.js +1 -1
  301. package/vendor/desktop/vendor/faces/cli/vendor/client/foreign-sessions.js +1 -1
  302. package/vendor/desktop/vendor/faces/cli/vendor/client/google-signin.js +1 -1
  303. package/vendor/desktop/vendor/faces/cli/vendor/client/hooks.js +1 -1
  304. package/vendor/desktop/vendor/faces/cli/vendor/client/model-discovery.js +1 -1
  305. package/vendor/desktop/vendor/faces/cli/vendor/client/model-sync.js +1 -1
  306. package/vendor/desktop/vendor/faces/cli/vendor/client/naming.js +1 -1
  307. package/vendor/desktop/vendor/faces/cli/vendor/client/platform.js +1 -1
  308. package/vendor/desktop/vendor/faces/cli/vendor/client/prefs.js +1 -1
  309. package/vendor/desktop/vendor/faces/cli/vendor/client/presence.js +1 -1
  310. package/vendor/desktop/vendor/faces/cli/vendor/client/record-vault.js +2 -2
  311. package/vendor/desktop/vendor/faces/cli/vendor/client/session-search.js +1 -1
  312. package/vendor/desktop/vendor/faces/cli/vendor/client/session-store.js +1 -1
  313. package/vendor/desktop/vendor/faces/cli/vendor/client/skills.js +1 -1
  314. package/vendor/desktop/vendor/faces/cli/vendor/client/topup.js +1 -1
  315. package/vendor/desktop/vendor/faces/cli/vendor/client/touch.js +1 -1
  316. package/vendor/desktop/vendor/faces/cli/vendor/client/update.js +1 -1
  317. package/vendor/desktop/vendor/faces/cli/vendor/client/user-models.js +1 -1
  318. package/vendor/desktop/vendor/faces/cli/vendor/desktop/lib/local/attachments.js +1 -1
  319. package/vendor/desktop/vendor/faces/cli/vendor/desktop/lib/local/autonomous.js +1 -1
  320. package/vendor/desktop/vendor/faces/cli/vendor/desktop/lib/local/claude-pro.js +1 -1
  321. package/vendor/desktop/vendor/faces/cli/vendor/desktop/lib/local/context.js +1 -1
  322. package/vendor/desktop/vendor/faces/cli/vendor/desktop/lib/local/engine.js +1 -1
  323. package/vendor/desktop/vendor/faces/cli/vendor/desktop/lib/local/entitlement.js +1 -1
  324. package/vendor/desktop/vendor/faces/cli/vendor/desktop/lib/local/exec-plan.js +1 -1
  325. package/vendor/desktop/vendor/faces/cli/vendor/desktop/lib/local/integrity.js +1 -1
  326. package/vendor/desktop/vendor/faces/cli/vendor/desktop/lib/local/local.js +1 -1
  327. package/vendor/desktop/vendor/faces/cli/vendor/desktop/lib/local/perm-rules.js +2 -0
  328. package/vendor/desktop/vendor/faces/cli/vendor/desktop/lib/local/perm-store.js +3 -1
  329. package/vendor/desktop/vendor/faces/cli/vendor/desktop/lib/local/perm-write.js +2 -0
  330. package/vendor/desktop/vendor/faces/cli/vendor/desktop/lib/local/pro-sessions.js +3 -1
  331. package/vendor/desktop/vendor/faces/cli/vendor/desktop/lib/local/prompt.js +1 -1
  332. package/vendor/desktop/vendor/faces/cli/vendor/desktop/lib/local/queue.js +1 -1
  333. package/vendor/desktop/vendor/faces/cli/vendor/desktop/lib/local/repeat-guard.js +1 -1
  334. package/vendor/desktop/vendor/faces/cli/vendor/desktop/lib/local/session-rounds.js +1 -1
  335. package/vendor/desktop/vendor/faces/cli/vendor/desktop/lib/local/shell.js +1 -1
  336. package/vendor/desktop/vendor/faces/cli/vendor/desktop/lib/local/spill.js +1 -1
  337. package/vendor/desktop/vendor/faces/cli/vendor/desktop/lib/local/tools.js +1 -1
  338. package/vendor/desktop/vendor/faces/cli/vendor/desktop/lib/local/turn-guard.js +1 -1
  339. package/vendor/desktop/vendor/faces/cli/vendor/desktop/lib/local/verify-stop.js +1 -1
  340. package/vendor/desktop/vendor/faces/cli/vendor/desktop/lib/local/worktree-lock.js +1 -1
  341. package/vendor/desktop/vendor/faces/cli/vendor/desktop/lib/settings.js +1 -1
  342. package/vendor/desktop/vendor/faces/cli/vendor/desktop/main.js +3 -3
  343. package/vendor/desktop/vendor/faces/cli/vendor/desktop/renderer/usage.js +1 -1
  344. package/vendor/desktop/vendor/faces/cli/vendor/hosts/install.js +1 -1
  345. package/vendor/desktop/vendor/faces/cli/vendor/hosts/openai-shim.js +1 -1
  346. package/vendor/desktop/vendor/faces/cli/vendor/hosts/spec.js +1 -1
  347. package/vendor/desktop/vendor/faces/cli/vendor/hosts/targets.js +1 -1
  348. package/vendor/desktop/vendor/faces/cli/vendor/mcp/admission.js +1 -1
  349. package/vendor/desktop/vendor/faces/cli/vendor/mcp/server.js +1 -1
  350. package/vendor/desktop/vendor/faces/cli/vendor/mcp/tools.js +1 -1
  351. package/vendor/desktop/vendor/faces/cli/vendor/one/src/child.js +1 -1
  352. package/vendor/desktop/vendor/faces/cli/vendor/one/src/protocol.js +1 -1
  353. package/vendor/desktop/vendor/faces/cli/vendor/one/src/selfhost.js +1 -1
  354. package/vendor/desktop/vendor/fingerprint.js +1 -1
  355. package/vendor/desktop/vendor/foreign-memory.js +1 -1
  356. package/vendor/desktop/vendor/foreign-sessions.js +1 -1
  357. package/vendor/desktop/vendor/google-signin.js +1 -1
  358. package/vendor/desktop/vendor/hooks.js +1 -1
  359. package/vendor/desktop/vendor/model-discovery.js +1 -1
  360. package/vendor/desktop/vendor/model-sync.js +1 -1
  361. package/vendor/desktop/vendor/naming.js +1 -1
  362. package/vendor/desktop/vendor/platform.js +1 -1
  363. package/vendor/desktop/vendor/prefs.js +1 -1
  364. package/vendor/desktop/vendor/presence.js +1 -1
  365. package/vendor/desktop/vendor/protocol.js +1 -1
  366. package/vendor/desktop/vendor/record-vault.js +2 -2
  367. package/vendor/desktop/vendor/selfhost.js +1 -1
  368. package/vendor/desktop/vendor/session-search.js +1 -1
  369. package/vendor/desktop/vendor/session-store.js +1 -1
  370. package/vendor/desktop/vendor/skills.js +1 -1
  371. package/vendor/desktop/vendor/topup.js +1 -1
  372. package/vendor/desktop/vendor/touch.js +1 -1
  373. package/vendor/desktop/vendor/update.js +1 -1
  374. package/vendor/desktop/vendor/user-models.js +1 -1
@@ -30,6 +30,9 @@
30
30
  * 2 usage error, or no credential to run an unattended turn with
31
31
  */
32
32
 
33
+ const { spawn, spawnSync } = require('node:child_process');
34
+ const os = require('node:os');
35
+ const fs = require('node:fs');
33
36
  const path = require('node:path');
34
37
 
35
38
  const { queue, autonomous } = require('./deps.js');
@@ -39,7 +42,7 @@ const { fmtElapsed } = require('./format.js');
39
42
  const limits = require('./limits.js');
40
43
 
41
44
  const SUBCOMMANDS = new Set([
42
- 'add', 'list', 'run', 'proceed', 'reconcile', 'clear', 'retry', 'help',
45
+ 'add', 'list', 'run', 'proceed', 'start', 'tick', 'timer', 'report', 'reconcile', 'clear', 'retry', 'help',
43
46
  ]);
44
47
 
45
48
  /**
@@ -48,7 +51,24 @@ const SUBCOMMANDS = new Set([
48
51
  * re-arms a failed task, `reconcile` can chain straight into a drain, and
49
52
  * `run`/`proceed` are the drain. See the guard in `runQueueCommand`.
50
53
  */
51
- const EXECUTES = new Set(['run', 'proceed', 'retry', 'reconcile']);
54
+ /**
55
+ * The verbs that RUN something. `add`, `list`, `report` and `clear` decide
56
+ * nothing and stay available on a build that failed the interlock; these act —
57
+ * `retry` re-arms a failed task, `reconcile` can chain straight into a drain,
58
+ * and `run`/`proceed`/`start` are the drain. See the guard in
59
+ * `runQueueCommand`.
60
+ */
61
+ const EXECUTES = new Set(['run', 'proceed', 'start', 'tick', 'timer', 'retry', 'reconcile']);
62
+
63
+ /**
64
+ * The load gate, applied inside a `tick` and nowhere else.
65
+ *
66
+ * A flat number rather than a multiple of the core count: the machine that runs
67
+ * a timer is usually also the machine somebody is working on, and "4.0" is a
68
+ * sentence a user can reason about ("more than four runnable things and the
69
+ * drain waits") where "1.5 × 8 cores" is not. `--max-load 0` disables the gate.
70
+ */
71
+ const DEFAULT_MAX_LOAD = 4.0;
52
72
 
53
73
  /**
54
74
  * Parse the subcommand's own argv. Deliberately its own tiny parser rather than
@@ -58,7 +78,7 @@ const EXECUTES = new Set(['run', 'proceed', 'retry', 'reconcile']);
58
78
  */
59
79
  function parseFlags(argv) {
60
80
  const opts = { terms: [], json: false, flags: {} };
61
- const takesValue = new Set(['cwd', 'model', 'effort', 'workers', 'max', 'max-rounds', 'source', 'class']);
81
+ const takesValue = new Set(['cwd', 'model', 'effort', 'workers', 'max', 'max-rounds', 'source', 'class', 'since', 'max-load', 'every']);
62
82
  for (let i = 0; i < argv.length; i++) {
63
83
  const a = argv[i];
64
84
  if (a === '--json') {
@@ -68,7 +88,7 @@ function parseFlags(argv) {
68
88
  if (a.startsWith('--')) {
69
89
  const [rawName, inline] = a.slice(2).split('=');
70
90
  const name = rawName.trim();
71
- const bools = new Set(['commit', 'all', 'auto', 'stop-on-error', 'single-pass', 'help']);
91
+ const bools = new Set(['commit', 'all', 'auto', 'stop-on-error', 'single-pass', 'help', 'wait']);
72
92
  if (bools.has(name)) {
73
93
  opts.flags[name] = true;
74
94
  continue;
@@ -319,6 +339,56 @@ async function runQueueCommand(command, argv, io = {}) {
319
339
  return 0;
320
340
  }
321
341
 
342
+ if (command === 'report') {
343
+ // THE MISSING HALF OF "SET A TIMER AND REPORT BACK".
344
+ //
345
+ // A drain writes its outcome to runs.jsonl and stdout. Nothing read it back
346
+ // into a conversation, so an AI that queued work and stopped had no way to
347
+ // learn how it went — the timer fired, the task finished, and the next turn
348
+ // still knew nothing. This is that surface: a plain command any host can
349
+ // run with an ordinary shell tool, reading the plugin's own files, so it
350
+ // works identically whether the model is Claude, Codex, Gemini, Cursor or
351
+ // anything else. `--since <id>` narrows to what happened after a task.
352
+ const since = args.flags.since !== undefined ? Number.parseInt(String(args.flags.since), 10) : null;
353
+ const limit = intFlag(args.flags, 'max') || 20;
354
+ const runs = queue.readRuns(process.env, { limit });
355
+ const items = queue.loadQueue(process.env);
356
+ const counts = describeCounts(items);
357
+ // `--since` filters by task id rather than by timestamp: the caller knows
358
+ // the id it queued (it printed it), and ids are monotonic, so "since #12"
359
+ // is the question actually being asked — "did what I queued finish?".
360
+ const selected = Number.isFinite(since) && since !== null ? runs.filter((r) => Number(r.id) > since) : runs;
361
+ if (json) {
362
+ emit({ ok: true, file: queue.runsPath(process.env), counts, runs: selected });
363
+ return 0;
364
+ }
365
+ stdout.write(`runs: ${queue.runsPath(process.env)}\n`);
366
+ if (!selected.length) {
367
+ stdout.write(
368
+ Number.isFinite(since) && since !== null
369
+ ? `(nothing finished after #${since})\n`
370
+ : '(no finished runs yet)\n'
371
+ );
372
+ }
373
+ for (const r of selected) {
374
+ // `stopped` is a task that hit its tool-round horizon and is still
375
+ // pending — not a failure, and saying "failed" here would send a caller
376
+ // chasing work that is queued and will resume.
377
+ const mark = r.status === 'done' ? '✓' : r.status === 'stopped' ? '⏸' : '✗';
378
+ stdout.write(`${mark} #${r.id} ${String(r.status || '?').padEnd(7)} ${r.model || '(default)'} ${fmtElapsed(r.ms)}\n`);
379
+ stdout.write(` ${String(r.task || '').replace(/\s+/g, ' ').trim().slice(0, 160)}\n`);
380
+ if (r.error) stdout.write(` error: ${String(r.error).split('\n')[0]}\n`);
381
+ if (r.files && r.files.length) stdout.write(` files: ${r.files.slice(0, 8).join(', ')}\n`);
382
+ }
383
+ // The queue counts, so "is anything still in flight" is answered in the
384
+ // same breath as "what finished" — a report that says only what is done
385
+ // leaves the reader unable to tell "finished" from "still running".
386
+ stdout.write(
387
+ `queue: ${counts.pending} pending, ${counts.running} running, ${counts.done} done, ${counts.error} error\n`
388
+ );
389
+ return 0;
390
+ }
391
+
322
392
  if (command === 'clear') {
323
393
  const res = queue.clearQueue(process.env, { all: Boolean(args.flags.all) });
324
394
  emit({ ok: true, ...res }, `aegiscode: removed ${res.removed} finished task(s); ${res.kept} kept`);
@@ -340,6 +410,198 @@ async function runQueueCommand(command, argv, io = {}) {
340
410
  return 0;
341
411
  }
342
412
 
413
+ // ── start: the drain, detached ───────────────────────────────────────────
414
+ //
415
+ // Held deliberately BEFORE the engine is built: this process does not run a
416
+ // turn, it spawns one and exits. The pattern it replaces was the reason a
417
+ // long drain never survived — a caller (an AI shelling out, a timer with a
418
+ // timeout) ran `proceed` inline and the harness killed it at its own wall
419
+ // clock, taking the drain and the lock with it. A detached child leads its
420
+ // own process group, so the kill does not reach it, and this command returns
421
+ // a pid in milliseconds instead of blocking for the length of the work.
422
+ if (command === 'start') {
423
+ const running = queue.loadQueue(process.env).filter((i) => i.status === 'running' && i.pid);
424
+ if (running.length) {
425
+ stderr.write(
426
+ `aegiscode autonomous start: #${running[0].id} is already running (pid ${running[0].pid})\n`
427
+ );
428
+ return 1;
429
+ }
430
+ const childArgs = ['autonomous', 'proceed'];
431
+ // Read the flag directly, not the `commit` local: that one is declared below
432
+ // this branch (it belongs to the model-running path), and reading it here
433
+ // would be a temporal-dead-zone error at runtime.
434
+ if (args.flags.commit) childArgs.push('--commit');
435
+ if (intFlag(args.flags, 'max')) childArgs.push('--max', String(intFlag(args.flags, 'max')));
436
+ if (args.flags['stop-on-error']) childArgs.push('--stop-on-error');
437
+
438
+ // Re-exec THIS cli through the same interpreter, not through $PATH: a
439
+ // globally installed `aegiscode` may be a different build or missing
440
+ // entirely from a detached process's environment, and a detached drain that
441
+ // silently ran nothing is the failure mode this whole change is about.
442
+ const self = process.argv[1];
443
+ if (!self) {
444
+ stderr.write('aegiscode autonomous start: cannot locate the CLI entry point to detach\n');
445
+ return 2;
446
+ }
447
+ let child;
448
+ try {
449
+ child = spawn(process.execPath, [self, ...childArgs], {
450
+ cwd,
451
+ env: process.env,
452
+ detached: true,
453
+ // The log is where `report` cannot help: a child that dies before it
454
+ // settles anything leaves nothing in runs.jsonl, and without a file its
455
+ // last words go to a closed pipe.
456
+ stdio: 'ignore',
457
+ });
458
+ } catch (e) {
459
+ stderr.write(`aegiscode autonomous start: could not spawn the drain — ${e.message}\n`);
460
+ return 1;
461
+ }
462
+ child.unref();
463
+ emit(
464
+ { ok: true, pid: child.pid, log: queue.dataDir(process.env) },
465
+ `aegiscode: drain started in the background (pid ${child.pid})\n` +
466
+ ' it writes ~/.aegiscode/runs.jsonl as tasks settle — read it back with `aegiscode autonomous report`'
467
+ );
468
+ return 0;
469
+ }
470
+
471
+ // ── timer: the thing that makes "set a timer" real ────────────────────
472
+ //
473
+ // Before this, `/schedule` was a stub that printed a URL and no timer was
474
+ // ever armed: a queued task was drained only if a human typed `proceed`, so
475
+ // "set a timer and report back" could not work on any model or any host. The
476
+ // unit below is what wakes up. Its body is `tick`, never `proceed`, because
477
+ // the load gate has to be INSIDE the thing the timer calls.
478
+ if (command === 'timer') {
479
+ const action = (args.terms[0] || 'status').toLowerCase();
480
+ const every = intFlag(args.flags, 'every') || 5;
481
+ const maxLoad = args.flags['max-load'] !== undefined ? Number(args.flags['max-load']) : DEFAULT_MAX_LOAD;
482
+ if (!Number.isFinite(maxLoad) || maxLoad < 0) {
483
+ stderr.write('aegiscode autonomous timer: --max-load needs a number >= 0 (0 disables the gate)\n');
484
+ return 2;
485
+ }
486
+ // Re-exec THIS cli, not whatever `aegiscode` resolves to inside a systemd
487
+ // or cron environment — a PATH there is not the user's PATH, and a timer
488
+ // that silently runs a different build (or nothing) is the exact failure
489
+ // this whole change exists to end.
490
+ const self = process.argv[1] ? path.resolve(process.argv[1]) : null;
491
+ if (!self) {
492
+ stderr.write('aegiscode autonomous timer: cannot locate the CLI entry point to schedule\n');
493
+ return 2;
494
+ }
495
+ // `tick` always commits: the timer fires unattended, and a drain that left
496
+ // every change as an uncommitted diff would just accumulate work nobody
497
+ // reviews. `--commit` is in the unit body unconditionally, once.
498
+ const tickArgs = ['autonomous', 'tick', '--commit', '--max-load', String(maxLoad)];
499
+ const plan = timerPlan({ every, maxLoad, self, tickArgs, cwd });
500
+
501
+ if (action === 'status') {
502
+ const written = plan.kind === 'unsupported' ? false : plan.paths.every((p) => fs.existsSync(p));
503
+ const state = plan.state();
504
+ // WRITTEN IS NOT ARMED. The units can sit on disk while the scheduler
505
+ // refuses to load them (no user systemd, a container, WSL), and calling
506
+ // that "installed" is exactly the silent-timer failure this change is
507
+ // about. `installed` therefore means the scheduler accepted it, and
508
+ // `written` says whether the files are there to be finished by hand.
509
+ const active = state === 'active' || state === 'loaded' || state === 'registered';
510
+ const installed = written && (active || plan.kind === 'schtasks');
511
+ // Prefer the installed unit's own values. The flags describe a timer that
512
+ // does not exist yet; only the files (or the scheduler's record) describe
513
+ // the one that is going to fire. `--every 9 status` on a 5-minute timer
514
+ // must not answer "9".
515
+ const recorded = written && typeof plan.read === 'function' ? plan.read() : null;
516
+ const fromUnit = Boolean(recorded && (recorded.every != null || recorded.maxLoad != null));
517
+ const shownEvery = recorded && recorded.every != null ? recorded.every : every;
518
+ const shownMaxLoad = recorded && recorded.maxLoad != null ? recorded.maxLoad : maxLoad;
519
+ if (json) {
520
+ emit({
521
+ ok: true, installed, written, kind: plan.kind, paths: plan.paths,
522
+ every: shownEvery, maxLoad: shownMaxLoad, fromUnit, state,
523
+ });
524
+ return 0;
525
+ }
526
+ stdout.write(`timer: ${plan.kind} — ${installed ? 'installed and armed' : written ? 'WRITTEN BUT NOT ARMED' : 'not installed'}\n`);
527
+ for (const p of plan.paths) stdout.write(` ${fs.existsSync(p) ? '✓' : '·'} ${p}\n`);
528
+ stdout.write(
529
+ ` every ${shownEvery} min, load gate ${shownMaxLoad > 0 ? shownMaxLoad : 'off'}` +
530
+ `${fromUnit ? ' (from the installed unit)' : ''}\n`
531
+ );
532
+ if (!fromUnit && !written) {
533
+ stdout.write(` (requested values — nothing is installed, so nothing fires)\n`);
534
+ }
535
+ if (state) stdout.write(` state: ${state}\n`);
536
+ if (!installed) {
537
+ stdout.write(
538
+ written
539
+ ? '\n the units exist but the scheduler has not loaded them. finish it:\n' +
540
+ ' systemctl --user daemon-reload && systemctl --user enable --now aegiscode-queue.timer\n'
541
+ : '\n install it: aegiscode autonomous timer install\n'
542
+ );
543
+ }
544
+ return 0;
545
+ }
546
+
547
+ if (action === 'install') {
548
+ if (plan.kind === 'unsupported') {
549
+ stderr.write(`aegiscode autonomous timer: this platform (${process.platform}) has no supported scheduler\n`);
550
+ return 2;
551
+ }
552
+ try {
553
+ plan.install();
554
+ } catch (e) {
555
+ stderr.write(`aegiscode autonomous timer: install failed — ${e.message}\n`);
556
+ return 1;
557
+ }
558
+ emit(
559
+ { ok: true, kind: plan.kind, paths: plan.paths, every, maxLoad },
560
+ `aegiscode: timer installed — every ${every} min, load gate ${maxLoad > 0 ? maxLoad : 'off'}\n` +
561
+ ` it runs: aegiscode autonomous tick --max-load ${maxLoad}\n` +
562
+ ' collect what it did with `aegiscode autonomous report`'
563
+ );
564
+ return 0;
565
+ }
566
+
567
+ if (action === 'remove') {
568
+ try {
569
+ plan.remove();
570
+ } catch (e) {
571
+ stderr.write(`aegiscode autonomous timer: remove failed — ${e.message}\n`);
572
+ return 1;
573
+ }
574
+ emit({ ok: true, kind: plan.kind, paths: plan.paths }, 'aegiscode: timer removed');
575
+ return 0;
576
+ }
577
+
578
+ stderr.write(`aegiscode autonomous timer: unknown action \`${action}\` — install | status | remove\n`);
579
+ return 2;
580
+ }
581
+
582
+ // ── tick: one gated drain, the body of the timer ────────────────────────
583
+ //
584
+ // The gate lives HERE, inside the tick, not in a wrapper: whatever arms the
585
+ // tick cannot be trusted to know the machine's state at the moment it fires.
586
+ // Over the threshold means "somebody is using this computer" — skip, exit 0,
587
+ // and let the next tick try. Exit 0 rather than 1 so a skip is not recorded
588
+ // as a failure in the timer's log; the printed line is what makes it visible.
589
+ if (command === 'tick') {
590
+ const maxLoad = args.flags['max-load'] !== undefined ? Number(args.flags['max-load']) : DEFAULT_MAX_LOAD;
591
+ if (!Number.isFinite(maxLoad) || maxLoad < 0) {
592
+ stderr.write('aegiscode autonomous tick: --max-load needs a number >= 0 (0 disables the gate)\n');
593
+ return 2;
594
+ }
595
+ const load = os.loadavg()[0];
596
+ if (maxLoad > 0 && load > maxLoad) {
597
+ emit(
598
+ { ok: true, skipped: 'load', load: Number(load.toFixed(2)), maxLoad },
599
+ `aegiscode: tick skipped — load ${load.toFixed(2)} > ${maxLoad}\n`
600
+ );
601
+ return 0;
602
+ }
603
+ }
604
+
343
605
  // ── the three commands that need a model ─────────────────────────────────
344
606
  const built = buildEngine({ io });
345
607
  if (built.error) {
@@ -420,15 +682,39 @@ async function runQueueCommand(command, argv, io = {}) {
420
682
  }
421
683
  }
422
684
  const commit = args.flags.commit ? true : undefined;
423
- const onSigint = () => {
424
- // Ctrl-C stops the RUNNING turn, not the process: the task is settled back
425
- // to `error` with a reason, so the queue does not keep a `running` item
426
- // whose worker is gone.
685
+ // A DRAIN MUST RELEASE ITS LOCK ON ANY KILL THAT CAN BE CAUGHT. SIGINT was
686
+ // handled alone; SIGTERM and SIGHUP were not, so the ordinary ways a drain is
687
+ // stopped — a timer's timeout, a harness killing the tool call, a closed
688
+ // terminal, `systemctl stop` — skipped the `finally` in worker.proceed(),
689
+ // leaving queue.lock and a `running` item behind. The next tick then failed
690
+ // with "another drain holds the queue lock" and the queue stayed stuck. All
691
+ // three now unwind the same way. (SIGKILL cannot be caught; the heartbeat in
692
+ // queue.js is what reclaims that case.)
693
+ // First signal: cancel the turn and let the drain unwind, so the `finally`
694
+ // that releases the lock actually runs. Second signal: stop waiting and die.
695
+ // Without that escalation the handler would SWALLOW the signal — replacing the
696
+ // default action means `kill` no longer kills, and a drain wedged past its
697
+ // cancel would be unkillable short of SIGKILL.
698
+ let signals = 0;
699
+ const onSignal = (signal) => () => {
700
+ signals += 1;
701
+ if (signals > 1) {
702
+ process.removeListener('SIGINT', onSigint);
703
+ process.removeListener('SIGTERM', onSigterm);
704
+ process.removeListener('SIGHUP', onSighup);
705
+ process.exit(130);
706
+ }
427
707
  const items = queue.loadQueue(process.env);
428
708
  const running = items.find((i) => i.status === 'running' && i.pid === process.pid);
429
709
  if (running) worker.cancel(running.id);
710
+ if (signal !== 'SIGINT') process.exitCode = 130;
430
711
  };
712
+ const onSigint = onSignal('SIGINT');
713
+ const onSigterm = onSignal('SIGTERM');
714
+ const onSighup = onSignal('SIGHUP');
431
715
  process.on('SIGINT', onSigint);
716
+ process.on('SIGTERM', onSigterm);
717
+ process.on('SIGHUP', onSighup);
432
718
 
433
719
  try {
434
720
  if (command === 'reconcile') {
@@ -457,7 +743,7 @@ async function runQueueCommand(command, argv, io = {}) {
457
743
  return 0;
458
744
  }
459
745
 
460
- if (command === 'proceed' || command === 'run') {
746
+ if (command === 'proceed' || command === 'run' || command === 'tick') {
461
747
  const max = command === 'run' ? 1 : intFlag(args.flags, 'max') || 0;
462
748
  const res = await worker.proceed({
463
749
  commit,
@@ -483,12 +769,277 @@ async function runQueueCommand(command, argv, io = {}) {
483
769
  }
484
770
  } finally {
485
771
  process.removeListener('SIGINT', onSigint);
772
+ process.removeListener('SIGTERM', onSigterm);
773
+ process.removeListener('SIGHUP', onSighup);
486
774
  }
487
775
 
488
776
  stdout.write(usageText());
489
777
  return 2;
490
778
  }
491
779
 
780
+ /**
781
+ * The repeating timer that calls `tick` — the half of "set a timer, report back"
782
+ * that did not exist. `/schedule` was a stub pointing at a web page and nothing
783
+ * ever armed a wake-up, so a queued task waited for a human to type `proceed`.
784
+ *
785
+ * Three schedulers, because the plugin ships on three platforms and the house
786
+ * pattern (see desktop/lib/local/system.js) is to dispatch rather than pretend
787
+ * one tool exists everywhere. Each plan is `{kind, paths, install, remove, state}`
788
+ * so the caller never branches on platform itself.
789
+ *
790
+ * The body is `tick --max-load N`, never `proceed`, because the load gate has to
791
+ * be inside the unit the scheduler fires — the scheduler cannot know whether the
792
+ * machine is busy at the moment it fires.
793
+ *
794
+ * `Persistent=true` (systemd) matters more than it looks: without it a tick that
795
+ * came due while the machine was asleep is simply dropped, and a queue that
796
+ * quietly stops draining for a day is indistinguishable from one that works.
797
+ */
798
+ function timerPlan({ every, maxLoad, self, tickArgs, cwd }) {
799
+ const minutes = Math.max(1, Math.floor(every));
800
+ const body = [process.execPath, self, ...tickArgs].map(shellQuote).join(' ');
801
+ const workdir = cwd || process.cwd();
802
+
803
+ if (process.platform === 'linux') {
804
+ const dir = path.join(os.homedir(), '.config', 'systemd', 'user');
805
+ const service = path.join(dir, 'aegiscode-queue.service');
806
+ const timer = path.join(dir, 'aegiscode-queue.timer');
807
+ const serviceBody = [
808
+ '[Unit]',
809
+ 'Description=AEGIS Code — drain the unattended work queue (one gated tick)',
810
+ '',
811
+ '[Service]',
812
+ 'Type=oneshot',
813
+ `WorkingDirectory=${workdir}`,
814
+ `ExecStart=${body}`,
815
+ 'Nice=10',
816
+ // A tick that never returns must not block the next one forever; the
817
+ // worker's own lock and heartbeat reclaim the queue either way.
818
+ 'TimeoutStartSec=6h',
819
+ '',
820
+ ].join('\n');
821
+ const timerBody = [
822
+ '[Unit]',
823
+ 'Description=AEGIS Code — the queue tick timer',
824
+ '',
825
+ '[Timer]',
826
+ `OnActiveSec=1min`,
827
+ `OnUnitActiveSec=${minutes}min`,
828
+ // Catch up a tick missed while the machine was off, instead of skipping it.
829
+ 'Persistent=true',
830
+ 'AccuracySec=30s',
831
+ '',
832
+ '[Install]',
833
+ 'WantedBy=timers.target',
834
+ '',
835
+ ].join('\n');
836
+ return {
837
+ kind: 'systemd-user',
838
+ paths: [service, timer],
839
+ install() {
840
+ fs.mkdirSync(dir, { recursive: true });
841
+ fs.writeFileSync(service, serviceBody);
842
+ fs.writeFileSync(timer, timerBody);
843
+ // `--user` and no sudo: this is the user's own queue, and a timer that
844
+ // needed root would simply never be installed by the people who need it.
845
+ runScheduler(['systemctl', '--user', 'daemon-reload'], { ignore: true });
846
+ const r = runScheduler(['systemctl', '--user', 'enable', '--now', 'aegiscode-queue.timer'], { ignore: true });
847
+ if (r.error || r.status !== 0) {
848
+ // The units ARE on disk at this point, so "install failed" alone would
849
+ // be misleading — and leaving it there silently is the exact failure
850
+ // this change exists to end: a timer that looks installed and never
851
+ // fires. Say what was written, why the scheduler refused, and the one
852
+ // command that finishes the job (or the cron line, for a machine with
853
+ // no user systemd — WSL and most containers).
854
+ const why = r.error ? r.error.message : String(r.stderr || '').trim();
855
+ throw new Error(
856
+ `units were written to ${dir}, but the scheduler refused to load them: ${why}\n` +
857
+ ' finish it yourself: systemctl --user daemon-reload && systemctl --user enable --now aegiscode-queue.timer\n' +
858
+ ` or use cron instead: */${minutes} * * * * ${body}`
859
+ );
860
+ }
861
+ },
862
+ remove() {
863
+ try { runScheduler(['systemctl', '--user', 'disable', '--now', 'aegiscode-queue.timer']); } catch { /* not installed */ }
864
+ for (const p of [timer, service]) { try { fs.unlinkSync(p); } catch { /* absent */ } }
865
+ try { runScheduler(['systemctl', '--user', 'daemon-reload']); } catch { /* no systemd */ }
866
+ },
867
+ state() {
868
+ try {
869
+ const r = spawnSync('systemctl', ['--user', 'is-active', 'aegiscode-queue.timer'], { encoding: 'utf8' });
870
+ const s = String(r.stdout || '').trim();
871
+ return s || null;
872
+ } catch {
873
+ return null;
874
+ }
875
+ },
876
+ // What the INSTALLED unit actually says, not what this invocation asked
877
+ // for. `timer status --every 9` on a timer installed with `--every 5`
878
+ // used to print "every 9 min" — a status command that reports your flags
879
+ // back to you instead of the machine's state, which is the same class of
880
+ // lie as a timer that claims to be installed and never fires.
881
+ read() {
882
+ let installedEvery = null;
883
+ let installedMaxLoad = null;
884
+ try {
885
+ const t = fs.readFileSync(timer, 'utf8');
886
+ const m = /OnUnitActiveSec=(\d+)\s*min/.exec(t);
887
+ if (m) installedEvery = Number(m[1]);
888
+ } catch { /* not written */ }
889
+ try {
890
+ const s = fs.readFileSync(service, 'utf8');
891
+ const m = /--max-load\s+(\S+)/.exec(s);
892
+ if (m) installedMaxLoad = Number(m[1]);
893
+ } catch { /* not written */ }
894
+ return { every: installedEvery, maxLoad: installedMaxLoad };
895
+ },
896
+ };
897
+ }
898
+
899
+ if (process.platform === 'darwin') {
900
+ const dir = path.join(os.homedir(), 'Library', 'LaunchAgents');
901
+ const plist = path.join(dir, 'org.aegiscloud.aegiscode-queue.plist');
902
+ const label = 'org.aegiscloud.aegiscode-queue';
903
+ const plistBody = [
904
+ '<?xml version="1.0" encoding="UTF-8"?>',
905
+ '<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">',
906
+ '<plist version="1.0">',
907
+ '<dict>',
908
+ ' <key>Label</key>',
909
+ ` <string>${label}</string>`,
910
+ ' <key>ProgramArguments</key>',
911
+ ' <array>',
912
+ ` <string>${xmlEscape(process.execPath)}</string>`,
913
+ ` <string>${xmlEscape(self)}</string>`,
914
+ ...tickArgs.map((a) => ` <string>${xmlEscape(a)}</string>`),
915
+ ' </array>',
916
+ ' <key>WorkingDirectory</key>',
917
+ ` <string>${xmlEscape(workdir)}</string>`,
918
+ ' <key>StartInterval</key>',
919
+ ` <integer>${minutes * 60}</integer>`,
920
+ // RunAtLoad replaces systemd's Persistent: launchd never runs a job that
921
+ // came due while the Mac was asleep, so the next login must fire once.
922
+ ' <key>RunAtLoad</key>',
923
+ ' <true/>',
924
+ ' <key>StandardErrorPath</key>',
925
+ ` <string>${xmlEscape(path.join(os.homedir(), '.aegiscode', 'timer.log'))}</string>`,
926
+ '</dict>',
927
+ '</plist>',
928
+ '',
929
+ ].join('\n');
930
+ return {
931
+ kind: 'launchd',
932
+ paths: [plist],
933
+ install() {
934
+ fs.mkdirSync(dir, { recursive: true });
935
+ fs.writeFileSync(plist, plistBody);
936
+ runScheduler(['launchctl', 'unload', plist], { ignore: true });
937
+ runScheduler(['launchctl', 'load', '-w', plist]);
938
+ },
939
+ remove() {
940
+ try { runScheduler(['launchctl', 'unload', '-w', plist]); } catch { /* not loaded */ }
941
+ try { fs.unlinkSync(plist); } catch { /* absent */ }
942
+ },
943
+ state() {
944
+ try {
945
+ const r = spawnSync('launchctl', ['list', label], { encoding: 'utf8' });
946
+ return r.status === 0 ? 'loaded' : 'not loaded';
947
+ } catch {
948
+ return null;
949
+ }
950
+ },
951
+ read() {
952
+ try {
953
+ const p = fs.readFileSync(plist, 'utf8');
954
+ const secs = /<key>StartInterval<\/key>\s*<integer>(\d+)<\/integer>/.exec(p);
955
+ const ml = /<string>--max-load<\/string>\s*<string>([^<]+)<\/string>/.exec(p);
956
+ return {
957
+ every: secs ? Math.round(Number(secs[1]) / 60) : null,
958
+ maxLoad: ml ? Number(ml[1]) : null,
959
+ };
960
+ } catch {
961
+ return { every: null, maxLoad: null };
962
+ }
963
+ },
964
+ };
965
+ }
966
+
967
+ if (process.platform === 'win32') {
968
+ const name = 'AegisCodeQueue';
969
+ return {
970
+ kind: 'schtasks',
971
+ paths: [],
972
+ install() {
973
+ // `/rl limited`: the drain is the user's own work, not a system task.
974
+ runScheduler(['schtasks', '/Create', '/tn', name, '/tr', body, '/sc', 'minute',
975
+ '/mo', String(minutes), '/f', '/rl', 'LIMITED']);
976
+ },
977
+ remove() {
978
+ try { runScheduler(['schtasks', '/Delete', '/tn', name, '/f']); } catch { /* absent */ }
979
+ },
980
+ state() {
981
+ try {
982
+ const r = spawnSync('schtasks', ['/Query', '/tn', name], { encoding: 'utf8' });
983
+ return r.status === 0 ? 'registered' : 'not registered';
984
+ } catch {
985
+ return null;
986
+ }
987
+ },
988
+ // The task XML is the only record of what was actually registered —
989
+ // `/Create /f` overwrites, so the flags on this invocation prove nothing.
990
+ read() {
991
+ try {
992
+ const r = spawnSync('schtasks', ['/Query', '/tn', name, '/XML'], { encoding: 'utf8' });
993
+ const xml = String(r.stdout || '');
994
+ const iv = /<Interval>PT(\d+)M<\/Interval>/i.exec(xml);
995
+ const ml = /--max-load\s+(\d+(?:\.\d+)?)/.exec(xml);
996
+ return { every: iv ? Number(iv[1]) : null, maxLoad: ml ? Number(ml[1]) : null };
997
+ } catch {
998
+ return { every: null, maxLoad: null };
999
+ }
1000
+ },
1001
+ };
1002
+ }
1003
+
1004
+ return {
1005
+ kind: 'unsupported',
1006
+ paths: [],
1007
+ install() {},
1008
+ remove() {},
1009
+ state: () => null,
1010
+ read: () => ({ every: null, maxLoad: null }),
1011
+ };
1012
+ }
1013
+
1014
+ /** Run a scheduler binary; throw with its stderr so an install can say why. */
1015
+ function runScheduler(argv, { ignore = false } = {}) {
1016
+ const [cmd, ...rest] = argv;
1017
+ const r = spawnSync(cmd, rest, { encoding: 'utf8' });
1018
+ if (ignore) return r;
1019
+ if (r.error) throw new Error(`${cmd}: ${r.error.message}`);
1020
+ if (r.status !== 0) {
1021
+ throw new Error(`${cmd} ${rest.join(' ')} exited ${r.status}: ${String(r.stderr || '').trim()}`);
1022
+ }
1023
+ return r;
1024
+ }
1025
+
1026
+
1027
+ /** A command line inside a unit/plist: quote only what needs quoting. */
1028
+ function shellQuote(s) {
1029
+ const v = String(s);
1030
+ if (!/[\s"']/.test(v)) return v;
1031
+ return '"' + v.replace(/"/g, '\\"') + '"';
1032
+ }
1033
+
1034
+ /** XML text escaping for the launchd plist. */
1035
+ function xmlEscape(s) {
1036
+ return String(s)
1037
+ .replace(/&/g, '&amp;')
1038
+ .replace(/</g, '&lt;')
1039
+ .replace(/>/g, '&gt;')
1040
+ .replace(/"/g, '&quot;');
1041
+ }
1042
+
492
1043
  /** The one place this surface is documented, printed by `help` and on misuse. */
493
1044
  function usageText() {
494
1045
  return [
@@ -502,6 +1053,17 @@ function usageText() {
502
1053
  ' list show queued tasks and the tail of the runs log',
503
1054
  ' run drain ONE task, then stop',
504
1055
  ' proceed drain every pending task (--max N, --stop-on-error, --commit)',
1056
+ ' start drain in the BACKGROUND (detached) and return its pid at once',
1057
+ ' use this instead of `proceed` when nothing is waiting for the',
1058
+ ' output — a long drain outlives a harness timeout this way',
1059
+ ' (--max N, --stop-on-error, --commit)',
1060
+ ' tick ONE drain, skipped when the machine is busy — the timer body',
1061
+ ' (--max-load N, default 4.0; 0 disables the gate)',
1062
+ ' timer install|status|remove the repeating timer that calls `tick`',
1063
+ ' (--every MIN default 5, --max-load N default 4.0)',
1064
+ ' report what finished: settled runs from the log (+ queue counts)',
1065
+ ' --since <id> for only what happened after that task,',
1066
+ ' --max N for more of the log',
505
1067
  ' reconcile queue the next unfinished PLAN.md phase (--auto drains it)',
506
1068
  ' retry <id> put a finished task back in the queue',
507
1069
  ' clear drop finished tasks (--all empties the queue)',
@@ -514,4 +1076,6 @@ function usageText() {
514
1076
  ].join('\n') + '\n';
515
1077
  }
516
1078
 
517
- module.exports = { runQueueCommand, parseFlags, taskLine, usageText, SUBCOMMANDS };
1079
+ module.exports = {
1080
+ runQueueCommand, parseFlags, taskLine, usageText, SUBCOMMANDS, timerPlan, DEFAULT_MAX_LOAD,
1081
+ };