@shipfox/api-workflows 4.0.0 → 6.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (277) hide show
  1. package/.turbo/turbo-build.log +4 -4
  2. package/CHANGELOG.md +104 -0
  3. package/dist/core/agent-defaults.d.ts +17 -0
  4. package/dist/core/agent-defaults.d.ts.map +1 -0
  5. package/dist/core/agent-defaults.js +21 -0
  6. package/dist/core/agent-defaults.js.map +1 -0
  7. package/dist/core/agent-tool-capability-warning.d.ts +4 -0
  8. package/dist/core/agent-tool-capability-warning.d.ts.map +1 -1
  9. package/dist/core/agent-tool-capability-warning.js +15 -17
  10. package/dist/core/agent-tool-capability-warning.js.map +1 -1
  11. package/dist/core/agent-tools.d.ts +11 -9
  12. package/dist/core/agent-tools.d.ts.map +1 -1
  13. package/dist/core/agent-tools.js +23 -18
  14. package/dist/core/agent-tools.js.map +1 -1
  15. package/dist/core/checkout.d.ts +21 -7
  16. package/dist/core/checkout.d.ts.map +1 -1
  17. package/dist/core/checkout.js +23 -11
  18. package/dist/core/checkout.js.map +1 -1
  19. package/dist/core/entities/workflow-run-attempt.d.ts +1 -1
  20. package/dist/core/entities/workflow-run-attempt.d.ts.map +1 -1
  21. package/dist/core/entities/workflow-run-attempt.js.map +1 -1
  22. package/dist/core/job-execution.d.ts +3 -1
  23. package/dist/core/job-execution.d.ts.map +1 -1
  24. package/dist/core/job-execution.js +14 -12
  25. package/dist/core/job-execution.js.map +1 -1
  26. package/dist/core/job-transition/derive-job-execution-outputs.d.ts +1 -1
  27. package/dist/core/job-transition/derive-job-execution-outputs.d.ts.map +1 -1
  28. package/dist/core/job-transition/derive-job-execution-outputs.js.map +1 -1
  29. package/dist/core/job-transition/derive-job-success.js +1 -1
  30. package/dist/core/job-transition/derive-job-success.js.map +1 -1
  31. package/dist/core/listener-execution-materialization.d.ts +3 -3
  32. package/dist/core/listener-execution-materialization.d.ts.map +1 -1
  33. package/dist/core/listener-execution-materialization.js +3 -4
  34. package/dist/core/listener-execution-materialization.js.map +1 -1
  35. package/dist/core/run-workflow.d.ts +12 -1
  36. package/dist/core/run-workflow.d.ts.map +1 -1
  37. package/dist/core/run-workflow.js +13 -8
  38. package/dist/core/run-workflow.js.map +1 -1
  39. package/dist/core/step-config/agent.d.ts +8 -8
  40. package/dist/core/step-config/agent.d.ts.map +1 -1
  41. package/dist/core/step-config/agent.js +12 -10
  42. package/dist/core/step-config/agent.js.map +1 -1
  43. package/dist/core/step-config/complete-step-dispatch-config.d.ts +4 -4
  44. package/dist/core/step-config/complete-step-dispatch-config.d.ts.map +1 -1
  45. package/dist/core/step-config/complete-step-dispatch-config.js +2 -2
  46. package/dist/core/step-config/complete-step-dispatch-config.js.map +1 -1
  47. package/dist/core/step-config/materialize-job-execution-steps.d.ts +3 -3
  48. package/dist/core/step-config/materialize-job-execution-steps.d.ts.map +1 -1
  49. package/dist/core/step-config/materialize-job-execution-steps.js +5 -6
  50. package/dist/core/step-config/materialize-job-execution-steps.js.map +1 -1
  51. package/dist/core/step-config/materialize-workflow-model.d.ts +3 -3
  52. package/dist/core/step-config/materialize-workflow-model.d.ts.map +1 -1
  53. package/dist/core/step-config/materialize-workflow-model.js +4 -4
  54. package/dist/core/step-config/materialize-workflow-model.js.map +1 -1
  55. package/dist/core/step-config/resolve-job-execution-name.d.ts +1 -1
  56. package/dist/core/step-config/resolve-job-execution-name.d.ts.map +1 -1
  57. package/dist/core/step-config/resolve-job-execution-name.js.map +1 -1
  58. package/dist/core/step-config/resolve-step-config.d.ts +4 -4
  59. package/dist/core/step-config/resolve-step-config.d.ts.map +1 -1
  60. package/dist/core/step-config/resolve-step-config.js +6 -6
  61. package/dist/core/step-config/resolve-step-config.js.map +1 -1
  62. package/dist/core/step-config/run.d.ts +1 -1
  63. package/dist/core/step-config/run.d.ts.map +1 -1
  64. package/dist/core/step-config/run.js.map +1 -1
  65. package/dist/core/workflow-run-creation.d.ts +3 -3
  66. package/dist/core/workflow-run-creation.d.ts.map +1 -1
  67. package/dist/core/workflow-run-creation.js +3 -4
  68. package/dist/core/workflow-run-creation.js.map +1 -1
  69. package/dist/db/db.d.ts +16 -4
  70. package/dist/db/db.d.ts.map +1 -1
  71. package/dist/db/job-listeners.d.ts +7 -1
  72. package/dist/db/job-listeners.d.ts.map +1 -1
  73. package/dist/db/job-listeners.js +10 -5
  74. package/dist/db/job-listeners.js.map +1 -1
  75. package/dist/db/runner-lease-table.d.ts +5 -5
  76. package/dist/db/runner-lease-table.d.ts.map +1 -1
  77. package/dist/db/runner-lease-table.js +3 -2
  78. package/dist/db/runner-lease-table.js.map +1 -1
  79. package/dist/db/schema/workflow-run-attempts.d.ts +9 -3
  80. package/dist/db/schema/workflow-run-attempts.d.ts.map +1 -1
  81. package/dist/db/schema/workflow-run-attempts.js +2 -1
  82. package/dist/db/schema/workflow-run-attempts.js.map +1 -1
  83. package/dist/db/schema/workflow-runs.js +1 -1
  84. package/dist/db/schema/workflow-runs.js.map +1 -1
  85. package/dist/db/workflow-runs/job-executions.d.ts +5 -0
  86. package/dist/db/workflow-runs/job-executions.d.ts.map +1 -1
  87. package/dist/db/workflow-runs/job-executions.js +14 -7
  88. package/dist/db/workflow-runs/job-executions.js.map +1 -1
  89. package/dist/db/workflow-runs/jobs.d.ts.map +1 -1
  90. package/dist/db/workflow-runs/jobs.js +3 -1
  91. package/dist/db/workflow-runs/jobs.js.map +1 -1
  92. package/dist/db/workflow-runs/run-create.d.ts +9 -2
  93. package/dist/db/workflow-runs/run-create.d.ts.map +1 -1
  94. package/dist/db/workflow-runs/run-create.js +12 -9
  95. package/dist/db/workflow-runs/run-create.js.map +1 -1
  96. package/dist/db/workflow-runs/run-rerun.d.ts.map +1 -1
  97. package/dist/db/workflow-runs/run-rerun.js +3 -1
  98. package/dist/db/workflow-runs/run-rerun.js.map +1 -1
  99. package/dist/index.d.ts +18 -4
  100. package/dist/index.d.ts.map +1 -1
  101. package/dist/index.js +61 -37
  102. package/dist/index.js.map +1 -1
  103. package/dist/presentation/dto/checkout-token.d.ts +14 -1
  104. package/dist/presentation/dto/checkout-token.d.ts.map +1 -1
  105. package/dist/presentation/dto/checkout-token.js.map +1 -1
  106. package/dist/presentation/index.d.ts +1 -1
  107. package/dist/presentation/index.d.ts.map +1 -1
  108. package/dist/presentation/index.js +1 -1
  109. package/dist/presentation/index.js.map +1 -1
  110. package/dist/presentation/inter-module.d.ts +18 -0
  111. package/dist/presentation/inter-module.d.ts.map +1 -0
  112. package/dist/presentation/inter-module.js +113 -0
  113. package/dist/presentation/inter-module.js.map +1 -0
  114. package/dist/presentation/routes/agent-runtime-config.d.ts +6 -1
  115. package/dist/presentation/routes/agent-runtime-config.d.ts.map +1 -1
  116. package/dist/presentation/routes/agent-runtime-config.js +59 -57
  117. package/dist/presentation/routes/agent-runtime-config.js.map +1 -1
  118. package/dist/presentation/routes/cancel-run.d.ts +2 -1
  119. package/dist/presentation/routes/cancel-run.d.ts.map +1 -1
  120. package/dist/presentation/routes/cancel-run.js +37 -34
  121. package/dist/presentation/routes/cancel-run.js.map +1 -1
  122. package/dist/presentation/routes/checkout-token.d.ts +8 -1
  123. package/dist/presentation/routes/checkout-token.d.ts.map +1 -1
  124. package/dist/presentation/routes/checkout-token.js +65 -47
  125. package/dist/presentation/routes/checkout-token.js.map +1 -1
  126. package/dist/presentation/routes/get-run-aggregates.d.ts +2 -1
  127. package/dist/presentation/routes/get-run-aggregates.d.ts.map +1 -1
  128. package/dist/presentation/routes/get-run-aggregates.js +44 -53
  129. package/dist/presentation/routes/get-run-aggregates.js.map +1 -1
  130. package/dist/presentation/routes/get-run.d.ts +2 -1
  131. package/dist/presentation/routes/get-run.d.ts.map +1 -1
  132. package/dist/presentation/routes/get-run.js +53 -50
  133. package/dist/presentation/routes/get-run.js.map +1 -1
  134. package/dist/presentation/routes/get-step-secrets.d.ts +3 -1
  135. package/dist/presentation/routes/get-step-secrets.d.ts.map +1 -1
  136. package/dist/presentation/routes/get-step-secrets.js +72 -68
  137. package/dist/presentation/routes/get-step-secrets.js.map +1 -1
  138. package/dist/presentation/routes/index.d.ts +19 -2
  139. package/dist/presentation/routes/index.d.ts.map +1 -1
  140. package/dist/presentation/routes/index.js +38 -30
  141. package/dist/presentation/routes/index.js.map +1 -1
  142. package/dist/presentation/routes/leased-step.d.ts +2 -0
  143. package/dist/presentation/routes/leased-step.d.ts.map +1 -1
  144. package/dist/presentation/routes/leased-step.js +1 -2
  145. package/dist/presentation/routes/leased-step.js.map +1 -1
  146. package/dist/presentation/routes/list-run-attempts.d.ts +2 -1
  147. package/dist/presentation/routes/list-run-attempts.d.ts.map +1 -1
  148. package/dist/presentation/routes/list-run-attempts.js +29 -26
  149. package/dist/presentation/routes/list-run-attempts.js.map +1 -1
  150. package/dist/presentation/routes/list-runs.d.ts +2 -1
  151. package/dist/presentation/routes/list-runs.d.ts.map +1 -1
  152. package/dist/presentation/routes/list-runs.js +51 -60
  153. package/dist/presentation/routes/list-runs.js.map +1 -1
  154. package/dist/presentation/routes/next-step.d.ts +10 -1
  155. package/dist/presentation/routes/next-step.d.ts.map +1 -1
  156. package/dist/presentation/routes/next-step.js +64 -50
  157. package/dist/presentation/routes/next-step.js.map +1 -1
  158. package/dist/presentation/routes/project-access.d.ts +10 -0
  159. package/dist/presentation/routes/project-access.d.ts.map +1 -0
  160. package/dist/presentation/routes/project-access.js +17 -0
  161. package/dist/presentation/routes/project-access.js.map +1 -0
  162. package/dist/presentation/routes/report-step.d.ts +2 -1
  163. package/dist/presentation/routes/report-step.d.ts.map +1 -1
  164. package/dist/presentation/routes/report-step.js +62 -61
  165. package/dist/presentation/routes/report-step.js.map +1 -1
  166. package/dist/presentation/routes/require-accessible-run.d.ts +3 -1
  167. package/dist/presentation/routes/require-accessible-run.d.ts.map +1 -1
  168. package/dist/presentation/routes/require-accessible-run.js +3 -6
  169. package/dist/presentation/routes/require-accessible-run.js.map +1 -1
  170. package/dist/presentation/routes/rerun-run.d.ts +2 -1
  171. package/dist/presentation/routes/rerun-run.d.ts.map +1 -1
  172. package/dist/presentation/routes/rerun-run.js +46 -43
  173. package/dist/presentation/routes/rerun-run.js.map +1 -1
  174. package/dist/temporal/activities/index.d.ts +44 -9
  175. package/dist/temporal/activities/index.d.ts.map +1 -1
  176. package/dist/temporal/activities/index.js +13 -9
  177. package/dist/temporal/activities/index.js.map +1 -1
  178. package/dist/temporal/activities/orchestration-activities.d.ts +20 -11
  179. package/dist/temporal/activities/orchestration-activities.d.ts.map +1 -1
  180. package/dist/temporal/activities/orchestration-activities.js +48 -33
  181. package/dist/temporal/activities/orchestration-activities.js.map +1 -1
  182. package/dist/tsconfig.test.tsbuildinfo +1 -1
  183. package/package.json +41 -44
  184. package/src/core/agent-defaults.test.ts +28 -0
  185. package/src/core/agent-defaults.ts +36 -0
  186. package/src/core/agent-tool-capability-warning.test.ts +36 -11
  187. package/src/core/agent-tool-capability-warning.ts +27 -25
  188. package/src/core/agent-tools.ts +33 -36
  189. package/src/core/checkout.test.ts +38 -25
  190. package/src/core/checkout.ts +41 -14
  191. package/src/core/entities/workflow-run-attempt.ts +1 -1
  192. package/src/core/job-execution.ts +19 -9
  193. package/src/core/job-transition/derive-job-execution-outputs.ts +1 -1
  194. package/src/core/job-transition/derive-job-success.ts +1 -1
  195. package/src/core/listener-execution-materialization.test.ts +4 -2
  196. package/src/core/listener-execution-materialization.ts +6 -9
  197. package/src/core/run-workflow.test.ts +43 -38
  198. package/src/core/run-workflow.ts +26 -9
  199. package/src/core/step-config/agent.ts +24 -26
  200. package/src/core/step-config/complete-step-dispatch-config.test.ts +22 -23
  201. package/src/core/step-config/complete-step-dispatch-config.ts +6 -6
  202. package/src/core/step-config/materialize-job-execution-steps.test.ts +34 -23
  203. package/src/core/step-config/materialize-job-execution-steps.ts +38 -39
  204. package/src/core/step-config/materialize-workflow-model.test.ts +94 -82
  205. package/src/core/step-config/materialize-workflow-model.ts +31 -29
  206. package/src/core/step-config/resolve-job-execution-name.ts +1 -1
  207. package/src/core/step-config/resolve-step-config.ts +11 -9
  208. package/src/core/step-config/run.ts +1 -1
  209. package/src/core/workflow-run-creation.test.ts +14 -10
  210. package/src/core/workflow-run-creation.ts +6 -9
  211. package/src/db/job-listeners.ts +20 -5
  212. package/src/db/runner-lease-table.ts +2 -2
  213. package/src/db/schema/workflow-run-attempts.ts +7 -3
  214. package/src/db/schema/workflow-runs.ts +1 -1
  215. package/src/db/workflow-runs/job-executions.ts +15 -1
  216. package/src/db/workflow-runs/jobs.ts +4 -1
  217. package/src/db/workflow-runs/run-create.test.ts +7 -1
  218. package/src/db/workflow-runs/run-create.ts +25 -15
  219. package/src/db/workflow-runs/run-rerun.test.ts +1 -1
  220. package/src/db/workflow-runs/run-rerun.ts +6 -3
  221. package/src/index.ts +75 -33
  222. package/src/presentation/dto/checkout-token.ts +7 -1
  223. package/src/presentation/index.ts +1 -1
  224. package/src/presentation/inter-module.test.ts +149 -0
  225. package/src/presentation/inter-module.ts +132 -0
  226. package/src/presentation/routes/agent-runtime-config.test.ts +53 -10
  227. package/src/presentation/routes/agent-runtime-config.ts +89 -64
  228. package/src/presentation/routes/cancel-run.test.ts +10 -20
  229. package/src/presentation/routes/cancel-run.ts +30 -27
  230. package/src/presentation/routes/checkout-token.test.ts +52 -33
  231. package/src/presentation/routes/checkout-token.ts +109 -49
  232. package/src/presentation/routes/get-run-aggregates.test.ts +13 -7
  233. package/src/presentation/routes/get-run-aggregates.ts +54 -57
  234. package/src/presentation/routes/get-run.test.ts +10 -18
  235. package/src/presentation/routes/get-run.ts +51 -48
  236. package/src/presentation/routes/get-step-secrets.test.ts +29 -7
  237. package/src/presentation/routes/get-step-secrets.ts +72 -61
  238. package/src/presentation/routes/index.test.ts +16 -1
  239. package/src/presentation/routes/index.ts +54 -29
  240. package/src/presentation/routes/leased-step.ts +3 -2
  241. package/src/presentation/routes/list-run-attempts.test.ts +9 -19
  242. package/src/presentation/routes/list-run-attempts.ts +21 -18
  243. package/src/presentation/routes/list-runs.test.ts +13 -7
  244. package/src/presentation/routes/list-runs.ts +64 -67
  245. package/src/presentation/routes/next-step.test.ts +30 -11
  246. package/src/presentation/routes/next-step.ts +68 -48
  247. package/src/presentation/routes/project-access.ts +16 -0
  248. package/src/presentation/routes/report-step.test.ts +18 -2
  249. package/src/presentation/routes/report-step.ts +51 -49
  250. package/src/presentation/routes/require-accessible-run.ts +5 -2
  251. package/src/presentation/routes/rerun-run.test.ts +9 -19
  252. package/src/presentation/routes/rerun-run.ts +39 -36
  253. package/src/temporal/activities/index.ts +32 -12
  254. package/src/temporal/activities/orchestration-activities.test.ts +10 -8
  255. package/src/temporal/activities/orchestration-activities.ts +74 -50
  256. package/src/temporal/workflows/job-execution-orchestration.test.ts +47 -2
  257. package/test/env.ts +1 -3
  258. package/test/factories/project.ts +10 -5
  259. package/test/factories/workflow-model.test.ts +5 -1
  260. package/test/factories/workflow-model.ts +1 -1
  261. package/test/factories/workflow-run.ts +1 -1
  262. package/test/fixtures/agent-inter-module.ts +27 -0
  263. package/test/fixtures/annotations-inter-module.ts +5 -0
  264. package/test/fixtures/auth-inter-module.ts +22 -0
  265. package/test/fixtures/lease-token.ts +2 -1
  266. package/test/fixtures/projects-inter-module.ts +8 -0
  267. package/test/fixtures/runners-inter-module.ts +52 -0
  268. package/test/fixtures/secrets-inter-module.ts +61 -0
  269. package/test/globalSetup.ts +11 -11
  270. package/tsconfig.build.tsbuildinfo +1 -1
  271. package/dist/core/source-control.d.ts +0 -5
  272. package/dist/core/source-control.d.ts.map +0 -1
  273. package/dist/core/source-control.js +0 -19
  274. package/dist/core/source-control.js.map +0 -1
  275. package/src/core/source-control.test.ts +0 -17
  276. package/src/core/source-control.ts +0 -22
  277. package/src/temporal/workflows/job-execution-orchestration-timeout.test.ts +0 -165
@@ -1,6 +1,6 @@
1
1
  $ shipfox-swc && shipfox-temporal-bundle dist/temporal/workflows/index.js
2
- Successfully compiled: 114 files with swc (131.56ms)
3
- 2026-07-19T08:15:25.864Z [INFO] asset workflow-bundle-4cbe48212b3a51eda262.js 1.59 MiB [emitted] [immutable] (name: main)
2
+ Successfully compiled: 116 files with swc (715.25ms)
3
+ 2026-07-21T08:12:09.510Z [INFO] asset workflow-bundle-4cbe48212b3a51eda262.js 1.59 MiB [emitted] [immutable] (name: main)
4
4
  runtime modules 670 bytes 3 modules
5
5
  modules by path ../../../node_modules/.pnpm/ 424 KiB
6
6
  modules by path ../../../node_modules/.pnpm/@temporalio+common@1.18.1/node_modules/@temporal...(truncated) 155 KiB 34 modules
@@ -16,6 +16,6 @@ modules by path ./dist/ 39.5 KiB
16
16
  optional modules 30 bytes [optional]
17
17
  __temporal_custom_payload_converter (ignored) 15 bytes [optional] [built] [code generated]
18
18
  __temporal_custom_failure_converter (ignored) 15 bytes [optional] [built] [code generated]
19
- webpack 5.107.2 compiled successfully in 743 ms
20
- 2026-07-19T08:15:25.867Z [INFO] Workflow bundle created { size: '1.59MB' }
19
+ webpack 5.107.2 compiled successfully in 4093 ms
20
+ 2026-07-21T08:12:09.538Z [INFO] Workflow bundle created { size: '1.59MB' }
21
21
  /home/runner/work/shipfox/shipfox/libs/api/workflows/dist/temporal/workflows/index.js: 1665965 bytes
package/CHANGELOG.md CHANGED
@@ -1,5 +1,109 @@
1
1
  # @shipfox/api-workflows
2
2
 
3
+ ## 6.0.0
4
+
5
+ ### Major Changes
6
+
7
+ - a8f0545: Adds the versioned Definitions workflow snapshot contract and registered presentation.
8
+ - 9006b75: Adds the Runners inter-module contract and requires the injected Runners client when composing Workflows.
9
+
10
+ ### Minor Changes
11
+
12
+ - 23563de: Moves Triggers to the injected Workflows inter-module contract with stable run idempotency and listener delivery commands.
13
+ - a42b575: Exposes Secrets through its inter-module contract and migrates Agent, integrations, and Workflows consumers.
14
+ - 23a4dc2: Moves Logs and Integrations to injected Workflows inter-module clients with minimal log and leased agent-tool queries.
15
+
16
+ ### Patch Changes
17
+
18
+ - 0bb82a4: Adds the Agent and Integrations inter-module APIs, moving Workflows agent configuration, runtime credential resolution, and integration consumers behind producer-owned clients.
19
+ - 9cb2442: Moves workflow capability-warning annotations behind the producer-owned inter-module API.
20
+ - b70f920: Adds assigned runner activation and descendant provisioner revocation.
21
+ - 112c0fa: Adds the Auth inter-module token-minting contract and removes Auth implementation and configuration coupling from its consumers.
22
+ - f73da5d: Enforces bounded API context imports and routes inter-module consumers through producer contracts.
23
+ - Updated dependencies [e52513c]
24
+ - Updated dependencies [a8f0545]
25
+ - Updated dependencies [0bb82a4]
26
+ - Updated dependencies [9cb2442]
27
+ - Updated dependencies [b70f920]
28
+ - Updated dependencies [23563de]
29
+ - Updated dependencies [6a52909]
30
+ - Updated dependencies [e6eba5b]
31
+ - Updated dependencies [54ce48b]
32
+ - Updated dependencies [add4c77]
33
+ - Updated dependencies [9006b75]
34
+ - Updated dependencies [3cda0c6]
35
+ - Updated dependencies [ba2e3dc]
36
+ - Updated dependencies [f4bc2eb]
37
+ - Updated dependencies [c0162b0]
38
+ - Updated dependencies [7ac43a4]
39
+ - Updated dependencies [f262539]
40
+ - Updated dependencies [a01e917]
41
+ - Updated dependencies [3bb4e26]
42
+ - Updated dependencies [a42b575]
43
+ - Updated dependencies [112c0fa]
44
+ - Updated dependencies [8bdc149]
45
+ - Updated dependencies [795e293]
46
+ - Updated dependencies [e10c829]
47
+ - Updated dependencies [f73da5d]
48
+ - Updated dependencies [3810996]
49
+ - Updated dependencies [23a4dc2]
50
+ - Updated dependencies [b00ed29]
51
+ - Updated dependencies [8aa7cd3]
52
+ - Updated dependencies [4a91956]
53
+ - Updated dependencies [81f9544]
54
+ - Updated dependencies [4604a06]
55
+ - Updated dependencies [6741be8]
56
+ - @shipfox/api-runners@6.0.0
57
+ - @shipfox/api-runners-dto@6.0.0
58
+ - @shipfox/api-definitions-dto@6.0.0
59
+ - @shipfox/api-agent-dto@6.0.0
60
+ - @shipfox/api-integration-core-dto@6.0.0
61
+ - @shipfox/api-projects@6.0.0
62
+ - @shipfox/annotations-dto@6.0.0
63
+ - @shipfox/api-workflows-dto@6.0.0
64
+ - @shipfox/api-auth-dto@6.0.0
65
+ - @shipfox/node-module@0.4.0
66
+ - @shipfox/node-temporal@0.3.2
67
+ - @shipfox/node-drizzle@0.3.2
68
+ - @shipfox/node-outbox@0.2.4
69
+ - @shipfox/api-secrets-dto@6.0.0
70
+ - @shipfox/api-auth-context@6.0.0
71
+ - @shipfox/node-fastify@0.2.4
72
+ - @shipfox/inter-module@0.2.0
73
+ - @shipfox/api-projects-dto@6.0.0
74
+
75
+ ## 5.0.0
76
+
77
+ ### Patch Changes
78
+
79
+ - bb037af: Resolves workspace packages from source during development while published consumers continue to use compiled output.
80
+ - Updated dependencies [2875241]
81
+ - Updated dependencies [bb037af]
82
+ - Updated dependencies [fb70438]
83
+ - @shipfox/api-integration-core@5.0.0
84
+ - @shipfox/annotations@5.0.0
85
+ - @shipfox/api-agent@5.0.0
86
+ - @shipfox/api-agent-dto@5.0.0
87
+ - @shipfox/api-auth@5.0.0
88
+ - @shipfox/api-auth-context@5.0.0
89
+ - @shipfox/api-definitions@5.0.0
90
+ - @shipfox/api-projects@5.0.0
91
+ - @shipfox/api-runners@5.0.0
92
+ - @shipfox/api-runners-dto@5.0.0
93
+ - @shipfox/api-secrets@5.0.0
94
+ - @shipfox/api-secrets-dto@5.0.0
95
+ - @shipfox/api-workflows-dto@5.0.0
96
+ - @shipfox/expression@1.1.3
97
+ - @shipfox/node-drizzle@0.3.1
98
+ - @shipfox/node-error-monitoring@0.1.3
99
+ - @shipfox/node-fastify@0.2.3
100
+ - @shipfox/node-module@0.3.2
101
+ - @shipfox/node-opentelemetry@0.5.2
102
+ - @shipfox/node-outbox@0.2.3
103
+ - @shipfox/node-postgres@0.4.2
104
+ - @shipfox/node-temporal@0.3.1
105
+ - @shipfox/runner-labels@0.1.1
106
+
3
107
  ## 4.0.0
4
108
 
5
109
  ### Patch Changes
@@ -0,0 +1,17 @@
1
+ import type { AgentThinking, Harness, ModelProviderRef } from '@shipfox/api-agent-dto';
2
+ import type { AgentInterModuleClient } from '@shipfox/api-agent-dto/inter-module';
3
+ export interface AgentDefaultsInput {
4
+ readonly harness?: Harness | undefined;
5
+ readonly provider?: ModelProviderRef | undefined;
6
+ readonly model?: string | undefined;
7
+ readonly thinking?: AgentThinking | undefined;
8
+ }
9
+ export interface ResolvedAgentDefaults {
10
+ readonly harness: Harness;
11
+ readonly provider: ModelProviderRef;
12
+ readonly model: string;
13
+ readonly thinking: AgentThinking;
14
+ }
15
+ export type AgentDefaultsResolver = (input: AgentDefaultsInput) => ResolvedAgentDefaults | Promise<ResolvedAgentDefaults>;
16
+ export declare function createAgentDefaultsResolver(agent: AgentInterModuleClient, workspaceId: string | null): AgentDefaultsResolver;
17
+ //# sourceMappingURL=agent-defaults.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent-defaults.d.ts","sourceRoot":"","sources":["../../src/core/agent-defaults.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,aAAa,EAAE,OAAO,EAAE,gBAAgB,EAAC,MAAM,wBAAwB,CAAC;AACrF,OAAO,KAAK,EAAC,sBAAsB,EAAC,MAAM,qCAAqC,CAAC;AAEhF,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IACvC,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"}
@@ -0,0 +1,21 @@
1
+ export function createAgentDefaultsResolver(agent, workspaceId) {
2
+ return async (config)=>await agent.resolveAgentConfig({
3
+ workspaceId,
4
+ config: {
5
+ ...config.harness === undefined ? {} : {
6
+ harness: config.harness
7
+ },
8
+ ...config.provider === undefined ? {} : {
9
+ provider: config.provider
10
+ },
11
+ ...config.model === undefined ? {} : {
12
+ model: config.model
13
+ },
14
+ ...config.thinking === undefined ? {} : {
15
+ thinking: config.thinking
16
+ }
17
+ }
18
+ });
19
+ }
20
+
21
+ //# sourceMappingURL=agent-defaults.js.map
@@ -0,0 +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,6 +1,10 @@
1
+ import { type AnnotationsInterModuleClient } from '@shipfox/annotations-dto/inter-module';
1
2
  import type { LeasedJobContext } from '@shipfox/api-auth-context';
3
+ import type { RunnersInterModuleClient } from '@shipfox/api-runners-dto/inter-module';
2
4
  import type { Step } from './entities/step.js';
3
5
  export declare function warnAgentToolCapabilityMismatchOnDispatch(params: {
6
+ annotations: AnnotationsInterModuleClient;
7
+ runners: RunnersInterModuleClient;
4
8
  leaseIdentity: LeasedJobContext;
5
9
  step: Step;
6
10
  }): Promise<void>;
@@ -1 +1 @@
1
- {"version":3,"file":"agent-tool-capability-warning.d.ts","sourceRoot":"","sources":["../../src/core/agent-tool-capability-warning.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAC,gBAAgB,EAAC,MAAM,2BAA2B,CAAC;AAIhE,OAAO,KAAK,EAAC,IAAI,EAAC,MAAM,oBAAoB,CAAC;AAO7C,wBAAsB,yCAAyC,CAAC,MAAM,EAAE;IACtE,aAAa,EAAE,gBAAgB,CAAC;IAChC,IAAI,EAAE,IAAI,CAAC;CACZ,GAAG,OAAO,CAAC,IAAI,CAAC,CAqFhB"}
1
+ {"version":3,"file":"agent-tool-capability-warning.d.ts","sourceRoot":"","sources":["../../src/core/agent-tool-capability-warning.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,4BAA4B,EAElC,MAAM,uCAAuC,CAAC;AAM/C,OAAO,KAAK,EAAC,gBAAgB,EAAC,MAAM,2BAA2B,CAAC;AAChE,OAAO,KAAK,EAAC,wBAAwB,EAAC,MAAM,uCAAuC,CAAC;AAIpF,OAAO,KAAK,EAAC,IAAI,EAAC,MAAM,oBAAoB,CAAC;AAO7C,wBAAsB,yCAAyC,CAAC,MAAM,EAAE;IACtE,WAAW,EAAE,4BAA4B,CAAC;IAC1C,OAAO,EAAE,wBAAwB,CAAC;IAClC,aAAa,EAAE,gBAAgB,CAAC;IAChC,IAAI,EAAE,IAAI,CAAC;CACZ,GAAG,OAAO,CAAC,IAAI,CAAC,CAqFhB"}
@@ -1,6 +1,6 @@
1
- import { AnnotationBodyTooLargeError, AnnotationCountLimitExceededError, AnnotationTotalBytesLimitExceededError, writeAnnotations } from '@shipfox/annotations';
1
+ import { annotationsInterModuleContract } from '@shipfox/annotations-dto/inter-module';
2
2
  import { harnessSchema, materializedAgentStepConfigSchema } from '@shipfox/api-agent-dto';
3
- import { getEffectiveRunnerToolCapabilities, unadvertisedRunnerTools } from '@shipfox/api-runners';
3
+ import { isInterModuleKnownError } from '@shipfox/inter-module';
4
4
  import { logger } from '@shipfox/node-opentelemetry';
5
5
  import { recordWorkflowAgentToolWarningFailed } from '#metrics/instance.js';
6
6
  const TOOL_LIST_LIMIT = 10;
@@ -13,7 +13,7 @@ export async function warnAgentToolCapabilityMismatchOnDispatch(params) {
13
13
  if (!harness.success) return;
14
14
  let effective;
15
15
  try {
16
- effective = await getEffectiveRunnerToolCapabilities({
16
+ effective = await params.runners.getEffectiveRunnerToolCapabilities({
17
17
  runnerSessionId: params.leaseIdentity.runnerSessionId
18
18
  });
19
19
  } catch (error) {
@@ -25,11 +25,8 @@ export async function warnAgentToolCapabilityMismatchOnDispatch(params) {
25
25
  }, 'Failed to read runner tool capabilities for agent tool warning');
26
26
  return;
27
27
  }
28
- const missing = unadvertisedRunnerTools({
29
- harness: harness.data,
30
- requestedTools,
31
- capabilities: effective.capabilities
32
- });
28
+ const advertised = new Set(effective.capabilities.harnesses[harness.data]?.tools ?? []);
29
+ const missing = requestedTools.filter((tool)=>!advertised.has(tool));
33
30
  const context = `agent-tool-capability:${params.step.id}`;
34
31
  const operation = missing.length === 0 ? {
35
32
  context,
@@ -44,18 +41,19 @@ export async function warnAgentToolCapabilityMismatchOnDispatch(params) {
44
41
  missing,
45
42
  reason: warningReason({
46
43
  reportFresh: effective.reportFresh,
47
- harnessKnown: effective.harnessKnown(harness.data)
44
+ harnessKnown: effective.capabilities.harnesses[harness.data] !== undefined
48
45
  })
49
46
  })
50
47
  };
51
48
  try {
52
- await writeAnnotations({
53
- ...writeParamsFromLease(params.leaseIdentity),
49
+ await params.annotations.replaceOrRemoveAnnotation({
50
+ ...annotationTargetFromLease(params.leaseIdentity),
54
51
  originStepId: params.step.id,
55
52
  originStepAttempt: params.step.currentAttempt,
56
- operations: [
57
- operation
58
- ]
53
+ context,
54
+ annotation: operation.op === 'remove' ? {
55
+ op: 'remove'
56
+ } : operation
59
57
  });
60
58
  } catch (error) {
61
59
  const reason = isAnnotationBudgetError(error) ? 'budget' : 'write';
@@ -76,7 +74,7 @@ export async function warnAgentToolCapabilityMismatchOnDispatch(params) {
76
74
  missing,
77
75
  reason: warningReason({
78
76
  reportFresh: effective.reportFresh,
79
- harnessKnown: effective.harnessKnown(harness.data)
77
+ harnessKnown: effective.capabilities.harnesses[harness.data] !== undefined
80
78
  })
81
79
  }, 'Runner missing requested agent tools; dispatch is continuing');
82
80
  }
@@ -128,7 +126,7 @@ function warningReason(params) {
128
126
  if (params.harnessKnown) return 'known-absence';
129
127
  return params.reportFresh ? 'harness-not-advertised' : 'unknown-or-stale';
130
128
  }
131
- function writeParamsFromLease(lease) {
129
+ function annotationTargetFromLease(lease) {
132
130
  return {
133
131
  workspaceId: lease.workspaceId,
134
132
  projectId: lease.projectId,
@@ -140,7 +138,7 @@ function writeParamsFromLease(lease) {
140
138
  };
141
139
  }
142
140
  function isAnnotationBudgetError(error) {
143
- return error instanceof AnnotationBodyTooLargeError || error instanceof AnnotationCountLimitExceededError || error instanceof AnnotationTotalBytesLimitExceededError;
141
+ return isInterModuleKnownError(annotationsInterModuleContract.methods.replaceOrRemoveAnnotation, error);
144
142
  }
145
143
  function recordWarningWriteFailure(reason) {
146
144
  recordWorkflowAgentToolWarningFailed(reason);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/core/agent-tool-capability-warning.ts"],"sourcesContent":["import {\n AnnotationBodyTooLargeError,\n AnnotationCountLimitExceededError,\n AnnotationTotalBytesLimitExceededError,\n type WriteAnnotationsParams,\n writeAnnotations,\n} from '@shipfox/annotations';\nimport {\n harnessSchema,\n type MaterializedAgentStepConfigDto,\n materializedAgentStepConfigSchema,\n} from '@shipfox/api-agent-dto';\nimport type {LeasedJobContext} from '@shipfox/api-auth-context';\nimport {getEffectiveRunnerToolCapabilities, unadvertisedRunnerTools} from '@shipfox/api-runners';\nimport {logger} from '@shipfox/node-opentelemetry';\nimport {recordWorkflowAgentToolWarningFailed} from '#metrics/instance.js';\nimport type {Step} from './entities/step.js';\n\nconst TOOL_LIST_LIMIT = 10;\n\ntype WarningFailureReason = 'budget' | 'lookup' | 'write';\ntype WarningReason = 'known-absence' | 'harness-not-advertised' | 'unknown-or-stale';\n\nexport async function warnAgentToolCapabilityMismatchOnDispatch(params: {\n leaseIdentity: LeasedJobContext;\n step: Step;\n}): Promise<void> {\n const config = parseAgentConfig(params.step);\n if (!config) return;\n\n const requestedTools = config.tools ?? [];\n if (requestedTools.length === 0) return;\n\n const harness = harnessSchema.safeParse(config.harness);\n if (!harness.success) return;\n\n let effective: Awaited<ReturnType<typeof getEffectiveRunnerToolCapabilities>>;\n try {\n effective = await getEffectiveRunnerToolCapabilities({\n runnerSessionId: params.leaseIdentity.runnerSessionId,\n });\n } catch (error) {\n recordWarningWriteFailure('lookup');\n logger().warn(\n {error, jobExecutionId: params.leaseIdentity.jobExecutionId, stepId: params.step.id},\n 'Failed to read runner tool capabilities for agent tool warning',\n );\n return;\n }\n\n const missing = unadvertisedRunnerTools({\n harness: harness.data,\n requestedTools,\n capabilities: effective.capabilities,\n });\n const context = `agent-tool-capability:${params.step.id}`;\n\n const operation =\n missing.length === 0\n ? {context, style: 'warning' as const, op: 'remove' as const}\n : {\n context,\n style: 'warning' as const,\n op: 'replace' as const,\n body: warningBody({\n harness: harness.data,\n missing,\n reason: warningReason({\n reportFresh: effective.reportFresh,\n harnessKnown: effective.harnessKnown(harness.data),\n }),\n }),\n };\n\n try {\n await writeAnnotations({\n ...writeParamsFromLease(params.leaseIdentity),\n originStepId: params.step.id,\n originStepAttempt: params.step.currentAttempt,\n operations: [operation],\n });\n } catch (error) {\n const reason = isAnnotationBudgetError(error) ? 'budget' : 'write';\n recordWarningWriteFailure(reason);\n logger().warn(\n {\n error,\n reason,\n jobExecutionId: params.leaseIdentity.jobExecutionId,\n stepId: params.step.id,\n },\n 'Failed to write agent tool capability warning annotation',\n );\n return;\n }\n\n if (missing.length > 0) {\n logger().warn(\n {\n jobExecutionId: params.leaseIdentity.jobExecutionId,\n stepId: params.step.id,\n harness: harness.data,\n missing,\n reason: warningReason({\n reportFresh: effective.reportFresh,\n harnessKnown: effective.harnessKnown(harness.data),\n }),\n },\n 'Runner missing requested agent tools; dispatch is continuing',\n );\n }\n}\n\nfunction parseAgentConfig(step: Step): MaterializedAgentStepConfigDto | null {\n if (step.type !== 'agent') return null;\n\n const parsed = materializedAgentStepConfigSchema.safeParse(step.config);\n return parsed.success ? parsed.data : null;\n}\n\nfunction warningBody(params: {\n harness: string;\n missing: readonly string[];\n reason: WarningReason;\n}): string {\n const tools = formatToolList(params.missing);\n const harness = markdownInlineCode(params.harness);\n if (params.reason === 'known-absence') {\n return [\n '**Runner missing requested agent tools**',\n '',\n `The matched runner advertised a ${harness} tool set without: ${tools}.`,\n 'Execution is continuing on this runner because labels matched; the step may fail if the harness cannot provide these tools.',\n ].join('\\n');\n }\n\n if (params.reason === 'harness-not-advertised') {\n return [\n '**Runner missing requested agent harness tools**',\n '',\n `The matched runner advertised fresh tool capabilities, but did not advertise a ${harness} tool set. Support for ${tools} could not be confirmed.`,\n 'Execution is continuing on this runner because labels matched; the step may fail if the harness cannot provide these tools.',\n ].join('\\n');\n }\n\n return [\n '**Could not confirm runner agent tools**',\n '',\n `The matched runner reported no or stale tool capabilities, so support for ${tools} could not be confirmed.`,\n 'Execution is continuing on this runner because labels matched.',\n ].join('\\n');\n}\n\nfunction formatToolList(tools: readonly string[]): string {\n const visible = tools.slice(0, TOOL_LIST_LIMIT).map(markdownInlineCode);\n const remaining = tools.length - visible.length;\n return remaining > 0 ? `${visible.join(', ')} ...and ${remaining} more` : visible.join(', ');\n}\n\nfunction markdownInlineCode(value: string): string {\n const maxBacktickRun = Math.max(\n 0,\n ...Array.from(value.matchAll(/`+/g), (match) => match[0].length),\n );\n const delimiter = '`'.repeat(maxBacktickRun + 1);\n const needsPadding = value.startsWith('`') || value.endsWith('`');\n const content = needsPadding ? ` ${value} ` : value;\n return `${delimiter}${content}${delimiter}`;\n}\n\nfunction warningReason(params: {reportFresh: boolean; harnessKnown: boolean}): WarningReason {\n if (params.harnessKnown) return 'known-absence';\n return params.reportFresh ? 'harness-not-advertised' : 'unknown-or-stale';\n}\n\nfunction writeParamsFromLease(\n lease: LeasedJobContext,\n): Omit<WriteAnnotationsParams, 'originStepId' | 'originStepAttempt' | 'operations'> {\n return {\n workspaceId: lease.workspaceId,\n projectId: lease.projectId,\n workflowRunId: lease.workflowRunId,\n workflowRunAttempt: lease.workflowRunAttempt ?? 1,\n workflowRunAttemptId: lease.workflowRunAttemptId,\n jobId: lease.jobId,\n jobExecutionId: lease.jobExecutionId,\n };\n}\n\nfunction isAnnotationBudgetError(error: unknown): boolean {\n return (\n error instanceof AnnotationBodyTooLargeError ||\n error instanceof AnnotationCountLimitExceededError ||\n error instanceof AnnotationTotalBytesLimitExceededError\n );\n}\n\nfunction recordWarningWriteFailure(reason: WarningFailureReason): void {\n recordWorkflowAgentToolWarningFailed(reason);\n}\n"],"names":["AnnotationBodyTooLargeError","AnnotationCountLimitExceededError","AnnotationTotalBytesLimitExceededError","writeAnnotations","harnessSchema","materializedAgentStepConfigSchema","getEffectiveRunnerToolCapabilities","unadvertisedRunnerTools","logger","recordWorkflowAgentToolWarningFailed","TOOL_LIST_LIMIT","warnAgentToolCapabilityMismatchOnDispatch","params","config","parseAgentConfig","step","requestedTools","tools","length","harness","safeParse","success","effective","runnerSessionId","leaseIdentity","error","recordWarningWriteFailure","warn","jobExecutionId","stepId","id","missing","data","capabilities","context","operation","style","op","body","warningBody","reason","warningReason","reportFresh","harnessKnown","writeParamsFromLease","originStepId","originStepAttempt","currentAttempt","operations","isAnnotationBudgetError","type","parsed","formatToolList","markdownInlineCode","join","visible","slice","map","remaining","value","maxBacktickRun","Math","max","Array","from","matchAll","match","delimiter","repeat","needsPadding","startsWith","endsWith","content","lease","workspaceId","projectId","workflowRunId","workflowRunAttempt","workflowRunAttemptId","jobId"],"mappings":"AAAA,SACEA,2BAA2B,EAC3BC,iCAAiC,EACjCC,sCAAsC,EAEtCC,gBAAgB,QACX,uBAAuB;AAC9B,SACEC,aAAa,EAEbC,iCAAiC,QAC5B,yBAAyB;AAEhC,SAAQC,kCAAkC,EAAEC,uBAAuB,QAAO,uBAAuB;AACjG,SAAQC,MAAM,QAAO,8BAA8B;AACnD,SAAQC,oCAAoC,QAAO,uBAAuB;AAG1E,MAAMC,kBAAkB;AAKxB,OAAO,eAAeC,0CAA0CC,MAG/D;IACC,MAAMC,SAASC,iBAAiBF,OAAOG,IAAI;IAC3C,IAAI,CAACF,QAAQ;IAEb,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warning.ts"],"sourcesContent":["import {\n type AnnotationsInterModuleClient,\n annotationsInterModuleContract,\n} from '@shipfox/annotations-dto/inter-module';\nimport {\n harnessSchema,\n type MaterializedAgentStepConfigDto,\n materializedAgentStepConfigSchema,\n} from '@shipfox/api-agent-dto';\nimport type {LeasedJobContext} from '@shipfox/api-auth-context';\nimport type {RunnersInterModuleClient} from '@shipfox/api-runners-dto/inter-module';\nimport {isInterModuleKnownError} from '@shipfox/inter-module';\nimport {logger} from '@shipfox/node-opentelemetry';\nimport {recordWorkflowAgentToolWarningFailed} from '#metrics/instance.js';\nimport type {Step} from './entities/step.js';\n\nconst TOOL_LIST_LIMIT = 10;\n\ntype WarningFailureReason = 'budget' | 'lookup' | 'write';\ntype WarningReason = 'known-absence' | 'harness-not-advertised' | 'unknown-or-stale';\n\nexport async function warnAgentToolCapabilityMismatchOnDispatch(params: {\n annotations: AnnotationsInterModuleClient;\n runners: RunnersInterModuleClient;\n leaseIdentity: LeasedJobContext;\n step: Step;\n}): Promise<void> {\n const config = parseAgentConfig(params.step);\n if (!config) return;\n\n const requestedTools = config.tools ?? [];\n if (requestedTools.length === 0) return;\n\n const harness = harnessSchema.safeParse(config.harness);\n if (!harness.success) return;\n\n let effective: Awaited<\n ReturnType<RunnersInterModuleClient['getEffectiveRunnerToolCapabilities']>\n >;\n try {\n effective = await params.runners.getEffectiveRunnerToolCapabilities({\n runnerSessionId: params.leaseIdentity.runnerSessionId,\n });\n } catch (error) {\n recordWarningWriteFailure('lookup');\n logger().warn(\n {error, jobExecutionId: params.leaseIdentity.jobExecutionId, stepId: params.step.id},\n 'Failed to read runner tool capabilities for agent tool warning',\n );\n return;\n }\n\n const advertised = new Set(effective.capabilities.harnesses[harness.data]?.tools ?? []);\n const missing = requestedTools.filter((tool) => !advertised.has(tool));\n const context = `agent-tool-capability:${params.step.id}`;\n\n const operation =\n missing.length === 0\n ? {context, style: 'warning' as const, op: 'remove' as const}\n : {\n context,\n style: 'warning' as const,\n op: 'replace' as const,\n body: warningBody({\n harness: harness.data,\n missing,\n reason: warningReason({\n reportFresh: effective.reportFresh,\n harnessKnown: effective.capabilities.harnesses[harness.data] !== undefined,\n }),\n }),\n };\n\n try {\n await params.annotations.replaceOrRemoveAnnotation({\n ...annotationTargetFromLease(params.leaseIdentity),\n originStepId: params.step.id,\n originStepAttempt: params.step.currentAttempt,\n context,\n annotation: operation.op === 'remove' ? {op: 'remove'} : operation,\n });\n } catch (error) {\n const reason = isAnnotationBudgetError(error) ? 'budget' : 'write';\n recordWarningWriteFailure(reason);\n logger().warn(\n {\n error,\n reason,\n jobExecutionId: params.leaseIdentity.jobExecutionId,\n stepId: params.step.id,\n },\n 'Failed to write agent tool capability warning annotation',\n );\n return;\n }\n\n if (missing.length > 0) {\n logger().warn(\n {\n jobExecutionId: params.leaseIdentity.jobExecutionId,\n stepId: params.step.id,\n harness: harness.data,\n missing,\n reason: warningReason({\n reportFresh: effective.reportFresh,\n harnessKnown: effective.capabilities.harnesses[harness.data] !== undefined,\n }),\n },\n 'Runner missing requested agent tools; dispatch is continuing',\n );\n }\n}\n\nfunction parseAgentConfig(step: Step): MaterializedAgentStepConfigDto | null {\n if (step.type !== 'agent') return null;\n\n const parsed = materializedAgentStepConfigSchema.safeParse(step.config);\n return parsed.success ? parsed.data : null;\n}\n\nfunction warningBody(params: {\n harness: string;\n missing: readonly string[];\n reason: WarningReason;\n}): string {\n const tools = formatToolList(params.missing);\n const harness = markdownInlineCode(params.harness);\n if (params.reason === 'known-absence') {\n return [\n '**Runner missing requested agent tools**',\n '',\n `The matched runner advertised a ${harness} tool set without: ${tools}.`,\n 'Execution is continuing on this runner because labels matched; the step may fail if the harness cannot provide these tools.',\n ].join('\\n');\n }\n\n if (params.reason === 'harness-not-advertised') {\n return [\n '**Runner missing requested agent harness tools**',\n '',\n `The matched runner advertised fresh tool capabilities, but did not advertise a ${harness} tool set. Support for ${tools} could not be confirmed.`,\n 'Execution is continuing on this runner because labels matched; the step may fail if the harness cannot provide these tools.',\n ].join('\\n');\n }\n\n return [\n '**Could not confirm runner agent tools**',\n '',\n `The matched runner reported no or stale tool capabilities, so support for ${tools} could not be confirmed.`,\n 'Execution is continuing on this runner because labels matched.',\n ].join('\\n');\n}\n\nfunction formatToolList(tools: readonly string[]): string {\n const visible = tools.slice(0, TOOL_LIST_LIMIT).map(markdownInlineCode);\n const remaining = tools.length - visible.length;\n return remaining > 0 ? `${visible.join(', ')} ...and ${remaining} more` : visible.join(', ');\n}\n\nfunction markdownInlineCode(value: string): string {\n const maxBacktickRun = Math.max(\n 0,\n ...Array.from(value.matchAll(/`+/g), (match) => match[0].length),\n );\n const delimiter = '`'.repeat(maxBacktickRun + 1);\n const needsPadding = value.startsWith('`') || value.endsWith('`');\n const content = needsPadding ? ` ${value} ` : value;\n return `${delimiter}${content}${delimiter}`;\n}\n\nfunction warningReason(params: {reportFresh: boolean; harnessKnown: boolean}): WarningReason {\n if (params.harnessKnown) return 'known-absence';\n return params.reportFresh ? 'harness-not-advertised' : 'unknown-or-stale';\n}\n\nfunction annotationTargetFromLease(\n lease: LeasedJobContext,\n): Omit<\n Parameters<AnnotationsInterModuleClient['replaceOrRemoveAnnotation']>[0],\n 'originStepId' | 'originStepAttempt' | 'context' | 'annotation'\n> {\n return {\n workspaceId: lease.workspaceId,\n projectId: lease.projectId,\n workflowRunId: lease.workflowRunId,\n workflowRunAttempt: lease.workflowRunAttempt ?? 1,\n workflowRunAttemptId: lease.workflowRunAttemptId,\n jobId: lease.jobId,\n jobExecutionId: lease.jobExecutionId,\n };\n}\n\nfunction isAnnotationBudgetError(error: unknown): boolean {\n return isInterModuleKnownError(\n annotationsInterModuleContract.methods.replaceOrRemoveAnnotation,\n error,\n );\n}\n\nfunction recordWarningWriteFailure(reason: WarningFailureReason): void {\n recordWorkflowAgentToolWarningFailed(reason);\n}\n"],"names":["annotationsInterModuleContract","harnessSchema","materializedAgentStepConfigSchema","isInterModuleKnownError","logger","recordWorkflowAgentToolWarningFailed","TOOL_LIST_LIMIT","warnAgentToolCapabilityMismatchOnDispatch","params","config","parseAgentConfig","step","requestedTools","tools","length","harness","safeParse","success","effective","runners","getEffectiveRunnerToolCapabilities","runnerSessionId","leaseIdentity","error","recordWarningWriteFailure","warn","jobExecutionId","stepId","id","advertised","Set","capabilities","harnesses","data","missing","filter","tool","has","context","operation","style","op","body","warningBody","reason","warningReason","reportFresh","harnessKnown","undefined","annotations","replaceOrRemoveAnnotation","annotationTargetFromLease","originStepId","originStepAttempt","currentAttempt","annotation","isAnnotationBudgetError","type","parsed","formatToolList","markdownInlineCode","join","visible","slice","map","remaining","value","maxBacktickRun","Math","max","Array","from","matchAll","match","delimiter","repeat","needsPadding","startsWith","endsWith","content","lease","workspaceId","projectId","workflowRunId","workflowRunAttempt","workflowRunAttemptId","jobId","methods"],"mappings":"AAAA,SAEEA,8BAA8B,QACzB,wCAAwC;AAC/C,SACEC,aAAa,EAEbC,iCAAiC,QAC5B,yBAAyB;AAGhC,SAAQC,uBAAuB,QAAO,wBAAwB;AAC9D,SAAQC,MAAM,QAAO,8BAA8B;AACnD,SAAQC,oCAAoC,QAAO,uBAAuB;AAG1E,MAAMC,kBAAkB;AAKxB,OAAO,eAAeC,0CAA0CC,MAK/D;IACC,MAAMC,SAASC,iBAAiBF,OAAOG,IAAI;IAC3C,IAAI,CAACF,QAAQ;IAEb,MAAMG,iBAAiBH,OAAOI,KAAK,IAAI,EAAE;IACzC,IAAID,eAAeE,MAAM,KAAK,GAAG;IAEjC,MAAMC,UAAUd,cAAce,SAAS,CAACP,OAAOM,OAAO;IACtD,IAAI,CAACA,QAAQE,OAAO,EAAE;IAEtB,IAAIC;IAGJ,IAAI;QACFA,YAAY,MAAMV,OAAOW,OAAO,CAACC,kCAAkC,CAAC;YAClEC,iBAAiBb,OAAOc,aAAa,CAACD,eAAe;QACvD;IACF,EAAE,OAAOE,OAAO;QACdC,0BAA0B;QAC1BpB,SAASqB,IAAI,CACX;YAACF;YAAOG,gBAAgBlB,OAAOc,aAAa,CAAC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AAGH,QAAQD,IAAI,CAAC,MAAM,QAAQ,EAAEI,UAAU,KAAK,CAAC,GAAGH,QAAQD,IAAI,CAAC;AACzF;AAEA,SAASD,mBAAmBM,KAAa;IACvC,MAAMC,iBAAiBC,KAAKC,GAAG,CAC7B,MACGC,MAAMC,IAAI,CAACL,MAAMM,QAAQ,CAAC,QAAQ,CAACC,QAAUA,KAAK,CAAC,EAAE,CAAC3D,MAAM;IAEjE,MAAM4D,YAAY,IAAIC,MAAM,CAACR,iBAAiB;IAC9C,MAAMS,eAAeV,MAAMW,UAAU,CAAC,QAAQX,MAAMY,QAAQ,CAAC;IAC7D,MAAMC,UAAUH,eAAe,CAAC,CAAC,EAAEV,MAAM,CAAC,CAAC,GAAGA;IAC9C,OAAO,GAAGQ,YAAYK,UAAUL,WAAW;AAC7C;AAEA,SAAS7B,cAAcrC,MAAqD;IAC1E,IAAIA,OAAOuC,YAAY,EAAE,OAAO;IAChC,OAAOvC,OAAOsC,WAAW,GAAG,2BAA2B;AACzD;AAEA,SAASK,0BACP6B,KAAuB;IAKvB,OAAO;QACLC,aAAaD,MAAMC,WAAW;QAC9BC,WAAWF,MAAME,SAAS;QAC1BC,eAAeH,MAAMG,aAAa;QAClCC,oBAAoBJ,MAAMI,kBAAkB,IAAI;QAChDC,sBAAsBL,MAAMK,oBAAoB;QAChDC,OAAON,MAAMM,KAAK;QAClB5D,gBAAgBsD,MAAMtD,cAAc;IACtC;AACF;AAEA,SAAS8B,wBAAwBjC,KAAc;IAC7C,OAAOpB,wBACLH,+BAA+BuF,OAAO,CAACrC,yBAAyB,EAChE3B;AAEJ;AAEA,SAASC,0BAA0BoB,MAA4B;IAC7DvC,qCAAqCuC;AACvC"}
@@ -1,16 +1,18 @@
1
1
  import type { MaterializedAgentIntegrationConfigDto } from '@shipfox/api-agent-dto';
2
- import type { WorkflowModel } from '@shipfox/api-definitions';
3
- import type { AgentToolCatalogs, GetIntegrationConnectionByIdFn, IntegrationProviderKind, LoadWorkspaceConnectionSnapshot, WorkspaceConnectionSnapshot } from '@shipfox/api-integration-core';
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';
4
5
  type WorkflowModelJob = WorkflowModel['jobs'][number];
5
6
  type WorkflowModelAgentStep = Extract<WorkflowModelJob['steps'][number], {
6
7
  kind: 'agent';
7
8
  }>;
8
9
  type WorkflowModelStepIntegration = NonNullable<WorkflowModelAgentStep['integrations']>[number];
9
- interface AgentToolMaterializationServices {
10
- readonly catalogs: AgentToolCatalogs;
11
- readonly loadWorkspaceConnectionSnapshot: LoadWorkspaceConnectionSnapshot;
12
- readonly getIntegrationConnectionById: GetIntegrationConnectionByIdFn;
13
- }
10
+ type AgentToolCatalogs = ReadonlyMap<IntegrationProviderKind, readonly AgentToolCatalogEntry[]>;
11
+ type WorkspaceConnectionSnapshot = ReadonlyMap<string, {
12
+ id: string;
13
+ provider: IntegrationProviderKind;
14
+ capabilities: readonly ('source_control' | 'agent_tools')[];
15
+ }>;
14
16
  export interface AgentToolMaterializationContext {
15
17
  readonly catalogs: AgentToolCatalogs;
16
18
  readonly workspaceConnectionSnapshot: WorkspaceConnectionSnapshot;
@@ -28,12 +30,12 @@ export interface AgentToolMaterializationSnapshotStep {
28
30
  readonly stepId: string;
29
31
  readonly integrations: readonly MaterializedAgentIntegrationConfigDto[];
30
32
  }
31
- export declare function setAgentToolMaterializationServices(nextServices: AgentToolMaterializationServices): void;
32
- export declare function clearAgentToolMaterializationServices(): void;
33
33
  export declare function loadAgentToolMaterializationContext(params: {
34
34
  readonly model: WorkflowModel | null;
35
35
  readonly workspaceId: string;
36
36
  readonly projectId: string;
37
+ readonly integrations?: IntegrationsModuleClient | undefined;
38
+ readonly projects?: ProjectsModuleClient | undefined;
37
39
  readonly jobs?: readonly WorkflowModelJob[] | undefined;
38
40
  }): Promise<AgentToolMaterializationContext | undefined>;
39
41
  export declare function materializeAgentIntegrations(params: {
@@ -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,0BAA0B,CAAC;AAC5D,OAAO,KAAK,EAGV,iBAAiB,EACjB,8BAA8B,EAC9B,uBAAuB,EACvB,+BAA+B,EAC/B,2BAA2B,EAC5B,MAAM,+BAA+B,CAAC;AAIvC,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;AAEhG,UAAU,gCAAgC;IACxC,QAAQ,CAAC,QAAQ,EAAE,iBAAiB,CAAC;IACrC,QAAQ,CAAC,+BAA+B,EAAE,+BAA+B,CAAC;IAC1E,QAAQ,CAAC,4BAA4B,EAAE,8BAA8B,CAAC;CACvE;AAED,MAAM,WAAW,+BAA+B;IAC9C,QAAQ,CAAC,QAAQ,EAAE,iBAAiB,CAAC;IACrC,QAAQ,CAAC,2BAA2B,EAAE,2BAA2B,CAAC;IAClE,QAAQ,CAAC,iBAAiB,EAAE;QAC1B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;QACpB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;QACtB,QAAQ,CAAC,QAAQ,EAAE,uBAAuB,CAAC;KAC5C,CAAC;CACH;AAED,MAAM,WAAW,gCAAgC;IAC/C,QAAQ,CAAC,KAAK,EAAE,SA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C,GAAG,IAAI,CAwB1C"}
@@ -1,30 +1,35 @@
1
- import { getProjectById } from '@shipfox/api-projects';
2
1
  import { AgentIntegrationMaterializationError } from './errors.js';
3
- let services;
4
- export function setAgentToolMaterializationServices(nextServices) {
5
- services = nextServices;
6
- }
7
- export function clearAgentToolMaterializationServices() {
8
- services = undefined;
9
- }
10
2
  export async function loadAgentToolMaterializationContext(params) {
11
3
  if (!modelHasAgentStepIntegrations(params.model, params.jobs)) return undefined;
12
- if (services === undefined) {
13
- throw new AgentIntegrationMaterializationError('Agent tool materialization is not configured');
4
+ if (params.projects === undefined) {
5
+ throw new AgentIntegrationMaterializationError('Project access is not configured');
14
6
  }
15
- const project = await getProjectById(params.projectId);
16
- if (project === undefined) {
7
+ const { project } = await params.projects.getProjectById({
8
+ projectId: params.projectId
9
+ });
10
+ if (project === null) {
17
11
  throw new AgentIntegrationMaterializationError(`Project ${params.projectId} was not found while materializing agent integrations`);
18
12
  }
19
- const [workspaceConnectionSnapshot, defaultConnection] = await Promise.all([
20
- services.loadWorkspaceConnectionSnapshot(params.workspaceId),
21
- services.getIntegrationConnectionById(project.sourceConnectionId)
22
- ]);
23
- if (defaultConnection === undefined) {
13
+ if (params.integrations === undefined) {
14
+ throw new AgentIntegrationMaterializationError('Agent tool materialization is not configured');
15
+ }
16
+ const context = await params.integrations.getAgentToolsContext({
17
+ workspaceId: params.workspaceId,
18
+ defaultConnectionId: project.sourceConnectionId
19
+ });
20
+ const workspaceConnectionSnapshot = new Map(context.workspaceConnections.map(({ slug, ...connection })=>[
21
+ slug,
22
+ connection
23
+ ]));
24
+ const defaultConnection = context.defaultConnection;
25
+ if (defaultConnection === null) {
24
26
  throw new AgentIntegrationMaterializationError(`Source connection ${project.sourceConnectionId} was not found while materializing agent integrations`);
25
27
  }
26
28
  return {
27
- catalogs: services.catalogs,
29
+ catalogs: new Map(context.catalogs.map(({ provider, tools })=>[
30
+ provider,
31
+ tools
32
+ ])),
28
33
  workspaceConnectionSnapshot,
29
34
  defaultConnection: {
30
35
  id: defaultConnection.id,
@@ -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';\nimport type {\n AgentToolCatalogEntry,\n AgentToolCatalogMethod,\n AgentToolCatalogs,\n GetIntegrationConnectionByIdFn,\n IntegrationProviderKind,\n LoadWorkspaceConnectionSnapshot,\n WorkspaceConnectionSnapshot,\n} from '@shipfox/api-integration-core';\nimport {getProjectById} from '@shipfox/api-projects';\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];\n\ninterface AgentToolMaterializationServices {\n readonly catalogs: AgentToolCatalogs;\n readonly loadWorkspaceConnectionSnapshot: LoadWorkspaceConnectionSnapshot;\n readonly getIntegrationConnectionById: GetIntegrationConnectionByIdFn;\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\nlet services: AgentToolMaterializationServices | undefined;\n\nexport function setAgentToolMaterializationServices(\n nextServices: AgentToolMaterializationServices,\n): void {\n services = nextServices;\n}\n\nexport function clearAgentToolMaterializationServices(): void {\n services = undefined;\n}\n\nexport async function loadAgentToolMaterializationContext(params: {\n readonly model: WorkflowModel | null;\n readonly workspaceId: string;\n readonly projectId: string;\n readonly jobs?: readonly WorkflowModelJob[] | undefined;\n}): Promise<AgentToolMaterializationContext | undefined> {\n if (!modelHasAgentStepIntegrations(params.model, params.jobs)) return undefined;\n if (services === undefined) {\n throw new AgentIntegrationMaterializationError('Agent tool materialization is not configured');\n }\n\n const project = await getProjectById(params.projectId);\n if (project === undefined) {\n throw new AgentIntegrationMaterializationError(\n `Project ${params.projectId} was not found while materializing agent integrations`,\n );\n }\n\n const [workspaceConnectionSnapshot, defaultConnection] = await Promise.all([\n services.loadWorkspaceConnectionSnapshot(params.workspaceId),\n services.getIntegrationConnectionById(project.sourceConnectionId),\n ]);\n if (defaultConnection === undefined) {\n throw new AgentIntegrationMaterializationError(\n `Source connection ${project.sourceConnectionId} was not found while materializing agent integrations`,\n );\n }\n\n return {\n catalogs: services.catalogs,\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":["getProjectById","AgentIntegrationMaterializationError","services","setAgentToolMaterializationServices","nextServices","clearAgentToolMaterializationServices","undefined","loadAgentToolMaterializationContext","params","modelHasAgentStepIntegrations","model","jobs","project","projectId","workspaceConnectionSnapshot","defaultConnection","Promise","all","loadWorkspaceConnectionSnapshot","workspaceId","getIntegrationConnectionById","sourceConnectionId","catalogs","id","slug","provider","materializeAgentIntegrations","snapshot","findSnapshotStep","integrations","map","copyMaterializedIntegration","context","integration","materializeAgentIntegration","createAgentToolMaterializationSnapshot","steps","flatMap","job","step","kind","jobKey","key","stepId","length","find","connection","resolveConnection","catalog","get","tools","selectTools","include","exclude","requiredScope","mergeRequiredScopes","tool","connectionId","connectionSlug","methods","method","selected","Map","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":"AAcA,SAAQA,cAAc,QAAO,wBAAwB;AACrD,SAAQC,oCAAoC,QAAO,cAAc;AAsCjE,IAAIC;AAEJ,OAAO,SAASC,oCACdC,YAA8C;IAE9CF,WAAWE;AACb;AAEA,OAAO,SAASC;IACdH,WAAWI;AACb;AAEA,OAAO,eAAeC,oCAAoCC,MAKzD;IACC,IAAI,CAACC,8BAA8BD,OAAOE,KAAK,EAAEF,OAAOG,IAAI,GAAG,OAAOL;IACtE,IAAIJ,aAAaI,WAAW;QAC1B,MAAM,IAAIL,qCAAqC;IACjD;IAEA,MAAMW,UAAU,MAAMZ,eAAeQ,OAAOK,SAAS;IACrD,IAAID,YAAYN,WAAW;QACzB,MAAM,IAAIL,qCACR,CAAC,QAAQ,EAAEO,OAAOK,SAAS,CAAC,qDAAqD,CAAC;IAEtF;IAEA,MAAM,CAACC,6BAA6BC,kBAAkB,GAAG,MAAMC,QAAQC,GAAG,CAAC;QACzEf,SAASgB,+BAA+B,CAACV,OAAOW,WAAW;QAC3DjB,SAASkB,4BAA4B,CAACR,QAAQS,kBA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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;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WAAWD,KAAK3B,YAAY,KAAKL;AAE5E"}
@@ -1,4 +1,5 @@
1
- import type { CheckoutSpec, IntegrationSourceControlService } from '@shipfox/api-integration-core';
1
+ import type { IntegrationsModuleClient } from '@shipfox/api-integration-core-dto';
2
+ import type { ProjectsModuleClient } from '@shipfox/api-projects-dto';
2
3
  export interface CheckoutIntent {
3
4
  workspaceId: string;
4
5
  connectionId: string;
@@ -13,17 +14,30 @@ export interface CheckoutIntent {
13
14
  * (`workflowRunId`/`workflowRunAttemptId`/`workspaceId` in the lease claim are informational).
14
15
  * Chain: job → attempt → run → project source metadata. Credential-free.
15
16
  */
16
- export declare function resolveCheckoutIntent(jobId: string): Promise<CheckoutIntent>;
17
+ export declare function resolveCheckoutIntent(jobId: string, projects: ProjectsModuleClient): Promise<CheckoutIntent>;
17
18
  /**
18
19
  * Resolves the job's checkout intent and exchanges it for a short-lived,
19
- * scoped checkout spec. `ref` is left undefined so the provider defaults to the
20
- * repository's default branch.
20
+ * scoped checkout spec. Omitting `ref` lets the provider use the repository's
21
+ * default branch while preserving the JSON-only inter-module boundary.
21
22
  */
22
- export declare function createJobCheckoutSpec({ jobId, sourceControl, }: {
23
+ export declare function createJobCheckoutSpec({ jobId, integrations, projects, }: {
23
24
  jobId: string;
24
- sourceControl: IntegrationSourceControlService;
25
+ integrations: IntegrationsModuleClient;
26
+ projects: ProjectsModuleClient;
25
27
  }): Promise<{
26
- spec: CheckoutSpec;
28
+ spec: {
29
+ repositoryUrl: string;
30
+ ref: string;
31
+ credentials?: {
32
+ username: string;
33
+ token: string;
34
+ expiresAt: Date;
35
+ };
36
+ gitAuthor?: {
37
+ name: string;
38
+ email: string;
39
+ };
40
+ };
27
41
  persistCredentials: boolean;
28
42
  }>;
29
43
  //# sourceMappingURL=checkout.d.ts.map