@skaile/workspaces 6.13.1 → 6.15.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 (193) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/dist/app-sdk/index.js +1 -1
  3. package/dist/{asset-feeds-HS4IUMUN.js → asset-feeds-PM7FKHJP.js} +6 -6
  4. package/dist/{asset-feeds-HS4IUMUN.js.map → asset-feeds-PM7FKHJP.js.map} +1 -1
  5. package/dist/asset-manager/index.js +1 -1
  6. package/dist/bridge/harnesses/claude-sdk.js +15 -17
  7. package/dist/bridge/harnesses/claude-sdk.js.map +1 -1
  8. package/dist/bridge/harnesses/codex.js +4 -4
  9. package/dist/bridge/harnesses/continue.js +5 -5
  10. package/dist/bridge/harnesses/echo.js +4 -4
  11. package/dist/bridge/harnesses/gemini.js +7 -7
  12. package/dist/bridge/harnesses/goose.js +5 -5
  13. package/dist/bridge/harnesses/omp.js +9 -8
  14. package/dist/bridge/harnesses/omp.js.map +1 -1
  15. package/dist/bridge/harnesses/opencode.js +7 -88
  16. package/dist/bridge/harnesses/opencode.js.map +1 -1
  17. package/dist/bridge/harnesses/qwen.js +7 -7
  18. package/dist/bridge/index.js +13 -11
  19. package/dist/bridge/src/harness-binaries.d.ts +52 -5
  20. package/dist/bridge/src/harness-binaries.d.ts.map +1 -1
  21. package/dist/bridge/src/harness-detect.d.ts +73 -0
  22. package/dist/bridge/src/harness-detect.d.ts.map +1 -0
  23. package/dist/bridge/src/harness-model-check.d.ts.map +1 -1
  24. package/dist/bridge/src/harness-model-discovery.d.ts +66 -0
  25. package/dist/bridge/src/harness-model-discovery.d.ts.map +1 -0
  26. package/dist/bridge/src/harnesses/_subprocess-cli.d.ts.map +1 -1
  27. package/dist/bridge/src/harnesses/claude-sdk.d.ts +4 -2
  28. package/dist/bridge/src/harnesses/claude-sdk.d.ts.map +1 -1
  29. package/dist/bridge/src/harnesses/omp.d.ts.map +1 -1
  30. package/dist/bridge/src/index.d.ts +3 -1
  31. package/dist/bridge/src/index.d.ts.map +1 -1
  32. package/dist/bridge/src/models.d.ts +9 -0
  33. package/dist/bridge/src/models.d.ts.map +1 -1
  34. package/dist/{chunk-GFBKUX3J.js → chunk-2RVEYDQK.js} +7 -21
  35. package/dist/chunk-2RVEYDQK.js.map +1 -0
  36. package/dist/{chunk-MVUXBWNW.js → chunk-6HTN2UIJ.js} +3 -3
  37. package/dist/{chunk-MVUXBWNW.js.map → chunk-6HTN2UIJ.js.map} +1 -1
  38. package/dist/{chunk-4KALKIWP.js → chunk-6VQW2X2F.js} +7 -7
  39. package/dist/{chunk-4KALKIWP.js.map → chunk-6VQW2X2F.js.map} +1 -1
  40. package/dist/{chunk-4OAUOH3A.js → chunk-6WIZC6GM.js} +5 -5
  41. package/dist/{chunk-4OAUOH3A.js.map → chunk-6WIZC6GM.js.map} +1 -1
  42. package/dist/{chunk-6EPNTAF3.js → chunk-72PPC4SC.js} +4 -4
  43. package/dist/{chunk-6EPNTAF3.js.map → chunk-72PPC4SC.js.map} +1 -1
  44. package/dist/{chunk-3NKXGAP4.js → chunk-A3G3FHGB.js} +2 -2
  45. package/dist/{chunk-3NKXGAP4.js.map → chunk-A3G3FHGB.js.map} +1 -1
  46. package/dist/{chunk-Z56QSYGJ.js → chunk-A4VKIVGB.js} +4 -4
  47. package/dist/{chunk-Z56QSYGJ.js.map → chunk-A4VKIVGB.js.map} +1 -1
  48. package/dist/chunk-AEFDFCS2.js +88 -0
  49. package/dist/chunk-AEFDFCS2.js.map +1 -0
  50. package/dist/{chunk-HTJPDSAC.js → chunk-C5ZCREBI.js} +3 -3
  51. package/dist/{chunk-HTJPDSAC.js.map → chunk-C5ZCREBI.js.map} +1 -1
  52. package/dist/{chunk-TBH6UXYN.js → chunk-CWUHUL6W.js} +3 -3
  53. package/dist/{chunk-TBH6UXYN.js.map → chunk-CWUHUL6W.js.map} +1 -1
  54. package/dist/{chunk-G2ZWIYZR.js → chunk-DFFJKGCW.js} +3 -3
  55. package/dist/{chunk-G2ZWIYZR.js.map → chunk-DFFJKGCW.js.map} +1 -1
  56. package/dist/{chunk-EISPUJ7D.js → chunk-EMIOFJQJ.js} +3 -3
  57. package/dist/{chunk-EISPUJ7D.js.map → chunk-EMIOFJQJ.js.map} +1 -1
  58. package/dist/{chunk-2O4QWC5S.js → chunk-FJJEC6O2.js} +4 -4
  59. package/dist/{chunk-2O4QWC5S.js.map → chunk-FJJEC6O2.js.map} +1 -1
  60. package/dist/{chunk-HP62IELJ.js → chunk-HCIXCCUH.js} +3 -3
  61. package/dist/{chunk-HP62IELJ.js.map → chunk-HCIXCCUH.js.map} +1 -1
  62. package/dist/{chunk-GJT2Q5XD.js → chunk-HXST2IYJ.js} +3 -3
  63. package/dist/{chunk-GJT2Q5XD.js.map → chunk-HXST2IYJ.js.map} +1 -1
  64. package/dist/{chunk-YYQDSC7I.js → chunk-IRIWNKQS.js} +3 -3
  65. package/dist/{chunk-YYQDSC7I.js.map → chunk-IRIWNKQS.js.map} +1 -1
  66. package/dist/{chunk-GIMFNRNR.js → chunk-IYXOSBQ4.js} +419 -15
  67. package/dist/chunk-IYXOSBQ4.js.map +1 -0
  68. package/dist/{chunk-MECT5Z5D.js → chunk-J7FEWDRQ.js} +5 -5
  69. package/dist/{chunk-MECT5Z5D.js.map → chunk-J7FEWDRQ.js.map} +1 -1
  70. package/dist/{chunk-E6BXLB5Z.js → chunk-JIZ35OOU.js} +3 -3
  71. package/dist/{chunk-E6BXLB5Z.js.map → chunk-JIZ35OOU.js.map} +1 -1
  72. package/dist/{chunk-DWPQBMCY.js → chunk-JPV4WE5L.js} +2 -2
  73. package/dist/{chunk-DWPQBMCY.js.map → chunk-JPV4WE5L.js.map} +1 -1
  74. package/dist/{chunk-AONNQPPS.js → chunk-KIFAU62K.js} +3 -3
  75. package/dist/{chunk-AONNQPPS.js.map → chunk-KIFAU62K.js.map} +1 -1
  76. package/dist/{chunk-JXKT2QGT.js → chunk-LBJCOEXH.js} +10 -4
  77. package/dist/chunk-LBJCOEXH.js.map +1 -0
  78. package/dist/{chunk-HG2PDB3T.js → chunk-MUQBP2BK.js} +2 -2
  79. package/dist/{chunk-HG2PDB3T.js.map → chunk-MUQBP2BK.js.map} +1 -1
  80. package/dist/{chunk-DUIZB6JM.js → chunk-O74SRQ3W.js} +3 -3
  81. package/dist/{chunk-DUIZB6JM.js.map → chunk-O74SRQ3W.js.map} +1 -1
  82. package/dist/{chunk-7YGOEJRD.js → chunk-OIWFXUZB.js} +4 -4
  83. package/dist/{chunk-7YGOEJRD.js.map → chunk-OIWFXUZB.js.map} +1 -1
  84. package/dist/{chunk-P6VNPRLD.js → chunk-PFBPESW7.js} +8 -8
  85. package/dist/{chunk-P6VNPRLD.js.map → chunk-PFBPESW7.js.map} +1 -1
  86. package/dist/{chunk-ZJMSX2T6.js → chunk-R7422XD4.js} +7 -7
  87. package/dist/{chunk-ZJMSX2T6.js.map → chunk-R7422XD4.js.map} +1 -1
  88. package/dist/{chunk-R2P77YRM.js → chunk-RKTEHX2S.js} +3 -3
  89. package/dist/{chunk-R2P77YRM.js.map → chunk-RKTEHX2S.js.map} +1 -1
  90. package/dist/{chunk-7MO23JPX.js → chunk-SXRN27TU.js} +5 -5
  91. package/dist/{chunk-7MO23JPX.js.map → chunk-SXRN27TU.js.map} +1 -1
  92. package/dist/{chunk-BALPY67W.js → chunk-TYRAEMWE.js} +3 -3
  93. package/dist/{chunk-BALPY67W.js.map → chunk-TYRAEMWE.js.map} +1 -1
  94. package/dist/{chunk-MNED5ZCW.js → chunk-U7EJB6LY.js} +2 -2
  95. package/dist/{chunk-MNED5ZCW.js.map → chunk-U7EJB6LY.js.map} +1 -1
  96. package/dist/{chunk-ESUF2ZYT.js → chunk-U7EZ2WSC.js} +2 -2
  97. package/dist/{chunk-ESUF2ZYT.js.map → chunk-U7EZ2WSC.js.map} +1 -1
  98. package/dist/{chunk-UZCAULGU.js → chunk-XPSZIBPU.js} +8 -8
  99. package/dist/{chunk-UZCAULGU.js.map → chunk-XPSZIBPU.js.map} +1 -1
  100. package/dist/{chunk-UBN7HI4S.js → chunk-YDMZWVZN.js} +3 -3
  101. package/dist/{chunk-UBN7HI4S.js.map → chunk-YDMZWVZN.js.map} +1 -1
  102. package/dist/chunk-YKD2MYLU.js +210 -0
  103. package/dist/chunk-YKD2MYLU.js.map +1 -0
  104. package/dist/{chunk-F6IEGYOI.js → chunk-YLKOCMU7.js} +101 -55
  105. package/dist/chunk-YLKOCMU7.js.map +1 -0
  106. package/dist/{claude-code-G52B7TRB.js → claude-code-5QYXWC5H.js} +4 -4
  107. package/dist/{claude-code-G52B7TRB.js.map → claude-code-5QYXWC5H.js.map} +1 -1
  108. package/dist/cli/index.js +95 -57
  109. package/dist/cli/index.js.map +1 -1
  110. package/dist/cli/src/commands/harness-preflight.d.ts.map +1 -1
  111. package/dist/cli/src/commands/harness.d.ts +14 -0
  112. package/dist/cli/src/commands/harness.d.ts.map +1 -1
  113. package/dist/cli/src/commands/serve-preflight.d.ts +1 -6
  114. package/dist/cli/src/commands/serve-preflight.d.ts.map +1 -1
  115. package/dist/connectors/index.js +15 -13
  116. package/dist/{connectors-TT6HTFH6.js → connectors-DLXW27NQ.js} +18 -16
  117. package/dist/{connectors-TT6HTFH6.js.map → connectors-DLXW27NQ.js.map} +1 -1
  118. package/dist/connectors-shared/index.js +2 -2
  119. package/dist/{ensure-sources-XZ3MUJOM.js → ensure-sources-I7GCXPXK.js} +17 -15
  120. package/dist/ensure-sources-I7GCXPXK.js.map +1 -0
  121. package/dist/factory-assets/connectors/box.js +15 -13
  122. package/dist/factory-assets/connectors/deploy.js +15 -13
  123. package/dist/factory-assets/connectors/devserver.js +15 -13
  124. package/dist/factory-assets/connectors/flow/adapter.js +15 -13
  125. package/dist/factory-assets/connectors/flow/run-flow.js +16 -14
  126. package/dist/factory-assets/connectors/flow.js +15 -13
  127. package/dist/factory-assets/connectors/git.js +15 -13
  128. package/dist/factory-assets/connectors/gmail.js +15 -13
  129. package/dist/factory-assets/connectors/googledrive.js +15 -13
  130. package/dist/factory-assets/connectors/local.js +15 -13
  131. package/dist/factory-assets/connectors/mattermost.js +15 -13
  132. package/dist/factory-assets/connectors/memory.js +15 -13
  133. package/dist/factory-assets/connectors/minio.js +15 -13
  134. package/dist/factory-assets/connectors/postgres.js +15 -13
  135. package/dist/factory-assets/connectors/s3.js +15 -13
  136. package/dist/factory-assets/connectors/sharepoint.js +15 -13
  137. package/dist/factory-assets/connectors/sqlite.js +15 -13
  138. package/dist/factory-assets/connectors/static-server.js +15 -13
  139. package/dist/factory-assets/connectors/tunnel.js +15 -13
  140. package/dist/factory-assets/connectors/webdav.js +15 -13
  141. package/dist/factory-assets/connectors/xstate-store.js +15 -13
  142. package/dist/factory-assets/connectors/xstate.js +15 -13
  143. package/dist/{helpers-Q6LFWGYT.js → helpers-U75UGGH5.js} +17 -15
  144. package/dist/{helpers-Q6LFWGYT.js.map → helpers-U75UGGH5.js.map} +1 -1
  145. package/dist/{library-publish-OADODIMW.js → library-publish-57422ULT.js} +30 -28
  146. package/dist/library-publish-57422ULT.js.map +1 -0
  147. package/dist/model-endpoint/index.js +3 -3
  148. package/dist/{open-library-MNCHOTAF.js → open-library-EVUKLOV7.js} +18 -16
  149. package/dist/{open-library-MNCHOTAF.js.map → open-library-EVUKLOV7.js.map} +1 -1
  150. package/dist/{project-PHO6JOVL.js → project-HB7OYPEF.js} +26 -24
  151. package/dist/{project-PHO6JOVL.js.map → project-HB7OYPEF.js.map} +1 -1
  152. package/dist/runner/index.js +21 -19
  153. package/dist/runner/src/compaction/prompt.d.ts.map +1 -1
  154. package/dist/runner/src/context-usage/compose.d.ts.map +1 -1
  155. package/dist/runner/src/session-builder.d.ts.map +1 -1
  156. package/dist/runner/src/work-practices.d.ts +9 -0
  157. package/dist/runner/src/work-practices.d.ts.map +1 -0
  158. package/dist/sdk/asset-manager.js +1 -1
  159. package/dist/sdk/bridge.js +13 -11
  160. package/dist/sdk/index.js +21 -19
  161. package/dist/sdk/index.js.map +1 -1
  162. package/dist/sdk/runner.js +21 -19
  163. package/dist/sdk/session.js +2 -2
  164. package/dist/sdk/types.js +1 -1
  165. package/dist/{serve-preflight-GLE2LPGT.js → serve-preflight-YY3YC6GH.js} +19 -17
  166. package/dist/{serve-preflight-GLE2LPGT.js.map → serve-preflight-YY3YC6GH.js.map} +1 -1
  167. package/dist/session/index.js +2 -2
  168. package/dist/{setup-EPNOIKDM.js → setup-2XV6T53V.js} +18 -16
  169. package/dist/setup-2XV6T53V.js.map +1 -0
  170. package/dist/{source-CUSCY3KR.js → source-VXE3RSSA.js} +28 -26
  171. package/dist/{source-CUSCY3KR.js.map → source-VXE3RSSA.js.map} +1 -1
  172. package/dist/{source-manifest-publish-AHLDG4XS.js → source-manifest-publish-IIVQLM67.js} +30 -28
  173. package/dist/source-manifest-publish-IIVQLM67.js.map +1 -0
  174. package/dist/tui/index.js +21 -19
  175. package/dist/tui/index.js.map +1 -1
  176. package/dist/types/index.js +1 -1
  177. package/dist/types/src/context-usage.d.ts +1 -1
  178. package/dist/types/src/events.d.ts +3 -2
  179. package/dist/types/src/events.d.ts.map +1 -1
  180. package/dist/workspace-plugin/adapters/mcp.js +17 -15
  181. package/dist/workspace-plugin/adapters/omp.js +7 -7
  182. package/dist/workspace-plugin/index.js +1 -1
  183. package/package.json +1 -1
  184. package/dist/chunk-F6IEGYOI.js.map +0 -1
  185. package/dist/chunk-GFBKUX3J.js.map +0 -1
  186. package/dist/chunk-GIMFNRNR.js.map +0 -1
  187. package/dist/chunk-JXKT2QGT.js.map +0 -1
  188. package/dist/chunk-WWSRIT3J.js +0 -59
  189. package/dist/chunk-WWSRIT3J.js.map +0 -1
  190. package/dist/ensure-sources-XZ3MUJOM.js.map +0 -1
  191. package/dist/library-publish-OADODIMW.js.map +0 -1
  192. package/dist/setup-EPNOIKDM.js.map +0 -1
  193. package/dist/source-manifest-publish-AHLDG4XS.js.map +0 -1
@@ -1,6 +1,6 @@
1
1
  import { initTelemetry } from './chunk-4R6DROGN.js';
2
2
  import { parseSkillFrontmatter, validateFlowVersions } from './chunk-KOI7QFDH.js';
3
- import { FlowAdapter, SessionNodeExecutor, SessionSubpromptRunner, SessionInlineSubFlowRunner, driveOrchestratorTurn } from './chunk-4KALKIWP.js';
3
+ import { FlowAdapter, SessionNodeExecutor, SessionSubpromptRunner, SessionInlineSubFlowRunner, driveOrchestratorTurn } from './chunk-6VQW2X2F.js';
4
4
  import { loadFlow, flowLookupRoots, findFlowFileInRoots, FLOW_FILE_EXTENSIONS } from './chunk-WDG5IVEA.js';
5
5
  import { renderStimulusPrompt } from './chunk-WD3L5QSU.js';
6
6
  import { flowSkillVersionPins } from './chunk-7RGTAEG6.js';
@@ -537,5 +537,5 @@ function walkForSkill(dir, skillId) {
537
537
  }
538
538
 
539
539
  export { awaitAgentEnd, resolveFlowPath, resumeFlow, runFlow };
540
- //# sourceMappingURL=chunk-UBN7HI4S.js.map
541
- //# sourceMappingURL=chunk-UBN7HI4S.js.map
540
+ //# sourceMappingURL=chunk-YDMZWVZN.js.map
541
+ //# sourceMappingURL=chunk-YDMZWVZN.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,EAC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EAAG;AAChE,IAAA,IAAI,CAAC,KAAA,CAAM,WAAA,EAAY,EAAG;AAC1B,IAAA,MAAM,IAAA,GAAO,IAAA,CAAK,IAAA,CAAK,GAAA,EAAK,MAAM,IAAI,CAAA;AACtC,IAAA,MAAM,OAAA,GAAU,IAAA,CAAK,IAAA,CAAK,IAAA,EAAM,UAAU,CAAA;AAC1C,IAAA,IAAI,EAAA,CAAG,UAAA,CAAW,OAAO,CAAA,EAAG;AAC1B,MAAA,IAAI,KAAA,CAAM,IAAA,KAAS,OAAA,EAAS,OAAO,OAAA;AAAA,IACrC,CAAA,MAAO;AACL,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-UBN7HI4S.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,eA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,EAAA,KAAA,MAAW,KAAA,IAAS,GAAG,WAAA,CAAY,GAAA,EAAK,EAAE,aAAA,EAAe,IAAA,EAAM,CAAA,EAAG;AAChE,IAAA,IAAI,CAAC,KAAA,CAAM,WAAA,EAAY,EAAG;AAC1B,IAAA,MAAM,IAAA,GAAO,IAAA,CAAK,IAAA,CAAK,GAAA,EAAK,MAAM,IAAI,CAAA;AACtC,IAAA,MAAM,OAAA,GAAU,IAAA,CAAK,IAAA,CAAK,IAAA,EAAM,UAAU,CAAA;AAC1C,IAAA,IAAI,EAAA,CAAG,UAAA,CAAW,OAAO,CAAA,EAAG;AAC1B,MAAA,IAAI,KAAA,CAAM,IAAA,KAAS,OAAA,EAAS,OAAO,OAAA;AAAA,IACrC,CAAA,MAAO;AACL,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-YDMZWVZN.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"]}
@@ -0,0 +1,210 @@
1
+ import { statSync, accessSync, constants, readdirSync } from 'fs';
2
+ import os from 'os';
3
+ import path from 'path';
4
+ import semver from 'semver';
5
+
6
+ // bridge/src/harness-binaries.ts
7
+ var HARNESS_BINARIES = {
8
+ omp: {
9
+ bin: "omp",
10
+ envPrefix: "OMP",
11
+ hint: "The omp agent is not installed or not on your PATH. Install it and try again."
12
+ },
13
+ gemini: {
14
+ bin: "gemini",
15
+ envPrefix: "GEMINI",
16
+ hint: "Gemini CLI is not installed or not on your PATH. Install it with `npm i -g @google/gemini-cli` (\u2265 v0.6.1).",
17
+ minVersion: "0.6.1"
18
+ },
19
+ qwen: {
20
+ bin: "qwen",
21
+ envPrefix: "QWEN",
22
+ hint: "Qwen Code is not installed or not on your PATH. Install it with `npm i -g @qwen-code/qwen-code`."
23
+ },
24
+ opencode: {
25
+ bin: "opencode",
26
+ envPrefix: "OPENCODE",
27
+ hint: "OpenCode is not installed or not on your PATH. Install it with `npm i -g opencode-ai`."
28
+ },
29
+ goose: {
30
+ bin: "goose",
31
+ envPrefix: "GOOSE",
32
+ hint: "Goose is not installed or not on your PATH. Install it from https://block.github.io/goose (download script or Homebrew)."
33
+ },
34
+ continue: {
35
+ bin: "cn",
36
+ envPrefix: "CONTINUE",
37
+ hint: "Continue CLI is not installed or not on your PATH. Install it with `npm i -g @continuedev/cli`."
38
+ }
39
+ };
40
+ var SDK_CLI_BINARIES = {
41
+ "claude-sdk": {
42
+ bin: "claude",
43
+ envPrefix: "CLAUDE",
44
+ overrideEnv: "CLAUDE_CODE_PATH",
45
+ // Container images point `CLAUDE_CODE_PATH` at a `cli.js` extracted from the SDK (mode 0644).
46
+ overrideMayBeScript: true,
47
+ hint: "Claude Code CLI not found; the Claude Agent SDK falls back to its bundled CLI. Install it with `npm i -g @anthropic-ai/claude-code` to see its login state."
48
+ },
49
+ codex: {
50
+ bin: "codex",
51
+ envPrefix: "CODEX",
52
+ hint: "Codex CLI not found on PATH; the Codex SDK runs its bundled binary. Install `npm i -g @openai/codex` to see its login state."
53
+ }
54
+ };
55
+ function isExecutableFile(file) {
56
+ try {
57
+ if (!statSync(file).isFile()) return false;
58
+ accessSync(file, process.platform === "win32" ? constants.F_OK : constants.X_OK);
59
+ return true;
60
+ } catch {
61
+ return false;
62
+ }
63
+ }
64
+ function isRegularFile(file) {
65
+ try {
66
+ return statSync(file).isFile();
67
+ } catch {
68
+ return false;
69
+ }
70
+ }
71
+ var TOOLCHAIN_DIR_CACHE_TTL_MS = 5e3;
72
+ var toolchainCache;
73
+ function versionedDirs(parent, ...suffix) {
74
+ let names;
75
+ try {
76
+ names = readdirSync(parent, { withFileTypes: true }).filter((d) => d.isDirectory()).map((d) => d.name);
77
+ } catch {
78
+ return [];
79
+ }
80
+ const parsed = names.map((name) => ({ name, version: semver.coerce(name) }));
81
+ parsed.sort((a, b) => {
82
+ if (a.version && b.version) return semver.rcompare(a.version, b.version);
83
+ if (a.version) return -1;
84
+ if (b.version) return 1;
85
+ return a.name.localeCompare(b.name);
86
+ });
87
+ return parsed.map((p) => path.join(parent, p.name, ...suffix));
88
+ }
89
+ function computeToolchainBinDirs(env, home) {
90
+ const win = process.platform === "win32";
91
+ const dirs = [];
92
+ const npmPrefix = (env.NPM_CONFIG_PREFIX ?? env.npm_config_prefix)?.trim();
93
+ if (npmPrefix) {
94
+ dirs.push(path.join(npmPrefix, "bin"));
95
+ if (win) dirs.push(npmPrefix);
96
+ }
97
+ if (win && env.APPDATA) dirs.push(path.join(env.APPDATA, "npm"));
98
+ dirs.push(
99
+ path.join(home, ".local", "bin"),
100
+ path.join(home, ".bun", "bin"),
101
+ path.join(home, ".volta", "bin"),
102
+ path.join(home, ".asdf", "shims"),
103
+ path.join(home, "Library", "pnpm"),
104
+ path.join(home, ".cargo", "bin"),
105
+ path.join(home, ".npm-global", "bin"),
106
+ path.join(home, ".npm-packages", "bin"),
107
+ path.join(home, ".deno", "bin"),
108
+ path.join(home, "go", "bin"),
109
+ path.join(home, ".pyenv", "shims")
110
+ );
111
+ if (win) dirs.push(path.join(home, "scoop", "shims"));
112
+ const miseData = env.MISE_DATA_DIR?.trim();
113
+ const miseRoot = miseData || path.join(home, ".local", "share", "mise");
114
+ dirs.push(path.join(miseRoot, "shims"));
115
+ if (!miseData) dirs.push(path.join(home, ".mise", "shims"));
116
+ dirs.push(path.join(home, ".nix-profile", "bin"));
117
+ if (!win) {
118
+ dirs.push(
119
+ "/opt/homebrew/bin",
120
+ "/usr/local/bin",
121
+ "/run/current-system/sw/bin",
122
+ "/nix/var/nix/profiles/default/bin"
123
+ );
124
+ }
125
+ dirs.push(...versionedDirs(path.join(miseRoot, "installs", "node"), "bin"));
126
+ dirs.push(
127
+ ...versionedDirs(
128
+ path.join(env.NVM_DIR?.trim() || path.join(home, ".nvm"), "versions", "node"),
129
+ "bin"
130
+ )
131
+ );
132
+ dirs.push(
133
+ ...versionedDirs(
134
+ path.join(home, ".local", "share", "fnm", "node-versions"),
135
+ "installation",
136
+ "bin"
137
+ )
138
+ );
139
+ dirs.push(...versionedDirs(path.join(home, ".fnm", "node-versions"), "installation", "bin"));
140
+ if (win) {
141
+ const fnmDir = env.FNM_DIR?.trim() || env.LOCALAPPDATA || env.APPDATA;
142
+ if (fnmDir) {
143
+ const root = env.FNM_DIR?.trim() ? fnmDir : path.join(fnmDir, "fnm");
144
+ dirs.push(...versionedDirs(path.join(root, "node-versions"), "installation"));
145
+ }
146
+ }
147
+ return dirs;
148
+ }
149
+ function toolchainBinDirs(env = process.env, home = os.homedir()) {
150
+ const key = JSON.stringify([
151
+ home,
152
+ env.NPM_CONFIG_PREFIX,
153
+ env.npm_config_prefix,
154
+ env.MISE_DATA_DIR,
155
+ env.NVM_DIR,
156
+ env.FNM_DIR,
157
+ env.APPDATA,
158
+ env.LOCALAPPDATA
159
+ ]);
160
+ const now = Date.now();
161
+ if (toolchainCache && toolchainCache.key === key && now - toolchainCache.at < TOOLCHAIN_DIR_CACHE_TTL_MS) {
162
+ return [...toolchainCache.dirs];
163
+ }
164
+ const dirs = computeToolchainBinDirs(env, home);
165
+ toolchainCache = { key, at: now, dirs };
166
+ return [...dirs];
167
+ }
168
+ function harnessSearchDirs(env = process.env) {
169
+ const seen = /* @__PURE__ */ new Set();
170
+ const out = [];
171
+ const home = env.HOME || os.homedir();
172
+ for (const dir of [...(env.PATH ?? "").split(path.delimiter), ...toolchainBinDirs(env, home)]) {
173
+ if (!dir || seen.has(dir)) continue;
174
+ seen.add(dir);
175
+ out.push(dir);
176
+ }
177
+ return out;
178
+ }
179
+ function harnessSpawnPath(env = process.env) {
180
+ return harnessSearchDirs(env).join(path.delimiter);
181
+ }
182
+ function resolveHarnessBinary(harness, env = process.env) {
183
+ const override = env[overrideVar(harness)];
184
+ if (override && harness.overrideMayBeScript && /[\\/]/.test(override)) {
185
+ if (isRegularFile(override)) return path.resolve(override);
186
+ return resolveHarnessBinary(harness, { ...env, [overrideVar(harness)]: "" });
187
+ }
188
+ const name = override || harness.bin;
189
+ if (name.includes("/") || name.includes(path.sep)) {
190
+ return isExecutableFile(name) ? path.resolve(name) : void 0;
191
+ }
192
+ const exts = process.platform === "win32" ? ["", ...(env.PATHEXT ?? ".EXE;.CMD;.BAT").split(";").filter(Boolean)] : [""];
193
+ for (const dir of harnessSearchDirs(env)) {
194
+ for (const ext of exts) {
195
+ const candidate = path.join(dir, name + ext);
196
+ if (isExecutableFile(candidate)) return path.resolve(candidate);
197
+ }
198
+ }
199
+ return void 0;
200
+ }
201
+ function overrideVar(harness) {
202
+ return harness.overrideEnv ?? `${harness.envPrefix}_BRIDGE_BIN`;
203
+ }
204
+ function findHarnessBinary(harness, env = process.env) {
205
+ return resolveHarnessBinary(harness, env) !== void 0;
206
+ }
207
+
208
+ export { HARNESS_BINARIES, SDK_CLI_BINARIES, findHarnessBinary, harnessSearchDirs, harnessSpawnPath, isExecutableFile, overrideVar, resolveHarnessBinary, toolchainBinDirs };
209
+ //# sourceMappingURL=chunk-YKD2MYLU.js.map
210
+ //# sourceMappingURL=chunk-YKD2MYLU.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../bridge/src/harness-binaries.ts"],"names":[],"mappings":";;;;;;AAqCO,IAAM,gBAAA,GAA4D;AAAA,EACvE,GAAA,EAAK;AAAA,IACH,GAAA,EAAK,KAAA;AAAA,IACL,SAAA,EAAW,KAAA;AAAA,IACX,IAAA,EAAM;AAAA,GACR;AAAA,EACA,MAAA,EAAQ;AAAA,IACN,GAAA,EAAK,QAAA;AAAA,IACL,SAAA,EAAW,QAAA;AAAA,IACX,IAAA,EA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;AAOO,SAAS,iBAAA,CAAkB,OAAA,EAAwB,GAAA,GAAW,OAAA,CAAQ,GAAA,EAAc;AACzF,EAAA,OAAO,oBAAA,CAAqB,OAAA,EAAS,GAAG,CAAA,KAAM,MAAA;AAChD","file":"chunk-YKD2MYLU.js","sourcesContent":["/**\n * The external program each CLI harness spawns, and the one line the user gets when it is\n * missing. The harnesses print `hint` when the spawn fails; `skaile run` and `--dry-run` print\n * it before a turn starts ({@link resolveHarnessBinary}).\n *\n * One resolver serves detection and every spawn: it searches `PATH` and then the well-known\n * install dirs of the user's toolchains (nvm, volta, bun, mise, fnm, pnpm, Homebrew, cargo,\n * nix, a custom npm prefix), so a harness installed there is found even when the parent\n * process runs with a minimal `PATH`. Spawns pass {@link harnessSpawnPath} as the child's\n * `PATH` so the program and the helpers it launches (`node`, shims) resolve the same way.\n */\nimport { accessSync, constants, readdirSync, statSync } from \"node:fs\";\nimport os from \"node:os\";\nimport path from \"node:path\";\nimport semver from \"semver\";\n\n/** One CLI harness's program. */\nexport interface HarnessBinary {\n /** Program name looked up on `PATH`. */\n bin: string;\n /** Test-seam prefix: `<PREFIX>_BRIDGE_BIN` replaces the program (the harness reads the same). */\n envPrefix: string;\n /** The install line. */\n hint: string;\n /** Env var naming the program instead of `<envPrefix>_BRIDGE_BIN` (e.g. `CLAUDE_CODE_PATH`). */\n overrideEnv?: string;\n /** Lowest supported version (semver). Detection reports an older program as outdated. */\n minVersion?: string;\n /**\n * The override path may be a script without the exec bit (the SDK runs it through `node`); a\n * missing override path then falls back to looking up `bin`. Only for programs that are not\n * spawned directly.\n */\n overrideMayBeScript?: boolean;\n}\n\n/** The CLI harnesses that spawn a program, by harness id. */\nexport const HARNESS_BINARIES: Readonly<Record<string, HarnessBinary>> = {\n omp: {\n bin: \"omp\",\n envPrefix: \"OMP\",\n hint: \"The omp agent is not installed or not on your PATH. Install it and try again.\",\n },\n gemini: {\n bin: \"gemini\",\n envPrefix: \"GEMINI\",\n hint: \"Gemini CLI is not installed or not on your PATH. Install it with `npm i -g @google/gemini-cli` (≥ v0.6.1).\",\n minVersion: \"0.6.1\",\n },\n qwen: {\n bin: \"qwen\",\n envPrefix: \"QWEN\",\n hint: \"Qwen Code is not installed or not on your PATH. Install it with `npm i -g @qwen-code/qwen-code`.\",\n },\n opencode: {\n bin: \"opencode\",\n envPrefix: \"OPENCODE\",\n hint: \"OpenCode is not installed or not on your PATH. Install it with `npm i -g opencode-ai`.\",\n },\n goose: {\n bin: \"goose\",\n envPrefix: \"GOOSE\",\n hint: \"Goose is not installed or not on your PATH. Install it from https://block.github.io/goose (download script or Homebrew).\",\n },\n continue: {\n bin: \"cn\",\n envPrefix: \"CONTINUE\",\n hint: \"Continue CLI is not installed or not on your PATH. Install it with `npm i -g @continuedev/cli`.\",\n },\n};\n\n/**\n * The CLIs next to the SDK harnesses. The SDKs run without them (they bundle a binary); the\n * CLI is only looked up to report its version and the account login.\n */\nexport const SDK_CLI_BINARIES: Readonly<Record<\"claude-sdk\" | \"codex\", HarnessBinary>> = {\n \"claude-sdk\": {\n bin: \"claude\",\n envPrefix: \"CLAUDE\",\n overrideEnv: \"CLAUDE_CODE_PATH\",\n // Container images point `CLAUDE_CODE_PATH` at a `cli.js` extracted from the SDK (mode 0644).\n overrideMayBeScript: true,\n hint: \"Claude Code CLI not found; the Claude Agent SDK falls back to its bundled CLI. Install it with `npm i -g @anthropic-ai/claude-code` to see its login state.\",\n },\n codex: {\n bin: \"codex\",\n envPrefix: \"CODEX\",\n hint: \"Codex CLI not found on PATH; the Codex SDK runs its bundled binary. Install `npm i -g @openai/codex` to see its login state.\",\n },\n};\n\n/** Whether `file` is a regular file the process may execute (existence only on Windows). */\nexport function isExecutableFile(file: string): boolean {\n try {\n if (!statSync(file).isFile()) return false;\n accessSync(file, process.platform === \"win32\" ? constants.F_OK : constants.X_OK);\n return true;\n } catch {\n return false;\n }\n}\n\nfunction isRegularFile(file: string): boolean {\n try {\n return statSync(file).isFile();\n } catch {\n return false;\n }\n}\n\ntype Env = Record<string, string | undefined>;\n\n/** How long a computed toolchain dir list is reused (the dirs are read from disk). */\nconst TOOLCHAIN_DIR_CACHE_TTL_MS = 5000;\nlet toolchainCache: { key: string; at: number; dirs: string[] } | undefined;\n\n/** Subdirectories of `parent`, newest semver first (unparsable names last), joined with `suffix`. */\nfunction versionedDirs(parent: string, ...suffix: string[]): string[] {\n let names: string[];\n try {\n names = readdirSync(parent, { withFileTypes: true })\n .filter((d) => d.isDirectory())\n .map((d) => d.name);\n } catch {\n return [];\n }\n const parsed = names.map((name) => ({ name, version: semver.coerce(name) }));\n parsed.sort((a, b) => {\n if (a.version && b.version) return semver.rcompare(a.version, b.version);\n if (a.version) return -1;\n if (b.version) return 1;\n return a.name.localeCompare(b.name);\n });\n return parsed.map((p) => path.join(parent, p.name, ...suffix));\n}\n\nfunction computeToolchainBinDirs(env: Env, home: string): string[] {\n const win = process.platform === \"win32\";\n const dirs: string[] = [];\n\n const npmPrefix = (env.NPM_CONFIG_PREFIX ?? env.npm_config_prefix)?.trim();\n if (npmPrefix) {\n dirs.push(path.join(npmPrefix, \"bin\"));\n if (win) dirs.push(npmPrefix);\n }\n if (win && env.APPDATA) dirs.push(path.join(env.APPDATA, \"npm\"));\n\n dirs.push(\n path.join(home, \".local\", \"bin\"),\n path.join(home, \".bun\", \"bin\"),\n path.join(home, \".volta\", \"bin\"),\n path.join(home, \".asdf\", \"shims\"),\n path.join(home, \"Library\", \"pnpm\"),\n path.join(home, \".cargo\", \"bin\"),\n path.join(home, \".npm-global\", \"bin\"),\n path.join(home, \".npm-packages\", \"bin\"),\n path.join(home, \".deno\", \"bin\"),\n path.join(home, \"go\", \"bin\"),\n path.join(home, \".pyenv\", \"shims\"),\n );\n if (win) dirs.push(path.join(home, \"scoop\", \"shims\"));\n\n const miseData = env.MISE_DATA_DIR?.trim();\n const miseRoot = miseData || path.join(home, \".local\", \"share\", \"mise\");\n dirs.push(path.join(miseRoot, \"shims\"));\n if (!miseData) dirs.push(path.join(home, \".mise\", \"shims\"));\n\n dirs.push(path.join(home, \".nix-profile\", \"bin\"));\n if (!win) {\n dirs.push(\n \"/opt/homebrew/bin\",\n \"/usr/local/bin\",\n \"/run/current-system/sw/bin\",\n \"/nix/var/nix/profiles/default/bin\",\n );\n }\n\n // Per-version node roots: the version in use is whichever the user's shell would pick, which\n // we cannot know here, so the newest installed version of each manager comes first.\n dirs.push(...versionedDirs(path.join(miseRoot, \"installs\", \"node\"), \"bin\"));\n dirs.push(\n ...versionedDirs(\n path.join(env.NVM_DIR?.trim() || path.join(home, \".nvm\"), \"versions\", \"node\"),\n \"bin\",\n ),\n );\n dirs.push(\n ...versionedDirs(\n path.join(home, \".local\", \"share\", \"fnm\", \"node-versions\"),\n \"installation\",\n \"bin\",\n ),\n );\n dirs.push(...versionedDirs(path.join(home, \".fnm\", \"node-versions\"), \"installation\", \"bin\"));\n if (win) {\n const fnmDir = env.FNM_DIR?.trim() || env.LOCALAPPDATA || env.APPDATA;\n if (fnmDir) {\n const root = env.FNM_DIR?.trim() ? fnmDir : path.join(fnmDir, \"fnm\");\n dirs.push(...versionedDirs(path.join(root, \"node-versions\"), \"installation\"));\n }\n }\n return dirs;\n}\n\n/**\n * Well-known install dirs of the user's toolchains, in lookup order. Dirs need not exist except\n * the per-version node roots, which are listed from disk (newest version first). The result is\n * cached for 5 s per `home` (and per the env values it reads).\n *\n * @param env - Environment read for `NPM_CONFIG_PREFIX`, `MISE_DATA_DIR`, `NVM_DIR`, `FNM_DIR`, `APPDATA`, `LOCALAPPDATA` (default `process.env`).\n * @param home - The home dir the per-user dirs hang off (default `os.homedir()`).\n */\nexport function toolchainBinDirs(env: Env = process.env, home: string = os.homedir()): string[] {\n const key = JSON.stringify([\n home,\n env.NPM_CONFIG_PREFIX,\n env.npm_config_prefix,\n env.MISE_DATA_DIR,\n env.NVM_DIR,\n env.FNM_DIR,\n env.APPDATA,\n env.LOCALAPPDATA,\n ]);\n const now = Date.now();\n if (\n toolchainCache &&\n toolchainCache.key === key &&\n now - toolchainCache.at < TOOLCHAIN_DIR_CACHE_TTL_MS\n ) {\n return [...toolchainCache.dirs];\n }\n const dirs = computeToolchainBinDirs(env, home);\n toolchainCache = { key, at: now, dirs };\n return [...dirs];\n}\n\n/**\n * `PATH` entries, then {@link toolchainBinDirs} (rooted at `env.HOME`, else `os.homedir()`);\n * empty entries dropped, duplicates removed in order.\n */\nexport function harnessSearchDirs(env: Env = process.env): string[] {\n const seen = new Set<string>();\n const out: string[] = [];\n const home = env.HOME || os.homedir();\n for (const dir of [...(env.PATH ?? \"\").split(path.delimiter), ...toolchainBinDirs(env, home)]) {\n if (!dir || seen.has(dir)) continue;\n seen.add(dir);\n out.push(dir);\n }\n return out;\n}\n\n/** The `PATH` a harness child runs with: {@link harnessSearchDirs} joined. */\nexport function harnessSpawnPath(env: Env = process.env): string {\n return harnessSearchDirs(env).join(path.delimiter);\n}\n\n/**\n * The absolute path of the program a harness spawns, or `undefined` when it cannot be found.\n * The override env var (`<PREFIX>_BRIDGE_BIN`, or the row's `overrideEnv`) replaces `bin`. A name\n * with a path separator is checked as a path; any other name is searched in `PATH`, then the\n * toolchain dirs. The project's `node_modules/.bin` is never searched: it is repo-controlled.\n *\n * A row with `overrideMayBeScript` accepts an override path that is a regular file without the\n * exec bit (a `cli.js`), and falls back to the normal lookup of `bin` when that path is missing.\n *\n * @param harness - The harness's {@link HARNESS_BINARIES} (or {@link SDK_CLI_BINARIES}) row.\n * @param env - Environment to read `PATH` and the override from (default `process.env`).\n */\nexport function resolveHarnessBinary(\n harness: HarnessBinary,\n env: Env = process.env,\n): string | undefined {\n const override = env[overrideVar(harness)];\n if (override && harness.overrideMayBeScript && /[\\\\/]/.test(override)) {\n if (isRegularFile(override)) return path.resolve(override);\n return resolveHarnessBinary(harness, { ...env, [overrideVar(harness)]: \"\" });\n }\n const name = override || harness.bin;\n if (name.includes(\"/\") || name.includes(path.sep)) {\n return isExecutableFile(name) ? path.resolve(name) : undefined;\n }\n const exts =\n process.platform === \"win32\"\n ? [\"\", ...(env.PATHEXT ?? \".EXE;.CMD;.BAT\").split(\";\").filter(Boolean)]\n : [\"\"];\n for (const dir of harnessSearchDirs(env)) {\n for (const ext of exts) {\n const candidate = path.join(dir, name + ext);\n if (isExecutableFile(candidate)) return path.resolve(candidate);\n }\n }\n return undefined;\n}\n\n/** The env var that overrides `harness`'s program. */\nexport function overrideVar(harness: HarnessBinary): string {\n return harness.overrideEnv ?? `${harness.envPrefix}_BRIDGE_BIN`;\n}\n\n/**\n * Whether the harness's program is found (now also in the toolchain dirs).\n *\n * @deprecated Use `resolveHarnessBinary(row, env) !== undefined`. Kept for hosts that still call it.\n */\nexport function findHarnessBinary(harness: HarnessBinary, env: Env = process.env): boolean {\n return resolveHarnessBinary(harness, env) !== undefined;\n}\n"]}