@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.
- package/.turbo/turbo-build.log +2 -0
- package/.turbo/turbo-type$colon$emit.log +1 -0
- package/.turbo/turbo-type.log +1 -0
- package/CHANGELOG.md +311 -0
- package/LICENSE +21 -0
- package/dist/core/agent-tool-capability-warning.d.ts +7 -0
- package/dist/core/agent-tool-capability-warning.d.ts.map +1 -0
- package/dist/core/agent-tool-capability-warning.js +149 -0
- package/dist/core/agent-tool-capability-warning.js.map +1 -0
- package/dist/core/agent-tools.d.ts +51 -0
- package/dist/core/agent-tools.d.ts.map +1 -0
- package/dist/core/agent-tools.js +296 -0
- package/dist/core/agent-tools.js.map +1 -0
- package/dist/core/checkout.d.ts +29 -0
- package/dist/core/checkout.d.ts.map +1 -0
- package/dist/core/checkout.js +42 -0
- package/dist/core/checkout.js.map +1 -0
- package/dist/core/condition-trace.d.ts +13 -0
- package/dist/core/condition-trace.d.ts.map +1 -0
- package/dist/core/condition-trace.js +51 -0
- package/dist/core/condition-trace.js.map +1 -0
- package/dist/core/entities/index.d.ts +5 -0
- package/dist/core/entities/index.d.ts.map +1 -0
- package/dist/core/entities/index.js +3 -0
- package/dist/core/entities/index.js.map +1 -0
- package/dist/core/entities/job-execution.d.ts +30 -0
- package/dist/core/entities/job-execution.d.ts.map +1 -0
- package/dist/core/entities/job-execution.js +3 -0
- package/dist/core/entities/job-execution.js.map +1 -0
- package/dist/core/entities/job-listener-event.d.ts +15 -0
- package/dist/core/entities/job-listener-event.d.ts.map +1 -0
- package/dist/core/entities/job-listener-event.js +3 -0
- package/dist/core/entities/job-listener-event.js.map +1 -0
- package/dist/core/entities/job.d.ts +54 -0
- package/dist/core/entities/job.d.ts.map +1 -0
- package/dist/core/entities/job.js +29 -0
- package/dist/core/entities/job.js.map +1 -0
- package/dist/core/entities/step.d.ts +86 -0
- package/dist/core/entities/step.d.ts.map +1 -0
- package/dist/core/entities/step.js +12 -0
- package/dist/core/entities/step.js.map +1 -0
- package/dist/core/entities/workflow-run-attempt.d.ts +20 -0
- package/dist/core/entities/workflow-run-attempt.d.ts.map +1 -0
- package/dist/core/entities/workflow-run-attempt.js +3 -0
- package/dist/core/entities/workflow-run-attempt.js.map +1 -0
- package/dist/core/entities/workflow-run.d.ts +66 -0
- package/dist/core/entities/workflow-run.d.ts.map +1 -0
- package/dist/core/entities/workflow-run.js +10 -0
- package/dist/core/entities/workflow-run.js.map +1 -0
- package/dist/core/errors.d.ts +85 -0
- package/dist/core/errors.d.ts.map +1 -0
- package/dist/core/errors.js +134 -0
- package/dist/core/errors.js.map +1 -0
- package/dist/core/index.d.ts +14 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +9 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/job-execution-outcome.d.ts +29 -0
- package/dist/core/job-execution-outcome.d.ts.map +1 -0
- package/dist/core/job-execution-outcome.js +31 -0
- package/dist/core/job-execution-outcome.js.map +1 -0
- package/dist/core/job-execution.d.ts +37 -0
- package/dist/core/job-execution.d.ts.map +1 -0
- package/dist/core/job-execution.js +425 -0
- package/dist/core/job-execution.js.map +1 -0
- package/dist/core/job-transition/decide-job-activation.d.ts +29 -0
- package/dist/core/job-transition/decide-job-activation.d.ts.map +1 -0
- package/dist/core/job-transition/decide-job-activation.js +51 -0
- package/dist/core/job-transition/decide-job-activation.js.map +1 -0
- package/dist/core/job-transition/derive-job-execution-outputs.d.ts +18 -0
- package/dist/core/job-transition/derive-job-execution-outputs.d.ts.map +1 -0
- package/dist/core/job-transition/derive-job-execution-outputs.js +23 -0
- package/dist/core/job-transition/derive-job-execution-outputs.js.map +1 -0
- package/dist/core/job-transition/derive-job-success.d.ts +16 -0
- package/dist/core/job-transition/derive-job-success.d.ts.map +1 -0
- package/dist/core/job-transition/derive-job-success.js +47 -0
- package/dist/core/job-transition/derive-job-success.js.map +1 -0
- package/dist/core/job-transition/index.d.ts +5 -0
- package/dist/core/job-transition/index.d.ts.map +1 -0
- package/dist/core/job-transition/index.js +6 -0
- package/dist/core/job-transition/index.js.map +1 -0
- package/dist/core/job-transition/runtime-completion-status-for-job.d.ts +4 -0
- package/dist/core/job-transition/runtime-completion-status-for-job.d.ts.map +1 -0
- package/dist/core/job-transition/runtime-completion-status-for-job.js +8 -0
- package/dist/core/job-transition/runtime-completion-status-for-job.js.map +1 -0
- package/dist/core/listener-execution-materialization.d.ts +30 -0
- package/dist/core/listener-execution-materialization.d.ts.map +1 -0
- package/dist/core/listener-execution-materialization.js +87 -0
- package/dist/core/listener-execution-materialization.js.map +1 -0
- package/dist/core/run-workflow.d.ts +11 -0
- package/dist/core/run-workflow.d.ts.map +1 -0
- package/dist/core/run-workflow.js +28 -0
- package/dist/core/run-workflow.js.map +1 -0
- package/dist/core/source-control.d.ts +5 -0
- package/dist/core/source-control.d.ts.map +1 -0
- package/dist/core/source-control.js +19 -0
- package/dist/core/source-control.js.map +1 -0
- package/dist/core/step-config/agent.d.ts +49 -0
- package/dist/core/step-config/agent.d.ts.map +1 -0
- package/dist/core/step-config/agent.js +337 -0
- package/dist/core/step-config/agent.js.map +1 -0
- package/dist/core/step-config/assemble-run-context.d.ts +94 -0
- package/dist/core/step-config/assemble-run-context.d.ts.map +1 -0
- package/dist/core/step-config/assemble-run-context.js +393 -0
- package/dist/core/step-config/assemble-run-context.js.map +1 -0
- package/dist/core/step-config/complete-step-dispatch-config.d.ts +13 -0
- package/dist/core/step-config/complete-step-dispatch-config.d.ts.map +1 -0
- package/dist/core/step-config/complete-step-dispatch-config.js +38 -0
- package/dist/core/step-config/complete-step-dispatch-config.js.map +1 -0
- package/dist/core/step-config/fields.d.ts +38 -0
- package/dist/core/step-config/fields.d.ts.map +1 -0
- package/dist/core/step-config/fields.js +72 -0
- package/dist/core/step-config/fields.js.map +1 -0
- package/dist/core/step-config/index.d.ts +8 -0
- package/dist/core/step-config/index.d.ts.map +1 -0
- package/dist/core/step-config/index.js +7 -0
- package/dist/core/step-config/index.js.map +1 -0
- package/dist/core/step-config/materialize-job-execution-steps.d.ts +35 -0
- package/dist/core/step-config/materialize-job-execution-steps.d.ts.map +1 -0
- package/dist/core/step-config/materialize-job-execution-steps.js +92 -0
- package/dist/core/step-config/materialize-job-execution-steps.js.map +1 -0
- package/dist/core/step-config/materialize-workflow-model.d.ts +42 -0
- package/dist/core/step-config/materialize-workflow-model.d.ts.map +1 -0
- package/dist/core/step-config/materialize-workflow-model.js +96 -0
- package/dist/core/step-config/materialize-workflow-model.js.map +1 -0
- package/dist/core/step-config/resolve-job-execution-name.d.ts +18 -0
- package/dist/core/step-config/resolve-job-execution-name.d.ts.map +1 -0
- package/dist/core/step-config/resolve-job-execution-name.js +36 -0
- package/dist/core/step-config/resolve-job-execution-name.js.map +1 -0
- package/dist/core/step-config/resolve-step-config.d.ts +33 -0
- package/dist/core/step-config/resolve-step-config.d.ts.map +1 -0
- package/dist/core/step-config/resolve-step-config.js +164 -0
- package/dist/core/step-config/resolve-step-config.js.map +1 -0
- package/dist/core/step-config/run.d.ts +39 -0
- package/dist/core/step-config/run.d.ts.map +1 -0
- package/dist/core/step-config/run.js +360 -0
- package/dist/core/step-config/run.js.map +1 -0
- package/dist/core/step-config/workflow-evaluation-context.d.ts +6 -0
- package/dist/core/step-config/workflow-evaluation-context.d.ts.map +1 -0
- package/dist/core/step-config/workflow-evaluation-context.js +3 -0
- package/dist/core/step-config/workflow-evaluation-context.js.map +1 -0
- package/dist/core/step-transition/apply-step-transition.d.ts +26 -0
- package/dist/core/step-transition/apply-step-transition.d.ts.map +1 -0
- package/dist/core/step-transition/apply-step-transition.js +141 -0
- package/dist/core/step-transition/apply-step-transition.js.map +1 -0
- package/dist/core/step-transition/decide-step-transition.d.ts +71 -0
- package/dist/core/step-transition/decide-step-transition.d.ts.map +1 -0
- package/dist/core/step-transition/decide-step-transition.js +110 -0
- package/dist/core/step-transition/decide-step-transition.js.map +1 -0
- package/dist/core/step-transition/evaluate-gate.d.ts +28 -0
- package/dist/core/step-transition/evaluate-gate.d.ts.map +1 -0
- package/dist/core/step-transition/evaluate-gate.js +159 -0
- package/dist/core/step-transition/evaluate-gate.js.map +1 -0
- package/dist/core/step-transition/read-step-outputs.d.ts +3 -0
- package/dist/core/step-transition/read-step-outputs.d.ts.map +1 -0
- package/dist/core/step-transition/read-step-outputs.js +24 -0
- package/dist/core/step-transition/read-step-outputs.js.map +1 -0
- package/dist/core/workflow-run-creation.d.ts +43 -0
- package/dist/core/workflow-run-creation.d.ts.map +1 -0
- package/dist/core/workflow-run-creation.js +80 -0
- package/dist/core/workflow-run-creation.js.map +1 -0
- package/dist/core/workflow-scheduling/index.d.ts +5 -0
- package/dist/core/workflow-scheduling/index.d.ts.map +1 -0
- package/dist/core/workflow-scheduling/index.js +4 -0
- package/dist/core/workflow-scheduling/index.js.map +1 -0
- package/dist/core/workflow-scheduling/run-progress.d.ts +20 -0
- package/dist/core/workflow-scheduling/run-progress.d.ts.map +1 -0
- package/dist/core/workflow-scheduling/run-progress.js +40 -0
- package/dist/core/workflow-scheduling/run-progress.js.map +1 -0
- package/dist/core/workflow-scheduling/runtime-dag.d.ts +10 -0
- package/dist/core/workflow-scheduling/runtime-dag.d.ts.map +1 -0
- package/dist/core/workflow-scheduling/runtime-dag.js +3 -0
- package/dist/core/workflow-scheduling/runtime-dag.js.map +1 -0
- package/dist/core/workflow-scheduling/runtime-scheduling-command.d.ts +16 -0
- package/dist/core/workflow-scheduling/runtime-scheduling-command.d.ts.map +1 -0
- package/dist/core/workflow-scheduling/runtime-scheduling-command.js +3 -0
- package/dist/core/workflow-scheduling/runtime-scheduling-command.js.map +1 -0
- package/dist/core/workflow-scheduling/schedule-runtime-dag.d.ts +9 -0
- package/dist/core/workflow-scheduling/schedule-runtime-dag.d.ts.map +1 -0
- package/dist/core/workflow-scheduling/schedule-runtime-dag.js +72 -0
- package/dist/core/workflow-scheduling/schedule-runtime-dag.js.map +1 -0
- package/dist/db/db.d.ts +4959 -0
- package/dist/db/db.d.ts.map +1 -0
- package/dist/db/db.js +37 -0
- package/dist/db/db.js.map +1 -0
- package/dist/db/index.d.ts +9 -0
- package/dist/db/index.d.ts.map +1 -0
- package/dist/db/index.js +10 -0
- package/dist/db/index.js.map +1 -0
- package/dist/db/job-listener-events.d.ts +18 -0
- package/dist/db/job-listener-events.d.ts.map +1 -0
- package/dist/db/job-listener-events.js +59 -0
- package/dist/db/job-listener-events.js.map +1 -0
- package/dist/db/job-listeners.d.ts +55 -0
- package/dist/db/job-listeners.d.ts.map +1 -0
- package/dist/db/job-listeners.js +358 -0
- package/dist/db/job-listeners.js.map +1 -0
- package/dist/db/outbox-writes.d.ts +12 -0
- package/dist/db/outbox-writes.d.ts.map +1 -0
- package/dist/db/outbox-writes.js +20 -0
- package/dist/db/outbox-writes.js.map +1 -0
- package/dist/db/runner-lease-table.d.ts +469 -0
- package/dist/db/runner-lease-table.d.ts.map +1 -0
- package/dist/db/runner-lease-table.js +42 -0
- package/dist/db/runner-lease-table.js.map +1 -0
- package/dist/db/schema/common.d.ts +2 -0
- package/dist/db/schema/common.d.ts.map +1 -0
- package/dist/db/schema/common.js +4 -0
- package/dist/db/schema/common.js.map +1 -0
- package/dist/db/schema/job-executions.d.ts +311 -0
- package/dist/db/schema/job-executions.d.ts.map +1 -0
- package/dist/db/schema/job-executions.js +76 -0
- package/dist/db/schema/job-executions.js.map +1 -0
- package/dist/db/schema/job-listener-events.d.ts +200 -0
- package/dist/db/schema/job-listener-events.d.ts.map +1 -0
- package/dist/db/schema/job-listener-events.js +50 -0
- package/dist/db/schema/job-listener-events.js.map +1 -0
- package/dist/db/schema/jobs.d.ts +542 -0
- package/dist/db/schema/jobs.d.ts.map +1 -0
- package/dist/db/schema/jobs.js +121 -0
- package/dist/db/schema/jobs.js.map +1 -0
- package/dist/db/schema/outbox.d.ts +195 -0
- package/dist/db/schema/outbox.d.ts.map +1 -0
- package/dist/db/schema/outbox.js +5 -0
- package/dist/db/schema/outbox.js.map +1 -0
- package/dist/db/schema/step-attempts.d.ts +330 -0
- package/dist/db/schema/step-attempts.d.ts.map +1 -0
- package/dist/db/schema/step-attempts.js +80 -0
- package/dist/db/schema/step-attempts.js.map +1 -0
- package/dist/db/schema/steps.d.ts +352 -0
- package/dist/db/schema/steps.d.ts.map +1 -0
- package/dist/db/schema/steps.js +80 -0
- package/dist/db/schema/steps.js.map +1 -0
- package/dist/db/schema/workflow-run-attempts.d.ts +239 -0
- package/dist/db/schema/workflow-run-attempts.d.ts.map +1 -0
- package/dist/db/schema/workflow-run-attempts.js +53 -0
- package/dist/db/schema/workflow-run-attempts.js.map +1 -0
- package/dist/db/schema/workflow-runs.d.ts +360 -0
- package/dist/db/schema/workflow-runs.d.ts.map +1 -0
- package/dist/db/schema/workflow-runs.js +85 -0
- package/dist/db/schema/workflow-runs.js.map +1 -0
- package/dist/db/workflow-runs/job-executions.d.ts +49 -0
- package/dist/db/workflow-runs/job-executions.d.ts.map +1 -0
- package/dist/db/workflow-runs/job-executions.js +271 -0
- package/dist/db/workflow-runs/job-executions.js.map +1 -0
- package/dist/db/workflow-runs/jobs.d.ts +60 -0
- package/dist/db/workflow-runs/jobs.d.ts.map +1 -0
- package/dist/db/workflow-runs/jobs.js +288 -0
- package/dist/db/workflow-runs/jobs.js.map +1 -0
- package/dist/db/workflow-runs/outbox.d.ts +20 -0
- package/dist/db/workflow-runs/outbox.d.ts.map +1 -0
- package/dist/db/workflow-runs/outbox.js +68 -0
- package/dist/db/workflow-runs/outbox.js.map +1 -0
- package/dist/db/workflow-runs/queries.d.ts +71 -0
- package/dist/db/workflow-runs/queries.d.ts.map +1 -0
- package/dist/db/workflow-runs/queries.js +253 -0
- package/dist/db/workflow-runs/queries.js.map +1 -0
- package/dist/db/workflow-runs/run-create.d.ts +32 -0
- package/dist/db/workflow-runs/run-create.d.ts.map +1 -0
- package/dist/db/workflow-runs/run-create.js +288 -0
- package/dist/db/workflow-runs/run-create.js.map +1 -0
- package/dist/db/workflow-runs/run-graph.d.ts +27 -0
- package/dist/db/workflow-runs/run-graph.d.ts.map +1 -0
- package/dist/db/workflow-runs/run-graph.js +63 -0
- package/dist/db/workflow-runs/run-graph.js.map +1 -0
- package/dist/db/workflow-runs/run-rerun.d.ts +8 -0
- package/dist/db/workflow-runs/run-rerun.d.ts.map +1 -0
- package/dist/db/workflow-runs/run-rerun.js +207 -0
- package/dist/db/workflow-runs/run-rerun.js.map +1 -0
- package/dist/db/workflow-runs/run-status.d.ts +24 -0
- package/dist/db/workflow-runs/run-status.d.ts.map +1 -0
- package/dist/db/workflow-runs/run-status.js +249 -0
- package/dist/db/workflow-runs/run-status.js.map +1 -0
- package/dist/db/workflow-runs/runs.d.ts +7 -0
- package/dist/db/workflow-runs/runs.d.ts.map +1 -0
- package/dist/db/workflow-runs/runs.js +5 -0
- package/dist/db/workflow-runs/runs.js.map +1 -0
- package/dist/db/workflow-runs/shared.d.ts +24 -0
- package/dist/db/workflow-runs/shared.d.ts.map +1 -0
- package/dist/db/workflow-runs/shared.js +50 -0
- package/dist/db/workflow-runs/shared.js.map +1 -0
- package/dist/db/workflow-runs/steps.d.ts +83 -0
- package/dist/db/workflow-runs/steps.d.ts.map +1 -0
- package/dist/db/workflow-runs/steps.js +246 -0
- package/dist/db/workflow-runs/steps.js.map +1 -0
- package/dist/db/workflow-runs.d.ts +12 -0
- package/dist/db/workflow-runs.d.ts.map +1 -0
- package/dist/db/workflow-runs.js +8 -0
- package/dist/db/workflow-runs.js.map +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +54 -0
- package/dist/index.js.map +1 -0
- package/dist/metrics/index.d.ts +2 -0
- package/dist/metrics/index.d.ts.map +1 -0
- package/dist/metrics/index.js +3 -0
- package/dist/metrics/index.js.map +1 -0
- package/dist/metrics/instance.d.ts +20 -0
- package/dist/metrics/instance.d.ts.map +1 -0
- package/dist/metrics/instance.js +127 -0
- package/dist/metrics/instance.js.map +1 -0
- package/dist/metrics/service.d.ts +2 -0
- package/dist/metrics/service.d.ts.map +1 -0
- package/dist/metrics/service.js +30 -0
- package/dist/metrics/service.js.map +1 -0
- package/dist/presentation/dto/checkout-token.d.ts +6 -0
- package/dist/presentation/dto/checkout-token.d.ts.map +1 -0
- package/dist/presentation/dto/checkout-token.js +74 -0
- package/dist/presentation/dto/checkout-token.js.map +1 -0
- package/dist/presentation/dto/index.d.ts +4 -0
- package/dist/presentation/dto/index.d.ts.map +1 -0
- package/dist/presentation/dto/index.js +5 -0
- package/dist/presentation/dto/index.js.map +1 -0
- package/dist/presentation/dto/job.d.ts +6 -0
- package/dist/presentation/dto/job.d.ts.map +1 -0
- package/dist/presentation/dto/job.js +59 -0
- package/dist/presentation/dto/job.js.map +1 -0
- package/dist/presentation/dto/step.d.ts +6 -0
- package/dist/presentation/dto/step.d.ts.map +1 -0
- package/dist/presentation/dto/step.js +162 -0
- package/dist/presentation/dto/step.js.map +1 -0
- package/dist/presentation/dto/workflow-run.d.ts +6 -0
- package/dist/presentation/dto/workflow-run.d.ts.map +1 -0
- package/dist/presentation/dto/workflow-run.js +35 -0
- package/dist/presentation/dto/workflow-run.js.map +1 -0
- package/dist/presentation/index.d.ts +3 -0
- package/dist/presentation/index.d.ts.map +1 -0
- package/dist/presentation/index.js +4 -0
- package/dist/presentation/index.js.map +1 -0
- package/dist/presentation/routes/agent-runtime-config.d.ts +2 -0
- package/dist/presentation/routes/agent-runtime-config.d.ts.map +1 -0
- package/dist/presentation/routes/agent-runtime-config.js +71 -0
- package/dist/presentation/routes/agent-runtime-config.js.map +1 -0
- package/dist/presentation/routes/cancel-run.d.ts +2 -0
- package/dist/presentation/routes/cancel-run.d.ts.map +1 -0
- package/dist/presentation/routes/cancel-run.js +46 -0
- package/dist/presentation/routes/cancel-run.js.map +1 -0
- package/dist/presentation/routes/checkout-token.d.ts +2 -0
- package/dist/presentation/routes/checkout-token.d.ts.map +1 -0
- package/dist/presentation/routes/checkout-token.js +64 -0
- package/dist/presentation/routes/checkout-token.js.map +1 -0
- package/dist/presentation/routes/get-run-aggregates.d.ts +2 -0
- package/dist/presentation/routes/get-run-aggregates.d.ts.map +1 -0
- package/dist/presentation/routes/get-run-aggregates.js +60 -0
- package/dist/presentation/routes/get-run-aggregates.js.map +1 -0
- package/dist/presentation/routes/get-run.d.ts +2 -0
- package/dist/presentation/routes/get-run.d.ts.map +1 -0
- package/dist/presentation/routes/get-run.js +60 -0
- package/dist/presentation/routes/get-run.js.map +1 -0
- package/dist/presentation/routes/get-step-secrets.d.ts +2 -0
- package/dist/presentation/routes/get-step-secrets.d.ts.map +1 -0
- package/dist/presentation/routes/get-step-secrets.js +115 -0
- package/dist/presentation/routes/get-step-secrets.js.map +1 -0
- package/dist/presentation/routes/index.d.ts +4 -0
- package/dist/presentation/routes/index.d.ts.map +1 -0
- package/dist/presentation/routes/index.js +41 -0
- package/dist/presentation/routes/index.js.map +1 -0
- package/dist/presentation/routes/leased-step.d.ts +14 -0
- package/dist/presentation/routes/leased-step.d.ts.map +1 -0
- package/dist/presentation/routes/leased-step.js +50 -0
- package/dist/presentation/routes/leased-step.js.map +1 -0
- package/dist/presentation/routes/list-run-attempts.d.ts +2 -0
- package/dist/presentation/routes/list-run-attempts.d.ts.map +1 -0
- package/dist/presentation/routes/list-run-attempts.js +35 -0
- package/dist/presentation/routes/list-run-attempts.js.map +1 -0
- package/dist/presentation/routes/list-runs.d.ts +2 -0
- package/dist/presentation/routes/list-runs.d.ts.map +1 -0
- package/dist/presentation/routes/list-runs.js +70 -0
- package/dist/presentation/routes/list-runs.js.map +1 -0
- package/dist/presentation/routes/next-step.d.ts +2 -0
- package/dist/presentation/routes/next-step.d.ts.map +1 -0
- package/dist/presentation/routes/next-step.js +65 -0
- package/dist/presentation/routes/next-step.js.map +1 -0
- package/dist/presentation/routes/report-step.d.ts +2 -0
- package/dist/presentation/routes/report-step.d.ts.map +1 -0
- package/dist/presentation/routes/report-step.js +73 -0
- package/dist/presentation/routes/report-step.js.map +1 -0
- package/dist/presentation/routes/require-accessible-run.d.ts +7 -0
- package/dist/presentation/routes/require-accessible-run.d.ts.map +1 -0
- package/dist/presentation/routes/require-accessible-run.js +25 -0
- package/dist/presentation/routes/require-accessible-run.js.map +1 -0
- package/dist/presentation/routes/rerun-run.d.ts +2 -0
- package/dist/presentation/routes/rerun-run.d.ts.map +1 -0
- package/dist/presentation/routes/rerun-run.js +56 -0
- package/dist/presentation/routes/rerun-run.js.map +1 -0
- package/dist/presentation/subscribers/index.d.ts +8 -0
- package/dist/presentation/subscribers/index.d.ts.map +1 -0
- package/dist/presentation/subscribers/index.js +9 -0
- package/dist/presentation/subscribers/index.js.map +1 -0
- package/dist/presentation/subscribers/on-job-event-delivered.d.ts +3 -0
- package/dist/presentation/subscribers/on-job-event-delivered.d.ts.map +1 -0
- package/dist/presentation/subscribers/on-job-event-delivered.js +24 -0
- package/dist/presentation/subscribers/on-job-event-delivered.js.map +1 -0
- package/dist/presentation/subscribers/on-job-steps-settled.d.ts +3 -0
- package/dist/presentation/subscribers/on-job-steps-settled.d.ts.map +1 -0
- package/dist/presentation/subscribers/on-job-steps-settled.js +36 -0
- package/dist/presentation/subscribers/on-job-steps-settled.js.map +1 -0
- package/dist/presentation/subscribers/on-runner-job-claimed.d.ts +3 -0
- package/dist/presentation/subscribers/on-runner-job-claimed.d.ts.map +1 -0
- package/dist/presentation/subscribers/on-runner-job-claimed.js +20 -0
- package/dist/presentation/subscribers/on-runner-job-claimed.js.map +1 -0
- package/dist/presentation/subscribers/on-runner-job-lease-expired.d.ts +3 -0
- package/dist/presentation/subscribers/on-runner-job-lease-expired.d.ts.map +1 -0
- package/dist/presentation/subscribers/on-runner-job-lease-expired.js +35 -0
- package/dist/presentation/subscribers/on-runner-job-lease-expired.js.map +1 -0
- package/dist/presentation/subscribers/on-runner-job-queued.d.ts +3 -0
- package/dist/presentation/subscribers/on-runner-job-queued.d.ts.map +1 -0
- package/dist/presentation/subscribers/on-runner-job-queued.js +20 -0
- package/dist/presentation/subscribers/on-runner-job-queued.js.map +1 -0
- package/dist/presentation/subscribers/on-workflow-run-attempt-created.d.ts +3 -0
- package/dist/presentation/subscribers/on-workflow-run-attempt-created.d.ts.map +1 -0
- package/dist/presentation/subscribers/on-workflow-run-attempt-created.js +35 -0
- package/dist/presentation/subscribers/on-workflow-run-attempt-created.js.map +1 -0
- package/dist/presentation/subscribers/on-workflow-run-cancelled.d.ts +3 -0
- package/dist/presentation/subscribers/on-workflow-run-cancelled.d.ts.map +1 -0
- package/dist/presentation/subscribers/on-workflow-run-cancelled.js +25 -0
- package/dist/presentation/subscribers/on-workflow-run-cancelled.js.map +1 -0
- package/dist/temporal/activities/index.d.ts +23 -0
- package/dist/temporal/activities/index.d.ts.map +1 -0
- package/dist/temporal/activities/index.js +26 -0
- package/dist/temporal/activities/index.js.map +1 -0
- package/dist/temporal/activities/orchestration-activities.d.ts +130 -0
- package/dist/temporal/activities/orchestration-activities.d.ts.map +1 -0
- package/dist/temporal/activities/orchestration-activities.js +188 -0
- package/dist/temporal/activities/orchestration-activities.js.map +1 -0
- package/dist/temporal/constants.d.ts +7 -0
- package/dist/temporal/constants.d.ts.map +1 -0
- package/dist/temporal/constants.js +8 -0
- package/dist/temporal/constants.js.map +1 -0
- package/dist/temporal/index.d.ts +3 -0
- package/dist/temporal/index.d.ts.map +1 -0
- package/dist/temporal/index.js +4 -0
- package/dist/temporal/index.js.map +1 -0
- package/dist/temporal/workflow-not-found.d.ts +2 -0
- package/dist/temporal/workflow-not-found.d.ts.map +1 -0
- package/dist/temporal/workflow-not-found.js +10 -0
- package/dist/temporal/workflow-not-found.js.map +1 -0
- package/dist/temporal/workflows/deadline.d.ts +3 -0
- package/dist/temporal/workflows/deadline.d.ts.map +1 -0
- package/dist/temporal/workflows/deadline.js +8 -0
- package/dist/temporal/workflows/deadline.js.map +1 -0
- package/dist/temporal/workflows/index.d.ts +4 -0
- package/dist/temporal/workflows/index.d.ts.map +1 -0
- package/dist/temporal/workflows/index.js +5 -0
- package/dist/temporal/workflows/index.js.map +1 -0
- package/dist/temporal/workflows/job-execution-orchestration.d.ts +27 -0
- package/dist/temporal/workflows/job-execution-orchestration.d.ts.map +1 -0
- package/dist/temporal/workflows/job-execution-orchestration.js +265 -0
- package/dist/temporal/workflows/job-execution-orchestration.js.map +1 -0
- package/dist/temporal/workflows/job-listener-orchestration.d.ts +40 -0
- package/dist/temporal/workflows/job-listener-orchestration.d.ts.map +1 -0
- package/dist/temporal/workflows/job-listener-orchestration.js +332 -0
- package/dist/temporal/workflows/job-listener-orchestration.js.map +1 -0
- package/dist/temporal/workflows/run-orchestration.d.ts +8 -0
- package/dist/temporal/workflows/run-orchestration.d.ts.map +1 -0
- package/dist/temporal/workflows/run-orchestration.js +243 -0
- package/dist/temporal/workflows/run-orchestration.js.map +1 -0
- package/dist/temporal/workflows/test-env.d.ts +114 -0
- package/dist/temporal/workflows/test-env.d.ts.map +1 -0
- package/dist/temporal/workflows/test-env.js +323 -0
- package/dist/temporal/workflows/test-env.js.map +1 -0
- package/dist/tsconfig.test.tsbuildinfo +1 -0
- package/drizzle/0000_initial.sql +211 -0
- package/drizzle/0001_agent_tool_materialization.sql +1 -0
- package/drizzle/meta/0000_snapshot.json +1613 -0
- package/drizzle/meta/_journal.json +20 -0
- package/drizzle.config.ts +7 -0
- package/package.json +91 -0
- package/src/core/README.md +79 -0
- package/src/core/agent-tool-capability-warning.test.ts +280 -0
- package/src/core/agent-tool-capability-warning.ts +200 -0
- package/src/core/agent-tools.ts +422 -0
- package/src/core/checkout.test.ts +112 -0
- package/src/core/checkout.ts +63 -0
- package/src/core/condition-trace.ts +64 -0
- package/src/core/entities/index.ts +9 -0
- package/src/core/entities/job-execution.ts +32 -0
- package/src/core/entities/job-listener-event.ts +15 -0
- package/src/core/entities/job.ts +91 -0
- package/src/core/entities/step.ts +126 -0
- package/src/core/entities/workflow-run-attempt.ts +21 -0
- package/src/core/entities/workflow-run.ts +94 -0
- package/src/core/errors.test.ts +45 -0
- package/src/core/errors.ts +209 -0
- package/src/core/index.ts +54 -0
- package/src/core/job-execution-outcome.ts +64 -0
- package/src/core/job-execution.test.ts +1560 -0
- package/src/core/job-execution.ts +581 -0
- package/src/core/job-transition/decide-job-activation.test.ts +196 -0
- package/src/core/job-transition/decide-job-activation.ts +79 -0
- package/src/core/job-transition/derive-job-execution-outputs.ts +41 -0
- package/src/core/job-transition/derive-job-success.test.ts +133 -0
- package/src/core/job-transition/derive-job-success.ts +67 -0
- package/src/core/job-transition/index.ts +11 -0
- package/src/core/job-transition/runtime-completion-status-for-job.ts +14 -0
- package/src/core/listener-execution-materialization.test.ts +49 -0
- package/src/core/listener-execution-materialization.ts +162 -0
- package/src/core/run-workflow.test.ts +229 -0
- package/src/core/run-workflow.ts +41 -0
- package/src/core/source-control.test.ts +17 -0
- package/src/core/source-control.ts +22 -0
- package/src/core/step-config/agent.ts +459 -0
- package/src/core/step-config/assemble-run-context.test.ts +1021 -0
- package/src/core/step-config/assemble-run-context.ts +535 -0
- package/src/core/step-config/complete-step-dispatch-config.test.ts +354 -0
- package/src/core/step-config/complete-step-dispatch-config.ts +40 -0
- package/src/core/step-config/fields.ts +111 -0
- package/src/core/step-config/index.ts +41 -0
- package/src/core/step-config/materialize-job-execution-steps.test.ts +494 -0
- package/src/core/step-config/materialize-job-execution-steps.ts +136 -0
- package/src/core/step-config/materialize-workflow-model.test.ts +1214 -0
- package/src/core/step-config/materialize-workflow-model.ts +140 -0
- package/src/core/step-config/resolve-job-execution-name.test.ts +94 -0
- package/src/core/step-config/resolve-job-execution-name.ts +51 -0
- package/src/core/step-config/resolve-step-config.ts +199 -0
- package/src/core/step-config/run.ts +467 -0
- package/src/core/step-config/workflow-evaluation-context.ts +6 -0
- package/src/core/step-transition/apply-step-transition.ts +163 -0
- package/src/core/step-transition/decide-step-transition.test.ts +307 -0
- package/src/core/step-transition/decide-step-transition.ts +200 -0
- package/src/core/step-transition/evaluate-gate.test.ts +317 -0
- package/src/core/step-transition/evaluate-gate.ts +168 -0
- package/src/core/step-transition/read-step-outputs.ts +27 -0
- package/src/core/workflow-run-creation.test.ts +155 -0
- package/src/core/workflow-run-creation.ts +131 -0
- package/src/core/workflow-scheduling/index.ts +15 -0
- package/src/core/workflow-scheduling/run-progress.test.ts +46 -0
- package/src/core/workflow-scheduling/run-progress.ts +68 -0
- package/src/core/workflow-scheduling/runtime-dag.ts +10 -0
- package/src/core/workflow-scheduling/runtime-scheduling-command.ts +20 -0
- package/src/core/workflow-scheduling/schedule-runtime-dag.test.ts +197 -0
- package/src/core/workflow-scheduling/schedule-runtime-dag.ts +115 -0
- package/src/db/db.ts +40 -0
- package/src/db/index.ts +86 -0
- package/src/db/job-listener-events.test.ts +113 -0
- package/src/db/job-listener-events.ts +73 -0
- package/src/db/job-listeners.test.ts +865 -0
- package/src/db/job-listeners.ts +564 -0
- package/src/db/outbox-writes.ts +40 -0
- package/src/db/rerun-listener.test.ts +64 -0
- package/src/db/run-timeout.test.ts +102 -0
- package/src/db/runner-lease-table.ts +39 -0
- package/src/db/schema/common.ts +3 -0
- package/src/db/schema/job-executions.ts +85 -0
- package/src/db/schema/job-listener-events.ts +58 -0
- package/src/db/schema/jobs.ts +136 -0
- package/src/db/schema/outbox.ts +4 -0
- package/src/db/schema/step-attempts.ts +99 -0
- package/src/db/schema/steps.ts +99 -0
- package/src/db/schema/workflow-run-attempts.ts +59 -0
- package/src/db/schema/workflow-runs.ts +112 -0
- package/src/db/workflow-runs/job-executions.test.ts +99 -0
- package/src/db/workflow-runs/job-executions.ts +421 -0
- package/src/db/workflow-runs/job-status.test.ts +532 -0
- package/src/db/workflow-runs/jobs.test.ts +194 -0
- package/src/db/workflow-runs/jobs.ts +418 -0
- package/src/db/workflow-runs/outbox.ts +109 -0
- package/src/db/workflow-runs/queries.test.ts +256 -0
- package/src/db/workflow-runs/queries.ts +437 -0
- package/src/db/workflow-runs/run-create.test.ts +1281 -0
- package/src/db/workflow-runs/run-create.ts +373 -0
- package/src/db/workflow-runs/run-graph.ts +95 -0
- package/src/db/workflow-runs/run-rerun.test.ts +625 -0
- package/src/db/workflow-runs/run-rerun.ts +266 -0
- package/src/db/workflow-runs/run-status.test.ts +425 -0
- package/src/db/workflow-runs/run-status.ts +391 -0
- package/src/db/workflow-runs/runs.ts +17 -0
- package/src/db/workflow-runs/shared.ts +84 -0
- package/src/db/workflow-runs/steps.test.ts +191 -0
- package/src/db/workflow-runs/steps.ts +476 -0
- package/src/db/workflow-runs.ts +111 -0
- package/src/index.ts +99 -0
- package/src/metrics/index.ts +1 -0
- package/src/metrics/instance.ts +160 -0
- package/src/metrics/service.ts +30 -0
- package/src/presentation/dto/checkout-token.test.ts +107 -0
- package/src/presentation/dto/checkout-token.ts +85 -0
- package/src/presentation/dto/index.ts +3 -0
- package/src/presentation/dto/job.test.ts +108 -0
- package/src/presentation/dto/job.ts +64 -0
- package/src/presentation/dto/step.test.ts +307 -0
- package/src/presentation/dto/step.ts +145 -0
- package/src/presentation/dto/workflow-run.ts +38 -0
- package/src/presentation/index.ts +10 -0
- package/src/presentation/routes/agent-runtime-config.test.ts +478 -0
- package/src/presentation/routes/agent-runtime-config.ts +81 -0
- package/src/presentation/routes/cancel-run.test.ts +156 -0
- package/src/presentation/routes/cancel-run.ts +37 -0
- package/src/presentation/routes/checkout-token.test.ts +366 -0
- package/src/presentation/routes/checkout-token.ts +61 -0
- package/src/presentation/routes/get-run-aggregates.test.ts +114 -0
- package/src/presentation/routes/get-run-aggregates.ts +69 -0
- package/src/presentation/routes/get-run.test.ts +604 -0
- package/src/presentation/routes/get-run.ts +66 -0
- package/src/presentation/routes/get-step-secrets.test.ts +260 -0
- package/src/presentation/routes/get-step-secrets.ts +117 -0
- package/src/presentation/routes/index.test.ts +71 -0
- package/src/presentation/routes/index.ts +42 -0
- package/src/presentation/routes/leased-step.ts +54 -0
- package/src/presentation/routes/list-run-attempts.test.ts +163 -0
- package/src/presentation/routes/list-run-attempts.ts +27 -0
- package/src/presentation/routes/list-runs.test.ts +244 -0
- package/src/presentation/routes/list-runs.ts +83 -0
- package/src/presentation/routes/next-step.test.ts +366 -0
- package/src/presentation/routes/next-step.ts +62 -0
- package/src/presentation/routes/report-step.test.ts +374 -0
- package/src/presentation/routes/report-step.ts +61 -0
- package/src/presentation/routes/require-accessible-run.ts +27 -0
- package/src/presentation/routes/rerun-run.test.ts +202 -0
- package/src/presentation/routes/rerun-run.ts +48 -0
- package/src/presentation/subscribers/index.ts +7 -0
- package/src/presentation/subscribers/on-job-event-delivered.test.ts +71 -0
- package/src/presentation/subscribers/on-job-event-delivered.ts +30 -0
- package/src/presentation/subscribers/on-job-steps-settled.test.ts +75 -0
- package/src/presentation/subscribers/on-job-steps-settled.ts +42 -0
- package/src/presentation/subscribers/on-runner-job-claimed.test.ts +57 -0
- package/src/presentation/subscribers/on-runner-job-claimed.ts +23 -0
- package/src/presentation/subscribers/on-runner-job-lease-expired.test.ts +73 -0
- package/src/presentation/subscribers/on-runner-job-lease-expired.ts +36 -0
- package/src/presentation/subscribers/on-runner-job-queued.test.ts +57 -0
- package/src/presentation/subscribers/on-runner-job-queued.ts +23 -0
- package/src/presentation/subscribers/on-workflow-run-attempt-created.test.ts +69 -0
- package/src/presentation/subscribers/on-workflow-run-attempt-created.ts +40 -0
- package/src/presentation/subscribers/on-workflow-run-cancelled.test.ts +59 -0
- package/src/presentation/subscribers/on-workflow-run-cancelled.ts +29 -0
- package/src/temporal/activities/index.ts +45 -0
- package/src/temporal/activities/orchestration-activities.test.ts +115 -0
- package/src/temporal/activities/orchestration-activities.ts +305 -0
- package/src/temporal/constants.ts +6 -0
- package/src/temporal/index.ts +6 -0
- package/src/temporal/workflow-not-found.ts +9 -0
- package/src/temporal/workflows/deadline.ts +7 -0
- package/src/temporal/workflows/index.ts +11 -0
- package/src/temporal/workflows/job-execution-orchestration-timeout.test.ts +165 -0
- package/src/temporal/workflows/job-execution-orchestration.test.ts +311 -0
- package/src/temporal/workflows/job-execution-orchestration.ts +314 -0
- package/src/temporal/workflows/job-listener-orchestration-continuation.test.ts +93 -0
- package/src/temporal/workflows/job-listener-orchestration.test.ts +406 -0
- package/src/temporal/workflows/job-listener-orchestration.ts +490 -0
- package/src/temporal/workflows/run-orchestration.test.ts +409 -0
- package/src/temporal/workflows/run-orchestration.ts +283 -0
- package/src/temporal/workflows/test-env.ts +409 -0
- package/test/env.ts +11 -0
- package/test/factories/job.ts +83 -0
- package/test/factories/project.ts +16 -0
- package/test/factories/workflow-model.test.ts +26 -0
- package/test/factories/workflow-model.ts +268 -0
- package/test/factories/workflow-run.ts +58 -0
- package/test/fixtures/active-lease-token.ts +85 -0
- package/test/fixtures/job-with-steps.ts +42 -0
- package/test/fixtures/lease-token.ts +44 -0
- package/test/fixtures/strip-setup-step.ts +23 -0
- package/test/globalSetup.ts +54 -0
- package/test/helpers/workflow-runs.ts +210 -0
- package/test/index.ts +3 -0
- package/test/setup.ts +17 -0
- package/tsconfig.build.json +9 -0
- package/tsconfig.build.tsbuildinfo +1 -0
- package/tsconfig.json +3 -0
- package/tsconfig.test.json +8 -0
- package/vitest.config.ts +12 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/db/workflow-runs/run-create.ts"],"sourcesContent":["import {\n type AgentDefaultsResolver,\n catalogDefaultAgentResolver,\n} from '@shipfox/api-agent/core/resolve-agent-config';\nimport type {WorkflowModel} from '@shipfox/api-definitions';\nimport {getVariablesByNamespace} from '@shipfox/api-secrets';\nimport {analyzeContextKeyAccess, type ResolvedFieldSegment} from '@shipfox/expression';\nimport {logger} from '@shipfox/node-opentelemetry';\nimport {eq} from 'drizzle-orm';\nimport {\n createAgentToolMaterializationSnapshot,\n loadAgentToolMaterializationContext,\n} from '#core/agent-tools.js';\nimport type {\n TriggerPayload,\n WorkflowRun,\n WorkflowSourceSnapshot,\n} from '#core/entities/workflow-run.js';\nimport {InterpolationUnresolvableError} from '#core/errors.js';\nimport type {MaterializedWorkflowJob} from '#core/step-config/materialize-workflow-model.js';\nimport type {WorkflowStepTemplateDiagnostic} from '#core/step-config/resolve-step-config.js';\nimport {\n deriveInitialJobExecutionPlan,\n materializeWorkflowRunJobs,\n} from '#core/workflow-run-creation.js';\nimport {recordWorkflowRunCreated} from '#metrics/instance.js';\nimport {db} from '../db.js';\nimport {workflowRunAttempts} from '../schema/workflow-run-attempts.js';\nimport {toWorkflowRun, workflowRuns} from '../schema/workflow-runs.js';\nimport {type MaterializedRunGraphJob, persistMaterializedRunGraph} from './run-graph.js';\n\nexport type WorkflowModelJob = WorkflowModel['jobs'][number];\n\nexport interface ReferencedVariable {\n readonly key: string;\n readonly field: InterpolationUnresolvableError['field'];\n readonly source: string;\n readonly envKey?: string | undefined;\n}\n\nexport interface CreateWorkflowRunParams {\n workspaceId: string;\n projectId: string;\n definitionId: string;\n name?: string | undefined;\n model: WorkflowModel;\n triggerPayload: TriggerPayload;\n inputs?: Record<string, unknown> | undefined;\n sourceSnapshot?: WorkflowSourceSnapshot | null | undefined;\n triggerIdempotencyKey?: string | undefined;\n resolveAgentDefaults?: AgentDefaultsResolver | undefined;\n}\n\nexport async function createWorkflowRun(params: CreateWorkflowRunParams): Promise<WorkflowRun> {\n const agentToolContext = await loadAgentToolMaterializationContext({\n model: params.model,\n workspaceId: params.workspaceId,\n projectId: params.projectId,\n });\n const agentToolMaterialization = createAgentToolMaterializationSnapshot({\n model: params.model,\n context: agentToolContext,\n });\n const result = await db().transaction(async (tx) => {\n const insertResult = await tx\n .insert(workflowRuns)\n .values({\n workspaceId: params.workspaceId,\n projectId: params.projectId,\n definitionId: params.definitionId,\n name: params.name ?? params.model.name,\n status: 'pending',\n currentAttempt: 1,\n triggerProvider: params.triggerPayload.provider ?? null,\n triggerSource: params.triggerPayload.source,\n triggerEvent: params.triggerPayload.event,\n triggerPayload: params.triggerPayload,\n inputs: params.inputs ?? null,\n sourceSnapshot: params.sourceSnapshot ?? null,\n triggerIdempotencyKey: params.triggerIdempotencyKey ?? null,\n })\n .onConflictDoNothing({target: workflowRuns.triggerIdempotencyKey})\n .returning();\n\n const runRow = insertResult[0];\n if (!runRow) {\n // Conflict path: skip jobs/steps/outbox so the first insert keeps ownership of side effects.\n if (!params.triggerIdempotencyKey) {\n throw new Error('Insert returned no rows');\n }\n const existing = await tx\n .select()\n .from(workflowRuns)\n .where(eq(workflowRuns.triggerIdempotencyKey, params.triggerIdempotencyKey))\n .limit(1);\n const existingRow = existing[0];\n if (!existingRow) {\n throw new Error(\n `Idempotency conflict but existing run missing for key ${params.triggerIdempotencyKey}`,\n );\n }\n return {run: toWorkflowRun(existingRow), created: false};\n }\n\n const run = toWorkflowRun(runRow);\n const [attemptRow] = await tx\n .insert(workflowRunAttempts)\n .values({\n workflowRunId: runRow.id,\n attempt: 1,\n status: 'pending',\n model: params.model,\n agentToolMaterialization,\n })\n .returning();\n if (!attemptRow) throw new Error('Insert returned no rows');\n\n // Resolving one-shot templates here gives interpolation access to the inserted run id.\n // If resolution fails, the transaction rolls back the run, jobs, steps, and outbox event together.\n // Listening steps are resolved later when a job execution is created.\n const oneShotJobs = params.model.jobs.filter((job) => job.mode !== 'listening');\n const vars = await loadReferencedVariables({\n model: params.model,\n jobs: oneShotJobs,\n workspaceId: params.workspaceId,\n projectId: params.projectId,\n definitionId: params.definitionId,\n });\n const materializedJobs = materializeWorkflowRunJobs({\n run,\n model: params.model,\n triggerPayload: params.triggerPayload,\n inputs: params.inputs ?? null,\n vars,\n resolveAgentDefaults: params.resolveAgentDefaults ?? catalogDefaultAgentResolver,\n definitionId: params.definitionId,\n agentToolContext,\n agentToolSnapshot: agentToolMaterialization,\n });\n\n const graphJobs = materializeRunGraphJobs({\n params,\n run,\n vars,\n materializedJobs,\n });\n await persistMaterializedRunGraph(tx, {\n run,\n workflowRunAttempt: attemptRow,\n materializedJobs: graphJobs,\n });\n\n logTemplateDiagnostics({\n workflowRunId: runRow.id,\n diagnostics: materializedJobs.flatMap((job) =>\n job.steps.flatMap((step) =>\n (step.diagnostics ?? []).map((diagnostic) => ({\n jobKey: job.key,\n stepName: step.name,\n ...diagnostic,\n })),\n ),\n ),\n });\n\n return {run, created: true};\n });\n\n if (result.created)\n recordWorkflowRunCreated(result.run.triggerPayload.provider ?? result.run.triggerSource);\n\n return result.run;\n}\n\nexport async function loadReferencedVariables(params: {\n readonly model: WorkflowModel;\n readonly jobs?: readonly WorkflowModelJob[] | undefined;\n readonly workspaceId: string;\n readonly projectId: string;\n readonly definitionId: string;\n}): Promise<Record<string, string> | undefined> {\n const references = referencedVariables(params.model, params.jobs ?? params.model.jobs);\n const keys = [...new Set(references.map((reference) => reference.key))].sort();\n if (keys.length === 0) return undefined;\n\n const vars = await getVariablesByNamespace({\n workspaceId: params.workspaceId,\n projectId: params.projectId,\n namespace: '',\n });\n const missingKey = keys.find((key) => !(key in vars));\n if (missingKey !== undefined) {\n const reference = references.find((candidate) => candidate.key === missingKey);\n throw new InterpolationUnresolvableError(params.definitionId, {\n field: reference?.field ?? 'env',\n source: reference?.source ?? `vars.${missingKey}`,\n ...(reference?.envKey === undefined ? {} : {envKey: reference.envKey}),\n });\n }\n\n return vars;\n}\n\nfunction materializeRunGraphJobs(params: {\n readonly params: CreateWorkflowRunParams;\n readonly run: WorkflowRun;\n readonly vars: Record<string, string> | undefined;\n readonly materializedJobs: readonly MaterializedWorkflowJob[];\n}): readonly MaterializedRunGraphJob[] {\n return params.materializedJobs.map((job, jobIndex) => ({\n job: {\n key: job.key,\n mode: job.mode,\n name: workflowTemplateSource(job.name),\n status: 'pending' as const,\n checkoutPersistCredentials: job.checkout.persistCredentials,\n checkoutPermissionsContents: job.checkout.permissions.contents,\n success: job.success ?? null,\n executionTimeoutMs: job.executionTimeoutMs ?? null,\n listeningTimeoutMs: job.listening?.timeoutMs ?? null,\n maxExecutions: job.listening?.maxExecutions ?? null,\n onResolve: job.listening?.onResolve ?? null,\n batchDebounceMs: job.listening?.batch?.debounceMs ?? null,\n batchMaxSize: job.listening?.batch?.maxSize ?? null,\n batchMaxWaitMs: job.listening?.batch?.maxWaitMs ?? null,\n listeningOn: job.listening?.on ? [...job.listening.on] : null,\n listeningUntil: job.listening?.until ? [...job.listening.until] : null,\n dependencies: [...job.dependencies],\n runner: job.runner.length === 0 ? null : [...job.runner],\n position: job.position,\n },\n createExecution: (jobRow) => {\n if (jobRow.mode === 'listening') return undefined;\n\n const fallbackName = `${jobRow.key} #1`;\n const modelJob = params.params.model.jobs[jobIndex];\n if (!modelJob) return undefined;\n const executionPlan = deriveInitialJobExecutionPlan({\n run: params.run,\n modelJob,\n job,\n jobId: jobRow.id,\n sequence: 1,\n fallbackName,\n triggerPayload: params.params.triggerPayload,\n inputs: params.params.inputs ?? null,\n vars: params.vars,\n });\n\n return {\n sequence: 1,\n name: executionPlan.name,\n runner: [...executionPlan.runner],\n status: 'pending' as const,\n evaluationTrace:\n executionPlan.evaluationTrace?.length === 0 ? null : executionPlan.evaluationTrace,\n };\n },\n createSteps: () =>\n job.steps.map((step) => ({\n key: step.key,\n name: step.name,\n sourceLocation: step.sourceLocation,\n status: step.status,\n type: step.type,\n config: step.config,\n condition: step.condition ?? null,\n configPlan: step.configPlan ?? null,\n authoredConfig: step.authoredConfig,\n position: step.position,\n })),\n }));\n}\n\nfunction referencedVariables(\n model: WorkflowModel,\n jobs: readonly WorkflowModelJob[],\n): readonly ReferencedVariable[] {\n const references: ReferencedVariable[] = [];\n\n if (jobs.length > 0) {\n collectTemplateVariableReferences(model.templates?.env, references);\n }\n\n for (const job of jobs) {\n collectFieldVariableReferences(job.name, references, {field: 'job.name'});\n for (const template of job.runnerTemplates ?? []) {\n collectFieldVariableReferences(template, references, {field: 'job.runner'});\n }\n collectTemplateVariableReferences(job.outputs, references, {field: 'job.outputs'});\n collectTemplateVariableReferences(job.templates?.env, references);\n\n for (const step of job.steps) {\n collectFieldVariableReferences(step.templates?.name, references, {field: 'step.name'});\n if (step.kind === 'run') {\n collectFieldVariableReferences(step.templates?.command, references, {field: 'run'});\n collectTemplateVariableReferences(step.templates?.env, references);\n } else {\n collectFieldVariableReferences(step.templates?.prompt, references, {field: 'agent.prompt'});\n collectFieldVariableReferences(step.templates?.model, references, {field: 'agent.model'});\n collectFieldVariableReferences(step.templates?.provider, references, {\n field: 'agent.provider',\n });\n }\n }\n }\n\n return references;\n}\n\nfunction collectTemplateVariableReferences(\n templates: Readonly<Record<string, readonly ResolvedFieldSegment[]>> | undefined,\n references: ReferencedVariable[],\n source?: {\n readonly field: InterpolationUnresolvableError['field'];\n },\n): void {\n for (const [envKey, template] of Object.entries(templates ?? {})) {\n collectFieldVariableReferences(\n template,\n references,\n source === undefined ? {field: 'env', envKey} : source,\n );\n }\n}\n\nfunction collectFieldVariableReferences(\n template: readonly ResolvedFieldSegment[] | undefined,\n references: ReferencedVariable[],\n source: {\n readonly field: InterpolationUnresolvableError['field'];\n readonly envKey?: string | undefined;\n },\n): void {\n for (const segment of template ?? []) {\n if (segment.kind === 'literal') continue;\n const keyAccess = analyzeContextKeyAccess(segment.expression);\n for (const reference of keyAccess.references) {\n if (reference.root !== 'vars') continue;\n references.push({\n key: reference.key,\n field: source.field,\n source: segment.expression.source,\n envKey: source.envKey,\n });\n }\n }\n}\n\nfunction workflowTemplateSource(template: MaterializedWorkflowJob['name']): string | null {\n if (template === undefined) return null;\n\n return template\n .map((segment) =>\n segment.kind === 'literal' ? segment.value : `$${'{{'} ${segment.expression.source} ${'}}'}`,\n )\n .join('');\n}\n\nfunction logTemplateDiagnostics(params: {\n readonly workflowRunId: string;\n readonly diagnostics: readonly (WorkflowStepTemplateDiagnostic & {\n readonly jobKey: string;\n readonly stepName: string;\n })[];\n}): void {\n if (params.diagnostics.length === 0) return;\n\n logger().warn(\n {workflowRunId: params.workflowRunId, diagnostics: params.diagnostics},\n 'Workflow interpolation resolved with diagnostics',\n );\n}\n"],"names":["catalogDefaultAgentResolver","getVariablesByNamespace","analyzeContextKeyAccess","logger","eq","createAgentToolMaterializationSnapshot","loadAgentToolMaterializationContext","InterpolationUnresolvableError","deriveInitialJobExecutionPlan","materializeWorkflowRunJobs","recordWorkflowRunCreated","db","workflowRunAttempts","toWorkflowRun","workflowRuns","persistMaterializedRunGraph","createWorkflowRun","params","agentToolContext","model","workspaceId","projectId","agentToolMaterialization","context","result","transaction","tx","insertResult","insert","values","definitionId","name","status","currentAttempt","triggerProvider","triggerPayload","provider","triggerSource","source","triggerEvent","event","inputs","sourceSnapshot","triggerIdempotencyKey","onConflictDoNothing","target","returning","runRow","Error","existing","select","from","where","limit","existingRow","run","created","attemptRow","workflowRunId","id","attempt","oneShotJobs","jobs","filter","job","mode","vars","loadReferencedVariables","materializedJobs","resolveAgentDefaults","agentToolSnapshot","graphJobs","materializeRunGraphJobs","workflowRunAttempt","logTemplateDiagnostics","diagnostics","flatMap","steps","step","map","diagnostic","jobKey","key","stepName","references","referencedVariables","keys","Set","reference","sort","length","undefined","namespace","missingKey","find","candidate","field","envKey","jobIndex","workflowTemplateSource","checkoutPersistCredentials","checkout","persistCredentials","checkoutPermissionsContents","permissions","contents","success","executionTimeoutMs","listeningTimeoutMs","listening","timeoutMs","maxExecutions","onResolve","batchDebounceMs","batch","debounceMs","batchMaxSize","maxSize","batchMaxWaitMs","maxWaitMs","listeningOn","on","listeningUntil","until","dependencies","runner","position","createExecution","jobRow","fallbackName","modelJob","executionPlan","jobId","sequence","evaluationTrace","createSteps","sourceLocation","type","config","condition","configPlan","authoredConfig","collectTemplateVariableReferences","templates","env","collectFieldVariableReferences","template","runnerTemplates","outputs","kind","command","prompt","Object","entries","segment","keyAccess","expression","root","push","value","join","warn"],"mappings":"AAAA,SAEEA,2BAA2B,QACtB,+CAA+C;AAEtD,SAAQC,uBAAuB,QAAO,uBAAuB;AAC7D,SAAQC,uBAAuB,QAAkC,sBAAsB;AACvF,SAAQC,MAAM,QAAO,8BAA8B;AACnD,SAAQC,EAAE,QAAO,cAAc;AAC/B,SACEC,sCAAsC,EACtCC,mCAAmC,QAC9B,uBAAuB;AAM9B,SAAQC,8BAA8B,QAAO,kBAAkB;AAG/D,SACEC,6BAA6B,EAC7BC,0BAA0B,QACrB,iCAAiC;A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aAAa,CAAC,GAAI;QAChEE,+BACEC,UACA9D,YACA9C,WAAWqD,YAAY;YAACK,OAAO;YAAOC;QAAM,IAAI3D;IAEpD;AACF;AAEA,SAAS2G,+BACPC,QAAqD,EACrD9D,UAAgC,EAChC9C,MAGC;IAED,KAAK,MAAMoH,WAAWR,YAAY,EAAE,CAAE;QACpC,IAAIQ,QAAQL,IAAI,KAAK,WAAW;QAChC,MAAMM,YAAYzJ,wBAAwBwJ,QAAQE,UAAU;QAC5D,KAAK,MAAMpE,aAAamE,UAAUvE,UAAU,CAAE;YAC5C,IAAII,UAAUqE,IAAI,KAAK,QAAQ;YAC/BzE,WAAW0E,IAAI,CAAC;gBACd5E,KAAKM,UAAUN,GAAG;gBAClBc,OAAO1D,OAAO0D,KAAK;gBACnB1D,QAAQoH,QAAQE,UAAU,CAACtH,MAAM;gBACjC2D,QAAQ3D,OAAO2D,MAAM;YACvB;QACF;IACF;AACF;AAEA,SAASE,uBAAuB+C,QAAyC;IACvE,IAAIA,aAAavD,WAAW,OAAO;IAEnC,OAAOuD,SACJnE,GAAG,CAAC,CAAC2E,UACJA,QAAQL,IAAI,KAAK,YAAYK,QAAQK,KAAK,GAAG,CAAC,CAAC,EAAE,KAAK,CAAC,EAAEL,QAAQE,UAAU,CAACtH,MAAM,CAAC,CAAC,EAAE,MAAM,EAE7F0H,IAAI,CAAC;AACV;AAEA,SAAStF,uBAAuBzD,MAM/B;IACC,IAAIA,OAAO0D,WAAW,CAACe,MAAM,KAAK,GAAG;IAErCvF,SAAS8J,IAAI,CACX;QAACvG,eAAezC,OAAOyC,aAAa;QAAEiB,aAAa1D,OAAO0D,WAAW;IAAA,GACrE;AAEJ"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { SQL } from 'drizzle-orm';
|
|
2
|
+
import type { WorkflowRun } from '#core/entities/workflow-run.js';
|
|
3
|
+
import type { Tx } from '../db.js';
|
|
4
|
+
import { type JobExecutionCreateDb, type JobExecutionDb } from '../schema/job-executions.js';
|
|
5
|
+
import { type JobCreateDb, type JobDb } from '../schema/jobs.js';
|
|
6
|
+
import { type StepCreateDb } from '../schema/steps.js';
|
|
7
|
+
type MaterializedRunGraphJobExecution = Omit<JobExecutionCreateDb, 'finishedAt' | 'jobId'> & {
|
|
8
|
+
readonly finishedAt?: JobExecutionCreateDb['finishedAt'] | SQL | undefined;
|
|
9
|
+
};
|
|
10
|
+
export interface MaterializedRunGraphJob {
|
|
11
|
+
readonly job: Omit<JobCreateDb, 'workflowRunAttemptId'>;
|
|
12
|
+
readonly createExecution?: ((job: JobDb) => MaterializedRunGraphJobExecution | undefined) | undefined;
|
|
13
|
+
readonly createSteps?: ((params: {
|
|
14
|
+
readonly job: JobDb;
|
|
15
|
+
readonly jobExecution: JobExecutionDb;
|
|
16
|
+
}) => readonly Omit<StepCreateDb, 'jobExecutionId'>[]) | undefined;
|
|
17
|
+
}
|
|
18
|
+
export declare function persistMaterializedRunGraph(tx: Tx, params: {
|
|
19
|
+
readonly run: Pick<WorkflowRun, 'id' | 'workspaceId' | 'projectId' | 'definitionId'>;
|
|
20
|
+
readonly workflowRunAttempt: {
|
|
21
|
+
readonly id: string;
|
|
22
|
+
readonly attempt: number;
|
|
23
|
+
};
|
|
24
|
+
readonly materializedJobs: readonly MaterializedRunGraphJob[];
|
|
25
|
+
}): Promise<void>;
|
|
26
|
+
export {};
|
|
27
|
+
//# sourceMappingURL=run-graph.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-graph.d.ts","sourceRoot":"","sources":["../../../src/db/workflow-runs/run-graph.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,GAAG,EAAC,MAAM,aAAa,CAAC;AACrC,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,gCAAgC,CAAC;AAChE,OAAO,KAAK,EAAC,EAAE,EAAC,MAAM,UAAU,CAAC;AAEjC,OAAO,EACL,KAAK,oBAAoB,EACzB,KAAK,cAAc,EAEpB,MAAM,6B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
|
|
1
|
+
import { WORKFLOWS_WORKFLOW_RUN_ATTEMPT_CREATED } from '@shipfox/api-workflows-dto';
|
|
2
|
+
import { writeWorkflowsOutboxEvent } from '../outbox-writes.js';
|
|
3
|
+
import { jobExecutions } from '../schema/job-executions.js';
|
|
4
|
+
import { jobs } from '../schema/jobs.js';
|
|
5
|
+
import { steps } from '../schema/steps.js';
|
|
6
|
+
export async function persistMaterializedRunGraph(tx, params) {
|
|
7
|
+
const jobRows = params.materializedJobs.length === 0 ? [] : await tx.insert(jobs).values(params.materializedJobs.map((materializedJob)=>({
|
|
8
|
+
...materializedJob.job,
|
|
9
|
+
workflowRunAttemptId: params.workflowRunAttempt.id
|
|
10
|
+
}))).returning();
|
|
11
|
+
const jobExecutionValues = jobRows.flatMap((jobRow, jobIndex)=>{
|
|
12
|
+
const materializedJob = params.materializedJobs[jobIndex];
|
|
13
|
+
const jobExecution = materializedJob?.createExecution?.(jobRow);
|
|
14
|
+
return jobExecution === undefined ? [] : [
|
|
15
|
+
{
|
|
16
|
+
...jobExecution,
|
|
17
|
+
jobId: jobRow.id
|
|
18
|
+
}
|
|
19
|
+
];
|
|
20
|
+
});
|
|
21
|
+
const jobExecutionRows = jobExecutionValues.length === 0 ? [] : await tx.insert(jobExecutions).values(jobExecutionValues).returning();
|
|
22
|
+
const jobById = new Map(jobRows.map((job)=>[
|
|
23
|
+
job.id,
|
|
24
|
+
job
|
|
25
|
+
]));
|
|
26
|
+
const materializedJobByJobId = new Map(jobRows.flatMap((jobRow, index)=>{
|
|
27
|
+
const materializedJob = params.materializedJobs[index];
|
|
28
|
+
return materializedJob === undefined ? [] : [
|
|
29
|
+
[
|
|
30
|
+
jobRow.id,
|
|
31
|
+
materializedJob
|
|
32
|
+
]
|
|
33
|
+
];
|
|
34
|
+
}));
|
|
35
|
+
const stepValues = jobExecutionRows.flatMap((jobExecution)=>{
|
|
36
|
+
const job = jobById.get(jobExecution.jobId);
|
|
37
|
+
const materializedJob = materializedJobByJobId.get(jobExecution.jobId);
|
|
38
|
+
if (!job || !materializedJob) return [];
|
|
39
|
+
return (materializedJob.createSteps?.({
|
|
40
|
+
job,
|
|
41
|
+
jobExecution
|
|
42
|
+
}) ?? []).map((step)=>({
|
|
43
|
+
...step,
|
|
44
|
+
jobExecutionId: jobExecution.id
|
|
45
|
+
}));
|
|
46
|
+
});
|
|
47
|
+
if (stepValues.length > 0) {
|
|
48
|
+
await tx.insert(steps).values(stepValues);
|
|
49
|
+
}
|
|
50
|
+
await writeWorkflowsOutboxEvent(tx, {
|
|
51
|
+
type: WORKFLOWS_WORKFLOW_RUN_ATTEMPT_CREATED,
|
|
52
|
+
payload: {
|
|
53
|
+
workflowRunId: params.run.id,
|
|
54
|
+
workflowRunAttemptId: params.workflowRunAttempt.id,
|
|
55
|
+
attempt: params.workflowRunAttempt.attempt,
|
|
56
|
+
workspaceId: params.run.workspaceId,
|
|
57
|
+
projectId: params.run.projectId,
|
|
58
|
+
definitionId: params.run.definitionId
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
//# sourceMappingURL=run-graph.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/db/workflow-runs/run-graph.ts"],"sourcesContent":["import {WORKFLOWS_WORKFLOW_RUN_ATTEMPT_CREATED} from '@shipfox/api-workflows-dto';\nimport type {SQL} from 'drizzle-orm';\nimport type {WorkflowRun} from '#core/entities/workflow-run.js';\nimport type {Tx} from '../db.js';\nimport {writeWorkflowsOutboxEvent} from '../outbox-writes.js';\nimport {\n type JobExecutionCreateDb,\n type JobExecutionDb,\n jobExecutions,\n} from '../schema/job-executions.js';\nimport {type JobCreateDb, type JobDb, jobs} from '../schema/jobs.js';\nimport {type StepCreateDb, steps} from '../schema/steps.js';\n\ntype MaterializedRunGraphJobExecution = Omit<JobExecutionCreateDb, 'finishedAt' | 'jobId'> & {\n readonly finishedAt?: JobExecutionCreateDb['finishedAt'] | SQL | undefined;\n};\n\nexport interface MaterializedRunGraphJob {\n readonly job: Omit<JobCreateDb, 'workflowRunAttemptId'>;\n readonly createExecution?:\n | ((job: JobDb) => MaterializedRunGraphJobExecution | undefined)\n | undefined;\n readonly createSteps?:\n | ((params: {\n readonly job: JobDb;\n readonly jobExecution: JobExecutionDb;\n }) => readonly Omit<StepCreateDb, 'jobExecutionId'>[])\n | undefined;\n}\n\nexport async function persistMaterializedRunGraph(\n tx: Tx,\n params: {\n readonly run: Pick<WorkflowRun, 'id' | 'workspaceId' | 'projectId' | 'definitionId'>;\n readonly workflowRunAttempt: {readonly id: string; readonly attempt: number};\n readonly materializedJobs: readonly MaterializedRunGraphJob[];\n },\n): Promise<void> {\n const jobRows =\n params.materializedJobs.length === 0\n ? []\n : await tx\n .insert(jobs)\n .values(\n params.materializedJobs.map((materializedJob) => ({\n ...materializedJob.job,\n workflowRunAttemptId: params.workflowRunAttempt.id,\n })),\n )\n .returning();\n\n const jobExecutionValues = jobRows.flatMap((jobRow, jobIndex) => {\n const materializedJob = params.materializedJobs[jobIndex];\n const jobExecution = materializedJob?.createExecution?.(jobRow);\n return jobExecution === undefined ? [] : [{...jobExecution, jobId: jobRow.id}];\n });\n const jobExecutionRows =\n jobExecutionValues.length === 0\n ? []\n : await tx.insert(jobExecutions).values(jobExecutionValues).returning();\n\n const jobById = new Map(jobRows.map((job) => [job.id, job]));\n const materializedJobByJobId = new Map(\n jobRows.flatMap((jobRow, index) => {\n const materializedJob = params.materializedJobs[index];\n return materializedJob === undefined ? [] : [[jobRow.id, materializedJob] as const];\n }),\n );\n const stepValues = jobExecutionRows.flatMap((jobExecution) => {\n const job = jobById.get(jobExecution.jobId);\n const materializedJob = materializedJobByJobId.get(jobExecution.jobId);\n if (!job || !materializedJob) return [];\n\n return (materializedJob.createSteps?.({job, jobExecution}) ?? []).map((step) => ({\n ...step,\n jobExecutionId: jobExecution.id,\n }));\n });\n\n if (stepValues.length > 0) {\n await tx.insert(steps).values(stepValues);\n }\n\n await writeWorkflowsOutboxEvent(tx, {\n type: WORKFLOWS_WORKFLOW_RUN_ATTEMPT_CREATED,\n payload: {\n workflowRunId: params.run.id,\n workflowRunAttemptId: params.workflowRunAttempt.id,\n attempt: params.workflowRunAttempt.attempt,\n workspaceId: params.run.workspaceId,\n projectId: params.run.projectId,\n definitionId: params.run.definitionId,\n },\n });\n}\n"],"names":["WORKFLOWS_WORKFLOW_RUN_ATTEMPT_CREATED","writeWorkflowsOutboxEvent","jobExecutions","jobs","steps","persistMaterializedRunGraph","tx","params","jobRows","materializedJobs","length","insert","values","map","materializedJob","job","workflowRunAttemptId","workflowRunAttempt","id","returning","jobExecutionValues","flatMap","jobRow","jobIndex","jobExecution","createExecution","undefined","jobId","jobExecutionRows","jobById","Map","materializedJobByJobId","index","stepValues","get","createSteps","step","jobExecutionId","type","payload","workflowRunId","run","attempt","workspaceId","projectId","definitionId"],"mappings":"AAAA,SAAQA,sCAAsC,QAAO,6BAA6B;AAIlF,SAAQC,yBAAyB,QAAO,sBAAsB;AAC9D,SAGEC,aAAa,QACR,8BAA8B;AACrC,SAAsCC,IAAI,QAAO,oBAAoB;AACrE,SAA2BC,KAAK,QAAO,qBAAqB;AAmB5D,OAAO,eAAeC,4BACpBC,EAAM,EACNC,MAIC;IAED,MAAMC,UACJD,OAAOE,gBAAgB,CAACC,MAAM,KAAK,IAC/B,EAAE,GACF,MAAMJ,GACHK,MAAM,CAACR,MACPS,MAAM,CACLL,OAAOE,gBAAgB,CAACI,GAAG,CAAC,CAACC,kBAAqB,CAAA;YAChD,GAAGA,gBAAgBC,GAAG;YACtBC,sBAAsBT,OAAOU,kBAAkB,CAACC,EAAE;QACpD,CAAA,IAEDC,SAAS;IAElB,MAAMC,qBAAqBZ,QAAQa,OAAO,CAAC,CAACC,QAAQC;QAClD,MAAMT,kBAAkBP,OAAOE,gBAAgB,CAACc,SAAS;QACzD,MAAMC,eAAeV,iBAAiBW,kBAAkBH;QACxD,OAAOE,iBAAiBE,YAAY,EAAE,GAA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C,aAAapC,OAAOkC,GAAG,CAACE,WAAW;YACnCC,WAAWrC,OAAOkC,GAAG,CAACG,SAAS;YAC/BC,cAActC,OAAOkC,GAAG,CAACI,YAAY;QACvC;IACF;AACF"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type WorkflowRun } from '#core/entities/workflow-run.js';
|
|
2
|
+
export interface CreateRerunWorkflowRunParams {
|
|
3
|
+
workflowRunId: string;
|
|
4
|
+
mode: 'all' | 'failed';
|
|
5
|
+
actorUserId: string;
|
|
6
|
+
}
|
|
7
|
+
export declare function createRerunWorkflowRun(params: CreateRerunWorkflowRunParams): Promise<WorkflowRun>;
|
|
8
|
+
//# sourceMappingURL=run-rerun.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-rerun.d.ts","sourceRoot":"","sources":["../../../src/db/workflow-runs/run-rerun.ts"],"names":[],"mappings":"AACA,OAAO,EAAwB,KAAK,WAAW,EAAC,MAAM,gCAAgC,CAAC;AAavF,MAAM,WAAW,4BAA4B;IAC3C,aAAa,EAAE,MAAM,CAAC;IACtB,IAAI,EAAE,KAAK,GAAG,QAAQ,CAAC;IACvB,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,wBAAsB,sBAAsB,CAC1C,MAAM,EAAE,4BAA4B,GACnC,OAAO,CAAC,WAAW,CAAC,CAiGtB"}
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
import { and, asc, eq, inArray, sql } from 'drizzle-orm';
|
|
2
|
+
import { isWorkflowRunTerminal } from '#core/entities/workflow-run.js';
|
|
3
|
+
import { NoFailedJobsError, RunNotTerminalError, SourceRunNotFoundError } from '#core/errors.js';
|
|
4
|
+
import { deriveJobExecutionRunner } from '#core/workflow-run-creation.js';
|
|
5
|
+
import { recordWorkflowRunCreated } from '#metrics/instance.js';
|
|
6
|
+
import { db } from '../db.js';
|
|
7
|
+
import { jobExecutions } from '../schema/job-executions.js';
|
|
8
|
+
import { jobs } from '../schema/jobs.js';
|
|
9
|
+
import { steps } from '../schema/steps.js';
|
|
10
|
+
import { workflowRunAttempts } from '../schema/workflow-run-attempts.js';
|
|
11
|
+
import { toWorkflowRun, workflowRuns } from '../schema/workflow-runs.js';
|
|
12
|
+
import { persistMaterializedRunGraph } from './run-graph.js';
|
|
13
|
+
import { lockWorkflowRun } from './shared.js';
|
|
14
|
+
export async function createRerunWorkflowRun(params) {
|
|
15
|
+
const result = await db().transaction(async (tx)=>{
|
|
16
|
+
const workflowRunId = params.workflowRunId;
|
|
17
|
+
await tx.execute(sql`select pg_advisory_xact_lock(hashtext(${workflowRunId}))`);
|
|
18
|
+
const sourceRow = await lockWorkflowRun(workflowRunId, tx);
|
|
19
|
+
if (!sourceRow) throw new SourceRunNotFoundError(workflowRunId);
|
|
20
|
+
const [sourceAttemptRow] = await tx.select().from(workflowRunAttempts).where(and(eq(workflowRunAttempts.workflowRunId, sourceRow.id), eq(workflowRunAttempts.attempt, sourceRow.currentAttempt))).limit(1).for('update');
|
|
21
|
+
if (!sourceAttemptRow) {
|
|
22
|
+
throw new Error(`Current attempt ${sourceRow.currentAttempt} missing for run ${sourceRow.id}`);
|
|
23
|
+
}
|
|
24
|
+
if (!isWorkflowRunTerminal(sourceAttemptRow.status)) {
|
|
25
|
+
throw new RunNotTerminalError(sourceRow.id);
|
|
26
|
+
}
|
|
27
|
+
const sourceJobs = await tx.select().from(jobs).where(eq(jobs.workflowRunAttemptId, sourceAttemptRow.id)).orderBy(asc(jobs.position), asc(jobs.id));
|
|
28
|
+
if (params.mode === 'failed' && !sourceJobs.some((job)=>job.status === 'failed' || job.status === 'cancelled')) {
|
|
29
|
+
throw new NoFailedJobsError(sourceRow.id);
|
|
30
|
+
}
|
|
31
|
+
const [attemptRow] = await tx.select({
|
|
32
|
+
value: sql`coalesce(max(${workflowRunAttempts.attempt}), 1)`
|
|
33
|
+
}).from(workflowRunAttempts).where(eq(workflowRunAttempts.workflowRunId, sourceRow.id));
|
|
34
|
+
const attempt = Number(attemptRow?.value ?? 1) + 1;
|
|
35
|
+
const [newAttemptRow] = await tx.insert(workflowRunAttempts).values({
|
|
36
|
+
workflowRunId: sourceRow.id,
|
|
37
|
+
attempt,
|
|
38
|
+
status: 'pending',
|
|
39
|
+
rerunMode: params.mode,
|
|
40
|
+
rerunByUserId: params.actorUserId,
|
|
41
|
+
model: sourceAttemptRow.model,
|
|
42
|
+
agentToolMaterialization: sourceAttemptRow.agentToolMaterialization
|
|
43
|
+
}).returning();
|
|
44
|
+
if (!newAttemptRow) throw new Error('Insert returned no rows');
|
|
45
|
+
const sourceGraph = await loadRerunSourceGraph(tx, sourceJobs);
|
|
46
|
+
const sourceRun = toWorkflowRun(sourceRow);
|
|
47
|
+
const graphJobs = materializeRerunGraphJobs({
|
|
48
|
+
mode: params.mode,
|
|
49
|
+
sourceRun,
|
|
50
|
+
sourceAttempt: sourceAttemptRow,
|
|
51
|
+
sourceJobs,
|
|
52
|
+
...sourceGraph
|
|
53
|
+
});
|
|
54
|
+
await persistMaterializedRunGraph(tx, {
|
|
55
|
+
run: sourceRun,
|
|
56
|
+
workflowRunAttempt: newAttemptRow,
|
|
57
|
+
materializedJobs: graphJobs
|
|
58
|
+
});
|
|
59
|
+
const [newRunRow] = await tx.update(workflowRuns).set({
|
|
60
|
+
currentAttempt: attempt,
|
|
61
|
+
status: 'pending',
|
|
62
|
+
version: sql`${workflowRuns.version} + 1`,
|
|
63
|
+
updatedAt: new Date(),
|
|
64
|
+
startedAt: null,
|
|
65
|
+
finishedAt: null
|
|
66
|
+
}).where(eq(workflowRuns.id, sourceRow.id)).returning();
|
|
67
|
+
if (!newRunRow) throw new Error(`Workflow run missing after rerun: ${sourceRow.id}`);
|
|
68
|
+
return toWorkflowRun(newRunRow);
|
|
69
|
+
});
|
|
70
|
+
recordWorkflowRunCreated(result.triggerPayload.provider ?? result.triggerSource);
|
|
71
|
+
return result;
|
|
72
|
+
}
|
|
73
|
+
async function loadRerunSourceGraph(tx, sourceJobs) {
|
|
74
|
+
const sourceJobIds = sourceJobs.map((job)=>job.id);
|
|
75
|
+
const sourceJobExecutionRows = sourceJobIds.length === 0 ? [] : await tx.select().from(jobExecutions).where(inArray(jobExecutions.jobId, sourceJobIds)).orderBy(asc(jobExecutions.jobId), asc(jobExecutions.sequence), asc(jobExecutions.id));
|
|
76
|
+
const sourceJobExecutionByJobId = new Map();
|
|
77
|
+
for (const jobExecution of sourceJobExecutionRows){
|
|
78
|
+
if (!sourceJobExecutionByJobId.has(jobExecution.jobId)) {
|
|
79
|
+
sourceJobExecutionByJobId.set(jobExecution.jobId, jobExecution);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
const sourceJobExecutionIds = [
|
|
83
|
+
...sourceJobExecutionByJobId.values()
|
|
84
|
+
].map((jobExecution)=>jobExecution.id);
|
|
85
|
+
const sourceSteps = sourceJobExecutionIds.length === 0 ? [] : await tx.select().from(steps).where(inArray(steps.jobExecutionId, sourceJobExecutionIds)).orderBy(asc(steps.jobExecutionId), asc(steps.position), asc(steps.id));
|
|
86
|
+
const sourceJobById = new Map(sourceJobs.map((job)=>[
|
|
87
|
+
job.id,
|
|
88
|
+
job
|
|
89
|
+
]));
|
|
90
|
+
const sourceJobByJobExecutionId = new Map([
|
|
91
|
+
...sourceJobExecutionByJobId.entries()
|
|
92
|
+
].flatMap(([jobId, jobExecution])=>{
|
|
93
|
+
const job = sourceJobById.get(jobId);
|
|
94
|
+
return job ? [
|
|
95
|
+
[
|
|
96
|
+
jobExecution.id,
|
|
97
|
+
job
|
|
98
|
+
]
|
|
99
|
+
] : [];
|
|
100
|
+
}));
|
|
101
|
+
return {
|
|
102
|
+
sourceJobExecutionByJobId,
|
|
103
|
+
sourceJobByJobExecutionId,
|
|
104
|
+
sourceSteps
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
function materializeRerunGraphJobs(params) {
|
|
108
|
+
const sourceModelJobByKey = new Map((params.sourceAttempt.model?.jobs ?? []).map((job)=>[
|
|
109
|
+
job.key,
|
|
110
|
+
job
|
|
111
|
+
]));
|
|
112
|
+
const sourceStepsByJobId = new Map();
|
|
113
|
+
for (const step of params.sourceSteps){
|
|
114
|
+
const sourceJob = params.sourceJobByJobExecutionId.get(step.jobExecutionId);
|
|
115
|
+
if (!sourceJob) continue;
|
|
116
|
+
const sourceJobSteps = sourceStepsByJobId.get(sourceJob.id) ?? [];
|
|
117
|
+
sourceJobSteps.push(step);
|
|
118
|
+
sourceStepsByJobId.set(sourceJob.id, sourceJobSteps);
|
|
119
|
+
}
|
|
120
|
+
return params.sourceJobs.map((sourceJob)=>{
|
|
121
|
+
const carriedOver = params.mode === 'failed' && sourceJob.status === 'succeeded';
|
|
122
|
+
return {
|
|
123
|
+
job: {
|
|
124
|
+
key: sourceJob.key,
|
|
125
|
+
name: sourceJob.name,
|
|
126
|
+
mode: sourceJob.mode,
|
|
127
|
+
status: carriedOver ? 'succeeded' : 'pending',
|
|
128
|
+
statusReason: null,
|
|
129
|
+
carriedOver,
|
|
130
|
+
checkoutPersistCredentials: sourceJob.checkoutPersistCredentials,
|
|
131
|
+
checkoutPermissionsContents: sourceJob.checkoutPermissionsContents,
|
|
132
|
+
success: sourceJob.success,
|
|
133
|
+
executionTimeoutMs: sourceJob.executionTimeoutMs,
|
|
134
|
+
listeningTimeoutMs: sourceJob.listeningTimeoutMs,
|
|
135
|
+
maxExecutions: sourceJob.maxExecutions,
|
|
136
|
+
onResolve: sourceJob.onResolve,
|
|
137
|
+
batchDebounceMs: sourceJob.batchDebounceMs,
|
|
138
|
+
batchMaxSize: sourceJob.batchMaxSize,
|
|
139
|
+
batchMaxWaitMs: sourceJob.batchMaxWaitMs,
|
|
140
|
+
listenerStatus: 'inactive',
|
|
141
|
+
resolutionReason: null,
|
|
142
|
+
listeningOn: sourceJob.listeningOn ? [
|
|
143
|
+
...sourceJob.listeningOn
|
|
144
|
+
] : null,
|
|
145
|
+
listeningUntil: sourceJob.listeningUntil ? [
|
|
146
|
+
...sourceJob.listeningUntil
|
|
147
|
+
] : null,
|
|
148
|
+
outputs: carriedOver && sourceJob.outputs ? {
|
|
149
|
+
...sourceJob.outputs
|
|
150
|
+
} : null,
|
|
151
|
+
dependencies: [
|
|
152
|
+
...sourceJob.dependencies
|
|
153
|
+
],
|
|
154
|
+
runner: sourceJob.runner ? [
|
|
155
|
+
...sourceJob.runner
|
|
156
|
+
] : null,
|
|
157
|
+
position: sourceJob.position
|
|
158
|
+
},
|
|
159
|
+
createExecution: (job)=>{
|
|
160
|
+
if (job.mode === 'listening') return undefined;
|
|
161
|
+
const sourceExecution = params.sourceJobExecutionByJobId.get(sourceJob.id);
|
|
162
|
+
const modelJob = sourceModelJobByKey.get(job.key);
|
|
163
|
+
const executionName = sourceExecution?.name ?? `${job.key} #1`;
|
|
164
|
+
const runner = carriedOver || modelJob === undefined ? sourceExecution?.runner ?? job.runner ?? null : deriveJobExecutionRunner({
|
|
165
|
+
run: params.sourceRun,
|
|
166
|
+
modelJob,
|
|
167
|
+
jobId: job.id,
|
|
168
|
+
sequence: 1,
|
|
169
|
+
executionName,
|
|
170
|
+
status: 'pending'
|
|
171
|
+
});
|
|
172
|
+
return {
|
|
173
|
+
sequence: 1,
|
|
174
|
+
name: executionName,
|
|
175
|
+
runner: runner ? [
|
|
176
|
+
...runner
|
|
177
|
+
] : null,
|
|
178
|
+
status: carriedOver ? 'succeeded' : 'pending',
|
|
179
|
+
statusReason: null,
|
|
180
|
+
outputs: carriedOver && sourceExecution?.outputs ? {
|
|
181
|
+
...sourceExecution.outputs
|
|
182
|
+
} : null,
|
|
183
|
+
...carriedOver ? {
|
|
184
|
+
finishedAt: sql`now()`
|
|
185
|
+
} : {}
|
|
186
|
+
};
|
|
187
|
+
},
|
|
188
|
+
createSteps: ()=>(sourceStepsByJobId.get(sourceJob.id) ?? []).map((step)=>({
|
|
189
|
+
key: step.key,
|
|
190
|
+
name: step.name,
|
|
191
|
+
sourceLocation: step.sourceLocation,
|
|
192
|
+
status: carriedOver ? step.status : 'pending',
|
|
193
|
+
statusReason: carriedOver ? step.statusReason : null,
|
|
194
|
+
type: step.type,
|
|
195
|
+
config: step.config,
|
|
196
|
+
condition: step.condition ?? null,
|
|
197
|
+
configPlan: step.configPlan,
|
|
198
|
+
authoredConfig: step.authoredConfig,
|
|
199
|
+
error: null,
|
|
200
|
+
position: step.position,
|
|
201
|
+
currentAttempt: 1
|
|
202
|
+
}))
|
|
203
|
+
};
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
//# sourceMappingURL=run-rerun.js.map
|
|
@@ -0,0 +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,K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AAC;oBAAA,IAAI,CAAC,CAAC;gBACjD;YACF;YACA4H,aAAa,IACX,AAAC9B,CAAAA,mBAAmBH,GAAG,CAACK,UAAUpE,EAAE,KAAK,EAAE,AAAD,EAAG+C,GAAG,CAAC,CAACoB,OAAU,CAAA;wBAC1DF,KAAKE,KAAKF,GAAG;wBACbO,MAAML,KAAKK,IAAI;wBACfyB,gBAAgB9B,KAAK8B,cAAc;wBACnC3F,QAAQiE,cAAcJ,KAAK7D,MAAM,GAAI;wBACrCmE,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;wBACP7F,UAAUyD,KAAKzD,QAAQ;wBACvBR,gBAAgB;oBAClB,CAAA;QACJ;IACF;AACF"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { type JobStatusReason } from '#core/entities/job.js';
|
|
2
|
+
import { type WorkflowRun, type WorkflowRunStatus } from '#core/entities/workflow-run.js';
|
|
3
|
+
export interface CancelWorkflowRunParams {
|
|
4
|
+
workflowRunId: string;
|
|
5
|
+
}
|
|
6
|
+
export interface FailWorkflowRunAsTimedOutParams {
|
|
7
|
+
runAttemptId: string;
|
|
8
|
+
}
|
|
9
|
+
export interface RunTerminationSpec {
|
|
10
|
+
terminalStatus: Extract<WorkflowRunStatus, 'failed' | 'cancelled'>;
|
|
11
|
+
statusReason: Extract<JobStatusReason, 'timed_out' | 'run_cancelled'>;
|
|
12
|
+
markExecutionTimedOut: boolean;
|
|
13
|
+
emitCancelledEvent: boolean;
|
|
14
|
+
}
|
|
15
|
+
export declare function failWorkflowRunAsTimedOut(params: FailWorkflowRunAsTimedOutParams): Promise<WorkflowRun>;
|
|
16
|
+
export declare function cancelWorkflowRun(params: CancelWorkflowRunParams): Promise<WorkflowRun>;
|
|
17
|
+
export interface UpdateWorkflowRunStatusParams {
|
|
18
|
+
workflowRunId?: string;
|
|
19
|
+
workflowRunAttemptId?: string;
|
|
20
|
+
status: WorkflowRunStatus;
|
|
21
|
+
expectedVersion: number;
|
|
22
|
+
}
|
|
23
|
+
export declare function updateWorkflowRunStatus(params: UpdateWorkflowRunStatusParams): Promise<WorkflowRun>;
|
|
24
|
+
//# sourceMappingURL=run-status.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-status.d.ts","sourceRoot":"","sources":["../../../src/db/workflow-runs/run-status.ts"],"names":[],"mappings":"AAKA,OAAO,EAA0B,KAAK,eAAe,EAAC,MAAM,uBAAuB,CAAC;AACpF,OAAO,EAEL,KAAK,WAAW,EAChB,KAAK,iBAAiB,EACvB,MAAM,gCAAgC,CAAC;AAkBxC,MAAM,WAAW,uBAAuB;IACtC,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,+BAA+B;IAC9C,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,kBAAkB;IACjC,cAAc,EAAE,OAAO,CAAC,iBAAiB,EAAE,QAAQ,GAAG,WAAW,CAAC,CAAC;IACnE,YAAY,EAAE,OAAO,CAAC,eAAe,EAAE,WAAW,GAAG,eAAe,CAAC,CAAC;IACtE,qBAAqB,EAAE,OAAO,CAAC;IAC/B,kBAAkB,EAAE,OAAO,CAAC;CAC7B;AA2ID,wBAAsB,yBAAyB,CAC7C,MAAM,EAAE,+BAA+B,GACtC,OAAO,CAAC,WAAW,CAAC,CAgCtB;AAED,wBAAsB,iBAAiB,CAAC,MAAM,EAAE,uBAAuB,GAAG,OAAO,CAAC,WAAW,CAAC,CA4C7F;AAED,MAAM,WAAW,6BAA6B;IAC5C,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,MAAM,EAAE,iBAAiB,CAAC;IAC1B,eAAe,EAAE,MAAM,CAAC;CACzB;AAED,wBAAsB,uBAAuB,CAC3C,MAAM,EAAE,6BAA6B,GACpC,OAAO,CAAC,WAAW,CAAC,CAuHtB"}
|