@shipfox/api-workflows 2.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 (661) hide show
  1. package/.turbo/turbo-build.log +2 -0
  2. package/.turbo/turbo-type$colon$emit.log +1 -0
  3. package/.turbo/turbo-type.log +1 -0
  4. package/CHANGELOG.md +311 -0
  5. package/LICENSE +21 -0
  6. package/dist/core/agent-tool-capability-warning.d.ts +7 -0
  7. package/dist/core/agent-tool-capability-warning.d.ts.map +1 -0
  8. package/dist/core/agent-tool-capability-warning.js +149 -0
  9. package/dist/core/agent-tool-capability-warning.js.map +1 -0
  10. package/dist/core/agent-tools.d.ts +51 -0
  11. package/dist/core/agent-tools.d.ts.map +1 -0
  12. package/dist/core/agent-tools.js +296 -0
  13. package/dist/core/agent-tools.js.map +1 -0
  14. package/dist/core/checkout.d.ts +29 -0
  15. package/dist/core/checkout.d.ts.map +1 -0
  16. package/dist/core/checkout.js +42 -0
  17. package/dist/core/checkout.js.map +1 -0
  18. package/dist/core/condition-trace.d.ts +13 -0
  19. package/dist/core/condition-trace.d.ts.map +1 -0
  20. package/dist/core/condition-trace.js +51 -0
  21. package/dist/core/condition-trace.js.map +1 -0
  22. package/dist/core/entities/index.d.ts +5 -0
  23. package/dist/core/entities/index.d.ts.map +1 -0
  24. package/dist/core/entities/index.js +3 -0
  25. package/dist/core/entities/index.js.map +1 -0
  26. package/dist/core/entities/job-execution.d.ts +30 -0
  27. package/dist/core/entities/job-execution.d.ts.map +1 -0
  28. package/dist/core/entities/job-execution.js +3 -0
  29. package/dist/core/entities/job-execution.js.map +1 -0
  30. package/dist/core/entities/job-listener-event.d.ts +15 -0
  31. package/dist/core/entities/job-listener-event.d.ts.map +1 -0
  32. package/dist/core/entities/job-listener-event.js +3 -0
  33. package/dist/core/entities/job-listener-event.js.map +1 -0
  34. package/dist/core/entities/job.d.ts +54 -0
  35. package/dist/core/entities/job.d.ts.map +1 -0
  36. package/dist/core/entities/job.js +29 -0
  37. package/dist/core/entities/job.js.map +1 -0
  38. package/dist/core/entities/step.d.ts +86 -0
  39. package/dist/core/entities/step.d.ts.map +1 -0
  40. package/dist/core/entities/step.js +12 -0
  41. package/dist/core/entities/step.js.map +1 -0
  42. package/dist/core/entities/workflow-run-attempt.d.ts +20 -0
  43. package/dist/core/entities/workflow-run-attempt.d.ts.map +1 -0
  44. package/dist/core/entities/workflow-run-attempt.js +3 -0
  45. package/dist/core/entities/workflow-run-attempt.js.map +1 -0
  46. package/dist/core/entities/workflow-run.d.ts +66 -0
  47. package/dist/core/entities/workflow-run.d.ts.map +1 -0
  48. package/dist/core/entities/workflow-run.js +10 -0
  49. package/dist/core/entities/workflow-run.js.map +1 -0
  50. package/dist/core/errors.d.ts +85 -0
  51. package/dist/core/errors.d.ts.map +1 -0
  52. package/dist/core/errors.js +134 -0
  53. package/dist/core/errors.js.map +1 -0
  54. package/dist/core/index.d.ts +14 -0
  55. package/dist/core/index.d.ts.map +1 -0
  56. package/dist/core/index.js +9 -0
  57. package/dist/core/index.js.map +1 -0
  58. package/dist/core/job-execution-outcome.d.ts +29 -0
  59. package/dist/core/job-execution-outcome.d.ts.map +1 -0
  60. package/dist/core/job-execution-outcome.js +31 -0
  61. package/dist/core/job-execution-outcome.js.map +1 -0
  62. package/dist/core/job-execution.d.ts +37 -0
  63. package/dist/core/job-execution.d.ts.map +1 -0
  64. package/dist/core/job-execution.js +425 -0
  65. package/dist/core/job-execution.js.map +1 -0
  66. package/dist/core/job-transition/decide-job-activation.d.ts +29 -0
  67. package/dist/core/job-transition/decide-job-activation.d.ts.map +1 -0
  68. package/dist/core/job-transition/decide-job-activation.js +51 -0
  69. package/dist/core/job-transition/decide-job-activation.js.map +1 -0
  70. package/dist/core/job-transition/derive-job-execution-outputs.d.ts +18 -0
  71. package/dist/core/job-transition/derive-job-execution-outputs.d.ts.map +1 -0
  72. package/dist/core/job-transition/derive-job-execution-outputs.js +23 -0
  73. package/dist/core/job-transition/derive-job-execution-outputs.js.map +1 -0
  74. package/dist/core/job-transition/derive-job-success.d.ts +16 -0
  75. package/dist/core/job-transition/derive-job-success.d.ts.map +1 -0
  76. package/dist/core/job-transition/derive-job-success.js +47 -0
  77. package/dist/core/job-transition/derive-job-success.js.map +1 -0
  78. package/dist/core/job-transition/index.d.ts +5 -0
  79. package/dist/core/job-transition/index.d.ts.map +1 -0
  80. package/dist/core/job-transition/index.js +6 -0
  81. package/dist/core/job-transition/index.js.map +1 -0
  82. package/dist/core/job-transition/runtime-completion-status-for-job.d.ts +4 -0
  83. package/dist/core/job-transition/runtime-completion-status-for-job.d.ts.map +1 -0
  84. package/dist/core/job-transition/runtime-completion-status-for-job.js +8 -0
  85. package/dist/core/job-transition/runtime-completion-status-for-job.js.map +1 -0
  86. package/dist/core/listener-execution-materialization.d.ts +30 -0
  87. package/dist/core/listener-execution-materialization.d.ts.map +1 -0
  88. package/dist/core/listener-execution-materialization.js +87 -0
  89. package/dist/core/listener-execution-materialization.js.map +1 -0
  90. package/dist/core/run-workflow.d.ts +11 -0
  91. package/dist/core/run-workflow.d.ts.map +1 -0
  92. package/dist/core/run-workflow.js +28 -0
  93. package/dist/core/run-workflow.js.map +1 -0
  94. package/dist/core/source-control.d.ts +5 -0
  95. package/dist/core/source-control.d.ts.map +1 -0
  96. package/dist/core/source-control.js +19 -0
  97. package/dist/core/source-control.js.map +1 -0
  98. package/dist/core/step-config/agent.d.ts +49 -0
  99. package/dist/core/step-config/agent.d.ts.map +1 -0
  100. package/dist/core/step-config/agent.js +337 -0
  101. package/dist/core/step-config/agent.js.map +1 -0
  102. package/dist/core/step-config/assemble-run-context.d.ts +94 -0
  103. package/dist/core/step-config/assemble-run-context.d.ts.map +1 -0
  104. package/dist/core/step-config/assemble-run-context.js +393 -0
  105. package/dist/core/step-config/assemble-run-context.js.map +1 -0
  106. package/dist/core/step-config/complete-step-dispatch-config.d.ts +13 -0
  107. package/dist/core/step-config/complete-step-dispatch-config.d.ts.map +1 -0
  108. package/dist/core/step-config/complete-step-dispatch-config.js +38 -0
  109. package/dist/core/step-config/complete-step-dispatch-config.js.map +1 -0
  110. package/dist/core/step-config/fields.d.ts +38 -0
  111. package/dist/core/step-config/fields.d.ts.map +1 -0
  112. package/dist/core/step-config/fields.js +72 -0
  113. package/dist/core/step-config/fields.js.map +1 -0
  114. package/dist/core/step-config/index.d.ts +8 -0
  115. package/dist/core/step-config/index.d.ts.map +1 -0
  116. package/dist/core/step-config/index.js +7 -0
  117. package/dist/core/step-config/index.js.map +1 -0
  118. package/dist/core/step-config/materialize-job-execution-steps.d.ts +35 -0
  119. package/dist/core/step-config/materialize-job-execution-steps.d.ts.map +1 -0
  120. package/dist/core/step-config/materialize-job-execution-steps.js +92 -0
  121. package/dist/core/step-config/materialize-job-execution-steps.js.map +1 -0
  122. package/dist/core/step-config/materialize-workflow-model.d.ts +42 -0
  123. package/dist/core/step-config/materialize-workflow-model.d.ts.map +1 -0
  124. package/dist/core/step-config/materialize-workflow-model.js +96 -0
  125. package/dist/core/step-config/materialize-workflow-model.js.map +1 -0
  126. package/dist/core/step-config/resolve-job-execution-name.d.ts +18 -0
  127. package/dist/core/step-config/resolve-job-execution-name.d.ts.map +1 -0
  128. package/dist/core/step-config/resolve-job-execution-name.js +36 -0
  129. package/dist/core/step-config/resolve-job-execution-name.js.map +1 -0
  130. package/dist/core/step-config/resolve-step-config.d.ts +33 -0
  131. package/dist/core/step-config/resolve-step-config.d.ts.map +1 -0
  132. package/dist/core/step-config/resolve-step-config.js +164 -0
  133. package/dist/core/step-config/resolve-step-config.js.map +1 -0
  134. package/dist/core/step-config/run.d.ts +39 -0
  135. package/dist/core/step-config/run.d.ts.map +1 -0
  136. package/dist/core/step-config/run.js +360 -0
  137. package/dist/core/step-config/run.js.map +1 -0
  138. package/dist/core/step-config/workflow-evaluation-context.d.ts +6 -0
  139. package/dist/core/step-config/workflow-evaluation-context.d.ts.map +1 -0
  140. package/dist/core/step-config/workflow-evaluation-context.js +3 -0
  141. package/dist/core/step-config/workflow-evaluation-context.js.map +1 -0
  142. package/dist/core/step-transition/apply-step-transition.d.ts +26 -0
  143. package/dist/core/step-transition/apply-step-transition.d.ts.map +1 -0
  144. package/dist/core/step-transition/apply-step-transition.js +141 -0
  145. package/dist/core/step-transition/apply-step-transition.js.map +1 -0
  146. package/dist/core/step-transition/decide-step-transition.d.ts +71 -0
  147. package/dist/core/step-transition/decide-step-transition.d.ts.map +1 -0
  148. package/dist/core/step-transition/decide-step-transition.js +110 -0
  149. package/dist/core/step-transition/decide-step-transition.js.map +1 -0
  150. package/dist/core/step-transition/evaluate-gate.d.ts +28 -0
  151. package/dist/core/step-transition/evaluate-gate.d.ts.map +1 -0
  152. package/dist/core/step-transition/evaluate-gate.js +159 -0
  153. package/dist/core/step-transition/evaluate-gate.js.map +1 -0
  154. package/dist/core/step-transition/read-step-outputs.d.ts +3 -0
  155. package/dist/core/step-transition/read-step-outputs.d.ts.map +1 -0
  156. package/dist/core/step-transition/read-step-outputs.js +24 -0
  157. package/dist/core/step-transition/read-step-outputs.js.map +1 -0
  158. package/dist/core/workflow-run-creation.d.ts +43 -0
  159. package/dist/core/workflow-run-creation.d.ts.map +1 -0
  160. package/dist/core/workflow-run-creation.js +80 -0
  161. package/dist/core/workflow-run-creation.js.map +1 -0
  162. package/dist/core/workflow-scheduling/index.d.ts +5 -0
  163. package/dist/core/workflow-scheduling/index.d.ts.map +1 -0
  164. package/dist/core/workflow-scheduling/index.js +4 -0
  165. package/dist/core/workflow-scheduling/index.js.map +1 -0
  166. package/dist/core/workflow-scheduling/run-progress.d.ts +20 -0
  167. package/dist/core/workflow-scheduling/run-progress.d.ts.map +1 -0
  168. package/dist/core/workflow-scheduling/run-progress.js +40 -0
  169. package/dist/core/workflow-scheduling/run-progress.js.map +1 -0
  170. package/dist/core/workflow-scheduling/runtime-dag.d.ts +10 -0
  171. package/dist/core/workflow-scheduling/runtime-dag.d.ts.map +1 -0
  172. package/dist/core/workflow-scheduling/runtime-dag.js +3 -0
  173. package/dist/core/workflow-scheduling/runtime-dag.js.map +1 -0
  174. package/dist/core/workflow-scheduling/runtime-scheduling-command.d.ts +16 -0
  175. package/dist/core/workflow-scheduling/runtime-scheduling-command.d.ts.map +1 -0
  176. package/dist/core/workflow-scheduling/runtime-scheduling-command.js +3 -0
  177. package/dist/core/workflow-scheduling/runtime-scheduling-command.js.map +1 -0
  178. package/dist/core/workflow-scheduling/schedule-runtime-dag.d.ts +9 -0
  179. package/dist/core/workflow-scheduling/schedule-runtime-dag.d.ts.map +1 -0
  180. package/dist/core/workflow-scheduling/schedule-runtime-dag.js +72 -0
  181. package/dist/core/workflow-scheduling/schedule-runtime-dag.js.map +1 -0
  182. package/dist/db/db.d.ts +4959 -0
  183. package/dist/db/db.d.ts.map +1 -0
  184. package/dist/db/db.js +37 -0
  185. package/dist/db/db.js.map +1 -0
  186. package/dist/db/index.d.ts +9 -0
  187. package/dist/db/index.d.ts.map +1 -0
  188. package/dist/db/index.js +10 -0
  189. package/dist/db/index.js.map +1 -0
  190. package/dist/db/job-listener-events.d.ts +18 -0
  191. package/dist/db/job-listener-events.d.ts.map +1 -0
  192. package/dist/db/job-listener-events.js +59 -0
  193. package/dist/db/job-listener-events.js.map +1 -0
  194. package/dist/db/job-listeners.d.ts +55 -0
  195. package/dist/db/job-listeners.d.ts.map +1 -0
  196. package/dist/db/job-listeners.js +358 -0
  197. package/dist/db/job-listeners.js.map +1 -0
  198. package/dist/db/outbox-writes.d.ts +12 -0
  199. package/dist/db/outbox-writes.d.ts.map +1 -0
  200. package/dist/db/outbox-writes.js +20 -0
  201. package/dist/db/outbox-writes.js.map +1 -0
  202. package/dist/db/runner-lease-table.d.ts +469 -0
  203. package/dist/db/runner-lease-table.d.ts.map +1 -0
  204. package/dist/db/runner-lease-table.js +42 -0
  205. package/dist/db/runner-lease-table.js.map +1 -0
  206. package/dist/db/schema/common.d.ts +2 -0
  207. package/dist/db/schema/common.d.ts.map +1 -0
  208. package/dist/db/schema/common.js +4 -0
  209. package/dist/db/schema/common.js.map +1 -0
  210. package/dist/db/schema/job-executions.d.ts +311 -0
  211. package/dist/db/schema/job-executions.d.ts.map +1 -0
  212. package/dist/db/schema/job-executions.js +76 -0
  213. package/dist/db/schema/job-executions.js.map +1 -0
  214. package/dist/db/schema/job-listener-events.d.ts +200 -0
  215. package/dist/db/schema/job-listener-events.d.ts.map +1 -0
  216. package/dist/db/schema/job-listener-events.js +50 -0
  217. package/dist/db/schema/job-listener-events.js.map +1 -0
  218. package/dist/db/schema/jobs.d.ts +542 -0
  219. package/dist/db/schema/jobs.d.ts.map +1 -0
  220. package/dist/db/schema/jobs.js +121 -0
  221. package/dist/db/schema/jobs.js.map +1 -0
  222. package/dist/db/schema/outbox.d.ts +195 -0
  223. package/dist/db/schema/outbox.d.ts.map +1 -0
  224. package/dist/db/schema/outbox.js +5 -0
  225. package/dist/db/schema/outbox.js.map +1 -0
  226. package/dist/db/schema/step-attempts.d.ts +330 -0
  227. package/dist/db/schema/step-attempts.d.ts.map +1 -0
  228. package/dist/db/schema/step-attempts.js +80 -0
  229. package/dist/db/schema/step-attempts.js.map +1 -0
  230. package/dist/db/schema/steps.d.ts +352 -0
  231. package/dist/db/schema/steps.d.ts.map +1 -0
  232. package/dist/db/schema/steps.js +80 -0
  233. package/dist/db/schema/steps.js.map +1 -0
  234. package/dist/db/schema/workflow-run-attempts.d.ts +239 -0
  235. package/dist/db/schema/workflow-run-attempts.d.ts.map +1 -0
  236. package/dist/db/schema/workflow-run-attempts.js +53 -0
  237. package/dist/db/schema/workflow-run-attempts.js.map +1 -0
  238. package/dist/db/schema/workflow-runs.d.ts +360 -0
  239. package/dist/db/schema/workflow-runs.d.ts.map +1 -0
  240. package/dist/db/schema/workflow-runs.js +85 -0
  241. package/dist/db/schema/workflow-runs.js.map +1 -0
  242. package/dist/db/workflow-runs/job-executions.d.ts +49 -0
  243. package/dist/db/workflow-runs/job-executions.d.ts.map +1 -0
  244. package/dist/db/workflow-runs/job-executions.js +271 -0
  245. package/dist/db/workflow-runs/job-executions.js.map +1 -0
  246. package/dist/db/workflow-runs/jobs.d.ts +60 -0
  247. package/dist/db/workflow-runs/jobs.d.ts.map +1 -0
  248. package/dist/db/workflow-runs/jobs.js +288 -0
  249. package/dist/db/workflow-runs/jobs.js.map +1 -0
  250. package/dist/db/workflow-runs/outbox.d.ts +20 -0
  251. package/dist/db/workflow-runs/outbox.d.ts.map +1 -0
  252. package/dist/db/workflow-runs/outbox.js +68 -0
  253. package/dist/db/workflow-runs/outbox.js.map +1 -0
  254. package/dist/db/workflow-runs/queries.d.ts +71 -0
  255. package/dist/db/workflow-runs/queries.d.ts.map +1 -0
  256. package/dist/db/workflow-runs/queries.js +253 -0
  257. package/dist/db/workflow-runs/queries.js.map +1 -0
  258. package/dist/db/workflow-runs/run-create.d.ts +32 -0
  259. package/dist/db/workflow-runs/run-create.d.ts.map +1 -0
  260. package/dist/db/workflow-runs/run-create.js +288 -0
  261. package/dist/db/workflow-runs/run-create.js.map +1 -0
  262. package/dist/db/workflow-runs/run-graph.d.ts +27 -0
  263. package/dist/db/workflow-runs/run-graph.d.ts.map +1 -0
  264. package/dist/db/workflow-runs/run-graph.js +63 -0
  265. package/dist/db/workflow-runs/run-graph.js.map +1 -0
  266. package/dist/db/workflow-runs/run-rerun.d.ts +8 -0
  267. package/dist/db/workflow-runs/run-rerun.d.ts.map +1 -0
  268. package/dist/db/workflow-runs/run-rerun.js +207 -0
  269. package/dist/db/workflow-runs/run-rerun.js.map +1 -0
  270. package/dist/db/workflow-runs/run-status.d.ts +24 -0
  271. package/dist/db/workflow-runs/run-status.d.ts.map +1 -0
  272. package/dist/db/workflow-runs/run-status.js +249 -0
  273. package/dist/db/workflow-runs/run-status.js.map +1 -0
  274. package/dist/db/workflow-runs/runs.d.ts +7 -0
  275. package/dist/db/workflow-runs/runs.d.ts.map +1 -0
  276. package/dist/db/workflow-runs/runs.js +5 -0
  277. package/dist/db/workflow-runs/runs.js.map +1 -0
  278. package/dist/db/workflow-runs/shared.d.ts +24 -0
  279. package/dist/db/workflow-runs/shared.d.ts.map +1 -0
  280. package/dist/db/workflow-runs/shared.js +50 -0
  281. package/dist/db/workflow-runs/shared.js.map +1 -0
  282. package/dist/db/workflow-runs/steps.d.ts +83 -0
  283. package/dist/db/workflow-runs/steps.d.ts.map +1 -0
  284. package/dist/db/workflow-runs/steps.js +246 -0
  285. package/dist/db/workflow-runs/steps.js.map +1 -0
  286. package/dist/db/workflow-runs.d.ts +12 -0
  287. package/dist/db/workflow-runs.d.ts.map +1 -0
  288. package/dist/db/workflow-runs.js +8 -0
  289. package/dist/db/workflow-runs.js.map +1 -0
  290. package/dist/index.d.ts +10 -0
  291. package/dist/index.d.ts.map +1 -0
  292. package/dist/index.js +54 -0
  293. package/dist/index.js.map +1 -0
  294. package/dist/metrics/index.d.ts +2 -0
  295. package/dist/metrics/index.d.ts.map +1 -0
  296. package/dist/metrics/index.js +3 -0
  297. package/dist/metrics/index.js.map +1 -0
  298. package/dist/metrics/instance.d.ts +20 -0
  299. package/dist/metrics/instance.d.ts.map +1 -0
  300. package/dist/metrics/instance.js +127 -0
  301. package/dist/metrics/instance.js.map +1 -0
  302. package/dist/metrics/service.d.ts +2 -0
  303. package/dist/metrics/service.d.ts.map +1 -0
  304. package/dist/metrics/service.js +30 -0
  305. package/dist/metrics/service.js.map +1 -0
  306. package/dist/presentation/dto/checkout-token.d.ts +6 -0
  307. package/dist/presentation/dto/checkout-token.d.ts.map +1 -0
  308. package/dist/presentation/dto/checkout-token.js +74 -0
  309. package/dist/presentation/dto/checkout-token.js.map +1 -0
  310. package/dist/presentation/dto/index.d.ts +4 -0
  311. package/dist/presentation/dto/index.d.ts.map +1 -0
  312. package/dist/presentation/dto/index.js +5 -0
  313. package/dist/presentation/dto/index.js.map +1 -0
  314. package/dist/presentation/dto/job.d.ts +6 -0
  315. package/dist/presentation/dto/job.d.ts.map +1 -0
  316. package/dist/presentation/dto/job.js +59 -0
  317. package/dist/presentation/dto/job.js.map +1 -0
  318. package/dist/presentation/dto/step.d.ts +6 -0
  319. package/dist/presentation/dto/step.d.ts.map +1 -0
  320. package/dist/presentation/dto/step.js +162 -0
  321. package/dist/presentation/dto/step.js.map +1 -0
  322. package/dist/presentation/dto/workflow-run.d.ts +6 -0
  323. package/dist/presentation/dto/workflow-run.d.ts.map +1 -0
  324. package/dist/presentation/dto/workflow-run.js +35 -0
  325. package/dist/presentation/dto/workflow-run.js.map +1 -0
  326. package/dist/presentation/index.d.ts +3 -0
  327. package/dist/presentation/index.d.ts.map +1 -0
  328. package/dist/presentation/index.js +4 -0
  329. package/dist/presentation/index.js.map +1 -0
  330. package/dist/presentation/routes/agent-runtime-config.d.ts +2 -0
  331. package/dist/presentation/routes/agent-runtime-config.d.ts.map +1 -0
  332. package/dist/presentation/routes/agent-runtime-config.js +71 -0
  333. package/dist/presentation/routes/agent-runtime-config.js.map +1 -0
  334. package/dist/presentation/routes/cancel-run.d.ts +2 -0
  335. package/dist/presentation/routes/cancel-run.d.ts.map +1 -0
  336. package/dist/presentation/routes/cancel-run.js +46 -0
  337. package/dist/presentation/routes/cancel-run.js.map +1 -0
  338. package/dist/presentation/routes/checkout-token.d.ts +2 -0
  339. package/dist/presentation/routes/checkout-token.d.ts.map +1 -0
  340. package/dist/presentation/routes/checkout-token.js +64 -0
  341. package/dist/presentation/routes/checkout-token.js.map +1 -0
  342. package/dist/presentation/routes/get-run-aggregates.d.ts +2 -0
  343. package/dist/presentation/routes/get-run-aggregates.d.ts.map +1 -0
  344. package/dist/presentation/routes/get-run-aggregates.js +60 -0
  345. package/dist/presentation/routes/get-run-aggregates.js.map +1 -0
  346. package/dist/presentation/routes/get-run.d.ts +2 -0
  347. package/dist/presentation/routes/get-run.d.ts.map +1 -0
  348. package/dist/presentation/routes/get-run.js +60 -0
  349. package/dist/presentation/routes/get-run.js.map +1 -0
  350. package/dist/presentation/routes/get-step-secrets.d.ts +2 -0
  351. package/dist/presentation/routes/get-step-secrets.d.ts.map +1 -0
  352. package/dist/presentation/routes/get-step-secrets.js +115 -0
  353. package/dist/presentation/routes/get-step-secrets.js.map +1 -0
  354. package/dist/presentation/routes/index.d.ts +4 -0
  355. package/dist/presentation/routes/index.d.ts.map +1 -0
  356. package/dist/presentation/routes/index.js +41 -0
  357. package/dist/presentation/routes/index.js.map +1 -0
  358. package/dist/presentation/routes/leased-step.d.ts +14 -0
  359. package/dist/presentation/routes/leased-step.d.ts.map +1 -0
  360. package/dist/presentation/routes/leased-step.js +50 -0
  361. package/dist/presentation/routes/leased-step.js.map +1 -0
  362. package/dist/presentation/routes/list-run-attempts.d.ts +2 -0
  363. package/dist/presentation/routes/list-run-attempts.d.ts.map +1 -0
  364. package/dist/presentation/routes/list-run-attempts.js +35 -0
  365. package/dist/presentation/routes/list-run-attempts.js.map +1 -0
  366. package/dist/presentation/routes/list-runs.d.ts +2 -0
  367. package/dist/presentation/routes/list-runs.d.ts.map +1 -0
  368. package/dist/presentation/routes/list-runs.js +70 -0
  369. package/dist/presentation/routes/list-runs.js.map +1 -0
  370. package/dist/presentation/routes/next-step.d.ts +2 -0
  371. package/dist/presentation/routes/next-step.d.ts.map +1 -0
  372. package/dist/presentation/routes/next-step.js +65 -0
  373. package/dist/presentation/routes/next-step.js.map +1 -0
  374. package/dist/presentation/routes/report-step.d.ts +2 -0
  375. package/dist/presentation/routes/report-step.d.ts.map +1 -0
  376. package/dist/presentation/routes/report-step.js +73 -0
  377. package/dist/presentation/routes/report-step.js.map +1 -0
  378. package/dist/presentation/routes/require-accessible-run.d.ts +7 -0
  379. package/dist/presentation/routes/require-accessible-run.d.ts.map +1 -0
  380. package/dist/presentation/routes/require-accessible-run.js +25 -0
  381. package/dist/presentation/routes/require-accessible-run.js.map +1 -0
  382. package/dist/presentation/routes/rerun-run.d.ts +2 -0
  383. package/dist/presentation/routes/rerun-run.d.ts.map +1 -0
  384. package/dist/presentation/routes/rerun-run.js +56 -0
  385. package/dist/presentation/routes/rerun-run.js.map +1 -0
  386. package/dist/presentation/subscribers/index.d.ts +8 -0
  387. package/dist/presentation/subscribers/index.d.ts.map +1 -0
  388. package/dist/presentation/subscribers/index.js +9 -0
  389. package/dist/presentation/subscribers/index.js.map +1 -0
  390. package/dist/presentation/subscribers/on-job-event-delivered.d.ts +3 -0
  391. package/dist/presentation/subscribers/on-job-event-delivered.d.ts.map +1 -0
  392. package/dist/presentation/subscribers/on-job-event-delivered.js +24 -0
  393. package/dist/presentation/subscribers/on-job-event-delivered.js.map +1 -0
  394. package/dist/presentation/subscribers/on-job-steps-settled.d.ts +3 -0
  395. package/dist/presentation/subscribers/on-job-steps-settled.d.ts.map +1 -0
  396. package/dist/presentation/subscribers/on-job-steps-settled.js +36 -0
  397. package/dist/presentation/subscribers/on-job-steps-settled.js.map +1 -0
  398. package/dist/presentation/subscribers/on-runner-job-claimed.d.ts +3 -0
  399. package/dist/presentation/subscribers/on-runner-job-claimed.d.ts.map +1 -0
  400. package/dist/presentation/subscribers/on-runner-job-claimed.js +20 -0
  401. package/dist/presentation/subscribers/on-runner-job-claimed.js.map +1 -0
  402. package/dist/presentation/subscribers/on-runner-job-lease-expired.d.ts +3 -0
  403. package/dist/presentation/subscribers/on-runner-job-lease-expired.d.ts.map +1 -0
  404. package/dist/presentation/subscribers/on-runner-job-lease-expired.js +35 -0
  405. package/dist/presentation/subscribers/on-runner-job-lease-expired.js.map +1 -0
  406. package/dist/presentation/subscribers/on-runner-job-queued.d.ts +3 -0
  407. package/dist/presentation/subscribers/on-runner-job-queued.d.ts.map +1 -0
  408. package/dist/presentation/subscribers/on-runner-job-queued.js +20 -0
  409. package/dist/presentation/subscribers/on-runner-job-queued.js.map +1 -0
  410. package/dist/presentation/subscribers/on-workflow-run-attempt-created.d.ts +3 -0
  411. package/dist/presentation/subscribers/on-workflow-run-attempt-created.d.ts.map +1 -0
  412. package/dist/presentation/subscribers/on-workflow-run-attempt-created.js +35 -0
  413. package/dist/presentation/subscribers/on-workflow-run-attempt-created.js.map +1 -0
  414. package/dist/presentation/subscribers/on-workflow-run-cancelled.d.ts +3 -0
  415. package/dist/presentation/subscribers/on-workflow-run-cancelled.d.ts.map +1 -0
  416. package/dist/presentation/subscribers/on-workflow-run-cancelled.js +25 -0
  417. package/dist/presentation/subscribers/on-workflow-run-cancelled.js.map +1 -0
  418. package/dist/temporal/activities/index.d.ts +23 -0
  419. package/dist/temporal/activities/index.d.ts.map +1 -0
  420. package/dist/temporal/activities/index.js +26 -0
  421. package/dist/temporal/activities/index.js.map +1 -0
  422. package/dist/temporal/activities/orchestration-activities.d.ts +130 -0
  423. package/dist/temporal/activities/orchestration-activities.d.ts.map +1 -0
  424. package/dist/temporal/activities/orchestration-activities.js +188 -0
  425. package/dist/temporal/activities/orchestration-activities.js.map +1 -0
  426. package/dist/temporal/constants.d.ts +7 -0
  427. package/dist/temporal/constants.d.ts.map +1 -0
  428. package/dist/temporal/constants.js +8 -0
  429. package/dist/temporal/constants.js.map +1 -0
  430. package/dist/temporal/index.d.ts +3 -0
  431. package/dist/temporal/index.d.ts.map +1 -0
  432. package/dist/temporal/index.js +4 -0
  433. package/dist/temporal/index.js.map +1 -0
  434. package/dist/temporal/workflow-not-found.d.ts +2 -0
  435. package/dist/temporal/workflow-not-found.d.ts.map +1 -0
  436. package/dist/temporal/workflow-not-found.js +10 -0
  437. package/dist/temporal/workflow-not-found.js.map +1 -0
  438. package/dist/temporal/workflows/deadline.d.ts +3 -0
  439. package/dist/temporal/workflows/deadline.d.ts.map +1 -0
  440. package/dist/temporal/workflows/deadline.js +8 -0
  441. package/dist/temporal/workflows/deadline.js.map +1 -0
  442. package/dist/temporal/workflows/index.d.ts +4 -0
  443. package/dist/temporal/workflows/index.d.ts.map +1 -0
  444. package/dist/temporal/workflows/index.js +5 -0
  445. package/dist/temporal/workflows/index.js.map +1 -0
  446. package/dist/temporal/workflows/job-execution-orchestration.d.ts +27 -0
  447. package/dist/temporal/workflows/job-execution-orchestration.d.ts.map +1 -0
  448. package/dist/temporal/workflows/job-execution-orchestration.js +265 -0
  449. package/dist/temporal/workflows/job-execution-orchestration.js.map +1 -0
  450. package/dist/temporal/workflows/job-listener-orchestration.d.ts +40 -0
  451. package/dist/temporal/workflows/job-listener-orchestration.d.ts.map +1 -0
  452. package/dist/temporal/workflows/job-listener-orchestration.js +332 -0
  453. package/dist/temporal/workflows/job-listener-orchestration.js.map +1 -0
  454. package/dist/temporal/workflows/run-orchestration.d.ts +8 -0
  455. package/dist/temporal/workflows/run-orchestration.d.ts.map +1 -0
  456. package/dist/temporal/workflows/run-orchestration.js +243 -0
  457. package/dist/temporal/workflows/run-orchestration.js.map +1 -0
  458. package/dist/temporal/workflows/test-env.d.ts +114 -0
  459. package/dist/temporal/workflows/test-env.d.ts.map +1 -0
  460. package/dist/temporal/workflows/test-env.js +323 -0
  461. package/dist/temporal/workflows/test-env.js.map +1 -0
  462. package/dist/tsconfig.test.tsbuildinfo +1 -0
  463. package/drizzle/0000_initial.sql +211 -0
  464. package/drizzle/0001_agent_tool_materialization.sql +1 -0
  465. package/drizzle/meta/0000_snapshot.json +1613 -0
  466. package/drizzle/meta/_journal.json +20 -0
  467. package/drizzle.config.ts +7 -0
  468. package/package.json +91 -0
  469. package/src/core/README.md +79 -0
  470. package/src/core/agent-tool-capability-warning.test.ts +280 -0
  471. package/src/core/agent-tool-capability-warning.ts +200 -0
  472. package/src/core/agent-tools.ts +422 -0
  473. package/src/core/checkout.test.ts +112 -0
  474. package/src/core/checkout.ts +63 -0
  475. package/src/core/condition-trace.ts +64 -0
  476. package/src/core/entities/index.ts +9 -0
  477. package/src/core/entities/job-execution.ts +32 -0
  478. package/src/core/entities/job-listener-event.ts +15 -0
  479. package/src/core/entities/job.ts +91 -0
  480. package/src/core/entities/step.ts +126 -0
  481. package/src/core/entities/workflow-run-attempt.ts +21 -0
  482. package/src/core/entities/workflow-run.ts +94 -0
  483. package/src/core/errors.test.ts +45 -0
  484. package/src/core/errors.ts +209 -0
  485. package/src/core/index.ts +54 -0
  486. package/src/core/job-execution-outcome.ts +64 -0
  487. package/src/core/job-execution.test.ts +1560 -0
  488. package/src/core/job-execution.ts +581 -0
  489. package/src/core/job-transition/decide-job-activation.test.ts +196 -0
  490. package/src/core/job-transition/decide-job-activation.ts +79 -0
  491. package/src/core/job-transition/derive-job-execution-outputs.ts +41 -0
  492. package/src/core/job-transition/derive-job-success.test.ts +133 -0
  493. package/src/core/job-transition/derive-job-success.ts +67 -0
  494. package/src/core/job-transition/index.ts +11 -0
  495. package/src/core/job-transition/runtime-completion-status-for-job.ts +14 -0
  496. package/src/core/listener-execution-materialization.test.ts +49 -0
  497. package/src/core/listener-execution-materialization.ts +162 -0
  498. package/src/core/run-workflow.test.ts +229 -0
  499. package/src/core/run-workflow.ts +41 -0
  500. package/src/core/source-control.test.ts +17 -0
  501. package/src/core/source-control.ts +22 -0
  502. package/src/core/step-config/agent.ts +459 -0
  503. package/src/core/step-config/assemble-run-context.test.ts +1021 -0
  504. package/src/core/step-config/assemble-run-context.ts +535 -0
  505. package/src/core/step-config/complete-step-dispatch-config.test.ts +354 -0
  506. package/src/core/step-config/complete-step-dispatch-config.ts +40 -0
  507. package/src/core/step-config/fields.ts +111 -0
  508. package/src/core/step-config/index.ts +41 -0
  509. package/src/core/step-config/materialize-job-execution-steps.test.ts +494 -0
  510. package/src/core/step-config/materialize-job-execution-steps.ts +136 -0
  511. package/src/core/step-config/materialize-workflow-model.test.ts +1214 -0
  512. package/src/core/step-config/materialize-workflow-model.ts +140 -0
  513. package/src/core/step-config/resolve-job-execution-name.test.ts +94 -0
  514. package/src/core/step-config/resolve-job-execution-name.ts +51 -0
  515. package/src/core/step-config/resolve-step-config.ts +199 -0
  516. package/src/core/step-config/run.ts +467 -0
  517. package/src/core/step-config/workflow-evaluation-context.ts +6 -0
  518. package/src/core/step-transition/apply-step-transition.ts +163 -0
  519. package/src/core/step-transition/decide-step-transition.test.ts +307 -0
  520. package/src/core/step-transition/decide-step-transition.ts +200 -0
  521. package/src/core/step-transition/evaluate-gate.test.ts +317 -0
  522. package/src/core/step-transition/evaluate-gate.ts +168 -0
  523. package/src/core/step-transition/read-step-outputs.ts +27 -0
  524. package/src/core/workflow-run-creation.test.ts +155 -0
  525. package/src/core/workflow-run-creation.ts +131 -0
  526. package/src/core/workflow-scheduling/index.ts +15 -0
  527. package/src/core/workflow-scheduling/run-progress.test.ts +46 -0
  528. package/src/core/workflow-scheduling/run-progress.ts +68 -0
  529. package/src/core/workflow-scheduling/runtime-dag.ts +10 -0
  530. package/src/core/workflow-scheduling/runtime-scheduling-command.ts +20 -0
  531. package/src/core/workflow-scheduling/schedule-runtime-dag.test.ts +197 -0
  532. package/src/core/workflow-scheduling/schedule-runtime-dag.ts +115 -0
  533. package/src/db/db.ts +40 -0
  534. package/src/db/index.ts +86 -0
  535. package/src/db/job-listener-events.test.ts +113 -0
  536. package/src/db/job-listener-events.ts +73 -0
  537. package/src/db/job-listeners.test.ts +865 -0
  538. package/src/db/job-listeners.ts +564 -0
  539. package/src/db/outbox-writes.ts +40 -0
  540. package/src/db/rerun-listener.test.ts +64 -0
  541. package/src/db/run-timeout.test.ts +102 -0
  542. package/src/db/runner-lease-table.ts +39 -0
  543. package/src/db/schema/common.ts +3 -0
  544. package/src/db/schema/job-executions.ts +85 -0
  545. package/src/db/schema/job-listener-events.ts +58 -0
  546. package/src/db/schema/jobs.ts +136 -0
  547. package/src/db/schema/outbox.ts +4 -0
  548. package/src/db/schema/step-attempts.ts +99 -0
  549. package/src/db/schema/steps.ts +99 -0
  550. package/src/db/schema/workflow-run-attempts.ts +59 -0
  551. package/src/db/schema/workflow-runs.ts +112 -0
  552. package/src/db/workflow-runs/job-executions.test.ts +99 -0
  553. package/src/db/workflow-runs/job-executions.ts +421 -0
  554. package/src/db/workflow-runs/job-status.test.ts +532 -0
  555. package/src/db/workflow-runs/jobs.test.ts +194 -0
  556. package/src/db/workflow-runs/jobs.ts +418 -0
  557. package/src/db/workflow-runs/outbox.ts +109 -0
  558. package/src/db/workflow-runs/queries.test.ts +256 -0
  559. package/src/db/workflow-runs/queries.ts +437 -0
  560. package/src/db/workflow-runs/run-create.test.ts +1281 -0
  561. package/src/db/workflow-runs/run-create.ts +373 -0
  562. package/src/db/workflow-runs/run-graph.ts +95 -0
  563. package/src/db/workflow-runs/run-rerun.test.ts +625 -0
  564. package/src/db/workflow-runs/run-rerun.ts +266 -0
  565. package/src/db/workflow-runs/run-status.test.ts +425 -0
  566. package/src/db/workflow-runs/run-status.ts +391 -0
  567. package/src/db/workflow-runs/runs.ts +17 -0
  568. package/src/db/workflow-runs/shared.ts +84 -0
  569. package/src/db/workflow-runs/steps.test.ts +191 -0
  570. package/src/db/workflow-runs/steps.ts +476 -0
  571. package/src/db/workflow-runs.ts +111 -0
  572. package/src/index.ts +99 -0
  573. package/src/metrics/index.ts +1 -0
  574. package/src/metrics/instance.ts +160 -0
  575. package/src/metrics/service.ts +30 -0
  576. package/src/presentation/dto/checkout-token.test.ts +107 -0
  577. package/src/presentation/dto/checkout-token.ts +85 -0
  578. package/src/presentation/dto/index.ts +3 -0
  579. package/src/presentation/dto/job.test.ts +108 -0
  580. package/src/presentation/dto/job.ts +64 -0
  581. package/src/presentation/dto/step.test.ts +307 -0
  582. package/src/presentation/dto/step.ts +145 -0
  583. package/src/presentation/dto/workflow-run.ts +38 -0
  584. package/src/presentation/index.ts +10 -0
  585. package/src/presentation/routes/agent-runtime-config.test.ts +478 -0
  586. package/src/presentation/routes/agent-runtime-config.ts +81 -0
  587. package/src/presentation/routes/cancel-run.test.ts +156 -0
  588. package/src/presentation/routes/cancel-run.ts +37 -0
  589. package/src/presentation/routes/checkout-token.test.ts +366 -0
  590. package/src/presentation/routes/checkout-token.ts +61 -0
  591. package/src/presentation/routes/get-run-aggregates.test.ts +114 -0
  592. package/src/presentation/routes/get-run-aggregates.ts +69 -0
  593. package/src/presentation/routes/get-run.test.ts +604 -0
  594. package/src/presentation/routes/get-run.ts +66 -0
  595. package/src/presentation/routes/get-step-secrets.test.ts +260 -0
  596. package/src/presentation/routes/get-step-secrets.ts +117 -0
  597. package/src/presentation/routes/index.test.ts +71 -0
  598. package/src/presentation/routes/index.ts +42 -0
  599. package/src/presentation/routes/leased-step.ts +54 -0
  600. package/src/presentation/routes/list-run-attempts.test.ts +163 -0
  601. package/src/presentation/routes/list-run-attempts.ts +27 -0
  602. package/src/presentation/routes/list-runs.test.ts +244 -0
  603. package/src/presentation/routes/list-runs.ts +83 -0
  604. package/src/presentation/routes/next-step.test.ts +366 -0
  605. package/src/presentation/routes/next-step.ts +62 -0
  606. package/src/presentation/routes/report-step.test.ts +374 -0
  607. package/src/presentation/routes/report-step.ts +61 -0
  608. package/src/presentation/routes/require-accessible-run.ts +27 -0
  609. package/src/presentation/routes/rerun-run.test.ts +202 -0
  610. package/src/presentation/routes/rerun-run.ts +48 -0
  611. package/src/presentation/subscribers/index.ts +7 -0
  612. package/src/presentation/subscribers/on-job-event-delivered.test.ts +71 -0
  613. package/src/presentation/subscribers/on-job-event-delivered.ts +30 -0
  614. package/src/presentation/subscribers/on-job-steps-settled.test.ts +75 -0
  615. package/src/presentation/subscribers/on-job-steps-settled.ts +42 -0
  616. package/src/presentation/subscribers/on-runner-job-claimed.test.ts +57 -0
  617. package/src/presentation/subscribers/on-runner-job-claimed.ts +23 -0
  618. package/src/presentation/subscribers/on-runner-job-lease-expired.test.ts +73 -0
  619. package/src/presentation/subscribers/on-runner-job-lease-expired.ts +36 -0
  620. package/src/presentation/subscribers/on-runner-job-queued.test.ts +57 -0
  621. package/src/presentation/subscribers/on-runner-job-queued.ts +23 -0
  622. package/src/presentation/subscribers/on-workflow-run-attempt-created.test.ts +69 -0
  623. package/src/presentation/subscribers/on-workflow-run-attempt-created.ts +40 -0
  624. package/src/presentation/subscribers/on-workflow-run-cancelled.test.ts +59 -0
  625. package/src/presentation/subscribers/on-workflow-run-cancelled.ts +29 -0
  626. package/src/temporal/activities/index.ts +45 -0
  627. package/src/temporal/activities/orchestration-activities.test.ts +115 -0
  628. package/src/temporal/activities/orchestration-activities.ts +305 -0
  629. package/src/temporal/constants.ts +6 -0
  630. package/src/temporal/index.ts +6 -0
  631. package/src/temporal/workflow-not-found.ts +9 -0
  632. package/src/temporal/workflows/deadline.ts +7 -0
  633. package/src/temporal/workflows/index.ts +11 -0
  634. package/src/temporal/workflows/job-execution-orchestration-timeout.test.ts +165 -0
  635. package/src/temporal/workflows/job-execution-orchestration.test.ts +311 -0
  636. package/src/temporal/workflows/job-execution-orchestration.ts +314 -0
  637. package/src/temporal/workflows/job-listener-orchestration-continuation.test.ts +93 -0
  638. package/src/temporal/workflows/job-listener-orchestration.test.ts +406 -0
  639. package/src/temporal/workflows/job-listener-orchestration.ts +490 -0
  640. package/src/temporal/workflows/run-orchestration.test.ts +409 -0
  641. package/src/temporal/workflows/run-orchestration.ts +283 -0
  642. package/src/temporal/workflows/test-env.ts +409 -0
  643. package/test/env.ts +11 -0
  644. package/test/factories/job.ts +83 -0
  645. package/test/factories/project.ts +16 -0
  646. package/test/factories/workflow-model.test.ts +26 -0
  647. package/test/factories/workflow-model.ts +268 -0
  648. package/test/factories/workflow-run.ts +58 -0
  649. package/test/fixtures/active-lease-token.ts +85 -0
  650. package/test/fixtures/job-with-steps.ts +42 -0
  651. package/test/fixtures/lease-token.ts +44 -0
  652. package/test/fixtures/strip-setup-step.ts +23 -0
  653. package/test/globalSetup.ts +54 -0
  654. package/test/helpers/workflow-runs.ts +210 -0
  655. package/test/index.ts +3 -0
  656. package/test/setup.ts +17 -0
  657. package/tsconfig.build.json +9 -0
  658. package/tsconfig.build.tsbuildinfo +1 -0
  659. package/tsconfig.json +3 -0
  660. package/tsconfig.test.json +8 -0
  661. package/vitest.config.ts +12 -0
@@ -0,0 +1,71 @@
1
+ import { ModelProviderConfigNotFoundError } from '@shipfox/api-agent/core/errors';
2
+ import { resolveRuntimeCredentials } from '@shipfox/api-agent/core/resolve-runtime-credentials';
3
+ import { agentRuntimeCredentialsResponseSchema, materializedAgentStepConfigSchema } from '@shipfox/api-agent-dto';
4
+ import { SecretDecryptionError } from '@shipfox/api-secrets';
5
+ import { agentRuntimeConfigQuerySchema } from '@shipfox/api-workflows-dto';
6
+ import { captureException } from '@shipfox/node-error-monitoring';
7
+ import { ClientError, defineRoute } from '@shipfox/node-fastify';
8
+ import { ZodError } from 'zod';
9
+ import { loadRunningLeasedStep } from './leased-step.js';
10
+ export const agentRuntimeConfigRoute = defineRoute({
11
+ method: 'GET',
12
+ path: '/agent-runtime-config',
13
+ description: "Returns the resolved harness, provider, model, thinking effort, and decrypted provider credential bundle for the runner's currently leased running agent step. The job is identified by the lease token and the step is bound to that job before credentials are returned.",
14
+ schema: {
15
+ querystring: agentRuntimeConfigQuerySchema,
16
+ response: {
17
+ 200: agentRuntimeCredentialsResponseSchema
18
+ }
19
+ },
20
+ errorHandler: (error)=>{
21
+ if (error instanceof SecretDecryptionError) {
22
+ captureException(error);
23
+ throw new ClientError('Model provider credentials could not be decrypted', 'model-provider-credentials-invalid', {
24
+ status: 409,
25
+ cause: error
26
+ });
27
+ }
28
+ if (error instanceof ModelProviderConfigNotFoundError) {
29
+ throw new ClientError('Model provider credentials are not configured', 'model-provider-not-configured', {
30
+ status: 409
31
+ });
32
+ }
33
+ throw error;
34
+ },
35
+ handler: async (request, reply)=>{
36
+ const { step_id: stepId, attempt } = request.query;
37
+ const { step, workspaceId } = await loadRunningLeasedStep({
38
+ request,
39
+ stepId,
40
+ attempt
41
+ });
42
+ if (step.type !== 'agent') {
43
+ throw new ClientError('Step is not an agent step', 'step-not-agent', {
44
+ status: 409
45
+ });
46
+ }
47
+ let agentConfig;
48
+ try {
49
+ agentConfig = materializedAgentStepConfigSchema.parse(step.config);
50
+ } catch (error) {
51
+ if (error instanceof ZodError) {
52
+ throw new ClientError('Agent step config is invalid', 'agent-step-config-invalid', {
53
+ status: 409,
54
+ cause: error
55
+ });
56
+ }
57
+ throw error;
58
+ }
59
+ const runtimeConfig = await resolveRuntimeCredentials({
60
+ workspaceId,
61
+ harness: agentConfig.harness,
62
+ provider: agentConfig.provider,
63
+ model: agentConfig.model,
64
+ thinking: agentConfig.thinking
65
+ });
66
+ reply.header('cache-control', 'no-store');
67
+ return runtimeConfig;
68
+ }
69
+ });
70
+
71
+ //# sourceMappingURL=agent-runtime-config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/presentation/routes/agent-runtime-config.ts"],"sourcesContent":["import {ModelProviderConfigNotFoundError} from '@shipfox/api-agent/core/errors';\nimport {resolveRuntimeCredentials} from '@shipfox/api-agent/core/resolve-runtime-credentials';\nimport {\n agentRuntimeCredentialsResponseSchema,\n type MaterializedAgentStepConfigDto,\n materializedAgentStepConfigSchema,\n} from '@shipfox/api-agent-dto';\nimport {SecretDecryptionError} from '@shipfox/api-secrets';\nimport {agentRuntimeConfigQuerySchema} from '@shipfox/api-workflows-dto';\nimport {captureException} from '@shipfox/node-error-monitoring';\nimport {ClientError, defineRoute} from '@shipfox/node-fastify';\nimport {ZodError} from 'zod';\nimport {loadRunningLeasedStep} from './leased-step.js';\n\nexport const agentRuntimeConfigRoute = defineRoute({\n method: 'GET',\n path: '/agent-runtime-config',\n description:\n \"Returns the resolved harness, provider, model, thinking effort, and decrypted provider credential bundle for the runner's currently leased running agent step. The job is identified by the lease token and the step is bound to that job before credentials are returned.\",\n schema: {\n querystring: agentRuntimeConfigQuerySchema,\n response: {\n 200: agentRuntimeCredentialsResponseSchema,\n },\n },\n errorHandler: (error) => {\n if (error instanceof SecretDecryptionError) {\n captureException(error);\n throw new ClientError(\n 'Model provider credentials could not be decrypted',\n 'model-provider-credentials-invalid',\n {\n status: 409,\n cause: error,\n },\n );\n }\n if (error instanceof ModelProviderConfigNotFoundError) {\n throw new ClientError(\n 'Model provider credentials are not configured',\n 'model-provider-not-configured',\n {\n status: 409,\n },\n );\n }\n throw error;\n },\n handler: async (request, reply) => {\n const {step_id: stepId, attempt} = request.query;\n const {step, workspaceId} = await loadRunningLeasedStep({request, stepId, attempt});\n\n if (step.type !== 'agent') {\n throw new ClientError('Step is not an agent step', 'step-not-agent', {status: 409});\n }\n\n let agentConfig: MaterializedAgentStepConfigDto;\n try {\n agentConfig = materializedAgentStepConfigSchema.parse(step.config);\n } catch (error) {\n if (error instanceof ZodError) {\n throw new ClientError('Agent step config is invalid', 'agent-step-config-invalid', {\n status: 409,\n cause: error,\n });\n }\n throw error;\n }\n\n const runtimeConfig = await resolveRuntimeCredentials({\n workspaceId,\n harness: agentConfig.harness,\n provider: agentConfig.provider,\n model: agentConfig.model,\n thinking: agentConfig.thinking,\n });\n\n reply.header('cache-control', 'no-store');\n return runtimeConfig;\n },\n});\n"],"names":["ModelProviderConfigNotFoundError","resolveRuntimeCredentials","agentRuntimeCredentialsResponseSchema","materializedAgentStepConfigSchema","SecretDecryptionError","agentRuntimeConfigQuerySchema","captureException","ClientError","defineRoute","ZodError","loadRunningLeasedStep","agentRuntimeConfigRoute","method","path","description","schema","querystring","response","errorHandler","error","status","cause","handler","request","reply","step_id","stepId","attempt","query","step","workspaceId","type","agentConfig","parse","config","runtimeConfig","harness","provider","model","thinking","header"],"mappings":"AAAA,SAAQA,gCAAgC,QAAO,iCAAiC;AAChF,SAAQC,yBAAyB,QAAO,sDAAsD;AAC9F,SACEC,qCAAqC,EAErCC,iCAAiC,QAC5B,yBAAyB;AAChC,SAAQC,qBAAqB,QAAO,uBAAuB;AAC3D,SAAQC,6BAA6B,QAAO,6BAA6B;AACzE,SAAQC,gBAAgB,QAAO,iCAAiC;AAChE,SAAQC,WAAW,EAAEC,WAAW,QAAO,wBAAwB;AAC/D,SAAQC,QAAQ,QAAO,MAAM;AAC7B,SAAQC,qBAAqB,QAAO,mBAAmB;AAEvD,OAAO,MAAMC,0BAA0BH,YAAY;IACjDI,QAAQ;IACRC,MAAM;IACNC,aACE;IACFC,QAAQ;QACNC,aAAaX;QACbY,UAAU;YACR,KAAKf;QACP;IACF;IACAgB,cAAc,CAACC;QACb,IAAIA,iBAAiBf,uBAAuB;YAC1CE,iBAAiBa;YACjB,MAAM,IAAIZ,YACR,qDACA,sCACA;gBACEa,QAAQ;gBACRC,OAAOF;YACT;QAEJ;QACA,IAAIA,iBAAiBnB,kCAAkC;YACrD,MAAM,IAAIO,YACR,iDACA,iCACA;gBACEa,QAAQ;YACV;QAEJ;QACA,MAAMD;IACR;IACAG,SAAS,OAAOC,SAASC;QACvB,MAAM,EAACC,SAASC,MAAM,EAAEC,OAAO,EAAC,GAAGJ,QAAQK,KAAK;QAChD,MAAM,EAACC,IAAI,EAAEC,WAAW,EAAC,GAAG,MAAMpB,sBAAsB;YAACa;YAASG;YAAQC;QAAO;QAEjF,IAAIE,KAAKE,IAAI,KAAK,SAAS;YACzB,MAAM,IAAIxB,YAAY,6BAA6B,kBAAkB;gBAACa,QAAQ;YAAG;QACnF;QAEA,IAAIY;QACJ,IAAI;YACFA,cAAc7B,kCAAkC8B,KAAK,CAACJ,KAAKK,MAAM;QACnE,EAAE,OAAOf,OAAO;YACd,IAAIA,iBAAiBV,UAAU;gBAC7B,MAAM,IAAIF,YAAY,gCAAgC,6BAA6B;oBACjFa,QAAQ;oBACRC,OAAOF;gBACT;YACF;YACA,MAAMA;QACR;QAEA,MAAMgB,gBAAgB,MAAMlC,0BAA0B;YACpD6B;YACAM,SAASJ,YAAYI,OAAO;YAC5BC,UAAUL,YAAYK,QAAQ;YAC9BC,OAAON,YAAYM,KAAK;YACxBC,UAAUP,YAAYO,QAAQ;QAChC;QAEAf,MAAMgB,MAAM,CAAC,iBAAiB;QAC9B,OAAOL;IACT;AACF,GAAG"}
@@ -0,0 +1,2 @@
1
+ export declare const cancelRunRoute: import("@shipfox/node-fastify").RouteDefinition;
2
+ //# sourceMappingURL=cancel-run.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cancel-run.d.ts","sourceRoot":"","sources":["../../../src/presentation/routes/cancel-run.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,cAAc,iDA4BzB,CAAC"}
@@ -0,0 +1,46 @@
1
+ import { workflowRunDtoSchema } from '@shipfox/api-workflows-dto';
2
+ import { ClientError, defineRoute } from '@shipfox/node-fastify';
3
+ import { z } from 'zod';
4
+ import { WorkflowRunNotCancellableError, WorkflowRunNotFoundError } from '#core/errors.js';
5
+ import { cancelWorkflowRun } from '#db/index.js';
6
+ import { toRunDto } from '#presentation/dto/index.js';
7
+ import { requireAccessibleRun } from './require-accessible-run.js';
8
+ export const cancelRunRoute = defineRoute({
9
+ method: 'POST',
10
+ path: '/:id/cancel',
11
+ description: 'Cancel an in-progress workflow run',
12
+ schema: {
13
+ params: z.object({
14
+ id: z.string().uuid()
15
+ }),
16
+ response: {
17
+ 200: workflowRunDtoSchema
18
+ }
19
+ },
20
+ errorHandler: (error)=>{
21
+ if (error instanceof WorkflowRunNotCancellableError) {
22
+ throw new ClientError(error.message, 'run-already-finished', {
23
+ status: 409
24
+ });
25
+ }
26
+ if (error instanceof WorkflowRunNotFoundError) {
27
+ throw new ClientError('Run not found', 'not-found', {
28
+ status: 404
29
+ });
30
+ }
31
+ throw error;
32
+ },
33
+ handler: async (request)=>{
34
+ const { id } = request.params;
35
+ const run = await requireAccessibleRun({
36
+ request,
37
+ id
38
+ });
39
+ const cancelled = await cancelWorkflowRun({
40
+ workflowRunId: run.id
41
+ });
42
+ return toRunDto(cancelled);
43
+ }
44
+ });
45
+
46
+ //# sourceMappingURL=cancel-run.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/presentation/routes/cancel-run.ts"],"sourcesContent":["import {workflowRunDtoSchema} from '@shipfox/api-workflows-dto';\nimport {ClientError, defineRoute} from '@shipfox/node-fastify';\nimport {z} from 'zod';\nimport {WorkflowRunNotCancellableError, WorkflowRunNotFoundError} from '#core/errors.js';\nimport {cancelWorkflowRun} from '#db/index.js';\nimport {toRunDto} from '#presentation/dto/index.js';\nimport {requireAccessibleRun} from './require-accessible-run.js';\n\nexport const cancelRunRoute = defineRoute({\n method: 'POST',\n path: '/:id/cancel',\n description: 'Cancel an in-progress workflow run',\n schema: {\n params: z.object({\n id: z.string().uuid(),\n }),\n response: {\n 200: workflowRunDtoSchema,\n },\n },\n errorHandler: (error) => {\n if (error instanceof WorkflowRunNotCancellableError) {\n throw new ClientError(error.message, 'run-already-finished', {status: 409});\n }\n if (error instanceof WorkflowRunNotFoundError) {\n throw new ClientError('Run not found', 'not-found', {status: 404});\n }\n throw error;\n },\n handler: async (request) => {\n const {id} = request.params;\n const run = await requireAccessibleRun({request, id});\n\n const cancelled = await cancelWorkflowRun({workflowRunId: run.id});\n return toRunDto(cancelled);\n },\n});\n"],"names":["workflowRunDtoSchema","ClientError","defineRoute","z","WorkflowRunNotCancellableError","WorkflowRunNotFoundError","cancelWorkflowRun","toRunDto","requireAccessibleRun","cancelRunRoute","method","path","description","schema","params","object","id","string","uuid","response","errorHandler","error","message","status","handler","request","run","cancelled","workflowRunId"],"mappings":"AAAA,SAAQA,oBAAoB,QAAO,6BAA6B;AAChE,SAAQC,WAAW,EAAEC,WAAW,QAAO,wBAAwB;AAC/D,SAAQC,CAAC,QAAO,MAAM;AACtB,SAAQC,8BAA8B,EAAEC,wBAAwB,QAAO,kBAAkB;AACzF,SAAQC,iBAAiB,QAAO,eAAe;AAC/C,SAAQC,QAAQ,QAAO,6BAA6B;AACpD,SAAQC,oBAAoB,QAAO,8BAA8B;AAEjE,OAAO,MAAMC,iBAAiBP,YAAY;IACxCQ,QAAQ;IACRC,MAAM;IACNC,aAAa;IACbC,QAAQ;QACNC,QAAQX,EAAEY,MAAM,CAAC;YACfC,IAAIb,EAAEc,MAAM,GAAGC,IAAI;QACrB;QACAC,UAAU;YACR,KAAKnB;QACP;IACF;IACAoB,cAAc,CAACC;QACb,IAAIA,iBAAiBjB,gCAAgC;YACnD,MAAM,IAAIH,YAAYoB,MAAMC,OAAO,EAAE,wBAAwB;gBAACC,QAAQ;YAAG;QAC3E;QACA,IAAIF,iBAAiBhB,0BAA0B;YAC7C,MAAM,IAAIJ,YAAY,iBAAiB,aAAa;gBAACsB,QAAQ;YAAG;QAClE;QACA,MAAMF;IACR;IACAG,SAAS,OAAOC;QACd,MAAM,EAACT,EAAE,EAAC,GAAGS,QAAQX,MAAM;QAC3B,MAAMY,MAAM,MAAMlB,qBAAqB;YAACiB;YAAST;QAAE;QAEnD,MAAMW,YAAY,MAAMrB,kBAAkB;YAACsB,eAAeF,IAAIV,EAAE;QAAA;QAChE,OAAOT,SAASoB;IAClB;AACF,GAAG"}
@@ -0,0 +1,2 @@
1
+ export declare const checkoutTokenRoute: import("@shipfox/node-fastify").RouteDefinition;
2
+ //# sourceMappingURL=checkout-token.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"checkout-token.d.ts","sourceRoot":"","sources":["../../../src/presentation/routes/checkout-token.ts"],"names":[],"mappings":"AAcA,eAAO,MAAM,kBAAkB,iDA8C7B,CAAC"}
@@ -0,0 +1,64 @@
1
+ import { requireLeasedJobContext } from '@shipfox/api-auth-context';
2
+ import { integrationRouteErrorHandler } from '@shipfox/api-integration-core';
3
+ import { isJobLeaseActive } from '@shipfox/api-runners';
4
+ import { checkoutTokenResponseSchema } from '@shipfox/api-workflows-dto';
5
+ import { ClientError, defineRoute } from '@shipfox/node-fastify';
6
+ import { createJobCheckoutSpec } from '#core/checkout.js';
7
+ import { CheckoutIntentUnresolvedError, JobNotFoundError, WorkflowRunNotFoundError } from '#core/errors.js';
8
+ import { sourceControl } from '#core/source-control.js';
9
+ import { toCheckoutTokenDto } from '#presentation/dto/checkout-token.js';
10
+ export const checkoutTokenRoute = defineRoute({
11
+ method: 'POST',
12
+ path: '/checkout-token',
13
+ description: "Exchanges the runner's job lease for short-lived, read-only checkout credentials for the job's repository. The job is identified by the access token, so no job ID is needed. The checkout target is resolved server-side from the job's run and project; no credential material is stored on the job or run. Returns the repository URL, ref, and (when the provider needs auth) a short-lived credential that expires soon.",
14
+ schema: {
15
+ response: {
16
+ 200: checkoutTokenResponseSchema
17
+ }
18
+ },
19
+ errorHandler: (error)=>{
20
+ if (error instanceof JobNotFoundError) {
21
+ throw new ClientError(error.message, 'job-not-found', {
22
+ status: 404
23
+ });
24
+ }
25
+ if (error instanceof WorkflowRunNotFoundError) {
26
+ throw new ClientError(error.message, 'run-not-found', {
27
+ status: 404
28
+ });
29
+ }
30
+ if (error instanceof CheckoutIntentUnresolvedError) {
31
+ throw new ClientError(error.message, 'checkout-unavailable', {
32
+ status: 404
33
+ });
34
+ }
35
+ // Connection and provider errors (and the structural provider-error detection)
36
+ // map through the shared handler, which re-throws unknowns to the global handler.
37
+ return integrationRouteErrorHandler(error);
38
+ },
39
+ handler: async (request, reply)=>{
40
+ const leasedJob = requireLeasedJobContext(request);
41
+ const leaseIsActive = await isJobLeaseActive({
42
+ jobId: leasedJob.jobId,
43
+ jobExecutionId: leasedJob.jobExecutionId,
44
+ runnerSessionId: leasedJob.runnerSessionId
45
+ });
46
+ if (!leaseIsActive) {
47
+ throw new ClientError('Job lease is no longer active', 'lease-not-active', {
48
+ status: 404
49
+ });
50
+ }
51
+ const checkout = await createJobCheckoutSpec({
52
+ jobId: leasedJob.jobId,
53
+ sourceControl: sourceControl()
54
+ });
55
+ // The body carries short-lived git credentials; forbid any intermediary or
56
+ // client cache from retaining them.
57
+ reply.header('cache-control', 'no-store');
58
+ return toCheckoutTokenDto(checkout.spec, {
59
+ persist: checkout.persistCredentials
60
+ });
61
+ }
62
+ });
63
+
64
+ //# sourceMappingURL=checkout-token.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/presentation/routes/checkout-token.ts"],"sourcesContent":["import {requireLeasedJobContext} from '@shipfox/api-auth-context';\nimport {integrationRouteErrorHandler} from '@shipfox/api-integration-core';\nimport {isJobLeaseActive} from '@shipfox/api-runners';\nimport {checkoutTokenResponseSchema} from '@shipfox/api-workflows-dto';\nimport {ClientError, defineRoute} from '@shipfox/node-fastify';\nimport {createJobCheckoutSpec} from '#core/checkout.js';\nimport {\n CheckoutIntentUnresolvedError,\n JobNotFoundError,\n WorkflowRunNotFoundError,\n} from '#core/errors.js';\nimport {sourceControl} from '#core/source-control.js';\nimport {toCheckoutTokenDto} from '#presentation/dto/checkout-token.js';\n\nexport const checkoutTokenRoute = defineRoute({\n method: 'POST',\n path: '/checkout-token',\n description:\n \"Exchanges the runner's job lease for short-lived, read-only checkout credentials for the job's repository. The job is identified by the access token, so no job ID is needed. The checkout target is resolved server-side from the job's run and project; no credential material is stored on the job or run. Returns the repository URL, ref, and (when the provider needs auth) a short-lived credential that expires soon.\",\n schema: {\n response: {\n 200: checkoutTokenResponseSchema,\n },\n },\n errorHandler: (error) => {\n if (error instanceof JobNotFoundError) {\n throw new ClientError(error.message, 'job-not-found', {status: 404});\n }\n if (error instanceof WorkflowRunNotFoundError) {\n throw new ClientError(error.message, 'run-not-found', {status: 404});\n }\n if (error instanceof CheckoutIntentUnresolvedError) {\n throw new ClientError(error.message, 'checkout-unavailable', {status: 404});\n }\n // Connection and provider errors (and the structural provider-error detection)\n // map through the shared handler, which re-throws unknowns to the global handler.\n return integrationRouteErrorHandler(error);\n },\n handler: async (request, reply) => {\n const leasedJob = requireLeasedJobContext(request);\n\n const leaseIsActive = await isJobLeaseActive({\n jobId: leasedJob.jobId,\n jobExecutionId: leasedJob.jobExecutionId,\n runnerSessionId: leasedJob.runnerSessionId,\n });\n if (!leaseIsActive) {\n throw new ClientError('Job lease is no longer active', 'lease-not-active', {status: 404});\n }\n\n const checkout = await createJobCheckoutSpec({\n jobId: leasedJob.jobId,\n sourceControl: sourceControl(),\n });\n\n // The body carries short-lived git credentials; forbid any intermediary or\n // client cache from retaining them.\n reply.header('cache-control', 'no-store');\n return toCheckoutTokenDto(checkout.spec, {persist: checkout.persistCredentials});\n },\n});\n"],"names":["requireLeasedJobContext","integrationRouteErrorHandler","isJobLeaseActive","checkoutTokenResponseSchema","ClientError","defineRoute","createJobCheckoutSpec","CheckoutIntentUnresolvedError","JobNotFoundError","WorkflowRunNotFoundError","sourceControl","toCheckoutTokenDto","checkoutTokenRoute","method","path","description","schema","response","errorHandler","error","message","status","handler","request","reply","leasedJob","leaseIsActive","jobId","jobExecutionId","runnerSessionId","checkout","header","spec","persist","persistCredentials"],"mappings":"AAAA,SAAQA,uBAAuB,QAAO,4BAA4B;AAClE,SAAQC,4BAA4B,QAAO,gCAAgC;AAC3E,SAAQC,gBAAgB,QAAO,uBAAuB;AACtD,SAAQC,2BAA2B,QAAO,6BAA6B;AACvE,SAAQC,WAAW,EAAEC,WAAW,QAAO,wBAAwB;AAC/D,SAAQC,qBAAqB,QAAO,oBAAoB;AACxD,SACEC,6BAA6B,EAC7BC,gBAAgB,EAChBC,wBAAwB,QACnB,kBAAkB;AACzB,SAAQC,aAAa,QAAO,0BAA0B;AACtD,SAAQC,kBAAkB,QAAO,sCAAsC;AAEvE,OAAO,MAAMC,qBAAqBP,YAAY;IAC5CQ,QAAQ;IACRC,MAAM;IACNC,aACE;IACFC,QAAQ;QACNC,UAAU;YACR,KAAKd;QACP;IACF;IACAe,cAAc,CAACC;QACb,IAAIA,iBAAiBX,kBAAkB;YACrC,MAAM,IAAIJ,YAAYe,MAAMC,OAAO,EAAE,iBAAiB;gBAACC,QAAQ;YAAG;QACpE;QACA,IAAIF,iBAAiBV,0BAA0B;YAC7C,MAAM,IAAIL,YAAYe,MAAMC,OAAO,EAAE,iBAAiB;gBAACC,QAAQ;YAAG;QACpE;QACA,IAAIF,iBAAiBZ,+BAA+B;YAClD,MAAM,IAAIH,YAAYe,MAAMC,OAAO,EAAE,wBAAwB;gBAACC,QAAQ;YAAG;QAC3E;QACA,+EAA+E;QAC/E,kFAAkF;QAClF,OAAOpB,6BAA6BkB;IACtC;IACAG,SAAS,OAAOC,SAASC;QACvB,MAAMC,YAAYzB,wBAAwBuB;QAE1C,MAAMG,gBAAgB,MAAMxB,iBAAiB;YAC3CyB,OAAOF,UAAUE,KAAK;YACtBC,gBAAgBH,UAAUG,cAAc;YACxCC,iBAAiBJ,UAAUI,eAAe;QAC5C;QACA,IAAI,CAACH,eAAe;YAClB,MAAM,IAAItB,YAAY,iCAAiC,oBAAoB;gBAACiB,QAAQ;YAAG;QACzF;QAEA,MAAMS,WAAW,MAAMxB,sBAAsB;YAC3CqB,OAAOF,UAAUE,KAAK;YACtBjB,eAAeA;QACjB;QAEA,2EAA2E;QAC3E,oCAAoC;QACpCc,MAAMO,MAAM,CAAC,iBAAiB;QAC9B,OAAOpB,mBAAmBmB,SAASE,IAAI,EAAE;YAACC,SAASH,SAASI,kBAAkB;QAAA;IAChF;AACF,GAAG"}
@@ -0,0 +1,2 @@
1
+ export declare const getRunAggregatesRoute: import("@shipfox/node-fastify").RouteDefinition;
2
+ //# sourceMappingURL=get-run-aggregates.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-run-aggregates.d.ts","sourceRoot":"","sources":["../../../src/presentation/routes/get-run-aggregates.ts"],"names":[],"mappings":"AASA,eAAO,MAAM,qBAAqB,iDA2DhC,CAAC"}
@@ -0,0 +1,60 @@
1
+ import { ProjectNotFoundError, requireProjectAccess } from '@shipfox/api-projects';
2
+ import { workflowRunAggregatesQuerySchema, workflowRunAggregatesResponseSchema } from '@shipfox/api-workflows-dto';
3
+ import { ClientError, defineRoute } from '@shipfox/node-fastify';
4
+ import { logger } from '@shipfox/node-opentelemetry';
5
+ import { getWorkflowRunAggregates } from '#db/index.js';
6
+ export const getRunAggregatesRoute = defineRoute({
7
+ method: 'GET',
8
+ path: '/aggregates',
9
+ description: 'Get faceted workflow run counts for a project',
10
+ schema: {
11
+ querystring: workflowRunAggregatesQuerySchema,
12
+ response: {
13
+ 200: workflowRunAggregatesResponseSchema
14
+ }
15
+ },
16
+ errorHandler: (error)=>{
17
+ if (error instanceof ProjectNotFoundError) {
18
+ throw new ClientError(error.message, 'project-not-found', {
19
+ status: 404
20
+ });
21
+ }
22
+ throw error;
23
+ },
24
+ handler: async (request)=>{
25
+ const startedAt = performance.now();
26
+ const { project_id: projectId, status, definition_id: definitionId, trigger_source: triggerSource, created_from: createdFrom, created_to: createdTo } = request.query;
27
+ const { project } = await requireProjectAccess({
28
+ request,
29
+ projectId
30
+ });
31
+ const filters = {
32
+ status,
33
+ definitionId,
34
+ triggerSource,
35
+ createdFrom: createdFrom ? new Date(createdFrom) : undefined,
36
+ createdTo: createdTo ? new Date(createdTo) : undefined
37
+ };
38
+ const aggregates = await getWorkflowRunAggregates({
39
+ projectId: project.id,
40
+ filters
41
+ });
42
+ logger().info({
43
+ projectId: project.id,
44
+ filterKeys: Object.entries(filters).filter(([, value])=>value !== undefined).map(([key])=>key),
45
+ aggregateBucketSizes: {
46
+ status: aggregates.status.length,
47
+ triggerSource: aggregates.triggerSource.length,
48
+ workflow: aggregates.workflow.length
49
+ },
50
+ durationMs: Math.round(performance.now() - startedAt)
51
+ }, 'Aggregated workflow runs');
52
+ return {
53
+ status: aggregates.status,
54
+ trigger_source: aggregates.triggerSource,
55
+ workflow: aggregates.workflow
56
+ };
57
+ }
58
+ });
59
+
60
+ //# sourceMappingURL=get-run-aggregates.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/presentation/routes/get-run-aggregates.ts"],"sourcesContent":["import {ProjectNotFoundError, requireProjectAccess} from '@shipfox/api-projects';\nimport {\n workflowRunAggregatesQuerySchema,\n workflowRunAggregatesResponseSchema,\n} from '@shipfox/api-workflows-dto';\nimport {ClientError, defineRoute} from '@shipfox/node-fastify';\nimport {logger} from '@shipfox/node-opentelemetry';\nimport {getWorkflowRunAggregates} from '#db/index.js';\n\nexport const getRunAggregatesRoute = defineRoute({\n method: 'GET',\n path: '/aggregates',\n description: 'Get faceted workflow run counts for a project',\n schema: {\n querystring: workflowRunAggregatesQuerySchema,\n response: {\n 200: workflowRunAggregatesResponseSchema,\n },\n },\n errorHandler: (error) => {\n if (error instanceof ProjectNotFoundError) {\n throw new ClientError(error.message, 'project-not-found', {status: 404});\n }\n throw error;\n },\n handler: async (request) => {\n const startedAt = performance.now();\n const {\n project_id: projectId,\n status,\n definition_id: definitionId,\n trigger_source: triggerSource,\n created_from: createdFrom,\n created_to: createdTo,\n } = request.query;\n\n const {project} = await requireProjectAccess({request, projectId});\n const filters = {\n status,\n definitionId,\n triggerSource,\n createdFrom: createdFrom ? new Date(createdFrom) : undefined,\n createdTo: createdTo ? new Date(createdTo) : undefined,\n };\n const aggregates = await getWorkflowRunAggregates({projectId: project.id, filters});\n\n logger().info(\n {\n projectId: project.id,\n filterKeys: Object.entries(filters)\n .filter(([, value]) => value !== undefined)\n .map(([key]) => key),\n aggregateBucketSizes: {\n status: aggregates.status.length,\n triggerSource: aggregates.triggerSource.length,\n workflow: aggregates.workflow.length,\n },\n durationMs: Math.round(performance.now() - startedAt),\n },\n 'Aggregated workflow runs',\n );\n\n return {\n status: aggregates.status,\n trigger_source: aggregates.triggerSource,\n workflow: aggregates.workflow,\n };\n },\n});\n"],"names":["ProjectNotFoundError","requireProjectAccess","workflowRunAggregatesQuerySchema","workflowRunAggregatesResponseSchema","ClientError","defineRoute","logger","getWorkflowRunAggregates","getRunAggregatesRoute","method","path","description","schema","querystring","response","errorHandler","error","message","status","handler","request","startedAt","performance","now","project_id","projectId","definition_id","definitionId","trigger_source","triggerSource","created_from","createdFrom","created_to","createdTo","query","project","filters","Date","undefined","aggregates","id","info","filterKeys","Object","entries","filter","value","map","key","aggregateBucketSizes","length","workflow","durationMs","Math","round"],"mappings":"AAAA,SAAQA,oBAAoB,EAAEC,oBAAoB,QAAO,wBAAwB;AACjF,SACEC,gCAAgC,EAChCC,mCAAmC,QAC9B,6BAA6B;AACpC,SAAQC,WAAW,EAAEC,WAAW,QAAO,wBAAwB;AAC/D,SAAQC,MAAM,QAAO,8BAA8B;AACnD,SAAQC,wBAAwB,QAAO,eAAe;AAEtD,OAAO,MAAMC,wBAAwBH,YAAY;IAC/CI,QAAQ;IACRC,MAAM;IACNC,aAAa;IACbC,QAAQ;QACNC,aAAaX;QACbY,UAAU;YACR,KAAKX;QACP;IACF;IACAY,cAAc,CAACC;QACb,IAAIA,iBAAiBhB,sBAAsB;YACzC,MAAM,IAAII,YAAYY,MAAMC,OAAO,EAAE,qBAAqB;gBAACC,QAAQ;YAAG;QACxE;QACA,MAAMF;IACR;IACAG,SAAS,OAAOC;QACd,MAAMC,YAAYC,YAAYC,GAAG;QACjC,MAAM,EACJC,YAAYC,SAAS,EACrBP,MAAM,EACNQ,eAAeC,YAAY,EAC3BC,gBAAgBC,aAAa,EAC7BC,cAAcC,WAAW,EACzBC,YAAYC,SAAS,EACtB,GAAGb,QAAQc,KAAK;QAEjB,MAAM,EAACC,OAAO,EAAC,GAAG,MAAMlC,qBAAqB;YAACmB;YAASK;QAAS;QAChE,MAAMW,UAAU;YACdlB;YACAS;YACAE;YACAE,aAAaA,cAAc,IAAIM,KAAKN,eAAeO;YACnDL,WAAWA,YAAY,IAAII,KAAKJ,aAAaK;QAC/C;QACA,MAAMC,aAAa,MAAMhC,yBAAyB;YAACkB,WAAWU,QAAQK,EAAE;YAAEJ;QAAO;QAEjF9B,SAASmC,IAAI,CACX;YACEhB,WAAWU,QAAQK,EAAE;YACrBE,YAAYC,OAAOC,OAAO,CAACR,SACxBS,MAAM,CAAC,CAAC,GAAGC,MAAM,GAAKA,UAAUR,WAChCS,GAAG,CAAC,CAAC,CAACC,IAAI,GAAKA;YAClBC,sBAAsB;gBACpB/B,QAAQqB,WAAWrB,MAAM,CAACgC,MAAM;gBAChCrB,eAAeU,WAAWV,aAAa,CAACqB,MAAM;gBAC9CC,UAAUZ,WAAWY,QAAQ,CAACD,MAAM;YACtC;YACAE,YAAYC,KAAKC,KAAK,CAAChC,YAAYC,GAAG,KAAKF;QAC7C,GACA;QAGF,OAAO;YACLH,QAAQqB,WAAWrB,MAAM;YACzBU,gBAAgBW,WAAWV,aAAa;YACxCsB,UAAUZ,WAAWY,QAAQ;QAC/B;IACF;AACF,GAAG"}
@@ -0,0 +1,2 @@
1
+ export declare const getRunRoute: import("@shipfox/node-fastify").RouteDefinition;
2
+ //# sourceMappingURL=get-run.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-run.d.ts","sourceRoot":"","sources":["../../../src/presentation/routes/get-run.ts"],"names":[],"mappings":"AAcA,eAAO,MAAM,WAAW,iDAmDtB,CAAC"}
@@ -0,0 +1,60 @@
1
+ import { workflowRunDetailResponseSchema } from '@shipfox/api-workflows-dto';
2
+ import { ClientError, defineRoute } from '@shipfox/node-fastify';
3
+ import { z } from 'zod';
4
+ import { getWorkflowRunDetail } from '#db/index.js';
5
+ import { toJobDto, toJobExecutionDto, toRunAttemptDto, toRunDto, toStepAttemptDto, toStepDto } from '#presentation/dto/index.js';
6
+ import { requireAccessibleRun } from './require-accessible-run.js';
7
+ export const getRunRoute = defineRoute({
8
+ method: 'GET',
9
+ path: '/:id',
10
+ description: 'Get a workflow run by ID with jobs and steps',
11
+ schema: {
12
+ params: z.object({
13
+ id: z.string().uuid()
14
+ }),
15
+ querystring: z.object({
16
+ attempt: z.coerce.number().int().positive().optional()
17
+ }),
18
+ response: {
19
+ 200: workflowRunDetailResponseSchema
20
+ }
21
+ },
22
+ handler: async (request)=>{
23
+ const { id } = request.params;
24
+ await requireAccessibleRun({
25
+ request,
26
+ id
27
+ });
28
+ const run = await getWorkflowRunDetail(id, request.query.attempt);
29
+ if (!run) {
30
+ throw new ClientError('Run not found', 'not-found', {
31
+ status: 404
32
+ });
33
+ }
34
+ const jobDtos = run.jobs.map((job)=>({
35
+ ...toJobDto(job),
36
+ job_executions: job.jobExecutions.map((jobExecution)=>({
37
+ ...toJobExecutionDto(jobExecution),
38
+ steps: jobExecution.steps.map((step)=>{
39
+ const attempts = step.attempts.map(toStepAttemptDto);
40
+ const latestTerminalAttempt = attempts.filter((attempt)=>attempt.status !== 'running').at(-1);
41
+ return {
42
+ ...toStepDto(step),
43
+ exit_code: latestTerminalAttempt?.exit_code ?? null,
44
+ outputs: latestTerminalAttempt?.outputs ?? null,
45
+ response: latestTerminalAttempt?.response ?? null,
46
+ gate_result: latestTerminalAttempt?.gate_result ?? null,
47
+ attempts
48
+ };
49
+ })
50
+ }))
51
+ }));
52
+ return {
53
+ ...toRunDto(run, run.latestAttempt),
54
+ run_attempt: toRunAttemptDto(run.runAttempt),
55
+ jobs: jobDtos
56
+ };
57
+ }
58
+ });
59
+
60
+ //# sourceMappingURL=get-run.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/presentation/routes/get-run.ts"],"sourcesContent":["import {workflowRunDetailResponseSchema} from '@shipfox/api-workflows-dto';\nimport {ClientError, defineRoute} from '@shipfox/node-fastify';\nimport {z} from 'zod';\nimport {getWorkflowRunDetail} from '#db/index.js';\nimport {\n toJobDto,\n toJobExecutionDto,\n toRunAttemptDto,\n toRunDto,\n toStepAttemptDto,\n toStepDto,\n} from '#presentation/dto/index.js';\nimport {requireAccessibleRun} from './require-accessible-run.js';\n\nexport const getRunRoute = defineRoute({\n method: 'GET',\n path: '/:id',\n description: 'Get a workflow run by ID with jobs and steps',\n schema: {\n params: z.object({\n id: z.string().uuid(),\n }),\n querystring: z.object({\n attempt: z.coerce.number().int().positive().optional(),\n }),\n response: {\n 200: workflowRunDetailResponseSchema,\n },\n },\n handler: async (request) => {\n const {id} = request.params;\n await requireAccessibleRun({request, id});\n\n const run = await getWorkflowRunDetail(id, request.query.attempt);\n if (!run) {\n throw new ClientError('Run not found', 'not-found', {status: 404});\n }\n\n const jobDtos = run.jobs.map((job) => ({\n ...toJobDto(job),\n job_executions: job.jobExecutions.map((jobExecution) => ({\n ...toJobExecutionDto(jobExecution),\n steps: jobExecution.steps.map((step) => {\n const attempts = step.attempts.map(toStepAttemptDto);\n const latestTerminalAttempt = attempts\n .filter((attempt) => attempt.status !== 'running')\n .at(-1);\n return {\n ...toStepDto(step),\n exit_code: latestTerminalAttempt?.exit_code ?? null,\n outputs: latestTerminalAttempt?.outputs ?? null,\n response: latestTerminalAttempt?.response ?? null,\n gate_result: latestTerminalAttempt?.gate_result ?? null,\n attempts,\n };\n }),\n })),\n }));\n\n return {\n ...toRunDto(run, run.latestAttempt),\n run_attempt: toRunAttemptDto(run.runAttempt),\n jobs: jobDtos,\n };\n },\n});\n"],"names":["workflowRunDetailResponseSchema","ClientError","defineRoute","z","getWorkflowRunDetail","toJobDto","toJobExecutionDto","toRunAttemptDto","toRunDto","toStepAttemptDto","toStepDto","requireAccessibleRun","getRunRoute","method","path","description","schema","params","object","id","string","uuid","querystring","attempt","coerce","number","int","positive","optional","response","handler","request","run","query","status","jobDtos","jobs","map","job","job_executions","jobExecutions","jobExecution","steps","step","attempts","latestTerminalAttempt","filter","at","exit_code","outputs","gate_result","latestAttempt","run_attempt","runAttempt"],"mappings":"AAAA,SAAQA,+BAA+B,QAAO,6BAA6B;AAC3E,SAAQC,WAAW,EAAEC,WAAW,QAAO,wBAAwB;AAC/D,SAAQC,CAAC,QAAO,MAAM;AACtB,SAAQC,oBAAoB,QAAO,eAAe;AAClD,SACEC,QAAQ,EACRC,iBAAiB,EACjBC,eAAe,EACfC,QAAQ,EACRC,gBAAgB,EAChBC,SAAS,QACJ,6BAA6B;AACpC,SAAQC,oBAAoB,QAAO,8BAA8B;AAEjE,OAAO,MAAMC,cAAcV,YAAY;IACrCW,QAAQ;IACRC,MAAM;IACNC,aAAa;IACbC,QAAQ;QACNC,QAAQd,EAAEe,MAAM,CAAC;YACfC,IAAIhB,EAAEiB,MAAM,GAAGC,IAAI;QACrB;QACAC,aAAanB,EAAEe,MAAM,CAAC;YACpBK,SAASpB,EAAEqB,MAAM,CAACC,MAAM,GAAGC,GAAG,GAAGC,QAAQ,GAAGC,QAAQ;QACtD;QACAC,UAAU;YACR,KAAK7B;QACP;IACF;IACA8B,SAAS,OAAOC;QACd,MAAM,EAACZ,EAAE,EAAC,GAAGY,QAAQd,MAAM;QAC3B,MAAMN,qBAAqB;YAACoB;YAASZ;QAAE;QAEvC,MAAMa,MAAM,MAAM5B,qBAAqBe,IAAIY,QAAQE,KAAK,CAACV,OAAO;QAChE,IAAI,CAACS,KAAK;YACR,MAAM,IAAI/B,YAAY,iBAAiB,aAAa;gBAACiC,QAAQ;YAAG;QAClE;QAEA,MAAMC,UAAUH,IAAII,IAAI,CAACC,GAAG,CAAC,CAACC,MAAS,CAAA;gBACrC,GAAGjC,SAASiC,IAAI;gBAChBC,gBAAgBD,IAAIE,aAAa,CAACH,GAAG,CAAC,CAACI,eAAkB,CAAA;wBACvD,GAAGnC,kBAAkBmC,aAAa;wBAClCC,OAAOD,aAAaC,KAAK,CAACL,GAAG,CAAC,CAACM;4BAC7B,MAAMC,WAAWD,KAAKC,QAAQ,CAACP,GAAG,CAAC5B;4BACnC,MAAMoC,wBAAwBD,SAC3BE,MAAM,CAAC,CAACvB,UAAYA,QAAQW,MAAM,KAAK,WACvCa,EAAE,CAAC,CAAC;4BACP,OAAO;gCACL,GAAGrC,UAAUiC,KAAK;gCAClBK,WAAWH,uBAAuBG,aAAa;gCAC/CC,SAASJ,uBAAuBI,WAAW;gCAC3CpB,UAAUgB,uBAAuBhB,YAAY;gCAC7CqB,aAAaL,uBAAuBK,eAAe;gCACnDN;4BACF;wBACF;oBACF,CAAA;YACF,CAAA;QAEA,OAAO;YACL,GAAGpC,SAASwB,KAAKA,IAAImB,aAAa,CAAC;YACnCC,aAAa7C,gBAAgByB,IAAIqB,UAAU;YAC3CjB,MAAMD;QACR;IACF;AACF,GAAG"}
@@ -0,0 +1,2 @@
1
+ export declare const getStepSecretsRoute: import("@shipfox/node-fastify").RouteDefinition;
2
+ //# sourceMappingURL=get-step-secrets.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-step-secrets.d.ts","sourceRoot":"","sources":["../../../src/presentation/routes/get-step-secrets.ts"],"names":[],"mappings":"AAgBA,eAAO,MAAM,mBAAmB,iDAiE9B,CAAC"}
@@ -0,0 +1,115 @@
1
+ import { getSecret, SecretDecryptionError } from '@shipfox/api-secrets';
2
+ import { materializedSecretBindingSchema, stepSecretsParamsSchema, stepSecretsQuerySchema, stepSecretsResponseSchema } from '@shipfox/api-secrets-dto';
3
+ import { captureException } from '@shipfox/node-error-monitoring';
4
+ import { ClientError, defineRoute } from '@shipfox/node-fastify';
5
+ import { logger } from '@shipfox/node-opentelemetry';
6
+ import { ZodError, z } from 'zod';
7
+ import { loadRunningLeasedStep } from './leased-step.js';
8
+ const secretBindingsSchema = z.array(materializedSecretBindingSchema);
9
+ export const getStepSecretsRoute = defineRoute({
10
+ method: 'GET',
11
+ path: '/steps/:stepId/secrets',
12
+ description: "Returns decrypted secret values referenced by the runner's currently leased running run step. The job scope and secret bindings are re-derived from server state; the runner supplies only the step id and current attempt.",
13
+ schema: {
14
+ params: stepSecretsParamsSchema,
15
+ querystring: stepSecretsQuerySchema,
16
+ response: {
17
+ 200: stepSecretsResponseSchema
18
+ }
19
+ },
20
+ errorHandler: (error)=>{
21
+ if (error instanceof SecretDecryptionError) {
22
+ captureException(error);
23
+ throw new ClientError('Step secret could not be decrypted', 'secret-value-invalid', {
24
+ status: 409,
25
+ cause: error
26
+ });
27
+ }
28
+ throw error;
29
+ },
30
+ handler: async (request, reply)=>{
31
+ const { stepId } = request.params;
32
+ const { attempt } = request.query;
33
+ const { leasedJob, step, workspaceId, projectId } = await loadRunningLeasedStep({
34
+ request,
35
+ stepId,
36
+ attempt
37
+ });
38
+ if (step.type !== 'run') {
39
+ throw new ClientError('Step is not a run step', 'step-not-run', {
40
+ status: 409
41
+ });
42
+ }
43
+ const secretBindings = parseSecretBindings(step.config.secret_bindings);
44
+ const references = distinctSecretReferences(secretBindings);
45
+ const secrets = await Promise.all(references.map(async (reference)=>{
46
+ const value = await getSecret({
47
+ workspaceId,
48
+ projectId,
49
+ namespace: '',
50
+ key: reference.key,
51
+ store: reference.store
52
+ });
53
+ if (value === null) {
54
+ throw new ClientError('Secret not found', 'secret-not-found', {
55
+ status: 422
56
+ });
57
+ }
58
+ return {
59
+ ...reference,
60
+ value
61
+ };
62
+ }));
63
+ logger().info({
64
+ jobId: leasedJob.jobId,
65
+ workspaceId,
66
+ stepId,
67
+ keyCount: references.length
68
+ }, 'Resolved step secrets');
69
+ logger().debug({
70
+ jobId: leasedJob.jobId,
71
+ workspaceId,
72
+ stepId,
73
+ keys: references.map((ref)=>ref.key)
74
+ }, 'Resolved step secret keys');
75
+ reply.header('cache-control', 'no-store');
76
+ return {
77
+ secrets
78
+ };
79
+ }
80
+ });
81
+ function parseSecretBindings(value) {
82
+ try {
83
+ return secretBindingsSchema.parse(value ?? []);
84
+ } catch (error) {
85
+ if (error instanceof ZodError) {
86
+ throw new ClientError('Step secret bindings are invalid', 'secret-bindings-invalid', {
87
+ status: 409,
88
+ cause: error
89
+ });
90
+ }
91
+ throw error;
92
+ }
93
+ }
94
+ function distinctSecretReferences(bindings) {
95
+ const seen = new Set();
96
+ const references = [];
97
+ for (const binding of bindings){
98
+ for (const segment of binding.segments){
99
+ if (segment.kind !== 'secret') continue;
100
+ const id = secretReferenceId(segment);
101
+ if (seen.has(id)) continue;
102
+ seen.add(id);
103
+ references.push({
104
+ store: segment.store,
105
+ key: segment.key
106
+ });
107
+ }
108
+ }
109
+ return references;
110
+ }
111
+ function secretReferenceId(reference) {
112
+ return `${reference.store}\0${reference.key}`;
113
+ }
114
+
115
+ //# sourceMappingURL=get-step-secrets.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/presentation/routes/get-step-secrets.ts"],"sourcesContent":["import {getSecret, SecretDecryptionError} from '@shipfox/api-secrets';\nimport {\n materializedSecretBindingSchema,\n type StepSecretDto,\n stepSecretsParamsSchema,\n stepSecretsQuerySchema,\n stepSecretsResponseSchema,\n} from '@shipfox/api-secrets-dto';\nimport {captureException} from '@shipfox/node-error-monitoring';\nimport {ClientError, defineRoute} from '@shipfox/node-fastify';\nimport {logger} from '@shipfox/node-opentelemetry';\nimport {ZodError, z} from 'zod';\nimport {loadRunningLeasedStep} from './leased-step.js';\n\nconst secretBindingsSchema = z.array(materializedSecretBindingSchema);\n\nexport const getStepSecretsRoute = defineRoute({\n method: 'GET',\n path: '/steps/:stepId/secrets',\n description:\n \"Returns decrypted secret values referenced by the runner's currently leased running run step. The job scope and secret bindings are re-derived from server state; the runner supplies only the step id and current attempt.\",\n schema: {\n params: stepSecretsParamsSchema,\n querystring: stepSecretsQuerySchema,\n response: {\n 200: stepSecretsResponseSchema,\n },\n },\n errorHandler: (error) => {\n if (error instanceof SecretDecryptionError) {\n captureException(error);\n throw new ClientError('Step secret could not be decrypted', 'secret-value-invalid', {\n status: 409,\n cause: error,\n });\n }\n throw error;\n },\n handler: async (request, reply) => {\n const {stepId} = request.params;\n const {attempt} = request.query;\n const {leasedJob, step, workspaceId, projectId} = await loadRunningLeasedStep({\n request,\n stepId,\n attempt,\n });\n\n if (step.type !== 'run') {\n throw new ClientError('Step is not a run step', 'step-not-run', {status: 409});\n }\n\n const secretBindings = parseSecretBindings(step.config.secret_bindings);\n const references = distinctSecretReferences(secretBindings);\n const secrets = await Promise.all(\n references.map(async (reference): Promise<StepSecretDto> => {\n const value = await getSecret({\n workspaceId,\n projectId,\n namespace: '',\n key: reference.key,\n store: reference.store,\n });\n if (value === null) {\n throw new ClientError('Secret not found', 'secret-not-found', {status: 422});\n }\n return {...reference, value};\n }),\n );\n\n logger().info(\n {jobId: leasedJob.jobId, workspaceId, stepId, keyCount: references.length},\n 'Resolved step secrets',\n );\n logger().debug(\n {jobId: leasedJob.jobId, workspaceId, stepId, keys: references.map((ref) => ref.key)},\n 'Resolved step secret keys',\n );\n\n reply.header('cache-control', 'no-store');\n return {secrets};\n },\n});\n\nfunction parseSecretBindings(value: unknown): z.infer<typeof secretBindingsSchema> {\n try {\n return secretBindingsSchema.parse(value ?? []);\n } catch (error) {\n if (error instanceof ZodError) {\n throw new ClientError('Step secret bindings are invalid', 'secret-bindings-invalid', {\n status: 409,\n cause: error,\n });\n }\n throw error;\n }\n}\n\nfunction distinctSecretReferences(\n bindings: ReadonlyArray<z.infer<typeof materializedSecretBindingSchema>>,\n): Array<Pick<StepSecretDto, 'store' | 'key'>> {\n const seen = new Set<string>();\n const references: Array<Pick<StepSecretDto, 'store' | 'key'>> = [];\n for (const binding of bindings) {\n for (const segment of binding.segments) {\n if (segment.kind !== 'secret') continue;\n const id = secretReferenceId(segment);\n if (seen.has(id)) continue;\n seen.add(id);\n references.push({store: segment.store, key: segment.key});\n }\n }\n return references;\n}\n\nfunction secretReferenceId(reference: Pick<StepSecretDto, 'store' | 'key'>): string {\n return `${reference.store}\\0${reference.key}`;\n}\n"],"names":["getSecret","SecretDecryptionError","materializedSecretBindingSchema","stepSecretsParamsSchema","stepSecretsQuerySchema","stepSecretsResponseSchema","captureException","ClientError","defineRoute","logger","ZodError","z","loadRunningLeasedStep","secretBindingsSchema","array","getStepSecretsRoute","method","path","description","schema","params","querystring","response","errorHandler","error","status","cause","handler","request","reply","stepId","attempt","query","leasedJob","step","workspaceId","projectId","type","secretBindings","parseSecretBindings","config","secret_bindings","references","distinctSecretReferences","secrets","Promise","all","map","reference","value","namespace","key","store","info","jobId","keyCount","length","debug","keys","ref","header","parse","bindings","seen","Set","binding","segment","segments","kind","id","secretReferenceId","has","add","push"],"mappings":"AAAA,SAAQA,SAAS,EAAEC,qBAAqB,QAAO,uBAAuB;AACtE,SACEC,+BAA+B,EAE/BC,uBAAuB,EACvBC,sBAAsB,EACtBC,yBAAyB,QACpB,2BAA2B;AAClC,SAAQC,gBAAgB,QAAO,iCAAiC;AAChE,SAAQC,WAAW,EAAEC,WAAW,QAAO,wBAAwB;AAC/D,SAAQC,MAAM,QAAO,8BAA8B;AACnD,SAAQC,QAAQ,EAAEC,CAAC,QAAO,MAAM;AAChC,SAAQC,qBAAqB,QAAO,mBAAmB;AAEvD,MAAMC,uBAAuBF,EAAEG,KAAK,CAACZ;AAErC,OAAO,MAAMa,sBAAsBP,YAAY;IAC7CQ,QAAQ;IACRC,MAAM;IACNC,aACE;IACFC,QAAQ;QACNC,QAAQjB;QACRkB,aAAajB;QACbkB,UAAU;YACR,KAAKjB;QACP;IACF;IACAkB,cAAc,CAACC;QACb,IAAIA,iBAAiBvB,uBAAuB;YAC1CK,iBAAiBkB;YACjB,MAAM,IAAIjB,YAAY,sCAAsC,wBAAwB;gBAClFkB,QAAQ;gBACRC,OAAOF;YACT;QACF;QACA,MAAMA;IACR;IACAG,SAAS,OAAOC,SAASC;QACvB,MAAM,EAACC,MAAM,EAAC,GAAGF,QAAQR,MAAM;QAC/B,MAAM,EAACW,OAAO,EAAC,GAAGH,QAAQI,KAAK;QAC/B,MAAM,EAACC,SAAS,EAAEC,IAAI,EAAEC,WAAW,EAAEC,SAAS,EAAC,GAAG,MAAMxB,sBAAsB;YAC5EgB;YACAE;YACAC;QACF;QAEA,IAAIG,KAAKG,IAAI,KAAK,OAAO;YACvB,MAAM,IAAI9B,YAAY,0BAA0B,gBAAgB;gBAACkB,QAAQ;YAAG;QAC9E;QAEA,MAAMa,iBAAiBC,oBAAoBL,KAAKM,MAAM,CAACC,eAAe;QACtE,MAAMC,aAAaC,yBAAyBL;QAC5C,MAAMM,UAAU,MAAMC,QAAQC,GAAG,CAC/BJ,WAAWK,GAAG,CAAC,OAAOC;YACpB,MAAMC,QAAQ,MAAMjD,UAAU;gBAC5BmC;gBACAC;gBACAc,WAAW;gBACXC,KAAKH,UAAUG,GAAG;gBAClBC,OAAOJ,UAAUI,KAAK;YACxB;YACA,IAAIH,UAAU,MAAM;gBAClB,MAAM,IAAI1C,YAAY,oBAAoB,oBAAoB;oBAACkB,QAAQ;gBAAG;YAC5E;YACA,OAAO;gBAAC,GAAGuB,SAAS;gBAAEC;YAAK;QAC7B;QAGFxC,SAAS4C,IAAI,CACX;YAACC,OAAOrB,UAAUqB,KAAK;YAAEnB;YAAaL;YAAQyB,UAAUb,WAAWc,MAAM;QAAA,GACzE;QAEF/C,SAASgD,KAAK,CACZ;YAACH,OAAOrB,UAAUqB,KAAK;YAAEnB;YAAaL;YAAQ4B,MAAMhB,WAAWK,GAAG,CAAC,CAACY,MAAQA,IAAIR,GAAG;QAAC,GACpF;QAGFtB,MAAM+B,MAAM,CAAC,iBAAiB;QAC9B,OAAO;YAAChB;QAAO;IACjB;AACF,GAAG;AAEH,SAASL,oBAAoBU,KAAc;IACzC,IAAI;QACF,OAAOpC,qBAAqBgD,KAAK,CAACZ,SAAS,EAAE;IAC/C,EAAE,OAAOzB,OAAO;QACd,IAAIA,iBAAiBd,UAAU;YAC7B,MAAM,IAAIH,YAAY,oCAAoC,2BAA2B;gBACnFkB,QAAQ;gBACRC,OAAOF;YACT;QACF;QACA,MAAMA;IACR;AACF;AAEA,SAASmB,yBACPmB,QAAwE;IAExE,MAAMC,OAAO,IAAIC;IACjB,MAAMtB,aAA0D,EAAE;IAClE,KAAK,MAAMuB,WAAWH,SAAU;QAC9B,KAAK,MAAMI,WAAWD,QAAQE,QAAQ,CAAE;YACtC,IAAID,QAAQE,IAAI,KAAK,UAAU;YAC/B,MAAMC,KAAKC,kBAAkBJ;YAC7B,IAAIH,KAAKQ,GAAG,CAACF,KAAK;YAClBN,KAAKS,GAAG,CAACH;YACT3B,WAAW+B,IAAI,CAAC;gBAACrB,OAAOc,QAAQd,KAAK;gBAAED,KAAKe,QAAQf,GAAG;YAAA;QACzD;IACF;IACA,OAAOT;AACT;AAEA,SAAS4B,kBAAkBtB,SAA+C;IACxE,OAAO,GAAGA,UAAUI,KAAK,CAAC,EAAE,EAAEJ,UAAUG,GAAG,EAAE;AAC/C"}
@@ -0,0 +1,4 @@
1
+ import type { RouteGroup } from '@shipfox/node-fastify';
2
+ export declare const leaseTokenRouteGroup: RouteGroup;
3
+ export declare const workflowRoutes: RouteGroup[];
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/presentation/routes/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,uBAAuB,CAAC;AAatD,eAAO,MAAM,oBAAoB,EAAE,UAWlC,CAAC;AAEF,eAAO,MAAM,cAAc,EAAE,UAAU,EActC,CAAC"}
@@ -0,0 +1,41 @@
1
+ import { AUTH_LEASED_JOB, AUTH_USER } from '@shipfox/api-auth-context';
2
+ import { agentRuntimeConfigRoute } from './agent-runtime-config.js';
3
+ import { cancelRunRoute } from './cancel-run.js';
4
+ import { checkoutTokenRoute } from './checkout-token.js';
5
+ import { getRunRoute } from './get-run.js';
6
+ import { getRunAggregatesRoute } from './get-run-aggregates.js';
7
+ import { getStepSecretsRoute } from './get-step-secrets.js';
8
+ import { listRunAttemptsRoute } from './list-run-attempts.js';
9
+ import { listRunsRoute } from './list-runs.js';
10
+ import { nextStepRoute } from './next-step.js';
11
+ import { reportStepRoute } from './report-step.js';
12
+ import { rerunRunRoute } from './rerun-run.js';
13
+ export const leaseTokenRouteGroup = {
14
+ // The lease token names the job, so the path carries no job id ("current").
15
+ prefix: '/runs/jobs/current',
16
+ auth: AUTH_LEASED_JOB,
17
+ routes: [
18
+ nextStepRoute,
19
+ reportStepRoute,
20
+ checkoutTokenRoute,
21
+ agentRuntimeConfigRoute,
22
+ getStepSecretsRoute
23
+ ]
24
+ };
25
+ export const workflowRoutes = [
26
+ {
27
+ prefix: '/workflows/runs',
28
+ auth: AUTH_USER,
29
+ routes: [
30
+ listRunsRoute,
31
+ getRunAggregatesRoute,
32
+ listRunAttemptsRoute,
33
+ getRunRoute,
34
+ cancelRunRoute,
35
+ rerunRunRoute
36
+ ]
37
+ },
38
+ leaseTokenRouteGroup
39
+ ];
40
+
41
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/presentation/routes/index.ts"],"sourcesContent":["import {AUTH_LEASED_JOB, AUTH_USER} from '@shipfox/api-auth-context';\nimport type {RouteGroup} from '@shipfox/node-fastify';\nimport {agentRuntimeConfigRoute} from './agent-runtime-config.js';\nimport {cancelRunRoute} from './cancel-run.js';\nimport {checkoutTokenRoute} from './checkout-token.js';\nimport {getRunRoute} from './get-run.js';\nimport {getRunAggregatesRoute} from './get-run-aggregates.js';\nimport {getStepSecretsRoute} from './get-step-secrets.js';\nimport {listRunAttemptsRoute} from './list-run-attempts.js';\nimport {listRunsRoute} from './list-runs.js';\nimport {nextStepRoute} from './next-step.js';\nimport {reportStepRoute} from './report-step.js';\nimport {rerunRunRoute} from './rerun-run.js';\n\nexport const leaseTokenRouteGroup: RouteGroup = {\n // The lease token names the job, so the path carries no job id (\"current\").\n prefix: '/runs/jobs/current',\n auth: AUTH_LEASED_JOB,\n routes: [\n nextStepRoute,\n reportStepRoute,\n checkoutTokenRoute,\n agentRuntimeConfigRoute,\n getStepSecretsRoute,\n ],\n};\n\nexport const workflowRoutes: RouteGroup[] = [\n {\n prefix: '/workflows/runs',\n auth: AUTH_USER,\n routes: [\n listRunsRoute,\n getRunAggregatesRoute,\n listRunAttemptsRoute,\n getRunRoute,\n cancelRunRoute,\n rerunRunRoute,\n ],\n },\n leaseTokenRouteGroup,\n];\n"],"names":["AUTH_LEASED_JOB","AUTH_USER","agentRuntimeConfigRoute","cancelRunRoute","checkoutTokenRoute","getRunRoute","getRunAggregatesRoute","getStepSecretsRoute","listRunAttemptsRoute","listRunsRoute","nextStepRoute","reportStepRoute","rerunRunRoute","leaseTokenRouteGroup","prefix","auth","routes","workflowRoutes"],"mappings":"AAAA,SAAQA,eAAe,EAAEC,SAAS,QAAO,4BAA4B;AAErE,SAAQC,uBAAuB,QAAO,4BAA4B;AAClE,SAAQC,cAAc,QAAO,kBAAkB;AAC/C,SAAQC,kBAAkB,QAAO,sBAAsB;AACvD,SAAQC,WAAW,QAAO,eAAe;AACzC,SAAQC,qBAAqB,QAAO,0BAA0B;AAC9D,SAAQC,mBAAmB,QAAO,wBAAwB;AAC1D,SAAQC,oBAAoB,QAAO,yBAAyB;AAC5D,SAAQC,aAAa,QAAO,iBAAiB;AAC7C,SAAQC,aAAa,QAAO,iBAAiB;AAC7C,SAAQC,eAAe,QAAO,mBAAmB;AACjD,SAAQC,aAAa,QAAO,iBAAiB;AAE7C,OAAO,MAAMC,uBAAmC;IAC9C,4EAA4E;IAC5EC,QAAQ;IACRC,MAAMf;IACNgB,QAAQ;QACNN;QACAC;QACAP;QACAF;QACAK;KACD;AACH,EAAE;AAEF,OAAO,MAAMU,iBAA+B;IAC1C;QACEH,QAAQ;QACRC,MAAMd;QACNe,QAAQ;YACNP;YACAH;YACAE;YACAH;YACAF;YACAS;SACD;IACH;IACAC;CACD,CAAC"}
@@ -0,0 +1,14 @@
1
+ import { type LeasedJobContext } from '@shipfox/api-auth-context';
2
+ import type { Step } from '#core/entities/step.js';
3
+ export interface LoadedRunningLeasedStep {
4
+ leasedJob: LeasedJobContext;
5
+ step: Step;
6
+ workspaceId: string;
7
+ projectId: string;
8
+ }
9
+ export declare function loadRunningLeasedStep(params: {
10
+ request: object;
11
+ stepId: string;
12
+ attempt: number;
13
+ }): Promise<LoadedRunningLeasedStep>;
14
+ //# sourceMappingURL=leased-step.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"leased-step.d.ts","sourceRoot":"","sources":["../../../src/presentation/routes/leased-step.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,gBAAgB,EAA0B,MAAM,2BAA2B,CAAC;AAGzF,OAAO,KAAK,EAAC,IAAI,EAAC,MAAM,wBAAwB,CAAC;AAGjD,MAAM,WAAW,uBAAuB;IACtC,SAAS,EAAE,gBAAgB,CAAC;IAC5B,IAAI,EAAE,IAAI,CAAC;IACX,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,wBAAsB,qBAAqB,CAAC,MAAM,EAAE;IAClD,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;CACjB,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAoCnC"}