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
package/src/doctor.js CHANGED
@@ -1,641 +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
- * doctor.js — ONE report about this AEGISONE install (AEGISONE decision D7).
10
- *
11
- * aegis doctor → the report, for a human
12
- * aegis doctor --json → the same object, printed as JSON
13
- *
14
- * The exit code is the contract scripts branch on, so it is real:
15
- *
16
- * 0 healthy everything this file can check agrees with itself
17
- * 1 warn usable, but something is out of date: a vendor tree that was
18
- * never staged (or is entirely absent), a newer version
19
- * published, no credential configured yet
20
- * 2 broken the install cannot be trusted: a face version that does not
21
- * match the product version, an unreadable shared store, a
22
- * staged file that differs from its source, `--gui` asked for
23
- * with no Electron to serve it
24
- *
25
- * ## Every input is a seam
26
- *
27
- * The report reads a lot of the machine — versions, the credential store, the
28
- * environment file, a staged tree, the registry. None of it is read at module
29
- * scope, and none of it is read from inside the decision: `report()` takes
30
- * `{ platform, env, exists, readFile, hashFile, registry, electronPaths }` (plus
31
- * the path and pair overrides below) and every one of them defaults to a real
32
- * implementation built lazily *inside* the function that needs it. That is the
33
- * standing ON rule — nothing in `one/` touches `process.*` at module scope —
34
- * and it is what lets the ON5 test reach all three exit codes without a network,
35
- * without a display, and without a real install to break.
36
- *
37
- * ## One check, not a second one
38
- *
39
- * The "is there a newer version" answer comes from `client/update.js`, the
40
- * module that already owns the registry probe, the 2.5s timeout and the
41
- * once-a-day cache (`CHECK_INTERVAL_MS`). Doctor passes the injected probe
42
- * through to it and reports what it returns — it does not fetch anything
43
- * itself, and it does not add a second cache. The same call is the one the
44
- * desktop's applier consumes (see `client/update.js::checkPublished` and
45
- * `desktop/main.js::fetchDetailed`), which is D7's "one update path".
46
- */
47
-
48
- const path = require('node:path');
49
- const fs = require('node:fs');
50
- const crypto = require('node:crypto');
51
-
52
- /** Exit codes. Public: scripts branch on these, so they are frozen. */
53
- const EXIT = Object.freeze({ OK: 0, WARN: 1, BROKEN: 2 });
54
-
55
- /** The two faces, in package-name order, with the versions they must carry. */
56
- const FACE_PACKAGES = Object.freeze([
57
- Object.freeze({ dir: 'cli', package: 'aegiscode' }),
58
- Object.freeze({ dir: 'desktop', package: 'aegis-desktop' }),
59
- ]);
60
-
61
- /** Where the ONE bundle keeps the two staged faces (D6 layout). */
62
- const BUNDLE_FACES = Object.freeze([
63
- Object.freeze({ face: 'cli', root: 'cli', staged: 'one/vendor/cli' }),
64
- Object.freeze({ face: 'desktop', root: 'desktop', staged: 'one/vendor/desktop' }),
65
- ]);
66
-
67
- // ---------------------------------------------------------------------------
68
- // Real seams. Built lazily, inside functions — never at module scope.
69
- // ---------------------------------------------------------------------------
70
-
71
- /** The directory this file lives in, without asking `process` anything. */
72
- function oneDir() {
73
- return path.resolve(__dirname, '..');
74
- }
75
-
76
- function repoDir() {
77
- return path.resolve(__dirname, '..', '..');
78
- }
79
-
80
- /** `@returns {{path: string|null}}` — the home AEGISCODE_HOME resolves to. */
81
- function homeHint(env) {
82
- const e = env || {};
83
- return e.AEGISCODE_HOME || e.AEGIS_HOME || null;
84
- }
85
-
86
- /**
87
- * The default `{ exists, readFile, hashFile }` set.
88
- *
89
- * `readFile` returns text and NEVER throws for a missing file (it returns
90
- * null) — because "the file is not there" and "the file is there and I cannot
91
- * read it" are different facts, and the second one is exit 2. Callers that
92
- * need to tell them apart use `exists` first; a throw from `readFile` is
93
- * therefore a real I/O failure and is treated as one.
94
- */
95
- function defaultFs() {
96
- return {
97
- exists: (p) => {
98
- try {
99
- return fs.existsSync(p);
100
- } catch {
101
- return false;
102
- }
103
- },
104
- readFile: (p) => {
105
- try {
106
- return fs.readFileSync(p, 'utf8');
107
- } catch (err) {
108
- if (err && (err.code === 'ENOENT' || err.code === 'EISDIR')) return null;
109
- throw err;
110
- }
111
- },
112
- hashFile: (p) => crypto.createHash('sha256').update(fs.readFileSync(p)).digest('hex'),
113
- listFiles: (dir, base) => listFiles(dir, base === undefined ? dir : base),
114
- };
115
- }
116
-
117
- /** Every file under `dir`, as paths relative to `base`. Sorted, so it is stable. */
118
- function listFiles(dir, base) {
119
- const out = [];
120
- const walk = (d) => {
121
- let entries;
122
- try {
123
- entries = fs.readdirSync(d, { withFileTypes: true });
124
- } catch {
125
- return;
126
- }
127
- for (const e of entries) {
128
- if (e.name === 'node_modules' || e.name === '.git') continue;
129
- const p = path.join(d, e.name);
130
- if (e.isDirectory()) walk(p);
131
- else out.push(path.relative(base, p).split(path.sep).join('/'));
132
- }
133
- };
134
- walk(dir);
135
- return out.sort();
136
- }
137
-
138
- /**
139
- * Where the desktop keeps what only the OS can decrypt.
140
- *
141
- * On Linux a plain Node process cannot read `safeStorage` blobs, so the CLI
142
- * reports *that the keychain holds something*, never the key. The location is
143
- * derived from the same `$AEGISCODE_HOME`-or-`~/.aegiscode` rule
144
- * `client/credentials.js` uses, with the Electron userData path preferred when
145
- * the caller knows it.
146
- */
147
- function defaultElectronPaths(env, deps) {
148
- const d = deps || {};
149
- const home = homeHint(env);
150
- const base = home || path.join(env && env.HOME ? env.HOME : '', '.aegiscode');
151
- return {
152
- electron: d.electron !== undefined ? d.electron : null,
153
- desktopMain: d.desktopMain !== undefined ? d.desktopMain : null,
154
- userData: d.userData !== undefined ? d.userData : base,
155
- keychain: d.keychain !== undefined ? d.keychain : path.join(base, 'settings.json'),
156
- };
157
- }
158
-
159
- /**
160
- * The one registry check, reached through `client/update.js`.
161
- *
162
- * Lazy and injectable: doctor never contains a fetch, a timeout or an
163
- * interval — the shared module owns all three, and the caller can replace the
164
- * whole thing with a stub. Requires are inside the function so `doctor.js`
165
- * can be loaded in a test with no client tree beside it.
166
- */
167
- function defaultRegistry() {
168
- let shared = null;
169
- const load = () => {
170
- if (shared) return shared;
171
- const candidates = [
172
- path.join(repoDir(), 'client', 'update.js'),
173
- path.join(oneDir(), 'vendor', 'cli', 'vendor', 'client', 'update.js'),
174
- ];
175
- for (const c of candidates) {
176
- try {
177
- // eslint-disable-next-line global-require
178
- shared = require(c);
179
- break;
180
- } catch {
181
- /* try the next layout */
182
- }
183
- }
184
- return shared;
185
- };
186
- return {
187
- /** The cached once-a-day check. Non-blocking by construction. */
188
- check(opts) {
189
- const mod = load();
190
- if (!mod || typeof mod.updateNotice !== 'function') {
191
- return { latest: null, behind: false, reason: 'unavailable' };
192
- }
193
- return mod.updateNotice(opts || {});
194
- },
195
- /** The shared "what happens next" verdict both appliers consume. */
196
- plan(opts) {
197
- const mod = load();
198
- if (!mod || typeof mod.updatePlan !== 'function') return null;
199
- return mod.updatePlan(opts || {});
200
- },
201
- };
202
- }
203
-
204
- /** The shared non-secret preference store (ON4/D5), resolved lazily. */
205
- function defaultStorePath(env) {
206
- try {
207
- // eslint-disable-next-line global-require
208
- const prefs = require(path.join(repoDir(), 'client', 'prefs.js'));
209
- if (typeof prefs.prefsFile === 'function') return prefs.prefsFile(env);
210
- } catch {
211
- /* fall through to the documented rule */
212
- }
213
- const home = homeHint(env);
214
- const base = home || path.join((env && env.HOME) || '', '.aegiscode');
215
- return path.join(base, 'preferences.json');
216
- }
217
-
218
- /** The credential resolver, lazy for the same reason the registry is. */
219
- function defaultCredentials() {
220
- let mod = null;
221
- return {
222
- resolve(o) {
223
- if (!mod) {
224
- try {
225
- // eslint-disable-next-line global-require
226
- mod = require(path.join(repoDir(), 'client', 'credentials.js'));
227
- } catch {
228
- mod = null;
229
- }
230
- }
231
- if (!mod || typeof mod.resolveApiKey !== 'function') return { key: '', source: 'none', from: '' };
232
- try {
233
- return mod.resolveApiKey(o || {});
234
- } catch {
235
- return { key: '', source: 'none', from: '' };
236
- }
237
- },
238
- };
239
- }
240
-
241
- // ---------------------------------------------------------------------------
242
- // Vendor integrity
243
- // ---------------------------------------------------------------------------
244
-
245
- /**
246
- * Every staged file in the ONE bundle, paired with the source it was copied
247
- * from.
248
- *
249
- * The rule is D6's layout, not a second manifest: inside `one/vendor/<face>/`
250
- * a path either mirrors the face's own tree (`<rel>` ← `<face>/<rel>`) or is a
251
- * staged shared module (`vendor/<rel>` ← `<rel>` at the repo root). The desktop
252
- * stages the shared half FLAT, so a `desktop/vendor/<name>` may come from any
253
- * of the shared roots — the candidates below are tried in a fixed order and the
254
- * first that exists wins. A staged file with no source at all is reported as
255
- * such: it means the bundle cannot be re-derived, which is a broken tree, not
256
- * a cosmetic one.
257
- */
258
- function vendorPairs(seams) {
259
- const { root, exists } = seams;
260
- const pairs = [];
261
- for (const { face, root: faceRoot, staged } of BUNDLE_FACES) {
262
- const stagedAbs = path.join(root, staged);
263
- const files = seams.listFiles(stagedAbs, stagedAbs);
264
- for (const rel of files) {
265
- const candidates = [];
266
- if (rel.startsWith('vendor/')) {
267
- const trimmed = rel.slice('vendor/'.length);
268
- candidates.push(path.join(root, trimmed));
269
- candidates.push(path.join(root, faceRoot, trimmed));
270
- if (face === 'desktop') {
271
- const base = path.basename(trimmed);
272
- for (const shared of ['client', 'mcp', 'covenant', 'commands', 'skills', 'tools', 'hosts']) {
273
- candidates.push(path.join(root, shared, base));
274
- }
275
- candidates.push(path.join(root, base));
276
- }
277
- } else {
278
- candidates.push(path.join(root, faceRoot, rel));
279
- candidates.push(path.join(root, rel));
280
- }
281
- const source = candidates.find((c) => exists(c)) || null;
282
- pairs.push({ face, staged: path.join(staged, rel), source, candidates });
283
- }
284
- }
285
- return pairs;
286
- }
287
-
288
- function checkVendor(seams, injectedPairs) {
289
- const pairs = injectedPairs || vendorPairs(seams);
290
- const missingSource = [];
291
- const mismatch = [];
292
- let matched = 0;
293
- let staged = 0;
294
- for (const p of pairs) {
295
- if (!seams.exists(path.join(seams.root, p.staged))) continue;
296
- staged += 1;
297
- if (!p.source) {
298
- missingSource.push(p.staged);
299
- continue;
300
- }
301
- let a;
302
- let b;
303
- try {
304
- a = seams.hashFile(path.join(seams.root, p.source));
305
- b = seams.hashFile(path.join(seams.root, p.staged));
306
- } catch (err) {
307
- mismatch.push({ staged: p.staged, source: p.source, error: String((err && err.message) || err) });
308
- continue;
309
- }
310
- if (a === b) matched += 1;
311
- else mismatch.push({ staged: p.staged, source: p.source });
312
- }
313
- return {
314
- staged,
315
- matched,
316
- mismatch,
317
- missingSource,
318
- // A bundle that was never staged is *stale*, not corrupt: the sources are
319
- // fine and the packaged faces are the only thing missing. That is a warn.
320
- stale: pairs.length > 0 && staged === 0,
321
- checked: pairs.length,
322
- };
323
- }
324
-
325
- // ---------------------------------------------------------------------------
326
- // The report
327
- // ---------------------------------------------------------------------------
328
-
329
- function readJson(seams, rel) {
330
- const abs = path.join(seams.root, rel);
331
- if (!seams.exists(abs)) return { ok: false, missing: true, value: null, path: rel };
332
- let text;
333
- try {
334
- text = seams.readFile(abs);
335
- } catch (err) {
336
- return { ok: false, unreadable: true, value: null, path: rel, error: String((err && err.message) || err) };
337
- }
338
- if (text == null) return { ok: false, missing: true, value: null, path: rel };
339
- try {
340
- return { ok: true, value: JSON.parse(text), path: rel };
341
- } catch (err) {
342
- return { ok: false, unreadable: true, value: null, path: rel, error: String((err && err.message) || err) };
343
- }
344
- }
345
-
346
- /** `undefined` when the seam was not supplied, so a caller knows to default. */
347
- function resolveSeams(options) {
348
- const o = options || {};
349
- const env = o.env || {};
350
- const base = defaultFs();
351
- const supplied = o || {};
352
- return {
353
- root: o.root || repoDir(),
354
- platform: o.platform || 'linux',
355
- env,
356
- exists: supplied.exists || base.exists,
357
- readFile: supplied.readFile || base.readFile,
358
- hashFile: supplied.hashFile || base.hashFile,
359
- listFiles: supplied.listFiles || base.listFiles,
360
- credentials: o.credentials || defaultCredentials(),
361
- storePath: o.storePath || defaultStorePath(env),
362
- registry: o.registry || defaultRegistry(),
363
- electronPaths: o.electronPaths || defaultElectronPaths(env, o),
364
- updateCache: o.updateCache,
365
- saveUpdateCache: o.saveUpdateCache,
366
- now: typeof o.now === 'number' ? o.now : 0,
367
- guiRequested: Boolean(o.guiRequested),
368
- guiImplied: o.guiImplied,
369
- vendorPairs: o.vendorPairs,
370
- };
371
- }
372
-
373
- /**
374
- * Build the report and its exit code. Pure given the seams.
375
- *
376
- * @param {object} [options] the seam object documented at the top.
377
- * @returns {{report: object, code: number}}
378
- */
379
- function diagnose(options) {
380
- const seams = resolveSeams(options);
381
- const problems = [];
382
- const broken = (code, detail) => problems.push({ level: 'broken', code, detail });
383
- const warn = (code, detail) => problems.push({ level: 'warn', code, detail });
384
-
385
- // ── versions ─────────────────────────────────────────────────────────────
386
- const productFile = readJson(seams, 'one/package.json');
387
- const product = productFile.ok
388
- ? { name: productFile.value.name || 'aegisone', version: String(productFile.value.version || '') }
389
- : { name: 'aegisone', version: '' };
390
- if (!productFile.ok) broken('product-unreadable', `one/package.json ${productFile.unreadable ? 'is unreadable' : 'is missing'}`);
391
-
392
- let expected = null;
393
- try {
394
- // eslint-disable-next-line global-require
395
- expected = require('./release.js').deriveFaceVersions(product.version);
396
- } catch (err) {
397
- expected = null;
398
- if (productFile.ok) broken('product-version-invalid', `${product.version}: ${String((err && err.message) || err)}`);
399
- }
400
-
401
- const faces = {};
402
- for (const { dir, package: pkg } of FACE_PACKAGES) {
403
- const file = readJson(seams, `${dir}/package.json`);
404
- const actual = file.ok ? String(file.value.version || '') : '';
405
- const want = expected && expected[pkg] ? expected[pkg].version : null;
406
- if (!file.ok) broken('face-unreadable', `${dir}/package.json ${file.unreadable ? 'is unreadable' : 'is missing'}`);
407
- else if (want && actual !== want) {
408
- broken('version-mismatch', `${pkg} is ${actual}, product ${product.version} derives ${want}`);
409
- }
410
- faces[pkg] = { dir, version: actual, expected: want, ok: Boolean(want && actual === want) };
411
- }
412
-
413
- // ── credential ───────────────────────────────────────────────────────────
414
- let cred = { key: '', source: 'none', from: '' };
415
- try {
416
- cred = seams.credentials.resolve({ env: seams.env }) || cred;
417
- } catch {
418
- cred = { key: '', source: 'none', from: '' };
419
- }
420
- const electronPaths = seams.electronPaths || {};
421
- let credentialSource = cred.key ? (cred.source === 'env' ? 'env' : cred.source === 'envfile' ? 'env-file' : 'env-file') : 'none';
422
- if (!cred.key && electronPaths.keychain && seams.exists(electronPaths.keychain)) {
423
- const text = (() => {
424
- try {
425
- return seams.readFile(electronPaths.keychain);
426
- } catch {
427
- return null;
428
- }
429
- })();
430
- if (text && /encrypt|safeStorage/i.test(text)) credentialSource = 'keychain';
431
- }
432
- if (credentialSource === 'none') warn('no-credential', 'no credential found (env, credentials.json, or the OS keychain)');
433
-
434
- // ── shared store ─────────────────────────────────────────────────────────
435
- const store = { path: seams.storePath, exists: false, readable: null, legacy: null };
436
- try {
437
- store.exists = seams.exists(seams.storePath);
438
- } catch {
439
- store.exists = false;
440
- }
441
- let storeRel = store.path;
442
- if (store.exists) {
443
- let text = null;
444
- try {
445
- text = seams.readFile(store.path);
446
- } catch (err) {
447
- store.readable = false;
448
- broken('store-unreadable', `${store.path}: ${String((err && err.message) || err)}`);
449
- }
450
- if (store.readable === null) {
451
- if (text == null) {
452
- store.readable = false;
453
- broken('store-unreadable', `${store.path} exists but could not be read`);
454
- } else {
455
- try {
456
- const parsed = JSON.parse(text);
457
- store.readable = true;
458
- store.legacy = (parsed && parsed.version) || null;
459
- } catch (err) {
460
- store.readable = false;
461
- broken('store-unreadable', `${store.path} is not valid JSON: ${String((err && err.message) || err)}`);
462
- }
463
- }
464
- }
465
- storeRel = path.basename(store.path);
466
- }
467
- store.display = storeRel;
468
-
469
- // ── vendor integrity ─────────────────────────────────────────────────────
470
- let vendor;
471
- try {
472
- vendor = checkVendor(seams, seams.vendorPairs);
473
- } catch (err) {
474
- vendor = { staged: 0, matched: 0, mismatch: [], missingSource: [], stale: false, checked: 0, error: String((err && err.message) || err) };
475
- broken('vendor-unreadable', vendor.error);
476
- }
477
- for (const m of vendor.mismatch) {
478
- broken('vendor-hash-mismatch', `${m.staged} differs from ${m.source || 'its source'}`);
479
- }
480
- for (const m of vendor.missingSource) broken('vendor-source-missing', `${m} has no source to be re-derived from`);
481
- if (vendor.stale) warn('vendor-stale', 'the ONE bundle has never been staged (one/vendor is empty) — run `npm run predist`');
482
-
483
- // ── update state: the ONE check ──────────────────────────────────────────
484
- const update = {
485
- channel: 'npm',
486
- current: product.version,
487
- latest: null,
488
- behind: false,
489
- reason: null,
490
- checkedAt: null,
491
- cached: true,
492
- action: 'none',
493
- applier: 'npm',
494
- instruction: null,
495
- };
496
- try {
497
- const notice =
498
- seams.registry.check({
499
- current: product.version,
500
- cache: seams.updateCache,
501
- save: seams.saveUpdateCache,
502
- now: seams.now,
503
- }) || {};
504
- update.latest = notice.latest || null;
505
- update.behind = Boolean(notice.behind);
506
- update.reason = notice.reason || null;
507
- } catch (err) {
508
- update.reason = 'unavailable';
509
- update.error = String((err && err.message) || err);
510
- }
511
- try {
512
- const plan = seams.registry.plan({ current: product.version, latest: update.latest, behind: update.behind });
513
- if (plan) {
514
- update.action = plan.action;
515
- update.applier = plan.applier;
516
- update.instruction = plan.instruction;
517
- }
518
- } catch {
519
- /* the plan is a projection; without it the raw check still reports */
520
- }
521
- if (update.behind) {
522
- warn('update-available', `${update.current} → ${update.latest} (${update.instruction || 'run the channel updater'})`);
523
- }
524
-
525
- // ── the window face, when it was asked for ───────────────────────────────
526
- const electron = (electronPaths && electronPaths.electron) || null;
527
- if (seams.guiRequested && !electron) {
528
- broken('gui-without-electron', '--gui was requested but Electron is not installed — use --tui');
529
- }
530
-
531
- const brokenCount = problems.filter((p) => p.level === 'broken').length;
532
- const warnCount = problems.filter((p) => p.level === 'warn').length;
533
- const code = brokenCount ? EXIT.BROKEN : warnCount ? EXIT.WARN : EXIT.OK;
534
-
535
- const report = {
536
- aegis: 'one',
537
- status: brokenCount ? 'broken' : warnCount ? 'warn' : 'healthy',
538
- exitCode: code,
539
- product,
540
- faces,
541
- credential: { source: credentialSource, found: Boolean(cred.key), from: cred.key ? cred.from : '' },
542
- store: { path: store.path, exists: store.exists, readable: store.exists ? store.readable === true : null },
543
- vendor: {
544
- staged: vendor.staged,
545
- matched: vendor.matched,
546
- mismatched: vendor.mismatch.length,
547
- missingSource: vendor.missingSource.length,
548
- stale: vendor.stale,
549
- },
550
- update,
551
- gui: {
552
- requested: Boolean(seams.guiRequested),
553
- electron: electron || null,
554
- usable: Boolean(electron) && (!seams.guiImplied || seams.guiImplied),
555
- },
556
- problems,
557
- };
558
- return { report, code };
559
- }
560
-
561
- /** The same object, for a human. Derived from `report` — never a second truth. */
562
- function render(report) {
563
- const lines = [];
564
- const pad = (s, n) => String(s) + ' '.repeat(Math.max(0, n - String(s).length));
565
- lines.push(`aegis doctor — ${report.status} (exit ${report.exitCode})`);
566
- lines.push(` product ${report.product.name} ${report.product.version}`);
567
- for (const [pkg, f] of Object.entries(report.faces)) {
568
- const tail = f.ok ? '' : ` (expected ${f.expected || 'unknown'})`;
569
- lines.push(` ${pad(pkg, 14)} ${f.version || 'unknown'}${tail}`);
570
- }
571
- lines.push(` credential ${report.credential.source}`);
572
- lines.push(` shared store ${report.store.path} ${report.store.exists ? (report.store.readable ? '(readable)' : '(unreadable)') : '(absent)'}`);
573
- lines.push(
574
- ` vendor ${report.vendor.staged} staged, ${report.vendor.matched} matching, ` +
575
- `${report.vendor.mismatched} mismatched, ${report.vendor.missingSource} without a source` +
576
- (report.vendor.stale ? ' (never staged)' : '')
577
- );
578
- const u = report.update;
579
- lines.push(
580
- ` update ${u.behind ? `${u.current} → ${u.latest}` : `${u.current} is current`}` +
581
- ` (next: ${u.action}${u.instruction ? ` — ${u.instruction}` : ''})`
582
- );
583
- lines.push(` window face ${report.gui.electron ? `Electron at ${report.gui.electron}` : 'not installed'}`);
584
- if (report.problems.length) {
585
- lines.push(' problems:');
586
- for (const p of report.problems) lines.push(` ${p.level === 'broken' ? '✗' : '!'} ${p.code}: ${p.detail}`);
587
- }
588
- return lines.join('\n') + '\n';
589
- }
590
-
591
- /** Does this argv ask the doctor about the window face? */
592
- function wantsGui(argv, env) {
593
- const args = Array.isArray(argv) ? argv : [];
594
- if (args.includes('--gui')) return true;
595
- return (env || {}).AEGISONE_FACE === 'gui';
596
- }
597
-
598
- /**
599
- * `aegis doctor` — print and return an exit code.
600
- *
601
- * @param {string[]} argv arguments after `doctor`
602
- * @param {object} [deps] seam overrides, plus `{ stdout, stderr }`
603
- * @returns {number} EXIT.OK | EXIT.WARN | EXIT.BROKEN
604
- */
605
- function main(argv, deps) {
606
- const d = deps || {};
607
- const args = Array.isArray(argv) ? argv : [];
608
- const out = d.stdout || process.stdout;
609
- const env = d.env || process.env || {};
610
- const options = Object.assign({}, d, { env, guiRequested: wantsGui(args, env) });
611
- const { report, code } = diagnose(options);
612
- const text = args.includes('--json') ? JSON.stringify(report) + '\n' : render(report);
613
- try {
614
- out.write(text);
615
- } catch {
616
- /* a closed pipe is not a broken install */
617
- }
618
- return code;
619
- }
620
-
621
- module.exports = {
622
- EXIT,
623
- FACE_PACKAGES,
624
- wantsGui,
625
- diagnose,
626
- render,
627
- main,
628
- // Exported for tests and for a future `aegis doctor --fix`: the same seams.
629
- vendorPairs,
630
- resolveSeams,
631
- };
632
-
633
- // `aegis doctor` reaches main() through one/bin/aegis.js, but this file is also
634
- // a program in its own right: `node one/src/doctor.js` is what runs when the bin
635
- // is not on PATH, and what a bug report pastes. It shipped without this block,
636
- // so that invocation printed nothing and exited 0 — "never silently do nothing",
637
- // broken in the one command whose whole job is to say what is wrong. The guard
638
- // is the same idiom as one/scripts/bundle.js and one/bin/aegis.js, and it is
639
- // inert on import: `require('./doctor.js')` from the bin reads nothing, which is
640
- // the property the ON seam rule under `one/` actually protects.
641
- if (require.main === module) process.exitCode = main(process.argv.slice(2));
3
+ "use strict";const path=require("node:path"),fs=require("node:fs"),crypto=require("node:crypto"),EXIT=Object.freeze({OK:0,WARN:1,BROKEN:2}),FACE_PACKAGES=Object.freeze([Object.freeze({dir:"cli",package:"aegiscode"}),Object.freeze({dir:"desktop",package:"aegis-desktop"})]),BUNDLE_FACES=Object.freeze([Object.freeze({face:"cli",root:"cli",staged:"one/vendor/cli"}),Object.freeze({face:"desktop",root:"desktop",staged:"one/vendor/desktop"})]);function oneDir(){return path.resolve(__dirname,"..")}function repoDir(){return path.resolve(__dirname,"..","..")}function homeHint(e){const t=e||{};return t.AEGISCODE_HOME||t.AEGIS_HOME||null}function defaultFs(){return{exists:e=>{try{return fs.existsSync(e)}catch{return!1}},readFile:e=>{try{return fs.readFileSync(e,"utf8")}catch(e){if(e&&("ENOENT"===e.code||"EISDIR"===e.code))return null;throw e}},hashFile:e=>crypto.createHash("sha256").update(fs.readFileSync(e)).digest("hex"),listFiles:(e,t)=>listFiles(e,void 0===t?e:t)}}function listFiles(e,t){const n=[],r=e=>{let s;try{s=fs.readdirSync(e,{withFileTypes:!0})}catch{return}for(const o of s){if("node_modules"===o.name||".git"===o.name)continue;const s=path.join(e,o.name);o.isDirectory()?r(s):n.push(path.relative(t,s).split(path.sep).join("/"))}};return r(e),n.sort()}function defaultElectronPaths(e,t){const n=t||{},r=homeHint(e)||path.join(e&&e.HOME?e.HOME:"",".aegiscode");return{electron:void 0!==n.electron?n.electron:null,desktopMain:void 0!==n.desktopMain?n.desktopMain:null,userData:void 0!==n.userData?n.userData:r,keychain:void 0!==n.keychain?n.keychain:path.join(r,"settings.json")}}function defaultRegistry(){let e=null;const t=()=>{if(e)return e;const t=[path.join(repoDir(),"client","update.js"),path.join(oneDir(),"vendor","cli","vendor","client","update.js")];for(const n of t)try{e=require(n);break}catch{}return e};return{check(e){const n=t();return n&&"function"==typeof n.updateNotice?n.updateNotice(e||{}):{latest:null,behind:!1,reason:"unavailable"}},plan(e){const n=t();return n&&"function"==typeof n.updatePlan?n.updatePlan(e||{}):null}}}function defaultStorePath(e){try{const t=require(path.join(repoDir(),"client","prefs.js"));if("function"==typeof t.prefsFile)return t.prefsFile(e)}catch{}const t=homeHint(e)||path.join(e&&e.HOME||"",".aegiscode");return path.join(t,"preferences.json")}function defaultCredentials(){let e=null;return{resolve(t){if(!e)try{e=require(path.join(repoDir(),"client","credentials.js"))}catch{e=null}if(!e||"function"!=typeof e.resolveApiKey)return{key:"",source:"none",from:""};try{return e.resolveApiKey(t||{})}catch{return{key:"",source:"none",from:""}}}}}function vendorPairs(e){const{root:t,exists:n}=e,r=[];for(const{face:s,root:o,staged:a}of BUNDLE_FACES){const i=path.join(t,a),c=e.listFiles(i,i);for(const e of c){const i=[];if(e.startsWith("vendor/")){const n=e.slice(7);if(i.push(path.join(t,n)),i.push(path.join(t,o,n)),"desktop"===s){const e=path.basename(n);for(const n of["client","mcp","covenant","commands","skills","tools","hosts"])i.push(path.join(t,n,e));i.push(path.join(t,e))}}else i.push(path.join(t,o,e)),i.push(path.join(t,e));const c=i.find((e=>n(e)))||null;r.push({face:s,staged:path.join(a,e),source:c,candidates:i})}}return r}function checkVendor(e,t){const n=t||vendorPairs(e),r=[],s=[];let o=0,a=0;for(const t of n){if(!e.exists(path.join(e.root,t.staged)))continue;if(a+=1,!t.source){r.push(t.staged);continue}let n,i;try{n=e.hashFile(path.join(e.root,t.source)),i=e.hashFile(path.join(e.root,t.staged))}catch(e){s.push({staged:t.staged,source:t.source,error:String(e&&e.message||e)});continue}n===i?o+=1:s.push({staged:t.staged,source:t.source})}return{staged:a,matched:o,mismatch:s,missingSource:r,stale:n.length>0&&0===a,checked:n.length}}function readJson(e,t){const n=path.join(e.root,t);if(!e.exists(n))return{ok:!1,missing:!0,value:null,path:t};let r;try{r=e.readFile(n)}catch(e){return{ok:!1,unreadable:!0,value:null,path:t,error:String(e&&e.message||e)}}if(null==r)return{ok:!1,missing:!0,value:null,path:t};try{return{ok:!0,value:JSON.parse(r),path:t}}catch(e){return{ok:!1,unreadable:!0,value:null,path:t,error:String(e&&e.message||e)}}}function resolveSeams(e){const t=e||{},n=t.env||{},r=defaultFs(),s=t||{};return{root:t.root||repoDir(),platform:t.platform||"linux",env:n,exists:s.exists||r.exists,readFile:s.readFile||r.readFile,hashFile:s.hashFile||r.hashFile,listFiles:s.listFiles||r.listFiles,credentials:t.credentials||defaultCredentials(),storePath:t.storePath||defaultStorePath(n),registry:t.registry||defaultRegistry(),electronPaths:t.electronPaths||defaultElectronPaths(n,t),updateCache:t.updateCache,saveUpdateCache:t.saveUpdateCache,now:"number"==typeof t.now?t.now:0,guiRequested:Boolean(t.guiRequested),guiImplied:t.guiImplied,vendorPairs:t.vendorPairs}}function diagnose(e){const t=resolveSeams(e),n=[],r=(e,t)=>n.push({level:"broken",code:e,detail:t}),s=(e,t)=>n.push({level:"warn",code:e,detail:t}),o=readJson(t,"one/package.json"),a=o.ok?{name:o.value.name||"aegisone",version:String(o.value.version||"")}:{name:"aegisone",version:""};o.ok||r("product-unreadable","one/package.json "+(o.unreadable?"is unreadable":"is missing"));let i=null;try{i=require("./release.js").deriveFaceVersions(a.version)}catch(e){i=null,o.ok&&r("product-version-invalid",`${a.version}: ${String(e&&e.message||e)}`)}const c={};for(const{dir:e,package:n}of FACE_PACKAGES){const s=readJson(t,`${e}/package.json`),o=s.ok?String(s.value.version||""):"",l=i&&i[n]?i[n].version:null;s.ok?l&&o!==l&&r("version-mismatch",`${n} is ${o}, product ${a.version} derives ${l}`):r("face-unreadable",`${e}/package.json ${s.unreadable?"is unreadable":"is missing"}`),c[n]={dir:e,version:o,expected:l,ok:Boolean(l&&o===l)}}let l={key:"",source:"none",from:""};try{l=t.credentials.resolve({env:t.env})||l}catch{l={key:"",source:"none",from:""}}const u=t.electronPaths||{};let d=l.key?"env"===l.source?"env":(l.source,"env-file"):"none";if(!l.key&&u.keychain&&t.exists(u.keychain)){const e=(()=>{try{return t.readFile(u.keychain)}catch{return null}})();e&&/encrypt|safeStorage/i.test(e)&&(d="keychain")}"none"===d&&s("no-credential","no credential found (env, credentials.json, or the OS keychain)");const h={path:t.storePath,exists:!1,readable:null,legacy:null};try{h.exists=t.exists(t.storePath)}catch{h.exists=!1}let p,f=h.path;if(h.exists){let e=null;try{e=t.readFile(h.path)}catch(e){h.readable=!1,r("store-unreadable",`${h.path}: ${String(e&&e.message||e)}`)}if(null===h.readable)if(null==e)h.readable=!1,r("store-unreadable",`${h.path} exists but could not be read`);else try{const t=JSON.parse(e);h.readable=!0,h.legacy=t&&t.version||null}catch(e){h.readable=!1,r("store-unreadable",`${h.path} is not valid JSON: ${String(e&&e.message||e)}`)}f=path.basename(h.path)}h.display=f;try{p=checkVendor(t,t.vendorPairs)}catch(e){p={staged:0,matched:0,mismatch:[],missingSource:[],stale:!1,checked:0,error:String(e&&e.message||e)},r("vendor-unreadable",p.error)}for(const e of p.mismatch)r("vendor-hash-mismatch",`${e.staged} differs from ${e.source||"its source"}`);for(const e of p.missingSource)r("vendor-source-missing",`${e} has no source to be re-derived from`);p.stale&&s("vendor-stale","the ONE bundle has never been staged (one/vendor is empty) — run `npm run predist`");const g={channel:"npm",current:a.version,latest:null,behind:!1,reason:null,checkedAt:null,cached:!0,action:"none",applier:"npm",instruction:null};try{const e=t.registry.check({current:a.version,cache:t.updateCache,save:t.saveUpdateCache,now:t.now})||{};g.latest=e.latest||null,g.behind=Boolean(e.behind),g.reason=e.reason||null}catch(e){g.reason="unavailable",g.error=String(e&&e.message||e)}try{const e=t.registry.plan({current:a.version,latest:g.latest,behind:g.behind});e&&(g.action=e.action,g.applier=e.applier,g.instruction=e.instruction)}catch{}g.behind&&s("update-available",`${g.current} → ${g.latest} (${g.instruction||"run the channel updater"})`);const v=u&&u.electron||null;t.guiRequested&&!v&&r("gui-without-electron","--gui was requested but Electron is not installed — use --tui");const m=n.filter((e=>"broken"===e.level)).length,y=n.filter((e=>"warn"===e.level)).length,b=m?EXIT.BROKEN:y?EXIT.WARN:EXIT.OK;return{report:{aegis:"one",status:m?"broken":y?"warn":"healthy",exitCode:b,product:a,faces:c,credential:{source:d,found:Boolean(l.key),from:l.key?l.from:""},store:{path:h.path,exists:h.exists,readable:h.exists?!0===h.readable:null},vendor:{staged:p.staged,matched:p.matched,mismatched:p.mismatch.length,missingSource:p.missingSource.length,stale:p.stale},update:g,gui:{requested:Boolean(t.guiRequested),electron:v||null,usable:Boolean(v)&&(!t.guiImplied||t.guiImplied)},problems:n},code:b}}function render(e){const t=[];t.push(`aegis doctor — ${e.status} (exit ${e.exitCode})`),t.push(` product ${e.product.name} ${e.product.version}`);for(const[r,s]of Object.entries(e.faces)){const e=s.ok?"":` (expected ${s.expected||"unknown"})`;t.push(` ${n=r,14,String(n)+" ".repeat(Math.max(0,14-String(n).length))} ${s.version||"unknown"}${e}`)}var n;t.push(` credential ${e.credential.source}`),t.push(` shared store ${e.store.path} ${e.store.exists?e.store.readable?"(readable)":"(unreadable)":"(absent)"}`),t.push(` vendor ${e.vendor.staged} staged, ${e.vendor.matched} matching, ${e.vendor.mismatched} mismatched, ${e.vendor.missingSource} without a source`+(e.vendor.stale?" (never staged)":""));const r=e.update;if(t.push(" update "+(r.behind?`${r.current} → ${r.latest}`:`${r.current} is current`)+` (next: ${r.action}${r.instruction?` — ${r.instruction}`:""})`),t.push(" window face "+(e.gui.electron?`Electron at ${e.gui.electron}`:"not installed")),e.problems.length){t.push(" problems:");for(const n of e.problems)t.push(` ${"broken"===n.level?"✗":"!"} ${n.code}: ${n.detail}`)}return t.join("\n")+"\n"}function wantsGui(e,t){return!!(Array.isArray(e)?e:[]).includes("--gui")||"gui"===(t||{}).AEGISONE_FACE}function main(e,t){const n=t||{},r=Array.isArray(e)?e:[],s=n.stdout||process.stdout,o=n.env||process.env||{},a=Object.assign({},n,{env:o,guiRequested:wantsGui(r,o)}),{report:i,code:c}=diagnose(a),l=r.includes("--json")?JSON.stringify(i)+"\n":render(i);try{s.write(l)}catch{}return c}module.exports={EXIT:EXIT,FACE_PACKAGES:FACE_PACKAGES,wantsGui:wantsGui,diagnose:diagnose,render:render,main:main,vendorPairs:vendorPairs,resolveSeams:resolveSeams},require.main===module&&(process.exitCode=main(process.argv.slice(2)));