@skaile/workspaces 4.39.0 → 5.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (337) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/dist/{asset-feeds-KXL45ALC.js → asset-feeds-HIWT4DVT.js} +24 -96
  3. package/dist/asset-feeds-HIWT4DVT.js.map +1 -0
  4. package/dist/asset-manager/catalog-deployer.js +10 -9
  5. package/dist/asset-manager/index.js +15 -14
  6. package/dist/asset-manager/installer.js +10 -9
  7. package/dist/asset-manager/src/catalog-deployer.d.ts +1 -3
  8. package/dist/asset-manager/src/catalog-deployer.d.ts.map +1 -1
  9. package/dist/asset-manager/src/index.d.ts +6 -8
  10. package/dist/asset-manager/src/index.d.ts.map +1 -1
  11. package/dist/bridge/drivers/claude-sdk.js +23 -11
  12. package/dist/bridge/drivers/claude-sdk.js.map +1 -1
  13. package/dist/bridge/drivers/codex.js +11 -10
  14. package/dist/bridge/drivers/codex.js.map +1 -1
  15. package/dist/bridge/drivers/continue.js +12 -11
  16. package/dist/bridge/drivers/continue.js.map +1 -1
  17. package/dist/bridge/drivers/echo.js +2 -2
  18. package/dist/bridge/drivers/gemini.js +6 -6
  19. package/dist/bridge/drivers/goose.js +12 -11
  20. package/dist/bridge/drivers/goose.js.map +1 -1
  21. package/dist/bridge/drivers/omp.js +3 -3
  22. package/dist/bridge/drivers/opencode.js +12 -11
  23. package/dist/bridge/drivers/opencode.js.map +1 -1
  24. package/dist/bridge/drivers/qwen.js +6 -6
  25. package/dist/bridge/index.js +13 -12
  26. package/dist/bridge/src/drivers/claude-sdk.d.ts +4 -0
  27. package/dist/bridge/src/drivers/claude-sdk.d.ts.map +1 -1
  28. package/dist/bridge/src/types.d.ts +7 -0
  29. package/dist/bridge/src/types.d.ts.map +1 -1
  30. package/dist/{chunk-7RC37XFW.js → chunk-22DN3DB2.js} +59 -12
  31. package/dist/chunk-22DN3DB2.js.map +1 -0
  32. package/dist/{chunk-SM6EUQMY.js → chunk-32DMH2GD.js} +8 -8
  33. package/dist/{chunk-SM6EUQMY.js.map → chunk-32DMH2GD.js.map} +1 -1
  34. package/dist/{chunk-A5EDMBFG.js → chunk-43ZBF3WH.js} +5 -8
  35. package/dist/chunk-43ZBF3WH.js.map +1 -0
  36. package/dist/{chunk-5RWL4L3X.js → chunk-53WMBXSL.js} +60 -14
  37. package/dist/chunk-53WMBXSL.js.map +1 -0
  38. package/dist/{chunk-YCMZHL4T.js → chunk-7QMRP6BC.js} +4 -4
  39. package/dist/{chunk-YCMZHL4T.js.map → chunk-7QMRP6BC.js.map} +1 -1
  40. package/dist/chunk-A2ULN3KX.js +40 -0
  41. package/dist/chunk-A2ULN3KX.js.map +1 -0
  42. package/dist/{chunk-DSB6X25D.js → chunk-AG44ZJ7W.js} +3 -3
  43. package/dist/{chunk-DSB6X25D.js.map → chunk-AG44ZJ7W.js.map} +1 -1
  44. package/dist/{chunk-SSCPTAFJ.js → chunk-CFL5IJHV.js} +3 -3
  45. package/dist/{chunk-SSCPTAFJ.js.map → chunk-CFL5IJHV.js.map} +1 -1
  46. package/dist/{chunk-36ML6SFP.js → chunk-CGJ7B6MZ.js} +4 -4
  47. package/dist/{chunk-36ML6SFP.js.map → chunk-CGJ7B6MZ.js.map} +1 -1
  48. package/dist/{chunk-6X4DHKHP.js → chunk-CT6NQSA4.js} +3 -3
  49. package/dist/{chunk-6X4DHKHP.js.map → chunk-CT6NQSA4.js.map} +1 -1
  50. package/dist/{chunk-5K2VT6E2.js → chunk-DXUQCMVT.js} +3 -3
  51. package/dist/{chunk-5K2VT6E2.js.map → chunk-DXUQCMVT.js.map} +1 -1
  52. package/dist/{chunk-B4IAZTZZ.js → chunk-EB6OPURC.js} +3 -3
  53. package/dist/{chunk-B4IAZTZZ.js.map → chunk-EB6OPURC.js.map} +1 -1
  54. package/dist/{chunk-252TK4RU.js → chunk-GFPG27HK.js} +12 -14
  55. package/dist/chunk-GFPG27HK.js.map +1 -0
  56. package/dist/{chunk-2EL2PBRC.js → chunk-H4EGUQ7M.js} +3 -3
  57. package/dist/{chunk-2EL2PBRC.js.map → chunk-H4EGUQ7M.js.map} +1 -1
  58. package/dist/{chunk-YQEF36D5.js → chunk-H5G3OYY6.js} +4 -4
  59. package/dist/{chunk-YQEF36D5.js.map → chunk-H5G3OYY6.js.map} +1 -1
  60. package/dist/{chunk-C75VKXAM.js → chunk-HD5K3BYW.js} +3 -3
  61. package/dist/{chunk-C75VKXAM.js.map → chunk-HD5K3BYW.js.map} +1 -1
  62. package/dist/{chunk-VJNTB4DN.js → chunk-HTBGJCKP.js} +4 -4
  63. package/dist/{chunk-VJNTB4DN.js.map → chunk-HTBGJCKP.js.map} +1 -1
  64. package/dist/{chunk-JEPSP6XK.js → chunk-HWE3FXF4.js} +17 -11
  65. package/dist/chunk-HWE3FXF4.js.map +1 -0
  66. package/dist/{chunk-QVLQGXT6.js → chunk-I3ITSUWS.js} +5 -5
  67. package/dist/{chunk-QVLQGXT6.js.map → chunk-I3ITSUWS.js.map} +1 -1
  68. package/dist/{chunk-H7N6RWNF.js → chunk-I7Z4FN52.js} +4 -4
  69. package/dist/{chunk-H7N6RWNF.js.map → chunk-I7Z4FN52.js.map} +1 -1
  70. package/dist/{chunk-WCWFS36P.js → chunk-IGXKUCLI.js} +3 -3
  71. package/dist/{chunk-WCWFS36P.js.map → chunk-IGXKUCLI.js.map} +1 -1
  72. package/dist/{chunk-VXPFSZDT.js → chunk-JFVEX4G5.js} +6 -6
  73. package/dist/{chunk-VXPFSZDT.js.map → chunk-JFVEX4G5.js.map} +1 -1
  74. package/dist/{chunk-YYH5EVPM.js → chunk-JUXQUZOQ.js} +12 -4
  75. package/dist/{chunk-YYH5EVPM.js.map → chunk-JUXQUZOQ.js.map} +1 -1
  76. package/dist/{chunk-M7GPCWEV.js → chunk-KREXWKVX.js} +3 -3
  77. package/dist/{chunk-M7GPCWEV.js.map → chunk-KREXWKVX.js.map} +1 -1
  78. package/dist/{chunk-TQ6XNACF.js → chunk-LHFZTVIM.js} +23 -24
  79. package/dist/chunk-LHFZTVIM.js.map +1 -0
  80. package/dist/{chunk-YV3YI3TA.js → chunk-MBVNMPG7.js} +4 -4
  81. package/dist/{chunk-YV3YI3TA.js.map → chunk-MBVNMPG7.js.map} +1 -1
  82. package/dist/{chunk-3C3ODIDE.js → chunk-MX7IRKTO.js} +6 -6
  83. package/dist/{chunk-3C3ODIDE.js.map → chunk-MX7IRKTO.js.map} +1 -1
  84. package/dist/{chunk-UDFWBALP.js → chunk-NFGRW3L7.js} +3 -3
  85. package/dist/{chunk-UDFWBALP.js.map → chunk-NFGRW3L7.js.map} +1 -1
  86. package/dist/{chunk-5LF27VUB.js → chunk-ODT7HSLI.js} +16 -15
  87. package/dist/chunk-ODT7HSLI.js.map +1 -0
  88. package/dist/{chunk-QBQITQAM.js → chunk-PV4OBVA3.js} +3 -3
  89. package/dist/{chunk-QBQITQAM.js.map → chunk-PV4OBVA3.js.map} +1 -1
  90. package/dist/{chunk-ORH2BZEM.js → chunk-QCI6D7E4.js} +69 -22
  91. package/dist/chunk-QCI6D7E4.js.map +1 -0
  92. package/dist/{chunk-DIQDYNXZ.js → chunk-QZLWJETK.js} +3 -3
  93. package/dist/{chunk-DIQDYNXZ.js.map → chunk-QZLWJETK.js.map} +1 -1
  94. package/dist/{chunk-TSVRKUGV.js → chunk-RP4B4HVX.js} +11 -2
  95. package/dist/chunk-RP4B4HVX.js.map +1 -0
  96. package/dist/{chunk-X4DKUGV4.js → chunk-RSHMAEK3.js} +7 -13
  97. package/dist/chunk-RSHMAEK3.js.map +1 -0
  98. package/dist/chunk-RVRB27AN.js +64 -0
  99. package/dist/chunk-RVRB27AN.js.map +1 -0
  100. package/dist/{chunk-5NYBY6ZE.js → chunk-TVOODIZE.js} +3 -3
  101. package/dist/{chunk-5NYBY6ZE.js.map → chunk-TVOODIZE.js.map} +1 -1
  102. package/dist/{chunk-FTPKMJFD.js → chunk-TVYLXZTT.js} +2 -2
  103. package/dist/{chunk-FTPKMJFD.js.map → chunk-TVYLXZTT.js.map} +1 -1
  104. package/dist/{chunk-EOKAFBJ7.js → chunk-TYUJB336.js} +3 -3
  105. package/dist/{chunk-EOKAFBJ7.js.map → chunk-TYUJB336.js.map} +1 -1
  106. package/dist/{chunk-OLMNDIAU.js → chunk-UVOJSWD2.js} +95 -320
  107. package/dist/chunk-UVOJSWD2.js.map +1 -0
  108. package/dist/{chunk-DOVURNRK.js → chunk-VDJKWKH2.js} +3 -3
  109. package/dist/chunk-VDJKWKH2.js.map +1 -0
  110. package/dist/{chunk-VDBP6Y5M.js → chunk-WCQMXBO5.js} +21 -47
  111. package/dist/chunk-WCQMXBO5.js.map +1 -0
  112. package/dist/{chunk-NLKIW2VI.js → chunk-WOJ4AK3Q.js} +3 -3
  113. package/dist/{chunk-NLKIW2VI.js.map → chunk-WOJ4AK3Q.js.map} +1 -1
  114. package/dist/{chunk-XU7JET5Z.js → chunk-X7MHVL4R.js} +16 -100
  115. package/dist/chunk-X7MHVL4R.js.map +1 -0
  116. package/dist/{chunk-K3IBZ2UZ.js → chunk-XUUYAS3Z.js} +3 -3
  117. package/dist/{chunk-K3IBZ2UZ.js.map → chunk-XUUYAS3Z.js.map} +1 -1
  118. package/dist/{chunk-BCUVRJXV.js → chunk-XWLEXD34.js} +3 -3
  119. package/dist/{chunk-BCUVRJXV.js.map → chunk-XWLEXD34.js.map} +1 -1
  120. package/dist/{chunk-P7BU6DAC.js → chunk-YOWFUJO7.js} +69 -31
  121. package/dist/chunk-YOWFUJO7.js.map +1 -0
  122. package/dist/{chunk-OQRB7JUS.js → chunk-YV4J7V53.js} +3 -3
  123. package/dist/{chunk-OQRB7JUS.js.map → chunk-YV4J7V53.js.map} +1 -1
  124. package/dist/{chunk-JXT46QFC.js → chunk-ZDKJHQY2.js} +2 -2
  125. package/dist/{chunk-JXT46QFC.js.map → chunk-ZDKJHQY2.js.map} +1 -1
  126. package/dist/cli/index.js +375 -699
  127. package/dist/cli/index.js.map +1 -1
  128. package/dist/cli/src/asset-feeds.d.ts +1 -8
  129. package/dist/cli/src/asset-feeds.d.ts.map +1 -1
  130. package/dist/cli/src/commands/asset-cmd.d.ts.map +1 -1
  131. package/dist/cli/src/commands/library-cmd.d.ts.map +1 -1
  132. package/dist/cli/src/commands/library-index.d.ts +5 -12
  133. package/dist/cli/src/commands/library-index.d.ts.map +1 -1
  134. package/dist/cli/src/commands/manage.d.ts +74 -58
  135. package/dist/cli/src/commands/manage.d.ts.map +1 -1
  136. package/dist/cli/src/commands/show.d.ts +1 -1
  137. package/dist/cli/src/commands/skailify-lib.d.ts +0 -31
  138. package/dist/cli/src/commands/skailify-lib.d.ts.map +1 -1
  139. package/dist/cli/src/commands/source-manifest.d.ts.map +1 -1
  140. package/dist/cli/src/commands/validate.d.ts +20 -2
  141. package/dist/cli/src/commands/validate.d.ts.map +1 -1
  142. package/dist/cli/src/flow-discovery.d.ts +2 -2
  143. package/dist/cli/src/hooks/pre-commit-version.d.ts +1 -1
  144. package/dist/cli/src/skill-walker.d.ts +7 -10
  145. package/dist/cli/src/skill-walker.d.ts.map +1 -1
  146. package/dist/connectors/config.js +6 -5
  147. package/dist/connectors/index.js +21 -20
  148. package/dist/core/discovery.js +1 -1
  149. package/dist/core/index.js +9 -8
  150. package/dist/core/manifest.js +2 -2
  151. package/dist/core/models.js +1 -1
  152. package/dist/core/plugin-groupings.d.ts +2 -0
  153. package/dist/core/plugin-groupings.js +4 -0
  154. package/dist/core/plugin-groupings.js.map +1 -0
  155. package/dist/core/publish-manifest.js +2 -2
  156. package/dist/core/ref.js +1 -1
  157. package/dist/core/runtime-assets.js +6 -5
  158. package/dist/core/src/discovery.d.ts +11 -51
  159. package/dist/core/src/discovery.d.ts.map +1 -1
  160. package/dist/core/src/index.d.ts +3 -2
  161. package/dist/core/src/index.d.ts.map +1 -1
  162. package/dist/core/src/models.d.ts +6 -33
  163. package/dist/core/src/models.d.ts.map +1 -1
  164. package/dist/core/src/plugin-groupings.d.ts +31 -0
  165. package/dist/core/src/plugin-groupings.d.ts.map +1 -0
  166. package/dist/core/src/repo-manager.d.ts.map +1 -1
  167. package/dist/core/src/settings.d.ts +1 -1
  168. package/dist/core/src/workspace-config.d.ts +1 -1
  169. package/dist/core/workspace-config.js +5 -4
  170. package/dist/deploy/index.js +9 -8
  171. package/dist/deploy/index.js.map +1 -1
  172. package/dist/discovery/index.js +6 -5
  173. package/dist/discovery/src/discover.d.ts +9 -25
  174. package/dist/discovery/src/discover.d.ts.map +1 -1
  175. package/dist/discovery/src/index.d.ts +0 -2
  176. package/dist/discovery/src/index.d.ts.map +1 -1
  177. package/dist/discovery/src/source-config.d.ts +13 -9
  178. package/dist/discovery/src/source-config.d.ts.map +1 -1
  179. package/dist/discovery/src/tree-entries.d.ts +6 -11
  180. package/dist/discovery/src/tree-entries.d.ts.map +1 -1
  181. package/dist/{ensure-sources-J5CDTQ36.js → ensure-sources-G4FXTJDB.js} +18 -17
  182. package/dist/ensure-sources-G4FXTJDB.js.map +1 -0
  183. package/dist/factory-assets/README.md +1 -1
  184. package/dist/factory-assets/connectors/box.js +21 -20
  185. package/dist/factory-assets/connectors/deploy.js +21 -20
  186. package/dist/factory-assets/connectors/devserver.js +21 -20
  187. package/dist/factory-assets/connectors/flow/CONNECTOR.md +6 -1
  188. package/dist/factory-assets/connectors/flow/adapter.d.ts.map +1 -1
  189. package/dist/factory-assets/connectors/flow/adapter.js +21 -20
  190. package/dist/factory-assets/connectors/flow/contract/flow.v2.schema.json +13 -3
  191. package/dist/factory-assets/connectors/flow/contract/index.d.ts +1 -0
  192. package/dist/factory-assets/connectors/flow/contract/index.d.ts.map +1 -1
  193. package/dist/factory-assets/connectors/flow/contract/output-fields.d.ts +21 -5
  194. package/dist/factory-assets/connectors/flow/contract/output-fields.d.ts.map +1 -1
  195. package/dist/factory-assets/connectors/flow/contract/schema.d.ts +2 -0
  196. package/dist/factory-assets/connectors/flow/contract/schema.d.ts.map +1 -1
  197. package/dist/factory-assets/connectors/flow/contract/sub-flow-output.d.ts +20 -0
  198. package/dist/factory-assets/connectors/flow/contract/sub-flow-output.d.ts.map +1 -0
  199. package/dist/factory-assets/connectors/flow/contract.js +4 -4
  200. package/dist/factory-assets/connectors/flow/engine/bindings.d.ts.map +1 -1
  201. package/dist/factory-assets/connectors/flow/engine/flow-output.d.ts +12 -0
  202. package/dist/factory-assets/connectors/flow/engine/flow-output.d.ts.map +1 -0
  203. package/dist/factory-assets/connectors/flow/engine/index.d.ts +1 -0
  204. package/dist/factory-assets/connectors/flow/engine/index.d.ts.map +1 -1
  205. package/dist/factory-assets/connectors/flow/engine/loader.d.ts +3 -3
  206. package/dist/factory-assets/connectors/flow/engine/locate.d.ts +2 -2
  207. package/dist/factory-assets/connectors/flow/engine/locate.d.ts.map +1 -1
  208. package/dist/factory-assets/connectors/flow/engine/types.d.ts +0 -2
  209. package/dist/factory-assets/connectors/flow/engine/types.d.ts.map +1 -1
  210. package/dist/factory-assets/connectors/flow/engine.js +13 -12
  211. package/dist/factory-assets/connectors/flow/inline-sub-flow-host.d.ts.map +1 -1
  212. package/dist/factory-assets/connectors/flow/prompt-fragments.js +3 -3
  213. package/dist/factory-assets/connectors/flow/run-flow.d.ts.map +1 -1
  214. package/dist/factory-assets/connectors/flow/run-flow.js +23 -22
  215. package/dist/factory-assets/connectors/flow/sub-flow-runner.d.ts +6 -5
  216. package/dist/factory-assets/connectors/flow/sub-flow-runner.d.ts.map +1 -1
  217. package/dist/factory-assets/connectors/flow.js +21 -20
  218. package/dist/factory-assets/connectors/git.js +21 -20
  219. package/dist/factory-assets/connectors/gmail.js +21 -20
  220. package/dist/factory-assets/connectors/googledrive.js +21 -20
  221. package/dist/factory-assets/connectors/local.js +21 -20
  222. package/dist/factory-assets/connectors/mattermost.js +21 -20
  223. package/dist/factory-assets/connectors/memory.js +21 -20
  224. package/dist/factory-assets/connectors/minio.js +21 -20
  225. package/dist/factory-assets/connectors/postgres.js +21 -20
  226. package/dist/factory-assets/connectors/s3.js +21 -20
  227. package/dist/factory-assets/connectors/sharepoint.js +21 -20
  228. package/dist/factory-assets/connectors/sqlite.js +21 -20
  229. package/dist/factory-assets/connectors/static-server.js +21 -20
  230. package/dist/factory-assets/connectors/tunnel.js +21 -20
  231. package/dist/factory-assets/connectors/webdav.js +21 -20
  232. package/dist/factory-assets/connectors/xstate-store.js +21 -20
  233. package/dist/factory-assets/connectors/xstate.js +21 -20
  234. package/dist/factory-assets/skills/skaile-author-asset/SKILL.md +37 -26
  235. package/dist/factory-assets/skills/skaile-manage-workspace/SKILL.md +2 -2
  236. package/dist/factory-assets/skills/skailify/SKILL.md +10 -19
  237. package/dist/{flows-PX53XFV7.js → flows-7E2GVW5L.js} +14 -13
  238. package/dist/{flows-PX53XFV7.js.map → flows-7E2GVW5L.js.map} +1 -1
  239. package/dist/{helpers-EP6H3O3S.js → helpers-EVPKJXGS.js} +18 -17
  240. package/dist/{helpers-EP6H3O3S.js.map → helpers-EVPKJXGS.js.map} +1 -1
  241. package/dist/library/index.js +13 -12
  242. package/dist/library/install.js +2 -2
  243. package/dist/library/src/index.d.ts +1 -1
  244. package/dist/library/src/index.d.ts.map +1 -1
  245. package/dist/library/src/local/db.d.ts.map +1 -1
  246. package/dist/library/src/local/library-manager.d.ts.map +1 -1
  247. package/dist/library/src/local/library.d.ts.map +1 -1
  248. package/dist/library/src/local/local-catalog-source.d.ts +0 -9
  249. package/dist/library/src/local/local-catalog-source.d.ts.map +1 -1
  250. package/dist/library/src/local/schema.d.ts +1 -20
  251. package/dist/library/src/local/schema.d.ts.map +1 -1
  252. package/dist/library/src/remote/remote-catalog-source.d.ts +1 -11
  253. package/dist/library/src/remote/remote-catalog-source.d.ts.map +1 -1
  254. package/dist/library/src/sync/manifest-writeback.d.ts +5 -5
  255. package/dist/library/src/sync/manifest-writeback.d.ts.map +1 -1
  256. package/dist/library/src/user-library.d.ts +1 -9
  257. package/dist/library/src/user-library.d.ts.map +1 -1
  258. package/dist/{library-publish-KKT73FJK.js → library-publish-SBEWWTPM.js} +25 -24
  259. package/dist/library-publish-SBEWWTPM.js.map +1 -0
  260. package/dist/open-library-UAZIGZUQ.js +39 -0
  261. package/dist/{open-library-R62UBL6E.js.map → open-library-UAZIGZUQ.js.map} +1 -1
  262. package/dist/paths-U7TA7MTE.js +22 -0
  263. package/dist/{paths-W4LDORQQ.js.map → paths-U7TA7MTE.js.map} +1 -1
  264. package/dist/{plugin-store-D45CREMJ.js → plugin-store-TT45MGQZ.js} +11 -10
  265. package/dist/plugin-store-TT45MGQZ.js.map +1 -0
  266. package/dist/plugins/index.js +1 -1
  267. package/dist/plugins/src/catalog-source.d.ts +4 -55
  268. package/dist/plugins/src/catalog-source.d.ts.map +1 -1
  269. package/dist/plugins/src/index.d.ts +1 -1
  270. package/dist/plugins/src/index.d.ts.map +1 -1
  271. package/dist/{project-GCW5DFAB.js → project-JLD5RCVK.js} +19 -18
  272. package/dist/{project-GCW5DFAB.js.map → project-JLD5RCVK.js.map} +1 -1
  273. package/dist/resolver/index.js +10 -9
  274. package/dist/runner/index.js +32 -31
  275. package/dist/runner/src/compaction/orchestrator.d.ts +2 -1
  276. package/dist/runner/src/compaction/orchestrator.d.ts.map +1 -1
  277. package/dist/runner/src/compaction-gate.d.ts +13 -0
  278. package/dist/runner/src/compaction-gate.d.ts.map +1 -1
  279. package/dist/runner/src/serve.d.ts.map +1 -1
  280. package/dist/sdk/asset-manager.js +15 -14
  281. package/dist/sdk/bridge.js +13 -12
  282. package/dist/sdk/core.js +9 -8
  283. package/dist/sdk/flow.js +13 -12
  284. package/dist/sdk/index.js +32 -31
  285. package/dist/sdk/index.js.map +1 -1
  286. package/dist/sdk/resolver.js +10 -9
  287. package/dist/sdk/runner.js +32 -31
  288. package/dist/secrets/index.js +2 -2
  289. package/dist/{setup-Q3LXY5AE.js → setup-PGZM4SOO.js} +23 -22
  290. package/dist/setup-PGZM4SOO.js.map +1 -0
  291. package/dist/skills-7QVYPIXI.js +26 -0
  292. package/dist/{skills-R3RPIPWP.js.map → skills-7QVYPIXI.js.map} +1 -1
  293. package/dist/source-SDZYXVVV.js +40 -0
  294. package/dist/{source-CFQESKJU.js.map → source-SDZYXVVV.js.map} +1 -1
  295. package/dist/{source-manifest-publish-3TCBA2RV.js → source-manifest-publish-UDLTYV6Y.js} +26 -25
  296. package/dist/source-manifest-publish-UDLTYV6Y.js.map +1 -0
  297. package/dist/tui/index.js +32 -31
  298. package/dist/tui/index.js.map +1 -1
  299. package/dist/workspace-plugin/adapters/mcp.js +16 -15
  300. package/dist/workspace-plugin/adapters/omp.js +13 -13
  301. package/dist/workspace-plugin/adapters/omp.js.map +1 -1
  302. package/dist/workspace-plugin/index.js +1 -1
  303. package/dist/workspace-plugin/src/adapters/mcp.d.ts +4 -4
  304. package/dist/workspace-plugin/src/adapters/mcp.d.ts.map +1 -1
  305. package/dist/workspace-plugin/src/adapters/omp.d.ts +2 -2
  306. package/dist/workspace-plugin/src/tools/skills.d.ts +5 -17
  307. package/dist/workspace-plugin/src/tools/skills.d.ts.map +1 -1
  308. package/package.json +7 -1
  309. package/dist/asset-feeds-KXL45ALC.js.map +0 -1
  310. package/dist/chunk-252TK4RU.js.map +0 -1
  311. package/dist/chunk-5LF27VUB.js.map +0 -1
  312. package/dist/chunk-5RWL4L3X.js.map +0 -1
  313. package/dist/chunk-7RC37XFW.js.map +0 -1
  314. package/dist/chunk-A5EDMBFG.js.map +0 -1
  315. package/dist/chunk-DOVURNRK.js.map +0 -1
  316. package/dist/chunk-JEPSP6XK.js.map +0 -1
  317. package/dist/chunk-OLMNDIAU.js.map +0 -1
  318. package/dist/chunk-ORH2BZEM.js.map +0 -1
  319. package/dist/chunk-P7BU6DAC.js.map +0 -1
  320. package/dist/chunk-QVZA2MDT.js +0 -81
  321. package/dist/chunk-QVZA2MDT.js.map +0 -1
  322. package/dist/chunk-TQ6XNACF.js.map +0 -1
  323. package/dist/chunk-TSVRKUGV.js.map +0 -1
  324. package/dist/chunk-VDBP6Y5M.js.map +0 -1
  325. package/dist/chunk-X4DKUGV4.js.map +0 -1
  326. package/dist/chunk-XU7JET5Z.js.map +0 -1
  327. package/dist/discovery/src/domains.d.ts +0 -149
  328. package/dist/discovery/src/domains.d.ts.map +0 -1
  329. package/dist/ensure-sources-J5CDTQ36.js.map +0 -1
  330. package/dist/library-publish-KKT73FJK.js.map +0 -1
  331. package/dist/open-library-R62UBL6E.js +0 -38
  332. package/dist/paths-W4LDORQQ.js +0 -21
  333. package/dist/plugin-store-D45CREMJ.js.map +0 -1
  334. package/dist/setup-Q3LXY5AE.js.map +0 -1
  335. package/dist/skills-R3RPIPWP.js +0 -25
  336. package/dist/source-CFQESKJU.js +0 -39
  337. package/dist/source-manifest-publish-3TCBA2RV.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../bridge/src/cloud.ts","../bridge/src/drivers/scrub-transcript.ts","../bridge/src/agent-transcript.ts","../bridge/src/drivers/resume-probe.ts"],"names":["join"],"mappings":";;;;;;;;;;;AAuCA,IAAM,iBAAA,GAAoB,CAAC,mBAAA,EAAqB,sBAAA,EAAwB,oBAAoB,CAAA;AAQrF,IAAM,0BAAA,GAA6B;AAQ1C,IAAM,iBAAA,GAA0C;AAAA,EAC9C,mBAAA,EAAqB,IAAA;AAAA,EACrB,aAAA,EAAe,IAAA;AAAA,EACf,WAAA,EAAa;AACf,CAAA;AAcO,SAAS,mBAAmB,KAAA,EAA4C;AAC7E,EAAA,MAAM,UAAW,KAAA,CAA6B,OAAA;AAC9C,EAAA,MAAM,SAAA,GAAY,eAAe,KAAK,CAAA;AACtC,EAAA,IAAI,OAAA,KAAY,yBAAA,IAA6B,SAAA,KAAc,SAAA,EAAW,OAAO,SAAA;AAC7E,EAAA,IAAI,OAAA,KAAY,eAAA,IAAmB,SAAA,KAAc,QAAA,EAAU,OAAO,QAAA;AAClE,EAAA,IAAI,SAAA,KAAc,WAAW,OAAO,SAAA;AACpC,EAAA,OAAO,WAAA;AACT;AA2CO,SAAS,uBAAuB,IAAA,EAAsD;AAC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AAuB,IAAA,EAAM,GAAG,CAAA;AAClD,EAAA,MAAM,SAAA,GAAY,MAAM,SAAA,IAAa,uBAAA;AACrC,EAAA,MAAM,MAAA,GAAS,MAAM,MAAA,IAAU,oBAAA;AAC/B,EAAA,IAAI;AAIF,IAAA,MAAM,WAAW,MAAM,cAAA;AAAA,MACrB,gBAAgB,SAAS,CAAA,CAAA;AAAA,MACzB,MAAM,MAAA,CAAO,SAAA,EAAW,SAAS,CAAA;AAAA,MACjC;AAAA,KACF;AACA,IAAA,OAAO,WAAW,kBAAA,GAAqB,YAAA;AAAA,EACzC,CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,MAAA;AAAA,EACT;AACF","file":"chunk-5NYBY6ZE.js","sourcesContent":["/**\n * AI endpoint transport for the `claude-sdk` driver — the Claude Agent SDK's\n * child-process environment.\n *\n * {@link buildClaudeEndpointEnv} takes an **AI provider registry entry** and\n * is what the driver calls, on every transport. It is plan §2.3's\n * `buildEndpointEnv` for the claude-sdk row (named for the driver because the\n * vars it emits — `CLAUDE_CODE_USE_*`, `ANTHROPIC_*` — are the Claude Agent\n * SDK's own contract, not a portable one).\n *\n * A registry entry says what the deleted `cloud` axis said — Amazon Bedrock,\n * Google Vertex AI, Azure AI Foundry, a generic gateway — with `surface` +\n * `transport` + `base_url` + `credential`, and says it for the direct\n * endpoint too, which the `cloud` axis could not address at all.\n *\n * Cross-repo contract: env key names and semantics here are load-bearing —\n * the platform resolves credential bundles against the same key set.\n */\n\nimport {\n type AIProviderEntry,\n type AIProviderLlmEntry,\n entryTransport,\n normalizeAnthropicBaseUrl,\n resolveEntryBaseUrl,\n} from \"@skaile/workspaces/core/provider-registry\";\n\n/**\n * Env vars scrubbed from the inherited environment before an endpoint env is\n * assembled. Ambient first-party credentials or a stale `CLAUDE_CODE_USE_*`\n * flag must never leak into a session whose entry points elsewhere (the\n * ambient carriers are restored explicitly when the entry has none of its\n * own).\n *\n * Deliberately NOT exhaustive: ambient transport-specific vars (AWS_*,\n * GOOGLE_*, ANTHROPIC_VERTEX_PROJECT_ID, ANTHROPIC_FOUNDRY_*) survive so a\n * standalone CLI inherits its own signing chain; the SDK ignores vars whose\n * transport flag is unset.\n */\nconst SCRUBBED_ENV_KEYS = [\"ANTHROPIC_API_KEY\", \"ANTHROPIC_AUTH_TOKEN\", \"ANTHROPIC_BASE_URL\"];\n\n/**\n * The Anthropic first-party endpoint. An entry that resolves to exactly this\n * host needs no `ANTHROPIC_BASE_URL`: the SDK already points there, and an\n * explicit value would make every default session look like a third-party\n * redirect to Claude Code's own telemetry and auth heuristics.\n */\nexport const ANTHROPIC_DEFAULT_BASE_URL = \"https://api.anthropic.com\";\n\n/**\n * Headers the SDK owns and an entry must not restate through\n * `ANTHROPIC_CUSTOM_HEADERS`: the protocol version it was built against, and\n * the two credential carriers (which are `credential.ref`'s job — a literal\n * secret in `headers` is a validation error anyway).\n */\nconst SDK_OWNED_HEADERS: Record<string, true> = {\n \"anthropic-version\": true,\n authorization: true,\n \"x-api-key\": true,\n};\n\n/**\n * Which of the Claude Agent SDK's four native transports an entry addresses.\n *\n * The SDK has no `transport` field: it switches on a `CLAUDE_CODE_USE_*` flag.\n * Bedrock and Vertex are their own wire surfaces, so they are recognized by\n * `surface` as well as by `transport` — a legacy-derived entry that had no\n * region (and therefore no `params`, and therefore no `transport`) is still a\n * Bedrock session, exactly as it was before the registry existed.\n */\nexport type ClaudeEndpointMode = \"anthropic\" | \"bedrock\" | \"vertex\" | \"foundry\";\n\n/** Classify a registry entry into its {@link ClaudeEndpointMode}. */\nexport function claudeEndpointMode(entry: AIProviderEntry): ClaudeEndpointMode {\n const surface = (entry as AIProviderLlmEntry).surface;\n const transport = entryTransport(entry);\n if (surface === \"bedrock-converse-stream\" || transport === \"bedrock\") return \"bedrock\";\n if (surface === \"google-vertex\" || transport === \"vertex\") return \"vertex\";\n if (transport === \"foundry\") return \"foundry\";\n return \"anthropic\";\n}\n\n/** Arguments for {@link buildClaudeEndpointEnv}. */\nexport interface ClaudeEndpointEnvInput {\n /** The selected registry entry — the whole endpoint definition. */\n entry: AIProviderEntry;\n /**\n * The entry's credential, already resolved from its `credential.ref`\n * (`resolveEntryCredential`). Absent for `kind: none`, for an ambient\n * `sigv4` / `google_adc` / `azure_entra` chain, for `oauth` (whose blob the\n * runner writes to the Claude credentials file, never to the env), and for a\n * reference that did not resolve.\n */\n credential?: string;\n /**\n * The driver's base environment — `process.env` with `undefined` dropped.\n * The endpoint vars are layered **on top** of it, never instead of it, so\n * `PATH`, `HOME` and `SKAILE_SESSION_ID` reach the child.\n */\n baseEnv: Record<string, string>;\n /** `AgentConfig.env` plus any credential material the session carried. */\n configEnv?: Record<string, string>;\n}\n\n/**\n * Assemble the Claude Agent SDK child env for one registry entry (plan §2.3).\n *\n * Pure (no external state read, no input mutated). Starts from `baseEnv`\n * merged with `configEnv`, scrubs the inherited Anthropic credential/routing\n * vars and every `CLAUDE_CODE_USE_*` flag, then writes exactly what the entry\n * describes: at most one transport flag, the endpoint, and the credential in\n * the carrier its `kind` names.\n *\n * Credential kinds (§1.4): `api_key_header` → `ANTHROPIC_API_KEY` (the SDK\n * sends it as `x-api-key`); `bearer` → `ANTHROPIC_AUTH_TOKEN` (sent as\n * `Authorization: Bearer`); `sigv4` / `google_adc` / `azure_entra` emit\n * nothing and let the AWS/Google/Azure chain sign — which is why the scrub\n * deliberately spares ambient `AWS_*` / `GOOGLE_*` values; `oauth` and `none`\n * emit nothing, and the pre-scrub ambient carriers are restored so an OAuth or\n * shell-configured session keeps the auth it had.\n *\n * Never returns `undefined` or empty values; absent settings are omitted.\n */\nexport function buildClaudeEndpointEnv(args: ClaudeEndpointEnvInput): Record<string, string> {\n const { entry, credential, baseEnv, configEnv } = args;\n const env: Record<string, string> = { ...baseEnv, ...(configEnv ?? {}) };\n\n // Captured before the scrub — an entry with no credential material of its\n // own falls back to these, the way the gateway branch always has.\n const ambient = { authToken: env.ANTHROPIC_AUTH_TOKEN, apiKey: env.ANTHROPIC_API_KEY };\n\n for (const key of Object.keys(env)) {\n if (SCRUBBED_ENV_KEYS.includes(key) || key.startsWith(\"CLAUDE_CODE_USE_\")) {\n delete env[key];\n }\n }\n\n const set = (key: string, value: string | undefined) => {\n // Falsy check is deliberate: an empty-string credential/setting is never\n // valid env — dropping it beats shipping a key the SDK treats as set.\n if (value) env[key] = value;\n };\n\n const kind = entry.credential?.kind ?? \"none\";\n const params = (entry as AIProviderLlmEntry).params as Record<string, string> | undefined;\n\n // Static headers ride as ANTHROPIC_CUSTOM_HEADERS (`Name: Value` per line),\n // the only channel the SDK offers. An entry with none leaves an ambient\n // value alone.\n const headers = Object.entries(entry.headers ?? {}).filter(\n ([name]) => !SDK_OWNED_HEADERS[name.toLowerCase()],\n );\n if (headers.length > 0) {\n env.ANTHROPIC_CUSTOM_HEADERS = headers.map(([name, value]) => `${name}: ${value}`).join(\"\\n\");\n }\n\n switch (claudeEndpointMode(entry)) {\n case \"bedrock\": {\n env.CLAUDE_CODE_USE_BEDROCK = \"1\";\n // The AWS credential bundle itself is `configEnv` material (AWS_*), and\n // ambient AWS_* survived the scrub, so a standalone CLI keeps its own.\n set(\"AWS_REGION\", params?.region);\n break;\n }\n case \"vertex\": {\n env.CLAUDE_CODE_USE_VERTEX = \"1\";\n // GOOGLE_APPLICATION_CREDENTIALS is a path the runner materialized; it\n // arrives through `configEnv` or ambient, never from `credential`.\n set(\"ANTHROPIC_VERTEX_PROJECT_ID\", params?.project);\n set(\"CLOUD_ML_REGION\", params?.location);\n break;\n }\n case \"foundry\": {\n env.CLAUDE_CODE_USE_FOUNDRY = \"1\";\n // §1.3: an explicit `base_url` wins over the resource-derived endpoint,\n // and the SDK has a separate var for each form.\n if (entry.base_url) set(\"ANTHROPIC_FOUNDRY_BASE_URL\", entry.base_url);\n else set(\"ANTHROPIC_FOUNDRY_RESOURCE\", params?.resource);\n set(\"ANTHROPIC_FOUNDRY_API_KEY\", credential);\n break;\n }\n case \"anthropic\": {\n const baseUrl = normalizeAnthropicBaseUrl(resolveEntryBaseUrl(entry));\n if (baseUrl && baseUrl.toLowerCase() !== ANTHROPIC_DEFAULT_BASE_URL) {\n env.ANTHROPIC_BASE_URL = baseUrl;\n }\n if (kind === \"bearer\") set(\"ANTHROPIC_AUTH_TOKEN\", credential);\n else if (kind === \"api_key_header\") set(\"ANTHROPIC_API_KEY\", credential);\n if (!credential) {\n // `oauth` / `none` / an unresolved ref: the ambient carriers are the\n // only auth this session has, and the scrub just removed them.\n if (ambient.authToken) env.ANTHROPIC_AUTH_TOKEN = ambient.authToken;\n else set(\"ANTHROPIC_API_KEY\", ambient.apiKey);\n }\n break;\n }\n }\n\n return env;\n}\n","/**\n * Poisoned-transcript repair for the Claude Agent SDK driver.\n *\n * The Anthropic Messages API can permanently reject a conversation once its\n * persisted history contains a malformed content block. Because the bad block\n * lives in the SDK's on-disk JSONL transcript, every replayed turn fails with\n * the same `400 invalid_request_error` and the session is bricked with no\n * in-band recovery.\n *\n * This module repairs the transcript in place, covering three known poison\n * classes:\n *\n * 1. **Image `media_type` mismatch / omission.** An image block whose declared\n * `media_type` does not match — or is missing for — the actual bytes:\n * `... The image was specified using the image/png media type, but the\n * image appears to be a image/jpeg image`. Produced by the Claude Code\n * `Read` tool's format fallback (anthropics/claude-code#55338, #30124,\n * #33179). Repaired by sniffing the base64 magic bytes and correcting\n * `media_type`.\n * 2. **Oversized image.** An image whose decoded payload exceeds the API's\n * 5 MB per-image limit (anthropics/claude-code#34566). Replaced with a\n * text stub — the byte budget cannot be recovered any other way.\n * 3. **`cache_control` on an empty text block.** A text block carrying a\n * `cache_control` marker with empty/whitespace `text`\n * (anthropics/claude-code#59626). The `cache_control` field is stripped.\n *\n * Genuinely unidentifiable image blocks are also replaced with a text stub.\n *\n * Recovering by content scan (rather than parsing the API's `messages.N`\n * index) is deliberate: the index addresses the assembled API request, not a\n * JSONL line, and reproducing the SDK's message-assembly is fragile. A full\n * scan is index-free and repairs every poisoned block in one pass.\n *\n * **Async and line-streaming since #454.** A Claude Code transcript is routinely\n * multi-megabyte (base64 images inline in `tool_result` blocks), and this runs on\n * a failed turn *and before every resume* — inside the single-threaded `skaile\n * serve` loop. The previous `readFileSync` + `writeFileSync` + `renameSync` held\n * the loop for the whole file and materialised it twice over as one string. Both\n * passes now stream line by line off a `createReadStream`, so the loop is yielded\n * between lines and peak memory is one JSONL line rather than the whole file, and\n * every I/O phase is deadline-bounded.\n *\n * Streaming was chosen over a worker thread: the work is I/O-bound rather than\n * CPU-bound (per-line `JSON.parse` on a yielded loop is not what stalls a turn),\n * and a worker would add a structured-clone of the same multi-MB payload plus a\n * thread lifecycle to a path that must never block a turn.\n *\n * @module\n */\n\nimport { createReadStream, createWriteStream } from \"node:fs\";\nimport { readdir, rename, stat, unlink } from \"node:fs/promises\";\nimport { join } from \"node:path\";\nimport { pipeline } from \"node:stream/promises\";\nimport { fsDeadlineMs, tryWithFsDeadline, withFsDeadline } from \"@skaile/workspaces/core\";\n\n/**\n * Minimal logger shape accepted by {@link scrubPoisonedTranscript}. Compatible\n * with the bridge `Logger`, but narrowed so the helper stays unit-testable\n * without a real logger instance.\n *\n * @category Transcript repair\n */\nexport interface ScrubLogger {\n info(message: string, data?: Record<string, unknown>): void;\n warn(message: string, data?: Record<string, unknown>): void;\n}\n\n/**\n * Options for {@link scrubPoisonedTranscript}.\n *\n * @category Transcript repair\n */\nexport interface ScrubTranscriptOptions {\n /**\n * Claude Code config directory — the parent of `projects/`. Resolve from\n * `CLAUDE_CONFIG_DIR`, falling back to `~/.claude`.\n */\n configDir: string;\n /** SDK session id whose transcript JSONL should be repaired. */\n sessionId: string;\n /** Optional logger for diagnostics. */\n log?: ScrubLogger;\n /**\n * Where the transcript is read and written. Defaults to this process's own\n * filesystem access ({@link localTranscriptStore}); with the agent uid split\n * the transcript belongs to the agent uid and must be reached through it.\n */\n store?: TranscriptStore;\n}\n\n/**\n * Filesystem access to Claude Code transcripts. The CLI creates them 0600 in\n * 0700 dirs, so when it runs as a different uid than the runner, only that uid\n * can locate, read or rewrite them (see `agent-transcript.ts`).\n *\n * @category Transcript repair\n */\nexport interface TranscriptStore {\n /** Path of `<sessionId>.jsonl` under `<configDir>/projects/`, or `null` when absent. */\n locate(configDir: string, sessionId: string, timeoutMs?: number): Promise<string | null>;\n /** The file's contents as UTF-8 chunks. */\n read(filePath: string): AsyncIterable<string>;\n /** Atomically replace the file with `chunks` via a `.scrub-tmp` sibling. */\n replace(filePath: string, chunks: AsyncIterable<string>): Promise<void>;\n /** Remove the sibling a failed or abandoned {@link replace} left (best effort). */\n discardTemp(filePath: string): Promise<void>;\n}\n\n/**\n * Outcome of a {@link scrubPoisonedTranscript} pass.\n *\n * @category Transcript repair\n */\nexport interface ScrubTranscriptResult {\n /** The located JSONL transcript path, or `null` when not found. */\n filePath: string | null;\n /** Image blocks whose `media_type` was corrected (or filled in) to match the bytes. */\n corrected: number;\n /**\n * Image blocks replaced with a text stub — either unidentifiable bytes or a\n * payload over the API's 5 MB per-image limit.\n */\n stubbed: number;\n /** Empty text blocks from which a rejected `cache_control` marker was stripped. */\n cacheStripped: number;\n /**\n * `true` when the transcript was located, contained at least one poisoned\n * block, and was rewritten. `false` means nothing needed repair (or the\n * file was not found) — the caller should not retry the resume.\n */\n changed: boolean;\n}\n\n/** Text inserted in place of an image block whose format cannot be identified. */\nconst STUB_TEXT = \"[image removed: unprocessable image data]\";\n\n/** Text inserted in place of an image block that exceeds the API size limit. */\nconst STUB_TEXT_OVERSIZED = \"[image removed: image too large]\";\n\n/**\n * The Anthropic Messages API rejects any single image whose decoded payload\n * exceeds 5 MB. An image at or under this is left alone; a larger one is\n * stubbed (its byte budget cannot be recovered).\n */\nconst MAX_IMAGE_BYTES = 5 * 1024 * 1024;\n\n/**\n * Identify an image's media type from the leading bytes of its base64 payload.\n *\n * Recognises the four formats the Anthropic API accepts. Returns `null` when\n * the magic bytes match no known format — the caller treats that as a\n * genuinely corrupt block and stubs it.\n *\n * @param base64 - Base64-encoded image data (only the prefix is inspected).\n * @returns An `image/*` media type, or `null` when unrecognised.\n * @category Transcript repair\n */\nexport function sniffImageMediaType(base64: string): string | null {\n let buf: Buffer;\n try {\n // 32 base64 chars decode to 24 bytes — enough for the WebP check at 12.\n buf = Buffer.from(base64.slice(0, 32), \"base64\");\n } catch {\n return null;\n }\n if (buf.length < 4) {\n return null;\n }\n // JPEG — SOI marker `FF D8`. Third byte varies (and may be corrupt), so a\n // two-byte check is intentional: it still matches malformed JPEGs, which is\n // exactly the poison case the API flags as \"appears to be image/jpeg\".\n if (buf[0] === 0xff && buf[1] === 0xd8) {\n return \"image/jpeg\";\n }\n // PNG — `89 50 4E 47`.\n if (buf[0] === 0x89 && buf[1] === 0x50 && buf[2] === 0x4e && buf[3] === 0x47) {\n return \"image/png\";\n }\n // GIF — `47 49 46 38` (\"GIF8\").\n if (buf[0] === 0x47 && buf[1] === 0x49 && buf[2] === 0x46 && buf[3] === 0x38) {\n return \"image/gif\";\n }\n // WebP — `RIFF` at 0..3 and `WEBP` at 8..11.\n if (\n buf.length >= 12 &&\n buf[0] === 0x52 &&\n buf[1] === 0x49 &&\n buf[2] === 0x46 &&\n buf[3] === 0x46 &&\n buf[8] === 0x57 &&\n buf[9] === 0x45 &&\n buf[10] === 0x42 &&\n buf[11] === 0x50\n ) {\n return \"image/webp\";\n }\n return null;\n}\n\n/** A base64 image source on a content block (shape is SDK-defined). */\ninterface Base64ImageSource {\n type?: string;\n media_type?: string;\n data?: string;\n}\n\n/** Loosely-typed content block from a transcript message. */\ninterface ContentBlockLike {\n type?: string;\n source?: Base64ImageSource;\n content?: unknown;\n [k: string]: unknown;\n}\n\n/** Mutable counters threaded through one scrub pass. */\ninterface ScrubCounters {\n corrected: number;\n stubbed: number;\n cacheStripped: number;\n}\n\n/** Total repairs recorded in a counter set — used to detect per-line changes. */\nfunction totalChanges(c: ScrubCounters): number {\n return c.corrected + c.stubbed + c.cacheStripped;\n}\n\n/**\n * Repair a single content block. Returns the (possibly replaced) block.\n *\n * - A `tool_result` block recurses into its `content` array.\n * - A text block carrying a `cache_control` marker whose `text` is empty or\n * whitespace has the marker stripped (the API rejects `cache_control` on\n * empty text blocks).\n * - An image block whose decoded payload exceeds the API's 5 MB limit is\n * replaced with a text stub.\n * - An image block whose bytes match no known format is replaced with a text\n * stub (an image cannot simply be dropped — a `tool_result` must keep at\n * least one content entry, and a bare `image` block is replaced 1:1).\n * - An image block whose declared `media_type` mismatches (or is missing for)\n * the sniffed type is corrected in place.\n * - Every other block is returned untouched.\n */\nfunction scrubBlock(block: ContentBlockLike, counters: ScrubCounters): ContentBlockLike {\n if (block.type === \"tool_result\" && Array.isArray(block.content)) {\n return {\n ...block,\n content: (block.content as ContentBlockLike[]).map((inner) => scrubBlock(inner, counters)),\n };\n }\n\n // A `cache_control` marker on a text block whose text is empty or whitespace\n // is rejected by the API (\"cache_control cannot be set for empty text\n // blocks\"). Strip the marker — the empty block itself is harmless.\n if (block.type === \"text\" && block.cache_control != null) {\n const text = typeof block.text === \"string\" ? block.text : \"\";\n if (text.trim() === \"\") {\n counters.cacheStripped++;\n const clone = { ...block };\n delete clone.cache_control;\n return clone;\n }\n }\n\n if (\n block.type === \"image\" &&\n block.source?.type === \"base64\" &&\n typeof block.source.data === \"string\"\n ) {\n const data = block.source.data;\n // The API rejects any image whose decoded payload exceeds 5 MB. The byte\n // budget cannot be salvaged, so the whole block becomes a text stub.\n // base64 encodes 3 bytes per 4 chars, so decoded length ≈ len * 3 / 4.\n if (Math.floor((data.length * 3) / 4) > MAX_IMAGE_BYTES) {\n counters.stubbed++;\n return { type: \"text\", text: STUB_TEXT_OVERSIZED };\n }\n const sniffed = sniffImageMediaType(data);\n if (sniffed === null) {\n counters.stubbed++;\n return { type: \"text\", text: STUB_TEXT };\n }\n if (sniffed !== block.source.media_type) {\n counters.corrected++;\n return { ...block, source: { ...block.source, media_type: sniffed } };\n }\n }\n\n return block;\n}\n\n/**\n * Locate the JSONL transcript for `sessionId` under `<configDir>/projects/`.\n *\n * Claude Code encodes the project directory into the `projects/` subfolder\n * name; rather than reproduce that encoding, this scans every subfolder for\n * `<sessionId>.jsonl` (the session id is a UUID — globally unique).\n *\n * Async and deadline-bounded since #454. The `existsSync(projectsDir)` probe is\n * gone: `readdir` already fails on a missing directory, so the probe was a\n * second stat on the same path for no information.\n *\n * `timeoutMs` defaults to {@link fsDeadlineMs} so callers that only need the\n * path (the resume probe) can omit it.\n *\n * @category Transcript repair\n */\nexport async function locateTranscriptPath(\n configDir: string,\n sessionId: string,\n timeoutMs: number = fsDeadlineMs(),\n): Promise<string | null> {\n const projectsDir = join(configDir, \"projects\");\n const entries = await tryWithFsDeadline(\n `readdir ${projectsDir}`,\n () => readdir(projectsDir),\n null,\n timeoutMs,\n );\n if (!entries) return null;\n for (const entry of entries) {\n const candidate = join(projectsDir, entry, `${sessionId}.jsonl`);\n const found = await tryWithFsDeadline(\n `stat ${candidate}`,\n async () => (await stat(candidate)).isFile(),\n false,\n timeoutMs,\n );\n if (found) return candidate;\n }\n return null;\n}\n\n/**\n * Yield a file's contents line by line, reproducing `readFileSync(...).split(\"\\n\")`\n * exactly — including the final (possibly empty) segment, so a trailing newline\n * survives a rewrite byte for byte.\n *\n * Splits on `\\n` alone, so a line out of a CRLF transcript arrives with its\n * `\\r` still attached. That carrier byte is part of the line here, and\n * {@link repairLine} re-attaches it to a line it rewrites — the file keeps the\n * terminator style it arrived with. Deliberately not `node:readline`:\n * `crlfDelay` strips the `\\r` outright (rewriting a CRLF transcript to LF) and\n * the interface swallows the trailing-newline distinction, either of which\n * would make the \"clean transcript is left byte-for-byte untouched\" guarantee\n * false. Only one line is held in memory at a time, so a multi-MB transcript\n * never materialises as a single string.\n */\nasync function* streamLines(chunks: AsyncIterable<string>): AsyncGenerator<string> {\n let pending = \"\";\n for await (const chunk of chunks) {\n pending += chunk;\n let idx = pending.indexOf(\"\\n\");\n while (idx !== -1) {\n yield pending.slice(0, idx);\n pending = pending.slice(idx + 1);\n idx = pending.indexOf(\"\\n\");\n }\n }\n yield pending;\n}\n\n/**\n * The runner's own filesystem access: the default {@link TranscriptStore}.\n *\n * @category Transcript repair\n */\nexport const localTranscriptStore: TranscriptStore = {\n locate: (configDir, sessionId, timeoutMs) =>\n locateTranscriptPath(configDir, sessionId, timeoutMs),\n async *read(filePath) {\n const stream = createReadStream(filePath, { encoding: \"utf8\" });\n try {\n for await (const chunk of stream) yield chunk as string;\n } finally {\n stream.destroy();\n }\n },\n async replace(filePath, chunks) {\n const tmpPath = `${filePath}.scrub-tmp`;\n await pipeline(chunks, createWriteStream(tmpPath, { encoding: \"utf8\" }));\n await rename(tmpPath, filePath);\n },\n async discardTemp(filePath) {\n const tmpPath = `${filePath}.scrub-tmp`;\n await tryWithFsDeadline(`unlink ${tmpPath}`, () => unlink(tmpPath), undefined, fsDeadlineMs());\n },\n};\n\n/**\n * Repair one JSONL line, returning the (possibly rewritten) line and mutating\n * `counters`. A non-JSON, blank, or content-less line is returned untouched.\n *\n * The reader splits on `\\n` only, so a line from a CRLF transcript still carries\n * its trailing `\\r`. An untouched line is returned verbatim and keeps it; a\n * rewritten one is rebuilt by `JSON.stringify`, which would drop it — leaving a\n * repaired CRLF transcript with mixed line endings. So the terminator is split\n * off before the parse and re-appended to the rewritten line.\n */\nfunction repairLine(line: string, counters: ScrubCounters): string {\n if (line.trim() === \"\") return line;\n const eol = line.endsWith(\"\\r\") ? \"\\r\" : \"\";\n const body = eol === \"\" ? line : line.slice(0, -1);\n let entry: { message?: { content?: unknown } };\n try {\n entry = JSON.parse(body);\n } catch {\n return line; // Not JSON — leave untouched.\n }\n const content = entry.message?.content;\n if (!Array.isArray(content)) return line;\n const before = totalChanges(counters);\n const scrubbed = (content as ContentBlockLike[]).map((block) => scrubBlock(block, counters));\n if (totalChanges(counters) === before) return line; // Nothing changed on this line.\n return `${JSON.stringify({ ...entry, message: { ...entry.message, content: scrubbed } })}${eol}`;\n}\n\n/**\n * Scan a Claude Code SDK transcript for image content blocks whose declared\n * `media_type` does not match the actual bytes, repair them, and atomically\n * rewrite the file.\n *\n * Safe to call after a turn has failed: the SDK query is dead at that point,\n * and the next resume re-reads the transcript from disk.\n *\n * **Async since #454.** Two streaming passes rather than one whole-file read:\n * pass 1 counts repairs without writing anything, and pass 2 runs only when\n * pass 1 found something. The common case — the preventive scrub of a clean\n * transcript before every resume — is therefore one streaming read and zero\n * writes, and a clean transcript is still left byte-for-byte untouched.\n *\n * @param opts - Config directory, session id, and an optional logger.\n * @returns A {@link ScrubTranscriptResult}. When `changed` is `true` the\n * caller may retry the resume with the same session id.\n * @category Transcript repair\n */\nexport async function scrubPoisonedTranscript(\n opts: ScrubTranscriptOptions,\n): Promise<ScrubTranscriptResult> {\n const { configDir, sessionId, log } = opts;\n const store = opts.store ?? localTranscriptStore;\n const timeoutMs = fsDeadlineMs();\n const result: ScrubTranscriptResult = {\n filePath: null,\n corrected: 0,\n stubbed: 0,\n cacheStripped: 0,\n changed: false,\n };\n\n let filePath: string | null;\n try {\n filePath = await store.locate(configDir, sessionId, timeoutMs);\n } catch (err) {\n log?.warn(\"scrub-transcript: failed to locate transcript\", {\n configDir,\n sessionId,\n error: err instanceof Error ? err.message : String(err),\n });\n return result;\n }\n if (!filePath) {\n log?.warn(\"scrub-transcript: no transcript found\", { configDir, sessionId });\n return result;\n }\n result.filePath = filePath;\n\n // ── Pass 1: detect. Streams the transcript, counting repairs, writing nothing.\n const counters: ScrubCounters = { corrected: 0, stubbed: 0, cacheStripped: 0 };\n try {\n await withFsDeadline(\n `scan transcript ${filePath}`,\n async () => {\n for await (const line of streamLines(store.read(filePath))) repairLine(line, counters);\n },\n timeoutMs,\n );\n } catch (err) {\n log?.warn(\"scrub-transcript: failed to read transcript\", {\n filePath,\n error: err instanceof Error ? err.message : String(err),\n });\n return result;\n }\n\n result.corrected = counters.corrected;\n result.stubbed = counters.stubbed;\n result.cacheStripped = counters.cacheStripped;\n\n if (totalChanges(counters) === 0) {\n return result;\n }\n\n // ── Pass 2: rewrite. Atomic: stream a sibling temp file, then rename over the\n // original. Line separators are re-emitted exactly as pass 1 split them, so a\n // trailing newline and any blank lines survive verbatim.\n const source = filePath;\n try {\n await withFsDeadline(\n `rewrite transcript ${source}`,\n async () => {\n const discard: ScrubCounters = { corrected: 0, stubbed: 0, cacheStripped: 0 };\n await store.replace(\n source,\n (async function* () {\n let first = true;\n for await (const line of streamLines(store.read(source))) {\n yield first ? repairLine(line, discard) : `\\n${repairLine(line, discard)}`;\n first = false;\n }\n })(),\n );\n },\n timeoutMs,\n );\n } catch (err) {\n log?.warn(\"scrub-transcript: failed to rewrite transcript\", {\n filePath,\n error: err instanceof Error ? err.message : String(err),\n });\n // Never leave a half-written `.scrub-tmp` in the SDK's projects dir, also\n // when the deadline abandoned the replace mid-write.\n await store.discardTemp(source).catch(() => {});\n return result;\n }\n\n result.changed = true;\n log?.info(\"scrub-transcript: repaired poisoned transcript\", {\n filePath,\n corrected: result.corrected,\n stubbed: result.stubbed,\n cacheStripped: result.cacheStripped,\n });\n return result;\n}\n","import { type ChildProcess, spawn } from \"node:child_process\";\nimport { join } from \"node:path\";\nimport { fsDeadlineMs, withFsDeadline } from \"@skaile/workspaces/core\";\nimport { resolveAgentExec } from \"./agent-exec.js\";\nimport { localTranscriptStore, type TranscriptStore } from \"./drivers/scrub-transcript.js\";\n\n/**\n * Transcripts reached through the agent launch shim.\n *\n * With the uid split on, the Claude CLI runs as the agent uid and creates its\n * transcripts 0600 in 0700 dirs, so the runner can no longer list, read or\n * rewrite them itself. This store runs plain tools (`find`, `cat`, `sh`, `mv`)\n * as the agent uid through the shim instead. The child gets only `PATH` and\n * `LC_ALL`, never the runner's environment, and runs in `/` because the\n * runner's own cwd may not be enterable by the agent uid.\n */\nexport function agentTranscriptStore(shim: string): TranscriptStore {\n // A replace the scrub's deadline abandoned keeps running; discardTemp stops\n // it before removing its temp file.\n const inFlight = new Map<string, ChildProcess>();\n // Paths whose rewrite discardTemp gave up on: their rename must never run.\n const cancelled = new Set<string>();\n const track = (filePath: string, child: ChildProcess) => {\n inFlight.set(filePath, child);\n child.once(\"close\", () => {\n if (inFlight.get(filePath) === child) inFlight.delete(filePath);\n });\n };\n return {\n async locate(configDir, sessionId, timeoutMs = 10_000) {\n // A session id is a UUID; anything glob- or path-shaped is not ours.\n if (!/^[A-Za-z0-9._-]+$/.test(sessionId)) return null;\n const projectsDir = join(configDir, \"projects\");\n // Markers on stdout, not exit codes, carry the answer: a shim or launcher\n // failure has exit codes of its own and must never read as \"not found\".\n const { stdout } = await collect(\n runAsAgent(shim, [\n \"sh\",\n \"-c\",\n '[ -d \"$1\" ] || { echo \"@@no-projects\"; exit 0; }; ' +\n 'find \"$1\" -mindepth 2 -maxdepth 2 -type f -name \"$2\" -print -quit; echo \"@@find:$?\"',\n \"sh\",\n projectsDir,\n `${sessionId}.jsonl`,\n ]),\n timeoutMs,\n );\n const lines = stdout.split(\"\\n\").map((l) => l.trim());\n // A missing projects/ is the same \"not found\" as a failed readdir locally.\n if (lines.includes(\"@@no-projects\")) return null;\n const status = lines.find((l) => l.startsWith(\"@@find:\"));\n if (status === undefined)\n throw new Error(\"locating a transcript as the agent uid failed (no answer from the shim)\");\n // A path find printed counts even if it later hit an unreadable sibling.\n const found = lines.find((l) => l.startsWith(\"/\"));\n if (found) return found;\n if (status !== \"@@find:0\")\n throw new Error(`locating a transcript as the agent uid failed (${status.slice(2)})`);\n return null;\n },\n\n async *read(filePath) {\n const child = runAsAgent(shim, [\"cat\", \"--\", filePath]);\n const exited = exitOf(child);\n exited.catch(() => {}); // awaited below; this only stops an unhandled rejection\n const stderr = drain(child);\n child.stdout?.setEncoding(\"utf8\");\n for await (const chunk of child.stdout as AsyncIterable<string>) yield chunk;\n const code = await exited;\n if (code !== 0)\n throw new Error(`reading ${filePath} as the agent uid failed: ${await stderr}`);\n },\n\n async replace(filePath, chunks) {\n const child = runAsAgent(shim, [\n \"sh\",\n \"-c\",\n // 0600 like the CLI's own files. Only writes the temp file: the rename\n // is a separate step below, run only after the input was fully sent,\n // so a killed or starved writer can never commit a partial transcript.\n 'umask 077; cat > \"$1.scrub-tmp\"',\n \"sh\",\n filePath,\n ]);\n cancelled.delete(filePath);\n track(filePath, child);\n const exited = exitOf(child);\n exited.catch(() => {}); // awaited below; this only stops an unhandled rejection\n const stderr = drain(child);\n const stdin = child.stdin;\n if (!stdin) throw new Error(\"agent shim has no stdin\");\n // A child that dies early surfaces through its exit code, not an EPIPE crash.\n stdin.on(\"error\", () => {});\n const gone = exited.then(\n () => undefined,\n () => undefined,\n );\n // Stop pulling input as soon as the child is gone (killed by discardTemp,\n // or failed), instead of waiting on a producer that may never resume.\n const input = chunks[Symbol.asyncIterator]();\n let drained = false;\n try {\n for (;;) {\n const next = await Promise.race([\n input.next(),\n gone.then(() => ({ dead: true as const })),\n ]);\n if (\"dead\" in next || stdin.destroyed) break;\n if (next.done) {\n drained = true;\n break;\n }\n if (!stdin.write(next.value)) {\n await Promise.race([new Promise((resolve) => stdin.once(\"drain\", resolve)), gone]);\n }\n }\n } finally {\n stdin.end();\n // Close the producer too, so the reader feeding it (a `cat` through\n // the shim) is torn down rather than left blocked on a full pipe.\n if (!drained) void input.return?.()?.catch(() => {});\n }\n const code = await exited;\n if (code !== 0 || !drained)\n throw new Error(`rewriting ${filePath} as the agent uid failed: ${await stderr}`);\n if (cancelled.has(filePath)) throw new Error(`rewrite of ${filePath} was abandoned`);\n const mover = runAsAgent(shim, [\"mv\", \"-f\", \"--\", `${filePath}.scrub-tmp`, filePath]);\n track(filePath, mover);\n const moved = await collect(mover, 10_000);\n if (moved.code !== 0) throw new Error(`renaming the rewritten ${filePath} failed`);\n },\n\n async discardTemp(filePath) {\n // Before anything else, so a writer that is just finishing never renames.\n cancelled.add(filePath);\n const pending = inFlight.get(filePath);\n if (pending && pending.exitCode === null && pending.signalCode === null) {\n // The writer cannot commit (the rename is a separate step), so this only\n // stops it; bounded, since a writer stuck on a hung mount may never die.\n const closed = new Promise((resolve) => pending.once(\"close\", resolve));\n pending.kill(\"SIGKILL\");\n await withFsDeadline(`stop the rewrite of ${filePath}`, () => closed, fsDeadlineMs());\n }\n await collect(runAsAgent(shim, [\"rm\", \"-f\", \"--\", `${filePath}.scrub-tmp`]), 10_000);\n },\n };\n}\n\n/**\n * The transcript store for this runner: through the agent shim when\n * `SKAILE_AGENT_EXEC` is set, the runner's own filesystem otherwise.\n */\nexport function transcriptStoreForRuntime(\n env: Record<string, string | undefined> = process.env,\n): TranscriptStore {\n const shim = resolveAgentExec(env);\n return shim ? agentTranscriptStore(shim) : localTranscriptStore;\n}\n\nfunction runAsAgent(shim: string, argv: string[]): ChildProcess {\n return spawn(shim, [\"--\", ...argv], {\n cwd: \"/\",\n env: { PATH: process.env.PATH ?? \"/usr/bin:/bin\", LC_ALL: \"C\" },\n stdio: [\"pipe\", \"pipe\", \"pipe\"],\n });\n}\n\nfunction exitOf(child: ChildProcess): Promise<number> {\n return new Promise((resolve, reject) => {\n child.once(\"error\", reject);\n child.once(\"close\", (code) => resolve(code ?? 1));\n });\n}\n\n/** Keep the last 1 KiB of stderr for the error message, and keep the pipe drained. */\nfunction drain(child: ChildProcess): Promise<string> {\n return new Promise((resolve) => {\n let tail = \"\";\n child.stderr?.setEncoding(\"utf8\");\n child.stderr?.on(\"data\", (c: string) => {\n tail = (tail + c).slice(-1024);\n });\n child.stderr?.once(\"close\", () => resolve(tail.trim()));\n });\n}\n\nasync function collect(\n child: ChildProcess,\n timeoutMs: number,\n): Promise<{ code: number; stdout: string }> {\n let stdout = \"\";\n child.stdout?.setEncoding(\"utf8\");\n child.stdout?.on(\"data\", (c: string) => {\n stdout += c;\n });\n void drain(child);\n child.stdin?.end();\n let timer: NodeJS.Timeout | undefined;\n try {\n const code = await Promise.race([\n exitOf(child),\n new Promise<never>((_, reject) => {\n timer = setTimeout(() => {\n child.kill(\"SIGKILL\");\n reject(new Error(`agent shim did not answer within ${timeoutMs} ms`));\n }, timeoutMs);\n }),\n ]);\n return { code, stdout };\n } finally {\n clearTimeout(timer);\n }\n}\n","/**\n * Pre-first-turn resume probe for the Claude Agent SDK driver.\n *\n * A tier-1 native resume only hands its session id to the SDK inside the first\n * real turn, so the `jsonl_lost` outcome (\"No conversation found\") is invisible\n * until a turn is consumed. The runner shares the container filesystem with the\n * SDK, so a cheap `stat` of the on-disk JSONL transcript is an authoritative,\n * side-effect-free signal of whether the resume will find its history — no\n * probe query, no spurious model turn.\n *\n * @module\n */\n\nimport { homedir } from \"node:os\";\nimport { join } from \"node:path\";\nimport { withFsDeadline } from \"@skaile/workspaces/core\";\nimport { locateTranscriptPath } from \"./scrub-transcript.js\";\n\n/**\n * Overall wall-clock budget for the probe. Deliberately a small fraction of the\n * platform's `session_init_ack` timeout (`DEFAULT_INIT_ACK_TIMEOUT_MS`, 15s):\n * the probe runs synchronously on the pre-ack path, so a wedged\n * `CLAUDE_CONFIG_DIR` mount must never push the ack past its deadline.\n */\nconst RESUME_PROBE_TIMEOUT_MS = 2_000;\n\n/**\n * Outcome of {@link probeResumeTranscript}: whether the SDK transcript for a\n * requested tier-1 resume exists on disk.\n *\n * @category Resume probe\n */\nexport type ResumeProbeOutcome = \"transcript_found\" | \"jsonl_lost\";\n\n/**\n * Resolve the Claude Code config directory — the parent of `projects/` — from\n * an explicit env map, the process environment, or the `~/.claude` default.\n *\n * The runner's probe and the claude-sdk driver share this one resolver, so they\n * agree as long as they see the same `CLAUDE_CONFIG_DIR`. Today they do:\n * `CLAUDE_CONFIG_DIR` is container-scoped and neither side threads a per-session\n * override through `config.env`, so both fall through to `process.env`. If a\n * future change ever set the driver's `config.env.CLAUDE_CONFIG_DIR` to a\n * divergent path, the reactive `resume_failed { jsonl_lost }` turn remains the\n * safety net.\n *\n * @category Resume probe\n */\nexport function resolveClaudeConfigDir(env?: Record<string, string | undefined>): string {\n return env?.CLAUDE_CONFIG_DIR || process.env.CLAUDE_CONFIG_DIR || join(homedir(), \".claude\");\n}\n\n/**\n * Probe whether the SDK JSONL transcript for `sessionId` exists on disk.\n *\n * Non-null locator result → `transcript_found`; null → `jsonl_lost`;\n * `undefined` → outcome unknown (the probe exceeded its budget or errored). The\n * caller leaves the ack field ABSENT on `undefined` so the reactive\n * `resume_failed { jsonl_lost }` turn stays the safety net — a timed-out probe\n * must never masquerade as a genuine `jsonl_lost` and force a needless downgrade.\n *\n * `opts.timeoutMs` overrides {@link RESUME_PROBE_TIMEOUT_MS}; `opts.locate`\n * overrides the transcript locator (used by tests / alternate stores).\n *\n * @category Resume probe\n */\nexport async function probeResumeTranscript(\n sessionId: string,\n opts?: {\n env?: Record<string, string | undefined>;\n timeoutMs?: number;\n locate?: (configDir: string, sessionId: string) => Promise<string | null>;\n },\n): Promise<ResumeProbeOutcome | undefined> {\n const configDir = resolveClaudeConfigDir(opts?.env);\n const timeoutMs = opts?.timeoutMs ?? RESUME_PROBE_TIMEOUT_MS;\n const locate = opts?.locate ?? locateTranscriptPath;\n try {\n // Bound the whole probe on wall-clock and THROW on expiry: the inner per-op\n // deadline swallows a timeout into a null path (a false `jsonl_lost`), so a\n // wedged mount must yield \"unknown\" here rather than a spurious downgrade.\n const filePath = await withFsDeadline(\n `resume-probe ${sessionId}`,\n () => locate(configDir, sessionId),\n timeoutMs,\n );\n return filePath ? \"transcript_found\" : \"jsonl_lost\";\n } catch {\n return undefined;\n }\n}\n"]}
1
+ {"version":3,"sources":["../bridge/src/cloud.ts","../bridge/src/drivers/scrub-transcript.ts","../bridge/src/agent-transcript.ts","../bridge/src/drivers/resume-probe.ts"],"names":["join"],"mappings":";;;;;;;;;;;AAuCA,IAAM,iBAAA,GAAoB,CAAC,mBAAA,EAAqB,sBAAA,EAAwB,oBAAoB,CAAA;AAQrF,IAAM,0BAAA,GAA6B;AAQ1C,IAAM,iBAAA,GAA0C;AAAA,EAC9C,mBAAA,EAAqB,IAAA;AAAA,EACrB,aAAA,EAAe,IAAA;AAAA,EACf,WAAA,EAAa;AACf,CAAA;AAcO,SAAS,mBAAmB,KAAA,EAA4C;AAC7E,EAAA,MAAM,UAAW,KAAA,CAA6B,OAAA;AAC9C,EAAA,MAAM,SAAA,GAA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K,CAAA;AAAA,EACpB;AACF;AC5LA,IAAM,uBAAA,GAA0B,GAAA;AAwBzB,SAAS,uBAAuB,GAAA,EAAkD;AACvF,EAAA,OAAO,GAAA,EAAK,qBAAqB,OAAA,CAAQ,GAAA,CAAI,qBAAqBA,IAAAA,CAAK,OAAA,IAAW,SAAS,CAAA;AAC7F;AAgBA,eAAsB,qBAAA,CACpB,WACA,IAAA,EAKyC;AACzC,EAAA,MAAM,SAAA,GAAY,sBAAA,CAAuB,IAAA,EAAM,GAAG,CAAA;AAClD,EAAA,MAAM,SAAA,GAAY,MAAM,SAAA,IAAa,uBAAA;AACrC,EAAA,MAAM,MAAA,GAAS,MAAM,MAAA,IAAU,oBAAA;AAC/B,EAAA,IAAI;AAIF,IAAA,MAAM,WAAW,MAAM,cAAA;AAAA,MACrB,gBAAgB,SAAS,CAAA,CAAA;AAAA,MACzB,MAAM,MAAA,CAAO,SAAA,EAAW,SAAS,CAAA;AAAA,MACjC;AAAA,KACF;AACA,IAAA,OAAO,WAAW,kBAAA,GAAqB,YAAA;AAAA,EACzC,CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,MAAA;AAAA,EACT;AACF","file":"chunk-TVOODIZE.js","sourcesContent":["/**\n * AI endpoint transport for the `claude-sdk` driver — the Claude Agent SDK's\n * child-process environment.\n *\n * {@link buildClaudeEndpointEnv} takes an **AI provider registry entry** and\n * is what the driver calls, on every transport. It is plan §2.3's\n * `buildEndpointEnv` for the claude-sdk row (named for the driver because the\n * vars it emits — `CLAUDE_CODE_USE_*`, `ANTHROPIC_*` — are the Claude Agent\n * SDK's own contract, not a portable one).\n *\n * A registry entry says what the deleted `cloud` axis said — Amazon Bedrock,\n * Google Vertex AI, Azure AI Foundry, a generic gateway — with `surface` +\n * `transport` + `base_url` + `credential`, and says it for the direct\n * endpoint too, which the `cloud` axis could not address at all.\n *\n * Cross-repo contract: env key names and semantics here are load-bearing —\n * the platform resolves credential bundles against the same key set.\n */\n\nimport {\n type AIProviderEntry,\n type AIProviderLlmEntry,\n entryTransport,\n normalizeAnthropicBaseUrl,\n resolveEntryBaseUrl,\n} from \"@skaile/workspaces/core/provider-registry\";\n\n/**\n * Env vars scrubbed from the inherited environment before an endpoint env is\n * assembled. Ambient first-party credentials or a stale `CLAUDE_CODE_USE_*`\n * flag must never leak into a session whose entry points elsewhere (the\n * ambient carriers are restored explicitly when the entry has none of its\n * own).\n *\n * Deliberately NOT exhaustive: ambient transport-specific vars (AWS_*,\n * GOOGLE_*, ANTHROPIC_VERTEX_PROJECT_ID, ANTHROPIC_FOUNDRY_*) survive so a\n * standalone CLI inherits its own signing chain; the SDK ignores vars whose\n * transport flag is unset.\n */\nconst SCRUBBED_ENV_KEYS = [\"ANTHROPIC_API_KEY\", \"ANTHROPIC_AUTH_TOKEN\", \"ANTHROPIC_BASE_URL\"];\n\n/**\n * The Anthropic first-party endpoint. An entry that resolves to exactly this\n * host needs no `ANTHROPIC_BASE_URL`: the SDK already points there, and an\n * explicit value would make every default session look like a third-party\n * redirect to Claude Code's own telemetry and auth heuristics.\n */\nexport const ANTHROPIC_DEFAULT_BASE_URL = \"https://api.anthropic.com\";\n\n/**\n * Headers the SDK owns and an entry must not restate through\n * `ANTHROPIC_CUSTOM_HEADERS`: the protocol version it was built against, and\n * the two credential carriers (which are `credential.ref`'s job — a literal\n * secret in `headers` is a validation error anyway).\n */\nconst SDK_OWNED_HEADERS: Record<string, true> = {\n \"anthropic-version\": true,\n authorization: true,\n \"x-api-key\": true,\n};\n\n/**\n * Which of the Claude Agent SDK's four native transports an entry addresses.\n *\n * The SDK has no `transport` field: it switches on a `CLAUDE_CODE_USE_*` flag.\n * Bedrock and Vertex are their own wire surfaces, so they are recognized by\n * `surface` as well as by `transport` — a legacy-derived entry that had no\n * region (and therefore no `params`, and therefore no `transport`) is still a\n * Bedrock session, exactly as it was before the registry existed.\n */\nexport type ClaudeEndpointMode = \"anthropic\" | \"bedrock\" | \"vertex\" | \"foundry\";\n\n/** Classify a registry entry into its {@link ClaudeEndpointMode}. */\nexport function claudeEndpointMode(entry: AIProviderEntry): ClaudeEndpointMode {\n const surface = (entry as AIProviderLlmEntry).surface;\n const transport = entryTransport(entry);\n if (surface === \"bedrock-converse-stream\" || transport === \"bedrock\") return \"bedrock\";\n if (surface === \"google-vertex\" || transport === \"vertex\") return \"vertex\";\n if (transport === \"foundry\") return \"foundry\";\n return \"anthropic\";\n}\n\n/** Arguments for {@link buildClaudeEndpointEnv}. */\nexport interface ClaudeEndpointEnvInput {\n /** The selected registry entry — the whole endpoint definition. */\n entry: AIProviderEntry;\n /**\n * The entry's credential, already resolved from its `credential.ref`\n * (`resolveEntryCredential`). Absent for `kind: none`, for an ambient\n * `sigv4` / `google_adc` / `azure_entra` chain, for `oauth` (whose blob the\n * runner writes to the Claude credentials file, never to the env), and for a\n * reference that did not resolve.\n */\n credential?: string;\n /**\n * The driver's base environment — `process.env` with `undefined` dropped.\n * The endpoint vars are layered **on top** of it, never instead of it, so\n * `PATH`, `HOME` and `SKAILE_SESSION_ID` reach the child.\n */\n baseEnv: Record<string, string>;\n /** `AgentConfig.env` plus any credential material the session carried. */\n configEnv?: Record<string, string>;\n}\n\n/**\n * Assemble the Claude Agent SDK child env for one registry entry (plan §2.3).\n *\n * Pure (no external state read, no input mutated). Starts from `baseEnv`\n * merged with `configEnv`, scrubs the inherited Anthropic credential/routing\n * vars and every `CLAUDE_CODE_USE_*` flag, then writes exactly what the entry\n * describes: at most one transport flag, the endpoint, and the credential in\n * the carrier its `kind` names.\n *\n * Credential kinds (§1.4): `api_key_header` → `ANTHROPIC_API_KEY` (the SDK\n * sends it as `x-api-key`); `bearer` → `ANTHROPIC_AUTH_TOKEN` (sent as\n * `Authorization: Bearer`); `sigv4` / `google_adc` / `azure_entra` emit\n * nothing and let the AWS/Google/Azure chain sign — which is why the scrub\n * deliberately spares ambient `AWS_*` / `GOOGLE_*` values; `oauth` and `none`\n * emit nothing, and the pre-scrub ambient carriers are restored so an OAuth or\n * shell-configured session keeps the auth it had.\n *\n * Never returns `undefined` or empty values; absent settings are omitted.\n */\nexport function buildClaudeEndpointEnv(args: ClaudeEndpointEnvInput): Record<string, string> {\n const { entry, credential, baseEnv, configEnv } = args;\n const env: Record<string, string> = { ...baseEnv, ...(configEnv ?? {}) };\n\n // Captured before the scrub — an entry with no credential material of its\n // own falls back to these, the way the gateway branch always has.\n const ambient = { authToken: env.ANTHROPIC_AUTH_TOKEN, apiKey: env.ANTHROPIC_API_KEY };\n\n for (const key of Object.keys(env)) {\n if (SCRUBBED_ENV_KEYS.includes(key) || key.startsWith(\"CLAUDE_CODE_USE_\")) {\n delete env[key];\n }\n }\n\n const set = (key: string, value: string | undefined) => {\n // Falsy check is deliberate: an empty-string credential/setting is never\n // valid env — dropping it beats shipping a key the SDK treats as set.\n if (value) env[key] = value;\n };\n\n const kind = entry.credential?.kind ?? \"none\";\n const params = (entry as AIProviderLlmEntry).params as Record<string, string> | undefined;\n\n // Static headers ride as ANTHROPIC_CUSTOM_HEADERS (`Name: Value` per line),\n // the only channel the SDK offers. An entry with none leaves an ambient\n // value alone.\n const headers = Object.entries(entry.headers ?? {}).filter(\n ([name]) => !SDK_OWNED_HEADERS[name.toLowerCase()],\n );\n if (headers.length > 0) {\n env.ANTHROPIC_CUSTOM_HEADERS = headers.map(([name, value]) => `${name}: ${value}`).join(\"\\n\");\n }\n\n switch (claudeEndpointMode(entry)) {\n case \"bedrock\": {\n env.CLAUDE_CODE_USE_BEDROCK = \"1\";\n // The AWS credential bundle itself is `configEnv` material (AWS_*), and\n // ambient AWS_* survived the scrub, so a standalone CLI keeps its own.\n set(\"AWS_REGION\", params?.region);\n break;\n }\n case \"vertex\": {\n env.CLAUDE_CODE_USE_VERTEX = \"1\";\n // GOOGLE_APPLICATION_CREDENTIALS is a path the runner materialized; it\n // arrives through `configEnv` or ambient, never from `credential`.\n set(\"ANTHROPIC_VERTEX_PROJECT_ID\", params?.project);\n set(\"CLOUD_ML_REGION\", params?.location);\n break;\n }\n case \"foundry\": {\n env.CLAUDE_CODE_USE_FOUNDRY = \"1\";\n // §1.3: an explicit `base_url` wins over the resource-derived endpoint,\n // and the SDK has a separate var for each form.\n if (entry.base_url) set(\"ANTHROPIC_FOUNDRY_BASE_URL\", entry.base_url);\n else set(\"ANTHROPIC_FOUNDRY_RESOURCE\", params?.resource);\n set(\"ANTHROPIC_FOUNDRY_API_KEY\", credential);\n break;\n }\n case \"anthropic\": {\n const baseUrl = normalizeAnthropicBaseUrl(resolveEntryBaseUrl(entry));\n if (baseUrl && baseUrl.toLowerCase() !== ANTHROPIC_DEFAULT_BASE_URL) {\n env.ANTHROPIC_BASE_URL = baseUrl;\n }\n if (kind === \"bearer\") set(\"ANTHROPIC_AUTH_TOKEN\", credential);\n else if (kind === \"api_key_header\") set(\"ANTHROPIC_API_KEY\", credential);\n if (!credential) {\n // `oauth` / `none` / an unresolved ref: the ambient carriers are the\n // only auth this session has, and the scrub just removed them.\n if (ambient.authToken) env.ANTHROPIC_AUTH_TOKEN = ambient.authToken;\n else set(\"ANTHROPIC_API_KEY\", ambient.apiKey);\n }\n break;\n }\n }\n\n return env;\n}\n","/**\n * Poisoned-transcript repair for the Claude Agent SDK driver.\n *\n * The Anthropic Messages API can permanently reject a conversation once its\n * persisted history contains a malformed content block. Because the bad block\n * lives in the SDK's on-disk JSONL transcript, every replayed turn fails with\n * the same `400 invalid_request_error` and the session is bricked with no\n * in-band recovery.\n *\n * This module repairs the transcript in place, covering three known poison\n * classes:\n *\n * 1. **Image `media_type` mismatch / omission.** An image block whose declared\n * `media_type` does not match — or is missing for — the actual bytes:\n * `... The image was specified using the image/png media type, but the\n * image appears to be a image/jpeg image`. Produced by the Claude Code\n * `Read` tool's format fallback (anthropics/claude-code#55338, #30124,\n * #33179). Repaired by sniffing the base64 magic bytes and correcting\n * `media_type`.\n * 2. **Oversized image.** An image whose decoded payload exceeds the API's\n * 5 MB per-image limit (anthropics/claude-code#34566). Replaced with a\n * text stub — the byte budget cannot be recovered any other way.\n * 3. **`cache_control` on an empty text block.** A text block carrying a\n * `cache_control` marker with empty/whitespace `text`\n * (anthropics/claude-code#59626). The `cache_control` field is stripped.\n *\n * Genuinely unidentifiable image blocks are also replaced with a text stub.\n *\n * Recovering by content scan (rather than parsing the API's `messages.N`\n * index) is deliberate: the index addresses the assembled API request, not a\n * JSONL line, and reproducing the SDK's message-assembly is fragile. A full\n * scan is index-free and repairs every poisoned block in one pass.\n *\n * **Async and line-streaming since #454.** A Claude Code transcript is routinely\n * multi-megabyte (base64 images inline in `tool_result` blocks), and this runs on\n * a failed turn *and before every resume* — inside the single-threaded `skaile\n * serve` loop. The previous `readFileSync` + `writeFileSync` + `renameSync` held\n * the loop for the whole file and materialised it twice over as one string. Both\n * passes now stream line by line off a `createReadStream`, so the loop is yielded\n * between lines and peak memory is one JSONL line rather than the whole file, and\n * every I/O phase is deadline-bounded.\n *\n * Streaming was chosen over a worker thread: the work is I/O-bound rather than\n * CPU-bound (per-line `JSON.parse` on a yielded loop is not what stalls a turn),\n * and a worker would add a structured-clone of the same multi-MB payload plus a\n * thread lifecycle to a path that must never block a turn.\n *\n * @module\n */\n\nimport { createReadStream, createWriteStream } from \"node:fs\";\nimport { readdir, rename, stat, unlink } from \"node:fs/promises\";\nimport { join } from \"node:path\";\nimport { pipeline } from \"node:stream/promises\";\nimport { fsDeadlineMs, tryWithFsDeadline, withFsDeadline } from \"@skaile/workspaces/core\";\n\n/**\n * Minimal logger shape accepted by {@link scrubPoisonedTranscript}. Compatible\n * with the bridge `Logger`, but narrowed so the helper stays unit-testable\n * without a real logger instance.\n *\n * @category Transcript repair\n */\nexport interface ScrubLogger {\n info(message: string, data?: Record<string, unknown>): void;\n warn(message: string, data?: Record<string, unknown>): void;\n}\n\n/**\n * Options for {@link scrubPoisonedTranscript}.\n *\n * @category Transcript repair\n */\nexport interface ScrubTranscriptOptions {\n /**\n * Claude Code config directory — the parent of `projects/`. Resolve from\n * `CLAUDE_CONFIG_DIR`, falling back to `~/.claude`.\n */\n configDir: string;\n /** SDK session id whose transcript JSONL should be repaired. */\n sessionId: string;\n /** Optional logger for diagnostics. */\n log?: ScrubLogger;\n /**\n * Where the transcript is read and written. Defaults to this process's own\n * filesystem access ({@link localTranscriptStore}); with the agent uid split\n * the transcript belongs to the agent uid and must be reached through it.\n */\n store?: TranscriptStore;\n}\n\n/**\n * Filesystem access to Claude Code transcripts. The CLI creates them 0600 in\n * 0700 dirs, so when it runs as a different uid than the runner, only that uid\n * can locate, read or rewrite them (see `agent-transcript.ts`).\n *\n * @category Transcript repair\n */\nexport interface TranscriptStore {\n /** Path of `<sessionId>.jsonl` under `<configDir>/projects/`, or `null` when absent. */\n locate(configDir: string, sessionId: string, timeoutMs?: number): Promise<string | null>;\n /** The file's contents as UTF-8 chunks. */\n read(filePath: string): AsyncIterable<string>;\n /** Atomically replace the file with `chunks` via a `.scrub-tmp` sibling. */\n replace(filePath: string, chunks: AsyncIterable<string>): Promise<void>;\n /** Remove the sibling a failed or abandoned {@link replace} left (best effort). */\n discardTemp(filePath: string): Promise<void>;\n}\n\n/**\n * Outcome of a {@link scrubPoisonedTranscript} pass.\n *\n * @category Transcript repair\n */\nexport interface ScrubTranscriptResult {\n /** The located JSONL transcript path, or `null` when not found. */\n filePath: string | null;\n /** Image blocks whose `media_type` was corrected (or filled in) to match the bytes. */\n corrected: number;\n /**\n * Image blocks replaced with a text stub — either unidentifiable bytes or a\n * payload over the API's 5 MB per-image limit.\n */\n stubbed: number;\n /** Empty text blocks from which a rejected `cache_control` marker was stripped. */\n cacheStripped: number;\n /**\n * `true` when the transcript was located, contained at least one poisoned\n * block, and was rewritten. `false` means nothing needed repair (or the\n * file was not found) — the caller should not retry the resume.\n */\n changed: boolean;\n}\n\n/** Text inserted in place of an image block whose format cannot be identified. */\nconst STUB_TEXT = \"[image removed: unprocessable image data]\";\n\n/** Text inserted in place of an image block that exceeds the API size limit. */\nconst STUB_TEXT_OVERSIZED = \"[image removed: image too large]\";\n\n/**\n * The Anthropic Messages API rejects any single image whose decoded payload\n * exceeds 5 MB. An image at or under this is left alone; a larger one is\n * stubbed (its byte budget cannot be recovered).\n */\nconst MAX_IMAGE_BYTES = 5 * 1024 * 1024;\n\n/**\n * Identify an image's media type from the leading bytes of its base64 payload.\n *\n * Recognises the four formats the Anthropic API accepts. Returns `null` when\n * the magic bytes match no known format — the caller treats that as a\n * genuinely corrupt block and stubs it.\n *\n * @param base64 - Base64-encoded image data (only the prefix is inspected).\n * @returns An `image/*` media type, or `null` when unrecognised.\n * @category Transcript repair\n */\nexport function sniffImageMediaType(base64: string): string | null {\n let buf: Buffer;\n try {\n // 32 base64 chars decode to 24 bytes — enough for the WebP check at 12.\n buf = Buffer.from(base64.slice(0, 32), \"base64\");\n } catch {\n return null;\n }\n if (buf.length < 4) {\n return null;\n }\n // JPEG — SOI marker `FF D8`. Third byte varies (and may be corrupt), so a\n // two-byte check is intentional: it still matches malformed JPEGs, which is\n // exactly the poison case the API flags as \"appears to be image/jpeg\".\n if (buf[0] === 0xff && buf[1] === 0xd8) {\n return \"image/jpeg\";\n }\n // PNG — `89 50 4E 47`.\n if (buf[0] === 0x89 && buf[1] === 0x50 && buf[2] === 0x4e && buf[3] === 0x47) {\n return \"image/png\";\n }\n // GIF — `47 49 46 38` (\"GIF8\").\n if (buf[0] === 0x47 && buf[1] === 0x49 && buf[2] === 0x46 && buf[3] === 0x38) {\n return \"image/gif\";\n }\n // WebP — `RIFF` at 0..3 and `WEBP` at 8..11.\n if (\n buf.length >= 12 &&\n buf[0] === 0x52 &&\n buf[1] === 0x49 &&\n buf[2] === 0x46 &&\n buf[3] === 0x46 &&\n buf[8] === 0x57 &&\n buf[9] === 0x45 &&\n buf[10] === 0x42 &&\n buf[11] === 0x50\n ) {\n return \"image/webp\";\n }\n return null;\n}\n\n/** A base64 image source on a content block (shape is SDK-defined). */\ninterface Base64ImageSource {\n type?: string;\n media_type?: string;\n data?: string;\n}\n\n/** Loosely-typed content block from a transcript message. */\ninterface ContentBlockLike {\n type?: string;\n source?: Base64ImageSource;\n content?: unknown;\n [k: string]: unknown;\n}\n\n/** Mutable counters threaded through one scrub pass. */\ninterface ScrubCounters {\n corrected: number;\n stubbed: number;\n cacheStripped: number;\n}\n\n/** Total repairs recorded in a counter set — used to detect per-line changes. */\nfunction totalChanges(c: ScrubCounters): number {\n return c.corrected + c.stubbed + c.cacheStripped;\n}\n\n/**\n * Repair a single content block. Returns the (possibly replaced) block.\n *\n * - A `tool_result` block recurses into its `content` array.\n * - A text block carrying a `cache_control` marker whose `text` is empty or\n * whitespace has the marker stripped (the API rejects `cache_control` on\n * empty text blocks).\n * - An image block whose decoded payload exceeds the API's 5 MB limit is\n * replaced with a text stub.\n * - An image block whose bytes match no known format is replaced with a text\n * stub (an image cannot simply be dropped — a `tool_result` must keep at\n * least one content entry, and a bare `image` block is replaced 1:1).\n * - An image block whose declared `media_type` mismatches (or is missing for)\n * the sniffed type is corrected in place.\n * - Every other block is returned untouched.\n */\nfunction scrubBlock(block: ContentBlockLike, counters: ScrubCounters): ContentBlockLike {\n if (block.type === \"tool_result\" && Array.isArray(block.content)) {\n return {\n ...block,\n content: (block.content as ContentBlockLike[]).map((inner) => scrubBlock(inner, counters)),\n };\n }\n\n // A `cache_control` marker on a text block whose text is empty or whitespace\n // is rejected by the API (\"cache_control cannot be set for empty text\n // blocks\"). Strip the marker — the empty block itself is harmless.\n if (block.type === \"text\" && block.cache_control != null) {\n const text = typeof block.text === \"string\" ? block.text : \"\";\n if (text.trim() === \"\") {\n counters.cacheStripped++;\n const clone = { ...block };\n delete clone.cache_control;\n return clone;\n }\n }\n\n if (\n block.type === \"image\" &&\n block.source?.type === \"base64\" &&\n typeof block.source.data === \"string\"\n ) {\n const data = block.source.data;\n // The API rejects any image whose decoded payload exceeds 5 MB. The byte\n // budget cannot be salvaged, so the whole block becomes a text stub.\n // base64 encodes 3 bytes per 4 chars, so decoded length ≈ len * 3 / 4.\n if (Math.floor((data.length * 3) / 4) > MAX_IMAGE_BYTES) {\n counters.stubbed++;\n return { type: \"text\", text: STUB_TEXT_OVERSIZED };\n }\n const sniffed = sniffImageMediaType(data);\n if (sniffed === null) {\n counters.stubbed++;\n return { type: \"text\", text: STUB_TEXT };\n }\n if (sniffed !== block.source.media_type) {\n counters.corrected++;\n return { ...block, source: { ...block.source, media_type: sniffed } };\n }\n }\n\n return block;\n}\n\n/**\n * Locate the JSONL transcript for `sessionId` under `<configDir>/projects/`.\n *\n * Claude Code encodes the project directory into the `projects/` subfolder\n * name; rather than reproduce that encoding, this scans every subfolder for\n * `<sessionId>.jsonl` (the session id is a UUID — globally unique).\n *\n * Async and deadline-bounded since #454. The `existsSync(projectsDir)` probe is\n * gone: `readdir` already fails on a missing directory, so the probe was a\n * second stat on the same path for no information.\n *\n * `timeoutMs` defaults to {@link fsDeadlineMs} so callers that only need the\n * path (the resume probe) can omit it.\n *\n * @category Transcript repair\n */\nexport async function locateTranscriptPath(\n configDir: string,\n sessionId: string,\n timeoutMs: number = fsDeadlineMs(),\n): Promise<string | null> {\n const projectsDir = join(configDir, \"projects\");\n const entries = await tryWithFsDeadline(\n `readdir ${projectsDir}`,\n () => readdir(projectsDir),\n null,\n timeoutMs,\n );\n if (!entries) return null;\n for (const entry of entries) {\n const candidate = join(projectsDir, entry, `${sessionId}.jsonl`);\n const found = await tryWithFsDeadline(\n `stat ${candidate}`,\n async () => (await stat(candidate)).isFile(),\n false,\n timeoutMs,\n );\n if (found) return candidate;\n }\n return null;\n}\n\n/**\n * Yield a file's contents line by line, reproducing `readFileSync(...).split(\"\\n\")`\n * exactly — including the final (possibly empty) segment, so a trailing newline\n * survives a rewrite byte for byte.\n *\n * Splits on `\\n` alone, so a line out of a CRLF transcript arrives with its\n * `\\r` still attached. That carrier byte is part of the line here, and\n * {@link repairLine} re-attaches it to a line it rewrites — the file keeps the\n * terminator style it arrived with. Deliberately not `node:readline`:\n * `crlfDelay` strips the `\\r` outright (rewriting a CRLF transcript to LF) and\n * the interface swallows the trailing-newline distinction, either of which\n * would make the \"clean transcript is left byte-for-byte untouched\" guarantee\n * false. Only one line is held in memory at a time, so a multi-MB transcript\n * never materialises as a single string.\n */\nasync function* streamLines(chunks: AsyncIterable<string>): AsyncGenerator<string> {\n let pending = \"\";\n for await (const chunk of chunks) {\n pending += chunk;\n let idx = pending.indexOf(\"\\n\");\n while (idx !== -1) {\n yield pending.slice(0, idx);\n pending = pending.slice(idx + 1);\n idx = pending.indexOf(\"\\n\");\n }\n }\n yield pending;\n}\n\n/**\n * The runner's own filesystem access: the default {@link TranscriptStore}.\n *\n * @category Transcript repair\n */\nexport const localTranscriptStore: TranscriptStore = {\n locate: (configDir, sessionId, timeoutMs) =>\n locateTranscriptPath(configDir, sessionId, timeoutMs),\n async *read(filePath) {\n const stream = createReadStream(filePath, { encoding: \"utf8\" });\n try {\n for await (const chunk of stream) yield chunk as string;\n } finally {\n stream.destroy();\n }\n },\n async replace(filePath, chunks) {\n const tmpPath = `${filePath}.scrub-tmp`;\n await pipeline(chunks, createWriteStream(tmpPath, { encoding: \"utf8\" }));\n await rename(tmpPath, filePath);\n },\n async discardTemp(filePath) {\n const tmpPath = `${filePath}.scrub-tmp`;\n await tryWithFsDeadline(`unlink ${tmpPath}`, () => unlink(tmpPath), undefined, fsDeadlineMs());\n },\n};\n\n/**\n * Repair one JSONL line, returning the (possibly rewritten) line and mutating\n * `counters`. A non-JSON, blank, or content-less line is returned untouched.\n *\n * The reader splits on `\\n` only, so a line from a CRLF transcript still carries\n * its trailing `\\r`. An untouched line is returned verbatim and keeps it; a\n * rewritten one is rebuilt by `JSON.stringify`, which would drop it — leaving a\n * repaired CRLF transcript with mixed line endings. So the terminator is split\n * off before the parse and re-appended to the rewritten line.\n */\nfunction repairLine(line: string, counters: ScrubCounters): string {\n if (line.trim() === \"\") return line;\n const eol = line.endsWith(\"\\r\") ? \"\\r\" : \"\";\n const body = eol === \"\" ? line : line.slice(0, -1);\n let entry: { message?: { content?: unknown } };\n try {\n entry = JSON.parse(body);\n } catch {\n return line; // Not JSON — leave untouched.\n }\n const content = entry.message?.content;\n if (!Array.isArray(content)) return line;\n const before = totalChanges(counters);\n const scrubbed = (content as ContentBlockLike[]).map((block) => scrubBlock(block, counters));\n if (totalChanges(counters) === before) return line; // Nothing changed on this line.\n return `${JSON.stringify({ ...entry, message: { ...entry.message, content: scrubbed } })}${eol}`;\n}\n\n/**\n * Scan a Claude Code SDK transcript for image content blocks whose declared\n * `media_type` does not match the actual bytes, repair them, and atomically\n * rewrite the file.\n *\n * Safe to call after a turn has failed: the SDK query is dead at that point,\n * and the next resume re-reads the transcript from disk.\n *\n * **Async since #454.** Two streaming passes rather than one whole-file read:\n * pass 1 counts repairs without writing anything, and pass 2 runs only when\n * pass 1 found something. The common case — the preventive scrub of a clean\n * transcript before every resume — is therefore one streaming read and zero\n * writes, and a clean transcript is still left byte-for-byte untouched.\n *\n * @param opts - Config directory, session id, and an optional logger.\n * @returns A {@link ScrubTranscriptResult}. When `changed` is `true` the\n * caller may retry the resume with the same session id.\n * @category Transcript repair\n */\nexport async function scrubPoisonedTranscript(\n opts: ScrubTranscriptOptions,\n): Promise<ScrubTranscriptResult> {\n const { configDir, sessionId, log } = opts;\n const store = opts.store ?? localTranscriptStore;\n const timeoutMs = fsDeadlineMs();\n const result: ScrubTranscriptResult = {\n filePath: null,\n corrected: 0,\n stubbed: 0,\n cacheStripped: 0,\n changed: false,\n };\n\n let filePath: string | null;\n try {\n filePath = await store.locate(configDir, sessionId, timeoutMs);\n } catch (err) {\n log?.warn(\"scrub-transcript: failed to locate transcript\", {\n configDir,\n sessionId,\n error: err instanceof Error ? err.message : String(err),\n });\n return result;\n }\n if (!filePath) {\n log?.warn(\"scrub-transcript: no transcript found\", { configDir, sessionId });\n return result;\n }\n result.filePath = filePath;\n\n // ── Pass 1: detect. Streams the transcript, counting repairs, writing nothing.\n const counters: ScrubCounters = { corrected: 0, stubbed: 0, cacheStripped: 0 };\n try {\n await withFsDeadline(\n `scan transcript ${filePath}`,\n async () => {\n for await (const line of streamLines(store.read(filePath))) repairLine(line, counters);\n },\n timeoutMs,\n );\n } catch (err) {\n log?.warn(\"scrub-transcript: failed to read transcript\", {\n filePath,\n error: err instanceof Error ? err.message : String(err),\n });\n return result;\n }\n\n result.corrected = counters.corrected;\n result.stubbed = counters.stubbed;\n result.cacheStripped = counters.cacheStripped;\n\n if (totalChanges(counters) === 0) {\n return result;\n }\n\n // ── Pass 2: rewrite. Atomic: stream a sibling temp file, then rename over the\n // original. Line separators are re-emitted exactly as pass 1 split them, so a\n // trailing newline and any blank lines survive verbatim.\n const source = filePath;\n try {\n await withFsDeadline(\n `rewrite transcript ${source}`,\n async () => {\n const discard: ScrubCounters = { corrected: 0, stubbed: 0, cacheStripped: 0 };\n await store.replace(\n source,\n (async function* () {\n let first = true;\n for await (const line of streamLines(store.read(source))) {\n yield first ? repairLine(line, discard) : `\\n${repairLine(line, discard)}`;\n first = false;\n }\n })(),\n );\n },\n timeoutMs,\n );\n } catch (err) {\n log?.warn(\"scrub-transcript: failed to rewrite transcript\", {\n filePath,\n error: err instanceof Error ? err.message : String(err),\n });\n // Never leave a half-written `.scrub-tmp` in the SDK's projects dir, also\n // when the deadline abandoned the replace mid-write.\n await store.discardTemp(source).catch(() => {});\n return result;\n }\n\n result.changed = true;\n log?.info(\"scrub-transcript: repaired poisoned transcript\", {\n filePath,\n corrected: result.corrected,\n stubbed: result.stubbed,\n cacheStripped: result.cacheStripped,\n });\n return result;\n}\n","import { type ChildProcess, spawn } from \"node:child_process\";\nimport { join } from \"node:path\";\nimport { fsDeadlineMs, withFsDeadline } from \"@skaile/workspaces/core\";\nimport { resolveAgentExec } from \"./agent-exec.js\";\nimport { localTranscriptStore, type TranscriptStore } from \"./drivers/scrub-transcript.js\";\n\n/**\n * Transcripts reached through the agent launch shim.\n *\n * With the uid split on, the Claude CLI runs as the agent uid and creates its\n * transcripts 0600 in 0700 dirs, so the runner can no longer list, read or\n * rewrite them itself. This store runs plain tools (`find`, `cat`, `sh`, `mv`)\n * as the agent uid through the shim instead. The child gets only `PATH` and\n * `LC_ALL`, never the runner's environment, and runs in `/` because the\n * runner's own cwd may not be enterable by the agent uid.\n */\nexport function agentTranscriptStore(shim: string): TranscriptStore {\n // A replace the scrub's deadline abandoned keeps running; discardTemp stops\n // it before removing its temp file.\n const inFlight = new Map<string, ChildProcess>();\n // Paths whose rewrite discardTemp gave up on: their rename must never run.\n const cancelled = new Set<string>();\n const track = (filePath: string, child: ChildProcess) => {\n inFlight.set(filePath, child);\n child.once(\"close\", () => {\n if (inFlight.get(filePath) === child) inFlight.delete(filePath);\n });\n };\n return {\n async locate(configDir, sessionId, timeoutMs = 10_000) {\n // A session id is a UUID; anything glob- or path-shaped is not ours.\n if (!/^[A-Za-z0-9._-]+$/.test(sessionId)) return null;\n const projectsDir = join(configDir, \"projects\");\n // Markers on stdout, not exit codes, carry the answer: a shim or launcher\n // failure has exit codes of its own and must never read as \"not found\".\n const { stdout } = await collect(\n runAsAgent(shim, [\n \"sh\",\n \"-c\",\n '[ -d \"$1\" ] || { echo \"@@no-projects\"; exit 0; }; ' +\n 'find \"$1\" -mindepth 2 -maxdepth 2 -type f -name \"$2\" -print -quit; echo \"@@find:$?\"',\n \"sh\",\n projectsDir,\n `${sessionId}.jsonl`,\n ]),\n timeoutMs,\n );\n const lines = stdout.split(\"\\n\").map((l) => l.trim());\n // A missing projects/ is the same \"not found\" as a failed readdir locally.\n if (lines.includes(\"@@no-projects\")) return null;\n const status = lines.find((l) => l.startsWith(\"@@find:\"));\n if (status === undefined)\n throw new Error(\"locating a transcript as the agent uid failed (no answer from the shim)\");\n // A path find printed counts even if it later hit an unreadable sibling.\n const found = lines.find((l) => l.startsWith(\"/\"));\n if (found) return found;\n if (status !== \"@@find:0\")\n throw new Error(`locating a transcript as the agent uid failed (${status.slice(2)})`);\n return null;\n },\n\n async *read(filePath) {\n const child = runAsAgent(shim, [\"cat\", \"--\", filePath]);\n const exited = exitOf(child);\n exited.catch(() => {}); // awaited below; this only stops an unhandled rejection\n const stderr = drain(child);\n child.stdout?.setEncoding(\"utf8\");\n for await (const chunk of child.stdout as AsyncIterable<string>) yield chunk;\n const code = await exited;\n if (code !== 0)\n throw new Error(`reading ${filePath} as the agent uid failed: ${await stderr}`);\n },\n\n async replace(filePath, chunks) {\n const child = runAsAgent(shim, [\n \"sh\",\n \"-c\",\n // 0600 like the CLI's own files. Only writes the temp file: the rename\n // is a separate step below, run only after the input was fully sent,\n // so a killed or starved writer can never commit a partial transcript.\n 'umask 077; cat > \"$1.scrub-tmp\"',\n \"sh\",\n filePath,\n ]);\n cancelled.delete(filePath);\n track(filePath, child);\n const exited = exitOf(child);\n exited.catch(() => {}); // awaited below; this only stops an unhandled rejection\n const stderr = drain(child);\n const stdin = child.stdin;\n if (!stdin) throw new Error(\"agent shim has no stdin\");\n // A child that dies early surfaces through its exit code, not an EPIPE crash.\n stdin.on(\"error\", () => {});\n const gone = exited.then(\n () => undefined,\n () => undefined,\n );\n // Stop pulling input as soon as the child is gone (killed by discardTemp,\n // or failed), instead of waiting on a producer that may never resume.\n const input = chunks[Symbol.asyncIterator]();\n let drained = false;\n try {\n for (;;) {\n const next = await Promise.race([\n input.next(),\n gone.then(() => ({ dead: true as const })),\n ]);\n if (\"dead\" in next || stdin.destroyed) break;\n if (next.done) {\n drained = true;\n break;\n }\n if (!stdin.write(next.value)) {\n await Promise.race([new Promise((resolve) => stdin.once(\"drain\", resolve)), gone]);\n }\n }\n } finally {\n stdin.end();\n // Close the producer too, so the reader feeding it (a `cat` through\n // the shim) is torn down rather than left blocked on a full pipe.\n if (!drained) void input.return?.()?.catch(() => {});\n }\n const code = await exited;\n if (code !== 0 || !drained)\n throw new Error(`rewriting ${filePath} as the agent uid failed: ${await stderr}`);\n if (cancelled.has(filePath)) throw new Error(`rewrite of ${filePath} was abandoned`);\n const mover = runAsAgent(shim, [\"mv\", \"-f\", \"--\", `${filePath}.scrub-tmp`, filePath]);\n track(filePath, mover);\n const moved = await collect(mover, 10_000);\n if (moved.code !== 0) throw new Error(`renaming the rewritten ${filePath} failed`);\n },\n\n async discardTemp(filePath) {\n // Before anything else, so a writer that is just finishing never renames.\n cancelled.add(filePath);\n const pending = inFlight.get(filePath);\n if (pending && pending.exitCode === null && pending.signalCode === null) {\n // The writer cannot commit (the rename is a separate step), so this only\n // stops it; bounded, since a writer stuck on a hung mount may never die.\n const closed = new Promise((resolve) => pending.once(\"close\", resolve));\n pending.kill(\"SIGKILL\");\n await withFsDeadline(`stop the rewrite of ${filePath}`, () => closed, fsDeadlineMs());\n }\n await collect(runAsAgent(shim, [\"rm\", \"-f\", \"--\", `${filePath}.scrub-tmp`]), 10_000);\n },\n };\n}\n\n/**\n * The transcript store for this runner: through the agent shim when\n * `SKAILE_AGENT_EXEC` is set, the runner's own filesystem otherwise.\n */\nexport function transcriptStoreForRuntime(\n env: Record<string, string | undefined> = process.env,\n): TranscriptStore {\n const shim = resolveAgentExec(env);\n return shim ? agentTranscriptStore(shim) : localTranscriptStore;\n}\n\nfunction runAsAgent(shim: string, argv: string[]): ChildProcess {\n return spawn(shim, [\"--\", ...argv], {\n cwd: \"/\",\n env: { PATH: process.env.PATH ?? \"/usr/bin:/bin\", LC_ALL: \"C\" },\n stdio: [\"pipe\", \"pipe\", \"pipe\"],\n });\n}\n\nfunction exitOf(child: ChildProcess): Promise<number> {\n return new Promise((resolve, reject) => {\n child.once(\"error\", reject);\n child.once(\"close\", (code) => resolve(code ?? 1));\n });\n}\n\n/** Keep the last 1 KiB of stderr for the error message, and keep the pipe drained. */\nfunction drain(child: ChildProcess): Promise<string> {\n return new Promise((resolve) => {\n let tail = \"\";\n child.stderr?.setEncoding(\"utf8\");\n child.stderr?.on(\"data\", (c: string) => {\n tail = (tail + c).slice(-1024);\n });\n child.stderr?.once(\"close\", () => resolve(tail.trim()));\n });\n}\n\nasync function collect(\n child: ChildProcess,\n timeoutMs: number,\n): Promise<{ code: number; stdout: string }> {\n let stdout = \"\";\n child.stdout?.setEncoding(\"utf8\");\n child.stdout?.on(\"data\", (c: string) => {\n stdout += c;\n });\n void drain(child);\n child.stdin?.end();\n let timer: NodeJS.Timeout | undefined;\n try {\n const code = await Promise.race([\n exitOf(child),\n new Promise<never>((_, reject) => {\n timer = setTimeout(() => {\n child.kill(\"SIGKILL\");\n reject(new Error(`agent shim did not answer within ${timeoutMs} ms`));\n }, timeoutMs);\n }),\n ]);\n return { code, stdout };\n } finally {\n clearTimeout(timer);\n }\n}\n","/**\n * Pre-first-turn resume probe for the Claude Agent SDK driver.\n *\n * A tier-1 native resume only hands its session id to the SDK inside the first\n * real turn, so the `jsonl_lost` outcome (\"No conversation found\") is invisible\n * until a turn is consumed. The runner shares the container filesystem with the\n * SDK, so a cheap `stat` of the on-disk JSONL transcript is an authoritative,\n * side-effect-free signal of whether the resume will find its history — no\n * probe query, no spurious model turn.\n *\n * @module\n */\n\nimport { homedir } from \"node:os\";\nimport { join } from \"node:path\";\nimport { withFsDeadline } from \"@skaile/workspaces/core\";\nimport { locateTranscriptPath } from \"./scrub-transcript.js\";\n\n/**\n * Overall wall-clock budget for the probe. Deliberately a small fraction of the\n * platform's `session_init_ack` timeout (`DEFAULT_INIT_ACK_TIMEOUT_MS`, 15s):\n * the probe runs synchronously on the pre-ack path, so a wedged\n * `CLAUDE_CONFIG_DIR` mount must never push the ack past its deadline.\n */\nconst RESUME_PROBE_TIMEOUT_MS = 2_000;\n\n/**\n * Outcome of {@link probeResumeTranscript}: whether the SDK transcript for a\n * requested tier-1 resume exists on disk.\n *\n * @category Resume probe\n */\nexport type ResumeProbeOutcome = \"transcript_found\" | \"jsonl_lost\";\n\n/**\n * Resolve the Claude Code config directory — the parent of `projects/` — from\n * an explicit env map, the process environment, or the `~/.claude` default.\n *\n * The runner's probe and the claude-sdk driver share this one resolver, so they\n * agree as long as they see the same `CLAUDE_CONFIG_DIR`. Today they do:\n * `CLAUDE_CONFIG_DIR` is container-scoped and neither side threads a per-session\n * override through `config.env`, so both fall through to `process.env`. If a\n * future change ever set the driver's `config.env.CLAUDE_CONFIG_DIR` to a\n * divergent path, the reactive `resume_failed { jsonl_lost }` turn remains the\n * safety net.\n *\n * @category Resume probe\n */\nexport function resolveClaudeConfigDir(env?: Record<string, string | undefined>): string {\n return env?.CLAUDE_CONFIG_DIR || process.env.CLAUDE_CONFIG_DIR || join(homedir(), \".claude\");\n}\n\n/**\n * Probe whether the SDK JSONL transcript for `sessionId` exists on disk.\n *\n * Non-null locator result → `transcript_found`; null → `jsonl_lost`;\n * `undefined` → outcome unknown (the probe exceeded its budget or errored). The\n * caller leaves the ack field ABSENT on `undefined` so the reactive\n * `resume_failed { jsonl_lost }` turn stays the safety net — a timed-out probe\n * must never masquerade as a genuine `jsonl_lost` and force a needless downgrade.\n *\n * `opts.timeoutMs` overrides {@link RESUME_PROBE_TIMEOUT_MS}; `opts.locate`\n * overrides the transcript locator (used by tests / alternate stores).\n *\n * @category Resume probe\n */\nexport async function probeResumeTranscript(\n sessionId: string,\n opts?: {\n env?: Record<string, string | undefined>;\n timeoutMs?: number;\n locate?: (configDir: string, sessionId: string) => Promise<string | null>;\n },\n): Promise<ResumeProbeOutcome | undefined> {\n const configDir = resolveClaudeConfigDir(opts?.env);\n const timeoutMs = opts?.timeoutMs ?? RESUME_PROBE_TIMEOUT_MS;\n const locate = opts?.locate ?? locateTranscriptPath;\n try {\n // Bound the whole probe on wall-clock and THROW on expiry: the inner per-op\n // deadline swallows a timeout into a null path (a false `jsonl_lost`), so a\n // wedged mount must yield \"unknown\" here rather than a spurious downgrade.\n const filePath = await withFsDeadline(\n `resume-probe ${sessionId}`,\n () => locate(configDir, sessionId),\n timeoutMs,\n );\n return filePath ? \"transcript_found\" : \"jsonl_lost\";\n } catch {\n return undefined;\n }\n}\n"]}
@@ -298,5 +298,5 @@ function resolveProjectDir(additionalEnvVars) {
298
298
  }
299
299
 
300
300
  export { PluginStore, WorkspacePlugin, buildClaudePluginFiles, resolveProjectDir };
301
- //# sourceMappingURL=chunk-FTPKMJFD.js.map
302
- //# sourceMappingURL=chunk-FTPKMJFD.js.map
301
+ //# sourceMappingURL=chunk-TVYLXZTT.js.map
302
+ //# sourceMappingURL=chunk-TVYLXZTT.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../workspace-plugin/src/adapters/claude-code.ts","../workspace-plugin/src/store.ts","../workspace-plugin/src/plugin.ts","../workspace-plugin/src/utils/project-dir.ts"],"names":["err"],"mappings":";;;;;;AAeA,IAAM,WAAA,GAAc;AAAA,EAClB,IAAA,EAAM,QAAA;AAAA,EACN,OAAA,EAAS,OAAA;AAAA,EACT,WAAA,EAAa,yEAAA;AAAA,EACb,MAAA,EAAQ,EAAE,IAAA,EAAM,WAAA,EAAa,KAAK,8BAAA,EAA+B;AAAA,EACjE,UAAA,EAAY,yCAAA;AAAA,EACZ,QAAA,EAAU,CAAC,QAAA,EAAU,YAAA,EAAc,aAAa,WAAW,CAAA;AAAA,EAC3D,KAAA,EAAO,oBAAA;AAAA,EACP,UAAA,EAAY,aAAA;AAAA,EACZ,UAAA,EAAY;AAAA,IACV,gBAAA,EAAkB;AAAA,MAChB,IAAA,EAAM,QAAA;AAAA,MACN,KAAA,EAAO,kBAAA;AAAA,MACP,WAAA,EAAa;AAAA;AACf;AAEJ,CAAA;AAOA,IAAM,UAAA,GAAa;AAAA,EACjB,KAAA,EAAO;AAAA,IACL,YAAA,EAAc,CAAC,EAAE,KAAA,EAAO,CAAC,EAAE,IAAA,EAAM,SAAA,EAAW,OAAA,EAAS,kCAAA,EAAoC,CAAA,EAAG,CAAA;AAAA,IAC5F,UAAA,EAAY,CAAC,EAAE,KAAA,EAAO,CAAC,EAAE,IAAA,EAAM,SAAA,EAAW,OAAA,EAAS,gCAAA,EAAkC,CAAA,EAAG,CAAA;AAAA,IACxF,gBAAA,EAAkB;AAAA,MAChB,EAAE,OAAO,CAAC,EAAE,MAAM,SAAA,EAAW,OAAA,EAAS,uCAAA,EAAyC,CAAA;AAAE;AACnF;AAEJ,CAAA;AAMA,IAAM,QAAA,GAAW;AAAA,EACf,UAAA,E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AAI,CAAA;AAAA,EAC7C;AACF;;;ACnOO,SAAS,kBAAkB,iBAAA,EAAsC;AACtE,EAAA,IAAI,OAAA,CAAQ,GAAA,CAAI,kBAAA,EAAoB,OAAO,QAAQ,GAAA,CAAI,kBAAA;AACvD,EAAA,KAAA,MAAW,GAAA,IAAO,iBAAA,IAAqB,EAAC,EAAG;AACzC,IAAA,MAAM,GAAA,GAAM,OAAA,CAAQ,GAAA,CAAI,GAAG,CAAA;AAC3B,IAAA,IAAI,KAAK,OAAO,GAAA;AAAA,EAClB;AACA,EAAA,OAAO,QAAQ,GAAA,EAAI;AACrB","file":"chunk-FTPKMJFD.js","sourcesContent":["// ── Claude Code plugin-directory generator (STATELESS) ──────────────────────\n// Generates the contents of a Claude Code plugin directory\n// (`.claude/plugins/skaile/`) as an in-memory file map. No plugin instance or\n// boot() is required — safe to call from install commands.\n//\n// The previous standalone `@skaile/workspace-plugin-claude` package shipped\n// these as static files plus loose `.mjs` hook scripts; they are now\n// CLI-owned templates. Hooks invoke the `skaile` binary directly\n// (`skaile plugin hook <event>`) and MCP runs via `skaile mcp-server` — no\n// generated script files, no shebang, no runtime assumption.\n\n/**\n * The Claude Code plugin manifest. `name` is `skaile`; `hooks` and\n * `mcpServers` point at sibling files in the generated directory.\n */\nconst PLUGIN_JSON = {\n name: \"skaile\",\n version: \"0.1.0\",\n description: \"Skaile workspace — connectors, mounts, skills, flows, shared state\",\n author: { name: \"skaile-ai\", url: \"https://github.com/skaile-ai\" },\n repository: \"https://github.com/skaile-ai/workspaces\",\n keywords: [\"skaile\", \"connectors\", \"workspace\", \"ai-assets\"],\n hooks: \"./hooks/hooks.json\",\n mcpServers: \"./.mcp.json\",\n userConfig: {\n skaile_yaml_path: {\n type: \"string\",\n title: \"skaile.yaml path\",\n description: \"Override path to skaile.yaml (default: auto-detect from project root)\",\n },\n },\n};\n\n/**\n * Hook wiring. Each lifecycle event invokes the `skaile` binary directly —\n * no loose `.mjs` scripts. `skaile plugin hook <event>` resolves the project\n * directory itself (`CLAUDE_PROJECT_DIR` / cwd) and always exits 0.\n */\nconst HOOKS_JSON = {\n hooks: {\n SessionStart: [{ hooks: [{ type: \"command\", command: \"skaile plugin hook session-start\" }] }],\n SessionEnd: [{ hooks: [{ type: \"command\", command: \"skaile plugin hook session-end\" }] }],\n UserPromptSubmit: [\n { hooks: [{ type: \"command\", command: \"skaile plugin hook user-prompt-submit\" }] },\n ],\n },\n};\n\n/**\n * MCP server wiring. Spawns `skaile mcp-server` — a stdio MCP subprocess that\n * runs on plain Node (no Claude Agent SDK).\n */\nconst MCP_JSON = {\n mcpServers: {\n \"skaile-workspace\": {\n command: \"skaile\",\n args: [\"mcp-server\"],\n env: {},\n },\n },\n};\n\n/**\n * Build the Claude Code plugin directory as an in-memory file map.\n *\n * Returns `{ relativePath: contents }` for every file the installer must\n * write under `<projectDir>/.claude/plugins/skaile/`. The installer is also\n * responsible for populating `skills/` from the project's `.skaile/skills/`.\n *\n * Stateless — no plugin instance, no `boot()`. The generated artifacts carry\n * no project-specific paths: hooks and the MCP server resolve the project\n * directory themselves at runtime.\n *\n * @returns A map of plugin-relative file paths to their string contents.\n *\n * @docLink packages/workspace-plugin/concepts#adapters\n */\nexport function buildClaudePluginFiles(): Record<string, string> {\n return {\n \".claude-plugin/plugin.json\": `${JSON.stringify(PLUGIN_JSON, null, 2)}\\n`,\n \"hooks/hooks.json\": `${JSON.stringify(HOOKS_JSON, null, 2)}\\n`,\n \".mcp.json\": `${JSON.stringify(MCP_JSON, null, 2)}\\n`,\n \"skills/.gitkeep\": \"\",\n };\n}\n","import { mkdir, readFile, writeFile } from \"node:fs/promises\";\nimport { dirname } from \"node:path\";\n\ninterface Subscriber {\n regex: RegExp;\n handler: (key: string, value: unknown) => void;\n}\n\n/**\n * Disk-backed reactive key-value store for plugin state.\n *\n * Keeps an in-memory map that can be flushed to / loaded from a JSON file.\n * Supports glob-style subscriptions (`connector:*`, `*`).\n *\n * State is persisted to `<projectDir>/.skaile/plugin-state.json`.\n * The instance is available on {@link WorkspacePlugin} as the public `store`\n * field after `boot()` resolves.\n *\n * @docLink packages/workspace-plugin/concepts#plugin-store\n */\nexport class PluginStore {\n private readonly statePath: string;\n private data: Map<string, unknown> = new Map();\n private subscribers: Subscriber[] = [];\n\n constructor(statePath: string) {\n this.statePath = statePath;\n }\n\n /** Synchronous read from in-memory map. */\n get<T>(key: string): T | undefined {\n return this.data.get(key) as T | undefined;\n }\n\n /** Write to in-memory map and notify matching subscribers. */\n set<T>(key: string, value: T): void {\n this.data.set(key, value);\n this.notify(key, value);\n }\n\n /** Remove key and notify matching subscribers. */\n delete(key: string): void {\n this.data.delete(key);\n this.notify(key, undefined);\n }\n\n /**\n * Subscribe to changes matching a glob-style pattern.\n * `*` matches any sequence of characters.\n * Returns an unsubscribe function.\n */\n subscribe(pattern: string, handler: (key: string, value: unknown) => void): () => void {\n const escaped = pattern.replace(/[.+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n const regexStr = `^${escaped.replace(/\\*/g, \".*\")}$`;\n const sub: Subscriber = { regex: new RegExp(regexStr), handler };\n this.subscribers.push(sub);\n\n return () => {\n const idx = this.subscribers.indexOf(sub);\n if (idx !== -1) this.subscribers.splice(idx, 1);\n };\n }\n\n /** Rehydrate from disk JSON. Missing file = empty store (no throw). */\n async load(): Promise<void> {\n try {\n const raw = await readFile(this.statePath, \"utf-8\");\n const parsed = JSON.parse(raw);\n if (parsed && typeof parsed === \"object\" && !Array.isArray(parsed)) {\n this.data = new Map(Object.entries(parsed));\n }\n } catch (e: unknown) {\n // Missing file or invalid JSON — start with empty store\n }\n }\n\n /** Write entire store to disk as JSON. Creates parent dirs if needed. */\n async flush(): Promise<void> {\n const obj = Object.fromEntries(this.data);\n const json = JSON.stringify(obj, null, 2);\n await mkdir(dirname(this.statePath), { recursive: true });\n await writeFile(this.statePath, json, \"utf-8\");\n }\n\n private notify(key: string, value: unknown): void {\n for (const sub of this.subscribers) {\n if (sub.regex.test(key)) {\n sub.handler(key, value);\n }\n }\n }\n}\n","import { readFileSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport type { ConnectorManager } from \"@skaile/workspaces/connectors\";\nimport { createLogger } from \"@skaile/workspaces/core/logging\";\nimport type { Logger } from \"@skaile/workspaces/types\";\nimport { PluginStore } from \"./store.js\";\n\n/**\n * Construction options for {@link WorkspacePlugin}.\n *\n * At minimum `projectDir` must be supplied. All other fields are optional\n * and are pre-resolved by the caller when available (e.g. the runner already\n * knows `driver`/`model` from its own settings resolution).\n *\n * @docLink packages/workspace-plugin/concepts#workspaceplugin-lifecycle\n */\nexport interface WorkspacePluginOpts {\n projectDir: string;\n /**\n * Active connector manager. The unified `ConnectorManager` owns both\n * filesystem-face (mountable) and tool-face connectors.\n */\n connectorManager?: ConnectorManager;\n bootOwned?: boolean;\n onLog?: (msg: string) => void;\n /** Pre-resolved driver type (avoids needing boot() to read settings). */\n driver?: string;\n /** Pre-resolved model. */\n model?: string;\n}\n\n/**\n * Shared runtime core for the skaile workspace plugin.\n *\n * Manages the full lifecycle (`boot` → tools available → `shutdown`) and\n * surfaces workspace capabilities — mounts, connectors, flows, skills,\n * sessions, and config validation — through two adapters:\n *\n * - **MCP, in-process** (runner): call {@link buildWorkspaceMcpServer} for the\n * Claude Agent SDK server the runner embeds into its `query()` call.\n * - **MCP, stdio** (`skaile mcp-server`): call {@link runMcpServerStdio} for a\n * raw `@modelcontextprotocol/sdk` server — no Claude Agent SDK.\n * - **OMP**: call {@link buildOmpToolSet} for the 13-tool native subset and\n * {@link buildOmpExtensionSource} for the generated extension file.\n *\n * Two boot modes are supported via {@link WorkspacePluginOpts.bootOwned}:\n * - `bootOwned: false` (default) — managers injected externally by the runner.\n * - `bootOwned: true` — plugin owns the full manager lifecycle (standalone MCP\n * subprocess or OMP extension).\n *\n * @docLink packages/workspace-plugin/concepts#workspaceplugin-lifecycle\n */\nexport class WorkspacePlugin {\n readonly projectDir: string;\n connectorManager: ConnectorManager | null;\n readonly store: PluginStore;\n\n private readonly bootOwned: boolean;\n private readonly onLog: (msg: string) => void;\n private readonly log: Logger = createLogger({\n kind: \"mcp\",\n subkind: \"skaile-workspace\",\n });\n driver?: string;\n model?: string;\n\n constructor(opts: WorkspacePluginOpts) {\n this.projectDir = opts.projectDir;\n this.connectorManager = opts.connectorManager ?? null;\n this.store = new PluginStore(join(opts.projectDir, \".skaile\", \"plugin-state.json\"));\n this.bootOwned = opts.bootOwned ?? false;\n if (opts.driver) this.driver = opts.driver;\n if (opts.model) this.model = opts.model;\n this.onLog = opts.onLog ?? (() => {});\n this.log.debug(\"plugin constructed\", {\n driver: opts.driver,\n hasConnectors: !!opts.connectorManager,\n model: opts.model,\n bootOwned: this.bootOwned,\n });\n }\n\n async boot(): Promise<void> {\n if (!this.bootOwned) {\n // Managers were injected externally — resolve settings only (non-fatal)\n try {\n const { resolveSettings } = await import(\"@skaile/workspaces/core\");\n const settings = await resolveSettings(this.projectDir);\n this.driver = settings.driver ?? \"omp\";\n this.model = settings.model;\n } catch {\n /* non-fatal */\n }\n await this.store.load();\n return;\n }\n\n // bootOwned: we own the managers lifecycle\n try {\n const { resolveSettings } = await import(\"@skaile/workspaces/core\");\n const settings = await resolveSettings(this.projectDir);\n this.driver = settings.driver ?? \"omp\";\n this.model = settings.model;\n } catch {\n /* non-fatal */\n }\n\n try {\n const {\n ConnectorManager,\n loadConnectorDeclarations,\n registerBuiltinConnectors,\n createCliSecretProviderChain,\n } = await import(\"@skaile/workspaces/connectors\");\n\n registerBuiltinConnectors();\n\n const secrets = createCliSecretProviderChain();\n\n const connectorDecls = await loadConnectorDeclarations(this.projectDir);\n const cm = new ConnectorManager(this.projectDir, { secrets });\n await cm.connectAll(connectorDecls);\n this.connectorManager = cm;\n\n this.log.info(\"workspace plugin booted\", {\n connectors: connectorDecls.length,\n });\n this.onLog(`WorkspacePlugin booted: ${connectorDecls.length} connectors`);\n } catch (err) {\n this.log.warn(\"workspace plugin boot warning\", {\n error: err instanceof Error ? err.message : String(err),\n });\n this.onLog(`WorkspacePlugin boot warning: ${err}`);\n }\n\n await this.store.load();\n }\n\n async reload(): Promise<void> {\n if (!this.bootOwned) return;\n await this.shutdown();\n await this.boot();\n }\n\n async shutdown(): Promise<void> {\n this.log.info(\"workspace plugin shutdown\");\n await this.store.flush();\n if (!this.bootOwned) return;\n try {\n await (this.connectorManager as any)?.disconnectAll?.();\n } catch {\n /* best-effort */\n }\n this.connectorManager = null;\n }\n\n buildSystemPromptSection(driver?: string): string {\n const d = driver ?? this.driver ?? \"unknown\";\n // The unified ConnectorManager owns both mountable (filesystem-face) and\n // tool-face connectors. Filesystem-face connectors expose a `mountPath`.\n const all = (this.connectorManager as any)?.listConnectors?.() ?? [];\n const mounts = (all as any[]).filter((c) => typeof c.mountPath === \"string\");\n const connectors = (all as any[]).filter((c) => typeof c.mountPath !== \"string\");\n const lines = [\"## Workspace (skaile)\", \"\", `Driver: ${d}`, `Project: ${this.projectDir}`];\n if (mounts.length > 0) {\n lines.push(\"\", \"Mounts:\");\n for (const v of mounts) {\n lines.push(` · ${v.id} (${v.driver}) → ${v.mountPath ?? \"(unmounted)\"}`);\n }\n }\n if (connectors.length > 0) {\n lines.push(\"\", \"Connectors:\");\n for (const c of connectors) {\n lines.push(` · ${c.id} (${c.driver})`);\n }\n }\n lines.push(\"\", \"Use workspace_info for full details. Use workspace_validate to check health.\");\n\n for (const name of [\"SOUL.md\", \"RULES.md\"]) {\n const skaileOverride = join(this.projectDir, \".skaile\", name);\n const rootFile = join(this.projectDir, name);\n for (const candidate of [skaileOverride, rootFile]) {\n try {\n const content = readFileSync(candidate, \"utf-8\").trim();\n if (content) {\n lines.push(\"\", `## ${name.replace(\".md\", \"\")}`, \"\", content);\n break;\n }\n } catch {\n // file not found, try next\n }\n }\n }\n\n return lines.join(\"\\n\");\n }\n\n /**\n * Build the in-process Claude Agent SDK MCP server (runner embedding).\n * Returns `null` when `@anthropic-ai/claude-agent-sdk` is unavailable.\n */\n async buildWorkspaceMcpServer(): Promise<unknown | null> {\n this.log.info(\"building workspace MCP server\");\n try {\n const { buildWorkspaceMcpServer } = await import(\"./adapters/mcp.js\");\n const server = await buildWorkspaceMcpServer(this);\n if (server) this.log.info(\"workspace MCP server ready\");\n else this.log.debug(\"workspace MCP server skipped (no tools)\");\n return server;\n } catch (err) {\n this.log.error(\"workspace MCP server build failed\", err);\n throw err;\n }\n }\n\n /**\n * Build the raw `@modelcontextprotocol/sdk` stdio MCP server — no Claude\n * Agent SDK. Used by the `skaile mcp-server` subprocess. The returned\n * server is not yet connected to a transport.\n */\n async buildWorkspaceMcpStdioServer(): Promise<unknown> {\n this.log.info(\"building workspace stdio MCP server\");\n const { buildWorkspaceMcpStdioServer } = await import(\"./adapters/mcp.js\");\n return buildWorkspaceMcpStdioServer(this);\n }\n\n /**\n * Build and run the stdio MCP server: builds the raw\n * `@modelcontextprotocol/sdk` server and connects a `StdioServerTransport`.\n * Used by the `skaile mcp-server` subprocess.\n */\n async runMcpServerStdio(): Promise<void> {\n this.log.info(\"starting workspace stdio MCP server\");\n const { runMcpServerStdio } = await import(\"./adapters/mcp.js\");\n await runMcpServerStdio(this);\n }\n\n async buildOmpToolSet(): Promise<unknown[]> {\n const { buildOmpToolSet } = await import(\"./adapters/omp.js\");\n return buildOmpToolSet(this);\n }\n\n async buildOmpExtensionSource(): Promise<string> {\n const { buildOmpExtensionSource } = await import(\"./adapters/omp.js\");\n return buildOmpExtensionSource(this.projectDir);\n }\n\n async handleSlashCommand(group: string, args: string[]): Promise<string> {\n const { handleSlashCommand } = await import(\"./adapters/omp.js\");\n return handleSlashCommand(this, group, args);\n }\n}\n","// utils/project-dir.ts\n// Centralised project-directory resolution used by all plugin entry points.\n\n/**\n * Resolve the skaile project directory from environment variables.\n *\n * Resolution order:\n * 1. `SKAILE_PROJECT_DIR` (always checked first)\n * 2. Any additional env var keys supplied by the caller (in order)\n * 3. `process.cwd()` as final fallback\n *\n * @param additionalEnvVars - Optional list of extra environment variable names\n * to check before falling back to `process.cwd()`.\n * @returns Absolute path to the resolved project directory.\n *\n * @example\n * // Claude Code — also checks CLAUDE_PROJECT_DIR\n * const projectDir = resolveProjectDir([\"CLAUDE_PROJECT_DIR\"]);\n *\n * // OMP / standalone — SKAILE_PROJECT_DIR or cwd only\n * const projectDir = resolveProjectDir();\n *\n * @docLink packages/workspace-plugin/concepts#workspaceplugin-lifecycle\n */\nexport function resolveProjectDir(additionalEnvVars?: string[]): string {\n if (process.env.SKAILE_PROJECT_DIR) return process.env.SKAILE_PROJECT_DIR;\n for (const key of additionalEnvVars ?? []) {\n const val = process.env[key];\n if (val) return val;\n }\n return process.cwd();\n}\n"]}
1
+ {"version":3,"sources":["../workspace-plugin/src/adapters/claude-code.ts","../workspace-plugin/src/store.ts","../workspace-plugin/src/plugin.ts","../workspace-plugin/src/utils/project-dir.ts"],"names":["err"],"mappings":";;;;;;AAeA,IAAM,WAAA,GAAc;AAAA,EAClB,IAAA,EAAM,QAAA;AAAA,EACN,OAAA,EAAS,OAAA;AAAA,EACT,WAAA,EAAa,yEAAA;AAAA,EACb,MAAA,EAAQ,EAAE,IAAA,EAAM,WAAA,EAAa,KAAK,8BAAA,EAA+B;AAAA,EACjE,UAAA,EAAY,yCAAA;AAAA,EACZ,QAAA,EAAU,CAAC,QAAA,EAAU,YAAA,EAAc,aAAa,WAAW,CAAA;AAAA,EAC3D,KAAA,EAAO,oBAAA;AAAA,EACP,UAAA,EAAY,aAAA;AAAA,EACZ,UAAA,EAAY;AAAA,IACV,gBAAA,EAAkB;AAAA,MAChB,IAAA,EAAM,QAAA;AAAA,MACN,KAAA,EAAO,kBAAA;AAAA,MACP,WAAA,EAAa;AAAA;AACf;AAEJ,CAAA;AAOA,IAAM,UAAA,GAAa;AAAA,EACjB,KAAA,EAAO;AAAA,IACL,YAAA,EAAc,CAAC,EAAE,KAAA,EAAO,CAAC,EAAE,IAAA,EAAM,SAAA,EAAW,OAAA,EAAS,kCAAA,EAAoC,CAAA,EAAG,CAAA;AAAA,IAC5F,UAAA,EAAY,C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,GAAI,MAAM,OAAO,oCAAmB,CAAA;AACpE,IAAA,OAAO,uBAAA,CAAwB,KAAK,UAAU,CAAA;AAAA,EAChD;AAAA,EAEA,MAAM,kBAAA,CAAmB,KAAA,EAAe,IAAA,EAAiC;AACvE,IAAA,MAAM,EAAE,kBAAA,EAAmB,GAAI,MAAM,OAAO,oCAAmB,CAAA;AAC/D,IAAA,OAAO,kBAAA,CAAmB,IAAA,EAAM,KAAA,EAAO,IAAI,CAAA;AAAA,EAC7C;AACF;;;ACnOO,SAAS,kBAAkB,iBAAA,EAAsC;AACtE,EAAA,IAAI,OAAA,CAAQ,GAAA,CAAI,kBAAA,EAAoB,OAAO,QAAQ,GAAA,CAAI,kBAAA;AACvD,EAAA,KAAA,MAAW,GAAA,IAAO,iBAAA,IAAqB,EAAC,EAAG;AACzC,IAAA,MAAM,GAAA,GAAM,OAAA,CAAQ,GAAA,CAAI,GAAG,CAAA;AAC3B,IAAA,IAAI,KAAK,OAAO,GAAA;AAAA,EAClB;AACA,EAAA,OAAO,QAAQ,GAAA,EAAI;AACrB","file":"chunk-TVYLXZTT.js","sourcesContent":["// ── Claude Code plugin-directory generator (STATELESS) ──────────────────────\n// Generates the contents of a Claude Code plugin directory\n// (`.claude/plugins/skaile/`) as an in-memory file map. No plugin instance or\n// boot() is required — safe to call from install commands.\n//\n// The previous standalone `@skaile/workspace-plugin-claude` package shipped\n// these as static files plus loose `.mjs` hook scripts; they are now\n// CLI-owned templates. Hooks invoke the `skaile` binary directly\n// (`skaile plugin hook <event>`) and MCP runs via `skaile mcp-server` — no\n// generated script files, no shebang, no runtime assumption.\n\n/**\n * The Claude Code plugin manifest. `name` is `skaile`; `hooks` and\n * `mcpServers` point at sibling files in the generated directory.\n */\nconst PLUGIN_JSON = {\n name: \"skaile\",\n version: \"0.1.0\",\n description: \"Skaile workspace — connectors, mounts, skills, flows, shared state\",\n author: { name: \"skaile-ai\", url: \"https://github.com/skaile-ai\" },\n repository: \"https://github.com/skaile-ai/workspaces\",\n keywords: [\"skaile\", \"connectors\", \"workspace\", \"ai-assets\"],\n hooks: \"./hooks/hooks.json\",\n mcpServers: \"./.mcp.json\",\n userConfig: {\n skaile_yaml_path: {\n type: \"string\",\n title: \"skaile.yaml path\",\n description: \"Override path to skaile.yaml (default: auto-detect from project root)\",\n },\n },\n};\n\n/**\n * Hook wiring. Each lifecycle event invokes the `skaile` binary directly —\n * no loose `.mjs` scripts. `skaile plugin hook <event>` resolves the project\n * directory itself (`CLAUDE_PROJECT_DIR` / cwd) and always exits 0.\n */\nconst HOOKS_JSON = {\n hooks: {\n SessionStart: [{ hooks: [{ type: \"command\", command: \"skaile plugin hook session-start\" }] }],\n SessionEnd: [{ hooks: [{ type: \"command\", command: \"skaile plugin hook session-end\" }] }],\n UserPromptSubmit: [\n { hooks: [{ type: \"command\", command: \"skaile plugin hook user-prompt-submit\" }] },\n ],\n },\n};\n\n/**\n * MCP server wiring. Spawns `skaile mcp-server` — a stdio MCP subprocess that\n * runs on plain Node (no Claude Agent SDK).\n */\nconst MCP_JSON = {\n mcpServers: {\n \"skaile-workspace\": {\n command: \"skaile\",\n args: [\"mcp-server\"],\n env: {},\n },\n },\n};\n\n/**\n * Build the Claude Code plugin directory as an in-memory file map.\n *\n * Returns `{ relativePath: contents }` for every file the installer must\n * write under `<projectDir>/.claude/plugins/skaile/`. The installer is also\n * responsible for populating `skills/` from the project's `.skaile/skills/`.\n *\n * Stateless — no plugin instance, no `boot()`. The generated artifacts carry\n * no project-specific paths: hooks and the MCP server resolve the project\n * directory themselves at runtime.\n *\n * @returns A map of plugin-relative file paths to their string contents.\n *\n * @docLink packages/workspace-plugin/concepts#adapters\n */\nexport function buildClaudePluginFiles(): Record<string, string> {\n return {\n \".claude-plugin/plugin.json\": `${JSON.stringify(PLUGIN_JSON, null, 2)}\\n`,\n \"hooks/hooks.json\": `${JSON.stringify(HOOKS_JSON, null, 2)}\\n`,\n \".mcp.json\": `${JSON.stringify(MCP_JSON, null, 2)}\\n`,\n \"skills/.gitkeep\": \"\",\n };\n}\n","import { mkdir, readFile, writeFile } from \"node:fs/promises\";\nimport { dirname } from \"node:path\";\n\ninterface Subscriber {\n regex: RegExp;\n handler: (key: string, value: unknown) => void;\n}\n\n/**\n * Disk-backed reactive key-value store for plugin state.\n *\n * Keeps an in-memory map that can be flushed to / loaded from a JSON file.\n * Supports glob-style subscriptions (`connector:*`, `*`).\n *\n * State is persisted to `<projectDir>/.skaile/plugin-state.json`.\n * The instance is available on {@link WorkspacePlugin} as the public `store`\n * field after `boot()` resolves.\n *\n * @docLink packages/workspace-plugin/concepts#plugin-store\n */\nexport class PluginStore {\n private readonly statePath: string;\n private data: Map<string, unknown> = new Map();\n private subscribers: Subscriber[] = [];\n\n constructor(statePath: string) {\n this.statePath = statePath;\n }\n\n /** Synchronous read from in-memory map. */\n get<T>(key: string): T | undefined {\n return this.data.get(key) as T | undefined;\n }\n\n /** Write to in-memory map and notify matching subscribers. */\n set<T>(key: string, value: T): void {\n this.data.set(key, value);\n this.notify(key, value);\n }\n\n /** Remove key and notify matching subscribers. */\n delete(key: string): void {\n this.data.delete(key);\n this.notify(key, undefined);\n }\n\n /**\n * Subscribe to changes matching a glob-style pattern.\n * `*` matches any sequence of characters.\n * Returns an unsubscribe function.\n */\n subscribe(pattern: string, handler: (key: string, value: unknown) => void): () => void {\n const escaped = pattern.replace(/[.+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n const regexStr = `^${escaped.replace(/\\*/g, \".*\")}$`;\n const sub: Subscriber = { regex: new RegExp(regexStr), handler };\n this.subscribers.push(sub);\n\n return () => {\n const idx = this.subscribers.indexOf(sub);\n if (idx !== -1) this.subscribers.splice(idx, 1);\n };\n }\n\n /** Rehydrate from disk JSON. Missing file = empty store (no throw). */\n async load(): Promise<void> {\n try {\n const raw = await readFile(this.statePath, \"utf-8\");\n const parsed = JSON.parse(raw);\n if (parsed && typeof parsed === \"object\" && !Array.isArray(parsed)) {\n this.data = new Map(Object.entries(parsed));\n }\n } catch (e: unknown) {\n // Missing file or invalid JSON — start with empty store\n }\n }\n\n /** Write entire store to disk as JSON. Creates parent dirs if needed. */\n async flush(): Promise<void> {\n const obj = Object.fromEntries(this.data);\n const json = JSON.stringify(obj, null, 2);\n await mkdir(dirname(this.statePath), { recursive: true });\n await writeFile(this.statePath, json, \"utf-8\");\n }\n\n private notify(key: string, value: unknown): void {\n for (const sub of this.subscribers) {\n if (sub.regex.test(key)) {\n sub.handler(key, value);\n }\n }\n }\n}\n","import { readFileSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport type { ConnectorManager } from \"@skaile/workspaces/connectors\";\nimport { createLogger } from \"@skaile/workspaces/core/logging\";\nimport type { Logger } from \"@skaile/workspaces/types\";\nimport { PluginStore } from \"./store.js\";\n\n/**\n * Construction options for {@link WorkspacePlugin}.\n *\n * At minimum `projectDir` must be supplied. All other fields are optional\n * and are pre-resolved by the caller when available (e.g. the runner already\n * knows `driver`/`model` from its own settings resolution).\n *\n * @docLink packages/workspace-plugin/concepts#workspaceplugin-lifecycle\n */\nexport interface WorkspacePluginOpts {\n projectDir: string;\n /**\n * Active connector manager. The unified `ConnectorManager` owns both\n * filesystem-face (mountable) and tool-face connectors.\n */\n connectorManager?: ConnectorManager;\n bootOwned?: boolean;\n onLog?: (msg: string) => void;\n /** Pre-resolved driver type (avoids needing boot() to read settings). */\n driver?: string;\n /** Pre-resolved model. */\n model?: string;\n}\n\n/**\n * Shared runtime core for the skaile workspace plugin.\n *\n * Manages the full lifecycle (`boot` → tools available → `shutdown`) and\n * surfaces workspace capabilities — mounts, connectors, flows, skills,\n * sessions, and config validation — through two adapters:\n *\n * - **MCP, in-process** (runner): call {@link buildWorkspaceMcpServer} for the\n * Claude Agent SDK server the runner embeds into its `query()` call.\n * - **MCP, stdio** (`skaile mcp-server`): call {@link runMcpServerStdio} for a\n * raw `@modelcontextprotocol/sdk` server — no Claude Agent SDK.\n * - **OMP**: call {@link buildOmpToolSet} for the 13-tool native subset and\n * {@link buildOmpExtensionSource} for the generated extension file.\n *\n * Two boot modes are supported via {@link WorkspacePluginOpts.bootOwned}:\n * - `bootOwned: false` (default) — managers injected externally by the runner.\n * - `bootOwned: true` — plugin owns the full manager lifecycle (standalone MCP\n * subprocess or OMP extension).\n *\n * @docLink packages/workspace-plugin/concepts#workspaceplugin-lifecycle\n */\nexport class WorkspacePlugin {\n readonly projectDir: string;\n connectorManager: ConnectorManager | null;\n readonly store: PluginStore;\n\n private readonly bootOwned: boolean;\n private readonly onLog: (msg: string) => void;\n private readonly log: Logger = createLogger({\n kind: \"mcp\",\n subkind: \"skaile-workspace\",\n });\n driver?: string;\n model?: string;\n\n constructor(opts: WorkspacePluginOpts) {\n this.projectDir = opts.projectDir;\n this.connectorManager = opts.connectorManager ?? null;\n this.store = new PluginStore(join(opts.projectDir, \".skaile\", \"plugin-state.json\"));\n this.bootOwned = opts.bootOwned ?? false;\n if (opts.driver) this.driver = opts.driver;\n if (opts.model) this.model = opts.model;\n this.onLog = opts.onLog ?? (() => {});\n this.log.debug(\"plugin constructed\", {\n driver: opts.driver,\n hasConnectors: !!opts.connectorManager,\n model: opts.model,\n bootOwned: this.bootOwned,\n });\n }\n\n async boot(): Promise<void> {\n if (!this.bootOwned) {\n // Managers were injected externally — resolve settings only (non-fatal)\n try {\n const { resolveSettings } = await import(\"@skaile/workspaces/core\");\n const settings = await resolveSettings(this.projectDir);\n this.driver = settings.driver ?? \"omp\";\n this.model = settings.model;\n } catch {\n /* non-fatal */\n }\n await this.store.load();\n return;\n }\n\n // bootOwned: we own the managers lifecycle\n try {\n const { resolveSettings } = await import(\"@skaile/workspaces/core\");\n const settings = await resolveSettings(this.projectDir);\n this.driver = settings.driver ?? \"omp\";\n this.model = settings.model;\n } catch {\n /* non-fatal */\n }\n\n try {\n const {\n ConnectorManager,\n loadConnectorDeclarations,\n registerBuiltinConnectors,\n createCliSecretProviderChain,\n } = await import(\"@skaile/workspaces/connectors\");\n\n registerBuiltinConnectors();\n\n const secrets = createCliSecretProviderChain();\n\n const connectorDecls = await loadConnectorDeclarations(this.projectDir);\n const cm = new ConnectorManager(this.projectDir, { secrets });\n await cm.connectAll(connectorDecls);\n this.connectorManager = cm;\n\n this.log.info(\"workspace plugin booted\", {\n connectors: connectorDecls.length,\n });\n this.onLog(`WorkspacePlugin booted: ${connectorDecls.length} connectors`);\n } catch (err) {\n this.log.warn(\"workspace plugin boot warning\", {\n error: err instanceof Error ? err.message : String(err),\n });\n this.onLog(`WorkspacePlugin boot warning: ${err}`);\n }\n\n await this.store.load();\n }\n\n async reload(): Promise<void> {\n if (!this.bootOwned) return;\n await this.shutdown();\n await this.boot();\n }\n\n async shutdown(): Promise<void> {\n this.log.info(\"workspace plugin shutdown\");\n await this.store.flush();\n if (!this.bootOwned) return;\n try {\n await (this.connectorManager as any)?.disconnectAll?.();\n } catch {\n /* best-effort */\n }\n this.connectorManager = null;\n }\n\n buildSystemPromptSection(driver?: string): string {\n const d = driver ?? this.driver ?? \"unknown\";\n // The unified ConnectorManager owns both mountable (filesystem-face) and\n // tool-face connectors. Filesystem-face connectors expose a `mountPath`.\n const all = (this.connectorManager as any)?.listConnectors?.() ?? [];\n const mounts = (all as any[]).filter((c) => typeof c.mountPath === \"string\");\n const connectors = (all as any[]).filter((c) => typeof c.mountPath !== \"string\");\n const lines = [\"## Workspace (skaile)\", \"\", `Driver: ${d}`, `Project: ${this.projectDir}`];\n if (mounts.length > 0) {\n lines.push(\"\", \"Mounts:\");\n for (const v of mounts) {\n lines.push(` · ${v.id} (${v.driver}) → ${v.mountPath ?? \"(unmounted)\"}`);\n }\n }\n if (connectors.length > 0) {\n lines.push(\"\", \"Connectors:\");\n for (const c of connectors) {\n lines.push(` · ${c.id} (${c.driver})`);\n }\n }\n lines.push(\"\", \"Use workspace_info for full details. Use workspace_validate to check health.\");\n\n for (const name of [\"SOUL.md\", \"RULES.md\"]) {\n const skaileOverride = join(this.projectDir, \".skaile\", name);\n const rootFile = join(this.projectDir, name);\n for (const candidate of [skaileOverride, rootFile]) {\n try {\n const content = readFileSync(candidate, \"utf-8\").trim();\n if (content) {\n lines.push(\"\", `## ${name.replace(\".md\", \"\")}`, \"\", content);\n break;\n }\n } catch {\n // file not found, try next\n }\n }\n }\n\n return lines.join(\"\\n\");\n }\n\n /**\n * Build the in-process Claude Agent SDK MCP server (runner embedding).\n * Returns `null` when `@anthropic-ai/claude-agent-sdk` is unavailable.\n */\n async buildWorkspaceMcpServer(): Promise<unknown | null> {\n this.log.info(\"building workspace MCP server\");\n try {\n const { buildWorkspaceMcpServer } = await import(\"./adapters/mcp.js\");\n const server = await buildWorkspaceMcpServer(this);\n if (server) this.log.info(\"workspace MCP server ready\");\n else this.log.debug(\"workspace MCP server skipped (no tools)\");\n return server;\n } catch (err) {\n this.log.error(\"workspace MCP server build failed\", err);\n throw err;\n }\n }\n\n /**\n * Build the raw `@modelcontextprotocol/sdk` stdio MCP server — no Claude\n * Agent SDK. Used by the `skaile mcp-server` subprocess. The returned\n * server is not yet connected to a transport.\n */\n async buildWorkspaceMcpStdioServer(): Promise<unknown> {\n this.log.info(\"building workspace stdio MCP server\");\n const { buildWorkspaceMcpStdioServer } = await import(\"./adapters/mcp.js\");\n return buildWorkspaceMcpStdioServer(this);\n }\n\n /**\n * Build and run the stdio MCP server: builds the raw\n * `@modelcontextprotocol/sdk` server and connects a `StdioServerTransport`.\n * Used by the `skaile mcp-server` subprocess.\n */\n async runMcpServerStdio(): Promise<void> {\n this.log.info(\"starting workspace stdio MCP server\");\n const { runMcpServerStdio } = await import(\"./adapters/mcp.js\");\n await runMcpServerStdio(this);\n }\n\n async buildOmpToolSet(): Promise<unknown[]> {\n const { buildOmpToolSet } = await import(\"./adapters/omp.js\");\n return buildOmpToolSet(this);\n }\n\n async buildOmpExtensionSource(): Promise<string> {\n const { buildOmpExtensionSource } = await import(\"./adapters/omp.js\");\n return buildOmpExtensionSource(this.projectDir);\n }\n\n async handleSlashCommand(group: string, args: string[]): Promise<string> {\n const { handleSlashCommand } = await import(\"./adapters/omp.js\");\n return handleSlashCommand(this, group, args);\n }\n}\n","// utils/project-dir.ts\n// Centralised project-directory resolution used by all plugin entry points.\n\n/**\n * Resolve the skaile project directory from environment variables.\n *\n * Resolution order:\n * 1. `SKAILE_PROJECT_DIR` (always checked first)\n * 2. Any additional env var keys supplied by the caller (in order)\n * 3. `process.cwd()` as final fallback\n *\n * @param additionalEnvVars - Optional list of extra environment variable names\n * to check before falling back to `process.cwd()`.\n * @returns Absolute path to the resolved project directory.\n *\n * @example\n * // Claude Code — also checks CLAUDE_PROJECT_DIR\n * const projectDir = resolveProjectDir([\"CLAUDE_PROJECT_DIR\"]);\n *\n * // OMP / standalone — SKAILE_PROJECT_DIR or cwd only\n * const projectDir = resolveProjectDir();\n *\n * @docLink packages/workspace-plugin/concepts#workspaceplugin-lifecycle\n */\nexport function resolveProjectDir(additionalEnvVars?: string[]): string {\n if (process.env.SKAILE_PROJECT_DIR) return process.env.SKAILE_PROJECT_DIR;\n for (const key of additionalEnvVars ?? []) {\n const val = process.env[key];\n if (val) return val;\n }\n return process.cwd();\n}\n"]}
@@ -1,4 +1,4 @@
1
- import { findAiAssetsRoot } from './chunk-DOVURNRK.js';
1
+ import { findAiAssetsRoot } from './chunk-VDJKWKH2.js';
2
2
 
3
3
  // workspace-plugin/src/utils/ai-assets.ts
4
4
  function findAiAssetsRoot2(startDir) {
@@ -6,5 +6,5 @@ function findAiAssetsRoot2(startDir) {
6
6
  }
7
7
 
8
8
  export { findAiAssetsRoot2 as findAiAssetsRoot };
9
- //# sourceMappingURL=chunk-EOKAFBJ7.js.map
10
- //# sourceMappingURL=chunk-EOKAFBJ7.js.map
9
+ //# sourceMappingURL=chunk-TYUJB336.js.map
10
+ //# sourceMappingURL=chunk-TYUJB336.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../workspace-plugin/src/utils/ai-assets.ts"],"names":["findAiAssetsRoot"],"mappings":";;;AA+BO,SAASA,kBAAiB,QAAA,EAA0C;AACzE,EAAA,OAAO,iBAAuB,QAAQ,CAAA;AACxC","file":"chunk-EOKAFBJ7.js","sourcesContent":["// utils/ai-assets.ts\n// Shared utility for locating the ai-assets root directory.\n//\n// This is NOT a startup path (an earlier comment here claimed it was). Every\n// caller is an agent-invokable tool in `tools/flows.ts` / `tools/skills.ts`, so\n// the walk runs on a request path inside the long-lived `skaile serve` process,\n// once per tool invocation. With `projectDir = /skaile` the upward walk passes\n// directly beside the rclone FUSE workspace mount, so a synchronous `statSync`\n// here parks the whole event loop when that mount wedges — the failure mode\n// behind the 2026-08-07 outages. See issue #454.\nimport { findAiAssetsRoot as findAiAssetsRootShared } from \"@skaile/workspaces/asset-manager/catalog-deployer\";\n\n/**\n * Walk up from `startDir` looking for an `ai-assets/` directory.\n *\n * Delegates to the shared implementation in `asset-manager/catalog-deployer`,\n * which is async, deadline-bounded, level-capped, and refuses a candidate that\n * resolves at or under a workspace mount (continuing upward so a legitimate\n * parent still wins).\n *\n * @param startDir - Absolute path to begin the upward search from (typically\n * the skaile `projectDir`).\n * Note the upward walk is now level-capped rather than running to the\n * filesystem root. Six levels covers every real layout and stops an\n * unbounded climb across mount boundaries.\n *\n * @returns Absolute path to the first usable `ai-assets/` directory found, or\n * `null` if no match exists within the cap.\n *\n * @docLink packages/workspace-plugin/concepts#workspaceplugin-lifecycle\n */\nexport function findAiAssetsRoot(startDir: string): Promise<string | null> {\n return findAiAssetsRootShared(startDir);\n}\n"]}
1
+ {"version":3,"sources":["../workspace-plugin/src/utils/ai-assets.ts"],"names":["findAiAssetsRoot"],"mappings":";;;AA+BO,SAASA,kBAAiB,QAAA,EAA0C;AACzE,EAAA,OAAO,iBAAuB,QAAQ,CAAA;AACxC","file":"chunk-TYUJB336.js","sourcesContent":["// utils/ai-assets.ts\n// Shared utility for locating the ai-assets root directory.\n//\n// This is NOT a startup path (an earlier comment here claimed it was). Every\n// caller is an agent-invokable tool in `tools/flows.ts` / `tools/skills.ts`, so\n// the walk runs on a request path inside the long-lived `skaile serve` process,\n// once per tool invocation. With `projectDir = /skaile` the upward walk passes\n// directly beside the rclone FUSE workspace mount, so a synchronous `statSync`\n// here parks the whole event loop when that mount wedges — the failure mode\n// behind the 2026-08-07 outages. See issue #454.\nimport { findAiAssetsRoot as findAiAssetsRootShared } from \"@skaile/workspaces/asset-manager/catalog-deployer\";\n\n/**\n * Walk up from `startDir` looking for an `ai-assets/` directory.\n *\n * Delegates to the shared implementation in `asset-manager/catalog-deployer`,\n * which is async, deadline-bounded, level-capped, and refuses a candidate that\n * resolves at or under a workspace mount (continuing upward so a legitimate\n * parent still wins).\n *\n * @param startDir - Absolute path to begin the upward search from (typically\n * the skaile `projectDir`).\n * Note the upward walk is now level-capped rather than running to the\n * filesystem root. Six levels covers every real layout and stops an\n * unbounded climb across mount boundaries.\n *\n * @returns Absolute path to the first usable `ai-assets/` directory found, or\n * `null` if no match exists within the cap.\n *\n * @docLink packages/workspace-plugin/concepts#workspaceplugin-lifecycle\n */\nexport function findAiAssetsRoot(startDir: string): Promise<string | null> {\n return findAiAssetsRootShared(startDir);\n}\n"]}