@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 @@
1
+ {"version":3,"file":"worktree-inspection.js","sourceRoot":"","sources":["../../../src/infrastructure/git/worktree-inspection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAE/C,OAAO,EACL,2BAA2B,EAC3B,0BAA0B,GAC3B,MAAM,oCAAoC,CAAC;AAO5C,KAAK,UAAU,UAAU,CACvB,IAAY,EACZ,IAAuB;IAEvB,IAAI,MAAM,GAAG,CAAC,CAAC;IACf,MAAM,MAAM,GAAG,MAAM,cAAc,CAAC;QAClC,UAAU,EAAE,KAAK;QACjB,SAAS,EAAE,CAAC,GAAG,2BAA2B,EAAE,GAAG,IAAI,CAAC;QACpD,SAAS,EAAE,IAAI;QACf,SAAS,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,mBAAmB,EAAE,GAAG,EAAE;QACpD,UAAU,EAAE,0BAA0B,CAAC,UAAU;QACjD,MAAM,EAAE,0BAA0B,CAAC,WAAW;QAC9C,OAAO,CAAC,OAAO,EAAE,IAAI;YACnB,IAAI,OAAO,KAAK,QAAQ;gBAAE,OAAO;YACjC,MAAM,IAAI,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;YAClC,IAAI,MAAM,GAAG,0BAA0B,CAAC,WAAW;gBACjD,MAAM,IAAI,YAAY,CACpB,WAAW,EACX,sCAAsC,CACvC,CAAC;QACN,CAA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,IAAI,EAAE,iBAAiB,EAAE,CAAC;SACxD,CAAC;IACJ,CAAC;IACD,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE,CAAC;QAC5B,MAAM,KAAK,GAAG,MAAM,YAAY,CAAC,KAAK,EAAE,OAAO,EAAE,eAAe,CAAC,CAAC,KAAK,CACrE,GAAsB,EAAE,CAAC,CAAC;YACxB,KAAK,EAAE,aAAa;YACpB,MAAM,EAAE,uBAAuB;SAChC,CAAC,CACH,CAAC;QACF,UAAU,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,GAAG,KAAK,EAAE,CAAC,CAAC;QAClE,IAAI,KAAK,CAAC,KAAK,KAAK,aAAa;YAC/B,MAAM,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC;IAC1D,CAAC;IACD,OAAO,EAAE,QAAQ,EAAE,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,UAAU,EAAE,MAAM,EAAE,CAAC;AAC/D,CAAC","sourcesContent":["import { lstat, realpath } from \"node:fs/promises\";\nimport { resolve, join } from \"node:path\";\nimport { OutpostError } from \"../../domain/errors.ts\";\nimport { requireSuccess } from \"../process.ts\";\nimport type { StorageEntry, StorageIssue } from \"../storage-inventory.types.ts\";\nimport {\n worktreeInspectionArguments,\n worktreeInspectionDefaults,\n} from \"./worktree-inspection.constants.ts\";\nimport type {\n WorkspaceGitEntry,\n WorkspaceGitInspection,\n WorkspaceGitState,\n} from \"./worktree-inspection.types.ts\";\n\nasync function inspectGit(\n path: string,\n args: readonly string[],\n): Promise<string> {\n let length = 0;\n const result = await requireSuccess({\n executable: \"git\",\n arguments: [...worktreeInspectionArguments, ...args],\n directory: path,\n variables: { LC_ALL: \"C\", GIT_TERMINAL_PROMPT: \"0\" },\n deadlineMs: worktreeInspectionDefaults.deadlineMs,\n retain: worktreeInspectionDefaults.retainBytes,\n observe(channel, text) {\n if (channel !== \"stdout\") return;\n length += Buffer.byteLength(text);\n if (length > worktreeInspectionDefaults.retainBytes)\n throw new OutpostError(\n \"workspace\",\n \"Git inspection output limit exceeded\",\n );\n },\n });\n return result.stdout;\n}\n\nasync function inspectEntry(\n entry: StorageEntry,\n records: readonly (readonly string[])[],\n commonDirectory: string,\n): Promise<WorkspaceGitState> {\n if (entry.kind !== \"directory\")\n return { state: \"skipped\", reason: \"NOT_DIRECTORY\" };\n const fields = records.find((record) => {\n const path = record\n .find((field) => field.startsWith(\"worktree \"))\n ?.slice(9);\n return path !== undefined && resolve(path) === resolve(entry.path);\n });\n if (!fields) return { state: \"unregistered\" };\n const head = fields.find((field) => field.startsWith(\"HEAD \"))?.slice(5);\n if (!head) return { state: \"unavailable\", reason: \"INVALID_REGISTRATION\" };\n // A listed worktree may have been replaced since registration or inventory.\n if (\n !(await lstat(entry.path)).isDirectory() ||\n (await realpath(entry.path)) !== resolve(entry.path)\n )\n return { state: \"unavailable\", reason: \"WORKSPACE_CHANGED\" };\n const marker = await lstat(join(entry.path, \".git\"));\n if (!marker.isFile())\n return { state: \"unavailable\", reason: \"INVALID_GIT_MARKER\" };\n const top = (\n await inspectGit(entry.path, [\"rev-parse\", \"--show-toplevel\"])\n ).trim();\n if (resolve(top) !== resolve(entry.path))\n return { state: \"unavailable\", reason: \"WORKSPACE_CHANGED\" };\n const common = (\n await inspectGit(entry.path, [\n \"rev-parse\",\n \"--path-format=absolute\",\n \"--git-common-dir\",\n ])\n ).trim();\n if ((await realpath(common)) !== commonDirectory)\n return { state: \"unavailable\", reason: \"REGISTRATION_MISMATCH\" };\n const status = await inspectGit(entry.path, [\n \"status\",\n \"--porcelain=v1\",\n \"-z\",\n \"--untracked-files=normal\",\n \"--ignore-submodules=none\",\n ]);\n return {\n state: \"registered\",\n head,\n branch:\n fields\n .find((field) => field.startsWith(\"branch refs/heads/\"))\n ?.slice(18) ?? null,\n dirty: status.length > 0,\n locked: fields.some(\n (field) => field === \"locked\" || field.startsWith(\"locked \"),\n ),\n };\n}\n\nexport async function inspectWorktreeGit(\n repository: string,\n entries: readonly StorageEntry[],\n): Promise<WorkspaceGitInspection> {\n const workspaces: WorkspaceGitEntry[] = [];\n const issues: StorageIssue[] = [];\n if (!entries.length) return { complete: true, workspaces, issues };\n let records: string[][];\n let commonDirectory: string;\n try {\n commonDirectory = await realpath(\n (\n await inspectGit(repository, [\n \"rev-parse\",\n \"--path-format=absolute\",\n \"--git-common-dir\",\n ])\n ).trim(),\n );\n const list = await inspectGit(repository, [\n \"worktree\",\n \"list\",\n \"--porcelain\",\n \"-z\",\n ]);\n records = list\n .split(\"\\0\\0\")\n .filter(Boolean)\n .map((record) => record.split(\"\\0\"));\n } catch {\n return {\n complete: false,\n workspaces: entries.map(({ name, path }) => ({\n name,\n path,\n state: \"unavailable\",\n reason: \"GIT_LIST_FAILED\",\n })),\n issues: [{ path: repository, code: \"GIT_LIST_FAILED\" }],\n };\n }\n for (const entry of entries) {\n const state = await inspectEntry(entry, records, commonDirectory).catch(\n (): WorkspaceGitState => ({\n state: \"unavailable\",\n reason: \"GIT_INSPECTION_FAILED\",\n }),\n );\n workspaces.push({ name: entry.name, path: entry.path, ...state });\n if (state.state === \"unavailable\")\n issues.push({ path: entry.path, code: state.reason });\n }\n return { complete: issues.length === 0, workspaces, issues };\n}\n"]}
@@ -0,0 +1,19 @@
1
+ import type { StorageEntry, StorageIssue } from "../storage-inventory.types.ts";
2
+ export type WorkspaceGitState = {
3
+ readonly state: "registered";
4
+ readonly head: string;
5
+ readonly branch: string | null;
6
+ readonly dirty: boolean;
7
+ readonly locked: boolean;
8
+ } | {
9
+ readonly state: "unregistered";
10
+ } | {
11
+ readonly state: "skipped" | "unavailable";
12
+ readonly reason: string;
13
+ };
14
+ export type WorkspaceGitEntry = Pick<StorageEntry, "name" | "path"> & WorkspaceGitState;
15
+ export interface WorkspaceGitInspection {
16
+ readonly complete: boolean;
17
+ readonly workspaces: readonly WorkspaceGitEntry[];
18
+ readonly issues: readonly StorageIssue[];
19
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=worktree-inspection.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"worktree-inspection.types.js","sourceRoot":"","sources":["../../../src/infrastructure/git/worktree-inspection.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { StorageEntry, StorageIssue } from \"../storage-inventory.types.ts\";\n\nexport type WorkspaceGitState =\n | {\n readonly state: \"registered\";\n readonly head: string;\n readonly branch: string | null;\n readonly dirty: boolean;\n readonly locked: boolean;\n }\n | { readonly state: \"unregistered\" }\n | { readonly state: \"skipped\" | \"unavailable\"; readonly reason: string };\n\nexport type WorkspaceGitEntry = Pick<StorageEntry, \"name\" | \"path\"> &\n WorkspaceGitState;\n\nexport interface WorkspaceGitInspection {\n readonly complete: boolean;\n readonly workspaces: readonly WorkspaceGitEntry[];\n readonly issues: readonly StorageIssue[];\n}\n"]}
@@ -0,0 +1 @@
1
+ export declare const inspectionFileFlags: number;
@@ -0,0 +1,5 @@
1
+ import { constants } from "node:fs";
2
+ export const inspectionFileFlags = constants.O_RDONLY |
3
+ (constants.O_NOFOLLOW ?? 0) |
4
+ (constants.O_NONBLOCK ?? 0);
5
+ //# sourceMappingURL=inspection-file.constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inspection-file.constants.js","sourceRoot":"","sources":["../../src/infrastructure/inspection-file.constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEpC,MAAM,CAAC,MAAM,mBAAmB,GAC9B,SAAS,CAAC,QAAQ;IAClB,CAAC,SAAS,CAAC,UAAU,IAAI,CAAC,CAAC;IAC3B,CAAC,SAAS,CAAC,UAAU,IAAI,CAAC,CAAC,CAAC","sourcesContent":["import { constants } from \"node:fs\";\n\nexport const inspectionFileFlags =\n constants.O_RDONLY |\n (constants.O_NOFOLLOW ?? 0) |\n (constants.O_NONBLOCK ?? 0);\n"]}
@@ -0,0 +1 @@
1
+ export declare function readInspectionFile(path: string, maxBytes: number): Promise<Buffer>;
@@ -0,0 +1,43 @@
1
+ import { lstat, open, realpath } from "node:fs/promises";
2
+ import { resolve } from "node:path";
3
+ import { positive } from "../domain/errors.js";
4
+ import { inspectionFileFlags } from "./inspection-file.constants.js";
5
+ function unchanged(before, after) {
6
+ return (before.dev === after.dev &&
7
+ before.ino === after.ino &&
8
+ before.size === after.size &&
9
+ before.mtimeMs === after.mtimeMs &&
10
+ before.ctimeMs === after.ctimeMs);
11
+ }
12
+ export async function readInspectionFile(path, maxBytes) {
13
+ positive(maxBytes, "maxBytes");
14
+ const before = await lstat(path);
15
+ if (!before.isFile() || (await realpath(path)) !== resolve(path))
16
+ throw new Error("Inspection path changed");
17
+ if (before.size > maxBytes)
18
+ throw new Error("Inspection file is too large");
19
+ const file = await open(path, inspectionFileFlags);
20
+ try {
21
+ const opened = await file.stat();
22
+ if (!opened.isFile() || !unchanged(before, opened))
23
+ throw new Error("Inspection file changed");
24
+ const buffer = Buffer.alloc(maxBytes + 1);
25
+ let length = 0;
26
+ while (length < buffer.length) {
27
+ const { bytesRead } = await file.read(buffer, length, buffer.length - length, length);
28
+ if (!bytesRead)
29
+ break;
30
+ length += bytesRead;
31
+ }
32
+ if (length > maxBytes)
33
+ throw new Error("Inspection file is too large");
34
+ if (!unchanged(opened, await file.stat()) ||
35
+ !unchanged(opened, await lstat(path)))
36
+ throw new Error("Inspection file changed");
37
+ return buffer.subarray(0, length);
38
+ }
39
+ finally {
40
+ await file.close();
41
+ }
42
+ }
43
+ //# sourceMappingURL=inspection-file.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inspection-file.js","sourceRoot":"","sources":["../../src/infrastructure/inspection-file.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO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,CAAC,KAAK,CAAC,QAAQ,GAAG,CAAC,CAAC,CAAC;QAC1C,IAAI,MAAM,GAAG,CAAC,CAAC;QACf,OAAO,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC;YAC9B,MAAM,EAAE,SAAS,EAAE,GAAG,MAAM,IAAI,CAAC,IAAI,CACnC,MAAM,EACN,MAAM,EACN,MAAM,CAAC,MAAM,GAAG,MAAM,EACtB,MAAM,CACP,CAAC;YACF,IAAI,CAAC,SAAS;gBAAE,MAAM;YACtB,MAAM,IAAI,SAAS,CAAC;QACtB,CAAC;QACD,IAAI,MAAM,GAAG,QAAQ;YAAE,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;QACvE,IACE,CAAC,SAAS,CAAC,MAAM,EAAE,MAAM,IAAI,CAAC,IAAI,EAAE,CAAC;YACrC,CAAC,SAAS,CAAC,MAAM,EAAE,MAAM,KAAK,CAAC,IAAI,CAAC,CAAC;YAErC,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;QAC7C,OAAO,MAAM,CAAC,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;IACpC,CAAC;YAAS,CAAC;QACT,MAAM,IAAI,CAAC,KAAK,EAAE,CAAC;IACrB,CAAC;AACH,CAAC","sourcesContent":["import { lstat, open, realpath } from \"node:fs/promises\";\nimport { resolve } from \"node:path\";\nimport type { Stats } from \"node:fs\";\nimport { positive } from \"../domain/errors.ts\";\nimport { inspectionFileFlags } from \"./inspection-file.constants.ts\";\n\nfunction unchanged(before: Stats, after: Stats): boolean {\n return (\n before.dev === after.dev &&\n before.ino === after.ino &&\n before.size === after.size &&\n before.mtimeMs === after.mtimeMs &&\n before.ctimeMs === after.ctimeMs\n );\n}\n\nexport async function readInspectionFile(\n path: string,\n maxBytes: number,\n): Promise<Buffer> {\n positive(maxBytes, \"maxBytes\");\n const before = await lstat(path);\n if (!before.isFile() || (await realpath(path)) !== resolve(path))\n throw new Error(\"Inspection path changed\");\n if (before.size > maxBytes) throw new Error(\"Inspection file is too large\");\n const file = await open(path, inspectionFileFlags);\n try {\n const opened = await file.stat();\n if (!opened.isFile() || !unchanged(before, opened))\n throw new Error(\"Inspection file changed\");\n const buffer = Buffer.alloc(maxBytes + 1);\n let length = 0;\n while (length < buffer.length) {\n const { bytesRead } = await file.read(\n buffer,\n length,\n buffer.length - length,\n length,\n );\n if (!bytesRead) break;\n length += bytesRead;\n }\n if (length > maxBytes) throw new Error(\"Inspection file is too large\");\n if (\n !unchanged(opened, await file.stat()) ||\n !unchanged(opened, await lstat(path))\n )\n throw new Error(\"Inspection file changed\");\n return buffer.subarray(0, length);\n } finally {\n await file.close();\n }\n}\n"]}
@@ -0,0 +1 @@
1
+ export declare const inspectionHashChunkBytes = 65536;
@@ -0,0 +1,2 @@
1
+ export const inspectionHashChunkBytes = 65_536;
2
+ //# sourceMappingURL=inspection-hash.constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inspection-hash.constants.js","sourceRoot":"","sources":["../../src/infrastructure/inspection-hash.constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,wBAAwB,GAAG,MAAM,CAAC","sourcesContent":["export const inspectionHashChunkBytes = 65_536;\n"]}
@@ -0,0 +1,2 @@
1
+ import type { InspectionHash } from "./inspection-hash.types.ts";
2
+ export declare function hashInspectionEntry(path: string, maxBytes?: number): Promise<InspectionHash>;
@@ -0,0 +1,62 @@
1
+ import { createHash } from "node:crypto";
2
+ import { lstat, open, readlink, realpath } from "node:fs/promises";
3
+ import { dirname, resolve } from "node:path";
4
+ import { OutpostError } from "../domain/errors.js";
5
+ import { inspectionFileFlags } from "./inspection-file.constants.js";
6
+ import { inspectionHashChunkBytes } from "./inspection-hash.constants.js";
7
+ function unchanged(before, after) {
8
+ return (before.dev === after.dev &&
9
+ before.ino === after.ino &&
10
+ before.size === after.size &&
11
+ before.mtimeMs === after.mtimeMs &&
12
+ before.ctimeMs === after.ctimeMs);
13
+ }
14
+ export async function hashInspectionEntry(path, maxBytes = Number.MAX_SAFE_INTEGER) {
15
+ const before = await lstat(path);
16
+ if ((await realpath(dirname(path))) !== resolve(dirname(path)))
17
+ throw new Error("Hash path traverses a symlink");
18
+ const hash = createHash("sha256");
19
+ if (before.isSymbolicLink()) {
20
+ const target = await readlink(path, { encoding: "buffer" });
21
+ if (target.length > maxBytes)
22
+ throw new OutpostError("workspace", "Checksum byte limit exceeded", {
23
+ reason: "CHECKSUM_LIMIT",
24
+ });
25
+ if (!unchanged(before, await lstat(path)))
26
+ throw new Error("Hash source changed");
27
+ return {
28
+ kind: "symlink",
29
+ bytes: target.length,
30
+ sha256: hash.update(target).digest("hex"),
31
+ };
32
+ }
33
+ if (!before.isFile())
34
+ throw new Error("Hash source is not a regular file");
35
+ if (before.size > maxBytes)
36
+ throw new OutpostError("workspace", "Checksum byte limit exceeded", {
37
+ reason: "CHECKSUM_LIMIT",
38
+ });
39
+ const file = await open(path, inspectionFileFlags);
40
+ try {
41
+ const opened = await file.stat();
42
+ if (!opened.isFile() || !unchanged(before, opened))
43
+ throw new Error("Hash source changed");
44
+ const buffer = Buffer.alloc(inspectionHashChunkBytes);
45
+ let bytes = 0;
46
+ while (bytes < opened.size) {
47
+ const result = await file.read(buffer, 0, Math.min(buffer.length, opened.size - bytes), bytes);
48
+ if (!result.bytesRead)
49
+ throw new Error("Hash source truncated");
50
+ bytes += result.bytesRead;
51
+ hash.update(buffer.subarray(0, result.bytesRead));
52
+ }
53
+ if (!unchanged(opened, await file.stat()) ||
54
+ !unchanged(opened, await lstat(path)))
55
+ throw new Error("Hash source changed");
56
+ return { kind: "file", bytes, sha256: hash.digest("hex") };
57
+ }
58
+ finally {
59
+ await file.close();
60
+ }
61
+ }
62
+ //# sourceMappingURL=inspection-hash.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inspection-hash.js","sourceRoot":"","sources":["../../src/infrastructure/inspection-hash.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,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KAAK,CAAC,EAC5C,KAAK,CACN,CAAC;YACF,IAAI,CAAC,MAAM,CAAC,SAAS;gBAAE,MAAM,IAAI,KAAK,CAAC,uBAAuB,CAAC,CAAC;YAChE,KAAK,IAAI,MAAM,CAAC,SAAS,CAAC;YAC1B,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC;QACpD,CAAC;QACD,IACE,CAAC,SAAS,CAAC,MAAM,EAAE,MAAM,IAAI,CAAC,IAAI,EAAE,CAAC;YACrC,CAAC,SAAS,CAAC,MAAM,EAAE,MAAM,KAAK,CAAC,IAAI,CAAC,CAAC;YAErC,MAAM,IAAI,KAAK,CAAC,qBAAqB,CAAC,CAAC;QACzC,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;IAC7D,CAAC;YAAS,CAAC;QACT,MAAM,IAAI,CAAC,KAAK,EAAE,CAAC;IACrB,CAAC;AACH,CAAC","sourcesContent":["import { createHash } from \"node:crypto\";\nimport { lstat, open, readlink, realpath } from \"node:fs/promises\";\nimport { dirname, resolve } from \"node:path\";\nimport type { Stats } from \"node:fs\";\nimport { OutpostError } from \"../domain/errors.ts\";\nimport { inspectionFileFlags } from \"./inspection-file.constants.ts\";\nimport { inspectionHashChunkBytes } from \"./inspection-hash.constants.ts\";\nimport type { InspectionHash } from \"./inspection-hash.types.ts\";\n\nfunction unchanged(before: Stats, after: Stats): boolean {\n return (\n before.dev === after.dev &&\n before.ino === after.ino &&\n before.size === after.size &&\n before.mtimeMs === after.mtimeMs &&\n before.ctimeMs === after.ctimeMs\n );\n}\n\nexport async function hashInspectionEntry(\n path: string,\n maxBytes = Number.MAX_SAFE_INTEGER,\n): Promise<InspectionHash> {\n const before = await lstat(path);\n if ((await realpath(dirname(path))) !== resolve(dirname(path)))\n throw new Error(\"Hash path traverses a symlink\");\n const hash = createHash(\"sha256\");\n if (before.isSymbolicLink()) {\n const target = await readlink(path, { encoding: \"buffer\" });\n if (target.length > maxBytes)\n throw new OutpostError(\"workspace\", \"Checksum byte limit exceeded\", {\n reason: \"CHECKSUM_LIMIT\",\n });\n if (!unchanged(before, await lstat(path)))\n throw new Error(\"Hash source changed\");\n return {\n kind: \"symlink\",\n bytes: target.length,\n sha256: hash.update(target).digest(\"hex\"),\n };\n }\n if (!before.isFile()) throw new Error(\"Hash source is not a regular file\");\n if (before.size > maxBytes)\n throw new OutpostError(\"workspace\", \"Checksum byte limit exceeded\", {\n reason: \"CHECKSUM_LIMIT\",\n });\n const file = await open(path, inspectionFileFlags);\n try {\n const opened = await file.stat();\n if (!opened.isFile() || !unchanged(before, opened))\n throw new Error(\"Hash source changed\");\n const buffer = Buffer.alloc(inspectionHashChunkBytes);\n let bytes = 0;\n while (bytes < opened.size) {\n const result = await file.read(\n buffer,\n 0,\n Math.min(buffer.length, opened.size - bytes),\n bytes,\n );\n if (!result.bytesRead) throw new Error(\"Hash source truncated\");\n bytes += result.bytesRead;\n hash.update(buffer.subarray(0, result.bytesRead));\n }\n if (\n !unchanged(opened, await file.stat()) ||\n !unchanged(opened, await lstat(path))\n )\n throw new Error(\"Hash source changed\");\n return { kind: \"file\", bytes, sha256: hash.digest(\"hex\") };\n } finally {\n await file.close();\n }\n}\n"]}
@@ -0,0 +1,5 @@
1
+ export interface InspectionHash {
2
+ readonly kind: "file" | "symlink";
3
+ readonly bytes: number;
4
+ readonly sha256: string;
5
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=inspection-hash.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inspection-hash.types.js","sourceRoot":"","sources":["../../src/infrastructure/inspection-hash.types.ts"],"names":[],"mappings":"","sourcesContent":["export interface InspectionHash {\n readonly kind: \"file\" | \"symlink\";\n readonly bytes: number;\n readonly sha256: string;\n}\n"]}
@@ -0,0 +1,4 @@
1
+ export declare const journalRetentionLimits: {
2
+ readonly maxMarkerBytes: 4096;
3
+ readonly maxLogBytes: 1073741824;
4
+ };
@@ -0,0 +1,5 @@
1
+ export const journalRetentionLimits = {
2
+ maxMarkerBytes: 4096,
3
+ maxLogBytes: 1_073_741_824,
4
+ };
5
+ //# sourceMappingURL=journal-retention.constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"journal-retention.constants.js","sourceRoot":"","sources":["../../src/infrastructure/journal-retention.constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,sBAAsB,GAAG;IACpC,cAAc,EAAE,IAAI;IACpB,WAAW,EAAE,aAAa;CAClB,CAAC","sourcesContent":["export const journalRetentionLimits = {\n maxMarkerBytes: 4096,\n maxLogBytes: 1_073_741_824,\n} as const;\n"]}
@@ -0,0 +1,2 @@
1
+ export declare function markJournalClosed(file: string): Promise<void>;
2
+ export declare function closedJournal(file: string): Promise<boolean>;
@@ -0,0 +1,51 @@
1
+ import { journalRetentionLimits } from "./journal-retention.constants.js";
2
+ import { lstat, writeFile } from "node:fs/promises";
3
+ import { hashInspectionEntry } from "./inspection-hash.js";
4
+ import { readInspectionFile } from "./inspection-file.js";
5
+ export async function markJournalClosed(file) {
6
+ const info = await lstat(file);
7
+ const fingerprint = await hashInspectionEntry(file);
8
+ await writeFile(`${file}.closed.json`, JSON.stringify({
9
+ version: 1,
10
+ closedAt: new Date().toISOString(),
11
+ dev: info.dev,
12
+ ino: info.ino,
13
+ mtimeMs: info.mtimeMs,
14
+ ctimeMs: info.ctimeMs,
15
+ ...fingerprint,
16
+ }), { flag: "wx", mode: 0o600 });
17
+ }
18
+ export async function closedJournal(file) {
19
+ try {
20
+ const record = JSON.parse((await readInspectionFile(`${file}.closed.json`, journalRetentionLimits.maxMarkerBytes)).toString("utf8"));
21
+ if (!record ||
22
+ typeof record !== "object" ||
23
+ !("version" in record) ||
24
+ record.version !== 1 ||
25
+ !("closedAt" in record) ||
26
+ typeof record.closedAt !== "string" ||
27
+ !Number.isFinite(Date.parse(record.closedAt)) ||
28
+ !("kind" in record) ||
29
+ record.kind !== "file" ||
30
+ !("bytes" in record) ||
31
+ typeof record.bytes !== "number" ||
32
+ !Number.isSafeInteger(record.bytes) ||
33
+ record.bytes < 0 ||
34
+ !("sha256" in record) ||
35
+ typeof record.sha256 !== "string" ||
36
+ !/^[a-f0-9]{64}$/.test(record.sha256))
37
+ return false;
38
+ const info = await lstat(file);
39
+ for (const key of ["dev", "ino", "mtimeMs", "ctimeMs"])
40
+ if (Object.getOwnPropertyDescriptor(record, key)?.value !== info[key])
41
+ return false;
42
+ const current = await hashInspectionEntry(file, journalRetentionLimits.maxLogBytes);
43
+ return (current.kind === "file" &&
44
+ current.bytes === record.bytes &&
45
+ current.sha256 === record.sha256);
46
+ }
47
+ catch {
48
+ return false;
49
+ }
50
+ }
51
+ //# sourceMappingURL=journal-retention.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"journal-retention.js","sourceRoot":"","sources":["../../src/infrastructure/journal-retention.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,kCAAkC,CAAC;AAC1E,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE1D,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAAC,IAAY;IAClD,MAAM,IAAI,GAAG,MAAM,KAAK,CAAC,IAAI,CAAC,CAAC;IAC/B,MAAM,WAAW,GAAG,MAAM,mBAAmB,CAAC,IAAI,CAAC,CAAC;IACpD,MAAM,SAAS,CACb,GAAG,IAAI,cAAc,EACrB,IAAI,CAAC,SAAS,CAAC;QACb,OAAO,EAAE,CAAC;QACV,QAAQ,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;QAClC,GAAG,EAAE,IAAI,CAAC,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AM,KAAK,CAAC,IAAI,CAAC,CAAC;QAC/B,KAAK,MAAM,GAAG,IAAI,CAAC,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,SAAS,CAAU;YAC7D,IAAI,MAAM,CAAC,wBAAwB,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,KAAK,KAAK,IAAI,CAAC,GAAG,CAAC;gBACnE,OAAO,KAAK,CAAC;QACjB,MAAM,OAAO,GAAG,MAAM,mBAAmB,CACvC,IAAI,EACJ,sBAAsB,CAAC,WAAW,CACnC,CAAC;QACF,OAAO,CACL,OAAO,CAAC,IAAI,KAAK,MAAM;YACvB,OAAO,CAAC,KAAK,KAAK,MAAM,CAAC,KAAK;YAC9B,OAAO,CAAC,MAAM,KAAK,MAAM,CAAC,MAAM,CACjC,CAAC;IACJ,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC","sourcesContent":["import { journalRetentionLimits } from \"./journal-retention.constants.ts\";\nimport { lstat, writeFile } from \"node:fs/promises\";\nimport { hashInspectionEntry } from \"./inspection-hash.ts\";\nimport { readInspectionFile } from \"./inspection-file.ts\";\n\nexport async function markJournalClosed(file: string): Promise<void> {\n const info = await lstat(file);\n const fingerprint = await hashInspectionEntry(file);\n await writeFile(\n `${file}.closed.json`,\n JSON.stringify({\n version: 1,\n closedAt: new Date().toISOString(),\n dev: info.dev,\n ino: info.ino,\n mtimeMs: info.mtimeMs,\n ctimeMs: info.ctimeMs,\n ...fingerprint,\n }),\n { flag: \"wx\", mode: 0o600 },\n );\n}\n\nexport async function closedJournal(file: string): Promise<boolean> {\n try {\n const record: unknown = JSON.parse(\n (\n await readInspectionFile(\n `${file}.closed.json`,\n journalRetentionLimits.maxMarkerBytes,\n )\n ).toString(\"utf8\"),\n );\n if (\n !record ||\n typeof record !== \"object\" ||\n !(\"version\" in record) ||\n record.version !== 1 ||\n !(\"closedAt\" in record) ||\n typeof record.closedAt !== \"string\" ||\n !Number.isFinite(Date.parse(record.closedAt)) ||\n !(\"kind\" in record) ||\n record.kind !== \"file\" ||\n !(\"bytes\" in record) ||\n typeof record.bytes !== \"number\" ||\n !Number.isSafeInteger(record.bytes) ||\n record.bytes < 0 ||\n !(\"sha256\" in record) ||\n typeof record.sha256 !== \"string\" ||\n !/^[a-f0-9]{64}$/.test(record.sha256)\n )\n return false;\n const info = await lstat(file);\n for (const key of [\"dev\", \"ino\", \"mtimeMs\", \"ctimeMs\"] as const)\n if (Object.getOwnPropertyDescriptor(record, key)?.value !== info[key])\n return false;\n const current = await hashInspectionEntry(\n file,\n journalRetentionLimits.maxLogBytes,\n );\n return (\n current.kind === \"file\" &&\n current.bytes === record.bytes &&\n current.sha256 === record.sha256\n );\n } catch {\n return false;\n }\n}\n"]}
@@ -1,5 +1,7 @@
1
+ import { lock } from "./git/lock.js";
2
+ import { markJournalClosed } from "./journal-retention.js";
1
3
  import { randomUUID } from "node:crypto";
2
- import { mkdir, open } from "node:fs/promises";
4
+ import { mkdir, open, rm } from "node:fs/promises";
3
5
  import { dirname, join, resolve } from "node:path";
4
6
  import { reporter } from "./reporter.js";
5
7
  export async function journal(repository, logging = {}, label) {
@@ -9,20 +11,32 @@ export async function journal(repository, logging = {}, label) {
9
11
  : undefined;
10
12
  let handle, pending = Promise.resolve();
11
13
  let failure;
14
+ let release;
15
+ let closing;
16
+ const managed = !!logging && logging !== "stdout" && logging.file === undefined;
12
17
  const display = reporter({ ...(label ? { label } : {}) });
13
18
  if (file) {
14
19
  await mkdir(dirname(file), { recursive: true });
15
- handle = await open(file, "a", 0o600);
16
- await handle.write(JSON.stringify({
17
- kind: "dispatch-start",
18
- at: new Date().toISOString(),
19
- label,
20
- }) + "\n");
20
+ release = await lock(repository, `journal:${file}`);
21
+ try {
22
+ await rm(`${file}.closed.json`, { force: true });
23
+ handle = await open(file, managed ? "wx" : "a", 0o600);
24
+ await handle.write(JSON.stringify({
25
+ kind: "dispatch-start",
26
+ at: new Date().toISOString(),
27
+ label,
28
+ }) + "\n");
29
+ }
30
+ catch (error) {
31
+ await handle?.close();
32
+ await release();
33
+ throw error;
34
+ }
21
35
  }
22
36
  return {
23
37
  ...(file ? { file } : {}),
24
38
  record(event) {
25
- if (!logging)
39
+ if (!logging || closing)
26
40
  return;
27
41
  if (event.kind === "raw" && logging !== "stdout" && !logging.verbose)
28
42
  return;
@@ -42,11 +56,21 @@ export async function journal(repository, logging = {}, label) {
42
56
  failure = error;
43
57
  });
44
58
  },
45
- async close() {
46
- await pending;
47
- await handle?.close();
48
- if (failure)
49
- throw failure;
59
+ close() {
60
+ closing ??= (async () => {
61
+ try {
62
+ await pending;
63
+ await handle?.close();
64
+ if (failure)
65
+ throw failure;
66
+ if (file && managed)
67
+ await markJournalClosed(file);
68
+ }
69
+ finally {
70
+ await release?.();
71
+ }
72
+ })();
73
+ return closing;
50
74
  },
51
75
  };
52
76
  }
@@ -1 +1 @@
1
- {"version":3,"file":"journal.js","sourceRoot":"","sources":["../../src/infrastructure/journal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEnD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAIzC,MAAM,CAAC,KAAK,UAAU,OAAO,CAC3B,UAAkB,EAClB,UAAmB,EAAE,EACrB,KAAc;IAEd,MAAM,IAAI,GACR,OAAO,IAAI,OAAO,KAAK,QAAQ;QAC7B,CAAC,CAAC,OAAO,CACL,UAAU,EACV,OAAO,CAAC,IAAI;YACV,IAAI,CACF,UAAU,EACV,MAAM,EACN,GAAG,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,iBAAiB,EAAE,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,GAAG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C,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;gBAC3B,GAAG,KAAK;aACT,CAAC,GAAG,IAAI,CAAC;YACZ,IAAI,OAAO,KAAK,QAAQ;gBAAE,OAAO,CAAC,KAAK,CAAC,CAAC;;gBAEvC,OAAO,GAAG,OAAO;qBACd,IAAI,CAAC,KAAK,IAAI,EAAE;oBACf,MAAM,MAAM,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;gBAC5B,CAAC,CAAC;qBACD,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;oBACf,OAAO,GAAG,KAAK,CAAC;gBAClB,CAAC,CAAC,CAAC;QACT,CAAC;QACD,KAAK,CAAC,KAAK;YACT,MAAM,OAAO,CAAC;YACd,MAAM,MAAM,EAAE,KAAK,EAAE,CAAC;YACtB,IAAI,OAAO;gBAAE,MAAM,OAAO,CAAC;QAC7B,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { randomUUID } from \"node:crypto\";\nimport type { FileHandle } from \"node:fs/promises\";\nimport { mkdir, open } from \"node:fs/promises\";\nimport { dirname, join, resolve } from \"node:path\";\nimport type { Journal, Logging } from \"./journal.types.ts\";\nimport { reporter } from \"./reporter.ts\";\n\nexport type { Logging } from \"./journal.types.ts\";\n\nexport async function journal(\n repository: string,\n logging: Logging = {},\n label?: string,\n): Promise<Journal> {\n const file =\n logging && logging !== \"stdout\"\n ? resolve(\n repository,\n logging.file ??\n join(\n \".outpost\",\n \"logs\",\n `${label ? label.replace(/[^A-Za-z0-9_-]/g, \"-\").slice(0, 64) + \"-\" : \"\"}${new Date().toISOString().replaceAll(\":\", \"-\")}-${randomUUID()}.jsonl`,\n ),\n )\n : undefined;\n let handle: FileHandle | undefined,\n pending = Promise.resolve();\n let failure: unknown;\n const display = reporter({ ...(label ? { label } : {}) });\n if (file) {\n await mkdir(dirname(file), { recursive: true });\n handle = await open(file, \"a\", 0o600);\n await handle.write(\n JSON.stringify({\n kind: \"dispatch-start\",\n at: new Date().toISOString(),\n label,\n }) + \"\\n\",\n );\n }\n return {\n ...(file ? { file } : {}),\n record(event) {\n if (!logging) return;\n if (event.kind === \"raw\" && logging !== \"stdout\" && !logging.verbose)\n return;\n const line =\n JSON.stringify({\n at: new Date().toISOString(),\n ...(label ? { label } : {}),\n ...event,\n }) + \"\\n\";\n if (logging === \"stdout\") display(event);\n else\n pending = pending\n .then(async () => {\n await handle?.write(line);\n })\n .catch((error) => {\n failure = error;\n });\n },\n async close() {\n await pending;\n await handle?.close();\n if (failure) throw failure;\n },\n };\n}\n"]}
1
+ {"version":3,"file":"journal.js","sourceRoot":"","sources":["../../src/infrastructure/journal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AACrC,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEnD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAIzC,MAAM,CAAC,KAAK,UAAU,OAAO,CAC3B,UAAkB,EAClB,UAAmB,EAAE,EACrB,KAAc;IAEd,MAAM,IAAI,GACR,OAAO,IAAI,OAAO,KAAK,QAAQ;QAC7B,CAAC,CAAC,OAAO,CACL,UAAU,EACV,OAAO,CAAC,IAAI;YACV,IAAI,CACF,UAAU,EACV,MAAM,EACN,GAAG,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,iBAAiB,EAAE,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,UAAU,CAAC,GAAG,EA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AE,CAAC;YACL,OAAO,OAAO,CAAC;QACjB,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { lock } from \"./git/lock.ts\";\nimport { markJournalClosed } from \"./journal-retention.ts\";\nimport { randomUUID } from \"node:crypto\";\nimport type { FileHandle } from \"node:fs/promises\";\nimport { mkdir, open, rm } from \"node:fs/promises\";\nimport { dirname, join, resolve } from \"node:path\";\nimport type { Journal, Logging } from \"./journal.types.ts\";\nimport { reporter } from \"./reporter.ts\";\n\nexport type { Logging } from \"./journal.types.ts\";\n\nexport async function journal(\n repository: string,\n logging: Logging = {},\n label?: string,\n): Promise<Journal> {\n const file =\n logging && logging !== \"stdout\"\n ? resolve(\n repository,\n logging.file ??\n join(\n \".outpost\",\n \"logs\",\n `${label ? label.replace(/[^A-Za-z0-9_-]/g, \"-\").slice(0, 64) + \"-\" : \"\"}${new Date().toISOString().replaceAll(\":\", \"-\")}-${randomUUID()}.jsonl`,\n ),\n )\n : undefined;\n let handle: FileHandle | undefined,\n pending = Promise.resolve();\n let failure: unknown;\n let release: (() => Promise<void>) | undefined;\n let closing: Promise<void> | undefined;\n const managed =\n !!logging && logging !== \"stdout\" && logging.file === undefined;\n const display = reporter({ ...(label ? { label } : {}) });\n if (file) {\n await mkdir(dirname(file), { recursive: true });\n release = await lock(repository, `journal:${file}`);\n try {\n await rm(`${file}.closed.json`, { force: true });\n handle = await open(file, managed ? \"wx\" : \"a\", 0o600);\n await handle.write(\n JSON.stringify({\n kind: \"dispatch-start\",\n at: new Date().toISOString(),\n label,\n }) + \"\\n\",\n );\n } catch (error) {\n await handle?.close();\n await release();\n throw error;\n }\n }\n return {\n ...(file ? { file } : {}),\n record(event) {\n if (!logging || closing) return;\n if (event.kind === \"raw\" && logging !== \"stdout\" && !logging.verbose)\n return;\n const line =\n JSON.stringify({\n at: new Date().toISOString(),\n ...(label ? { label } : {}),\n ...event,\n }) + \"\\n\";\n if (logging === \"stdout\") display(event);\n else\n pending = pending\n .then(async () => {\n await handle?.write(line);\n })\n .catch((error) => {\n failure = error;\n });\n },\n close() {\n closing ??= (async () => {\n try {\n await pending;\n await handle?.close();\n if (failure) throw failure;\n if (file && managed) await markJournalClosed(file);\n } finally {\n await release?.();\n }\n })();\n return closing;\n },\n };\n}\n"]}
@@ -0,0 +1,10 @@
1
+ export declare const telemetryNames: {
2
+ readonly workflows: "outpost.workflow.executions";
3
+ readonly tasks: "outpost.task.executions";
4
+ readonly attempts: "outpost.task.attempts";
5
+ readonly retries: "outpost.task.retries";
6
+ readonly usage: "outpost.agent.tokens";
7
+ readonly workflowDuration: "outpost.workflow.duration";
8
+ readonly taskDuration: "outpost.task.duration";
9
+ readonly attemptDuration: "outpost.task.attempt.duration";
10
+ };
@@ -0,0 +1,11 @@
1
+ export const telemetryNames = {
2
+ workflows: "outpost.workflow.executions",
3
+ tasks: "outpost.task.executions",
4
+ attempts: "outpost.task.attempts",
5
+ retries: "outpost.task.retries",
6
+ usage: "outpost.agent.tokens",
7
+ workflowDuration: "outpost.workflow.duration",
8
+ taskDuration: "outpost.task.duration",
9
+ attemptDuration: "outpost.task.attempt.duration",
10
+ };
11
+ //# sourceMappingURL=opentelemetry.constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"opentelemetry.constants.js","sourceRoot":"","sources":["../../src/infrastructure/opentelemetry.constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,SAAS,EAAE,6BAA6B;IACxC,KAAK,EAAE,yBAAyB;IAChC,QAAQ,EAAE,uBAAuB;IACjC,OAAO,EAAE,sBAAsB;IAC/B,KAAK,EAAE,sBAAsB;IAC7B,gBAAgB,EAAE,2BAA2B;IAC7C,YAAY,EAAE,uBAAuB;IACrC,eAAe,EAAE,+BAA+B;CACxC,CAAC","sourcesContent":["export const telemetryNames = {\n workflows: \"outpost.workflow.executions\",\n tasks: \"outpost.task.executions\",\n attempts: \"outpost.task.attempts\",\n retries: \"outpost.task.retries\",\n usage: \"outpost.agent.tokens\",\n workflowDuration: \"outpost.workflow.duration\",\n taskDuration: \"outpost.task.duration\",\n attemptDuration: \"outpost.task.attempt.duration\",\n} as const;\n"]}
@@ -0,0 +1,3 @@
1
+ import type { OpenTelemetryObserver, OpenTelemetryOptions } from "./opentelemetry.types.ts";
2
+ export type { OpenTelemetryObserver, OpenTelemetryOptions, } from "./opentelemetry.types.ts";
3
+ export declare function openTelemetry(options: OpenTelemetryOptions): OpenTelemetryObserver;
@@ -0,0 +1,131 @@
1
+ import { context, trace, SpanStatusCode } from "@opentelemetry/api";
2
+ import { usageDimensions } from "../domain/workflow/budget.constants.js";
3
+ import { telemetryNames } from "./opentelemetry.constants.js";
4
+ export function openTelemetry(options) {
5
+ function safe(action) {
6
+ try {
7
+ return action();
8
+ }
9
+ catch (error) {
10
+ try {
11
+ options.onError?.(error);
12
+ }
13
+ catch { }
14
+ }
15
+ }
16
+ const counters = {
17
+ workflows: safe(() => options.meter.createCounter(telemetryNames.workflows)),
18
+ tasks: safe(() => options.meter.createCounter(telemetryNames.tasks)),
19
+ attempts: safe(() => options.meter.createCounter(telemetryNames.attempts)),
20
+ retries: safe(() => options.meter.createCounter(telemetryNames.retries)),
21
+ usage: safe(() => options.meter.createCounter(telemetryNames.usage, { unit: "{token}" })),
22
+ };
23
+ const durations = {
24
+ workflow: safe(() => options.meter.createHistogram(telemetryNames.workflowDuration, {
25
+ unit: "s",
26
+ })),
27
+ task: safe(() => options.meter.createHistogram(telemetryNames.taskDuration, { unit: "s" })),
28
+ attempt: safe(() => options.meter.createHistogram(telemetryNames.attemptDuration, {
29
+ unit: "s",
30
+ })),
31
+ };
32
+ const executions = new Map();
33
+ let closed = false;
34
+ function start(name, parent, at) {
35
+ const span = safe(() => options.tracer.startSpan(name, { startTime: at }, parent));
36
+ return {
37
+ span,
38
+ context: span ? trace.setSpan(parent, span) : parent,
39
+ started: at,
40
+ };
41
+ }
42
+ function finish(operation, status, at, duration) {
43
+ if (!operation)
44
+ return;
45
+ const attributes = { "outpost.status": status };
46
+ safe(() => operation.span?.setAttributes(attributes));
47
+ if (status !== "skipped" && status !== "paused")
48
+ safe(() => operation.span?.setStatus({
49
+ code: status === "done" ? SpanStatusCode.OK : SpanStatusCode.ERROR,
50
+ }));
51
+ safe(() => operation.span?.end(at));
52
+ safe(() => duration?.record(Math.max(0, at - operation.started) / 1000, attributes));
53
+ }
54
+ function complete(execution, status, at) {
55
+ for (const attempt of execution.attempts.values())
56
+ finish(attempt, status, at, durations.attempt);
57
+ for (const task of execution.tasks.values())
58
+ finish(task, status, at, durations.task);
59
+ finish(execution.workflow, status, at, durations.workflow);
60
+ safe(() => counters.workflows?.add(1, { "outpost.status": status }));
61
+ }
62
+ return {
63
+ observe(event) {
64
+ if (closed)
65
+ return;
66
+ const at = Date.parse(event.timestamp);
67
+ if (!Number.isFinite(at))
68
+ return;
69
+ if (event.type === "start") {
70
+ if (executions.has(event.executionId))
71
+ return;
72
+ executions.set(event.executionId, {
73
+ workflow: start("outpost.workflow", context.active(), at),
74
+ tasks: new Map(),
75
+ attempts: new Map(),
76
+ });
77
+ return;
78
+ }
79
+ const execution = executions.get(event.executionId);
80
+ if (!execution)
81
+ return;
82
+ if (event.type === "finish") {
83
+ executions.delete(event.executionId);
84
+ complete(execution, event.status ?? "done", at);
85
+ return;
86
+ }
87
+ if (event.type === "usage") {
88
+ for (const dimension of usageDimensions) {
89
+ const value = event.usage?.[dimension];
90
+ if (value !== undefined && Number.isFinite(value) && value > 0)
91
+ safe(() => counters.usage?.add(value, { "outpost.token.type": dimension }));
92
+ }
93
+ return;
94
+ }
95
+ if (event.key === undefined)
96
+ return;
97
+ if (event.type === "attempt") {
98
+ execution.attempts.set(event.key, start("outpost.task.attempt", execution.tasks.get(event.key)?.context ??
99
+ execution.workflow.context, at));
100
+ safe(() => counters.attempts?.add(1));
101
+ return;
102
+ }
103
+ if (event.type === "retry") {
104
+ finish(execution.attempts.get(event.key), "failed", at, durations.attempt);
105
+ execution.attempts.delete(event.key);
106
+ safe(() => counters.retries?.add(1));
107
+ return;
108
+ }
109
+ if (event.type === "task" && event.status === "active") {
110
+ execution.tasks.set(event.key, start("outpost.task", execution.workflow.context, at));
111
+ return;
112
+ }
113
+ if (event.type === "task" && event.status) {
114
+ finish(execution.attempts.get(event.key), event.status, at, durations.attempt);
115
+ finish(execution.tasks.get(event.key), event.status, at, durations.task);
116
+ execution.attempts.delete(event.key);
117
+ execution.tasks.delete(event.key);
118
+ safe(() => counters.tasks?.add(1, { "outpost.status": event.status }));
119
+ }
120
+ },
121
+ close() {
122
+ if (closed)
123
+ return;
124
+ closed = true;
125
+ for (const execution of executions.values())
126
+ complete(execution, "cancelled", Date.now());
127
+ executions.clear();
128
+ },
129
+ };
130
+ }
131
+ //# sourceMappingURL=opentelemetry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"opentelemetry.js","sourceRoot":"","sources":["../../src/infrastructure/opentelemetry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAGpE,OAAO,EAAE,eAAe,EAAE,MAAM,wCAAwC,CAAC;AACzE,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAa9D,MAAM,UAAU,aAAa,CAC3B,OAA6B;IAE7B,SAAS,IAAI,CAAI,MAAe;QAC9B,IAAI,CAAC;YACH,OAAO,MAAM,EAAE,CAAC;QAClB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,CAAC;gBACH,OAAO,CAAC,OAAO,EAAE,CAAC,KAAK,CAAC,CAAC;YAC3B,CAAC;YAAC,MAAM,CAAC,CAAA,CAAC;QACZ,CAAC;IACH,CAAC;IACD,MAAM,QAAQ,GAAG;QACf,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE,CACnB,OAAO,CAAC,KAAK,CAAC,aAAa,CAAC,cAAc,CAAC,SAAS,CAAC,CACtD;QACD,KAAK,EAAE,IAAI,CAAC,GAAG,EAAE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AU,CAAC,MAAM,EAAE;gBACzC,QAAQ,CAAC,SAAS,EAAE,WAAW,EAAE,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC;YAC/C,UAAU,CAAC,KAAK,EAAE,CAAC;QACrB,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { context, trace, SpanStatusCode } from \"@opentelemetry/api\";\nimport type { Context, Histogram } from \"@opentelemetry/api\";\nimport type { WorkflowEvent } from \"../domain/workflow.types.ts\";\nimport { usageDimensions } from \"../domain/workflow/budget.constants.ts\";\nimport { telemetryNames } from \"./opentelemetry.constants.ts\";\nimport type {\n OpenTelemetryObserver,\n OpenTelemetryOptions,\n TelemetryExecution,\n TelemetryOperation,\n} from \"./opentelemetry.types.ts\";\n\nexport type {\n OpenTelemetryObserver,\n OpenTelemetryOptions,\n} from \"./opentelemetry.types.ts\";\n\nexport function openTelemetry(\n options: OpenTelemetryOptions,\n): OpenTelemetryObserver {\n function safe<T>(action: () => T): T | undefined {\n try {\n return action();\n } catch (error) {\n try {\n options.onError?.(error);\n } catch {}\n }\n }\n const counters = {\n workflows: safe(() =>\n options.meter.createCounter(telemetryNames.workflows),\n ),\n tasks: safe(() => options.meter.createCounter(telemetryNames.tasks)),\n attempts: safe(() => options.meter.createCounter(telemetryNames.attempts)),\n retries: safe(() => options.meter.createCounter(telemetryNames.retries)),\n usage: safe(() =>\n options.meter.createCounter(telemetryNames.usage, { unit: \"{token}\" }),\n ),\n };\n const durations = {\n workflow: safe(() =>\n options.meter.createHistogram(telemetryNames.workflowDuration, {\n unit: \"s\",\n }),\n ),\n task: safe(() =>\n options.meter.createHistogram(telemetryNames.taskDuration, { unit: \"s\" }),\n ),\n attempt: safe(() =>\n options.meter.createHistogram(telemetryNames.attemptDuration, {\n unit: \"s\",\n }),\n ),\n };\n const executions = new Map<string, TelemetryExecution>();\n let closed = false;\n function start(\n name: string,\n parent: Context,\n at: number,\n ): TelemetryOperation {\n const span = safe(() =>\n options.tracer.startSpan(name, { startTime: at }, parent),\n );\n return {\n span,\n context: span ? trace.setSpan(parent, span) : parent,\n started: at,\n };\n }\n function finish(\n operation: TelemetryOperation | undefined,\n status: string,\n at: number,\n duration: Histogram | undefined,\n ): void {\n if (!operation) return;\n const attributes = { \"outpost.status\": status };\n safe(() => operation.span?.setAttributes(attributes));\n if (status !== \"skipped\" && status !== \"paused\")\n safe(() =>\n operation.span?.setStatus({\n code: status === \"done\" ? SpanStatusCode.OK : SpanStatusCode.ERROR,\n }),\n );\n safe(() => operation.span?.end(at));\n safe(() =>\n duration?.record(Math.max(0, at - operation.started) / 1000, attributes),\n );\n }\n function complete(\n execution: TelemetryExecution,\n status: string,\n at: number,\n ): void {\n for (const attempt of execution.attempts.values())\n finish(attempt, status, at, durations.attempt);\n for (const task of execution.tasks.values())\n finish(task, status, at, durations.task);\n finish(execution.workflow, status, at, durations.workflow);\n safe(() => counters.workflows?.add(1, { \"outpost.status\": status }));\n }\n return {\n observe(event: WorkflowEvent) {\n if (closed) return;\n const at = Date.parse(event.timestamp);\n if (!Number.isFinite(at)) return;\n if (event.type === \"start\") {\n if (executions.has(event.executionId)) return;\n executions.set(event.executionId, {\n workflow: start(\"outpost.workflow\", context.active(), at),\n tasks: new Map(),\n attempts: new Map(),\n });\n return;\n }\n const execution = executions.get(event.executionId);\n if (!execution) return;\n if (event.type === \"finish\") {\n executions.delete(event.executionId);\n complete(execution, event.status ?? \"done\", at);\n return;\n }\n if (event.type === \"usage\") {\n for (const dimension of usageDimensions) {\n const value = event.usage?.[dimension];\n if (value !== undefined && Number.isFinite(value) && value > 0)\n safe(() =>\n counters.usage?.add(value, { \"outpost.token.type\": dimension }),\n );\n }\n return;\n }\n if (event.key === undefined) return;\n if (event.type === \"attempt\") {\n execution.attempts.set(\n event.key,\n start(\n \"outpost.task.attempt\",\n execution.tasks.get(event.key)?.context ??\n execution.workflow.context,\n at,\n ),\n );\n safe(() => counters.attempts?.add(1));\n return;\n }\n if (event.type === \"retry\") {\n finish(\n execution.attempts.get(event.key),\n \"failed\",\n at,\n durations.attempt,\n );\n execution.attempts.delete(event.key);\n safe(() => counters.retries?.add(1));\n return;\n }\n if (event.type === \"task\" && event.status === \"active\") {\n execution.tasks.set(\n event.key,\n start(\"outpost.task\", execution.workflow.context, at),\n );\n return;\n }\n if (event.type === \"task\" && event.status) {\n finish(\n execution.attempts.get(event.key),\n event.status,\n at,\n durations.attempt,\n );\n finish(\n execution.tasks.get(event.key),\n event.status,\n at,\n durations.task,\n );\n execution.attempts.delete(event.key);\n execution.tasks.delete(event.key);\n safe(() => counters.tasks?.add(1, { \"outpost.status\": event.status }));\n }\n },\n close() {\n if (closed) return;\n closed = true;\n for (const execution of executions.values())\n complete(execution, \"cancelled\", Date.now());\n executions.clear();\n },\n };\n}\n"]}