@elie-laloum/outpost 3.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 (381) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/README.md +3 -1
  3. package/SECURITY.md +3 -1
  4. package/dist/adapters/agents/gemini-adapter.d.ts +3 -0
  5. package/dist/adapters/agents/gemini-adapter.js +15 -0
  6. package/dist/adapters/agents/gemini-adapter.js.map +1 -0
  7. package/dist/adapters/agents/gemini-diagnostics.d.ts +2 -0
  8. package/dist/adapters/agents/gemini-diagnostics.js +15 -0
  9. package/dist/adapters/agents/gemini-diagnostics.js.map +1 -0
  10. package/dist/adapters/agents/gemini-events.d.ts +2 -0
  11. package/dist/adapters/agents/gemini-events.js +50 -0
  12. package/dist/adapters/agents/gemini-events.js.map +1 -0
  13. package/dist/adapters/agents/gemini-request.d.ts +4 -0
  14. package/dist/adapters/agents/gemini-request.js +21 -0
  15. package/dist/adapters/agents/gemini-request.js.map +1 -0
  16. package/dist/adapters/agents/gemini.types.d.ts +6 -0
  17. package/dist/adapters/agents/gemini.types.js +2 -0
  18. package/dist/adapters/agents/gemini.types.js.map +1 -0
  19. package/dist/adapters/agents/protocol-fixtures.constants.d.ts +1 -1
  20. package/dist/adapters/agents/protocol-fixtures.constants.js +37 -0
  21. package/dist/adapters/agents/protocol-fixtures.constants.js.map +1 -1
  22. package/dist/application/agent-bootstrap.constants.d.ts +1 -0
  23. package/dist/application/agent-bootstrap.constants.js +1 -0
  24. package/dist/application/agent-bootstrap.constants.js.map +1 -1
  25. package/dist/application/agent-bootstrap.js +6 -2
  26. package/dist/application/agent-bootstrap.js.map +1 -1
  27. package/dist/application/agent-output.js +9 -2
  28. package/dist/application/agent-output.js.map +1 -1
  29. package/dist/application/artifact-tasks.d.ts +5 -0
  30. package/dist/application/artifact-tasks.js +31 -0
  31. package/dist/application/artifact-tasks.js.map +1 -0
  32. package/dist/application/artifact-tasks.types.d.ts +8 -0
  33. package/dist/application/artifact-tasks.types.js +2 -0
  34. package/dist/application/artifact-tasks.types.js.map +1 -0
  35. package/dist/application/dispatch-validation.js +2 -0
  36. package/dist/application/dispatch-validation.js.map +1 -1
  37. package/dist/application/doctor-agent.constants.d.ts +2 -0
  38. package/dist/application/doctor-agent.constants.js +2 -0
  39. package/dist/application/doctor-agent.constants.js.map +1 -1
  40. package/dist/application/doctor-agent.js +1 -1
  41. package/dist/application/doctor-agent.js.map +1 -1
  42. package/dist/application/doctor-protocol.js +2 -1
  43. package/dist/application/doctor-protocol.js.map +1 -1
  44. package/dist/application/doctor.constants.js +1 -1
  45. package/dist/application/doctor.constants.js.map +1 -1
  46. package/dist/application/doctor.types.d.ts +1 -1
  47. package/dist/application/doctor.types.js.map +1 -1
  48. package/dist/application/outpost.types.d.ts +2 -0
  49. package/dist/application/outpost.types.js.map +1 -1
  50. package/dist/application/queue-worker.d.ts +2 -0
  51. package/dist/application/queue-worker.js +75 -0
  52. package/dist/application/queue-worker.js.map +1 -0
  53. package/dist/application/queue-worker.types.d.ts +15 -0
  54. package/dist/application/queue-worker.types.js +2 -0
  55. package/dist/application/queue-worker.types.js.map +1 -0
  56. package/dist/application/queued-task.d.ts +3 -0
  57. package/dist/application/queued-task.js +56 -0
  58. package/dist/application/queued-task.js.map +1 -0
  59. package/dist/application/queued-task.types.d.ts +11 -0
  60. package/dist/application/queued-task.types.js +2 -0
  61. package/dist/application/queued-task.types.js.map +1 -0
  62. package/dist/application/recovery-inspection.js +5 -0
  63. package/dist/application/recovery-inspection.js.map +1 -1
  64. package/dist/application/recovery-inspection.types.d.ts +3 -0
  65. package/dist/application/recovery-inspection.types.js.map +1 -1
  66. package/dist/application/recovery-restore-snapshot.d.ts +2 -0
  67. package/dist/application/recovery-restore-snapshot.js +57 -0
  68. package/dist/application/recovery-restore-snapshot.js.map +1 -0
  69. package/dist/application/recovery-restore.d.ts +3 -0
  70. package/dist/application/recovery-restore.js +161 -0
  71. package/dist/application/recovery-restore.js.map +1 -0
  72. package/dist/application/recovery-restore.types.d.ts +28 -0
  73. package/dist/application/recovery-restore.types.js +2 -0
  74. package/dist/application/recovery-restore.types.js.map +1 -0
  75. package/dist/application/recovery-retention.js +5 -0
  76. package/dist/application/recovery-retention.js.map +1 -1
  77. package/dist/application/recovery-verification.d.ts +2 -1
  78. package/dist/application/recovery-verification.js +1 -1
  79. package/dist/application/recovery-verification.js.map +1 -1
  80. package/dist/application/remote-apply.js +6 -0
  81. package/dist/application/remote-apply.js.map +1 -1
  82. package/dist/application/remote-download.js +2 -2
  83. package/dist/application/remote-download.js.map +1 -1
  84. package/dist/application/remote-history.d.ts +6 -0
  85. package/dist/application/remote-history.js +114 -0
  86. package/dist/application/remote-history.js.map +1 -0
  87. package/dist/application/remote-upload.d.ts +2 -0
  88. package/dist/application/remote-upload.js +17 -0
  89. package/dist/application/remote-upload.js.map +1 -0
  90. package/dist/application/remote-validation.js +20 -28
  91. package/dist/application/remote-validation.js.map +1 -1
  92. package/dist/application/remote-workspace.js +4 -10
  93. package/dist/application/remote-workspace.js.map +1 -1
  94. package/dist/application/sandbox-activity.d.ts +3 -0
  95. package/dist/application/sandbox-activity.js +25 -0
  96. package/dist/application/sandbox-activity.js.map +1 -0
  97. package/dist/application/sandbox-provision.js +55 -10
  98. package/dist/application/sandbox-provision.js.map +1 -1
  99. package/dist/application/sandbox-session.types.d.ts +2 -0
  100. package/dist/application/sandbox-session.types.js.map +1 -1
  101. package/dist/application/sandbox.js +23 -11
  102. package/dist/application/sandbox.js.map +1 -1
  103. package/dist/application/speculation-host.d.ts +2 -0
  104. package/dist/application/speculation-host.js +30 -0
  105. package/dist/application/speculation-host.js.map +1 -0
  106. package/dist/application/speculation.constants.d.ts +4 -0
  107. package/dist/application/speculation.constants.js +2 -0
  108. package/dist/application/speculation.constants.js.map +1 -0
  109. package/dist/application/speculation.d.ts +2 -0
  110. package/dist/application/speculation.js +166 -0
  111. package/dist/application/speculation.js.map +1 -0
  112. package/dist/application/speculation.types.d.ts +56 -0
  113. package/dist/application/speculation.types.js +2 -0
  114. package/dist/application/speculation.types.js.map +1 -0
  115. package/dist/application/storage-reservation.d.ts +3 -0
  116. package/dist/application/storage-reservation.js +10 -0
  117. package/dist/application/storage-reservation.js.map +1 -0
  118. package/dist/application/storage-reservation.types.d.ts +4 -0
  119. package/dist/application/storage-reservation.types.js +2 -0
  120. package/dist/application/storage-reservation.types.js.map +1 -0
  121. package/dist/application/task-usage.d.ts +1 -1
  122. package/dist/application/task-usage.js.map +1 -1
  123. package/dist/application/tasks.js +1 -1
  124. package/dist/application/tasks.js.map +1 -1
  125. package/dist/application/tasks.types.d.ts +4 -3
  126. package/dist/application/tasks.types.js.map +1 -1
  127. package/dist/application/workspace-allocation.d.ts +3 -0
  128. package/dist/application/workspace-allocation.js +34 -0
  129. package/dist/application/workspace-allocation.js.map +1 -0
  130. package/dist/application/workspace.js +2 -2
  131. package/dist/application/workspace.js.map +1 -1
  132. package/dist/cli/doctor-command.js +1 -1
  133. package/dist/cli/doctor-command.js.map +1 -1
  134. package/dist/cli/main.constants.d.ts +11 -2
  135. package/dist/cli/main.constants.js +8 -4
  136. package/dist/cli/main.constants.js.map +1 -1
  137. package/dist/cli/recovery-command.js +28 -4
  138. package/dist/cli/recovery-command.js.map +1 -1
  139. package/dist/cli/recovery-restore-command.d.ts +2 -0
  140. package/dist/cli/recovery-restore-command.js +34 -0
  141. package/dist/cli/recovery-restore-command.js.map +1 -0
  142. package/dist/cli/scaffold-files.js +2 -2
  143. package/dist/cli/scaffold-files.js.map +1 -1
  144. package/dist/cli/scaffold-validation.js +1 -1
  145. package/dist/cli/scaffold-validation.js.map +1 -1
  146. package/dist/cli/scaffold.constants.d.ts +5 -0
  147. package/dist/cli/scaffold.constants.js +7 -2
  148. package/dist/cli/scaffold.constants.js.map +1 -1
  149. package/dist/cli/scaffold.types.d.ts +1 -1
  150. package/dist/cli/scaffold.types.js.map +1 -1
  151. package/dist/domain/agent.types.d.ts +2 -0
  152. package/dist/domain/agent.types.js.map +1 -1
  153. package/dist/domain/artifact-reference.d.ts +4 -0
  154. package/dist/domain/artifact-reference.js +90 -0
  155. package/dist/domain/artifact-reference.js.map +1 -0
  156. package/dist/domain/artifact.constants.d.ts +2 -0
  157. package/dist/domain/artifact.constants.js +3 -0
  158. package/dist/domain/artifact.constants.js.map +1 -0
  159. package/dist/domain/artifact.d.ts +7 -0
  160. package/dist/domain/artifact.js +104 -0
  161. package/dist/domain/artifact.js.map +1 -0
  162. package/dist/domain/artifact.types.d.ts +44 -0
  163. package/dist/domain/artifact.types.js +2 -0
  164. package/dist/domain/artifact.types.js.map +1 -0
  165. package/dist/domain/egress.constants.d.ts +1 -0
  166. package/dist/domain/egress.constants.js +7 -0
  167. package/dist/domain/egress.constants.js.map +1 -0
  168. package/dist/domain/egress.d.ts +2 -0
  169. package/dist/domain/egress.js +48 -0
  170. package/dist/domain/egress.js.map +1 -0
  171. package/dist/domain/egress.types.d.ts +8 -0
  172. package/dist/domain/egress.types.js +2 -0
  173. package/dist/domain/egress.types.js.map +1 -0
  174. package/dist/domain/sandbox.types.d.ts +1 -0
  175. package/dist/domain/sandbox.types.js.map +1 -1
  176. package/dist/domain/task-queue.constants.d.ts +8 -0
  177. package/dist/domain/task-queue.constants.js +9 -0
  178. package/dist/domain/task-queue.constants.js.map +1 -0
  179. package/dist/domain/task-queue.d.ts +11 -0
  180. package/dist/domain/task-queue.js +105 -0
  181. package/dist/domain/task-queue.js.map +1 -0
  182. package/dist/domain/task-queue.types.d.ts +41 -0
  183. package/dist/domain/task-queue.types.js +2 -0
  184. package/dist/domain/task-queue.types.js.map +1 -0
  185. package/dist/domain/workflow/budget.d.ts +2 -2
  186. package/dist/domain/workflow/budget.js +5 -3
  187. package/dist/domain/workflow/budget.js.map +1 -1
  188. package/dist/domain/workflow/checkpoint-validation.d.ts +3 -0
  189. package/dist/domain/workflow/checkpoint-validation.js +81 -0
  190. package/dist/domain/workflow/checkpoint-validation.js.map +1 -0
  191. package/dist/domain/workflow/checkpoint-value.d.ts +2 -0
  192. package/dist/domain/workflow/checkpoint-value.js +49 -0
  193. package/dist/domain/workflow/checkpoint-value.js.map +1 -0
  194. package/dist/domain/workflow/checkpoint.d.ts +3 -0
  195. package/dist/domain/workflow/checkpoint.js +70 -0
  196. package/dist/domain/workflow/checkpoint.js.map +1 -0
  197. package/dist/domain/workflow/checkpoint.types.d.ts +40 -0
  198. package/dist/domain/workflow/checkpoint.types.js +2 -0
  199. package/dist/domain/workflow/checkpoint.types.js.map +1 -0
  200. package/dist/domain/workflow/gate-validation.d.ts +4 -0
  201. package/dist/domain/workflow/gate-validation.js +71 -0
  202. package/dist/domain/workflow/gate-validation.js.map +1 -0
  203. package/dist/domain/workflow/gates.constants.d.ts +4 -0
  204. package/dist/domain/workflow/gates.constants.js +5 -0
  205. package/dist/domain/workflow/gates.constants.js.map +1 -0
  206. package/dist/domain/workflow/gates.d.ts +7 -0
  207. package/dist/domain/workflow/gates.js +85 -0
  208. package/dist/domain/workflow/gates.js.map +1 -0
  209. package/dist/domain/workflow/gates.types.d.ts +27 -0
  210. package/dist/domain/workflow/gates.types.js +2 -0
  211. package/dist/domain/workflow/gates.types.js.map +1 -0
  212. package/dist/domain/workflow/task-runner.js +14 -2
  213. package/dist/domain/workflow/task-runner.js.map +1 -1
  214. package/dist/domain/workflow/usage-receipt.constants.d.ts +2 -0
  215. package/dist/domain/workflow/usage-receipt.constants.js +3 -0
  216. package/dist/domain/workflow/usage-receipt.constants.js.map +1 -0
  217. package/dist/domain/workflow/usage-receipt.d.ts +2 -0
  218. package/dist/domain/workflow/usage-receipt.js +18 -0
  219. package/dist/domain/workflow/usage-receipt.js.map +1 -0
  220. package/dist/domain/workflow/validation.js +6 -0
  221. package/dist/domain/workflow/validation.js.map +1 -1
  222. package/dist/domain/workflow/workflow-scheduler.js +65 -32
  223. package/dist/domain/workflow/workflow-scheduler.js.map +1 -1
  224. package/dist/domain/workflow/workflow-state.d.ts +2 -1
  225. package/dist/domain/workflow/workflow-state.js +91 -16
  226. package/dist/domain/workflow/workflow-state.js.map +1 -1
  227. package/dist/domain/workflow.types.d.ts +13 -2
  228. package/dist/domain/workflow.types.js.map +1 -1
  229. package/dist/index.d.ts +32 -2
  230. package/dist/index.js +14 -1
  231. package/dist/index.js.map +1 -1
  232. package/dist/infrastructure/artifact-store.constants.d.ts +1 -0
  233. package/dist/infrastructure/artifact-store.constants.js +2 -0
  234. package/dist/infrastructure/artifact-store.constants.js.map +1 -0
  235. package/dist/infrastructure/artifact-store.d.ts +3 -0
  236. package/dist/infrastructure/artifact-store.js +100 -0
  237. package/dist/infrastructure/artifact-store.js.map +1 -0
  238. package/dist/infrastructure/artifact-store.types.d.ts +4 -0
  239. package/dist/infrastructure/artifact-store.types.js +2 -0
  240. package/dist/infrastructure/artifact-store.types.js.map +1 -0
  241. package/dist/infrastructure/file-manifest.d.ts +1 -1
  242. package/dist/infrastructure/file-manifest.js +3 -2
  243. package/dist/infrastructure/file-manifest.js.map +1 -1
  244. package/dist/infrastructure/git/verification-command.d.ts +1 -1
  245. package/dist/infrastructure/git/verification-command.js +3 -2
  246. package/dist/infrastructure/git/verification-command.js.map +1 -1
  247. package/dist/infrastructure/opentelemetry.js +1 -1
  248. package/dist/infrastructure/opentelemetry.js.map +1 -1
  249. package/dist/infrastructure/resource-activity-inspection.d.ts +2 -0
  250. package/dist/infrastructure/resource-activity-inspection.js +152 -0
  251. package/dist/infrastructure/resource-activity-inspection.js.map +1 -0
  252. package/dist/infrastructure/resource-activity.constants.d.ts +8 -0
  253. package/dist/infrastructure/resource-activity.constants.js +26 -0
  254. package/dist/infrastructure/resource-activity.constants.js.map +1 -0
  255. package/dist/infrastructure/resource-activity.d.ts +2 -0
  256. package/dist/infrastructure/resource-activity.js +166 -0
  257. package/dist/infrastructure/resource-activity.js.map +1 -0
  258. package/dist/infrastructure/resource-activity.types.d.ts +53 -0
  259. package/dist/infrastructure/resource-activity.types.js +2 -0
  260. package/dist/infrastructure/resource-activity.types.js.map +1 -0
  261. package/dist/infrastructure/storage-mutation-lock.constants.d.ts +5 -0
  262. package/dist/infrastructure/storage-mutation-lock.constants.js +6 -0
  263. package/dist/infrastructure/storage-mutation-lock.constants.js.map +1 -0
  264. package/dist/infrastructure/storage-mutation-lock.d.ts +1 -0
  265. package/dist/infrastructure/storage-mutation-lock.js +21 -0
  266. package/dist/infrastructure/storage-mutation-lock.js.map +1 -0
  267. package/dist/infrastructure/storage-reservations.constants.d.ts +4 -0
  268. package/dist/infrastructure/storage-reservations.constants.js +5 -0
  269. package/dist/infrastructure/storage-reservations.constants.js.map +1 -0
  270. package/dist/infrastructure/storage-reservations.d.ts +2 -0
  271. package/dist/infrastructure/storage-reservations.js +150 -0
  272. package/dist/infrastructure/storage-reservations.js.map +1 -0
  273. package/dist/infrastructure/storage-reservations.types.d.ts +21 -0
  274. package/dist/infrastructure/storage-reservations.types.js +2 -0
  275. package/dist/infrastructure/storage-reservations.types.js.map +1 -0
  276. package/dist/infrastructure/task-queue-http.constants.d.ts +2 -0
  277. package/dist/infrastructure/task-queue-http.constants.js +3 -0
  278. package/dist/infrastructure/task-queue-http.constants.js.map +1 -0
  279. package/dist/infrastructure/task-queue-http.d.ts +4 -0
  280. package/dist/infrastructure/task-queue-http.js +158 -0
  281. package/dist/infrastructure/task-queue-http.js.map +1 -0
  282. package/dist/infrastructure/task-queue-http.types.d.ts +16 -0
  283. package/dist/infrastructure/task-queue-http.types.js +2 -0
  284. package/dist/infrastructure/task-queue-http.types.js.map +1 -0
  285. package/dist/infrastructure/task-queue.d.ts +2 -0
  286. package/dist/infrastructure/task-queue.js +134 -0
  287. package/dist/infrastructure/task-queue.js.map +1 -0
  288. package/dist/infrastructure/transfer.js +5 -0
  289. package/dist/infrastructure/transfer.js.map +1 -1
  290. package/dist/infrastructure/workflow-checkpoint.constants.d.ts +1 -0
  291. package/dist/infrastructure/workflow-checkpoint.constants.js +2 -0
  292. package/dist/infrastructure/workflow-checkpoint.constants.js.map +1 -0
  293. package/dist/infrastructure/workflow-checkpoint.d.ts +3 -0
  294. package/dist/infrastructure/workflow-checkpoint.js +77 -0
  295. package/dist/infrastructure/workflow-checkpoint.js.map +1 -0
  296. package/dist/infrastructure/workflow-checkpoint.types.d.ts +4 -0
  297. package/dist/infrastructure/workflow-checkpoint.types.js +2 -0
  298. package/dist/infrastructure/workflow-checkpoint.types.js.map +1 -0
  299. package/dist/providers/agents.d.ts +2 -0
  300. package/dist/providers/agents.js +1 -0
  301. package/dist/providers/agents.js.map +1 -1
  302. package/dist/providers/container-isolation.d.ts +2 -0
  303. package/dist/providers/container-isolation.js +29 -0
  304. package/dist/providers/container-isolation.js.map +1 -0
  305. package/dist/providers/container-mounts.js +7 -2
  306. package/dist/providers/container-mounts.js.map +1 -1
  307. package/dist/providers/container-network.d.ts +2 -0
  308. package/dist/providers/container-network.js +14 -0
  309. package/dist/providers/container-network.js.map +1 -0
  310. package/dist/providers/container-plan.js +4 -2
  311. package/dist/providers/container-plan.js.map +1 -1
  312. package/dist/providers/container.constants.d.ts +1 -0
  313. package/dist/providers/container.constants.js +1 -0
  314. package/dist/providers/container.constants.js.map +1 -1
  315. package/dist/providers/container.js +19 -2
  316. package/dist/providers/container.js.map +1 -1
  317. package/dist/providers/container.types.d.ts +3 -0
  318. package/dist/providers/container.types.js.map +1 -1
  319. package/dist/providers/daytona-command.js +3 -2
  320. package/dist/providers/daytona-command.js.map +1 -1
  321. package/dist/providers/daytona-terminal.d.ts +3 -0
  322. package/dist/providers/daytona-terminal.js +128 -0
  323. package/dist/providers/daytona-terminal.js.map +1 -0
  324. package/dist/providers/daytona.js +2 -0
  325. package/dist/providers/daytona.js.map +1 -1
  326. package/dist/providers/docker.d.ts +1 -0
  327. package/dist/providers/docker.js.map +1 -1
  328. package/dist/providers/file-batches.d.ts +1 -1
  329. package/dist/providers/file-batches.js +9 -0
  330. package/dist/providers/file-batches.js.map +1 -1
  331. package/dist/providers/file-upload.constants.d.ts +1 -0
  332. package/dist/providers/file-upload.constants.js +68 -0
  333. package/dist/providers/file-upload.constants.js.map +1 -0
  334. package/dist/providers/file-upload.d.ts +2 -0
  335. package/dist/providers/file-upload.js +146 -0
  336. package/dist/providers/file-upload.js.map +1 -0
  337. package/dist/providers/firecracker-command.d.ts +5 -0
  338. package/dist/providers/firecracker-command.js +114 -0
  339. package/dist/providers/firecracker-command.js.map +1 -0
  340. package/dist/providers/firecracker-files.constants.d.ts +1 -0
  341. package/dist/providers/firecracker-files.constants.js +21 -0
  342. package/dist/providers/firecracker-files.constants.js.map +1 -0
  343. package/dist/providers/firecracker-files.d.ts +3 -0
  344. package/dist/providers/firecracker-files.js +110 -0
  345. package/dist/providers/firecracker-files.js.map +1 -0
  346. package/dist/providers/firecracker-machine.d.ts +3 -0
  347. package/dist/providers/firecracker-machine.js +155 -0
  348. package/dist/providers/firecracker-machine.js.map +1 -0
  349. package/dist/providers/firecracker.constants.d.ts +10 -0
  350. package/dist/providers/firecracker.constants.js +11 -0
  351. package/dist/providers/firecracker.constants.js.map +1 -0
  352. package/dist/providers/firecracker.d.ts +4 -0
  353. package/dist/providers/firecracker.js +103 -0
  354. package/dist/providers/firecracker.js.map +1 -0
  355. package/dist/providers/firecracker.types.d.ts +36 -0
  356. package/dist/providers/firecracker.types.js +2 -0
  357. package/dist/providers/firecracker.types.js.map +1 -0
  358. package/dist/providers/local.js +2 -1
  359. package/dist/providers/local.js.map +1 -1
  360. package/dist/providers/podman.d.ts +1 -0
  361. package/dist/providers/podman.js.map +1 -1
  362. package/dist/providers/terminal-bridge.d.ts +14 -0
  363. package/dist/providers/terminal-bridge.js +100 -0
  364. package/dist/providers/terminal-bridge.js.map +1 -0
  365. package/dist/providers/vercel-directory.d.ts +2 -0
  366. package/dist/providers/vercel-directory.js +7 -0
  367. package/dist/providers/vercel-directory.js.map +1 -0
  368. package/dist/providers/vercel-files.js +3 -2
  369. package/dist/providers/vercel-files.js.map +1 -1
  370. package/dist/providers/vercel-network.d.ts +2 -0
  371. package/dist/providers/vercel-network.js +18 -0
  372. package/dist/providers/vercel-network.js.map +1 -0
  373. package/dist/providers/vercel.d.ts +1 -0
  374. package/dist/providers/vercel.js +5 -1
  375. package/dist/providers/vercel.js.map +1 -1
  376. package/dist/providers/vercel.types.d.ts +2 -0
  377. package/dist/providers/vercel.types.js.map +1 -1
  378. package/dist/providers/versions.constants.d.ts +1 -0
  379. package/dist/providers/versions.constants.js +1 -0
  380. package/dist/providers/versions.constants.js.map +1 -1
  381. package/package.json +5 -1
@@ -1 +1 @@
1
- {"version":3,"file":"workflow-state.js","sourceRoot":"","sources":["../../../src/domain/workflow/workflow-state.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAWzC,MAAM,UAAU,aAAa,CAC3B,IAAY,EACZ,KAAsB,EACtB,OAAwB;IAExB,MAAM,WAAW,GAAG,UAAU,EAAE,CAAC;IACjC,MAAM,IAAI,GAAG,IAAI,eAAe,EAAE,CAAC;IACnC,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM;QAC3B,CAAC,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;QAChD,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC;IAChB,MAAM,MAAM,GAAG,IAAI,GAAG,EAAiB,CAAC;IACxC,MAAM,cAAc,GAAG,IAAI,GAAG,EAAgB,CAAC;IAC/C,MAAM,OAAO,GAAG,IAAI,GAAG,CACrB,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC;QAClB,IAAI;QACJ,EAAE,GAAG,EAAE,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,CAAC,EAAE;KAClD,CAAC,CACH,CAAC;IACF,MAAM,MAAM,GAAc,EAAE,EAC1B,cAAc,GAAc,EAAE,CAAC;IACjC,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AM;QACN,OAAO;QACP,MAAM;QACN,cAAc;QACd,MAAM;QACN,IAAI;QACJ,MAAM;QACN,OAAO;QACP,OAAO;KACR,CAAC;AACJ,CAAC","sourcesContent":["import { workflowAccounting } from \"./budget.ts\";\nimport { randomUUID } from \"node:crypto\";\nimport type {\n Task,\n TaskContext,\n TaskRecord,\n TaskStatus,\n WorkflowEvent,\n WorkflowExecutionState,\n WorkflowOptions,\n} from \"../workflow.types.ts\";\n\nexport function workflowState(\n name: string,\n tasks: readonly Task[],\n options: WorkflowOptions,\n): WorkflowExecutionState {\n const executionId = randomUUID();\n const stop = new AbortController();\n const signal = options.signal\n ? AbortSignal.any([options.signal, stop.signal])\n : stop.signal;\n const values = new Map<Task, unknown>();\n const activeAttempts = new Map<Task, number>();\n const records = new Map<Task, TaskRecord>(\n tasks.map((item) => [\n item,\n { key: item.key, status: \"waiting\", attempts: 0 },\n ]),\n );\n const errors: unknown[] = [],\n observerErrors: unknown[] = [];\n const accounting = workflowAccounting(options.budget, (error) => {\n errors.push(error);\n if (error.dimension !== \"attempts\") stop.abort(error);\n });\n const record = (item: Task) => records.get(item)!;\n function emit(\n event: Omit<WorkflowEvent, \"executionId\" | \"workflow\" | \"timestamp\">,\n ): void {\n try {\n options.observe?.({\n ...event,\n executionId,\n workflow: name,\n timestamp: new Date().toISOString(),\n });\n } catch (error) {\n observerErrors.push(error);\n }\n }\n function finish(item: Task, status: TaskStatus): void {\n Object.assign(record(item), {\n status,\n finishedAt: new Date().toISOString(),\n });\n emit({\n type: \"task\",\n key: item.key,\n status,\n attempt: record(item).attempts,\n ...(record(item).startedAt\n ? { durationMs: Date.now() - Date.parse(record(item).startedAt!) }\n : {}),\n });\n }\n function context(\n item: Task,\n attempt: number,\n taskSignal: AbortSignal,\n ): TaskContext {\n if (attempt > 0) activeAttempts.set(item, attempt);\n return {\n signal: taskSignal,\n attempt,\n executionId,\n reportUsage(usage) {\n if (\n attempt === 0 ||\n record(item).status !== \"active\" ||\n activeAttempts.get(item) !== attempt\n )\n throw new Error(\n \"Usage must be reported during its active task attempt\",\n );\n accounting.report(usage);\n emit({\n type: \"usage\",\n key: item.key,\n attempt,\n usage: Object.freeze({ ...usage }),\n });\n },\n value<T>(dependency: Task<T>): T {\n if (!item.after.includes(dependency))\n throw new Error(\n `${item.key}: undeclared dependency ${dependency.key}`,\n );\n if (!values.has(dependency))\n throw new Error(`${dependency.key} has no successful value`);\n return values.get(dependency) as T;\n },\n };\n }\n\n return {\n executionId,\n accounting,\n closeAttempt(item) {\n activeAttempts.delete(item);\n },\n stop,\n signal,\n values,\n records,\n errors,\n observerErrors,\n record,\n emit,\n finish,\n context,\n options,\n };\n}\n"]}
1
+ {"version":3,"file":"workflow-state.js","sourceRoot":"","sources":["../../../src/domain/workflow/workflow-state.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AACvE,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAG1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAWzC,MAAM,UAAU,aAAa,CAC3B,IAAY,EACZ,KAAsB,EACtB,OAAwB,EACxB,UAAsC;IAEtC,MAAM,WAAW,GAAG,UAAU,EAAE,OAAO,EAAE,WAAW,IAAI,UAAU,EAAE,CAAC;IACrE,MAAM,IAAI,GAAG,IAAI,eAAe,EAAE,CAAC;IACnC,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM;QAC3B,CAAC,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;QAChD,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC;IAChB,MAAM,MAAM,GAAG,IAAI,GAAG,EAAiB,CAAC;IACxC,MAAM,cAAc,GAAG,IAAI,GAAG,EAAgB,CAAC;IAC/C,MAAM,OAAO,GAAG,IAAI,G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,KAAK,CAAC,OAAO;YACX,MAAM,UAAU,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;QAClC,CAAC;QACD,WAAW;QACX,UAAU;QACV,YAAY,CAAC,IAAI;YACf,cAAc,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAC9B,CAAC;QACD,IAAI;QACJ,MAAM;QACN,MAAM;QACN,OAAO;QACP,MAAM;QACN,cAAc;QACd,MAAM;QACN,IAAI;QACJ,MAAM;QACN,OAAO;QACP,OAAO;KACR,CAAC;IACF,OAAO,OAAO,CAAC;AACjB,CAAC","sourcesContent":["import { maxUsageReceiptsPerTask } from \"./usage-receipt.constants.ts\";\nimport { validateUsageReceipt } from \"./usage-receipt.ts\";\nimport type { Usage } from \"../agent.types.ts\";\nimport type { WorkflowCheckpointSession } from \"./checkpoint.types.ts\";\nimport { workflowAccounting } from \"./budget.ts\";\nimport { randomUUID } from \"node:crypto\";\nimport type {\n Task,\n TaskContext,\n TaskRecord,\n TaskStatus,\n WorkflowEvent,\n WorkflowExecutionState,\n WorkflowOptions,\n} from \"../workflow.types.ts\";\n\nexport function workflowState(\n name: string,\n tasks: readonly Task[],\n options: WorkflowOptions,\n checkpoint?: WorkflowCheckpointSession,\n): WorkflowExecutionState {\n const executionId = checkpoint?.initial?.executionId ?? randomUUID();\n const stop = new AbortController();\n const signal = options.signal\n ? AbortSignal.any([options.signal, stop.signal])\n : stop.signal;\n const values = new Map<Task, unknown>();\n const activeAttempts = new Map<Task, number>();\n const records = new Map<Task, TaskRecord>(\n tasks.map((item) => [\n item,\n { key: item.key, status: \"waiting\", attempts: 0 },\n ]),\n );\n const saved = checkpoint?.initial;\n if (saved) {\n const complete = saved.records.every((entry) =>\n [\"done\", \"skipped\"].includes(entry.status),\n );\n const settledPause =\n saved.records.some((entry) =>\n [\"paused\", \"rejected\"].includes(entry.status),\n ) &&\n saved.records.every(\n (entry) =>\n [\"done\", \"skipped\", \"paused\", \"rejected\"].includes(entry.status) ||\n (entry.status === \"waiting\" && entry.attempts === 0),\n );\n for (const item of tasks) {\n const entry = saved.records.find((entry) => entry.key === item.key)!;\n records.set(item, {\n ...entry,\n ...(entry.usageReceipts\n ? { usageReceipts: Object.freeze([...entry.usageReceipts]) }\n : {}),\n ...(entry.pause\n ? {\n pause: Object.freeze({\n ...entry.pause,\n actors: Object.freeze([...entry.pause.actors]),\n }),\n }\n : {}),\n ...(entry.decision\n ? { decision: Object.freeze({ ...entry.decision }) }\n : {}),\n status:\n [\"done\", \"paused\", \"rejected\"].includes(entry.status) ||\n complete ||\n (settledPause && entry.status === \"skipped\")\n ? entry.status\n : \"waiting\",\n });\n if (entry.status === \"done\") {\n const output = saved.values[item.key]!;\n values.set(item, output.kind === \"json\" ? output.value : undefined);\n }\n }\n }\n const errors: unknown[] = [],\n observerErrors: unknown[] = [];\n for (const entry of records.values())\n if (entry.status === \"rejected\") errors.push(new Error(entry.error));\n const accounting = workflowAccounting(\n options.budget,\n (error) => {\n errors.push(error);\n if (error.dimension !== \"attempts\") stop.abort(error);\n },\n saved?.usage,\n );\n const record = (item: Task) => records.get(item)!;\n function emit(\n event: Omit<WorkflowEvent, \"executionId\" | \"workflow\" | \"timestamp\">,\n ): void {\n try {\n options.observe?.({\n ...event,\n executionId,\n workflow: name,\n timestamp: new Date().toISOString(),\n });\n } catch (error) {\n observerErrors.push(error);\n }\n }\n function finish(item: Task, status: TaskStatus): void {\n Object.assign(record(item), {\n status,\n finishedAt: new Date().toISOString(),\n });\n emit({\n type: \"task\",\n key: item.key,\n status,\n attempt: record(item).attempts,\n ...(record(item).startedAt\n ? { durationMs: Date.now() - Date.parse(record(item).startedAt!) }\n : {}),\n });\n }\n function context(\n item: Task,\n attempt: number,\n taskSignal: AbortSignal,\n ): TaskContext {\n if (attempt > 0) activeAttempts.set(item, attempt);\n function report(usage: Usage, receipt?: string): void {\n const current = record(item);\n if (\n attempt === 0 ||\n current.status !== \"active\" ||\n activeAttempts.get(item) !== attempt\n )\n throw new Error(\n \"Usage must be reported during its active task attempt\",\n );\n if (receipt !== undefined) {\n validateUsageReceipt(receipt);\n if (current.usageReceipts?.includes(receipt)) return;\n if ((current.usageReceipts?.length ?? 0) >= maxUsageReceiptsPerTask)\n throw new Error(\"Workflow usage receipt limit exceeded\");\n }\n const previousReceipts = current.usageReceipts;\n if (receipt !== undefined)\n current.usageReceipts = Object.freeze([\n ...(previousReceipts ?? []),\n receipt,\n ]);\n try {\n accounting.report(usage);\n } catch (error) {\n if (previousReceipts) current.usageReceipts = previousReceipts;\n else delete current.usageReceipts;\n throw error;\n }\n void runtime.persist().catch((error: unknown) => stop.abort(error));\n emit({\n type: \"usage\",\n key: item.key,\n attempt,\n usage: Object.freeze({ ...usage }),\n });\n }\n\n return {\n signal: taskSignal,\n attempt,\n executionId,\n checkpoint: () => runtime.persist(),\n reportUsage: (usage) => report(usage),\n reportUsageOnce: (receipt, usage) => {\n validateUsageReceipt(receipt);\n report(usage, receipt);\n },\n value<T>(dependency: Task<T>): T {\n if (!item.after.includes(dependency))\n throw new Error(\n `${item.key}: undeclared dependency ${dependency.key}`,\n );\n if (!values.has(dependency))\n throw new Error(`${dependency.key} has no successful value`);\n return values.get(dependency) as T;\n },\n };\n }\n\n const runtime: WorkflowExecutionState = {\n async persist() {\n await checkpoint?.save(runtime);\n },\n executionId,\n accounting,\n closeAttempt(item) {\n activeAttempts.delete(item);\n },\n stop,\n signal,\n values,\n records,\n errors,\n observerErrors,\n record,\n emit,\n finish,\n context,\n options,\n };\n return runtime;\n}\n"]}
@@ -1,3 +1,5 @@
1
+ import type { WorkflowDecision, WorkflowDecisionRecord, WorkflowGate, WorkflowPauseRequest } from "./workflow/gates.types.ts";
2
+ import type { WorkflowCheckpointOptions } from "./workflow/checkpoint.types.ts";
1
3
  import type { Usage } from "./agent.types.ts";
2
4
  import type { WorkflowAccounting, WorkflowBudget, WorkflowUsage } from "./workflow/budget.types.ts";
3
5
  export interface TaskContext {
@@ -5,6 +7,8 @@ export interface TaskContext {
5
7
  readonly attempt: number;
6
8
  readonly executionId: string;
7
9
  reportUsage(usage: Usage): void;
10
+ reportUsageOnce?(receipt: string, usage: Usage): void;
11
+ checkpoint?(): Promise<void>;
8
12
  value<T>(dependency: Task<T>): T;
9
13
  }
10
14
  export interface Retry {
@@ -14,6 +18,7 @@ export interface Retry {
14
18
  }
15
19
  export interface Task<T = unknown> {
16
20
  readonly key: string;
21
+ readonly gate?: WorkflowGate;
17
22
  readonly after: readonly Task[];
18
23
  readonly perform: (context: TaskContext) => T | Promise<T>;
19
24
  readonly condition?: (context: TaskContext) => boolean | Promise<boolean>;
@@ -23,8 +28,11 @@ export interface Task<T = unknown> {
23
28
  export type TaskOptions<T> = Omit<Task<T>, "after"> & {
24
29
  readonly after?: readonly Task[];
25
30
  };
26
- export type TaskStatus = "waiting" | "active" | "done" | "failed" | "skipped" | "cancelled";
31
+ export type TaskStatus = "waiting" | "active" | "done" | "failed" | "skipped" | "cancelled" | "paused" | "rejected";
27
32
  export interface TaskRecord {
33
+ usageReceipts?: readonly string[];
34
+ pause?: WorkflowPauseRequest;
35
+ decision?: WorkflowDecisionRecord;
28
36
  readonly key: string;
29
37
  status: TaskStatus;
30
38
  attempts: number;
@@ -44,6 +52,8 @@ export interface WorkflowEvent {
44
52
  readonly durationMs?: number;
45
53
  }
46
54
  export interface WorkflowOptions {
55
+ readonly decisions?: readonly WorkflowDecision[];
56
+ readonly checkpoint?: WorkflowCheckpointOptions;
47
57
  readonly signal?: AbortSignal;
48
58
  readonly concurrency?: number;
49
59
  readonly budget?: WorkflowBudget;
@@ -53,7 +63,7 @@ export interface WorkflowOptions {
53
63
  export interface WorkflowResult {
54
64
  readonly executionId: string;
55
65
  readonly name: string;
56
- readonly status: "done" | "failed" | "cancelled";
66
+ readonly status: "done" | "failed" | "cancelled" | "paused";
57
67
  readonly tasks: readonly Readonly<TaskRecord>[];
58
68
  readonly errors: readonly unknown[];
59
69
  readonly observerErrors: readonly unknown[];
@@ -78,6 +88,7 @@ export interface WorkflowExecutionState {
78
88
  readonly observerErrors: unknown[];
79
89
  readonly options: WorkflowOptions;
80
90
  readonly accounting: WorkflowAccounting;
91
+ persist(): Promise<void>;
81
92
  closeAttempt(task: Task): void;
82
93
  record(task: Task): TaskRecord;
83
94
  emit(event: WorkflowNotification): void;
@@ -1 +1 @@
1
- {"version":3,"file":"workflow.types.js","sourceRoot":"","sources":["../../src/domain/workflow.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { Usage } from \"./agent.types.ts\";\nimport type {\n WorkflowAccounting,\n WorkflowBudget,\n WorkflowUsage,\n} from \"./workflow/budget.types.ts\";\n\nexport interface TaskContext {\n readonly signal: AbortSignal;\n readonly attempt: number;\n readonly executionId: string;\n reportUsage(usage: Usage): void;\n value<T>(dependency: Task<T>): T;\n}\n\nexport interface Retry {\n readonly attempts: number;\n readonly delayMs?: number;\n readonly accepts?: (error: unknown, attempt: number) => boolean;\n}\n\nexport interface Task<T = unknown> {\n readonly key: string;\n readonly after: readonly Task[];\n readonly perform: (context: TaskContext) => T | Promise<T>;\n readonly condition?: (context: TaskContext) => boolean | Promise<boolean>;\n readonly retry?: Retry;\n readonly timeoutMs?: number;\n}\n\nexport type TaskOptions<T> = Omit<Task<T>, \"after\"> & {\n readonly after?: readonly Task[];\n};\n\nexport type TaskStatus =\n \"waiting\" | \"active\" | \"done\" | \"failed\" | \"skipped\" | \"cancelled\";\n\nexport interface TaskRecord {\n readonly key: string;\n status: TaskStatus;\n attempts: number;\n startedAt?: string;\n finishedAt?: string;\n error?: string;\n}\n\nexport interface WorkflowEvent {\n readonly executionId: string;\n readonly workflow: string;\n readonly timestamp: string;\n readonly type: \"start\" | \"task\" | \"attempt\" | \"retry\" | \"usage\" | \"finish\";\n readonly key?: string;\n readonly status?: TaskStatus;\n readonly attempt?: number;\n readonly usage?: Usage;\n readonly durationMs?: number;\n}\n\nexport interface WorkflowOptions {\n readonly signal?: AbortSignal;\n readonly concurrency?: number;\n readonly budget?: WorkflowBudget;\n readonly stopOnError?: boolean;\n readonly observe?: (event: WorkflowEvent) => void;\n}\n\nexport interface WorkflowResult {\n readonly executionId: string;\n readonly name: string;\n readonly status: \"done\" | \"failed\" | \"cancelled\";\n readonly tasks: readonly Readonly<TaskRecord>[];\n readonly errors: readonly unknown[];\n readonly observerErrors: readonly unknown[];\n readonly usage: WorkflowUsage;\n value<T>(task: Task<T>): T;\n unwrap(): void;\n}\n\nexport interface Workflow {\n readonly name: string;\n readonly tasks: readonly Task[];\n start(options?: WorkflowOptions): Promise<WorkflowResult>;\n diagram(): string;\n}\n\nexport type WorkflowNotification = Omit<\n WorkflowEvent,\n \"executionId\" | \"workflow\" | \"timestamp\"\n>;\nexport interface WorkflowExecutionState {\n readonly executionId: string;\n readonly stop: AbortController;\n readonly signal: AbortSignal;\n readonly values: Map<Task, unknown>;\n readonly records: Map<Task, TaskRecord>;\n readonly errors: unknown[];\n readonly observerErrors: unknown[];\n readonly options: WorkflowOptions;\n readonly accounting: WorkflowAccounting;\n closeAttempt(task: Task): void;\n record(task: Task): TaskRecord;\n emit(event: WorkflowNotification): void;\n finish(task: Task, status: TaskStatus): void;\n context(task: Task, attempt: number, signal: AbortSignal): TaskContext;\n}\n"]}
1
+ {"version":3,"file":"workflow.types.js","sourceRoot":"","sources":["../../src/domain/workflow.types.ts"],"names":[],"mappings":"","sourcesContent":["import type {\n WorkflowDecision,\n WorkflowDecisionRecord,\n WorkflowGate,\n WorkflowPauseRequest,\n} from \"./workflow/gates.types.ts\";\nimport type { WorkflowCheckpointOptions } from \"./workflow/checkpoint.types.ts\";\nimport type { Usage } from \"./agent.types.ts\";\nimport type {\n WorkflowAccounting,\n WorkflowBudget,\n WorkflowUsage,\n} from \"./workflow/budget.types.ts\";\n\nexport interface TaskContext {\n readonly signal: AbortSignal;\n readonly attempt: number;\n readonly executionId: string;\n reportUsage(usage: Usage): void;\n reportUsageOnce?(receipt: string, usage: Usage): void;\n checkpoint?(): Promise<void>;\n value<T>(dependency: Task<T>): T;\n}\n\nexport interface Retry {\n readonly attempts: number;\n readonly delayMs?: number;\n readonly accepts?: (error: unknown, attempt: number) => boolean;\n}\n\nexport interface Task<T = unknown> {\n readonly key: string;\n readonly gate?: WorkflowGate;\n readonly after: readonly Task[];\n readonly perform: (context: TaskContext) => T | Promise<T>;\n readonly condition?: (context: TaskContext) => boolean | Promise<boolean>;\n readonly retry?: Retry;\n readonly timeoutMs?: number;\n}\n\nexport type TaskOptions<T> = Omit<Task<T>, \"after\"> & {\n readonly after?: readonly Task[];\n};\n\nexport type TaskStatus =\n | \"waiting\"\n | \"active\"\n | \"done\"\n | \"failed\"\n | \"skipped\"\n | \"cancelled\"\n | \"paused\"\n | \"rejected\";\n\nexport interface TaskRecord {\n usageReceipts?: readonly string[];\n pause?: WorkflowPauseRequest;\n decision?: WorkflowDecisionRecord;\n readonly key: string;\n status: TaskStatus;\n attempts: number;\n startedAt?: string;\n finishedAt?: string;\n error?: string;\n}\n\nexport interface WorkflowEvent {\n readonly executionId: string;\n readonly workflow: string;\n readonly timestamp: string;\n readonly type: \"start\" | \"task\" | \"attempt\" | \"retry\" | \"usage\" | \"finish\";\n readonly key?: string;\n readonly status?: TaskStatus;\n readonly attempt?: number;\n readonly usage?: Usage;\n readonly durationMs?: number;\n}\n\nexport interface WorkflowOptions {\n readonly decisions?: readonly WorkflowDecision[];\n readonly checkpoint?: WorkflowCheckpointOptions;\n readonly signal?: AbortSignal;\n readonly concurrency?: number;\n readonly budget?: WorkflowBudget;\n readonly stopOnError?: boolean;\n readonly observe?: (event: WorkflowEvent) => void;\n}\n\nexport interface WorkflowResult {\n readonly executionId: string;\n readonly name: string;\n readonly status: \"done\" | \"failed\" | \"cancelled\" | \"paused\";\n readonly tasks: readonly Readonly<TaskRecord>[];\n readonly errors: readonly unknown[];\n readonly observerErrors: readonly unknown[];\n readonly usage: WorkflowUsage;\n value<T>(task: Task<T>): T;\n unwrap(): void;\n}\n\nexport interface Workflow {\n readonly name: string;\n readonly tasks: readonly Task[];\n start(options?: WorkflowOptions): Promise<WorkflowResult>;\n diagram(): string;\n}\n\nexport type WorkflowNotification = Omit<\n WorkflowEvent,\n \"executionId\" | \"workflow\" | \"timestamp\"\n>;\nexport interface WorkflowExecutionState {\n readonly executionId: string;\n readonly stop: AbortController;\n readonly signal: AbortSignal;\n readonly values: Map<Task, unknown>;\n readonly records: Map<Task, TaskRecord>;\n readonly errors: unknown[];\n readonly observerErrors: unknown[];\n readonly options: WorkflowOptions;\n readonly accounting: WorkflowAccounting;\n persist(): Promise<void>;\n closeAttempt(task: Task): void;\n record(task: Task): TaskRecord;\n emit(event: WorkflowNotification): void;\n finish(task: Task, status: TaskStatus): void;\n context(task: Task, attempt: number, signal: AbortSignal): TaskContext;\n}\n"]}
package/dist/index.d.ts CHANGED
@@ -4,11 +4,11 @@ export type { DispatchOptions, Execution, Turn, } from "./application/execution.
4
4
  export { WorkflowFailure, WorkflowBudgetExceeded, task, workflow, } from "./domain/workflow.ts";
5
5
  export type { Retry, Task, TaskContext, TaskOptions, TaskRecord, TaskStatus, Workflow, WorkflowEvent, WorkflowOptions, WorkflowBudget, WorkflowUsage, WorkflowResult, } from "./domain/workflow.ts";
6
6
  export { agentTask, commandTask, isolatedTask } from "./application/tasks.ts";
7
- export { claude, codex } from "./providers/agents.ts";
7
+ export { claude, codex, gemini } from "./providers/agents.ts";
8
8
  export { agentVersions } from "./providers/versions.ts";
9
9
  export { conversations } from "./infrastructure/conversations.ts";
10
10
  export type { ConversationFormat, ConversationLocation, } from "./infrastructure/conversations.ts";
11
- export type { ClaudeSettings, CodexSettings } from "./providers/agents.ts";
11
+ export type { ClaudeSettings, CodexSettings, GeminiSettings, } from "./providers/agents.ts";
12
12
  export { mountedProvider, remoteProvider } from "./providers/factories.ts";
13
13
  export { ResponseError, response } from "./domain/response.ts";
14
14
  export type { ResponseSpec, StandardValidator } from "./domain/response.ts";
@@ -29,3 +29,33 @@ export type { SandboxDiagnosticOptions, SandboxDiagnosticReport, DiagnosticCapab
29
29
  export type { DiagnosticCheck, DiagnosticStatus, DoctorAgent, } from "./application/doctor.types.ts";
30
30
  export { diagnoseAgentProtocol } from "./application/doctor-protocol.ts";
31
31
  export type { AgentProtocolReport } from "./application/doctor-protocol.types.ts";
32
+ export { reserveRecoveryStorage } from "./application/storage-reservation.ts";
33
+ export type { RecoveryStorageReservationOptions } from "./application/storage-reservation.types.ts";
34
+ export type { StorageReservation, StorageReservationOptions, } from "./infrastructure/storage-reservations.types.ts";
35
+ export { planRecoveryRestore, restoreRecoveryTransfer, } from "./application/recovery-restore.ts";
36
+ export type { RecoveryRestoreOptions, RecoveryRestorePlan, RecoveryRestoreResult, } from "./application/recovery-restore.types.ts";
37
+ export { fileWorkflowCheckpointStore } from "./infrastructure/workflow-checkpoint.ts";
38
+ export type { FileWorkflowCheckpointOptions } from "./infrastructure/workflow-checkpoint.types.ts";
39
+ export type { WorkflowCheckpoint, WorkflowCheckpointOptions, WorkflowCheckpointStore, WorkflowCheckpointLease, WorkflowCheckpointValue, WorkflowJson, } from "./domain/workflow/checkpoint.types.ts";
40
+ export { approvalTask, pauseTask } from "./domain/workflow/gates.ts";
41
+ export type { WorkflowGate, WorkflowGateOptions, WorkflowPauseRequest, WorkflowDecision, WorkflowDecisionRecord, } from "./domain/workflow/gates.types.ts";
42
+ export { inspectRecovery } from "./application/recovery-inspection.ts";
43
+ export type { RecoveryInspection, RecoveryInspectionOptions, } from "./application/recovery-inspection.types.ts";
44
+ export type { ResourceActivityRecord, ResourceInspection, ResourceInspectionEntry, ResourceOperation, ResourceOperationKind, ResourceOperationResult, ResourcePhase, } from "./infrastructure/resource-activity.types.ts";
45
+ export { artifact, publishArtifact, readStoredArtifact, } from "./domain/artifact.ts";
46
+ export { artifactTask, readArtifact } from "./application/artifact-tasks.ts";
47
+ export { fileArtifactStore } from "./infrastructure/artifact-store.ts";
48
+ export type { ArtifactContract, ArtifactContractOptions, ArtifactIdentity, ArtifactProducer, ArtifactReference, ArtifactStore, JsonArtifactOptions, PublishArtifactOptions, ReadArtifactOptions, } from "./domain/artifact.types.ts";
49
+ export type { ArtifactTaskOptions } from "./application/artifact-tasks.types.ts";
50
+ export type { FileArtifactStoreOptions } from "./infrastructure/artifact-store.types.ts";
51
+ export { sqliteTaskQueue } from "./infrastructure/task-queue.ts";
52
+ export { serveTaskQueue, httpTaskQueue, } from "./infrastructure/task-queue-http.ts";
53
+ export { runQueueWorker } from "./application/queue-worker.ts";
54
+ export { queuedTask } from "./application/queued-task.ts";
55
+ export type { QueueRequest, QueueResult, QueueJob, QueueClaim, QueueLease, TaskQueue, DurableTaskQueue, } from "./domain/task-queue.types.ts";
56
+ export type { QueueServerOptions, QueueServer, QueueClientOptions, } from "./infrastructure/task-queue-http.types.ts";
57
+ export type { QueueHandlerContext, QueueHandler, QueueWorkerOptions, } from "./application/queue-worker.types.ts";
58
+ export type { QueuedTaskOptions } from "./application/queued-task.types.ts";
59
+ export type { EgressPolicy } from "./domain/egress.types.ts";
60
+ export { speculate } from "./application/speculation.ts";
61
+ export type { SpeculationOptions, SpeculationResult, SpeculativeCandidate, SpeculativeCandidateResult, SpeculativeOutput, SpeculativeHostSnapshot, SpeculativeValidation, } from "./application/speculation.types.ts";
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  export { attach, createSandbox, dispatch, openWorkspace, } from "./application/outpost.js";
2
2
  export { WorkflowFailure, WorkflowBudgetExceeded, task, workflow, } from "./domain/workflow.js";
3
3
  export { agentTask, commandTask, isolatedTask } from "./application/tasks.js";
4
- export { claude, codex } from "./providers/agents.js";
4
+ export { claude, codex, gemini } from "./providers/agents.js";
5
5
  export { agentVersions } from "./providers/versions.js";
6
6
  export { conversations } from "./infrastructure/conversations.js";
7
7
  export { mountedProvider, remoteProvider } from "./providers/factories.js";
@@ -12,4 +12,17 @@ export { planRecoveryRetention, pruneRecoveryRetention, assertRecoveryQuota, } f
12
12
  export { verifyRecoveryTransfer } from "./application/recovery-verification.js";
13
13
  export { diagnoseSandbox } from "./application/doctor-sandbox.js";
14
14
  export { diagnoseAgentProtocol } from "./application/doctor-protocol.js";
15
+ export { reserveRecoveryStorage } from "./application/storage-reservation.js";
16
+ export { planRecoveryRestore, restoreRecoveryTransfer, } from "./application/recovery-restore.js";
17
+ export { fileWorkflowCheckpointStore } from "./infrastructure/workflow-checkpoint.js";
18
+ export { approvalTask, pauseTask } from "./domain/workflow/gates.js";
19
+ export { inspectRecovery } from "./application/recovery-inspection.js";
20
+ export { artifact, publishArtifact, readStoredArtifact, } from "./domain/artifact.js";
21
+ export { artifactTask, readArtifact } from "./application/artifact-tasks.js";
22
+ export { fileArtifactStore } from "./infrastructure/artifact-store.js";
23
+ export { sqliteTaskQueue } from "./infrastructure/task-queue.js";
24
+ export { serveTaskQueue, httpTaskQueue, } from "./infrastructure/task-queue-http.js";
25
+ export { runQueueWorker } from "./application/queue-worker.js";
26
+ export { queuedTask } from "./application/queued-task.js";
27
+ export { speculate } from "./application/speculation.js";
15
28
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,MAAM,EACN,aAAa,EACb,QAAQ,EACR,aAAa,GACd,MAAM,0BAA0B,CAAC;AAoBlC,OAAO,EACL,eAAe,EACf,sBAAsB,EACtB,IAAI,EACJ,QAAQ,GACT,MAAM,sBAAsB,CAAC;AAiB9B,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAE9E,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAEtD,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAExD,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AASlE,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAE3E,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAI/D,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAoCnE,OAAO,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AAMxD,OAAO,EACL,qBAAqB,EACrB,sBAAsB,EACtB,mBAAmB,GACpB,MAAM,qCAAqC,CAAC;AAS7C,OAAO,EAAE,sBAAsB,EAAE,MAAM,wCAAwC,CAAC;AAMhF,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAWlE,OAAO,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAC","sourcesContent":["export {\n attach,\n createSandbox,\n dispatch,\n openWorkspace,\n} from \"./application/outpost.ts\";\n\nexport type {\n AttachOptions,\n AttachResult,\n ContinuationOptions,\n DispatchResult,\n Sandbox,\n SandboxOptions,\n WarmDispatchResult,\n Workspace,\n WorkspaceOptions,\n} from \"./application/outpost.ts\";\n\nexport type {\n DispatchOptions,\n Execution,\n Turn,\n} from \"./application/execution.ts\";\n\nexport {\n WorkflowFailure,\n WorkflowBudgetExceeded,\n task,\n workflow,\n} from \"./domain/workflow.ts\";\n\nexport type {\n Retry,\n Task,\n TaskContext,\n TaskOptions,\n TaskRecord,\n TaskStatus,\n Workflow,\n WorkflowEvent,\n WorkflowOptions,\n WorkflowBudget,\n WorkflowUsage,\n WorkflowResult,\n} from \"./domain/workflow.ts\";\n\nexport { agentTask, commandTask, isolatedTask } from \"./application/tasks.ts\";\n\nexport { claude, codex } from \"./providers/agents.ts\";\n\nexport { agentVersions } from \"./providers/versions.ts\";\n\nexport { conversations } from \"./infrastructure/conversations.ts\";\n\nexport type {\n ConversationFormat,\n ConversationLocation,\n} from \"./infrastructure/conversations.ts\";\n\nexport type { ClaudeSettings, CodexSettings } from \"./providers/agents.ts\";\n\nexport { mountedProvider, remoteProvider } from \"./providers/factories.ts\";\n\nexport { ResponseError, response } from \"./domain/response.ts\";\n\nexport type { ResponseSpec, StandardValidator } from \"./domain/response.ts\";\n\nexport { OutpostError, recoveryDetails } from \"./domain/errors.ts\";\n\nexport type { FaultCode } from \"./domain/errors.ts\";\n\nexport type {\n AgentAdapter,\n AgentEvent,\n AgentInput,\n AgentObservation,\n BranchPolicy,\n Channel,\n Command,\n CommandResult,\n Commit,\n ConversationContext,\n ConversationRecord,\n ConversationStore,\n Disposal,\n LifecycleHooks,\n FileManifestEntry,\n FileTransfers,\n SandboxContext,\n SandboxLease,\n SandboxProvider,\n StageLimits,\n TransferOptions,\n Usage,\n Variables,\n Volume,\n WorkspaceRecord,\n} from \"./domain/ports.ts\";\n\nexport type { Brief, PromptVariables } from \"./domain/prompts.ts\";\n\nexport type { Logging } from \"./infrastructure/journal.ts\";\n\nexport { reporter } from \"./infrastructure/reporter.ts\";\n\nexport type { ReporterOptions } from \"./infrastructure/reporter.ts\";\n\nexport type { VariableQuestion } from \"./application/interactive-brief.ts\";\n\nexport {\n planRecoveryRetention,\n pruneRecoveryRetention,\n assertRecoveryQuota,\n} from \"./application/recovery-retention.ts\";\nexport type {\n RecoveryRetentionPolicy,\n RecoveryRetentionOptions,\n RecoveryRetentionPlan,\n RecoveryRetentionEntry,\n RecoveryPruneResult,\n RecoveryQuotaOptions,\n} from \"./application/recovery-retention.types.ts\";\nexport { verifyRecoveryTransfer } from \"./application/recovery-verification.ts\";\nexport type {\n RecoveryVerification,\n RecoveryVerificationOptions,\n} from \"./application/recovery-verification.types.ts\";\n\nexport { diagnoseSandbox } from \"./application/doctor-sandbox.ts\";\nexport type {\n SandboxDiagnosticOptions,\n SandboxDiagnosticReport,\n DiagnosticCapability,\n} from \"./application/doctor-sandbox.types.ts\";\nexport type {\n DiagnosticCheck,\n DiagnosticStatus,\n DoctorAgent,\n} from \"./application/doctor.types.ts\";\nexport { diagnoseAgentProtocol } from \"./application/doctor-protocol.ts\";\nexport type { AgentProtocolReport } from \"./application/doctor-protocol.types.ts\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OA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f,kBAAkB,GACnB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAC7E,OAAO,EAAE,iBAAiB,EAAE,MAAM,oCAAoC,CAAC;AAevE,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AACjE,OAAO,EACL,cAAc,EACd,aAAa,GACd,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAwB1D,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC","sourcesContent":["export {\n attach,\n createSandbox,\n dispatch,\n openWorkspace,\n} from \"./application/outpost.ts\";\n\nexport type {\n AttachOptions,\n AttachResult,\n ContinuationOptions,\n DispatchResult,\n Sandbox,\n SandboxOptions,\n WarmDispatchResult,\n Workspace,\n WorkspaceOptions,\n} from \"./application/outpost.ts\";\n\nexport type {\n DispatchOptions,\n Execution,\n Turn,\n} from \"./application/execution.ts\";\n\nexport {\n WorkflowFailure,\n WorkflowBudgetExceeded,\n task,\n workflow,\n} from \"./domain/workflow.ts\";\n\nexport type {\n Retry,\n Task,\n TaskContext,\n TaskOptions,\n TaskRecord,\n TaskStatus,\n Workflow,\n WorkflowEvent,\n WorkflowOptions,\n WorkflowBudget,\n WorkflowUsage,\n WorkflowResult,\n} from \"./domain/workflow.ts\";\n\nexport { agentTask, commandTask, isolatedTask } from \"./application/tasks.ts\";\n\nexport { claude, codex, gemini } from \"./providers/agents.ts\";\n\nexport { agentVersions } from \"./providers/versions.ts\";\n\nexport { conversations } from \"./infrastructure/conversations.ts\";\n\nexport type {\n ConversationFormat,\n ConversationLocation,\n} from \"./infrastructure/conversations.ts\";\n\nexport type {\n ClaudeSettings,\n CodexSettings,\n GeminiSettings,\n} from \"./providers/agents.ts\";\n\nexport { mountedProvider, remoteProvider } from \"./providers/factories.ts\";\n\nexport { ResponseError, response } from \"./domain/response.ts\";\n\nexport type { ResponseSpec, StandardValidator } from \"./domain/response.ts\";\n\nexport { OutpostError, recoveryDetails } from \"./domain/errors.ts\";\n\nexport type { FaultCode } from \"./domain/errors.ts\";\n\nexport type {\n AgentAdapter,\n AgentEvent,\n AgentInput,\n AgentObservation,\n BranchPolicy,\n Channel,\n Command,\n CommandResult,\n Commit,\n ConversationContext,\n ConversationRecord,\n ConversationStore,\n Disposal,\n LifecycleHooks,\n FileManifestEntry,\n FileTransfers,\n SandboxContext,\n SandboxLease,\n SandboxProvider,\n StageLimits,\n TransferOptions,\n Usage,\n Variables,\n Volume,\n WorkspaceRecord,\n} from \"./domain/ports.ts\";\n\nexport type { Brief, PromptVariables } from \"./domain/prompts.ts\";\n\nexport type { Logging } from \"./infrastructure/journal.ts\";\n\nexport { reporter } from \"./infrastructure/reporter.ts\";\n\nexport type { ReporterOptions } from \"./infrastructure/reporter.ts\";\n\nexport type { VariableQuestion } from \"./application/interactive-brief.ts\";\n\nexport {\n planRecoveryRetention,\n pruneRecoveryRetention,\n assertRecoveryQuota,\n} from \"./application/recovery-retention.ts\";\nexport type {\n RecoveryRetentionPolicy,\n RecoveryRetentionOptions,\n RecoveryRetentionPlan,\n RecoveryRetentionEntry,\n RecoveryPruneResult,\n RecoveryQuotaOptions,\n} from \"./application/recovery-retention.types.ts\";\nexport { verifyRecoveryTransfer } from \"./application/recovery-verification.ts\";\nexport type {\n RecoveryVerification,\n RecoveryVerificationOptions,\n} from \"./application/recovery-verification.types.ts\";\n\nexport { diagnoseSandbox } from \"./application/doctor-sandbox.ts\";\nexport type {\n SandboxDiagnosticOptions,\n SandboxDiagnosticReport,\n DiagnosticCapability,\n} from \"./application/doctor-sandbox.types.ts\";\nexport type {\n DiagnosticCheck,\n DiagnosticStatus,\n DoctorAgent,\n} from \"./application/doctor.types.ts\";\nexport { diagnoseAgentProtocol } from \"./application/doctor-protocol.ts\";\nexport type { AgentProtocolReport } from \"./application/doctor-protocol.types.ts\";\n\nexport { reserveRecoveryStorage } from \"./application/storage-reservation.ts\";\nexport type { RecoveryStorageReservationOptions } from \"./application/storage-reservation.types.ts\";\nexport type {\n StorageReservation,\n StorageReservationOptions,\n} from \"./infrastructure/storage-reservations.types.ts\";\n\nexport {\n planRecoveryRestore,\n restoreRecoveryTransfer,\n} from \"./application/recovery-restore.ts\";\nexport type {\n RecoveryRestoreOptions,\n RecoveryRestorePlan,\n RecoveryRestoreResult,\n} from \"./application/recovery-restore.types.ts\";\n\nexport { fileWorkflowCheckpointStore } from \"./infrastructure/workflow-checkpoint.ts\";\nexport type { FileWorkflowCheckpointOptions } from \"./infrastructure/workflow-checkpoint.types.ts\";\nexport type {\n WorkflowCheckpoint,\n WorkflowCheckpointOptions,\n WorkflowCheckpointStore,\n WorkflowCheckpointLease,\n WorkflowCheckpointValue,\n WorkflowJson,\n} from \"./domain/workflow/checkpoint.types.ts\";\n\nexport { approvalTask, pauseTask } from \"./domain/workflow/gates.ts\";\nexport type {\n WorkflowGate,\n WorkflowGateOptions,\n WorkflowPauseRequest,\n WorkflowDecision,\n WorkflowDecisionRecord,\n} from \"./domain/workflow/gates.types.ts\";\n\nexport { inspectRecovery } from \"./application/recovery-inspection.ts\";\nexport type {\n RecoveryInspection,\n RecoveryInspectionOptions,\n} from \"./application/recovery-inspection.types.ts\";\nexport type {\n ResourceActivityRecord,\n ResourceInspection,\n ResourceInspectionEntry,\n ResourceOperation,\n ResourceOperationKind,\n ResourceOperationResult,\n ResourcePhase,\n} from \"./infrastructure/resource-activity.types.ts\";\n\nexport {\n artifact,\n publishArtifact,\n readStoredArtifact,\n} from \"./domain/artifact.ts\";\nexport { artifactTask, readArtifact } from \"./application/artifact-tasks.ts\";\nexport { fileArtifactStore } from \"./infrastructure/artifact-store.ts\";\nexport type {\n ArtifactContract,\n ArtifactContractOptions,\n ArtifactIdentity,\n ArtifactProducer,\n ArtifactReference,\n ArtifactStore,\n JsonArtifactOptions,\n PublishArtifactOptions,\n ReadArtifactOptions,\n} from \"./domain/artifact.types.ts\";\nexport type { ArtifactTaskOptions } from \"./application/artifact-tasks.types.ts\";\nexport type { FileArtifactStoreOptions } from \"./infrastructure/artifact-store.types.ts\";\n\nexport { sqliteTaskQueue } from \"./infrastructure/task-queue.ts\";\nexport {\n serveTaskQueue,\n httpTaskQueue,\n} from \"./infrastructure/task-queue-http.ts\";\nexport { runQueueWorker } from \"./application/queue-worker.ts\";\nexport { queuedTask } from \"./application/queued-task.ts\";\nexport type {\n QueueRequest,\n QueueResult,\n QueueJob,\n QueueClaim,\n QueueLease,\n TaskQueue,\n DurableTaskQueue,\n} from \"./domain/task-queue.types.ts\";\nexport type {\n QueueServerOptions,\n QueueServer,\n QueueClientOptions,\n} from \"./infrastructure/task-queue-http.types.ts\";\nexport type {\n QueueHandlerContext,\n QueueHandler,\n QueueWorkerOptions,\n} from \"./application/queue-worker.types.ts\";\nexport type { QueuedTaskOptions } from \"./application/queued-task.types.ts\";\n\nexport type { EgressPolicy } from \"./domain/egress.types.ts\";\n\nexport { speculate } from \"./application/speculation.ts\";\nexport type {\n SpeculationOptions,\n SpeculationResult,\n SpeculativeCandidate,\n SpeculativeCandidateResult,\n SpeculativeOutput,\n SpeculativeHostSnapshot,\n SpeculativeValidation,\n} from \"./application/speculation.types.ts\";\n"]}
@@ -0,0 +1 @@
1
+ export declare const artifactMaxBytes: number;
@@ -0,0 +1,2 @@
1
+ export const artifactMaxBytes = 16 * 1024 * 1024;
2
+ //# sourceMappingURL=artifact-store.constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"artifact-store.constants.js","sourceRoot":"","sources":["../../src/infrastructure/artifact-store.constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,gBAAgB,GAAG,EAAE,GAAG,IAAI,GAAG,IAAI,CAAC","sourcesContent":["export const artifactMaxBytes = 16 * 1024 * 1024;\n"]}
@@ -0,0 +1,3 @@
1
+ import type { ArtifactStore } from "../domain/artifact.types.ts";
2
+ import type { FileArtifactStoreOptions } from "./artifact-store.types.ts";
3
+ export declare function fileArtifactStore(options: FileArtifactStoreOptions): ArtifactStore;
@@ -0,0 +1,100 @@
1
+ import { artifactDigestPattern } from "../domain/artifact.constants.js";
2
+ import { randomUUID } from "node:crypto";
3
+ import { link, lstat, mkdir, open, rm } from "node:fs/promises";
4
+ import { dirname, join, resolve } from "node:path";
5
+ import { readInspectionFile } from "./inspection-file.js";
6
+ import { artifactMaxBytes } from "./artifact-store.constants.js";
7
+ async function directory(path) {
8
+ const parent = dirname(path);
9
+ if (parent !== path) {
10
+ await directory(parent);
11
+ try {
12
+ await mkdir(path, { mode: 0o700 });
13
+ }
14
+ catch (error) {
15
+ if (!code(error, "EEXIST"))
16
+ throw error;
17
+ }
18
+ }
19
+ if (!(await lstat(path)).isDirectory())
20
+ throw new Error("Artifact directory must not contain symlinks");
21
+ }
22
+ function code(error, expected) {
23
+ return (!!error &&
24
+ typeof error === "object" &&
25
+ "code" in error &&
26
+ error.code === expected);
27
+ }
28
+ async function readArtifactFile(path, maxBytes) {
29
+ try {
30
+ return await readInspectionFile(path, maxBytes);
31
+ }
32
+ catch (error) {
33
+ if (!(error instanceof Error) ||
34
+ error.message !== "Inspection file changed")
35
+ throw error;
36
+ // Removing the staging hard link can change ctime once after publication.
37
+ return readInspectionFile(path, maxBytes);
38
+ }
39
+ }
40
+ export function fileArtifactStore(options) {
41
+ const root = resolve(options.directory), maxBytes = options.maxBytes ?? artifactMaxBytes;
42
+ if (!Number.isSafeInteger(maxBytes) || maxBytes < 1)
43
+ throw new Error("Artifact maxBytes must be a positive safe integer");
44
+ const path = (id) => {
45
+ if (!artifactDigestPattern.test(id))
46
+ throw new Error("Invalid artifact storage ID");
47
+ return join(root, `${id}.blob`);
48
+ };
49
+ return {
50
+ async put(id, input, signal) {
51
+ signal?.throwIfAborted();
52
+ const target = path(id);
53
+ if (input.byteLength > maxBytes)
54
+ throw new Error("Artifact exceeds maxBytes");
55
+ const bytes = Buffer.from(input);
56
+ await directory(root);
57
+ const temporary = join(root, `.${randomUUID()}.tmp`);
58
+ try {
59
+ const file = await open(temporary, "wx", 0o600);
60
+ try {
61
+ await file.writeFile(bytes, signal ? { signal } : {});
62
+ await file.sync();
63
+ }
64
+ finally {
65
+ await file.close();
66
+ }
67
+ signal?.throwIfAborted();
68
+ try {
69
+ await link(temporary, target);
70
+ }
71
+ catch (error) {
72
+ if (!code(error, "EEXIST"))
73
+ throw error;
74
+ if (!bytes.equals(await readArtifactFile(target, maxBytes)))
75
+ throw new Error("Existing artifact content integrity mismatch");
76
+ }
77
+ if (process.platform !== "win32") {
78
+ const parent = await open(root, "r");
79
+ try {
80
+ await parent.sync();
81
+ }
82
+ finally {
83
+ await parent.close();
84
+ }
85
+ }
86
+ }
87
+ finally {
88
+ await rm(temporary, { force: true });
89
+ }
90
+ },
91
+ async get(id, signal) {
92
+ signal?.throwIfAborted();
93
+ const target = path(id);
94
+ const bytes = await readArtifactFile(target, maxBytes);
95
+ signal?.throwIfAborted();
96
+ return bytes;
97
+ },
98
+ };
99
+ }
100
+ //# sourceMappingURL=artifact-store.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"artifact-store.js","sourceRoot":"","sources":["../../src/infrastructure/artifact-store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AACxE,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AAChE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEnD,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAGjE,KAAK,UAAU,SAAS,CAAC,IAAY;IACnC,MAAM,MAAM,GAAG,OAAO,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AI,CAAC;oBACH,MAAM,IAAI,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;gBAChC,CAAC;gBAAC,OAAO,KAAK,EAAE,CAAC;oBACf,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,QAAQ,CAAC;wBAAE,MAAM,KAAK,CAAC;oBACxC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,gBAAgB,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;wBACzD,MAAM,IAAI,KAAK,CAAC,8CAA8C,CAAC,CAAC;gBACpE,CAAC;gBACD,IAAI,OAAO,CAAC,QAAQ,KAAK,OAAO,EAAE,CAAC;oBACjC,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;oBACrC,IAAI,CAAC;wBACH,MAAM,MAAM,CAAC,IAAI,EAAE,CAAC;oBACtB,CAAC;4BAAS,CAAC;wBACT,MAAM,MAAM,CAAC,KAAK,EAAE,CAAC;oBACvB,CAAC;gBACH,CAAC;YACH,CAAC;oBAAS,CAAC;gBACT,MAAM,EAAE,CAAC,SAAS,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;YACvC,CAAC;QACH,CAAC;QACD,KAAK,CAAC,GAAG,CAAC,EAAE,EAAE,MAAM;YAClB,MAAM,EAAE,cAAc,EAAE,CAAC;YACzB,MAAM,MAAM,GAAG,IAAI,CAAC,EAAE,CAAC,CAAC;YACxB,MAAM,KAAK,GAAG,MAAM,gBAAgB,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;YACvD,MAAM,EAAE,cAAc,EAAE,CAAC;YACzB,OAAO,KAAK,CAAC;QACf,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { artifactDigestPattern } from \"../domain/artifact.constants.ts\";\nimport { randomUUID } from \"node:crypto\";\nimport { link, lstat, mkdir, open, rm } from \"node:fs/promises\";\nimport { dirname, join, resolve } from \"node:path\";\nimport type { ArtifactStore } from \"../domain/artifact.types.ts\";\nimport { readInspectionFile } from \"./inspection-file.ts\";\nimport { artifactMaxBytes } from \"./artifact-store.constants.ts\";\nimport type { FileArtifactStoreOptions } from \"./artifact-store.types.ts\";\n\nasync function directory(path: string): Promise<void> {\n const parent = dirname(path);\n if (parent !== path) {\n await directory(parent);\n try {\n await mkdir(path, { mode: 0o700 });\n } catch (error) {\n if (!code(error, \"EEXIST\")) throw error;\n }\n }\n if (!(await lstat(path)).isDirectory())\n throw new Error(\"Artifact directory must not contain symlinks\");\n}\n\nfunction code(error: unknown, expected: string): boolean {\n return (\n !!error &&\n typeof error === \"object\" &&\n \"code\" in error &&\n error.code === expected\n );\n}\n\nasync function readArtifactFile(\n path: string,\n maxBytes: number,\n): Promise<Buffer> {\n try {\n return await readInspectionFile(path, maxBytes);\n } catch (error) {\n if (\n !(error instanceof Error) ||\n error.message !== \"Inspection file changed\"\n )\n throw error;\n // Removing the staging hard link can change ctime once after publication.\n return readInspectionFile(path, maxBytes);\n }\n}\n\nexport function fileArtifactStore(\n options: FileArtifactStoreOptions,\n): ArtifactStore {\n const root = resolve(options.directory),\n maxBytes = options.maxBytes ?? artifactMaxBytes;\n if (!Number.isSafeInteger(maxBytes) || maxBytes < 1)\n throw new Error(\"Artifact maxBytes must be a positive safe integer\");\n const path = (id: string) => {\n if (!artifactDigestPattern.test(id))\n throw new Error(\"Invalid artifact storage ID\");\n return join(root, `${id}.blob`);\n };\n return {\n async put(id, input, signal) {\n signal?.throwIfAborted();\n const target = path(id);\n if (input.byteLength > maxBytes)\n throw new Error(\"Artifact exceeds maxBytes\");\n const bytes = Buffer.from(input);\n await directory(root);\n const temporary = join(root, `.${randomUUID()}.tmp`);\n try {\n const file = await open(temporary, \"wx\", 0o600);\n try {\n await file.writeFile(bytes, signal ? { signal } : {});\n await file.sync();\n } finally {\n await file.close();\n }\n signal?.throwIfAborted();\n try {\n await link(temporary, target);\n } catch (error) {\n if (!code(error, \"EEXIST\")) throw error;\n if (!bytes.equals(await readArtifactFile(target, maxBytes)))\n throw new Error(\"Existing artifact content integrity mismatch\");\n }\n if (process.platform !== \"win32\") {\n const parent = await open(root, \"r\");\n try {\n await parent.sync();\n } finally {\n await parent.close();\n }\n }\n } finally {\n await rm(temporary, { force: true });\n }\n },\n async get(id, signal) {\n signal?.throwIfAborted();\n const target = path(id);\n const bytes = await readArtifactFile(target, maxBytes);\n signal?.throwIfAborted();\n return bytes;\n },\n };\n}\n"]}
@@ -0,0 +1,4 @@
1
+ export interface FileArtifactStoreOptions {
2
+ readonly directory: string;
3
+ readonly maxBytes?: number;
4
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=artifact-store.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"artifact-store.types.js","sourceRoot":"","sources":["../../src/infrastructure/artifact-store.types.ts"],"names":[],"mappings":"","sourcesContent":["export interface FileArtifactStoreOptions {\n readonly directory: string;\n readonly maxBytes?: number;\n}\n"]}
@@ -1,5 +1,5 @@
1
1
  import type { FileManifestEntry } from "../domain/sandbox.types.ts";
2
- export declare function fileManifest(root: string, path: string): Promise<FileManifestEntry>;
2
+ export declare function fileManifest(root: string, path: string, signal?: AbortSignal): Promise<FileManifestEntry>;
3
3
  export declare function sameFile(left: FileManifestEntry, right: FileManifestEntry): boolean;
4
4
  export declare function sameLocalFile(remote: FileManifestEntry, local: FileManifestEntry): boolean;
5
5
  export declare function validateFilePaths(paths: readonly string[]): void;
@@ -3,7 +3,8 @@ import { createReadStream } from "node:fs";
3
3
  import { lstat, readlink } from "node:fs/promises";
4
4
  import { OutpostError } from "../domain/errors.js";
5
5
  import { safeDestination } from "./files.js";
6
- export async function fileManifest(root, path) {
6
+ export async function fileManifest(root, path, signal) {
7
+ signal?.throwIfAborted();
7
8
  const target = await safeDestination(root, path);
8
9
  const info = await lstat(target);
9
10
  if (!info.isFile() && !info.isSymbolicLink())
@@ -18,7 +19,7 @@ export async function fileManifest(root, path) {
18
19
  hash.update(value);
19
20
  }
20
21
  else {
21
- for await (const chunk of createReadStream(target))
22
+ for await (const chunk of createReadStream(target, { signal }))
22
23
  hash.update(chunk);
23
24
  }
24
25
  return {
@@ -1 +1 @@
1
- {"version":3,"file":"file-manifest.js","sourceRoot":"","sources":["../../src/infrastructure/file-manifest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAC3C,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAEnD,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAE7C,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,IAAY,EACZ,IAAY;IAEZ,MAAM,MAAM,GAAG,MAAM,eAAe,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IACjD,MAAM,IAAI,GAAG,MAAM,KAAK,CAAC,MAAM,CAAC,CAAC;IACjC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE;QAC1C,MAAM,IAAI,YAAY,CAAC,UAAU,EAAE,gCAAgC,EAAE;YACnE,IAAI;SACL,CAAC,CAAC;IACL,MAAM,IAAI,GAAG,UAAU,CAAC,QAAQ,CAAC,CAAC;IAClC,IAAI,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;IACrB,IAAI,IAAI,CAAC,cAAc,EAAE,EAAE,CAAC;QAC1B,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC;QAClD,IAAI,GAAG,KAAK,CAAC,MAAM,CAAC;QACpB,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACrB,CAAC;SAAM,CAAC;QACN,IAAI,KAAK,EAAE,MAAM,KAAK,IAAI,gBAAgB,CAAC,MAAM,CAAC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AC,IAAI,KAAK,QAAQ;YAC9B,CAAC,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,IAAI,CAAC;YACjC,KAAK,CAAC,IAAI,GAAG,CAAC;YACd,CAAC,CAAC,QAAQ,IAAI,KAAK,CAAC;YACpB,OAAO,KAAK,CAAC,MAAM,KAAK,QAAQ;YAChC,CAAC,gBAAgB,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC;YAEpC,MAAM,IAAI,YAAY,CAAC,UAAU,EAAE,6BAA6B,CAAC,CAAC;QACpE,OAAO;YACL,IAAI,EAAE,KAAK,CAAC,IAAI;YAChB,IAAI,EAAE,KAAK,CAAC,IAAI;YAChB,IAAI,EAAE,KAAK,CAAC,IAAI;YAChB,IAAI,EAAE,KAAK,CAAC,IAAI;YAChB,MAAM,EAAE,KAAK,CAAC,MAAM;SACrB,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { createHash } from \"node:crypto\";\nimport { createReadStream } from \"node:fs\";\nimport { lstat, readlink } from \"node:fs/promises\";\nimport { OutpostError } from \"../domain/errors.ts\";\nimport type { FileManifestEntry } from \"../domain/sandbox.types.ts\";\nimport { safeDestination } from \"./files.ts\";\n\nexport async function fileManifest(\n root: string,\n path: string,\n): Promise<FileManifestEntry> {\n const target = await safeDestination(root, path);\n const info = await lstat(target);\n if (!info.isFile() && !info.isSymbolicLink())\n throw new OutpostError(\"provider\", \"Unsupported manifest file type\", {\n path,\n });\n const hash = createHash(\"sha256\");\n let size = info.size;\n if (info.isSymbolicLink()) {\n const value = Buffer.from(await readlink(target));\n size = value.length;\n hash.update(value);\n } else {\n for await (const chunk of createReadStream(target)) hash.update(chunk);\n }\n return {\n path,\n kind: info.isSymbolicLink() ? \"link\" : \"file\",\n mode: info.mode & 0o777,\n size,\n sha256: hash.digest(\"hex\"),\n };\n}\n\nexport function sameFile(\n left: FileManifestEntry,\n right: FileManifestEntry,\n): boolean {\n return (\n left.path === right.path &&\n left.kind === right.kind &&\n left.mode === right.mode &&\n left.size === right.size &&\n left.sha256 === right.sha256\n );\n}\n\nexport function sameLocalFile(\n remote: FileManifestEntry,\n local: FileManifestEntry,\n): boolean {\n if (process.platform !== \"win32\") return sameFile(remote, local);\n return sameFile(\n { ...remote, mode: remote.mode & 0o200 },\n { ...local, mode: local.mode & 0o200 },\n );\n}\n\nexport function validateFilePaths(paths: readonly string[]): void {\n if (\n new Set(paths).size !== paths.length ||\n paths.some(\n (path) =>\n !path ||\n path.includes(\"\\\\\") ||\n path.includes(\"\\0\") ||\n path\n .split(\"/\")\n .some(\n (part) =>\n !part ||\n part === \".\" ||\n part === \"..\" ||\n part.toLowerCase() === \".git\",\n ),\n )\n )\n throw new OutpostError(\"provider\", \"Unsafe or duplicate manifest path\");\n}\n\nexport function parseManifest(\n value: unknown,\n paths: readonly string[],\n): FileManifestEntry[] {\n validateFilePaths(paths);\n if (!Array.isArray(value) || value.length !== paths.length)\n throw new OutpostError(\"provider\", \"Invalid file manifest\");\n return value.map((entry: unknown, index) => {\n if (\n !entry ||\n typeof entry !== \"object\" ||\n !(\"path\" in entry) ||\n typeof entry.path !== \"string\" ||\n entry.path !== paths[index] ||\n !(\"kind\" in entry) ||\n (entry.kind !== \"file\" && entry.kind !== \"link\") ||\n !(\"mode\" in entry) ||\n typeof entry.mode !== \"number\" ||\n !Number.isInteger(entry.mode) ||\n entry.mode < 0 ||\n entry.mode > 0o777 ||\n !(\"size\" in entry) ||\n typeof entry.size !== \"number\" ||\n !Number.isSafeInteger(entry.size) ||\n entry.size < 0 ||\n !(\"sha256\" in entry) ||\n typeof entry.sha256 !== \"string\" ||\n !/^[a-f0-9]{64}$/.test(entry.sha256)\n )\n throw new OutpostError(\"provider\", \"Invalid file manifest entry\");\n return {\n path: entry.path,\n kind: entry.kind,\n mode: entry.mode,\n size: entry.size,\n sha256: entry.sha256,\n };\n });\n}\n"]}
1
+ {"version":3,"file":"file-manifest.js","sourceRoot":"","sources":["../../src/infrastructure/file-manifest.ts"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CAAC,IAAI,GAAG,CAAC;YACd,CAAC,CAAC,QAAQ,IAAI,KAAK,CAAC;YACpB,OAAO,KAAK,CAAC,MAAM,KAAK,QAAQ;YAChC,CAAC,gBAAgB,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC;YAEpC,MAAM,IAAI,YAAY,CAAC,UAAU,EAAE,6BAA6B,CAAC,CAAC;QACpE,OAAO;YACL,IAAI,EAAE,KAAK,CAAC,IAAI;YAChB,IAAI,EAAE,KAAK,CAAC,IAAI;YAChB,IAAI,EAAE,KAAK,CAAC,IAAI;YAChB,IAAI,EAAE,KAAK,CAAC,IAAI;YAChB,MAAM,EAAE,KAAK,CAAC,MAAM;SACrB,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { createHash } from \"node:crypto\";\nimport { createReadStream } from \"node:fs\";\nimport { lstat, readlink } from \"node:fs/promises\";\nimport { OutpostError } from \"../domain/errors.ts\";\nimport type { FileManifestEntry } from \"../domain/sandbox.types.ts\";\nimport { safeDestination } from \"./files.ts\";\n\nexport async function fileManifest(\n root: string,\n path: string,\n signal?: AbortSignal,\n): Promise<FileManifestEntry> {\n signal?.throwIfAborted();\n const target = await safeDestination(root, path);\n const info = await lstat(target);\n if (!info.isFile() && !info.isSymbolicLink())\n throw new OutpostError(\"provider\", \"Unsupported manifest file type\", {\n path,\n });\n const hash = createHash(\"sha256\");\n let size = info.size;\n if (info.isSymbolicLink()) {\n const value = Buffer.from(await readlink(target));\n size = value.length;\n hash.update(value);\n } else {\n for await (const chunk of createReadStream(target, { signal }))\n hash.update(chunk);\n }\n return {\n path,\n kind: info.isSymbolicLink() ? \"link\" : \"file\",\n mode: info.mode & 0o777,\n size,\n sha256: hash.digest(\"hex\"),\n };\n}\n\nexport function sameFile(\n left: FileManifestEntry,\n right: FileManifestEntry,\n): boolean {\n return (\n left.path === right.path &&\n left.kind === right.kind &&\n left.mode === right.mode &&\n left.size === right.size &&\n left.sha256 === right.sha256\n );\n}\n\nexport function sameLocalFile(\n remote: FileManifestEntry,\n local: FileManifestEntry,\n): boolean {\n if (process.platform !== \"win32\") return sameFile(remote, local);\n return sameFile(\n { ...remote, mode: remote.mode & 0o200 },\n { ...local, mode: local.mode & 0o200 },\n );\n}\n\nexport function validateFilePaths(paths: readonly string[]): void {\n if (\n new Set(paths).size !== paths.length ||\n paths.some(\n (path) =>\n !path ||\n path.includes(\"\\\\\") ||\n path.includes(\"\\0\") ||\n path\n .split(\"/\")\n .some(\n (part) =>\n !part ||\n part === \".\" ||\n part === \"..\" ||\n part.toLowerCase() === \".git\",\n ),\n )\n )\n throw new OutpostError(\"provider\", \"Unsafe or duplicate manifest path\");\n}\n\nexport function parseManifest(\n value: unknown,\n paths: readonly string[],\n): FileManifestEntry[] {\n validateFilePaths(paths);\n if (!Array.isArray(value) || value.length !== paths.length)\n throw new OutpostError(\"provider\", \"Invalid file manifest\");\n return value.map((entry: unknown, index) => {\n if (\n !entry ||\n typeof entry !== \"object\" ||\n !(\"path\" in entry) ||\n typeof entry.path !== \"string\" ||\n entry.path !== paths[index] ||\n !(\"kind\" in entry) ||\n (entry.kind !== \"file\" && entry.kind !== \"link\") ||\n !(\"mode\" in entry) ||\n typeof entry.mode !== \"number\" ||\n !Number.isInteger(entry.mode) ||\n entry.mode < 0 ||\n entry.mode > 0o777 ||\n !(\"size\" in entry) ||\n typeof entry.size !== \"number\" ||\n !Number.isSafeInteger(entry.size) ||\n entry.size < 0 ||\n !(\"sha256\" in entry) ||\n typeof entry.sha256 !== \"string\" ||\n !/^[a-f0-9]{64}$/.test(entry.sha256)\n )\n throw new OutpostError(\"provider\", \"Invalid file manifest entry\");\n return {\n path: entry.path,\n kind: entry.kind,\n mode: entry.mode,\n size: entry.size,\n sha256: entry.sha256,\n };\n });\n}\n"]}
@@ -1 +1 @@
1
- export declare function verificationGit(directory: string, args: readonly string[]): Promise<string>;
1
+ export declare function verificationGit(directory: string, args: readonly string[], deadlineMs?: number, signal?: AbortSignal): Promise<string>;
@@ -1,7 +1,7 @@
1
1
  import { execFile } from "node:child_process";
2
2
  import { promisify } from "node:util";
3
3
  import { gitDefaults } from "./git.constants.js";
4
- export async function verificationGit(directory, args) {
4
+ export async function verificationGit(directory, args, deadlineMs = gitDefaults.deadlineMs, signal) {
5
5
  const environment = Object.fromEntries(Object.entries(process.env).filter(([key]) => !key.toUpperCase().startsWith("GIT_")));
6
6
  const result = await promisify(execFile)("git", [
7
7
  "-c",
@@ -26,7 +26,8 @@ export async function verificationGit(directory, args) {
26
26
  GIT_OPTIONAL_LOCKS: "0",
27
27
  LC_ALL: "C",
28
28
  },
29
- timeout: gitDefaults.deadlineMs,
29
+ timeout: deadlineMs,
30
+ ...(signal ? { signal } : {}),
30
31
  maxBuffer: gitDefaults.retainBytes,
31
32
  encoding: "utf8",
32
33
  windowsHide: true,
@@ -1 +1 @@
1
- {"version":3,"file":"verification-command.js","sourceRoot":"","sources":["../../../src/infrastructure/git/verification-command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEjD,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,SAAiB,EACjB,IAAuB;IAEvB,MAAM,WAAW,GAAG,MAAM,CAAC,WAAW,CACpC,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,CAChC,CAAC,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC,UAAU,CAAC,MAAM,CAAC,CACjD,CACF,CAAC;IACF,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,QAAQ,CAAC,CACtC,KAAK,EACL;QACE,IAAI;QACJ,kBAAkB,OAAO,CAAC,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,WAAW,EAAE;QACtE,IAAI;QACJ,sBAAsB;QACtB,IAAI;QACJ,wBAAwB;QACxB,IAAI;QACJ,WAAW;QACX,GAAG,IAAI;KACR,EACD;QACE,GAAG,EAAE,SAAS;QACd,GAAG,EAAE;YACH,GAAG,WAAW;YACd,mBAAmB,EAAE,GAAG;YACxB,iBAAiB,EAAE,OAAO,CAAC,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,WAAW;YACrE,iBAAiB,EAAE,GAAG;YACtB,iBAAiB,EAAE,GAAG;YACtB,kBAAkB,EAAE,MAAM;YAC1B,mBAAmB,EAAE,GAAG;YACxB,kBAAkB,EAAE,GAAG;YACvB,MAAM,EAAE,GAAG;SACZ;QACD,OAAO,EAAE,WAAW,CAAC,UAAU;QAC/B,SAAS,EAAE,WAAW,CAAC,WAAW;QAClC,QAAQ,EAAE,MAAM;QAChB,WAAW,EAAE,IAAI;KAClB,CACF,CAAC;IACF,OAAO,MAAM,CAAC,MAAM,CAAC;AACvB,CAAC","sourcesContent":["import { execFile } from \"node:child_process\";\nimport { promisify } from \"node:util\";\nimport { gitDefaults } from \"./git.constants.ts\";\n\nexport async function verificationGit(\n directory: string,\n args: readonly string[],\n): Promise<string> {\n const environment = Object.fromEntries(\n Object.entries(process.env).filter(\n ([key]) => !key.toUpperCase().startsWith(\"GIT_\"),\n ),\n );\n const result = await promisify(execFile)(\n \"git\",\n [\n \"-c\",\n `core.hooksPath=${process.platform === \"win32\" ? \"NUL\" : \"/dev/null\"}`,\n \"-c\",\n \"core.fsmonitor=false\",\n \"-c\",\n \"maintenance.auto=false\",\n \"-c\",\n \"gc.auto=0\",\n ...args,\n ],\n {\n cwd: directory,\n env: {\n ...environment,\n GIT_CONFIG_NOSYSTEM: \"1\",\n GIT_CONFIG_GLOBAL: process.platform === \"win32\" ? \"NUL\" : \"/dev/null\",\n GIT_ATTR_NOSYSTEM: \"1\",\n GIT_NO_LAZY_FETCH: \"1\",\n GIT_ALLOW_PROTOCOL: \"file\",\n GIT_TERMINAL_PROMPT: \"0\",\n GIT_OPTIONAL_LOCKS: \"0\",\n LC_ALL: \"C\",\n },\n timeout: gitDefaults.deadlineMs,\n maxBuffer: gitDefaults.retainBytes,\n encoding: \"utf8\",\n windowsHide: true,\n },\n );\n return result.stdout;\n}\n"]}
1
+ {"version":3,"file":"verification-command.js","sourceRoot":"","sources":["../../../src/infrastructure/git/verification-command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEjD,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,SAAiB,EACjB,IAAuB,EACvB,aAAqB,WAAW,CAAC,UAAU,EAC3C,MAAoB;IAEpB,MAAM,WAAW,GAAG,MAAM,CAAC,WAAW,CACpC,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,CAChC,CAAC,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC,UAAU,CAAC,MAAM,CAAC,CACjD,CACF,CAAC;IACF,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,QAAQ,CAAC,CACtC,KAAK,EACL;QACE,IAAI;QACJ,kBAAkB,OAAO,CAAC,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,WAAW,EAAE;QACtE,IAAI;QACJ,sBAAsB;QACtB,IAAI;QACJ,wBAAwB;QACxB,IAAI;QACJ,WAAW;QACX,GAAG,IAAI;KACR,EACD;QACE,GAAG,EAAE,SAAS;QACd,GAAG,EAAE;YACH,GAAG,WAAW;YACd,mBAAmB,EAAE,GAAG;YACxB,iBAAiB,EAAE,OAAO,CAAC,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,WAAW;YACrE,iBAAiB,EAAE,GAAG;YACtB,iBAAiB,EAAE,GAAG;YACtB,kBAAkB,EAAE,MAAM;YAC1B,mBAAmB,EAAE,GAAG;YACxB,kBAAkB,EAAE,GAAG;YACvB,MAAM,EAAE,GAAG;SACZ;QACD,OAAO,EAAE,UAAU;QACnB,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC7B,SAAS,EAAE,WAAW,CAAC,WAAW;QAClC,QAAQ,EAAE,MAAM;QAChB,WAAW,EAAE,IAAI;KAClB,CACF,CAAC;IACF,OAAO,MAAM,CAAC,MAAM,CAAC;AACvB,CAAC","sourcesContent":["import { execFile } from \"node:child_process\";\nimport { promisify } from \"node:util\";\nimport { gitDefaults } from \"./git.constants.ts\";\n\nexport async function verificationGit(\n directory: string,\n args: readonly string[],\n deadlineMs: number = gitDefaults.deadlineMs,\n signal?: AbortSignal,\n): Promise<string> {\n const environment = Object.fromEntries(\n Object.entries(process.env).filter(\n ([key]) => !key.toUpperCase().startsWith(\"GIT_\"),\n ),\n );\n const result = await promisify(execFile)(\n \"git\",\n [\n \"-c\",\n `core.hooksPath=${process.platform === \"win32\" ? \"NUL\" : \"/dev/null\"}`,\n \"-c\",\n \"core.fsmonitor=false\",\n \"-c\",\n \"maintenance.auto=false\",\n \"-c\",\n \"gc.auto=0\",\n ...args,\n ],\n {\n cwd: directory,\n env: {\n ...environment,\n GIT_CONFIG_NOSYSTEM: \"1\",\n GIT_CONFIG_GLOBAL: process.platform === \"win32\" ? \"NUL\" : \"/dev/null\",\n GIT_ATTR_NOSYSTEM: \"1\",\n GIT_NO_LAZY_FETCH: \"1\",\n GIT_ALLOW_PROTOCOL: \"file\",\n GIT_TERMINAL_PROMPT: \"0\",\n GIT_OPTIONAL_LOCKS: \"0\",\n LC_ALL: \"C\",\n },\n timeout: deadlineMs,\n ...(signal ? { signal } : {}),\n maxBuffer: gitDefaults.retainBytes,\n encoding: \"utf8\",\n windowsHide: true,\n },\n );\n return result.stdout;\n}\n"]}
@@ -44,7 +44,7 @@ export function openTelemetry(options) {
44
44
  return;
45
45
  const attributes = { "outpost.status": status };
46
46
  safe(() => operation.span?.setAttributes(attributes));
47
- if (status !== "skipped")
47
+ if (status !== "skipped" && status !== "paused")
48
48
  safe(() => operation.span?.setStatus({
49
49
  code: status === "done" ? SpanStatusCode.OK : SpanStatusCode.ERROR,
50
50
  }));
@@ -1 +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,CAAC,OAAO,CAAC,KAAK,CAAC,aAAa,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;QACpE,QAAQ,EAAE,IAAI,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,aAAa,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC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/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\")\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"]}
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,CAAC,OAAO,CAAC,KAAK,CAAC,aAAa,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;QACpE,QAAQ,EAAE,IAAI,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,aAAa,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC;QAC1E,OAAO,EAAE,IAAI,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,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CAAC;gBACvD,SAAS,CAAC,KAAK,CAAC,GAAG,CACjB,KAAK,CAAC,GAAG,EACT,KAAK,CAAC,cAAc,EAAE,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,EAAE,CAAC,CACtD,CAAC;gBACF,OAAO;YACT,CAAC;YACD,IAAI,KAAK,CAAC,IAAI,KAAK,MAAM,IAAI,KAAK,CAAC,MAAM,EAAE,CAAC;gBAC1C,MAAM,CACJ,SAAS,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,EACjC,KAAK,CAAC,MAAM,EACZ,EAAE,EACF,SAAS,CAAC,OAAO,CAClB,CAAC;gBACF,MAAM,CACJ,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,EAC9B,KAAK,CAAC,MAAM,EACZ,EAAE,EACF,SAAS,CAAC,IAAI,CACf,CAAC;gBACF,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;gBACrC,SAAS,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;gBAClC,IAAI,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,EAAE,EAAE,gBAAgB,EAAE,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;YACzE,CAAC;QACH,CAAC;QACD,KAAK;YACH,IAAI,MAAM;gBAAE,OAAO;YACnB,MAAM,GAAG,IAAI,CAAC;YACd,KAAK,MAAM,SAAS,IAAI,UAAU,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"]}
@@ -0,0 +1,2 @@
1
+ import type { ResourceInspection } from "./resource-activity.types.ts";
2
+ export declare function inspectResourceActivity(repository: string, maxEntries?: number): Promise<ResourceInspection>;