@cleocode/core 2026.9.26 → 2026.10.2

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 (410) hide show
  1. package/dist/build-provenance.json +2 -2
  2. package/dist/cloud/journal.d.ts +9 -5
  3. package/dist/cloud/journal.d.ts.map +1 -1
  4. package/dist/cloud/journal.js +29 -8
  5. package/dist/cloud/journal.js.map +1 -1
  6. package/dist/cloud/manifest-check.d.ts +140 -4
  7. package/dist/cloud/manifest-check.d.ts.map +1 -1
  8. package/dist/cloud/manifest-check.js +309 -10
  9. package/dist/cloud/manifest-check.js.map +1 -1
  10. package/dist/cloud/nexus-attach.d.ts +119 -0
  11. package/dist/cloud/nexus-attach.d.ts.map +1 -0
  12. package/dist/cloud/nexus-attach.js +267 -0
  13. package/dist/cloud/nexus-attach.js.map +1 -0
  14. package/dist/cloud/nexus-auth.d.ts +15 -3
  15. package/dist/cloud/nexus-auth.d.ts.map +1 -1
  16. package/dist/cloud/nexus-auth.js +90 -6
  17. package/dist/cloud/nexus-auth.js.map +1 -1
  18. package/dist/cloud/nexus-cloud-activity.d.ts +37 -0
  19. package/dist/cloud/nexus-cloud-activity.d.ts.map +1 -0
  20. package/dist/cloud/nexus-cloud-activity.js +79 -0
  21. package/dist/cloud/nexus-cloud-activity.js.map +1 -0
  22. package/dist/cloud/nexus-cloud-status.d.ts +132 -0
  23. package/dist/cloud/nexus-cloud-status.d.ts.map +1 -0
  24. package/dist/cloud/nexus-cloud-status.js +476 -0
  25. package/dist/cloud/nexus-cloud-status.js.map +1 -0
  26. package/dist/cloud/nexus-cloud.d.ts +179 -0
  27. package/dist/cloud/nexus-cloud.d.ts.map +1 -0
  28. package/dist/cloud/nexus-cloud.js +296 -0
  29. package/dist/cloud/nexus-cloud.js.map +1 -0
  30. package/dist/cloud/nexus-device.d.ts +32 -7
  31. package/dist/cloud/nexus-device.d.ts.map +1 -1
  32. package/dist/cloud/nexus-device.js +54 -7
  33. package/dist/cloud/nexus-device.js.map +1 -1
  34. package/dist/cloud/nexus-enrol.d.ts +35 -4
  35. package/dist/cloud/nexus-enrol.d.ts.map +1 -1
  36. package/dist/cloud/nexus-enrol.js +192 -47
  37. package/dist/cloud/nexus-enrol.js.map +1 -1
  38. package/dist/cloud/nexus-home.d.ts +74 -0
  39. package/dist/cloud/nexus-home.d.ts.map +1 -0
  40. package/dist/cloud/nexus-home.js +97 -0
  41. package/dist/cloud/nexus-home.js.map +1 -0
  42. package/dist/cloud/nexus-link.d.ts +8 -1
  43. package/dist/cloud/nexus-link.d.ts.map +1 -1
  44. package/dist/cloud/nexus-link.js +138 -11
  45. package/dist/cloud/nexus-link.js.map +1 -1
  46. package/dist/cloud/nexus-logout.d.ts +114 -0
  47. package/dist/cloud/nexus-logout.d.ts.map +1 -0
  48. package/dist/cloud/nexus-logout.js +429 -0
  49. package/dist/cloud/nexus-logout.js.map +1 -0
  50. package/dist/cloud/nexus-vault-keys.d.ts +129 -0
  51. package/dist/cloud/nexus-vault-keys.d.ts.map +1 -0
  52. package/dist/cloud/nexus-vault-keys.js +277 -0
  53. package/dist/cloud/nexus-vault-keys.js.map +1 -0
  54. package/dist/cloud/nexus-vault-state.d.ts +121 -0
  55. package/dist/cloud/nexus-vault-state.d.ts.map +1 -0
  56. package/dist/cloud/nexus-vault-state.js +274 -0
  57. package/dist/cloud/nexus-vault-state.js.map +1 -0
  58. package/dist/cloud/nexus-vault.d.ts +160 -0
  59. package/dist/cloud/nexus-vault.d.ts.map +1 -0
  60. package/dist/cloud/nexus-vault.js +1733 -0
  61. package/dist/cloud/nexus-vault.js.map +1 -0
  62. package/dist/cloud/signing.d.ts +24 -8
  63. package/dist/cloud/signing.d.ts.map +1 -1
  64. package/dist/cloud/signing.js +61 -15
  65. package/dist/cloud/signing.js.map +1 -1
  66. package/dist/docs/export-document.js +8341 -3317
  67. package/dist/docs/export-document.js.map +3 -3
  68. package/dist/doctor/migrations.d.ts +75 -0
  69. package/dist/doctor/migrations.d.ts.map +1 -0
  70. package/dist/doctor/migrations.js +136 -0
  71. package/dist/doctor/migrations.js.map +1 -0
  72. package/dist/doctor/sync-sealer.d.ts +48 -0
  73. package/dist/doctor/sync-sealer.d.ts.map +1 -0
  74. package/dist/doctor/sync-sealer.js +109 -0
  75. package/dist/doctor/sync-sealer.js.map +1 -0
  76. package/dist/doctor/sync-triggers.d.ts +53 -0
  77. package/dist/doctor/sync-triggers.d.ts.map +1 -0
  78. package/dist/doctor/sync-triggers.js +157 -0
  79. package/dist/doctor/sync-triggers.js.map +1 -0
  80. package/dist/init.d.ts.map +1 -1
  81. package/dist/init.js +5 -1
  82. package/dist/init.js.map +1 -1
  83. package/dist/internal.d.ts +1 -1
  84. package/dist/internal.d.ts.map +1 -1
  85. package/dist/internal.js +1 -1
  86. package/dist/internal.js.map +1 -1
  87. package/dist/llm/plugin-facade.js +8668 -3644
  88. package/dist/llm/plugin-facade.js.map +3 -3
  89. package/dist/nexus/projects-clean.d.ts +3 -0
  90. package/dist/nexus/projects-clean.d.ts.map +1 -1
  91. package/dist/nexus/projects-clean.js +9 -3
  92. package/dist/nexus/projects-clean.js.map +1 -1
  93. package/dist/nexus/registry-roots.d.ts +3 -1
  94. package/dist/nexus/registry-roots.d.ts.map +1 -1
  95. package/dist/nexus/registry-roots.js +5 -2
  96. package/dist/nexus/registry-roots.js.map +1 -1
  97. package/dist/nexus/registry.d.ts +8 -1
  98. package/dist/nexus/registry.d.ts.map +1 -1
  99. package/dist/nexus/registry.js +24 -10
  100. package/dist/nexus/registry.js.map +1 -1
  101. package/dist/nexus/workspace.d.ts +4 -1
  102. package/dist/nexus/workspace.d.ts.map +1 -1
  103. package/dist/nexus/workspace.js +10 -4
  104. package/dist/nexus/workspace.js.map +1 -1
  105. package/dist/orchestrate/spawn-ops.d.ts.map +1 -1
  106. package/dist/orchestrate/spawn-ops.js +7 -2
  107. package/dist/orchestrate/spawn-ops.js.map +1 -1
  108. package/dist/orchestrate/worker-verify.d.ts +121 -12
  109. package/dist/orchestrate/worker-verify.d.ts.map +1 -1
  110. package/dist/orchestrate/worker-verify.js +172 -21
  111. package/dist/orchestrate/worker-verify.js.map +1 -1
  112. package/dist/orchestration/spawn-prompt.d.ts.map +1 -1
  113. package/dist/orchestration/spawn-prompt.js +15 -9
  114. package/dist/orchestration/spawn-prompt.js.map +1 -1
  115. package/dist/release/ci-evidence.d.ts +9 -0
  116. package/dist/release/ci-evidence.d.ts.map +1 -1
  117. package/dist/release/ci-evidence.js +9 -2
  118. package/dist/release/ci-evidence.js.map +1 -1
  119. package/dist/resources/backend.d.ts +15 -3
  120. package/dist/resources/backend.d.ts.map +1 -1
  121. package/dist/resources/backend.js +7 -3
  122. package/dist/resources/backend.js.map +1 -1
  123. package/dist/resources/darwin-backend.d.ts +142 -0
  124. package/dist/resources/darwin-backend.d.ts.map +1 -0
  125. package/dist/resources/darwin-backend.js +288 -0
  126. package/dist/resources/darwin-backend.js.map +1 -0
  127. package/dist/resources/governor.d.ts +44 -1
  128. package/dist/resources/governor.d.ts.map +1 -1
  129. package/dist/resources/governor.js +100 -36
  130. package/dist/resources/governor.js.map +1 -1
  131. package/dist/resources/heavy-command.d.ts +132 -0
  132. package/dist/resources/heavy-command.d.ts.map +1 -0
  133. package/dist/resources/heavy-command.js +768 -0
  134. package/dist/resources/heavy-command.js.map +1 -0
  135. package/dist/resources/monitor.d.ts +50 -1
  136. package/dist/resources/monitor.d.ts.map +1 -1
  137. package/dist/resources/monitor.js +83 -1
  138. package/dist/resources/monitor.js.map +1 -1
  139. package/dist/resources/run-admission.d.ts +303 -0
  140. package/dist/resources/run-admission.d.ts.map +1 -0
  141. package/dist/resources/run-admission.js +648 -0
  142. package/dist/resources/run-admission.js.map +1 -0
  143. package/dist/resources/run-class.d.ts +111 -0
  144. package/dist/resources/run-class.d.ts.map +1 -0
  145. package/dist/resources/run-class.js +658 -0
  146. package/dist/resources/run-class.js.map +1 -0
  147. package/dist/resources/run-governed.d.ts +158 -0
  148. package/dist/resources/run-governed.d.ts.map +1 -0
  149. package/dist/resources/run-governed.js +406 -0
  150. package/dist/resources/run-governed.js.map +1 -0
  151. package/dist/resources/slot-holder.d.ts +267 -0
  152. package/dist/resources/slot-holder.d.ts.map +1 -0
  153. package/dist/resources/slot-holder.js +505 -0
  154. package/dist/resources/slot-holder.js.map +1 -0
  155. package/dist/resources/tool-groups.d.ts +74 -0
  156. package/dist/resources/tool-groups.d.ts.map +1 -0
  157. package/dist/resources/tool-groups.js +118 -0
  158. package/dist/resources/tool-groups.js.map +1 -0
  159. package/dist/routing/build-command-groups.d.ts.map +1 -1
  160. package/dist/routing/build-command-groups.js +1 -0
  161. package/dist/routing/build-command-groups.js.map +1 -1
  162. package/dist/selfimprove/fix-gen.js +8676 -3652
  163. package/dist/selfimprove/fix-gen.js.map +3 -3
  164. package/dist/sentient/cross-project-hygiene.d.ts +3 -2
  165. package/dist/sentient/cross-project-hygiene.d.ts.map +1 -1
  166. package/dist/sentient/cross-project-hygiene.js +5 -2
  167. package/dist/sentient/cross-project-hygiene.js.map +1 -1
  168. package/dist/sentient/state.d.ts +7 -0
  169. package/dist/sentient/state.d.ts.map +1 -1
  170. package/dist/sentient/state.js.map +1 -1
  171. package/dist/sentient/tick.d.ts +14 -2
  172. package/dist/sentient/tick.d.ts.map +1 -1
  173. package/dist/sentient/tick.js +63 -4
  174. package/dist/sentient/tick.js.map +1 -1
  175. package/dist/setup/sections/nexus-account.d.ts +8 -6
  176. package/dist/setup/sections/nexus-account.d.ts.map +1 -1
  177. package/dist/setup/sections/nexus-account.js +53 -9
  178. package/dist/setup/sections/nexus-account.js.map +1 -1
  179. package/dist/store/backup-recover.d.ts.map +1 -1
  180. package/dist/store/backup-recover.js +5 -0
  181. package/dist/store/backup-recover.js.map +1 -1
  182. package/dist/store/data-accessor.d.ts +1 -0
  183. package/dist/store/data-accessor.d.ts.map +1 -1
  184. package/dist/store/data-accessor.js +7 -0
  185. package/dist/store/data-accessor.js.map +1 -1
  186. package/dist/store/dual-scope-db.d.ts +23 -1
  187. package/dist/store/dual-scope-db.d.ts.map +1 -1
  188. package/dist/store/dual-scope-db.js +126 -36
  189. package/dist/store/dual-scope-db.js.map +1 -1
  190. package/dist/store/exodus/recovery.d.ts.map +1 -1
  191. package/dist/store/exodus/recovery.js +15 -0
  192. package/dist/store/exodus/recovery.js.map +1 -1
  193. package/dist/store/legacy-tasks-lineage.d.ts.map +1 -1
  194. package/dist/store/legacy-tasks-lineage.js +5 -0
  195. package/dist/store/legacy-tasks-lineage.js.map +1 -1
  196. package/dist/store/lock.d.ts +8 -1
  197. package/dist/store/lock.d.ts.map +1 -1
  198. package/dist/store/lock.js +10 -2
  199. package/dist/store/lock.js.map +1 -1
  200. package/dist/store/migration-manager.d.ts +5 -0
  201. package/dist/store/migration-manager.d.ts.map +1 -1
  202. package/dist/store/migration-manager.js +11 -0
  203. package/dist/store/migration-manager.js.map +1 -1
  204. package/dist/store/migration-runner.d.ts +158 -0
  205. package/dist/store/migration-runner.d.ts.map +1 -0
  206. package/dist/store/migration-runner.js +493 -0
  207. package/dist/store/migration-runner.js.map +1 -0
  208. package/dist/store/portable-bundle-import.d.ts +15 -1
  209. package/dist/store/portable-bundle-import.d.ts.map +1 -1
  210. package/dist/store/portable-bundle-import.js +24 -4
  211. package/dist/store/portable-bundle-import.js.map +1 -1
  212. package/dist/store/portable-bundle-relocate.d.ts +43 -0
  213. package/dist/store/portable-bundle-relocate.d.ts.map +1 -1
  214. package/dist/store/portable-bundle-relocate.js +79 -5
  215. package/dist/store/portable-bundle-relocate.js.map +1 -1
  216. package/dist/store/portable-bundle-scan.d.ts +20 -0
  217. package/dist/store/portable-bundle-scan.d.ts.map +1 -1
  218. package/dist/store/portable-bundle-scan.js +38 -3
  219. package/dist/store/portable-bundle-scan.js.map +1 -1
  220. package/dist/store/portable-bundle.d.ts +33 -0
  221. package/dist/store/portable-bundle.d.ts.map +1 -1
  222. package/dist/store/portable-bundle.js +34 -7
  223. package/dist/store/portable-bundle.js.map +1 -1
  224. package/dist/store/row-identity-registry.d.ts +137 -7
  225. package/dist/store/row-identity-registry.d.ts.map +1 -1
  226. package/dist/store/row-identity-registry.js +364 -9
  227. package/dist/store/row-identity-registry.js.map +1 -1
  228. package/dist/store/row-identity.d.ts.map +1 -1
  229. package/dist/store/row-identity.js +9 -10
  230. package/dist/store/row-identity.js.map +1 -1
  231. package/dist/store/sqlite-data-accessor.d.ts.map +1 -1
  232. package/dist/store/sqlite-data-accessor.js +10 -0
  233. package/dist/store/sqlite-data-accessor.js.map +1 -1
  234. package/dist/store/sqlite.d.ts +31 -0
  235. package/dist/store/sqlite.d.ts.map +1 -1
  236. package/dist/store/sqlite.js +5 -1
  237. package/dist/store/sqlite.js.map +1 -1
  238. package/dist/store/sync/capture.d.ts +203 -0
  239. package/dist/store/sync/capture.d.ts.map +1 -0
  240. package/dist/store/sync/capture.js +562 -0
  241. package/dist/store/sync/capture.js.map +1 -0
  242. package/dist/store/sync/clock-store.d.ts.map +1 -1
  243. package/dist/store/sync/clock-store.js +2 -0
  244. package/dist/store/sync/clock-store.js.map +1 -1
  245. package/dist/store/sync/fk-orphans.d.ts +133 -0
  246. package/dist/store/sync/fk-orphans.d.ts.map +1 -0
  247. package/dist/store/sync/fk-orphans.js +265 -0
  248. package/dist/store/sync/fk-orphans.js.map +1 -0
  249. package/dist/store/sync/flags.d.ts +7 -0
  250. package/dist/store/sync/flags.d.ts.map +1 -1
  251. package/dist/store/sync/flags.js +16 -0
  252. package/dist/store/sync/flags.js.map +1 -1
  253. package/dist/store/sync/hlc.d.ts.map +1 -1
  254. package/dist/store/sync/hlc.js +4 -0
  255. package/dist/store/sync/hlc.js.map +1 -1
  256. package/dist/store/sync/identity-fill.d.ts +45 -0
  257. package/dist/store/sync/identity-fill.d.ts.map +1 -0
  258. package/dist/store/sync/identity-fill.js +85 -0
  259. package/dist/store/sync/identity-fill.js.map +1 -0
  260. package/dist/store/sync/machinery.d.ts +27 -0
  261. package/dist/store/sync/machinery.d.ts.map +1 -0
  262. package/dist/store/sync/machinery.js +44 -0
  263. package/dist/store/sync/machinery.js.map +1 -0
  264. package/dist/store/sync/netting.d.ts +120 -0
  265. package/dist/store/sync/netting.d.ts.map +1 -0
  266. package/dist/store/sync/netting.js +336 -0
  267. package/dist/store/sync/netting.js.map +1 -0
  268. package/dist/store/sync/replica.d.ts +59 -3
  269. package/dist/store/sync/replica.d.ts.map +1 -1
  270. package/dist/store/sync/replica.js +84 -3
  271. package/dist/store/sync/replica.js.map +1 -1
  272. package/dist/store/sync/schema.d.ts +18 -3
  273. package/dist/store/sync/schema.d.ts.map +1 -1
  274. package/dist/store/sync/schema.js +27 -3
  275. package/dist/store/sync/schema.js.map +1 -1
  276. package/dist/store/sync/seal-backlog.d.ts +21 -0
  277. package/dist/store/sync/seal-backlog.d.ts.map +1 -0
  278. package/dist/store/sync/seal-backlog.js +24 -0
  279. package/dist/store/sync/seal-backlog.js.map +1 -0
  280. package/dist/store/sync/sealer-values.d.ts +34 -0
  281. package/dist/store/sync/sealer-values.d.ts.map +1 -0
  282. package/dist/store/sync/sealer-values.js +53 -0
  283. package/dist/store/sync/sealer-values.js.map +1 -0
  284. package/dist/store/sync/sealer.d.ts +145 -0
  285. package/dist/store/sync/sealer.d.ts.map +1 -0
  286. package/dist/store/sync/sealer.js +906 -0
  287. package/dist/store/sync/sealer.js.map +1 -0
  288. package/dist/store/sync/structural.d.ts +63 -0
  289. package/dist/store/sync/structural.d.ts.map +1 -0
  290. package/dist/store/sync/structural.js +180 -0
  291. package/dist/store/sync/structural.js.map +1 -0
  292. package/dist/store/sync/timestamps.d.ts +92 -0
  293. package/dist/store/sync/timestamps.d.ts.map +1 -0
  294. package/dist/store/sync/timestamps.js +228 -0
  295. package/dist/store/sync/timestamps.js.map +1 -0
  296. package/dist/store/sync/tombstones.d.ts +75 -0
  297. package/dist/store/sync/tombstones.d.ts.map +1 -0
  298. package/dist/store/sync/tombstones.js +103 -0
  299. package/dist/store/sync/tombstones.js.map +1 -0
  300. package/dist/store/sync/trigger-classes.d.ts +221 -0
  301. package/dist/store/sync/trigger-classes.d.ts.map +1 -0
  302. package/dist/store/sync/trigger-classes.js +441 -0
  303. package/dist/store/sync/trigger-classes.js.map +1 -0
  304. package/dist/store/sync/trigger-suspend-at-path.d.ts +23 -0
  305. package/dist/store/sync/trigger-suspend-at-path.d.ts.map +1 -0
  306. package/dist/store/sync/trigger-suspend-at-path.js +44 -0
  307. package/dist/store/sync/trigger-suspend-at-path.js.map +1 -0
  308. package/dist/store/sync/writer-version.d.ts +43 -0
  309. package/dist/store/sync/writer-version.d.ts.map +1 -0
  310. package/dist/store/sync/writer-version.js +90 -0
  311. package/dist/store/sync/writer-version.js.map +1 -0
  312. package/dist/store/table-classification.d.ts.map +1 -1
  313. package/dist/store/table-classification.js +102 -0
  314. package/dist/store/table-classification.js.map +1 -1
  315. package/dist/store/trigger-suspend-schema.d.ts +44 -0
  316. package/dist/store/trigger-suspend-schema.d.ts.map +1 -0
  317. package/dist/store/trigger-suspend-schema.js +25 -0
  318. package/dist/store/trigger-suspend-schema.js.map +1 -0
  319. package/dist/store/vault-manifest.d.ts +365 -0
  320. package/dist/store/vault-manifest.d.ts.map +1 -0
  321. package/dist/store/vault-manifest.js +812 -0
  322. package/dist/store/vault-manifest.js.map +1 -0
  323. package/dist/store/writer-lease.d.ts +31 -0
  324. package/dist/store/writer-lease.d.ts.map +1 -1
  325. package/dist/store/writer-lease.js +65 -2
  326. package/dist/store/writer-lease.js.map +1 -1
  327. package/dist/system/health.d.ts.map +1 -1
  328. package/dist/system/health.js +21 -0
  329. package/dist/system/health.js.map +1 -1
  330. package/dist/system/project-health.d.ts.map +1 -1
  331. package/dist/system/project-health.js +3 -1
  332. package/dist/system/project-health.js.map +1 -1
  333. package/dist/tasks/affected-packages.d.ts +58 -0
  334. package/dist/tasks/affected-packages.d.ts.map +1 -1
  335. package/dist/tasks/affected-packages.js +75 -6
  336. package/dist/tasks/affected-packages.js.map +1 -1
  337. package/dist/tasks/affected-scope.d.ts +150 -23
  338. package/dist/tasks/affected-scope.d.ts.map +1 -1
  339. package/dist/tasks/affected-scope.js +320 -32
  340. package/dist/tasks/affected-scope.js.map +1 -1
  341. package/dist/tasks/change-set.d.ts +96 -0
  342. package/dist/tasks/change-set.d.ts.map +1 -1
  343. package/dist/tasks/change-set.js +169 -4
  344. package/dist/tasks/change-set.js.map +1 -1
  345. package/dist/tasks/complete-ci.d.ts +115 -0
  346. package/dist/tasks/complete-ci.d.ts.map +1 -0
  347. package/dist/tasks/complete-ci.js +171 -0
  348. package/dist/tasks/complete-ci.js.map +1 -0
  349. package/dist/tasks/complete.d.ts.map +1 -1
  350. package/dist/tasks/complete.js +50 -17
  351. package/dist/tasks/complete.js.map +1 -1
  352. package/dist/tasks/compute-task-view.d.ts.map +1 -1
  353. package/dist/tasks/compute-task-view.js +7 -0
  354. package/dist/tasks/compute-task-view.js.map +1 -1
  355. package/dist/tasks/done-plan.d.ts.map +1 -1
  356. package/dist/tasks/done-plan.js +51 -30
  357. package/dist/tasks/done-plan.js.map +1 -1
  358. package/dist/tasks/done-record.d.ts +6 -0
  359. package/dist/tasks/done-record.d.ts.map +1 -1
  360. package/dist/tasks/done-record.js +9 -3
  361. package/dist/tasks/done-record.js.map +1 -1
  362. package/dist/tasks/evidence.d.ts +3 -2
  363. package/dist/tasks/evidence.d.ts.map +1 -1
  364. package/dist/tasks/evidence.js +143 -12
  365. package/dist/tasks/evidence.js.map +1 -1
  366. package/dist/tasks/gate-notes.d.ts +22 -0
  367. package/dist/tasks/gate-notes.d.ts.map +1 -0
  368. package/dist/tasks/gate-notes.js +33 -0
  369. package/dist/tasks/gate-notes.js.map +1 -0
  370. package/dist/tasks/index.d.ts +2 -1
  371. package/dist/tasks/index.d.ts.map +1 -1
  372. package/dist/tasks/index.js +2 -1
  373. package/dist/tasks/index.js.map +1 -1
  374. package/dist/tasks/test-run-binding.d.ts +117 -0
  375. package/dist/tasks/test-run-binding.d.ts.map +1 -0
  376. package/dist/tasks/test-run-binding.js +365 -0
  377. package/dist/tasks/test-run-binding.js.map +1 -0
  378. package/dist/tasks/tool-cache-env.d.ts +123 -0
  379. package/dist/tasks/tool-cache-env.d.ts.map +1 -0
  380. package/dist/tasks/tool-cache-env.js +287 -0
  381. package/dist/tasks/tool-cache-env.js.map +1 -0
  382. package/dist/tasks/tool-cache-failed-first.d.ts +155 -0
  383. package/dist/tasks/tool-cache-failed-first.d.ts.map +1 -0
  384. package/dist/tasks/tool-cache-failed-first.js +285 -0
  385. package/dist/tasks/tool-cache-failed-first.js.map +1 -0
  386. package/dist/tasks/tool-cache.d.ts +375 -55
  387. package/dist/tasks/tool-cache.d.ts.map +1 -1
  388. package/dist/tasks/tool-cache.js +912 -303
  389. package/dist/tasks/tool-cache.js.map +1 -1
  390. package/dist/tasks/tool-resolver.d.ts +4 -3
  391. package/dist/tasks/tool-resolver.d.ts.map +1 -1
  392. package/dist/tasks/tool-resolver.js +15 -4
  393. package/dist/tasks/tool-resolver.js.map +1 -1
  394. package/dist/tasks/tool-semaphore.d.ts +67 -7
  395. package/dist/tasks/tool-semaphore.d.ts.map +1 -1
  396. package/dist/tasks/tool-semaphore.js +134 -56
  397. package/dist/tasks/tool-semaphore.js.map +1 -1
  398. package/dist/upgrade.d.ts.map +1 -1
  399. package/dist/upgrade.js +4 -0
  400. package/dist/upgrade.js.map +1 -1
  401. package/dist/validation/engine-ops.d.ts +6 -0
  402. package/dist/validation/engine-ops.d.ts.map +1 -1
  403. package/dist/validation/engine-ops.js +8 -0
  404. package/dist/validation/engine-ops.js.map +1 -1
  405. package/migrations/drizzle-cleo-project/20260930170000_t12819-trigger-suspend-clause/migration.sql +367 -0
  406. package/migrations/sync-journal/20260930120000_t12343-capture/migration.sql +47 -0
  407. package/migrations/sync-journal/20261001170000_t12984-sealer/migration.sql +101 -0
  408. package/package.json +13 -13
  409. package/templates/CLEO-INJECTION.md +5 -5
  410. package/templates/CLEO-REFERENCE.md +8 -4
@@ -0,0 +1,429 @@
1
+ /**
2
+ * Cleo Nexus device logout: `cleo logout nexus [--revoke]` with device
3
+ * credentials (cleo-nexus device contract §3.5, review M3, T12844).
4
+ *
5
+ * A logout never reports success while a credential may still be live:
6
+ *
7
+ * 1. Under the lock, the live credentials move into `pendingSignOut`
8
+ * (`--revoke`: `pendingRevoke`), newest first: `pending`, then `current`
9
+ * ({@link applyBeginSignOut}, {@link applyBeginRevoke}). From then on they
10
+ * are used for nothing but that request. The lock is released.
11
+ * 2. E9 (`POST /v1/devices/self/sign-out`) or E10 (`DELETE /v1/devices/self`)
12
+ * is sent with each credential in turn, newest first, with one attempt and
13
+ * a {@link NEXUS_REVOKE_TIMEOUT_MS} timeout.
14
+ * 3. Done means proved: 200, or a 401 whose reason proves the device state
15
+ * (`device-signed-out`, `device-revoked`, or `credential-revoked` with
16
+ * `revokedReason` `signed-out` / `revoked`). A revoke needs proof of a
17
+ * revoke; a signed-out device is not a revoked one. Any other 401 means
18
+ * that credential is dead, so the next one is tried. A network error,
19
+ * timeout, 429, 5xx or a route the server does not have yet stops the run:
20
+ * the slot is kept and every remaining request is left for the next run
21
+ * without another call.
22
+ * 4. The lock is re-taken and the slot is changed only if it still holds the
23
+ * credential that was answered (compare-and-swap):
24
+ * - a sign-out (confirmed, or every credential dead) clears
25
+ * `pendingSignOut` and keeps the device keys for the next login;
26
+ * - a revoke that ended (confirmed, found the device signed out, or every
27
+ * credential dead) forgets the device locally ({@link applyForgetDevice}),
28
+ * so no later login re-activates the id the user asked to burn. The
29
+ * entry is deleted, or kept stripped while `retired` requests of other
30
+ * devices remain; the store keeps the file while other entries remain.
31
+ * Only a confirmed request is reported `confirmed`; the others name the
32
+ * web remedy.
33
+ *
34
+ * Unsettled slots, and the `retired` requests of replaced devices, are
35
+ * retried by every later logout and, best effort with a shorter timeout, by
36
+ * `cleo login nexus` and `cleo project link` ({@link retryNexusDeviceEnds}).
37
+ * Retired requests are sent before the entry's own request.
38
+ *
39
+ * No function here logs, and no result or error carries a token.
40
+ *
41
+ * @task T12870
42
+ * @epic T12323
43
+ */
44
+ import { z } from 'zod';
45
+ import { Http, NexusError } from './http.js';
46
+ import { logoutFromNexus, NEXUS_REVOKE_TIMEOUT_MS, resolveNexusApiUrl } from './nexus-auth.js';
47
+ import { FileNexusTokenStore, nexusOriginKey } from './nexus-credentials.js';
48
+ import { applyBeginRevoke, applyBeginSignOut, applyForgetDevice, applyRetiredSettled, applySignOutConfirmed, isForgottenDevice, NexusDeviceStore, UnreadableNexusDevice, } from './nexus-device.js';
49
+ /**
50
+ * Timeout of each E9/E10 call when a login or a link only retries on the way
51
+ * ({@link retryNexusDeviceEnds}); an explicit logout uses {@link NEXUS_REVOKE_TIMEOUT_MS}.
52
+ */
53
+ export const NEXUS_END_RETRY_TIMEOUT_MS = 2_000;
54
+ function context(opts) {
55
+ const apiUrl = resolveNexusApiUrl(opts.apiUrl);
56
+ return {
57
+ apiUrl,
58
+ origin: nexusOriginKey(apiUrl),
59
+ fetch: opts.fetch ?? ((input, init) => globalThis.fetch(input, init)),
60
+ devices: opts.deviceStore ?? new NexusDeviceStore(),
61
+ now: opts.now ?? (() => new Date()),
62
+ timeoutMs: opts.timeoutMs ?? NEXUS_REVOKE_TIMEOUT_MS,
63
+ };
64
+ }
65
+ /** E9 answers `{ deviceId, state }`; E10 answers `{ revoked }`. Only the status matters. */
66
+ const endAnswerSchema = z.looseObject({});
67
+ /**
68
+ * What a 401 proves about the device (§4.0.4): `revoked`, `signed-out`, or
69
+ * nothing (`null`: only this credential is dead).
70
+ */
71
+ function provenState(details) {
72
+ const reason = details?.['reason'];
73
+ const revokedReason = details?.['revokedReason'];
74
+ if (reason === 'device-revoked')
75
+ return 'revoked';
76
+ if (reason === 'device-signed-out')
77
+ return 'signed-out';
78
+ if (reason === 'credential-revoked' && revokedReason === 'revoked')
79
+ return 'revoked';
80
+ if (reason === 'credential-revoked' && revokedReason === 'signed-out')
81
+ return 'signed-out';
82
+ return null;
83
+ }
84
+ /**
85
+ * Send E9 or E10 with one credential: one attempt, a plain timeout, no lock held.
86
+ *
87
+ * @returns `done` for 200 or a 401 that proves the requested state,
88
+ * `signed-out` for a revoke that proves only a sign-out, `stale` for any
89
+ * other 401, `unanswered` for everything else, with the reason in `detail`.
90
+ */
91
+ async function callEnd(ctx, action, token) {
92
+ const timed = (input, init) => ctx.fetch(input, { ...init, signal: AbortSignal.timeout(ctx.timeoutMs) });
93
+ const http = new Http({ baseUrl: ctx.apiUrl, token, fetch: timed, maxAttempts: 1 });
94
+ try {
95
+ if (action === 'sign-out') {
96
+ await http.request('POST', '/v1/devices/self/sign-out', endAnswerSchema, {});
97
+ }
98
+ else {
99
+ await http.request('DELETE', '/v1/devices/self', endAnswerSchema);
100
+ }
101
+ return { answer: 'done', detail: 'HTTP 200' };
102
+ }
103
+ catch (err) {
104
+ if (!(err instanceof NexusError)) {
105
+ return {
106
+ answer: 'unanswered',
107
+ detail: err instanceof Error ? err.message : String(err),
108
+ transport: true,
109
+ };
110
+ }
111
+ if (err.status === 401) {
112
+ const reason = err.details?.['reason'];
113
+ const detail = `HTTP 401 ${typeof reason === 'string' ? reason : err.code}`;
114
+ const state = provenState(err.details);
115
+ if (state === 'revoked' || (state === 'signed-out' && action === 'sign-out')) {
116
+ return { answer: 'done', detail };
117
+ }
118
+ if (state === 'signed-out')
119
+ return { answer: 'signed-out', detail };
120
+ // Only the Nexus API's own verdict on this credential counts as dead. A
121
+ // 401 without its envelope (a proxy or SSO gateway) or with reason
122
+ // `missing` (an Authorization header stripped on the way) proves
123
+ // nothing about the credential, so it is treated as no answer.
124
+ const dead = err.code === 'E_UNAUTHENTICATED' &&
125
+ (reason === 'invalid' ||
126
+ reason === 'credential-expired' ||
127
+ reason === 'credential-revoked');
128
+ return { answer: dead ? 'stale' : 'unanswered', detail };
129
+ }
130
+ return {
131
+ answer: 'unanswered',
132
+ detail: err.code === 'E_NETWORK' ? 'no answer' : `HTTP ${err.status} ${err.code}`,
133
+ transport: err.code === 'E_NETWORK',
134
+ };
135
+ }
136
+ }
137
+ /** Every unsettled request of one entry: its `retired` items first, then its own slot. */
138
+ function requestsOf(userId, entry) {
139
+ const out = [];
140
+ for (const r of entry.retired ?? []) {
141
+ out.push({
142
+ userId,
143
+ deviceId: r.deviceId,
144
+ action: r.kind,
145
+ retired: true,
146
+ credentials: r.credentials,
147
+ });
148
+ }
149
+ const own = entry.pendingRevoke ?? entry.pendingSignOut;
150
+ if (own) {
151
+ out.push({
152
+ userId,
153
+ deviceId: entry.deviceId,
154
+ action: entry.pendingRevoke ? 'revoke' : 'sign-out',
155
+ retired: false,
156
+ credentials: own.credentials,
157
+ });
158
+ }
159
+ return out;
160
+ }
161
+ /** The credentials a request's slot holds now, or `null` when the slot is gone. */
162
+ function slotNow(entry, req) {
163
+ if (entry === null)
164
+ return null;
165
+ if (req.retired) {
166
+ const item = (entry.retired ?? []).find((r) => r.deviceId === req.deviceId && r.kind === req.action);
167
+ return item ? item.credentials : null;
168
+ }
169
+ if (entry.deviceId !== req.deviceId)
170
+ return null;
171
+ const slot = req.action === 'revoke' ? entry.pendingRevoke : entry.pendingSignOut;
172
+ return slot ? slot.credentials : null;
173
+ }
174
+ /**
175
+ * End a request under the lock, only if its slot still holds `token` (CAS):
176
+ * clear a sign-out slot, settle a retired item, or forget the device after a
177
+ * revoke. An entry left with nothing to keep is deleted.
178
+ */
179
+ async function settleEnded(ctx, req, token) {
180
+ return ctx.devices.update((tx) => {
181
+ const entry = tx.get(ctx.apiUrl, req.userId);
182
+ const creds = slotNow(entry, req);
183
+ if (entry === null || creds === null || !creds.some((c) => c.token === token)) {
184
+ return { applied: false, removed: false };
185
+ }
186
+ const next = req.retired
187
+ ? applyRetiredSettled(entry, req.deviceId, req.action)
188
+ : req.action === 'sign-out'
189
+ ? applySignOutConfirmed(entry)
190
+ : applyForgetDevice(entry);
191
+ if (isForgottenDevice(next)) {
192
+ const removed = tx.delete(ctx.apiUrl, req.userId, {
193
+ deviceId: entry.deviceId,
194
+ credentialId: entry.current?.credentialId ?? null,
195
+ });
196
+ return { applied: true, removed };
197
+ }
198
+ tx.set(ctx.apiUrl, req.userId, next);
199
+ return { applied: true, removed: false };
200
+ });
201
+ }
202
+ /** Try each credential of one request, newest first, and end it when it can be ended. */
203
+ async function settleRequest(ctx, req, warnings) {
204
+ const row = (outcome, removedLocally = false) => ({
205
+ userId: req.userId,
206
+ deviceId: req.deviceId,
207
+ action: req.action,
208
+ retired: req.retired,
209
+ outcome,
210
+ removedLocally,
211
+ });
212
+ const what = `${req.action === 'revoke' ? 'revoke' : 'sign-out'} of device ${req.deviceId}`;
213
+ const web = req.action === 'revoke'
214
+ ? `revoke device ${req.deviceId} on cleocode.dev (Devices)`
215
+ : `sign out or revoke device ${req.deviceId} on cleocode.dev (Devices)`;
216
+ const end = async (token, outcome, note) => {
217
+ const settled = await settleEnded(ctx, req, token);
218
+ if (!settled.applied) {
219
+ warnings.push(`${what}: the local entry changed while the request was in flight (a login or another logout?); this machine may hold a newer credential. Run \`cleo logout nexus${req.action === 'revoke' ? ' --revoke' : ''}\` again`);
220
+ }
221
+ else if (note !== null) {
222
+ warnings.push(note);
223
+ }
224
+ return row(outcome, settled.removed);
225
+ };
226
+ for (const c of req.credentials) {
227
+ const { answer, detail, transport } = await callEnd(ctx, req.action, c.token);
228
+ if (answer === 'done')
229
+ return { row: await end(c.token, 'confirmed', null), unreachable: false };
230
+ if (answer === 'signed-out') {
231
+ const signedOut = await end(c.token, 'signed-out', `device ${req.deviceId} is signed out but not revoked, and a signed-out device's credentials cannot revoke it; this machine forgot the device, so the next login enrols a new one. To burn the old id, ${web}`);
232
+ return { row: signedOut, unreachable: false };
233
+ }
234
+ if (answer === 'unanswered') {
235
+ warnings.push(`${what} not confirmed (${detail}); it was kept and is retried by the next \`cleo logout nexus\`, \`cleo login nexus\` or \`cleo project link\``);
236
+ return { row: row('pending'), unreachable: transport === true };
237
+ }
238
+ }
239
+ // Every credential is dead: retrying can never succeed, so the request ends here.
240
+ const first = req.credentials[0];
241
+ if (first === undefined)
242
+ return { row: row('unconfirmed'), unreachable: false };
243
+ const ended = await end(first.token, 'unconfirmed', `${what} not confirmed: the server refused every credential this machine held for it as no longer valid, so none is live and none was kept${req.action === 'revoke' && !req.retired ? '; this machine forgot the device' : ''}. To make sure, ${web}`);
244
+ return { row: ended, unreachable: false };
245
+ }
246
+ /** Every unsettled request on the origin, plus a warning per entry this machine cannot open. */
247
+ async function unsettled(ctx, warnings, warnUnreadable) {
248
+ const out = [];
249
+ for (const d of await ctx.devices.list()) {
250
+ if (d.origin !== ctx.origin)
251
+ continue;
252
+ if (d instanceof UnreadableNexusDevice) {
253
+ if (!warnUnreadable)
254
+ continue;
255
+ warnings.push(`the device entry for user ${d.userId}${d.deviceId ? ` (device ${d.deviceId})` : ''} cannot be opened on this machine (${d.reason}); sign it out or revoke it on cleocode.dev`);
256
+ continue;
257
+ }
258
+ out.push(...requestsOf(d.userId, d.unseal()));
259
+ }
260
+ return out;
261
+ }
262
+ /** Sort rows by user, then device, for a stable envelope. */
263
+ function byUserThenDevice(a, b) {
264
+ return a.userId.localeCompare(b.userId) || a.deviceId.localeCompare(b.deviceId);
265
+ }
266
+ /**
267
+ * Retry every unsettled sign-out and revoke on the origin (contract §3.5,
268
+ * L2): each entry's `pendingSignOut` or `pendingRevoke`, and the `retired`
269
+ * requests of devices it replaced. Never throws for a server that cannot be
270
+ * reached; the rows and warnings say what is still open.
271
+ *
272
+ * @param opts - API URL, stores and test overrides.
273
+ * @returns One row per request tried, and the warnings.
274
+ */
275
+ export async function settleNexusDeviceEnds(opts = {}) {
276
+ const ctx = context(opts);
277
+ const warnings = [];
278
+ const devices = [];
279
+ let unreachable = false;
280
+ let skipped = 0;
281
+ for (const req of await unsettled(ctx, warnings, opts.warnUnreadable ?? true)) {
282
+ if (unreachable) {
283
+ skipped += 1;
284
+ // The server already failed to answer in this run: leave the rest for
285
+ // the next run rather than wait out one timeout per request.
286
+ devices.push({
287
+ userId: req.userId,
288
+ deviceId: req.deviceId,
289
+ action: req.action,
290
+ retired: req.retired,
291
+ outcome: 'pending',
292
+ removedLocally: false,
293
+ });
294
+ continue;
295
+ }
296
+ try {
297
+ const r = await settleRequest(ctx, req, warnings);
298
+ // Only a transport failure (no answer at all) stops the run: an HTTP
299
+ // error on one request (a 404, 5xx or 429 for an old device) never
300
+ // keeps the entry's own sign-out or revoke from being sent.
301
+ if (r.unreachable)
302
+ unreachable = true;
303
+ devices.push(r.row);
304
+ }
305
+ catch (err) {
306
+ // A store failure on one request keeps every row collected so far.
307
+ warnings.push(`${req.action} of device ${req.deviceId} could not be settled locally (${err instanceof Error ? err.message : String(err)}); it is retried next time`);
308
+ devices.push({
309
+ userId: req.userId,
310
+ deviceId: req.deviceId,
311
+ action: req.action,
312
+ retired: req.retired,
313
+ outcome: 'pending',
314
+ removedLocally: false,
315
+ });
316
+ }
317
+ }
318
+ if (skipped > 0) {
319
+ warnings.push(`${skipped} more unsettled sign-out or revoke request(s) were not sent because Cleo Nexus did not answer; they are retried next time`);
320
+ }
321
+ return { devices: devices.sort(byUserThenDevice), warnings };
322
+ }
323
+ /**
324
+ * Best-effort {@link settleNexusDeviceEnds} for flows that only retry on the
325
+ * way (login, commands that need a credential): a store or network failure
326
+ * becomes a warning and never fails the caller.
327
+ *
328
+ * @param opts - API URL, stores and test overrides.
329
+ * @param warnings - Receives the warnings.
330
+ */
331
+ export async function retryNexusDeviceEnds(opts, warnings) {
332
+ try {
333
+ const settled = await settleNexusDeviceEnds({
334
+ timeoutMs: NEXUS_END_RETRY_TIMEOUT_MS,
335
+ ...opts,
336
+ warnUnreadable: false,
337
+ });
338
+ warnings.push(...settled.warnings);
339
+ }
340
+ catch (err) {
341
+ warnings.push(`could not retry an unsettled Cleo Nexus sign-out (${err instanceof Error ? err.message : String(err)}); \`cleo logout nexus\` retries it`);
342
+ }
343
+ }
344
+ /**
345
+ * Under the lock, move every readable entry on the origin into its
346
+ * sign-out or revoke slot. A revoke of an entry with no credential left
347
+ * (already signed out) cannot be sent, so the device is forgotten locally
348
+ * and the web remedy is returned.
349
+ *
350
+ * @returns Warnings for the result envelope.
351
+ */
352
+ async function beginEnds(ctx, action) {
353
+ const begin = action === 'revoke' ? applyBeginRevoke : applyBeginSignOut;
354
+ return ctx.devices.update((tx) => {
355
+ const notes = [];
356
+ for (const k of tx.keys()) {
357
+ if (k.origin !== ctx.origin || !k.readable)
358
+ continue;
359
+ const entry = tx.get(ctx.apiUrl, k.userId);
360
+ if (entry === null)
361
+ continue;
362
+ const next = begin(entry, ctx.now());
363
+ if (action === 'revoke' && next.pendingRevoke === null && next.keys !== null) {
364
+ const forgotten = applyForgetDevice(next);
365
+ if (isForgottenDevice(forgotten)) {
366
+ tx.delete(ctx.apiUrl, k.userId, { deviceId: entry.deviceId, credentialId: null });
367
+ }
368
+ else {
369
+ tx.set(ctx.apiUrl, k.userId, forgotten);
370
+ }
371
+ notes.push(`device ${next.deviceId} holds no credential (it is signed out), so it cannot be revoked from here; this machine forgot it, so the next login enrols a new device. To burn the old id, revoke device ${next.deviceId} on cleocode.dev (Devices)`);
372
+ continue;
373
+ }
374
+ tx.set(ctx.apiUrl, k.userId, next);
375
+ }
376
+ return [...tx.warnings, ...notes];
377
+ });
378
+ }
379
+ /**
380
+ * `cleo logout nexus [--revoke]` with device credentials (contract §3.5, M3).
381
+ *
382
+ * Every readable entry on the origin is moved to `pendingSignOut` (or
383
+ * `pendingRevoke`), then every unsettled request on the origin is sent,
384
+ * including ones left by earlier runs. A leftover 9.24 session for the origin
385
+ * is signed out too. The device keys stay after a sign-out, so a later login
386
+ * reuses the device id; a confirmed revoke removes the entry.
387
+ *
388
+ * @param opts - API URL, `revoke`, stores and test overrides.
389
+ * @returns The per-device outcomes. A row that is not `confirmed` is also
390
+ * named in `warnings`; the result never claims a sign-out the server did
391
+ * not confirm.
392
+ * A device file that cannot be read or locked is reported as a warning, and
393
+ * the 9.24 session is still signed out.
394
+ */
395
+ export async function logoutNexusDevice(opts = {}) {
396
+ const ctx = context(opts);
397
+ const action = opts.revoke === true ? 'revoke' : 'sign-out';
398
+ const warnings = [];
399
+ let devices = [];
400
+ try {
401
+ warnings.push(...(await beginEnds(ctx, action)));
402
+ const settled = await settleNexusDeviceEnds({
403
+ ...opts,
404
+ apiUrl: ctx.apiUrl,
405
+ deviceStore: ctx.devices,
406
+ });
407
+ devices = settled.devices;
408
+ warnings.push(...settled.warnings);
409
+ }
410
+ catch (err) {
411
+ // A broken device file must not stop the 9.24 session sign-out below.
412
+ warnings.push(`the device credentials could not be signed out (${err instanceof Error ? err.message : String(err)}); fix the device file and run \`cleo logout nexus\` again`);
413
+ }
414
+ let session = null;
415
+ const sessions = opts.store ?? new FileNexusTokenStore();
416
+ if ((await sessions.get(ctx.apiUrl)) !== null) {
417
+ session = await logoutFromNexus({
418
+ apiUrl: ctx.apiUrl,
419
+ store: sessions,
420
+ ...(opts.fetch ? { fetch: opts.fetch } : {}),
421
+ });
422
+ warnings.push(...session.warnings);
423
+ }
424
+ if (action === 'revoke' && devices.length === 0 && session !== null) {
425
+ warnings.push(`no device credential is stored for ${ctx.apiUrl}, so nothing was revoked; the 9.24 session was signed out`);
426
+ }
427
+ return { apiUrl: ctx.apiUrl, action, devices, session, warnings };
428
+ }
429
+ //# sourceMappingURL=nexus-logout.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nexus-logout.js","sourceRoot":"","sources":["../../src/cloud/nexus-logout.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AAQH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAkB,IAAI,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,uBAAuB,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAC/F,OAAO,EAAE,mBAAmB,EAAwB,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACnG,OAAO,EACL,gBAAgB,EAChB,iBAAiB,EACjB,i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CAAC,GAAG,CAAC,4DAA4D,CAChK,CAAC;IACJ,CAAC;IAED,IAAI,OAAO,GAA6B,IAAI,CAAC;IAC7C,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,IAAI,IAAI,mBAAmB,EAAE,CAAC;IACzD,IAAI,CAAC,MAAM,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,KAAK,IAAI,EAAE,CAAC;QAC9C,OAAO,GAAG,MAAM,eAAe,CAAC;YAC9B,MAAM,EAAE,GAAG,CAAC,MAAM;YAClB,KAAK,EAAE,QAAQ;YACf,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SAC7C,CAAC,CAAC;QACH,QAAQ,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;IACrC,CAAC;IACD,IAAI,MAAM,KAAK,QAAQ,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,IAAI,OAAO,KAAK,IAAI,EAAE,CAAC;QACpE,QAAQ,CAAC,IAAI,CACX,sCAAsC,GAAG,CAAC,MAAM,2DAA2D,CAC5G,CAAC;IACJ,CAAC;IACD,OAAO,EAAE,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC;AACpE,CAAC"}
@@ -0,0 +1,129 @@
1
+ /**
2
+ * The vault's connection and keys: a read-write device connection, the
3
+ * account master key, this device's certificate, and the stream data keys.
4
+ *
5
+ * Owner decision (2026-10-01): adding a device needs only `cleo login` and
6
+ * the one-time browser approval; that approval also hands the device the
7
+ * encryption key. So the account master key (MK) is escrowed on Cleo Nexus:
8
+ *
9
+ * 1. `GET /v1/account/keys/escrow` returns MK sealed to this device's X25519
10
+ * key (`sealTo`), released only to an approved, active device. The client
11
+ * opens it with the device's private key and checks it against the
12
+ * escrow's verifier.
13
+ * 2. No escrow and no account keys: this is the account's first vault use.
14
+ * The client mints MK and escrows it (`PUT`, insert-only). A concurrent
15
+ * first device loses the insert with 409 and reads the winner's key.
16
+ * 3. The device certifies itself under MK (a self-grant, `PUT
17
+ * /v1/devices/:id/key`), so other devices can verify its snapshots.
18
+ * 4. Signer trust comes from `certifiedSigners` over `GET /v1/devices/trust`,
19
+ * with the trust state persisted in {@link NexusVaultState}.
20
+ *
21
+ * Threat model (cleo-nexus T082): the escrow `PUT` sends MK to the server
22
+ * over TLS, and the server stores it encrypted under a server-held key
23
+ * (`KEY_ESCROW_SECRET`). Snapshots are therefore encrypted at rest with keys
24
+ * Cleo Nexus can recover: this is server-escrowed encryption, not
25
+ * zero-knowledge end-to-end encryption. What the escrow does guarantee is
26
+ * that MK is released only to an approved, active device of the account,
27
+ * sealed to that device's key.
28
+ *
29
+ * A project's data key (PDK) is minted by its first pusher and stored
30
+ * wrapped by MK (`PUT /v1/projects/:id/keys/:userId`); the home stream key
31
+ * is derived from MK.
32
+ *
33
+ * No function here logs a key, and no error carries one.
34
+ *
35
+ * @task T12336
36
+ * @epic T12322
37
+ */
38
+ import type { CloudWarning } from '@cleocode/contracts';
39
+ import { type KeyPair } from './crypto.js';
40
+ import { type FetchLike, Http, type ResponseSchema } from './http.js';
41
+ import { type TrustedSigners } from './keys.js';
42
+ import { resolveNexusApiUrl } from './nexus-auth.js';
43
+ import { type NexusCloudOptions } from './nexus-cloud.js';
44
+ import type { SealedNexusDevice } from './nexus-device.js';
45
+ import { NexusVaultState } from './nexus-vault-state.js';
46
+ /** Timeout of a snapshot blob upload or download. */
47
+ export declare const NEXUS_VAULT_BLOB_TIMEOUT_MS: number;
48
+ /** The sealed-box context of an escrow release (must match the server, cleo-nexus T082). */
49
+ export declare const escrowContext: (userId: string, deviceId: string) => string;
50
+ /** Options of every vault command. */
51
+ export interface NexusVaultOptions extends NexusCloudOptions {
52
+ /** Vault state store (tests). */
53
+ vaultState?: NexusVaultState;
54
+ /** Timeout of a blob transfer; default {@link NEXUS_VAULT_BLOB_TIMEOUT_MS}. */
55
+ blobTimeoutMs?: number;
56
+ }
57
+ /** A read-write connection with this machine's device credential and keys. */
58
+ export interface NexusVaultConnection {
59
+ readonly apiUrl: string;
60
+ readonly userId: string;
61
+ readonly deviceId: string;
62
+ readonly device: SealedNexusDevice;
63
+ /** Device keys: X25519 for sealed boxes, Ed25519 for signatures. */
64
+ readonly keys: {
65
+ encryption: KeyPair;
66
+ signing: KeyPair;
67
+ };
68
+ /** The authenticated client (sends `X-Cleo-Device-Id`). For the journal. */
69
+ readonly http: Http;
70
+ /** `fetch` for presigned blob transfers (long timeout, no credential). */
71
+ readonly blobFetch: FetchLike;
72
+ readonly state: NexusVaultState;
73
+ readonly warnings: CloudWarning[];
74
+ /** A request whose failure stays a raw {@link NexusError} (callers handle server codes). */
75
+ raw<T>(method: string, path: string, schema: ResponseSchema<T>, body?: unknown): Promise<T>;
76
+ /** {@link NexusVaultConnection.raw}, with failures mapped to {@link NexusAccountError}. */
77
+ call<T>(method: string, path: string, schema: ResponseSchema<T>, body?: unknown): Promise<T>;
78
+ /** `GET`, mapped; a 404 answers `null`. */
79
+ find<T>(path: string, schema: ResponseSchema<T>): Promise<T | null>;
80
+ }
81
+ /**
82
+ * Open a read-write vault connection with this machine's device credential.
83
+ *
84
+ * @param opts - API URL, account, stores and test overrides.
85
+ * @returns The connection.
86
+ * @throws {NexusAccountError} Not signed in, device mode off, or no device keys.
87
+ */
88
+ export declare function connectNexusVault(opts?: NexusVaultOptions): Promise<NexusVaultConnection>;
89
+ /** The unlocked account key and the signers this device trusts. */
90
+ export interface NexusAccountKey {
91
+ masterKey: Buffer;
92
+ keyVersion: number;
93
+ signers: TrustedSigners;
94
+ }
95
+ /**
96
+ * Get the account master key for this device, minting and escrowing it on
97
+ * the account's first vault use, and certify this device under it.
98
+ *
99
+ * @param conn - A vault connection.
100
+ * @param opts - `readOnly`: never mint, escrow or certify (GET only); a missing escrow is
101
+ * `E_NEXUS_VAULT_EMPTY`.
102
+ * @returns The key, its version and the trusted signers.
103
+ * @throws {NexusAccountError} `E_NEXUS_VAULT_KEY_UNAVAILABLE` when the key
104
+ * cannot be obtained or verified; a mapped API error otherwise.
105
+ */
106
+ export declare function unlockNexusAccountKey(conn: NexusVaultConnection, opts?: {
107
+ readOnly?: boolean;
108
+ }): Promise<NexusAccountKey>;
109
+ /**
110
+ * The data key of a project stream: unwrap the newest wrapped key, or mint
111
+ * and store one when the project has none yet (its first push).
112
+ *
113
+ * @param conn - A vault connection.
114
+ * @param mk - The unlocked master key.
115
+ * @param projectId - The server's project id.
116
+ * @param mint - Whether a missing key may be created (push: yes; restore: no).
117
+ * @returns The project data key, or `null` when none exists and `mint` is false.
118
+ */
119
+ export declare function nexusProjectDataKey(conn: NexusVaultConnection, mk: Buffer, projectId: string, mint: boolean): Promise<Buffer | null>;
120
+ /**
121
+ * The data key of the account's `home:` stream (derived from MK, never stored).
122
+ *
123
+ * @param mk - The unlocked master key.
124
+ * @returns The home stream key.
125
+ */
126
+ export declare function nexusHomeDataKey(mk: Buffer): Buffer;
127
+ /** Re-export for callers that only need the URL resolver. */
128
+ export { resolveNexusApiUrl };
129
+ //# sourceMappingURL=nexus-vault-keys.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nexus-vault-keys.d.ts","sourceRoot":"","sources":["../../src/cloud/nexus-vault-keys.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AASxD,OAAO,EAAE,KAAK,OAAO,EAAyB,MAAM,aAAa,CAAC;AAClE,OAAO,EAAE,KAAK,SAAS,EAAE,IAAI,EAAc,KAAK,cAAc,EAAE,MAAM,WAAW,CAAC;AAClF,OAAO,EAML,KAAK,cAAc,EAGpB,MAAM,WAAW,CAAC;AACnB,OAAO,EAAqB,kBAAkB,EAAE,MAAM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