@shipfox/api-workflows 5.0.0 → 7.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (277) hide show
  1. package/.turbo/turbo-build.log +4 -4
  2. package/CHANGELOG.md +89 -0
  3. package/dist/core/agent-defaults.d.ts +17 -0
  4. package/dist/core/agent-defaults.d.ts.map +1 -0
  5. package/dist/core/agent-defaults.js +21 -0
  6. package/dist/core/agent-defaults.js.map +1 -0
  7. package/dist/core/agent-tool-capability-warning.d.ts +4 -0
  8. package/dist/core/agent-tool-capability-warning.d.ts.map +1 -1
  9. package/dist/core/agent-tool-capability-warning.js +15 -17
  10. package/dist/core/agent-tool-capability-warning.js.map +1 -1
  11. package/dist/core/agent-tools.d.ts +11 -9
  12. package/dist/core/agent-tools.d.ts.map +1 -1
  13. package/dist/core/agent-tools.js +23 -18
  14. package/dist/core/agent-tools.js.map +1 -1
  15. package/dist/core/checkout.d.ts +21 -7
  16. package/dist/core/checkout.d.ts.map +1 -1
  17. package/dist/core/checkout.js +23 -11
  18. package/dist/core/checkout.js.map +1 -1
  19. package/dist/core/entities/workflow-run-attempt.d.ts +1 -1
  20. package/dist/core/entities/workflow-run-attempt.d.ts.map +1 -1
  21. package/dist/core/entities/workflow-run-attempt.js.map +1 -1
  22. package/dist/core/job-execution.d.ts +3 -1
  23. package/dist/core/job-execution.d.ts.map +1 -1
  24. package/dist/core/job-execution.js +14 -12
  25. package/dist/core/job-execution.js.map +1 -1
  26. package/dist/core/job-transition/derive-job-execution-outputs.d.ts +1 -1
  27. package/dist/core/job-transition/derive-job-execution-outputs.d.ts.map +1 -1
  28. package/dist/core/job-transition/derive-job-execution-outputs.js.map +1 -1
  29. package/dist/core/job-transition/derive-job-success.js +1 -1
  30. package/dist/core/job-transition/derive-job-success.js.map +1 -1
  31. package/dist/core/listener-execution-materialization.d.ts +3 -3
  32. package/dist/core/listener-execution-materialization.d.ts.map +1 -1
  33. package/dist/core/listener-execution-materialization.js +3 -4
  34. package/dist/core/listener-execution-materialization.js.map +1 -1
  35. package/dist/core/run-workflow.d.ts +12 -1
  36. package/dist/core/run-workflow.d.ts.map +1 -1
  37. package/dist/core/run-workflow.js +13 -8
  38. package/dist/core/run-workflow.js.map +1 -1
  39. package/dist/core/step-config/agent.d.ts +8 -8
  40. package/dist/core/step-config/agent.d.ts.map +1 -1
  41. package/dist/core/step-config/agent.js +12 -10
  42. package/dist/core/step-config/agent.js.map +1 -1
  43. package/dist/core/step-config/complete-step-dispatch-config.d.ts +4 -4
  44. package/dist/core/step-config/complete-step-dispatch-config.d.ts.map +1 -1
  45. package/dist/core/step-config/complete-step-dispatch-config.js +2 -2
  46. package/dist/core/step-config/complete-step-dispatch-config.js.map +1 -1
  47. package/dist/core/step-config/materialize-job-execution-steps.d.ts +3 -3
  48. package/dist/core/step-config/materialize-job-execution-steps.d.ts.map +1 -1
  49. package/dist/core/step-config/materialize-job-execution-steps.js +5 -6
  50. package/dist/core/step-config/materialize-job-execution-steps.js.map +1 -1
  51. package/dist/core/step-config/materialize-workflow-model.d.ts +3 -3
  52. package/dist/core/step-config/materialize-workflow-model.d.ts.map +1 -1
  53. package/dist/core/step-config/materialize-workflow-model.js +4 -4
  54. package/dist/core/step-config/materialize-workflow-model.js.map +1 -1
  55. package/dist/core/step-config/resolve-job-execution-name.d.ts +1 -1
  56. package/dist/core/step-config/resolve-job-execution-name.d.ts.map +1 -1
  57. package/dist/core/step-config/resolve-job-execution-name.js.map +1 -1
  58. package/dist/core/step-config/resolve-step-config.d.ts +4 -4
  59. package/dist/core/step-config/resolve-step-config.d.ts.map +1 -1
  60. package/dist/core/step-config/resolve-step-config.js +6 -6
  61. package/dist/core/step-config/resolve-step-config.js.map +1 -1
  62. package/dist/core/step-config/run.d.ts +1 -1
  63. package/dist/core/step-config/run.d.ts.map +1 -1
  64. package/dist/core/step-config/run.js.map +1 -1
  65. package/dist/core/workflow-run-creation.d.ts +3 -3
  66. package/dist/core/workflow-run-creation.d.ts.map +1 -1
  67. package/dist/core/workflow-run-creation.js +3 -4
  68. package/dist/core/workflow-run-creation.js.map +1 -1
  69. package/dist/db/db.d.ts +16 -4
  70. package/dist/db/db.d.ts.map +1 -1
  71. package/dist/db/job-listeners.d.ts +7 -1
  72. package/dist/db/job-listeners.d.ts.map +1 -1
  73. package/dist/db/job-listeners.js +10 -5
  74. package/dist/db/job-listeners.js.map +1 -1
  75. package/dist/db/runner-lease-table.d.ts +5 -5
  76. package/dist/db/runner-lease-table.d.ts.map +1 -1
  77. package/dist/db/runner-lease-table.js +3 -2
  78. package/dist/db/runner-lease-table.js.map +1 -1
  79. package/dist/db/schema/workflow-run-attempts.d.ts +9 -3
  80. package/dist/db/schema/workflow-run-attempts.d.ts.map +1 -1
  81. package/dist/db/schema/workflow-run-attempts.js +2 -1
  82. package/dist/db/schema/workflow-run-attempts.js.map +1 -1
  83. package/dist/db/schema/workflow-runs.js +1 -1
  84. package/dist/db/schema/workflow-runs.js.map +1 -1
  85. package/dist/db/workflow-runs/job-executions.d.ts +5 -0
  86. package/dist/db/workflow-runs/job-executions.d.ts.map +1 -1
  87. package/dist/db/workflow-runs/job-executions.js +14 -7
  88. package/dist/db/workflow-runs/job-executions.js.map +1 -1
  89. package/dist/db/workflow-runs/jobs.d.ts.map +1 -1
  90. package/dist/db/workflow-runs/jobs.js +3 -1
  91. package/dist/db/workflow-runs/jobs.js.map +1 -1
  92. package/dist/db/workflow-runs/run-create.d.ts +9 -2
  93. package/dist/db/workflow-runs/run-create.d.ts.map +1 -1
  94. package/dist/db/workflow-runs/run-create.js +12 -9
  95. package/dist/db/workflow-runs/run-create.js.map +1 -1
  96. package/dist/db/workflow-runs/run-rerun.d.ts.map +1 -1
  97. package/dist/db/workflow-runs/run-rerun.js +3 -1
  98. package/dist/db/workflow-runs/run-rerun.js.map +1 -1
  99. package/dist/index.d.ts +18 -4
  100. package/dist/index.d.ts.map +1 -1
  101. package/dist/index.js +61 -37
  102. package/dist/index.js.map +1 -1
  103. package/dist/presentation/dto/checkout-token.d.ts +14 -1
  104. package/dist/presentation/dto/checkout-token.d.ts.map +1 -1
  105. package/dist/presentation/dto/checkout-token.js.map +1 -1
  106. package/dist/presentation/index.d.ts +1 -1
  107. package/dist/presentation/index.d.ts.map +1 -1
  108. package/dist/presentation/index.js +1 -1
  109. package/dist/presentation/index.js.map +1 -1
  110. package/dist/presentation/inter-module.d.ts +18 -0
  111. package/dist/presentation/inter-module.d.ts.map +1 -0
  112. package/dist/presentation/inter-module.js +113 -0
  113. package/dist/presentation/inter-module.js.map +1 -0
  114. package/dist/presentation/routes/agent-runtime-config.d.ts +6 -1
  115. package/dist/presentation/routes/agent-runtime-config.d.ts.map +1 -1
  116. package/dist/presentation/routes/agent-runtime-config.js +59 -57
  117. package/dist/presentation/routes/agent-runtime-config.js.map +1 -1
  118. package/dist/presentation/routes/cancel-run.d.ts +2 -1
  119. package/dist/presentation/routes/cancel-run.d.ts.map +1 -1
  120. package/dist/presentation/routes/cancel-run.js +37 -34
  121. package/dist/presentation/routes/cancel-run.js.map +1 -1
  122. package/dist/presentation/routes/checkout-token.d.ts +8 -1
  123. package/dist/presentation/routes/checkout-token.d.ts.map +1 -1
  124. package/dist/presentation/routes/checkout-token.js +65 -47
  125. package/dist/presentation/routes/checkout-token.js.map +1 -1
  126. package/dist/presentation/routes/get-run-aggregates.d.ts +2 -1
  127. package/dist/presentation/routes/get-run-aggregates.d.ts.map +1 -1
  128. package/dist/presentation/routes/get-run-aggregates.js +44 -53
  129. package/dist/presentation/routes/get-run-aggregates.js.map +1 -1
  130. package/dist/presentation/routes/get-run.d.ts +2 -1
  131. package/dist/presentation/routes/get-run.d.ts.map +1 -1
  132. package/dist/presentation/routes/get-run.js +53 -50
  133. package/dist/presentation/routes/get-run.js.map +1 -1
  134. package/dist/presentation/routes/get-step-secrets.d.ts +3 -1
  135. package/dist/presentation/routes/get-step-secrets.d.ts.map +1 -1
  136. package/dist/presentation/routes/get-step-secrets.js +72 -68
  137. package/dist/presentation/routes/get-step-secrets.js.map +1 -1
  138. package/dist/presentation/routes/index.d.ts +19 -2
  139. package/dist/presentation/routes/index.d.ts.map +1 -1
  140. package/dist/presentation/routes/index.js +38 -30
  141. package/dist/presentation/routes/index.js.map +1 -1
  142. package/dist/presentation/routes/leased-step.d.ts +2 -0
  143. package/dist/presentation/routes/leased-step.d.ts.map +1 -1
  144. package/dist/presentation/routes/leased-step.js +1 -2
  145. package/dist/presentation/routes/leased-step.js.map +1 -1
  146. package/dist/presentation/routes/list-run-attempts.d.ts +2 -1
  147. package/dist/presentation/routes/list-run-attempts.d.ts.map +1 -1
  148. package/dist/presentation/routes/list-run-attempts.js +29 -26
  149. package/dist/presentation/routes/list-run-attempts.js.map +1 -1
  150. package/dist/presentation/routes/list-runs.d.ts +2 -1
  151. package/dist/presentation/routes/list-runs.d.ts.map +1 -1
  152. package/dist/presentation/routes/list-runs.js +51 -60
  153. package/dist/presentation/routes/list-runs.js.map +1 -1
  154. package/dist/presentation/routes/next-step.d.ts +10 -1
  155. package/dist/presentation/routes/next-step.d.ts.map +1 -1
  156. package/dist/presentation/routes/next-step.js +64 -50
  157. package/dist/presentation/routes/next-step.js.map +1 -1
  158. package/dist/presentation/routes/project-access.d.ts +10 -0
  159. package/dist/presentation/routes/project-access.d.ts.map +1 -0
  160. package/dist/presentation/routes/project-access.js +17 -0
  161. package/dist/presentation/routes/project-access.js.map +1 -0
  162. package/dist/presentation/routes/report-step.d.ts +2 -1
  163. package/dist/presentation/routes/report-step.d.ts.map +1 -1
  164. package/dist/presentation/routes/report-step.js +62 -61
  165. package/dist/presentation/routes/report-step.js.map +1 -1
  166. package/dist/presentation/routes/require-accessible-run.d.ts +3 -1
  167. package/dist/presentation/routes/require-accessible-run.d.ts.map +1 -1
  168. package/dist/presentation/routes/require-accessible-run.js +3 -6
  169. package/dist/presentation/routes/require-accessible-run.js.map +1 -1
  170. package/dist/presentation/routes/rerun-run.d.ts +2 -1
  171. package/dist/presentation/routes/rerun-run.d.ts.map +1 -1
  172. package/dist/presentation/routes/rerun-run.js +46 -43
  173. package/dist/presentation/routes/rerun-run.js.map +1 -1
  174. package/dist/temporal/activities/index.d.ts +44 -9
  175. package/dist/temporal/activities/index.d.ts.map +1 -1
  176. package/dist/temporal/activities/index.js +13 -9
  177. package/dist/temporal/activities/index.js.map +1 -1
  178. package/dist/temporal/activities/orchestration-activities.d.ts +20 -11
  179. package/dist/temporal/activities/orchestration-activities.d.ts.map +1 -1
  180. package/dist/temporal/activities/orchestration-activities.js +48 -33
  181. package/dist/temporal/activities/orchestration-activities.js.map +1 -1
  182. package/dist/tsconfig.test.tsbuildinfo +1 -1
  183. package/package.json +28 -21
  184. package/src/core/agent-defaults.test.ts +28 -0
  185. package/src/core/agent-defaults.ts +36 -0
  186. package/src/core/agent-tool-capability-warning.test.ts +36 -11
  187. package/src/core/agent-tool-capability-warning.ts +27 -25
  188. package/src/core/agent-tools.ts +33 -36
  189. package/src/core/checkout.test.ts +38 -25
  190. package/src/core/checkout.ts +41 -14
  191. package/src/core/entities/workflow-run-attempt.ts +1 -1
  192. package/src/core/job-execution.ts +19 -9
  193. package/src/core/job-transition/derive-job-execution-outputs.ts +1 -1
  194. package/src/core/job-transition/derive-job-success.ts +1 -1
  195. package/src/core/listener-execution-materialization.test.ts +4 -2
  196. package/src/core/listener-execution-materialization.ts +6 -9
  197. package/src/core/run-workflow.test.ts +43 -38
  198. package/src/core/run-workflow.ts +26 -9
  199. package/src/core/step-config/agent.ts +24 -26
  200. package/src/core/step-config/complete-step-dispatch-config.test.ts +22 -23
  201. package/src/core/step-config/complete-step-dispatch-config.ts +6 -6
  202. package/src/core/step-config/materialize-job-execution-steps.test.ts +34 -23
  203. package/src/core/step-config/materialize-job-execution-steps.ts +38 -39
  204. package/src/core/step-config/materialize-workflow-model.test.ts +94 -82
  205. package/src/core/step-config/materialize-workflow-model.ts +31 -29
  206. package/src/core/step-config/resolve-job-execution-name.ts +1 -1
  207. package/src/core/step-config/resolve-step-config.ts +11 -9
  208. package/src/core/step-config/run.ts +1 -1
  209. package/src/core/workflow-run-creation.test.ts +14 -10
  210. package/src/core/workflow-run-creation.ts +6 -9
  211. package/src/db/job-listeners.ts +20 -5
  212. package/src/db/runner-lease-table.ts +2 -2
  213. package/src/db/schema/workflow-run-attempts.ts +7 -3
  214. package/src/db/schema/workflow-runs.ts +1 -1
  215. package/src/db/workflow-runs/job-executions.ts +15 -1
  216. package/src/db/workflow-runs/jobs.ts +4 -1
  217. package/src/db/workflow-runs/run-create.test.ts +7 -1
  218. package/src/db/workflow-runs/run-create.ts +25 -15
  219. package/src/db/workflow-runs/run-rerun.test.ts +1 -1
  220. package/src/db/workflow-runs/run-rerun.ts +6 -3
  221. package/src/index.ts +75 -33
  222. package/src/presentation/dto/checkout-token.ts +7 -1
  223. package/src/presentation/index.ts +1 -1
  224. package/src/presentation/inter-module.test.ts +149 -0
  225. package/src/presentation/inter-module.ts +132 -0
  226. package/src/presentation/routes/agent-runtime-config.test.ts +53 -10
  227. package/src/presentation/routes/agent-runtime-config.ts +89 -64
  228. package/src/presentation/routes/cancel-run.test.ts +10 -20
  229. package/src/presentation/routes/cancel-run.ts +30 -27
  230. package/src/presentation/routes/checkout-token.test.ts +52 -33
  231. package/src/presentation/routes/checkout-token.ts +109 -49
  232. package/src/presentation/routes/get-run-aggregates.test.ts +13 -7
  233. package/src/presentation/routes/get-run-aggregates.ts +54 -57
  234. package/src/presentation/routes/get-run.test.ts +10 -18
  235. package/src/presentation/routes/get-run.ts +51 -48
  236. package/src/presentation/routes/get-step-secrets.test.ts +29 -7
  237. package/src/presentation/routes/get-step-secrets.ts +72 -61
  238. package/src/presentation/routes/index.test.ts +16 -1
  239. package/src/presentation/routes/index.ts +54 -29
  240. package/src/presentation/routes/leased-step.ts +3 -2
  241. package/src/presentation/routes/list-run-attempts.test.ts +9 -19
  242. package/src/presentation/routes/list-run-attempts.ts +21 -18
  243. package/src/presentation/routes/list-runs.test.ts +13 -7
  244. package/src/presentation/routes/list-runs.ts +64 -67
  245. package/src/presentation/routes/next-step.test.ts +30 -11
  246. package/src/presentation/routes/next-step.ts +68 -48
  247. package/src/presentation/routes/project-access.ts +16 -0
  248. package/src/presentation/routes/report-step.test.ts +18 -2
  249. package/src/presentation/routes/report-step.ts +51 -49
  250. package/src/presentation/routes/require-accessible-run.ts +5 -2
  251. package/src/presentation/routes/rerun-run.test.ts +9 -19
  252. package/src/presentation/routes/rerun-run.ts +39 -36
  253. package/src/temporal/activities/index.ts +32 -12
  254. package/src/temporal/activities/orchestration-activities.test.ts +10 -8
  255. package/src/temporal/activities/orchestration-activities.ts +74 -50
  256. package/src/temporal/workflows/job-execution-orchestration.test.ts +47 -2
  257. package/test/env.ts +1 -3
  258. package/test/factories/project.ts +10 -5
  259. package/test/factories/workflow-model.test.ts +5 -1
  260. package/test/factories/workflow-model.ts +1 -1
  261. package/test/factories/workflow-run.ts +1 -1
  262. package/test/fixtures/agent-inter-module.ts +27 -0
  263. package/test/fixtures/annotations-inter-module.ts +5 -0
  264. package/test/fixtures/auth-inter-module.ts +22 -0
  265. package/test/fixtures/lease-token.ts +2 -1
  266. package/test/fixtures/projects-inter-module.ts +8 -0
  267. package/test/fixtures/runners-inter-module.ts +52 -0
  268. package/test/fixtures/secrets-inter-module.ts +61 -0
  269. package/test/globalSetup.ts +11 -11
  270. package/tsconfig.build.tsbuildinfo +1 -1
  271. package/dist/core/source-control.d.ts +0 -5
  272. package/dist/core/source-control.d.ts.map +0 -1
  273. package/dist/core/source-control.js +0 -19
  274. package/dist/core/source-control.js.map +0 -1
  275. package/src/core/source-control.test.ts +0 -17
  276. package/src/core/source-control.ts +0 -22
  277. package/src/temporal/workflows/job-execution-orchestration-timeout.test.ts +0 -165
@@ -1,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 new UnsupportedHarnessThinkingError('claude', 'off', [
315
- 'low',
316
- 'medium',
317
- 'high',
318
- 'xhigh',
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: AgentDefaultsResolver;
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.each([
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 cause;
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('Agent configuration cannot be resolved for definition def-1');
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 = catalogDefaultAgentResolver,
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
- ...job.steps.map((step, stepPosition) => {
76
- // The trusted context exposes the stable job key; the authored display field remains `job.name`.
77
- const stepContext = {...context.values, job: {key: job.key}};
78
- const resolved = resolveStepConfig({
79
- jobKey: job.key,
80
- step,
81
- workflowEnv: model.env,
82
- workflowEnvTemplates: model.templates?.env,
83
- jobEnv: job.env,
84
- jobEnvTemplates: job.templates?.env,
85
- context: stepContext,
86
- site: context.site,
87
- resolveAgentDefaults,
88
- definitionId,
89
- agentToolContext,
90
- agentToolSnapshot,
91
- });
92
- return {
93
- key: step.key ?? null,
94
- name: resolved.name ?? stepDisplayName(step),
95
- sourceLocation: step.sourceLocation ?? null,
96
- status: 'pending' as const,
97
- type: step.kind,
98
- config: resolved.config,
99
- ...(step.if === undefined ? {} : {condition: step.if}),
100
- authoredConfig: resolved.authoredConfig,
101
- ...materializedConfigPlan(resolved.configPlan, resolved.trace),
102
- ...(resolved.diagnostics.length === 0 ? {} : {diagnostics: resolved.diagnostics}),
103
- position: stepPosition + 1,
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