aegisone 1.0.34 → 1.0.37

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 (372) hide show
  1. package/LICENSE +661 -0
  2. package/README.md +1 -1
  3. package/SOURCE-OFFER.txt +9 -0
  4. package/bin/aegis.js +1 -322
  5. package/package.json +4 -5
  6. package/scripts/bump.mjs +1 -211
  7. package/scripts/bundle.js +1 -129
  8. package/scripts/predist.mjs +1 -976
  9. package/src/child.js +1 -285
  10. package/src/dispatch.js +1 -269
  11. package/src/doctor.js +1 -639
  12. package/src/host.js +1 -111
  13. package/src/iface/paths.js +3 -0
  14. package/src/iface/pty.js +3 -0
  15. package/src/iface/update.js +3 -0
  16. package/src/iface/window.js +3 -0
  17. package/src/permissions.js +1 -383
  18. package/src/probes.js +1 -159
  19. package/src/protocol.js +3 -0
  20. package/src/release.js +1 -409
  21. package/src/selfhost.js +3 -0
  22. package/vendor/cli/package.json +3 -7
  23. package/vendor/cli/scripts/check.mjs +1 -52
  24. package/vendor/cli/scripts/demo.mjs +1 -94
  25. package/vendor/cli/scripts/predist.mjs +1 -75
  26. package/vendor/cli/scripts/runtests.mjs +1 -56
  27. package/vendor/cli/scripts/seal-gate.mjs +1 -74
  28. package/vendor/cli/src/agents.js +1 -139
  29. package/vendor/cli/src/app.js +1 -2957
  30. package/vendor/cli/src/art.js +1 -289
  31. package/vendor/cli/src/chatflow.js +1 -3023
  32. package/vendor/cli/src/checkpoint.js +1 -90
  33. package/vendor/cli/src/clipboard.js +1 -424
  34. package/vendor/cli/src/cloudsync.js +1 -528
  35. package/vendor/cli/src/commands.js +1 -4089
  36. package/vendor/cli/src/config.js +1 -581
  37. package/vendor/cli/src/connect.js +1 -349
  38. package/vendor/cli/src/credentials.js +1 -33
  39. package/vendor/cli/src/deps.js +1 -232
  40. package/vendor/cli/src/devrun.js +1 -187
  41. package/vendor/cli/src/diff.js +1 -333
  42. package/vendor/cli/src/diffview.js +1 -296
  43. package/vendor/cli/src/engine.js +1 -297
  44. package/vendor/cli/src/entitlement.js +1 -355
  45. package/vendor/cli/src/events.js +1 -707
  46. package/vendor/cli/src/export.js +1 -67
  47. package/vendor/cli/src/filepreview.js +1 -153
  48. package/vendor/cli/src/fingerprint.js +1 -592
  49. package/vendor/cli/src/format.js +1 -259
  50. package/vendor/cli/src/fuzzy.js +1 -119
  51. package/vendor/cli/src/history.js +1 -423
  52. package/vendor/cli/src/init.js +1 -175
  53. package/vendor/cli/src/input.js +1 -139
  54. package/vendor/cli/src/keys.js +1 -183
  55. package/vendor/cli/src/markdown.js +1 -306
  56. package/vendor/cli/src/models.js +1 -507
  57. package/vendor/cli/src/naming.js +1 -57
  58. package/vendor/cli/src/overlays.js +1 -462
  59. package/vendor/cli/src/panels.js +1 -1418
  60. package/vendor/cli/src/ping.js +1 -226
  61. package/vendor/cli/src/presence.js +1 -238
  62. package/vendor/cli/src/render.js +1 -516
  63. package/vendor/cli/src/screen.js +1 -518
  64. package/vendor/cli/src/screens.js +1 -896
  65. package/vendor/cli/src/secret.js +1 -59
  66. package/vendor/cli/src/securefs.js +1 -359
  67. package/vendor/cli/src/settings.js +1 -155
  68. package/vendor/cli/src/shared.js +1 -52
  69. package/vendor/cli/src/sharedpaths.js +1 -53
  70. package/vendor/cli/src/signup.js +1 -156
  71. package/vendor/cli/src/summarize.js +1 -95
  72. package/vendor/cli/src/sysdiag.js +1 -585
  73. package/vendor/cli/src/system.js +1 -40
  74. package/vendor/cli/src/theme.js +1 -570
  75. package/vendor/cli/src/title.js +1 -220
  76. package/vendor/cli/src/todos.js +1 -115
  77. package/vendor/cli/src/tokens.js +1 -263
  78. package/vendor/cli/src/topup.js +1 -210
  79. package/vendor/cli/src/update.js +1 -191
  80. package/vendor/cli/vendor/client/aegis.js +1 -2441
  81. package/vendor/cli/vendor/client/attest.js +1 -518
  82. package/vendor/cli/vendor/client/authorship-key.js +1 -410
  83. package/vendor/cli/vendor/client/auto-provision.js +1 -134
  84. package/vendor/cli/vendor/client/brain-catalog.js +1 -268
  85. package/vendor/cli/vendor/client/byok-catalog.js +1 -199
  86. package/vendor/cli/vendor/client/catalog-client.js +1 -487
  87. package/vendor/cli/vendor/client/conversation-export.js +1 -177
  88. package/vendor/cli/vendor/client/credentials.js +1 -494
  89. package/vendor/cli/vendor/client/device-fingerprint.js +1 -141
  90. package/vendor/cli/vendor/client/drive-connect.js +1 -110
  91. package/vendor/cli/vendor/client/drive-upload.js +1 -234
  92. package/vendor/cli/vendor/client/env-file.js +1 -1273
  93. package/vendor/cli/vendor/client/fingerprint.js +1 -1064
  94. package/vendor/cli/vendor/client/foreign-memory.js +1 -669
  95. package/vendor/cli/vendor/client/google-signin.js +1 -133
  96. package/vendor/cli/vendor/client/hooks.js +1 -430
  97. package/vendor/cli/vendor/client/model-discovery.js +1 -373
  98. package/vendor/cli/vendor/client/naming.js +1 -283
  99. package/vendor/cli/vendor/client/platform.js +1 -937
  100. package/vendor/cli/vendor/client/prefs.js +1 -351
  101. package/vendor/cli/vendor/client/presence-constants.js +1 -107
  102. package/vendor/cli/vendor/client/presence.js +1 -438
  103. package/vendor/cli/vendor/client/record-vault.js +3 -1055
  104. package/vendor/cli/vendor/client/session-store.js +1 -575
  105. package/vendor/cli/vendor/client/topup.js +1 -297
  106. package/vendor/cli/vendor/client/touch.js +1 -458
  107. package/vendor/cli/vendor/client/update.js +1 -763
  108. package/vendor/cli/vendor/client/user-models.js +1 -381
  109. package/vendor/cli/vendor/desktop/lib/local/agents.js +1 -105
  110. package/vendor/cli/vendor/desktop/lib/local/attachments.js +1 -276
  111. package/vendor/cli/vendor/desktop/lib/local/autonomous.js +1 -1045
  112. package/vendor/cli/vendor/desktop/lib/local/claude-pro.js +1 -1028
  113. package/vendor/cli/vendor/desktop/lib/local/context.js +1 -125
  114. package/vendor/cli/vendor/desktop/lib/local/engine.js +1 -3666
  115. package/vendor/cli/vendor/desktop/lib/local/entitlement.js +1 -660
  116. package/vendor/cli/vendor/desktop/lib/local/git-scope.js +1 -228
  117. package/vendor/cli/vendor/desktop/lib/local/integrity.js +1 -1
  118. package/vendor/cli/vendor/desktop/lib/local/local.js +1 -2145
  119. package/vendor/cli/vendor/desktop/lib/local/prompt.js +1 -280
  120. package/vendor/cli/vendor/desktop/lib/local/queue.js +1 -560
  121. package/vendor/cli/vendor/desktop/lib/local/session-rounds.js +1 -238
  122. package/vendor/cli/vendor/desktop/lib/local/spill.js +1 -75
  123. package/vendor/cli/vendor/desktop/lib/local/turn-guard.js +1 -300
  124. package/vendor/cli/vendor/desktop/lib/local/worktree-lock.js +1 -235
  125. package/vendor/cli/vendor/desktop/lib/settings.js +1 -890
  126. package/vendor/cli/vendor/desktop/main.js +67 -1
  127. package/vendor/cli/vendor/desktop/renderer/usage.js +1 -1239
  128. package/vendor/cli/vendor/hosts/install.js +1 -638
  129. package/vendor/cli/vendor/hosts/openai-shim.js +1 -515
  130. package/vendor/cli/vendor/hosts/spec.js +1 -164
  131. package/vendor/cli/vendor/hosts/targets.js +1 -346
  132. package/vendor/cli/vendor/mcp/server.js +1 -221
  133. package/vendor/cli/vendor/mcp/tools.js +1 -408
  134. package/vendor/cli/vendor/one/src/child.js +1 -285
  135. package/vendor/cli/vendor/one/src/permissions.js +1 -383
  136. package/vendor/cli/vendor/one/src/selfhost.js +3 -0
  137. package/vendor/desktop/bin/aegis.js +1 -32
  138. package/vendor/desktop/lib/account-key.js +1 -56
  139. package/vendor/desktop/lib/auto.js +1 -461
  140. package/vendor/desktop/lib/avatar/companion.js +1 -698
  141. package/vendor/desktop/lib/avatar/cosmetics.js +1 -532
  142. package/vendor/desktop/lib/avatar/events.js +1 -344
  143. package/vendor/desktop/lib/avatar/holder-turn.js +1 -350
  144. package/vendor/desktop/lib/avatar/holders.js +1 -612
  145. package/vendor/desktop/lib/avatar/identity.js +1 -641
  146. package/vendor/desktop/lib/avatar/level.js +1 -368
  147. package/vendor/desktop/lib/avatar/mirror.js +1 -524
  148. package/vendor/desktop/lib/avatar/persona.js +1 -388
  149. package/vendor/desktop/lib/avatar/profile.js +1 -977
  150. package/vendor/desktop/lib/avatar/register.js +1 -307
  151. package/vendor/desktop/lib/avatar/store.js +1 -472
  152. package/vendor/desktop/lib/avatar/tiers.js +1 -38
  153. package/vendor/desktop/lib/avatar/transfer.js +1 -415
  154. package/vendor/desktop/lib/avatar/turn.js +1 -216
  155. package/vendor/desktop/lib/avatar/voice.js +1 -328
  156. package/vendor/desktop/lib/avatar/xp.js +1 -404
  157. package/vendor/desktop/lib/deep-link.js +1 -120
  158. package/vendor/desktop/lib/fingerprint.js +2 -347
  159. package/vendor/desktop/lib/google-connect.js +1 -323
  160. package/vendor/desktop/lib/local/agents.js +1 -105
  161. package/vendor/desktop/lib/local/attachments.js +1 -276
  162. package/vendor/desktop/lib/local/autonomous.js +1 -1045
  163. package/vendor/desktop/lib/local/claude-pro.js +1 -1028
  164. package/vendor/desktop/lib/local/context.js +1 -125
  165. package/vendor/desktop/lib/local/engine.js +1 -3666
  166. package/vendor/desktop/lib/local/entitlement.js +1 -660
  167. package/vendor/desktop/lib/local/git-scope.js +1 -228
  168. package/vendor/desktop/lib/local/integrity.js +1 -1
  169. package/vendor/desktop/lib/local/local.js +1 -2145
  170. package/vendor/desktop/lib/local/prompt.js +1 -280
  171. package/vendor/desktop/lib/local/queue.js +1 -560
  172. package/vendor/desktop/lib/local/session-rounds.js +1 -238
  173. package/vendor/desktop/lib/local/spill.js +1 -75
  174. package/vendor/desktop/lib/local/telemetry.js +1 -470
  175. package/vendor/desktop/lib/local/turn-guard.js +1 -300
  176. package/vendor/desktop/lib/local/worktree-lock.js +1 -235
  177. package/vendor/desktop/lib/provider-key-mirror.js +1 -252
  178. package/vendor/desktop/lib/quick-launcher.js +1 -84
  179. package/vendor/desktop/lib/settings.js +1 -890
  180. package/vendor/desktop/lib/sync/memory-queue.js +1 -60
  181. package/vendor/desktop/lib/sync/persist-gate.js +1 -148
  182. package/vendor/desktop/lib/sync/sessions.js +1 -106
  183. package/vendor/desktop/lib/window-state.js +1 -66
  184. package/vendor/desktop/main.js +67 -1
  185. package/vendor/desktop/package.json +3 -5
  186. package/vendor/desktop/preload.js +1 -679
  187. package/vendor/desktop/renderer/app.js +1 -7250
  188. package/vendor/desktop/renderer/avatar/assemble.js +1 -335
  189. package/vendor/desktop/renderer/avatar/avatar.js +1 -380
  190. package/vendor/desktop/renderer/avatar/cards.js +1 -141
  191. package/vendor/desktop/renderer/avatar/hud.js +1 -206
  192. package/vendor/desktop/renderer/avatar/machine.js +1 -213
  193. package/vendor/desktop/renderer/avatar/pane.js +1 -439
  194. package/vendor/desktop/renderer/avatar/parts.js +1 -437
  195. package/vendor/desktop/renderer/budget.js +1 -172
  196. package/vendor/desktop/renderer/companion.js +1 -223
  197. package/vendor/desktop/renderer/diff.js +1 -359
  198. package/vendor/desktop/renderer/diffview.js +1 -336
  199. package/vendor/desktop/renderer/filepreview.js +1 -211
  200. package/vendor/desktop/renderer/fingerprint.js +3 -789
  201. package/vendor/desktop/renderer/markdown.js +1 -168
  202. package/vendor/desktop/renderer/provider-mark.js +1 -311
  203. package/vendor/desktop/renderer/provider-toolbar.js +1 -134
  204. package/vendor/desktop/renderer/providers.js +1 -259
  205. package/vendor/desktop/renderer/quick.js +1 -285
  206. package/vendor/desktop/renderer/stream-policy.js +1 -387
  207. package/vendor/desktop/renderer/transcript-view.js +1 -323
  208. package/vendor/desktop/renderer/usage.js +1 -1239
  209. package/vendor/desktop/vendor/aegis.js +1 -2441
  210. package/vendor/desktop/vendor/attest.js +1 -518
  211. package/vendor/desktop/vendor/authorship-key.js +1 -410
  212. package/vendor/desktop/vendor/auto-provision.js +1 -134
  213. package/vendor/desktop/vendor/brain-catalog.js +1 -268
  214. package/vendor/desktop/vendor/byok-catalog.js +1 -199
  215. package/vendor/desktop/vendor/catalog-client.js +1 -487
  216. package/vendor/desktop/vendor/conversation-export.js +1 -177
  217. package/vendor/desktop/vendor/credentials.js +1 -494
  218. package/vendor/desktop/vendor/device-fingerprint.js +1 -141
  219. package/vendor/desktop/vendor/drive-connect.js +1 -110
  220. package/vendor/desktop/vendor/drive-upload.js +1 -234
  221. package/vendor/desktop/vendor/env-file.js +1 -1273
  222. package/vendor/desktop/vendor/faces/cli/LICENSE +661 -0
  223. package/vendor/desktop/vendor/faces/cli/README.md +784 -0
  224. package/vendor/desktop/vendor/faces/cli/bin/aegiscode.js +20 -0
  225. package/vendor/desktop/vendor/faces/cli/package.json +44 -0
  226. package/vendor/desktop/vendor/faces/cli/scripts/check.mjs +4 -0
  227. package/vendor/desktop/vendor/faces/cli/scripts/demo.mjs +4 -0
  228. package/vendor/desktop/vendor/faces/cli/scripts/predist.mjs +4 -0
  229. package/vendor/desktop/vendor/faces/cli/scripts/runtests.mjs +4 -0
  230. package/vendor/desktop/vendor/faces/cli/scripts/seal-gate.mjs +3 -0
  231. package/vendor/desktop/vendor/faces/cli/src/agents.js +3 -0
  232. package/vendor/desktop/vendor/faces/cli/src/app.js +3 -0
  233. package/vendor/desktop/vendor/faces/cli/src/art.js +3 -0
  234. package/vendor/desktop/vendor/faces/cli/src/autonomous.js +3 -0
  235. package/vendor/desktop/vendor/faces/cli/src/caps.js +3 -0
  236. package/vendor/desktop/vendor/faces/cli/src/chatflow.js +3 -0
  237. package/vendor/desktop/vendor/faces/cli/src/checkpoint.js +3 -0
  238. package/vendor/desktop/vendor/faces/cli/src/clipboard.js +3 -0
  239. package/vendor/desktop/vendor/faces/cli/src/cloudsync.js +3 -0
  240. package/vendor/desktop/vendor/faces/cli/src/commands.js +3 -0
  241. package/vendor/desktop/vendor/faces/cli/src/config.js +3 -0
  242. package/vendor/desktop/vendor/faces/cli/src/connect.js +3 -0
  243. package/vendor/desktop/vendor/faces/cli/src/credentials.js +3 -0
  244. package/vendor/desktop/vendor/faces/cli/src/deps.js +3 -0
  245. package/vendor/desktop/vendor/faces/cli/src/devrun.js +3 -0
  246. package/vendor/desktop/vendor/faces/cli/src/diff.js +3 -0
  247. package/vendor/desktop/vendor/faces/cli/src/diffview.js +3 -0
  248. package/vendor/desktop/vendor/faces/cli/src/engine.js +3 -0
  249. package/vendor/desktop/vendor/faces/cli/src/entitlement.js +3 -0
  250. package/vendor/desktop/vendor/faces/cli/src/events.js +3 -0
  251. package/vendor/desktop/vendor/faces/cli/src/export.js +3 -0
  252. package/vendor/desktop/vendor/faces/cli/src/filepreview.js +3 -0
  253. package/vendor/desktop/vendor/faces/cli/src/fingerprint.js +3 -0
  254. package/vendor/desktop/vendor/faces/cli/src/format.js +3 -0
  255. package/vendor/desktop/vendor/faces/cli/src/fuzzy.js +3 -0
  256. package/vendor/desktop/vendor/faces/cli/src/gate.js +3 -0
  257. package/vendor/desktop/vendor/faces/cli/src/history.js +3 -0
  258. package/vendor/desktop/vendor/faces/cli/src/init.js +3 -0
  259. package/vendor/desktop/vendor/faces/cli/src/input.js +3 -0
  260. package/vendor/desktop/vendor/faces/cli/src/keys.js +3 -0
  261. package/vendor/desktop/vendor/faces/cli/src/limits.js +3 -0
  262. package/vendor/desktop/vendor/faces/cli/src/markdown.js +3 -0
  263. package/vendor/desktop/vendor/faces/cli/src/mcp.js +3 -0
  264. package/vendor/desktop/vendor/faces/cli/src/models.js +3 -0
  265. package/vendor/desktop/vendor/faces/cli/src/naming.js +3 -0
  266. package/vendor/desktop/vendor/faces/cli/src/overlays.js +3 -0
  267. package/vendor/desktop/vendor/faces/cli/src/panels.js +3 -0
  268. package/vendor/desktop/vendor/faces/cli/src/permissions.js +3 -0
  269. package/vendor/desktop/vendor/faces/cli/src/ping.js +3 -0
  270. package/vendor/desktop/vendor/faces/cli/src/presence.js +3 -0
  271. package/vendor/desktop/vendor/faces/cli/src/provenance.js +58 -0
  272. package/vendor/desktop/vendor/faces/cli/src/provenance.lock.json +36 -0
  273. package/vendor/desktop/vendor/faces/cli/src/render.js +3 -0
  274. package/vendor/desktop/vendor/faces/cli/src/screen.js +3 -0
  275. package/vendor/desktop/vendor/faces/cli/src/screens.js +3 -0
  276. package/vendor/desktop/vendor/faces/cli/src/secret.js +3 -0
  277. package/vendor/desktop/vendor/faces/cli/src/securefs.js +3 -0
  278. package/vendor/desktop/vendor/faces/cli/src/settings.js +3 -0
  279. package/vendor/desktop/vendor/faces/cli/src/shared.js +3 -0
  280. package/vendor/desktop/vendor/faces/cli/src/sharedpaths.js +3 -0
  281. package/vendor/desktop/vendor/faces/cli/src/signup.js +3 -0
  282. package/vendor/desktop/vendor/faces/cli/src/summarize.js +3 -0
  283. package/vendor/desktop/vendor/faces/cli/src/sysdiag.js +3 -0
  284. package/vendor/desktop/vendor/faces/cli/src/system.js +3 -0
  285. package/vendor/desktop/vendor/faces/cli/src/theme.js +3 -0
  286. package/vendor/desktop/vendor/faces/cli/src/title.js +3 -0
  287. package/vendor/desktop/vendor/faces/cli/src/todos.js +3 -0
  288. package/vendor/desktop/vendor/faces/cli/src/tokens.js +3 -0
  289. package/vendor/desktop/vendor/faces/cli/src/topup.js +3 -0
  290. package/vendor/desktop/vendor/faces/cli/src/update.js +3 -0
  291. package/vendor/desktop/vendor/faces/cli/vendor/client/aegis.js +4 -0
  292. package/vendor/desktop/vendor/faces/cli/vendor/client/attest.js +3 -0
  293. package/vendor/desktop/vendor/faces/cli/vendor/client/authorship-key.js +3 -0
  294. package/vendor/desktop/vendor/faces/cli/vendor/client/auto-provision.js +3 -0
  295. package/vendor/desktop/vendor/faces/cli/vendor/client/brain-catalog.js +3 -0
  296. package/vendor/desktop/vendor/faces/cli/vendor/client/byok-catalog.js +3 -0
  297. package/vendor/desktop/vendor/faces/cli/vendor/client/catalog-client.js +3 -0
  298. package/vendor/desktop/vendor/faces/cli/vendor/client/conversation-export.js +3 -0
  299. package/vendor/desktop/vendor/faces/cli/vendor/client/credentials.js +3 -0
  300. package/vendor/desktop/vendor/faces/cli/vendor/client/device-fingerprint.js +3 -0
  301. package/vendor/desktop/vendor/faces/cli/vendor/client/drive-connect.js +3 -0
  302. package/vendor/desktop/vendor/faces/cli/vendor/client/drive-upload.js +3 -0
  303. package/vendor/desktop/vendor/faces/cli/vendor/client/env-file.js +3 -0
  304. package/vendor/desktop/vendor/faces/cli/vendor/client/fingerprint.js +3 -0
  305. package/vendor/desktop/vendor/faces/cli/vendor/client/foreign-memory.js +3 -0
  306. package/vendor/desktop/vendor/faces/cli/vendor/client/google-signin.js +3 -0
  307. package/vendor/desktop/vendor/faces/cli/vendor/client/hooks.js +3 -0
  308. package/vendor/desktop/vendor/faces/cli/vendor/client/model-discovery.js +3 -0
  309. package/vendor/desktop/vendor/faces/cli/vendor/client/naming.js +3 -0
  310. package/vendor/desktop/vendor/faces/cli/vendor/client/platform.js +3 -0
  311. package/vendor/desktop/vendor/faces/cli/vendor/client/prefs.js +3 -0
  312. package/vendor/desktop/vendor/faces/cli/vendor/client/presence-constants.js +3 -0
  313. package/vendor/desktop/vendor/faces/cli/vendor/client/presence.js +3 -0
  314. package/vendor/desktop/vendor/faces/cli/vendor/client/record-vault.js +105 -0
  315. package/vendor/desktop/vendor/faces/cli/vendor/client/session-store.js +3 -0
  316. package/vendor/desktop/vendor/faces/cli/vendor/client/topup.js +3 -0
  317. package/vendor/desktop/vendor/faces/cli/vendor/client/touch.js +3 -0
  318. package/vendor/desktop/vendor/faces/cli/vendor/client/update.js +3 -0
  319. package/vendor/desktop/vendor/faces/cli/vendor/client/user-models.js +3 -0
  320. package/vendor/desktop/vendor/faces/cli/vendor/covenant/README.md +21 -0
  321. package/vendor/desktop/vendor/faces/cli/vendor/covenant/aegis.seal +177 -0
  322. package/vendor/desktop/vendor/faces/cli/vendor/desktop/lib/local/aegis-seal.mjs +241 -0
  323. package/vendor/desktop/vendor/faces/cli/vendor/desktop/lib/local/agents.js +3 -0
  324. package/vendor/desktop/vendor/faces/cli/vendor/desktop/lib/local/attachments.js +3 -0
  325. package/vendor/desktop/vendor/faces/cli/vendor/desktop/lib/local/autonomous.js +3 -0
  326. package/vendor/desktop/vendor/faces/cli/vendor/desktop/lib/local/claude-pro.js +3 -0
  327. package/vendor/desktop/vendor/faces/cli/vendor/desktop/lib/local/context.js +3 -0
  328. package/vendor/desktop/vendor/faces/cli/vendor/desktop/lib/local/covenant.js +567 -0
  329. package/vendor/desktop/vendor/faces/cli/vendor/desktop/lib/local/engine.js +3 -0
  330. package/vendor/desktop/vendor/faces/cli/vendor/desktop/lib/local/entitlement.js +3 -0
  331. package/vendor/desktop/vendor/faces/cli/vendor/desktop/lib/local/exec-plan.js +3 -0
  332. package/vendor/desktop/vendor/faces/cli/vendor/desktop/lib/local/git-scope.js +3 -0
  333. package/vendor/desktop/vendor/faces/cli/vendor/desktop/lib/local/integrity.js +3 -0
  334. package/vendor/desktop/vendor/faces/cli/vendor/desktop/lib/local/local.js +3 -0
  335. package/vendor/desktop/vendor/faces/cli/vendor/desktop/lib/local/prompt.js +3 -0
  336. package/vendor/desktop/vendor/faces/cli/vendor/desktop/lib/local/queue.js +3 -0
  337. package/vendor/desktop/vendor/faces/cli/vendor/desktop/lib/local/session-rounds.js +3 -0
  338. package/vendor/desktop/vendor/faces/cli/vendor/desktop/lib/local/shell.js +3 -0
  339. package/vendor/desktop/vendor/faces/cli/vendor/desktop/lib/local/spill.js +3 -0
  340. package/vendor/desktop/vendor/faces/cli/vendor/desktop/lib/local/tools.js +3 -0
  341. package/vendor/desktop/vendor/faces/cli/vendor/desktop/lib/local/turn-guard.js +3 -0
  342. package/vendor/desktop/vendor/faces/cli/vendor/desktop/lib/local/worktree-lock.js +3 -0
  343. package/vendor/desktop/vendor/faces/cli/vendor/desktop/lib/settings.js +3 -0
  344. package/vendor/desktop/vendor/faces/cli/vendor/desktop/main.js +4 -0
  345. package/vendor/desktop/vendor/faces/cli/vendor/desktop/renderer/usage.js +3 -0
  346. package/vendor/desktop/vendor/faces/cli/vendor/hosts/install.js +1 -0
  347. package/vendor/desktop/vendor/faces/cli/vendor/hosts/openai-shim.js +2 -0
  348. package/vendor/desktop/vendor/faces/cli/vendor/hosts/spec.js +1 -0
  349. package/vendor/desktop/vendor/faces/cli/vendor/hosts/targets.js +1 -0
  350. package/vendor/desktop/vendor/faces/cli/vendor/mcp/server.js +4 -0
  351. package/vendor/desktop/vendor/faces/cli/vendor/mcp/tools.js +3 -0
  352. package/vendor/desktop/vendor/faces/cli/vendor/one/src/child.js +3 -0
  353. package/vendor/desktop/vendor/faces/cli/vendor/one/src/permissions.js +3 -0
  354. package/vendor/desktop/vendor/faces/cli/vendor/one/src/selfhost.js +3 -0
  355. package/vendor/desktop/vendor/faces/cli/vendor/tools/agent-gate.mjs +1203 -0
  356. package/vendor/desktop/vendor/fingerprint.js +1 -1064
  357. package/vendor/desktop/vendor/foreign-memory.js +1 -669
  358. package/vendor/desktop/vendor/google-signin.js +1 -133
  359. package/vendor/desktop/vendor/hooks.js +1 -430
  360. package/vendor/desktop/vendor/model-discovery.js +1 -373
  361. package/vendor/desktop/vendor/naming.js +1 -283
  362. package/vendor/desktop/vendor/platform.js +1 -937
  363. package/vendor/desktop/vendor/prefs.js +1 -351
  364. package/vendor/desktop/vendor/presence-constants.js +1 -107
  365. package/vendor/desktop/vendor/presence.js +1 -438
  366. package/vendor/desktop/vendor/record-vault.js +3 -1055
  367. package/vendor/desktop/vendor/selfhost.js +3 -0
  368. package/vendor/desktop/vendor/session-store.js +1 -575
  369. package/vendor/desktop/vendor/topup.js +1 -297
  370. package/vendor/desktop/vendor/touch.js +1 -458
  371. package/vendor/desktop/vendor/update.js +1 -763
  372. package/vendor/desktop/vendor/user-models.js +1 -381
@@ -1,228 +1,3 @@
1
1
  // SPDX-License-Identifier: AGPL-3.0-or-later
2
2
  // Copyright (C) 2026 Niklas Borneklint — AEGIS Code (aegiscode) / Aegiscloud.
3
- // AEGIS Code (aegiscode) — source: https://github.com/aegisinfo/aegiscode-plugin
4
- // Conveying a modified copy, or running one as a network service, owes the
5
- // corresponding source under this licence (§5/§13) — see LICENSING.md.
6
- 'use strict';
7
-
8
- /**
9
- * /ping — the terminal's "reply ready" alert.
10
- *
11
- * WHAT IT IS, AND WHY HERE. aegis-desktop already tells the user a turn landed
12
- * when they are looking somewhere else: `notifyReplyIfUnfocused()` in
13
- * desktop/main.js raises a native Notification from the one place every chat
14
- * call resolves, and only when the window is minimized, hidden or unfocused — a
15
- * foregrounded chat needs no OS-level nudge. The terminal has no `isFocused()`,
16
- * so the two things that function reads have to be re-derived:
17
- *
18
- * * "the window is not in front" — approximate it with TIME. A turn that took
19
- * less than `pingMinSeconds` ran while the user was still watching the
20
- * spinner; one that took longer is a turn they plausibly walked away from.
21
- * That is the only honest proxy a TUI has, and it is why the threshold
22
- * exists at all rather than pinging on every reply.
23
- * * "the window can show a notification" — check `process.stdout.isTTY`
24
- * instead of `Notification.isSupported()`. A `-p` headless run, a piped
25
- * transcript or an autonomous queue worker has no user to notify, and
26
- * writing escape sequences into a file is not a notice.
27
- *
28
- * WHAT IT SENDS. Terminal notification escapes, the only channel a CLI has:
29
- * OSC 9 (iTerm2, WezTerm, Windows Terminal, conhost) and OSC 777
30
- * (`notify;title;body` — VTE/GNOME Terminal, kitty, urxvt), each BEL-terminated,
31
- * plus optionally the plain BEL bell for terminals that implement neither
32
- * (macOS Terminal.app) — what the user hears is then whatever their terminal's
33
- * bell setting says. Modes are one word on purpose: `off`, `bell`, `notify`,
34
- * `both`.
35
- *
36
- * Ported verbatim in behaviour from the upstream engine's `src/ping.js`, ESM →
37
- * CommonJS, dependency-free: no TTY, no config file, no app.js import, so the
38
- * decision and the byte sequence are both unit-testable. It keeps all four of
39
- * the properties that module is built around:
40
- *
41
- * 1. It cannot break the host. `writePing()` returns a boolean and never
42
- * throws, whatever the stream does (a closed stdout, an EPIPE, a stub with
43
- * no `write`). A notice that can take down a session is worse than none.
44
- * 2. It cannot corrupt the terminal. Both payloads are free text written
45
- * INSIDE an escape sequence: a BEL in the text would end the OSC early, an
46
- * ESC would start a new escape, a newline would break a WM's rendering.
47
- * `sanitizePingText()` strips every control byte before anything is
48
- * written — the same reasoning as `flattenTitle` at the OSC 0 edge in
49
- * this host's `title.js`.
50
- * 3. It cannot lie about what happened. The notice row is only pushed when a
51
- * sequence was actually written; `off` writes nothing and says nothing
52
- * rather than reporting a ping it did not send.
53
- * 4. It cannot nag. An aborted turn never pings — the user pressed Escape, so
54
- * they are demonstrably looking at the screen.
55
- */
56
-
57
- /** The one-word modes, in the order `/ping` lists them. */
58
- const PING_MODES = Object.freeze(['off', 'bell', 'notify', 'both']);
59
-
60
- /** Default mode. On, like the desktop's own notification — it is the whole
61
- * point of the feature, and the threshold below is what keeps it quiet. */
62
- const DEFAULT_PING_MODE = 'both';
63
-
64
- /** The desktop's rule is "unfocused", not "slow". 30s is where a terminal turn
65
- * stops reading as one the user is still watching, and it is the floor under
66
- * the noise: a two-second reply never pings. */
67
- const DEFAULT_PING_SECONDS = 30;
68
-
69
- /** One hour. Past this the duration is a story, not a threshold. */
70
- const MAX_PING_SECONDS = 3600;
71
-
72
- /** The title every notification carries, matching desktop/main.js's own. */
73
- const PING_TITLE = 'AEGIS Code';
74
-
75
- /** Longest payload the sanitizer will pass through. A title is a short line; a
76
- * notification daemon truncates anyway, so a cap here only bounds what this
77
- * module can be made to write. */
78
- const PING_TEXT_MAX = 120;
79
-
80
- const BEL = '\u0007';
81
- const ESC = '\u001b';
82
- const BODY = 'Reply ready';
83
-
84
- /**
85
- * One of PING_MODES, or the default. An unknown string is NOT an error here —
86
- * the config file is user-editable and a typo must not disable the feature
87
- * silently, so it reads as "unset" and takes the default. `/ping` refuses the
88
- * same strings out loud, which is where a typo is actually seen.
89
- */
90
- function normalizePingMode(value) {
91
- const v = String(value == null ? '' : value).trim().toLowerCase();
92
- return PING_MODES.includes(v) ? v : DEFAULT_PING_MODE;
93
- }
94
-
95
- /**
96
- * Seconds, clamped to [0, MAX_PING_SECONDS]. 0 is legal and means "ping every
97
- * turn, however short". Anything unparseable falls back to the default rather
98
- * than to 0, so a corrupt config cannot turn the notice into a per-turn nag.
99
- */
100
- function normalizePingSeconds(value) {
101
- // `Number('')` is 0 and `Number(' ')` is 0, so an ABSENT value would read as
102
- // "ping every turn" — the loudest setting from the weakest input. Unset is
103
- // separated from zero before anything is parsed.
104
- const raw = typeof value === 'number' ? value : String(value == null ? '' : value).trim();
105
- if (raw === '') return DEFAULT_PING_SECONDS;
106
- const n = typeof raw === 'number' ? raw : Number(raw);
107
- if (!Number.isFinite(n) || n < 0) return DEFAULT_PING_SECONDS;
108
- return Math.min(MAX_PING_SECONDS, Math.floor(n));
109
- }
110
-
111
- /** Strip every byte that could end or re-open the escape sequence, collapse to
112
- * one printable line, cap the length. */
113
- function sanitizePingText(text, max = PING_TEXT_MAX) {
114
- const flat = String(text == null ? '' : text)
115
- .replace(/[\u0000-\u001f\u007f]/g, ' ')
116
- .replace(/\s+/g, ' ')
117
- .trim();
118
- const limit = Number.isFinite(max) && max > 0 ? Math.floor(max) : PING_TEXT_MAX;
119
- return flat.length > limit ? `${flat.slice(0, Math.max(0, limit - 1))}…` : flat;
120
- }
121
-
122
- /**
123
- * The decision, in one place so it can be tested without a TTY:
124
- *
125
- * off → never. "Off is off" is the rule /yolo and /confirm follow.
126
- * aborted → never. Escape means the user was looking at the screen.
127
- * !isTTY → never. Headless/piped: there is no one to ping.
128
- * short turn → never, until the threshold.
129
- */
130
- function shouldPing({ mode, elapsedMs, minSeconds, isTTY, aborted } = {}) {
131
- if (normalizePingMode(mode) === 'off') return false;
132
- if (aborted) return false;
133
- if (!isTTY) return false;
134
- // `Number(null)` is 0 and 0 is a legal duration, so an ABSENT elapsed time
135
- // would read as "this turn just finished" and ping on a caller's bug. Only a
136
- // real number (or a non-empty numeric string) counts.
137
- const raw = typeof elapsedMs === 'number' ? elapsedMs : String(elapsedMs == null ? '' : elapsedMs).trim();
138
- if (raw === '') return false;
139
- const elapsed = Number(raw);
140
- if (!Number.isFinite(elapsed) || elapsed < 0) return false;
141
- return elapsed >= normalizePingSeconds(minSeconds) * 1000;
142
- }
143
-
144
- /**
145
- * The bytes to write. Empty string when the mode is off, so a caller cannot
146
- * accidentally send something "off" did not mean. Both payloads are sanitized
147
- * into locals first, so no branch can write an unsanitized string.
148
- */
149
- function buildPing({ mode = DEFAULT_PING_MODE, title = PING_TITLE, body = BODY } = {}) {
150
- const m = normalizePingMode(mode);
151
- if (m === 'off') return '';
152
- const t = sanitizePingText(title);
153
- const b = sanitizePingText(body);
154
- const parts = [];
155
- if (m === 'notify' || m === 'both') {
156
- // OSC 9: "notification with this body" — no title field, so it carries the
157
- // body only. OSC 777: the form that DOES take a title, and the one VTE and
158
- // kitty implement. Both are BEL-terminated; both are ignored harmlessly by
159
- // a terminal that knows neither.
160
- parts.push(`${ESC}]9;${b}${BEL}`);
161
- parts.push(`${ESC}]777;notify;${t};${b}${BEL}`);
162
- }
163
- if (m === 'bell' || m === 'both') parts.push(BEL);
164
- return parts.join('');
165
- }
166
-
167
- /**
168
- * Write it, or do not — never throws. Returns whether anything was written, and
169
- * the caller pushes its notice row only on `true` (property 3 above).
170
- */
171
- function writePing(stream, text) {
172
- if (!text) return false;
173
- if (!stream || typeof stream.write !== 'function') return false;
174
- try {
175
- stream.write(text);
176
- return true;
177
- } catch {
178
- return false;
179
- }
180
- }
181
-
182
- /** "45s" / "3m12s" / "1h02m" — the compact shape the turn's own timing row
183
- * uses. Seconds in, one short string out. */
184
- function formatPingDuration(seconds) {
185
- const s = Math.max(0, Math.floor(Number(seconds) || 0));
186
- if (s < 60) return `${s}s`;
187
- const m = Math.floor(s / 60);
188
- if (m < 60) return `${m}m${String(s % 60).padStart(2, '0')}s`;
189
- return `${Math.floor(m / 60)}h${String(m % 60).padStart(2, '0')}m`;
190
- }
191
-
192
- /** The transcript row: the duration, which channel fired, and the one switch a
193
- * user needs at that moment. */
194
- function pingNoticeText({ seconds, mode } = {}) {
195
- const m = normalizePingMode(mode);
196
- const how = m === 'bell' ? 'bell rung' : m === 'notify' ? 'notification sent' : 'bell rung, notification sent';
197
- return `[ping] reply ready after ${formatPingDuration(seconds)} — ${how}; /ping off silences this`;
198
- }
199
-
200
- /**
201
- * The whole act, in one call the session loop can make: decide, write, and
202
- * describe. Returns the notice text to push, or null when nothing was sent
203
- * (off, aborted, not a TTY, under the threshold, or a stream that refused).
204
- */
205
- function pingTurn({ stream, mode, minSeconds, elapsedMs, isTTY, aborted } = {}) {
206
- if (!shouldPing({ mode, minSeconds, elapsedMs, isTTY, aborted })) return null;
207
- const text = buildPing({ mode });
208
- if (!writePing(stream, text)) return null;
209
- return pingNoticeText({ seconds: Number(elapsedMs) / 1000, mode });
210
- }
211
-
212
- module.exports = {
213
- PING_MODES,
214
- DEFAULT_PING_MODE,
215
- DEFAULT_PING_SECONDS,
216
- MAX_PING_SECONDS,
217
- PING_TITLE,
218
- PING_TEXT_MAX,
219
- normalizePingMode,
220
- normalizePingSeconds,
221
- sanitizePingText,
222
- shouldPing,
223
- buildPing,
224
- writePing,
225
- formatPingDuration,
226
- pingNoticeText,
227
- pingTurn,
228
- };
3
+ "use strict";const PING_MODES=Object.freeze(["off","bell","notify","both"]),DEFAULT_PING_MODE="both",DEFAULT_PING_SECONDS=30,MAX_PING_SECONDS=3600,PING_TITLE="AEGIS Code",PING_TEXT_MAX=120,BEL="",ESC="",BODY="Reply ready";function normalizePingMode(n){const i=String(null==n?"":n).trim().toLowerCase();return PING_MODES.includes(i)?i:DEFAULT_PING_MODE}function normalizePingSeconds(n){const i="number"==typeof n?n:String(null==n?"":n).trim();if(""===i)return DEFAULT_PING_SECONDS;const e="number"==typeof i?i:Number(i);return!Number.isFinite(e)||e<0?DEFAULT_PING_SECONDS:Math.min(MAX_PING_SECONDS,Math.floor(e))}function sanitizePingText(n,i=PING_TEXT_MAX){const e=String(null==n?"":n).replace(/[\u0000-\u001f\u007f]/g," ").replace(/\s+/g," ").trim(),t=Number.isFinite(i)&&i>0?Math.floor(i):PING_TEXT_MAX;return e.length>t?`${e.slice(0,Math.max(0,t-1))}…`:e}function shouldPing({mode:n,elapsedMs:i,minSeconds:e,isTTY:t,aborted:o}={}){if("off"===normalizePingMode(n))return!1;if(o)return!1;if(!t)return!1;const r="number"==typeof i?i:String(null==i?"":i).trim();if(""===r)return!1;const u=Number(r);return!(!Number.isFinite(u)||u<0)&&u>=1e3*normalizePingSeconds(e)}function buildPing({mode:n=DEFAULT_PING_MODE,title:i=PING_TITLE,body:e=BODY}={}){const t=normalizePingMode(n);if("off"===t)return"";const o=sanitizePingText(i),r=sanitizePingText(e),u=[];return"notify"!==t&&"both"!==t||(u.push(`${ESC}]9;${r}${BEL}`),u.push(`${ESC}]777;notify;${o};${r}${BEL}`)),"bell"!==t&&"both"!==t||u.push(BEL),u.join("")}function writePing(n,i){if(!i)return!1;if(!n||"function"!=typeof n.write)return!1;try{return n.write(i),!0}catch{return!1}}function formatPingDuration(n){const i=Math.max(0,Math.floor(Number(n)||0));if(i<60)return`${i}s`;const e=Math.floor(i/60);return e<60?`${e}m${String(i%60).padStart(2,"0")}s`:`${Math.floor(e/60)}h${String(e%60).padStart(2,"0")}m`}function pingNoticeText({seconds:n,mode:i}={}){const e=normalizePingMode(i),t="bell"===e?"bell rung":"notify"===e?"notification sent":"bell rung, notification sent";return`[ping] reply ready after ${formatPingDuration(n)} — ${t}; /ping off silences this`}function pingTurn({stream:n,mode:i,minSeconds:e,elapsedMs:t,isTTY:o,aborted:r}={}){return shouldPing({mode:i,minSeconds:e,elapsedMs:t,isTTY:o,aborted:r})&&writePing(n,buildPing({mode:i}))?pingNoticeText({seconds:Number(t)/1e3,mode:i}):null}module.exports={PING_MODES:PING_MODES,DEFAULT_PING_MODE:DEFAULT_PING_MODE,DEFAULT_PING_SECONDS:DEFAULT_PING_SECONDS,MAX_PING_SECONDS:MAX_PING_SECONDS,PING_TITLE:PING_TITLE,PING_TEXT_MAX:PING_TEXT_MAX,normalizePingMode:normalizePingMode,normalizePingSeconds:normalizePingSeconds,sanitizePingText:sanitizePingText,shouldPing:shouldPing,buildPing:buildPing,writePing:writePing,formatPingDuration:formatPingDuration,pingNoticeText:pingNoticeText,pingTurn:pingTurn};
@@ -1,240 +1,3 @@
1
1
  // SPDX-License-Identifier: AGPL-3.0-or-later
2
2
  // Copyright (C) 2026 Niklas Borneklint — AEGIS Code (aegiscode) / Aegiscloud.
3
- // AEGIS Code (aegiscode) — source: https://github.com/aegisinfo/aegiscode-plugin
4
- // Conveying a modified copy, or running one as a network service, owes the
5
- // corresponding source under this licence (§5/§13) — see LICENSING.md.
6
- 'use strict';
7
-
8
- /**
9
- * The CLI's presence beacon — the `aegiscode` half of `client/presence.js`.
10
- *
11
- * `client/presence.js` owns the protocol (the route, the cadence the server
12
- * asks for, the backoff ladder, the body allowlist). This file owns the three
13
- * things only the CLI can know:
14
- *
15
- * - WHICH key. The credential store resolution (env → credentials.json →
16
- * config.json) is the CLI's, not the shared transport's, and it is the same
17
- * resolution every other CLI call uses. A host with no key does not beacon:
18
- * `presence.js` returns an inert store rather than 401-looping, and this
19
- * module simply reports that it is off.
20
- * - WHICH build. `cli/package.json` at require time, so the panel shows the
21
- * version the user actually installed rather than a constant that drifts
22
- * from the release.
23
- * - HOW BUSY. `autonomous: true` while `aegiscode autonomous` is draining a
24
- * queue, and the pending depth at send time, so the panel can tell "an idle
25
- * terminal is open" from "this machine is working through a queue".
26
- *
27
- * A module-level singleton, because a beacon is a process-wide fact and the
28
- * lifecycle hooks that start and stop it are in `bin/aegiscode.js` — argument
29
- * parsing and process lifecycle, which is not testable — while everything
30
- * below is driven directly by `test/cli-presence.test.mjs`.
31
- *
32
- * Kill switch: `AEGIS_NO_PRESENCE=1` (or `0`/`false` for the settings-file
33
- * equivalent is NOT read here — this host has no settings store). An operator
34
- * debugging a network stack, or a CI runner that must make no outbound calls,
35
- * gets to turn the beacon off without a code change.
36
- */
37
-
38
- const path = require('node:path');
39
- const { resolveShared } = require('./sharedpaths.js');
40
-
41
- /** `AEGIS_NO_PRESENCE` truthy ⇒ never beacon from this host. Anything else
42
- * (unset, '', '0', 'false', 'no') leaves the beacon on: the default has to be
43
- * "beacon", because a presence panel that is off unless someone remembers to
44
- * switch it on is a panel with no rows in it. */
45
- const KILL_ENV = 'AEGIS_NO_PRESENCE';
46
-
47
- function presenceDisabled(env) {
48
- try {
49
- const raw = env && env[KILL_ENV];
50
- if (raw == null || String(raw).trim() === '') return false;
51
- return /^(1|true|on|yes)$/i.test(String(raw).trim());
52
- } catch {
53
- return false;
54
- }
55
- }
56
-
57
- /** Lazily required so `--help`, `--version` and `key status` stay instant and
58
- * dependency-free: a beacon is for a *session*, not for a subcommand. */
59
- function loadShared() {
60
- const presence = require(resolveShared(path.join('client', 'presence.js')));
61
- const fingerprint = require(resolveShared(path.join('client', 'device-fingerprint.js')));
62
- return { presence, fingerprint };
63
- }
64
-
65
- /** The CLI's own build string. A missing/unreadable package.json is not a
66
- * reason to skip the beacon: the fields are individually optional server-side. */
67
- function cliVersion() {
68
- try {
69
- return require(path.join(__dirname, '..', 'package.json')).version || null;
70
- } catch {
71
- return null;
72
- }
73
- }
74
-
75
- let current = null;
76
-
77
- /**
78
- * Start (or restart) the CLI beacon. Idempotent by replacement: calling it
79
- * twice stops the first store, so the timer count cannot grow with the number
80
- * of calls. Never throws — a beacon that cannot start is a beacon that is off,
81
- * and the session proceeds.
82
- *
83
- * @param {object} [opts]
84
- * @param {object} [opts.client] an already-built aegis client (its apiKey wins)
85
- * @param {object} [opts.credentials] the credential store to resolve a key from
86
- * @param {boolean} [opts.autonomous] this process is draining a queue
87
- * @param {number|function} [opts.queueDepth] pending tasks, or a reader for them
88
- * @param {object} [opts.env] override process.env (tests)
89
- * @param {object} [opts.io] { stdout, stderr } — never used today, kept
90
- * so a future `--verbose` can narrate a beat
91
- * @returns {{enabled: boolean, reason: string|null, stop: () => void, state: () => object}}
92
- */
93
- function start(opts = {}) {
94
- stop();
95
- const env = opts.env || process.env;
96
- if (presenceDisabled(env)) {
97
- return (current = inert('kill-switch'));
98
- }
99
-
100
- let apiKey = '';
101
- try {
102
- if (opts.client && typeof opts.client.apiKey === 'string') apiKey = opts.client.apiKey;
103
- if (!apiKey && opts.credentials && typeof opts.credentials.resolveApiKey === 'function') {
104
- const resolved = opts.credentials.resolveApiKey({ env });
105
- apiKey = (resolved && (resolved.key || resolved.apiKey)) || '';
106
- }
107
- } catch {
108
- apiKey = '';
109
- }
110
- if (!apiKey) return (current = inert('no-api-key'));
111
-
112
- try {
113
- const { presence, fingerprint } = loadShared();
114
- const store = presence.createPresence({
115
- apiKey,
116
- // 'cli', not 'aegiscode': aegis1 keeps only the names in its own
117
- // PRESENCE_APPS tuple (app.py) and stores anything else as 'other', so a
118
- // product name here would make every terminal session unidentifiable in
119
- // the admin panel while still answering 200. See
120
- // client/presence-constants.js — a test parses the server's tuple and
121
- // fails if the two lists drift.
122
- app: 'cli',
123
- version: cliVersion(),
124
- platform: process.platform,
125
- // The SAME identity the device-registration path uses — see the header of
126
- // client/presence.js for why the beacon must carry the machine, not a
127
- // per-run random token. Computed here rather than inside presence.js so a
128
- // fingerprint failure is visible at the call site.
129
- install: fingerprint.machineFingerprint(),
130
- queueDepth: opts.queueDepth,
131
- autonomous: Boolean(opts.autonomous),
132
- log: opts.log,
133
- fetchImpl: opts.fetchImpl,
134
- now: opts.now,
135
- setTimer: opts.setTimer,
136
- clearTimer: opts.clearTimer,
137
- });
138
- store.start();
139
- return (current = store);
140
- } catch (err) {
141
- // A require failure here is a packaging bug, not a user-facing one: stay
142
- // quiet, keep the session working, and leave `state().reason` for a test.
143
- return (current = inert(`load-failed:${String((err && err.message) || err).slice(0, 80)}`));
144
- }
145
- }
146
-
147
- function inert(reason) {
148
- return {
149
- enabled: false,
150
- reason,
151
- install: null,
152
- stop: () => true,
153
- state: () => ({ enabled: false, reason, beats: 0, failures: 0, running: false }),
154
- };
155
- }
156
-
157
- /** Stop the beacon. Idempotent; safe when `start()` never ran. */
158
- function stop() {
159
- if (!current) return false;
160
- try {
161
- current.stop();
162
- } catch {
163
- /* an already-dead beacon is not an error */
164
- }
165
- current = null;
166
- return true;
167
- }
168
-
169
- /** The active store (or null). For tests and for a host that wants to read
170
- * `state()` — `{beats, failures, lastSeenAt, intervalMs}` — after a beat. */
171
- function active() {
172
- return current;
173
- }
174
-
175
- /**
176
- * How many tasks are waiting, read at SEND time.
177
- *
178
- * Resolved through the shared-path resolver (`sharedpaths.js`) rather than by
179
- * re-implementing a queue counter, so there is exactly one queue file and one
180
- * definition of "pending" in this repo — the same `desktop/lib/local/queue.js`
181
- * the desktop drains. A missing module, an unreadable file or a malformed line
182
- * is 0: the beacon reports presence, not bookkeeping, and a broken queue must
183
- * not silence the beacon that would have shown the machine was alive.
184
- */
185
- function queueDepthReader() {
186
- let queue = null;
187
- try {
188
- queue = require(resolveShared(path.join('desktop', 'lib', 'local', 'queue.js')));
189
- } catch {
190
- queue = null;
191
- }
192
- return () => {
193
- try {
194
- if (!queue || typeof queue.readQueue !== 'function' || typeof queue.queuePath !== 'function') return 0;
195
- const items = queue.readQueue(queue.queuePath());
196
- return (Array.isArray(items) ? items : []).filter((t) => t && t.status === 'pending').length;
197
- } catch {
198
- return 0;
199
- }
200
- };
201
- }
202
-
203
- /**
204
- * Let an in-flight beat finish before the process exits.
205
- *
206
- * This is not optional politeness — it is the difference between a beat and no
207
- * beat. `bin/aegiscode.js` ends with `process.exit()`, and a one-shot run
208
- * (`aegiscode -p "…"`, `aegiscode autonomous run`) reaches it in tens of
209
- * milliseconds, so the first beat posted at startup would be killed mid-flight
210
- * and the machine would never appear in the panel. Bounded, because a beacon
211
- * must never be the reason a CLI hangs: if the request has not answered within
212
- * `timeoutMs`, the process exits and that beat is simply lost.
213
- *
214
- * @param {number} [timeoutMs] default 1500 — the beacon's own request timeout
215
- * is 20 s, far too long to hold an exit open.
216
- * @returns {Promise<'drained'|'none'|'timeout'>}
217
- */
218
- function flush(timeoutMs = 1500) {
219
- try {
220
- if (!current || typeof current.pending !== 'function') return Promise.resolve('none');
221
- const inflight = current.pending();
222
- if (!inflight) return Promise.resolve('none');
223
- const limit = Number.isFinite(Number(timeoutMs)) && Number(timeoutMs) > 0 ? Number(timeoutMs) : 1500;
224
- return Promise.race([
225
- Promise.resolve(inflight).then(() => 'drained', () => 'drained'),
226
- new Promise((resolve) => {
227
- // Deliberately NOT unref'd, unlike every other timer in this module: the
228
- // caller is already in its exit path and has asked for a bounded wait, so
229
- // this timer is the thing that must be allowed to keep the loop alive
230
- // long enough to fire. An unref'd timer here would leave the process with
231
- // an empty event loop and a `flush()` promise that never settles.
232
- setTimeout(() => resolve('timeout'), limit);
233
- }),
234
- ]);
235
- } catch {
236
- return Promise.resolve('none');
237
- }
238
- }
239
-
240
- module.exports = { start, stop, active, flush, presenceDisabled, queueDepthReader, cliVersion, KILL_ENV };
3
+ "use strict";const path=require("node:path"),{resolveShared:resolveShared}=require("./sharedpaths.js"),KILL_ENV="AEGIS_NO_PRESENCE";function presenceDisabled(e){try{const r=e&&e[KILL_ENV];return null!=r&&""!==String(r).trim()&&/^(1|true|on|yes)$/i.test(String(r).trim())}catch{return!1}}function loadShared(){return{presence:require(resolveShared(path.join("client","presence.js"))),fingerprint:require(resolveShared(path.join("client","device-fingerprint.js")))}}function cliVersion(){try{return require(path.join(__dirname,"..","package.json")).version||null}catch{return null}}let current=null;function start(e={}){stop();const r=e.env||process.env;if(presenceDisabled(r))return current=inert("kill-switch");let t="";try{if(e.client&&"string"==typeof e.client.apiKey&&(t=e.client.apiKey),!t&&e.credentials&&"function"==typeof e.credentials.resolveApiKey){const n=e.credentials.resolveApiKey({env:r});t=n&&(n.key||n.apiKey)||""}}catch{t=""}if(!t)return current=inert("no-api-key");try{const{presence:r,fingerprint:n}=loadShared(),i=r.createPresence({apiKey:t,app:"cli",version:cliVersion(),platform:process.platform,install:n.machineFingerprint(),queueDepth:e.queueDepth,autonomous:Boolean(e.autonomous),log:e.log,fetchImpl:e.fetchImpl,now:e.now,setTimer:e.setTimer,clearTimer:e.clearTimer});return i.start(),current=i}catch(e){return current=inert(`load-failed:${String(e&&e.message||e).slice(0,80)}`)}}function inert(e){return{enabled:!1,reason:e,install:null,stop:()=>!0,state:()=>({enabled:!1,reason:e,beats:0,failures:0,running:!1})}}function stop(){if(!current)return!1;try{current.stop()}catch{}return current=null,!0}function active(){return current}function queueDepthReader(){let e=null;try{e=require(resolveShared(path.join("desktop","lib","local","queue.js")))}catch{e=null}return()=>{try{if(!e||"function"!=typeof e.readQueue||"function"!=typeof e.queuePath)return 0;const r=e.readQueue(e.queuePath());return(Array.isArray(r)?r:[]).filter((e=>e&&"pending"===e.status)).length}catch{return 0}}}function flush(e=1500){try{if(!current||"function"!=typeof current.pending)return Promise.resolve("none");const r=current.pending();if(!r)return Promise.resolve("none");const t=Number.isFinite(Number(e))&&Number(e)>0?Number(e):1500;return Promise.race([Promise.resolve(r).then((()=>"drained"),(()=>"drained")),new Promise((e=>{setTimeout((()=>e("timeout")),t)}))])}catch{return Promise.resolve("none")}}module.exports={start:start,stop:stop,active:active,flush:flush,presenceDisabled:presenceDisabled,queueDepthReader:queueDepthReader,cliVersion:cliVersion,KILL_ENV:KILL_ENV};