@shipfox/api-workflows 4.0.0 → 6.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 (277) hide show
  1. package/.turbo/turbo-build.log +4 -4
  2. package/CHANGELOG.md +104 -0
  3. package/dist/core/agent-defaults.d.ts +17 -0
  4. package/dist/core/agent-defaults.d.ts.map +1 -0
  5. package/dist/core/agent-defaults.js +21 -0
  6. package/dist/core/agent-defaults.js.map +1 -0
  7. package/dist/core/agent-tool-capability-warning.d.ts +4 -0
  8. package/dist/core/agent-tool-capability-warning.d.ts.map +1 -1
  9. package/dist/core/agent-tool-capability-warning.js +15 -17
  10. package/dist/core/agent-tool-capability-warning.js.map +1 -1
  11. package/dist/core/agent-tools.d.ts +11 -9
  12. package/dist/core/agent-tools.d.ts.map +1 -1
  13. package/dist/core/agent-tools.js +23 -18
  14. package/dist/core/agent-tools.js.map +1 -1
  15. package/dist/core/checkout.d.ts +21 -7
  16. package/dist/core/checkout.d.ts.map +1 -1
  17. package/dist/core/checkout.js +23 -11
  18. package/dist/core/checkout.js.map +1 -1
  19. package/dist/core/entities/workflow-run-attempt.d.ts +1 -1
  20. package/dist/core/entities/workflow-run-attempt.d.ts.map +1 -1
  21. package/dist/core/entities/workflow-run-attempt.js.map +1 -1
  22. package/dist/core/job-execution.d.ts +3 -1
  23. package/dist/core/job-execution.d.ts.map +1 -1
  24. package/dist/core/job-execution.js +14 -12
  25. package/dist/core/job-execution.js.map +1 -1
  26. package/dist/core/job-transition/derive-job-execution-outputs.d.ts +1 -1
  27. package/dist/core/job-transition/derive-job-execution-outputs.d.ts.map +1 -1
  28. package/dist/core/job-transition/derive-job-execution-outputs.js.map +1 -1
  29. package/dist/core/job-transition/derive-job-success.js +1 -1
  30. package/dist/core/job-transition/derive-job-success.js.map +1 -1
  31. package/dist/core/listener-execution-materialization.d.ts +3 -3
  32. package/dist/core/listener-execution-materialization.d.ts.map +1 -1
  33. package/dist/core/listener-execution-materialization.js +3 -4
  34. package/dist/core/listener-execution-materialization.js.map +1 -1
  35. package/dist/core/run-workflow.d.ts +12 -1
  36. package/dist/core/run-workflow.d.ts.map +1 -1
  37. package/dist/core/run-workflow.js +13 -8
  38. package/dist/core/run-workflow.js.map +1 -1
  39. package/dist/core/step-config/agent.d.ts +8 -8
  40. package/dist/core/step-config/agent.d.ts.map +1 -1
  41. package/dist/core/step-config/agent.js +12 -10
  42. package/dist/core/step-config/agent.js.map +1 -1
  43. package/dist/core/step-config/complete-step-dispatch-config.d.ts +4 -4
  44. package/dist/core/step-config/complete-step-dispatch-config.d.ts.map +1 -1
  45. package/dist/core/step-config/complete-step-dispatch-config.js +2 -2
  46. package/dist/core/step-config/complete-step-dispatch-config.js.map +1 -1
  47. package/dist/core/step-config/materialize-job-execution-steps.d.ts +3 -3
  48. package/dist/core/step-config/materialize-job-execution-steps.d.ts.map +1 -1
  49. package/dist/core/step-config/materialize-job-execution-steps.js +5 -6
  50. package/dist/core/step-config/materialize-job-execution-steps.js.map +1 -1
  51. package/dist/core/step-config/materialize-workflow-model.d.ts +3 -3
  52. package/dist/core/step-config/materialize-workflow-model.d.ts.map +1 -1
  53. package/dist/core/step-config/materialize-workflow-model.js +4 -4
  54. package/dist/core/step-config/materialize-workflow-model.js.map +1 -1
  55. package/dist/core/step-config/resolve-job-execution-name.d.ts +1 -1
  56. package/dist/core/step-config/resolve-job-execution-name.d.ts.map +1 -1
  57. package/dist/core/step-config/resolve-job-execution-name.js.map +1 -1
  58. package/dist/core/step-config/resolve-step-config.d.ts +4 -4
  59. package/dist/core/step-config/resolve-step-config.d.ts.map +1 -1
  60. package/dist/core/step-config/resolve-step-config.js +6 -6
  61. package/dist/core/step-config/resolve-step-config.js.map +1 -1
  62. package/dist/core/step-config/run.d.ts +1 -1
  63. package/dist/core/step-config/run.d.ts.map +1 -1
  64. package/dist/core/step-config/run.js.map +1 -1
  65. package/dist/core/workflow-run-creation.d.ts +3 -3
  66. package/dist/core/workflow-run-creation.d.ts.map +1 -1
  67. package/dist/core/workflow-run-creation.js +3 -4
  68. package/dist/core/workflow-run-creation.js.map +1 -1
  69. package/dist/db/db.d.ts +16 -4
  70. package/dist/db/db.d.ts.map +1 -1
  71. package/dist/db/job-listeners.d.ts +7 -1
  72. package/dist/db/job-listeners.d.ts.map +1 -1
  73. package/dist/db/job-listeners.js +10 -5
  74. package/dist/db/job-listeners.js.map +1 -1
  75. package/dist/db/runner-lease-table.d.ts +5 -5
  76. package/dist/db/runner-lease-table.d.ts.map +1 -1
  77. package/dist/db/runner-lease-table.js +3 -2
  78. package/dist/db/runner-lease-table.js.map +1 -1
  79. package/dist/db/schema/workflow-run-attempts.d.ts +9 -3
  80. package/dist/db/schema/workflow-run-attempts.d.ts.map +1 -1
  81. package/dist/db/schema/workflow-run-attempts.js +2 -1
  82. package/dist/db/schema/workflow-run-attempts.js.map +1 -1
  83. package/dist/db/schema/workflow-runs.js +1 -1
  84. package/dist/db/schema/workflow-runs.js.map +1 -1
  85. package/dist/db/workflow-runs/job-executions.d.ts +5 -0
  86. package/dist/db/workflow-runs/job-executions.d.ts.map +1 -1
  87. package/dist/db/workflow-runs/job-executions.js +14 -7
  88. package/dist/db/workflow-runs/job-executions.js.map +1 -1
  89. package/dist/db/workflow-runs/jobs.d.ts.map +1 -1
  90. package/dist/db/workflow-runs/jobs.js +3 -1
  91. package/dist/db/workflow-runs/jobs.js.map +1 -1
  92. package/dist/db/workflow-runs/run-create.d.ts +9 -2
  93. package/dist/db/workflow-runs/run-create.d.ts.map +1 -1
  94. package/dist/db/workflow-runs/run-create.js +12 -9
  95. package/dist/db/workflow-runs/run-create.js.map +1 -1
  96. package/dist/db/workflow-runs/run-rerun.d.ts.map +1 -1
  97. package/dist/db/workflow-runs/run-rerun.js +3 -1
  98. package/dist/db/workflow-runs/run-rerun.js.map +1 -1
  99. package/dist/index.d.ts +18 -4
  100. package/dist/index.d.ts.map +1 -1
  101. package/dist/index.js +61 -37
  102. package/dist/index.js.map +1 -1
  103. package/dist/presentation/dto/checkout-token.d.ts +14 -1
  104. package/dist/presentation/dto/checkout-token.d.ts.map +1 -1
  105. package/dist/presentation/dto/checkout-token.js.map +1 -1
  106. package/dist/presentation/index.d.ts +1 -1
  107. package/dist/presentation/index.d.ts.map +1 -1
  108. package/dist/presentation/index.js +1 -1
  109. package/dist/presentation/index.js.map +1 -1
  110. package/dist/presentation/inter-module.d.ts +18 -0
  111. package/dist/presentation/inter-module.d.ts.map +1 -0
  112. package/dist/presentation/inter-module.js +113 -0
  113. package/dist/presentation/inter-module.js.map +1 -0
  114. package/dist/presentation/routes/agent-runtime-config.d.ts +6 -1
  115. package/dist/presentation/routes/agent-runtime-config.d.ts.map +1 -1
  116. package/dist/presentation/routes/agent-runtime-config.js +59 -57
  117. package/dist/presentation/routes/agent-runtime-config.js.map +1 -1
  118. package/dist/presentation/routes/cancel-run.d.ts +2 -1
  119. package/dist/presentation/routes/cancel-run.d.ts.map +1 -1
  120. package/dist/presentation/routes/cancel-run.js +37 -34
  121. package/dist/presentation/routes/cancel-run.js.map +1 -1
  122. package/dist/presentation/routes/checkout-token.d.ts +8 -1
  123. package/dist/presentation/routes/checkout-token.d.ts.map +1 -1
  124. package/dist/presentation/routes/checkout-token.js +65 -47
  125. package/dist/presentation/routes/checkout-token.js.map +1 -1
  126. package/dist/presentation/routes/get-run-aggregates.d.ts +2 -1
  127. package/dist/presentation/routes/get-run-aggregates.d.ts.map +1 -1
  128. package/dist/presentation/routes/get-run-aggregates.js +44 -53
  129. package/dist/presentation/routes/get-run-aggregates.js.map +1 -1
  130. package/dist/presentation/routes/get-run.d.ts +2 -1
  131. package/dist/presentation/routes/get-run.d.ts.map +1 -1
  132. package/dist/presentation/routes/get-run.js +53 -50
  133. package/dist/presentation/routes/get-run.js.map +1 -1
  134. package/dist/presentation/routes/get-step-secrets.d.ts +3 -1
  135. package/dist/presentation/routes/get-step-secrets.d.ts.map +1 -1
  136. package/dist/presentation/routes/get-step-secrets.js +72 -68
  137. package/dist/presentation/routes/get-step-secrets.js.map +1 -1
  138. package/dist/presentation/routes/index.d.ts +19 -2
  139. package/dist/presentation/routes/index.d.ts.map +1 -1
  140. package/dist/presentation/routes/index.js +38 -30
  141. package/dist/presentation/routes/index.js.map +1 -1
  142. package/dist/presentation/routes/leased-step.d.ts +2 -0
  143. package/dist/presentation/routes/leased-step.d.ts.map +1 -1
  144. package/dist/presentation/routes/leased-step.js +1 -2
  145. package/dist/presentation/routes/leased-step.js.map +1 -1
  146. package/dist/presentation/routes/list-run-attempts.d.ts +2 -1
  147. package/dist/presentation/routes/list-run-attempts.d.ts.map +1 -1
  148. package/dist/presentation/routes/list-run-attempts.js +29 -26
  149. package/dist/presentation/routes/list-run-attempts.js.map +1 -1
  150. package/dist/presentation/routes/list-runs.d.ts +2 -1
  151. package/dist/presentation/routes/list-runs.d.ts.map +1 -1
  152. package/dist/presentation/routes/list-runs.js +51 -60
  153. package/dist/presentation/routes/list-runs.js.map +1 -1
  154. package/dist/presentation/routes/next-step.d.ts +10 -1
  155. package/dist/presentation/routes/next-step.d.ts.map +1 -1
  156. package/dist/presentation/routes/next-step.js +64 -50
  157. package/dist/presentation/routes/next-step.js.map +1 -1
  158. package/dist/presentation/routes/project-access.d.ts +10 -0
  159. package/dist/presentation/routes/project-access.d.ts.map +1 -0
  160. package/dist/presentation/routes/project-access.js +17 -0
  161. package/dist/presentation/routes/project-access.js.map +1 -0
  162. package/dist/presentation/routes/report-step.d.ts +2 -1
  163. package/dist/presentation/routes/report-step.d.ts.map +1 -1
  164. package/dist/presentation/routes/report-step.js +62 -61
  165. package/dist/presentation/routes/report-step.js.map +1 -1
  166. package/dist/presentation/routes/require-accessible-run.d.ts +3 -1
  167. package/dist/presentation/routes/require-accessible-run.d.ts.map +1 -1
  168. package/dist/presentation/routes/require-accessible-run.js +3 -6
  169. package/dist/presentation/routes/require-accessible-run.js.map +1 -1
  170. package/dist/presentation/routes/rerun-run.d.ts +2 -1
  171. package/dist/presentation/routes/rerun-run.d.ts.map +1 -1
  172. package/dist/presentation/routes/rerun-run.js +46 -43
  173. package/dist/presentation/routes/rerun-run.js.map +1 -1
  174. package/dist/temporal/activities/index.d.ts +44 -9
  175. package/dist/temporal/activities/index.d.ts.map +1 -1
  176. package/dist/temporal/activities/index.js +13 -9
  177. package/dist/temporal/activities/index.js.map +1 -1
  178. package/dist/temporal/activities/orchestration-activities.d.ts +20 -11
  179. package/dist/temporal/activities/orchestration-activities.d.ts.map +1 -1
  180. package/dist/temporal/activities/orchestration-activities.js +48 -33
  181. package/dist/temporal/activities/orchestration-activities.js.map +1 -1
  182. package/dist/tsconfig.test.tsbuildinfo +1 -1
  183. package/package.json +41 -44
  184. package/src/core/agent-defaults.test.ts +28 -0
  185. package/src/core/agent-defaults.ts +36 -0
  186. package/src/core/agent-tool-capability-warning.test.ts +36 -11
  187. package/src/core/agent-tool-capability-warning.ts +27 -25
  188. package/src/core/agent-tools.ts +33 -36
  189. package/src/core/checkout.test.ts +38 -25
  190. package/src/core/checkout.ts +41 -14
  191. package/src/core/entities/workflow-run-attempt.ts +1 -1
  192. package/src/core/job-execution.ts +19 -9
  193. package/src/core/job-transition/derive-job-execution-outputs.ts +1 -1
  194. package/src/core/job-transition/derive-job-success.ts +1 -1
  195. package/src/core/listener-execution-materialization.test.ts +4 -2
  196. package/src/core/listener-execution-materialization.ts +6 -9
  197. package/src/core/run-workflow.test.ts +43 -38
  198. package/src/core/run-workflow.ts +26 -9
  199. package/src/core/step-config/agent.ts +24 -26
  200. package/src/core/step-config/complete-step-dispatch-config.test.ts +22 -23
  201. package/src/core/step-config/complete-step-dispatch-config.ts +6 -6
  202. package/src/core/step-config/materialize-job-execution-steps.test.ts +34 -23
  203. package/src/core/step-config/materialize-job-execution-steps.ts +38 -39
  204. package/src/core/step-config/materialize-workflow-model.test.ts +94 -82
  205. package/src/core/step-config/materialize-workflow-model.ts +31 -29
  206. package/src/core/step-config/resolve-job-execution-name.ts +1 -1
  207. package/src/core/step-config/resolve-step-config.ts +11 -9
  208. package/src/core/step-config/run.ts +1 -1
  209. package/src/core/workflow-run-creation.test.ts +14 -10
  210. package/src/core/workflow-run-creation.ts +6 -9
  211. package/src/db/job-listeners.ts +20 -5
  212. package/src/db/runner-lease-table.ts +2 -2
  213. package/src/db/schema/workflow-run-attempts.ts +7 -3
  214. package/src/db/schema/workflow-runs.ts +1 -1
  215. package/src/db/workflow-runs/job-executions.ts +15 -1
  216. package/src/db/workflow-runs/jobs.ts +4 -1
  217. package/src/db/workflow-runs/run-create.test.ts +7 -1
  218. package/src/db/workflow-runs/run-create.ts +25 -15
  219. package/src/db/workflow-runs/run-rerun.test.ts +1 -1
  220. package/src/db/workflow-runs/run-rerun.ts +6 -3
  221. package/src/index.ts +75 -33
  222. package/src/presentation/dto/checkout-token.ts +7 -1
  223. package/src/presentation/index.ts +1 -1
  224. package/src/presentation/inter-module.test.ts +149 -0
  225. package/src/presentation/inter-module.ts +132 -0
  226. package/src/presentation/routes/agent-runtime-config.test.ts +53 -10
  227. package/src/presentation/routes/agent-runtime-config.ts +89 -64
  228. package/src/presentation/routes/cancel-run.test.ts +10 -20
  229. package/src/presentation/routes/cancel-run.ts +30 -27
  230. package/src/presentation/routes/checkout-token.test.ts +52 -33
  231. package/src/presentation/routes/checkout-token.ts +109 -49
  232. package/src/presentation/routes/get-run-aggregates.test.ts +13 -7
  233. package/src/presentation/routes/get-run-aggregates.ts +54 -57
  234. package/src/presentation/routes/get-run.test.ts +10 -18
  235. package/src/presentation/routes/get-run.ts +51 -48
  236. package/src/presentation/routes/get-step-secrets.test.ts +29 -7
  237. package/src/presentation/routes/get-step-secrets.ts +72 -61
  238. package/src/presentation/routes/index.test.ts +16 -1
  239. package/src/presentation/routes/index.ts +54 -29
  240. package/src/presentation/routes/leased-step.ts +3 -2
  241. package/src/presentation/routes/list-run-attempts.test.ts +9 -19
  242. package/src/presentation/routes/list-run-attempts.ts +21 -18
  243. package/src/presentation/routes/list-runs.test.ts +13 -7
  244. package/src/presentation/routes/list-runs.ts +64 -67
  245. package/src/presentation/routes/next-step.test.ts +30 -11
  246. package/src/presentation/routes/next-step.ts +68 -48
  247. package/src/presentation/routes/project-access.ts +16 -0
  248. package/src/presentation/routes/report-step.test.ts +18 -2
  249. package/src/presentation/routes/report-step.ts +51 -49
  250. package/src/presentation/routes/require-accessible-run.ts +5 -2
  251. package/src/presentation/routes/rerun-run.test.ts +9 -19
  252. package/src/presentation/routes/rerun-run.ts +39 -36
  253. package/src/temporal/activities/index.ts +32 -12
  254. package/src/temporal/activities/orchestration-activities.test.ts +10 -8
  255. package/src/temporal/activities/orchestration-activities.ts +74 -50
  256. package/src/temporal/workflows/job-execution-orchestration.test.ts +47 -2
  257. package/test/env.ts +1 -3
  258. package/test/factories/project.ts +10 -5
  259. package/test/factories/workflow-model.test.ts +5 -1
  260. package/test/factories/workflow-model.ts +1 -1
  261. package/test/factories/workflow-run.ts +1 -1
  262. package/test/fixtures/agent-inter-module.ts +27 -0
  263. package/test/fixtures/annotations-inter-module.ts +5 -0
  264. package/test/fixtures/auth-inter-module.ts +22 -0
  265. package/test/fixtures/lease-token.ts +2 -1
  266. package/test/fixtures/projects-inter-module.ts +8 -0
  267. package/test/fixtures/runners-inter-module.ts +52 -0
  268. package/test/fixtures/secrets-inter-module.ts +61 -0
  269. package/test/globalSetup.ts +11 -11
  270. package/tsconfig.build.tsbuildinfo +1 -1
  271. package/dist/core/source-control.d.ts +0 -5
  272. package/dist/core/source-control.d.ts.map +0 -1
  273. package/dist/core/source-control.js +0 -19
  274. package/dist/core/source-control.js.map +0 -1
  275. package/src/core/source-control.test.ts +0 -17
  276. package/src/core/source-control.ts +0 -22
  277. package/src/temporal/workflows/job-execution-orchestration-timeout.test.ts +0 -165
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/db/workflow-runs/run-rerun.ts"],"sourcesContent":["import {and, asc, eq, inArray, sql} from 'drizzle-orm';\nimport {isWorkflowRunTerminal, type WorkflowRun} from '#core/entities/workflow-run.js';\nimport {NoFailedJobsError, RunNotTerminalError, SourceRunNotFoundError} from '#core/errors.js';\nimport {deriveJobExecutionRunner} from '#core/workflow-run-creation.js';\nimport {recordWorkflowRunCreated} from '#metrics/instance.js';\nimport {db, type Tx} from '../db.js';\nimport {type JobExecutionDb, jobExecutions} from '../schema/job-executions.js';\nimport {type JobDb, jobs} from '../schema/jobs.js';\nimport {type StepDb, steps} from '../schema/steps.js';\nimport {type WorkflowRunAttemptDb, workflowRunAttempts} from '../schema/workflow-run-attempts.js';\nimport {toWorkflowRun, workflowRuns} from '../schema/workflow-runs.js';\nimport {type MaterializedRunGraphJob, persistMaterializedRunGraph} from './run-graph.js';\nimport {lockWorkflowRun} from './shared.js';\n\nexport interface CreateRerunWorkflowRunParams {\n workflowRunId: string;\n mode: 'all' | 'failed';\n actorUserId: string;\n}\n\nexport async function createRerunWorkflowRun(\n params: CreateRerunWorkflowRunParams,\n): Promise<WorkflowRun> {\n const result = await db().transaction(async (tx) => {\n const workflowRunId = params.workflowRunId;\n await tx.execute(sql`select pg_advisory_xact_lock(hashtext(${workflowRunId}))`);\n\n const sourceRow = await lockWorkflowRun(workflowRunId, tx);\n if (!sourceRow) throw new SourceRunNotFoundError(workflowRunId);\n\n const [sourceAttemptRow] = await tx\n .select()\n .from(workflowRunAttempts)\n .where(\n and(\n eq(workflowRunAttempts.workflowRunId, sourceRow.id),\n eq(workflowRunAttempts.attempt, sourceRow.currentAttempt),\n ),\n )\n .limit(1)\n .for('update');\n if (!sourceAttemptRow) {\n throw new Error(\n `Current attempt ${sourceRow.currentAttempt} missing for run ${sourceRow.id}`,\n );\n }\n if (!isWorkflowRunTerminal(sourceAttemptRow.status)) {\n throw new RunNotTerminalError(sourceRow.id);\n }\n\n const sourceJobs = await tx\n .select()\n .from(jobs)\n .where(eq(jobs.workflowRunAttemptId, sourceAttemptRow.id))\n .orderBy(asc(jobs.position), asc(jobs.id));\n\n if (\n params.mode === 'failed' &&\n !sourceJobs.some((job) => job.status === 'failed' || job.status === 'cancelled')\n ) {\n throw new NoFailedJobsError(sourceRow.id);\n }\n\n const [attemptRow] = await tx\n .select({value: sql<number>`coalesce(max(${workflowRunAttempts.attempt}), 1)`})\n .from(workflowRunAttempts)\n .where(eq(workflowRunAttempts.workflowRunId, sourceRow.id));\n const attempt = Number(attemptRow?.value ?? 1) + 1;\n\n const [newAttemptRow] = await tx\n .insert(workflowRunAttempts)\n .values({\n workflowRunId: sourceRow.id,\n attempt,\n status: 'pending',\n rerunMode: params.mode,\n rerunByUserId: params.actorUserId,\n model: sourceAttemptRow.model,\n agentToolMaterialization: sourceAttemptRow.agentToolMaterialization,\n })\n .returning();\n if (!newAttemptRow) throw new Error('Insert returned no rows');\n\n const sourceGraph = await loadRerunSourceGraph(tx, sourceJobs);\n\n const sourceRun = toWorkflowRun(sourceRow);\n const graphJobs = materializeRerunGraphJobs({\n mode: params.mode,\n sourceRun,\n sourceAttempt: sourceAttemptRow,\n sourceJobs,\n ...sourceGraph,\n });\n await persistMaterializedRunGraph(tx, {\n run: sourceRun,\n workflowRunAttempt: newAttemptRow,\n materializedJobs: graphJobs,\n });\n\n const [newRunRow] = await tx\n .update(workflowRuns)\n .set({\n currentAttempt: attempt,\n status: 'pending',\n version: sql`${workflowRuns.version} + 1`,\n updatedAt: new Date(),\n startedAt: null,\n finishedAt: null,\n })\n .where(eq(workflowRuns.id, sourceRow.id))\n .returning();\n if (!newRunRow) throw new Error(`Workflow run missing after rerun: ${sourceRow.id}`);\n\n return toWorkflowRun(newRunRow);\n });\n\n recordWorkflowRunCreated(result.triggerPayload.provider ?? result.triggerSource);\n\n return result;\n}\n\nasync function loadRerunSourceGraph(\n tx: Tx,\n sourceJobs: readonly JobDb[],\n): Promise<{\n readonly sourceJobExecutionByJobId: ReadonlyMap<string, JobExecutionDb>;\n readonly sourceJobByJobExecutionId: ReadonlyMap<string, JobDb>;\n readonly sourceSteps: readonly StepDb[];\n}> {\n const sourceJobIds = sourceJobs.map((job) => job.id);\n const sourceJobExecutionRows =\n sourceJobIds.length === 0\n ? []\n : await tx\n .select()\n .from(jobExecutions)\n .where(inArray(jobExecutions.jobId, sourceJobIds))\n .orderBy(asc(jobExecutions.jobId), asc(jobExecutions.sequence), asc(jobExecutions.id));\n const sourceJobExecutionByJobId = new Map<string, JobExecutionDb>();\n for (const jobExecution of sourceJobExecutionRows) {\n if (!sourceJobExecutionByJobId.has(jobExecution.jobId)) {\n sourceJobExecutionByJobId.set(jobExecution.jobId, jobExecution);\n }\n }\n\n const sourceJobExecutionIds = [...sourceJobExecutionByJobId.values()].map(\n (jobExecution) => jobExecution.id,\n );\n const sourceSteps =\n sourceJobExecutionIds.length === 0\n ? []\n : await tx\n .select()\n .from(steps)\n .where(inArray(steps.jobExecutionId, sourceJobExecutionIds))\n .orderBy(asc(steps.jobExecutionId), asc(steps.position), asc(steps.id));\n\n const sourceJobById = new Map(sourceJobs.map((job) => [job.id, job]));\n const sourceJobByJobExecutionId = new Map(\n [...sourceJobExecutionByJobId.entries()].flatMap(([jobId, jobExecution]) => {\n const job = sourceJobById.get(jobId);\n return job ? [[jobExecution.id, job] as const] : [];\n }),\n );\n\n return {sourceJobExecutionByJobId, sourceJobByJobExecutionId, sourceSteps};\n}\n\nfunction materializeRerunGraphJobs(params: {\n readonly mode: CreateRerunWorkflowRunParams['mode'];\n readonly sourceRun: WorkflowRun;\n readonly sourceAttempt: WorkflowRunAttemptDb;\n readonly sourceJobs: readonly JobDb[];\n readonly sourceJobExecutionByJobId: ReadonlyMap<string, JobExecutionDb>;\n readonly sourceJobByJobExecutionId: ReadonlyMap<string, JobDb>;\n readonly sourceSteps: readonly StepDb[];\n}): readonly MaterializedRunGraphJob[] {\n const sourceModelJobByKey = new Map(\n (params.sourceAttempt.model?.jobs ?? []).map((job) => [job.key, job]),\n );\n const sourceStepsByJobId = new Map<string, StepDb[]>();\n for (const step of params.sourceSteps) {\n const sourceJob = params.sourceJobByJobExecutionId.get(step.jobExecutionId);\n if (!sourceJob) continue;\n const sourceJobSteps = sourceStepsByJobId.get(sourceJob.id) ?? [];\n sourceJobSteps.push(step);\n sourceStepsByJobId.set(sourceJob.id, sourceJobSteps);\n }\n\n return params.sourceJobs.map((sourceJob) => {\n const carriedOver = params.mode === 'failed' && sourceJob.status === 'succeeded';\n\n return {\n job: {\n key: sourceJob.key,\n name: sourceJob.name,\n mode: sourceJob.mode,\n status: carriedOver ? ('succeeded' as const) : ('pending' as const),\n statusReason: null,\n carriedOver,\n checkoutPersistCredentials: sourceJob.checkoutPersistCredentials,\n checkoutPermissionsContents: sourceJob.checkoutPermissionsContents,\n success: sourceJob.success,\n executionTimeoutMs: sourceJob.executionTimeoutMs,\n listeningTimeoutMs: sourceJob.listeningTimeoutMs,\n maxExecutions: sourceJob.maxExecutions,\n onResolve: sourceJob.onResolve,\n batchDebounceMs: sourceJob.batchDebounceMs,\n batchMaxSize: sourceJob.batchMaxSize,\n batchMaxWaitMs: sourceJob.batchMaxWaitMs,\n listenerStatus: 'inactive' as const,\n resolutionReason: null,\n listeningOn: sourceJob.listeningOn ? [...sourceJob.listeningOn] : null,\n listeningUntil: sourceJob.listeningUntil ? [...sourceJob.listeningUntil] : null,\n outputs: carriedOver && sourceJob.outputs ? {...sourceJob.outputs} : null,\n dependencies: [...sourceJob.dependencies],\n runner: sourceJob.runner ? [...sourceJob.runner] : null,\n position: sourceJob.position,\n },\n createExecution: (job) => {\n if (job.mode === 'listening') return undefined;\n\n const sourceExecution = params.sourceJobExecutionByJobId.get(sourceJob.id);\n const modelJob = sourceModelJobByKey.get(job.key);\n const executionName = sourceExecution?.name ?? `${job.key} #1`;\n const runner =\n carriedOver || modelJob === undefined\n ? (sourceExecution?.runner ?? job.runner ?? null)\n : deriveJobExecutionRunner({\n run: params.sourceRun,\n modelJob,\n jobId: job.id,\n sequence: 1,\n executionName,\n status: 'pending',\n });\n\n return {\n sequence: 1,\n name: executionName,\n runner: runner ? [...runner] : null,\n status: carriedOver ? ('succeeded' as const) : ('pending' as const),\n statusReason: null,\n outputs: carriedOver && sourceExecution?.outputs ? {...sourceExecution.outputs} : null,\n ...(carriedOver ? {finishedAt: sql`now()`} : {}),\n };\n },\n createSteps: () =>\n (sourceStepsByJobId.get(sourceJob.id) ?? []).map((step) => ({\n key: step.key,\n name: step.name,\n sourceLocation: step.sourceLocation,\n status: carriedOver ? step.status : ('pending' as const),\n statusReason: carriedOver ? step.statusReason : null,\n type: step.type,\n config: step.config,\n condition: step.condition ?? null,\n configPlan: step.configPlan,\n authoredConfig: step.authoredConfig,\n error: null,\n position: step.position,\n currentAttempt: 1,\n })),\n };\n });\n}\n"],"names":["and","asc","eq","inArray","sql","isWorkflowRunTerminal","NoFailedJobsError","RunNotTerminalError","SourceRunNotFoundError","deriveJobExecutionRunner","recordWorkflowRunCreated","db","jobExecutions","jobs","steps","workflowRunAttempts","toWorkflowRun","workflowRuns","persistMaterializedRunGraph","lockWorkflowRun","createRerunWorkflowRun","params","result","transaction","tx","workflowRunId","execute","sourceRow","sourceAttemptRow","select","from","where","id","attempt","currentAttempt","limit","for","Error","status","sourceJobs","workflowRunAttemptId","orderBy","position","mode","some","job","attemptRow","value","Number","newAttemptRow","insert","values","rerunMode","rerunByUserId","actorUserId","model","agentToolMaterialization","returning","sourceGraph","loadRerunSourceGraph","sourceRun","graphJobs","materializeRerunGraphJobs","sourceAttempt","run","workflowRunAttempt","materializedJobs","newRunRow","update","set","version","updatedAt","Date","startedAt","finishedAt","triggerPayload","provider","triggerSource","sourceJobIds","map","sourceJobExecutionRows","length","jobId","sequence","sourceJobExecutionByJobId","Map","jobExecution","has","sourceJobExecutionIds","sourceSteps","jobExecutionId","sourceJobById","sourceJobByJobExecutionId","entries","flatMap","get","sourceModelJobByKey","key","sourceStepsByJobId","step","sourceJob","sourceJobSteps","push","carriedOver","name","statusReason","checkoutPersistCredentials","checkoutPermissionsContents","success","executionTimeoutMs","listeningTimeoutMs","maxExecutions","onResolve","batchDebounceMs","batchMaxSize","batchMaxWaitMs","listenerStatus","resolutionReason","listeningOn","listeningUntil","outputs","dependencies","runner","createExecution","undefined","sourceExecution","modelJob","executionName","createSteps","sourceLocation","type","config","condition","configPlan","authoredConfig","error"],"mappings":"AAAA,SAAQA,GAAG,EAAEC,GAAG,EAAEC,EAAE,EAAEC,OAAO,EAAEC,GAAG,QAAO,cAAc;AACvD,SAAQC,qBAAqB,QAAyB,iCAAiC;AACvF,SAAQC,iBAAiB,EAAEC,mBAAmB,EAAEC,sBAAsB,QAAO,kBAAkB;AAC/F,SAAQC,wBAAwB,QAAO,iCAAiC;AACxE,SAAQC,wBAAwB,QAAO,uBAAuB;AAC9D,SAAQC,EAAE,QAAgB,WAAW;AACrC,SAA6BC,aAAa,QAAO,8BAA8B;AAC/E,SAAoBC,IAAI,QAAO,oBAAoB;AACnD,SAAqBC,KAAK,QAAO,qBAAqB;AACtD,SAAmCC,mBAAmB,QAAO,qCAAqC;AAClG,SAAQC,aAAa,EAAEC,YAAY,QAAO,6BAA6B;AACvE,SAAsCC,2BAA2B,QAAO,iBAAiB;AACzF,SAAQC,eAAe,QAAO,cAAc;AAQ5C,OAAO,eAAeC,uBACpBC,MAAoC;IAEpC,MAAMC,SAAS,MAAMX,KAAKY,WAAW,CAAC,OAAOC;QAC3C,MAAMC,gBAAgBJ,OAAOI,aAAa;QAC1C,MAAMD,GAAGE,OAAO,CAACtB,GAAG,CAAC,sCAAsC,EAAEqB,cAAc,EAAE,CAAC;QAE9E,MAAME,YAAY,MAAMR,gBAAgBM,eAAeD;QACvD,IAAI,CAACG,WAAW,MAAM,IAAInB,uBAAuBiB;QAEjD,MAAM,CAACG,iBAAiB,GAAG,MAAMJ,GAC9BK,MAAM,GACNC,IAAI,CAACf,qBACLgB,KAAK,CACJ/B,IACEE,GAAGa,oBAAoBU,aAAa,EAAEE,UAAUK,EAAE,GAClD9B,GAAGa,oBAAoBkB,OAAO,EAAEN,UAAUO,cAAc,IAG3DC,KAAK,CAAC,GACNC,GAAG,CAAC;QACP,IAAI,CAACR,kBAAkB;YACrB,MAAM,IAA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c;wBACnCC,OAAO;wBACP7F,UAAUyD,KAAKzD,QAAQ;wBACvBR,gBAAgB;oBAClB,CAAA;QACJ;IACF;AACF"}
1
+ {"version":3,"sources":["../../../src/db/workflow-runs/run-rerun.ts"],"sourcesContent":["import {readPersistedWorkflowModel} from '@shipfox/api-definitions-dto';\nimport {and, asc, eq, inArray, sql} from 'drizzle-orm';\nimport {isWorkflowRunTerminal, type WorkflowRun} from '#core/entities/workflow-run.js';\nimport {NoFailedJobsError, RunNotTerminalError, SourceRunNotFoundError} from '#core/errors.js';\nimport {deriveJobExecutionRunner} from '#core/workflow-run-creation.js';\nimport {recordWorkflowRunCreated} from '#metrics/instance.js';\nimport {db, type Tx} from '../db.js';\nimport {type JobExecutionDb, jobExecutions} from '../schema/job-executions.js';\nimport {type JobDb, jobs} from '../schema/jobs.js';\nimport {type StepDb, steps} from '../schema/steps.js';\nimport {type WorkflowRunAttemptDb, workflowRunAttempts} from '../schema/workflow-run-attempts.js';\nimport {toWorkflowRun, workflowRuns} from '../schema/workflow-runs.js';\nimport {type MaterializedRunGraphJob, persistMaterializedRunGraph} from './run-graph.js';\nimport {lockWorkflowRun} from './shared.js';\n\nexport interface CreateRerunWorkflowRunParams {\n workflowRunId: string;\n mode: 'all' | 'failed';\n actorUserId: string;\n}\n\nexport async function createRerunWorkflowRun(\n params: CreateRerunWorkflowRunParams,\n): Promise<WorkflowRun> {\n const result = await db().transaction(async (tx) => {\n const workflowRunId = params.workflowRunId;\n await tx.execute(sql`select pg_advisory_xact_lock(hashtext(${workflowRunId}))`);\n\n const sourceRow = await lockWorkflowRun(workflowRunId, tx);\n if (!sourceRow) throw new SourceRunNotFoundError(workflowRunId);\n\n const [sourceAttemptRow] = await tx\n .select()\n .from(workflowRunAttempts)\n .where(\n and(\n eq(workflowRunAttempts.workflowRunId, sourceRow.id),\n eq(workflowRunAttempts.attempt, sourceRow.currentAttempt),\n ),\n )\n .limit(1)\n .for('update');\n if (!sourceAttemptRow) {\n throw new Error(\n `Current attempt ${sourceRow.currentAttempt} missing for run ${sourceRow.id}`,\n );\n }\n if (!isWorkflowRunTerminal(sourceAttemptRow.status)) {\n throw new RunNotTerminalError(sourceRow.id);\n }\n\n const sourceJobs = await tx\n .select()\n .from(jobs)\n .where(eq(jobs.workflowRunAttemptId, sourceAttemptRow.id))\n .orderBy(asc(jobs.position), asc(jobs.id));\n\n if (\n params.mode === 'failed' &&\n !sourceJobs.some((job) => job.status === 'failed' || job.status === 'cancelled')\n ) {\n throw new NoFailedJobsError(sourceRow.id);\n }\n\n const [attemptRow] = await tx\n .select({value: sql<number>`coalesce(max(${workflowRunAttempts.attempt}), 1)`})\n .from(workflowRunAttempts)\n .where(eq(workflowRunAttempts.workflowRunId, sourceRow.id));\n const attempt = Number(attemptRow?.value ?? 1) + 1;\n\n const [newAttemptRow] = await tx\n .insert(workflowRunAttempts)\n .values({\n workflowRunId: sourceRow.id,\n attempt,\n status: 'pending',\n rerunMode: params.mode,\n rerunByUserId: params.actorUserId,\n model: sourceAttemptRow.model,\n agentToolMaterialization: sourceAttemptRow.agentToolMaterialization,\n })\n .returning();\n if (!newAttemptRow) throw new Error('Insert returned no rows');\n\n const sourceGraph = await loadRerunSourceGraph(tx, sourceJobs);\n\n const sourceRun = toWorkflowRun(sourceRow);\n const graphJobs = materializeRerunGraphJobs({\n mode: params.mode,\n sourceRun,\n sourceAttempt: sourceAttemptRow,\n sourceJobs,\n ...sourceGraph,\n });\n await persistMaterializedRunGraph(tx, {\n run: sourceRun,\n workflowRunAttempt: newAttemptRow,\n materializedJobs: graphJobs,\n });\n\n const [newRunRow] = await tx\n .update(workflowRuns)\n .set({\n currentAttempt: attempt,\n status: 'pending',\n version: sql`${workflowRuns.version} + 1`,\n updatedAt: new Date(),\n startedAt: null,\n finishedAt: null,\n })\n .where(eq(workflowRuns.id, sourceRow.id))\n .returning();\n if (!newRunRow) throw new Error(`Workflow run missing after rerun: ${sourceRow.id}`);\n\n return toWorkflowRun(newRunRow);\n });\n\n recordWorkflowRunCreated(result.triggerPayload.provider ?? result.triggerSource);\n\n return result;\n}\n\nasync function loadRerunSourceGraph(\n tx: Tx,\n sourceJobs: readonly JobDb[],\n): Promise<{\n readonly sourceJobExecutionByJobId: ReadonlyMap<string, JobExecutionDb>;\n readonly sourceJobByJobExecutionId: ReadonlyMap<string, JobDb>;\n readonly sourceSteps: readonly StepDb[];\n}> {\n const sourceJobIds = sourceJobs.map((job) => job.id);\n const sourceJobExecutionRows =\n sourceJobIds.length === 0\n ? []\n : await tx\n .select()\n .from(jobExecutions)\n .where(inArray(jobExecutions.jobId, sourceJobIds))\n .orderBy(asc(jobExecutions.jobId), asc(jobExecutions.sequence), asc(jobExecutions.id));\n const sourceJobExecutionByJobId = new Map<string, JobExecutionDb>();\n for (const jobExecution of sourceJobExecutionRows) {\n if (!sourceJobExecutionByJobId.has(jobExecution.jobId)) {\n sourceJobExecutionByJobId.set(jobExecution.jobId, jobExecution);\n }\n }\n\n const sourceJobExecutionIds = [...sourceJobExecutionByJobId.values()].map(\n (jobExecution) => jobExecution.id,\n );\n const sourceSteps =\n sourceJobExecutionIds.length === 0\n ? []\n : await tx\n .select()\n .from(steps)\n .where(inArray(steps.jobExecutionId, sourceJobExecutionIds))\n .orderBy(asc(steps.jobExecutionId), asc(steps.position), asc(steps.id));\n\n const sourceJobById = new Map(sourceJobs.map((job) => [job.id, job]));\n const sourceJobByJobExecutionId = new Map(\n [...sourceJobExecutionByJobId.entries()].flatMap(([jobId, jobExecution]) => {\n const job = sourceJobById.get(jobId);\n return job ? [[jobExecution.id, job] as const] : [];\n }),\n );\n\n return {sourceJobExecutionByJobId, sourceJobByJobExecutionId, sourceSteps};\n}\n\nfunction materializeRerunGraphJobs(params: {\n readonly mode: CreateRerunWorkflowRunParams['mode'];\n readonly sourceRun: WorkflowRun;\n readonly sourceAttempt: WorkflowRunAttemptDb;\n readonly sourceJobs: readonly JobDb[];\n readonly sourceJobExecutionByJobId: ReadonlyMap<string, JobExecutionDb>;\n readonly sourceJobByJobExecutionId: ReadonlyMap<string, JobDb>;\n readonly sourceSteps: readonly StepDb[];\n}): readonly MaterializedRunGraphJob[] {\n const sourceModel =\n params.sourceAttempt.model === null\n ? null\n : readPersistedWorkflowModel(params.sourceAttempt.model);\n const sourceModelJobByKey = new Map((sourceModel?.jobs ?? []).map((job) => [job.key, job]));\n const sourceStepsByJobId = new Map<string, StepDb[]>();\n for (const step of params.sourceSteps) {\n const sourceJob = params.sourceJobByJobExecutionId.get(step.jobExecutionId);\n if (!sourceJob) continue;\n const sourceJobSteps = sourceStepsByJobId.get(sourceJob.id) ?? [];\n sourceJobSteps.push(step);\n sourceStepsByJobId.set(sourceJob.id, sourceJobSteps);\n }\n\n return params.sourceJobs.map((sourceJob) => {\n const carriedOver = params.mode === 'failed' && sourceJob.status === 'succeeded';\n\n return {\n job: {\n key: sourceJob.key,\n name: sourceJob.name,\n mode: sourceJob.mode,\n status: carriedOver ? ('succeeded' as const) : ('pending' as const),\n statusReason: null,\n carriedOver,\n checkoutPersistCredentials: sourceJob.checkoutPersistCredentials,\n checkoutPermissionsContents: sourceJob.checkoutPermissionsContents,\n success: sourceJob.success,\n executionTimeoutMs: sourceJob.executionTimeoutMs,\n listeningTimeoutMs: sourceJob.listeningTimeoutMs,\n maxExecutions: sourceJob.maxExecutions,\n onResolve: sourceJob.onResolve,\n batchDebounceMs: sourceJob.batchDebounceMs,\n batchMaxSize: sourceJob.batchMaxSize,\n batchMaxWaitMs: sourceJob.batchMaxWaitMs,\n listenerStatus: 'inactive' as const,\n resolutionReason: null,\n listeningOn: sourceJob.listeningOn ? [...sourceJob.listeningOn] : null,\n listeningUntil: sourceJob.listeningUntil ? [...sourceJob.listeningUntil] : null,\n outputs: carriedOver && sourceJob.outputs ? {...sourceJob.outputs} : null,\n dependencies: [...sourceJob.dependencies],\n runner: sourceJob.runner ? [...sourceJob.runner] : null,\n position: sourceJob.position,\n },\n createExecution: (job) => {\n if (job.mode === 'listening') return undefined;\n\n const sourceExecution = params.sourceJobExecutionByJobId.get(sourceJob.id);\n const modelJob = sourceModelJobByKey.get(job.key);\n const executionName = sourceExecution?.name ?? `${job.key} #1`;\n const runner =\n carriedOver || modelJob === undefined\n ? (sourceExecution?.runner ?? job.runner ?? null)\n : deriveJobExecutionRunner({\n run: params.sourceRun,\n modelJob,\n jobId: job.id,\n sequence: 1,\n executionName,\n status: 'pending',\n });\n\n return {\n sequence: 1,\n name: executionName,\n runner: runner ? [...runner] : null,\n status: carriedOver ? ('succeeded' as const) : ('pending' as const),\n statusReason: null,\n outputs: carriedOver && sourceExecution?.outputs ? {...sourceExecution.outputs} : null,\n ...(carriedOver ? {finishedAt: sql`now()`} : {}),\n };\n },\n createSteps: () =>\n (sourceStepsByJobId.get(sourceJob.id) ?? []).map((step) => ({\n key: step.key,\n name: step.name,\n sourceLocation: step.sourceLocation,\n status: carriedOver ? step.status : ('pending' as const),\n statusReason: carriedOver ? step.statusReason : null,\n type: step.type,\n config: step.config,\n condition: step.condition ?? null,\n configPlan: step.configPlan,\n authoredConfig: step.authoredConfig,\n error: null,\n position: step.position,\n currentAttempt: 1,\n })),\n };\n });\n}\n"],"names":["readPersistedWorkflowModel","and","asc","eq","inArray","sql","isWorkflowRunTerminal","NoFailedJobsError","RunNotTerminalError","SourceRunNotFoundError","deriveJobExecutionRunner","recordWorkflowRunCreated","db","jobExecutions","jobs","steps","workflowRunAttempts","toWorkflowRun","workflowRuns","persistMaterializedRunGraph","lockWorkflowRun","createRerunWorkflowRun","params","result","transaction","tx","workflowRunId","execute","sourceRow","sourceAttemptRow","select","from","where","id","attempt","currentAttempt","limit","for","Error","status","sourceJobs","workflowRunAttemptId","orderBy","position","mode","some","job","attemptRow","value","Number","newAttemptRow","insert","values","rerunMode","rerunByUserId","actorUserId","model","agentToolMaterialization","returning","sourceGraph","loadRerunSourceGraph","sourceRun","graphJobs","materializeRerunGraphJobs","sourceAttempt","run","workflowRunAttempt","materializedJobs","newRunRow","update","set","version","updatedAt","Date","startedAt","finishedAt","triggerPayload","provider","triggerSource","sourceJobIds","map","sourceJobExecutionRows","length","jobId","sequence","sourceJobExecutionByJobId","Map","jobExecution","has","sourceJobExecutionIds","sourceSteps","jobExecutionId","sourceJobById","sourceJobByJobExecutionId","entries","flatMap","get","sourceModel","sourceModelJobByKey","key","sourceStepsByJobId","step","sourceJob","sourceJobSteps","push","carriedOver","name","statusReason","checkoutPersistCredentials","checkoutPermissionsContents","success","executionTimeoutMs","listeningTimeoutMs","maxExecutions","onResolve","batchDebounceMs","batchMaxSize","batchMaxWaitMs","listenerStatus","resolutionReason","listeningOn","listeningUntil","outputs","dependencies","runner","createExecution","undefined","sourceExecution","modelJob","executionName","createSteps","sourceLocation","type","config","condition","configPlan","authoredConfig","error"],"mappings":"AAAA,SAAQA,0BAA0B,QAAO,+BAA+B;AACxE,SAAQC,GAAG,EAAEC,GAAG,EAAEC,EAAE,EAAEC,OAAO,EAAEC,GAAG,QAAO,cAAc;AACvD,SAAQC,qBAAqB,QAAyB,iCAAiC;AACvF,SAAQC,iBAAiB,EAAEC,mBAAmB,EAAEC,sBAAsB,QAAO,kBAAkB;AAC/F,SAAQC,wBAAwB,QAAO,iCAAiC;AACxE,SAAQC,wBAAwB,QAAO,uBAAuB;AAC9D,SAAQC,EAAE,QAAgB,WAAW;AACrC,SAA6BC,aAAa,QAAO,8BAA8B;AAC/E,SAAoBC,IAAI,QAAO,oBAAoB;AACnD,SAAqBC,KAAK,QAAO,qBAAqB;AACtD,SAAmCC,mBAAmB,QAAO,qCAAqC;AAClG,SAAQC,aAAa,EAAEC,YAAY,QAAO,6BAA6B;AACvE,SAAsCC,2BAA2B,QAAO,iBAAiB;AACzF,SAAQC,eAAe,QAAO,cAAc;AAQ5C,OAAO,eAAeC,uBACpBC,MAAoC;IAEpC,MAAMC,SAAS,MAAMX,KAAKY,WAAW,CAAC,OAAOC;QAC3C,MAAMC,gBAAgBJ,OAAOI,aAAa;QAC1C,MAAMD,GAAGE,OAAO,CAACtB,GAAG,CAAC,s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D;YACF;YACA6H,aAAa,IACX,AAAC9B,CAAAA,mBAAmBJ,GAAG,CAACM,UAAUrE,EAAE,KAAK,EAAE,AAAD,EAAG+C,GAAG,CAAC,CAACqB,OAAU,CAAA;wBAC1DF,KAAKE,KAAKF,GAAG;wBACbO,MAAML,KAAKK,IAAI;wBACfyB,gBAAgB9B,KAAK8B,cAAc;wBACnC5F,QAAQkE,cAAcJ,KAAK9D,MAAM,GAAI;wBACrCoE,cAAcF,cAAcJ,KAAKM,YAAY,GAAG;wBAChDyB,MAAM/B,KAAK+B,IAAI;wBACfC,QAAQhC,KAAKgC,MAAM;wBACnBC,WAAWjC,KAAKiC,SAAS,IAAI;wBAC7BC,YAAYlC,KAAKkC,UAAU;wBAC3BC,gBAAgBnC,KAAKmC,cAAc;wBACnCC,OAAO;wBACP9F,UAAU0D,KAAK1D,QAAQ;wBACvBR,gBAAgB;oBAClB,CAAA;QACJ;IACF;AACF"}
package/dist/index.d.ts CHANGED
@@ -1,10 +1,24 @@
1
+ import type { AnnotationsInterModuleClient } from '@shipfox/annotations-dto/inter-module';
2
+ import type { AgentInterModuleClient } from '@shipfox/api-agent-dto/inter-module';
3
+ import type { AuthInterModuleClient } from '@shipfox/api-auth-dto/inter-module';
4
+ import type { DefinitionsInterModuleClient } from '@shipfox/api-definitions-dto/inter-module';
5
+ import type { IntegrationsModuleClient } from '@shipfox/api-integration-core-dto';
6
+ import type { ProjectsModuleClient } from '@shipfox/api-projects-dto';
7
+ import type { RunnersInterModuleClient } from '@shipfox/api-runners-dto/inter-module';
8
+ import type { SecretsInterModuleClient } from '@shipfox/api-secrets-dto/inter-module';
1
9
  import { type ShipfoxModule } from '@shipfox/node-module';
2
- export { clearAgentToolMaterializationServices, setAgentToolMaterializationServices, } from '#core/agent-tools.js';
3
10
  export type { Job, JobListenerEvent, JobListenerEventDisposition, RunWorkflowParams, Step, TriggerPayload, WorkflowRun, WorkflowSourceSnapshot, } from '#core/index.js';
4
11
  export { DefinitionNotFoundError, InterpolationUnresolvableError, isPermanentRunWorkflowError, ProjectMismatchError, runWorkflow, WorkflowRunNotCancellableError, } from '#core/index.js';
5
- export { setSourceControl } from '#core/source-control.js';
6
12
  export { closeDb, type DeliverEventToListenerParams, type DeliverEventToListenerResult, db, deliverEventToListener, getStepById, getStepByIdForJobExecution, migrationsPath, workflowsOutbox, } from '#db/index.js';
7
- export { routes } from '#presentation/index.js';
8
13
  export { loadRunningLeasedStep } from '#presentation/routes/leased-step.js';
9
- export declare const workflowsModule: ShipfoxModule;
14
+ export declare function createWorkflowsModule({ agent, definitions, annotations, auth, integrations, projects, runners, secrets, }: {
15
+ agent: AgentInterModuleClient;
16
+ definitions: DefinitionsInterModuleClient;
17
+ annotations: AnnotationsInterModuleClient;
18
+ auth: AuthInterModuleClient;
19
+ integrations: IntegrationsModuleClient;
20
+ projects: ProjectsModuleClient;
21
+ runners: RunnersInterModuleClient;
22
+ secrets: SecretsInterModuleClient;
23
+ }): ShipfoxModule;
10
24
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAC,KAAK,aAAa,EAAoB,MAAM,sBAAsB,CAAC;AAe3E,OAAO,EACL,qCAAqC,EACrC,mCAAmC,GACpC,MAAM,sBAAsB,CAAC;AAC9B,YAAY,EACV,GAAG,EACH,gBAAgB,EAChB,2BAA2B,EAC3B,iBAAiB,EACjB,IAAI,EACJ,cAAc,EACd,WAAW,EACX,sBAAsB,GACvB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,uBAAuB,EACvB,8BAA8B,EAC9B,2BAA2B,EAC3B,oBAAoB,EACpB,WAAW,EACX,8BAA8B,GAC/B,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAC,gBAAgB,EAAC,MAAM,yBAAyB,CAAC;AACzD,OAAO,EACL,OAAO,EACP,KAAK,4BAA4B,EACjC,KAAK,4BAA4B,EACjC,EAAE,EAC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,eAAe,GAChB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAC,qBAAqB,EAAC,MAAM,qCAAqC,CAAC;AAO1E,wBAAgB,qBAAqB,CAAC,EACpC,KAAK,EACL,WAAW,EACX,WAAW,EACX,IAAI,EACJ,YAAY,EACZ,QAAQ,EACR,OAAO,EACP,OAAO,GACR,EAAE;IACD,KAAK,EAAE,sBAAsB,CAAC;IAC9B,WAAW,EAAE,4BAA4B,CAAC;IAC1C,WAAW,EAAE,4BAA4B,CAAC;IAC1C,IAAI,EAAE,qBAAqB,CAAC;IAC5B,YAAY,EAAE,wBAAwB,CAAC;IACvC,QAAQ,EAAE,oBAAoB,CAAC;IAC/B,OAAO,EAAE,wBAAwB,CAAC;IAClC,OAAO,EAAE,wBAAwB,CAAC;CACnC,GAAG,aAAa,CA8ChB"}
package/dist/index.js CHANGED
@@ -5,50 +5,74 @@ import { WORKFLOWS_JOB_EVENT_DELIVERED, WORKFLOWS_JOB_STEPS_SETTLED, WORKFLOWS_W
5
5
  import { subscriberFactory } from '@shipfox/node-module';
6
6
  import { db, migrationsPath, workflowsOutbox } from '#db/index.js';
7
7
  import { registerWorkflowsServiceMetrics } from '#metrics/index.js';
8
- import { onJobEventDelivered, onJobStepsSettled, onRunnerJobClaimed, onRunnerJobLeaseExpired, onRunnerJobQueued, onWorkflowRunAttemptCreated, onWorkflowRunCancelled, routes } from '#presentation/index.js';
8
+ import { createWorkflowRoutes, onJobEventDelivered, onJobStepsSettled, onRunnerJobClaimed, onRunnerJobLeaseExpired, onRunnerJobQueued, onWorkflowRunAttemptCreated, onWorkflowRunCancelled } from '#presentation/index.js';
9
+ import { createWorkflowsInterModulePresentation } from '#presentation/inter-module.js';
9
10
  import { createOrchestrationActivities, WORKFLOWS_TASK_QUEUE } from '#temporal/index.js';
10
- export { clearAgentToolMaterializationServices, setAgentToolMaterializationServices } from '#core/agent-tools.js';
11
11
  export { DefinitionNotFoundError, InterpolationUnresolvableError, isPermanentRunWorkflowError, ProjectMismatchError, runWorkflow, WorkflowRunNotCancellableError } from '#core/index.js';
12
- export { setSourceControl } from '#core/source-control.js';
13
12
  export { closeDb, db, deliverEventToListener, getStepById, getStepByIdForJobExecution, migrationsPath, workflowsOutbox } from '#db/index.js';
14
- export { routes } from '#presentation/index.js';
15
13
  export { loadRunningLeasedStep } from '#presentation/routes/leased-step.js';
16
14
  const packageRoot = resolve(dirname(fileURLToPath(import.meta.url)), '..');
17
15
  const workflowsPath = resolve(packageRoot, 'dist/temporal/workflows/index.js');
18
16
  const subscriber = subscriberFactory();
19
- export const workflowsModule = {
20
- name: 'workflows',
21
- database: {
22
- db,
23
- migrationsPath
24
- },
25
- routes,
26
- metrics: registerWorkflowsServiceMetrics,
27
- publishers: [
28
- {
29
- name: 'workflows',
30
- table: workflowsOutbox,
17
+ export function createWorkflowsModule({ agent, definitions, annotations, auth, integrations, projects, runners, secrets }) {
18
+ return {
19
+ name: 'workflows',
20
+ database: {
31
21
  db,
32
- eventSchemas: workflowsEventSchemas
33
- }
34
- ],
35
- subscribers: [
36
- subscriber(WORKFLOWS_WORKFLOW_RUN_ATTEMPT_CREATED, onWorkflowRunAttemptCreated),
37
- subscriber(WORKFLOWS_WORKFLOW_RUN_CANCELLED, onWorkflowRunCancelled),
38
- subscriber(WORKFLOWS_JOB_EVENT_DELIVERED, onJobEventDelivered),
39
- subscriber(WORKFLOWS_JOB_STEPS_SETTLED, onJobStepsSettled),
40
- subscriber(RUNNER_JOB_LEASE_EXPIRED, onRunnerJobLeaseExpired),
41
- subscriber(RUNNER_JOB_QUEUED, onRunnerJobQueued),
42
- subscriber(RUNNER_JOB_CLAIMED, onRunnerJobClaimed)
43
- ],
44
- workers: [
45
- {
46
- taskQueue: WORKFLOWS_TASK_QUEUE,
47
- workflowsPath,
48
- activities: createOrchestrationActivities,
49
- workflows: []
50
- }
51
- ]
52
- };
22
+ migrationsPath
23
+ },
24
+ routes: createWorkflowRoutes({
25
+ agent,
26
+ annotations,
27
+ auth,
28
+ integrations,
29
+ projects,
30
+ runners,
31
+ secrets
32
+ }),
33
+ metrics: registerWorkflowsServiceMetrics,
34
+ publishers: [
35
+ {
36
+ name: 'workflows',
37
+ table: workflowsOutbox,
38
+ db,
39
+ eventSchemas: workflowsEventSchemas
40
+ }
41
+ ],
42
+ subscribers: [
43
+ subscriber(WORKFLOWS_WORKFLOW_RUN_ATTEMPT_CREATED, onWorkflowRunAttemptCreated),
44
+ subscriber(WORKFLOWS_WORKFLOW_RUN_CANCELLED, onWorkflowRunCancelled),
45
+ subscriber(WORKFLOWS_JOB_EVENT_DELIVERED, onJobEventDelivered),
46
+ subscriber(WORKFLOWS_JOB_STEPS_SETTLED, onJobStepsSettled),
47
+ subscriber(RUNNER_JOB_LEASE_EXPIRED, onRunnerJobLeaseExpired),
48
+ subscriber(RUNNER_JOB_QUEUED, onRunnerJobQueued),
49
+ subscriber(RUNNER_JOB_CLAIMED, onRunnerJobClaimed)
50
+ ],
51
+ workers: [
52
+ {
53
+ taskQueue: WORKFLOWS_TASK_QUEUE,
54
+ workflowsPath,
55
+ activities: ()=>createOrchestrationActivities({
56
+ agent,
57
+ integrations,
58
+ projects,
59
+ runners,
60
+ secrets
61
+ }),
62
+ workflows: []
63
+ }
64
+ ],
65
+ interModulePresentations: [
66
+ createWorkflowsInterModulePresentation({
67
+ agent,
68
+ definitions,
69
+ integrations,
70
+ projects,
71
+ runners,
72
+ secrets
73
+ })
74
+ ]
75
+ };
76
+ }
53
77
 
54
78
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"sourcesContent":["import {dirname, resolve} from 'node:path';\nimport {fileURLToPath} from 'node:url';\nimport {\n RUNNER_JOB_CLAIMED,\n RUNNER_JOB_LEASE_EXPIRED,\n RUNNER_JOB_QUEUED,\n type RunnersEventMap,\n} from '@shipfox/api-runners-dto';\nimport {\n WORKFLOWS_JOB_EVENT_DELIVERED,\n WORKFLOWS_JOB_STEPS_SETTLED,\n WORKFLOWS_WORKFLOW_RUN_ATTEMPT_CREATED,\n WORKFLOWS_WORKFLOW_RUN_CANCELLED,\n type WorkflowsEventMapDto,\n workflowsEventSchemas,\n} from '@shipfox/api-workflows-dto';\nimport {type ShipfoxModule, subscriberFactory} from '@shipfox/node-module';\nimport {db, migrationsPath, workflowsOutbox} from '#db/index.js';\nimport {registerWorkflowsServiceMetrics} from '#metrics/index.js';\nimport {\n onJobEventDelivered,\n onJobStepsSettled,\n onRunnerJobClaimed,\n onRunnerJobLeaseExpired,\n onRunnerJobQueued,\n onWorkflowRunAttemptCreated,\n onWorkflowRunCancelled,\n routes,\n} from '#presentation/index.js';\nimport {createOrchestrationActivities, WORKFLOWS_TASK_QUEUE} from '#temporal/index.js';\n\nexport {\n clearAgentToolMaterializationServices,\n setAgentToolMaterializationServices,\n} from '#core/agent-tools.js';\nexport type {\n Job,\n JobListenerEvent,\n JobListenerEventDisposition,\n RunWorkflowParams,\n Step,\n TriggerPayload,\n WorkflowRun,\n WorkflowSourceSnapshot,\n} from '#core/index.js';\nexport {\n DefinitionNotFoundError,\n InterpolationUnresolvableError,\n isPermanentRunWorkflowError,\n ProjectMismatchError,\n runWorkflow,\n WorkflowRunNotCancellableError,\n} from '#core/index.js';\nexport {setSourceControl} from '#core/source-control.js';\nexport {\n closeDb,\n type DeliverEventToListenerParams,\n type DeliverEventToListenerResult,\n db,\n deliverEventToListener,\n getStepById,\n getStepByIdForJobExecution,\n migrationsPath,\n workflowsOutbox,\n} from '#db/index.js';\nexport {routes} from '#presentation/index.js';\nexport {loadRunningLeasedStep} from '#presentation/routes/leased-step.js';\n\nconst packageRoot = resolve(dirname(fileURLToPath(import.meta.url)), '..');\nconst workflowsPath = resolve(packageRoot, 'dist/temporal/workflows/index.js');\n\nconst subscriber = subscriberFactory<WorkflowsEventMapDto & RunnersEventMap>();\n\nexport const workflowsModule: ShipfoxModule = {\n name: 'workflows',\n database: {db, migrationsPath},\n routes,\n metrics: registerWorkflowsServiceMetrics,\n publishers: [\n {name: 'workflows', table: workflowsOutbox, db, eventSchemas: workflowsEventSchemas},\n ],\n subscribers: [\n subscriber(WORKFLOWS_WORKFLOW_RUN_ATTEMPT_CREATED, onWorkflowRunAttemptCreated),\n subscriber(WORKFLOWS_WORKFLOW_RUN_CANCELLED, onWorkflowRunCancelled),\n subscriber(WORKFLOWS_JOB_EVENT_DELIVERED, onJobEventDelivered),\n subscriber(WORKFLOWS_JOB_STEPS_SETTLED, onJobStepsSettled),\n subscriber(RUNNER_JOB_LEASE_EXPIRED, onRunnerJobLeaseExpired),\n subscriber(RUNNER_JOB_QUEUED, onRunnerJobQueued),\n subscriber(RUNNER_JOB_CLAIMED, onRunnerJobClaimed),\n ],\n workers: [\n {\n taskQueue: WORKFLOWS_TASK_QUEUE,\n workflowsPath,\n activities: createOrchestrationActivities,\n workflows: [],\n },\n ],\n};\n"],"names":["dirname","resolve","fileURLToPath","RUNNER_JOB_CLAIMED","RUNNER_JOB_LEASE_EXPIRED","RUNNER_JOB_QUEUED","WORKFLOWS_JOB_EVENT_DELIVERED","WORKFLOWS_JOB_STEPS_SETTLED","WORKFLOWS_WORKFLOW_RUN_ATTEMPT_CREATED","WORKFLOWS_WORKFLOW_RUN_CANCELLED","workflowsEventSchemas","subscriberFactory","db","migrationsPath","workflowsOutbox","registerWorkflowsServiceMetrics","onJobEventDelivered","onJobStepsSettled","onRunnerJobClaimed","onRunnerJobLeaseExpired","onRunnerJobQueued","onWorkflowRunAttemptCreated","onWorkflowRunCancelled","routes","createOrchestrationActivities","WORKFLOWS_TASK_QUEUE","clearAgentToolMaterializationServices","setAgentToolMaterializationServices","DefinitionNotFoundError","InterpolationUnresolvableError","isPermanentRunWorkflowError","ProjectMismatchError","runWorkflow","WorkflowRunNotCancellableError","setSourceControl","closeDb","deliverEventToListener","getStepById","getStepByIdForJobExecution","loadRunningLeasedStep","packageRoot","url","workflowsPath","subscriber","workflowsModule","name","database","metrics","publishers","table","eventSchemas","subscribers","workers","taskQueue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YAAaI,OAAOnC;YAAiBF;YAAIsC,cAAcxC;QAAqB;KACpF;IACDyC,aAAa;QACXR,WAAWnC,wCAAwCa;QACnDsB,WAAWlC,kCAAkCa;QAC7CqB,WAAWrC,+BAA+BU;QAC1C2B,WAAWpC,6BAA6BU;QACxC0B,WAAWvC,0BAA0Be;QACrCwB,WAAWtC,mBAAmBe;QAC9BuB,WAAWxC,oBAAoBe;KAChC;IACDkC,SAAS;QACP;YACEC,WAAW5B;YACXiB;YACAY,YAAY9B;YACZ+B,WAAW,EAAE;QACf;KACD;AACH,EAAE"}
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["import {dirname, resolve} from 'node:path';\nimport {fileURLToPath} from 'node:url';\nimport type {AnnotationsInterModuleClient} from '@shipfox/annotations-dto/inter-module';\nimport type {AgentInterModuleClient} from '@shipfox/api-agent-dto/inter-module';\nimport type {AuthInterModuleClient} from '@shipfox/api-auth-dto/inter-module';\nimport type {DefinitionsInterModuleClient} from '@shipfox/api-definitions-dto/inter-module';\nimport type {IntegrationsModuleClient} from '@shipfox/api-integration-core-dto';\nimport type {ProjectsModuleClient} from '@shipfox/api-projects-dto';\nimport {\n RUNNER_JOB_CLAIMED,\n RUNNER_JOB_LEASE_EXPIRED,\n RUNNER_JOB_QUEUED,\n type RunnersEventMap,\n} from '@shipfox/api-runners-dto';\nimport type {RunnersInterModuleClient} from '@shipfox/api-runners-dto/inter-module';\nimport type {SecretsInterModuleClient} from '@shipfox/api-secrets-dto/inter-module';\nimport {\n WORKFLOWS_JOB_EVENT_DELIVERED,\n WORKFLOWS_JOB_STEPS_SETTLED,\n WORKFLOWS_WORKFLOW_RUN_ATTEMPT_CREATED,\n WORKFLOWS_WORKFLOW_RUN_CANCELLED,\n type WorkflowsEventMapDto,\n workflowsEventSchemas,\n} from '@shipfox/api-workflows-dto';\nimport {type ShipfoxModule, subscriberFactory} from '@shipfox/node-module';\nimport {db, migrationsPath, workflowsOutbox} from '#db/index.js';\nimport {registerWorkflowsServiceMetrics} from '#metrics/index.js';\nimport {\n createWorkflowRoutes,\n onJobEventDelivered,\n onJobStepsSettled,\n onRunnerJobClaimed,\n onRunnerJobLeaseExpired,\n onRunnerJobQueued,\n onWorkflowRunAttemptCreated,\n onWorkflowRunCancelled,\n} from '#presentation/index.js';\nimport {createWorkflowsInterModulePresentation} from '#presentation/inter-module.js';\nimport {createOrchestrationActivities, WORKFLOWS_TASK_QUEUE} from '#temporal/index.js';\n\nexport type {\n Job,\n JobListenerEvent,\n JobListenerEventDisposition,\n RunWorkflowParams,\n Step,\n TriggerPayload,\n WorkflowRun,\n WorkflowSourceSnapshot,\n} from '#core/index.js';\nexport {\n DefinitionNotFoundError,\n InterpolationUnresolvableError,\n isPermanentRunWorkflowError,\n ProjectMismatchError,\n runWorkflow,\n WorkflowRunNotCancellableError,\n} from '#core/index.js';\nexport {\n closeDb,\n type DeliverEventToListenerParams,\n type DeliverEventToListenerResult,\n db,\n deliverEventToListener,\n getStepById,\n getStepByIdForJobExecution,\n migrationsPath,\n workflowsOutbox,\n} from '#db/index.js';\nexport {loadRunningLeasedStep} from '#presentation/routes/leased-step.js';\n\nconst packageRoot = resolve(dirname(fileURLToPath(import.meta.url)), '..');\nconst workflowsPath = resolve(packageRoot, 'dist/temporal/workflows/index.js');\n\nconst subscriber = subscriberFactory<WorkflowsEventMapDto & RunnersEventMap>();\n\nexport function createWorkflowsModule({\n agent,\n definitions,\n annotations,\n auth,\n integrations,\n projects,\n runners,\n secrets,\n}: {\n agent: AgentInterModuleClient;\n definitions: DefinitionsInterModuleClient;\n annotations: AnnotationsInterModuleClient;\n auth: AuthInterModuleClient;\n integrations: IntegrationsModuleClient;\n projects: ProjectsModuleClient;\n runners: RunnersInterModuleClient;\n secrets: SecretsInterModuleClient;\n}): ShipfoxModule {\n return {\n name: 'workflows',\n database: {db, migrationsPath},\n routes: createWorkflowRoutes({\n agent,\n annotations,\n auth,\n integrations,\n projects,\n runners,\n secrets,\n }),\n metrics: registerWorkflowsServiceMetrics,\n publishers: [\n {name: 'workflows', table: workflowsOutbox, db, eventSchemas: workflowsEventSchemas},\n ],\n subscribers: [\n subscriber(WORKFLOWS_WORKFLOW_RUN_ATTEMPT_CREATED, onWorkflowRunAttemptCreated),\n subscriber(WORKFLOWS_WORKFLOW_RUN_CANCELLED, onWorkflowRunCancelled),\n subscriber(WORKFLOWS_JOB_EVENT_DELIVERED, onJobEventDelivered),\n subscriber(WORKFLOWS_JOB_STEPS_SETTLED, onJobStepsSettled),\n subscriber(RUNNER_JOB_LEASE_EXPIRED, onRunnerJobLeaseExpired),\n subscriber(RUNNER_JOB_QUEUED, onRunnerJobQueued),\n subscriber(RUNNER_JOB_CLAIMED, onRunnerJobClaimed),\n ],\n workers: [\n {\n taskQueue: WORKFLOWS_TASK_QUEUE,\n workflowsPath,\n activities: () =>\n createOrchestrationActivities({agent, integrations, projects, runners, secrets}),\n workflows: [],\n },\n ],\n interModulePresentations: [\n createWorkflowsInterModulePresentation({\n agent,\n definitions,\n integrations,\n projects,\n runners,\n secrets,\n }),\n ],\n };\n}\n"],"names":["dirname","resolve","fileURLToPath","RUNNER_JOB_CLAIMED","RUNNER_JOB_LEASE_EXPIRED","RUNNER_JOB_QUEUED","WORKFLOWS_JOB_EVENT_DELIVERED","WORKFLOWS_JOB_STEPS_SETTLED","WORKFLOWS_WORKFLOW_RUN_ATTEMPT_CREATED","WORKFLOWS_WORKFLOW_RUN_CANCELLED","workflowsEventSchemas","subscriberFactory","db","migrationsPath","workflowsOutbox","registerWorkflowsServiceMetrics","createWorkflowRoutes","onJobEventDelivered","onJobStepsSettled","onRunnerJobClaimed","onRunnerJobLeaseExpired","onRunnerJobQueued","onWorkflowRunAttemptCreated","onWorkflowRunCancelled","createWorkflowsInterModulePresentation","createOrchestrationActivities","WORKFLOWS_TASK_QUEUE","DefinitionNotFoundError","InterpolationUnresolvableError","isPermanentRunWorkflowError","ProjectMismatchError","runWorkflow","WorkflowRunNotCancellableError","closeDb","deliverEventToListener","getStepById","getStepByIdForJobExecution","loadRunningLeasedStep","packageRoot","url","workflowsPath","subscriber","createWorkflowsModule","agent","definitions","annotations","auth","integrations","projects","runners","secrets","name","database","routes","metrics","publishers","table","eventSchemas","subscribers","workers","taskQueue","activities","workflows","interModulePresentations"],"mappings":"AAAA,SAAQA,OAAO,EAAEC,OAAO,QAAO,YAAY;AAC3C,SAAQC,aAAa,QAAO,WAAW;AAOvC,SACEC,kBAAkB,EAClBC,wBAAwB,EACxBC,iBAAiB,QAEZ,2BAA2B;AAGlC,SACEC,6BAA6B,EAC7BC,2BAA2B,EAC3BC,sCAAsC,EACtCC,gCAAgC,EAEhCC,qBAAqB,QAChB,6BAA6B;AACpC,SAA4BC,iBAAiB,QAAO,uBAAuB;AAC3E,SAAQC,EAAE,EAAEC,cAAc,EAAEC,eAAe,QAAO,eAAe;AACjE,SAAQC,+BAA+B,QAAO,oBAAoB;AAClE,SACEC,oBAAoB,EACpBC,mBAAmB,EACnBC,iBAAiB,EACjBC,kBAAkB,EAClBC,uBAAuB,EACvBC,iBAAiB,EACjBC,2BAA2B,EAC3BC,sBAAsB,QACjB,yBAAyB;AAChC,SAAQC,sCAAsC,QAAO,gCAAgC;AACrF,SAAQC,6BAA6B,EAAEC,oBAAoB,QAAO,qBAAqB;AAYvF,SACEC,uBAAuB,EACvBC,8BAA8B,EAC9BC,2BAA2B,EAC3BC,oBAAoB,EACpBC,WAAW,EACXC,8BAA8B,QACzB,iBAAiB;AACxB,SACEC,OAAO,EAGPrB,EAAE,EACFsB,sBAAsB,EACtBC,WAAW,EACXC,0BAA0B,EAC1BvB,cAAc,EACdC,eAAe,QACV,eAAe;AACtB,SAAQuB,qBAAqB,QAAO,sCAAsC;AAE1E,MAAMC,cAAcrC,QAAQD,QAAQE,cAAc,YAAYqC,GAAG,IAAI;AACrE,MAAMC,gBAAgBvC,QAAQqC,aAAa;AAE3C,MAAMG,aAAa9B;AAEnB,OAAO,SAAS+B,sBAAsB,EACpCC,KAAK,EACLC,WAAW,EACXC,WAAW,EACXC,IAAI,EACJC,YAAY,EACZC,QAAQ,EACRC,OAAO,EACPC,OAAO,EAUR;IACC,OAAO;QACLC,MAAM;QACNC,UAAU;YAACxC;YAAIC;QAAc;QAC7BwC,QAAQrC,qBAAqB;YAC3B2B;YACAE;YACAC;YACAC;YACAC;YACAC;YACAC;QACF;QACAI,SAASvC;QACTwC,YAAY;YACV;gBAACJ,MAAM;gBAAaK,OAAO1C;gBAAiBF;gBAAI6C,cAAc/C;YAAqB;SACpF;QACDgD,aAAa;YACXjB,WAAWjC,wCAAwCc;YACnDmB,WAAWhC,kCAAkCc;YAC7CkB,WAAWnC,+BAA+BW;YAC1CwB,WAAWlC,6BAA6BW;YACxCuB,WAAWrC,0BAA0BgB;YACrCqB,WAAWpC,mBAAmBgB;YAC9BoB,WAAWtC,oBAAoBgB;SAChC;QACDwC,SAAS;YACP;gBACEC,WAAWlC;gBACXc;gBACAqB,YAAY,IACVpC,8BAA8B;wBAACkB;wBAAOI;wBAAcC;wBAAUC;wBAASC;oBAAO;gBAChFY,WAAW,EAAE;YACf;SACD;QACDC,0BAA0B;YACxBvC,uCAAuC;gBACrCmB;gBACAC;gBACAG;gBACAC;gBACAC;gBACAC;YACF;SACD;IACH;AACF"}
@@ -1,6 +1,19 @@
1
- import type { CheckoutSpec } from '@shipfox/api-integration-core';
1
+ type CheckoutSpec = {
2
+ repositoryUrl: string;
3
+ ref: string;
4
+ credentials?: {
5
+ username: string;
6
+ token: string;
7
+ expiresAt: Date;
8
+ } | undefined;
9
+ gitAuthor?: {
10
+ name: string;
11
+ email: string;
12
+ } | undefined;
13
+ };
2
14
  import type { CheckoutTokenResponseDto } from '@shipfox/api-workflows-dto';
3
15
  export declare function toCheckoutTokenDto(spec: CheckoutSpec, options: {
4
16
  persist: boolean;
5
17
  }): CheckoutTokenResponseDto;
18
+ export {};
6
19
  //# sourceMappingURL=checkout-token.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"checkout-token.d.ts","sourceRoot":"","sources":["../../../src/presentation/dto/checkout-token.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,+BAA+B,CAAC;AAChE,OAAO,KAAK,EAAC,wBAAwB,EAAC,MAAM,4BAA4B,CAAC;AAwCzE,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,YAAY,EAClB,OAAO,EAAE;IAAC,OAAO,EAAE,OAAO,CAAA;CAAC,GAC1B,wBAAwB,CA0B1B"}
1
+ {"version":3,"file":"checkout-token.d.ts","sourceRoot":"","sources":["../../../src/presentation/dto/checkout-token.ts"],"names":[],"mappings":"AAAA,KAAK,YAAY,GAAG;IAClB,aAAa,EAAE,MAAM,CAAC;IACtB,GAAG,EAAE,MAAM,CAAC;IACZ,WAAW,CAAC,EAAE;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,IAAI,CAAA;KAAC,GAAG,SAAS,CAAC;IAC7E,SAAS,CAAC,EAAE;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAC,GAAG,SAAS,CAAC;CACvD,CAAC;AAEF,OAAO,KAAK,EAAC,wBAAwB,EAAC,MAAM,4BAA4B,CAAC;AAwCzE,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,YAAY,EAClB,OAAO,EAAE;IAAC,OAAO,EAAE,OAAO,CAAA;CAAC,GAC1B,wBAAwB,CA0B1B"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/presentation/dto/checkout-token.ts"],"sourcesContent":["import type {CheckoutSpec} from '@shipfox/api-integration-core';\nimport type {CheckoutTokenResponseDto} from '@shipfox/api-workflows-dto';\n\nconst SCP_LIKE_HOST_RE = /^(?:[^@:/]+@)?([^:/]+):/;\n\n// Defense in depth: createCheckoutSpec's contract is that `repositoryUrl` never\n// embeds credentials (they live in `credentials` so redaction can mask them). A\n// provider bug that put a token in the URL would bypass redaction and leak it\n// into `git remote -v` and logs, so reject it before it reaches the runner.\nfunction assertNoEmbeddedCredentials(repositoryUrl: string): void {\n // Run the scp-style check unconditionally: a genuine scp form\n // (git@host:org/repo.git) fails URL parsing, but a `user:secret@host:path`\n // string parses with a bogus `user:` scheme and *empty* URL userinfo, so the\n // url.username check below would miss its embedded password.\n assertNoScpCredentials(repositoryUrl);\n\n let url: URL;\n try {\n url = new URL(repositoryUrl);\n } catch {\n return;\n }\n if (url.username || url.password) {\n throw new Error('Checkout repository URL must not embed credentials');\n }\n}\n\n// scp-like userinfo is everything before the first `@`, and that `@` precedes\n// the first `/`. A bare `git@host:path` user is fine; a `user:secret@host:path`\n// password embeds a credential, so reject any colon in the userinfo segment.\nfunction assertNoScpCredentials(repositoryUrl: string): void {\n const atIndex = repositoryUrl.indexOf('@');\n const slashIndex = repositoryUrl.indexOf('/');\n if (atIndex === -1 || (slashIndex !== -1 && atIndex > slashIndex)) {\n return;\n }\n if (repositoryUrl.slice(0, atIndex).includes(':')) {\n throw new Error('Checkout repository URL must not embed credentials');\n }\n}\n\nexport function toCheckoutTokenDto(\n spec: CheckoutSpec,\n options: {persist: boolean},\n): CheckoutTokenResponseDto {\n assertNoEmbeddedCredentials(spec.repositoryUrl);\n\n // Every provider that returns credentials uses a username (GitHub:\n // 'x-access-token'), so the response is always basic auth; a credential-free\n // spec (debug) omits auth entirely.\n return {\n repository_url: spec.repositoryUrl,\n ref: spec.ref,\n ...(spec.gitAuthor\n ? {git_author: {name: spec.gitAuthor.name, email: spec.gitAuthor.email}}\n : {}),\n ...(spec.credentials\n ? {\n auth: {\n kind: 'basic' as const,\n username: spec.credentials.username,\n token: spec.credentials.token,\n expires_at: spec.credentials.expiresAt.toISOString(),\n carry: 'header' as const,\n host: checkoutHost(spec.repositoryUrl),\n persist: options.persist,\n },\n }\n : {}),\n };\n}\n\nfunction checkoutHost(repositoryUrl: string): string {\n try {\n const host = new URL(repositoryUrl).host;\n if (host) return host;\n } catch {\n // Fall through to scp-like parsing.\n }\n\n const scpLike = SCP_LIKE_HOST_RE.exec(repositoryUrl);\n if (scpLike?.[1]) return scpLike[1];\n\n throw new Error('Checkout repository URL must include a host');\n}\n"],"names":["SCP_LIKE_HOST_RE","assertNoEmbeddedCredentials","repositoryUrl","assertNoScpCredentials","url","URL","username","password","Error","atIndex","indexOf","slashIndex","slice","includes","toCheckoutTokenDto","spec","options","repository_url","ref","gitAuthor","git_author","name","email","credentials","auth","kind","token","expires_at","expiresAt","toISOString","carry","host","checkoutHost","persist","scpLike","exec"],"mappings":"AAGA,MAAMA,mBAAmB;AAEzB,gFAAgF;AAChF,gFAAgF;AAChF,8EAA8E;AAC9E,4EAA4E;AAC5E,SAASC,4BAA4BC,aAAqB;IACxD,8DAA8D;IAC9D,2EAA2E;IAC3E,6EAA6E;IAC7E,6DAA6D;IAC7DC,uBAAuBD;IAEvB,IAAIE;IACJ,IAAI;QACFA,MAAM,IAAIC,IAAIH;IAChB,EAAE,OAAM;QACN;IACF;IACA,IAAIE,IAAIE,QAAQ,IAAIF,IAAIG,QAAQ,EAAE;QAChC,MAAM,IAAIC,MAAM;IAClB;AACF;AAEA,8EAA8E;AAC9E,gFAAgF;AAChF,6EAA6E;AAC7E,SAASL,uBAAuBD,aAAqB;IACnD,MAAMO,UAAUP,cAAcQ,OAAO,CAAC;IACtC,MAAMC,aAAaT,cAAcQ,OAAO,CAAC;IACzC,IAAID,YAAY,CAAC,KAAME,eAAe,CAAC,KAAKF,UAAUE,YAAa;QACjE;IACF;IACA,IAAIT,cAAcU,KAAK,CAAC,GAAGH,SAASI,QAAQ,CAAC,MAAM;QACjD,MAAM,IAAIL,MAAM;IAClB;AACF;AAEA,OAAO,SAASM,mBACdC,IAAkB,EAClBC,OAA2B;IAE3Bf,4BAA4Bc,KAAKb,aAAa;IAE9C,mEAAmE;IACnE,6EAA6E;IAC7E,oCAAoC;IACpC,OAAO;QACLe,gBAAgBF,KAAKb,aAAa;QAClCgB,KAAKH,KAAKG,GAAG;QACb,GAAIH,KAAKI,SAAS,GACd;YAACC,YAAY;gBAACC,MAAMN,KAAKI,SAAS,CAACE,IAAI;gBAAEC,OAAOP,KAAKI,SAAS,CAACG,KAAK;YAAA;QAAC,IACrE,CAAC,CAAC;QACN,GAAIP,KAAKQ,WAAW,GAChB;YACEC,MAAM;gBACJC,MAAM;gBACNnB,UAAUS,KAAKQ,WAAW,CAACjB,QAAQ;gBACnCoB,OAAOX,KAAKQ,WAAW,CAACG,KAAK;gBAC7BC,YAAYZ,KAAKQ,WAAW,CAACK,SAAS,CAACC,WAAW;gBAClDC,OAAO;gBACPC,MAAMC,aAAajB,KAAKb,aAAa;gBACrC+B,SAASjB,QAAQiB,OAAO;YAC1B;QACF,IACA,CAAC,CAAC;IACR;AACF;AAEA,SAASD,aAAa9B,aAAqB;IACzC,IAAI;QACF,MAAM6B,OAAO,IAAI1B,IAAIH,eAAe6B,IAAI;QACxC,IAAIA,MAAM,OAAOA;IACnB,EAAE,OAAM;IACN,oCAAoC;IACtC;IAEA,MAAMG,UAAUlC,iBAAiBmC,IAAI,CAACjC;IACtC,IAAIgC,SAAS,CAAC,EAAE,EAAE,OAAOA,OAAO,CAAC,EAAE;IAEnC,MAAM,IAAI1B,MAAM;AAClB"}
1
+ {"version":3,"sources":["../../../src/presentation/dto/checkout-token.ts"],"sourcesContent":["type CheckoutSpec = {\n repositoryUrl: string;\n ref: string;\n credentials?: {username: string; token: string; expiresAt: Date} | undefined;\n gitAuthor?: {name: string; email: string} | undefined;\n};\n\nimport type {CheckoutTokenResponseDto} from '@shipfox/api-workflows-dto';\n\nconst SCP_LIKE_HOST_RE = /^(?:[^@:/]+@)?([^:/]+):/;\n\n// Defense in depth: createCheckoutSpec's contract is that `repositoryUrl` never\n// embeds credentials (they live in `credentials` so redaction can mask them). A\n// provider bug that put a token in the URL would bypass redaction and leak it\n// into `git remote -v` and logs, so reject it before it reaches the runner.\nfunction assertNoEmbeddedCredentials(repositoryUrl: string): void {\n // Run the scp-style check unconditionally: a genuine scp form\n // (git@host:org/repo.git) fails URL parsing, but a `user:secret@host:path`\n // string parses with a bogus `user:` scheme and *empty* URL userinfo, so the\n // url.username check below would miss its embedded password.\n assertNoScpCredentials(repositoryUrl);\n\n let url: URL;\n try {\n url = new URL(repositoryUrl);\n } catch {\n return;\n }\n if (url.username || url.password) {\n throw new Error('Checkout repository URL must not embed credentials');\n }\n}\n\n// scp-like userinfo is everything before the first `@`, and that `@` precedes\n// the first `/`. A bare `git@host:path` user is fine; a `user:secret@host:path`\n// password embeds a credential, so reject any colon in the userinfo segment.\nfunction assertNoScpCredentials(repositoryUrl: string): void {\n const atIndex = repositoryUrl.indexOf('@');\n const slashIndex = repositoryUrl.indexOf('/');\n if (atIndex === -1 || (slashIndex !== -1 && atIndex > slashIndex)) {\n return;\n }\n if (repositoryUrl.slice(0, atIndex).includes(':')) {\n throw new Error('Checkout repository URL must not embed credentials');\n }\n}\n\nexport function toCheckoutTokenDto(\n spec: CheckoutSpec,\n options: {persist: boolean},\n): CheckoutTokenResponseDto {\n assertNoEmbeddedCredentials(spec.repositoryUrl);\n\n // Every provider that returns credentials uses a username (GitHub:\n // 'x-access-token'), so the response is always basic auth; a credential-free\n // spec (debug) omits auth entirely.\n return {\n repository_url: spec.repositoryUrl,\n ref: spec.ref,\n ...(spec.gitAuthor\n ? {git_author: {name: spec.gitAuthor.name, email: spec.gitAuthor.email}}\n : {}),\n ...(spec.credentials\n ? {\n auth: {\n kind: 'basic' as const,\n username: spec.credentials.username,\n token: spec.credentials.token,\n expires_at: spec.credentials.expiresAt.toISOString(),\n carry: 'header' as const,\n host: checkoutHost(spec.repositoryUrl),\n persist: options.persist,\n },\n }\n : {}),\n };\n}\n\nfunction checkoutHost(repositoryUrl: string): string {\n try {\n const host = new URL(repositoryUrl).host;\n if (host) return host;\n } catch {\n // Fall through to scp-like parsing.\n }\n\n const scpLike = SCP_LIKE_HOST_RE.exec(repositoryUrl);\n if (scpLike?.[1]) return scpLike[1];\n\n throw new Error('Checkout repository URL must include a host');\n}\n"],"names":["SCP_LIKE_HOST_RE","assertNoEmbeddedCredentials","repositoryUrl","assertNoScpCredentials","url","URL","username","password","Error","atIndex","indexOf","slashIndex","slice","includes","toCheckoutTokenDto","spec","options","repository_url","ref","gitAuthor","git_author","name","email","credentials","auth","kind","token","expires_at","expiresAt","toISOString","carry","host","checkoutHost","persist","scpLike","exec"],"mappings":"AASA,MAAMA,mBAAmB;AAEzB,gFAAgF;AAChF,gFAAgF;AAChF,8EAA8E;AAC9E,4EAA4E;AAC5E,SAASC,4BAA4BC,aAAqB;IACxD,8DAA8D;IAC9D,2EAA2E;IAC3E,6EAA6E;IAC7E,6DAA6D;IAC7DC,uBAAuBD;IAEvB,IAAIE;IACJ,IAAI;QACFA,MAAM,IAAIC,IAAIH;IAChB,EAAE,OAAM;QACN;IACF;IACA,IAAIE,IAAIE,QAAQ,IAAIF,IAAIG,QAAQ,EAAE;QAChC,MAAM,IAAIC,MAAM;IAClB;AACF;AAEA,8EAA8E;AAC9E,gFAAgF;AAChF,6EAA6E;AAC7E,SAASL,uBAAuBD,aAAqB;IACnD,MAAMO,UAAUP,cAAcQ,OAAO,CAAC;IACtC,MAAMC,aAAaT,cAAcQ,OAAO,CAAC;IACzC,IAAID,YAAY,CAAC,KAAME,eAAe,CAAC,KAAKF,UAAUE,YAAa;QACjE;IACF;IACA,IAAIT,cAAcU,KAAK,CAAC,GAAGH,SAASI,QAAQ,CAAC,MAAM;QACjD,MAAM,IAAIL,MAAM;IAClB;AACF;AAEA,OAAO,SAASM,mBACdC,IAAkB,EAClBC,OAA2B;IAE3Bf,4BAA4Bc,KAAKb,aAAa;IAE9C,mEAAmE;IACnE,6EAA6E;IAC7E,oCAAoC;IACpC,OAAO;QACLe,gBAAgBF,KAAKb,aAAa;QAClCgB,KAAKH,KAAKG,GAAG;QACb,GAAIH,KAAKI,SAAS,GACd;YAACC,YAAY;gBAACC,MAAMN,KAAKI,SAAS,CAACE,IAAI;gBAAEC,OAAOP,KAAKI,SAAS,CAACG,KAAK;YAAA;QAAC,IACrE,CAAC,CAAC;QACN,GAAIP,KAAKQ,WAAW,GAChB;YACEC,MAAM;gBACJC,MAAM;gBACNnB,UAAUS,KAAKQ,WAAW,CAACjB,QAAQ;gBACnCoB,OAAOX,KAAKQ,WAAW,CAACG,KAAK;gBAC7BC,YAAYZ,KAAKQ,WAAW,CAACK,SAAS,CAACC,WAAW;gBAClDC,OAAO;gBACPC,MAAMC,aAAajB,KAAKb,aAAa;gBACrC+B,SAASjB,QAAQiB,OAAO;YAC1B;QACF,IACA,CAAC,CAAC;IACR;AACF;AAEA,SAASD,aAAa9B,aAAqB;IACzC,IAAI;QACF,MAAM6B,OAAO,IAAI1B,IAAIH,eAAe6B,IAAI;QACxC,IAAIA,MAAM,OAAOA;IACnB,EAAE,OAAM;IACN,oCAAoC;IACtC;IAEA,MAAMG,UAAUlC,iBAAiBmC,IAAI,CAACjC;IACtC,IAAIgC,SAAS,CAAC,EAAE,EAAE,OAAOA,OAAO,CAAC,EAAE;IAEnC,MAAM,IAAI1B,MAAM;AAClB"}
@@ -1,3 +1,3 @@
1
- export { workflowRoutes as routes } from './routes/index.js';
1
+ export { createWorkflowRoutes } from './routes/index.js';
2
2
  export { onJobEventDelivered, onJobStepsSettled, onRunnerJobClaimed, onRunnerJobLeaseExpired, onRunnerJobQueued, onWorkflowRunAttemptCreated, onWorkflowRunCancelled, } from './subscribers/index.js';
3
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/presentation/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,cAAc,IAAI,MAAM,EAAC,MAAM,mBAAmB,CAAC;AAC3D,OAAO,EACL,mBAAmB,EACnB,iBAAiB,EACjB,kBAAkB,EAClB,uBAAuB,EACvB,iBAAiB,EACjB,2BAA2B,EAC3B,sBAAsB,GACvB,MAAM,wBAAwB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/presentation/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,oBAAoB,EAAC,MAAM,mBAAmB,CAAC;AACvD,OAAO,EACL,mBAAmB,EACnB,iBAAiB,EACjB,kBAAkB,EAClB,uBAAuB,EACvB,iBAAiB,EACjB,2BAA2B,EAC3B,sBAAsB,GACvB,MAAM,wBAAwB,CAAC"}
@@ -1,4 +1,4 @@
1
- export { workflowRoutes as routes } from './routes/index.js';
1
+ export { createWorkflowRoutes } from './routes/index.js';
2
2
  export { onJobEventDelivered, onJobStepsSettled, onRunnerJobClaimed, onRunnerJobLeaseExpired, onRunnerJobQueued, onWorkflowRunAttemptCreated, onWorkflowRunCancelled } from './subscribers/index.js';
3
3
 
4
4
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/presentation/index.ts"],"sourcesContent":["export {workflowRoutes as routes} from './routes/index.js';\nexport {\n onJobEventDelivered,\n onJobStepsSettled,\n onRunnerJobClaimed,\n onRunnerJobLeaseExpired,\n onRunnerJobQueued,\n onWorkflowRunAttemptCreated,\n onWorkflowRunCancelled,\n} from './subscribers/index.js';\n"],"names":["workflowRoutes","routes","onJobEventDelivered","onJobStepsSettled","onRunnerJobClaimed","onRunnerJobLeaseExpired","onRunnerJobQueued","onWorkflowRunAttemptCreated","onWorkflowRunCancelled"],"mappings":"AAAA,SAAQA,kBAAkBC,MAAM,QAAO,oBAAoB;AAC3D,SACEC,mBAAmB,EACnBC,iBAAiB,EACjBC,kBAAkB,EAClBC,uBAAuB,EACvBC,iBAAiB,EACjBC,2BAA2B,EAC3BC,sBAAsB,QACjB,yBAAyB"}
1
+ {"version":3,"sources":["../../src/presentation/index.ts"],"sourcesContent":["export {createWorkflowRoutes} from './routes/index.js';\nexport {\n onJobEventDelivered,\n onJobStepsSettled,\n onRunnerJobClaimed,\n onRunnerJobLeaseExpired,\n onRunnerJobQueued,\n onWorkflowRunAttemptCreated,\n onWorkflowRunCancelled,\n} from './subscribers/index.js';\n"],"names":["createWorkflowRoutes","onJobEventDelivered","onJobStepsSettled","onRunnerJobClaimed","onRunnerJobLeaseExpired","onRunnerJobQueued","onWorkflowRunAttemptCreated","onWorkflowRunCancelled"],"mappings":"AAAA,SAAQA,oBAAoB,QAAO,oBAAoB;AACvD,SACEC,mBAAmB,EACnBC,iBAAiB,EACjBC,kBAAkB,EAClBC,uBAAuB,EACvBC,iBAAiB,EACjBC,2BAA2B,EAC3BC,sBAAsB,QACjB,yBAAyB"}
@@ -0,0 +1,18 @@
1
+ import type { AgentInterModuleClient } from '@shipfox/api-agent-dto/inter-module';
2
+ import type { DefinitionsInterModuleClient } from '@shipfox/api-definitions-dto/inter-module';
3
+ import type { IntegrationsModuleClient } from '@shipfox/api-integration-core-dto';
4
+ import type { ProjectsModuleClient } from '@shipfox/api-projects-dto';
5
+ import type { RunnersInterModuleClient } from '@shipfox/api-runners-dto/inter-module';
6
+ import type { SecretsInterModuleClient } from '@shipfox/api-secrets-dto/inter-module';
7
+ import { workflowsInterModuleContract } from '@shipfox/api-workflows-dto/inter-module';
8
+ import { type InterModulePresentation } from '@shipfox/inter-module';
9
+ export declare function createWorkflowsInterModulePresentation(params: {
10
+ agent: AgentInterModuleClient;
11
+ definitions: DefinitionsInterModuleClient;
12
+ secrets: Pick<SecretsInterModuleClient, 'getVariablesByNamespace'>;
13
+ runners: RunnersInterModuleClient;
14
+ integrations: IntegrationsModuleClient;
15
+ projects: ProjectsModuleClient;
16
+ }): InterModulePresentation<typeof workflowsInterModuleContract>;
17
+ export declare function toStartRunKnownError(error: unknown, definitionId: string): unknown;
18
+ //# sourceMappingURL=inter-module.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inter-module.d.ts","sourceRoot":"","sources":["../../src/presentation/inter-module.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAC,sBAAsB,EAAC,MAAM,qCAAqC,CAAC;AAChF,OAAO,KAAK,EAAC,4BAA4B,EAAC,MAAM,2CAA2C,CAAC;AAC5F,OAAO,KAAK,EAAC,wBAAwB,EAAC,MAAM,mCAAmC,CAAC;AAChF,OAAO,KAAK,EAAC,oBAAoB,EAAC,MAAM,2BAA2B,CAAC;AACpE,OAAO,KAAK,EAAC,wBAAwB,EAAC,MAAM,uCAAuC,CAAC;AACpF,OAAO,KAAK,EAAC,wBAAwB,EAAC,MAAM,uCAAuC,CAAC;AACpF,OAAO,EAAC,4BAA4B,EAAC,MAAM,yCAAyC,CAAC;AACrF,OAAO,EAGL,KAAK,uBAAuB,EAC7B,MAAM,uBAAuB,CAAC;AAa/B,wBAAgB,sCAAsC,CAAC,MAAM,EAAE;IAC7D,KAAK,EAAE,sBAAsB,CAAC;IAC9B,WAAW,EAAE,4BAA4B,CAAC;IAC1C,OAAO,EAAE,IAAI,CAAC,wBAAwB,EAAE,yBAAyB,CAAC,CAAC;IACnE,OAAO,EAAE,wBAAwB,CAAC;IAClC,YAAY,EAAE,wBAAwB,CAAC;IACvC,QAAQ,EAAE,oBAAoB,CAAC;CAChC,GAAG,uBAAuB,CAAC,OAAO,4BAA4B,CAAC,CA+D/D;AAED,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,GAAG,OAAO,CA8BlF"}
@@ -0,0 +1,113 @@
1
+ import { DEFAULT_HARNESS, harnessSchema, materializedAgentStepConfigSchema } from '@shipfox/api-agent-dto';
2
+ import { workflowsInterModuleContract } from '@shipfox/api-workflows-dto/inter-module';
3
+ import { createInterModuleKnownError, defineInterModulePresentation } from '@shipfox/inter-module';
4
+ import { InvalidJobRunnerLabelsError } from '#core/errors.js';
5
+ import { AgentConfigUnresolvableError, AgentIntegrationMaterializationError, DefinitionNotFoundError, InterpolationUnresolvableError, ProjectMismatchError, runWorkflow } from '#core/index.js';
6
+ import { getJobScope, getStepById, getStepByIdForJobExecution } from '#db/index.js';
7
+ import { deliverEventToListener } from '#db/job-listener-events.js';
8
+ export function createWorkflowsInterModulePresentation(params) {
9
+ return defineInterModulePresentation(workflowsInterModuleContract, {
10
+ startRunFromTrigger: async (input)=>{
11
+ try {
12
+ const run = await runWorkflow(params.definitions, {
13
+ agent: params.agent,
14
+ workspaceId: input.workspaceId,
15
+ projectId: input.projectId,
16
+ definitionId: input.definitionId,
17
+ triggerPayload: input.triggerPayload,
18
+ inputs: input.inputs,
19
+ triggerIdempotencyKey: input.idempotencyKey,
20
+ integrations: params.integrations,
21
+ projects: params.projects
22
+ }, {
23
+ secrets: params.secrets
24
+ });
25
+ return {
26
+ id: run.id,
27
+ name: run.name
28
+ };
29
+ } catch (error) {
30
+ throw toStartRunKnownError(error, input.definitionId);
31
+ }
32
+ },
33
+ deliverEventToJobListener: async (input)=>await deliverEventToListener({
34
+ ...input,
35
+ receivedAt: new Date(input.receivedAt)
36
+ }),
37
+ getStepLogContext: async ({ stepId })=>{
38
+ const step = await getStepById(stepId);
39
+ const parsed = harnessSchema.safeParse(step?.config.harness);
40
+ return {
41
+ harness: parsed.success ? parsed.data : DEFAULT_HARNESS
42
+ };
43
+ },
44
+ getLeasedAgentToolContext: async (input)=>{
45
+ const method = workflowsInterModuleContract.methods.getLeasedAgentToolContext;
46
+ const { active: leaseIsActive } = await params.runners.getLeaseState({
47
+ jobId: input.jobId,
48
+ jobExecutionId: input.jobExecutionId,
49
+ runnerSessionId: input.runnerSessionId
50
+ });
51
+ if (!leaseIsActive) throw createInterModuleKnownError(method, 'lease-not-active', {});
52
+ const step = await getStepByIdForJobExecution({
53
+ stepId: input.stepId,
54
+ jobExecutionId: input.jobExecutionId
55
+ });
56
+ if (!step) throw createInterModuleKnownError(method, 'step-not-found', {});
57
+ const scope = await getJobScope(input.jobId);
58
+ if (!scope) throw createInterModuleKnownError(method, 'job-not-found', {});
59
+ if (step.currentAttempt !== input.attempt) {
60
+ throw createInterModuleKnownError(method, 'step-attempt-mismatch', {});
61
+ }
62
+ if (step.status !== 'running') throw createInterModuleKnownError(method, 'step-not-running', {});
63
+ if (step.type !== 'agent') throw createInterModuleKnownError(method, 'leased-step-not-agent', {});
64
+ const config = materializedAgentStepConfigSchema.safeParse(step.config);
65
+ if (!config.success) {
66
+ throw createInterModuleKnownError(method, 'agent-step-config-invalid', {});
67
+ }
68
+ return {
69
+ workspaceId: scope.workspaceId,
70
+ integrations: config.data.integrations ?? []
71
+ };
72
+ }
73
+ });
74
+ }
75
+ export function toStartRunKnownError(error, definitionId) {
76
+ const method = workflowsInterModuleContract.methods.startRunFromTrigger;
77
+ if (error instanceof DefinitionNotFoundError) {
78
+ return createInterModuleKnownError(method, 'definition-not-found', {
79
+ definitionId
80
+ });
81
+ }
82
+ if (error instanceof ProjectMismatchError) {
83
+ return createInterModuleKnownError(method, 'project-mismatch', {});
84
+ }
85
+ if (error instanceof AgentConfigUnresolvableError) {
86
+ return createInterModuleKnownError(method, 'agent-config-unresolvable', {
87
+ definitionId: error.definitionId
88
+ });
89
+ }
90
+ if (error instanceof AgentIntegrationMaterializationError) {
91
+ return createInterModuleKnownError(method, 'agent-integration-materialization-failed', {});
92
+ }
93
+ if (error instanceof InterpolationUnresolvableError) {
94
+ return createInterModuleKnownError(method, 'interpolation-unresolvable', {
95
+ definitionId: error.definitionId,
96
+ field: error.field,
97
+ source: error.source,
98
+ ...error.envKey === undefined ? {} : {
99
+ envKey: error.envKey
100
+ }
101
+ });
102
+ }
103
+ if (error instanceof InvalidJobRunnerLabelsError) {
104
+ return createInterModuleKnownError(method, 'invalid-job-runner-labels', {
105
+ labels: [
106
+ ...error.labels
107
+ ]
108
+ });
109
+ }
110
+ return error;
111
+ }
112
+
113
+ //# sourceMappingURL=inter-module.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/presentation/inter-module.ts"],"sourcesContent":["import {\n DEFAULT_HARNESS,\n harnessSchema,\n materializedAgentStepConfigSchema,\n} from '@shipfox/api-agent-dto';\nimport type {AgentInterModuleClient} from '@shipfox/api-agent-dto/inter-module';\nimport type {DefinitionsInterModuleClient} from '@shipfox/api-definitions-dto/inter-module';\nimport type {IntegrationsModuleClient} from '@shipfox/api-integration-core-dto';\nimport type {ProjectsModuleClient} from '@shipfox/api-projects-dto';\nimport type {RunnersInterModuleClient} from '@shipfox/api-runners-dto/inter-module';\nimport type {SecretsInterModuleClient} from '@shipfox/api-secrets-dto/inter-module';\nimport {workflowsInterModuleContract} from '@shipfox/api-workflows-dto/inter-module';\nimport {\n createInterModuleKnownError,\n defineInterModulePresentation,\n type InterModulePresentation,\n} from '@shipfox/inter-module';\nimport {InvalidJobRunnerLabelsError} from '#core/errors.js';\nimport {\n AgentConfigUnresolvableError,\n AgentIntegrationMaterializationError,\n DefinitionNotFoundError,\n InterpolationUnresolvableError,\n ProjectMismatchError,\n runWorkflow,\n} from '#core/index.js';\nimport {getJobScope, getStepById, getStepByIdForJobExecution} from '#db/index.js';\nimport {deliverEventToListener} from '#db/job-listener-events.js';\n\nexport function createWorkflowsInterModulePresentation(params: {\n agent: AgentInterModuleClient;\n definitions: DefinitionsInterModuleClient;\n secrets: Pick<SecretsInterModuleClient, 'getVariablesByNamespace'>;\n runners: RunnersInterModuleClient;\n integrations: IntegrationsModuleClient;\n projects: ProjectsModuleClient;\n}): InterModulePresentation<typeof workflowsInterModuleContract> {\n return defineInterModulePresentation(workflowsInterModuleContract, {\n startRunFromTrigger: async (input) => {\n try {\n const run = await runWorkflow(\n params.definitions,\n {\n agent: params.agent,\n workspaceId: input.workspaceId,\n projectId: input.projectId,\n definitionId: input.definitionId,\n triggerPayload: input.triggerPayload,\n inputs: input.inputs,\n triggerIdempotencyKey: input.idempotencyKey,\n integrations: params.integrations,\n projects: params.projects,\n },\n {secrets: params.secrets},\n );\n return {id: run.id, name: run.name};\n } catch (error) {\n throw toStartRunKnownError(error, input.definitionId);\n }\n },\n deliverEventToJobListener: async (input) =>\n await deliverEventToListener({...input, receivedAt: new Date(input.receivedAt)}),\n getStepLogContext: async ({stepId}) => {\n const step = await getStepById(stepId);\n const parsed = harnessSchema.safeParse(step?.config.harness);\n return {harness: parsed.success ? parsed.data : DEFAULT_HARNESS};\n },\n getLeasedAgentToolContext: async (input) => {\n const method = workflowsInterModuleContract.methods.getLeasedAgentToolContext;\n const {active: leaseIsActive} = await params.runners.getLeaseState({\n jobId: input.jobId,\n jobExecutionId: input.jobExecutionId,\n runnerSessionId: input.runnerSessionId,\n });\n if (!leaseIsActive) throw createInterModuleKnownError(method, 'lease-not-active', {});\n\n const step = await getStepByIdForJobExecution({\n stepId: input.stepId,\n jobExecutionId: input.jobExecutionId,\n });\n if (!step) throw createInterModuleKnownError(method, 'step-not-found', {});\n\n const scope = await getJobScope(input.jobId);\n if (!scope) throw createInterModuleKnownError(method, 'job-not-found', {});\n if (step.currentAttempt !== input.attempt) {\n throw createInterModuleKnownError(method, 'step-attempt-mismatch', {});\n }\n if (step.status !== 'running')\n throw createInterModuleKnownError(method, 'step-not-running', {});\n if (step.type !== 'agent')\n throw createInterModuleKnownError(method, 'leased-step-not-agent', {});\n\n const config = materializedAgentStepConfigSchema.safeParse(step.config);\n if (!config.success) {\n throw createInterModuleKnownError(method, 'agent-step-config-invalid', {});\n }\n return {workspaceId: scope.workspaceId, integrations: config.data.integrations ?? []};\n },\n });\n}\n\nexport function toStartRunKnownError(error: unknown, definitionId: string): unknown {\n const method = workflowsInterModuleContract.methods.startRunFromTrigger;\n if (error instanceof DefinitionNotFoundError) {\n return createInterModuleKnownError(method, 'definition-not-found', {definitionId});\n }\n if (error instanceof ProjectMismatchError) {\n return createInterModuleKnownError(method, 'project-mismatch', {});\n }\n if (error instanceof AgentConfigUnresolvableError) {\n return createInterModuleKnownError(method, 'agent-config-unresolvable', {\n definitionId: error.definitionId,\n });\n }\n if (error instanceof AgentIntegrationMaterializationError) {\n return createInterModuleKnownError(method, 'agent-integration-materialization-failed', {});\n }\n if (error instanceof InterpolationUnresolvableError) {\n return createInterModuleKnownError(method, 'interpolation-unresolvable', {\n definitionId: error.definitionId,\n field: error.field,\n source: error.source,\n ...(error.envKey === undefined ? {} : {envKey: error.envKey}),\n });\n }\n if (error instanceof InvalidJobRunnerLabelsError) {\n return createInterModuleKnownError(method, 'invalid-job-runner-labels', {\n labels: [...error.labels],\n });\n }\n return error;\n}\n"],"names":["DEFAULT_HARNESS","harnessSchema","materializedAgentStepConfigSchema","workflowsInterModuleContract","createInterModuleKnownError","defineInterModulePresentation","InvalidJobRunnerLabelsError","AgentConfigUnresolvableError","AgentIntegrationMaterializationError","DefinitionNotFoundError","InterpolationUnresolvableError","ProjectMismatchError","runWorkflow","getJobScope","getStepById","getStepByIdForJobExecution","deliverEventToListener","createWorkflowsInterModulePresentation","params","startRunFromTrigger","input","run","definitions","agent","workspaceId","projectId","definitionId","triggerPayload","inputs","triggerIdempotencyKey","idempotencyKey","integrations","projects","secrets","id","name","error","toStartRunKnownError","deliverEventToJobListener","receivedAt","Date","getStepLogContext","stepId","step","parsed","safeParse","config","harness","success","data","getLeasedAgentToolContext","method","methods","active","leaseIsActive","runners","getLeaseState","jobId","jobExecutionId","runnerSessionId","scope","currentAttempt","attempt","status","type","field","source","envKey","undefined","labels"],"mappings":"AAAA,SACEA,eAAe,EACfC,aAAa,EACbC,iCAAiC,QAC5B,yBAAyB;AAOhC,SAAQC,4BAA4B,QAAO,0CAA0C;AACrF,SACEC,2BAA2B,EAC3BC,6BAA6B,QAExB,wBAAwB;AAC/B,SAAQC,2BAA2B,QAAO,kBAAkB;AAC5D,SACEC,4BAA4B,EAC5BC,oCAAoC,EACpCC,uBAAuB,EACvBC,8BAA8B,EAC9BC,oBAAoB,EACpBC,WAAW,QACN,iBAAiB;AACxB,SAAQC,WAAW,EAAEC,WAAW,EAAEC,0BAA0B,QAAO,eAAe;AAClF,SAAQC,sBAAsB,QAAO,6BAA6B;AAElE,OAAO,SAASC,uCAAuCC,MAOtD;IACC,OAAOb,8BAA8BF,8BAA8B;QACjEgB,qBAAqB,OAAOC;YAC1B,IAAI;gBACF,MAAMC,MAAM,MAAMT,YAChBM,OAAOI,WAAW,EAClB;oBACEC,OAAOL,OAAOK,KAAK;oBACnBC,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AAQ,8BAA8B;YACvEzB,cAAcU,MAAMV,YAAY;YAChCuC,OAAO7B,MAAM6B,KAAK;YAClBC,QAAQ9B,MAAM8B,MAAM;YACpB,GAAI9B,MAAM+B,MAAM,KAAKC,YAAY,CAAC,IAAI;gBAACD,QAAQ/B,MAAM+B,MAAM;YAAA,CAAC;QAC9D;IACF;IACA,IAAI/B,iBAAiB9B,6BAA6B;QAChD,OAAOF,4BAA4B+C,QAAQ,6BAA6B;YACtEkB,QAAQ;mBAAIjC,MAAMiC,MAAM;aAAC;QAC3B;IACF;IACA,OAAOjC;AACT"}
@@ -1,2 +1,7 @@
1
- export declare const agentRuntimeConfigRoute: import("@shipfox/node-fastify").RouteDefinition;
1
+ import { type AgentInterModuleClient } from '@shipfox/api-agent-dto/inter-module';
2
+ import type { RunnersInterModuleClient } from '@shipfox/api-runners-dto/inter-module';
3
+ export declare function createAgentRuntimeConfigRoute(params: {
4
+ agent: AgentInterModuleClient;
5
+ runners: RunnersInterModuleClient;
6
+ }): import("@shipfox/node-fastify").RouteDefinition;
2
7
  //# sourceMappingURL=agent-runtime-config.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"agent-runtime-config.d.ts","sourceRoot":"","sources":["../../../src/presentation/routes/agent-runtime-config.ts"],"names":[],"mappings":"AAcA,eAAO,MAAM,uBAAuB,iDAkElC,CAAC"}
1
+ {"version":3,"file":"agent-runtime-config.d.ts","sourceRoot":"","sources":["../../../src/presentation/routes/agent-runtime-config.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,KAAK,sBAAsB,EAE5B,MAAM,qCAAqC,CAAC;AAC7C,OAAO,KAAK,EAAC,wBAAwB,EAAC,MAAM,uCAAuC,CAAC;AAQpF,wBAAgB,6BAA6B,CAAC,MAAM,EAAE;IACpD,KAAK,EAAE,sBAAsB,CAAC;IAC9B,OAAO,EAAE,wBAAwB,CAAC;CACnC,mDAqFA"}