@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":"agent.types.js","sourceRoot":"","sources":["../../src/domain/agent.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { Command, Variables } from \"./command.types.ts\";\nimport type { ConversationStore } from \"./conversation.types.ts\";\n\nexport interface Usage {\n readonly input: number;\n readonly cached: number;\n readonly cacheCreated?: number;\n readonly output: number;\n}\n\nexport type AgentEvent =\n | {\n readonly kind: \"phase\";\n readonly name: string;\n readonly agent?: string;\n readonly branch?: string;\n readonly directory?: string;\n }\n | {\n readonly kind: \"summary\";\n readonly durationMs: number;\n readonly status: number;\n readonly tokens: Usage;\n }\n | { readonly kind: \"warning\"; readonly message: string }\n | { readonly kind: \"text\"; readonly text: string }\n | { readonly kind: \"result\"; readonly text: string }\n | { readonly kind: \"prompt\"; readonly text: string }\n | { readonly kind: \"tool\"; readonly name: string; readonly input: unknown }\n | { readonly kind: \"conversation\"; readonly id: string }\n | { readonly kind: \"usage\"; readonly tokens: Usage }\n | { readonly kind: \"failure\"; readonly message: string }\n | { readonly kind: \"finished\" }\n | { readonly kind: \"raw\"; readonly value: unknown };\n\nexport type AgentObservation = AgentEvent & {\n readonly pass: number;\n readonly at: string;\n};\n\nexport type AgentEventHandlers = {\n readonly [Kind in AgentEvent[\"kind\"]]?: (\n event: Extract<AgentEvent, { kind: Kind }>,\n ) => void;\n};\n\nexport interface AgentInput {\n readonly text?: string;\n readonly interactive?: boolean;\n readonly continuation?: { readonly id: string; readonly fork?: boolean };\n}\n\nexport interface AgentAdapter {\n readonly name: string;\n readonly variables?: Variables;\n readonly conversations?: \"claude\" | \"codex\";\n readonly storage?: ConversationStore;\n readonly capture?: boolean;\n readonly resumable?: boolean;\n transcriptUsage?(text: string): Usage | undefined;\n request(input: AgentInput): Command;\n events(line: string): readonly AgentEvent[];\n}\n\nexport interface RequiredAgent {\n readonly agent: AgentAdapter;\n}\n"]}
1
+ {"version":3,"file":"agent.types.js","sourceRoot":"","sources":["../../src/domain/agent.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { Command, Variables } from \"./command.types.ts\";\nimport type { ConversationStore } from \"./conversation.types.ts\";\n\nexport interface Usage {\n readonly input: number;\n readonly cached: number;\n readonly cacheCreated?: number;\n readonly output: number;\n}\n\nexport type AgentEvent =\n | {\n readonly kind: \"phase\";\n readonly name: string;\n readonly agent?: string;\n readonly branch?: string;\n readonly directory?: string;\n }\n | {\n readonly kind: \"summary\";\n readonly durationMs: number;\n readonly status: number;\n readonly tokens: Usage;\n }\n | { readonly kind: \"warning\"; readonly message: string }\n | { readonly kind: \"text\"; readonly text: string }\n | { readonly kind: \"result\"; readonly text: string }\n | { readonly kind: \"prompt\"; readonly text: string }\n | { readonly kind: \"tool\"; readonly name: string; readonly input: unknown }\n | { readonly kind: \"conversation\"; readonly id: string }\n | { readonly kind: \"usage\"; readonly tokens: Usage }\n | { readonly kind: \"failure\"; readonly message: string }\n | { readonly kind: \"finished\" }\n | { readonly kind: \"raw\"; readonly value: unknown };\n\nexport type AgentObservation = AgentEvent & {\n readonly pass: number;\n readonly at: string;\n};\n\nexport type AgentEventHandlers = {\n readonly [Kind in AgentEvent[\"kind\"]]?: (\n event: Extract<AgentEvent, { kind: Kind }>,\n ) => void;\n};\n\nexport interface AgentInput {\n readonly text?: string;\n readonly interactive?: boolean;\n readonly continuation?: { readonly id: string; readonly fork?: boolean };\n}\n\nexport interface AgentAdapter {\n readonly name: string;\n readonly bootstrap?: string;\n readonly requiresFinishedEvent?: boolean;\n readonly variables?: Variables;\n readonly conversations?: \"claude\" | \"codex\";\n readonly storage?: ConversationStore;\n readonly capture?: boolean;\n readonly resumable?: boolean;\n transcriptUsage?(text: string): Usage | undefined;\n request(input: AgentInput): Command;\n events(line: string): readonly AgentEvent[];\n}\n\nexport interface RequiredAgent {\n readonly agent: AgentAdapter;\n}\n"]}
@@ -0,0 +1,4 @@
1
+ import type { ArtifactReference } from "./artifact.types.ts";
2
+ export declare function artifactDigest(bytes: Uint8Array | string): string;
3
+ export declare function artifactId(reference: Omit<ArtifactReference, "id">): string;
4
+ export declare function validateArtifactReference(value: unknown): ArtifactReference;
@@ -0,0 +1,90 @@
1
+ import { artifactDigestPattern, artifactLabelMaxLength, } from "./artifact.constants.js";
2
+ import { createHash } from "node:crypto";
3
+ export function artifactDigest(bytes) {
4
+ return createHash("sha256").update(bytes).digest("hex");
5
+ }
6
+ export function artifactId(reference) {
7
+ return artifactDigest(JSON.stringify([
8
+ reference.format,
9
+ reference.digest,
10
+ reference.size,
11
+ reference.contract.name,
12
+ reference.contract.version,
13
+ reference.contract.encoding,
14
+ reference.producer.executionId,
15
+ reference.producer.taskKey,
16
+ reference.producer.attempt,
17
+ reference.parents,
18
+ ]));
19
+ }
20
+ export function validateArtifactReference(value) {
21
+ const invalid = () => new Error("Invalid artifact reference or lineage");
22
+ if (!value ||
23
+ typeof value !== "object" ||
24
+ !("format" in value) ||
25
+ value.format !== 1 ||
26
+ !("id" in value) ||
27
+ !digest(value.id) ||
28
+ !("digest" in value) ||
29
+ !digest(value.digest) ||
30
+ !("size" in value) ||
31
+ typeof value.size !== "number" ||
32
+ !Number.isSafeInteger(value.size) ||
33
+ value.size < 0 ||
34
+ !("contract" in value) ||
35
+ !value.contract ||
36
+ typeof value.contract !== "object" ||
37
+ !("producer" in value) ||
38
+ !value.producer ||
39
+ typeof value.producer !== "object" ||
40
+ !("parents" in value) ||
41
+ !Array.isArray(value.parents) ||
42
+ !value.parents.every(digest) ||
43
+ new Set(value.parents).size !== value.parents.length)
44
+ throw invalid();
45
+ const contract = value.contract, producer = value.producer;
46
+ if (!("name" in contract) ||
47
+ !label(contract.name) ||
48
+ !("version" in contract) ||
49
+ !label(contract.version) ||
50
+ !("encoding" in contract) ||
51
+ (contract.encoding !== "json" && contract.encoding !== "binary") ||
52
+ !("executionId" in producer) ||
53
+ !label(producer.executionId) ||
54
+ !("taskKey" in producer) ||
55
+ !label(producer.taskKey) ||
56
+ !("attempt" in producer) ||
57
+ typeof producer.attempt !== "number" ||
58
+ !Number.isSafeInteger(producer.attempt) ||
59
+ producer.attempt < 1)
60
+ throw invalid();
61
+ const reference = Object.freeze({
62
+ format: 1,
63
+ id: value.id,
64
+ digest: value.digest,
65
+ size: value.size,
66
+ contract: Object.freeze({
67
+ name: contract.name,
68
+ version: contract.version,
69
+ encoding: contract.encoding,
70
+ }),
71
+ producer: Object.freeze({
72
+ executionId: producer.executionId,
73
+ taskKey: producer.taskKey,
74
+ attempt: producer.attempt,
75
+ }),
76
+ parents: Object.freeze([...value.parents]),
77
+ });
78
+ if (artifactId(reference) !== reference.id)
79
+ throw invalid();
80
+ return reference;
81
+ }
82
+ function digest(value) {
83
+ return typeof value === "string" && artifactDigestPattern.test(value);
84
+ }
85
+ function label(value) {
86
+ return (typeof value === "string" &&
87
+ value.trim().length > 0 &&
88
+ value.length <= artifactLabelMaxLength);
89
+ }
90
+ //# sourceMappingURL=artifact-reference.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"artifact-reference.js","sourceRoot":"","sources":["../../src/domain/artifact-reference.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,EACrB,sBAAsB,GACvB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAGzC,MAAM,UAAU,cAAc,CAAC,KAA0B;IACvD,OAAO,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAC1D,CAAC;AAED,MAAM,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C;QACT,EAAE,EAAE,KAAK,CAAC,EAAE;QACZ,MAAM,EAAE,KAAK,CAAC,MAAM;QACpB,IAAI,EAAE,KAAK,CAAC,IAAI;QAChB,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC;YACtB,IAAI,EAAE,QAAQ,CAAC,IAAI;YACnB,OAAO,EAAE,QAAQ,CAAC,OAAO;YACzB,QAAQ,EAAE,QAAQ,CAAC,QAAQ;SAC5B,CAAC;QACF,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC;YACtB,WAAW,EAAE,QAAQ,CAAC,WAAW;YACjC,OAAO,EAAE,QAAQ,CAAC,OAAO;YACzB,OAAO,EAAE,QAAQ,CAAC,OAAO;SAC1B,CAAC;QACF,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,KAAK,CAAC,OAAO,CAAC,CAAC;KAC3C,CAAC,CAAC;IACH,IAAI,UAAU,CAAC,SAAS,CAAC,KAAK,SAAS,CAAC,EAAE;QAAE,MAAM,OAAO,EAAE,CAAC;IAC5D,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,SAAS,MAAM,CAAC,KAAc;IAC5B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,qBAAqB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AACxE,CAAC;AAED,SAAS,KAAK,CAAC,KAAc;IAC3B,OAAO,CACL,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC;QACvB,KAAK,CAAC,MAAM,IAAI,sBAAsB,CACvC,CAAC;AACJ,CAAC","sourcesContent":["import {\n artifactDigestPattern,\n artifactLabelMaxLength,\n} from \"./artifact.constants.ts\";\nimport { createHash } from \"node:crypto\";\nimport type { ArtifactReference } from \"./artifact.types.ts\";\n\nexport function artifactDigest(bytes: Uint8Array | string): string {\n return createHash(\"sha256\").update(bytes).digest(\"hex\");\n}\n\nexport function artifactId(reference: Omit<ArtifactReference, \"id\">): string {\n return artifactDigest(\n JSON.stringify([\n reference.format,\n reference.digest,\n reference.size,\n reference.contract.name,\n reference.contract.version,\n reference.contract.encoding,\n reference.producer.executionId,\n reference.producer.taskKey,\n reference.producer.attempt,\n reference.parents,\n ]),\n );\n}\n\nexport function validateArtifactReference(value: unknown): ArtifactReference {\n const invalid = () => new Error(\"Invalid artifact reference or lineage\");\n if (\n !value ||\n typeof value !== \"object\" ||\n !(\"format\" in value) ||\n value.format !== 1 ||\n !(\"id\" in value) ||\n !digest(value.id) ||\n !(\"digest\" in value) ||\n !digest(value.digest) ||\n !(\"size\" in value) ||\n typeof value.size !== \"number\" ||\n !Number.isSafeInteger(value.size) ||\n value.size < 0 ||\n !(\"contract\" in value) ||\n !value.contract ||\n typeof value.contract !== \"object\" ||\n !(\"producer\" in value) ||\n !value.producer ||\n typeof value.producer !== \"object\" ||\n !(\"parents\" in value) ||\n !Array.isArray(value.parents) ||\n !value.parents.every(digest) ||\n new Set(value.parents).size !== value.parents.length\n )\n throw invalid();\n const contract = value.contract,\n producer = value.producer;\n if (\n !(\"name\" in contract) ||\n !label(contract.name) ||\n !(\"version\" in contract) ||\n !label(contract.version) ||\n !(\"encoding\" in contract) ||\n (contract.encoding !== \"json\" && contract.encoding !== \"binary\") ||\n !(\"executionId\" in producer) ||\n !label(producer.executionId) ||\n !(\"taskKey\" in producer) ||\n !label(producer.taskKey) ||\n !(\"attempt\" in producer) ||\n typeof producer.attempt !== \"number\" ||\n !Number.isSafeInteger(producer.attempt) ||\n producer.attempt < 1\n )\n throw invalid();\n const reference: ArtifactReference = Object.freeze({\n format: 1,\n id: value.id,\n digest: value.digest,\n size: value.size,\n contract: Object.freeze({\n name: contract.name,\n version: contract.version,\n encoding: contract.encoding,\n }),\n producer: Object.freeze({\n executionId: producer.executionId,\n taskKey: producer.taskKey,\n attempt: producer.attempt,\n }),\n parents: Object.freeze([...value.parents]),\n });\n if (artifactId(reference) !== reference.id) throw invalid();\n return reference;\n}\n\nfunction digest(value: unknown): value is string {\n return typeof value === \"string\" && artifactDigestPattern.test(value);\n}\n\nfunction label(value: unknown): value is string {\n return (\n typeof value === \"string\" &&\n value.trim().length > 0 &&\n value.length <= artifactLabelMaxLength\n );\n}\n"]}
@@ -0,0 +1,2 @@
1
+ export declare const artifactLabelMaxLength = 1024;
2
+ export declare const artifactDigestPattern: RegExp;
@@ -0,0 +1,3 @@
1
+ export const artifactLabelMaxLength = 1024;
2
+ export const artifactDigestPattern = /^[a-f0-9]{64}$/;
3
+ //# sourceMappingURL=artifact.constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"artifact.constants.js","sourceRoot":"","sources":["../../src/domain/artifact.constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,sBAAsB,GAAG,IAAI,CAAC;AAC3C,MAAM,CAAC,MAAM,qBAAqB,GAAG,gBAAgB,CAAC","sourcesContent":["export const artifactLabelMaxLength = 1024;\nexport const artifactDigestPattern = /^[a-f0-9]{64}$/;\n"]}
@@ -0,0 +1,7 @@
1
+ import type { ArtifactContract, ArtifactContractOptions, ArtifactReference, ArtifactStore, JsonArtifactOptions, PublishArtifactOptions, ReadArtifactOptions } from "./artifact.types.ts";
2
+ export declare const artifact: {
3
+ json<T>(options: JsonArtifactOptions<T>): ArtifactContract<T>;
4
+ binary(options: ArtifactContractOptions): ArtifactContract<Uint8Array>;
5
+ };
6
+ export declare function publishArtifact<T>(store: ArtifactStore, contract: ArtifactContract<T>, value: T, options: PublishArtifactOptions): Promise<ArtifactReference>;
7
+ export declare function readStoredArtifact<T>(store: ArtifactStore, contract: ArtifactContract<T>, value: unknown, options?: ReadArtifactOptions): Promise<T>;
@@ -0,0 +1,104 @@
1
+ import { artifactLabelMaxLength } from "./artifact.constants.js";
2
+ import { artifactDigest, artifactId, validateArtifactReference, } from "./artifact-reference.js";
3
+ import { checkpointValue } from "./workflow/checkpoint-value.js";
4
+ function identity(options) {
5
+ if (!options.name.trim() ||
6
+ !options.version.trim() ||
7
+ options.name.length > artifactLabelMaxLength ||
8
+ options.version.length > artifactLabelMaxLength)
9
+ throw new Error(`Artifact contract name and version must be nonempty and at most ${artifactLabelMaxLength} characters`);
10
+ return { name: options.name, version: options.version };
11
+ }
12
+ export const artifact = {
13
+ json(options) {
14
+ const schema = options.schema;
15
+ async function validate(value) {
16
+ if (typeof schema === "function")
17
+ return schema(value);
18
+ const result = await schema["~standard"].validate(value);
19
+ if (result.issues)
20
+ throw new Error(`Artifact schema validation failed: ${JSON.stringify(result.issues)}`);
21
+ return result.value;
22
+ }
23
+ return Object.freeze({
24
+ ...identity(options),
25
+ encoding: "json",
26
+ async encode(value) {
27
+ const checked = checkpointValue(await validate(value));
28
+ if (checked.kind !== "json")
29
+ throw new Error("Artifact payload must be JSON");
30
+ return Buffer.from(JSON.stringify(checked.value));
31
+ },
32
+ async decode(bytes) {
33
+ return validate(JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(bytes)));
34
+ },
35
+ });
36
+ },
37
+ binary(options) {
38
+ return Object.freeze({
39
+ ...identity(options),
40
+ encoding: "binary",
41
+ async encode(value) {
42
+ if (!(value instanceof Uint8Array))
43
+ throw new Error("Artifact payload must be Uint8Array");
44
+ return Uint8Array.from(value);
45
+ },
46
+ async decode(bytes) {
47
+ return Uint8Array.from(bytes);
48
+ },
49
+ });
50
+ },
51
+ };
52
+ export async function publishArtifact(store, contract, value, options) {
53
+ options.signal?.throwIfAborted();
54
+ const producer = { ...options.producer };
55
+ const parents = (options.parents ?? []).map((parent) => validateArtifactReference(parent).id);
56
+ const bytes = Uint8Array.from(await contract.encode(value));
57
+ options.signal?.throwIfAborted();
58
+ const metadata = {
59
+ format: 1,
60
+ digest: artifactDigest(bytes),
61
+ size: bytes.length,
62
+ contract: {
63
+ name: contract.name,
64
+ version: contract.version,
65
+ encoding: contract.encoding,
66
+ },
67
+ producer,
68
+ parents,
69
+ };
70
+ const reference = validateArtifactReference({
71
+ ...metadata,
72
+ id: artifactId(metadata),
73
+ });
74
+ await store.put(reference.id, bytes, options.signal);
75
+ options.signal?.throwIfAborted();
76
+ return reference;
77
+ }
78
+ export async function readStoredArtifact(store, contract, value, options = {}) {
79
+ options.signal?.throwIfAborted();
80
+ const reference = validateArtifactReference(value);
81
+ if (reference.contract.name !== contract.name ||
82
+ reference.contract.version !== contract.version ||
83
+ reference.contract.encoding !== contract.encoding)
84
+ throw new Error("Artifact contract mismatch");
85
+ const producer = options.producer;
86
+ if (producer &&
87
+ (reference.producer.executionId !== producer.executionId ||
88
+ reference.producer.taskKey !== producer.taskKey ||
89
+ reference.producer.attempt !== producer.attempt))
90
+ throw new Error("Artifact producer mismatch");
91
+ if (options.parents &&
92
+ JSON.stringify(reference.parents) !==
93
+ JSON.stringify(options.parents.map((parent) => validateArtifactReference(parent).id)))
94
+ throw new Error("Artifact lineage mismatch");
95
+ const bytes = await store.get(reference.id, options.signal);
96
+ options.signal?.throwIfAborted();
97
+ if (bytes.length !== reference.size ||
98
+ artifactDigest(bytes) !== reference.digest)
99
+ throw new Error("Artifact content integrity mismatch");
100
+ const result = await contract.decode(bytes);
101
+ options.signal?.throwIfAborted();
102
+ return result;
103
+ }
104
+ //# sourceMappingURL=artifact.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"artifact.js","sourceRoot":"","sources":["../../src/domain/artifact.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AACjE,OAAO,EACL,cAAc,EACd,UAAU,EACV,yBAAyB,GAC1B,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAWjE,SAAS,QAAQ,CAAC,OAAgC;IAChD,IACE,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,EAAE;QACpB,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,EAAE;QACvB,OAAO,CAAC,IAAI,CAAC,MAAM,GAAG,sBAAsB;QAC5C,OAAO,CAAC,OAAO,CAAC,MAAM,GAAG,sBAAsB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C,CAAC;IAChD,IACE,OAAO,CAAC,OAAO;QACf,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,OAAO,CAAC;YAC/B,IAAI,CAAC,SAAS,CACZ,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,yBAAyB,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CACtE;QAEH,MAAM,IAAI,KAAK,CAAC,2BAA2B,CAAC,CAAC;IAC/C,MAAM,KAAK,GAAG,MAAM,KAAK,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;IAC5D,OAAO,CAAC,MAAM,EAAE,cAAc,EAAE,CAAC;IACjC,IACE,KAAK,CAAC,MAAM,KAAK,SAAS,CAAC,IAAI;QAC/B,cAAc,CAAC,KAAK,CAAC,KAAK,SAAS,CAAC,MAAM;QAE1C,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAC;IACzD,MAAM,MAAM,GAAG,MAAM,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAC5C,OAAO,CAAC,MAAM,EAAE,cAAc,EAAE,CAAC;IACjC,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import { artifactLabelMaxLength } from \"./artifact.constants.ts\";\nimport {\n artifactDigest,\n artifactId,\n validateArtifactReference,\n} from \"./artifact-reference.ts\";\nimport { checkpointValue } from \"./workflow/checkpoint-value.ts\";\nimport type {\n ArtifactContract,\n ArtifactContractOptions,\n ArtifactReference,\n ArtifactStore,\n JsonArtifactOptions,\n PublishArtifactOptions,\n ReadArtifactOptions,\n} from \"./artifact.types.ts\";\n\nfunction identity(options: ArtifactContractOptions): ArtifactContractOptions {\n if (\n !options.name.trim() ||\n !options.version.trim() ||\n options.name.length > artifactLabelMaxLength ||\n options.version.length > artifactLabelMaxLength\n )\n throw new Error(\n `Artifact contract name and version must be nonempty and at most ${artifactLabelMaxLength} characters`,\n );\n return { name: options.name, version: options.version };\n}\n\nexport const artifact = {\n json<T>(options: JsonArtifactOptions<T>): ArtifactContract<T> {\n const schema = options.schema;\n async function validate(value: unknown): Promise<T> {\n if (typeof schema === \"function\") return schema(value);\n const result = await schema[\"~standard\"].validate(value);\n if (result.issues)\n throw new Error(\n `Artifact schema validation failed: ${JSON.stringify(result.issues)}`,\n );\n return result.value;\n }\n return Object.freeze({\n ...identity(options),\n encoding: \"json\",\n async encode(value: T) {\n const checked = checkpointValue(await validate(value));\n if (checked.kind !== \"json\")\n throw new Error(\"Artifact payload must be JSON\");\n return Buffer.from(JSON.stringify(checked.value));\n },\n async decode(bytes: Uint8Array) {\n return validate(\n JSON.parse(\n new TextDecoder(\"utf-8\", { fatal: true }).decode(bytes),\n ) as unknown,\n );\n },\n });\n },\n binary(options: ArtifactContractOptions): ArtifactContract<Uint8Array> {\n return Object.freeze({\n ...identity(options),\n encoding: \"binary\",\n async encode(value: Uint8Array) {\n if (!(value instanceof Uint8Array))\n throw new Error(\"Artifact payload must be Uint8Array\");\n return Uint8Array.from(value);\n },\n async decode(bytes: Uint8Array) {\n return Uint8Array.from(bytes);\n },\n });\n },\n};\n\nexport async function publishArtifact<T>(\n store: ArtifactStore,\n contract: ArtifactContract<T>,\n value: T,\n options: PublishArtifactOptions,\n): Promise<ArtifactReference> {\n options.signal?.throwIfAborted();\n const producer = { ...options.producer };\n const parents = (options.parents ?? []).map(\n (parent) => validateArtifactReference(parent).id,\n );\n const bytes = Uint8Array.from(await contract.encode(value));\n options.signal?.throwIfAborted();\n const metadata = {\n format: 1 as const,\n digest: artifactDigest(bytes),\n size: bytes.length,\n contract: {\n name: contract.name,\n version: contract.version,\n encoding: contract.encoding,\n },\n producer,\n parents,\n };\n const reference = validateArtifactReference({\n ...metadata,\n id: artifactId(metadata),\n });\n await store.put(reference.id, bytes, options.signal);\n options.signal?.throwIfAborted();\n return reference;\n}\n\nexport async function readStoredArtifact<T>(\n store: ArtifactStore,\n contract: ArtifactContract<T>,\n value: unknown,\n options: ReadArtifactOptions = {},\n): Promise<T> {\n options.signal?.throwIfAborted();\n const reference = validateArtifactReference(value);\n if (\n reference.contract.name !== contract.name ||\n reference.contract.version !== contract.version ||\n reference.contract.encoding !== contract.encoding\n )\n throw new Error(\"Artifact contract mismatch\");\n const producer = options.producer;\n if (\n producer &&\n (reference.producer.executionId !== producer.executionId ||\n reference.producer.taskKey !== producer.taskKey ||\n reference.producer.attempt !== producer.attempt)\n )\n throw new Error(\"Artifact producer mismatch\");\n if (\n options.parents &&\n JSON.stringify(reference.parents) !==\n JSON.stringify(\n options.parents.map((parent) => validateArtifactReference(parent).id),\n )\n )\n throw new Error(\"Artifact lineage mismatch\");\n const bytes = await store.get(reference.id, options.signal);\n options.signal?.throwIfAborted();\n if (\n bytes.length !== reference.size ||\n artifactDigest(bytes) !== reference.digest\n )\n throw new Error(\"Artifact content integrity mismatch\");\n const result = await contract.decode(bytes);\n options.signal?.throwIfAborted();\n return result;\n}\n"]}
@@ -0,0 +1,44 @@
1
+ import type { StandardValidator } from "./response.types.ts";
2
+ export interface ArtifactIdentity {
3
+ readonly name: string;
4
+ readonly version: string;
5
+ readonly encoding: "json" | "binary";
6
+ }
7
+ export interface ArtifactProducer {
8
+ readonly executionId: string;
9
+ readonly taskKey: string;
10
+ readonly attempt: number;
11
+ }
12
+ export interface ArtifactReference {
13
+ readonly format: 1;
14
+ readonly id: string;
15
+ readonly digest: string;
16
+ readonly size: number;
17
+ readonly contract: ArtifactIdentity;
18
+ readonly producer: ArtifactProducer;
19
+ readonly parents: readonly string[];
20
+ }
21
+ export interface ArtifactContract<T> extends ArtifactIdentity {
22
+ encode(value: T): Promise<Uint8Array>;
23
+ decode(bytes: Uint8Array): Promise<T>;
24
+ }
25
+ export type ArtifactContractOptions = Pick<ArtifactIdentity, "name" | "version">;
26
+ export type JsonArtifactOptions<T> = ArtifactContractOptions & {
27
+ readonly schema: StandardValidator<T> | ((input: unknown) => T | Promise<T>);
28
+ };
29
+ export interface ArtifactStore {
30
+ /** Publish atomically; reject conflicting bytes for an existing ID. */
31
+ put(id: string, bytes: Uint8Array, signal?: AbortSignal): Promise<void>;
32
+ /** Read bounded bytes or reject missing objects; callers verify integrity. */
33
+ get(id: string, signal?: AbortSignal): Promise<Uint8Array>;
34
+ }
35
+ export interface PublishArtifactOptions {
36
+ readonly producer: ArtifactProducer;
37
+ readonly parents?: readonly ArtifactReference[];
38
+ readonly signal?: AbortSignal;
39
+ }
40
+ export interface ReadArtifactOptions {
41
+ readonly producer?: ArtifactProducer;
42
+ readonly parents?: readonly ArtifactReference[];
43
+ readonly signal?: AbortSignal;
44
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=artifact.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"artifact.types.js","sourceRoot":"","sources":["../../src/domain/artifact.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { StandardValidator } from \"./response.types.ts\";\n\nexport interface ArtifactIdentity {\n readonly name: string;\n readonly version: string;\n readonly encoding: \"json\" | \"binary\";\n}\n\nexport interface ArtifactProducer {\n readonly executionId: string;\n readonly taskKey: string;\n readonly attempt: number;\n}\n\nexport interface ArtifactReference {\n readonly format: 1;\n readonly id: string;\n readonly digest: string;\n readonly size: number;\n readonly contract: ArtifactIdentity;\n readonly producer: ArtifactProducer;\n readonly parents: readonly string[];\n}\n\nexport interface ArtifactContract<T> extends ArtifactIdentity {\n encode(value: T): Promise<Uint8Array>;\n decode(bytes: Uint8Array): Promise<T>;\n}\n\nexport type ArtifactContractOptions = Pick<\n ArtifactIdentity,\n \"name\" | \"version\"\n>;\nexport type JsonArtifactOptions<T> = ArtifactContractOptions & {\n readonly schema: StandardValidator<T> | ((input: unknown) => T | Promise<T>);\n};\n\nexport interface ArtifactStore {\n /** Publish atomically; reject conflicting bytes for an existing ID. */\n put(id: string, bytes: Uint8Array, signal?: AbortSignal): Promise<void>;\n /** Read bounded bytes or reject missing objects; callers verify integrity. */\n get(id: string, signal?: AbortSignal): Promise<Uint8Array>;\n}\n\nexport interface PublishArtifactOptions {\n readonly producer: ArtifactProducer;\n readonly parents?: readonly ArtifactReference[];\n readonly signal?: AbortSignal;\n}\n\nexport interface ReadArtifactOptions {\n readonly producer?: ArtifactProducer;\n readonly parents?: readonly ArtifactReference[];\n readonly signal?: AbortSignal;\n}\n"]}
@@ -0,0 +1 @@
1
+ export declare const egressFields: readonly string[];
@@ -0,0 +1,7 @@
1
+ export const egressFields = [
2
+ "mode",
3
+ "domains",
4
+ "allowCidrs",
5
+ "denyCidrs",
6
+ ];
7
+ //# sourceMappingURL=egress.constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"egress.constants.js","sourceRoot":"","sources":["../../src/domain/egress.constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,YAAY,GAAsB;IAC7C,MAAM;IACN,SAAS;IACT,YAAY;IACZ,WAAW;CACZ,CAAC","sourcesContent":["export const egressFields: readonly string[] = [\n \"mode\",\n \"domains\",\n \"allowCidrs\",\n \"denyCidrs\",\n];\n"]}
@@ -0,0 +1,2 @@
1
+ import type { EgressPolicy } from "./egress.types.ts";
2
+ export declare function validateEgress(value: unknown): EgressPolicy | undefined;
@@ -0,0 +1,48 @@
1
+ import { isIP } from "node:net";
2
+ import { egressFields } from "./egress.constants.js";
3
+ import { invariant } from "./errors.js";
4
+ function entries(value, label, validate) {
5
+ if (value === undefined)
6
+ return [];
7
+ invariant(Array.isArray(value), `${label} must be an array`);
8
+ const items = Array.from(value);
9
+ invariant(items.every((entry) => typeof entry === "string" && validate(entry)), `Invalid ${label} entry`);
10
+ return [...new Set(items)];
11
+ }
12
+ function domain(value) {
13
+ const name = value.startsWith("*.") ? value.slice(2) : value;
14
+ return (name.length <= 253 &&
15
+ !isIP(name) &&
16
+ name.includes(".") &&
17
+ name
18
+ .split(".")
19
+ .every((label) => /^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$/i.test(label)));
20
+ }
21
+ function cidr(value) {
22
+ const parts = value.split("/");
23
+ if (parts.length !== 2)
24
+ return false;
25
+ const version = isIP(parts[0]);
26
+ return (version !== 0 &&
27
+ /^(0|[1-9][0-9]*)$/.test(parts[1]) &&
28
+ Number(parts[1]) <= (version === 4 ? 32 : 128) &&
29
+ !parts[0].includes("%"));
30
+ }
31
+ export function validateEgress(value) {
32
+ if (value === undefined)
33
+ return undefined;
34
+ invariant(value !== null && typeof value === "object" && !Array.isArray(value), "egress must be a policy object");
35
+ invariant("mode" in value, "egress requires a mode");
36
+ if (value.mode === "deny-all") {
37
+ invariant(Object.keys(value).every((key) => key === "mode"), "deny-all does not accept allowlist fields");
38
+ return { mode: "deny-all" };
39
+ }
40
+ invariant(value.mode === "allowlist", "egress mode must be deny-all or allowlist");
41
+ invariant(Object.keys(value).every((key) => egressFields.includes(key)), "Unknown egress policy field");
42
+ const domains = entries("domains" in value ? value.domains : undefined, "egress domains", domain);
43
+ const allowCidrs = entries("allowCidrs" in value ? value.allowCidrs : undefined, "egress allowCidrs", cidr);
44
+ const denyCidrs = entries("denyCidrs" in value ? value.denyCidrs : undefined, "egress denyCidrs", cidr);
45
+ invariant(domains.length + allowCidrs.length > 0, "egress allowlist requires an allowed domain or CIDR; use deny-all to block everything");
46
+ return { mode: "allowlist", domains, allowCidrs, denyCidrs };
47
+ }
48
+ //# sourceMappingURL=egress.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"egress.js","sourceRoot":"","sources":["../../src/domain/egress.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAChC,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAGxC,SAAS,OAAO,CACd,KAAc,EACd,KAAa,EACb,QAAoC;IAEpC,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,EAAE,CAAC;IACnC,SAAS,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC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AAI,CACL,CAAC;IACF,MAAM,SAAS,GAAG,OAAO,CACvB,WAAW,IAAI,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,EAClD,kBAAkB,EAClB,IAAI,CACL,CAAC;IACF,SAAS,CACP,OAAO,CAAC,MAAM,GAAG,UAAU,CAAC,MAAM,GAAG,CAAC,EACtC,uFAAuF,CACxF,CAAC;IACF,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,CAAC;AAC/D,CAAC","sourcesContent":["import { isIP } from \"node:net\";\nimport { egressFields } from \"./egress.constants.ts\";\nimport { invariant } from \"./errors.ts\";\nimport type { EgressPolicy } from \"./egress.types.ts\";\n\nfunction entries(\n value: unknown,\n label: string,\n validate: (entry: string) => boolean,\n): string[] {\n if (value === undefined) return [];\n invariant(Array.isArray(value), `${label} must be an array`);\n const items = Array.from(value);\n invariant(\n items.every((entry) => typeof entry === \"string\" && validate(entry)),\n `Invalid ${label} entry`,\n );\n return [...new Set<string>(items)];\n}\n\nfunction domain(value: string): boolean {\n const name = value.startsWith(\"*.\") ? value.slice(2) : value;\n return (\n name.length <= 253 &&\n !isIP(name) &&\n name.includes(\".\") &&\n name\n .split(\".\")\n .every((label) => /^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$/i.test(label))\n );\n}\n\nfunction cidr(value: string): boolean {\n const parts = value.split(\"/\");\n if (parts.length !== 2) return false;\n const version = isIP(parts[0]!);\n return (\n version !== 0 &&\n /^(0|[1-9][0-9]*)$/.test(parts[1]!) &&\n Number(parts[1]) <= (version === 4 ? 32 : 128) &&\n !parts[0]!.includes(\"%\")\n );\n}\n\nexport function validateEgress(value: unknown): EgressPolicy | undefined {\n if (value === undefined) return undefined;\n invariant(\n value !== null && typeof value === \"object\" && !Array.isArray(value),\n \"egress must be a policy object\",\n );\n invariant(\"mode\" in value, \"egress requires a mode\");\n if (value.mode === \"deny-all\") {\n invariant(\n Object.keys(value).every((key) => key === \"mode\"),\n \"deny-all does not accept allowlist fields\",\n );\n return { mode: \"deny-all\" };\n }\n invariant(\n value.mode === \"allowlist\",\n \"egress mode must be deny-all or allowlist\",\n );\n invariant(\n Object.keys(value).every((key) => egressFields.includes(key)),\n \"Unknown egress policy field\",\n );\n const domains = entries(\n \"domains\" in value ? value.domains : undefined,\n \"egress domains\",\n domain,\n );\n const allowCidrs = entries(\n \"allowCidrs\" in value ? value.allowCidrs : undefined,\n \"egress allowCidrs\",\n cidr,\n );\n const denyCidrs = entries(\n \"denyCidrs\" in value ? value.denyCidrs : undefined,\n \"egress denyCidrs\",\n cidr,\n );\n invariant(\n domains.length + allowCidrs.length > 0,\n \"egress allowlist requires an allowed domain or CIDR; use deny-all to block everything\",\n );\n return { mode: \"allowlist\", domains, allowCidrs, denyCidrs };\n}\n"]}
@@ -0,0 +1,8 @@
1
+ export type EgressPolicy = {
2
+ readonly mode: "deny-all";
3
+ } | {
4
+ readonly mode: "allowlist";
5
+ readonly domains?: readonly string[];
6
+ readonly allowCidrs?: readonly string[];
7
+ readonly denyCidrs?: readonly string[];
8
+ };
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=egress.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"egress.types.js","sourceRoot":"","sources":["../../src/domain/egress.types.ts"],"names":[],"mappings":"","sourcesContent":["export type EgressPolicy =\n | { readonly mode: \"deny-all\" }\n | {\n readonly mode: \"allowlist\";\n readonly domains?: readonly string[];\n readonly allowCidrs?: readonly string[];\n readonly denyCidrs?: readonly string[];\n };\n"]}
@@ -23,6 +23,7 @@ export interface FileManifestEntry {
23
23
  readonly sha256: string;
24
24
  }
25
25
  export interface FileTransfers {
26
+ uploadBatch?(source: string, entries: readonly FileManifestEntry[], destination: string, options?: TransferOptions): Promise<void>;
26
27
  manifest(source: string, paths: readonly string[], options?: TransferOptions): Promise<readonly FileManifestEntry[]>;
27
28
  downloadBatch(source: string, entries: readonly FileManifestEntry[], destination: string, options?: TransferOptions): Promise<void>;
28
29
  }
@@ -1 +1 @@
1
- {"version":3,"file":"sandbox.types.js","sourceRoot":"","sources":["../../src/domain/sandbox.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { Command, CommandResult, Variables } from \"./command.types.ts\";\n\nexport interface Volume {\n readonly source: string;\n readonly target: string;\n readonly readOnly?: boolean;\n}\n\nexport interface SandboxContext {\n readonly repository: string;\n readonly directory: string;\n readonly gitDirectories: readonly string[];\n readonly variables: Variables;\n readonly signal?: AbortSignal;\n}\n\nexport interface TransferOptions {\n readonly signal?: AbortSignal;\n readonly deadlineMs?: number;\n}\n\nexport interface FileManifestEntry {\n readonly path: string;\n readonly kind: \"file\" | \"link\";\n readonly mode: number;\n readonly size: number;\n readonly sha256: string;\n}\n\nexport interface FileTransfers {\n manifest(\n source: string,\n paths: readonly string[],\n options?: TransferOptions,\n ): Promise<readonly FileManifestEntry[]>;\n downloadBatch(\n source: string,\n entries: readonly FileManifestEntry[],\n destination: string,\n options?: TransferOptions,\n ): Promise<void>;\n}\n\nexport interface SandboxLease {\n readonly fileTransfers?: FileTransfers;\n readonly root: string;\n readonly home: string;\n invoke(command: Command): Promise<CommandResult>;\n upload(\n source: string,\n destination: string,\n options?: TransferOptions,\n ): Promise<void>;\n download(\n source: string,\n destination: string,\n options?: TransferOptions,\n ): Promise<void>;\n release(): Promise<void>;\n}\n\nexport interface SandboxProvider {\n readonly name: string;\n readonly placement: \"mounted\" | \"remote\" | \"host\";\n readonly variables?: Variables;\n acquire(context: SandboxContext): Promise<SandboxLease>;\n}\n"]}
1
+ {"version":3,"file":"sandbox.types.js","sourceRoot":"","sources":["../../src/domain/sandbox.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { Command, CommandResult, Variables } from \"./command.types.ts\";\n\nexport interface Volume {\n readonly source: string;\n readonly target: string;\n readonly readOnly?: boolean;\n}\n\nexport interface SandboxContext {\n readonly repository: string;\n readonly directory: string;\n readonly gitDirectories: readonly string[];\n readonly variables: Variables;\n readonly signal?: AbortSignal;\n}\n\nexport interface TransferOptions {\n readonly signal?: AbortSignal;\n readonly deadlineMs?: number;\n}\n\nexport interface FileManifestEntry {\n readonly path: string;\n readonly kind: \"file\" | \"link\";\n readonly mode: number;\n readonly size: number;\n readonly sha256: string;\n}\n\nexport interface FileTransfers {\n uploadBatch?(\n source: string,\n entries: readonly FileManifestEntry[],\n destination: string,\n options?: TransferOptions,\n ): Promise<void>;\n manifest(\n source: string,\n paths: readonly string[],\n options?: TransferOptions,\n ): Promise<readonly FileManifestEntry[]>;\n downloadBatch(\n source: string,\n entries: readonly FileManifestEntry[],\n destination: string,\n options?: TransferOptions,\n ): Promise<void>;\n}\n\nexport interface SandboxLease {\n readonly fileTransfers?: FileTransfers;\n readonly root: string;\n readonly home: string;\n invoke(command: Command): Promise<CommandResult>;\n upload(\n source: string,\n destination: string,\n options?: TransferOptions,\n ): Promise<void>;\n download(\n source: string,\n destination: string,\n options?: TransferOptions,\n ): Promise<void>;\n release(): Promise<void>;\n}\n\nexport interface SandboxProvider {\n readonly name: string;\n readonly placement: \"mounted\" | \"remote\" | \"host\";\n readonly variables?: Variables;\n acquire(context: SandboxContext): Promise<SandboxLease>;\n}\n"]}
@@ -0,0 +1,8 @@
1
+ export declare const queueMaxBytes = 1048576;
2
+ export declare const queueMaxValueBytes = 262144;
3
+ export declare const queueDefaultLeaseMs = 30000;
4
+ export declare const queueDefaultPollMs = 250;
5
+ export declare const queueMaxLeaseMs = 300000;
6
+ export declare const queueMaxStringLength = 512;
7
+ export declare const queueMinLeaseMs = 30;
8
+ export declare const queueMaxHandlers = 100;
@@ -0,0 +1,9 @@
1
+ export const queueMaxBytes = 1_048_576;
2
+ export const queueMaxValueBytes = 262_144;
3
+ export const queueDefaultLeaseMs = 30_000;
4
+ export const queueDefaultPollMs = 250;
5
+ export const queueMaxLeaseMs = 300_000;
6
+ export const queueMaxStringLength = 512;
7
+ export const queueMinLeaseMs = 30;
8
+ export const queueMaxHandlers = 100;
9
+ //# sourceMappingURL=task-queue.constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"task-queue.constants.js","sourceRoot":"","sources":["../../src/domain/task-queue.constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,aAAa,GAAG,SAAS,CAAC;AACvC,MAAM,CAAC,MAAM,kBAAkB,GAAG,OAAO,CAAC;AAC1C,MAAM,CAAC,MAAM,mBAAmB,GAAG,MAAM,CAAC;AAC1C,MAAM,CAAC,MAAM,kBAAkB,GAAG,GAAG,CAAC;AACtC,MAAM,CAAC,MAAM,eAAe,GAAG,OAAO,CAAC;AACvC,MAAM,CAAC,MAAM,oBAAoB,GAAG,GAAG,CAAC;AACxC,MAAM,CAAC,MAAM,eAAe,GAAG,EAAE,CAAC;AAClC,MAAM,CAAC,MAAM,gBAAgB,GAAG,GAAG,CAAC","sourcesContent":["export const queueMaxBytes = 1_048_576;\nexport const queueMaxValueBytes = 262_144;\nexport const queueDefaultLeaseMs = 30_000;\nexport const queueDefaultPollMs = 250;\nexport const queueMaxLeaseMs = 300_000;\nexport const queueMaxStringLength = 512;\nexport const queueMinLeaseMs = 30;\nexport const queueMaxHandlers = 100;\n"]}
@@ -0,0 +1,11 @@
1
+ import type { QueueClaim, QueueJob, QueueLease, QueueRequest, QueueResult } from "./task-queue.types.ts";
2
+ export declare function queueObject(value: unknown): Record<string, unknown>;
3
+ export declare function queueString(value: unknown): string;
4
+ export declare function queueNumber(value: unknown): number;
5
+ export declare function queueLeaseMs(value: unknown): number;
6
+ export declare function queueJson(value: unknown): import("./workflow/checkpoint.types.ts").WorkflowJson;
7
+ export declare function queueRequest(value: unknown): QueueRequest;
8
+ export declare function queueClaim(value: unknown): QueueClaim;
9
+ export declare function queueLease(value: unknown): QueueLease;
10
+ export declare function queueResult(value: unknown): QueueResult;
11
+ export declare function queueJob(value: unknown): QueueJob;
@@ -0,0 +1,105 @@
1
+ import { queueMaxValueBytes, queueMaxLeaseMs, queueMaxStringLength, queueMinLeaseMs, queueMaxHandlers, } from "./task-queue.constants.js";
2
+ import { checkpointValue } from "./workflow/checkpoint-value.js";
3
+ export function queueObject(value) {
4
+ if (!value || typeof value !== "object" || Array.isArray(value))
5
+ throw new Error("Invalid queue object");
6
+ return Object.fromEntries(Object.entries(value));
7
+ }
8
+ export function queueString(value) {
9
+ if (typeof value !== "string" ||
10
+ !value.length ||
11
+ value.length > queueMaxStringLength)
12
+ throw new Error("Invalid queue identifier");
13
+ return value;
14
+ }
15
+ export function queueNumber(value) {
16
+ if (typeof value !== "number" || !Number.isSafeInteger(value) || value < 0)
17
+ throw new Error("Invalid queue number");
18
+ return value;
19
+ }
20
+ export function queueLeaseMs(value) {
21
+ const ms = queueNumber(value);
22
+ if (ms < queueMinLeaseMs || ms > queueMaxLeaseMs)
23
+ throw new Error("Queue lease must be between 30 and 300000 milliseconds");
24
+ return ms;
25
+ }
26
+ export function queueJson(value) {
27
+ const checked = checkpointValue(value);
28
+ if (checked.kind !== "json")
29
+ throw new Error("Queue values must be JSON");
30
+ if (Buffer.byteLength(JSON.stringify(checked.value)) > queueMaxValueBytes)
31
+ throw new Error("Queue value exceeds size limit");
32
+ return checked.value;
33
+ }
34
+ export function queueRequest(value) {
35
+ const data = queueObject(value);
36
+ return {
37
+ id: queueString(data.id),
38
+ handler: queueString(data.handler),
39
+ input: queueJson(data.input),
40
+ ...(data.deadline === undefined
41
+ ? {}
42
+ : { deadline: queueNumber(data.deadline) }),
43
+ };
44
+ }
45
+ export function queueClaim(value) {
46
+ const data = queueObject(value);
47
+ if (!Array.isArray(data.handlers) ||
48
+ !data.handlers.length ||
49
+ data.handlers.length > queueMaxHandlers)
50
+ throw new Error("Invalid queue handlers");
51
+ return {
52
+ worker: queueString(data.worker),
53
+ handlers: data.handlers.map(queueString),
54
+ leaseMs: queueLeaseMs(data.leaseMs),
55
+ };
56
+ }
57
+ export function queueLease(value) {
58
+ const data = queueObject(value);
59
+ return {
60
+ id: queueString(data.id),
61
+ worker: queueString(data.worker),
62
+ fence: queueNumber(data.fence),
63
+ };
64
+ }
65
+ export function queueResult(value) {
66
+ const data = queueObject(value);
67
+ const usage = data.usage === undefined ? undefined : queueObject(data.usage);
68
+ return {
69
+ value: queueJson(data.value),
70
+ ...(data.error === undefined ? {} : { error: queueString(data.error) }),
71
+ ...(usage === undefined
72
+ ? {}
73
+ : {
74
+ usage: {
75
+ input: queueNumber(usage.input),
76
+ output: queueNumber(usage.output),
77
+ cached: queueNumber(usage.cached),
78
+ ...(usage.cacheCreated === undefined
79
+ ? {}
80
+ : { cacheCreated: queueNumber(usage.cacheCreated) }),
81
+ },
82
+ }),
83
+ };
84
+ }
85
+ export function queueJob(value) {
86
+ const data = queueObject(value);
87
+ const status = data.status;
88
+ if (status !== "pending" &&
89
+ status !== "active" &&
90
+ status !== "done" &&
91
+ status !== "failed" &&
92
+ status !== "cancelled")
93
+ throw new Error("Invalid queue status");
94
+ return {
95
+ ...queueRequest(data),
96
+ status,
97
+ fence: queueNumber(data.fence),
98
+ ...(data.worker === undefined ? {} : { worker: queueString(data.worker) }),
99
+ ...(data.expires === undefined
100
+ ? {}
101
+ : { expires: queueNumber(data.expires) }),
102
+ ...(data.result === undefined ? {} : { result: queueResult(data.result) }),
103
+ };
104
+ }
105
+ //# sourceMappingURL=task-queue.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"task-queue.js","sourceRoot":"","sources":["../../src/domain/task-queue.ts"],"names":[],"mappings":"AAOA,OAAO,EACL,kBAAkB,EAClB,eAAe,EACf,oBAAoB,EACpB,eAAe,EACf,gBAAgB,GACjB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAEjE,MAAM,UAAU,WAAW,CAAC,KAAc;IACxC,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QAC7D,MAAM,IAAI,KAAK,CAAC,sBAA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AAG,YAAY,CAAC,IAAI,CAAC;QACrB,MAAM;QACN,KAAK,EAAE,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC;QAC9B,GAAG,CAAC,IAAI,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;QAC1E,GAAG,CAAC,IAAI,CAAC,OAAO,KAAK,SAAS;YAC5B,CAAC,CAAC,EAAE;YACJ,CAAC,CAAC,EAAE,OAAO,EAAE,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;QAC3C,GAAG,CAAC,IAAI,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;KAC3E,CAAC;AACJ,CAAC","sourcesContent":["import type {\n QueueClaim,\n QueueJob,\n QueueLease,\n QueueRequest,\n QueueResult,\n} from \"./task-queue.types.ts\";\nimport {\n queueMaxValueBytes,\n queueMaxLeaseMs,\n queueMaxStringLength,\n queueMinLeaseMs,\n queueMaxHandlers,\n} from \"./task-queue.constants.ts\";\nimport { checkpointValue } from \"./workflow/checkpoint-value.ts\";\n\nexport function queueObject(value: unknown): Record<string, unknown> {\n if (!value || typeof value !== \"object\" || Array.isArray(value))\n throw new Error(\"Invalid queue object\");\n return Object.fromEntries(Object.entries(value));\n}\nexport function queueString(value: unknown): string {\n if (\n typeof value !== \"string\" ||\n !value.length ||\n value.length > queueMaxStringLength\n )\n throw new Error(\"Invalid queue identifier\");\n return value;\n}\nexport function queueNumber(value: unknown): number {\n if (typeof value !== \"number\" || !Number.isSafeInteger(value) || value < 0)\n throw new Error(\"Invalid queue number\");\n return value;\n}\nexport function queueLeaseMs(value: unknown): number {\n const ms = queueNumber(value);\n if (ms < queueMinLeaseMs || ms > queueMaxLeaseMs)\n throw new Error(\"Queue lease must be between 30 and 300000 milliseconds\");\n return ms;\n}\nexport function queueJson(value: unknown) {\n const checked = checkpointValue(value);\n if (checked.kind !== \"json\") throw new Error(\"Queue values must be JSON\");\n if (Buffer.byteLength(JSON.stringify(checked.value)) > queueMaxValueBytes)\n throw new Error(\"Queue value exceeds size limit\");\n return checked.value;\n}\nexport function queueRequest(value: unknown): QueueRequest {\n const data = queueObject(value);\n return {\n id: queueString(data.id),\n handler: queueString(data.handler),\n input: queueJson(data.input),\n ...(data.deadline === undefined\n ? {}\n : { deadline: queueNumber(data.deadline) }),\n };\n}\nexport function queueClaim(value: unknown): QueueClaim {\n const data = queueObject(value);\n if (\n !Array.isArray(data.handlers) ||\n !data.handlers.length ||\n data.handlers.length > queueMaxHandlers\n )\n throw new Error(\"Invalid queue handlers\");\n return {\n worker: queueString(data.worker),\n handlers: data.handlers.map(queueString),\n leaseMs: queueLeaseMs(data.leaseMs),\n };\n}\nexport function queueLease(value: unknown): QueueLease {\n const data = queueObject(value);\n return {\n id: queueString(data.id),\n worker: queueString(data.worker),\n fence: queueNumber(data.fence),\n };\n}\nexport function queueResult(value: unknown): QueueResult {\n const data = queueObject(value);\n const usage = data.usage === undefined ? undefined : queueObject(data.usage);\n return {\n value: queueJson(data.value),\n ...(data.error === undefined ? {} : { error: queueString(data.error) }),\n ...(usage === undefined\n ? {}\n : {\n usage: {\n input: queueNumber(usage.input),\n output: queueNumber(usage.output),\n cached: queueNumber(usage.cached),\n ...(usage.cacheCreated === undefined\n ? {}\n : { cacheCreated: queueNumber(usage.cacheCreated) }),\n },\n }),\n };\n}\nexport function queueJob(value: unknown): QueueJob {\n const data = queueObject(value);\n const status = data.status;\n if (\n status !== \"pending\" &&\n status !== \"active\" &&\n status !== \"done\" &&\n status !== \"failed\" &&\n status !== \"cancelled\"\n )\n throw new Error(\"Invalid queue status\");\n return {\n ...queueRequest(data),\n status,\n fence: queueNumber(data.fence),\n ...(data.worker === undefined ? {} : { worker: queueString(data.worker) }),\n ...(data.expires === undefined\n ? {}\n : { expires: queueNumber(data.expires) }),\n ...(data.result === undefined ? {} : { result: queueResult(data.result) }),\n };\n}\n"]}