@skaile/workspaces 6.4.0 → 6.6.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 (405) hide show
  1. package/CHANGELOG.md +58 -1
  2. package/README.md +4 -0
  3. package/dist/ai-sdk.js +55 -25
  4. package/dist/ai-sdk.js.map +1 -1
  5. package/dist/app-sdk/index.js +1 -1
  6. package/dist/{asset-feeds-UJSYGKCX.js → asset-feeds-WQ6YQPHV.js} +22 -22
  7. package/dist/{asset-feeds-UJSYGKCX.js.map → asset-feeds-WQ6YQPHV.js.map} +1 -1
  8. package/dist/asset-manager/catalog-deployer.js +8 -8
  9. package/dist/asset-manager/index.js +14 -14
  10. package/dist/asset-manager/installer.js +10 -10
  11. package/dist/asset-manager/renderers.js +9 -9
  12. package/dist/asset-manager/src/index.d.ts +114 -12
  13. package/dist/asset-manager/src/index.d.ts.map +1 -1
  14. package/dist/asset-manager/src/installer.d.ts +6 -0
  15. package/dist/asset-manager/src/installer.d.ts.map +1 -1
  16. package/dist/bridge/harnesses/claude-sdk.js +24 -19
  17. package/dist/bridge/harnesses/claude-sdk.js.map +1 -1
  18. package/dist/bridge/harnesses/codex.js +38 -36
  19. package/dist/bridge/harnesses/codex.js.map +1 -1
  20. package/dist/bridge/harnesses/continue.js +12 -13
  21. package/dist/bridge/harnesses/continue.js.map +1 -1
  22. package/dist/bridge/harnesses/echo.js +5 -6
  23. package/dist/bridge/harnesses/echo.js.map +1 -1
  24. package/dist/bridge/harnesses/gemini.js +9 -10
  25. package/dist/bridge/harnesses/goose.js +12 -13
  26. package/dist/bridge/harnesses/goose.js.map +1 -1
  27. package/dist/bridge/harnesses/omp.js +17 -12
  28. package/dist/bridge/harnesses/omp.js.map +1 -1
  29. package/dist/bridge/harnesses/opencode.js +12 -13
  30. package/dist/bridge/harnesses/opencode.js.map +1 -1
  31. package/dist/bridge/harnesses/qwen.js +9 -10
  32. package/dist/bridge/harnesses/qwen.js.map +1 -1
  33. package/dist/bridge/index.js +20 -21
  34. package/dist/bridge/src/ai-sdk.d.ts +0 -2
  35. package/dist/bridge/src/ai-sdk.d.ts.map +1 -1
  36. package/dist/bridge/src/codex/login-fallback.d.ts +39 -0
  37. package/dist/bridge/src/codex/login-fallback.d.ts.map +1 -0
  38. package/dist/bridge/src/error-classifier.d.ts +6 -0
  39. package/dist/bridge/src/error-classifier.d.ts.map +1 -1
  40. package/dist/bridge/src/harnesses/claude-sdk.d.ts.map +1 -1
  41. package/dist/bridge/src/harnesses/codex.d.ts +0 -6
  42. package/dist/bridge/src/harnesses/codex.d.ts.map +1 -1
  43. package/dist/bridge/src/harnesses/omp.d.ts.map +1 -1
  44. package/dist/bridge/src/index.d.ts +1 -0
  45. package/dist/bridge/src/index.d.ts.map +1 -1
  46. package/dist/{chunk-GTMANMBZ.js → chunk-2M3VLKT2.js} +3 -3
  47. package/dist/{chunk-GTMANMBZ.js.map → chunk-2M3VLKT2.js.map} +1 -1
  48. package/dist/{chunk-2WOA3TKK.js → chunk-2TLPC6TQ.js} +34 -19
  49. package/dist/chunk-2TLPC6TQ.js.map +1 -0
  50. package/dist/{chunk-O7KAQQAI.js → chunk-4BFEPZ6J.js} +4 -4
  51. package/dist/{chunk-O7KAQQAI.js.map → chunk-4BFEPZ6J.js.map} +1 -1
  52. package/dist/{chunk-TPQKFX6X.js → chunk-4J7JQX4G.js} +4 -4
  53. package/dist/{chunk-TPQKFX6X.js.map → chunk-4J7JQX4G.js.map} +1 -1
  54. package/dist/{chunk-6OHZUUR7.js → chunk-5DE3DGVR.js} +11 -5
  55. package/dist/chunk-5DE3DGVR.js.map +1 -0
  56. package/dist/{chunk-Q4XWCVFA.js → chunk-5ETYBC2X.js} +8 -8
  57. package/dist/{chunk-Q4XWCVFA.js.map → chunk-5ETYBC2X.js.map} +1 -1
  58. package/dist/{chunk-ZWCGJYR7.js → chunk-5XHQBCB5.js} +3 -3
  59. package/dist/{chunk-ZWCGJYR7.js.map → chunk-5XHQBCB5.js.map} +1 -1
  60. package/dist/{chunk-JSWMRYLM.js → chunk-65UAC3ZR.js} +31 -7
  61. package/dist/chunk-65UAC3ZR.js.map +1 -0
  62. package/dist/{chunk-UBLZALKP.js → chunk-6A6HE5LW.js} +3 -3
  63. package/dist/{chunk-UBLZALKP.js.map → chunk-6A6HE5LW.js.map} +1 -1
  64. package/dist/{chunk-ABVWUM2E.js → chunk-6ARPZHOV.js} +47 -25
  65. package/dist/chunk-6ARPZHOV.js.map +1 -0
  66. package/dist/{chunk-TDKZL5ZC.js → chunk-6RHWTZPT.js} +4 -4
  67. package/dist/{chunk-TDKZL5ZC.js.map → chunk-6RHWTZPT.js.map} +1 -1
  68. package/dist/{chunk-6WQGJF65.js → chunk-6SXSVKQY.js} +88 -17
  69. package/dist/chunk-6SXSVKQY.js.map +1 -0
  70. package/dist/{chunk-YFGXYQW4.js → chunk-7I5PNB2G.js} +3 -3
  71. package/dist/{chunk-YFGXYQW4.js.map → chunk-7I5PNB2G.js.map} +1 -1
  72. package/dist/{serve-preflight-NPWI4MV6.js → chunk-7PVGND4J.js} +30 -61
  73. package/dist/chunk-7PVGND4J.js.map +1 -0
  74. package/dist/{chunk-P7EL7QRD.js → chunk-7SJHSGUV.js} +34 -20
  75. package/dist/chunk-7SJHSGUV.js.map +1 -0
  76. package/dist/{chunk-VSCLUPGZ.js → chunk-AQNW2FET.js} +289 -44
  77. package/dist/chunk-AQNW2FET.js.map +1 -0
  78. package/dist/{chunk-45KLCFQB.js → chunk-B6N653ZG.js} +6 -6
  79. package/dist/{chunk-45KLCFQB.js.map → chunk-B6N653ZG.js.map} +1 -1
  80. package/dist/{chunk-6UP2EDFN.js → chunk-BSMW3PX2.js} +313 -4
  81. package/dist/chunk-BSMW3PX2.js.map +1 -0
  82. package/dist/{chunk-HTGTNN2B.js → chunk-CMXDFTA2.js} +3 -3
  83. package/dist/{chunk-HTGTNN2B.js.map → chunk-CMXDFTA2.js.map} +1 -1
  84. package/dist/{chunk-YJNE4V2M.js → chunk-DI6J2PJB.js} +70 -37
  85. package/dist/chunk-DI6J2PJB.js.map +1 -0
  86. package/dist/{chunk-V4OXHEWY.js → chunk-DS6UUCFG.js} +4 -4
  87. package/dist/{chunk-V4OXHEWY.js.map → chunk-DS6UUCFG.js.map} +1 -1
  88. package/dist/{chunk-U6S5CXKB.js → chunk-E2EC6SAX.js} +4 -4
  89. package/dist/{chunk-U6S5CXKB.js.map → chunk-E2EC6SAX.js.map} +1 -1
  90. package/dist/{chunk-TF5CWJQZ.js → chunk-EPXZQIC6.js} +23 -80
  91. package/dist/chunk-EPXZQIC6.js.map +1 -0
  92. package/dist/{chunk-6X3GDPCB.js → chunk-F4CZQD3T.js} +3 -4
  93. package/dist/chunk-F4CZQD3T.js.map +1 -0
  94. package/dist/{chunk-VZU67OKK.js → chunk-G5SYFFMD.js} +2 -2
  95. package/dist/{chunk-VZU67OKK.js.map → chunk-G5SYFFMD.js.map} +1 -1
  96. package/dist/{chunk-VV2DJT4I.js → chunk-GNUA7XT2.js} +4 -3
  97. package/dist/chunk-GNUA7XT2.js.map +1 -0
  98. package/dist/{chunk-E237FGGX.js → chunk-GTAHU4N4.js} +4 -4
  99. package/dist/{chunk-E237FGGX.js.map → chunk-GTAHU4N4.js.map} +1 -1
  100. package/dist/{chunk-SISUT7VR.js → chunk-GTGWRKMJ.js} +7 -7
  101. package/dist/{chunk-SISUT7VR.js.map → chunk-GTGWRKMJ.js.map} +1 -1
  102. package/dist/{chunk-BX7PSWJA.js → chunk-HGZN6JLP.js} +4 -4
  103. package/dist/{chunk-BX7PSWJA.js.map → chunk-HGZN6JLP.js.map} +1 -1
  104. package/dist/{chunk-L45IHRDH.js → chunk-HQAPUPBE.js} +3 -3
  105. package/dist/{chunk-L45IHRDH.js.map → chunk-HQAPUPBE.js.map} +1 -1
  106. package/dist/{chunk-L4OYPFLB.js → chunk-I5IF3JCG.js} +4 -4
  107. package/dist/{chunk-L4OYPFLB.js.map → chunk-I5IF3JCG.js.map} +1 -1
  108. package/dist/{chunk-IYZAJ2J2.js → chunk-J262X4JU.js} +36 -36
  109. package/dist/chunk-J262X4JU.js.map +1 -0
  110. package/dist/{chunk-WENTJ5KP.js → chunk-J4WKNJHO.js} +6 -6
  111. package/dist/{chunk-WENTJ5KP.js.map → chunk-J4WKNJHO.js.map} +1 -1
  112. package/dist/{chunk-3ENE6ZOF.js → chunk-JIQUF3X2.js} +9 -8
  113. package/dist/chunk-JIQUF3X2.js.map +1 -0
  114. package/dist/{chunk-TGB4E5Z6.js → chunk-JRVQV7WC.js} +414 -95
  115. package/dist/chunk-JRVQV7WC.js.map +1 -0
  116. package/dist/{chunk-BOS7P2Y4.js → chunk-KSH5CFQS.js} +3 -3
  117. package/dist/{chunk-BOS7P2Y4.js.map → chunk-KSH5CFQS.js.map} +1 -1
  118. package/dist/{chunk-UUKCPPTQ.js → chunk-KSUT5KAE.js} +3 -3
  119. package/dist/{chunk-UUKCPPTQ.js.map → chunk-KSUT5KAE.js.map} +1 -1
  120. package/dist/{chunk-DF5WJC3Q.js → chunk-LBJ4M5J2.js} +4 -4
  121. package/dist/{chunk-DF5WJC3Q.js.map → chunk-LBJ4M5J2.js.map} +1 -1
  122. package/dist/{chunk-GBXQFJ4G.js → chunk-MMOWIRHP.js} +310 -175
  123. package/dist/chunk-MMOWIRHP.js.map +1 -0
  124. package/dist/{chunk-G63KOHFS.js → chunk-MXI3XWV6.js} +4 -4
  125. package/dist/{chunk-G63KOHFS.js.map → chunk-MXI3XWV6.js.map} +1 -1
  126. package/dist/{chunk-ACBL7X62.js → chunk-N2PBAXAA.js} +3 -3
  127. package/dist/{chunk-ACBL7X62.js.map → chunk-N2PBAXAA.js.map} +1 -1
  128. package/dist/{chunk-5NHBLKKU.js → chunk-O7QZI6MQ.js} +3 -3
  129. package/dist/{chunk-5NHBLKKU.js.map → chunk-O7QZI6MQ.js.map} +1 -1
  130. package/dist/{chunk-U3SXCVR7.js → chunk-OY22B7E2.js} +4 -4
  131. package/dist/{chunk-U3SXCVR7.js.map → chunk-OY22B7E2.js.map} +1 -1
  132. package/dist/{chunk-C7TQARGC.js → chunk-PTJTOPE5.js} +3 -3
  133. package/dist/{chunk-C7TQARGC.js.map → chunk-PTJTOPE5.js.map} +1 -1
  134. package/dist/{chunk-HSF665NV.js → chunk-RAU5QPI6.js} +5 -5
  135. package/dist/{chunk-HSF665NV.js.map → chunk-RAU5QPI6.js.map} +1 -1
  136. package/dist/{chunk-RKI35EAN.js → chunk-RHCEX2EV.js} +3 -3
  137. package/dist/{chunk-RKI35EAN.js.map → chunk-RHCEX2EV.js.map} +1 -1
  138. package/dist/{chunk-76WSWPOB.js → chunk-SCRYXAHH.js} +15 -6
  139. package/dist/chunk-SCRYXAHH.js.map +1 -0
  140. package/dist/{chunk-DKXNKFKP.js → chunk-SGI5MRKP.js} +75 -3
  141. package/dist/chunk-SGI5MRKP.js.map +1 -0
  142. package/dist/{chunk-24D7IW5O.js → chunk-SHTXMERQ.js} +7 -8
  143. package/dist/chunk-SHTXMERQ.js.map +1 -0
  144. package/dist/{chunk-IZV3HDVG.js → chunk-SZKCE7EC.js} +5 -5
  145. package/dist/{chunk-IZV3HDVG.js.map → chunk-SZKCE7EC.js.map} +1 -1
  146. package/dist/{chunk-UAOHR6AL.js → chunk-TCH5UDKT.js} +4 -4
  147. package/dist/{chunk-UAOHR6AL.js.map → chunk-TCH5UDKT.js.map} +1 -1
  148. package/dist/{chunk-UVTN4O7N.js → chunk-TUFNY6OD.js} +33 -10
  149. package/dist/chunk-TUFNY6OD.js.map +1 -0
  150. package/dist/{chunk-PTBX55QF.js → chunk-U3UDOX6I.js} +4 -4
  151. package/dist/{chunk-PTBX55QF.js.map → chunk-U3UDOX6I.js.map} +1 -1
  152. package/dist/{chunk-BUU2DLPC.js → chunk-USSP43U3.js} +3 -3
  153. package/dist/{chunk-BUU2DLPC.js.map → chunk-USSP43U3.js.map} +1 -1
  154. package/dist/{chunk-IZQOO6MN.js → chunk-V5KG6CCV.js} +2 -2
  155. package/dist/{chunk-IZQOO6MN.js.map → chunk-V5KG6CCV.js.map} +1 -1
  156. package/dist/{chunk-CK3CJSRY.js → chunk-VJRL6ZK6.js} +4 -4
  157. package/dist/{chunk-CK3CJSRY.js.map → chunk-VJRL6ZK6.js.map} +1 -1
  158. package/dist/{chunk-76FLBODK.js → chunk-VT6G5AJV.js} +10 -7
  159. package/dist/chunk-VT6G5AJV.js.map +1 -0
  160. package/dist/{chunk-EXRQKOY6.js → chunk-VXYZ5M7Z.js} +83 -34
  161. package/dist/chunk-VXYZ5M7Z.js.map +1 -0
  162. package/dist/{chunk-QSIFEHSN.js → chunk-WW5NAU6N.js} +3 -3
  163. package/dist/{chunk-QSIFEHSN.js.map → chunk-WW5NAU6N.js.map} +1 -1
  164. package/dist/chunk-XD3RYAMR.js +83 -0
  165. package/dist/chunk-XD3RYAMR.js.map +1 -0
  166. package/dist/{chunk-HXZ3FQQN.js → chunk-XYCYGN3Q.js} +82 -50
  167. package/dist/chunk-XYCYGN3Q.js.map +1 -0
  168. package/dist/{chunk-5T3DTK7A.js → chunk-YN6N3RBM.js} +9 -10
  169. package/dist/chunk-YN6N3RBM.js.map +1 -0
  170. package/dist/{chunk-DCJ4BION.js → chunk-Z4FERR4U.js} +2 -2
  171. package/dist/{chunk-DCJ4BION.js.map → chunk-Z4FERR4U.js.map} +1 -1
  172. package/dist/{claude-code-UBT4ZME7.js → claude-code-LZH7Y4Y5.js} +5 -5
  173. package/dist/{claude-code-UBT4ZME7.js.map → claude-code-LZH7Y4Y5.js.map} +1 -1
  174. package/dist/cli/index.js +308 -162
  175. package/dist/cli/index.js.map +1 -1
  176. package/dist/cli/src/commands/cache.d.ts.map +1 -1
  177. package/dist/cli/src/commands/catalog.d.ts.map +1 -1
  178. package/dist/cli/src/commands/config.d.ts.map +1 -1
  179. package/dist/cli/src/commands/connector.d.ts.map +1 -1
  180. package/dist/cli/src/commands/deploy.d.ts.map +1 -1
  181. package/dist/cli/src/commands/harness.d.ts +5 -4
  182. package/dist/cli/src/commands/harness.d.ts.map +1 -1
  183. package/dist/cli/src/commands/integration.d.ts.map +1 -1
  184. package/dist/cli/src/commands/library-cmd.d.ts.map +1 -1
  185. package/dist/cli/src/commands/library-index.d.ts +6 -0
  186. package/dist/cli/src/commands/library-index.d.ts.map +1 -1
  187. package/dist/cli/src/commands/migrate-files.d.ts +3 -6
  188. package/dist/cli/src/commands/migrate-files.d.ts.map +1 -1
  189. package/dist/cli/src/commands/migrate-harness.d.ts +4 -3
  190. package/dist/cli/src/commands/migrate-harness.d.ts.map +1 -1
  191. package/dist/cli/src/commands/migrate.d.ts +2 -2
  192. package/dist/cli/src/commands/outdated.d.ts.map +1 -1
  193. package/dist/cli/src/commands/plugin-registry-cmd.d.ts.map +1 -1
  194. package/dist/cli/src/commands/project.d.ts +7 -1
  195. package/dist/cli/src/commands/project.d.ts.map +1 -1
  196. package/dist/cli/src/commands/run.d.ts.map +1 -1
  197. package/dist/cli/src/commands/serve-preflight.d.ts +21 -0
  198. package/dist/cli/src/commands/serve-preflight.d.ts.map +1 -1
  199. package/dist/cli/src/commands/serve.d.ts.map +1 -1
  200. package/dist/cli/src/commands/source-manifest.d.ts.map +1 -1
  201. package/dist/cli/src/commands/source.d.ts +8 -0
  202. package/dist/cli/src/commands/source.d.ts.map +1 -1
  203. package/dist/cli/src/commands/update.d.ts.map +1 -1
  204. package/dist/cli/src/commands/validate-instances.d.ts +6 -0
  205. package/dist/cli/src/commands/validate-instances.d.ts.map +1 -1
  206. package/dist/cli/src/commands/validate.d.ts.map +1 -1
  207. package/dist/cli/src/commands/verify.d.ts.map +1 -1
  208. package/dist/cli/src/config-checks.d.ts +8 -0
  209. package/dist/cli/src/config-checks.d.ts.map +1 -1
  210. package/dist/cli/src/ensure-sources.d.ts.map +1 -1
  211. package/dist/cli/src/helpers.d.ts +3 -2
  212. package/dist/cli/src/helpers.d.ts.map +1 -1
  213. package/dist/cli/src/plugin-store/index.d.ts.map +1 -1
  214. package/dist/cli/src/plugin-store/reconcile.d.ts.map +1 -1
  215. package/dist/cli/src/plugin-store/spec.d.ts +1 -0
  216. package/dist/cli/src/plugin-store/spec.d.ts.map +1 -1
  217. package/dist/cli/src/skill-checks.d.ts +2 -0
  218. package/dist/cli/src/skill-checks.d.ts.map +1 -1
  219. package/dist/connectors/config.js +5 -5
  220. package/dist/connectors/index.js +24 -25
  221. package/dist/connectors/src/connector-manager.d.ts.map +1 -1
  222. package/dist/connectors/src/index.d.ts +2 -2
  223. package/dist/connectors/src/index.d.ts.map +1 -1
  224. package/dist/connectors/src/managed-gitconfig.d.ts +22 -0
  225. package/dist/connectors/src/managed-gitconfig.d.ts.map +1 -1
  226. package/dist/connectors/src/mount-ledger.d.ts.map +1 -1
  227. package/dist/connectors/src/npm-installer.d.ts +11 -3
  228. package/dist/connectors/src/npm-installer.d.ts.map +1 -1
  229. package/dist/connectors-HU5MHSUJ.js +49 -0
  230. package/dist/{connectors-4WH32NK2.js.map → connectors-HU5MHSUJ.js.map} +1 -1
  231. package/dist/connectors-shared/index.js +2 -2
  232. package/dist/core/index.js +7 -7
  233. package/dist/core/logging.js +1 -1
  234. package/dist/core/manifest.js +2 -2
  235. package/dist/core/models.js +1 -1
  236. package/dist/core/publish-manifest.js +3 -3
  237. package/dist/core/ref.js +1 -1
  238. package/dist/core/runtime-assets.js +5 -5
  239. package/dist/core/src/agent-instances.d.ts +6 -0
  240. package/dist/core/src/agent-instances.d.ts.map +1 -1
  241. package/dist/core/src/config-key-diagnostics.d.ts +2 -1
  242. package/dist/core/src/config-key-diagnostics.d.ts.map +1 -1
  243. package/dist/core/src/index.d.ts +4 -4
  244. package/dist/core/src/index.d.ts.map +1 -1
  245. package/dist/core/src/lock.d.ts +20 -1
  246. package/dist/core/src/lock.d.ts.map +1 -1
  247. package/dist/core/src/logging/index.d.ts +1 -0
  248. package/dist/core/src/logging/index.d.ts.map +1 -1
  249. package/dist/core/src/logging/log-safe-text.d.ts +20 -0
  250. package/dist/core/src/logging/log-safe-text.d.ts.map +1 -0
  251. package/dist/core/src/manifest-yaml-editor.d.ts +4 -1
  252. package/dist/core/src/manifest-yaml-editor.d.ts.map +1 -1
  253. package/dist/core/src/manifest.d.ts.map +1 -1
  254. package/dist/core/src/models.d.ts +10 -0
  255. package/dist/core/src/models.d.ts.map +1 -1
  256. package/dist/core/src/repo-manager.d.ts +11 -0
  257. package/dist/core/src/repo-manager.d.ts.map +1 -1
  258. package/dist/core/src/runtime-assets.d.ts +12 -1
  259. package/dist/core/src/runtime-assets.d.ts.map +1 -1
  260. package/dist/core/src/walker.d.ts +3 -0
  261. package/dist/core/src/walker.d.ts.map +1 -1
  262. package/dist/core/src/workspace-config.d.ts +10 -2
  263. package/dist/core/src/workspace-config.d.ts.map +1 -1
  264. package/dist/core/workspace-config.js +4 -4
  265. package/dist/deploy/index.js +7 -7
  266. package/dist/discovery/index.js +5 -5
  267. package/dist/{ensure-sources-UC2RBYMP.js → ensure-sources-CAMWJTMR.js} +32 -32
  268. package/dist/ensure-sources-CAMWJTMR.js.map +1 -0
  269. package/dist/factory-assets/connectors/box.js +24 -25
  270. package/dist/factory-assets/connectors/deploy.js +24 -25
  271. package/dist/factory-assets/connectors/devserver.js +24 -25
  272. package/dist/factory-assets/connectors/flow/adapter.js +24 -25
  273. package/dist/factory-assets/connectors/flow/engine.js +8 -8
  274. package/dist/factory-assets/connectors/flow/run-flow.js +26 -27
  275. package/dist/factory-assets/connectors/flow.js +24 -25
  276. package/dist/factory-assets/connectors/git.js +24 -25
  277. package/dist/factory-assets/connectors/gmail.js +24 -25
  278. package/dist/factory-assets/connectors/googledrive.js +24 -25
  279. package/dist/factory-assets/connectors/local.js +24 -25
  280. package/dist/factory-assets/connectors/mattermost.js +24 -25
  281. package/dist/factory-assets/connectors/memory.js +24 -25
  282. package/dist/factory-assets/connectors/minio.js +24 -25
  283. package/dist/factory-assets/connectors/postgres.js +24 -25
  284. package/dist/factory-assets/connectors/s3.js +24 -25
  285. package/dist/factory-assets/connectors/sharepoint.js +24 -25
  286. package/dist/factory-assets/connectors/sqlite.js +24 -25
  287. package/dist/factory-assets/connectors/static-server.js +24 -25
  288. package/dist/factory-assets/connectors/tunnel.js +24 -25
  289. package/dist/factory-assets/connectors/webdav.js +24 -25
  290. package/dist/factory-assets/connectors/xstate-store.js +24 -25
  291. package/dist/factory-assets/connectors/xstate.js +24 -25
  292. package/dist/factory-assets/skills/authoring-skaile-assets/SKILL.md +2 -1
  293. package/dist/{flows-LYTKNGKE.js → flows-GVOVQGQW.js} +12 -12
  294. package/dist/{flows-LYTKNGKE.js.map → flows-GVOVQGQW.js.map} +1 -1
  295. package/dist/{helpers-SSSKT5XK.js → helpers-WMCCODAV.js} +29 -30
  296. package/dist/{helpers-SSSKT5XK.js.map → helpers-WMCCODAV.js.map} +1 -1
  297. package/dist/library/index.js +11 -11
  298. package/dist/library/install.js +4 -4
  299. package/dist/library/src/manifest-writer.d.ts +9 -0
  300. package/dist/library/src/manifest-writer.d.ts.map +1 -1
  301. package/dist/library/src/remote/remote-catalog-source.d.ts +9 -0
  302. package/dist/library/src/remote/remote-catalog-source.d.ts.map +1 -1
  303. package/dist/library/src/remote/rest-catalog-source.d.ts +1 -0
  304. package/dist/library/src/remote/rest-catalog-source.d.ts.map +1 -1
  305. package/dist/{library-publish-GQMNTAKK.js → library-publish-UQQMHTND.js} +55 -55
  306. package/dist/{library-publish-GQMNTAKK.js.map → library-publish-UQQMHTND.js.map} +1 -1
  307. package/dist/model-endpoint/index.js +10 -11
  308. package/dist/open-library-OJ4HT2X4.js +57 -0
  309. package/dist/{open-library-XGUCUJYE.js.map → open-library-OJ4HT2X4.js.map} +1 -1
  310. package/dist/open-registry-LWGIOJDK.js +32 -0
  311. package/dist/{open-registry-DIFEPDF6.js.map → open-registry-LWGIOJDK.js.map} +1 -1
  312. package/dist/paths-FR2752HV.js +22 -0
  313. package/dist/{paths-G4GFJLE2.js.map → paths-FR2752HV.js.map} +1 -1
  314. package/dist/{plugin-store-BBLDFD3L.js → plugin-store-IALJUBN2.js} +10 -10
  315. package/dist/{plugin-store-BBLDFD3L.js.map → plugin-store-IALJUBN2.js.map} +1 -1
  316. package/dist/project-UQFCYHYS.js +88 -0
  317. package/dist/{project-LB745WVZ.js.map → project-UQFCYHYS.js.map} +1 -1
  318. package/dist/resolver/index.js +8 -8
  319. package/dist/runner/index.js +40 -41
  320. package/dist/runner/src/composition/resolve-instance.d.ts.map +1 -1
  321. package/dist/runner/src/composition/resolve.d.ts +6 -0
  322. package/dist/runner/src/composition/resolve.d.ts.map +1 -1
  323. package/dist/runner/src/credential-notice.d.ts +3 -2
  324. package/dist/runner/src/credential-notice.d.ts.map +1 -1
  325. package/dist/runner/src/external-mcp.d.ts +22 -0
  326. package/dist/runner/src/external-mcp.d.ts.map +1 -1
  327. package/dist/runner/src/mcp-tools-snapshot.d.ts +13 -0
  328. package/dist/runner/src/mcp-tools-snapshot.d.ts.map +1 -0
  329. package/dist/runner/src/resources.d.ts +14 -0
  330. package/dist/runner/src/resources.d.ts.map +1 -1
  331. package/dist/runner/src/serve.d.ts.map +1 -1
  332. package/dist/sdk/asset-manager.js +14 -14
  333. package/dist/sdk/bridge.js +20 -21
  334. package/dist/sdk/core.js +7 -7
  335. package/dist/sdk/flow.js +8 -8
  336. package/dist/sdk/index.js +40 -41
  337. package/dist/sdk/index.js.map +1 -1
  338. package/dist/sdk/resolver.js +8 -8
  339. package/dist/sdk/runner.js +40 -41
  340. package/dist/sdk/session.js +2 -2
  341. package/dist/sdk/transport/ws/server.js +8 -8
  342. package/dist/sdk/transport/ws.js +8 -8
  343. package/dist/sdk/transport.js +8 -8
  344. package/dist/sdk/types.js +1 -1
  345. package/dist/serve-preflight-TYEKHC32.js +56 -0
  346. package/dist/serve-preflight-TYEKHC32.js.map +1 -0
  347. package/dist/session/index.js +2 -2
  348. package/dist/{setup-X6ZYH2MW.js → setup-4JV2IMCB.js} +30 -31
  349. package/dist/setup-4JV2IMCB.js.map +1 -0
  350. package/dist/{skills-62PXDBPJ.js → skills-6QTKFMLW.js} +13 -13
  351. package/dist/{skills-62PXDBPJ.js.map → skills-6QTKFMLW.js.map} +1 -1
  352. package/dist/source-XYMMJVKR.js +86 -0
  353. package/dist/{source-LAYCTRHP.js.map → source-XYMMJVKR.js.map} +1 -1
  354. package/dist/{source-manifest-publish-3S6PJ25W.js → source-manifest-publish-SZFGGKB4.js} +52 -53
  355. package/dist/source-manifest-publish-SZFGGKB4.js.map +1 -0
  356. package/dist/transport/index.js +8 -8
  357. package/dist/transport/ws/server.js +8 -8
  358. package/dist/transport/ws.js +8 -8
  359. package/dist/tui/index.js +40 -41
  360. package/dist/tui/index.js.map +1 -1
  361. package/dist/types/index.js +1 -1
  362. package/dist/types/manifests.js +1 -1
  363. package/dist/types/src/manifests/agent.d.ts +2 -2
  364. package/dist/types/src/manifests/agent.d.ts.map +1 -1
  365. package/dist/types/src/version.d.ts +8 -8
  366. package/dist/workspace-plugin/adapters/mcp.js +31 -32
  367. package/dist/workspace-plugin/adapters/omp.js +14 -14
  368. package/dist/workspace-plugin/index.js +2 -2
  369. package/package.json +1 -1
  370. package/dist/chunk-24D7IW5O.js.map +0 -1
  371. package/dist/chunk-2WOA3TKK.js.map +0 -1
  372. package/dist/chunk-3ENE6ZOF.js.map +0 -1
  373. package/dist/chunk-5T3DTK7A.js.map +0 -1
  374. package/dist/chunk-6OHZUUR7.js.map +0 -1
  375. package/dist/chunk-6UP2EDFN.js.map +0 -1
  376. package/dist/chunk-6WQGJF65.js.map +0 -1
  377. package/dist/chunk-6X3GDPCB.js.map +0 -1
  378. package/dist/chunk-76FLBODK.js.map +0 -1
  379. package/dist/chunk-76WSWPOB.js.map +0 -1
  380. package/dist/chunk-ABVWUM2E.js.map +0 -1
  381. package/dist/chunk-DKXNKFKP.js.map +0 -1
  382. package/dist/chunk-EXRQKOY6.js.map +0 -1
  383. package/dist/chunk-GBXQFJ4G.js.map +0 -1
  384. package/dist/chunk-HXZ3FQQN.js.map +0 -1
  385. package/dist/chunk-IYZAJ2J2.js.map +0 -1
  386. package/dist/chunk-JSWMRYLM.js.map +0 -1
  387. package/dist/chunk-P7EL7QRD.js.map +0 -1
  388. package/dist/chunk-QJQQNBVT.js +0 -315
  389. package/dist/chunk-QJQQNBVT.js.map +0 -1
  390. package/dist/chunk-TF5CWJQZ.js.map +0 -1
  391. package/dist/chunk-TGB4E5Z6.js.map +0 -1
  392. package/dist/chunk-UVTN4O7N.js.map +0 -1
  393. package/dist/chunk-VSCLUPGZ.js.map +0 -1
  394. package/dist/chunk-VV2DJT4I.js.map +0 -1
  395. package/dist/chunk-YJNE4V2M.js.map +0 -1
  396. package/dist/connectors-4WH32NK2.js +0 -50
  397. package/dist/ensure-sources-UC2RBYMP.js.map +0 -1
  398. package/dist/open-library-XGUCUJYE.js +0 -58
  399. package/dist/open-registry-DIFEPDF6.js +0 -32
  400. package/dist/paths-G4GFJLE2.js +0 -22
  401. package/dist/project-LB745WVZ.js +0 -88
  402. package/dist/serve-preflight-NPWI4MV6.js.map +0 -1
  403. package/dist/setup-X6ZYH2MW.js.map +0 -1
  404. package/dist/source-LAYCTRHP.js +0 -87
  405. package/dist/source-manifest-publish-3S6PJ25W.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../bridge/src/error-classifier.ts","../bridge/src/reconfigure-model-ref.ts","../bridge/src/reconfigure-ledger.ts","../bridge/src/runner-private-env.ts"],"names":[],"mappings":";;;AAkDO,IAAM,SAAA,GAAN,cAAwB,KAAA,CAAM;AAAA,EAC1B,MAAA;AAAA,EACT,YAAY,MAAA,EAAoB;AAC9B,IAAA,KAAA,CAAM,OAAO,OAAO,CAAA;AACpB,IAAA,IAAA,CAAK,IAAA,GAAO,WAAA;AACZ,IAAA,IAAA,CAAK,MAAA,GAAS,MAAA;AAAA,EAChB;AACF;AAaO,IAAM,uBAAA,GAAN,cAAsC,KAAA,CAAM;AAAA,EACxC,MAAA;AAAA,EACT,YAAY,MAAA,EAAoB;AAC9B,IAAA,KAAA,CAAM,OAAO,OAAO,CAAA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A,EAAW;AAC7F,EAAA,KAAA,MAAW,GAAA,IAAO,uBAAA,EAAyB,OAAO,GAAA,CAAI,GAAG,CAAA;AACzD,EAAA,OAAO,GAAA;AACT;AAQO,IAAM,qBAAA,GAA2C,CAAC,mBAAmB","file":"chunk-5DE3DGVR.js","sourcesContent":["/**\n * Error classification for the Claude Agent SDK harness.\n *\n * Wraps the Anthropic API error patterns surfaced through the bundled\n * `claude-cli.js`. The CLI flattens upstream HTTP errors into terse strings\n * like:\n *\n * `Claude Code returned an error result: Failed to authenticate. API Error:\n * 401 {\"type\":\"error\",\"error\":{\"type\":\"authentication_error\",\"message\":\n * \"Invalid authentication credentials\"}}`\n *\n * Word-for-word that reads as an auth failure, but in practice it also\n * fires when a Claude Max OAuth subscription has exhausted its current\n * quota window — Anthropic returns a non-200 that the CLI relabels as\n * \"Failed to authenticate\" without preserving the original error type.\n *\n * The classifier here:\n * 1. Parses an embedded JSON body when the upstream included one\n * (e.g. `{\"type\":\"error\",\"error\":{\"type\":\"rate_limit_error\",...}}`)\n * so we believe the structured `error.type` over the surrounding\n * free-text wrapper.\n * 2. Honours the SDK's `terminal_reason` when it explicitly indicates\n * a blocking-limit / rapid-refill / model-error condition — those\n * are authoritative even if the textual error reads as auth.\n * 3. Falls back to keyword heuristics on the message text.\n * 4. For OAuth-style credentials (Claude Code subscriptions), adds a\n * hint that bounces user attention to quota rather than credentials,\n * because that's overwhelmingly the cause when a CredentialsFile\n * provider that worked yesterday now returns \"Invalid authentication\n * credentials\" without anyone touching the file.\n */\n\nimport type { AgentError } from \"./types.js\";\n\n/**\n * Error thrown by harnesses when the upstream provider rejects the credential\n * with an authentication-shaped failure (HTTP 401 / `authentication_error`\n * structured body). Carries the structured {@link AgentError} produced by\n * {@link classifyClaudeSdkError} so the runner can mediate without\n * re-classifying string text.\n *\n * The runner's 401-mediation handler `instanceof`-discriminates on this\n * subclass so the auth-vs-rate_limit fork stays in one place.\n *\n * Spec: `_devlog/specs/2026-05-07-unified-credential-mediation.md`\n * § \"Runner-side handling on 401\".\n *\n * @category Errors\n * @since 3.3.0\n */\nexport class AuthError extends Error {\n readonly detail: AgentError;\n constructor(detail: AgentError) {\n super(detail.message);\n this.name = \"AuthError\";\n this.detail = detail;\n }\n}\n\n/**\n * Error thrown when an auth-shaped failure persists *after* a successful\n * credential self-heal — the refresh worked, yet the immediate retry still\n * returned 401. That combination rules out the credential and points at the\n * account itself: a hidden-tier rate limit, a billing block, or anti-abuse\n * throttling on OAuth tokens used at scale (Anthropic mislabels all three as\n * `authentication_error`). It deliberately does **not** extend {@link AuthError}\n * so the harness's auth self-heal does not fire again on it.\n *\n * @category Errors\n */\nexport class AccountUnavailableError extends Error {\n readonly detail: AgentError;\n constructor(detail: AgentError) {\n super(detail.message);\n this.name = \"AccountUnavailableError\";\n this.detail = detail;\n }\n}\n\n/**\n * Re-label an auth-shaped {@link AgentError} as an `account` failure. Called\n * when a 401 recurs after a successful credential refresh: the credential is\n * fine, so the user needs an account-state hint, not \"check your API key\".\n * Pure function.\n */\nexport function reclassifyAuthAsAccountUnavailable(detail: AgentError): AgentError {\n return {\n ...detail,\n category: \"account\",\n statusCode: detail.statusCode ?? 401,\n retryable: false,\n hint: \"The credential was refreshed successfully but Anthropic still rejected the request. This is an account-state issue, not an invalid credential — usually a rate limit at a hidden tier, a billing block, or anti-abuse throttling. Wait a few minutes and retry; if it persists, check the account's billing and usage limits at https://console.anthropic.com/.\",\n };\n}\n\n/**\n * `terminal_reason` values from the Claude Agent SDK that imply the failure\n * is a rate / quota / blocking condition rather than a credential problem.\n */\nconst RATE_LIMIT_TERMINAL_REASONS = new Set<string>([\"blocking_limit\", \"rapid_refill_breaker\"]);\n\n/**\n * `terminal_reason` values that indicate a generic, retryable model failure.\n * `prompt_too_long` is handled separately (not retryable, different hint).\n */\nconst MODEL_TERMINAL_REASONS = new Set<string>([\"model_error\", \"image_error\"]);\n\n/**\n * Input shape for {@link classifyClaudeSdkError} when decoding an `SDKResultError`.\n *\n * All fields are optional; `classifyClaudeSdkError` also accepts a plain `string`\n * (a thrown exception message) for the common non-SDK code paths.\n *\n * @docLink packages/bridge/api-reference#error-classifier\n */\nexport interface ClaudeSdkResultErrorInput {\n /** `errors` array from `SDKResultError`. Empty when not provided. */\n errors?: string[];\n /**\n * `terminal_reason` from `SDKResultError`. Authoritative when set to a\n * blocking/rapid-refill value, regardless of message text.\n */\n terminalReason?: string;\n /** `subtype` from `SDKResultError` — `error_max_turns` etc. */\n subtype?: string;\n /**\n * `true` when the configured Anthropic credential is a Claude Code\n * subscription (`CredentialsFile` provider) rather than a raw API key.\n * Changes the hint copy because `Invalid authentication credentials`\n * on an OAuth subscription almost always means quota.\n */\n oauthCredential?: boolean;\n /**\n * `true` when the harness runs on a developer machine (`skaile run`, `repl`, or a local\n * `serve`) and not in a provisioned runner. The hints then name CLI commands instead of the\n * platform's Settings screen, and do not promise a re-mint that nothing will do (p1943).\n */\n local?: boolean;\n}\n\n/**\n * The `apiError` tag the Claude Agent SDK (0.3.289) puts on the assistant\n * message it renders for a long-context entitlement 429.\n */\nexport const LONG_CONTEXT_CREDITS_API_ERROR = \"long_context_credits_required\";\n\n/**\n * Upstream and SDK-rendered wordings of the long-context entitlement 429:\n * \"Extra usage is required for long context\", \"Usage credits are required for\n * long context requests\", and the CLI's \"Usage credits required for 1M context\".\n */\nconst LONG_CONTEXT_ENTITLEMENT_PATTERN =\n /\\b(?:extra usage is|usage credits(?: are)?) required for (?:long|1m) context\\b/i;\n\n/**\n * Whether any of `texts` is the 429 Anthropic returns when the account may not\n * use a long (1M) context window: the seat is not out of quota, it cannot serve\n * a context over 200k. Matches only that wording, never a usage-limit 429.\n *\n * @docLink packages/bridge/api-reference#error-classifier\n */\nexport function isLongContextEntitlementRejection(\n texts: ReadonlyArray<string | null | undefined>,\n): boolean {\n return texts.some(\n (text) => typeof text === \"string\" && LONG_CONTEXT_ENTITLEMENT_PATTERN.test(text),\n );\n}\n\n/**\n * Classify a Claude SDK result-error or thrown error into a structured\n * {@link AgentError}. Pure function — safe to call from any layer.\n *\n * @param input - Either a free-text error message (from a thrown exception)\n * or a partially-decoded `SDKResultError` shape with `errors[]`,\n * `terminal_reason`, and `subtype`.\n * @returns A category, retryable flag, and human-readable hint.\n * @docLink packages/bridge/api-reference#error-classifier\n */\nexport function classifyClaudeSdkError(input: string | ClaudeSdkResultErrorInput): AgentError {\n const opts: ClaudeSdkResultErrorInput = typeof input === \"string\" ? { errors: [input] } : input;\n\n const message = (opts.errors ?? []).join(\"; \") || \"Unknown agent error\";\n\n // ── 1. Honour authoritative `terminal_reason` ──────────────────────────\n const byTerminalReason = classifyByTerminalReason(message, opts);\n if (byTerminalReason) {\n return byTerminalReason;\n }\n\n // ── 2. Inspect embedded JSON body for a structured error.type ──────────\n const structured = tryParseEmbeddedAnthropicError(message);\n if (structured) {\n const byStructured = classifyByStructuredError(message, structured, opts);\n if (byStructured) {\n return byStructured;\n }\n }\n\n // ── 3. Heuristic keyword classification on the wrapper text ────────────\n const lower = message.toLowerCase();\n\n const byKeyword = classifyByKeyword(message, lower, opts);\n if (byKeyword) {\n return byKeyword;\n }\n\n // ── 4. SDK result subtypes ─────────────────────────────────────────────\n const bySubtype = classifyBySubtype(message, opts);\n if (bySubtype) {\n return bySubtype;\n }\n\n return {\n message,\n category: \"unknown\",\n retryable: true,\n };\n}\n\n/**\n * Phase 1: classify on the SDK's authoritative `terminal_reason`. Returns\n * `null` when the reason is unset or not one of the recognised values.\n */\nfunction classifyByTerminalReason(\n message: string,\n opts: ClaudeSdkResultErrorInput,\n): AgentError | null {\n if (opts.terminalReason && RATE_LIMIT_TERMINAL_REASONS.has(opts.terminalReason)) {\n return {\n message,\n category: \"rate_limit\",\n retryable: true,\n hint: oauthQuotaHint(opts.oauthCredential),\n };\n }\n if (opts.terminalReason === \"prompt_too_long\") {\n return {\n message,\n category: \"model\",\n retryable: false,\n hint: \"The conversation is too long for the configured model. Start a new session or compact the existing one.\",\n };\n }\n if (opts.terminalReason && MODEL_TERMINAL_REASONS.has(opts.terminalReason)) {\n return {\n message,\n category: \"model\",\n retryable: true,\n hint: \"The model rejected this turn. Try again or switch models.\",\n };\n }\n return null;\n}\n\n/**\n * Phase 2: classify on the structured `error.type` parsed from an embedded\n * Anthropic JSON body. Returns `null` for an unrecognised `errorType`.\n */\nfunction classifyByStructuredError(\n message: string,\n structured: { errorType: string; statusCode?: number },\n opts: ClaudeSdkResultErrorInput,\n): AgentError | null {\n if (structured.errorType === \"rate_limit_error\") {\n return {\n message,\n category: \"rate_limit\",\n statusCode: structured.statusCode ?? 429,\n retryable: true,\n hint: oauthQuotaHint(opts.oauthCredential),\n };\n }\n if (structured.errorType === \"overloaded_error\") {\n return {\n message,\n category: \"rate_limit\",\n statusCode: structured.statusCode ?? 529,\n retryable: true,\n hint: \"Anthropic is overloaded. Try again in a moment.\",\n };\n }\n if (structured.errorType === \"authentication_error\") {\n // Anthropic genuinely says it's an auth failure. But for OAuth\n // credentials with the `oauth-2025-04-20` beta flow, this still\n // overwhelmingly correlates with quota. Surface both possibilities\n // in the hint so the user does not first re-upload a perfectly\n // good credentials file.\n return {\n message,\n category: \"auth\",\n statusCode: structured.statusCode ?? 401,\n retryable: false,\n hint: opts.oauthCredential\n ? \"Anthropic rejected the OAuth credential. With Claude Code subscriptions this is usually a quota or rate-limit issue rather than an invalid token — wait a few minutes before re-uploading the credentials file. If it persists, re-export `~/.claude/.credentials.json` from a working Claude Code install.\"\n : localAuthHint(\n opts,\n \"Anthropic rejected the API key. Check it in Settings -> AI Providers.\",\n ),\n };\n }\n if (structured.errorType === \"permission_error\") {\n return {\n message,\n category: \"auth\",\n statusCode: structured.statusCode ?? 403,\n retryable: false,\n hint: \"The configured credential does not have access to the requested model.\",\n };\n }\n if (structured.errorType === \"invalid_request_error\") {\n return {\n message,\n category: \"validation\",\n statusCode: structured.statusCode ?? 400,\n retryable: false,\n hint: \"Anthropic rejected the request shape. This is likely a bug — please report it.\",\n };\n }\n return null;\n}\n\n/**\n * Phase 3: heuristic keyword classification on the lowercased wrapper text.\n * `lower` is the pre-lowercased `message`. Returns `null` when no bucket hits.\n */\nfunction classifyByKeyword(\n message: string,\n lower: string,\n opts: ClaudeSdkResultErrorInput,\n): AgentError | null {\n if (\n lower.includes(\"rate limit\") ||\n lower.includes(\"rate_limit\") ||\n lower.includes(\"too many requests\") ||\n lower.includes(\"429\") ||\n lower.includes(\"quota\") ||\n lower.includes(\"blocking_limit\") ||\n lower.includes(\"rapid_refill\")\n ) {\n return {\n message,\n category: \"rate_limit\",\n retryable: true,\n hint: oauthQuotaHint(opts.oauthCredential),\n };\n }\n\n if (\n lower.includes(\"credit balance\") ||\n lower.includes(\"insufficient credit\") ||\n lower.includes(\"out of credits\")\n ) {\n return {\n message,\n category: \"rate_limit\",\n retryable: false,\n hint: \"The configured Anthropic account is out of credits. Top up at https://console.anthropic.com/ or switch providers.\",\n };\n }\n\n if (lower.includes(\"oauth authentication is currently not supported\")) {\n return {\n message,\n category: \"auth\",\n statusCode: 401,\n retryable: false,\n hint: \"The Claude Code CLI did not send the OAuth beta header. The bundled CLI in this image is too old — rebuild the agent image.\",\n };\n }\n\n // The Claude Code CLI emits this terse, JSON-less string when it finds no\n // usable credential — most commonly because the OAuth access token in\n // `~/.claude/.credentials.json` expired and the file carries no refresh token\n // (the platform provisions access-token-only files by design). It MUST be\n // classified as `auth` so the harness promotes it to `AuthError` and the\n // `onAuthError` self-heal re-mints the credential. Without this branch the\n // message falls through to `unknown`, the self-heal never fires, and every\n // subsequent turn dead-ends on \"please /login\". The check sits ahead of the\n // generic auth keywords because the string contains none of them.\n if (lower.includes(\"not logged in\") || lower.includes(\"please run /login\")) {\n return {\n message,\n category: \"auth\",\n statusCode: 401,\n retryable: false,\n hint: opts.oauthCredential\n ? opts.local\n ? \"The Claude Code login has expired. Log in again with `claude /login`, or set ANTHROPIC_API_KEY (or run `skaile providers add anthropic --credential env:ANTHROPIC_API_KEY`), then retry the prompt.\"\n : \"The Claude Code OAuth credential expired and could not be auto-refreshed in-container. The runner will re-mint it — retry the prompt. If it persists, re-export `~/.claude/.credentials.json` from a working Claude Code install.\"\n : opts.local\n ? \"No Anthropic credential is configured. Set ANTHROPIC_API_KEY, or run `skaile providers add anthropic --credential env:ANTHROPIC_API_KEY`.\"\n : \"No Anthropic credential is configured for this provider. Add one in Settings -> AI Providers.\",\n };\n }\n\n if (\n lower.includes(\"api key\") ||\n lower.includes(\"authentication\") ||\n lower.includes(\"invalid authentication\") ||\n lower.includes(\"unauthorized\") ||\n lower.includes(\"401\") ||\n lower.includes(\"403\")\n ) {\n return {\n message,\n category: \"auth\",\n retryable: false,\n hint: opts.oauthCredential\n ? \"Anthropic rejected the OAuth credential. With Claude Code subscriptions this is usually a quota or rate-limit issue rather than an invalid token — wait a few minutes before re-uploading the credentials file.\"\n : localAuthHint(opts, \"Check the API key configured for this AI provider in Settings.\"),\n };\n }\n\n if (\n lower.includes(\"model\") &&\n (lower.includes(\"not found\") ||\n lower.includes(\"not available\") ||\n lower.includes(\"does not exist\"))\n ) {\n return {\n message,\n category: \"model\",\n retryable: false,\n hint: \"The selected model is not available for this credential. Change the model in the AI provider config.\",\n };\n }\n\n if (\n lower.includes(\"context length\") ||\n lower.includes(\"token limit\") ||\n lower.includes(\"max_tokens\") ||\n lower.includes(\"prompt is too long\") ||\n lower.includes(\"prompt_too_long\")\n ) {\n return {\n message,\n category: \"model\",\n retryable: false,\n hint: \"The conversation is too long for the model. Start a new session or compact this one.\",\n };\n }\n\n if (\n lower.includes(\"timeout\") ||\n lower.includes(\"econnrefused\") ||\n lower.includes(\"enotfound\") ||\n lower.includes(\"fetch failed\") ||\n lower.includes(\"network\")\n ) {\n return {\n message,\n category: \"network\",\n retryable: true,\n hint: \"Network error reaching Anthropic. The runner will retry — try again if it persists.\",\n };\n }\n\n return null;\n}\n\n/**\n * Phase 4: classify on the SDK result `subtype` (`error_max_turns` etc).\n * Returns `null` when the subtype is unset or unrecognised.\n */\nfunction classifyBySubtype(message: string, opts: ClaudeSdkResultErrorInput): AgentError | null {\n if (opts.subtype === \"error_max_turns\") {\n return {\n message,\n category: \"unknown\",\n retryable: true,\n hint: \"The agent stopped after reaching `max_turns`. Resume the session or raise `max_turns` in the agent config.\",\n };\n }\n if (opts.subtype === \"error_max_budget_usd\") {\n return {\n message,\n category: \"rate_limit\",\n retryable: false,\n hint: \"The agent stopped because it hit the configured per-turn budget. Raise the budget or split the work.\",\n };\n }\n return null;\n}\n\n/**\n * The shared keyword buckets matched by {@link classifyGenericErrorMessage}.\n * Harnesses layer a provider-specific `hint` on top of the returned category.\n */\nexport type GenericErrorCategory = \"auth\" | \"rate_limit\" | \"model\" | \"network\";\n\n/**\n * Classify a free-text harness error against the keyword buckets common to the\n * subprocess/SDK harnesses (omp, codex). Returns the matched `category` +\n * `retryable` flag, or `null` when no shared bucket matches so the caller can\n * fall through to its own provider-specific buckets (e.g. codex sandbox) and\n * `unknown` default. The harness supplies the user-facing `hint` — only the\n * bucketing logic is shared, not the copy.\n */\nexport function classifyGenericErrorMessage(\n msg: string,\n): { category: GenericErrorCategory; retryable: boolean } | null {\n const lower = msg.toLowerCase();\n if (\n lower.includes(\"api key\") ||\n lower.includes(\"unauthorized\") ||\n lower.includes(\"authentication\") ||\n lower.includes(\"401\")\n ) {\n return { category: \"auth\", retryable: false };\n }\n if (\n lower.includes(\"rate limit\") ||\n lower.includes(\"429\") ||\n lower.includes(\"too many requests\") ||\n lower.includes(\"quota\")\n ) {\n return { category: \"rate_limit\", retryable: true };\n }\n if (\n lower.includes(\"model\") &&\n (lower.includes(\"not found\") ||\n lower.includes(\"not available\") ||\n lower.includes(\"does not exist\"))\n ) {\n return { category: \"model\", retryable: false };\n }\n if (\n lower.includes(\"context length\") ||\n lower.includes(\"too long\") ||\n lower.includes(\"token limit\") ||\n lower.includes(\"max_tokens\")\n ) {\n return { category: \"model\", retryable: false };\n }\n if (\n lower.includes(\"timeout\") ||\n lower.includes(\"econnrefused\") ||\n lower.includes(\"enotfound\") ||\n lower.includes(\"network\") ||\n lower.includes(\"fetch failed\") ||\n lower.includes(\"fetch\") ||\n lower.includes(\"connection\")\n ) {\n return { category: \"network\", retryable: true };\n }\n return null;\n}\n\n/**\n * The hint for a rejected API key: the platform's Settings wording in a provisioned runner, the\n * CLI command on a developer machine, which has no Settings screen (p1943).\n */\nfunction localAuthHint(opts: ClaudeSdkResultErrorInput, provisioned: string): string {\n return opts.local\n ? \"Check the API key with `skaile providers test <id>`, or set ANTHROPIC_API_KEY.\"\n : provisioned;\n}\n\n/**\n * Returns the rate-limit hint copy, branched on whether the active\n * credential is a Claude Code OAuth subscription.\n */\nfunction oauthQuotaHint(oauthCredential?: boolean): string {\n if (oauthCredential) {\n return \"Quota exhausted on this Claude Code subscription. Wait for the rate-limit window to reset (typically a few minutes for short windows, longer for daily/weekly limits) before retrying. The credential itself is fine.\";\n }\n return \"The Anthropic account hit a rate limit. Wait a moment and try again.\";\n}\n\n/**\n * Try to extract a structured Anthropic error body from a free-text wrapper.\n * The bundled `claude-cli.js` typically formats failures as\n * `... API Error: <status> {\"type\":\"error\",\"error\":{\"type\":\"<errorType>\",...}}`\n * with optional trailing garbage after the JSON.\n *\n * Strategy: find the first `{`, then forward-scan tracking brace depth (with\n * string-literal awareness so braces inside quoted values do not throw the\n * count). The substring from `braceStart` to the matching `}` is the JSON\n * candidate; one `JSON.parse` does the rest. O(n) in the input length.\n *\n * Returns `null` when nothing parseable is found.\n */\nfunction tryParseEmbeddedAnthropicError(\n text: string,\n): { errorType: string; statusCode?: number } | null {\n const braceStart = text.indexOf(\"{\");\n if (braceStart < 0) {\n return null;\n }\n\n const braceEnd = findMatchingCloseBrace(text, braceStart);\n if (braceEnd < 0) {\n return null;\n }\n\n let parsed: { type?: string; error?: { type?: string; message?: string } };\n try {\n parsed = JSON.parse(text.slice(braceStart, braceEnd));\n } catch {\n return null;\n }\n const errorType = parsed?.error?.type;\n if (typeof errorType !== \"string\") {\n return null;\n }\n const statusMatch = text.match(/API Error:\\s*(\\d{3})/i);\n const statusCode = statusMatch ? Number(statusMatch[1]) : undefined;\n return { errorType, statusCode };\n}\n\n/**\n * Forward-scan `text` from `braceStart` (a `{`) with brace counting, returning\n * the index just past the matching close brace, or `-1` if unbalanced.\n * String-literal awareness: skip braces between unescaped double quotes.\n */\nfunction findMatchingCloseBrace(text: string, braceStart: number): number {\n let depth = 0;\n let inString = false;\n let escaped = false;\n for (let i = braceStart; i < text.length; i++) {\n const ch = text.charCodeAt(i);\n if (inString) {\n if (escaped) {\n escaped = false;\n } else if (ch === 92 /* \\ */) {\n escaped = true;\n } else if (ch === 34 /* \" */) {\n inString = false;\n }\n continue;\n }\n if (ch === 34 /* \" */) {\n inString = true;\n } else if (ch === 123 /* { */) {\n depth++;\n } else if (ch === 125 /* } */) {\n depth--;\n if (depth === 0) {\n return i + 1;\n }\n }\n }\n return -1;\n}\n","// The registry selector a live model change (`reconfigure({ model })`) leaves a\n// session on. Shared by the runner's `runner.reconfigure` handler and every\n// harness whose `reconfigure()` rewrites `modelRef`, so both pick the same entry.\nimport {\n type AIProviderLlmEntry,\n type AIProviderRegistry,\n isEntryEnabled,\n type MergedAIProviderRegistry,\n parseModelRef,\n registryEntries,\n} from \"@skaile/workspaces/core/provider-registry\";\n\n/** What a model-only reconfigure does to the session's registry selector. */\nexport type ReconfigureModelScope =\n | {\n ok: true;\n /** The selector to run from now on; `undefined` leaves `modelRef` unset. */\n modelRef: string | undefined;\n }\n | {\n ok: false;\n code: \"model_not_on_provider\";\n /** The entry the session runs on, or the one the patch named. */\n providerId: string;\n message: string;\n };\n\nexport interface ReconfigureModelScopeInput {\n /** The model the patch names: bare, `<providerId>/<modelId>` or `@role`. */\n model: string;\n /** The session's current selector (`AgentConfig.modelRef`). */\n modelRef: string | undefined;\n registry: AIProviderRegistry | MergedAIProviderRegistry | undefined;\n roles?: Record<string, string>;\n}\n\nfunction selectable(\n registry: AIProviderRegistry | MergedAIProviderRegistry,\n): Array<[string, AIProviderLlmEntry]> {\n return registryEntries(registry).filter(\n (pair): pair is [string, AIProviderLlmEntry] =>\n (pair[1].kind === \"llm\" || pair[1].kind === \"embed\") && isEntryEnabled(pair[1]),\n );\n}\n\n/**\n * Whether an entry serves a model id. An entry that declares no model at all\n * (no `model_map`, no `capabilities`) passes any id through, as the wake does.\n * Otherwise the id must be a declared logical id or a `model_map` target: the\n * platform sends the provider-side id the wake translated to.\n */\nfunction entryServes(entry: AIProviderLlmEntry, modelId: string): boolean {\n const map = entry.model_map ?? {};\n const caps = entry.capabilities ?? {};\n if (Object.keys(map).length === 0 && Object.keys(caps).length === 0) return true;\n return modelId in map || modelId in caps || Object.values(map).includes(modelId);\n}\n\n/** The entry a selector runs on, resolved the way the harnesses resolve it. */\nfunction currentProviderId(\n modelRef: string | undefined,\n registry: AIProviderRegistry | MergedAIProviderRegistry,\n entries: Array<[string, AIProviderLlmEntry]>,\n roles: Record<string, string> | undefined,\n): string | undefined {\n const named = modelRef?.trim();\n if (!named) return entries[0]?.[0];\n // A selector that is exactly an entry id names the endpoint and no model.\n if (entries.some(([id]) => id === named)) return named;\n return parseModelRef(named, registry, roles)?.providerId;\n}\n\n/**\n * Decide the selector a live model change leaves the session on.\n *\n * A bare model id keeps the provider the session already runs on\n * (`<currentProvider>/<model>`): re-resolving it by id alone could move the\n * session to another entry that lists the same id, which changes billing and\n * data residency without a sign. Only a patch that names a provider\n * (`<providerId>/<model>` or `@role`) moves it. When the target entry declares\n * its models and this one is not among them, the patch is refused so the host\n * applies it at the next wake instead.\n *\n * A registry with at most one usable entry has nowhere to move to and keeps the\n * old behaviour: the selector becomes the patch's model when one was set.\n */\nexport function scopeReconfigureModel(input: ReconfigureModelScopeInput): ReconfigureModelScope {\n const { model, modelRef, registry, roles } = input;\n const legacy: ReconfigureModelScope = {\n ok: true,\n modelRef: modelRef === undefined ? undefined : model,\n };\n if (!registry) return legacy;\n const entries = selectable(registry);\n if (entries.length <= 1) return legacy;\n\n const selector = model.trim();\n if (selector.startsWith(\"@\")) return { ok: true, modelRef: selector };\n\n const slash = selector.indexOf(\"/\");\n if (slash > 0) {\n const head = selector.slice(0, slash);\n const tail = selector.slice(slash + 1);\n const named = entries.find(([id]) => id === head);\n if (named && tail !== \"\") {\n if (entryServes(named[1], tail)) return { ok: true, modelRef: selector };\n return refuse(head, tail);\n }\n }\n\n const providerId = currentProviderId(modelRef, registry, entries, roles);\n const current = entries.find(([id]) => id === providerId);\n if (!current) return legacy;\n if (!entryServes(current[1], selector)) return refuse(current[0], selector);\n return { ok: true, modelRef: `${current[0]}/${selector}` };\n}\n\nfunction refuse(providerId: string, modelId: string): ReconfigureModelScope {\n return {\n ok: false,\n code: \"model_not_on_provider\",\n providerId,\n message: `AI provider entry \"${providerId}\" does not list model \"${modelId}\"; the change applies when the session next starts.`,\n };\n}\n","// One owner for a live reconfigure (`AgentHarness.reconfigure()`): the desired\n// config, the snapshot the running process was last given, drift between them,\n// serial ordering of patches, the provider-entry scope rule, rollback on a\n// refusal and the typed outcome. A harness supplies one `applyLive` hook that\n// pushes a delta into its process; everything else lives here.\nimport type { Logger } from \"@skaile/workspaces/types\";\nimport { scopeReconfigureModel } from \"./reconfigure-model-ref.js\";\nimport type {\n AgentConfig,\n ReconfigureApplied,\n ReconfigureOutcome,\n ReconfigurePatch,\n ReconfigureRollback,\n} from \"./types.js\";\n\n/** The config fields a live reconfigure reads and writes (the harness's own config object). */\nexport type ReconfigureConfig = Pick<\n AgentConfig,\n \"model\" | \"modelRef\" | \"thinking\" | \"effort\" | \"registry\" | \"roles\"\n>;\n\n/** What the running process holds: the settings it spawned with or was last switched to. */\nexport interface ReconfigureSnapshot {\n model?: string;\n modelRef?: string;\n thinking?: AgentConfig[\"thinking\"];\n effort?: AgentConfig[\"effort\"];\n}\n\n/**\n * What an {@link ReconfigureLedgerOptions.applyLive} hook answers:\n *\n * - `\"applied\"`: the process now runs the delta.\n * - `\"respawn\"`: the process cannot take it live; the harness replaces it before\n * the next turn and the new process reads the desired config.\n * - `{ rejected }`: the process refuses it; the ledger rolls the config back to\n * the snapshot.\n */\nexport type ReconfigureApplyResult = \"applied\" | \"respawn\" | { rejected: string };\n\n/**\n * What an {@link ReconfigureLedgerOptions.applyLive} hook is told about a push.\n * `late` is true when the whole delta was answered `ok` earlier (it landed\n * mid-turn): a refusal then reaches the host only through\n * {@link ReconfigureLedgerOptions.onLateRejection}, so the hook must not also\n * report it on another channel (an `error` event).\n */\nexport interface ReconfigurePushContext {\n late: boolean;\n}\n\nconst FIELDS = [\"model\", \"modelRef\", \"thinking\", \"effort\"] as const;\n\nexport interface ReconfigureLedgerOptions<S extends ReconfigureSnapshot> {\n /**\n * The desired config. A getter, because a harness may replace its config object;\n * the ledger writes accepted patches into whatever it returns.\n */\n config: () => ReconfigureConfig;\n /**\n * Push a delta (the fields whose desired value differs from the snapshot) into\n * the running process. Called with the process up and idle, or at a turn\n * boundary through {@link ReconfigureLedger.flushBeforeTurn}. The hook receives\n * the live snapshot and may refine it (a harness that keeps extra fields on `S`\n * updates them here); on `\"applied\"` the ledger copies the delta into it.\n * A hook that throws counts as a rejection. Its `context.late` says whether a\n * refusal is reported elsewhere (see {@link ReconfigurePushContext}). Absent: the process reads the\n * desired config at its next spawn and there is nothing to push.\n */\n applyLive?: (\n delta: ReconfigureApplied,\n snapshot: S,\n context: ReconfigurePushContext,\n ) => ReconfigureApplyResult | Promise<ReconfigureApplyResult>;\n /** Whether the process is up and can take a push. Default: true. */\n isLive?: () => boolean;\n /** Whether no turn is in flight. Default: true. */\n isIdle?: () => boolean;\n /**\n * Called synchronously once a patch is written to the desired config, before\n * any live push. For harnesses that must refresh a derived cache on a change.\n */\n onDesired?: (applied: ReconfigureApplied) => void;\n /**\n * A refusal that arrives after the patch was already answered `ok` (it landed\n * mid-turn and flushed at the turn boundary). The config is already rolled back\n * when this runs, and an idle-time refusal never calls it (the capability call\n * answers that one). A harness emits the harness event `reconfigure-rollback`.\n */\n onLateRejection?: (rollback: ReconfigureRollback) => void;\n log?: Pick<Logger, \"warn\" | \"info\">;\n}\n\n/**\n * Serialised live reconfigure for one harness.\n *\n * `ok: true` means effective from the next turn: the next turn runs on the new\n * settings by live switch, query recycle or respawn. A patch that lands while a\n * turn is in flight (or before the process is ready) stays desired, is answered\n * `ok`, and is pushed by {@link flushBeforeTurn}.\n *\n * @category Bridge\n */\nexport class ReconfigureLedger<S extends ReconfigureSnapshot = ReconfigureSnapshot> {\n private snapshot: S | null = null;\n private respawn = false;\n private tail: Promise<unknown> | null = null;\n\n constructor(private readonly options: ReconfigureLedgerOptions<S>) {}\n\n /**\n * Record what a freshly spawned process runs. Call at every spawn: the\n * desired config is what that spawn read, so drift is computed against this.\n * `null` forgets the process (nothing left to push to).\n */\n setSnapshot(snapshot: S | null): void {\n this.snapshot = snapshot;\n this.respawn = false;\n }\n\n /**\n * The process cannot take the desired config live and the harness must replace\n * it before the next turn. Cleared by the next {@link setSnapshot}.\n */\n get needsRespawn(): boolean {\n return this.respawn;\n }\n\n /**\n * Apply a patch: scope the model to the session's provider entry, write it to\n * the desired config, and push it when the process is up and idle. Patches run\n * one at a time in arrival order.\n */\n reconfigure(patch: ReconfigurePatch): Promise<ReconfigureOutcome> {\n return this.enqueue(() => this.runPatch(patch));\n }\n\n /**\n * Push any drift to the process at a turn boundary. Await it before the turn\n * is sent, so the turn runs on the desired settings. Never rejects.\n */\n flushBeforeTurn(): Promise<void> {\n return this.enqueue(async () => {\n const snapshot = this.snapshot;\n if (!snapshot || this.respawn || !(this.options.isLive?.() ?? true)) return;\n await this.flush(snapshot, new Set());\n });\n }\n\n private enqueue<T>(job: () => Promise<T>): Promise<T> {\n // With nothing in flight the job's synchronous prefix (scope + write) runs now.\n const run = this.tail ? this.tail.then(job) : job();\n const settled = run.then(\n () => undefined,\n () => undefined,\n );\n this.tail = settled;\n void settled.then(() => {\n if (this.tail === settled) this.tail = null;\n });\n return run;\n }\n\n private async runPatch(patch: ReconfigurePatch): Promise<ReconfigureOutcome> {\n const config = this.options.config();\n const applied: ReconfigureApplied = {};\n if (patch.model !== undefined) {\n // In registry mode the spawned model derives from `modelRef`, so it moves\n // too: scoped to the current entry unless the patch names another one.\n const scope = scopeReconfigureModel({\n model: patch.model,\n modelRef: config.modelRef,\n registry: config.registry,\n roles: config.roles,\n });\n if (!scope.ok) {\n this.options.log?.warn(\"model change refused; keeping the current model\", {\n model: patch.model,\n providerId: scope.providerId,\n });\n return {\n ok: false,\n code: scope.code,\n message: scope.message,\n providerId: scope.providerId,\n };\n }\n config.model = applied.model = patch.model;\n if (scope.modelRef !== undefined) config.modelRef = applied.modelRef = scope.modelRef;\n }\n if (patch.thinking !== undefined) config.thinking = applied.thinking = patch.thinking;\n if (patch.effort !== undefined) config.effort = applied.effort = patch.effort;\n this.options.onDesired?.(applied);\n\n const snapshot = this.snapshot;\n // No process: the next spawn reads the desired config.\n if (!snapshot || this.respawn) return { ok: true, applied };\n const live = this.options.isLive?.() ?? true;\n const idle = this.options.isIdle?.() ?? true;\n // Mid-turn or before ready: stays desired, flushed at the turn boundary.\n if (!live || !idle) return { ok: true, applied };\n\n const own = new Set(Object.keys(applied) as Array<keyof ReconfigureApplied>);\n const rejected = await this.flush(snapshot, own);\n return rejected === null\n ? { ok: true, applied }\n : { ok: false, code: \"rejected\", message: rejected };\n }\n\n /**\n * Push the drift to the process. Returns the refusal message, or `null` when\n * the process took it (or will, by respawn). On a refusal the config rolls back\n * to the snapshot; fields outside `own` were answered `ok` earlier, so they are\n * reported through `onLateRejection`.\n */\n private async flush(\n snapshot: S,\n own: ReadonlySet<keyof ReconfigureApplied>,\n ): Promise<string | null> {\n const hook = this.options.applyLive;\n if (!hook) return null;\n const config = this.options.config();\n const delta: ReconfigureApplied = {};\n for (const key of FIELDS) {\n const value = config[key];\n if (value !== undefined && value !== snapshot[key]) Object.assign(delta, { [key]: value });\n }\n if (Object.keys(delta).length === 0) return null;\n\n // Nothing in the delta was answered to a caller of this push: it is all late.\n const context: ReconfigurePushContext = { late: own.size === 0 };\n let result: ReconfigureApplyResult;\n try {\n result = await hook(delta, snapshot, context);\n } catch (err) {\n result = { rejected: err instanceof Error ? err.message : String(err) };\n }\n // The process was replaced meanwhile; the new one read the desired config.\n if (this.snapshot !== snapshot) return null;\n\n if (result === \"applied\") {\n Object.assign(snapshot, delta);\n return null;\n }\n if (result === \"respawn\") {\n this.respawn = true;\n return null;\n }\n\n const requested: ReconfigureApplied = {};\n const restored: ReconfigureApplied = {};\n for (const key of Object.keys(delta) as (keyof ReconfigureApplied)[]) {\n // The hook may have applied part of the delta and refined the snapshot.\n Object.assign(config, { [key]: snapshot[key] });\n if (!own.has(key)) {\n Object.assign(requested, { [key]: delta[key] });\n Object.assign(restored, { [key]: snapshot[key] });\n }\n }\n this.options.log?.warn(\"live reconfigure refused; config rolled back\", {\n reason: result.rejected,\n fields: Object.keys(delta),\n });\n if (Object.keys(requested).length > 0) {\n this.options.onLateRejection?.({ message: result.rejected, requested, restored });\n }\n return result.rejected;\n }\n}\n","/**\n * Environment variables that belong to the runner process and must never reach\n * an agent child (the CLI, its tools, MCP servers, hooks).\n *\n * `SKAILE_WS_AUTH_TOKEN` authenticates the host on the runner's own WebSocket.\n * An agent that can read it can connect to the runner as the host and send host\n * commands (prompts, connector mutations such as flow-gate approvals). The\n * runner removes it from `process.env` at startup; every harness strips it again\n * from the env it hands its child, so a value that slips back in through\n * `AgentConfig.env` or an embedder that skipped the startup scrub still stops\n * at the harness.\n */\nexport const RUNNER_PRIVATE_ENV_KEYS: readonly string[] = [\n \"SKAILE_WS_AUTH_TOKEN\",\n \"SKAILE_WS_AUTH_TOKEN_FILE\",\n];\n\n/**\n * Remove every {@link RUNNER_PRIVATE_ENV_KEYS} entry from `env`, in place, and\n * return it. Call it on the final child env, after every merge.\n */\nexport function stripRunnerPrivateEnv<T extends Record<string, string | undefined>>(env: T): T {\n for (const key of RUNNER_PRIVATE_ENV_KEYS) delete env[key];\n return env;\n}\n\n/**\n * Variables the runner sets for the agent's shell on purpose, which every harness passes to its\n * child next to its own allowlist (p1738). `GIT_CONFIG_GLOBAL` points `git` at the runner's managed\n * gitconfig (`<project>/.skaile/managed-gitconfig`); a harness that dropped it left the agent\n * with no path to the managed credentials.\n */\nexport const RUNNER_AGENT_ENV_KEYS: readonly string[] = [\"GIT_CONFIG_GLOBAL\"];\n"]}
@@ -1,14 +1,14 @@
1
1
  import { initTelemetry } from './chunk-4R6DROGN.js';
2
- import { parseSkillFrontmatter, validateFlowVersions } from './chunk-C7TQARGC.js';
3
- import { FlowAdapter, SessionNodeExecutor, SessionSubpromptRunner, SessionInlineSubFlowRunner, driveOrchestratorTurn } from './chunk-EXRQKOY6.js';
4
- import { loadFlow, flowLookupRoots, findFlowFileInRoots, FLOW_FILE_EXTENSIONS } from './chunk-ZWCGJYR7.js';
2
+ import { parseSkillFrontmatter, validateFlowVersions } from './chunk-PTJTOPE5.js';
3
+ import { FlowAdapter, SessionNodeExecutor, SessionSubpromptRunner, SessionInlineSubFlowRunner, driveOrchestratorTurn } from './chunk-VXYZ5M7Z.js';
4
+ import { loadFlow, flowLookupRoots, findFlowFileInRoots, FLOW_FILE_EXTENSIONS } from './chunk-5XHQBCB5.js';
5
5
  import { renderStimulusPrompt } from './chunk-WD3L5QSU.js';
6
6
  import { flowSkillVersionPins } from './chunk-7RGTAEG6.js';
7
- import { resolveSettings } from './chunk-ABVWUM2E.js';
7
+ import { resolveSettings } from './chunk-6ARPZHOV.js';
8
8
  import { DEFAULT_HARNESS_ID } from './chunk-C5HFK34M.js';
9
9
  import { findKindDirs } from './chunk-MWXYN6NY.js';
10
- import { resolveAgentDir, resolveSkWorkspaceConfig } from './chunk-6WQGJF65.js';
11
- import { isValidAssetName } from './chunk-IZQOO6MN.js';
10
+ import { resolveAgentDir, resolveSkWorkspaceConfig } from './chunk-6SXSVKQY.js';
11
+ import { isValidAssetName } from './chunk-V5KG6CCV.js';
12
12
  import { createLogger } from './chunk-BOFL7GIF.js';
13
13
  import fs from 'fs';
14
14
  import path from 'path';
@@ -537,5 +537,5 @@ function walkForSkill(dir, skillId) {
537
537
  }
538
538
 
539
539
  export { awaitAgentEnd, resolveFlowPath, resumeFlow, runFlow };
540
- //# sourceMappingURL=chunk-Q4XWCVFA.js.map
541
- //# sourceMappingURL=chunk-Q4XWCVFA.js.map
540
+ //# sourceMappingURL=chunk-5ETYBC2X.js.map
541
+ //# sourceMappingURL=chunk-5ETYBC2X.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../factory-assets/connectors/flow/run-flow.ts"],"names":["c"],"mappings":";;;;;;;;;;;;;;;;AAkEA,IAAI,aAAA;AAEJ,eAAe,gBAAA,GAAiC;AAC9C,EAAA,IAAI,eAAe,OAAO,aAAA;AAC1B,EAAA,aAAA,GAAgB,MAAM,OAAO,mBAA2B,CAAA;AACxD,EAAA,OAAO,aAAA;AACT;AAMA,IAAM,0BAAA,GAA6B,CAAA,GAAI,EAAA,GAAK,EAAA,GAAK,GAAA;AAEjD,IAAM,0BAAA,uBAAiC,GAAA,CAAI;AAAA,EACzC,eAAA;AAAA,EACA,WAAA;AAAA,EACA,aAAA;AAAA,EACA,eAAA;AAAA,EACA,eAAA;AAAA,EACA,YAAA;AAAA,EACA,kBAAA;AAAA,EACA,eAAA;AAAA,EACA,eAAA;AAAA,EACA,WAAA;AAAA,EACA;AACF,CAAC,CAAA;AA4HD,eAAsB,QAAQ,IAAA,EAAiC;AAC7D,EAAA,MAAM,MAAA,GAAS,MAAM,gBAAA,EAAiB;AACtC,EAAA,MAAM;AAAA,IACJ,uBAAA;AAAA,IACA,2BAAA;AAAA,IACA,kBAAA;AAAA,IACA,kBAAA;AAAA,IACA,wBAAA;AAAA,IACA,gBAAA;AAAA,IACA,+BAAA;AAAA,IACA,mBAAA;AAAA,IACA,UAAA;AAAA,IACA,WAAA;AAAA,IACA;AAAA,GACF,GAAI,MAAA;AAEJ,EAAA,MAAM,IAAA,GAAO,QAAA,CAAS,IAAA,CAAK,QAAQ,CAAA;AACnC,EAAA,MAAM,QAAA,GAAW,IAAA,CAAK,QAAA,IAAY,eAAA,CAAgB,KAAK,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AAAA,IACpB;AAAA,EACF;AACA,EAAA,OAAO,IAAA;AACT","file":"chunk-Q4XWCVFA.js","sourcesContent":["/**\n * runFlow / resumeFlow — CLI entry helpers for the flow connector.\n *\n * Moved from `runner/src/runner.ts` to `factory-assets/connectors/flow/run-flow.ts`\n * in Phase 3 of the flow-connector extraction (2026-05-08). Behaviour is\n * byte-identical to the previous runner-side implementation; only the log\n * source changes from `runner:flow:<runId>` to `flow-connector:run:<runId>`.\n *\n * The runner re-exports these symbols with a deprecation warning for one\n * release. CLI consumers should switch to\n * `import { runFlow, resumeFlow } from \"@skaile/workspaces/factory-assets/connectors/flow/run-flow\"`.\n *\n * Internal runner helpers (FlowOrchestrator, bootstrapRunnerLogStore,\n * createAgentSession, resolveHarnessPaths, session helpers) are loaded lazily\n * via dynamic `await import(\"@skaile/workspaces/runner\")` inside\n * `loadRunnerModule()` below. The lazy load avoids a static package-level\n * cycle (runner → connectors → factory-assets → runner) — the cycle exists at\n * the workspace level but never resolves at module-load time because\n * factory-assets only ever calls `import` from inside an async function body.\n * The string-literal specifier preserves `bun --compile` and tsup static\n * analysis.\n */\n\nimport fs from \"node:fs\";\nimport path from \"node:path\";\nimport type { AgentEvent } from \"@skaile/workspaces/bridge\";\nimport {\n DEFAULT_HARNESS_ID,\n findKindDirs,\n isValidAssetName,\n resolveAgentDir,\n resolveSettings,\n resolveSkWorkspaceConfig,\n} from \"@skaile/workspaces/core\";\nimport { createLogger } from \"@skaile/workspaces/core/logging\";\nimport { parseSkillFrontmatter, validateFlowVersions } from \"@skaile/workspaces/resolver\";\nimport { initTelemetry } from \"@skaile/workspaces/telemetry\";\nimport type { FlowExecution, FlowPromptEvent } from \"@skaile/workspaces/types\";\nimport * as z from \"zod\";\nimport { FlowAdapter } from \"./adapter.js\";\nimport {\n findFlowFileInRoots,\n FLOW_FILE_EXTENSIONS,\n type FlowLookupMiss,\n flowLookupRoots,\n loadFlow,\n} from \"./engine/index.js\";\nimport { flowSkillVersionPins } from \"./engine/node-shape.js\";\nimport { SessionInlineSubFlowRunner } from \"./inline-sub-flow-host.js\";\nimport { SessionNodeExecutor } from \"./node-executor.js\";\nimport { driveOrchestratorTurn } from \"./orchestrator-turn.js\";\nimport { renderStimulusPrompt, type TurnStimulus } from \"./prompt-fragments.js\";\nimport { SessionSubpromptRunner } from \"./subprompt-runner.js\";\n\n/**\n * Lazy `import(\"@skaile/workspaces/runner\")` accessor. Cached on first call so\n * subsequent `runFlow` invocations don't re-evaluate the runner module.\n *\n * Dynamic ESM import is used (not `require`) so vitest and other ESM\n * bundlers honour their alias resolution — `require` would side-step the\n * configured aliases and pick up two distinct module instances when run\n * under vitest. The string-literal specifier ensures bun --compile keeps\n * the dependency (per the static-import-or-die rule in\n * connectors/CLAUDE.md).\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nlet _runnerModule: any | undefined;\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nasync function loadRunnerModule(): Promise<any> {\n if (_runnerModule) return _runnerModule;\n _runnerModule = await import(\"@skaile/workspaces/runner\");\n return _runnerModule;\n}\n\n/** Type-only re-export of SessionState so the runner tombstone shim still works. */\nexport type SessionState = import(\"@skaile/workspaces/runner\").SessionState;\n\n/** Maximum agent session duration (4 hours). Configurable via {@link RunOptions.sessionTimeoutMs}. */\nconst DEFAULT_SESSION_TIMEOUT_MS = 4 * 60 * 60 * 1000; // 4 hours\n\nconst FLOW_AGENT_OPERATION_NAMES = new Set([\n \"get_available\",\n \"get_state\",\n \"get_globals\",\n \"build_handoff\",\n \"validate_node\",\n \"start_node\",\n \"request_approval\",\n \"request_input\",\n \"complete_node\",\n \"skip_node\",\n \"fail_node\",\n]);\n\n/**\n * Options for {@link runFlow}.\n *\n * Wraps `FlowOrchestrator` with autonomous mode turned on by default. First-class\n * gate nodes remain mandatory human decisions in every mode.\n *\n * @docLink packages/factory-assets/flow#run-flow\n */\nexport interface RunOptions {\n /** The working directory for the project being orchestrated. */\n projectDir: string;\n /** Absolute path to the `.flow.yaml` or `.flow.json` definition file. */\n flowPath: string;\n /**\n * Directory containing `agent.yaml`, `SOUL.md`, `RULES.md`, `knowledge/`.\n * Resolved from `skaile.yaml` via `resolveAgentDir` when absent.\n */\n agentDir?: string;\n /**\n * Agent harness. Defaults to `settings.harness` (`\"omp\"` or `\"claude-sdk\"`).\n */\n harness?: string;\n /**\n */\n /**\n * Model name override. Falls back to `settings.model` when absent.\n */\n model?: string;\n /**\n * Path to a specific `settings.json` to load instead of the default\n * layered resolution chain (project → parent → global → built-in defaults).\n */\n settingsFile?: string;\n /**\n * When `true`, prints the initial flow state without starting the agent\n * and returns immediately.\n */\n dryRun?: boolean;\n /**\n * Per-session timeout in milliseconds. Defaults to\n * {@link DEFAULT_SESSION_TIMEOUT_MS} (4 hours).\n */\n sessionTimeoutMs?: number;\n /** Optional human-readable label shown in the session list. */\n sessionLabel?: string;\n /**\n * The session `skaile resume` continues. Its run id is kept and its harness thread resumed,\n * instead of starting a second session. Set by {@link resumeFlow}; not for other callers.\n */\n resumeSession?: SessionState;\n /** Autonomous mode for CLI runs. Defaults to true; first-class gate nodes are never bypassed. */\n autonomousMode?: boolean;\n /**\n * Called for each {@link AgentEvent} emitted during the run\n * (e.g. `text`, `tool_call`, `state_changed`).\n */\n onEvent?: (event: AgentEvent) => void;\n /**\n * Called for each diagnostic log line. Defaults to `process.stdout`.\n */\n onLog?: (line: string) => void;\n}\n\n/**\n * Options for resuming an existing CLI session.\n *\n * Reconnects the harness's conversation thread (conversation history is\n * preserved via the stored `harnessSessionId`) but restarts flow execution\n * from scratch — flow state is not persisted in CLI mode. For governed,\n * resumable flow runs use a host that persists flow state (e.g. the Skaile\n * platform).\n *\n * @docLink packages/factory-assets/flow#resume-flow\n */\nexport interface ResumeOptions {\n /** The working directory for the project being orchestrated. */\n projectDir: string;\n /**\n * Specific run ID to resume. When absent, the current session pointer\n * at `<projectDir>/.skaile/current` is used.\n */\n sessionId?: string;\n /**\n * Agent definition directory override. Defaults to the directory stored\n * in the session file.\n */\n agentDir?: string;\n /**\n * When `true`, prints the initial flow state without starting the agent\n * and returns immediately.\n */\n dryRun?: boolean;\n /**\n * Per-session timeout in milliseconds. Defaults to\n * {@link DEFAULT_SESSION_TIMEOUT_MS} (4 hours).\n */\n sessionTimeoutMs?: number;\n /**\n * Called for each {@link AgentEvent} emitted during the run.\n */\n onEvent?: RunOptions[\"onEvent\"];\n /**\n * Called for each diagnostic log line. Defaults to `process.stdout`.\n */\n onLog?: RunOptions[\"onLog\"];\n}\n\n// ---------------------------------------------------------------------------\n// Public API\n// ---------------------------------------------------------------------------\n\n/**\n * Start a new flow session from the CLI.\n *\n * Wraps `FlowOrchestrator` with autonomous mode turned on by default. The\n * runner remains idle between turns; first-class gates always park for a human\n * decision, including in autonomous mode. Non-CLI hosts (Skaile platform,\n * Pichi) use the orchestrator directly via the serve command surface and drive\n * gates through user actions.\n *\n * @docLink packages/factory-assets/flow#run-flow\n */\nexport async function runFlow(opts: RunOptions): Promise<void> {\n const runner = await loadRunnerModule();\n const {\n bootstrapRunnerLogStore,\n bootstrapCapabilityRegistry,\n CapabilityRegistry,\n createAgentSession,\n createSessionStimulusBus,\n defineCapability,\n registerCompositionCapabilities,\n resolveHarnessPaths,\n newSession,\n saveSession,\n touchSession,\n } = runner;\n\n const flow = loadFlow(opts.flowPath);\n const agentDir = opts.agentDir ?? resolveAgentDir(opts.projectDir);\n const settings = await resolveSettings(opts.projectDir, {\n harness: opts.harness,\n model: opts.model,\n });\n\n // `skaile resume` continues the session it was given: same run id, so the harness thread\n // (`harnessSessionId`) resumes and `session list` shows one run, not a second one (p850).\n const session = opts.resumeSession\n ? (({ error: _prior, ...kept }) => touchSession({ ...kept, status: \"running\" }))(\n opts.resumeSession,\n )\n : newSession({\n flowId: flow.id,\n projectDir: opts.projectDir,\n agentDir,\n harness: settings.harness ?? DEFAULT_HARNESS_ID,\n model: settings.model,\n label: opts.sessionLabel,\n });\n\n // A dry run only prints the plan: it must not leave a `running` session behind.\n if (!opts.dryRun) await saveSession(opts.projectDir, session);\n\n // Bootstrap structured logging — registers a process-singleton LogStore.\n // OnLogBridgeSink mirrors entries to opts.onLog when caller provides one,\n // preserving back-compat with CLI hosts that consume plain text lines.\n const wsConfigEarly = resolveSkWorkspaceConfig(opts.projectDir);\n const { dispose: disposeLogStore } = bootstrapRunnerLogStore({\n sessionId: session.runId,\n projectDir: opts.projectDir,\n yamlBlock: wsConfigEarly.logging,\n onLog: opts.onLog,\n // A host that takes lines through `onLog` prints them itself; the stdout\n // sink would add every record again as a raw JSON line.\n stdout: opts.onLog === undefined,\n });\n const flowLog = createLogger({\n kind: \"flow-connector\",\n subkind: \"run\",\n instance: session.runId,\n });\n const log = (line: string) => flowLog.info(line);\n const capabilityRegistry = new CapabilityRegistry();\n bootstrapCapabilityRegistry(capabilityRegistry);\n const capabilityHooks = {\n sessionId: session.runId,\n composeTools: () => capabilityRegistry.composeLLMTools(),\n resolve: (name: string) =>\n capabilityRegistry.list().find((cap: { name: string }) => cap.name === name) ?? null,\n invoke: (name: string, input: unknown, _signal?: AbortSignal, callId?: string) =>\n capabilityRegistry.invoke(name, input, { sessionId: session.runId, callId }),\n };\n\n try {\n // ── Dry run ────────────────────────────────────────────────────────────\n if (opts.dryRun) {\n const adapter = new FlowAdapter();\n const handle = await adapter.connect(\n {\n id: \"flow\",\n driver: \"flow\",\n access: \"read-only\" as const,\n options: { flow, seed: { runId: session.runId, startedBy: \"cli\" } },\n },\n {}, // flow needs no connect context\n );\n const state = adapter.getExecution(handle);\n const available = Object.values(state.nodes)\n .filter((n) => n.status === \"available\")\n .map((n) => n.id);\n // The plan is the command's output, not a log event: print it as plain lines\n // (no `[info] [flow-connector:run:…]` prefix from the log formatter).\n const printPlan = opts.onLog ?? ((line: string) => console.log(line));\n printPlan(`[dry-run] Flow: ${flow.name} (${flow.id})`);\n printPlan(`[dry-run] Available: ${available.join(\", \") || \"(none)\"}`);\n await adapter.disconnect(handle);\n return;\n }\n\n await validatePinnedVersions(flow, opts.projectDir, log);\n\n // ── Telemetry initialization ────────────────────────────────────────────\n const wsConfig = wsConfigEarly;\n const telemetry = await initTelemetry(wsConfig.telemetry);\n const flowTrace = telemetry.startTrace({\n name: `flow:${flow.id}`,\n kind: \"flow_run\",\n attributes: {\n \"skaile.flow.id\": flow.id,\n \"skaile.flow.run_id\": session.runId,\n },\n });\n\n // ── Agent session setup ─────────────────────────────────────────────────\n const harnessPaths = resolveHarnessPaths(settings);\n const agentSession = await createAgentSession({\n projectDir: opts.projectDir,\n agentDir: session.agentDir,\n harness: session.harness,\n model: session.model,\n resumeSessionId: session.harnessSessionId,\n projectClaudeMd: path.join(opts.projectDir, \"CLAUDE.md\"),\n promptsDir: path.join(opts.projectDir, harnessPaths.promptsDir),\n sessionId: session.runId,\n onLog: log,\n telemetry,\n trace: flowTrace,\n wsConfig,\n capabilities: capabilityHooks,\n capabilityRegistry,\n // A flow step has no one to answer an approval card: with `permission_mode: interactive`\n // a tool call that needs approval is refused instead of hanging the step.\n unattended: true,\n });\n if (agentSession.composition?.discoverableEntries.length) {\n registerCompositionCapabilities(\n capabilityRegistry,\n agentSession.composition.discoverableEntries,\n );\n }\n const { harness } = agentSession;\n const nodeExecutor = new SessionNodeExecutor({ workspaceDir: opts.projectDir });\n // Same endpoints and credentials the session harness used: the registry\n // and the credential env `createAgentSession` already resolved — not a\n // new resolution, not a new secret channel.\n const subpromptRunner = new SessionSubpromptRunner({\n harnessType: agentSession.harnessType,\n sessionModel: agentSession.model,\n workspaceDir: opts.projectDir,\n registry: agentSession.registry,\n credentialEnv: agentSession.credentialEnv,\n ...(agentSession.modelRef ? { modelRef: agentSession.modelRef } : {}),\n });\n let harnessStarted = false;\n const updatedSession = { ...session };\n\n // Track harness session ID so future resumes can reconnect the SDK thread.\n harness.on(\"agent-event\", () => {\n const runtimeSessionId = harness.runtimeSessionId;\n if (!runtimeSessionId || runtimeSessionId === updatedSession.harnessSessionId) return;\n updatedSession.harnessSessionId = runtimeSessionId;\n void saveSession(opts.projectDir, updatedSession).catch(() => {});\n });\n\n // ── FlowAdapter + stimulus bus ─────────────────────────────────────────\n //\n // Phase 4 of the flow-connector extraction: SessionStimulusBus is the sole\n // turn driver. The legacy FlowOrchestrator + onStateChange subscription\n // are gone — every turn is initiated either by the bus (after an adapter\n // mutation observed via `useBusForStimulus: true`) or by an explicit\n // `bus.signal()` call from this function (the initial flow_started turn).\n //\n // The bus's `driveTurn` callback receives the stimulus paragraph the\n // adapter rendered (not the full orchestrator prompt). It hands the turn to\n // `driveOrchestratorTurn`, which rebuilds the five-section prompt so the\n // agent sees the same flow context the legacy orchestrator produced — and\n // announces it, so a CLI consumer's `onEvent` stream carries the prompt too.\n const flowConnectorId = \"flow\";\n const turnTimeoutMs = opts.sessionTimeoutMs ?? DEFAULT_SESSION_TIMEOUT_MS;\n\n const ensureHarnessStarted = async (): Promise<void> => {\n if (harnessStarted) return;\n await harness.start();\n harnessStarted = true;\n };\n\n // Same widening the `state_changed` forwarder below performs: `onEvent` is\n // typed against the bridge's harness-level union, which has no case for a\n // runtime-level event.\n const emitFlowPrompt = (event: FlowPromptEvent): void => {\n opts.onEvent?.(event as unknown as AgentEvent);\n };\n\n const inlineSubFlowRunner = new SessionInlineSubFlowRunner({\n resolveFlow: (flowId) => loadFlow(resolveFlowPath(flowId, opts.projectDir)),\n nodeExecutor,\n subpromptRunner,\n driveAgentTurn: async ({ flow: childFlow, execution, stimulus }) => {\n await ensureHarnessStarted();\n await driveOrchestratorTurn({\n flow: childFlow,\n execution,\n stimulus,\n emit: emitFlowPrompt,\n deliver: (prompt) => awaitAgentEnd(harness, prompt, opts.onEvent, turnTimeoutMs),\n });\n },\n });\n\n // Forward declaration so `driveTurn` can read the live execution\n // snapshot. Assigned just below, before the bus can fire.\n let flowAdapterRef: FlowAdapter | null = null;\n let flowHandleRef: import(\"@skaile/workspaces/connectors\").ConnectorHandle | null = null;\n\n const stimulusBus = createSessionStimulusBus({\n driveTurn: async (\n promptFragment: string,\n metas: Array<Record<string, unknown>>,\n ): Promise<void> => {\n // The adapter signal carries `meta.kind` per stimulus. Use that to\n // reconstruct the typed `TurnStimulus`; for compound batches, fall\n // back to `state_changed` (the union element that means \"look at\n // current state and continue\").\n const lastKind = metas[metas.length - 1]?.kind;\n let stimulus: TurnStimulus;\n if (lastKind === \"flow_started\") {\n stimulus = { kind: \"flow_started\" };\n } else if (\n lastKind === \"user_message\" &&\n typeof metas[metas.length - 1]?.text === \"string\"\n ) {\n const meta = metas[metas.length - 1] as Record<string, unknown>;\n stimulus = {\n kind: \"user_message\",\n text: String(meta.text ?? \"\"),\n senderId: String(meta.senderId ?? \"user\"),\n };\n } else {\n stimulus = { kind: \"state_changed\" };\n }\n // The fragment passed in by the bus is the adapter's\n // `renderStimulusPrompt(stim)` joined across coalesced signals. It is\n // discarded in favour of the structured stimulus, which\n // `driveOrchestratorTurn` rebuilds the full prompt from; that keeps the\n // prompt shape stable and the structured form already contains\n // everything the fragment encoded.\n void promptFragment;\n if (!flowAdapterRef || !flowHandleRef) {\n throw new Error(\"driveTurn fired before FlowAdapter was wired\");\n }\n await flowAdapterRef.drainRuntimeNodes(flowHandleRef);\n const execution = flowAdapterRef.getExecution(flowHandleRef);\n if (execution.done || execution.status === \"failed\" || execution.status === \"cancelled\") {\n return;\n }\n if (!flowAdapterRef.shouldDriveAgentTurn(flowHandleRef, stimulus)) return;\n await ensureHarnessStarted();\n await driveOrchestratorTurn({\n flow,\n execution,\n stimulus,\n emit: emitFlowPrompt,\n deliver: (prompt) => awaitAgentEnd(harness, prompt, opts.onEvent, turnTimeoutMs),\n });\n },\n log: flowLog,\n });\n\n const flowAdapter = new FlowAdapter();\n const flowHandle = await flowAdapter.connect(\n {\n id: flowConnectorId,\n driver: \"flow\",\n access: \"read-write\" as const,\n options: {\n flow,\n seed: {\n runId: session.runId,\n startedBy: \"cli\",\n autonomousMode: opts.autonomousMode ?? true,\n },\n stimulusBus,\n useBusForStimulus: true,\n nodeExecutor,\n subpromptRunner,\n inlineSubFlowRunner,\n },\n },\n {}, // flow needs no connect context\n );\n flowAdapterRef = flowAdapter;\n flowHandleRef = flowHandle;\n\n // Flow operations retain the connector's published bare protocol names;\n // this is the intentional exception to generic capability namespaces.\n for (const operation of flowAdapter.tools\n .describeOperations(flowHandle)\n .filter(({ name }) => FLOW_AGENT_OPERATION_NAMES.has(name))) {\n const shape: Record<string, z.ZodType> = {};\n for (const arg of operation.args) {\n let schema: z.ZodType;\n switch (arg.type) {\n case \"boolean\":\n schema = z.boolean();\n break;\n case \"number\":\n schema = z.number();\n break;\n case \"json\":\n schema = z.json();\n break;\n default:\n schema = z.string();\n }\n shape[arg.name] = arg.required ? schema : schema.optional();\n }\n capabilityRegistry.register(\n defineCapability({\n name: operation.name,\n displayName: operation.name,\n description: operation.description,\n input: z.object(shape),\n side: \"agent\",\n origin: { kind: \"flow\", flowId: flow.id },\n scope: \"session\",\n audience: [\"llm\"],\n kind: operation.accessLevel === \"read\" ? \"query\" : \"effect\",\n handler: async (args: Record<string, unknown>) =>\n flowAdapter.executeOp(flowHandle, operation.name, args),\n }),\n \"agent\",\n );\n }\n\n // Forward state_changed events to the caller. The bus computes a\n // turn-kicking stimulus on each adapter mutation; the host-facing\n // event stream still observes the full snapshot via onChange.\n flowAdapter.onStateChange(flowHandle, (state: FlowExecution) => {\n opts.onEvent?.({\n type: \"state_changed\",\n store: `flow:${state.runId}`,\n state: state as unknown as Record<string, unknown>,\n } as unknown as AgentEvent);\n });\n\n // ── Execute ────────────────────────────────────────────────────────────\n flowLog.info(\"starting flow\", {\n flowId: flow.id,\n flowName: flow.name,\n runId: session.runId,\n });\n\n let runError: unknown;\n try {\n // Kick the initial flow_started turn explicitly. Subsequent turns are\n // driven by the bus signaling whenever the adapter mutates.\n const initialStimulus: TurnStimulus = { kind: \"flow_started\" };\n await stimulusBus.signal(flowConnectorId, {\n promptFragment: renderStimulusPrompt(initialStimulus),\n meta: { kind: initialStimulus.kind },\n });\n\n const finalState = flowAdapter.getExecution(flowHandle);\n if (finalState.done) {\n flowLog.info(\"flow complete\", { flowId: flow.id, flowName: flow.name });\n } else if (finalState.status === \"failed\") {\n flowLog.error(\"flow failed\", undefined, { flowId: flow.id, flowName: flow.name });\n } else {\n flowLog.warn(\"flow paused awaiting further stimulus\", {\n flowId: flow.id,\n status: finalState.status,\n note: \"CLI mode does not supply human approval/input decisions\",\n });\n }\n } catch (err) {\n // The harness could not start (SDK missing, bad credentials, …): no node ran, so the\n // session is `failed` with the cause, not a `paused` run that `resume` would pick up.\n runError = err;\n throw err;\n } finally {\n harness.kill();\n const lastState = flowAdapter.getExecution(flowHandle);\n const failed = runError !== undefined;\n let status: \"complete\" | \"failed\" | \"paused\" = \"paused\";\n if (failed) status = \"failed\";\n else if (lastState.status === \"complete\") status = \"complete\";\n await saveSession(\n opts.projectDir,\n touchSession({\n ...updatedSession,\n harnessSessionId: harness.runtimeSessionId ?? updatedSession.harnessSessionId,\n status,\n ...(failed\n ? { error: runError instanceof Error ? runError.message : String(runError) }\n : {}),\n }),\n ).catch(() => {});\n await flowAdapter.disconnect(flowHandle).catch(() => {});\n await agentSession.dispose();\n telemetry.endTrace(flowTrace, {\n status: flowAdapter.getExecution(flowHandle).status === \"complete\" ? \"ok\" : \"error\",\n });\n await telemetry.flush().catch(() => {});\n }\n } finally {\n disposeLogStore();\n }\n}\n\n/**\n * Resume an existing session from the CLI.\n *\n * With the Phase 2 turn-based model, flow state is NOT persisted to\n * local session files — only the harness session ID is kept. The CLI\n * can resume the agent's conversation thread, but the flow execution\n * itself starts from scratch because the runner has no durable store\n * for per-run state.\n *\n * For a governed, resumable flow run, use a host that persists flow\n * state (e.g. the Skaile platform). CLI resume is retained as a\n * harness-level convenience only: we load the session, restart the\n * flow, and the SDK will reconnect to the prior conversation thread.\n *\n * @docLink packages/factory-assets/flow#resume-flow\n */\nexport async function resumeFlow(opts: ResumeOptions): Promise<void> {\n const runner = await loadRunnerModule();\n const { loadSession, loadSessionById, bootstrapRunnerLogStore } = runner;\n\n const session = opts.sessionId\n ? await loadSessionById(opts.projectDir, opts.sessionId)\n : await loadSession(opts.projectDir);\n\n if (!session) {\n const hint = opts.sessionId\n ? `session ${opts.sessionId}`\n : `current session in ${opts.projectDir}/.skaile`;\n throw new Error(`No session found (${hint}) — run 'start' first`);\n }\n\n const flowPath = resolveFlowPath(session.flowId, opts.projectDir);\n\n // Bootstrap a transient logger for the resume diagnostics. The inner\n // runFlow() call will register its own LogStore for the new run. Keep\n // OnLogBridgeSink wiring so callers passing onLog still see this line.\n const wsConfigEarly = resolveSkWorkspaceConfig(opts.projectDir);\n const { dispose: disposeLogStore } = bootstrapRunnerLogStore({\n sessionId: session.runId,\n projectDir: opts.projectDir,\n yamlBlock: wsConfigEarly.logging,\n onLog: opts.onLog,\n stdout: opts.onLog === undefined,\n });\n const flowLog = createLogger({\n kind: \"flow-connector\",\n subkind: \"run\",\n instance: session.runId,\n });\n flowLog.info(\"resuming session\", {\n runId: session.runId,\n flowId: session.flowId,\n note: \"CLI mode does not persist flow state — flow restarts from scratch; harness thread resumes\",\n });\n\n try {\n await runFlow({\n projectDir: opts.projectDir,\n flowPath,\n agentDir: opts.agentDir ?? session.agentDir,\n harness: session.harness,\n model: session.model,\n sessionLabel: session.label,\n resumeSession: session,\n dryRun: opts.dryRun,\n sessionTimeoutMs: opts.sessionTimeoutMs,\n onEvent: opts.onEvent,\n onLog: opts.onLog,\n });\n } finally {\n disposeLogStore();\n }\n}\n\n// ---------------------------------------------------------------------------\n// Helpers\n// ---------------------------------------------------------------------------\n\nasync function validatePinnedVersions(\n flow: Awaited<ReturnType<typeof loadFlow>>,\n projectDir: string,\n log: (line: string) => void,\n): Promise<void> {\n const pinnedNodes = flowSkillVersionPins(flow);\n if (pinnedNodes.length === 0) return;\n\n const skillVersions = new Map<string, string>();\n const aiResourcesDir = findAiResourcesDir(projectDir);\n if (aiResourcesDir) {\n for (const node of pinnedNodes) {\n const skillId = node.skillId;\n if (skillVersions.has(skillId)) continue;\n const skillPath = findSkillMd(aiResourcesDir, skillId);\n if (skillPath) {\n const content = fs.readFileSync(skillPath, \"utf-8\");\n const fm = parseSkillFrontmatter(content);\n skillVersions.set(skillId, fm.metadata?.version ?? fm.version ?? \"\");\n }\n }\n }\n\n const checks = validateFlowVersions(pinnedNodes, skillVersions);\n const failures = checks.filter((c) => !c.satisfied);\n if (failures.length > 0) {\n const lines = failures.map(\n (f) => ` ${f.nodeId}: wants ${f.requested}, found ${f.actual || \"(none)\"}`,\n );\n throw new Error(`Skill version mismatch:\\n${lines.join(\"\\n\")}`);\n }\n for (const c of checks.filter((c) => c.satisfied)) {\n log(` Version OK: ${c.skillId} ${c.actual} satisfies ${c.requested}`);\n }\n}\n\n/**\n * Assert `found` sits inside one of `roots`.\n *\n * A backstop, not the primary control: `isValidAssetName` already rejects every\n * id containing a separator, and `findFlowFileInRoots` skips any candidate that\n * escapes its search dir. So on today's code this cannot fire — it is here to\n * fail loudly rather than silently if a future lookup stops enforcing\n * containment itself. Widening the accepted extensions must never widen which\n * paths are reachable, and this is the line that keeps that honest.\n */\nfunction assertContainedInAnyRoot(found: string, roots: string[], flowId: string): void {\n const resolved = path.resolve(found);\n const inside = roots.some((root) => {\n const relative = path.relative(path.resolve(root), resolved);\n return !relative.startsWith(\"..\") && !path.isAbsolute(relative);\n });\n if (!inside) {\n throw new Error(`Flow path escapes its lookup root: ${JSON.stringify(flowId)}`);\n }\n}\n\n/** One line per near-miss: a file that is right there but was still rejected. */\nfunction describeMisses(misses: FlowLookupMiss[], heading: string): string {\n const seen = new Set<string>();\n const lines: string[] = [];\n for (const miss of misses) {\n if (seen.has(miss.path)) continue;\n seen.add(miss.path);\n lines.push(\n miss.reason === \"id-mismatch\"\n ? ` ${miss.path}: declares id ${JSON.stringify(miss.declaredId ?? \"\")}`\n : ` ${miss.path}: could not be parsed (${miss.error ?? \"unknown error\"})`,\n );\n }\n return lines.length > 0 ? `\\n${heading}\\n${lines.join(\"\\n\")}` : \"\";\n}\n\n/**\n * Resolve one flow identity through the CLI/serve host's normal lookup order —\n * the same roots and filenames `skaile run` and `flow list` use, via\n * {@link flowLookupRoots} / {@link findFlowFileInRoots}. Resolution is by the\n * **declared** `id`, not by filename.\n *\n * @throws {Error} When `flowId` is not a canonical asset name, when no file\n * declares it, or when a match somehow resolves outside every lookup root.\n */\nexport function resolveFlowPath(flowId: string, projectDir: string): string {\n // Sub-flow targets and resumed session records are the two callers, so an\n // identity that is not canonical is a bug in the caller, not a missing file.\n if (!isValidAssetName(flowId)) {\n throw new Error(`Invalid canonical flow identity: ${JSON.stringify(flowId)}`);\n }\n\n const roots = flowLookupRoots(projectDir);\n const misses: FlowLookupMiss[] = [];\n const found = findFlowFileInRoots(flowId, roots, { onMiss: (m) => misses.push(m) });\n if (found) {\n assertContainedInAnyRoot(found, roots, flowId);\n return found;\n }\n\n // A file that is present but unparseable is a different problem from a missing\n // one, and \"not found\" is the wrong headline for it — that exact misdirection\n // is what this change exists to remove, so don't reintroduce it here.\n if (misses.length > 0 && misses.every((m) => m.reason === \"unparseable\")) {\n throw new Error(\n `Flow ${flowId} was found but could not be loaded.` + describeMisses(misses, \"Candidates:\"),\n );\n }\n\n const shown = roots.slice(0, 3).join(\", \");\n const more = roots.length > 3 ? \", …\" : \"\";\n // Spelled from FLOW_FILE_EXTENSIONS so the message cannot drift from the\n // candidate list the lookup actually probes.\n const accepted = FLOW_FILE_EXTENSIONS.map((ext) => `${flowId}${ext}`).join(\" | \");\n throw new Error(\n `Flow not found: ${flowId}. Searched ${roots.length} root(s) (${shown || \"none\"}${more}) ` +\n `for ${accepted} — flat, or inside a ${flowId}/ directory. ` +\n `Only the flows of this project are found: run \\`skaile add flow:@<publisher>/<name>\\` first for a flow that lives in a library or source.` +\n describeMisses(misses, \"Near misses:\"),\n );\n}\n\n/** Walk up from projectDir to find ai-assets/ */\nfunction findAiResourcesDir(projectDir: string): string | null {\n let dir = projectDir;\n for (let i = 0; i < 6; i++) {\n const candidate = path.join(dir, \"ai-assets\");\n if (fs.existsSync(candidate)) return candidate;\n const parent = path.dirname(dir);\n if (parent === dir) break;\n dir = parent;\n }\n return null;\n}\n\n/** Find SKILL.md for a given skill ID in any `skills/` directory under ai-assets */\nfunction findSkillMd(aiResourcesDir: string, skillId: string): string | null {\n for (const skillsDir of findKindDirs(aiResourcesDir, \"skills\")) {\n const found = walkForSkill(skillsDir, skillId);\n if (found) return found;\n }\n return null;\n}\n\n// ---------------------------------------------------------------------------\n// Turn-wait helper\n// ---------------------------------------------------------------------------\n\n/**\n * Minimal harness surface needed by the bus's `driveTurn` callback. Mirrors\n * the slice the legacy `FlowOrchestrator` consumed (`prompt` + `on` +\n * `removeAllListeners`) so we can keep the wait helper private to this\n * module without pulling in a runtime dep on `@skaile/workspaces/bridge`.\n */\ninterface TurnHarnessSurface {\n prompt(message: string): Promise<void>;\n on(event: \"agent-event\", handler: (event: AgentEvent) => void): void;\n removeAllListeners(event: \"agent-event\"): void;\n}\n\n/**\n * Send a prompt to the harness and resolve when the agent emits\n * `agent_end` (or reject on an `error` that is not an in-place retry).\n * Identical contract to the legacy `awaitAgentEnd` helper from\n * `flow-orchestrator.ts`. Phase 4 lifts the helper into `run-flow.ts` because\n * the bus now owns turn driving. Exported for tests only.\n */\nexport function awaitAgentEnd(\n harness: TurnHarnessSurface,\n prompt: string,\n onEvent: ((event: AgentEvent) => void) | undefined,\n timeoutMs: number,\n): Promise<void> {\n return new Promise<void>((resolve, reject) => {\n let settled = false;\n\n const done = (err?: Error) => {\n if (settled) return;\n settled = true;\n clearTimeout(timer);\n harness.removeAllListeners(\"agent-event\");\n if (err) reject(err);\n else resolve();\n };\n\n const timer = setTimeout(\n () => done(new Error(`Flow turn timed out after ${timeoutMs / 1000}s`)),\n timeoutMs,\n );\n\n harness.on(\"agent-event\", (event: AgentEvent) => {\n onEvent?.(event);\n if (event.type === \"agent_end\") done();\n // An in-place retry replays this same turn; its own end settles it.\n else if (event.type === \"error\" && event.retrying !== true) {\n const msg =\n (event as { error?: string; message?: string }).error ??\n (event as { message?: string }).message ??\n \"Agent error\";\n done(new Error(msg));\n }\n });\n\n harness.prompt(prompt).catch(done);\n });\n}\n\nfunction walkForSkill(dir: string, skillId: string): string | null {\n for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {\n if (!entry.isDirectory()) continue;\n const full = path.join(dir, entry.name);\n const skillMd = path.join(full, \"SKILL.md\");\n if (fs.existsSync(skillMd)) {\n if (entry.name === skillId) return skillMd;\n } else {\n const found = walkForSkill(full, skillId);\n if (found) return found;\n }\n }\n return null;\n}\n"]}
1
+ {"version":3,"sources":["../factory-assets/connectors/flow/run-flow.ts"],"names":["c"],"mappings":";;;;;;;;;;;;;;;;AAkEA,IAAI,aAAA;AAEJ,eAAe,gBAAA,GAAiC;AAC9C,EAAA,IAAI,eAAe,OAAO,aAAA;AAC1B,EAAA,aAAA,GAAgB,MAAM,OAAO,mBAA2B,CAAA;AACxD,EAAA,OAAO,aAAA;AACT;AAMA,IAAM,0BAAA,GAA6B,CAAA,GAAI,EAAA,GAAK,EAAA,GAAK,GAAA;AAEjD,IAAM,0BAAA,uBAAiC,GAAA,CAAI;AAAA,EACzC,eAAA;AAAA,EACA,WAAA;AAAA,EACA,aAAA;AAAA,EACA,eAAA;AAAA,EACA,eAAA;AAAA,EACA,YAAA;AAAA,EACA,kBAAA;AAAA,EACA,eAAA;AAAA,EACA,eAAA;AAAA,EACA,WAAA;AAAA,EACA;AACF,CAAC,CAAA;AA4HD,eAAsB,QAAQ,IAAA,EAAiC;AAC7D,EAAA,MAAM,MAAA,GAAS,MAAM,gBAAA,EAAiB;AACtC,EAAA,MAAM;AAAA,IACJ,uBAAA;AAAA,IACA,2BAAA;AAAA,IACA,kBAAA;AAAA,IACA,kBAAA;AAAA,IACA,wBAAA;AAAA,IACA,gBAAA;AAAA,IACA,+BAAA;AAAA,IACA,mBAAA;AAAA,IACA,UAAA;AAAA,IACA,WAAA;AAAA,IACA;AAAA,GACF,GAAI,MAAA;AAEJ,EAAA,MAAM,IAAA,GAAO,QAAA,CAAS,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,MAAA,MAAM,KAAA,GAAQ,YAAA,CAAa,IAAA,EAAM,OAAO,CAAA;AACxC,MAAA,IAAI,OAAO,OAAO,KAAA;AAAA,IACpB;AAAA,EACF;AACA,EAAA,OAAO,IAAA;AACT","file":"chunk-5ETYBC2X.js","sourcesContent":["/**\n * runFlow / resumeFlow — CLI entry helpers for the flow connector.\n *\n * Moved from `runner/src/runner.ts` to `factory-assets/connectors/flow/run-flow.ts`\n * in Phase 3 of the flow-connector extraction (2026-05-08). Behaviour is\n * byte-identical to the previous runner-side implementation; only the log\n * source changes from `runner:flow:<runId>` to `flow-connector:run:<runId>`.\n *\n * The runner re-exports these symbols with a deprecation warning for one\n * release. CLI consumers should switch to\n * `import { runFlow, resumeFlow } from \"@skaile/workspaces/factory-assets/connectors/flow/run-flow\"`.\n *\n * Internal runner helpers (FlowOrchestrator, bootstrapRunnerLogStore,\n * createAgentSession, resolveHarnessPaths, session helpers) are loaded lazily\n * via dynamic `await import(\"@skaile/workspaces/runner\")` inside\n * `loadRunnerModule()` below. The lazy load avoids a static package-level\n * cycle (runner → connectors → factory-assets → runner) — the cycle exists at\n * the workspace level but never resolves at module-load time because\n * factory-assets only ever calls `import` from inside an async function body.\n * The string-literal specifier preserves `bun --compile` and tsup static\n * analysis.\n */\n\nimport fs from \"node:fs\";\nimport path from \"node:path\";\nimport type { AgentEvent } from \"@skaile/workspaces/bridge\";\nimport {\n DEFAULT_HARNESS_ID,\n findKindDirs,\n isValidAssetName,\n resolveAgentDir,\n resolveSettings,\n resolveSkWorkspaceConfig,\n} from \"@skaile/workspaces/core\";\nimport { createLogger } from \"@skaile/workspaces/core/logging\";\nimport { parseSkillFrontmatter, validateFlowVersions } from \"@skaile/workspaces/resolver\";\nimport { initTelemetry } from \"@skaile/workspaces/telemetry\";\nimport type { FlowExecution, FlowPromptEvent } from \"@skaile/workspaces/types\";\nimport * as z from \"zod\";\nimport { FlowAdapter } from \"./adapter.js\";\nimport {\n findFlowFileInRoots,\n FLOW_FILE_EXTENSIONS,\n type FlowLookupMiss,\n flowLookupRoots,\n loadFlow,\n} from \"./engine/index.js\";\nimport { flowSkillVersionPins } from \"./engine/node-shape.js\";\nimport { SessionInlineSubFlowRunner } from \"./inline-sub-flow-host.js\";\nimport { SessionNodeExecutor } from \"./node-executor.js\";\nimport { driveOrchestratorTurn } from \"./orchestrator-turn.js\";\nimport { renderStimulusPrompt, type TurnStimulus } from \"./prompt-fragments.js\";\nimport { SessionSubpromptRunner } from \"./subprompt-runner.js\";\n\n/**\n * Lazy `import(\"@skaile/workspaces/runner\")` accessor. Cached on first call so\n * subsequent `runFlow` invocations don't re-evaluate the runner module.\n *\n * Dynamic ESM import is used (not `require`) so vitest and other ESM\n * bundlers honour their alias resolution — `require` would side-step the\n * configured aliases and pick up two distinct module instances when run\n * under vitest. The string-literal specifier ensures bun --compile keeps\n * the dependency (per the static-import-or-die rule in\n * connectors/CLAUDE.md).\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nlet _runnerModule: any | undefined;\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nasync function loadRunnerModule(): Promise<any> {\n if (_runnerModule) return _runnerModule;\n _runnerModule = await import(\"@skaile/workspaces/runner\");\n return _runnerModule;\n}\n\n/** Type-only re-export of SessionState so the runner tombstone shim still works. */\nexport type SessionState = import(\"@skaile/workspaces/runner\").SessionState;\n\n/** Maximum agent session duration (4 hours). Configurable via {@link RunOptions.sessionTimeoutMs}. */\nconst DEFAULT_SESSION_TIMEOUT_MS = 4 * 60 * 60 * 1000; // 4 hours\n\nconst FLOW_AGENT_OPERATION_NAMES = new Set([\n \"get_available\",\n \"get_state\",\n \"get_globals\",\n \"build_handoff\",\n \"validate_node\",\n \"start_node\",\n \"request_approval\",\n \"request_input\",\n \"complete_node\",\n \"skip_node\",\n \"fail_node\",\n]);\n\n/**\n * Options for {@link runFlow}.\n *\n * Wraps `FlowOrchestrator` with autonomous mode turned on by default. First-class\n * gate nodes remain mandatory human decisions in every mode.\n *\n * @docLink packages/factory-assets/flow#run-flow\n */\nexport interface RunOptions {\n /** The working directory for the project being orchestrated. */\n projectDir: string;\n /** Absolute path to the `.flow.yaml` or `.flow.json` definition file. */\n flowPath: string;\n /**\n * Directory containing `agent.yaml`, `SOUL.md`, `RULES.md`, `knowledge/`.\n * Resolved from `skaile.yaml` via `resolveAgentDir` when absent.\n */\n agentDir?: string;\n /**\n * Agent harness. Defaults to `settings.harness` (`\"omp\"` or `\"claude-sdk\"`).\n */\n harness?: string;\n /**\n */\n /**\n * Model name override. Falls back to `settings.model` when absent.\n */\n model?: string;\n /**\n * Path to a specific `settings.json` to load instead of the default\n * layered resolution chain (project → parent → global → built-in defaults).\n */\n settingsFile?: string;\n /**\n * When `true`, prints the initial flow state without starting the agent\n * and returns immediately.\n */\n dryRun?: boolean;\n /**\n * Per-session timeout in milliseconds. Defaults to\n * {@link DEFAULT_SESSION_TIMEOUT_MS} (4 hours).\n */\n sessionTimeoutMs?: number;\n /** Optional human-readable label shown in the session list. */\n sessionLabel?: string;\n /**\n * The session `skaile resume` continues. Its run id is kept and its harness thread resumed,\n * instead of starting a second session. Set by {@link resumeFlow}; not for other callers.\n */\n resumeSession?: SessionState;\n /** Autonomous mode for CLI runs. Defaults to true; first-class gate nodes are never bypassed. */\n autonomousMode?: boolean;\n /**\n * Called for each {@link AgentEvent} emitted during the run\n * (e.g. `text`, `tool_call`, `state_changed`).\n */\n onEvent?: (event: AgentEvent) => void;\n /**\n * Called for each diagnostic log line. Defaults to `process.stdout`.\n */\n onLog?: (line: string) => void;\n}\n\n/**\n * Options for resuming an existing CLI session.\n *\n * Reconnects the harness's conversation thread (conversation history is\n * preserved via the stored `harnessSessionId`) but restarts flow execution\n * from scratch — flow state is not persisted in CLI mode. For governed,\n * resumable flow runs use a host that persists flow state (e.g. the Skaile\n * platform).\n *\n * @docLink packages/factory-assets/flow#resume-flow\n */\nexport interface ResumeOptions {\n /** The working directory for the project being orchestrated. */\n projectDir: string;\n /**\n * Specific run ID to resume. When absent, the current session pointer\n * at `<projectDir>/.skaile/current` is used.\n */\n sessionId?: string;\n /**\n * Agent definition directory override. Defaults to the directory stored\n * in the session file.\n */\n agentDir?: string;\n /**\n * When `true`, prints the initial flow state without starting the agent\n * and returns immediately.\n */\n dryRun?: boolean;\n /**\n * Per-session timeout in milliseconds. Defaults to\n * {@link DEFAULT_SESSION_TIMEOUT_MS} (4 hours).\n */\n sessionTimeoutMs?: number;\n /**\n * Called for each {@link AgentEvent} emitted during the run.\n */\n onEvent?: RunOptions[\"onEvent\"];\n /**\n * Called for each diagnostic log line. Defaults to `process.stdout`.\n */\n onLog?: RunOptions[\"onLog\"];\n}\n\n// ---------------------------------------------------------------------------\n// Public API\n// ---------------------------------------------------------------------------\n\n/**\n * Start a new flow session from the CLI.\n *\n * Wraps `FlowOrchestrator` with autonomous mode turned on by default. The\n * runner remains idle between turns; first-class gates always park for a human\n * decision, including in autonomous mode. Non-CLI hosts (Skaile platform,\n * Pichi) use the orchestrator directly via the serve command surface and drive\n * gates through user actions.\n *\n * @docLink packages/factory-assets/flow#run-flow\n */\nexport async function runFlow(opts: RunOptions): Promise<void> {\n const runner = await loadRunnerModule();\n const {\n bootstrapRunnerLogStore,\n bootstrapCapabilityRegistry,\n CapabilityRegistry,\n createAgentSession,\n createSessionStimulusBus,\n defineCapability,\n registerCompositionCapabilities,\n resolveHarnessPaths,\n newSession,\n saveSession,\n touchSession,\n } = runner;\n\n const flow = loadFlow(opts.flowPath);\n const agentDir = opts.agentDir ?? resolveAgentDir(opts.projectDir);\n const settings = await resolveSettings(opts.projectDir, {\n harness: opts.harness,\n model: opts.model,\n });\n\n // `skaile resume` continues the session it was given: same run id, so the harness thread\n // (`harnessSessionId`) resumes and `session list` shows one run, not a second one (p850).\n const session = opts.resumeSession\n ? (({ error: _prior, ...kept }) => touchSession({ ...kept, status: \"running\" }))(\n opts.resumeSession,\n )\n : newSession({\n flowId: flow.id,\n projectDir: opts.projectDir,\n agentDir,\n harness: settings.harness ?? DEFAULT_HARNESS_ID,\n model: settings.model,\n label: opts.sessionLabel,\n });\n\n // A dry run only prints the plan: it must not leave a `running` session behind.\n if (!opts.dryRun) await saveSession(opts.projectDir, session);\n\n // Bootstrap structured logging — registers a process-singleton LogStore.\n // OnLogBridgeSink mirrors entries to opts.onLog when caller provides one,\n // preserving back-compat with CLI hosts that consume plain text lines.\n const wsConfigEarly = resolveSkWorkspaceConfig(opts.projectDir);\n const { dispose: disposeLogStore } = bootstrapRunnerLogStore({\n sessionId: session.runId,\n projectDir: opts.projectDir,\n yamlBlock: wsConfigEarly.logging,\n onLog: opts.onLog,\n // A host that takes lines through `onLog` prints them itself; the stdout\n // sink would add every record again as a raw JSON line.\n stdout: opts.onLog === undefined,\n });\n const flowLog = createLogger({\n kind: \"flow-connector\",\n subkind: \"run\",\n instance: session.runId,\n });\n const log = (line: string) => flowLog.info(line);\n const capabilityRegistry = new CapabilityRegistry();\n bootstrapCapabilityRegistry(capabilityRegistry);\n const capabilityHooks = {\n sessionId: session.runId,\n composeTools: () => capabilityRegistry.composeLLMTools(),\n resolve: (name: string) =>\n capabilityRegistry.list().find((cap: { name: string }) => cap.name === name) ?? null,\n invoke: (name: string, input: unknown, _signal?: AbortSignal, callId?: string) =>\n capabilityRegistry.invoke(name, input, { sessionId: session.runId, callId }),\n };\n\n try {\n // ── Dry run ────────────────────────────────────────────────────────────\n if (opts.dryRun) {\n const adapter = new FlowAdapter();\n const handle = await adapter.connect(\n {\n id: \"flow\",\n driver: \"flow\",\n access: \"read-only\" as const,\n options: { flow, seed: { runId: session.runId, startedBy: \"cli\" } },\n },\n {}, // flow needs no connect context\n );\n const state = adapter.getExecution(handle);\n const available = Object.values(state.nodes)\n .filter((n) => n.status === \"available\")\n .map((n) => n.id);\n // The plan is the command's output, not a log event: print it as plain lines\n // (no `[info] [flow-connector:run:…]` prefix from the log formatter).\n const printPlan = opts.onLog ?? ((line: string) => console.log(line));\n printPlan(`[dry-run] Flow: ${flow.name} (${flow.id})`);\n printPlan(`[dry-run] Available: ${available.join(\", \") || \"(none)\"}`);\n await adapter.disconnect(handle);\n return;\n }\n\n await validatePinnedVersions(flow, opts.projectDir, log);\n\n // ── Telemetry initialization ────────────────────────────────────────────\n const wsConfig = wsConfigEarly;\n const telemetry = await initTelemetry(wsConfig.telemetry);\n const flowTrace = telemetry.startTrace({\n name: `flow:${flow.id}`,\n kind: \"flow_run\",\n attributes: {\n \"skaile.flow.id\": flow.id,\n \"skaile.flow.run_id\": session.runId,\n },\n });\n\n // ── Agent session setup ─────────────────────────────────────────────────\n const harnessPaths = resolveHarnessPaths(settings);\n const agentSession = await createAgentSession({\n projectDir: opts.projectDir,\n agentDir: session.agentDir,\n harness: session.harness,\n model: session.model,\n resumeSessionId: session.harnessSessionId,\n projectClaudeMd: path.join(opts.projectDir, \"CLAUDE.md\"),\n promptsDir: path.join(opts.projectDir, harnessPaths.promptsDir),\n sessionId: session.runId,\n onLog: log,\n telemetry,\n trace: flowTrace,\n wsConfig,\n capabilities: capabilityHooks,\n capabilityRegistry,\n // A flow step has no one to answer an approval card: with `permission_mode: interactive`\n // a tool call that needs approval is refused instead of hanging the step.\n unattended: true,\n });\n if (agentSession.composition?.discoverableEntries.length) {\n registerCompositionCapabilities(\n capabilityRegistry,\n agentSession.composition.discoverableEntries,\n );\n }\n const { harness } = agentSession;\n const nodeExecutor = new SessionNodeExecutor({ workspaceDir: opts.projectDir });\n // Same endpoints and credentials the session harness used: the registry\n // and the credential env `createAgentSession` already resolved — not a\n // new resolution, not a new secret channel.\n const subpromptRunner = new SessionSubpromptRunner({\n harnessType: agentSession.harnessType,\n sessionModel: agentSession.model,\n workspaceDir: opts.projectDir,\n registry: agentSession.registry,\n credentialEnv: agentSession.credentialEnv,\n ...(agentSession.modelRef ? { modelRef: agentSession.modelRef } : {}),\n });\n let harnessStarted = false;\n const updatedSession = { ...session };\n\n // Track harness session ID so future resumes can reconnect the SDK thread.\n harness.on(\"agent-event\", () => {\n const runtimeSessionId = harness.runtimeSessionId;\n if (!runtimeSessionId || runtimeSessionId === updatedSession.harnessSessionId) return;\n updatedSession.harnessSessionId = runtimeSessionId;\n void saveSession(opts.projectDir, updatedSession).catch(() => {});\n });\n\n // ── FlowAdapter + stimulus bus ─────────────────────────────────────────\n //\n // Phase 4 of the flow-connector extraction: SessionStimulusBus is the sole\n // turn driver. The legacy FlowOrchestrator + onStateChange subscription\n // are gone — every turn is initiated either by the bus (after an adapter\n // mutation observed via `useBusForStimulus: true`) or by an explicit\n // `bus.signal()` call from this function (the initial flow_started turn).\n //\n // The bus's `driveTurn` callback receives the stimulus paragraph the\n // adapter rendered (not the full orchestrator prompt). It hands the turn to\n // `driveOrchestratorTurn`, which rebuilds the five-section prompt so the\n // agent sees the same flow context the legacy orchestrator produced — and\n // announces it, so a CLI consumer's `onEvent` stream carries the prompt too.\n const flowConnectorId = \"flow\";\n const turnTimeoutMs = opts.sessionTimeoutMs ?? DEFAULT_SESSION_TIMEOUT_MS;\n\n const ensureHarnessStarted = async (): Promise<void> => {\n if (harnessStarted) return;\n await harness.start();\n harnessStarted = true;\n };\n\n // Same widening the `state_changed` forwarder below performs: `onEvent` is\n // typed against the bridge's harness-level union, which has no case for a\n // runtime-level event.\n const emitFlowPrompt = (event: FlowPromptEvent): void => {\n opts.onEvent?.(event as unknown as AgentEvent);\n };\n\n const inlineSubFlowRunner = new SessionInlineSubFlowRunner({\n resolveFlow: (flowId) => loadFlow(resolveFlowPath(flowId, opts.projectDir)),\n nodeExecutor,\n subpromptRunner,\n driveAgentTurn: async ({ flow: childFlow, execution, stimulus }) => {\n await ensureHarnessStarted();\n await driveOrchestratorTurn({\n flow: childFlow,\n execution,\n stimulus,\n emit: emitFlowPrompt,\n deliver: (prompt) => awaitAgentEnd(harness, prompt, opts.onEvent, turnTimeoutMs),\n });\n },\n });\n\n // Forward declaration so `driveTurn` can read the live execution\n // snapshot. Assigned just below, before the bus can fire.\n let flowAdapterRef: FlowAdapter | null = null;\n let flowHandleRef: import(\"@skaile/workspaces/connectors\").ConnectorHandle | null = null;\n\n const stimulusBus = createSessionStimulusBus({\n driveTurn: async (\n promptFragment: string,\n metas: Array<Record<string, unknown>>,\n ): Promise<void> => {\n // The adapter signal carries `meta.kind` per stimulus. Use that to\n // reconstruct the typed `TurnStimulus`; for compound batches, fall\n // back to `state_changed` (the union element that means \"look at\n // current state and continue\").\n const lastKind = metas[metas.length - 1]?.kind;\n let stimulus: TurnStimulus;\n if (lastKind === \"flow_started\") {\n stimulus = { kind: \"flow_started\" };\n } else if (\n lastKind === \"user_message\" &&\n typeof metas[metas.length - 1]?.text === \"string\"\n ) {\n const meta = metas[metas.length - 1] as Record<string, unknown>;\n stimulus = {\n kind: \"user_message\",\n text: String(meta.text ?? \"\"),\n senderId: String(meta.senderId ?? \"user\"),\n };\n } else {\n stimulus = { kind: \"state_changed\" };\n }\n // The fragment passed in by the bus is the adapter's\n // `renderStimulusPrompt(stim)` joined across coalesced signals. It is\n // discarded in favour of the structured stimulus, which\n // `driveOrchestratorTurn` rebuilds the full prompt from; that keeps the\n // prompt shape stable and the structured form already contains\n // everything the fragment encoded.\n void promptFragment;\n if (!flowAdapterRef || !flowHandleRef) {\n throw new Error(\"driveTurn fired before FlowAdapter was wired\");\n }\n await flowAdapterRef.drainRuntimeNodes(flowHandleRef);\n const execution = flowAdapterRef.getExecution(flowHandleRef);\n if (execution.done || execution.status === \"failed\" || execution.status === \"cancelled\") {\n return;\n }\n if (!flowAdapterRef.shouldDriveAgentTurn(flowHandleRef, stimulus)) return;\n await ensureHarnessStarted();\n await driveOrchestratorTurn({\n flow,\n execution,\n stimulus,\n emit: emitFlowPrompt,\n deliver: (prompt) => awaitAgentEnd(harness, prompt, opts.onEvent, turnTimeoutMs),\n });\n },\n log: flowLog,\n });\n\n const flowAdapter = new FlowAdapter();\n const flowHandle = await flowAdapter.connect(\n {\n id: flowConnectorId,\n driver: \"flow\",\n access: \"read-write\" as const,\n options: {\n flow,\n seed: {\n runId: session.runId,\n startedBy: \"cli\",\n autonomousMode: opts.autonomousMode ?? true,\n },\n stimulusBus,\n useBusForStimulus: true,\n nodeExecutor,\n subpromptRunner,\n inlineSubFlowRunner,\n },\n },\n {}, // flow needs no connect context\n );\n flowAdapterRef = flowAdapter;\n flowHandleRef = flowHandle;\n\n // Flow operations retain the connector's published bare protocol names;\n // this is the intentional exception to generic capability namespaces.\n for (const operation of flowAdapter.tools\n .describeOperations(flowHandle)\n .filter(({ name }) => FLOW_AGENT_OPERATION_NAMES.has(name))) {\n const shape: Record<string, z.ZodType> = {};\n for (const arg of operation.args) {\n let schema: z.ZodType;\n switch (arg.type) {\n case \"boolean\":\n schema = z.boolean();\n break;\n case \"number\":\n schema = z.number();\n break;\n case \"json\":\n schema = z.json();\n break;\n default:\n schema = z.string();\n }\n shape[arg.name] = arg.required ? schema : schema.optional();\n }\n capabilityRegistry.register(\n defineCapability({\n name: operation.name,\n displayName: operation.name,\n description: operation.description,\n input: z.object(shape),\n side: \"agent\",\n origin: { kind: \"flow\", flowId: flow.id },\n scope: \"session\",\n audience: [\"llm\"],\n kind: operation.accessLevel === \"read\" ? \"query\" : \"effect\",\n handler: async (args: Record<string, unknown>) =>\n flowAdapter.executeOp(flowHandle, operation.name, args),\n }),\n \"agent\",\n );\n }\n\n // Forward state_changed events to the caller. The bus computes a\n // turn-kicking stimulus on each adapter mutation; the host-facing\n // event stream still observes the full snapshot via onChange.\n flowAdapter.onStateChange(flowHandle, (state: FlowExecution) => {\n opts.onEvent?.({\n type: \"state_changed\",\n store: `flow:${state.runId}`,\n state: state as unknown as Record<string, unknown>,\n } as unknown as AgentEvent);\n });\n\n // ── Execute ────────────────────────────────────────────────────────────\n flowLog.info(\"starting flow\", {\n flowId: flow.id,\n flowName: flow.name,\n runId: session.runId,\n });\n\n let runError: unknown;\n try {\n // Kick the initial flow_started turn explicitly. Subsequent turns are\n // driven by the bus signaling whenever the adapter mutates.\n const initialStimulus: TurnStimulus = { kind: \"flow_started\" };\n await stimulusBus.signal(flowConnectorId, {\n promptFragment: renderStimulusPrompt(initialStimulus),\n meta: { kind: initialStimulus.kind },\n });\n\n const finalState = flowAdapter.getExecution(flowHandle);\n if (finalState.done) {\n flowLog.info(\"flow complete\", { flowId: flow.id, flowName: flow.name });\n } else if (finalState.status === \"failed\") {\n flowLog.error(\"flow failed\", undefined, { flowId: flow.id, flowName: flow.name });\n } else {\n flowLog.warn(\"flow paused awaiting further stimulus\", {\n flowId: flow.id,\n status: finalState.status,\n note: \"CLI mode does not supply human approval/input decisions\",\n });\n }\n } catch (err) {\n // The harness could not start (SDK missing, bad credentials, …): no node ran, so the\n // session is `failed` with the cause, not a `paused` run that `resume` would pick up.\n runError = err;\n throw err;\n } finally {\n harness.kill();\n const lastState = flowAdapter.getExecution(flowHandle);\n const failed = runError !== undefined;\n let status: \"complete\" | \"failed\" | \"paused\" = \"paused\";\n if (failed) status = \"failed\";\n else if (lastState.status === \"complete\") status = \"complete\";\n await saveSession(\n opts.projectDir,\n touchSession({\n ...updatedSession,\n harnessSessionId: harness.runtimeSessionId ?? updatedSession.harnessSessionId,\n status,\n ...(failed\n ? { error: runError instanceof Error ? runError.message : String(runError) }\n : {}),\n }),\n ).catch(() => {});\n await flowAdapter.disconnect(flowHandle).catch(() => {});\n await agentSession.dispose();\n telemetry.endTrace(flowTrace, {\n status: flowAdapter.getExecution(flowHandle).status === \"complete\" ? \"ok\" : \"error\",\n });\n await telemetry.flush().catch(() => {});\n }\n } finally {\n disposeLogStore();\n }\n}\n\n/**\n * Resume an existing session from the CLI.\n *\n * With the Phase 2 turn-based model, flow state is NOT persisted to\n * local session files — only the harness session ID is kept. The CLI\n * can resume the agent's conversation thread, but the flow execution\n * itself starts from scratch because the runner has no durable store\n * for per-run state.\n *\n * For a governed, resumable flow run, use a host that persists flow\n * state (e.g. the Skaile platform). CLI resume is retained as a\n * harness-level convenience only: we load the session, restart the\n * flow, and the SDK will reconnect to the prior conversation thread.\n *\n * @docLink packages/factory-assets/flow#resume-flow\n */\nexport async function resumeFlow(opts: ResumeOptions): Promise<void> {\n const runner = await loadRunnerModule();\n const { loadSession, loadSessionById, bootstrapRunnerLogStore } = runner;\n\n const session = opts.sessionId\n ? await loadSessionById(opts.projectDir, opts.sessionId)\n : await loadSession(opts.projectDir);\n\n if (!session) {\n const hint = opts.sessionId\n ? `session ${opts.sessionId}`\n : `current session in ${opts.projectDir}/.skaile`;\n throw new Error(`No session found (${hint}) — run 'start' first`);\n }\n\n const flowPath = resolveFlowPath(session.flowId, opts.projectDir);\n\n // Bootstrap a transient logger for the resume diagnostics. The inner\n // runFlow() call will register its own LogStore for the new run. Keep\n // OnLogBridgeSink wiring so callers passing onLog still see this line.\n const wsConfigEarly = resolveSkWorkspaceConfig(opts.projectDir);\n const { dispose: disposeLogStore } = bootstrapRunnerLogStore({\n sessionId: session.runId,\n projectDir: opts.projectDir,\n yamlBlock: wsConfigEarly.logging,\n onLog: opts.onLog,\n stdout: opts.onLog === undefined,\n });\n const flowLog = createLogger({\n kind: \"flow-connector\",\n subkind: \"run\",\n instance: session.runId,\n });\n flowLog.info(\"resuming session\", {\n runId: session.runId,\n flowId: session.flowId,\n note: \"CLI mode does not persist flow state — flow restarts from scratch; harness thread resumes\",\n });\n\n try {\n await runFlow({\n projectDir: opts.projectDir,\n flowPath,\n agentDir: opts.agentDir ?? session.agentDir,\n harness: session.harness,\n model: session.model,\n sessionLabel: session.label,\n resumeSession: session,\n dryRun: opts.dryRun,\n sessionTimeoutMs: opts.sessionTimeoutMs,\n onEvent: opts.onEvent,\n onLog: opts.onLog,\n });\n } finally {\n disposeLogStore();\n }\n}\n\n// ---------------------------------------------------------------------------\n// Helpers\n// ---------------------------------------------------------------------------\n\nasync function validatePinnedVersions(\n flow: Awaited<ReturnType<typeof loadFlow>>,\n projectDir: string,\n log: (line: string) => void,\n): Promise<void> {\n const pinnedNodes = flowSkillVersionPins(flow);\n if (pinnedNodes.length === 0) return;\n\n const skillVersions = new Map<string, string>();\n const aiResourcesDir = findAiResourcesDir(projectDir);\n if (aiResourcesDir) {\n for (const node of pinnedNodes) {\n const skillId = node.skillId;\n if (skillVersions.has(skillId)) continue;\n const skillPath = findSkillMd(aiResourcesDir, skillId);\n if (skillPath) {\n const content = fs.readFileSync(skillPath, \"utf-8\");\n const fm = parseSkillFrontmatter(content);\n skillVersions.set(skillId, fm.metadata?.version ?? fm.version ?? \"\");\n }\n }\n }\n\n const checks = validateFlowVersions(pinnedNodes, skillVersions);\n const failures = checks.filter((c) => !c.satisfied);\n if (failures.length > 0) {\n const lines = failures.map(\n (f) => ` ${f.nodeId}: wants ${f.requested}, found ${f.actual || \"(none)\"}`,\n );\n throw new Error(`Skill version mismatch:\\n${lines.join(\"\\n\")}`);\n }\n for (const c of checks.filter((c) => c.satisfied)) {\n log(` Version OK: ${c.skillId} ${c.actual} satisfies ${c.requested}`);\n }\n}\n\n/**\n * Assert `found` sits inside one of `roots`.\n *\n * A backstop, not the primary control: `isValidAssetName` already rejects every\n * id containing a separator, and `findFlowFileInRoots` skips any candidate that\n * escapes its search dir. So on today's code this cannot fire — it is here to\n * fail loudly rather than silently if a future lookup stops enforcing\n * containment itself. Widening the accepted extensions must never widen which\n * paths are reachable, and this is the line that keeps that honest.\n */\nfunction assertContainedInAnyRoot(found: string, roots: string[], flowId: string): void {\n const resolved = path.resolve(found);\n const inside = roots.some((root) => {\n const relative = path.relative(path.resolve(root), resolved);\n return !relative.startsWith(\"..\") && !path.isAbsolute(relative);\n });\n if (!inside) {\n throw new Error(`Flow path escapes its lookup root: ${JSON.stringify(flowId)}`);\n }\n}\n\n/** One line per near-miss: a file that is right there but was still rejected. */\nfunction describeMisses(misses: FlowLookupMiss[], heading: string): string {\n const seen = new Set<string>();\n const lines: string[] = [];\n for (const miss of misses) {\n if (seen.has(miss.path)) continue;\n seen.add(miss.path);\n lines.push(\n miss.reason === \"id-mismatch\"\n ? ` ${miss.path}: declares id ${JSON.stringify(miss.declaredId ?? \"\")}`\n : ` ${miss.path}: could not be parsed (${miss.error ?? \"unknown error\"})`,\n );\n }\n return lines.length > 0 ? `\\n${heading}\\n${lines.join(\"\\n\")}` : \"\";\n}\n\n/**\n * Resolve one flow identity through the CLI/serve host's normal lookup order —\n * the same roots and filenames `skaile run` and `flow list` use, via\n * {@link flowLookupRoots} / {@link findFlowFileInRoots}. Resolution is by the\n * **declared** `id`, not by filename.\n *\n * @throws {Error} When `flowId` is not a canonical asset name, when no file\n * declares it, or when a match somehow resolves outside every lookup root.\n */\nexport function resolveFlowPath(flowId: string, projectDir: string): string {\n // Sub-flow targets and resumed session records are the two callers, so an\n // identity that is not canonical is a bug in the caller, not a missing file.\n if (!isValidAssetName(flowId)) {\n throw new Error(`Invalid canonical flow identity: ${JSON.stringify(flowId)}`);\n }\n\n const roots = flowLookupRoots(projectDir);\n const misses: FlowLookupMiss[] = [];\n const found = findFlowFileInRoots(flowId, roots, { onMiss: (m) => misses.push(m) });\n if (found) {\n assertContainedInAnyRoot(found, roots, flowId);\n return found;\n }\n\n // A file that is present but unparseable is a different problem from a missing\n // one, and \"not found\" is the wrong headline for it — that exact misdirection\n // is what this change exists to remove, so don't reintroduce it here.\n if (misses.length > 0 && misses.every((m) => m.reason === \"unparseable\")) {\n throw new Error(\n `Flow ${flowId} was found but could not be loaded.` + describeMisses(misses, \"Candidates:\"),\n );\n }\n\n const shown = roots.slice(0, 3).join(\", \");\n const more = roots.length > 3 ? \", …\" : \"\";\n // Spelled from FLOW_FILE_EXTENSIONS so the message cannot drift from the\n // candidate list the lookup actually probes.\n const accepted = FLOW_FILE_EXTENSIONS.map((ext) => `${flowId}${ext}`).join(\" | \");\n throw new Error(\n `Flow not found: ${flowId}. Searched ${roots.length} root(s) (${shown || \"none\"}${more}) ` +\n `for ${accepted} — flat, or inside a ${flowId}/ directory. ` +\n `Only the flows of this project are found: run \\`skaile add flow:@<publisher>/<name>\\` first for a flow that lives in a library or source.` +\n describeMisses(misses, \"Near misses:\"),\n );\n}\n\n/** Walk up from projectDir to find ai-assets/ */\nfunction findAiResourcesDir(projectDir: string): string | null {\n let dir = projectDir;\n for (let i = 0; i < 6; i++) {\n const candidate = path.join(dir, \"ai-assets\");\n if (fs.existsSync(candidate)) return candidate;\n const parent = path.dirname(dir);\n if (parent === dir) break;\n dir = parent;\n }\n return null;\n}\n\n/** Find SKILL.md for a given skill ID in any `skills/` directory under ai-assets */\nfunction findSkillMd(aiResourcesDir: string, skillId: string): string | null {\n for (const skillsDir of findKindDirs(aiResourcesDir, \"skills\")) {\n const found = walkForSkill(skillsDir, skillId);\n if (found) return found;\n }\n return null;\n}\n\n// ---------------------------------------------------------------------------\n// Turn-wait helper\n// ---------------------------------------------------------------------------\n\n/**\n * Minimal harness surface needed by the bus's `driveTurn` callback. Mirrors\n * the slice the legacy `FlowOrchestrator` consumed (`prompt` + `on` +\n * `removeAllListeners`) so we can keep the wait helper private to this\n * module without pulling in a runtime dep on `@skaile/workspaces/bridge`.\n */\ninterface TurnHarnessSurface {\n prompt(message: string): Promise<void>;\n on(event: \"agent-event\", handler: (event: AgentEvent) => void): void;\n removeAllListeners(event: \"agent-event\"): void;\n}\n\n/**\n * Send a prompt to the harness and resolve when the agent emits\n * `agent_end` (or reject on an `error` that is not an in-place retry).\n * Identical contract to the legacy `awaitAgentEnd` helper from\n * `flow-orchestrator.ts`. Phase 4 lifts the helper into `run-flow.ts` because\n * the bus now owns turn driving. Exported for tests only.\n */\nexport function awaitAgentEnd(\n harness: TurnHarnessSurface,\n prompt: string,\n onEvent: ((event: AgentEvent) => void) | undefined,\n timeoutMs: number,\n): Promise<void> {\n return new Promise<void>((resolve, reject) => {\n let settled = false;\n\n const done = (err?: Error) => {\n if (settled) return;\n settled = true;\n clearTimeout(timer);\n harness.removeAllListeners(\"agent-event\");\n if (err) reject(err);\n else resolve();\n };\n\n const timer = setTimeout(\n () => done(new Error(`Flow turn timed out after ${timeoutMs / 1000}s`)),\n timeoutMs,\n );\n\n harness.on(\"agent-event\", (event: AgentEvent) => {\n onEvent?.(event);\n if (event.type === \"agent_end\") done();\n // An in-place retry replays this same turn; its own end settles it.\n else if (event.type === \"error\" && event.retrying !== true) {\n const msg =\n (event as { error?: string; message?: string }).error ??\n (event as { message?: string }).message ??\n \"Agent error\";\n done(new Error(msg));\n }\n });\n\n harness.prompt(prompt).catch(done);\n });\n}\n\nfunction walkForSkill(dir: string, skillId: string): string | null {\n for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {\n if (!entry.isDirectory()) continue;\n const full = path.join(dir, entry.name);\n const skillMd = path.join(full, \"SKILL.md\");\n if (fs.existsSync(skillMd)) {\n if (entry.name === skillId) return skillMd;\n } else {\n const found = walkForSkill(full, skillId);\n if (found) return found;\n }\n }\n return null;\n}\n"]}
@@ -1,7 +1,7 @@
1
1
  import { isAgentNode, isSubpromptNode, isSubFlowNode, nodeBindings, isRouterNode, nodeIsOptional, nodeSkillId, nodeLabel, isActiveRuntimeNode } from './chunk-7RGTAEG6.js';
2
2
  import { parseFlowDefinition } from './chunk-JRN5QF4C.js';
3
3
  import { resolveFlowBindings, stableFlowJson, evaluateFlowExpression, FlowExpressionError, getConsumedOutputSchema, compileOutputFieldsSchema } from './chunk-NUELZWCF.js';
4
- import { projectAssetRoots } from './chunk-ABVWUM2E.js';
4
+ import { projectAssetRoots } from './chunk-6ARPZHOV.js';
5
5
  import { findKindDirs } from './chunk-MWXYN6NY.js';
6
6
  import * as path2 from 'path';
7
7
  import path2__default from 'path';
@@ -979,5 +979,5 @@ function findFlowFileInRoots(flowId, roots, opts = {}) {
979
979
  }
980
980
 
981
981
  export { FLOW_FILE_EXTENSIONS, FlowManifestSchema, appendAttempt, availableRouterFrontier, buildFlowExpressionContext, computeFlowState, computeFlowStateFromSnapshots, computeSkippable, countFailedAttempts, deriveCheckEvidence, evaluateRouterSelection, findFlowFileInRoots, flowFileCandidates, flowKindProvider, flowLookupRoots, hasAutomaticRetryBudget, interpolateNodeInstruction, isActiveExecutionExpired, isBlocking, loadAllFlowEntries, loadAllFlows, loadFlow, loadFlowEntriesFromDir, loadFlowsFromDir, nextAttemptNumber, persistedRouterSelection, planRouterSkips, producerOutputObtainedBy, projectAiAssetsRoots, remainingActiveExecutionMs, resolveAvailableRouter, resolveFlowOutputFields, resolveNextNodes, resolveNodeBindings, resolveTerminalFailureStatus, routerSelectionOutput, unsettledRouterBranchIds, validateConsumedNodeOutput, validateFlow };
982
- //# sourceMappingURL=chunk-ZWCGJYR7.js.map
983
- //# sourceMappingURL=chunk-ZWCGJYR7.js.map
982
+ //# sourceMappingURL=chunk-5XHQBCB5.js.map
983
+ //# sourceMappingURL=chunk-5XHQBCB5.js.map