@elie-laloum/outpost 2.0.0 → 4.0.0

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 (588) hide show
  1. package/CHANGELOG.md +42 -0
  2. package/README.md +3 -1
  3. package/SECURITY.md +3 -1
  4. package/dist/adapters/agents/claude-diagnostics.d.ts +1 -0
  5. package/dist/adapters/agents/claude-diagnostics.js +7 -0
  6. package/dist/adapters/agents/claude-diagnostics.js.map +1 -0
  7. package/dist/adapters/agents/cli-diagnostics.constants.d.ts +12 -0
  8. package/dist/adapters/agents/cli-diagnostics.constants.js +24 -0
  9. package/dist/adapters/agents/cli-diagnostics.constants.js.map +1 -0
  10. package/dist/adapters/agents/cli-diagnostics.d.ts +4 -0
  11. package/dist/adapters/agents/cli-diagnostics.js +14 -0
  12. package/dist/adapters/agents/cli-diagnostics.js.map +1 -0
  13. package/dist/adapters/agents/cli-diagnostics.types.d.ts +13 -0
  14. package/dist/adapters/agents/cli-diagnostics.types.js +2 -0
  15. package/dist/adapters/agents/cli-diagnostics.types.js.map +1 -0
  16. package/dist/adapters/agents/codex-diagnostics.d.ts +1 -0
  17. package/dist/adapters/agents/codex-diagnostics.js +7 -0
  18. package/dist/adapters/agents/codex-diagnostics.js.map +1 -0
  19. package/dist/adapters/agents/gemini-adapter.d.ts +3 -0
  20. package/dist/adapters/agents/gemini-adapter.js +15 -0
  21. package/dist/adapters/agents/gemini-adapter.js.map +1 -0
  22. package/dist/adapters/agents/gemini-diagnostics.d.ts +2 -0
  23. package/dist/adapters/agents/gemini-diagnostics.js +15 -0
  24. package/dist/adapters/agents/gemini-diagnostics.js.map +1 -0
  25. package/dist/adapters/agents/gemini-events.d.ts +2 -0
  26. package/dist/adapters/agents/gemini-events.js +50 -0
  27. package/dist/adapters/agents/gemini-events.js.map +1 -0
  28. package/dist/adapters/agents/gemini-request.d.ts +4 -0
  29. package/dist/adapters/agents/gemini-request.js +21 -0
  30. package/dist/adapters/agents/gemini-request.js.map +1 -0
  31. package/dist/adapters/agents/gemini.types.d.ts +6 -0
  32. package/dist/adapters/agents/gemini.types.js +2 -0
  33. package/dist/adapters/agents/gemini.types.js.map +1 -0
  34. package/dist/adapters/agents/protocol-fixtures.constants.d.ts +2 -0
  35. package/dist/adapters/agents/protocol-fixtures.constants.js +105 -0
  36. package/dist/adapters/agents/protocol-fixtures.constants.js.map +1 -0
  37. package/dist/adapters/agents/protocol-fixtures.types.d.ts +6 -0
  38. package/dist/adapters/agents/protocol-fixtures.types.js +2 -0
  39. package/dist/adapters/agents/protocol-fixtures.types.js.map +1 -0
  40. package/dist/application/agent-bootstrap.constants.d.ts +1 -0
  41. package/dist/application/agent-bootstrap.constants.js +1 -0
  42. package/dist/application/agent-bootstrap.constants.js.map +1 -1
  43. package/dist/application/agent-bootstrap.js +6 -2
  44. package/dist/application/agent-bootstrap.js.map +1 -1
  45. package/dist/application/agent-output.js +9 -2
  46. package/dist/application/agent-output.js.map +1 -1
  47. package/dist/application/artifact-tasks.d.ts +5 -0
  48. package/dist/application/artifact-tasks.js +31 -0
  49. package/dist/application/artifact-tasks.js.map +1 -0
  50. package/dist/application/artifact-tasks.types.d.ts +8 -0
  51. package/dist/application/artifact-tasks.types.js +2 -0
  52. package/dist/application/artifact-tasks.types.js.map +1 -0
  53. package/dist/application/diagnostic-probe.d.ts +3 -0
  54. package/dist/application/diagnostic-probe.js +55 -0
  55. package/dist/application/diagnostic-probe.js.map +1 -0
  56. package/dist/application/dispatch-validation.js +2 -0
  57. package/dist/application/dispatch-validation.js.map +1 -1
  58. package/dist/application/doctor-agent.constants.d.ts +11 -0
  59. package/dist/application/doctor-agent.constants.js +10 -0
  60. package/dist/application/doctor-agent.constants.js.map +1 -0
  61. package/dist/application/doctor-agent.d.ts +3 -0
  62. package/dist/application/doctor-agent.js +53 -0
  63. package/dist/application/doctor-agent.js.map +1 -0
  64. package/dist/application/doctor-image.d.ts +3 -0
  65. package/dist/application/doctor-image.js +133 -0
  66. package/dist/application/doctor-image.js.map +1 -0
  67. package/dist/application/doctor-protocol.d.ts +3 -0
  68. package/dist/application/doctor-protocol.js +30 -0
  69. package/dist/application/doctor-protocol.js.map +1 -0
  70. package/dist/application/doctor-protocol.types.d.ts +10 -0
  71. package/dist/application/doctor-protocol.types.js +2 -0
  72. package/dist/application/doctor-protocol.types.js.map +1 -0
  73. package/dist/application/doctor-sandbox.constants.d.ts +5 -0
  74. package/dist/application/doctor-sandbox.constants.js +6 -0
  75. package/dist/application/doctor-sandbox.constants.js.map +1 -0
  76. package/dist/application/doctor-sandbox.d.ts +4 -0
  77. package/dist/application/doctor-sandbox.js +133 -0
  78. package/dist/application/doctor-sandbox.js.map +1 -0
  79. package/dist/application/doctor-sandbox.types.d.ts +23 -0
  80. package/dist/application/doctor-sandbox.types.js +2 -0
  81. package/dist/application/doctor-sandbox.types.js.map +1 -0
  82. package/dist/application/doctor-transfers.constants.d.ts +6 -0
  83. package/dist/application/doctor-transfers.constants.js +7 -0
  84. package/dist/application/doctor-transfers.constants.js.map +1 -0
  85. package/dist/application/doctor-transfers.d.ts +4 -0
  86. package/dist/application/doctor-transfers.js +88 -0
  87. package/dist/application/doctor-transfers.js.map +1 -0
  88. package/dist/application/doctor.constants.d.ts +9 -0
  89. package/dist/application/doctor.constants.js +15 -0
  90. package/dist/application/doctor.constants.js.map +1 -0
  91. package/dist/application/doctor.d.ts +3 -0
  92. package/dist/application/doctor.js +106 -0
  93. package/dist/application/doctor.js.map +1 -0
  94. package/dist/application/doctor.types.d.ts +39 -0
  95. package/dist/application/doctor.types.js +2 -0
  96. package/dist/application/doctor.types.js.map +1 -0
  97. package/dist/application/execution.js +1 -0
  98. package/dist/application/execution.js.map +1 -1
  99. package/dist/application/outpost.types.d.ts +4 -0
  100. package/dist/application/outpost.types.js.map +1 -1
  101. package/dist/application/queue-worker.d.ts +2 -0
  102. package/dist/application/queue-worker.js +75 -0
  103. package/dist/application/queue-worker.js.map +1 -0
  104. package/dist/application/queue-worker.types.d.ts +15 -0
  105. package/dist/application/queue-worker.types.js +2 -0
  106. package/dist/application/queue-worker.types.js.map +1 -0
  107. package/dist/application/queued-task.d.ts +3 -0
  108. package/dist/application/queued-task.js +56 -0
  109. package/dist/application/queued-task.js.map +1 -0
  110. package/dist/application/queued-task.types.d.ts +11 -0
  111. package/dist/application/queued-task.types.js +2 -0
  112. package/dist/application/queued-task.types.js.map +1 -0
  113. package/dist/application/recovery-checksum-capture.d.ts +2 -0
  114. package/dist/application/recovery-checksum-capture.js +32 -0
  115. package/dist/application/recovery-checksum-capture.js.map +1 -0
  116. package/dist/application/recovery-checksum-paths.d.ts +2 -0
  117. package/dist/application/recovery-checksum-paths.js +11 -0
  118. package/dist/application/recovery-checksum-paths.js.map +1 -0
  119. package/dist/application/recovery-checksums.constants.d.ts +5 -0
  120. package/dist/application/recovery-checksums.constants.js +6 -0
  121. package/dist/application/recovery-checksums.constants.js.map +1 -0
  122. package/dist/application/recovery-checksums.d.ts +3 -0
  123. package/dist/application/recovery-checksums.js +94 -0
  124. package/dist/application/recovery-checksums.js.map +1 -0
  125. package/dist/application/recovery-checksums.types.d.ts +17 -0
  126. package/dist/application/recovery-checksums.types.js +2 -0
  127. package/dist/application/recovery-checksums.types.js.map +1 -0
  128. package/dist/application/recovery-inspection.d.ts +2 -0
  129. package/dist/application/recovery-inspection.js +32 -0
  130. package/dist/application/recovery-inspection.js.map +1 -0
  131. package/dist/application/recovery-inspection.types.d.ts +18 -0
  132. package/dist/application/recovery-inspection.types.js +2 -0
  133. package/dist/application/recovery-inspection.types.js.map +1 -0
  134. package/dist/application/recovery-restorability.d.ts +2 -0
  135. package/dist/application/recovery-restorability.js +137 -0
  136. package/dist/application/recovery-restorability.js.map +1 -0
  137. package/dist/application/recovery-restore-snapshot.d.ts +2 -0
  138. package/dist/application/recovery-restore-snapshot.js +57 -0
  139. package/dist/application/recovery-restore-snapshot.js.map +1 -0
  140. package/dist/application/recovery-restore.d.ts +3 -0
  141. package/dist/application/recovery-restore.js +161 -0
  142. package/dist/application/recovery-restore.js.map +1 -0
  143. package/dist/application/recovery-restore.types.d.ts +28 -0
  144. package/dist/application/recovery-restore.types.js +2 -0
  145. package/dist/application/recovery-restore.types.js.map +1 -0
  146. package/dist/application/recovery-retention-policy.d.ts +2 -0
  147. package/dist/application/recovery-retention-policy.js +21 -0
  148. package/dist/application/recovery-retention-policy.js.map +1 -0
  149. package/dist/application/recovery-retention.constants.d.ts +3 -0
  150. package/dist/application/recovery-retention.constants.js +2 -0
  151. package/dist/application/recovery-retention.constants.js.map +1 -0
  152. package/dist/application/recovery-retention.d.ts +4 -0
  153. package/dist/application/recovery-retention.js +207 -0
  154. package/dist/application/recovery-retention.js.map +1 -0
  155. package/dist/application/recovery-retention.types.d.ts +52 -0
  156. package/dist/application/recovery-retention.types.js +2 -0
  157. package/dist/application/recovery-retention.types.js.map +1 -0
  158. package/dist/application/recovery-verification.constants.d.ts +5 -0
  159. package/dist/application/recovery-verification.constants.js +10 -0
  160. package/dist/application/recovery-verification.constants.js.map +1 -0
  161. package/dist/application/recovery-verification.d.ts +3 -0
  162. package/dist/application/recovery-verification.js +107 -0
  163. package/dist/application/recovery-verification.js.map +1 -0
  164. package/dist/application/recovery-verification.types.d.ts +26 -0
  165. package/dist/application/recovery-verification.types.js +2 -0
  166. package/dist/application/recovery-verification.types.js.map +1 -0
  167. package/dist/application/remote-apply.js +30 -6
  168. package/dist/application/remote-apply.js.map +1 -1
  169. package/dist/application/remote-backup.js +6 -2
  170. package/dist/application/remote-backup.js.map +1 -1
  171. package/dist/application/remote-download.js +38 -6
  172. package/dist/application/remote-download.js.map +1 -1
  173. package/dist/application/remote-history.d.ts +6 -0
  174. package/dist/application/remote-history.js +114 -0
  175. package/dist/application/remote-history.js.map +1 -0
  176. package/dist/application/remote-upload.d.ts +2 -0
  177. package/dist/application/remote-upload.js +17 -0
  178. package/dist/application/remote-upload.js.map +1 -0
  179. package/dist/application/remote-validation.js +39 -28
  180. package/dist/application/remote-validation.js.map +1 -1
  181. package/dist/application/remote-workspace.constants.d.ts +3 -0
  182. package/dist/application/remote-workspace.constants.js +2 -0
  183. package/dist/application/remote-workspace.constants.js.map +1 -0
  184. package/dist/application/remote-workspace.js +10 -10
  185. package/dist/application/remote-workspace.js.map +1 -1
  186. package/dist/application/remote-workspace.types.d.ts +3 -1
  187. package/dist/application/remote-workspace.types.js.map +1 -1
  188. package/dist/application/sandbox-activity.d.ts +3 -0
  189. package/dist/application/sandbox-activity.js +25 -0
  190. package/dist/application/sandbox-activity.js.map +1 -0
  191. package/dist/application/sandbox-provision.js +55 -10
  192. package/dist/application/sandbox-provision.js.map +1 -1
  193. package/dist/application/sandbox-session.types.d.ts +2 -0
  194. package/dist/application/sandbox-session.types.js.map +1 -1
  195. package/dist/application/sandbox.js +33 -10
  196. package/dist/application/sandbox.js.map +1 -1
  197. package/dist/application/speculation-host.d.ts +2 -0
  198. package/dist/application/speculation-host.js +30 -0
  199. package/dist/application/speculation-host.js.map +1 -0
  200. package/dist/application/speculation.constants.d.ts +4 -0
  201. package/dist/application/speculation.constants.js +2 -0
  202. package/dist/application/speculation.constants.js.map +1 -0
  203. package/dist/application/speculation.d.ts +2 -0
  204. package/dist/application/speculation.js +166 -0
  205. package/dist/application/speculation.js.map +1 -0
  206. package/dist/application/speculation.types.d.ts +56 -0
  207. package/dist/application/speculation.types.js +2 -0
  208. package/dist/application/speculation.types.js.map +1 -0
  209. package/dist/application/storage-reservation.d.ts +3 -0
  210. package/dist/application/storage-reservation.js +10 -0
  211. package/dist/application/storage-reservation.js.map +1 -0
  212. package/dist/application/storage-reservation.types.d.ts +4 -0
  213. package/dist/application/storage-reservation.types.js +2 -0
  214. package/dist/application/storage-reservation.types.js.map +1 -0
  215. package/dist/application/task-usage.d.ts +4 -0
  216. package/dist/application/task-usage.js +41 -0
  217. package/dist/application/task-usage.js.map +1 -0
  218. package/dist/application/task-usage.types.d.ts +5 -0
  219. package/dist/application/task-usage.types.js +2 -0
  220. package/dist/application/task-usage.types.js.map +1 -0
  221. package/dist/application/tasks.js +23 -2
  222. package/dist/application/tasks.js.map +1 -1
  223. package/dist/application/tasks.types.d.ts +4 -3
  224. package/dist/application/tasks.types.js.map +1 -1
  225. package/dist/application/workspace-allocation.d.ts +3 -0
  226. package/dist/application/workspace-allocation.js +34 -0
  227. package/dist/application/workspace-allocation.js.map +1 -0
  228. package/dist/application/workspace.js +2 -2
  229. package/dist/application/workspace.js.map +1 -1
  230. package/dist/cli/commands.js +4 -0
  231. package/dist/cli/commands.js.map +1 -1
  232. package/dist/cli/doctor-command.d.ts +3 -0
  233. package/dist/cli/doctor-command.js +38 -0
  234. package/dist/cli/doctor-command.js.map +1 -0
  235. package/dist/cli/main.constants.d.ts +38 -2
  236. package/dist/cli/main.constants.js +21 -2
  237. package/dist/cli/main.constants.js.map +1 -1
  238. package/dist/cli/recovery-command.d.ts +2 -0
  239. package/dist/cli/recovery-command.js +93 -0
  240. package/dist/cli/recovery-command.js.map +1 -0
  241. package/dist/cli/recovery-prune-command.d.ts +2 -0
  242. package/dist/cli/recovery-prune-command.js +34 -0
  243. package/dist/cli/recovery-prune-command.js.map +1 -0
  244. package/dist/cli/recovery-restore-command.d.ts +2 -0
  245. package/dist/cli/recovery-restore-command.js +34 -0
  246. package/dist/cli/recovery-restore-command.js.map +1 -0
  247. package/dist/cli/recovery-verify-command.d.ts +2 -0
  248. package/dist/cli/recovery-verify-command.js +43 -0
  249. package/dist/cli/recovery-verify-command.js.map +1 -0
  250. package/dist/cli/scaffold-files.js +2 -2
  251. package/dist/cli/scaffold-files.js.map +1 -1
  252. package/dist/cli/scaffold-validation.js +1 -1
  253. package/dist/cli/scaffold-validation.js.map +1 -1
  254. package/dist/cli/scaffold.constants.d.ts +5 -0
  255. package/dist/cli/scaffold.constants.js +7 -2
  256. package/dist/cli/scaffold.constants.js.map +1 -1
  257. package/dist/cli/scaffold.types.d.ts +1 -1
  258. package/dist/cli/scaffold.types.js.map +1 -1
  259. package/dist/domain/agent.types.d.ts +2 -0
  260. package/dist/domain/agent.types.js.map +1 -1
  261. package/dist/domain/artifact-reference.d.ts +4 -0
  262. package/dist/domain/artifact-reference.js +90 -0
  263. package/dist/domain/artifact-reference.js.map +1 -0
  264. package/dist/domain/artifact.constants.d.ts +2 -0
  265. package/dist/domain/artifact.constants.js +3 -0
  266. package/dist/domain/artifact.constants.js.map +1 -0
  267. package/dist/domain/artifact.d.ts +7 -0
  268. package/dist/domain/artifact.js +104 -0
  269. package/dist/domain/artifact.js.map +1 -0
  270. package/dist/domain/artifact.types.d.ts +44 -0
  271. package/dist/domain/artifact.types.js +2 -0
  272. package/dist/domain/artifact.types.js.map +1 -0
  273. package/dist/domain/egress.constants.d.ts +1 -0
  274. package/dist/domain/egress.constants.js +7 -0
  275. package/dist/domain/egress.constants.js.map +1 -0
  276. package/dist/domain/egress.d.ts +2 -0
  277. package/dist/domain/egress.js +48 -0
  278. package/dist/domain/egress.js.map +1 -0
  279. package/dist/domain/egress.types.d.ts +8 -0
  280. package/dist/domain/egress.types.js +2 -0
  281. package/dist/domain/egress.types.js.map +1 -0
  282. package/dist/domain/ports.d.ts +1 -1
  283. package/dist/domain/ports.js.map +1 -1
  284. package/dist/domain/sandbox.types.d.ts +13 -0
  285. package/dist/domain/sandbox.types.js.map +1 -1
  286. package/dist/domain/task-queue.constants.d.ts +8 -0
  287. package/dist/domain/task-queue.constants.js +9 -0
  288. package/dist/domain/task-queue.constants.js.map +1 -0
  289. package/dist/domain/task-queue.d.ts +11 -0
  290. package/dist/domain/task-queue.js +105 -0
  291. package/dist/domain/task-queue.js.map +1 -0
  292. package/dist/domain/task-queue.types.d.ts +41 -0
  293. package/dist/domain/task-queue.types.js +2 -0
  294. package/dist/domain/task-queue.types.js.map +1 -0
  295. package/dist/domain/workflow/budget.constants.d.ts +1 -0
  296. package/dist/domain/workflow/budget.constants.js +7 -0
  297. package/dist/domain/workflow/budget.constants.js.map +1 -0
  298. package/dist/domain/workflow/budget.d.ts +9 -0
  299. package/dist/domain/workflow/budget.js +69 -0
  300. package/dist/domain/workflow/budget.js.map +1 -0
  301. package/dist/domain/workflow/budget.types.d.ts +15 -0
  302. package/dist/domain/workflow/budget.types.js +2 -0
  303. package/dist/domain/workflow/budget.types.js.map +1 -0
  304. package/dist/domain/workflow/checkpoint-validation.d.ts +3 -0
  305. package/dist/domain/workflow/checkpoint-validation.js +81 -0
  306. package/dist/domain/workflow/checkpoint-validation.js.map +1 -0
  307. package/dist/domain/workflow/checkpoint-value.d.ts +2 -0
  308. package/dist/domain/workflow/checkpoint-value.js +49 -0
  309. package/dist/domain/workflow/checkpoint-value.js.map +1 -0
  310. package/dist/domain/workflow/checkpoint.d.ts +3 -0
  311. package/dist/domain/workflow/checkpoint.js +70 -0
  312. package/dist/domain/workflow/checkpoint.js.map +1 -0
  313. package/dist/domain/workflow/checkpoint.types.d.ts +40 -0
  314. package/dist/domain/workflow/checkpoint.types.js +2 -0
  315. package/dist/domain/workflow/checkpoint.types.js.map +1 -0
  316. package/dist/domain/workflow/gate-validation.d.ts +4 -0
  317. package/dist/domain/workflow/gate-validation.js +71 -0
  318. package/dist/domain/workflow/gate-validation.js.map +1 -0
  319. package/dist/domain/workflow/gates.constants.d.ts +4 -0
  320. package/dist/domain/workflow/gates.constants.js +5 -0
  321. package/dist/domain/workflow/gates.constants.js.map +1 -0
  322. package/dist/domain/workflow/gates.d.ts +7 -0
  323. package/dist/domain/workflow/gates.js +85 -0
  324. package/dist/domain/workflow/gates.js.map +1 -0
  325. package/dist/domain/workflow/gates.types.d.ts +27 -0
  326. package/dist/domain/workflow/gates.types.js +2 -0
  327. package/dist/domain/workflow/gates.types.js.map +1 -0
  328. package/dist/domain/workflow/task-runner.js +22 -3
  329. package/dist/domain/workflow/task-runner.js.map +1 -1
  330. package/dist/domain/workflow/usage-receipt.constants.d.ts +2 -0
  331. package/dist/domain/workflow/usage-receipt.constants.js +3 -0
  332. package/dist/domain/workflow/usage-receipt.constants.js.map +1 -0
  333. package/dist/domain/workflow/usage-receipt.d.ts +2 -0
  334. package/dist/domain/workflow/usage-receipt.js +18 -0
  335. package/dist/domain/workflow/usage-receipt.js.map +1 -0
  336. package/dist/domain/workflow/validation.js +6 -0
  337. package/dist/domain/workflow/validation.js.map +1 -1
  338. package/dist/domain/workflow/workflow-scheduler.js +68 -33
  339. package/dist/domain/workflow/workflow-scheduler.js.map +1 -1
  340. package/dist/domain/workflow/workflow-state.d.ts +2 -1
  341. package/dist/domain/workflow/workflow-state.js +107 -3
  342. package/dist/domain/workflow/workflow-state.js.map +1 -1
  343. package/dist/domain/workflow.d.ts +2 -0
  344. package/dist/domain/workflow.js +1 -0
  345. package/dist/domain/workflow.js.map +1 -1
  346. package/dist/domain/workflow.types.d.ts +23 -3
  347. package/dist/domain/workflow.types.js.map +1 -1
  348. package/dist/index.d.ts +44 -5
  349. package/dist/index.js +19 -2
  350. package/dist/index.js.map +1 -1
  351. package/dist/infrastructure/artifact-store.constants.d.ts +1 -0
  352. package/dist/infrastructure/artifact-store.constants.js +2 -0
  353. package/dist/infrastructure/artifact-store.constants.js.map +1 -0
  354. package/dist/infrastructure/artifact-store.d.ts +3 -0
  355. package/dist/infrastructure/artifact-store.js +100 -0
  356. package/dist/infrastructure/artifact-store.js.map +1 -0
  357. package/dist/infrastructure/artifact-store.types.d.ts +4 -0
  358. package/dist/infrastructure/artifact-store.types.js +2 -0
  359. package/dist/infrastructure/artifact-store.types.js.map +1 -0
  360. package/dist/infrastructure/file-manifest.d.ts +6 -0
  361. package/dist/infrastructure/file-manifest.js +92 -0
  362. package/dist/infrastructure/file-manifest.js.map +1 -0
  363. package/dist/infrastructure/git/lock-inspection.constants.d.ts +4 -0
  364. package/dist/infrastructure/git/lock-inspection.constants.js +5 -0
  365. package/dist/infrastructure/git/lock-inspection.constants.js.map +1 -0
  366. package/dist/infrastructure/git/lock-inspection.d.ts +3 -0
  367. package/dist/infrastructure/git/lock-inspection.js +64 -0
  368. package/dist/infrastructure/git/lock-inspection.js.map +1 -0
  369. package/dist/infrastructure/git/lock-inspection.types.d.ts +27 -0
  370. package/dist/infrastructure/git/lock-inspection.types.js +2 -0
  371. package/dist/infrastructure/git/lock-inspection.types.js.map +1 -0
  372. package/dist/infrastructure/git/lock.d.ts +1 -0
  373. package/dist/infrastructure/git/lock.js +70 -29
  374. package/dist/infrastructure/git/lock.js.map +1 -1
  375. package/dist/infrastructure/git/process-identity.d.ts +3 -0
  376. package/dist/infrastructure/git/process-identity.js +73 -0
  377. package/dist/infrastructure/git/process-identity.js.map +1 -0
  378. package/dist/infrastructure/git/process-identity.types.d.ts +10 -0
  379. package/dist/infrastructure/git/process-identity.types.js +2 -0
  380. package/dist/infrastructure/git/process-identity.types.js.map +1 -0
  381. package/dist/infrastructure/git/verification-command.d.ts +1 -0
  382. package/dist/infrastructure/git/verification-command.js +37 -0
  383. package/dist/infrastructure/git/verification-command.js.map +1 -0
  384. package/dist/infrastructure/git/workspace-lease.js +1 -0
  385. package/dist/infrastructure/git/workspace-lease.js.map +1 -1
  386. package/dist/infrastructure/git/workspace.js +5 -1
  387. package/dist/infrastructure/git/workspace.js.map +1 -1
  388. package/dist/infrastructure/git/worktree-inspection.constants.d.ts +5 -0
  389. package/dist/infrastructure/git/worktree-inspection.constants.js +16 -0
  390. package/dist/infrastructure/git/worktree-inspection.constants.js.map +1 -0
  391. package/dist/infrastructure/git/worktree-inspection.d.ts +3 -0
  392. package/dist/infrastructure/git/worktree-inspection.js +120 -0
  393. package/dist/infrastructure/git/worktree-inspection.js.map +1 -0
  394. package/dist/infrastructure/git/worktree-inspection.types.d.ts +19 -0
  395. package/dist/infrastructure/git/worktree-inspection.types.js +2 -0
  396. package/dist/infrastructure/git/worktree-inspection.types.js.map +1 -0
  397. package/dist/infrastructure/inspection-file.constants.d.ts +1 -0
  398. package/dist/infrastructure/inspection-file.constants.js +5 -0
  399. package/dist/infrastructure/inspection-file.constants.js.map +1 -0
  400. package/dist/infrastructure/inspection-file.d.ts +1 -0
  401. package/dist/infrastructure/inspection-file.js +43 -0
  402. package/dist/infrastructure/inspection-file.js.map +1 -0
  403. package/dist/infrastructure/inspection-hash.constants.d.ts +1 -0
  404. package/dist/infrastructure/inspection-hash.constants.js +2 -0
  405. package/dist/infrastructure/inspection-hash.constants.js.map +1 -0
  406. package/dist/infrastructure/inspection-hash.d.ts +2 -0
  407. package/dist/infrastructure/inspection-hash.js +62 -0
  408. package/dist/infrastructure/inspection-hash.js.map +1 -0
  409. package/dist/infrastructure/inspection-hash.types.d.ts +5 -0
  410. package/dist/infrastructure/inspection-hash.types.js +2 -0
  411. package/dist/infrastructure/inspection-hash.types.js.map +1 -0
  412. package/dist/infrastructure/journal-retention.constants.d.ts +4 -0
  413. package/dist/infrastructure/journal-retention.constants.js +5 -0
  414. package/dist/infrastructure/journal-retention.constants.js.map +1 -0
  415. package/dist/infrastructure/journal-retention.d.ts +2 -0
  416. package/dist/infrastructure/journal-retention.js +51 -0
  417. package/dist/infrastructure/journal-retention.js.map +1 -0
  418. package/dist/infrastructure/journal.js +37 -13
  419. package/dist/infrastructure/journal.js.map +1 -1
  420. package/dist/infrastructure/opentelemetry.constants.d.ts +10 -0
  421. package/dist/infrastructure/opentelemetry.constants.js +11 -0
  422. package/dist/infrastructure/opentelemetry.constants.js.map +1 -0
  423. package/dist/infrastructure/opentelemetry.d.ts +3 -0
  424. package/dist/infrastructure/opentelemetry.js +131 -0
  425. package/dist/infrastructure/opentelemetry.js.map +1 -0
  426. package/dist/infrastructure/opentelemetry.types.d.ts +21 -0
  427. package/dist/infrastructure/opentelemetry.types.js +2 -0
  428. package/dist/infrastructure/opentelemetry.types.js.map +1 -0
  429. package/dist/infrastructure/resource-activity-inspection.d.ts +2 -0
  430. package/dist/infrastructure/resource-activity-inspection.js +152 -0
  431. package/dist/infrastructure/resource-activity-inspection.js.map +1 -0
  432. package/dist/infrastructure/resource-activity.constants.d.ts +8 -0
  433. package/dist/infrastructure/resource-activity.constants.js +26 -0
  434. package/dist/infrastructure/resource-activity.constants.js.map +1 -0
  435. package/dist/infrastructure/resource-activity.d.ts +2 -0
  436. package/dist/infrastructure/resource-activity.js +166 -0
  437. package/dist/infrastructure/resource-activity.js.map +1 -0
  438. package/dist/infrastructure/resource-activity.types.d.ts +53 -0
  439. package/dist/infrastructure/resource-activity.types.js +2 -0
  440. package/dist/infrastructure/resource-activity.types.js.map +1 -0
  441. package/dist/infrastructure/storage-inventory.constants.d.ts +6 -0
  442. package/dist/infrastructure/storage-inventory.constants.js +11 -0
  443. package/dist/infrastructure/storage-inventory.constants.js.map +1 -0
  444. package/dist/infrastructure/storage-inventory.d.ts +2 -0
  445. package/dist/infrastructure/storage-inventory.js +123 -0
  446. package/dist/infrastructure/storage-inventory.js.map +1 -0
  447. package/dist/infrastructure/storage-inventory.types.d.ts +38 -0
  448. package/dist/infrastructure/storage-inventory.types.js +2 -0
  449. package/dist/infrastructure/storage-inventory.types.js.map +1 -0
  450. package/dist/infrastructure/storage-mutation-lock.constants.d.ts +5 -0
  451. package/dist/infrastructure/storage-mutation-lock.constants.js +6 -0
  452. package/dist/infrastructure/storage-mutation-lock.constants.js.map +1 -0
  453. package/dist/infrastructure/storage-mutation-lock.d.ts +1 -0
  454. package/dist/infrastructure/storage-mutation-lock.js +21 -0
  455. package/dist/infrastructure/storage-mutation-lock.js.map +1 -0
  456. package/dist/infrastructure/storage-reservations.constants.d.ts +4 -0
  457. package/dist/infrastructure/storage-reservations.constants.js +5 -0
  458. package/dist/infrastructure/storage-reservations.constants.js.map +1 -0
  459. package/dist/infrastructure/storage-reservations.d.ts +2 -0
  460. package/dist/infrastructure/storage-reservations.js +150 -0
  461. package/dist/infrastructure/storage-reservations.js.map +1 -0
  462. package/dist/infrastructure/storage-reservations.types.d.ts +21 -0
  463. package/dist/infrastructure/storage-reservations.types.js +2 -0
  464. package/dist/infrastructure/storage-reservations.types.js.map +1 -0
  465. package/dist/infrastructure/task-queue-http.constants.d.ts +2 -0
  466. package/dist/infrastructure/task-queue-http.constants.js +3 -0
  467. package/dist/infrastructure/task-queue-http.constants.js.map +1 -0
  468. package/dist/infrastructure/task-queue-http.d.ts +4 -0
  469. package/dist/infrastructure/task-queue-http.js +158 -0
  470. package/dist/infrastructure/task-queue-http.js.map +1 -0
  471. package/dist/infrastructure/task-queue-http.types.d.ts +16 -0
  472. package/dist/infrastructure/task-queue-http.types.js +2 -0
  473. package/dist/infrastructure/task-queue-http.types.js.map +1 -0
  474. package/dist/infrastructure/task-queue.d.ts +2 -0
  475. package/dist/infrastructure/task-queue.js +134 -0
  476. package/dist/infrastructure/task-queue.js.map +1 -0
  477. package/dist/infrastructure/transfer.js +17 -0
  478. package/dist/infrastructure/transfer.js.map +1 -1
  479. package/dist/infrastructure/workflow-checkpoint.constants.d.ts +1 -0
  480. package/dist/infrastructure/workflow-checkpoint.constants.js +2 -0
  481. package/dist/infrastructure/workflow-checkpoint.constants.js.map +1 -0
  482. package/dist/infrastructure/workflow-checkpoint.d.ts +3 -0
  483. package/dist/infrastructure/workflow-checkpoint.js +77 -0
  484. package/dist/infrastructure/workflow-checkpoint.js.map +1 -0
  485. package/dist/infrastructure/workflow-checkpoint.types.d.ts +4 -0
  486. package/dist/infrastructure/workflow-checkpoint.types.js +2 -0
  487. package/dist/infrastructure/workflow-checkpoint.types.js.map +1 -0
  488. package/dist/providers/agents.d.ts +2 -0
  489. package/dist/providers/agents.js +1 -0
  490. package/dist/providers/agents.js.map +1 -1
  491. package/dist/providers/cloud.constants.d.ts +1 -0
  492. package/dist/providers/cloud.constants.js +1 -0
  493. package/dist/providers/cloud.constants.js.map +1 -1
  494. package/dist/providers/container-cache.constants.d.ts +11 -0
  495. package/dist/providers/container-cache.constants.js +9 -0
  496. package/dist/providers/container-cache.constants.js.map +1 -0
  497. package/dist/providers/container-cache.d.ts +4 -0
  498. package/dist/providers/container-cache.js +48 -0
  499. package/dist/providers/container-cache.js.map +1 -0
  500. package/dist/providers/container-cache.types.d.ts +8 -0
  501. package/dist/providers/container-cache.types.js +2 -0
  502. package/dist/providers/container-cache.types.js.map +1 -0
  503. package/dist/providers/container-isolation.d.ts +2 -0
  504. package/dist/providers/container-isolation.js +29 -0
  505. package/dist/providers/container-isolation.js.map +1 -0
  506. package/dist/providers/container-mounts.js +7 -2
  507. package/dist/providers/container-mounts.js.map +1 -1
  508. package/dist/providers/container-network.d.ts +2 -0
  509. package/dist/providers/container-network.js +14 -0
  510. package/dist/providers/container-network.js.map +1 -0
  511. package/dist/providers/container-plan.js +6 -2
  512. package/dist/providers/container-plan.js.map +1 -1
  513. package/dist/providers/container.constants.d.ts +1 -0
  514. package/dist/providers/container.constants.js +1 -0
  515. package/dist/providers/container.constants.js.map +1 -1
  516. package/dist/providers/container.js +50 -3
  517. package/dist/providers/container.js.map +1 -1
  518. package/dist/providers/container.types.d.ts +5 -0
  519. package/dist/providers/container.types.js.map +1 -1
  520. package/dist/providers/daytona-command.js +10 -6
  521. package/dist/providers/daytona-command.js.map +1 -1
  522. package/dist/providers/daytona-terminal.d.ts +3 -0
  523. package/dist/providers/daytona-terminal.js +128 -0
  524. package/dist/providers/daytona-terminal.js.map +1 -0
  525. package/dist/providers/daytona.js +15 -4
  526. package/dist/providers/daytona.js.map +1 -1
  527. package/dist/providers/diagnostic-container.d.ts +4 -0
  528. package/dist/providers/diagnostic-container.js +15 -0
  529. package/dist/providers/diagnostic-container.js.map +1 -0
  530. package/dist/providers/docker.d.ts +2 -0
  531. package/dist/providers/docker.js.map +1 -1
  532. package/dist/providers/file-batches.constants.d.ts +10 -0
  533. package/dist/providers/file-batches.constants.js +57 -0
  534. package/dist/providers/file-batches.constants.js.map +1 -0
  535. package/dist/providers/file-batches.d.ts +2 -0
  536. package/dist/providers/file-batches.js +160 -0
  537. package/dist/providers/file-batches.js.map +1 -0
  538. package/dist/providers/file-upload.constants.d.ts +1 -0
  539. package/dist/providers/file-upload.constants.js +68 -0
  540. package/dist/providers/file-upload.constants.js.map +1 -0
  541. package/dist/providers/file-upload.d.ts +2 -0
  542. package/dist/providers/file-upload.js +146 -0
  543. package/dist/providers/file-upload.js.map +1 -0
  544. package/dist/providers/firecracker-command.d.ts +5 -0
  545. package/dist/providers/firecracker-command.js +114 -0
  546. package/dist/providers/firecracker-command.js.map +1 -0
  547. package/dist/providers/firecracker-files.constants.d.ts +1 -0
  548. package/dist/providers/firecracker-files.constants.js +21 -0
  549. package/dist/providers/firecracker-files.constants.js.map +1 -0
  550. package/dist/providers/firecracker-files.d.ts +3 -0
  551. package/dist/providers/firecracker-files.js +110 -0
  552. package/dist/providers/firecracker-files.js.map +1 -0
  553. package/dist/providers/firecracker-machine.d.ts +3 -0
  554. package/dist/providers/firecracker-machine.js +155 -0
  555. package/dist/providers/firecracker-machine.js.map +1 -0
  556. package/dist/providers/firecracker.constants.d.ts +10 -0
  557. package/dist/providers/firecracker.constants.js +11 -0
  558. package/dist/providers/firecracker.constants.js.map +1 -0
  559. package/dist/providers/firecracker.d.ts +4 -0
  560. package/dist/providers/firecracker.js +103 -0
  561. package/dist/providers/firecracker.js.map +1 -0
  562. package/dist/providers/firecracker.types.d.ts +36 -0
  563. package/dist/providers/firecracker.types.js +2 -0
  564. package/dist/providers/firecracker.types.js.map +1 -0
  565. package/dist/providers/local.js +2 -1
  566. package/dist/providers/local.js.map +1 -1
  567. package/dist/providers/podman.d.ts +2 -0
  568. package/dist/providers/podman.js.map +1 -1
  569. package/dist/providers/terminal-bridge.d.ts +14 -0
  570. package/dist/providers/terminal-bridge.js +100 -0
  571. package/dist/providers/terminal-bridge.js.map +1 -0
  572. package/dist/providers/vercel-directory.d.ts +2 -0
  573. package/dist/providers/vercel-directory.js +7 -0
  574. package/dist/providers/vercel-directory.js.map +1 -0
  575. package/dist/providers/vercel-files.js +3 -2
  576. package/dist/providers/vercel-files.js.map +1 -1
  577. package/dist/providers/vercel-network.d.ts +2 -0
  578. package/dist/providers/vercel-network.js +18 -0
  579. package/dist/providers/vercel-network.js.map +1 -0
  580. package/dist/providers/vercel.d.ts +1 -0
  581. package/dist/providers/vercel.js +8 -2
  582. package/dist/providers/vercel.js.map +1 -1
  583. package/dist/providers/vercel.types.d.ts +2 -0
  584. package/dist/providers/vercel.types.js.map +1 -1
  585. package/dist/providers/versions.constants.d.ts +1 -0
  586. package/dist/providers/versions.constants.js +1 -0
  587. package/dist/providers/versions.constants.js.map +1 -1
  588. package/package.json +16 -1
@@ -1 +1 @@
1
- {"version":3,"file":"remote-backup.js","sourceRoot":"","sources":["../../src/application/remote-backup.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAE,GAAG,EAAE,MAAM,kCAAkC,CAAC;AAMvD,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AAEpD,MAAM,CAAC,KAAK,UAAU,UAAU,CAC9B,OAA+B,EAC/B,OAAsB,EACtB,YAAoB,EACpB,QAAgB;IAEhB,MAAM,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC;IAC9B,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC;IACnC,MAAM,aAAa,GAAG,IAAI,CAAC,QAAQ,EAAE,gBAAgB,CAAC,CAAC;IACvD,MAAM,GAAG,CAAC,SAAS,CAAC,SAAS,EAAE;QAC7B,MAAM;QACN,UAAU;QACV,MAAM;QACN,YAAY,aAAa,EAAE;KAC5B,CAAC,CAAC;IACH,MAAM,GAAG,CAAC,SAAS,CAAC,SAAS,EAAE;QAC7B,MAAM;QACN,UAAU;QACV,UAAU;QACV,YAAY,IAAI,CAAC,QAAQ,EAAE,sBAAsB,CAAC,EAAE;KACrD,CAAC,CAAC;IACH,MAAM,cAAc,GAAG,MAAM,MAAM,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;IACzD,KAAK,MAAM,IAAI,IAAI,cAAc,EAAE,CAAC;QAClC,MAAM,MAAM,GAAG,MAAM,eAAe,CAClC,IAAI,CAAC,QAAQ,EAAE,gBAAgB,CAAC,EAChC,IAAI,CACL,CAAC;QACF,MAAM,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QAClD,MAAM,EAAE,CAAC,MAAM,eAAe,CAAC,SAAS,CAAC,SAAS,EAAE,IAAI,CAAC,EAAE,MAAM,EAAE;YACjE,WAAW,EAAE,KAAK;SACnB,CAAC,CAAC;IACL,CAAC;IACD,MAAM,SAAS,CACb,IAAI,CAAC,QAAQ,EAAE,YAAY,CAAC,EAC5B,IAAI,CAAC,SAAS,CAAC;QACb,QAAQ,EAAE,YAAY;QACtB,IAAI,EAAE,IAAI;QACV,cAAc;QACd,QAAQ;KACT,CAAC,CACH,CAAC;IAEF,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,CAAC;AAC3C,CAAC","sourcesContent":["import { cp, mkdir, writeFile } from \"node:fs/promises\";\nimport { dirname, join } from \"node:path\";\nimport { safeDestination } from \"../infrastructure/files.ts\";\nimport { git } from \"../infrastructure/git/command.ts\";\nimport type {\n HostBackup,\n RemoteChanges,\n RemoteWorkspaceContext,\n} from \"./remote-workspace.types.ts\";\nimport { extras } from \"./workspace-fingerprint.ts\";\n\nexport async function backupHost(\n context: RemoteWorkspaceContext,\n changes: RemoteChanges,\n synchronized: string,\n transfer: string,\n): Promise<HostBackup> {\n const { workspace } = context;\n const { head, incoming } = changes;\n const previousPatch = join(transfer, \"previous.patch\");\n await git(workspace.directory, [\n \"diff\",\n \"--binary\",\n \"HEAD\",\n `--output=${previousPatch}`,\n ]);\n await git(workspace.directory, [\n \"diff\",\n \"--cached\",\n \"--binary\",\n `--output=${join(transfer, \"previous-index.patch\")}`,\n ]);\n const previousExtras = await extras(workspace.directory);\n for (const file of previousExtras) {\n const backup = await safeDestination(\n join(transfer, \"previous-files\"),\n file,\n );\n await mkdir(dirname(backup), { recursive: true });\n await cp(await safeDestination(workspace.directory, file), backup, {\n dereference: false,\n });\n }\n await writeFile(\n join(transfer, \"state.json\"),\n JSON.stringify({\n previous: synchronized,\n next: head,\n previousExtras,\n incoming,\n }),\n );\n\n return { previousPatch, previousExtras };\n}\n"]}
1
+ {"version":3,"file":"remote-backup.js","sourceRoot":"","sources":["../../src/application/remote-backup.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,gCAAgC,CAAC;AAC1E,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAE,GAAG,EAAE,MAAM,kCAAkC,CAAC;AAMvD,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AAEpD,MAAM,CAAC,KAAK,UAAU,UAAU,CAC9B,OAA+B,EAC/B,OAAsB,EACtB,YAAoB,EACpB,QAAgB;IAEhB,MAAM,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC;IAC9B,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC;IACnC,MAAM,aAAa,GAAG,IAAI,CAAC,QAAQ,EAAE,gBAAgB,CAAC,CAAC;IACvD,MAAM,GAAG,CAAC,SAAS,CAAC,SAAS,EAAE;QAC7B,MAAM;QACN,UAAU;QACV,MAAM;QACN,YAAY,aAAa,EAAE;KAC5B,CAAC,CAAC;IACH,MAAM,GAAG,CAAC,SAAS,CAAC,SAAS,EAAE;QAC7B,MAAM;QACN,UAAU;QACV,UAAU;QACV,YAAY,IAAI,CAAC,QAAQ,EAAE,sBAAsB,CAAC,EAAE;KACrD,CAAC,CAAC;IACH,MAAM,cAAc,GAAG,MAAM,MAAM,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;IACzD,KAAK,MAAM,IAAI,IAAI,cAAc,EAAE,CAAC;QAClC,MAAM,MAAM,GAAG,MAAM,eAAe,CAClC,IAAI,CAAC,QAAQ,EAAE,gBAAgB,CAAC,EAChC,IAAI,CACL,CAAC;QACF,MAAM,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QAClD,MAAM,EAAE,CAAC,MAAM,eAAe,CAAC,SAAS,CAAC,SAAS,EAAE,IAAI,CAAC,EAAE,MAAM,EAAE;YACjE,WAAW,EAAE,KAAK;YAClB,gBAAgB,EAAE,IAAI;SACvB,CAAC,CAAC;IACL,CAAC;IACD,MAAM,KAAK,GAAG;QACZ,QAAQ,EAAE,YAAY;QACtB,IAAI,EAAE,IAAI;QACV,cAAc;QACd,QAAQ;KACT,CAAC;IACF,MAAM,SAAS,CAAC,IAAI,CAAC,QAAQ,EAAE,YAAY,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC;IACrE,MAAM,wBAAwB,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;IAEhD,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,CAAC;AAC3C,CAAC","sourcesContent":["import { captureRecoveryChecksums } from \"./recovery-checksum-capture.ts\";\nimport { cp, mkdir, writeFile } from \"node:fs/promises\";\nimport { dirname, join } from \"node:path\";\nimport { safeDestination } from \"../infrastructure/files.ts\";\nimport { git } from \"../infrastructure/git/command.ts\";\nimport type {\n HostBackup,\n RemoteChanges,\n RemoteWorkspaceContext,\n} from \"./remote-workspace.types.ts\";\nimport { extras } from \"./workspace-fingerprint.ts\";\n\nexport async function backupHost(\n context: RemoteWorkspaceContext,\n changes: RemoteChanges,\n synchronized: string,\n transfer: string,\n): Promise<HostBackup> {\n const { workspace } = context;\n const { head, incoming } = changes;\n const previousPatch = join(transfer, \"previous.patch\");\n await git(workspace.directory, [\n \"diff\",\n \"--binary\",\n \"HEAD\",\n `--output=${previousPatch}`,\n ]);\n await git(workspace.directory, [\n \"diff\",\n \"--cached\",\n \"--binary\",\n `--output=${join(transfer, \"previous-index.patch\")}`,\n ]);\n const previousExtras = await extras(workspace.directory);\n for (const file of previousExtras) {\n const backup = await safeDestination(\n join(transfer, \"previous-files\"),\n file,\n );\n await mkdir(dirname(backup), { recursive: true });\n await cp(await safeDestination(workspace.directory, file), backup, {\n dereference: false,\n verbatimSymlinks: true,\n });\n }\n const state = {\n previous: synchronized,\n next: head,\n previousExtras,\n incoming,\n };\n await writeFile(join(transfer, \"state.json\"), JSON.stringify(state));\n await captureRecoveryChecksums(transfer, state);\n\n return { previousPatch, previousExtras };\n}\n"]}
@@ -1,5 +1,8 @@
1
- import { join, posix } from "node:path";
1
+ import { cp, mkdir, writeFile } from "node:fs/promises";
2
+ import { dirname, join, posix } from "node:path";
3
+ import { downloadHistory } from "./remote-history.js";
2
4
  import { OutpostError } from "../domain/errors.js";
5
+ import { fileManifest, parseManifest, sameFile, sameLocalFile, } from "../infrastructure/file-manifest.js";
3
6
  import { safeDestination } from "../infrastructure/files.js";
4
7
  export async function downloadChanges(context, synchronized, transfer) {
5
8
  const { workspace, lease, remoteBundle, run } = context;
@@ -12,13 +15,42 @@ export async function downloadChanges(context, synchronized, transfer) {
12
15
  for (const file of incoming) {
13
16
  if (/^\.outpost\/(locks|recovery|workspaces|logs)(\/|$)/i.test(file))
14
17
  throw new OutpostError("workspace", "Remote file overlaps Outpost runtime state", { file });
15
- await safeDestination(workspace.directory, file);
16
- await lease.download(posix.join(lease.root, file), await safeDestination(join(transfer, "incoming"), file));
18
+ await safeDestination(join(transfer, "incoming"), file);
17
19
  }
20
+ let manifest;
21
+ if (lease.fileTransfers) {
22
+ manifest = parseManifest(await lease.fileTransfers.manifest(lease.root, incoming), incoming);
23
+ await writeFile(join(transfer, "manifest.json"), JSON.stringify(manifest), {
24
+ mode: 0o600,
25
+ });
26
+ const changed = [];
27
+ for (const entry of manifest) {
28
+ const previous = context.transferred?.get(entry.path);
29
+ if (previous &&
30
+ sameFile(previous, entry) &&
31
+ sameLocalFile(entry, await fileManifest(workspace.directory, entry.path))) {
32
+ const target = await safeDestination(join(transfer, "incoming"), entry.path);
33
+ await mkdir(dirname(target), { recursive: true });
34
+ await cp(await safeDestination(workspace.directory, entry.path), target, { dereference: false, verbatimSymlinks: true });
35
+ continue;
36
+ }
37
+ changed.push(entry);
38
+ }
39
+ await lease.fileTransfers.downloadBatch(lease.root, changed, join(transfer, "incoming"));
40
+ for (const entry of manifest) {
41
+ if (!sameLocalFile(entry, await fileManifest(join(transfer, "incoming"), entry.path)))
42
+ throw new OutpostError("workspace", "Incoming file checksum mismatch", {
43
+ file: entry.path,
44
+ });
45
+ }
46
+ }
47
+ else
48
+ for (const file of incoming) {
49
+ await lease.download(posix.join(lease.root, file), await safeDestination(join(transfer, "incoming"), file));
50
+ }
18
51
  if (head !== synchronized) {
19
- await run(["bundle", "create", remoteBundle, "HEAD"]);
20
- await lease.download(remoteBundle, join(transfer, "commits.bundle"));
52
+ await downloadHistory(context, synchronized, head, transfer);
21
53
  }
22
- return { head, patch, incoming };
54
+ return { head, patch, incoming, ...(manifest ? { manifest } : {}) };
23
55
  }
24
56
  //# sourceMappingURL=remote-download.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"remote-download.js","sourceRoot":"","sources":["../../src/application/remote-download.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAM7D,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,OAA+B,EAC/B,YAAoB,EACpB,QAAgB;IAEhB,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,YAAY,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC;IACxD,MAAM,IAAI,GAAG,CAAC,MAAM,GAAG,CAA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,QAAQ,EAAE,CAAC;AACnC,CAAC","sourcesContent":["import { join, posix } from \"node:path\";\nimport { OutpostError } from \"../domain/errors.ts\";\nimport { safeDestination } from \"../infrastructure/files.ts\";\nimport type {\n RemoteChanges,\n RemoteWorkspaceContext,\n} from \"./remote-workspace.types.ts\";\n\nexport async function downloadChanges(\n context: RemoteWorkspaceContext,\n synchronized: string,\n transfer: string,\n): Promise<RemoteChanges> {\n const { workspace, lease, remoteBundle, run } = context;\n const head = (await run([\"rev-parse\", \"HEAD\"])).trim(),\n patch = join(transfer, \"remote.patch\");\n await run([\"diff\", \"--binary\", \"HEAD\", `--output=${remoteBundle}.patch`]);\n await lease.download(`${remoteBundle}.patch`, patch);\n const incoming = (\n await run([\"ls-files\", \"--others\", \"--exclude-standard\", \"-z\"])\n )\n .split(\"\\0\")\n .filter(Boolean);\n for (const file of incoming) {\n if (/^\\.outpost\\/(locks|recovery|workspaces|logs)(\\/|$)/i.test(file))\n throw new OutpostError(\n \"workspace\",\n \"Remote file overlaps Outpost runtime state\",\n { file },\n );\n await safeDestination(workspace.directory, file);\n await lease.download(\n posix.join(lease.root, file),\n await safeDestination(join(transfer, \"incoming\"), file),\n );\n }\n if (head !== synchronized) {\n await run([\"bundle\", \"create\", remoteBundle, \"HEAD\"]);\n await lease.download(remoteBundle, join(transfer, \"commits.bundle\"));\n }\n\n return { head, patch, incoming };\n}\n"]}
1
+ {"version":3,"file":"remote-download.js","sourceRoot":"","sources":["../../src/application/remote-download.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EACL,YAAY,EACZ,aAAa,EACb,QAAQ,EAC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L,MAAM,YAAY,CAAC,IAAI,CAAC,QAAQ,EAAE,UAAU,CAAC,EAAE,KAAK,CAAC,IAAI,CAAC,CAC3D;gBAED,MAAM,IAAI,YAAY,CAAC,WAAW,EAAE,iCAAiC,EAAE;oBACrE,IAAI,EAAE,KAAK,CAAC,IAAI;iBACjB,CAAC,CAAC;QACP,CAAC;IACH,CAAC;;QACC,KAAK,MAAM,IAAI,IAAI,QAAQ,EAAE,CAAC;YAC5B,MAAM,KAAK,CAAC,QAAQ,CAClB,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,EAC5B,MAAM,eAAe,CAAC,IAAI,CAAC,QAAQ,EAAE,UAAU,CAAC,EAAE,IAAI,CAAC,CACxD,CAAC;QACJ,CAAC;IACH,IAAI,IAAI,KAAK,YAAY,EAAE,CAAC;QAC1B,MAAM,eAAe,CAAC,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAC;IAC/D,CAAC;IAED,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC;AACtE,CAAC","sourcesContent":["import { cp, mkdir, writeFile } from \"node:fs/promises\";\nimport { dirname, join, posix } from \"node:path\";\nimport { downloadHistory } from \"./remote-history.ts\";\nimport { OutpostError } from \"../domain/errors.ts\";\nimport {\n fileManifest,\n parseManifest,\n sameFile,\n sameLocalFile,\n} from \"../infrastructure/file-manifest.ts\";\nimport type { FileManifestEntry } from \"../domain/sandbox.types.ts\";\nimport { safeDestination } from \"../infrastructure/files.ts\";\nimport type {\n RemoteChanges,\n RemoteWorkspaceContext,\n} from \"./remote-workspace.types.ts\";\n\nexport async function downloadChanges(\n context: RemoteWorkspaceContext,\n synchronized: string,\n transfer: string,\n): Promise<RemoteChanges> {\n const { workspace, lease, remoteBundle, run } = context;\n const head = (await run([\"rev-parse\", \"HEAD\"])).trim(),\n patch = join(transfer, \"remote.patch\");\n await run([\"diff\", \"--binary\", \"HEAD\", `--output=${remoteBundle}.patch`]);\n await lease.download(`${remoteBundle}.patch`, patch);\n const incoming = (\n await run([\"ls-files\", \"--others\", \"--exclude-standard\", \"-z\"])\n )\n .split(\"\\0\")\n .filter(Boolean);\n for (const file of incoming) {\n if (/^\\.outpost\\/(locks|recovery|workspaces|logs)(\\/|$)/i.test(file))\n throw new OutpostError(\n \"workspace\",\n \"Remote file overlaps Outpost runtime state\",\n { file },\n );\n await safeDestination(join(transfer, \"incoming\"), file);\n }\n let manifest: readonly FileManifestEntry[] | undefined;\n if (lease.fileTransfers) {\n manifest = parseManifest(\n await lease.fileTransfers.manifest(lease.root, incoming),\n incoming,\n );\n await writeFile(join(transfer, \"manifest.json\"), JSON.stringify(manifest), {\n mode: 0o600,\n });\n const changed: FileManifestEntry[] = [];\n for (const entry of manifest) {\n const previous = context.transferred?.get(entry.path);\n if (\n previous &&\n sameFile(previous, entry) &&\n sameLocalFile(\n entry,\n await fileManifest(workspace.directory, entry.path),\n )\n ) {\n const target = await safeDestination(\n join(transfer, \"incoming\"),\n entry.path,\n );\n await mkdir(dirname(target), { recursive: true });\n await cp(\n await safeDestination(workspace.directory, entry.path),\n target,\n { dereference: false, verbatimSymlinks: true },\n );\n continue;\n }\n changed.push(entry);\n }\n await lease.fileTransfers.downloadBatch(\n lease.root,\n changed,\n join(transfer, \"incoming\"),\n );\n for (const entry of manifest) {\n if (\n !sameLocalFile(\n entry,\n await fileManifest(join(transfer, \"incoming\"), entry.path),\n )\n )\n throw new OutpostError(\"workspace\", \"Incoming file checksum mismatch\", {\n file: entry.path,\n });\n }\n } else\n for (const file of incoming) {\n await lease.download(\n posix.join(lease.root, file),\n await safeDestination(join(transfer, \"incoming\"), file),\n );\n }\n if (head !== synchronized) {\n await downloadHistory(context, synchronized, head, transfer);\n }\n\n return { head, patch, incoming, ...(manifest ? { manifest } : {}) };\n}\n"]}
@@ -0,0 +1,6 @@
1
+ import type { SandboxLease } from "../domain/sandbox.types.ts";
2
+ import type { WorkspaceRecord } from "../domain/workspace.types.ts";
3
+ import type { RemoteSyncOptions, RemoteWorkspaceContext } from "./remote-workspace.types.ts";
4
+ export declare function seedHistory(workspace: WorkspaceRecord, lease: SandboxLease, options: RemoteSyncOptions, recovery: string, remoteBundle: string, run: RemoteWorkspaceContext["run"]): Promise<void>;
5
+ export declare function prepareHistoryValidation(context: RemoteWorkspaceContext, transfer: string): Promise<string>;
6
+ export declare function downloadHistory(context: RemoteWorkspaceContext, synchronized: string, head: string, transfer: string): Promise<void>;
@@ -0,0 +1,114 @@
1
+ import { mkdir, rename, rm } from "node:fs/promises";
2
+ import { join } from "node:path";
3
+ import { OutpostError } from "../domain/errors.js";
4
+ import { verificationGit } from "../infrastructure/git/verification-command.js";
5
+ async function probe(operation) {
6
+ try {
7
+ return await operation();
8
+ }
9
+ catch (error) {
10
+ if (error instanceof OutpostError &&
11
+ (error.details.status === 1 || error.details.status === 128))
12
+ return undefined;
13
+ if (error &&
14
+ typeof error === "object" &&
15
+ "code" in error &&
16
+ (error.code === 1 || error.code === 128))
17
+ return undefined;
18
+ throw error;
19
+ }
20
+ }
21
+ export async function seedHistory(workspace, lease, options, recovery, remoteBundle, run) {
22
+ const local = (args) => verificationGit(workspace.directory, args, options.limits?.gitMs, options.signal);
23
+ const bundle = join(recovery, "initial.bundle");
24
+ await local(["bundle", "create", bundle, "--all", "HEAD"]);
25
+ const head = (await local(["rev-parse", "HEAD"])).trim();
26
+ const candidate = (await probe(() => run(["rev-parse", "--verify", "HEAD"])))?.trim();
27
+ let base;
28
+ if (candidate &&
29
+ /^(?:[a-f0-9]{40}|[a-f0-9]{64})$/.test(candidate) &&
30
+ (await probe(() => local(["merge-base", "--is-ancestor", candidate, head]))) !== undefined &&
31
+ (await probe(() => run(["rev-list", "--objects", "--missing=error", "--quiet", candidate]))) !== undefined)
32
+ base = candidate;
33
+ if (base === head) {
34
+ await run(["checkout", "-B", workspace.branch, head]);
35
+ return;
36
+ }
37
+ let payload = bundle;
38
+ if (base) {
39
+ payload = join(recovery, "initial-delta.bundle");
40
+ await local(["bundle", "create", payload, "--all", "HEAD", `^${base}`]);
41
+ }
42
+ await lease.upload(payload, remoteBundle, {
43
+ ...(options.signal ? { signal: options.signal } : {}),
44
+ ...(options.limits?.copyMs ? { deadlineMs: options.limits.copyMs } : {}),
45
+ });
46
+ if (base &&
47
+ (await probe(() => run(["bundle", "verify", remoteBundle]))) === undefined)
48
+ await lease.upload(bundle, remoteBundle, {
49
+ ...(options.signal ? { signal: options.signal } : {}),
50
+ ...(options.limits?.copyMs ? { deadlineMs: options.limits.copyMs } : {}),
51
+ });
52
+ await run(["bundle", "verify", remoteBundle]);
53
+ await run(["fetch", remoteBundle, "HEAD"]);
54
+ await run(["checkout", "-B", workspace.branch, "FETCH_HEAD"]);
55
+ }
56
+ export async function prepareHistoryValidation(context, transfer) {
57
+ const validation = join(transfer, "validation");
58
+ await mkdir(validation, { recursive: true });
59
+ const snapshot = join(transfer, "host.bundle");
60
+ const run = (directory, args) => verificationGit(directory, args, context.options.limits?.gitMs);
61
+ await run(context.workspace.directory, [
62
+ "bundle",
63
+ "create",
64
+ snapshot,
65
+ "HEAD",
66
+ ]);
67
+ const format = (await run(context.workspace.directory, [
68
+ "rev-parse",
69
+ "--show-object-format",
70
+ ])).trim();
71
+ await run(validation, ["init", `--object-format=${format}`]);
72
+ await run(validation, ["config", "core.autocrlf", "false"]);
73
+ await run(validation, ["fetch", snapshot, "HEAD"]);
74
+ await run(validation, ["update-ref", "HEAD", "FETCH_HEAD"]);
75
+ await rm(snapshot);
76
+ return validation;
77
+ }
78
+ export async function downloadHistory(context, synchronized, head, transfer) {
79
+ const { run, lease, remoteBundle, options } = context;
80
+ const validation = await prepareHistoryValidation(context, transfer);
81
+ const local = (args) => verificationGit(validation, args, options.limits?.gitMs);
82
+ const usable = (await probe(() => local([
83
+ "rev-list",
84
+ "--objects",
85
+ "--missing=error",
86
+ "--quiet",
87
+ synchronized,
88
+ ]))) !== undefined &&
89
+ (await probe(() => run(["merge-base", "--is-ancestor", synchronized, head]))) !== undefined;
90
+ await run([
91
+ "bundle",
92
+ "create",
93
+ remoteBundle,
94
+ "HEAD",
95
+ ...(usable ? [`^${synchronized}`] : []),
96
+ ]);
97
+ const bundle = join(transfer, "commits.bundle");
98
+ const received = usable ? join(transfer, "commits-delta.bundle") : bundle;
99
+ await lease.download(remoteBundle, received, {
100
+ ...(options.limits?.copyMs ? { deadlineMs: options.limits.copyMs } : {}),
101
+ });
102
+ await local(["bundle", "verify", received]);
103
+ await local(["fetch", received, "HEAD"]);
104
+ if ((await local(["rev-parse", "FETCH_HEAD"])).trim() !== head)
105
+ throw new OutpostError("workspace", "Remote bundle HEAD changed during synchronization");
106
+ await local(["rev-list", "--objects", "--missing=error", "--quiet", head]);
107
+ await local(["update-ref", "HEAD", head]);
108
+ const complete = join(transfer, "complete.bundle");
109
+ await local(["bundle", "create", complete, "HEAD"]);
110
+ await rename(complete, bundle);
111
+ if (usable)
112
+ await rm(received);
113
+ }
114
+ //# sourceMappingURL=remote-history.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"remote-history.js","sourceRoot":"","sources":["../../src/application/remote-history.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAGnD,OAAO,EAAE,eAAe,EAAE,MAAM,+CAA+C,CAAC;AAMhF,KAAK,UAAU,KAAK,CAClB,SAAgC;IAEhC,IAAI,CAAC;QACH,OAAO,MAAM,SAAS,EAAE,CAAC;IAC3B,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IACE,KAAK,YAAY,YAAY;YAC7B,CAAC,KAAK,CAAC,OAAO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,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC;IACpD,MAAM,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;IAC/B,IAAI,MAAM;QAAE,MAAM,EAAE,CAAC,QAAQ,CAAC,CAAC;AACjC,CAAC","sourcesContent":["import { mkdir, rename, rm } from \"node:fs/promises\";\nimport { join } from \"node:path\";\nimport { OutpostError } from \"../domain/errors.ts\";\nimport type { SandboxLease } from \"../domain/sandbox.types.ts\";\nimport type { WorkspaceRecord } from \"../domain/workspace.types.ts\";\nimport { verificationGit } from \"../infrastructure/git/verification-command.ts\";\nimport type {\n RemoteSyncOptions,\n RemoteWorkspaceContext,\n} from \"./remote-workspace.types.ts\";\n\nasync function probe(\n operation: () => Promise<string>,\n): Promise<string | undefined> {\n try {\n return await operation();\n } catch (error) {\n if (\n error instanceof OutpostError &&\n (error.details.status === 1 || error.details.status === 128)\n )\n return undefined;\n if (\n error &&\n typeof error === \"object\" &&\n \"code\" in error &&\n (error.code === 1 || error.code === 128)\n )\n return undefined;\n throw error;\n }\n}\n\nexport async function seedHistory(\n workspace: WorkspaceRecord,\n lease: SandboxLease,\n options: RemoteSyncOptions,\n recovery: string,\n remoteBundle: string,\n run: RemoteWorkspaceContext[\"run\"],\n): Promise<void> {\n const local = (args: readonly string[]) =>\n verificationGit(\n workspace.directory,\n args,\n options.limits?.gitMs,\n options.signal,\n );\n const bundle = join(recovery, \"initial.bundle\");\n await local([\"bundle\", \"create\", bundle, \"--all\", \"HEAD\"]);\n const head = (await local([\"rev-parse\", \"HEAD\"])).trim();\n const candidate = (\n await probe(() => run([\"rev-parse\", \"--verify\", \"HEAD\"]))\n )?.trim();\n let base: string | undefined;\n if (\n candidate &&\n /^(?:[a-f0-9]{40}|[a-f0-9]{64})$/.test(candidate) &&\n (await probe(() =>\n local([\"merge-base\", \"--is-ancestor\", candidate, head]),\n )) !== undefined &&\n (await probe(() =>\n run([\"rev-list\", \"--objects\", \"--missing=error\", \"--quiet\", candidate]),\n )) !== undefined\n )\n base = candidate;\n if (base === head) {\n await run([\"checkout\", \"-B\", workspace.branch, head]);\n return;\n }\n let payload = bundle;\n if (base) {\n payload = join(recovery, \"initial-delta.bundle\");\n await local([\"bundle\", \"create\", payload, \"--all\", \"HEAD\", `^${base}`]);\n }\n await lease.upload(payload, remoteBundle, {\n ...(options.signal ? { signal: options.signal } : {}),\n ...(options.limits?.copyMs ? { deadlineMs: options.limits.copyMs } : {}),\n });\n if (\n base &&\n (await probe(() => run([\"bundle\", \"verify\", remoteBundle]))) === undefined\n )\n await lease.upload(bundle, remoteBundle, {\n ...(options.signal ? { signal: options.signal } : {}),\n ...(options.limits?.copyMs ? { deadlineMs: options.limits.copyMs } : {}),\n });\n await run([\"bundle\", \"verify\", remoteBundle]);\n await run([\"fetch\", remoteBundle, \"HEAD\"]);\n await run([\"checkout\", \"-B\", workspace.branch, \"FETCH_HEAD\"]);\n}\n\nexport async function prepareHistoryValidation(\n context: RemoteWorkspaceContext,\n transfer: string,\n): Promise<string> {\n const validation = join(transfer, \"validation\");\n await mkdir(validation, { recursive: true });\n const snapshot = join(transfer, \"host.bundle\");\n const run = (directory: string, args: readonly string[]) =>\n verificationGit(directory, args, context.options.limits?.gitMs);\n await run(context.workspace.directory, [\n \"bundle\",\n \"create\",\n snapshot,\n \"HEAD\",\n ]);\n const format = (\n await run(context.workspace.directory, [\n \"rev-parse\",\n \"--show-object-format\",\n ])\n ).trim();\n await run(validation, [\"init\", `--object-format=${format}`]);\n await run(validation, [\"config\", \"core.autocrlf\", \"false\"]);\n await run(validation, [\"fetch\", snapshot, \"HEAD\"]);\n await run(validation, [\"update-ref\", \"HEAD\", \"FETCH_HEAD\"]);\n await rm(snapshot);\n return validation;\n}\n\nexport async function downloadHistory(\n context: RemoteWorkspaceContext,\n synchronized: string,\n head: string,\n transfer: string,\n): Promise<void> {\n const { run, lease, remoteBundle, options } = context;\n const validation = await prepareHistoryValidation(context, transfer);\n const local = (args: readonly string[]) =>\n verificationGit(validation, args, options.limits?.gitMs);\n const usable =\n (await probe(() =>\n local([\n \"rev-list\",\n \"--objects\",\n \"--missing=error\",\n \"--quiet\",\n synchronized,\n ]),\n )) !== undefined &&\n (await probe(() =>\n run([\"merge-base\", \"--is-ancestor\", synchronized, head]),\n )) !== undefined;\n await run([\n \"bundle\",\n \"create\",\n remoteBundle,\n \"HEAD\",\n ...(usable ? [`^${synchronized}`] : []),\n ]);\n const bundle = join(transfer, \"commits.bundle\");\n const received = usable ? join(transfer, \"commits-delta.bundle\") : bundle;\n await lease.download(remoteBundle, received, {\n ...(options.limits?.copyMs ? { deadlineMs: options.limits.copyMs } : {}),\n });\n await local([\"bundle\", \"verify\", received]);\n await local([\"fetch\", received, \"HEAD\"]);\n if ((await local([\"rev-parse\", \"FETCH_HEAD\"])).trim() !== head)\n throw new OutpostError(\n \"workspace\",\n \"Remote bundle HEAD changed during synchronization\",\n );\n await local([\"rev-list\", \"--objects\", \"--missing=error\", \"--quiet\", head]);\n await local([\"update-ref\", \"HEAD\", head]);\n const complete = join(transfer, \"complete.bundle\");\n await local([\"bundle\", \"create\", complete, \"HEAD\"]);\n await rename(complete, bundle);\n if (usable) await rm(received);\n}\n"]}
@@ -0,0 +1,2 @@
1
+ import type { SandboxLease, TransferOptions } from "../domain/sandbox.types.ts";
2
+ export declare function uploadFiles(lease: SandboxLease, source: string, paths: readonly string[], options?: TransferOptions): Promise<void>;
@@ -0,0 +1,17 @@
1
+ import { posix } from "node:path";
2
+ import { fileManifest } from "../infrastructure/file-manifest.js";
3
+ import { safeDestination } from "../infrastructure/files.js";
4
+ export async function uploadFiles(lease, source, paths, options = {}) {
5
+ if (lease.fileTransfers?.uploadBatch) {
6
+ const entries = [];
7
+ for (const path of paths) {
8
+ options.signal?.throwIfAborted();
9
+ entries.push(await fileManifest(source, path, options.signal));
10
+ }
11
+ await lease.fileTransfers.uploadBatch(source, entries, lease.root, options);
12
+ return;
13
+ }
14
+ for (const path of paths)
15
+ await lease.upload(await safeDestination(source, path), posix.join(lease.root, path), options);
16
+ }
17
+ //# sourceMappingURL=remote-upload.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"remote-upload.js","sourceRoot":"","sources":["../../src/application/remote-upload.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAElC,OAAO,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAClE,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAE7D,MAAM,CAAC,KAAK,UAAU,WAAW,CAC/B,KAAmB,EACnB,MAAc,EACd,KAAwB,EACxB,UAA2B,EAAE;IAE7B,IAAI,KAAK,CAAC,aAAa,EAAE,WAAW,EAAE,CAAC;QACrC,MAAM,OAAO,GAAG,EAAE,CAAC;QACnB,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YACzB,OAAO,CAAC,MAAM,EAAE,cAAc,EAAE,CAAC;YACjC,OAAO,CAAC,IAAI,CAAC,MAAM,YAAY,CAAC,MAAM,EAAE,IAAI,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;QACjE,CAAC;QACD,MAAM,KAAK,CAAC,aAAa,CAAC,WAAW,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QAC5E,OAAO;IACT,CAAC;IACD,KAAK,MAAM,IAAI,IAAI,KAAK;QACtB,MAAM,KAAK,CAAC,MAAM,CAChB,MAAM,eAAe,CAAC,MAAM,EAAE,IAAI,CAAC,EACnC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,EAC5B,OAAO,CACR,CAAC;AACN,CAAC","sourcesContent":["import { posix } from \"node:path\";\nimport type { SandboxLease, TransferOptions } from \"../domain/sandbox.types.ts\";\nimport { fileManifest } from \"../infrastructure/file-manifest.ts\";\nimport { safeDestination } from \"../infrastructure/files.ts\";\n\nexport async function uploadFiles(\n lease: SandboxLease,\n source: string,\n paths: readonly string[],\n options: TransferOptions = {},\n): Promise<void> {\n if (lease.fileTransfers?.uploadBatch) {\n const entries = [];\n for (const path of paths) {\n options.signal?.throwIfAborted();\n entries.push(await fileManifest(source, path, options.signal));\n }\n await lease.fileTransfers.uploadBatch(source, entries, lease.root, options);\n return;\n }\n for (const path of paths)\n await lease.upload(\n await safeDestination(source, path),\n posix.join(lease.root, path),\n options,\n );\n}\n"]}
@@ -1,11 +1,32 @@
1
- import { readFile } from "node:fs/promises";
1
+ import { readFile, rm } from "node:fs/promises";
2
2
  import { join } from "node:path";
3
+ import { prepareHistoryValidation } from "./remote-history.js";
4
+ import { verificationGit } from "../infrastructure/git/verification-command.js";
3
5
  import { OutpostError } from "../domain/errors.js";
4
6
  import { git } from "../infrastructure/git/command.js";
7
+ import { remoteSyncLimits } from "./remote-workspace.constants.js";
5
8
  import { digest } from "./workspace-fingerprint.js";
6
9
  export async function validateChanges(context, changes, synchronized, expected, transfer) {
7
10
  const { workspace, options, recovery, run, protectedFiles, originalHead, initialPatch, initialIndex, } = context;
8
11
  const { head, patch, incoming } = changes;
12
+ const ignoredOverlaps = [];
13
+ for (let offset = 0; offset < incoming.length; offset += remoteSyncLimits.pathspecs) {
14
+ ignoredOverlaps.push(...(await git(workspace.directory, [
15
+ "ls-files",
16
+ "--others",
17
+ "--ignored",
18
+ "--exclude-standard",
19
+ "-z",
20
+ "--",
21
+ ...incoming
22
+ .slice(offset, offset + remoteSyncLimits.pathspecs)
23
+ .map((path) => `:(literal)${path}`),
24
+ ]))
25
+ .split("\0")
26
+ .filter(Boolean));
27
+ }
28
+ if (ignoredOverlaps.length)
29
+ throw new OutpostError("conflict", "Remote changes overlap ignored host files", { files: ignoredOverlaps, recovery: transfer });
9
30
  if (protectedFiles.length) {
10
31
  const changed = new Set([
11
32
  ...(await run(["diff", "--name-only", "-z", originalHead]))
@@ -21,42 +42,32 @@ export async function validateChanges(context, changes, synchronized, expected,
21
42
  }
22
43
  if ((await digest(workspace.directory, recovery)) !== expected)
23
44
  throw new OutpostError("conflict", "Host workspace changed while the remote sandbox was active", { recovery });
24
- if (head !== synchronized) {
25
- await git(workspace.directory, [
26
- "fetch",
27
- join(transfer, "commits.bundle"),
28
- "HEAD",
29
- ]);
30
- await git(workspace.directory, [
45
+ const validation = join(transfer, "validation");
46
+ if (head === synchronized)
47
+ await prepareHistoryValidation(context, transfer);
48
+ if (head !== synchronized)
49
+ await verificationGit(validation, [
31
50
  "merge-base",
32
51
  "--is-ancestor",
33
- "HEAD",
34
- "FETCH_HEAD",
52
+ synchronized,
53
+ head,
35
54
  ]);
36
- }
37
- const validation = join(transfer, "validation");
38
- await git(workspace.directory, [
39
- "worktree",
40
- "add",
41
- "--detach",
42
- validation,
43
- head,
44
- ]);
55
+ await verificationGit(validation, ["checkout", "--detach", head]);
45
56
  try {
46
57
  if ((await readFile(patch)).length)
47
- await git(validation, ["apply", "--binary", patch]);
58
+ await verificationGit(validation, ["apply", "--binary", patch]);
48
59
  if (!options.includeUncommitted && (await readFile(initialPatch)).length)
49
- await git(validation, ["apply", "--binary", initialPatch]);
60
+ await verificationGit(validation, ["apply", "--binary", initialPatch]);
50
61
  if (!options.includeUncommitted && (await readFile(initialIndex)).length)
51
- await git(validation, ["apply", "--cached", "--binary", initialIndex]);
62
+ await verificationGit(validation, [
63
+ "apply",
64
+ "--cached",
65
+ "--binary",
66
+ initialIndex,
67
+ ]);
52
68
  }
53
69
  finally {
54
- await git(workspace.directory, [
55
- "worktree",
56
- "remove",
57
- "--force",
58
- validation,
59
- ]);
70
+ await rm(validation, { recursive: true, force: true });
60
71
  }
61
72
  }
62
73
  //# sourceMappingURL=remote-validation.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"remote-validation.js","sourceRoot":"","sources":["../../src/application/remote-validation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,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,CAAC;QACT,MAAM,GAAG,CAAC,SAAS,CAAC,SAAS,EAAE;YAC7B,UAAU;YACV,QAAQ;YACR,SAAS;YACT,UAAU;SACX,CAAC,CAAC;IACL,CAAC;AACH,CAAC","sourcesContent":["import { readFile } from \"node:fs/promises\";\nimport { join } from \"node:path\";\nimport { OutpostError } from \"../domain/errors.ts\";\nimport { git } from \"../infrastructure/git/command.ts\";\nimport type {\n RemoteChanges,\n RemoteWorkspaceContext,\n} from \"./remote-workspace.types.ts\";\nimport { digest } from \"./workspace-fingerprint.ts\";\n\nexport async function validateChanges(\n context: RemoteWorkspaceContext,\n changes: RemoteChanges,\n synchronized: string,\n expected: string,\n transfer: string,\n): Promise<void> {\n const {\n workspace,\n options,\n recovery,\n run,\n protectedFiles,\n originalHead,\n initialPatch,\n initialIndex,\n } = context;\n const { head, patch, incoming } = changes;\n if (protectedFiles.length) {\n const changed = new Set([\n ...(await run([\"diff\", \"--name-only\", \"-z\", originalHead]))\n .split(\"\\0\")\n .filter(Boolean),\n ...incoming,\n ]);\n const overlaps = protectedFiles.filter((file) =>\n [...changed].some(\n (path) =>\n path === file ||\n path.startsWith(`${file}/`) ||\n file.startsWith(`${path}/`),\n ),\n );\n if (overlaps.length)\n throw new OutpostError(\n \"conflict\",\n \"Remote changes overlap uncommitted host files\",\n { files: overlaps, recovery: transfer },\n );\n }\n if ((await digest(workspace.directory, recovery)) !== expected)\n throw new OutpostError(\n \"conflict\",\n \"Host workspace changed while the remote sandbox was active\",\n { recovery },\n );\n if (head !== synchronized) {\n await git(workspace.directory, [\n \"fetch\",\n join(transfer, \"commits.bundle\"),\n \"HEAD\",\n ]);\n await git(workspace.directory, [\n \"merge-base\",\n \"--is-ancestor\",\n \"HEAD\",\n \"FETCH_HEAD\",\n ]);\n }\n const validation = join(transfer, \"validation\");\n await git(workspace.directory, [\n \"worktree\",\n \"add\",\n \"--detach\",\n validation,\n head,\n ]);\n try {\n if ((await readFile(patch)).length)\n await git(validation, [\"apply\", \"--binary\", patch]);\n if (!options.includeUncommitted && (await readFile(initialPatch)).length)\n await git(validation, [\"apply\", \"--binary\", initialPatch]);\n if (!options.includeUncommitted && (await readFile(initialIndex)).length)\n await git(validation, [\"apply\", \"--cached\", \"--binary\", initialIndex]);\n } finally {\n await git(workspace.directory, [\n \"worktree\",\n \"remove\",\n \"--force\",\n validation,\n ]);\n }\n}\n"]}
1
+ {"version":3,"file":"remote-validation.js","sourceRoot":"","sources":["../../src/application/remote-validation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAAE,eAAe,EAAE,MAAM,+CAA+C,CAAC;AAChF,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,GAAG,EAAE,MAAM,kCAAkC,CAAC;AAKvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AAEpD,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,OAA+B,EAC/B,OAAsB,EACtB,YAAoB,EACpB,QAAgB,EAChB,QAAgB;IAEhB,MAAM,EACJ,SAAS,EACT,OAAO,EACP,QAAQ,EACR,GAAG,EACH,cAAc,EACd,YAAY,EACZ,YAAY,EACZ,YAAY,GACb,GAAG,OAAO,CAAC;IACZ,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC;IAC1C,MAAM,eAAe,GAAa,EAAE,CAAC;IACrC,KACE,IAAI,MAAM,GAAG,CAAC,EACd,MAAM,GAAG,QAAQ,CAAC,MAAM,EACxB,MAAM,IAAI,gBAAgB,CAAC,SAAS,EACpC,CAAC;QACD,eAAe,CAAC,IAAI,CAClB,GAAG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AE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IACzD,CAAC;AACH,CAAC","sourcesContent":["import { readFile, rm } from \"node:fs/promises\";\nimport { join } from \"node:path\";\nimport { prepareHistoryValidation } from \"./remote-history.ts\";\nimport { verificationGit } from \"../infrastructure/git/verification-command.ts\";\nimport { OutpostError } from \"../domain/errors.ts\";\nimport { git } from \"../infrastructure/git/command.ts\";\nimport type {\n RemoteChanges,\n RemoteWorkspaceContext,\n} from \"./remote-workspace.types.ts\";\nimport { remoteSyncLimits } from \"./remote-workspace.constants.ts\";\nimport { digest } from \"./workspace-fingerprint.ts\";\n\nexport async function validateChanges(\n context: RemoteWorkspaceContext,\n changes: RemoteChanges,\n synchronized: string,\n expected: string,\n transfer: string,\n): Promise<void> {\n const {\n workspace,\n options,\n recovery,\n run,\n protectedFiles,\n originalHead,\n initialPatch,\n initialIndex,\n } = context;\n const { head, patch, incoming } = changes;\n const ignoredOverlaps: string[] = [];\n for (\n let offset = 0;\n offset < incoming.length;\n offset += remoteSyncLimits.pathspecs\n ) {\n ignoredOverlaps.push(\n ...(\n await git(workspace.directory, [\n \"ls-files\",\n \"--others\",\n \"--ignored\",\n \"--exclude-standard\",\n \"-z\",\n \"--\",\n ...incoming\n .slice(offset, offset + remoteSyncLimits.pathspecs)\n .map((path) => `:(literal)${path}`),\n ])\n )\n .split(\"\\0\")\n .filter(Boolean),\n );\n }\n if (ignoredOverlaps.length)\n throw new OutpostError(\n \"conflict\",\n \"Remote changes overlap ignored host files\",\n { files: ignoredOverlaps, recovery: transfer },\n );\n if (protectedFiles.length) {\n const changed = new Set([\n ...(await run([\"diff\", \"--name-only\", \"-z\", originalHead]))\n .split(\"\\0\")\n .filter(Boolean),\n ...incoming,\n ]);\n const overlaps = protectedFiles.filter((file) =>\n [...changed].some(\n (path) =>\n path === file ||\n path.startsWith(`${file}/`) ||\n file.startsWith(`${path}/`),\n ),\n );\n if (overlaps.length)\n throw new OutpostError(\n \"conflict\",\n \"Remote changes overlap uncommitted host files\",\n { files: overlaps, recovery: transfer },\n );\n }\n if ((await digest(workspace.directory, recovery)) !== expected)\n throw new OutpostError(\n \"conflict\",\n \"Host workspace changed while the remote sandbox was active\",\n { recovery },\n );\n const validation = join(transfer, \"validation\");\n if (head === synchronized) await prepareHistoryValidation(context, transfer);\n if (head !== synchronized)\n await verificationGit(validation, [\n \"merge-base\",\n \"--is-ancestor\",\n synchronized,\n head,\n ]);\n await verificationGit(validation, [\"checkout\", \"--detach\", head]);\n try {\n if ((await readFile(patch)).length)\n await verificationGit(validation, [\"apply\", \"--binary\", patch]);\n if (!options.includeUncommitted && (await readFile(initialPatch)).length)\n await verificationGit(validation, [\"apply\", \"--binary\", initialPatch]);\n if (!options.includeUncommitted && (await readFile(initialIndex)).length)\n await verificationGit(validation, [\n \"apply\",\n \"--cached\",\n \"--binary\",\n initialIndex,\n ]);\n } finally {\n await rm(validation, { recursive: true, force: true });\n }\n}\n"]}
@@ -0,0 +1,3 @@
1
+ export declare const remoteSyncLimits: {
2
+ readonly pathspecs: 32;
3
+ };
@@ -0,0 +1,2 @@
1
+ export const remoteSyncLimits = { pathspecs: 32 };
2
+ //# sourceMappingURL=remote-workspace.constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"remote-workspace.constants.js","sourceRoot":"","sources":["../../src/application/remote-workspace.constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,gBAAgB,GAAG,EAAE,SAAS,EAAE,EAAE,EAAW,CAAC","sourcesContent":["export const remoteSyncLimits = { pathspecs: 32 } as const;\n"]}
@@ -2,7 +2,8 @@ import { randomUUID } from "node:crypto";
2
2
  import { mkdir, readFile, rm } from "node:fs/promises";
3
3
  import { join, posix } from "node:path";
4
4
  import { OutpostError } from "../domain/errors.js";
5
- import { safeDestination } from "../infrastructure/files.js";
5
+ import { seedHistory } from "./remote-history.js";
6
+ import { uploadFiles } from "./remote-upload.js";
6
7
  import { git } from "../infrastructure/git/command.js";
7
8
  import { gitDefaults } from "../infrastructure/git/git.constants.js";
8
9
  import { applyChanges } from "./remote-apply.js";
@@ -14,10 +15,7 @@ export async function seedRemote(workspace, lease, options = {}) {
14
15
  options.signal?.throwIfAborted();
15
16
  const recovery = join(workspace.repository, ".outpost", "recovery", randomUUID());
16
17
  await mkdir(recovery, { recursive: true });
17
- const bundle = join(recovery, "initial.bundle");
18
- await git(workspace.directory, ["bundle", "create", bundle, "--all", "HEAD"]);
19
18
  const remoteBundle = posix.join(lease.root.replaceAll("\\", "/"), "..", `outpost-${randomUUID()}.bundle`);
20
- await lease.upload(bundle, remoteBundle);
21
19
  let initializing = true, failed = false;
22
20
  const run = async (args) => {
23
21
  let result;
@@ -40,12 +38,13 @@ export async function seedRemote(workspace, lease, options = {}) {
40
38
  ...result,
41
39
  recovery,
42
40
  });
41
+ if (result.stdout.length >= gitDefaults.retainBytes)
42
+ throw new OutpostError("workspace", "Remote Git output exceeds synchronization limit", { recovery });
43
43
  return result.stdout;
44
44
  };
45
45
  await run(["init"]);
46
46
  await run(["config", "core.autocrlf", "false"]);
47
- await run(["fetch", remoteBundle, "HEAD"]);
48
- await run(["checkout", "-B", workspace.branch, "FETCH_HEAD"]);
47
+ await seedHistory(workspace, lease, options, recovery, remoteBundle, run);
49
48
  for (const key of ["user.name", "user.email"]) {
50
49
  const fallback = key === "user.name" ? "Outpost" : "outpost@localhost";
51
50
  const value = (await git(workspace.repository, ["config", "--get", key]).catch(() => fallback)).trim() || fallback;
@@ -78,14 +77,12 @@ export async function seedRemote(workspace, lease, options = {}) {
78
77
  await lease.upload(initialPatch, `${remoteBundle}.patch`);
79
78
  await run(["apply", "--binary", `${remoteBundle}.patch`]);
80
79
  }
81
- for (const file of options.includeUncommitted
82
- ? await extras(workspace.directory)
83
- : [])
84
- await lease.upload(await safeDestination(workspace.directory, file), posix.join(lease.root, file));
80
+ await uploadFiles(lease, workspace.directory, options.includeUncommitted ? await extras(workspace.directory) : [], { ...(options.signal ? { signal: options.signal } : {}) });
85
81
  let synchronized = (await run(["rev-parse", "HEAD"])).trim();
86
82
  initializing = false;
87
83
  let expected = await digest(workspace.directory, recovery);
88
84
  const context = {
85
+ transferred: new Map(),
89
86
  workspace,
90
87
  lease,
91
88
  options,
@@ -110,6 +107,9 @@ export async function seedRemote(workspace, lease, options = {}) {
110
107
  await validateChanges(context, changes, synchronized, expected, transfer);
111
108
  const backup = await backupHost(context, changes, synchronized, transfer);
112
109
  await applyChanges(context, changes, backup, synchronized, expected, transfer);
110
+ context.transferred?.clear();
111
+ for (const entry of changes.manifest ?? [])
112
+ context.transferred?.set(entry.path, entry);
113
113
  const { head } = changes;
114
114
  synchronized = head;
115
115
  expected = await digest(workspace.directory, recovery);
@@ -1 +1 @@
1
- {"version":3,"file":"remote-workspace.js","sourceRoot":"","sources":["../../src/application/remote-workspace.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAGnD,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAE,GAAG,EAAE,MAAM,kCAAkC,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,wCAAwC,CAAC;AACrE,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAMzD,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AAO5D,MAAM,CAAC,KAAK,UAAU,UAAU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AAO,EACP,YAAY,EACZ,QAAQ,EACR,QAAQ,CACT,CAAC;gBACF,MAAM,MAAM,GAAG,MAAM,UAAU,CAC7B,OAAO,EACP,OAAO,EACP,YAAY,EACZ,QAAQ,CACT,CAAC;gBACF,MAAM,YAAY,CAChB,OAAO,EACP,OAAO,EACP,MAAM,EACN,YAAY,EACZ,QAAQ,EACR,QAAQ,CACT,CAAC;gBACF,MAAM,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC;gBACzB,YAAY,GAAG,IAAI,CAAC;gBACpB,QAAQ,GAAG,MAAM,MAAM,CAAC,SAAS,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;gBACvD,MAAM,EAAE,CAAC,QAAQ,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;YACvD,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,MAAM,GAAG,IAAI,CAAC;gBACd,MAAM,IAAI,YAAY,CACpB,WAAW,EACX,yEAAyE,EACzE,EAAE,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,CAAC,SAAS,EAAE,EACtD,KAAK,CACN,CAAC;YACJ,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { randomUUID } from \"node:crypto\";\nimport { mkdir, readFile, rm } from \"node:fs/promises\";\nimport { join, posix } from \"node:path\";\nimport { OutpostError } from \"../domain/errors.ts\";\nimport type { SandboxLease } from \"../domain/sandbox.types.ts\";\nimport type { WorkspaceRecord } from \"../domain/workspace.types.ts\";\nimport { safeDestination } from \"../infrastructure/files.ts\";\nimport { git } from \"../infrastructure/git/command.ts\";\nimport { gitDefaults } from \"../infrastructure/git/git.constants.ts\";\nimport { applyChanges } from \"./remote-apply.ts\";\nimport { backupHost } from \"./remote-backup.ts\";\nimport { downloadChanges } from \"./remote-download.ts\";\nimport { validateChanges } from \"./remote-validation.ts\";\nimport type {\n RemoteSync,\n RemoteSyncOptions,\n RemoteWorkspaceContext,\n} from \"./remote-workspace.types.ts\";\nimport { digest, extras } from \"./workspace-fingerprint.ts\";\n\nexport type {\n RemoteSync,\n RemoteSyncOptions,\n} from \"./remote-workspace.types.ts\";\n\nexport async function seedRemote(\n workspace: WorkspaceRecord,\n lease: SandboxLease,\n options: RemoteSyncOptions = {},\n): Promise<RemoteSync> {\n options.signal?.throwIfAborted();\n const recovery = join(\n workspace.repository,\n \".outpost\",\n \"recovery\",\n randomUUID(),\n );\n await mkdir(recovery, { recursive: true });\n const bundle = join(recovery, \"initial.bundle\");\n await git(workspace.directory, [\"bundle\", \"create\", bundle, \"--all\", \"HEAD\"]);\n const remoteBundle = posix.join(\n lease.root.replaceAll(\"\\\\\", \"/\"),\n \"..\",\n `outpost-${randomUUID()}.bundle`,\n );\n await lease.upload(bundle, remoteBundle);\n let initializing = true,\n failed = false;\n const run = async (args: readonly string[]) => {\n let result;\n for (let attempt = 0; attempt < 3; attempt++) {\n result = await lease.invoke({\n executable: \"git\",\n arguments: args,\n directory: lease.root,\n retain: gitDefaults.retainBytes,\n ...(initializing && options.signal ? { signal: options.signal } : {}),\n ...(options.limits?.gitMs ? { deadlineMs: options.limits.gitMs } : {}),\n });\n if (!initializing || result.status !== 126) break;\n }\n if (!result)\n throw new OutpostError(\"workspace\", \"Remote Git did not start\");\n if (result.status !== 0)\n throw new OutpostError(\"workspace\", \"Remote Git operation failed\", {\n ...result,\n recovery,\n });\n return result.stdout;\n };\n await run([\"init\"]);\n await run([\"config\", \"core.autocrlf\", \"false\"]);\n await run([\"fetch\", remoteBundle, \"HEAD\"]);\n await run([\"checkout\", \"-B\", workspace.branch, \"FETCH_HEAD\"]);\n for (const key of [\"user.name\", \"user.email\"] as const) {\n const fallback = key === \"user.name\" ? \"Outpost\" : \"outpost@localhost\";\n const value =\n (\n await git(workspace.repository, [\"config\", \"--get\", key]).catch(\n () => fallback,\n )\n ).trim() || fallback;\n await run([\"config\", key, value]);\n }\n const initialPatch = join(recovery, \"initial.patch\");\n await git(workspace.directory, [\n \"diff\",\n \"--binary\",\n \"HEAD\",\n `--output=${initialPatch}`,\n ]);\n const initialIndex = join(recovery, \"initial-index.patch\");\n await git(workspace.directory, [\n \"diff\",\n \"--cached\",\n \"--binary\",\n `--output=${initialIndex}`,\n ]);\n const protectedFiles = options.includeUncommitted\n ? []\n : [\n ...(\n await git(workspace.directory, [\"diff\", \"--name-only\", \"-z\", \"HEAD\"])\n )\n .split(\"\\0\")\n .filter(Boolean),\n ...(await extras(workspace.directory)),\n ];\n const originalHead = (\n await git(workspace.directory, [\"rev-parse\", \"HEAD\"])\n ).trim();\n if (options.includeUncommitted && (await readFile(initialPatch)).length) {\n await lease.upload(initialPatch, `${remoteBundle}.patch`);\n await run([\"apply\", \"--binary\", `${remoteBundle}.patch`]);\n }\n for (const file of options.includeUncommitted\n ? await extras(workspace.directory)\n : [])\n await lease.upload(\n await safeDestination(workspace.directory, file),\n posix.join(lease.root, file),\n );\n let synchronized = (await run([\"rev-parse\", \"HEAD\"])).trim();\n initializing = false;\n let expected = await digest(workspace.directory, recovery);\n const context: RemoteWorkspaceContext = {\n workspace,\n lease,\n options,\n recovery,\n remoteBundle,\n run,\n protectedFiles,\n originalHead,\n initialPatch,\n initialIndex,\n };\n return {\n async close() {\n if (!failed) await rm(recovery, { recursive: true, force: true });\n },\n async pull() {\n const transfer = join(recovery, randomUUID());\n await mkdir(transfer, { recursive: true });\n try {\n const changes = await downloadChanges(context, synchronized, transfer);\n await validateChanges(\n context,\n changes,\n synchronized,\n expected,\n transfer,\n );\n const backup = await backupHost(\n context,\n changes,\n synchronized,\n transfer,\n );\n await applyChanges(\n context,\n changes,\n backup,\n synchronized,\n expected,\n transfer,\n );\n const { head } = changes;\n synchronized = head;\n expected = await digest(workspace.directory, recovery);\n await rm(transfer, { recursive: true, force: true });\n } catch (cause) {\n failed = true;\n throw new OutpostError(\n \"workspace\",\n \"Remote changes could not be fully synchronized; recovery files retained\",\n { recovery: transfer, directory: workspace.directory },\n c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,GAAG,MAAM,MAAM,CAAC,SAAS,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;gBACvD,MAAM,EAAE,CAAC,QAAQ,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;YACvD,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,MAAM,GAAG,IAAI,CAAC;gBACd,MAAM,IAAI,YAAY,CACpB,WAAW,EACX,yEAAyE,EACzE,EAAE,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,CAAC,SAAS,EAAE,EACtD,KAAK,CACN,CAAC;YACJ,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { randomUUID } from \"node:crypto\";\nimport { mkdir, readFile, rm } from \"node:fs/promises\";\nimport { join, posix } from \"node:path\";\nimport { OutpostError } from \"../domain/errors.ts\";\nimport type { SandboxLease } from \"../domain/sandbox.types.ts\";\nimport type { WorkspaceRecord } from \"../domain/workspace.types.ts\";\nimport { seedHistory } from \"./remote-history.ts\";\nimport { uploadFiles } from \"./remote-upload.ts\";\nimport { git } from \"../infrastructure/git/command.ts\";\nimport { gitDefaults } from \"../infrastructure/git/git.constants.ts\";\nimport { applyChanges } from \"./remote-apply.ts\";\nimport { backupHost } from \"./remote-backup.ts\";\nimport { downloadChanges } from \"./remote-download.ts\";\nimport { validateChanges } from \"./remote-validation.ts\";\nimport type {\n RemoteSync,\n RemoteSyncOptions,\n RemoteWorkspaceContext,\n} from \"./remote-workspace.types.ts\";\nimport { digest, extras } from \"./workspace-fingerprint.ts\";\n\nexport type {\n RemoteSync,\n RemoteSyncOptions,\n} from \"./remote-workspace.types.ts\";\n\nexport async function seedRemote(\n workspace: WorkspaceRecord,\n lease: SandboxLease,\n options: RemoteSyncOptions = {},\n): Promise<RemoteSync> {\n options.signal?.throwIfAborted();\n const recovery = join(\n workspace.repository,\n \".outpost\",\n \"recovery\",\n randomUUID(),\n );\n await mkdir(recovery, { recursive: true });\n const remoteBundle = posix.join(\n lease.root.replaceAll(\"\\\\\", \"/\"),\n \"..\",\n `outpost-${randomUUID()}.bundle`,\n );\n let initializing = true,\n failed = false;\n const run = async (args: readonly string[]) => {\n let result;\n for (let attempt = 0; attempt < 3; attempt++) {\n result = await lease.invoke({\n executable: \"git\",\n arguments: args,\n directory: lease.root,\n retain: gitDefaults.retainBytes,\n ...(initializing && options.signal ? { signal: options.signal } : {}),\n ...(options.limits?.gitMs ? { deadlineMs: options.limits.gitMs } : {}),\n });\n if (!initializing || result.status !== 126) break;\n }\n if (!result)\n throw new OutpostError(\"workspace\", \"Remote Git did not start\");\n if (result.status !== 0)\n throw new OutpostError(\"workspace\", \"Remote Git operation failed\", {\n ...result,\n recovery,\n });\n if (result.stdout.length >= gitDefaults.retainBytes)\n throw new OutpostError(\n \"workspace\",\n \"Remote Git output exceeds synchronization limit\",\n { recovery },\n );\n return result.stdout;\n };\n await run([\"init\"]);\n await run([\"config\", \"core.autocrlf\", \"false\"]);\n await seedHistory(workspace, lease, options, recovery, remoteBundle, run);\n for (const key of [\"user.name\", \"user.email\"] as const) {\n const fallback = key === \"user.name\" ? \"Outpost\" : \"outpost@localhost\";\n const value =\n (\n await git(workspace.repository, [\"config\", \"--get\", key]).catch(\n () => fallback,\n )\n ).trim() || fallback;\n await run([\"config\", key, value]);\n }\n const initialPatch = join(recovery, \"initial.patch\");\n await git(workspace.directory, [\n \"diff\",\n \"--binary\",\n \"HEAD\",\n `--output=${initialPatch}`,\n ]);\n const initialIndex = join(recovery, \"initial-index.patch\");\n await git(workspace.directory, [\n \"diff\",\n \"--cached\",\n \"--binary\",\n `--output=${initialIndex}`,\n ]);\n const protectedFiles = options.includeUncommitted\n ? []\n : [\n ...(\n await git(workspace.directory, [\"diff\", \"--name-only\", \"-z\", \"HEAD\"])\n )\n .split(\"\\0\")\n .filter(Boolean),\n ...(await extras(workspace.directory)),\n ];\n const originalHead = (\n await git(workspace.directory, [\"rev-parse\", \"HEAD\"])\n ).trim();\n if (options.includeUncommitted && (await readFile(initialPatch)).length) {\n await lease.upload(initialPatch, `${remoteBundle}.patch`);\n await run([\"apply\", \"--binary\", `${remoteBundle}.patch`]);\n }\n await uploadFiles(\n lease,\n workspace.directory,\n options.includeUncommitted ? await extras(workspace.directory) : [],\n { ...(options.signal ? { signal: options.signal } : {}) },\n );\n let synchronized = (await run([\"rev-parse\", \"HEAD\"])).trim();\n initializing = false;\n let expected = await digest(workspace.directory, recovery);\n const context: RemoteWorkspaceContext = {\n transferred: new Map(),\n workspace,\n lease,\n options,\n recovery,\n remoteBundle,\n run,\n protectedFiles,\n originalHead,\n initialPatch,\n initialIndex,\n };\n return {\n async close() {\n if (!failed) await rm(recovery, { recursive: true, force: true });\n },\n async pull() {\n const transfer = join(recovery, randomUUID());\n await mkdir(transfer, { recursive: true });\n try {\n const changes = await downloadChanges(context, synchronized, transfer);\n await validateChanges(\n context,\n changes,\n synchronized,\n expected,\n transfer,\n );\n const backup = await backupHost(\n context,\n changes,\n synchronized,\n transfer,\n );\n await applyChanges(\n context,\n changes,\n backup,\n synchronized,\n expected,\n transfer,\n );\n context.transferred?.clear();\n for (const entry of changes.manifest ?? [])\n context.transferred?.set(entry.path, entry);\n const { head } = changes;\n synchronized = head;\n expected = await digest(workspace.directory, recovery);\n await rm(transfer, { recursive: true, force: true });\n } catch (cause) {\n failed = true;\n throw new OutpostError(\n \"workspace\",\n \"Remote changes could not be fully synchronized; recovery files retained\",\n { recovery: transfer, directory: workspace.directory },\n cause,\n );\n }\n },\n };\n}\n"]}
@@ -1,4 +1,4 @@
1
- import type { SandboxLease } from "../domain/sandbox.types.ts";
1
+ import type { FileManifestEntry, SandboxLease } from "../domain/sandbox.types.ts";
2
2
  import type { StageLimits, WorkspaceRecord } from "../domain/workspace.types.ts";
3
3
  export interface RemoteSync {
4
4
  pull(): Promise<void>;
@@ -10,6 +10,7 @@ export interface RemoteSyncOptions {
10
10
  readonly limits?: StageLimits;
11
11
  }
12
12
  export interface RemoteWorkspaceContext {
13
+ readonly transferred?: Map<string, FileManifestEntry>;
13
14
  readonly workspace: WorkspaceRecord;
14
15
  readonly lease: SandboxLease;
15
16
  readonly options: RemoteSyncOptions;
@@ -22,6 +23,7 @@ export interface RemoteWorkspaceContext {
22
23
  readonly initialIndex: string;
23
24
  }
24
25
  export interface RemoteChanges {
26
+ readonly manifest?: readonly FileManifestEntry[];
25
27
  readonly head: string;
26
28
  readonly patch: string;
27
29
  readonly incoming: readonly string[];
@@ -1 +1 @@
1
- {"version":3,"file":"remote-workspace.types.js","sourceRoot":"","sources":["../../src/application/remote-workspace.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { SandboxLease } from \"../domain/sandbox.types.ts\";\nimport type {\n StageLimits,\n WorkspaceRecord,\n} from \"../domain/workspace.types.ts\";\n\nexport interface RemoteSync {\n pull(): Promise<void>;\n close(): Promise<void>;\n}\n\nexport interface RemoteSyncOptions {\n readonly includeUncommitted?: boolean;\n readonly signal?: AbortSignal;\n readonly limits?: StageLimits;\n}\n\nexport interface RemoteWorkspaceContext {\n readonly workspace: WorkspaceRecord;\n readonly lease: SandboxLease;\n readonly options: RemoteSyncOptions;\n readonly recovery: string;\n readonly remoteBundle: string;\n readonly run: (args: readonly string[]) => Promise<string>;\n readonly protectedFiles: readonly string[];\n readonly originalHead: string;\n readonly initialPatch: string;\n readonly initialIndex: string;\n}\nexport interface RemoteChanges {\n readonly head: string;\n readonly patch: string;\n readonly incoming: readonly string[];\n}\nexport interface HostBackup {\n readonly previousPatch: string;\n readonly previousExtras: readonly string[];\n}\n"]}
1
+ {"version":3,"file":"remote-workspace.types.js","sourceRoot":"","sources":["../../src/application/remote-workspace.types.ts"],"names":[],"mappings":"","sourcesContent":["import type {\n FileManifestEntry,\n SandboxLease,\n} from \"../domain/sandbox.types.ts\";\nimport type {\n StageLimits,\n WorkspaceRecord,\n} from \"../domain/workspace.types.ts\";\n\nexport interface RemoteSync {\n pull(): Promise<void>;\n close(): Promise<void>;\n}\n\nexport interface RemoteSyncOptions {\n readonly includeUncommitted?: boolean;\n readonly signal?: AbortSignal;\n readonly limits?: StageLimits;\n}\n\nexport interface RemoteWorkspaceContext {\n readonly transferred?: Map<string, FileManifestEntry>;\n readonly workspace: WorkspaceRecord;\n readonly lease: SandboxLease;\n readonly options: RemoteSyncOptions;\n readonly recovery: string;\n readonly remoteBundle: string;\n readonly run: (args: readonly string[]) => Promise<string>;\n readonly protectedFiles: readonly string[];\n readonly originalHead: string;\n readonly initialPatch: string;\n readonly initialIndex: string;\n}\nexport interface RemoteChanges {\n readonly manifest?: readonly FileManifestEntry[];\n readonly head: string;\n readonly patch: string;\n readonly incoming: readonly string[];\n}\nexport interface HostBackup {\n readonly previousPatch: string;\n readonly previousExtras: readonly string[];\n}\n"]}
@@ -0,0 +1,3 @@
1
+ import type { SandboxLease } from "../domain/sandbox.types.ts";
2
+ import type { ResourceActivity } from "../infrastructure/resource-activity.types.ts";
3
+ export declare function trackedSandboxLease(lease: SandboxLease, activity: ResourceActivity): SandboxLease;