@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.
- package/.turbo/turbo-build.log +4 -4
- package/CHANGELOG.md +104 -0
- package/dist/core/agent-defaults.d.ts +17 -0
- package/dist/core/agent-defaults.d.ts.map +1 -0
- package/dist/core/agent-defaults.js +21 -0
- package/dist/core/agent-defaults.js.map +1 -0
- package/dist/core/agent-tool-capability-warning.d.ts +4 -0
- package/dist/core/agent-tool-capability-warning.d.ts.map +1 -1
- package/dist/core/agent-tool-capability-warning.js +15 -17
- package/dist/core/agent-tool-capability-warning.js.map +1 -1
- package/dist/core/agent-tools.d.ts +11 -9
- package/dist/core/agent-tools.d.ts.map +1 -1
- package/dist/core/agent-tools.js +23 -18
- package/dist/core/agent-tools.js.map +1 -1
- package/dist/core/checkout.d.ts +21 -7
- package/dist/core/checkout.d.ts.map +1 -1
- package/dist/core/checkout.js +23 -11
- package/dist/core/checkout.js.map +1 -1
- package/dist/core/entities/workflow-run-attempt.d.ts +1 -1
- package/dist/core/entities/workflow-run-attempt.d.ts.map +1 -1
- package/dist/core/entities/workflow-run-attempt.js.map +1 -1
- package/dist/core/job-execution.d.ts +3 -1
- package/dist/core/job-execution.d.ts.map +1 -1
- package/dist/core/job-execution.js +14 -12
- package/dist/core/job-execution.js.map +1 -1
- package/dist/core/job-transition/derive-job-execution-outputs.d.ts +1 -1
- package/dist/core/job-transition/derive-job-execution-outputs.d.ts.map +1 -1
- package/dist/core/job-transition/derive-job-execution-outputs.js.map +1 -1
- package/dist/core/job-transition/derive-job-success.js +1 -1
- package/dist/core/job-transition/derive-job-success.js.map +1 -1
- package/dist/core/listener-execution-materialization.d.ts +3 -3
- package/dist/core/listener-execution-materialization.d.ts.map +1 -1
- package/dist/core/listener-execution-materialization.js +3 -4
- package/dist/core/listener-execution-materialization.js.map +1 -1
- package/dist/core/run-workflow.d.ts +12 -1
- package/dist/core/run-workflow.d.ts.map +1 -1
- package/dist/core/run-workflow.js +13 -8
- package/dist/core/run-workflow.js.map +1 -1
- package/dist/core/step-config/agent.d.ts +8 -8
- package/dist/core/step-config/agent.d.ts.map +1 -1
- package/dist/core/step-config/agent.js +12 -10
- package/dist/core/step-config/agent.js.map +1 -1
- package/dist/core/step-config/complete-step-dispatch-config.d.ts +4 -4
- package/dist/core/step-config/complete-step-dispatch-config.d.ts.map +1 -1
- package/dist/core/step-config/complete-step-dispatch-config.js +2 -2
- package/dist/core/step-config/complete-step-dispatch-config.js.map +1 -1
- package/dist/core/step-config/materialize-job-execution-steps.d.ts +3 -3
- package/dist/core/step-config/materialize-job-execution-steps.d.ts.map +1 -1
- package/dist/core/step-config/materialize-job-execution-steps.js +5 -6
- package/dist/core/step-config/materialize-job-execution-steps.js.map +1 -1
- package/dist/core/step-config/materialize-workflow-model.d.ts +3 -3
- package/dist/core/step-config/materialize-workflow-model.d.ts.map +1 -1
- package/dist/core/step-config/materialize-workflow-model.js +4 -4
- package/dist/core/step-config/materialize-workflow-model.js.map +1 -1
- package/dist/core/step-config/resolve-job-execution-name.d.ts +1 -1
- package/dist/core/step-config/resolve-job-execution-name.d.ts.map +1 -1
- package/dist/core/step-config/resolve-job-execution-name.js.map +1 -1
- package/dist/core/step-config/resolve-step-config.d.ts +4 -4
- package/dist/core/step-config/resolve-step-config.d.ts.map +1 -1
- package/dist/core/step-config/resolve-step-config.js +6 -6
- package/dist/core/step-config/resolve-step-config.js.map +1 -1
- package/dist/core/step-config/run.d.ts +1 -1
- package/dist/core/step-config/run.d.ts.map +1 -1
- package/dist/core/step-config/run.js.map +1 -1
- package/dist/core/workflow-run-creation.d.ts +3 -3
- package/dist/core/workflow-run-creation.d.ts.map +1 -1
- package/dist/core/workflow-run-creation.js +3 -4
- package/dist/core/workflow-run-creation.js.map +1 -1
- package/dist/db/db.d.ts +16 -4
- package/dist/db/db.d.ts.map +1 -1
- package/dist/db/job-listeners.d.ts +7 -1
- package/dist/db/job-listeners.d.ts.map +1 -1
- package/dist/db/job-listeners.js +10 -5
- package/dist/db/job-listeners.js.map +1 -1
- package/dist/db/runner-lease-table.d.ts +5 -5
- package/dist/db/runner-lease-table.d.ts.map +1 -1
- package/dist/db/runner-lease-table.js +3 -2
- package/dist/db/runner-lease-table.js.map +1 -1
- package/dist/db/schema/workflow-run-attempts.d.ts +9 -3
- package/dist/db/schema/workflow-run-attempts.d.ts.map +1 -1
- package/dist/db/schema/workflow-run-attempts.js +2 -1
- package/dist/db/schema/workflow-run-attempts.js.map +1 -1
- package/dist/db/schema/workflow-runs.js +1 -1
- package/dist/db/schema/workflow-runs.js.map +1 -1
- package/dist/db/workflow-runs/job-executions.d.ts +5 -0
- package/dist/db/workflow-runs/job-executions.d.ts.map +1 -1
- package/dist/db/workflow-runs/job-executions.js +14 -7
- package/dist/db/workflow-runs/job-executions.js.map +1 -1
- package/dist/db/workflow-runs/jobs.d.ts.map +1 -1
- package/dist/db/workflow-runs/jobs.js +3 -1
- package/dist/db/workflow-runs/jobs.js.map +1 -1
- package/dist/db/workflow-runs/run-create.d.ts +9 -2
- package/dist/db/workflow-runs/run-create.d.ts.map +1 -1
- package/dist/db/workflow-runs/run-create.js +12 -9
- package/dist/db/workflow-runs/run-create.js.map +1 -1
- package/dist/db/workflow-runs/run-rerun.d.ts.map +1 -1
- package/dist/db/workflow-runs/run-rerun.js +3 -1
- package/dist/db/workflow-runs/run-rerun.js.map +1 -1
- package/dist/index.d.ts +18 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +61 -37
- package/dist/index.js.map +1 -1
- package/dist/presentation/dto/checkout-token.d.ts +14 -1
- package/dist/presentation/dto/checkout-token.d.ts.map +1 -1
- package/dist/presentation/dto/checkout-token.js.map +1 -1
- package/dist/presentation/index.d.ts +1 -1
- package/dist/presentation/index.d.ts.map +1 -1
- package/dist/presentation/index.js +1 -1
- package/dist/presentation/index.js.map +1 -1
- package/dist/presentation/inter-module.d.ts +18 -0
- package/dist/presentation/inter-module.d.ts.map +1 -0
- package/dist/presentation/inter-module.js +113 -0
- package/dist/presentation/inter-module.js.map +1 -0
- package/dist/presentation/routes/agent-runtime-config.d.ts +6 -1
- package/dist/presentation/routes/agent-runtime-config.d.ts.map +1 -1
- package/dist/presentation/routes/agent-runtime-config.js +59 -57
- package/dist/presentation/routes/agent-runtime-config.js.map +1 -1
- package/dist/presentation/routes/cancel-run.d.ts +2 -1
- package/dist/presentation/routes/cancel-run.d.ts.map +1 -1
- package/dist/presentation/routes/cancel-run.js +37 -34
- package/dist/presentation/routes/cancel-run.js.map +1 -1
- package/dist/presentation/routes/checkout-token.d.ts +8 -1
- package/dist/presentation/routes/checkout-token.d.ts.map +1 -1
- package/dist/presentation/routes/checkout-token.js +65 -47
- package/dist/presentation/routes/checkout-token.js.map +1 -1
- package/dist/presentation/routes/get-run-aggregates.d.ts +2 -1
- package/dist/presentation/routes/get-run-aggregates.d.ts.map +1 -1
- package/dist/presentation/routes/get-run-aggregates.js +44 -53
- package/dist/presentation/routes/get-run-aggregates.js.map +1 -1
- package/dist/presentation/routes/get-run.d.ts +2 -1
- package/dist/presentation/routes/get-run.d.ts.map +1 -1
- package/dist/presentation/routes/get-run.js +53 -50
- package/dist/presentation/routes/get-run.js.map +1 -1
- package/dist/presentation/routes/get-step-secrets.d.ts +3 -1
- package/dist/presentation/routes/get-step-secrets.d.ts.map +1 -1
- package/dist/presentation/routes/get-step-secrets.js +72 -68
- package/dist/presentation/routes/get-step-secrets.js.map +1 -1
- package/dist/presentation/routes/index.d.ts +19 -2
- package/dist/presentation/routes/index.d.ts.map +1 -1
- package/dist/presentation/routes/index.js +38 -30
- package/dist/presentation/routes/index.js.map +1 -1
- package/dist/presentation/routes/leased-step.d.ts +2 -0
- package/dist/presentation/routes/leased-step.d.ts.map +1 -1
- package/dist/presentation/routes/leased-step.js +1 -2
- package/dist/presentation/routes/leased-step.js.map +1 -1
- package/dist/presentation/routes/list-run-attempts.d.ts +2 -1
- package/dist/presentation/routes/list-run-attempts.d.ts.map +1 -1
- package/dist/presentation/routes/list-run-attempts.js +29 -26
- package/dist/presentation/routes/list-run-attempts.js.map +1 -1
- package/dist/presentation/routes/list-runs.d.ts +2 -1
- package/dist/presentation/routes/list-runs.d.ts.map +1 -1
- package/dist/presentation/routes/list-runs.js +51 -60
- package/dist/presentation/routes/list-runs.js.map +1 -1
- package/dist/presentation/routes/next-step.d.ts +10 -1
- package/dist/presentation/routes/next-step.d.ts.map +1 -1
- package/dist/presentation/routes/next-step.js +64 -50
- package/dist/presentation/routes/next-step.js.map +1 -1
- package/dist/presentation/routes/project-access.d.ts +10 -0
- package/dist/presentation/routes/project-access.d.ts.map +1 -0
- package/dist/presentation/routes/project-access.js +17 -0
- package/dist/presentation/routes/project-access.js.map +1 -0
- package/dist/presentation/routes/report-step.d.ts +2 -1
- package/dist/presentation/routes/report-step.d.ts.map +1 -1
- package/dist/presentation/routes/report-step.js +62 -61
- package/dist/presentation/routes/report-step.js.map +1 -1
- package/dist/presentation/routes/require-accessible-run.d.ts +3 -1
- package/dist/presentation/routes/require-accessible-run.d.ts.map +1 -1
- package/dist/presentation/routes/require-accessible-run.js +3 -6
- package/dist/presentation/routes/require-accessible-run.js.map +1 -1
- package/dist/presentation/routes/rerun-run.d.ts +2 -1
- package/dist/presentation/routes/rerun-run.d.ts.map +1 -1
- package/dist/presentation/routes/rerun-run.js +46 -43
- package/dist/presentation/routes/rerun-run.js.map +1 -1
- package/dist/temporal/activities/index.d.ts +44 -9
- package/dist/temporal/activities/index.d.ts.map +1 -1
- package/dist/temporal/activities/index.js +13 -9
- package/dist/temporal/activities/index.js.map +1 -1
- package/dist/temporal/activities/orchestration-activities.d.ts +20 -11
- package/dist/temporal/activities/orchestration-activities.d.ts.map +1 -1
- package/dist/temporal/activities/orchestration-activities.js +48 -33
- package/dist/temporal/activities/orchestration-activities.js.map +1 -1
- package/dist/tsconfig.test.tsbuildinfo +1 -1
- package/package.json +41 -44
- package/src/core/agent-defaults.test.ts +28 -0
- package/src/core/agent-defaults.ts +36 -0
- package/src/core/agent-tool-capability-warning.test.ts +36 -11
- package/src/core/agent-tool-capability-warning.ts +27 -25
- package/src/core/agent-tools.ts +33 -36
- package/src/core/checkout.test.ts +38 -25
- package/src/core/checkout.ts +41 -14
- package/src/core/entities/workflow-run-attempt.ts +1 -1
- package/src/core/job-execution.ts +19 -9
- package/src/core/job-transition/derive-job-execution-outputs.ts +1 -1
- package/src/core/job-transition/derive-job-success.ts +1 -1
- package/src/core/listener-execution-materialization.test.ts +4 -2
- package/src/core/listener-execution-materialization.ts +6 -9
- package/src/core/run-workflow.test.ts +43 -38
- package/src/core/run-workflow.ts +26 -9
- package/src/core/step-config/agent.ts +24 -26
- package/src/core/step-config/complete-step-dispatch-config.test.ts +22 -23
- package/src/core/step-config/complete-step-dispatch-config.ts +6 -6
- package/src/core/step-config/materialize-job-execution-steps.test.ts +34 -23
- package/src/core/step-config/materialize-job-execution-steps.ts +38 -39
- package/src/core/step-config/materialize-workflow-model.test.ts +94 -82
- package/src/core/step-config/materialize-workflow-model.ts +31 -29
- package/src/core/step-config/resolve-job-execution-name.ts +1 -1
- package/src/core/step-config/resolve-step-config.ts +11 -9
- package/src/core/step-config/run.ts +1 -1
- package/src/core/workflow-run-creation.test.ts +14 -10
- package/src/core/workflow-run-creation.ts +6 -9
- package/src/db/job-listeners.ts +20 -5
- package/src/db/runner-lease-table.ts +2 -2
- package/src/db/schema/workflow-run-attempts.ts +7 -3
- package/src/db/schema/workflow-runs.ts +1 -1
- package/src/db/workflow-runs/job-executions.ts +15 -1
- package/src/db/workflow-runs/jobs.ts +4 -1
- package/src/db/workflow-runs/run-create.test.ts +7 -1
- package/src/db/workflow-runs/run-create.ts +25 -15
- package/src/db/workflow-runs/run-rerun.test.ts +1 -1
- package/src/db/workflow-runs/run-rerun.ts +6 -3
- package/src/index.ts +75 -33
- package/src/presentation/dto/checkout-token.ts +7 -1
- package/src/presentation/index.ts +1 -1
- package/src/presentation/inter-module.test.ts +149 -0
- package/src/presentation/inter-module.ts +132 -0
- package/src/presentation/routes/agent-runtime-config.test.ts +53 -10
- package/src/presentation/routes/agent-runtime-config.ts +89 -64
- package/src/presentation/routes/cancel-run.test.ts +10 -20
- package/src/presentation/routes/cancel-run.ts +30 -27
- package/src/presentation/routes/checkout-token.test.ts +52 -33
- package/src/presentation/routes/checkout-token.ts +109 -49
- package/src/presentation/routes/get-run-aggregates.test.ts +13 -7
- package/src/presentation/routes/get-run-aggregates.ts +54 -57
- package/src/presentation/routes/get-run.test.ts +10 -18
- package/src/presentation/routes/get-run.ts +51 -48
- package/src/presentation/routes/get-step-secrets.test.ts +29 -7
- package/src/presentation/routes/get-step-secrets.ts +72 -61
- package/src/presentation/routes/index.test.ts +16 -1
- package/src/presentation/routes/index.ts +54 -29
- package/src/presentation/routes/leased-step.ts +3 -2
- package/src/presentation/routes/list-run-attempts.test.ts +9 -19
- package/src/presentation/routes/list-run-attempts.ts +21 -18
- package/src/presentation/routes/list-runs.test.ts +13 -7
- package/src/presentation/routes/list-runs.ts +64 -67
- package/src/presentation/routes/next-step.test.ts +30 -11
- package/src/presentation/routes/next-step.ts +68 -48
- package/src/presentation/routes/project-access.ts +16 -0
- package/src/presentation/routes/report-step.test.ts +18 -2
- package/src/presentation/routes/report-step.ts +51 -49
- package/src/presentation/routes/require-accessible-run.ts +5 -2
- package/src/presentation/routes/rerun-run.test.ts +9 -19
- package/src/presentation/routes/rerun-run.ts +39 -36
- package/src/temporal/activities/index.ts +32 -12
- package/src/temporal/activities/orchestration-activities.test.ts +10 -8
- package/src/temporal/activities/orchestration-activities.ts +74 -50
- package/src/temporal/workflows/job-execution-orchestration.test.ts +47 -2
- package/test/env.ts +1 -3
- package/test/factories/project.ts +10 -5
- package/test/factories/workflow-model.test.ts +5 -1
- package/test/factories/workflow-model.ts +1 -1
- package/test/factories/workflow-run.ts +1 -1
- package/test/fixtures/agent-inter-module.ts +27 -0
- package/test/fixtures/annotations-inter-module.ts +5 -0
- package/test/fixtures/auth-inter-module.ts +22 -0
- package/test/fixtures/lease-token.ts +2 -1
- package/test/fixtures/projects-inter-module.ts +8 -0
- package/test/fixtures/runners-inter-module.ts +52 -0
- package/test/fixtures/secrets-inter-module.ts +61 -0
- package/test/globalSetup.ts +11 -11
- package/tsconfig.build.tsbuildinfo +1 -1
- package/dist/core/source-control.d.ts +0 -5
- package/dist/core/source-control.d.ts.map +0 -1
- package/dist/core/source-control.js +0 -19
- package/dist/core/source-control.js.map +0 -1
- package/src/core/source-control.test.ts +0 -17
- package/src/core/source-control.ts +0 -22
- package/src/temporal/workflows/job-execution-orchestration-timeout.test.ts +0 -165
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import {UnsupportedHarnessThinkingError} from '@shipfox/api-agent/core/errors';
|
|
2
|
-
import type {AgentDefaultsResolver} from '@shipfox/api-agent/core/resolve-agent-config';
|
|
3
1
|
import {
|
|
4
2
|
AGENT_INTEGRATION_MCP_AUTH,
|
|
5
3
|
AGENT_INTEGRATION_MCP_ENDPOINT,
|
|
@@ -8,7 +6,10 @@ import {
|
|
|
8
6
|
type AgentIntegrationMcpServerConfigDto,
|
|
9
7
|
type MaterializedAgentIntegrationConfigDto,
|
|
10
8
|
} from '@shipfox/api-agent-dto';
|
|
9
|
+
import {agentInterModuleContract} from '@shipfox/api-agent-dto/inter-module';
|
|
11
10
|
import {parseWorkflowTemplate, planInterpolationField} from '@shipfox/expression';
|
|
11
|
+
import {createInterModuleKnownError} from '@shipfox/inter-module';
|
|
12
|
+
import type {AgentDefaultsResolver} from '#core/agent-defaults.js';
|
|
12
13
|
import type {Step} from '#core/entities/step.js';
|
|
13
14
|
import {AgentConfigUnresolvableError, InterpolationUnresolvableError} from '#core/errors.js';
|
|
14
15
|
import {completeStepDispatchConfig} from './complete-step-dispatch-config.js';
|
|
@@ -112,7 +113,7 @@ function integrationMcpServers(
|
|
|
112
113
|
}
|
|
113
114
|
|
|
114
115
|
describe('completeStepDispatchConfig', () => {
|
|
115
|
-
it('copies frozen agent integrations from the dispatch plan', () => {
|
|
116
|
+
it('copies frozen agent integrations from the dispatch plan', async () => {
|
|
116
117
|
const integrations = [materializedIntegration()];
|
|
117
118
|
const pending = step({
|
|
118
119
|
type: 'agent',
|
|
@@ -130,7 +131,7 @@ describe('completeStepDispatchConfig', () => {
|
|
|
130
131
|
},
|
|
131
132
|
});
|
|
132
133
|
|
|
133
|
-
const result = completeStepDispatchConfig({
|
|
134
|
+
const result = await completeStepDispatchConfig({
|
|
134
135
|
step: pending,
|
|
135
136
|
context,
|
|
136
137
|
resolveAgentDefaults,
|
|
@@ -141,7 +142,7 @@ describe('completeStepDispatchConfig', () => {
|
|
|
141
142
|
expect(result.config.mcpServers).toEqual(integrationMcpServers(integrations));
|
|
142
143
|
});
|
|
143
144
|
|
|
144
|
-
it('serializes residual secret env values as secret bindings without writing env values', () => {
|
|
145
|
+
it('serializes residual secret env values as secret bindings without writing env values', async () => {
|
|
145
146
|
const pending = step({
|
|
146
147
|
config: {},
|
|
147
148
|
configPlan: {
|
|
@@ -152,7 +153,7 @@ describe('completeStepDispatchConfig', () => {
|
|
|
152
153
|
},
|
|
153
154
|
});
|
|
154
155
|
|
|
155
|
-
const result = completeStepDispatchConfig({
|
|
156
|
+
const result = await completeStepDispatchConfig({
|
|
156
157
|
step: pending,
|
|
157
158
|
context,
|
|
158
159
|
resolveAgentDefaults,
|
|
@@ -196,7 +197,7 @@ describe('completeStepDispatchConfig', () => {
|
|
|
196
197
|
]);
|
|
197
198
|
});
|
|
198
199
|
|
|
199
|
-
it('rejects secret env bindings with malformed target names', () => {
|
|
200
|
+
it('rejects secret env bindings with malformed target names', async () => {
|
|
200
201
|
const pending = step({
|
|
201
202
|
config: {},
|
|
202
203
|
configPlan: {
|
|
@@ -214,10 +215,10 @@ describe('completeStepDispatchConfig', () => {
|
|
|
214
215
|
definitionId: 'def-1',
|
|
215
216
|
});
|
|
216
217
|
|
|
217
|
-
expect(act).toThrow();
|
|
218
|
+
await expect(act()).rejects.toThrow();
|
|
218
219
|
});
|
|
219
220
|
|
|
220
|
-
it('keeps fully resolved step config byte-identical apart from resolved env additions', () => {
|
|
221
|
+
it('keeps fully resolved step config byte-identical apart from resolved env additions', async () => {
|
|
221
222
|
const pending = step({
|
|
222
223
|
config: {run: 'echo "$SHA"'},
|
|
223
224
|
configPlan: {
|
|
@@ -227,7 +228,7 @@ describe('completeStepDispatchConfig', () => {
|
|
|
227
228
|
},
|
|
228
229
|
});
|
|
229
230
|
|
|
230
|
-
const result = completeStepDispatchConfig({
|
|
231
|
+
const result = await completeStepDispatchConfig({
|
|
231
232
|
step: pending,
|
|
232
233
|
context,
|
|
233
234
|
resolveAgentDefaults,
|
|
@@ -250,7 +251,7 @@ describe('completeStepDispatchConfig', () => {
|
|
|
250
251
|
});
|
|
251
252
|
});
|
|
252
253
|
|
|
253
|
-
it('completes deferred agent config with the resolved harness', () => {
|
|
254
|
+
it('completes deferred agent config with the resolved harness', async () => {
|
|
254
255
|
const integration = materializedIntegration();
|
|
255
256
|
const mcpServers = integrationMcpServers([integration]);
|
|
256
257
|
const pending = step({
|
|
@@ -267,7 +268,7 @@ describe('completeStepDispatchConfig', () => {
|
|
|
267
268
|
},
|
|
268
269
|
});
|
|
269
270
|
|
|
270
|
-
const result = completeStepDispatchConfig({
|
|
271
|
+
const result = await completeStepDispatchConfig({
|
|
271
272
|
step: pending,
|
|
272
273
|
context,
|
|
273
274
|
resolveAgentDefaults,
|
|
@@ -298,7 +299,7 @@ describe('completeStepDispatchConfig', () => {
|
|
|
298
299
|
});
|
|
299
300
|
});
|
|
300
301
|
|
|
301
|
-
it('wraps harness resolver errors as unresolvable agent config', () => {
|
|
302
|
+
it('wraps harness resolver errors as unresolvable agent config', async () => {
|
|
302
303
|
const pending = step({
|
|
303
304
|
type: 'agent',
|
|
304
305
|
config: {},
|
|
@@ -311,13 +312,11 @@ describe('completeStepDispatchConfig', () => {
|
|
|
311
312
|
},
|
|
312
313
|
});
|
|
313
314
|
const failingResolver: AgentDefaultsResolver = () => {
|
|
314
|
-
throw
|
|
315
|
-
|
|
316
|
-
'
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
'max',
|
|
320
|
-
]);
|
|
315
|
+
throw createInterModuleKnownError(
|
|
316
|
+
agentInterModuleContract.methods.resolveAgentConfig,
|
|
317
|
+
'agent-config-invalid',
|
|
318
|
+
{},
|
|
319
|
+
);
|
|
321
320
|
};
|
|
322
321
|
|
|
323
322
|
const act = () =>
|
|
@@ -328,10 +327,10 @@ describe('completeStepDispatchConfig', () => {
|
|
|
328
327
|
definitionId: 'def-1',
|
|
329
328
|
});
|
|
330
329
|
|
|
331
|
-
expect(act).toThrow(AgentConfigUnresolvableError);
|
|
330
|
+
await expect(act()).rejects.toThrow(AgentConfigUnresolvableError);
|
|
332
331
|
});
|
|
333
332
|
|
|
334
|
-
it('throws when a server-side segment still survives dispatch', () => {
|
|
333
|
+
it('throws when a server-side segment still survives dispatch', async () => {
|
|
335
334
|
const pending = step({
|
|
336
335
|
config: {},
|
|
337
336
|
configPlan: {
|
|
@@ -349,6 +348,6 @@ describe('completeStepDispatchConfig', () => {
|
|
|
349
348
|
definitionId: 'def-1',
|
|
350
349
|
});
|
|
351
350
|
|
|
352
|
-
expect(act).toThrow(InterpolationUnresolvableError);
|
|
351
|
+
await expect(act()).rejects.toThrow(InterpolationUnresolvableError);
|
|
353
352
|
});
|
|
354
353
|
});
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import type {AgentDefaultsResolver} from '@shipfox/api-agent/core/resolve-agent-config';
|
|
2
1
|
import {capTraceEntries} from '@shipfox/expression';
|
|
2
|
+
import type {AgentDefaultsResolver} from '#core/agent-defaults.js';
|
|
3
3
|
import type {PersistedEvaluationTraceEntry, Step} from '#core/entities/step.js';
|
|
4
4
|
import {completeAgentConfig} from './agent.js';
|
|
5
5
|
import {completeRunDispatchConfig} from './run.js';
|
|
6
6
|
import type {WorkflowEvaluationContext} from './workflow-evaluation-context.js';
|
|
7
7
|
|
|
8
|
-
export function completeStepDispatchConfig(params: {
|
|
8
|
+
export async function completeStepDispatchConfig(params: {
|
|
9
9
|
readonly step: Step;
|
|
10
10
|
readonly context: WorkflowEvaluationContext;
|
|
11
|
-
readonly resolveAgentDefaults
|
|
11
|
+
readonly resolveAgentDefaults?: AgentDefaultsResolver | undefined;
|
|
12
12
|
readonly definitionId: string;
|
|
13
|
-
}): {
|
|
13
|
+
}): Promise<{
|
|
14
14
|
readonly config: Record<string, unknown>;
|
|
15
15
|
readonly trace: readonly PersistedEvaluationTraceEntry[];
|
|
16
|
-
} {
|
|
16
|
+
}> {
|
|
17
17
|
const plan = params.step.configPlan;
|
|
18
18
|
if (plan === null) return {config: params.step.config, trace: []};
|
|
19
19
|
|
|
@@ -27,7 +27,7 @@ export function completeStepDispatchConfig(params: {
|
|
|
27
27
|
definitionId: params.definitionId,
|
|
28
28
|
trace,
|
|
29
29
|
});
|
|
30
|
-
completeAgentConfig({
|
|
30
|
+
await completeAgentConfig({
|
|
31
31
|
config,
|
|
32
32
|
plan,
|
|
33
33
|
context: params.context,
|
|
@@ -1,21 +1,29 @@
|
|
|
1
|
-
import {
|
|
2
|
-
InvalidAgentModelError,
|
|
3
|
-
UnsupportedModelProviderError,
|
|
4
|
-
} from '@shipfox/api-agent/core/errors';
|
|
5
|
-
import type {AgentDefaultsResolver} from '@shipfox/api-agent/core/resolve-agent-config';
|
|
6
1
|
import {
|
|
7
2
|
AGENT_INTEGRATION_MCP_AUTH,
|
|
8
3
|
AGENT_INTEGRATION_MCP_ENDPOINT,
|
|
9
4
|
AGENT_INTEGRATION_MCP_SERVER_NAME,
|
|
10
5
|
AGENT_INTEGRATION_MCP_TRANSPORT,
|
|
11
6
|
} from '@shipfox/api-agent-dto';
|
|
7
|
+
import {agentInterModuleContract} from '@shipfox/api-agent-dto/inter-module';
|
|
12
8
|
import type {AgentToolCatalogEntry} from '@shipfox/api-integration-core';
|
|
9
|
+
import {createInterModuleKnownError} from '@shipfox/inter-module';
|
|
10
|
+
import type {AgentDefaultsResolver} from '#core/agent-defaults.js';
|
|
13
11
|
import type {AgentToolMaterializationContext} from '#core/agent-tools.js';
|
|
14
12
|
import {AgentConfigUnresolvableError, InterpolationUnresolvableError} from '#core/errors.js';
|
|
13
|
+
import {resolveTestAgentDefaults} from '#test/fixtures/agent-inter-module.js';
|
|
15
14
|
import {workflowModel} from '#test/index.js';
|
|
16
|
-
import {materializeJobExecutionSteps} from './materialize-job-execution-steps.js';
|
|
15
|
+
import {materializeJobExecutionSteps as materializeJobExecutionStepsImpl} from './materialize-job-execution-steps.js';
|
|
17
16
|
import type {WorkflowEvaluationContext} from './workflow-evaluation-context.js';
|
|
18
17
|
|
|
18
|
+
function materializeJobExecutionSteps(
|
|
19
|
+
params: Parameters<typeof materializeJobExecutionStepsImpl>[0],
|
|
20
|
+
): ReturnType<typeof materializeJobExecutionStepsImpl> {
|
|
21
|
+
return materializeJobExecutionStepsImpl({
|
|
22
|
+
resolveAgentDefaults: resolveTestAgentDefaults,
|
|
23
|
+
...params,
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
|
|
19
27
|
function template(source: string): string {
|
|
20
28
|
return `\${{ ${source} }}`;
|
|
21
29
|
}
|
|
@@ -150,7 +158,7 @@ function githubAgentToolCatalog(): readonly AgentToolCatalogEntry[] {
|
|
|
150
158
|
}
|
|
151
159
|
|
|
152
160
|
describe('materializeJobExecutionSteps', () => {
|
|
153
|
-
it('prepends setup and resolves job-execution context fields', () => {
|
|
161
|
+
it('prepends setup and resolves job-execution context fields', async () => {
|
|
154
162
|
const model = workflowModel({
|
|
155
163
|
jobs: {
|
|
156
164
|
review: {
|
|
@@ -167,7 +175,7 @@ describe('materializeJobExecutionSteps', () => {
|
|
|
167
175
|
const job = model.jobs[0];
|
|
168
176
|
if (!job) throw new Error('Expected workflow job');
|
|
169
177
|
|
|
170
|
-
const steps = materializeJobExecutionSteps({model, job, context: jobExecutionContext()});
|
|
178
|
+
const steps = await materializeJobExecutionSteps({model, job, context: jobExecutionContext()});
|
|
171
179
|
|
|
172
180
|
expect(steps).toEqual([
|
|
173
181
|
{
|
|
@@ -231,7 +239,7 @@ describe('materializeJobExecutionSteps', () => {
|
|
|
231
239
|
]);
|
|
232
240
|
});
|
|
233
241
|
|
|
234
|
-
it('freezes resolved agent integration tools with default connection, repo, and token scope', () => {
|
|
242
|
+
it('freezes resolved agent integration tools with default connection, repo, and token scope', async () => {
|
|
235
243
|
const model = workflowModel({
|
|
236
244
|
jobs: {
|
|
237
245
|
fix: {
|
|
@@ -256,7 +264,7 @@ describe('materializeJobExecutionSteps', () => {
|
|
|
256
264
|
const job = model.jobs[0];
|
|
257
265
|
if (!job) throw new Error('Expected workflow job');
|
|
258
266
|
|
|
259
|
-
const steps = materializeJobExecutionSteps({
|
|
267
|
+
const steps = await materializeJobExecutionSteps({
|
|
260
268
|
model,
|
|
261
269
|
job,
|
|
262
270
|
context: jobExecutionContext(),
|
|
@@ -333,7 +341,7 @@ describe('materializeJobExecutionSteps', () => {
|
|
|
333
341
|
]);
|
|
334
342
|
});
|
|
335
343
|
|
|
336
|
-
it('carries frozen integrations through the agent dispatch plan when prompt is deferred', () => {
|
|
344
|
+
it('carries frozen integrations through the agent dispatch plan when prompt is deferred', async () => {
|
|
337
345
|
const model = workflowModel({
|
|
338
346
|
jobs: {
|
|
339
347
|
fix: {
|
|
@@ -360,7 +368,7 @@ describe('materializeJobExecutionSteps', () => {
|
|
|
360
368
|
const job = model.jobs[0];
|
|
361
369
|
if (!job) throw new Error('Expected workflow job');
|
|
362
370
|
|
|
363
|
-
const steps = materializeJobExecutionSteps({
|
|
371
|
+
const steps = await materializeJobExecutionSteps({
|
|
364
372
|
model,
|
|
365
373
|
job,
|
|
366
374
|
context: jobExecutionContext(),
|
|
@@ -412,7 +420,7 @@ describe('materializeJobExecutionSteps', () => {
|
|
|
412
420
|
]);
|
|
413
421
|
});
|
|
414
422
|
|
|
415
|
-
it('throws a permanent interpolation error for available missing value paths', () => {
|
|
423
|
+
it('throws a permanent interpolation error for available missing value paths', async () => {
|
|
416
424
|
const model = workflowModel({
|
|
417
425
|
jobs: {
|
|
418
426
|
review: {
|
|
@@ -426,7 +434,7 @@ describe('materializeJobExecutionSteps', () => {
|
|
|
426
434
|
|
|
427
435
|
let error: unknown;
|
|
428
436
|
try {
|
|
429
|
-
materializeJobExecutionSteps({
|
|
437
|
+
await materializeJobExecutionSteps({
|
|
430
438
|
model,
|
|
431
439
|
job,
|
|
432
440
|
context: {...baseContext, values: {...baseContext.values, inputs: {}}},
|
|
@@ -444,10 +452,7 @@ describe('materializeJobExecutionSteps', () => {
|
|
|
444
452
|
});
|
|
445
453
|
});
|
|
446
454
|
|
|
447
|
-
it
|
|
448
|
-
new UnsupportedModelProviderError('unknown-provider'),
|
|
449
|
-
new InvalidAgentModelError('pi', 'anthropic', 'missing-model'),
|
|
450
|
-
])('wraps known resolver errors as permanent agent config errors', (cause) => {
|
|
455
|
+
it('wraps known resolver errors as permanent agent config errors', async () => {
|
|
451
456
|
const model = workflowModel({
|
|
452
457
|
jobs: {
|
|
453
458
|
review: {steps: [{prompt: 'Summarize the review.'}]},
|
|
@@ -456,7 +461,11 @@ describe('materializeJobExecutionSteps', () => {
|
|
|
456
461
|
const job = model.jobs[0];
|
|
457
462
|
if (!job) throw new Error('Expected workflow job');
|
|
458
463
|
const resolveAgentDefaults = vi.fn<AgentDefaultsResolver>().mockImplementation(() => {
|
|
459
|
-
throw
|
|
464
|
+
throw createInterModuleKnownError(
|
|
465
|
+
agentInterModuleContract.methods.resolveAgentConfig,
|
|
466
|
+
'agent-config-invalid',
|
|
467
|
+
{},
|
|
468
|
+
);
|
|
460
469
|
});
|
|
461
470
|
|
|
462
471
|
const materialize = () =>
|
|
@@ -468,11 +477,13 @@ describe('materializeJobExecutionSteps', () => {
|
|
|
468
477
|
definitionId: 'def-1',
|
|
469
478
|
});
|
|
470
479
|
|
|
471
|
-
expect(materialize).toThrow(AgentConfigUnresolvableError);
|
|
472
|
-
expect(materialize).toThrow(
|
|
480
|
+
await expect(materialize()).rejects.toThrow(AgentConfigUnresolvableError);
|
|
481
|
+
await expect(materialize()).rejects.toThrow(
|
|
482
|
+
'Agent configuration cannot be resolved for definition def-1',
|
|
483
|
+
);
|
|
473
484
|
});
|
|
474
485
|
|
|
475
|
-
it('throws a permanent interpolation error for unsafe run interpolation', () => {
|
|
486
|
+
it('throws a permanent interpolation error for unsafe run interpolation', async () => {
|
|
476
487
|
const model = workflowModel({
|
|
477
488
|
jobs: {
|
|
478
489
|
review: {steps: [{run: `echo \`${template('execution.index')}\``}]},
|
|
@@ -489,6 +500,6 @@ describe('materializeJobExecutionSteps', () => {
|
|
|
489
500
|
definitionId: 'def-1',
|
|
490
501
|
});
|
|
491
502
|
|
|
492
|
-
expect(materialize).toThrow(InterpolationUnresolvableError);
|
|
503
|
+
await expect(materialize()).rejects.toThrow(InterpolationUnresolvableError);
|
|
493
504
|
});
|
|
494
505
|
});
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
type AgentDefaultsResolver,
|
|
3
|
-
catalogDefaultAgentResolver,
|
|
4
|
-
} from '@shipfox/api-agent/core/resolve-agent-config';
|
|
5
|
-
import type {WorkflowModel} from '@shipfox/api-definitions';
|
|
1
|
+
import type {WorkflowModel} from '@shipfox/api-definitions-dto';
|
|
6
2
|
import type {WorkflowExpression} from '@shipfox/expression';
|
|
3
|
+
import type {AgentDefaultsResolver} from '#core/agent-defaults.js';
|
|
7
4
|
import type {
|
|
8
5
|
AgentToolMaterializationContext,
|
|
9
6
|
AgentToolMaterializationSnapshot,
|
|
@@ -57,14 +54,14 @@ const SETUP_STEP: MaterializedWorkflowStep = {
|
|
|
57
54
|
position: 0,
|
|
58
55
|
};
|
|
59
56
|
|
|
60
|
-
export function materializeJobExecutionSteps(
|
|
57
|
+
export async function materializeJobExecutionSteps(
|
|
61
58
|
params: MaterializeJobExecutionStepsParams,
|
|
62
|
-
): readonly MaterializedWorkflowStep[] {
|
|
59
|
+
): Promise<readonly MaterializedWorkflowStep[]> {
|
|
63
60
|
const {
|
|
64
61
|
model,
|
|
65
62
|
job,
|
|
66
63
|
context,
|
|
67
|
-
resolveAgentDefaults
|
|
64
|
+
resolveAgentDefaults,
|
|
68
65
|
definitionId = model.name,
|
|
69
66
|
agentToolContext,
|
|
70
67
|
agentToolSnapshot,
|
|
@@ -72,37 +69,39 @@ export function materializeJobExecutionSteps(
|
|
|
72
69
|
|
|
73
70
|
return [
|
|
74
71
|
SETUP_STEP,
|
|
75
|
-
...
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
72
|
+
...(await Promise.all(
|
|
73
|
+
job.steps.map(async (step, stepPosition) => {
|
|
74
|
+
// The trusted context exposes the stable job key; the authored display field remains `job.name`.
|
|
75
|
+
const stepContext = {...context.values, job: {key: job.key}};
|
|
76
|
+
const resolved = await resolveStepConfig({
|
|
77
|
+
jobKey: job.key,
|
|
78
|
+
step,
|
|
79
|
+
workflowEnv: model.env,
|
|
80
|
+
workflowEnvTemplates: model.templates?.env,
|
|
81
|
+
jobEnv: job.env,
|
|
82
|
+
jobEnvTemplates: job.templates?.env,
|
|
83
|
+
context: stepContext,
|
|
84
|
+
site: context.site,
|
|
85
|
+
resolveAgentDefaults,
|
|
86
|
+
definitionId,
|
|
87
|
+
agentToolContext,
|
|
88
|
+
agentToolSnapshot,
|
|
89
|
+
});
|
|
90
|
+
return {
|
|
91
|
+
key: step.key ?? null,
|
|
92
|
+
name: resolved.name ?? stepDisplayName(step),
|
|
93
|
+
sourceLocation: step.sourceLocation ?? null,
|
|
94
|
+
status: 'pending' as const,
|
|
95
|
+
type: step.kind,
|
|
96
|
+
config: resolved.config,
|
|
97
|
+
...(step.if === undefined ? {} : {condition: step.if}),
|
|
98
|
+
authoredConfig: resolved.authoredConfig,
|
|
99
|
+
...materializedConfigPlan(resolved.configPlan, resolved.trace),
|
|
100
|
+
...(resolved.diagnostics.length === 0 ? {} : {diagnostics: resolved.diagnostics}),
|
|
101
|
+
position: stepPosition + 1,
|
|
102
|
+
};
|
|
103
|
+
}),
|
|
104
|
+
)),
|
|
106
105
|
];
|
|
107
106
|
}
|
|
108
107
|
|