@shipfox/api-workflows 7.1.0 → 9.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 (153) hide show
  1. package/.turbo/turbo-build.log +4 -4
  2. package/CHANGELOG.md +80 -0
  3. package/dist/core/agent-defaults.d.ts +2 -1
  4. package/dist/core/agent-defaults.d.ts.map +1 -1
  5. package/dist/core/agent-defaults.js.map +1 -1
  6. package/dist/core/agent-tools.d.ts +5 -2
  7. package/dist/core/agent-tools.d.ts.map +1 -1
  8. package/dist/core/agent-tools.js.map +1 -1
  9. package/dist/core/checkout.d.ts +2 -2
  10. package/dist/core/checkout.d.ts.map +1 -1
  11. package/dist/core/checkout.js.map +1 -1
  12. package/dist/core/entities/step.d.ts +2 -1
  13. package/dist/core/entities/step.d.ts.map +1 -1
  14. package/dist/core/entities/step.js.map +1 -1
  15. package/dist/core/errors.d.ts +0 -4
  16. package/dist/core/errors.d.ts.map +1 -1
  17. package/dist/core/errors.js +0 -6
  18. package/dist/core/errors.js.map +1 -1
  19. package/dist/core/job-execution.d.ts +0 -2
  20. package/dist/core/job-execution.d.ts.map +1 -1
  21. package/dist/core/job-execution.js +3 -7
  22. package/dist/core/job-execution.js.map +1 -1
  23. package/dist/core/run-workflow.d.ts +2 -2
  24. package/dist/core/run-workflow.d.ts.map +1 -1
  25. package/dist/core/run-workflow.js.map +1 -1
  26. package/dist/core/step-config/agent.d.ts +1 -1
  27. package/dist/core/step-config/agent.d.ts.map +1 -1
  28. package/dist/core/step-config/agent.js.map +1 -1
  29. package/dist/db/job-listeners.d.ts +2 -2
  30. package/dist/db/job-listeners.d.ts.map +1 -1
  31. package/dist/db/job-listeners.js.map +1 -1
  32. package/dist/db/workflow-runs/job-executions.d.ts +0 -5
  33. package/dist/db/workflow-runs/job-executions.d.ts.map +1 -1
  34. package/dist/db/workflow-runs/job-executions.js +0 -7
  35. package/dist/db/workflow-runs/job-executions.js.map +1 -1
  36. package/dist/db/workflow-runs/run-create.d.ts +2 -2
  37. package/dist/db/workflow-runs/run-create.d.ts.map +1 -1
  38. package/dist/db/workflow-runs/run-create.js.map +1 -1
  39. package/dist/db/workflow-runs.d.ts +1 -1
  40. package/dist/db/workflow-runs.d.ts.map +1 -1
  41. package/dist/db/workflow-runs.js +1 -1
  42. package/dist/db/workflow-runs.js.map +1 -1
  43. package/dist/index.d.ts +2 -2
  44. package/dist/index.d.ts.map +1 -1
  45. package/dist/index.js +2 -1
  46. package/dist/index.js.map +1 -1
  47. package/dist/presentation/inter-module.d.ts +2 -2
  48. package/dist/presentation/inter-module.d.ts.map +1 -1
  49. package/dist/presentation/inter-module.js +2 -1
  50. package/dist/presentation/inter-module.js.map +1 -1
  51. package/dist/presentation/routes/cancel-run.d.ts +1 -1
  52. package/dist/presentation/routes/cancel-run.d.ts.map +1 -1
  53. package/dist/presentation/routes/cancel-run.js.map +1 -1
  54. package/dist/presentation/routes/checkout-token.d.ts +2 -2
  55. package/dist/presentation/routes/checkout-token.d.ts.map +1 -1
  56. package/dist/presentation/routes/checkout-token.js +1 -1
  57. package/dist/presentation/routes/checkout-token.js.map +1 -1
  58. package/dist/presentation/routes/get-run-aggregates.d.ts +1 -1
  59. package/dist/presentation/routes/get-run-aggregates.d.ts.map +1 -1
  60. package/dist/presentation/routes/get-run-aggregates.js.map +1 -1
  61. package/dist/presentation/routes/get-run.d.ts +1 -1
  62. package/dist/presentation/routes/get-run.d.ts.map +1 -1
  63. package/dist/presentation/routes/get-run.js.map +1 -1
  64. package/dist/presentation/routes/index.d.ts +2 -2
  65. package/dist/presentation/routes/index.d.ts.map +1 -1
  66. package/dist/presentation/routes/index.js.map +1 -1
  67. package/dist/presentation/routes/list-run-attempts.d.ts +1 -1
  68. package/dist/presentation/routes/list-run-attempts.d.ts.map +1 -1
  69. package/dist/presentation/routes/list-run-attempts.js.map +1 -1
  70. package/dist/presentation/routes/list-runs.d.ts +1 -1
  71. package/dist/presentation/routes/list-runs.d.ts.map +1 -1
  72. package/dist/presentation/routes/list-runs.js.map +1 -1
  73. package/dist/presentation/routes/next-step.d.ts.map +1 -1
  74. package/dist/presentation/routes/next-step.js +11 -8
  75. package/dist/presentation/routes/next-step.js.map +1 -1
  76. package/dist/presentation/routes/project-access.d.ts +1 -1
  77. package/dist/presentation/routes/project-access.d.ts.map +1 -1
  78. package/dist/presentation/routes/project-access.js.map +1 -1
  79. package/dist/presentation/routes/require-accessible-run.d.ts +1 -1
  80. package/dist/presentation/routes/require-accessible-run.d.ts.map +1 -1
  81. package/dist/presentation/routes/require-accessible-run.js.map +1 -1
  82. package/dist/presentation/routes/rerun-run.d.ts +1 -1
  83. package/dist/presentation/routes/rerun-run.d.ts.map +1 -1
  84. package/dist/presentation/routes/rerun-run.js.map +1 -1
  85. package/dist/temporal/activities/index.d.ts +2 -2
  86. package/dist/temporal/activities/index.d.ts.map +1 -1
  87. package/dist/temporal/activities/index.js.map +1 -1
  88. package/dist/temporal/activities/orchestration-activities.d.ts +2 -2
  89. package/dist/temporal/activities/orchestration-activities.d.ts.map +1 -1
  90. package/dist/temporal/activities/orchestration-activities.js.map +1 -1
  91. package/dist/tsconfig.test.tsbuildinfo +1 -1
  92. package/package.json +26 -28
  93. package/src/core/agent-defaults.ts +2 -1
  94. package/src/core/agent-tool-capability-warning.test.ts +26 -56
  95. package/src/core/agent-tools.ts +9 -7
  96. package/src/core/checkout.test.ts +2 -2
  97. package/src/core/checkout.ts +2 -2
  98. package/src/core/entities/step.ts +1 -2
  99. package/src/core/errors.ts +0 -7
  100. package/src/core/job-execution.ts +3 -10
  101. package/src/core/run-workflow.test.ts +22 -55
  102. package/src/core/run-workflow.ts +2 -2
  103. package/src/core/step-config/agent.ts +1 -1
  104. package/src/core/step-config/materialize-job-execution-steps.test.ts +1 -2
  105. package/src/core/step-config/materialize-workflow-model.test.ts +10 -13
  106. package/src/db/job-listeners.ts +2 -2
  107. package/src/db/workflow-runs/job-executions.ts +0 -21
  108. package/src/db/workflow-runs/run-create.test.ts +30 -23
  109. package/src/db/workflow-runs/run-create.ts +2 -2
  110. package/src/db/workflow-runs.ts +0 -1
  111. package/src/index.ts +3 -3
  112. package/src/presentation/dto/checkout-token.test.ts +7 -1
  113. package/src/presentation/inter-module.ts +4 -7
  114. package/src/presentation/routes/agent-runtime-config.test.ts +40 -132
  115. package/src/presentation/routes/cancel-run.test.ts +1 -1
  116. package/src/presentation/routes/cancel-run.ts +1 -1
  117. package/src/presentation/routes/checkout-token.test.ts +4 -37
  118. package/src/presentation/routes/checkout-token.ts +2 -2
  119. package/src/presentation/routes/get-run-aggregates.test.ts +1 -1
  120. package/src/presentation/routes/get-run-aggregates.ts +1 -1
  121. package/src/presentation/routes/get-run.test.ts +1 -1
  122. package/src/presentation/routes/get-run.ts +1 -1
  123. package/src/presentation/routes/get-step-secrets.test.ts +2 -2
  124. package/src/presentation/routes/index.test.ts +3 -3
  125. package/src/presentation/routes/index.ts +2 -2
  126. package/src/presentation/routes/list-run-attempts.test.ts +1 -1
  127. package/src/presentation/routes/list-run-attempts.ts +1 -1
  128. package/src/presentation/routes/list-runs.test.ts +1 -1
  129. package/src/presentation/routes/list-runs.ts +1 -1
  130. package/src/presentation/routes/next-step.test.ts +27 -69
  131. package/src/presentation/routes/next-step.ts +9 -5
  132. package/src/presentation/routes/project-access.ts +1 -1
  133. package/src/presentation/routes/report-step.test.ts +2 -3
  134. package/src/presentation/routes/require-accessible-run.ts +1 -1
  135. package/src/presentation/routes/rerun-run.test.ts +1 -1
  136. package/src/presentation/routes/rerun-run.ts +1 -1
  137. package/src/temporal/activities/index.ts +2 -2
  138. package/src/temporal/activities/orchestration-activities.ts +2 -2
  139. package/test/factories/workflow-model.ts +3 -1
  140. package/test/fixtures/active-lease-token.ts +5 -32
  141. package/test/fixtures/agent-inter-module.ts +32 -1
  142. package/test/fixtures/auth-inter-module.ts +2 -13
  143. package/test/fixtures/lease-token.ts +43 -29
  144. package/test/fixtures/projects-inter-module.ts +1 -1
  145. package/test/fixtures/runners-inter-module.ts +40 -48
  146. package/test/globalSetup.ts +0 -38
  147. package/test/setup.ts +2 -0
  148. package/tsconfig.build.tsbuildinfo +1 -1
  149. package/dist/db/runner-lease-table.d.ts +0 -469
  150. package/dist/db/runner-lease-table.d.ts.map +0 -1
  151. package/dist/db/runner-lease-table.js +0 -43
  152. package/dist/db/runner-lease-table.js.map +0 -1
  153. package/src/db/runner-lease-table.ts +0 -39
@@ -1,6 +1,6 @@
1
1
  $ shipfox-swc && shipfox-temporal-bundle dist/temporal/workflows/index.js
2
- Successfully compiled: 116 files with swc (840.1ms)
3
- 2026-07-22T13:13:07.556Z [INFO] asset workflow-bundle-21a9ae8beb3cb55dabc1.js 3.31 MiB [emitted] [immutable] (name: main)
2
+ Successfully compiled: 115 files with swc (525.67ms)
3
+ 2026-07-23T14:12:06.476Z [INFO] asset workflow-bundle-21a9ae8beb3cb55dabc1.js 3.31 MiB [emitted] [immutable] (name: main)
4
4
  orphan modules 33.5 KiB [orphan] 21 modules
5
5
  runtime modules 1.13 KiB 5 modules
6
6
  modules by path ../../../node_modules/.pnpm/ 970 KiB 196 modules
@@ -16,6 +16,6 @@ optional modules 30 bytes [optional]
16
16
  __temporal_custom_payload_converter (ignored) 15 bytes [optional] [built] [code generated]
17
17
  __temporal_custom_failure_converter (ignored) 15 bytes [optional] [built] [code generated]
18
18
  ../../shared/node/temporal/dist/workflow-error-interceptor.js 1.21 KiB [built] [code generated]
19
- webpack 5.107.2 compiled successfully in 9135 ms
20
- 2026-07-22T13:13:07.570Z [INFO] Workflow bundle created { size: '3.31MB' }
19
+ webpack 5.107.2 compiled successfully in 6964 ms
20
+ 2026-07-23T14:12:06.486Z [INFO] Workflow bundle created { size: '3.31MB' }
21
21
  /home/runner/work/shipfox/shipfox/libs/api/workflows/dist/temporal/workflows/index.js: 3470576 bytes
package/CHANGELOG.md CHANGED
@@ -1,5 +1,85 @@
1
1
  # @shipfox/api-workflows
2
2
 
3
+ ## 9.0.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 475ce59: Republishes all public packages after restoring release authorization.
8
+ - a041e25: Moves lease-state validation behind the Runners inter-module boundary.
9
+ - Updated dependencies [8436596]
10
+ - Updated dependencies [475ce59]
11
+ - Updated dependencies [154e03f]
12
+ - @shipfox/api-secrets-dto@9.0.1
13
+ - @shipfox/runner-labels@0.1.2
14
+ - @shipfox/expression@1.1.4
15
+ - @shipfox/workflow-document@2.1.2
16
+ - @shipfox/annotations-dto@9.0.1
17
+ - @shipfox/api-agent-dto@9.0.1
18
+ - @shipfox/api-auth-context@9.0.1
19
+ - @shipfox/api-auth-dto@9.0.1
20
+ - @shipfox/api-definitions-dto@9.0.1
21
+ - @shipfox/api-integration-core-dto@9.0.1
22
+ - @shipfox/api-projects-dto@9.0.1
23
+ - @shipfox/api-runners-dto@9.0.1
24
+ - @shipfox/api-workflows-dto@9.0.1
25
+ - @shipfox/inter-module@0.2.1
26
+ - @shipfox/node-drizzle@0.3.3
27
+ - @shipfox/node-error-monitoring@0.2.1
28
+ - @shipfox/node-fastify@0.3.1
29
+ - @shipfox/node-module@1.0.0
30
+ - @shipfox/node-opentelemetry@0.6.1
31
+ - @shipfox/node-outbox@0.2.5
32
+ - @shipfox/node-postgres@0.4.3
33
+ - @shipfox/node-temporal@0.4.1
34
+
35
+ ## 9.0.0
36
+
37
+ ### Patch Changes
38
+
39
+ - 074e7b3: Decouples workflow test fixtures from peer API implementations.
40
+ - 46aa52f: Closes remaining API package-boundary exceptions and moves model-provider policy behind the Agent implementation boundary.
41
+ - a9f9c57: Decouples Definitions and Workflows tests from peer implementation packages and databases.
42
+ - Updated dependencies [46aa52f]
43
+ - Updated dependencies [02974d6]
44
+ - Updated dependencies [4a6d124]
45
+ - @shipfox/api-agent-dto@9.0.0
46
+ - @shipfox/api-integration-core-dto@9.0.0
47
+ - @shipfox/api-secrets-dto@9.0.0
48
+ - @shipfox/api-auth-context@9.0.0
49
+ - @shipfox/annotations-dto@6.0.0
50
+ - @shipfox/api-auth-dto@7.1.0
51
+ - @shipfox/api-definitions-dto@6.0.0
52
+ - @shipfox/api-projects-dto@8.0.0
53
+ - @shipfox/api-runners-dto@7.0.1
54
+ - @shipfox/api-workflows-dto@9.0.0
55
+ - @shipfox/inter-module@0.2.0
56
+ - @shipfox/runner-labels@0.1.1
57
+ - @shipfox/expression@1.1.3
58
+ - @shipfox/node-drizzle@0.3.2
59
+ - @shipfox/node-error-monitoring@0.2.0
60
+ - @shipfox/node-fastify@0.3.0
61
+ - @shipfox/node-module@0.5.0
62
+ - @shipfox/node-opentelemetry@0.6.0
63
+ - @shipfox/node-outbox@0.2.4
64
+ - @shipfox/node-postgres@0.4.2
65
+ - @shipfox/node-temporal@0.4.0
66
+ - @shipfox/workflow-document@2.1.1
67
+
68
+ ## 8.0.0
69
+
70
+ ### Patch Changes
71
+
72
+ - de559bb: Moves Agent validation policy behind a versioned inter-module catalog and injects it into Definitions normalization.
73
+ - b15f3a7: Removes Auth implementation dependencies from consumer test boundaries.
74
+ - Updated dependencies [de559bb]
75
+ - Updated dependencies [b15f3a7]
76
+ - Updated dependencies [7f227c6]
77
+ - @shipfox/api-agent-dto@8.0.0
78
+ - @shipfox/api-runners@8.0.0
79
+ - @shipfox/api-integration-core-dto@8.0.0
80
+ - @shipfox/api-projects-dto@8.0.0
81
+ - @shipfox/api-workflows-dto@8.0.0
82
+
3
83
  ## 7.1.0
4
84
 
5
85
  ### Patch Changes
@@ -1,5 +1,6 @@
1
- import type { AgentThinking, Harness, ModelProviderRef } from '@shipfox/api-agent-dto';
1
+ import type { ModelProviderRef } from '@shipfox/api-agent-dto';
2
2
  import type { AgentInterModuleClient } from '@shipfox/api-agent-dto/inter-module';
3
+ import type { AgentThinking, Harness } from '@shipfox/workflow-document';
3
4
  export interface AgentDefaultsInput {
4
5
  readonly harness?: Harness | undefined;
5
6
  readonly provider?: ModelProviderRef | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"agent-defaults.d.ts","sourceRoot":"","sources":["../../src/core/agent-defaults.ts"],"names":[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QAAQ,CAAC,QAAQ,CAAC,EAAE,gBAAgB,GAAG,SAAS,CAAC;IACjD,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACpC,QAAQ,CAAC,QAAQ,CAAC,EAAE,aAAa,GAAG,SAAS,CAAC;CAC/C;AAED,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,QAAQ,EAAE,gBAAgB,CAAC;IACpC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,QAAQ,EAAE,aAAa,CAAC;CAClC;AAED,MAAM,MAAM,qBAAqB,GAAG,CAClC,KAAK,EAAE,kBAAkB,KACtB,qBAAqB,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAAC;AAE5D,wBAAgB,2BAA2B,CACzC,KAAK,EAAE,sBAAsB,EAC7B,WAAW,EAAE,MAAM,GAAG,IAAI,GACzB,qBAAqB,CAWvB"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/core/agent-defaults.ts"],"sourcesContent":["import type {AgentThinking, Harness, ModelProviderRef} from '@shipfox/api-agent-dto';\nimport type {AgentInterModuleClient} from '@shipfox/api-agent-dto/inter-module';\n\nexport interface AgentDefaultsInput {\n readonly harness?: Harness | undefined;\n readonly provider?: ModelProviderRef | undefined;\n readonly model?: string | undefined;\n readonly thinking?: AgentThinking | undefined;\n}\n\nexport interface ResolvedAgentDefaults {\n readonly harness: Harness;\n readonly provider: ModelProviderRef;\n readonly model: string;\n readonly thinking: AgentThinking;\n}\n\nexport type AgentDefaultsResolver = (\n input: AgentDefaultsInput,\n) => ResolvedAgentDefaults | Promise<ResolvedAgentDefaults>;\n\nexport function createAgentDefaultsResolver(\n agent: AgentInterModuleClient,\n workspaceId: string | null,\n): AgentDefaultsResolver {\n return async (config) =>\n await agent.resolveAgentConfig({\n workspaceId,\n config: {\n ...(config.harness === undefined ? {} : {harness: config.harness}),\n ...(config.provider === undefined ? {} : {provider: config.provider}),\n ...(config.model === undefined ? {} : {model: config.model}),\n ...(config.thinking === undefined ? {} : {thinking: config.thinking}),\n },\n });\n}\n"],"names":["createAgentDefaultsResolver","agent","workspaceId","config","resolveAgentConfig","harness","undefined","provider","model","thinking"],"mappings":"AAqBA,OAAO,SAASA,4BACdC,KAA6B,EAC7BC,WAA0B;IAE1B,OAAO,OAAOC,SACZ,MAAMF,MAAMG,kBAAkB,CAAC;YAC7BF;YACAC,QAAQ;gBACN,GAAIA,OAAOE,OAAO,KAAKC,YAAY,CAAC,IAAI;oBAACD,SAASF,OAAOE,OAAO;gBAAA,CAAC;gBACjE,GAAIF,OAAOI,QAAQ,KAAKD,YAAY,CAAC,IAAI;oBAACC,UAAUJ,OAAOI,QAAQ;gBAAA,CAAC;gBACpE,GAAIJ,OAAOK,KAAK,KAAKF,YAAY,CAAC,IAAI;oBAACE,OAAOL,OAAOK,KAAK;gBAAA,CAAC;gBAC3D,GAAIL,OAAOM,QAAQ,KAAKH,YAAY,CAAC,IAAI;oBAACG,UAAUN,OAAOM,QAAQ;gBAAA,CAAC;YACtE;QACF;AACJ"}
1
+ {"version":3,"sources":["../../src/core/agent-defaults.ts"],"sourcesContent":["import type {ModelProviderRef} from '@shipfox/api-agent-dto';\nimport type {AgentInterModuleClient} from '@shipfox/api-agent-dto/inter-module';\nimport type {AgentThinking, Harness} from '@shipfox/workflow-document';\n\nexport interface AgentDefaultsInput {\n readonly harness?: Harness | undefined;\n readonly provider?: ModelProviderRef | undefined;\n readonly model?: string | undefined;\n readonly thinking?: AgentThinking | undefined;\n}\n\nexport interface ResolvedAgentDefaults {\n readonly harness: Harness;\n readonly provider: ModelProviderRef;\n readonly model: string;\n readonly thinking: AgentThinking;\n}\n\nexport type AgentDefaultsResolver = (\n input: AgentDefaultsInput,\n) => ResolvedAgentDefaults | Promise<ResolvedAgentDefaults>;\n\nexport function createAgentDefaultsResolver(\n agent: AgentInterModuleClient,\n workspaceId: string | null,\n): AgentDefaultsResolver {\n return async (config) =>\n await agent.resolveAgentConfig({\n workspaceId,\n config: {\n ...(config.harness === undefined ? {} : {harness: config.harness}),\n ...(config.provider === undefined ? {} : {provider: config.provider}),\n ...(config.model === undefined ? {} : {model: config.model}),\n ...(config.thinking === undefined ? {} : {thinking: config.thinking}),\n },\n });\n}\n"],"names":["createAgentDefaultsResolver","agent","workspaceId","config","resolveAgentConfig","harness","undefined","provider","model","thinking"],"mappings":"AAsBA,OAAO,SAASA,4BACdC,KAA6B,EAC7BC,WAA0B;IAE1B,OAAO,OAAOC,SACZ,MAAMF,MAAMG,kBAAkB,CAAC;YAC7BF;YACAC,QAAQ;gBACN,GAAIA,OAAOE,OAAO,KAAKC,YAAY,CAAC,IAAI;oBAACD,SAASF,OAAOE,OAAO;gBAAA,CAAC;gBACjE,GAAIF,OAAOI,QAAQ,KAAKD,YAAY,CAAC,IAAI;oBAACC,UAAUJ,OAAOI,QAAQ;gBAAA,CAAC;gBACpE,GAAIJ,OAAOK,KAAK,KAAKF,YAAY,CAAC,IAAI;oBAACE,OAAOL,OAAOK,KAAK;gBAAA,CAAC;gBAC3D,GAAIL,OAAOM,QAAQ,KAAKH,YAAY,CAAC,IAAI;oBAACG,UAAUN,OAAOM,QAAQ;gBAAA,CAAC;YACtE;QACF;AACJ"}
@@ -1,12 +1,15 @@
1
1
  import type { MaterializedAgentIntegrationConfigDto } from '@shipfox/api-agent-dto';
2
2
  import type { WorkflowModel } from '@shipfox/api-definitions-dto';
3
- import type { AgentToolCatalogEntry, IntegrationProviderKind, IntegrationsModuleClient } from '@shipfox/api-integration-core-dto';
4
- import type { ProjectsModuleClient } from '@shipfox/api-projects-dto';
3
+ import type { IntegrationsModuleClient } from '@shipfox/api-integration-core-dto/inter-module';
4
+ import type { ProjectsModuleClient } from '@shipfox/api-projects-dto/inter-module';
5
5
  type WorkflowModelJob = WorkflowModel['jobs'][number];
6
6
  type WorkflowModelAgentStep = Extract<WorkflowModelJob['steps'][number], {
7
7
  kind: 'agent';
8
8
  }>;
9
9
  type WorkflowModelStepIntegration = NonNullable<WorkflowModelAgentStep['integrations']>[number];
10
+ type IntegrationsAgentToolsContext = Awaited<ReturnType<IntegrationsModuleClient['getAgentToolsContext']>>;
11
+ export type AgentToolCatalogEntry = IntegrationsAgentToolsContext['catalogs'][number]['tools'][number];
12
+ type IntegrationProviderKind = IntegrationsAgentToolsContext['catalogs'][number]['provider'];
10
13
  type AgentToolCatalogs = ReadonlyMap<IntegrationProviderKind, readonly AgentToolCatalogEntry[]>;
11
14
  type WorkspaceConnectionSnapshot = ReadonlyMap<string, {
12
15
  id: string;
@@ -1 +1 @@
1
- {"version":3,"file":"agent-tools.d.ts","sourceRoot":"","sources":["../../src/core/agent-tools.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,qCAAqC,EAEtC,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,8BAA8B,CAAC;AAChE,OAAO,KAAK,EACV,qBAAqB,EAErB,uBAAuB,EACvB,wBAAwB,EACzB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,KAAK,EAAC,oBAAoB,EAAC,MAAM,2BAA2B,CAAC;AAGpE,KAAK,gBAAgB,GAAG,aAAa,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC;AACtD,KAAK,sBAAsB,GAAG,OAAO,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,EAAE;IAAC,IAAI,EAAE,OAAO,CAAA;CAAC,CAAC,CAAC;AAC1F,KAAK,4BAA4B,GAAG,WAAW,CAAC,sBAAsB,CAAC,cAAc,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;AAChG,KAAK,iBAAiB,GAAG,WAAW,CAAC,uBAAuB,EAAE,SAAS,qBAAqB,EAAE,CAAC,CAAC;AAChG,KAAK,2BAA2B,GAAG,WAAW,CAC5C,MAAM,EACN;IACE,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,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,CAAC,EAAE,wBAAwB,GAAG,SAAS,CAAC;IAC7D,QAAQ,CAAC,QAAQ,CAAC,EAAE,oBAAoB,GAAG,SAAS,CAAC;IACrD,QAAQ,CAAC,IAAI,CAAC,EAAE,SAAS,gBAAgB,EAAE,GAAG,SAAS,CAAC;CACzD,GAAG,OAAO,CAAC,+BAA+B,GAAG,SAAS,CAAC,CAuCvD;AAED,wBAAgB,4BAA4B,CAAC,MAAM,EAAE;IACnD,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,YAAY,EAAE,SAAS,4BAA4B,EAAE,GAAG,SAAS,CAAC;IAC3E,QAAQ,CAAC,OAAO,EAAE,+BAA+B,GAAG,SAAS,CAAC;IAC9D,QAAQ,CAAC,QAAQ,CAAC,EAAE,gCAAgC,GAAG,IAAI,GAAG,SAAS,CAAC;CACzE,GAAG,qCAAqC,EAAE,GAAG,SAAS,CActD;AAED,wBAAgB,sCAAsC,CAAC,MAAM,EAAE;IAC7D,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAC;IAC9B,QAAQ,CAAC,OAAO,EAAE,+BAA+B,GAAG,SAAS,CAAC;CAC/D,GAAG,gCAAgC,GAAG,IAAI,CAwB1C"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/core/agent-tools.ts"],"sourcesContent":["import type {\n MaterializedAgentIntegrationConfigDto,\n MaterializedAgentIntegrationToolConfigDto,\n} from '@shipfox/api-agent-dto';\nimport type {WorkflowModel} from '@shipfox/api-definitions-dto';\nimport type {\n AgentToolCatalogEntry,\n AgentToolCatalogMethod,\n IntegrationProviderKind,\n IntegrationsModuleClient,\n} from '@shipfox/api-integration-core-dto';\nimport type {ProjectsModuleClient} from '@shipfox/api-projects-dto';\nimport {AgentIntegrationMaterializationError} from './errors.js';\n\ntype WorkflowModelJob = WorkflowModel['jobs'][number];\ntype WorkflowModelAgentStep = Extract<WorkflowModelJob['steps'][number], {kind: 'agent'}>;\ntype WorkflowModelStepIntegration = NonNullable<WorkflowModelAgentStep['integrations']>[number];\ntype AgentToolCatalogs = ReadonlyMap<IntegrationProviderKind, readonly AgentToolCatalogEntry[]>;\ntype WorkspaceConnectionSnapshot = ReadonlyMap<\n string,\n {\n id: string;\n provider: IntegrationProviderKind;\n capabilities: readonly ('source_control' | 'agent_tools')[];\n }\n>;\n\nexport interface AgentToolMaterializationContext {\n readonly catalogs: AgentToolCatalogs;\n readonly workspaceConnectionSnapshot: WorkspaceConnectionSnapshot;\n readonly defaultConnection: {\n readonly id: string;\n readonly slug: string;\n readonly provider: IntegrationProviderKind;\n };\n}\n\nexport interface AgentToolMaterializationSnapshot {\n readonly steps: readonly AgentToolMaterializationSnapshotStep[];\n}\n\nexport interface AgentToolMaterializationSnapshotStep {\n readonly jobKey: string;\n readonly stepId: string;\n readonly integrations: readonly MaterializedAgentIntegrationConfigDto[];\n}\n\ninterface SelectedToolState {\n readonly entry: AgentToolCatalogEntry;\n readonly methods: Map<string, AgentToolCatalogMethod>;\n selectedStandalone: boolean;\n}\n\nexport async function loadAgentToolMaterializationContext(params: {\n readonly model: WorkflowModel | null;\n readonly workspaceId: string;\n readonly projectId: string;\n readonly integrations?: IntegrationsModuleClient | undefined;\n readonly projects?: ProjectsModuleClient | undefined;\n readonly jobs?: readonly WorkflowModelJob[] | undefined;\n}): Promise<AgentToolMaterializationContext | undefined> {\n if (!modelHasAgentStepIntegrations(params.model, params.jobs)) return undefined;\n\n if (params.projects === undefined) {\n throw new AgentIntegrationMaterializationError('Project access is not configured');\n }\n const {project} = await params.projects.getProjectById({projectId: params.projectId});\n if (project === null) {\n throw new AgentIntegrationMaterializationError(\n `Project ${params.projectId} was not found while materializing agent integrations`,\n );\n }\n\n if (params.integrations === undefined) {\n throw new AgentIntegrationMaterializationError('Agent tool materialization is not configured');\n }\n const context = await params.integrations.getAgentToolsContext({\n workspaceId: params.workspaceId,\n defaultConnectionId: project.sourceConnectionId,\n });\n const workspaceConnectionSnapshot = new Map(\n context.workspaceConnections.map(({slug, ...connection}) => [slug, connection]),\n );\n const defaultConnection = context.defaultConnection;\n if (defaultConnection === null) {\n throw new AgentIntegrationMaterializationError(\n `Source connection ${project.sourceConnectionId} was not found while materializing agent integrations`,\n );\n }\n\n return {\n catalogs: new Map(context.catalogs.map(({provider, tools}) => [provider, tools])),\n workspaceConnectionSnapshot,\n defaultConnection: {\n id: defaultConnection.id,\n slug: defaultConnection.slug,\n provider: defaultConnection.provider,\n },\n };\n}\n\nexport function materializeAgentIntegrations(params: {\n readonly jobKey: string;\n readonly stepId: string;\n readonly integrations: readonly WorkflowModelStepIntegration[] | undefined;\n readonly context: AgentToolMaterializationContext | undefined;\n readonly snapshot?: AgentToolMaterializationSnapshot | null | undefined;\n}): MaterializedAgentIntegrationConfigDto[] | undefined {\n const snapshot = findSnapshotStep(params);\n if (snapshot !== undefined) return snapshot.integrations.map(copyMaterializedIntegration);\n if (params.integrations === undefined) return undefined;\n if (params.context === undefined) {\n throw new AgentIntegrationMaterializationError(\n 'Agent integrations require materialization context',\n );\n }\n const {context} = params;\n\n return params.integrations.map((integration) =>\n materializeAgentIntegration({integration, context}),\n );\n}\n\nexport function createAgentToolMaterializationSnapshot(params: {\n readonly model: WorkflowModel;\n readonly context: AgentToolMaterializationContext | undefined;\n}): AgentToolMaterializationSnapshot | null {\n if (params.context === undefined) return null;\n\n const steps = params.model.jobs.flatMap((job) =>\n job.steps.flatMap((step) => {\n if (step.kind !== 'agent' || step.integrations === undefined) return [];\n const integrations = materializeAgentIntegrations({\n jobKey: job.key,\n stepId: step.id,\n integrations: step.integrations,\n context: params.context,\n });\n if (integrations === undefined) return [];\n return [\n {\n jobKey: job.key,\n stepId: step.id,\n integrations,\n },\n ];\n }),\n );\n\n return steps.length === 0 ? null : {steps};\n}\n\nfunction findSnapshotStep(params: {\n readonly jobKey: string;\n readonly stepId: string;\n readonly snapshot?: AgentToolMaterializationSnapshot | null | undefined;\n}): AgentToolMaterializationSnapshotStep | undefined {\n return params.snapshot?.steps.find(\n (step) => step.jobKey === params.jobKey && step.stepId === params.stepId,\n );\n}\n\nfunction materializeAgentIntegration(params: {\n readonly integration: WorkflowModelStepIntegration;\n readonly context: AgentToolMaterializationContext;\n}): MaterializedAgentIntegrationConfigDto {\n const connection = resolveConnection(params);\n const catalog = params.context.catalogs.get(connection.provider);\n if (catalog === undefined) {\n throw new AgentIntegrationMaterializationError(\n `Integration provider ${connection.provider} has no agent tool catalog`,\n );\n }\n\n const tools = selectTools({\n catalog,\n include: params.integration.include,\n exclude: params.integration.exclude ?? [],\n });\n const requiredScope = mergeRequiredScopes(tools.map((tool) => tool.requiredScope));\n\n return {\n connectionId: connection.id,\n connectionSlug: connection.slug,\n provider: connection.provider,\n requiredScope,\n tools,\n };\n}\n\nfunction copyMaterializedIntegration(\n integration: MaterializedAgentIntegrationConfigDto,\n): MaterializedAgentIntegrationConfigDto {\n return {\n ...integration,\n requiredScope: [...integration.requiredScope],\n tools: integration.tools.map((tool) => ({\n ...tool,\n requiredScope: [...tool.requiredScope],\n ...(tool.methods === undefined\n ? {}\n : {\n methods: tool.methods.map((method) => ({\n ...method,\n requiredScope: [...method.requiredScope],\n })),\n }),\n })),\n };\n}\n\nfunction resolveConnection(params: {\n readonly integration: WorkflowModelStepIntegration;\n readonly context: AgentToolMaterializationContext;\n}): AgentToolMaterializationContext['defaultConnection'] {\n if (params.integration.connection === undefined) return params.context.defaultConnection;\n\n const connection = params.context.workspaceConnectionSnapshot.get(params.integration.connection);\n if (connection === undefined) {\n throw new AgentIntegrationMaterializationError(\n `Integration connection ${params.integration.connection} was not found while materializing agent integrations`,\n );\n }\n return {\n id: connection.id,\n slug: params.integration.connection,\n provider: connection.provider,\n };\n}\n\nfunction selectTools(params: {\n readonly catalog: readonly AgentToolCatalogEntry[];\n readonly include: readonly string[];\n readonly exclude: readonly string[];\n}): MaterializedAgentIntegrationToolConfigDto[] {\n const selected = new Map<string, SelectedToolState>();\n\n for (const token of params.include) {\n applySelection({catalog: params.catalog, selected, token, mode: 'include'});\n }\n for (const token of params.exclude) {\n applySelection({catalog: params.catalog, selected, token, mode: 'exclude'});\n }\n\n const tools = params.catalog.flatMap((entry) => {\n const state = selected.get(entry.id);\n if (state === undefined) return [];\n return [materializedTool(state)];\n });\n if (tools.length === 0) {\n throw new AgentIntegrationMaterializationError(\n 'Agent integration selection resolved to no tools',\n );\n }\n return tools;\n}\n\nfunction applySelection(params: {\n readonly catalog: readonly AgentToolCatalogEntry[];\n readonly selected: Map<string, SelectedToolState>;\n readonly token: string;\n readonly mode: 'include' | 'exclude';\n}): void {\n if (params.token === '*') {\n for (const entry of params.catalog) applyEntrySelection(params, entry);\n return;\n }\n\n const match = findCatalogSelection(params.catalog, params.token);\n if (match === undefined) {\n throw new AgentIntegrationMaterializationError(`Unknown integration tool: ${params.token}`);\n }\n applyEntrySelection(params, match.entry, match.method);\n}\n\nfunction applyEntrySelection(\n params: {\n readonly selected: Map<string, SelectedToolState>;\n readonly token: string;\n readonly mode: 'include' | 'exclude';\n },\n entry: AgentToolCatalogEntry,\n method?: AgentToolCatalogMethod | undefined,\n): void {\n if (params.mode === 'exclude') {\n excludeEntrySelection(params.selected, entry, method);\n return;\n }\n\n const state =\n params.selected.get(entry.id) ??\n ({entry, methods: new Map(), selectedStandalone: false} satisfies SelectedToolState);\n if (entry.methods === undefined) {\n state.selectedStandalone = true;\n } else if (method === undefined) {\n for (const candidate of entry.methods) state.methods.set(candidate.id, candidate);\n } else {\n state.methods.set(method.id, method);\n }\n params.selected.set(entry.id, state);\n}\n\nfunction excludeEntrySelection(\n selected: Map<string, SelectedToolState>,\n entry: AgentToolCatalogEntry,\n method?: AgentToolCatalogMethod | undefined,\n): void {\n if (method === undefined) {\n selected.delete(entry.id);\n return;\n }\n\n const state = selected.get(entry.id);\n if (state === undefined) return;\n state.methods.delete(method.id);\n if (!state.selectedStandalone && state.methods.size === 0) selected.delete(entry.id);\n}\n\nfunction findCatalogSelection(\n catalog: readonly AgentToolCatalogEntry[],\n token: string,\n):\n | {readonly entry: AgentToolCatalogEntry; readonly method?: AgentToolCatalogMethod | undefined}\n | undefined {\n const entry = catalog.find((candidate) => candidate.id === token);\n if (entry !== undefined) return {entry};\n\n const wildcardSuffix = '.*';\n if (token.endsWith(wildcardSuffix)) {\n const family = token.slice(0, -wildcardSuffix.length);\n const familyEntry = catalog.find((candidate) => candidate.id === family);\n return familyEntry === undefined ? undefined : {entry: familyEntry};\n }\n\n const dotIndex = token.indexOf('.');\n if (dotIndex < 1) return undefined;\n const family = token.slice(0, dotIndex);\n const methodId = token.slice(dotIndex + 1);\n const familyEntry = catalog.find((candidate) => candidate.id === family);\n const method = familyEntry?.methods?.find((candidate) => candidate.id === methodId);\n if (familyEntry === undefined || method === undefined) return undefined;\n return {entry: familyEntry, method};\n}\n\nfunction materializedTool(state: SelectedToolState): MaterializedAgentIntegrationToolConfigDto {\n if (state.entry.methods === undefined) {\n return {\n id: state.entry.id,\n sensitivity: state.entry.sensitivity,\n sensitive: state.entry.sensitive,\n requiredScope: normalizeRequiredScope(state.entry.requiredScope),\n inputSchema: state.entry.inputSchema,\n ...(state.entry.outputSchema === undefined ? {} : {outputSchema: state.entry.outputSchema}),\n };\n }\n\n const methods = state.entry.methods\n .filter((method) => state.methods.has(method.id))\n .map((method) => ({\n id: method.id,\n token: `${state.entry.id}.${method.id}`,\n description: method.description,\n sensitivity: method.sensitivity,\n sensitive: method.sensitive,\n requiredScope: normalizeRequiredScope(method.requiredScope),\n }));\n\n return {\n id: state.entry.id,\n sensitivity: methods.some((method) => method.sensitivity === 'write') ? 'write' : 'read',\n sensitive: methods.some((method) => method.sensitive),\n requiredScope: mergeRequiredScopes(methods.map((method) => method.requiredScope)),\n inputSchema: state.entry.inputSchema,\n ...(state.entry.outputSchema === undefined ? {} : {outputSchema: state.entry.outputSchema}),\n methods,\n };\n}\n\nfunction mergeRequiredScopes(scopes: readonly unknown[]): unknown[] {\n const items = scopes.flatMap(normalizeRequiredScope);\n if (items.every(isPermissionScope)) {\n const byPermission = new Map<string, 'read' | 'write'>();\n for (const item of items) {\n const existing = byPermission.get(item.permission);\n if (existing === 'write') continue;\n byPermission.set(item.permission, item.access);\n }\n return [...byPermission.entries()].map(([permission, access]) => ({permission, access}));\n }\n\n const deduped = new Map<string, unknown>();\n for (const item of items) deduped.set(JSON.stringify(item), item);\n return [...deduped.values()];\n}\n\nfunction normalizeRequiredScope(scope: unknown): unknown[] {\n return Array.isArray(scope) ? [...scope] : [scope];\n}\n\nfunction isPermissionScope(\n value: unknown,\n): value is {permission: string; access: 'read' | 'write'} {\n if (typeof value !== 'object' || value === null) return false;\n const candidate = value as {permission?: unknown; access?: unknown};\n return (\n typeof candidate.permission === 'string' &&\n (candidate.access === 'read' || candidate.access === 'write')\n );\n}\n\nfunction modelHasAgentStepIntegrations(\n model: WorkflowModel | null,\n jobs: readonly WorkflowModelJob[] | undefined,\n): boolean {\n if (model === null) return false;\n return (jobs ?? model.jobs).some((job) =>\n job.steps.some((step) => step.kind === 'agent' && step.integrations !== undefined),\n );\n}\n"],"names":["AgentIntegrationMaterializationError","loadAgentToolMaterializationContext","params","modelHasAgentStepIntegrations","model","jobs","undefined","projects","project","getProjectById","projectId","integrations","context","getAgentToolsContext","workspaceId","defaultConnectionId","sourceConnectionId","workspaceConnectionSnapshot","Map","workspaceConnections","map","slug","connection","defaultConnection","catalogs","provider","tools","id","materializeAgentIntegrations","snapshot","findSnapshotStep","copyMaterializedIntegration","integration","materializeAgentIntegration","createAgentToolMaterializationSnapshot","steps","flatMap","job","step","kind","jobKey","key","stepId","length","find","resolveConnection","catalog","get","selectTools","include","exclude","requiredScope","mergeRequiredScopes","tool","connectionId","connectionSlug","methods","method","selected","token","applySelection","mode","entry","state","materializedTool","applyEntrySelection","match","findCatalogSelection","excludeEntrySelection","selectedStandalone","candidate","set","delete","size","wildcardSuffix","endsWith","family","slice","familyEntry","dotIndex","indexOf","methodId","sensitivity","sensitive","normalizeRequiredScope","inputSchema","outputSchema","filter","has","description","some","scopes","items","every","isPermissionScope","byPermission","item","existing","permission","access","entries","deduped","JSON","stringify","values","scope","Array","isArray","value"],"mappings":"AAYA,SAAQA,oCAAoC,QAAO,cAAc;AAyCjE,OAAO,eAAeC,oCAAoCC,MAOzD;IACC,IAAI,CAACC,8BAA8BD,OAAOE,KAAK,EAAEF,OAAOG,IAAI,GAAG,OAAOC;IAEtE,IAAIJ,OAAOK,QAAQ,KAAKD,WAAW;QACjC,MAAM,IAAIN,qCAAqC;IACjD;IACA,MAAM,EAACQ,OAAO,EAAC,GAAG,MAAMN,OAAOK,QAAQ,CAACE,cAAc,CAAC;QAACC,WAAWR,OAAOQ,SAAS;IAAA;IACnF,IAAIF,YAAY,MAAM;QACpB,MAAM,IAAIR,qCACR,CAAC,QAAQ,EAAEE,OAAOQ,SAAS,CAAC,qDAAqD,CAAC;IAEtF;IAEA,IAAIR,OAAOS,YAAY,KAAKL,WAAW;QACrC,MAAM,IAAIN,qCAAqC;IACjD;IACA,MAAMY,UAAU,MAAMV,OAAOS,YAAY,CAACE,oBAAoB,CAAC;QAC7DC,aAAaZ,OAAOY,WAAW;QAC/BC,qBAAqBP,QAAQQ,kBAAkB;IACjD;IACA,MAAMC,8BAA8B,IAAIC,IACtCN,QAAQO,oBAAoB,CAACC,GAAG,CAAC,CAAC,EAACC,IAAI,EAAE,GAAGC,YAAW,GAAK;YAACD;YAAMC;SAAW;IAEhF,MAAMC,oBAAoBX,QAAQW,iBAAiB;IACnD,IAAIA,sBAAsB,MAAM;QAC9B,MAAM,IAAIvB,qCACR,CAAC,kBAAkB,EAAEQ,QAAQQ,kBAAkB,CAAC,qDAAqD,CAAC;IAE1G;IAEA,OAAO;QACLQ,UAAU,IAAIN,IAAIN,QAAQY,QAAQ,CAACJ,GAAG,CAAC,CAAC,EAACK,QAAQ,EAAEC,KAAK,EAAC,GAAK;gBAACD;gBAAUC;aAAM;QAC/ET;QACAM,mBAAmB;YACjBI,IAAIJ,kBAA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AEF,KAAKG,MAAM;QAC/C;QACA,OAAO;eAAIJ,aAAaK,OAAO;SAAG,CAAChF,GAAG,CAAC,CAAC,CAAC8E,YAAYC,OAAO,GAAM,CAAA;gBAACD;gBAAYC;YAAM,CAAA;IACvF;IAEA,MAAME,UAAU,IAAInF;IACpB,KAAK,MAAM8E,QAAQJ,MAAOS,QAAQ9B,GAAG,CAAC+B,KAAKC,SAAS,CAACP,OAAOA;IAC5D,OAAO;WAAIK,QAAQG,MAAM;KAAG;AAC9B;AAEA,SAASpB,uBAAuBqB,KAAc;IAC5C,OAAOC,MAAMC,OAAO,CAACF,SAAS;WAAIA;KAAM,GAAG;QAACA;KAAM;AACpD;AAEA,SAASX,kBACPc,KAAc;IAEd,IAAI,OAAOA,UAAU,YAAYA,UAAU,MAAM,OAAO;IACxD,MAAMtC,YAAYsC;IAClB,OACE,OAAOtC,UAAU4B,UAAU,KAAK,YAC/B5B,CAAAA,UAAU6B,MAAM,KAAK,UAAU7B,UAAU6B,MAAM,KAAK,OAAM;AAE/D;AAEA,SAAShG,8BACPC,KAA2B,EAC3BC,IAA6C;IAE7C,IAAID,UAAU,MAAM,OAAO;IAC3B,OAAO,AAACC,CAAAA,QAAQD,MAAMC,IAAI,AAAD,EAAGqF,IAAI,CAAC,CAACrD,MAChCA,IAAIF,KAAK,CAACuD,IAAI,CAAC,CAACpD,OAASA,KAAKC,IAAI,KAAK,WAAWD,KAAK3B,YAAY,KAAKL;AAE5E"}
1
+ {"version":3,"sources":["../../src/core/agent-tools.ts"],"sourcesContent":["import type {\n MaterializedAgentIntegrationConfigDto,\n MaterializedAgentIntegrationToolConfigDto,\n} from '@shipfox/api-agent-dto';\nimport type {WorkflowModel} from '@shipfox/api-definitions-dto';\nimport type {IntegrationsModuleClient} from '@shipfox/api-integration-core-dto/inter-module';\nimport type {ProjectsModuleClient} from '@shipfox/api-projects-dto/inter-module';\nimport {AgentIntegrationMaterializationError} from './errors.js';\n\ntype WorkflowModelJob = WorkflowModel['jobs'][number];\ntype WorkflowModelAgentStep = Extract<WorkflowModelJob['steps'][number], {kind: 'agent'}>;\ntype WorkflowModelStepIntegration = NonNullable<WorkflowModelAgentStep['integrations']>[number];\ntype IntegrationsAgentToolsContext = Awaited<\n ReturnType<IntegrationsModuleClient['getAgentToolsContext']>\n>;\nexport type AgentToolCatalogEntry =\n IntegrationsAgentToolsContext['catalogs'][number]['tools'][number];\ntype AgentToolCatalogMethod = NonNullable<AgentToolCatalogEntry['methods']>[number];\ntype IntegrationProviderKind = IntegrationsAgentToolsContext['catalogs'][number]['provider'];\ntype AgentToolCatalogs = ReadonlyMap<IntegrationProviderKind, readonly AgentToolCatalogEntry[]>;\ntype WorkspaceConnectionSnapshot = ReadonlyMap<\n string,\n {\n id: string;\n provider: IntegrationProviderKind;\n capabilities: readonly ('source_control' | 'agent_tools')[];\n }\n>;\n\nexport interface AgentToolMaterializationContext {\n readonly catalogs: AgentToolCatalogs;\n readonly workspaceConnectionSnapshot: WorkspaceConnectionSnapshot;\n readonly defaultConnection: {\n readonly id: string;\n readonly slug: string;\n readonly provider: IntegrationProviderKind;\n };\n}\n\nexport interface AgentToolMaterializationSnapshot {\n readonly steps: readonly AgentToolMaterializationSnapshotStep[];\n}\n\nexport interface AgentToolMaterializationSnapshotStep {\n readonly jobKey: string;\n readonly stepId: string;\n readonly integrations: readonly MaterializedAgentIntegrationConfigDto[];\n}\n\ninterface SelectedToolState {\n readonly entry: AgentToolCatalogEntry;\n readonly methods: Map<string, AgentToolCatalogMethod>;\n selectedStandalone: boolean;\n}\n\nexport async function loadAgentToolMaterializationContext(params: {\n readonly model: WorkflowModel | null;\n readonly workspaceId: string;\n readonly projectId: string;\n readonly integrations?: IntegrationsModuleClient | undefined;\n readonly projects?: ProjectsModuleClient | undefined;\n readonly jobs?: readonly WorkflowModelJob[] | undefined;\n}): Promise<AgentToolMaterializationContext | undefined> {\n if (!modelHasAgentStepIntegrations(params.model, params.jobs)) return undefined;\n\n if (params.projects === undefined) {\n throw new AgentIntegrationMaterializationError('Project access is not configured');\n }\n const {project} = await params.projects.getProjectById({projectId: params.projectId});\n if (project === null) {\n throw new AgentIntegrationMaterializationError(\n `Project ${params.projectId} was not found while materializing agent integrations`,\n );\n }\n\n if (params.integrations === undefined) {\n throw new AgentIntegrationMaterializationError('Agent tool materialization is not configured');\n }\n const context = await params.integrations.getAgentToolsContext({\n workspaceId: params.workspaceId,\n defaultConnectionId: project.sourceConnectionId,\n });\n const workspaceConnectionSnapshot = new Map(\n context.workspaceConnections.map(({slug, ...connection}) => [slug, connection]),\n );\n const defaultConnection = context.defaultConnection;\n if (defaultConnection === null) {\n throw new AgentIntegrationMaterializationError(\n `Source connection ${project.sourceConnectionId} was not found while materializing agent integrations`,\n );\n }\n\n return {\n catalogs: new Map(context.catalogs.map(({provider, tools}) => [provider, tools])),\n workspaceConnectionSnapshot,\n defaultConnection: {\n id: defaultConnection.id,\n slug: defaultConnection.slug,\n provider: defaultConnection.provider,\n },\n };\n}\n\nexport function materializeAgentIntegrations(params: {\n readonly jobKey: string;\n readonly stepId: string;\n readonly integrations: readonly WorkflowModelStepIntegration[] | undefined;\n readonly context: AgentToolMaterializationContext | undefined;\n readonly snapshot?: AgentToolMaterializationSnapshot | null | undefined;\n}): MaterializedAgentIntegrationConfigDto[] | undefined {\n const snapshot = findSnapshotStep(params);\n if (snapshot !== undefined) return snapshot.integrations.map(copyMaterializedIntegration);\n if (params.integrations === undefined) return undefined;\n if (params.context === undefined) {\n throw new AgentIntegrationMaterializationError(\n 'Agent integrations require materialization context',\n );\n }\n const {context} = params;\n\n return params.integrations.map((integration) =>\n materializeAgentIntegration({integration, context}),\n );\n}\n\nexport function createAgentToolMaterializationSnapshot(params: {\n readonly model: WorkflowModel;\n readonly context: AgentToolMaterializationContext | undefined;\n}): AgentToolMaterializationSnapshot | null {\n if (params.context === undefined) return null;\n\n const steps = params.model.jobs.flatMap((job) =>\n job.steps.flatMap((step) => {\n if (step.kind !== 'agent' || step.integrations === undefined) return [];\n const integrations = materializeAgentIntegrations({\n jobKey: job.key,\n stepId: step.id,\n integrations: step.integrations,\n context: params.context,\n });\n if (integrations === undefined) return [];\n return [\n {\n jobKey: job.key,\n stepId: step.id,\n integrations,\n },\n ];\n }),\n );\n\n return steps.length === 0 ? null : {steps};\n}\n\nfunction findSnapshotStep(params: {\n readonly jobKey: string;\n readonly stepId: string;\n readonly snapshot?: AgentToolMaterializationSnapshot | null | undefined;\n}): AgentToolMaterializationSnapshotStep | undefined {\n return params.snapshot?.steps.find(\n (step) => step.jobKey === params.jobKey && step.stepId === params.stepId,\n );\n}\n\nfunction materializeAgentIntegration(params: {\n readonly integration: WorkflowModelStepIntegration;\n readonly context: AgentToolMaterializationContext;\n}): MaterializedAgentIntegrationConfigDto {\n const connection = resolveConnection(params);\n const catalog = params.context.catalogs.get(connection.provider);\n if (catalog === undefined) {\n throw new AgentIntegrationMaterializationError(\n `Integration provider ${connection.provider} has no agent tool catalog`,\n );\n }\n\n const tools = selectTools({\n catalog,\n include: params.integration.include,\n exclude: params.integration.exclude ?? [],\n });\n const requiredScope = mergeRequiredScopes(tools.map((tool) => tool.requiredScope));\n\n return {\n connectionId: connection.id,\n connectionSlug: connection.slug,\n provider: connection.provider,\n requiredScope,\n tools,\n };\n}\n\nfunction copyMaterializedIntegration(\n integration: MaterializedAgentIntegrationConfigDto,\n): MaterializedAgentIntegrationConfigDto {\n return {\n ...integration,\n requiredScope: [...integration.requiredScope],\n tools: integration.tools.map((tool) => ({\n ...tool,\n requiredScope: [...tool.requiredScope],\n ...(tool.methods === undefined\n ? {}\n : {\n methods: tool.methods.map((method) => ({\n ...method,\n requiredScope: [...method.requiredScope],\n })),\n }),\n })),\n };\n}\n\nfunction resolveConnection(params: {\n readonly integration: WorkflowModelStepIntegration;\n readonly context: AgentToolMaterializationContext;\n}): AgentToolMaterializationContext['defaultConnection'] {\n if (params.integration.connection === undefined) return params.context.defaultConnection;\n\n const connection = params.context.workspaceConnectionSnapshot.get(params.integration.connection);\n if (connection === undefined) {\n throw new AgentIntegrationMaterializationError(\n `Integration connection ${params.integration.connection} was not found while materializing agent integrations`,\n );\n }\n return {\n id: connection.id,\n slug: params.integration.connection,\n provider: connection.provider,\n };\n}\n\nfunction selectTools(params: {\n readonly catalog: readonly AgentToolCatalogEntry[];\n readonly include: readonly string[];\n readonly exclude: readonly string[];\n}): MaterializedAgentIntegrationToolConfigDto[] {\n const selected = new Map<string, SelectedToolState>();\n\n for (const token of params.include) {\n applySelection({catalog: params.catalog, selected, token, mode: 'include'});\n }\n for (const token of params.exclude) {\n applySelection({catalog: params.catalog, selected, token, mode: 'exclude'});\n }\n\n const tools = params.catalog.flatMap((entry) => {\n const state = selected.get(entry.id);\n if (state === undefined) return [];\n return [materializedTool(state)];\n });\n if (tools.length === 0) {\n throw new AgentIntegrationMaterializationError(\n 'Agent integration selection resolved to no tools',\n );\n }\n return tools;\n}\n\nfunction applySelection(params: {\n readonly catalog: readonly AgentToolCatalogEntry[];\n readonly selected: Map<string, SelectedToolState>;\n readonly token: string;\n readonly mode: 'include' | 'exclude';\n}): void {\n if (params.token === '*') {\n for (const entry of params.catalog) applyEntrySelection(params, entry);\n return;\n }\n\n const match = findCatalogSelection(params.catalog, params.token);\n if (match === undefined) {\n throw new AgentIntegrationMaterializationError(`Unknown integration tool: ${params.token}`);\n }\n applyEntrySelection(params, match.entry, match.method);\n}\n\nfunction applyEntrySelection(\n params: {\n readonly selected: Map<string, SelectedToolState>;\n readonly token: string;\n readonly mode: 'include' | 'exclude';\n },\n entry: AgentToolCatalogEntry,\n method?: AgentToolCatalogMethod | undefined,\n): void {\n if (params.mode === 'exclude') {\n excludeEntrySelection(params.selected, entry, method);\n return;\n }\n\n const state =\n params.selected.get(entry.id) ??\n ({entry, methods: new Map(), selectedStandalone: false} satisfies SelectedToolState);\n if (entry.methods === undefined) {\n state.selectedStandalone = true;\n } else if (method === undefined) {\n for (const candidate of entry.methods) state.methods.set(candidate.id, candidate);\n } else {\n state.methods.set(method.id, method);\n }\n params.selected.set(entry.id, state);\n}\n\nfunction excludeEntrySelection(\n selected: Map<string, SelectedToolState>,\n entry: AgentToolCatalogEntry,\n method?: AgentToolCatalogMethod | undefined,\n): void {\n if (method === undefined) {\n selected.delete(entry.id);\n return;\n }\n\n const state = selected.get(entry.id);\n if (state === undefined) return;\n state.methods.delete(method.id);\n if (!state.selectedStandalone && state.methods.size === 0) selected.delete(entry.id);\n}\n\nfunction findCatalogSelection(\n catalog: readonly AgentToolCatalogEntry[],\n token: string,\n):\n | {readonly entry: AgentToolCatalogEntry; readonly method?: AgentToolCatalogMethod | undefined}\n | undefined {\n const entry = catalog.find((candidate) => candidate.id === token);\n if (entry !== undefined) return {entry};\n\n const wildcardSuffix = '.*';\n if (token.endsWith(wildcardSuffix)) {\n const family = token.slice(0, -wildcardSuffix.length);\n const familyEntry = catalog.find((candidate) => candidate.id === family);\n return familyEntry === undefined ? undefined : {entry: familyEntry};\n }\n\n const dotIndex = token.indexOf('.');\n if (dotIndex < 1) return undefined;\n const family = token.slice(0, dotIndex);\n const methodId = token.slice(dotIndex + 1);\n const familyEntry = catalog.find((candidate) => candidate.id === family);\n const method = familyEntry?.methods?.find((candidate) => candidate.id === methodId);\n if (familyEntry === undefined || method === undefined) return undefined;\n return {entry: familyEntry, method};\n}\n\nfunction materializedTool(state: SelectedToolState): MaterializedAgentIntegrationToolConfigDto {\n if (state.entry.methods === undefined) {\n return {\n id: state.entry.id,\n sensitivity: state.entry.sensitivity,\n sensitive: state.entry.sensitive,\n requiredScope: normalizeRequiredScope(state.entry.requiredScope),\n inputSchema: state.entry.inputSchema,\n ...(state.entry.outputSchema === undefined ? {} : {outputSchema: state.entry.outputSchema}),\n };\n }\n\n const methods = state.entry.methods\n .filter((method) => state.methods.has(method.id))\n .map((method) => ({\n id: method.id,\n token: `${state.entry.id}.${method.id}`,\n description: method.description,\n sensitivity: method.sensitivity,\n sensitive: method.sensitive,\n requiredScope: normalizeRequiredScope(method.requiredScope),\n }));\n\n return {\n id: state.entry.id,\n sensitivity: methods.some((method) => method.sensitivity === 'write') ? 'write' : 'read',\n sensitive: methods.some((method) => method.sensitive),\n requiredScope: mergeRequiredScopes(methods.map((method) => method.requiredScope)),\n inputSchema: state.entry.inputSchema,\n ...(state.entry.outputSchema === undefined ? {} : {outputSchema: state.entry.outputSchema}),\n methods,\n };\n}\n\nfunction mergeRequiredScopes(scopes: readonly unknown[]): unknown[] {\n const items = scopes.flatMap(normalizeRequiredScope);\n if (items.every(isPermissionScope)) {\n const byPermission = new Map<string, 'read' | 'write'>();\n for (const item of items) {\n const existing = byPermission.get(item.permission);\n if (existing === 'write') continue;\n byPermission.set(item.permission, item.access);\n }\n return [...byPermission.entries()].map(([permission, access]) => ({permission, access}));\n }\n\n const deduped = new Map<string, unknown>();\n for (const item of items) deduped.set(JSON.stringify(item), item);\n return [...deduped.values()];\n}\n\nfunction normalizeRequiredScope(scope: unknown): unknown[] {\n return Array.isArray(scope) ? [...scope] : [scope];\n}\n\nfunction isPermissionScope(\n value: unknown,\n): value is {permission: string; access: 'read' | 'write'} {\n if (typeof value !== 'object' || value === null) return false;\n const candidate = value as {permission?: unknown; access?: unknown};\n return (\n typeof candidate.permission === 'string' &&\n (candidate.access === 'read' || candidate.access === 'write')\n );\n}\n\nfunction modelHasAgentStepIntegrations(\n model: WorkflowModel | null,\n jobs: readonly WorkflowModelJob[] | undefined,\n): boolean {\n if (model === null) return false;\n return (jobs ?? model.jobs).some((job) =>\n job.steps.some((step) => step.kind === 'agent' && step.integrations !== undefined),\n );\n}\n"],"names":["AgentIntegrationMaterializationError","loadAgentToolMaterializationContext","params","modelHasAgentStepIntegrations","model","jobs","undefined","projects","project","getProjectById","projectId","integrations","context","getAgentToolsContext","workspaceId","defaultConnectionId","sourceConnectionId","workspaceConnectionSnapshot","Map","workspaceConnections","map","slug","connection","defaultConnection","catalogs","provider","tools","id","materializeAgentIntegrations","snapshot","findSnapshotStep","copyMaterializedIntegration","integration","materializeAgentIntegration","createAgentToolMaterializationSnapshot","steps","flatMap","job","step","kind","jobKey","key","stepId","length","find","resolveConnection","catalog","get","selectTools","include","exclude","requiredScope","mergeRequiredScopes","tool","connectionId","connectionSlug","methods","method","selected","token","applySelection","mode","entry","state","materializedTool","applyEntrySelection","match","findCatalogSelection","excludeEntrySelection","selectedStandalone","candidate","set","delete","size","wildcardSuffix","endsWith","family","slice","familyEntry","dotIndex","indexOf","methodId","sensitivity","sensitive","normalizeRequiredScope","inputSchema","outputSchema","filter","has","description","some","scopes","items","every","isPermissionScope","byPermission","item","existing","permission","access","entries","deduped","JSON","stringify","values","scope","Array","isArray","value"],"mappings":"AAOA,SAAQA,oCAAoC,QAAO,cAAc;AAgDjE,OAAO,eAAeC,oCAAoCC,MAOzD;IACC,IAAI,CAACC,8BAA8BD,OAAOE,KAAK,EAAEF,OAAOG,IAAI,GAAG,OAAOC;IAEtE,IAAIJ,OAAOK,QAAQ,KAAKD,WAAW;QACjC,MAAM,IAAIN,qCAAqC;IACjD;IACA,MAAM,EAACQ,OAAO,EAAC,GAAG,MAAMN,OAAOK,QAAQ,CAACE,cAAc,CAAC;QAACC,WAAWR,OAAOQ,SAAS;IAAA;IACnF,IAAIF,YAAY,MAAM;QACpB,MAAM,IAAIR,qCACR,CAAC,QAAQ,EAAEE,OAAOQ,SAAS,CAAC,qDAAqD,CAAC;IAEtF;IAEA,IAAIR,OAAOS,YAAY,KAAKL,WAAW;QACrC,MAAM,IAAIN,qCAAqC;IACjD;IACA,MAAMY,UAAU,MAAMV,OAAOS,YAAY,CAACE,oBAAoB,CAAC;QAC7DC,aAAaZ,OAAOY,WAAW;QAC/BC,qBAAqBP,QAAQQ,kBAAkB;IACjD;IACA,MAAMC,8BAA8B,IAAIC,IACtCN,QAAQO,oBAAoB,CAACC,GAAG,CAAC,CAAC,EAACC,IAAI,EAAE,GAAGC,YAAW,GAAK;YAACD;YAAMC;SAAW;IAEhF,MAAMC,oBAAoBX,QAAQW,iBAAiB;IACnD,IAAIA,sBAAsB,MAAM;Q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/api-integration-core-dto';
2
- import type { ProjectsModuleClient } from '@shipfox/api-projects-dto';
1
+ import type { IntegrationsModuleClient } from '@shipfox/api-integration-core-dto/inter-module';
2
+ import type { ProjectsModuleClient } from '@shipfox/api-projects-dto/inter-module';
3
3
  export interface CheckoutIntent {
4
4
  workspaceId: string;
5
5
  connectionId: string;
@@ -1 +1 @@
1
- {"version":3,"file":"checkout.d.ts","sourceRoot":"","sources":["../../src/core/checkout.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,wBAAwB,EAAC,MAAM,mCAAmC,CAAC;AAChF,OAAO,KAAK,EAAC,oBAAoB,EAAC,MAAM,2BAA2B,CAAC;AAQpE,MAAM,WAAW,cAAc;IAC7B,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,oBAAoB,EAAE,MAAM,CAAC;IAC7B,kBAAkB,EAAE,OAAO,CAAC;IAC5B,WAAW,EAAE;QAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAA;KAAC,CAAC;CAC3C;AAED;;;;GAIG;AACH,wBAAsB,qBAAqB,CACzC,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,oBAAoB,GAC7B,OAAO,CAAC,cAAc,CAAC,CAiBzB;AAED;;;;GAIG;AACH,wBAAsB,qBAAqB,CAAC,EAC1C,KAAK,EACL,YAAY,EACZ,QAAQ,GACT,EAAE;IACD,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,EAAE,wBAAwB,CAAC;IACvC,QAAQ,EAAE,oBAAoB,CAAC;CAChC,GAAG,OAAO,CAAC;IACV,IAAI,EAAE;QACJ,aAAa,EAAE,MAAM,CAAC;QACtB,GAAG,EAAE,MAAM,CAAC;QACZ,WAAW,CAAC,EAAE;YAAC,QAAQ,EAAE,MAAM,CAAC;YAAC,KAAK,EAAE,MAAM,CAAC;YAAC,SAAS,EAAE,IAAI,CAAA;SAAC,CAAC;QACjE,SAAS,CAAC,EAAE;YAAC,IAAI,EAAE,MA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,CAAC,CAwBD"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/core/checkout.ts"],"sourcesContent":["import type {IntegrationsModuleClient} from '@shipfox/api-integration-core-dto';\nimport type {ProjectsModuleClient} from '@shipfox/api-projects-dto';\nimport {getJobById, getWorkflowRunByAttemptId} from '#db/workflow-runs.js';\nimport {\n CheckoutIntentUnresolvedError,\n JobNotFoundError,\n WorkflowRunNotFoundError,\n} from './errors.js';\n\nexport interface CheckoutIntent {\n workspaceId: string;\n connectionId: string;\n externalRepositoryId: string;\n persistCredentials: boolean;\n permissions: {contents: 'read' | 'write'};\n}\n\n/**\n * Resolves what to check out for a job, keyed off the authoritative `jobId`\n * (`workflowRunId`/`workflowRunAttemptId`/`workspaceId` in the lease claim are informational).\n * Chain: job → attempt → run → project source metadata. Credential-free.\n */\nexport async function resolveCheckoutIntent(\n jobId: string,\n projects: ProjectsModuleClient,\n): Promise<CheckoutIntent> {\n const job = await getJobById(jobId);\n if (!job) throw new JobNotFoundError(jobId);\n\n const run = await getWorkflowRunByAttemptId(job.workflowRunAttemptId);\n if (!run) throw new WorkflowRunNotFoundError(job.workflowRunAttemptId);\n\n const {project} = await projects.getProjectById({projectId: run.projectId});\n if (project === null) throw new CheckoutIntentUnresolvedError(run.projectId);\n\n return {\n workspaceId: project.workspaceId,\n connectionId: project.sourceConnectionId,\n externalRepositoryId: project.sourceExternalRepositoryId,\n persistCredentials: job.checkout.persistCredentials,\n permissions: job.checkout.permissions,\n };\n}\n\n/**\n * Resolves the job's checkout intent and exchanges it for a short-lived,\n * scoped checkout spec. Omitting `ref` lets the provider use the repository's\n * default branch while preserving the JSON-only inter-module boundary.\n */\nexport async function createJobCheckoutSpec({\n jobId,\n integrations,\n projects,\n}: {\n jobId: string;\n integrations: IntegrationsModuleClient;\n projects: ProjectsModuleClient;\n}): Promise<{\n spec: {\n repositoryUrl: string;\n ref: string;\n credentials?: {username: string; token: string; expiresAt: Date};\n gitAuthor?: {name: string; email: string};\n };\n persistCredentials: boolean;\n}> {\n const intent = await resolveCheckoutIntent(jobId, projects);\n const response = await integrations.createCheckoutSpec({\n workspaceId: intent.workspaceId,\n connectionId: intent.connectionId,\n externalRepositoryId: intent.externalRepositoryId,\n permissions: intent.permissions,\n });\n const {credentials, gitAuthor, ...checkout} = response;\n return {\n spec: {\n ...checkout,\n ...(credentials\n ? {\n credentials: {\n ...credentials,\n expiresAt: new Date(credentials.expiresAt),\n },\n }\n : {}),\n ...(gitAuthor ? {gitAuthor} : {}),\n },\n persistCredentials: intent.persistCredentials,\n };\n}\n"],"names":["getJobById","getWorkflowRunByAttemptId","CheckoutIntentUnresolvedError","JobNotFoundError","WorkflowRunNotFoundError","resolveCheckoutIntent","jobId","projects","job","run","workflowRunAttemptId","project","getProjectById","projectId","workspaceId","connectionId","sourceConnectionId","externalRepositoryId","sourceExternalRepositoryId","persistCredentials","checkout","permissions","createJobCheckoutSpec","integrations","intent","response","createCheckoutSpec","credentials","gitAuthor","spec","expiresAt","Date"],"mappings":"AAEA,SAAQA,UAAU,EAAEC,yBAAyB,QAAO,uBAAuB;AAC3E,SACEC,6BAA6B,EAC7BC,gBAAgB,EAChBC,wBAAwB,QACnB,cAAc;AAUrB;;;;CAIC,GACD,OAAO,eAAeC,sBACpBC,KAAa,EACbC,QAA8B;IAE9B,MAAMC,MAAM,MAAMR,WAAWM;IAC7B,IAAI,CAACE,KAAK,MAAM,IAAIL,iBAAiBG;IAErC,MAAMG,MAAM,MAAMR,0BAA0BO,IAAIE,oBAAoB;IACpE,IAAI,CAACD,KAAK,MAAM,IAAIL,yBAAyBI,IAAIE,oBAAoB;IAErE,MAAM,EAACC,OAAO,EAAC,GAAG,MAAMJ,SAASK,cAAc,CAAC;QAACC,WAAWJ,IAAII,SAAS;IAAA;IACzE,IAAIF,YAAY,MAAM,MAAM,IAAIT,8BAA8BO,IAAII,SAAS;IAE3E,OAAO;QACLC,aAAaH,QAAQG,WAAW;QAChCC,cAAcJ,QAAQK,kBAAkB;QACxCC,sBAAsBN,QAAQO,0BAA0B;QACxDC,oBAAoBX,IAAIY,QAAQ,CAACD,kBAAkB;QACnDE,aAAab,IAAIY,QAAQ,CAACC,WAAW;IACvC;AACF;AAEA;;;;CAIC,GACD,OAAO,eAAeC,sBAAsB,EAC1ChB,KAAK,EACLiB,YAAY,EACZhB,QAAQ,EAKT;IASC,MAAMiB,SAAS,MAAMnB,sBAAsBC,OAAOC;IAClD,MAAMkB,WAAW,MAAMF,aAAaG,kBAAkB,CAAC;QACrDZ,aAAaU,OAAOV,WAAW;QAC/BC,cAAcS,OAAOT,YAAY;QACjCE,sBAAsBO,OAAOP,oBAAoB;QACjDI,aAAaG,OAAOH,WAAW;IACjC;IACA,MAAM,EAACM,WAAW,EAAEC,SAAS,EAAE,GAAGR,UAAS,GAAGK;IAC9C,OAAO;QACLI,MAAM;YACJ,GAAGT,QAAQ;YACX,GAAIO,cACA;gBACEA,aAAa;oBACX,GAAGA,WAAW;oBACdG,WAAW,IAAIC,KAAKJ,YAAYG,SAAS;gBAC3C;YACF,IACA,CAAC,CAAC;YACN,GAAIF,YAAY;gBAACA;YAAS,IAAI,CAAC,CAAC;QAClC;QACAT,oBAAoBK,OAAOL,kBAAkB;IAC/C;AACF"}
1
+ {"version":3,"sources":["../../src/core/checkout.ts"],"sourcesContent":["import type {IntegrationsModuleClient} from '@shipfox/api-integration-core-dto/inter-module';\nimport type {ProjectsModuleClient} from '@shipfox/api-projects-dto/inter-module';\nimport {getJobById, getWorkflowRunByAttemptId} from '#db/workflow-runs.js';\nimport {\n CheckoutIntentUnresolvedError,\n JobNotFoundError,\n WorkflowRunNotFoundError,\n} from './errors.js';\n\nexport interface CheckoutIntent {\n workspaceId: string;\n connectionId: string;\n externalRepositoryId: string;\n persistCredentials: boolean;\n permissions: {contents: 'read' | 'write'};\n}\n\n/**\n * Resolves what to check out for a job, keyed off the authoritative `jobId`\n * (`workflowRunId`/`workflowRunAttemptId`/`workspaceId` in the lease claim are informational).\n * Chain: job → attempt → run → project source metadata. Credential-free.\n */\nexport async function resolveCheckoutIntent(\n jobId: string,\n projects: ProjectsModuleClient,\n): Promise<CheckoutIntent> {\n const job = await getJobById(jobId);\n if (!job) throw new JobNotFoundError(jobId);\n\n const run = await getWorkflowRunByAttemptId(job.workflowRunAttemptId);\n if (!run) throw new WorkflowRunNotFoundError(job.workflowRunAttemptId);\n\n const {project} = await projects.getProjectById({projectId: run.projectId});\n if (project === null) throw new CheckoutIntentUnresolvedError(run.projectId);\n\n return {\n workspaceId: project.workspaceId,\n connectionId: project.sourceConnectionId,\n externalRepositoryId: project.sourceExternalRepositoryId,\n persistCredentials: job.checkout.persistCredentials,\n permissions: job.checkout.permissions,\n };\n}\n\n/**\n * Resolves the job's checkout intent and exchanges it for a short-lived,\n * scoped checkout spec. Omitting `ref` lets the provider use the repository's\n * default branch while preserving the JSON-only inter-module boundary.\n */\nexport async function createJobCheckoutSpec({\n jobId,\n integrations,\n projects,\n}: {\n jobId: string;\n integrations: IntegrationsModuleClient;\n projects: ProjectsModuleClient;\n}): Promise<{\n spec: {\n repositoryUrl: string;\n ref: string;\n credentials?: {username: string; token: string; expiresAt: Date};\n gitAuthor?: {name: string; email: string};\n };\n persistCredentials: boolean;\n}> {\n const intent = await resolveCheckoutIntent(jobId, projects);\n const response = await integrations.createCheckoutSpec({\n workspaceId: intent.workspaceId,\n connectionId: intent.connectionId,\n externalRepositoryId: intent.externalRepositoryId,\n permissions: intent.permissions,\n });\n const {credentials, gitAuthor, ...checkout} = response;\n return {\n spec: {\n ...checkout,\n ...(credentials\n ? {\n credentials: {\n ...credentials,\n expiresAt: new Date(credentials.expiresAt),\n },\n }\n : {}),\n ...(gitAuthor ? {gitAuthor} : {}),\n },\n persistCredentials: intent.persistCredentials,\n };\n}\n"],"names":["getJobById","getWorkflowRunByAttemptId","CheckoutIntentUnresolvedError","JobNotFoundError","WorkflowRunNotFoundError","resolveCheckoutIntent","jobId","projects","job","run","workflowRunAttemptId","project","getProjectById","projectId","workspaceId","connectionId","sourceConnectionId","externalRepositoryId","sourceExternalRepositoryId","persistCredentials","checkout","permissions","createJobCheckoutSpec","integrations","intent","response","createCheckoutSpec","credentials","gitAuthor","spec","expiresAt","Date"],"mappings":"AAEA,SAAQA,UAAU,EAAEC,yBAAyB,QAAO,uBAAuB;AAC3E,SACEC,6BAA6B,EAC7BC,gBAAgB,EAChBC,wBAAwB,QACnB,cAAc;AAUrB;;;;CAIC,GACD,OAAO,eAAeC,sBACpBC,KAAa,EACbC,QAA8B;IAE9B,MAAMC,MAAM,MAAMR,WAAWM;IAC7B,IAAI,CAACE,KAAK,MAAM,IAAIL,iBAAiBG;IAErC,MAAMG,MAAM,MAAMR,0BAA0BO,IAAIE,oBAAoB;IACpE,IAAI,CAACD,KAAK,MAAM,IAAIL,yBAAyBI,IAAIE,oBAAoB;IAErE,MAAM,EAACC,OAAO,EAAC,GAAG,MAAMJ,SAASK,cAAc,CAAC;QAACC,WAAWJ,IAAII,SAAS;IAAA;IACzE,IAAIF,YAAY,MAAM,MAAM,IAAIT,8BAA8BO,IAAII,SAAS;IAE3E,OAAO;QACLC,aAAaH,QAAQG,WAAW;QAChCC,cAAcJ,QAAQK,kBAAkB;QACxCC,sBAAsBN,QAAQO,0BAA0B;QACxDC,oBAAoBX,IAAIY,QAAQ,CAACD,kBAAkB;QACnDE,aAAab,IAAIY,QAAQ,CAACC,WAAW;IACvC;AACF;AAEA;;;;CAIC,GACD,OAAO,eAAeC,sBAAsB,EAC1ChB,KAAK,EACLiB,YAAY,EACZhB,QAAQ,EAKT;IASC,MAAMiB,SAAS,MAAMnB,sBAAsBC,OAAOC;IAClD,MAAMkB,WAAW,MAAMF,aAAaG,kBAAkB,CAAC;QACrDZ,aAAaU,OAAOV,WAAW;QAC/BC,cAAcS,OAAOT,YAAY;QACjCE,sBAAsBO,OAAOP,oBAAoB;QACjDI,aAAaG,OAAOH,WAAW;IACjC;IACA,MAAM,EAACM,WAAW,EAAEC,SAAS,EAAE,GAAGR,UAAS,GAAGK;IAC9C,OAAO;QACLI,MAAM;YACJ,GAAGT,QAAQ;YACX,GAAIO,cACA;gBACEA,aAAa;oBACX,GAAGA,WAAW;oBACdG,WAAW,IAAIC,KAAKJ,YAAYG,SAAS;gBAC3C;YACF,IACA,CAAC,CAAC;YACN,GAAIF,YAAY;gBAACA;YAAS,IAAI,CAAC,CAAC;QAClC;QACAT,oBAAoBK,OAAOL,kBAAkB;IAC/C;AACF"}
@@ -1,5 +1,6 @@
1
- import type { AgentIntegrationMcpServerConfigDto, AgentThinking, Harness, MaterializedAgentIntegrationConfigDto } from '@shipfox/api-agent-dto';
1
+ import type { AgentIntegrationMcpServerConfigDto, MaterializedAgentIntegrationConfigDto } from '@shipfox/api-agent-dto';
2
2
  import type { EvaluationTraceEntry, EvaluationTraceLimitEntry, ResolvedField, WorkflowExpression } from '@shipfox/expression';
3
+ import type { AgentThinking, Harness } from '@shipfox/workflow-document';
3
4
  import type { InterpolationUnresolvableField } from '../errors.js';
4
5
  export type StepStatus = 'pending' | 'running' | 'succeeded' | 'failed' | 'cancelled' | 'skipped';
5
6
  export declare const STEP_STATUS_REASONS: readonly ["default_gate_rejected", "condition_rejected", "condition_errored"];
@@ -1 +1 @@
1
- {"version":3,"file":"step.d.ts","sourceRoot":"","sources":["../../../src/core/entities/step.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,kCAAkC,EAClC,aAAa,EACb,OAAO,EACP,qCAAqC,EACtC,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EACV,oBAAoB,EACpB,yBAAyB,EACzB,aAAa,EACb,kBAAkB,EACnB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAC,8BAA8B,EAAC,MAAM,cAAc,CAAC;AAEjE,MAAM,MAAM,UAAU,GAAG,SAAS,GAAG,SAAS,GAAG,WAAW,GAAG,QAAQ,GAAG,WAAW,GAAG,SAAS,CAAC;AAElG,eAAO,MAAM,mBAAmB,+EAItB,CAAC;AAEX,MAAM,MAAM,gBAA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AAG,IAAI,CAAC;IACxB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IAC3C,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,UAAU,EAAE,qBAAqB,GAAG,IAAI,CAAC;IACzC,SAAS,EAAE,IAAI,CAAC;IAChB,UAAU,EAAE,IAAI,GAAG,IAAI,CAAC;IACxB,SAAS,EAAE,IAAI,CAAC;CACjB"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/core/entities/step.ts"],"sourcesContent":["import type {\n AgentIntegrationMcpServerConfigDto,\n AgentThinking,\n Harness,\n MaterializedAgentIntegrationConfigDto,\n} from '@shipfox/api-agent-dto';\nimport type {\n EvaluationTraceEntry,\n EvaluationTraceLimitEntry,\n ResolvedField,\n WorkflowExpression,\n} from '@shipfox/expression';\nimport type {InterpolationUnresolvableField} from '../errors.js';\n\nexport type StepStatus = 'pending' | 'running' | 'succeeded' | 'failed' | 'cancelled' | 'skipped';\n\nexport const STEP_STATUS_REASONS = [\n 'default_gate_rejected',\n 'condition_rejected',\n 'condition_errored',\n] as const;\n\nexport type StepStatusReason = (typeof STEP_STATUS_REASONS)[number];\n\nconst STEP_STATUS_REASON_SET = new Set<StepStatusReason>(STEP_STATUS_REASONS);\n\nexport function toStepStatusReason(value: string | null): StepStatusReason | null {\n if (value === null) return null;\n return STEP_STATUS_REASON_SET.has(value as StepStatusReason) ? (value as StepStatusReason) : null;\n}\n\nexport type StepAttemptLogOutcome = 'drained' | 'abandoned';\n\n// A step_attempts row exists only once an attempt is dispatched, so it is never\n// 'pending' or 'skipped'.\nexport type StepAttemptStatus = Exclude<StepStatus, 'pending' | 'skipped'>;\n\nexport interface StepSourceLocation {\n startLine: number;\n endLine: number;\n}\n\n/**\n * Trace entry after a resolver-local expression trace is attached to workflow\n * storage.\n *\n * Step config traces are stored on step attempts with the resolved attempt\n * config; job-level traces are stored on the job or job-execution row whose\n * value/status they explain. Keep `field` as the authored field path that\n * produced the trace, not as a step-only enum.\n */\nexport type PersistedEvaluationTraceEntry =\n | (EvaluationTraceEntry & {\n readonly field: string;\n readonly envKey?: string;\n })\n | EvaluationTraceLimitEntry;\n\nexport interface StepConfigEvaluationTraceEntry extends EvaluationTraceEntry {\n readonly field: InterpolationUnresolvableField;\n readonly envKey?: string;\n}\n\nexport interface StepConfigDispatchPlan {\n run?: ResolvedField;\n env?: Readonly<Record<string, ResolvedField>>;\n agent?: {\n prompt?: ResolvedField;\n model?: ResolvedField;\n provider?: ResolvedField;\n harness?: Harness;\n thinking?: AgentThinking;\n tools?: readonly string[];\n integrations?: readonly MaterializedAgentIntegrationConfigDto[];\n mcpServers?: readonly AgentIntegrationMcpServerConfigDto[];\n };\n trace?: readonly (StepConfigEvaluationTraceEntry | EvaluationTraceLimitEntry)[];\n}\n\nexport interface Step {\n id: string;\n jobExecutionId: string;\n key: string | null;\n name: string;\n sourceLocation: StepSourceLocation | null;\n status: StepStatus;\n statusReason: StepStatusReason | null;\n evaluationTrace: readonly PersistedEvaluationTraceEntry[] | null;\n type: string;\n config: Record<string, unknown>;\n condition: WorkflowExpression | null;\n configPlan: StepConfigDispatchPlan | null;\n authoredConfig: Record<string, unknown> | null;\n error: Record<string, unknown> | null;\n position: number;\n version: number;\n // Execution-attempt identity for the current projection: which attempt the\n // status/output/error above reflect. Distinct from `version` (the optimistic\n // row counter). Starts at 1 and is bumped when a step is rewound.\n currentAttempt: number;\n createdAt: Date;\n updatedAt: Date;\n}\n\n// Append-only execution history: one row per dispatched attempt of a step. The\n// current projection lives on `Step`; this is the audit trail and the\n// idempotency anchor (unique on (stepId, attempt)).\nexport interface StepAttempt {\n id: string;\n stepId: string;\n attempt: number;\n executionOrder: number;\n status: StepAttemptStatus;\n config: Record<string, unknown> | null;\n evaluationTrace: readonly PersistedEvaluationTraceEntry[] | null;\n output: Record<string, unknown> | null;\n response: string | null;\n error: Record<string, unknown> | null;\n exitCode: number | null;\n gateResult: Record<string, unknown> | null;\n restartFeedback: string | null;\n logOutcome: StepAttemptLogOutcome | null;\n startedAt: Date;\n finishedAt: Date | null;\n createdAt: Date;\n}\n"],"names":["STEP_STATUS_REASONS","STEP_STATUS_REASON_SET","Set","toStepStatusReason","value","has"],"mappings":"AAgBA,OAAO,MAAMA,sBAAsB;IACjC;IACA;IACA;CACD,CAAU;AAIX,MAAMC,yBAAyB,IAAIC,IAAsBF;AAEzD,OAAO,SAASG,mBAAmBC,KAAoB;IACrD,IAAIA,UAAU,MAAM,OAAO;IAC3B,OAAOH,uBAAuBI,GAAG,CAACD,SAA8BA,QAA6B;AAC/F"}
1
+ {"version":3,"sources":["../../../src/core/entities/step.ts"],"sourcesContent":["import type {\n AgentIntegrationMcpServerConfigDto,\n MaterializedAgentIntegrationConfigDto,\n} from '@shipfox/api-agent-dto';\nimport type {\n EvaluationTraceEntry,\n EvaluationTraceLimitEntry,\n ResolvedField,\n WorkflowExpression,\n} from '@shipfox/expression';\nimport type {AgentThinking, Harness} from '@shipfox/workflow-document';\nimport type {InterpolationUnresolvableField} from '../errors.js';\n\nexport type StepStatus = 'pending' | 'running' | 'succeeded' | 'failed' | 'cancelled' | 'skipped';\n\nexport const STEP_STATUS_REASONS = [\n 'default_gate_rejected',\n 'condition_rejected',\n 'condition_errored',\n] as const;\n\nexport type StepStatusReason = (typeof STEP_STATUS_REASONS)[number];\n\nconst STEP_STATUS_REASON_SET = new Set<StepStatusReason>(STEP_STATUS_REASONS);\n\nexport function toStepStatusReason(value: string | null): StepStatusReason | null {\n if (value === null) return null;\n return STEP_STATUS_REASON_SET.has(value as StepStatusReason) ? (value as StepStatusReason) : null;\n}\n\nexport type StepAttemptLogOutcome = 'drained' | 'abandoned';\n\n// A step_attempts row exists only once an attempt is dispatched, so it is never\n// 'pending' or 'skipped'.\nexport type StepAttemptStatus = Exclude<StepStatus, 'pending' | 'skipped'>;\n\nexport interface StepSourceLocation {\n startLine: number;\n endLine: number;\n}\n\n/**\n * Trace entry after a resolver-local expression trace is attached to workflow\n * storage.\n *\n * Step config traces are stored on step attempts with the resolved attempt\n * config; job-level traces are stored on the job or job-execution row whose\n * value/status they explain. Keep `field` as the authored field path that\n * produced the trace, not as a step-only enum.\n */\nexport type PersistedEvaluationTraceEntry =\n | (EvaluationTraceEntry & {\n readonly field: string;\n readonly envKey?: string;\n })\n | EvaluationTraceLimitEntry;\n\nexport interface StepConfigEvaluationTraceEntry extends EvaluationTraceEntry {\n readonly field: InterpolationUnresolvableField;\n readonly envKey?: string;\n}\n\nexport interface StepConfigDispatchPlan {\n run?: ResolvedField;\n env?: Readonly<Record<string, ResolvedField>>;\n agent?: {\n prompt?: ResolvedField;\n model?: ResolvedField;\n provider?: ResolvedField;\n harness?: Harness;\n thinking?: AgentThinking;\n tools?: readonly string[];\n integrations?: readonly MaterializedAgentIntegrationConfigDto[];\n mcpServers?: readonly AgentIntegrationMcpServerConfigDto[];\n };\n trace?: readonly (StepConfigEvaluationTraceEntry | EvaluationTraceLimitEntry)[];\n}\n\nexport interface Step {\n id: string;\n jobExecutionId: string;\n key: string | null;\n name: string;\n sourceLocation: StepSourceLocation | null;\n status: StepStatus;\n statusReason: StepStatusReason | null;\n evaluationTrace: readonly PersistedEvaluationTraceEntry[] | null;\n type: string;\n config: Record<string, unknown>;\n condition: WorkflowExpression | null;\n configPlan: StepConfigDispatchPlan | null;\n authoredConfig: Record<string, unknown> | null;\n error: Record<string, unknown> | null;\n position: number;\n version: number;\n // Execution-attempt identity for the current projection: which attempt the\n // status/output/error above reflect. Distinct from `version` (the optimistic\n // row counter). Starts at 1 and is bumped when a step is rewound.\n currentAttempt: number;\n createdAt: Date;\n updatedAt: Date;\n}\n\n// Append-only execution history: one row per dispatched attempt of a step. The\n// current projection lives on `Step`; this is the audit trail and the\n// idempotency anchor (unique on (stepId, attempt)).\nexport interface StepAttempt {\n id: string;\n stepId: string;\n attempt: number;\n executionOrder: number;\n status: StepAttemptStatus;\n config: Record<string, unknown> | null;\n evaluationTrace: readonly PersistedEvaluationTraceEntry[] | null;\n output: Record<string, unknown> | null;\n response: string | null;\n error: Record<string, unknown> | null;\n exitCode: number | null;\n gateResult: Record<string, unknown> | null;\n restartFeedback: string | null;\n logOutcome: StepAttemptLogOutcome | null;\n startedAt: Date;\n finishedAt: Date | null;\n createdAt: Date;\n}\n"],"names":["STEP_STATUS_REASONS","STEP_STATUS_REASON_SET","Set","toStepStatusReason","value","has"],"mappings":"AAeA,OAAO,MAAMA,sBAAsB;IACjC;IACA;IACA;CACD,CAAU;AAIX,MAAMC,yBAAyB,IAAIC,IAAsBF;AAEzD,OAAO,SAASG,mBAAmBC,KAAoB;IACrD,IAAIA,UAAU,MAAM,OAAO;IAC3B,OAAOH,uBAAuBI,GAAG,CAACD,SAA8BA,QAA6B;AAC/F"}
@@ -36,10 +36,6 @@ export declare function isPermanentRunWorkflowError(error: unknown): boolean;
36
36
  export declare class JobNotFoundError extends Error {
37
37
  constructor(jobId: string);
38
38
  }
39
- export declare class JobLeaseNotActiveError extends Error {
40
- readonly jobExecutionId: string;
41
- constructor(jobExecutionId: string);
42
- }
43
39
  export declare class InvalidJobRunnerLabelsError extends Error {
44
40
  readonly labels: readonly string[];
45
41
  constructor(labels: readonly string[]);
@@ -1 +1 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/core/errors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,mBAAmB,CAAC;AACjD,OAAO,KAAK,EAAC,iBAAiB,EAAC,MAAM,4BAA4B,CAAC;AAElE,qBAAa,uBAAwB,SAAQ,KAAK;gBACpC,YAAY,EAAE,MAAM;CAIjC;AAED,qBAAa,oBAAqB,SAAQ,KAAK;gBACjC,mBAAmB,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM;CAMlE;AAED,qBAAa,4BAA6B,SAAQ,KAAK;IAEnD,QAAQ,CAAC,YAAY,EAAE,MAAM;gBAApB,YAAY,EAAE,MAAM,EAC7B,OAAO,CAAC,EAAE,Y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AAK;IAExC,QAAQ,CAAC,KAAK,EAAE,MAAM;IACtB,QAAQ,CAAC,MAAM,EAAE,SAAS;gBADjB,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,SAAS;CAK7B;AAED,qBAAa,wBAAyB,SAAQ,KAAK;gBACrC,aAAa,EAAE,MAAM;CAIlC;AAED,qBAAa,8BAA+B,SAAQ,KAAK;IAErD,QAAQ,CAAC,aAAa,EAAE,MAAM;IAC9B,QAAQ,CAAC,MAAM,EAAE,iBAAiB;gBADzB,aAAa,EAAE,MAAM,EACrB,MAAM,EAAE,iBAAiB;CAKrC;AAED,qBAAa,sBAAuB,SAAQ,KAAK;gBACnC,aAAa,EAAE,MAAM;CAIlC;AAED,qBAAa,mBAAoB,SAAQ,KAAK;gBAChC,aAAa,EAAE,MAAM;CAIlC;AAED,qBAAa,iBAAkB,SAAQ,KAAK;gBAC9B,aAAa,EAAE,MAAM;CAIlC;AAID,qBAAa,6BAA8B,SAAQ,KAAK;gBAC1C,SAAS,EAAE,MAAM;CAI9B;AAED,qBAAa,iBAAkB,SAAQ,KAAK;gBAC9B,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM;CAI1C;AAED,qBAAa,mBAAoB,SAAQ,KAAK;gBAChC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM;CAI1C;AAKD,qBAAa,qBAAsB,SAAQ,KAAK;IAE5C,QAAQ,CAAC,MAAM,EAAE,MAAM;IACvB,QAAQ,CAAC,KAAK,EAAE,MAAM;IACtB,QAAQ,CAAC,eAAe,EAAE,MAAM;IAChC,QAAQ,CAAC,cAAc,EAAE,MAAM;gBAHtB,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,EACb,eAAe,EAAE,MAAM,EACvB,cAAc,EAAE,MAAM;CAOlC"}
@@ -51,12 +51,6 @@ export class JobNotFoundError extends Error {
51
51
  this.name = 'JobNotFoundError';
52
52
  }
53
53
  }
54
- export class JobLeaseNotActiveError extends Error {
55
- constructor(jobExecutionId){
56
- super(`Job lease is no longer active: ${jobExecutionId}`), this.jobExecutionId = jobExecutionId;
57
- this.name = 'JobLeaseNotActiveError';
58
- }
59
- }
60
54
  export class InvalidJobRunnerLabelsError extends Error {
61
55
  constructor(labels){
62
56
  super(`Job runner labels are invalid: ${labels.join(', ')}`), this.labels = labels;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/core/errors.ts"],"sourcesContent":["import type {JobStatus} from './entities/job.js';\nimport type {WorkflowRunStatus} from './entities/workflow-run.js';\n\nexport class DefinitionNotFoundError extends Error {\n constructor(definitionId: string) {\n super(`Definition not found: ${definitionId}`);\n this.name = 'DefinitionNotFoundError';\n }\n}\n\nexport class ProjectMismatchError extends Error {\n constructor(definitionProjectId: string, requestProjectId: string) {\n super(\n `Definition belongs to project ${definitionProjectId}, but request targets project ${requestProjectId}`,\n );\n this.name = 'ProjectMismatchError';\n }\n}\n\nexport class AgentConfigUnresolvableError extends Error {\n constructor(\n readonly definitionId: string,\n options?: ErrorOptions | undefined,\n ) {\n super(`Agent configuration cannot be resolved for definition ${definitionId}`, options);\n this.name = 'AgentConfigUnresolvableError';\n }\n}\n\nexport class AgentIntegrationMaterializationError extends Error {\n constructor(message: string) {\n super(message);\n this.name = 'AgentIntegrationMaterializationError';\n }\n}\n\nexport type InterpolationUnresolvableField =\n | 'run'\n | 'env'\n | 'agent.prompt'\n | 'agent.model'\n | 'agent.provider'\n | 'job.runner'\n | 'job.outputs'\n | 'job.name'\n | 'step.name'\n | 'step.feedback';\n\nexport class InterpolationUnresolvableError extends Error {\n readonly field: InterpolationUnresolvableField;\n readonly source: string;\n readonly envKey?: string;\n\n constructor(\n readonly definitionId: string,\n params: {\n readonly field: InterpolationUnresolvableField;\n readonly source: string;\n readonly envKey?: string;\n readonly cause?: unknown;\n },\n ) {\n super(interpolationUnresolvableMessage(definitionId, params), {cause: params.cause});\n this.name = 'InterpolationUnresolvableError';\n this.field = params.field;\n this.source = params.source;\n if (params.envKey !== undefined) this.envKey = params.envKey;\n }\n}\n\nfunction interpolationUnresolvableMessage(\n definitionId: string,\n params: {\n readonly field: InterpolationUnresolvableField;\n readonly source: string;\n readonly envKey?: string;\n },\n): string {\n const envSuffix = params.envKey === undefined ? '' : ` (${params.envKey})`;\n return `Workflow interpolation cannot be resolved for definition ${definitionId}: ${params.field}${envSuffix} uses \\`${params.source}\\`. Use has(x) ? x : '' for optional references.`;\n}\n\n/**\n * True when a `runWorkflow` failure can never succeed on retry: the definition is gone or\n * the subscription points at the wrong project. Callers (e.g. the trigger dispatcher) use this\n * to skip a permanently-broken target instead of retrying it forever. Every other failure is\n * treated as transient so at-least-once delivery can converge.\n */\nexport function isPermanentRunWorkflowError(error: unknown): boolean {\n return (\n error instanceof DefinitionNotFoundError ||\n error instanceof ProjectMismatchError ||\n error instanceof AgentConfigUnresolvableError ||\n error instanceof AgentIntegrationMaterializationError ||\n error instanceof InterpolationUnresolvableError ||\n error instanceof InvalidJobRunnerLabelsError\n );\n}\n\nexport class JobNotFoundError extends Error {\n constructor(jobId: string) {\n super(`Job not found or has no steps: ${jobId}`);\n this.name = 'JobNotFoundError';\n }\n}\n\nexport class JobLeaseNotActiveError extends Error {\n constructor(readonly jobExecutionId: string) {\n super(`Job lease is no longer active: ${jobExecutionId}`);\n this.name = 'JobLeaseNotActiveError';\n }\n}\n\nexport class InvalidJobRunnerLabelsError extends Error {\n constructor(readonly labels: readonly string[]) {\n super(`Job runner labels are invalid: ${labels.join(', ')}`);\n this.name = 'InvalidJobRunnerLabelsError';\n }\n}\n\n// The job named by a lease is terminal, so it must not exchange its lease for\n// fresh checkout credentials. Server state is the final gate, not the token.\nexport class JobNotActiveError extends Error {\n constructor(\n readonly jobId: string,\n readonly status: JobStatus,\n ) {\n super(`Job ${jobId} is ${status} and cannot mint checkout credentials`);\n this.name = 'JobNotActiveError';\n }\n}\n\nexport class WorkflowRunNotFoundError extends Error {\n constructor(workflowRunId: string) {\n super(`Workflow run not found: ${workflowRunId}`);\n this.name = 'WorkflowRunNotFoundError';\n }\n}\n\nexport class WorkflowRunNotCancellableError extends Error {\n constructor(\n readonly workflowRunId: string,\n readonly status: WorkflowRunStatus,\n ) {\n super(`Workflow run ${workflowRunId} is ${status} and cannot be cancelled`);\n this.name = 'WorkflowRunNotCancellableError';\n }\n}\n\nexport class SourceRunNotFoundError extends Error {\n constructor(workflowRunId: string) {\n super(`Source workflow run not found: ${workflowRunId}`);\n this.name = 'SourceRunNotFoundError';\n }\n}\n\nexport class RunNotTerminalError extends Error {\n constructor(workflowRunId: string) {\n super(`Workflow run is not terminal: ${workflowRunId}`);\n this.name = 'RunNotTerminalError';\n }\n}\n\nexport class NoFailedJobsError extends Error {\n constructor(workflowRunId: string) {\n super(`Workflow run has no failed or cancelled jobs to re-run: ${workflowRunId}`);\n this.name = 'NoFailedJobsError';\n }\n}\n\n// The run's project (and therefore its source repository) cannot be resolved, so\n// there is nothing to check out.\nexport class CheckoutIntentUnresolvedError extends Error {\n constructor(projectId: string) {\n super(`Checkout intent unresolved: project ${projectId} not found`);\n this.name = 'CheckoutIntentUnresolvedError';\n }\n}\n\nexport class StepNotFoundError extends Error {\n constructor(stepId: string, jobId: string) {\n super(`Step ${stepId} not found in job ${jobId}`);\n this.name = 'StepNotFoundError';\n }\n}\n\nexport class StepNotRunningError extends Error {\n constructor(stepId: string, jobId: string) {\n super(`Step ${stepId} in job ${jobId} is not running and cannot accept a result`);\n this.name = 'StepNotRunningError';\n }\n}\n\n// A report whose attempt is ahead of the step's current attempt. The host\n// allocates attempt numbers, so a runner can never report one it was not\n// dispatched — this is a protocol error, not an idempotent no-op.\nexport class StepAttemptAheadError extends Error {\n constructor(\n readonly stepId: string,\n readonly jobId: string,\n readonly reportedAttempt: number,\n readonly currentAttempt: number,\n ) {\n super(\n `Step ${stepId} in job ${jobId} reported attempt ${reportedAttempt} ahead of current attempt ${currentAttempt}`,\n );\n this.name = 'StepAttemptAheadError';\n }\n}\n"],"names":["DefinitionNotFoundError","Error","definitionId","name","ProjectMismatchError","definitionProjectId","requestProjectId","AgentConfigUnresolvableError","options","AgentIntegrationMaterializationError","message","InterpolationUnresolvableError","params","interpolationUnresolvableMessage","cause","field","source","envKey","undefined","envSuffix","isPermanentRunWorkflowError","error","InvalidJobRunnerLabelsError","JobNotFoundError","jobId","JobLeaseNotActiveError","jobExecutionId","labels","join","JobNotActiveError","status","WorkflowRunNotFoundError","workflowRunId","WorkflowRunNotCancellableError","SourceRunNotFoundError","RunNotTerminalError","NoFailedJobsError","CheckoutIntentUnresolvedError","projectId","StepNotFoundError","stepId","StepNotRunningError","StepAttemptAheadError","reportedAttempt","currentAttempt"],"mappings":"AAGA,OAAO,MAAMA,gCAAgCC;IAC3C,YAAYC,YAAoB,CAAE;QAChC,KAAK,CAAC,CAAC,sBAAsB,EAAEA,cAAc;QAC7C,IAAI,CAACC,IAAI,GAAG;IACd;AACF;AAEA,OAAO,MAAMC,6BAA6BH;IACxC,YAAYI,mBAA2B,EAAEC,gBAAwB,CAAE;QACjE,KAAK,CACH,CAAC,8BAA8B,EAAED,oBAAoB,8BAA8B,EAAEC,kBAAkB;QAEzG,IAAI,CAACH,IAAI,GAAG;IACd;AACF;AAEA,OAAO,MAAMI,qCAAqCN;IAChD,YACE,AAASC,YAAoB,EAC7BM,OAAkC,CAClC;QACA,KAAK,CAAC,CAAC,sDAAsD,EAAEN,cAAc,EAAEM,eAHtEN,eAAAA;QAIT,IAAI,CAACC,IAAI,GAAG;IACd;AACF;AAEA,OAAO,MAAMM,6CAA6CR;IACxD,YAAYS,OAAe,CAAE;QAC3B,KAAK,CAACA;QACN,IAAI,CAACP,IAAI,GAAG;IACd;AACF;AAcA,OAAO,MAAMQ,uCAAuCV;IAKlD,YACE,AAASC,YAAoB,EAC7BU,MAKC,CACD;QACA,KAAK,CAACC,iCAAiCX,cAAcU,SAAS;YAACE,OAAOF,OAAOE,KAAK;QAAA,SARzEZ,eAAAA;QAST,IAAI,CAACC,IAAI,GAAG;QACZ,IAAI,CAACY,KAAK,GA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K,CAAC,CAAC,KAAK,EAAEgB,OAAO,kBAAkB,EAAEhB,OAAO;QAChD,IAAI,CAACrB,IAAI,GAAG;IACd;AACF;AAEA,OAAO,MAAMsC,4BAA4BxC;IACvC,YAAYuC,MAAc,EAAEhB,KAAa,CAAE;QACzC,KAAK,CAAC,CAAC,KAAK,EAAEgB,OAAO,QAAQ,EAAEhB,MAAM,0CAA0C,CAAC;QAChF,IAAI,CAACrB,IAAI,GAAG;IACd;AACF;AAEA,0EAA0E;AAC1E,yEAAyE;AACzE,kEAAkE;AAClE,OAAO,MAAMuC,8BAA8BzC;IACzC,YACE,AAASuC,MAAc,EACvB,AAAShB,KAAa,EACtB,AAASmB,eAAuB,EAChC,AAASC,cAAsB,CAC/B;QACA,KAAK,CACH,CAAC,KAAK,EAAEJ,OAAO,QAAQ,EAAEhB,MAAM,kBAAkB,EAAEmB,gBAAgB,0BAA0B,EAAEC,gBAAgB,QANxGJ,SAAAA,aACAhB,QAAAA,YACAmB,kBAAAA,sBACAC,iBAAAA;QAKT,IAAI,CAACzC,IAAI,GAAG;IACd;AACF"}
1
+ {"version":3,"sources":["../../src/core/errors.ts"],"sourcesContent":["import type {JobStatus} from './entities/job.js';\nimport type {WorkflowRunStatus} from './entities/workflow-run.js';\n\nexport class DefinitionNotFoundError extends Error {\n constructor(definitionId: string) {\n super(`Definition not found: ${definitionId}`);\n this.name = 'DefinitionNotFoundError';\n }\n}\n\nexport class ProjectMismatchError extends Error {\n constructor(definitionProjectId: string, requestProjectId: string) {\n super(\n `Definition belongs to project ${definitionProjectId}, but request targets project ${requestProjectId}`,\n );\n this.name = 'ProjectMismatchError';\n }\n}\n\nexport class AgentConfigUnresolvableError extends Error {\n constructor(\n readonly definitionId: string,\n options?: ErrorOptions | undefined,\n ) {\n super(`Agent configuration cannot be resolved for definition ${definitionId}`, options);\n this.name = 'AgentConfigUnresolvableError';\n }\n}\n\nexport class AgentIntegrationMaterializationError extends Error {\n constructor(message: string) {\n super(message);\n this.name = 'AgentIntegrationMaterializationError';\n }\n}\n\nexport type InterpolationUnresolvableField =\n | 'run'\n | 'env'\n | 'agent.prompt'\n | 'agent.model'\n | 'agent.provider'\n | 'job.runner'\n | 'job.outputs'\n | 'job.name'\n | 'step.name'\n | 'step.feedback';\n\nexport class InterpolationUnresolvableError extends Error {\n readonly field: InterpolationUnresolvableField;\n readonly source: string;\n readonly envKey?: string;\n\n constructor(\n readonly definitionId: string,\n params: {\n readonly field: InterpolationUnresolvableField;\n readonly source: string;\n readonly envKey?: string;\n readonly cause?: unknown;\n },\n ) {\n super(interpolationUnresolvableMessage(definitionId, params), {cause: params.cause});\n this.name = 'InterpolationUnresolvableError';\n this.field = params.field;\n this.source = params.source;\n if (params.envKey !== undefined) this.envKey = params.envKey;\n }\n}\n\nfunction interpolationUnresolvableMessage(\n definitionId: string,\n params: {\n readonly field: InterpolationUnresolvableField;\n readonly source: string;\n readonly envKey?: string;\n },\n): string {\n const envSuffix = params.envKey === undefined ? '' : ` (${params.envKey})`;\n return `Workflow interpolation cannot be resolved for definition ${definitionId}: ${params.field}${envSuffix} uses \\`${params.source}\\`. Use has(x) ? x : '' for optional references.`;\n}\n\n/**\n * True when a `runWorkflow` failure can never succeed on retry: the definition is gone or\n * the subscription points at the wrong project. Callers (e.g. the trigger dispatcher) use this\n * to skip a permanently-broken target instead of retrying it forever. Every other failure is\n * treated as transient so at-least-once delivery can converge.\n */\nexport function isPermanentRunWorkflowError(error: unknown): boolean {\n return (\n error instanceof DefinitionNotFoundError ||\n error instanceof ProjectMismatchError ||\n error instanceof AgentConfigUnresolvableError ||\n error instanceof AgentIntegrationMaterializationError ||\n error instanceof InterpolationUnresolvableError ||\n error instanceof InvalidJobRunnerLabelsError\n );\n}\n\nexport class JobNotFoundError extends Error {\n constructor(jobId: string) {\n super(`Job not found or has no steps: ${jobId}`);\n this.name = 'JobNotFoundError';\n }\n}\n\nexport class InvalidJobRunnerLabelsError extends Error {\n constructor(readonly labels: readonly string[]) {\n super(`Job runner labels are invalid: ${labels.join(', ')}`);\n this.name = 'InvalidJobRunnerLabelsError';\n }\n}\n\n// The job named by a lease is terminal, so it must not exchange its lease for\n// fresh checkout credentials. Server state is the final gate, not the token.\nexport class JobNotActiveError extends Error {\n constructor(\n readonly jobId: string,\n readonly status: JobStatus,\n ) {\n super(`Job ${jobId} is ${status} and cannot mint checkout credentials`);\n this.name = 'JobNotActiveError';\n }\n}\n\nexport class WorkflowRunNotFoundError extends Error {\n constructor(workflowRunId: string) {\n super(`Workflow run not found: ${workflowRunId}`);\n this.name = 'WorkflowRunNotFoundError';\n }\n}\n\nexport class WorkflowRunNotCancellableError extends Error {\n constructor(\n readonly workflowRunId: string,\n readonly status: WorkflowRunStatus,\n ) {\n super(`Workflow run ${workflowRunId} is ${status} and cannot be cancelled`);\n this.name = 'WorkflowRunNotCancellableError';\n }\n}\n\nexport class SourceRunNotFoundError extends Error {\n constructor(workflowRunId: string) {\n super(`Source workflow run not found: ${workflowRunId}`);\n this.name = 'SourceRunNotFoundError';\n }\n}\n\nexport class RunNotTerminalError extends Error {\n constructor(workflowRunId: string) {\n super(`Workflow run is not terminal: ${workflowRunId}`);\n this.name = 'RunNotTerminalError';\n }\n}\n\nexport class NoFailedJobsError extends Error {\n constructor(workflowRunId: string) {\n super(`Workflow run has no failed or cancelled jobs to re-run: ${workflowRunId}`);\n this.name = 'NoFailedJobsError';\n }\n}\n\n// The run's project (and therefore its source repository) cannot be resolved, so\n// there is nothing to check out.\nexport class CheckoutIntentUnresolvedError extends Error {\n constructor(projectId: string) {\n super(`Checkout intent unresolved: project ${projectId} not found`);\n this.name = 'CheckoutIntentUnresolvedError';\n }\n}\n\nexport class StepNotFoundError extends Error {\n constructor(stepId: string, jobId: string) {\n super(`Step ${stepId} not found in job ${jobId}`);\n this.name = 'StepNotFoundError';\n }\n}\n\nexport class StepNotRunningError extends Error {\n constructor(stepId: string, jobId: string) {\n super(`Step ${stepId} in job ${jobId} is not running and cannot accept a result`);\n this.name = 'StepNotRunningError';\n }\n}\n\n// A report whose attempt is ahead of the step's current attempt. The host\n// allocates attempt numbers, so a runner can never report one it was not\n// dispatched — this is a protocol error, not an idempotent no-op.\nexport class StepAttemptAheadError extends Error {\n constructor(\n readonly stepId: string,\n readonly jobId: string,\n readonly reportedAttempt: number,\n readonly currentAttempt: number,\n ) {\n super(\n `Step ${stepId} in job ${jobId} reported attempt ${reportedAttempt} ahead of current attempt ${currentAttempt}`,\n );\n this.name = 'StepAttemptAheadError';\n }\n}\n"],"names":["DefinitionNotFoundError","Error","definitionId","name","ProjectMismatchError","definitionProjectId","requestProjectId","AgentConfigUnresolvableError","options","AgentIntegrationMaterializationError","message","InterpolationUnresolvableError","params","interpolationUnresolvableMessage","cause","field","source","envKey","undefined","envSuffix","isPermanentRunWorkflowError","error","InvalidJobRunnerLabelsError","JobNotFoundError","jobId","labels","join","JobNotActiveError","status","WorkflowRunNotFoundError","workflowRunId","WorkflowRunNotCancellableError","SourceRunNotFoundError","RunNotTerminalError","NoFailedJobsError","CheckoutIntentUnresolvedError","projectId","StepNotFoundError","stepId","StepNotRunningError","StepAttemptAheadError","reportedAttempt","currentAttempt"],"mappings":"AAGA,OAAO,MAAMA,gCAAgCC;IAC3C,YAAYC,YAAoB,CAAE;QAChC,KAAK,CAAC,CAAC,sBAAsB,EAAEA,cAAc;QAC7C,IAAI,CAACC,IAAI,GAAG;IACd;AACF;AAEA,OAAO,MAAMC,6BAA6BH;IACxC,YAAYI,mBAA2B,EAAEC,gBAAwB,CAAE;QACjE,KAAK,CACH,CAAC,8BAA8B,EAAED,oBAAoB,8BAA8B,EAAEC,kBAAkB;QAEzG,IAAI,CAACH,IAAI,GAAG;IACd;AACF;AAEA,OAAO,MAAMI,qCAAqCN;IAChD,YACE,AAASC,YAAoB,EAC7BM,OAAkC,CAClC;QACA,KAAK,CAAC,CAAC,sDAAsD,EAAEN,cAAc,EAAEM,eAHtEN,eAAAA;QAIT,IAAI,CAACC,IAAI,GAAG;IACd;AACF;AAEA,OAAO,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EA,UAAU,UAAU,CAAC;QAClE,IAAI,CAACjC,IAAI,GAAG;IACd;AACF;AAEA,OAAO,MAAMkC,0BAA0BpC;IACrC,YAAYqC,MAAc,EAAEd,KAAa,CAAE;QACzC,KAAK,CAAC,CAAC,KAAK,EAAEc,OAAO,kBAAkB,EAAEd,OAAO;QAChD,IAAI,CAACrB,IAAI,GAAG;IACd;AACF;AAEA,OAAO,MAAMoC,4BAA4BtC;IACvC,YAAYqC,MAAc,EAAEd,KAAa,CAAE;QACzC,KAAK,CAAC,CAAC,KAAK,EAAEc,OAAO,QAAQ,EAAEd,MAAM,0CAA0C,CAAC;QAChF,IAAI,CAACrB,IAAI,GAAG;IACd;AACF;AAEA,0EAA0E;AAC1E,yEAAyE;AACzE,kEAAkE;AAClE,OAAO,MAAMqC,8BAA8BvC;IACzC,YACE,AAASqC,MAAc,EACvB,AAASd,KAAa,EACtB,AAASiB,eAAuB,EAChC,AAASC,cAAsB,CAC/B;QACA,KAAK,CACH,CAAC,KAAK,EAAEJ,OAAO,QAAQ,EAAEd,MAAM,kBAAkB,EAAEiB,gBAAgB,0BAA0B,EAAEC,gBAAgB,QANxGJ,SAAAA,aACAd,QAAAA,YACAiB,kBAAAA,sBACAC,iBAAAA;QAKT,IAAI,CAACvC,IAAI,GAAG;IACd;AACF"}
@@ -13,9 +13,7 @@ export type NextStep = {
13
13
  status: CompletionStatus;
14
14
  };
15
15
  export interface NextStepForLeasedJobExecutionParams {
16
- jobId: string;
17
16
  jobExecutionId: string;
18
- runnerSessionId: string;
19
17
  agent?: AgentInterModuleClient | undefined;
20
18
  }
21
19
  export declare function nextStepForLeasedJobExecution(params: NextStepForLeasedJobExecutionParams): Promise<NextStep>;
@@ -1 +1 @@
1
- {"version":3,"file":"job-execution.d.ts","sourceRoot":"","sources":["../../src/core/job-execution.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,sBAAsB,EAAC,MAAM,qCAAqC,CAAC;AAChF,OAAO,KAAK,EAAC,aAAa,E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CAAC,CAInB;AAED,wBAAgB,cAAc,CAC5B,KAAK,EAAE,MAAM,EACb,KAAK,CAAC,EAAE,sBAAsB,GAAG,SAAS,GACzC,OAAO,CAAC,QAAQ,CAAC,CAOnB;AAED,MAAM,WAAW,sBAAsB;IACrC,cAAc,EAAE,MAAM,CAAC;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,WAAW,GAAG,QAAQ,CAAC;IAC/B,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IAGvC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IACxC,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAGzB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,aAAa,CAAC;CAC5B;AAED,MAAM,MAAM,uBAAuB,GAAG,sBAAsB,CAAC;AAa7D,wBAAsB,gBAAgB,CACpC,MAAM,EAAE,sBAAsB,GAC7B,OAAO,CAAC,uBAAuB,CAAC,CAQlC;AAsGD,MAAM,MAAM,0BAA0B,GAAG,SAAS,GAAG,MAAM,GAAG,KAAK,CAAC;AAEpE,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,IAAI,EACZ,eAAe,EAAE,MAAM,EACvB,KAAK,EAAE,MAAM,GACZ,0BAA0B,CAU5B"}
@@ -1,10 +1,10 @@
1
1
  import { coerceStepOutputs, evaluatePlannedPredicateAtSite } from '@shipfox/expression';
2
2
  import { withTransaction } from '#db/db.js';
3
- import { countStepAttempts, dispatchStepWithCompletedConfig, finishStepAttempt, getDirectDependencyJobContexts, getJobExecutionById, getLatestJobExecutionByJobId, getStepAttemptsByJobExecutionId, getStepsByJobExecutionIdForUpdate, insertRunningStepAttempt, lockActiveJobExecutionLeaseForUpdate, markStepRunning, markStepSkipped, settleJobFailed, writeJobStepsSettledOutbox } from '#db/workflow-runs.js';
3
+ import { countStepAttempts, dispatchStepWithCompletedConfig, finishStepAttempt, getDirectDependencyJobContexts, getJobExecutionById, getLatestJobExecutionByJobId, getStepAttemptsByJobExecutionId, getStepsByJobExecutionIdForUpdate, insertRunningStepAttempt, markStepRunning, markStepSkipped, settleJobFailed, writeJobStepsSettledOutbox } from '#db/workflow-runs.js';
4
4
  import { recordWorkflowJobExecutionStepsSettled, recordWorkflowStepRestartEnqueued } from '#metrics/instance.js';
5
5
  import { createAgentDefaultsResolver } from './agent-defaults.js';
6
6
  import { defaultStepConditionTrace, explicitConditionTrace } from './condition-trace.js';
7
- import { AgentConfigUnresolvableError, InterpolationUnresolvableError, JobLeaseNotActiveError, JobNotFoundError, StepAttemptAheadError, StepNotFoundError, StepNotRunningError } from './errors.js';
7
+ import { AgentConfigUnresolvableError, InterpolationUnresolvableError, JobNotFoundError, StepAttemptAheadError, StepNotFoundError, StepNotRunningError } from './errors.js';
8
8
  import { assembleStepDispatchContext } from './step-config/assemble-run-context.js';
9
9
  import { completeStepDispatchConfig } from './step-config/complete-step-dispatch-config.js';
10
10
  import { applyStepTransition } from './step-transition/apply-step-transition.js';
@@ -234,11 +234,7 @@ function dispatchConfigError(error) {
234
234
  };
235
235
  }
236
236
  export function nextStepForLeasedJobExecution(params) {
237
- return withTransaction(async (tx)=>{
238
- const leaseIsActive = await lockActiveJobExecutionLeaseForUpdate(params, tx);
239
- if (!leaseIsActive) throw new JobLeaseNotActiveError(params.jobExecutionId);
240
- return nextStepForJobExecutionInTransaction(params.jobExecutionId, tx, params.agent);
241
- });
237
+ return withTransaction((tx)=>nextStepForJobExecutionInTransaction(params.jobExecutionId, tx, params.agent));
242
238
  }
243
239
  export function nextStepForJob(jobId, agent) {
244
240
  return withTransaction(async (tx)=>{