@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
@@ -0,0 +1,21 @@
1
+ import type { Context, Meter, Span, Tracer } from "@opentelemetry/api";
2
+ import type { WorkflowEvent } from "../domain/workflow.types.ts";
3
+ export interface OpenTelemetryOptions {
4
+ readonly tracer: Tracer;
5
+ readonly meter: Meter;
6
+ readonly onError?: (error: unknown) => void;
7
+ }
8
+ export interface OpenTelemetryObserver {
9
+ observe(event: WorkflowEvent): void;
10
+ close(): void;
11
+ }
12
+ export interface TelemetryOperation {
13
+ readonly span: Span | undefined;
14
+ readonly context: Context;
15
+ readonly started: number;
16
+ }
17
+ export interface TelemetryExecution {
18
+ readonly workflow: TelemetryOperation;
19
+ readonly tasks: Map<string, TelemetryOperation>;
20
+ readonly attempts: Map<string, TelemetryOperation>;
21
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=opentelemetry.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"opentelemetry.types.js","sourceRoot":"","sources":["../../src/infrastructure/opentelemetry.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { Context, Meter, Span, Tracer } from \"@opentelemetry/api\";\nimport type { WorkflowEvent } from \"../domain/workflow.types.ts\";\n\nexport interface OpenTelemetryOptions {\n readonly tracer: Tracer;\n readonly meter: Meter;\n readonly onError?: (error: unknown) => void;\n}\n\nexport interface OpenTelemetryObserver {\n observe(event: WorkflowEvent): void;\n close(): void;\n}\n\nexport interface TelemetryOperation {\n readonly span: Span | undefined;\n readonly context: Context;\n readonly started: number;\n}\n\nexport interface TelemetryExecution {\n readonly workflow: TelemetryOperation;\n readonly tasks: Map<string, TelemetryOperation>;\n readonly attempts: Map<string, TelemetryOperation>;\n}\n"]}
@@ -0,0 +1,2 @@
1
+ import type { ResourceInspection } from "./resource-activity.types.ts";
2
+ export declare function inspectResourceActivity(repository: string, maxEntries?: number): Promise<ResourceInspection>;
@@ -0,0 +1,152 @@
1
+ import { lstat, opendir, realpath } from "node:fs/promises";
2
+ import { join } from "node:path";
3
+ import { invariant, positive } from "../domain/errors.js";
4
+ import { observeOwnership } from "./git/process-identity.js";
5
+ import { readInspectionFile } from "./inspection-file.js";
6
+ import { resourceActivityDefaults as defaults, resourceOperationKinds, resourcePhases, } from "./resource-activity.constants.js";
7
+ function object(value) {
8
+ invariant(!!value && typeof value === "object" && !Array.isArray(value), "Invalid activity object");
9
+ }
10
+ function text(value) {
11
+ invariant(typeof value === "string" &&
12
+ value.length > 0 &&
13
+ value.length <= defaults.maxText, "Invalid activity text");
14
+ }
15
+ function date(value) {
16
+ text(value);
17
+ invariant(Number.isFinite(Date.parse(value)), "Invalid activity time");
18
+ }
19
+ function operation(value) {
20
+ object(value);
21
+ invariant(typeof value.count === "number" &&
22
+ Number.isSafeInteger(value.count) &&
23
+ value.count > 0, "Invalid activity count");
24
+ date(value.startedAt);
25
+ const kind = resourceOperationKinds.find((kind) => kind === value.kind);
26
+ invariant(kind, "Invalid activity operation");
27
+ return { count: value.count, startedAt: value.startedAt, kind };
28
+ }
29
+ function result(value) {
30
+ const base = operation(value);
31
+ object(value);
32
+ text(value.id);
33
+ date(value.finishedAt);
34
+ invariant(value.outcome === "completed" || value.outcome === "failed", "Invalid activity outcome");
35
+ return {
36
+ ...base,
37
+ id: value.id,
38
+ finishedAt: value.finishedAt,
39
+ outcome: value.outcome,
40
+ };
41
+ }
42
+ function identity(value) {
43
+ if (value === undefined)
44
+ return undefined;
45
+ object(value);
46
+ text(value.host);
47
+ text(value.boot);
48
+ text(value.namespace);
49
+ text(value.started);
50
+ return {
51
+ host: value.host,
52
+ boot: value.boot,
53
+ namespace: value.namespace,
54
+ started: value.started,
55
+ };
56
+ }
57
+ function record(value) {
58
+ object(value);
59
+ invariant(value.version === 1, "Unknown activity version");
60
+ text(value.id);
61
+ text(value.provider);
62
+ text(value.workspace);
63
+ date(value.createdAt);
64
+ date(value.updatedAt);
65
+ invariant(typeof value.pid === "number" &&
66
+ Number.isSafeInteger(value.pid) &&
67
+ value.pid > 0 &&
68
+ value.pid <= 2_147_483_647, "Invalid activity owner");
69
+ invariant(value.placement === "host" ||
70
+ value.placement === "mounted" ||
71
+ value.placement === "remote", "Invalid activity placement");
72
+ const phase = resourcePhases.find((phase) => phase === value.phase);
73
+ invariant(phase, "Invalid activity phase");
74
+ invariant(Array.isArray(value.operations) &&
75
+ value.operations.length <= resourceOperationKinds.length, "Invalid activity operations");
76
+ const owner = identity(value.identity);
77
+ return {
78
+ version: 1,
79
+ id: value.id,
80
+ pid: value.pid,
81
+ ...(owner ? { identity: owner } : {}),
82
+ provider: value.provider,
83
+ placement: value.placement,
84
+ workspace: value.workspace,
85
+ createdAt: value.createdAt,
86
+ updatedAt: value.updatedAt,
87
+ phase,
88
+ operations: value.operations.map(operation),
89
+ ...(value.lastOperation === undefined
90
+ ? {}
91
+ : { lastOperation: result(value.lastOperation) }),
92
+ ...(value.lastFailure === undefined
93
+ ? {}
94
+ : { lastFailure: result(value.lastFailure) }),
95
+ };
96
+ }
97
+ export async function inspectResourceActivity(repository, maxEntries = defaults.maxRecords) {
98
+ positive(maxEntries, "maxEntries");
99
+ const entries = [];
100
+ const issues = [];
101
+ let path = repository;
102
+ try {
103
+ for (const part of [".outpost", "locks", defaults.directory]) {
104
+ path = join(path, part);
105
+ const info = await lstat(path);
106
+ invariant(info.isDirectory() &&
107
+ !info.isSymbolicLink() &&
108
+ (await realpath(path)) === path, "Unsafe activity directory");
109
+ }
110
+ for await (const entry of await opendir(path)) {
111
+ const file = join(path, entry.name);
112
+ if (entries.length >= Math.min(maxEntries, defaults.maxRecords)) {
113
+ issues.push({ path, code: "RESOURCE_ENTRY_LIMIT" });
114
+ break;
115
+ }
116
+ try {
117
+ const value = record(JSON.parse((await readInspectionFile(file, defaults.maxRecordBytes)).toString("utf8")));
118
+ invariant(entry.name === `${value.id}.json`, "Activity identity mismatch");
119
+ entries.push({
120
+ path: file,
121
+ record: value,
122
+ ownership: await observeOwnership(value.pid, value.identity),
123
+ });
124
+ }
125
+ catch {
126
+ entries.push({
127
+ path: file,
128
+ ownership: {
129
+ status: "unknown",
130
+ reason: "RESOURCE_RECORD_UNREADABLE",
131
+ },
132
+ });
133
+ issues.push({ path: file, code: "RESOURCE_RECORD_UNREADABLE" });
134
+ }
135
+ }
136
+ }
137
+ catch (cause) {
138
+ if (!(cause &&
139
+ typeof cause === "object" &&
140
+ "code" in cause &&
141
+ cause.code === "ENOENT"))
142
+ issues.push({ path, code: "RESOURCE_DIRECTORY_UNAVAILABLE" });
143
+ }
144
+ entries.sort((left, right) => left.path.localeCompare(right.path));
145
+ return {
146
+ scope: "recorded-sandboxes",
147
+ complete: issues.length === 0,
148
+ entries,
149
+ issues,
150
+ };
151
+ }
152
+ //# sourceMappingURL=resource-activity-inspection.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resource-activity-inspection.js","sourceRoot":"","sources":["../../src/infrastructure/resource-activity-inspection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAE7D,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EACL,wBAAwB,IAAI,QAAQ,EACpC,sBAAsB,EACtB,cAAc,GACf,MAAM,kCAAkC,CAAC;AAU1C,SAAS,MAAM,CAAC,KAAc;IAC5B,SAAS,CACP,CAAC,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,KAAK,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AK,CAAC,IAAI,CAAC,CAAC,CAAC;IACnE,OAAO;QACL,KAAK,EAAE,oBAAoB;QAC3B,QAAQ,EAAE,MAAM,CAAC,MAAM,KAAK,CAAC;QAC7B,OAAO;QACP,MAAM;KACP,CAAC;AACJ,CAAC","sourcesContent":["import { lstat, opendir, realpath } from \"node:fs/promises\";\nimport { join } from \"node:path\";\nimport { invariant, positive } from \"../domain/errors.ts\";\nimport { observeOwnership } from \"./git/process-identity.ts\";\nimport type { LocalProcessIdentity } from \"./git/process-identity.types.ts\";\nimport { readInspectionFile } from \"./inspection-file.ts\";\nimport {\n resourceActivityDefaults as defaults,\n resourceOperationKinds,\n resourcePhases,\n} from \"./resource-activity.constants.ts\";\nimport type {\n ResourceActivityRecord,\n ResourceInspection,\n ResourceInspectionEntry,\n ResourceOperation,\n ResourceOperationResult,\n} from \"./resource-activity.types.ts\";\nimport type { StorageIssue } from \"./storage-inventory.types.ts\";\n\nfunction object(value: unknown): asserts value is Record<string, unknown> {\n invariant(\n !!value && typeof value === \"object\" && !Array.isArray(value),\n \"Invalid activity object\",\n );\n}\nfunction text(value: unknown): asserts value is string {\n invariant(\n typeof value === \"string\" &&\n value.length > 0 &&\n value.length <= defaults.maxText,\n \"Invalid activity text\",\n );\n}\nfunction date(value: unknown): asserts value is string {\n text(value);\n invariant(Number.isFinite(Date.parse(value)), \"Invalid activity time\");\n}\nfunction operation(value: unknown): ResourceOperation {\n object(value);\n invariant(\n typeof value.count === \"number\" &&\n Number.isSafeInteger(value.count) &&\n value.count > 0,\n \"Invalid activity count\",\n );\n date(value.startedAt);\n const kind = resourceOperationKinds.find((kind) => kind === value.kind);\n invariant(kind, \"Invalid activity operation\");\n return { count: value.count, startedAt: value.startedAt, kind };\n}\nfunction result(value: unknown): ResourceOperationResult {\n const base = operation(value);\n object(value);\n text(value.id);\n date(value.finishedAt);\n invariant(\n value.outcome === \"completed\" || value.outcome === \"failed\",\n \"Invalid activity outcome\",\n );\n return {\n ...base,\n id: value.id,\n finishedAt: value.finishedAt,\n outcome: value.outcome,\n };\n}\nfunction identity(value: unknown): LocalProcessIdentity | undefined {\n if (value === undefined) return undefined;\n object(value);\n text(value.host);\n text(value.boot);\n text(value.namespace);\n text(value.started);\n return {\n host: value.host,\n boot: value.boot,\n namespace: value.namespace,\n started: value.started,\n };\n}\nfunction record(value: unknown): ResourceActivityRecord {\n object(value);\n invariant(value.version === 1, \"Unknown activity version\");\n text(value.id);\n text(value.provider);\n text(value.workspace);\n date(value.createdAt);\n date(value.updatedAt);\n invariant(\n typeof value.pid === \"number\" &&\n Number.isSafeInteger(value.pid) &&\n value.pid > 0 &&\n value.pid <= 2_147_483_647,\n \"Invalid activity owner\",\n );\n invariant(\n value.placement === \"host\" ||\n value.placement === \"mounted\" ||\n value.placement === \"remote\",\n \"Invalid activity placement\",\n );\n const phase = resourcePhases.find((phase) => phase === value.phase);\n invariant(phase, \"Invalid activity phase\");\n invariant(\n Array.isArray(value.operations) &&\n value.operations.length <= resourceOperationKinds.length,\n \"Invalid activity operations\",\n );\n const owner = identity(value.identity);\n return {\n version: 1,\n id: value.id,\n pid: value.pid,\n ...(owner ? { identity: owner } : {}),\n provider: value.provider,\n placement: value.placement,\n workspace: value.workspace,\n createdAt: value.createdAt,\n updatedAt: value.updatedAt,\n phase,\n operations: value.operations.map(operation),\n ...(value.lastOperation === undefined\n ? {}\n : { lastOperation: result(value.lastOperation) }),\n ...(value.lastFailure === undefined\n ? {}\n : { lastFailure: result(value.lastFailure) }),\n };\n}\n\nexport async function inspectResourceActivity(\n repository: string,\n maxEntries: number = defaults.maxRecords,\n): Promise<ResourceInspection> {\n positive(maxEntries, \"maxEntries\");\n const entries: ResourceInspectionEntry[] = [];\n const issues: StorageIssue[] = [];\n let path = repository;\n try {\n for (const part of [\".outpost\", \"locks\", defaults.directory]) {\n path = join(path, part);\n const info = await lstat(path);\n invariant(\n info.isDirectory() &&\n !info.isSymbolicLink() &&\n (await realpath(path)) === path,\n \"Unsafe activity directory\",\n );\n }\n for await (const entry of await opendir(path)) {\n const file = join(path, entry.name);\n if (entries.length >= Math.min(maxEntries, defaults.maxRecords)) {\n issues.push({ path, code: \"RESOURCE_ENTRY_LIMIT\" });\n break;\n }\n try {\n const value = record(\n JSON.parse(\n (await readInspectionFile(file, defaults.maxRecordBytes)).toString(\n \"utf8\",\n ),\n ),\n );\n invariant(\n entry.name === `${value.id}.json`,\n \"Activity identity mismatch\",\n );\n entries.push({\n path: file,\n record: value,\n ownership: await observeOwnership(value.pid, value.identity),\n });\n } catch {\n entries.push({\n path: file,\n ownership: {\n status: \"unknown\",\n reason: \"RESOURCE_RECORD_UNREADABLE\",\n },\n });\n issues.push({ path: file, code: \"RESOURCE_RECORD_UNREADABLE\" });\n }\n }\n } catch (cause) {\n if (!(\n cause &&\n typeof cause === \"object\" &&\n \"code\" in cause &&\n cause.code === \"ENOENT\"\n ))\n issues.push({ path, code: \"RESOURCE_DIRECTORY_UNAVAILABLE\" });\n }\n entries.sort((left, right) => left.path.localeCompare(right.path));\n return {\n scope: \"recorded-sandboxes\",\n complete: issues.length === 0,\n entries,\n issues,\n };\n}\n"]}
@@ -0,0 +1,8 @@
1
+ export declare const resourceActivityDefaults: {
2
+ readonly directory: "resource-activity";
3
+ readonly maxRecords: 10000;
4
+ readonly maxRecordBytes: 65536;
5
+ readonly maxText: 4096;
6
+ };
7
+ export declare const resourcePhases: readonly ["allocating", "ready", "closing", "cleanup-failed", "allocation-uncertain"];
8
+ export declare const resourceOperationKinds: readonly ["dispatch", "attach", "diagnose", "command", "invoke", "upload", "download", "manifest", "download-batch", "upload-batch"];
@@ -0,0 +1,26 @@
1
+ export const resourceActivityDefaults = {
2
+ directory: "resource-activity",
3
+ maxRecords: 10_000,
4
+ maxRecordBytes: 65_536,
5
+ maxText: 4_096,
6
+ };
7
+ export const resourcePhases = [
8
+ "allocating",
9
+ "ready",
10
+ "closing",
11
+ "cleanup-failed",
12
+ "allocation-uncertain",
13
+ ];
14
+ export const resourceOperationKinds = [
15
+ "dispatch",
16
+ "attach",
17
+ "diagnose",
18
+ "command",
19
+ "invoke",
20
+ "upload",
21
+ "download",
22
+ "manifest",
23
+ "download-batch",
24
+ "upload-batch",
25
+ ];
26
+ //# sourceMappingURL=resource-activity.constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resource-activity.constants.js","sourceRoot":"","sources":["../../src/infrastructure/resource-activity.constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,wBAAwB,GAAG;IACtC,SAAS,EAAE,mBAAmB;IAC9B,UAAU,EAAE,MAAM;IAClB,cAAc,EAAE,MAAM;IACtB,OAAO,EAAE,KAAK;CACN,CAAC;AAEX,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,YAAY;IACZ,OAAO;IACP,SAAS;IACT,gBAAgB;IAChB,sBAAsB;CACd,CAAC;AACX,MAAM,CAAC,MAAM,sBAAsB,GAAG;IACpC,UAAU;IACV,QAAQ;IACR,UAAU;IACV,SAAS;IACT,QAAQ;IACR,QAAQ;IACR,UAAU;IACV,UAAU;IACV,gBAAgB;IAChB,cAAc;CACN,CAAC","sourcesContent":["export const resourceActivityDefaults = {\n directory: \"resource-activity\",\n maxRecords: 10_000,\n maxRecordBytes: 65_536,\n maxText: 4_096,\n} as const;\n\nexport const resourcePhases = [\n \"allocating\",\n \"ready\",\n \"closing\",\n \"cleanup-failed\",\n \"allocation-uncertain\",\n] as const;\nexport const resourceOperationKinds = [\n \"dispatch\",\n \"attach\",\n \"diagnose\",\n \"command\",\n \"invoke\",\n \"upload\",\n \"download\",\n \"manifest\",\n \"download-batch\",\n \"upload-batch\",\n] as const;\n"]}
@@ -0,0 +1,2 @@
1
+ import type { ResourceActivity, ResourceActivityOptions } from "./resource-activity.types.ts";
2
+ export declare function registerResourceActivity(options: ResourceActivityOptions): Promise<ResourceActivity>;
@@ -0,0 +1,166 @@
1
+ import { randomUUID } from "node:crypto";
2
+ import { mkdir, open, realpath, rename, rm, opendir } from "node:fs/promises";
3
+ import { join } from "node:path";
4
+ import { invariant } from "../domain/errors.js";
5
+ import { localProcessIdentity } from "./git/process-identity.js";
6
+ import { readInspectionFile } from "./inspection-file.js";
7
+ import { lockStorageMutation } from "./storage-mutation-lock.js";
8
+ import { resourceActivityDefaults as defaults } from "./resource-activity.constants.js";
9
+ async function activityDirectory(repository) {
10
+ let path = repository;
11
+ for (const part of [".outpost", "locks", defaults.directory]) {
12
+ path = join(path, part);
13
+ await mkdir(path, { recursive: true, mode: 0o700 });
14
+ invariant((await realpath(path)) === path, "Resource activity directory must not use symlinks");
15
+ }
16
+ return path;
17
+ }
18
+ export async function registerResourceActivity(options) {
19
+ for (const text of [options.workspace, options.provider])
20
+ invariant(text.length > 0 && text.length <= defaults.maxText, "Resource activity metadata exceeds its size limit");
21
+ const directory = await activityDirectory(options.repository);
22
+ const id = randomUUID();
23
+ const path = join(directory, `${id}.json`);
24
+ const createdAt = new Date().toISOString();
25
+ const identity = await localProcessIdentity();
26
+ let record = {
27
+ version: 1,
28
+ id,
29
+ pid: process.pid,
30
+ ...(identity ? { identity } : {}),
31
+ provider: options.provider,
32
+ placement: options.placement,
33
+ workspace: options.workspace,
34
+ createdAt,
35
+ updatedAt: createdAt,
36
+ phase: "allocating",
37
+ operations: [],
38
+ };
39
+ const unlock = await lockStorageMutation(options.repository);
40
+ try {
41
+ let count = 0;
42
+ for await (const _entry of await opendir(directory))
43
+ invariant(++count < defaults.maxRecords, "Too many resource activity records; inspect retained ownership before continuing");
44
+ const file = await open(path, "wx", 0o600);
45
+ try {
46
+ await file.writeFile(JSON.stringify(record));
47
+ await file.sync();
48
+ }
49
+ finally {
50
+ await file.close();
51
+ }
52
+ }
53
+ finally {
54
+ await unlock();
55
+ }
56
+ let pending = Promise.resolve();
57
+ let removed = false;
58
+ function serialize(action) {
59
+ const next = pending.then(action);
60
+ pending = next.catch(() => undefined);
61
+ return next;
62
+ }
63
+ async function verify() {
64
+ invariant((await realpath(directory)) === directory, "Resource activity directory changed");
65
+ invariant(!removed, "Resource activity is closed");
66
+ const current = (await readInspectionFile(path, defaults.maxRecordBytes)).toString("utf8");
67
+ invariant(current === JSON.stringify(record), "Resource activity identity changed; refusing mutation");
68
+ }
69
+ function update(next) {
70
+ return serialize(async () => {
71
+ await verify();
72
+ const value = { ...next(), updatedAt: new Date().toISOString() };
73
+ const data = JSON.stringify(value);
74
+ invariant(Buffer.byteLength(data) <= defaults.maxRecordBytes, "Resource activity record exceeds its size limit");
75
+ const temporary = `${path}.${randomUUID()}.tmp`;
76
+ const file = await open(temporary, "wx", 0o600);
77
+ try {
78
+ await file.writeFile(data);
79
+ await file.sync();
80
+ await file.close();
81
+ await rename(temporary, path);
82
+ record = value;
83
+ }
84
+ finally {
85
+ await file.close();
86
+ await rm(temporary, { force: true });
87
+ }
88
+ });
89
+ }
90
+ return {
91
+ async idle() {
92
+ await pending;
93
+ return record.operations.length === 0;
94
+ },
95
+ phase: (phase) => update(() => ({ ...record, phase })),
96
+ async run(kind, action) {
97
+ const operation = {
98
+ id: randomUUID(),
99
+ kind,
100
+ startedAt: new Date().toISOString(),
101
+ };
102
+ await update(() => {
103
+ const active = record.operations.find((value) => value.kind === kind);
104
+ const operations = record.operations.filter((value) => value.kind !== kind);
105
+ operations.push({
106
+ kind,
107
+ startedAt: active?.startedAt ?? operation.startedAt,
108
+ count: (active?.count ?? 0) + 1,
109
+ });
110
+ return { ...record, operations };
111
+ });
112
+ let outcome = "completed";
113
+ try {
114
+ return await action();
115
+ }
116
+ catch (cause) {
117
+ outcome = "failed";
118
+ throw cause;
119
+ }
120
+ finally {
121
+ const result = {
122
+ ...operation,
123
+ outcome,
124
+ count: 1,
125
+ finishedAt: new Date().toISOString(),
126
+ };
127
+ try {
128
+ await update(() => ({
129
+ ...record,
130
+ operations: record.operations.flatMap((value) => {
131
+ if (value.kind !== kind)
132
+ return [value];
133
+ if (value.count === 1)
134
+ return [];
135
+ return [{ ...value, count: value.count - 1 }];
136
+ }),
137
+ lastOperation: result,
138
+ ...(outcome === "failed" ? { lastFailure: result } : {}),
139
+ }));
140
+ }
141
+ catch (cause) {
142
+ if (outcome !== "failed")
143
+ throw cause;
144
+ }
145
+ }
146
+ },
147
+ remove: () => serialize(async () => {
148
+ if (removed)
149
+ return;
150
+ invariant(record.operations.length === 0, "Resource operations remain unsettled; activity record retained");
151
+ try {
152
+ await verify();
153
+ await rm(path);
154
+ }
155
+ catch (cause) {
156
+ if (!(cause &&
157
+ typeof cause === "object" &&
158
+ "code" in cause &&
159
+ cause.code === "ENOENT"))
160
+ throw cause;
161
+ }
162
+ removed = true;
163
+ }),
164
+ };
165
+ }
166
+ //# sourceMappingURL=resource-activity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resource-activity.js","sourceRoot":"","sources":["../../src/infrastructure/resource-activity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC9E,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChD,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAE,wBAAwB,IAAI,QAAQ,EAAE,MAAM,kCAAkC,CAAC;AAQxF,KAAK,UAAU,iBAAiB,CAAC,UAAkB;IACjD,IAAI,IAAI,GAAG,UAAU,CAAC;IACtB,KAAK,MAAM,IAAI,IAAI,CAAC,UAAU,EAAE,OAAO,EAAE,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC;QAC7D,IAAI,GAAG,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QACxB,MA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,GAAG,IAAI,CAAC;QACjB,CAAC,CAAC;KACL,CAAC;AACJ,CAAC","sourcesContent":["import { randomUUID } from \"node:crypto\";\nimport { mkdir, open, realpath, rename, rm, opendir } from \"node:fs/promises\";\nimport { join } from \"node:path\";\nimport { invariant } from \"../domain/errors.ts\";\nimport { localProcessIdentity } from \"./git/process-identity.ts\";\nimport { readInspectionFile } from \"./inspection-file.ts\";\nimport { lockStorageMutation } from \"./storage-mutation-lock.ts\";\nimport { resourceActivityDefaults as defaults } from \"./resource-activity.constants.ts\";\nimport type {\n ResourceActivity,\n ResourceActivityOptions,\n ResourceActivityRecord,\n ResourceOperationResult,\n} from \"./resource-activity.types.ts\";\n\nasync function activityDirectory(repository: string): Promise<string> {\n let path = repository;\n for (const part of [\".outpost\", \"locks\", defaults.directory]) {\n path = join(path, part);\n await mkdir(path, { recursive: true, mode: 0o700 });\n invariant(\n (await realpath(path)) === path,\n \"Resource activity directory must not use symlinks\",\n );\n }\n return path;\n}\n\nexport async function registerResourceActivity(\n options: ResourceActivityOptions,\n): Promise<ResourceActivity> {\n for (const text of [options.workspace, options.provider])\n invariant(\n text.length > 0 && text.length <= defaults.maxText,\n \"Resource activity metadata exceeds its size limit\",\n );\n const directory = await activityDirectory(options.repository);\n const id = randomUUID();\n const path = join(directory, `${id}.json`);\n const createdAt = new Date().toISOString();\n const identity = await localProcessIdentity();\n let record: ResourceActivityRecord = {\n version: 1,\n id,\n pid: process.pid,\n ...(identity ? { identity } : {}),\n provider: options.provider,\n placement: options.placement,\n workspace: options.workspace,\n createdAt,\n updatedAt: createdAt,\n phase: \"allocating\",\n operations: [],\n };\n const unlock = await lockStorageMutation(options.repository);\n try {\n let count = 0;\n for await (const _entry of await opendir(directory))\n invariant(\n ++count < defaults.maxRecords,\n \"Too many resource activity records; inspect retained ownership before continuing\",\n );\n const file = await open(path, \"wx\", 0o600);\n try {\n await file.writeFile(JSON.stringify(record));\n await file.sync();\n } finally {\n await file.close();\n }\n } finally {\n await unlock();\n }\n let pending = Promise.resolve();\n let removed = false;\n function serialize(action: () => Promise<void>): Promise<void> {\n const next = pending.then(action);\n pending = next.catch(() => undefined);\n return next;\n }\n async function verify(): Promise<void> {\n invariant(\n (await realpath(directory)) === directory,\n \"Resource activity directory changed\",\n );\n invariant(!removed, \"Resource activity is closed\");\n const current = (\n await readInspectionFile(path, defaults.maxRecordBytes)\n ).toString(\"utf8\");\n invariant(\n current === JSON.stringify(record),\n \"Resource activity identity changed; refusing mutation\",\n );\n }\n function update(next: () => ResourceActivityRecord): Promise<void> {\n return serialize(async () => {\n await verify();\n const value = { ...next(), updatedAt: new Date().toISOString() };\n const data = JSON.stringify(value);\n invariant(\n Buffer.byteLength(data) <= defaults.maxRecordBytes,\n \"Resource activity record exceeds its size limit\",\n );\n const temporary = `${path}.${randomUUID()}.tmp`;\n const file = await open(temporary, \"wx\", 0o600);\n try {\n await file.writeFile(data);\n await file.sync();\n await file.close();\n await rename(temporary, path);\n record = value;\n } finally {\n await file.close();\n await rm(temporary, { force: true });\n }\n });\n }\n return {\n async idle() {\n await pending;\n return record.operations.length === 0;\n },\n phase: (phase) => update(() => ({ ...record, phase })),\n async run(kind, action) {\n const operation = {\n id: randomUUID(),\n kind,\n startedAt: new Date().toISOString(),\n };\n await update(() => {\n const active = record.operations.find((value) => value.kind === kind);\n const operations = record.operations.filter(\n (value) => value.kind !== kind,\n );\n operations.push({\n kind,\n startedAt: active?.startedAt ?? operation.startedAt,\n count: (active?.count ?? 0) + 1,\n });\n return { ...record, operations };\n });\n let outcome: ResourceOperationResult[\"outcome\"] = \"completed\";\n try {\n return await action();\n } catch (cause) {\n outcome = \"failed\";\n throw cause;\n } finally {\n const result = {\n ...operation,\n outcome,\n count: 1,\n finishedAt: new Date().toISOString(),\n };\n try {\n await update(() => ({\n ...record,\n operations: record.operations.flatMap((value) => {\n if (value.kind !== kind) return [value];\n if (value.count === 1) return [];\n return [{ ...value, count: value.count - 1 }];\n }),\n lastOperation: result,\n ...(outcome === \"failed\" ? { lastFailure: result } : {}),\n }));\n } catch (cause) {\n if (outcome !== \"failed\") throw cause;\n }\n }\n },\n remove: () =>\n serialize(async () => {\n if (removed) return;\n invariant(\n record.operations.length === 0,\n \"Resource operations remain unsettled; activity record retained\",\n );\n try {\n await verify();\n await rm(path);\n } catch (cause) {\n if (!(\n cause &&\n typeof cause === \"object\" &&\n \"code\" in cause &&\n cause.code === \"ENOENT\"\n ))\n throw cause;\n }\n removed = true;\n }),\n };\n}\n"]}
@@ -0,0 +1,53 @@
1
+ import type { LocalProcessIdentity, LockOwnership } from "./git/process-identity.types.ts";
2
+ import type { StorageIssue } from "./storage-inventory.types.ts";
3
+ import type { resourceOperationKinds, resourcePhases } from "./resource-activity.constants.ts";
4
+ export type ResourcePhase = (typeof resourcePhases)[number];
5
+ export type ResourceOperationKind = (typeof resourceOperationKinds)[number];
6
+ export interface ResourceOperation {
7
+ readonly count: number;
8
+ readonly kind: ResourceOperationKind;
9
+ readonly startedAt: string;
10
+ }
11
+ export interface ResourceOperationResult extends ResourceOperation {
12
+ readonly id: string;
13
+ readonly finishedAt: string;
14
+ readonly outcome: "completed" | "failed";
15
+ }
16
+ export interface ResourceActivityRecord {
17
+ readonly version: 1;
18
+ readonly id: string;
19
+ readonly pid: number;
20
+ readonly identity?: LocalProcessIdentity;
21
+ readonly provider: string;
22
+ readonly placement: "mounted" | "remote" | "host";
23
+ readonly workspace: string;
24
+ readonly createdAt: string;
25
+ readonly updatedAt: string;
26
+ readonly phase: ResourcePhase;
27
+ readonly operations: readonly ResourceOperation[];
28
+ readonly lastOperation?: ResourceOperationResult;
29
+ readonly lastFailure?: ResourceOperationResult;
30
+ }
31
+ export interface ResourceActivity {
32
+ idle(): Promise<boolean>;
33
+ phase(phase: ResourcePhase): Promise<void>;
34
+ run<T>(kind: ResourceOperationKind, action: () => Promise<T>): Promise<T>;
35
+ remove(): Promise<void>;
36
+ }
37
+ export interface ResourceActivityOptions {
38
+ readonly repository: string;
39
+ readonly workspace: string;
40
+ readonly provider: string;
41
+ readonly placement: ResourceActivityRecord["placement"];
42
+ }
43
+ export interface ResourceInspectionEntry {
44
+ readonly path: string;
45
+ readonly record?: ResourceActivityRecord;
46
+ readonly ownership: LockOwnership;
47
+ }
48
+ export interface ResourceInspection {
49
+ readonly scope: "recorded-sandboxes";
50
+ readonly complete: boolean;
51
+ readonly entries: readonly ResourceInspectionEntry[];
52
+ readonly issues: readonly StorageIssue[];
53
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=resource-activity.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resource-activity.types.js","sourceRoot":"","sources":["../../src/infrastructure/resource-activity.types.ts"],"names":[],"mappings":"","sourcesContent":["import type {\n LocalProcessIdentity,\n LockOwnership,\n} from \"./git/process-identity.types.ts\";\nimport type { StorageIssue } from \"./storage-inventory.types.ts\";\nimport type {\n resourceOperationKinds,\n resourcePhases,\n} from \"./resource-activity.constants.ts\";\n\nexport type ResourcePhase = (typeof resourcePhases)[number];\nexport type ResourceOperationKind = (typeof resourceOperationKinds)[number];\nexport interface ResourceOperation {\n readonly count: number;\n readonly kind: ResourceOperationKind;\n readonly startedAt: string;\n}\nexport interface ResourceOperationResult extends ResourceOperation {\n readonly id: string;\n readonly finishedAt: string;\n readonly outcome: \"completed\" | \"failed\";\n}\nexport interface ResourceActivityRecord {\n readonly version: 1;\n readonly id: string;\n readonly pid: number;\n readonly identity?: LocalProcessIdentity;\n readonly provider: string;\n readonly placement: \"mounted\" | \"remote\" | \"host\";\n readonly workspace: string;\n readonly createdAt: string;\n readonly updatedAt: string;\n readonly phase: ResourcePhase;\n readonly operations: readonly ResourceOperation[];\n readonly lastOperation?: ResourceOperationResult;\n readonly lastFailure?: ResourceOperationResult;\n}\nexport interface ResourceActivity {\n idle(): Promise<boolean>;\n phase(phase: ResourcePhase): Promise<void>;\n run<T>(kind: ResourceOperationKind, action: () => Promise<T>): Promise<T>;\n remove(): Promise<void>;\n}\nexport interface ResourceActivityOptions {\n readonly repository: string;\n readonly workspace: string;\n readonly provider: string;\n readonly placement: ResourceActivityRecord[\"placement\"];\n}\nexport interface ResourceInspectionEntry {\n readonly path: string;\n readonly record?: ResourceActivityRecord;\n readonly ownership: LockOwnership;\n}\nexport interface ResourceInspection {\n readonly scope: \"recorded-sandboxes\";\n readonly complete: boolean;\n readonly entries: readonly ResourceInspectionEntry[];\n readonly issues: readonly StorageIssue[];\n}\n"]}
@@ -0,0 +1,6 @@
1
+ import type { StorageCategoryName } from "./storage-inventory.types.ts";
2
+ export declare const storageCategories: readonly StorageCategoryName[];
3
+ export declare const storageInventoryDefaults: Readonly<{
4
+ maxEntries: 100000;
5
+ maxDepth: 64;
6
+ }>;
@@ -0,0 +1,11 @@
1
+ export const storageCategories = [
2
+ "recovery",
3
+ "logs",
4
+ "locks",
5
+ "workspaces",
6
+ ];
7
+ export const storageInventoryDefaults = Object.freeze({
8
+ maxEntries: 100_000,
9
+ maxDepth: 64,
10
+ });
11
+ //# sourceMappingURL=storage-inventory.constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"storage-inventory.constants.js","sourceRoot":"","sources":["../../src/infrastructure/storage-inventory.constants.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,iBAAiB,GAAmC;IAC/D,UAAU;IACV,MAAM;IACN,OAAO;IACP,YAAY;CACb,CAAC;AACF,MAAM,CAAC,MAAM,wBAAwB,GAAG,MAAM,CAAC,MAAM,CAAC;IACpD,UAAU,EAAE,OAAO;IACnB,QAAQ,EAAE,EAAE;CACb,CAAC,CAAC","sourcesContent":["import type { StorageCategoryName } from \"./storage-inventory.types.ts\";\n\nexport const storageCategories: readonly StorageCategoryName[] = [\n \"recovery\",\n \"logs\",\n \"locks\",\n \"workspaces\",\n];\nexport const storageInventoryDefaults = Object.freeze({\n maxEntries: 100_000,\n maxDepth: 64,\n});\n"]}
@@ -0,0 +1,2 @@
1
+ import type { StorageInventory } from "./storage-inventory.types.ts";
2
+ export declare function storageInventory(root: string, maxEntries?: number): Promise<StorageInventory>;