@agimon-ai/po 0.0.0-alpha.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 (560) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +755 -0
  3. package/assets/banner.png +0 -0
  4. package/assets/banner.svg +25 -0
  5. package/assets/favicon.svg +15 -0
  6. package/assets/logo-light.png +0 -0
  7. package/assets/logo-light.svg +25 -0
  8. package/assets/logo.png +0 -0
  9. package/assets/logo.svg +25 -0
  10. package/assets/mascot.png +0 -0
  11. package/assets/mascot.svg +25 -0
  12. package/dist/_virtual/_rolldown/runtime.cjs +23 -0
  13. package/dist/antigravity.cjs +5 -0
  14. package/dist/antigravity.d.mts +2 -0
  15. package/dist/antigravity.mjs +2 -0
  16. package/dist/apiContracts.cjs +11 -0
  17. package/dist/apiContracts.cjs.map +1 -0
  18. package/dist/apiContracts.d.mts +52 -0
  19. package/dist/apiContracts.d.mts.map +1 -0
  20. package/dist/apiContracts.mjs +7 -0
  21. package/dist/apiContracts.mjs.map +1 -0
  22. package/dist/baseCommand.cjs +3 -0
  23. package/dist/baseCommand.d.mts +2 -0
  24. package/dist/baseCommand.mjs +2 -0
  25. package/dist/bin/cli.cjs +24 -0
  26. package/dist/bin/cli.cjs.map +1 -0
  27. package/dist/bin/cli.d.mts +1 -0
  28. package/dist/bin/cli.mjs +25 -0
  29. package/dist/bin/cli.mjs.map +1 -0
  30. package/dist/bin/doomRunner.cjs +33 -0
  31. package/dist/bin/doomRunner.cjs.map +1 -0
  32. package/dist/bin/doomRunner.d.mts +4 -0
  33. package/dist/bin/doomRunner.d.mts.map +1 -0
  34. package/dist/bin/doomRunner.mjs +32 -0
  35. package/dist/bin/doomRunner.mjs.map +1 -0
  36. package/dist/bin/serve.cjs +30 -0
  37. package/dist/bin/serve.cjs.map +1 -0
  38. package/dist/bin/serve.d.mts +1 -0
  39. package/dist/bin/serve.mjs +31 -0
  40. package/dist/bin/serve.mjs.map +1 -0
  41. package/dist/builders/cli/extensionAssembler/index.cjs +342 -0
  42. package/dist/builders/cli/extensionAssembler/index.cjs.map +1 -0
  43. package/dist/builders/cli/extensionAssembler/index.d.mts +85 -0
  44. package/dist/builders/cli/extensionAssembler/index.d.mts.map +1 -0
  45. package/dist/builders/cli/extensionAssembler/index.mjs +335 -0
  46. package/dist/builders/cli/extensionAssembler/index.mjs.map +1 -0
  47. package/dist/catalog/index.json +430 -0
  48. package/dist/cli.cjs +28 -0
  49. package/dist/cli.d.mts +11 -0
  50. package/dist/cli.mjs +11 -0
  51. package/dist/cliApp.cjs +6 -0
  52. package/dist/cliApp.d.mts +2 -0
  53. package/dist/cliApp.mjs +2 -0
  54. package/dist/codex.cjs +8 -0
  55. package/dist/codex.d.mts +2 -0
  56. package/dist/codex.mjs +2 -0
  57. package/dist/commands.cjs +18 -0
  58. package/dist/commands.d.mts +9 -0
  59. package/dist/commands.mjs +9 -0
  60. package/dist/compatibility.cjs +27 -0
  61. package/dist/compatibility.d.mts +6 -0
  62. package/dist/compatibility.mjs +6 -0
  63. package/dist/compatibilityCommand.cjs +4 -0
  64. package/dist/compatibilityCommand.d.mts +2 -0
  65. package/dist/compatibilityCommand.mjs +2 -0
  66. package/dist/compatibilityContext.cjs +3 -0
  67. package/dist/compatibilityContext.d.mts +2 -0
  68. package/dist/compatibilityContext.mjs +2 -0
  69. package/dist/compatibilityOptions.cjs +5 -0
  70. package/dist/compatibilityOptions.d.mts +2 -0
  71. package/dist/compatibilityOptions.mjs +2 -0
  72. package/dist/config.cjs +163 -0
  73. package/dist/config.d.mts +7 -0
  74. package/dist/config.mjs +7 -0
  75. package/dist/doctorCommand.cjs +5 -0
  76. package/dist/doctorCommand.d.mts +2 -0
  77. package/dist/doctorCommand.mjs +2 -0
  78. package/dist/emitMcpCommand.cjs +4 -0
  79. package/dist/emitMcpCommand.d.mts +2 -0
  80. package/dist/emitMcpCommand.mjs +2 -0
  81. package/dist/explainCommand.cjs +5 -0
  82. package/dist/explainCommand.d.mts +2 -0
  83. package/dist/explainCommand.mjs +2 -0
  84. package/dist/extensions/server.cjs +39 -0
  85. package/dist/extensions/server.cjs.map +1 -0
  86. package/dist/extensions/server.d.mts +5 -0
  87. package/dist/extensions/server.d.mts.map +1 -0
  88. package/dist/extensions/server.mjs +34 -0
  89. package/dist/extensions/server.mjs.map +1 -0
  90. package/dist/harnessContext.cjs +5 -0
  91. package/dist/harnessContext.d.mts +2 -0
  92. package/dist/harnessContext.mjs +2 -0
  93. package/dist/harnessState.cjs +19 -0
  94. package/dist/harnessState.d.mts +2 -0
  95. package/dist/harnessState.mjs +2 -0
  96. package/dist/help.cjs +12 -0
  97. package/dist/help.d.mts +6 -0
  98. package/dist/help.mjs +6 -0
  99. package/dist/index.cjs +306 -0
  100. package/dist/index.d.mts +40 -0
  101. package/dist/index.mjs +37 -0
  102. package/dist/initCommand.cjs +4 -0
  103. package/dist/initCommand.d.mts +2 -0
  104. package/dist/initCommand.mjs +2 -0
  105. package/dist/matrixOptions.cjs +28 -0
  106. package/dist/matrixOptions.d.mts +2 -0
  107. package/dist/matrixOptions.mjs +2 -0
  108. package/dist/matrixSwitcher.cjs +11 -0
  109. package/dist/matrixSwitcher.d.mts +3 -0
  110. package/dist/matrixSwitcher.mjs +3 -0
  111. package/dist/mcpFilter.cjs +9 -0
  112. package/dist/mcpFilter.d.mts +1 -0
  113. package/dist/mcpFilter.mjs +2 -0
  114. package/dist/options.cjs +3 -0
  115. package/dist/options.d.mts +2 -0
  116. package/dist/options.mjs +2 -0
  117. package/dist/process.cjs +12 -0
  118. package/dist/process.d.mts +2 -0
  119. package/dist/process.mjs +2 -0
  120. package/dist/projectTrust.cjs +6 -0
  121. package/dist/projectTrust.d.mts +2 -0
  122. package/dist/projectTrust.mjs +2 -0
  123. package/dist/repository.cjs +5 -0
  124. package/dist/repository.d.mts +2 -0
  125. package/dist/repository.mjs +2 -0
  126. package/dist/resourceCollector.cjs +9 -0
  127. package/dist/resourceCollector.d.mts +1 -0
  128. package/dist/resourceCollector.mjs +2 -0
  129. package/dist/router.cjs +6 -0
  130. package/dist/router.d.mts +2 -0
  131. package/dist/router.mjs +2 -0
  132. package/dist/services.cjs +97 -0
  133. package/dist/services.d.mts +12 -0
  134. package/dist/services.mjs +12 -0
  135. package/dist/shared.cjs +18 -0
  136. package/dist/shared.d.mts +2 -0
  137. package/dist/shared.mjs +2 -0
  138. package/dist/src/bin/agentDirectory.cjs +27 -0
  139. package/dist/src/bin/agentDirectory.cjs.map +1 -0
  140. package/dist/src/bin/agentDirectory.mjs +26 -0
  141. package/dist/src/bin/agentDirectory.mjs.map +1 -0
  142. package/dist/src/builders/apiContractExport/index.cjs +126 -0
  143. package/dist/src/builders/apiContractExport/index.cjs.map +1 -0
  144. package/dist/src/builders/apiContractExport/index.mjs +123 -0
  145. package/dist/src/builders/apiContractExport/index.mjs.map +1 -0
  146. package/dist/src/builders/cli/entryResolution.cjs +39 -0
  147. package/dist/src/builders/cli/entryResolution.cjs.map +1 -0
  148. package/dist/src/builders/cli/entryResolution.mjs +35 -0
  149. package/dist/src/builders/cli/entryResolution.mjs.map +1 -0
  150. package/dist/src/builders/cli/harnessContext.cjs +175 -0
  151. package/dist/src/builders/cli/harnessContext.cjs.map +1 -0
  152. package/dist/src/builders/cli/harnessContext.d.mts +48 -0
  153. package/dist/src/builders/cli/harnessContext.d.mts.map +1 -0
  154. package/dist/src/builders/cli/harnessContext.mjs +167 -0
  155. package/dist/src/builders/cli/harnessContext.mjs.map +1 -0
  156. package/dist/src/builders/cli/sessionComposition.cjs +27 -0
  157. package/dist/src/builders/cli/sessionComposition.cjs.map +1 -0
  158. package/dist/src/builders/cli/sessionComposition.mjs +26 -0
  159. package/dist/src/builders/cli/sessionComposition.mjs.map +1 -0
  160. package/dist/src/builders/hooks/index.cjs +238 -0
  161. package/dist/src/builders/hooks/index.cjs.map +1 -0
  162. package/dist/src/builders/hooks/index.mjs +231 -0
  163. package/dist/src/builders/hooks/index.mjs.map +1 -0
  164. package/dist/src/builders/native/index.cjs +176 -0
  165. package/dist/src/builders/native/index.cjs.map +1 -0
  166. package/dist/src/builders/native/index.d.mts +36 -0
  167. package/dist/src/builders/native/index.d.mts.map +1 -0
  168. package/dist/src/builders/native/index.mjs +170 -0
  169. package/dist/src/builders/native/index.mjs.map +1 -0
  170. package/dist/src/builders/server/backgroundSync.cjs +333 -0
  171. package/dist/src/builders/server/backgroundSync.cjs.map +1 -0
  172. package/dist/src/builders/server/backgroundSync.mjs +320 -0
  173. package/dist/src/builders/server/backgroundSync.mjs.map +1 -0
  174. package/dist/src/builders/server/computerUseBinding.cjs +273 -0
  175. package/dist/src/builders/server/computerUseBinding.cjs.map +1 -0
  176. package/dist/src/builders/server/computerUseBinding.mjs +269 -0
  177. package/dist/src/builders/server/computerUseBinding.mjs.map +1 -0
  178. package/dist/src/builders/server/computerUseRecordings.cjs +188 -0
  179. package/dist/src/builders/server/computerUseRecordings.cjs.map +1 -0
  180. package/dist/src/builders/server/computerUseRecordings.mjs +184 -0
  181. package/dist/src/builders/server/computerUseRecordings.mjs.map +1 -0
  182. package/dist/src/builders/server/defaultWorkspace.cjs +38 -0
  183. package/dist/src/builders/server/defaultWorkspace.cjs.map +1 -0
  184. package/dist/src/builders/server/defaultWorkspace.mjs +35 -0
  185. package/dist/src/builders/server/defaultWorkspace.mjs.map +1 -0
  186. package/dist/src/builders/server/idleRestart.cjs +149 -0
  187. package/dist/src/builders/server/idleRestart.cjs.map +1 -0
  188. package/dist/src/builders/server/idleRestart.mjs +136 -0
  189. package/dist/src/builders/server/idleRestart.mjs.map +1 -0
  190. package/dist/src/builders/server/index.cjs +63 -0
  191. package/dist/src/builders/server/index.cjs.map +1 -0
  192. package/dist/src/builders/server/index.mjs +60 -0
  193. package/dist/src/builders/server/index.mjs.map +1 -0
  194. package/dist/src/builders/server/logSink.cjs +57 -0
  195. package/dist/src/builders/server/logSink.cjs.map +1 -0
  196. package/dist/src/builders/server/logSink.mjs +57 -0
  197. package/dist/src/builders/server/logSink.mjs.map +1 -0
  198. package/dist/src/builders/server/mcpApp.cjs +152 -0
  199. package/dist/src/builders/server/mcpApp.cjs.map +1 -0
  200. package/dist/src/builders/server/mcpApp.d.mts +18 -0
  201. package/dist/src/builders/server/mcpApp.d.mts.map +1 -0
  202. package/dist/src/builders/server/mcpApp.mjs +147 -0
  203. package/dist/src/builders/server/mcpApp.mjs.map +1 -0
  204. package/dist/src/builders/server/mcpAppBuild.cjs +111 -0
  205. package/dist/src/builders/server/mcpAppBuild.cjs.map +1 -0
  206. package/dist/src/builders/server/mcpAppBuild.d.mts +24 -0
  207. package/dist/src/builders/server/mcpAppBuild.d.mts.map +1 -0
  208. package/dist/src/builders/server/mcpAppBuild.mjs +105 -0
  209. package/dist/src/builders/server/mcpAppBuild.mjs.map +1 -0
  210. package/dist/src/builders/server/mcpBundle.cjs +87 -0
  211. package/dist/src/builders/server/mcpBundle.cjs.map +1 -0
  212. package/dist/src/builders/server/mcpBundle.d.mts +23 -0
  213. package/dist/src/builders/server/mcpBundle.d.mts.map +1 -0
  214. package/dist/src/builders/server/mcpBundle.mjs +84 -0
  215. package/dist/src/builders/server/mcpBundle.mjs.map +1 -0
  216. package/dist/src/builders/server/packageReloadCheck.cjs +62 -0
  217. package/dist/src/builders/server/packageReloadCheck.cjs.map +1 -0
  218. package/dist/src/builders/server/packageReloadCheck.mjs +61 -0
  219. package/dist/src/builders/server/packageReloadCheck.mjs.map +1 -0
  220. package/dist/src/builders/server/packageUrl.cjs +210 -0
  221. package/dist/src/builders/server/packageUrl.cjs.map +1 -0
  222. package/dist/src/builders/server/packageUrl.mjs +203 -0
  223. package/dist/src/builders/server/packageUrl.mjs.map +1 -0
  224. package/dist/src/builders/server/runtime.cjs +1428 -0
  225. package/dist/src/builders/server/runtime.cjs.map +1 -0
  226. package/dist/src/builders/server/runtime.mjs +1420 -0
  227. package/dist/src/builders/server/runtime.mjs.map +1 -0
  228. package/dist/src/builders/server/runtimeResources.cjs +72 -0
  229. package/dist/src/builders/server/runtimeResources.cjs.map +1 -0
  230. package/dist/src/builders/server/runtimeResources.mjs +71 -0
  231. package/dist/src/builders/server/runtimeResources.mjs.map +1 -0
  232. package/dist/src/builders/server/selectionStatus.cjs +12 -0
  233. package/dist/src/builders/server/selectionStatus.cjs.map +1 -0
  234. package/dist/src/builders/server/selectionStatus.mjs +12 -0
  235. package/dist/src/builders/server/selectionStatus.mjs.map +1 -0
  236. package/dist/src/builders/server/sessionArguments.cjs +63 -0
  237. package/dist/src/builders/server/sessionArguments.cjs.map +1 -0
  238. package/dist/src/builders/server/sessionArguments.mjs +62 -0
  239. package/dist/src/builders/server/sessionArguments.mjs.map +1 -0
  240. package/dist/src/builders/server/shutdown.cjs +16 -0
  241. package/dist/src/builders/server/shutdown.cjs.map +1 -0
  242. package/dist/src/builders/server/shutdown.mjs +16 -0
  243. package/dist/src/builders/server/shutdown.mjs.map +1 -0
  244. package/dist/src/builders/server/webTemplateDecision.cjs +34 -0
  245. package/dist/src/builders/server/webTemplateDecision.cjs.map +1 -0
  246. package/dist/src/builders/server/webTemplateDecision.mjs +32 -0
  247. package/dist/src/builders/server/webTemplateDecision.mjs.map +1 -0
  248. package/dist/src/builders/server/workspaceCheckout.cjs +31 -0
  249. package/dist/src/builders/server/workspaceCheckout.cjs.map +1 -0
  250. package/dist/src/builders/server/workspaceCheckout.mjs +29 -0
  251. package/dist/src/builders/server/workspaceCheckout.mjs.map +1 -0
  252. package/dist/src/builders/web/bundle.cjs +225 -0
  253. package/dist/src/builders/web/bundle.cjs.map +1 -0
  254. package/dist/src/builders/web/bundle.d.mts +65 -0
  255. package/dist/src/builders/web/bundle.d.mts.map +1 -0
  256. package/dist/src/builders/web/bundle.mjs +221 -0
  257. package/dist/src/builders/web/bundle.mjs.map +1 -0
  258. package/dist/src/builders/web/bundleAssetPolicy.cjs +96 -0
  259. package/dist/src/builders/web/bundleAssetPolicy.cjs.map +1 -0
  260. package/dist/src/builders/web/bundleAssetPolicy.d.mts +22 -0
  261. package/dist/src/builders/web/bundleAssetPolicy.d.mts.map +1 -0
  262. package/dist/src/builders/web/bundleAssetPolicy.mjs +95 -0
  263. package/dist/src/builders/web/bundleAssetPolicy.mjs.map +1 -0
  264. package/dist/src/builders/web/index.cjs +361 -0
  265. package/dist/src/builders/web/index.cjs.map +1 -0
  266. package/dist/src/builders/web/index.d.mts +109 -0
  267. package/dist/src/builders/web/index.d.mts.map +1 -0
  268. package/dist/src/builders/web/index.mjs +342 -0
  269. package/dist/src/builders/web/index.mjs.map +1 -0
  270. package/dist/src/builders/web/webDevRoots.cjs +27 -0
  271. package/dist/src/builders/web/webDevRoots.cjs.map +1 -0
  272. package/dist/src/builders/web/webDevRoots.d.mts +22 -0
  273. package/dist/src/builders/web/webDevRoots.d.mts.map +1 -0
  274. package/dist/src/builders/web/webDevRoots.mjs +25 -0
  275. package/dist/src/builders/web/webDevRoots.mjs.map +1 -0
  276. package/dist/src/builders/web/webPluginGenerate.cjs +188 -0
  277. package/dist/src/builders/web/webPluginGenerate.cjs.map +1 -0
  278. package/dist/src/builders/web/webPluginGenerate.d.mts +56 -0
  279. package/dist/src/builders/web/webPluginGenerate.d.mts.map +1 -0
  280. package/dist/src/builders/web/webPluginGenerate.mjs +178 -0
  281. package/dist/src/builders/web/webPluginGenerate.mjs.map +1 -0
  282. package/dist/src/builders/web/webPluginManifest.cjs +128 -0
  283. package/dist/src/builders/web/webPluginManifest.cjs.map +1 -0
  284. package/dist/src/builders/web/webPluginManifest.d.mts +64 -0
  285. package/dist/src/builders/web/webPluginManifest.d.mts.map +1 -0
  286. package/dist/src/builders/web/webPluginManifest.mjs +118 -0
  287. package/dist/src/builders/web/webPluginManifest.mjs.map +1 -0
  288. package/dist/src/builders/web/webPluginScan.cjs +57 -0
  289. package/dist/src/builders/web/webPluginScan.cjs.map +1 -0
  290. package/dist/src/builders/web/webPluginScan.d.mts +19 -0
  291. package/dist/src/builders/web/webPluginScan.d.mts.map +1 -0
  292. package/dist/src/builders/web/webPluginScan.mjs +54 -0
  293. package/dist/src/builders/web/webPluginScan.mjs.map +1 -0
  294. package/dist/src/builders/web/webPluginVite.cjs +255 -0
  295. package/dist/src/builders/web/webPluginVite.cjs.map +1 -0
  296. package/dist/src/builders/web/webPluginVite.d.mts +64 -0
  297. package/dist/src/builders/web/webPluginVite.d.mts.map +1 -0
  298. package/dist/src/builders/web/webPluginVite.mjs +242 -0
  299. package/dist/src/builders/web/webPluginVite.mjs.map +1 -0
  300. package/dist/src/cli/cliApp.cjs +187 -0
  301. package/dist/src/cli/cliApp.cjs.map +1 -0
  302. package/dist/src/cli/cliApp.d.mts +32 -0
  303. package/dist/src/cli/cliApp.d.mts.map +1 -0
  304. package/dist/src/cli/cliApp.mjs +184 -0
  305. package/dist/src/cli/cliApp.mjs.map +1 -0
  306. package/dist/src/cli/commands/api-export/index.cjs +66 -0
  307. package/dist/src/cli/commands/api-export/index.cjs.map +1 -0
  308. package/dist/src/cli/commands/api-export/index.mjs +62 -0
  309. package/dist/src/cli/commands/api-export/index.mjs.map +1 -0
  310. package/dist/src/cli/commands/baseCommand.cjs +16 -0
  311. package/dist/src/cli/commands/baseCommand.cjs.map +1 -0
  312. package/dist/src/cli/commands/baseCommand.d.mts +24 -0
  313. package/dist/src/cli/commands/baseCommand.d.mts.map +1 -0
  314. package/dist/src/cli/commands/baseCommand.mjs +16 -0
  315. package/dist/src/cli/commands/baseCommand.mjs.map +1 -0
  316. package/dist/src/cli/commands/compat/context.cjs +115 -0
  317. package/dist/src/cli/commands/compat/context.cjs.map +1 -0
  318. package/dist/src/cli/commands/compat/context.d.mts +22 -0
  319. package/dist/src/cli/commands/compat/context.d.mts.map +1 -0
  320. package/dist/src/cli/commands/compat/context.mjs +110 -0
  321. package/dist/src/cli/commands/compat/context.mjs.map +1 -0
  322. package/dist/src/cli/commands/compat/help.cjs +26 -0
  323. package/dist/src/cli/commands/compat/help.cjs.map +1 -0
  324. package/dist/src/cli/commands/compat/help.d.mts +4 -0
  325. package/dist/src/cli/commands/compat/help.d.mts.map +1 -0
  326. package/dist/src/cli/commands/compat/help.mjs +25 -0
  327. package/dist/src/cli/commands/compat/help.mjs.map +1 -0
  328. package/dist/src/cli/commands/compat/index.cjs +73 -0
  329. package/dist/src/cli/commands/compat/index.cjs.map +1 -0
  330. package/dist/src/cli/commands/compat/index.d.mts +14 -0
  331. package/dist/src/cli/commands/compat/index.d.mts.map +1 -0
  332. package/dist/src/cli/commands/compat/index.mjs +70 -0
  333. package/dist/src/cli/commands/compat/index.mjs.map +1 -0
  334. package/dist/src/cli/commands/compat/options.cjs +88 -0
  335. package/dist/src/cli/commands/compat/options.cjs.map +1 -0
  336. package/dist/src/cli/commands/compat/options.d.mts +15 -0
  337. package/dist/src/cli/commands/compat/options.d.mts.map +1 -0
  338. package/dist/src/cli/commands/compat/options.mjs +86 -0
  339. package/dist/src/cli/commands/compat/options.mjs.map +1 -0
  340. package/dist/src/cli/commands/compat/providers/antigravity.cjs +294 -0
  341. package/dist/src/cli/commands/compat/providers/antigravity.cjs.map +1 -0
  342. package/dist/src/cli/commands/compat/providers/antigravity.d.mts +9 -0
  343. package/dist/src/cli/commands/compat/providers/antigravity.d.mts.map +1 -0
  344. package/dist/src/cli/commands/compat/providers/antigravity.mjs +289 -0
  345. package/dist/src/cli/commands/compat/providers/antigravity.mjs.map +1 -0
  346. package/dist/src/cli/commands/compat/providers/codex.cjs +178 -0
  347. package/dist/src/cli/commands/compat/providers/codex.cjs.map +1 -0
  348. package/dist/src/cli/commands/compat/providers/codex.d.mts +17 -0
  349. package/dist/src/cli/commands/compat/providers/codex.d.mts.map +1 -0
  350. package/dist/src/cli/commands/compat/providers/codex.mjs +170 -0
  351. package/dist/src/cli/commands/compat/providers/codex.mjs.map +1 -0
  352. package/dist/src/cli/commands/compat/providers/index.cjs +65 -0
  353. package/dist/src/cli/commands/compat/providers/index.cjs.map +1 -0
  354. package/dist/src/cli/commands/compat/providers/index.d.mts +15 -0
  355. package/dist/src/cli/commands/compat/providers/index.d.mts.map +1 -0
  356. package/dist/src/cli/commands/compat/providers/index.mjs +45 -0
  357. package/dist/src/cli/commands/compat/providers/index.mjs.map +1 -0
  358. package/dist/src/cli/commands/compat/providers/process.cjs +172 -0
  359. package/dist/src/cli/commands/compat/providers/process.cjs.map +1 -0
  360. package/dist/src/cli/commands/compat/providers/process.d.mts +33 -0
  361. package/dist/src/cli/commands/compat/providers/process.d.mts.map +1 -0
  362. package/dist/src/cli/commands/compat/providers/process.mjs +159 -0
  363. package/dist/src/cli/commands/compat/providers/process.mjs.map +1 -0
  364. package/dist/src/cli/commands/compat/providers/shared.cjs +76 -0
  365. package/dist/src/cli/commands/compat/providers/shared.cjs.map +1 -0
  366. package/dist/src/cli/commands/compat/providers/shared.d.mts +40 -0
  367. package/dist/src/cli/commands/compat/providers/shared.d.mts.map +1 -0
  368. package/dist/src/cli/commands/compat/providers/shared.mjs +61 -0
  369. package/dist/src/cli/commands/compat/providers/shared.mjs.map +1 -0
  370. package/dist/src/cli/commands/compat/types.d.mts +31 -0
  371. package/dist/src/cli/commands/compat/types.d.mts.map +1 -0
  372. package/dist/src/cli/commands/doctor/help.cjs +19 -0
  373. package/dist/src/cli/commands/doctor/help.cjs.map +1 -0
  374. package/dist/src/cli/commands/doctor/help.d.mts +4 -0
  375. package/dist/src/cli/commands/doctor/help.d.mts.map +1 -0
  376. package/dist/src/cli/commands/doctor/help.mjs +19 -0
  377. package/dist/src/cli/commands/doctor/help.mjs.map +1 -0
  378. package/dist/src/cli/commands/doctor/index.cjs +118 -0
  379. package/dist/src/cli/commands/doctor/index.cjs.map +1 -0
  380. package/dist/src/cli/commands/doctor/index.d.mts +33 -0
  381. package/dist/src/cli/commands/doctor/index.d.mts.map +1 -0
  382. package/dist/src/cli/commands/doctor/index.mjs +113 -0
  383. package/dist/src/cli/commands/doctor/index.mjs.map +1 -0
  384. package/dist/src/cli/commands/emit-mcp/index.cjs +32 -0
  385. package/dist/src/cli/commands/emit-mcp/index.cjs.map +1 -0
  386. package/dist/src/cli/commands/emit-mcp/index.d.mts +19 -0
  387. package/dist/src/cli/commands/emit-mcp/index.d.mts.map +1 -0
  388. package/dist/src/cli/commands/emit-mcp/index.mjs +31 -0
  389. package/dist/src/cli/commands/emit-mcp/index.mjs.map +1 -0
  390. package/dist/src/cli/commands/explain/index.cjs +155 -0
  391. package/dist/src/cli/commands/explain/index.cjs.map +1 -0
  392. package/dist/src/cli/commands/explain/index.d.mts +57 -0
  393. package/dist/src/cli/commands/explain/index.d.mts.map +1 -0
  394. package/dist/src/cli/commands/explain/index.mjs +150 -0
  395. package/dist/src/cli/commands/explain/index.mjs.map +1 -0
  396. package/dist/src/cli/commands/init/constants.cjs +11 -0
  397. package/dist/src/cli/commands/init/constants.cjs.map +1 -0
  398. package/dist/src/cli/commands/init/constants.mjs +11 -0
  399. package/dist/src/cli/commands/init/constants.mjs.map +1 -0
  400. package/dist/src/cli/commands/init/help.cjs +17 -0
  401. package/dist/src/cli/commands/init/help.cjs.map +1 -0
  402. package/dist/src/cli/commands/init/help.d.mts +4 -0
  403. package/dist/src/cli/commands/init/help.d.mts.map +1 -0
  404. package/dist/src/cli/commands/init/help.mjs +17 -0
  405. package/dist/src/cli/commands/init/help.mjs.map +1 -0
  406. package/dist/src/cli/commands/init/index.cjs +67 -0
  407. package/dist/src/cli/commands/init/index.cjs.map +1 -0
  408. package/dist/src/cli/commands/init/index.d.mts +12 -0
  409. package/dist/src/cli/commands/init/index.d.mts.map +1 -0
  410. package/dist/src/cli/commands/init/index.mjs +63 -0
  411. package/dist/src/cli/commands/init/index.mjs.map +1 -0
  412. package/dist/src/cli/commands/init/presenter.cjs +140 -0
  413. package/dist/src/cli/commands/init/presenter.cjs.map +1 -0
  414. package/dist/src/cli/commands/init/presenter.d.mts +8 -0
  415. package/dist/src/cli/commands/init/presenter.d.mts.map +1 -0
  416. package/dist/src/cli/commands/init/presenter.mjs +140 -0
  417. package/dist/src/cli/commands/init/presenter.mjs.map +1 -0
  418. package/dist/src/cli/commands/sync/help.cjs +34 -0
  419. package/dist/src/cli/commands/sync/help.cjs.map +1 -0
  420. package/dist/src/cli/commands/sync/help.d.mts +4 -0
  421. package/dist/src/cli/commands/sync/help.d.mts.map +1 -0
  422. package/dist/src/cli/commands/sync/help.mjs +34 -0
  423. package/dist/src/cli/commands/sync/help.mjs.map +1 -0
  424. package/dist/src/cli/commands/sync/index.cjs +215 -0
  425. package/dist/src/cli/commands/sync/index.cjs.map +1 -0
  426. package/dist/src/cli/commands/sync/index.d.mts +20 -0
  427. package/dist/src/cli/commands/sync/index.d.mts.map +1 -0
  428. package/dist/src/cli/commands/sync/index.mjs +206 -0
  429. package/dist/src/cli/commands/sync/index.mjs.map +1 -0
  430. package/dist/src/cli/commands/sync/presenter.cjs +58 -0
  431. package/dist/src/cli/commands/sync/presenter.cjs.map +1 -0
  432. package/dist/src/cli/commands/sync/presenter.d.mts +16 -0
  433. package/dist/src/cli/commands/sync/presenter.d.mts.map +1 -0
  434. package/dist/src/cli/commands/sync/presenter.mjs +57 -0
  435. package/dist/src/cli/commands/sync/presenter.mjs.map +1 -0
  436. package/dist/src/cli/commands/sync/workflow.cjs +16 -0
  437. package/dist/src/cli/commands/sync/workflow.cjs.map +1 -0
  438. package/dist/src/cli/commands/sync/workflow.mjs +16 -0
  439. package/dist/src/cli/commands/sync/workflow.mjs.map +1 -0
  440. package/dist/src/cli/commands/web/index.cjs +88 -0
  441. package/dist/src/cli/commands/web/index.cjs.map +1 -0
  442. package/dist/src/cli/commands/web/index.mjs +85 -0
  443. package/dist/src/cli/commands/web/index.mjs.map +1 -0
  444. package/dist/src/cli/harnessOptions.cjs +70 -0
  445. package/dist/src/cli/harnessOptions.cjs.map +1 -0
  446. package/dist/src/cli/harnessOptions.d.mts +26 -0
  447. package/dist/src/cli/harnessOptions.d.mts.map +1 -0
  448. package/dist/src/cli/harnessOptions.mjs +66 -0
  449. package/dist/src/cli/harnessOptions.mjs.map +1 -0
  450. package/dist/src/cli/help.cjs +82 -0
  451. package/dist/src/cli/help.cjs.map +1 -0
  452. package/dist/src/cli/help.d.mts +10 -0
  453. package/dist/src/cli/help.d.mts.map +1 -0
  454. package/dist/src/cli/help.mjs +78 -0
  455. package/dist/src/cli/help.mjs.map +1 -0
  456. package/dist/src/cli/matrixOptions.cjs +178 -0
  457. package/dist/src/cli/matrixOptions.cjs.map +1 -0
  458. package/dist/src/cli/matrixOptions.d.mts +90 -0
  459. package/dist/src/cli/matrixOptions.d.mts.map +1 -0
  460. package/dist/src/cli/matrixOptions.mjs +151 -0
  461. package/dist/src/cli/matrixOptions.mjs.map +1 -0
  462. package/dist/src/cli/options.cjs +281 -0
  463. package/dist/src/cli/options.cjs.map +1 -0
  464. package/dist/src/cli/options.d.mts +5 -0
  465. package/dist/src/cli/options.d.mts.map +1 -0
  466. package/dist/src/cli/options.mjs +279 -0
  467. package/dist/src/cli/options.mjs.map +1 -0
  468. package/dist/src/cli/router.cjs +57 -0
  469. package/dist/src/cli/router.cjs.map +1 -0
  470. package/dist/src/cli/router.d.mts +32 -0
  471. package/dist/src/cli/router.d.mts.map +1 -0
  472. package/dist/src/cli/router.mjs +54 -0
  473. package/dist/src/cli/router.mjs.map +1 -0
  474. package/dist/src/cli/server/options.cjs +71 -0
  475. package/dist/src/cli/server/options.cjs.map +1 -0
  476. package/dist/src/cli/server/options.mjs +70 -0
  477. package/dist/src/cli/server/options.mjs.map +1 -0
  478. package/dist/src/cli/server/processGuards.cjs +83 -0
  479. package/dist/src/cli/server/processGuards.cjs.map +1 -0
  480. package/dist/src/cli/server/processGuards.mjs +79 -0
  481. package/dist/src/cli/server/processGuards.mjs.map +1 -0
  482. package/dist/src/cli/server/run.cjs +69 -0
  483. package/dist/src/cli/server/run.cjs.map +1 -0
  484. package/dist/src/cli/server/run.mjs +66 -0
  485. package/dist/src/cli/server/run.mjs.map +1 -0
  486. package/dist/src/composition/harnessState/index.cjs +48 -0
  487. package/dist/src/composition/harnessState/index.cjs.map +1 -0
  488. package/dist/src/composition/harnessState/index.d.mts +19 -0
  489. package/dist/src/composition/harnessState/index.d.mts.map +1 -0
  490. package/dist/src/composition/harnessState/index.mjs +34 -0
  491. package/dist/src/composition/harnessState/index.mjs.map +1 -0
  492. package/dist/src/composition/layerPackageInstaller/index.cjs +651 -0
  493. package/dist/src/composition/layerPackageInstaller/index.cjs.map +1 -0
  494. package/dist/src/composition/layerPackageInstaller/index.d.mts +74 -0
  495. package/dist/src/composition/layerPackageInstaller/index.d.mts.map +1 -0
  496. package/dist/src/composition/layerPackageInstaller/index.mjs +637 -0
  497. package/dist/src/composition/layerPackageInstaller/index.mjs.map +1 -0
  498. package/dist/src/composition/poHomeMigration/index.cjs +234 -0
  499. package/dist/src/composition/poHomeMigration/index.cjs.map +1 -0
  500. package/dist/src/composition/poHomeMigration/index.d.mts +12 -0
  501. package/dist/src/composition/poHomeMigration/index.d.mts.map +1 -0
  502. package/dist/src/composition/poHomeMigration/index.mjs +226 -0
  503. package/dist/src/composition/poHomeMigration/index.mjs.map +1 -0
  504. package/dist/src/composition/projectTrust/index.cjs +51 -0
  505. package/dist/src/composition/projectTrust/index.cjs.map +1 -0
  506. package/dist/src/composition/projectTrust/index.d.mts +22 -0
  507. package/dist/src/composition/projectTrust/index.d.mts.map +1 -0
  508. package/dist/src/composition/projectTrust/index.mjs +48 -0
  509. package/dist/src/composition/projectTrust/index.mjs.map +1 -0
  510. package/dist/src/composition/repository/index.cjs +68 -0
  511. package/dist/src/composition/repository/index.cjs.map +1 -0
  512. package/dist/src/composition/repository/index.d.mts +22 -0
  513. package/dist/src/composition/repository/index.d.mts.map +1 -0
  514. package/dist/src/composition/repository/index.mjs +63 -0
  515. package/dist/src/composition/repository/index.mjs.map +1 -0
  516. package/dist/src/composition/syncPrune/index.cjs +85 -0
  517. package/dist/src/composition/syncPrune/index.cjs.map +1 -0
  518. package/dist/src/composition/syncPrune/index.d.mts +33 -0
  519. package/dist/src/composition/syncPrune/index.d.mts.map +1 -0
  520. package/dist/src/composition/syncPrune/index.mjs +82 -0
  521. package/dist/src/composition/syncPrune/index.mjs.map +1 -0
  522. package/dist/src/composition/syncService/index.cjs +808 -0
  523. package/dist/src/composition/syncService/index.cjs.map +1 -0
  524. package/dist/src/composition/syncService/index.d.mts +65 -0
  525. package/dist/src/composition/syncService/index.d.mts.map +1 -0
  526. package/dist/src/composition/syncService/index.mjs +792 -0
  527. package/dist/src/composition/syncService/index.mjs.map +1 -0
  528. package/dist/src/composition/syncService/localBuilds.cjs +367 -0
  529. package/dist/src/composition/syncService/localBuilds.cjs.map +1 -0
  530. package/dist/src/composition/syncService/localBuilds.mjs +358 -0
  531. package/dist/src/composition/syncService/localBuilds.mjs.map +1 -0
  532. package/dist/src/composition/transitionLayers.cjs +17 -0
  533. package/dist/src/composition/transitionLayers.cjs.map +1 -0
  534. package/dist/src/composition/transitionLayers.d.mts +6 -0
  535. package/dist/src/composition/transitionLayers.d.mts.map +1 -0
  536. package/dist/src/composition/transitionLayers.mjs +16 -0
  537. package/dist/src/composition/transitionLayers.mjs.map +1 -0
  538. package/dist/src/composition/types/harness.d.mts +52 -0
  539. package/dist/src/composition/types/harness.d.mts.map +1 -0
  540. package/dist/src/extensions/setupDiagnostics.cjs +65 -0
  541. package/dist/src/extensions/setupDiagnostics.cjs.map +1 -0
  542. package/dist/src/extensions/setupDiagnostics.mjs +64 -0
  543. package/dist/src/extensions/setupDiagnostics.mjs.map +1 -0
  544. package/dist/utils.cjs +4 -0
  545. package/dist/utils.d.mts +2 -0
  546. package/dist/utils.mjs +2 -0
  547. package/dist/webBuilder.cjs +59 -0
  548. package/dist/webBuilder.d.mts +9 -0
  549. package/dist/webBuilder.mjs +9 -0
  550. package/docs/server/api-export.md +86 -0
  551. package/docs/server/api.md +144 -0
  552. package/docs/server/getting-started.md +114 -0
  553. package/docs/server/index.md +67 -0
  554. package/docs/server/ipc.md +97 -0
  555. package/docs/server/lifecycle.md +108 -0
  556. package/docs/server/security.md +101 -0
  557. package/llms.txt +12 -0
  558. package/package.json +295 -0
  559. package/src/prompts/po-author-extension/SKILL.md +35 -0
  560. package/src/prompts/po-author-extension/references/extension-contract.md +134 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../../../../src/composition/syncService/index.ts"],"sourcesContent":["import { spawnSync } from 'node:child_process';\nimport crypto from 'node:crypto';\nimport fs from 'node:fs';\nimport path from 'node:path';\n\nimport { globalDoomConfigDirectory } from '@agimon-ai/po-config/config';\nimport { isLocalPackageSpecifier, loadMajorModesConfigLenient } from '@agimon-ai/po-config/majorModes';\nimport {\n createWorkspaceRegistry,\n identifyWorkspace,\n readWorkspaceMarker,\n type WorkspaceRegistry,\n writeWorkspaceMarker,\n} from '@agimon-ai/po-core/history';\nimport { piAgentDirectory } from '@agimon-ai/po-core/piSettings';\nimport { writeFileAtomic } from '@agimon-ai/po-core/runtimeJson';\n\nimport { poPackageRoot } from '../../builders/cli/entryResolution';\nimport { rootCompositions } from '../../builders/cli/sessionComposition';\nimport { ensureGlobalNativeBuild } from '../../builders/native';\nimport { ensureMcpAppBuild } from '../../builders/server/mcpAppBuild';\nimport { mcpPluginCandidates } from '../../builders/server/mcpBundle';\nimport {\n BUILD_RECORD,\n compositionPackageRoots,\n duplicatePluginCopies,\n ensureGlobalWebBuild,\n webHostVersion,\n} from '../../builders/web';\nimport {\n catalogInstallSpecifiers,\n catalogPackageRoots,\n ensureLayerPackages,\n type LayerPackageResult,\n packageCatalogHash,\n runtimeLayerPackageSpecifiers,\n} from '../layerPackageInstaller';\nimport { pruneAfterSync, type SyncPruneInput } from '../syncPrune';\nimport { buildLocalPackages, type LocalPackage, localBuildStamp } from './localBuilds';\n\nexport { localBuildStamp } from './localBuilds';\n\n/**\n * The sync service: installs what the configuration names, ensures the global builds,\n * prunes, and reports what happened as one `SyncReport`.\n *\n * The roots are the Po home, every registered workspace whose folder exists, and the\n * repository sync runs from, which it registers. One install covers the catalogue and every\n * root's published packages. When the signature over the catalogue, each root's selection,\n * each local package's build stamp and the host identity (the po package and po-web host\n * versions) matches `current.json` and every artifact it names exists, sync returns `noop`\n * without installing or building. The pointer records that identity, so a server from another\n * Po install can tell the build is not its own.\n *\n * Only one sync runs at a time per Po home, guarded by `<po home>/build/.sync.lock`. A CLI\n * run that finds the lock held reports `busy`. A background run instead leaves\n * `.sync.rerun`, and the holder runs once more, so the background request is never lost.\n */\n\nconst BUILD_DIRECTORY = 'build';\nconst LOCK_FILE = '.sync.lock';\nconst RERUN_FILE = '.sync.rerun';\nconst POINTER_FILE = 'current.json';\nconst LAST_ATTEMPT_FILE = 'last-attempt.json';\nconst MCP_APP_FILE = 'index.html';\nconst HOOK_EMITTER = path.join('tools', 'harness', 'emit-hooks.mjs');\nconst ROOTS_LABEL = 'roots';\nconst PACKAGES_LABEL = 'packages';\nconst WEB_LABEL = 'web';\nconst NATIVE_LABEL = 'native';\nconst MCP_LABEL = 'mcp app';\nconst PRUNE_LABEL = 'prune';\nconst HOOKS_LABEL = 'hooks';\nconst LOCAL_LABEL = 'local';\nconst BYTES_PER_MEGABYTE = 1024 * 1024;\n/** A lock file younger than this that cannot be parsed is still being written by its owner. */\nconst UNREADABLE_LOCK_GRACE_MS = 10_000;\nconst NO_SUCH_PROCESS = 'ESRCH';\n/**\n * Bumped when the pointer gains a field a reader relies on, so an older pointer never matches\n * the fast-exit signature and the next sync rewrites it. 2: per-root `fingerprints`. 3: `host`.\n */\nconst SIGNATURE_FORMAT = 3;\nconst PACKAGE_MANIFEST = 'package.json';\nconst ALREADY_EXISTS = 'EEXIST';\nconst NO_SUCH_FILE = 'ENOENT';\n\nexport const SYNC_EXIT_OK = 0;\nexport const SYNC_EXIT_FAILED = 1;\n/** EX_TEMPFAIL: another sync holds the lock. */\nexport const SYNC_EXIT_BUSY = 75;\n\nexport type SyncOrigin = 'cli' | 'background';\nexport type SyncStatus = 'ok' | 'noop' | 'partial' | 'failed' | 'busy';\n\nexport interface SyncResult {\n packages: Pick<LayerPackageResult, 'installed' | 'updated' | 'unchecked'>;\n /** The global web build key, or why there is none. */\n web: { status: 'built' | 'cached'; key: string } | { status: 'skipped'; reason: string };\n /** The global native build key, or why there is none. */\n native?: { status: 'built' | 'cached'; key: string } | { status: 'skipped'; reason: string };\n /** The MCP app build keys, comma separated, when any root's packages declare MCP UI widgets. */\n mcpApp?: string;\n}\n\nexport interface SyncRootReport {\n root: string;\n status: 'ok' | 'partial' | 'failed';\n unsynced: { selector: string; reason: string; stderr?: string[] }[];\n}\n\nexport interface SyncReport {\n status: SyncStatus;\n /** Assigned once sync writes a pointer; null until then. */\n generation: number | null;\n /** Assigned once sync computes the fast-exit signature; null until then. */\n catalogueHash: string | null;\n webKey: string | null;\n mcpKeys: string[];\n roots: SyncRootReport[];\n /** External commands sync ran, such as local package builds. */\n commands: string[];\n errors: string[];\n finishedAt: string;\n}\n\n/** One progress event; the CLI renders these as text or as JSON lines. */\nexport type SyncEvent =\n | { type: 'start'; label: string; message: string }\n | { type: 'line'; label: string; message: string }\n | { type: 'done'; label: string; summary: string }\n | { type: 'result'; result: SyncResult };\n\nexport interface SyncLockHolder {\n pid: number;\n /** Unique per acquisition, so a holder can tell its lock from a later one, even under its pid. */\n token?: string;\n startedAt: string;\n origin: SyncOrigin;\n}\n\nexport interface SyncOptions {\n homeDirectory: string;\n environment: NodeJS.ProcessEnv;\n /** The Po home every global build and the lock live under. */\n globalRoot: string;\n /**\n * The repository sync runs from: registered as a workspace, synced as a root, and its hooks\n * regenerated. Undefined with `--global`, which registers nothing.\n */\n repoRoot?: string;\n origin: SyncOrigin;\n onEvent?: (event: SyncEvent) => void;\n}\n\nexport interface SyncDeps {\n install: typeof ensureLayerPackages;\n buildWeb: typeof ensureGlobalWebBuild;\n buildNative: typeof ensureGlobalNativeBuild;\n bundleMcpApp: typeof ensureMcpAppBuild;\n prune: typeof pruneAfterSync;\n /** Whether a lock holder's process still runs. */\n isAlive: (pid: number) => boolean;\n pid: number;\n now: () => Date;\n}\n\n/** `process.kill(pid, 0)` probes without signalling; only ESRCH means the process is gone. */\nexport function processIsAlive(pid: number): boolean {\n try {\n process.kill(pid, 0);\n return true;\n } catch (error) {\n // EPERM means it runs under another user, which still holds the lock.\n return (error as NodeJS.ErrnoException).code !== NO_SUCH_PROCESS;\n }\n}\n\nconst DEFAULT_DEPS: SyncDeps = {\n install: ensureLayerPackages,\n buildWeb: ensureGlobalWebBuild,\n buildNative: ensureGlobalNativeBuild,\n bundleMcpApp: ensureMcpAppBuild,\n prune: pruneAfterSync,\n isAlive: processIsAlive,\n pid: process.pid,\n now: () => new Date(),\n};\n\nexport function syncExitCode(status: SyncStatus): number {\n if (status === 'busy') return SYNC_EXIT_BUSY;\n return status === 'ok' || status === 'noop' ? SYNC_EXIT_OK : SYNC_EXIT_FAILED;\n}\n\nexport function syncLockPath(globalRoot: string): string {\n return path.join(globalRoot, BUILD_DIRECTORY, LOCK_FILE);\n}\n\nexport function syncRerunPath(globalRoot: string): string {\n return path.join(globalRoot, BUILD_DIRECTORY, RERUN_FILE);\n}\n\nfunction pluralize(count: number, noun: string): string {\n return `${String(count)} ${noun}${count === 1 ? '' : 's'}`;\n}\n\nfunction errorMessage(error: unknown): string {\n return error instanceof Error ? error.message : String(error);\n}\n\nfunction packageSummary(result: SyncResult['packages']): string {\n const parts: string[] = [];\n if (result.updated.length > 0) parts.push(`updated ${pluralize(result.updated.length, 'package')}`);\n if (result.installed.length > 0) parts.push(`installed ${pluralize(result.installed.length, 'missing package')}`);\n if (parts.length === 0) parts.push('already up to date');\n if (result.unchecked.length > 0) parts.push(`${pluralize(result.unchecked.length, 'package')} left unchecked`);\n return parts.join(', ');\n}\n\nexport function formatSyncResult(result: SyncResult): string {\n return [\n `packages: ${packageSummary(result.packages)}`,\n `web: ${result.web.status === 'skipped' ? result.web.reason : `${result.web.key} (${result.web.status})`}`,\n ...(result.native === undefined\n ? []\n : [\n `native: ${result.native.status === 'skipped' ? result.native.reason : `${result.native.key} (${result.native.status})`}`,\n ]),\n ...(result.mcpApp === undefined ? [] : [`mcp app: ${result.mcpApp}`]),\n '',\n ].join('\\n');\n}\n\nfunction workspaceRegistry(\n homeDirectory: string,\n environment: NodeJS.ProcessEnv,\n onNotice: (message: string) => void,\n): WorkspaceRegistry {\n return createWorkspaceRegistry({\n directory: path.join(piAgentDirectory(environment, homeDirectory), 'server'),\n onNotice,\n });\n}\n\ntype RootCompositions = ReturnType<typeof rootCompositions>;\n\n/**\n * Each root's compositions, resolved the way the server resolves them: a selection that does\n * not resolve yet (an unbuilt local package, say) is left out with a diagnostic instead of\n * failing the whole root, so sync and the server derive the same web, MCP and fingerprint\n * inputs. A root that cannot be composed at all maps to why.\n */\nfunction composeRoots(\n roots: readonly string[],\n homeDirectory: string,\n environment: NodeJS.ProcessEnv,\n): Map<string, RootCompositions | Error> {\n return new Map(\n roots.map((root): [string, RootCompositions | Error] => {\n try {\n return [root, rootCompositions({ root, homeDirectory, environment, tolerateUnsynced: true })];\n } catch (error) {\n return [root, error instanceof Error ? error : new Error(String(error))];\n }\n }),\n );\n}\n\n/** Each root's composition package roots; a root that cannot be composed is left out with a notice. */\nfunction packageRootsByRoot(\n composed: ReadonlyMap<string, RootCompositions | Error>,\n onNotice: (message: string) => void,\n): Map<string, string[]> {\n return new Map(\n [...composed].map(([root, compositions]) => {\n if (!(compositions instanceof Error)) return [root, compositionPackageRoots(compositions)];\n onNotice(`'${root}' is left out of the web build: ${compositions.message}`);\n return [root, []];\n }),\n );\n}\n\n/** The selectors a lenient composition left out, each once with the first diagnostic that explains it. */\nfunction skippedSelections(compositions: RootCompositions): SyncRootReport['unsynced'] {\n const skipped = new Map<string, string>();\n for (const composition of compositions)\n for (const selection of composition.selections)\n if (selection.outcome === 'missing-optional' && !selection.optional && !skipped.has(selection.selector))\n skipped.set(selection.selector, selection.diagnostic ?? 'it does not resolve');\n return [...skipped].map(([selector, reason]) => ({ selector, reason }));\n}\n\n/**\n * The plugin roots one global web build covers: every installed catalogue package, so each\n * first-party plugin has a slot whether or not a config names it yet, then each root's own\n * composition package roots. Sync builds with these and the server derives the same key.\n */\nfunction webPluginRootsOf(\n globalRoot: string,\n rootPackageRoots: ReadonlyMap<string, readonly string[]>,\n environment: NodeJS.ProcessEnv,\n): string[] {\n return [...catalogPackageRoots(globalRoot, environment), ...[...rootPackageRoots.values()].flat()];\n}\n\n/**\n * Every package root the global web build covers: the catalogue packages, the global root,\n * every workspace the server has admitted, and `targetRoot`, which the server admits when it\n * opens it. A root whose configuration cannot be read is left out with a notice, as sync\n * leaves it out of the build when it cannot compose it.\n */\nexport function globalWebPluginRoots(\n targetRoot: string,\n homeDirectory: string,\n environment: NodeJS.ProcessEnv,\n onNotice: (message: string) => void,\n): string[] {\n const globalRoot = globalDoomConfigDirectory(homeDirectory);\n const admitted = workspaceRegistry(homeDirectory, environment, onNotice)\n .list()\n .map((workspace) => workspace.root)\n .filter((root) => fs.existsSync(root));\n const roots = [...new Set([globalRoot, ...admitted, targetRoot])];\n return webPluginRootsOf(\n globalRoot,\n packageRootsByRoot(composeRoots(roots, homeDirectory, environment), onNotice),\n environment,\n );\n}\n\n/**\n * Registers the repository as a workspace the way the server admits one, so one repository\n * never gets two ids, and returns the workspace root it belongs to.\n */\nfunction registerRepository(\n registry: WorkspaceRegistry,\n repoRoot: string,\n onNotice: (message: string) => void,\n): string {\n const checkoutRoot = fs.realpathSync(repoRoot);\n const { id, root, moved } = identifyWorkspace({\n records: registry.list(),\n checkoutRoot,\n marker: readWorkspaceMarker(checkoutRoot),\n });\n const record = registry.list().find((workspace) => workspace.id === id);\n if (record === undefined || moved)\n registry.add({ id, root, ...(record?.name === undefined ? {} : { name: record.name }) });\n if (moved) onNotice(`workspace '${id}' moved to '${root}'`);\n try {\n if (readWorkspaceMarker(root) === undefined) writeWorkspaceMarker(root, id);\n } catch (error) {\n onNotice(`'${root}' id could not be recorded in its git data: ${errorMessage(error)}`);\n }\n return root;\n}\n\n/**\n * The roots this sync covers: the Po home, every registered workspace whose folder exists,\n * and the repository, registered first. Entries whose folder is gone are removed with a warning.\n */\nfunction resolveRoots(options: SyncOptions, progress: Steps): string[] {\n const notice = (message: string): void => progress.line(ROOTS_LABEL, message);\n const registry = workspaceRegistry(options.homeDirectory, options.environment, notice);\n const repository =\n options.repoRoot === undefined || path.resolve(options.repoRoot) === path.resolve(options.globalRoot)\n ? undefined\n : registerRepository(registry, options.repoRoot, notice);\n const live: string[] = [];\n for (const workspace of registry.list()) {\n if (fs.existsSync(workspace.root)) {\n live.push(workspace.root);\n continue;\n }\n notice(`warning: removed workspace '${workspace.id}': '${workspace.root}' no longer exists`);\n registry.remove(workspace.id);\n }\n return [...new Set([options.globalRoot, ...live, ...(repository === undefined ? [] : [repository])])];\n}\n\n/** The packages a root's layers name by local path, each resolved against its layer's base directory. */\nfunction localPackages(config: ReturnType<typeof loadMajorModesConfigLenient>['config']): LocalPackage[] {\n const definitions = [...(config.default ? [config.default] : []), ...Object.values(config.layers)];\n const packages = new Map<string, LocalPackage>();\n for (const definition of definitions)\n for (const configured of definition.packages ?? []) {\n const selector = typeof configured === 'string' ? configured : configured.name;\n if (!isLocalPackageSpecifier(selector)) continue;\n const directory = path.resolve(definition.baseDirectory, selector);\n if (!packages.has(directory)) packages.set(directory, { selector, directory });\n }\n return [...packages.values()];\n}\n\n/**\n * SHA-256 over every mode's composition fingerprint, or why the root cannot be composed. The\n * pointer records it per root, so a server can tell a root whose selection changed since the\n * last sync by computing it again with the environment sync ran under.\n */\nexport function rootSelectionFingerprint(root: string, homeDirectory: string, environment: NodeJS.ProcessEnv): string {\n try {\n const fingerprints = rootCompositions({ root, homeDirectory, environment, tolerateUnsynced: true }).map(\n (composition) => composition.fingerprint,\n );\n return crypto.createHash('sha256').update(fingerprints.join('\\n')).digest('hex');\n } catch (error) {\n return `unresolved:${errorMessage(error)}`;\n }\n}\n\n/** The po package version this process runs from, or why it cannot be read. */\nfunction poPackageVersion(): string {\n try {\n const manifest = JSON.parse(fs.readFileSync(path.join(poPackageRoot(), PACKAGE_MANIFEST), 'utf8')) as {\n version?: unknown;\n };\n return typeof manifest.version === 'string' ? manifest.version : 'unversioned';\n } catch (error) {\n return `unreadable:${errorMessage(error)}`;\n }\n}\n\n/**\n * The Po install a sync or a server runs from: its po package version and the po-web host\n * version it builds with. Sync records it in the pointer; a server whose identity differs\n * refuses that pointer's builds and syncs with its own install.\n */\nexport function syncHostIdentity(globalRoot: string, environment: NodeJS.ProcessEnv): string {\n return `po@${poPackageVersion()}+po-web@${webHostVersion(globalRoot, environment)}`;\n}\n\n/** The fast-exit signature: catalogue hash, each root's selection and local build stamps, host identity. */\nfunction syncSignature(options: SyncOptions, roots: readonly string[], catalogueHash: string): string {\n const { homeDirectory, environment } = options;\n const value = {\n format: SIGNATURE_FORMAT,\n catalogueHash,\n roots: roots.map((root) => ({\n root,\n selection: rootSelectionFingerprint(root, homeDirectory, environment),\n local: localPackages(loadMajorModesConfigLenient(root, homeDirectory, environment).config).map(\n ({ directory }) => [directory, localBuildStamp(directory)],\n ),\n })),\n host: syncHostIdentity(options.globalRoot, environment),\n };\n return crypto.createHash('sha256').update(JSON.stringify(value)).digest('hex');\n}\n\n/** `current.json`: the last successful report minus its transient fields, plus what fast exit needs. */\nexport interface SyncPointer {\n generation: number;\n signature: string;\n catalogueHash: string;\n webKey: string | null;\n nativeKey: string | null;\n mcpKeys: string[];\n roots: SyncRootReport[];\n commands: string[];\n /** Each root's `rootSelectionFingerprint` at the time of the sync; absent in older pointers. */\n fingerprints?: Record<string, string>;\n /** The `syncHostIdentity` of the install that wrote the pointer; absent in older pointers. */\n host?: string;\n}\n\nexport function syncPointerPath(globalRoot: string): string {\n return path.join(globalRoot, BUILD_DIRECTORY, POINTER_FILE);\n}\n\nexport function syncLastAttemptPath(globalRoot: string): string {\n return path.join(globalRoot, BUILD_DIRECTORY, LAST_ATTEMPT_FILE);\n}\n\n/** The current pointer, or undefined when sync has not written one yet or it is unreadable. */\nexport function readSyncPointer(globalRoot: string): SyncPointer | undefined {\n try {\n const parsed = JSON.parse(fs.readFileSync(syncPointerPath(globalRoot), 'utf8')) as Partial<SyncPointer>;\n return typeof parsed.signature === 'string' && typeof parsed.generation === 'number'\n ? (parsed as SyncPointer)\n : undefined;\n } catch {\n // Missing or unreadable: there is nothing to fast-exit against.\n return undefined;\n }\n}\n\n/** The files whose presence proves each artifact a pointer names is complete. */\nfunction pointerArtifacts(\n globalRoot: string,\n pointer: Pick<SyncPointer, 'webKey' | 'nativeKey' | 'mcpKeys'>,\n): string[] {\n const build = path.join(globalRoot, BUILD_DIRECTORY);\n return [\n ...(pointer.webKey === null ? [] : [path.join(build, WEB_LABEL, pointer.webKey, BUILD_RECORD)]),\n ...(pointer.nativeKey === null ? [] : [path.join(build, NATIVE_LABEL, pointer.nativeKey, BUILD_RECORD)]),\n ...pointer.mcpKeys.map((key) => path.join(build, 'mcp-app', key, MCP_APP_FILE)),\n ];\n}\n\n/** The report of the last sync attempt, successful or not, or undefined when there is none. */\nexport function readSyncLastAttempt(globalRoot: string): SyncReport | undefined {\n try {\n const parsed = JSON.parse(fs.readFileSync(syncLastAttemptPath(globalRoot), 'utf8')) as Partial<SyncReport>;\n return Array.isArray(parsed.roots) ? (parsed as SyncReport) : undefined;\n } catch {\n // Missing or unreadable: no attempt to report reasons from.\n return undefined;\n }\n}\n\nfunction writeJsonFile(file: string, value: unknown): void {\n writeFileAtomic(file, `${JSON.stringify(value, null, 2)}\\n`);\n}\n\ntype LockAttempt = { acquired: true; token: string } | { acquired: false; holder: SyncLockHolder | undefined };\n\nfunction readHolder(lockPath: string): SyncLockHolder | undefined {\n try {\n const parsed = JSON.parse(fs.readFileSync(lockPath, 'utf8')) as Partial<SyncLockHolder>;\n return typeof parsed.pid === 'number' ? (parsed as SyncLockHolder) : undefined;\n } catch {\n // Missing or half-written: the caller decides from the file's age.\n return undefined;\n }\n}\n\nfunction lockIsStale(lockPath: string, deps: SyncDeps): boolean {\n const holder = readHolder(lockPath);\n if (holder !== undefined) return !deps.isAlive(holder.pid);\n try {\n return deps.now().getTime() - fs.statSync(lockPath).mtimeMs > UNREADABLE_LOCK_GRACE_MS;\n } catch {\n // Gone between the failed create and this check: free to retry.\n return true;\n }\n}\n\nfunction tryCreateLock(lockPath: string, holder: SyncLockHolder): boolean {\n try {\n const descriptor = fs.openSync(lockPath, 'wx');\n try {\n fs.writeSync(descriptor, JSON.stringify(holder));\n } finally {\n fs.closeSync(descriptor);\n }\n return true;\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === ALREADY_EXISTS) return false;\n throw error;\n }\n}\n\n/**\n * Takes over a lock judged stale. Removing it by path could remove a lock another taker created\n * since the check, so it is first renamed to a name only this process knows and checked again\n * there: a lock that turns out live is linked back (link never replaces), a stale one is dropped\n * before the exclusive create, which at most one taker wins.\n */\nfunction takeOverStaleLock(lockPath: string, holder: SyncLockHolder, deps: SyncDeps): boolean {\n const moved = `${lockPath}.${String(deps.pid)}.${crypto.randomUUID()}.stale`;\n try {\n fs.renameSync(lockPath, moved);\n } catch (error) {\n // Already gone: released, or moved by another taker; the create decides.\n if ((error as NodeJS.ErrnoException).code === NO_SUCH_FILE) return tryCreateLock(lockPath, holder);\n throw error;\n }\n try {\n if (!lockIsStale(moved, deps)) {\n try {\n fs.linkSync(moved, lockPath);\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code !== ALREADY_EXISTS) throw error;\n }\n return false;\n }\n } finally {\n fs.rmSync(moved, { force: true });\n }\n return tryCreateLock(lockPath, holder);\n}\n\n/** Creates the lock, taking over one whose holder is dead. Never inspects other processes beyond `kill(pid, 0)`. */\nfunction acquireLock(lockPath: string, origin: SyncOrigin, deps: SyncDeps): LockAttempt {\n fs.mkdirSync(path.dirname(lockPath), { recursive: true });\n const token = crypto.randomUUID();\n const holder: SyncLockHolder = { pid: deps.pid, token, startedAt: deps.now().toISOString(), origin };\n if (tryCreateLock(lockPath, holder)) return { acquired: true, token };\n // A racing taker that wins the takeover makes this attempt report busy, as it should.\n if (lockIsStale(lockPath, deps) && takeOverStaleLock(lockPath, holder, deps)) return { acquired: true, token };\n return { acquired: false, holder: readHolder(lockPath) };\n}\n\n/**\n * The lock as the holder with `token` sees it: undefined while the lock still names it, else\n * the busy report to stop with. A takeover that moved a live lock aside can let a third taker\n * create a new one, so a holder checks before each step whose overlap would do harm.\n */\nfunction lostLock(lockPath: string, token: string, deps: SyncDeps): SyncReport | undefined {\n const holder = readHolder(lockPath);\n if (holder?.token === token) return undefined;\n const by = holder === undefined ? 'another process' : `pid ${String(holder.pid)}`;\n return emptyReport('busy', [`po sync lost its lock to ${by}`], deps);\n}\n\nfunction releaseLock(lockPath: string, token: string): void {\n if (readHolder(lockPath)?.token === token) fs.rmSync(lockPath, { force: true });\n}\n\n/** Consumes the rerun marker; true when a background run asked for another pass. */\nfunction takeRerunRequest(rerunPath: string): boolean {\n if (!fs.existsSync(rerunPath)) return false;\n fs.rmSync(rerunPath, { force: true });\n return true;\n}\n\nfunction emptyReport(status: SyncStatus, errors: string[], deps: SyncDeps): SyncReport {\n return {\n status,\n generation: null,\n catalogueHash: null,\n webKey: null,\n mcpKeys: [],\n roots: [],\n commands: [],\n errors,\n finishedAt: deps.now().toISOString(),\n };\n}\n\n/** A step reporter over the event stream, mirroring the presenter's start/done/line. */\nfunction steps(emit: (event: SyncEvent) => void) {\n return {\n start(label: string, message: string): (summary: string) => void {\n emit({ type: 'start', label, message });\n return (summary) => emit({ type: 'done', label, summary });\n },\n line(label: string, message: string): void {\n emit({ type: 'line', label, message });\n },\n };\n}\n\ntype Steps = ReturnType<typeof steps>;\n\n/**\n * Drops old builds and unreferenced store content once installs and builds are done.\n * Never fatal: a failed prune leaves everything for the next explicit sync.\n */\nasync function pruneStep(progress: Steps, prune: SyncDeps['prune'], input: SyncPruneInput): Promise<void> {\n const done = progress.start(PRUNE_LABEL, 'dropping old builds and unused packages');\n try {\n const result = await prune(input);\n const runtime =\n 'skipped' in result.runtime\n ? result.runtime.skipped\n : `${(result.runtime.bytes / BYTES_PER_MEGABYTE).toFixed(1)} MB of packages released`;\n done(`removed ${pluralize(result.builds.length, 'old build')}, ${runtime}`);\n } catch (error) {\n done(`failed: ${errorMessage(error)}`);\n }\n}\n\n/** Regenerates the hook files the other frontends read before any harness code runs, in a root that has the emitter. */\nfunction emitFrontendHooks(root: string, progress: Steps, commands: string[]): void {\n const emitter = path.join(root, HOOK_EMITTER);\n if (!fs.existsSync(emitter)) return;\n commands.push(`${process.execPath} ${emitter} --write`);\n const result = spawnSync(process.execPath, [emitter, '--write'], { cwd: root, encoding: 'utf8' });\n if (result.status === 0) {\n progress.line(HOOKS_LABEL, `regenerated for Claude Code and Codex in '${root}'`);\n return;\n }\n progress.line(\n HOOKS_LABEL,\n `emit-hooks failed in '${root}' (${result.stderr?.trim() || `exit ${String(result.status)}`})`,\n );\n}\n\n/** A path with its symlinks resolved, or as given when it does not exist. */\nfunction realPath(file: string): string {\n try {\n return fs.realpathSync(file);\n } catch {\n // Missing: compare it as written.\n return path.resolve(file);\n }\n}\n\n/**\n * One sync pass under the lock. A failed step ends the pass with a `failed` report and leaves\n * the pointer alone; a lock that no longer names this holder (`lost`) ends it as busy.\n */\nasync function syncOnce(\n options: SyncOptions,\n deps: SyncDeps,\n emit: (event: SyncEvent) => void,\n lost: () => SyncReport | undefined,\n): Promise<SyncReport> {\n const { homeDirectory, environment, globalRoot } = options;\n const progress = steps(emit);\n const commands: string[] = [];\n const roots = resolveRoots(options, progress);\n const catalogueHash = packageCatalogHash(environment);\n const previous = readSyncPointer(globalRoot);\n if (\n previous !== undefined &&\n // Unsynced selectors are retried only when a person runs sync: with an unchanged signature a\n // background retry repeats the same failure, while something outside the signature (a package\n // manager installed since) is what a manual `po sync` is for. The pointer keeps the reasons.\n (options.origin === 'background' || previous.roots.every((root) => root.unsynced.length === 0)) &&\n previous.signature === syncSignature(options, roots, catalogueHash) &&\n pointerArtifacts(globalRoot, previous).every((file) => fs.existsSync(file))\n ) {\n progress.line(ROOTS_LABEL, `nothing changed since generation ${String(previous.generation)}`);\n return {\n ...emptyReport('noop', [], deps),\n generation: previous.generation,\n catalogueHash,\n webKey: previous.webKey,\n mcpKeys: previous.mcpKeys,\n roots: previous.roots,\n };\n }\n const unsynced = new Map<string, SyncRootReport['unsynced']>(roots.map((root) => [root, []]));\n const report = (status: 'ok' | 'failed', errors: string[], webKey: string | null, mcpKeys: string[]) => {\n const rootReports = roots.map((root): SyncRootReport => {\n const entries = unsynced.get(root) ?? [];\n return { root, status: status === 'ok' && entries.length > 0 ? 'partial' : status, unsynced: entries };\n });\n const partial = status === 'ok' && rootReports.some((root) => root.status === 'partial');\n return {\n ...emptyReport(partial ? 'partial' : status, errors, deps),\n generation: previous?.generation ?? null,\n catalogueHash,\n webKey,\n mcpKeys,\n roots: rootReports,\n commands,\n };\n };\n\n const lostBeforeInstall = lost();\n if (lostBeforeInstall !== undefined) return lostBeforeInstall;\n const packagesDone = progress.start(PACKAGES_LABEL, 'checking configured packages for updates');\n let packages: SyncResult['packages'];\n try {\n const configOf = (root: string) => loadMajorModesConfigLenient(root, homeDirectory, environment).config;\n const globalConfig = configOf(globalRoot);\n // One install covers the catalogue and every package some root does not get from its own\n // node_modules, including those the runtime already provides; the runtime manifest declares\n // exactly those, so pruning can drop anything no root needs. A name a root resolves from its\n // own node_modules stays out, so a workspace's local copy is never shadowed by, or blocked\n // on, a registry install.\n const specifiers = new Set(catalogInstallSpecifiers(environment));\n for (const root of roots) {\n const config = configOf(root);\n for (const specifier of runtimeLayerPackageSpecifiers(config, Object.keys(config.layers), root))\n specifiers.add(specifier);\n }\n packages = await deps.install({\n repoRoot: globalRoot,\n config: globalConfig,\n // Every declared layer, so a later mode switch finds its packages installed.\n layers: Object.keys(globalConfig.layers),\n environment,\n // A background run never bumps versions; only a person running sync asks for updates.\n refresh: options.origin === 'cli',\n specifiers: [...specifiers],\n exactManifest: true,\n onProgress: (message) => progress.line(PACKAGES_LABEL, message),\n });\n } catch (error) {\n packagesDone('failed');\n return report('failed', [`Installing packages failed: ${errorMessage(error)}`], null, []);\n }\n packagesDone(packageSummary(packages));\n\n const localByRoot = new Map(\n roots.map((root) => [root, localPackages(loadMajorModesConfigLenient(root, homeDirectory, environment).config)]),\n );\n const localDirectories = [...localByRoot.values()].flat().map(({ directory }) => directory);\n if (localDirectories.length > 0) {\n const localDone = progress.start(LOCAL_LABEL, 'building local packages');\n const outcomes = await buildLocalPackages({\n globalRoot,\n environment,\n directories: localDirectories,\n onCommand: (command) => commands.push(command),\n onNotice: (message) => progress.line(LOCAL_LABEL, message),\n });\n let failed = 0;\n for (const [root, packagesOfRoot] of localByRoot)\n for (const { selector, directory } of packagesOfRoot) {\n const outcome = outcomes.get(directory);\n if (outcome?.status !== 'failed') continue;\n unsynced.get(root)?.push({\n selector,\n reason: outcome.reason,\n ...(outcome.stderr === undefined ? {} : { stderr: outcome.stderr }),\n });\n }\n for (const outcome of outcomes.values()) if (outcome.status === 'failed') failed += 1;\n localDone(failed === 0 ? `${pluralize(outcomes.size, 'package')} ready` : `${String(failed)} failed`);\n }\n\n const composed = composeRoots(roots, homeDirectory, environment);\n // What a root's selection leaves out still syncs the rest of the root; each is reported once.\n for (const [root, compositions] of composed) {\n if (compositions instanceof Error) continue;\n const entries = unsynced.get(root) ?? [];\n for (const skipped of skippedSelections(compositions))\n if (!entries.some((entry) => entry.selector === skipped.selector)) entries.push(skipped);\n }\n\n const webDone = progress.start(WEB_LABEL, 'ensuring the global web build');\n let rootPackageRoots = packageRootsByRoot(composed, (message) => progress.line(WEB_LABEL, message));\n const buildWeb = (packageRoots: Map<string, string[]>) =>\n deps.buildWeb({\n poHome: globalRoot,\n pluginRoots: webPluginRootsOf(globalRoot, packageRoots, environment),\n environment,\n onNotice: (message) => progress.line(WEB_LABEL, message),\n });\n let built = await buildWeb(rootPackageRoots);\n if (built.status === 'failed') {\n // A local copy is the likeliest cause; one retry without them keeps the rest serving.\n const local = new Set(localDirectories.map(realPath));\n const withoutLocal = new Map(\n [...rootPackageRoots].map(([root, packageRoots]) => [\n root,\n packageRoots.filter((packageRoot) => !local.has(realPath(packageRoot))),\n ]),\n );\n const leftOut = [...rootPackageRoots].some(\n ([root, packageRoots]) => withoutLocal.get(root)?.length !== packageRoots.length,\n );\n const retried = leftOut ? await buildWeb(withoutLocal) : built;\n if (retried.status === 'failed') {\n webDone('failed');\n const retryReason = leftOut ? `; without local copies: ${retried.reason}` : '';\n return report('failed', [`The global web build failed: ${built.reason}${retryReason}`], null, []);\n }\n for (const [root, packagesOfRoot] of localByRoot) {\n const included = new Set((rootPackageRoots.get(root) ?? []).map(realPath));\n const entries = unsynced.get(root) ?? [];\n for (const { selector, directory } of packagesOfRoot)\n if (included.has(realPath(directory)) && !entries.some((entry) => entry.selector === selector))\n entries.push({\n selector,\n reason: `left out of the web build, which failed with it: ${built.reason}`,\n });\n }\n progress.line(WEB_LABEL, `built without local copies after: ${built.reason}`);\n rootPackageRoots = withoutLocal;\n built = retried;\n }\n const pluginRoots = webPluginRootsOf(globalRoot, rootPackageRoots, environment);\n const web: SyncResult['web'] = built.status === 'skipped' ? built : { status: built.status, key: built.build.key };\n webDone(web.status === 'skipped' ? web.reason : `${web.key} (${web.status})`);\n const webKey = web.status === 'skipped' ? null : web.key;\n\n const nativeDone = progress.start(NATIVE_LABEL, 'ensuring the global native build');\n const nativeBuilt = await deps.buildNative({\n poHome: globalRoot,\n pluginRoots,\n onNotice: (message) => progress.line(NATIVE_LABEL, message),\n });\n if (nativeBuilt.status === 'failed') {\n nativeDone('failed');\n return report('failed', [`The global native build failed: ${nativeBuilt.reason}`], webKey, []);\n }\n const native: NonNullable<SyncResult['native']> =\n nativeBuilt.status === 'skipped' ? nativeBuilt : { status: nativeBuilt.status, key: nativeBuilt.build.key };\n nativeDone(native.status === 'skipped' ? native.reason : `${native.key} (${native.status})`);\n const nativeKey = native.status === 'skipped' ? null : native.key;\n\n // One MCP app build per root; its key is a content hash, so roots with one widget set share it.\n const mcpDone = progress.start(MCP_LABEL, 'ensuring the MCP app build of each root');\n const mcpKeys: string[] = [];\n for (const [root, compositions] of composed) {\n if (compositions instanceof Error) {\n progress.line(MCP_LABEL, `'${root}' is left out of the MCP app build: ${compositions.message}`);\n continue;\n }\n try {\n const app = await deps.bundleMcpApp({ poHome: globalRoot, candidates: mcpPluginCandidates(compositions) });\n if (app !== undefined && !mcpKeys.includes(app.key)) mcpKeys.push(app.key);\n } catch (error) {\n unsynced.get(root)?.push({ selector: MCP_LABEL, reason: `the MCP app build failed: ${errorMessage(error)}` });\n }\n }\n mcpDone(mcpKeys.length === 0 ? 'no MCP UI widgets' : mcpKeys.join(', '));\n const mcpApp = mcpKeys.length === 0 ? undefined : mcpKeys.join(', ');\n\n // The pointer names only artifacts that exist; a missing one keeps the previous pointer.\n const missing = pointerArtifacts(globalRoot, { webKey, nativeKey, mcpKeys }).filter((file) => !fs.existsSync(file));\n if (missing.length > 0)\n return report('failed', [`Build artifacts are missing: ${missing.join(', ')}`], webKey, mcpKeys);\n // A root that names two copies of one plugin serves only one of them under its plugin id.\n if (built.status !== 'skipped')\n for (const [root, packageRoots] of rootPackageRoots)\n for (const [pluginId, slots] of duplicatePluginCopies(built.build, packageRoots))\n unsynced.get(root)?.push({\n selector: pluginId,\n reason: `two copies of plugin '${pluginId}' are selected (${slots.join(', ')})`,\n });\n const succeeded = report('ok', [], webKey, mcpKeys);\n const generation = (previous?.generation ?? 0) + 1;\n const pointer: SyncPointer = {\n generation,\n signature: syncSignature(options, roots, catalogueHash),\n catalogueHash,\n webKey,\n nativeKey,\n mcpKeys,\n roots: succeeded.roots,\n commands,\n fingerprints: Object.fromEntries(\n roots.map((root) => [root, rootSelectionFingerprint(root, homeDirectory, environment)]),\n ),\n host: syncHostIdentity(globalRoot, environment),\n };\n const lostBeforePointer = lost();\n if (lostBeforePointer !== undefined) return lostBeforePointer;\n writeJsonFile(syncPointerPath(globalRoot), pointer);\n\n await pruneStep(progress, deps.prune, {\n homeDirectory,\n environment,\n buildsRoot: globalRoot,\n ...(webKey === null ? {} : { webKey }),\n ...(nativeKey === null ? {} : { nativeKey }),\n ...(mcpKeys.length === 0 ? {} : { mcpAppKeys: mcpKeys }),\n });\n // The checkout itself too: a linked worktree registers under its main workspace root.\n for (const root of new Set([...roots, ...(options.repoRoot === undefined ? [] : [realPath(options.repoRoot)])]))\n emitFrontendHooks(root, progress, commands);\n emit({ type: 'result', result: { packages, web, native, ...(mcpApp === undefined ? {} : { mcpApp }) } });\n return { ...succeeded, generation };\n}\n\n/**\n * One pass whose report lands in `last-attempt.json`, so a failed background run leaves its\n * reasons. A pass that lost the lock leaves the file to the holder that took it.\n */\nasync function attempt(\n options: SyncOptions,\n deps: SyncDeps,\n emit: (event: SyncEvent) => void,\n lost: () => SyncReport | undefined,\n): Promise<SyncReport> {\n let report: SyncReport;\n try {\n report = await syncOnce(options, deps, emit, lost);\n } catch (error) {\n report = emptyReport('failed', [`po sync failed: ${errorMessage(error)}`], deps);\n }\n if (report.status === 'busy') return report;\n try {\n writeJsonFile(syncLastAttemptPath(options.globalRoot), report);\n } catch (error) {\n report = {\n ...report,\n errors: [...report.errors, `last-attempt.json could not be written: ${errorMessage(error)}`],\n };\n }\n return report;\n}\n\n/**\n * Runs sync under the Po home lock and reports the outcome.\n *\n * Busy when another live sync holds the lock; a background caller leaves a rerun marker\n * first. The holder repeats its pass while a marker is present. A marker that lands after\n * its last check but before the release is caught after the release: the holder takes the\n * lock again and runs once more, or leaves the marker to whoever took the lock first.\n */\nexport async function runSync(options: SyncOptions, overrides: Partial<SyncDeps> = {}): Promise<SyncReport> {\n const deps: SyncDeps = { ...DEFAULT_DEPS, ...overrides };\n const emit = options.onEvent ?? ((): void => {});\n const lockPath = syncLockPath(options.globalRoot);\n const rerunPath = syncRerunPath(options.globalRoot);\n let lock = acquireLock(lockPath, options.origin, deps);\n if (!lock.acquired) {\n if (options.origin === 'background') fs.writeFileSync(rerunPath, deps.now().toISOString());\n const holder = lock.holder === undefined ? 'another process' : `pid ${String(lock.holder.pid)}`;\n return emptyReport('busy', [`po sync is already running (${holder})`], deps);\n }\n for (;;) {\n const { token } = lock;\n const lost = () => lostLock(lockPath, token, deps);\n let report: SyncReport;\n try {\n // A marker left before this pass started is satisfied by this pass.\n takeRerunRequest(rerunPath);\n report = await attempt(options, deps, emit, lost);\n // A pass that lost the lock leaves the rerun marker to the holder that took it.\n while (report.status !== 'busy' && takeRerunRequest(rerunPath)) report = await attempt(options, deps, emit, lost);\n } finally {\n releaseLock(lockPath, token);\n }\n if (report.status === 'busy' || !fs.existsSync(rerunPath)) return report;\n lock = acquireLock(lockPath, options.origin, deps);\n if (!lock.acquired) return report;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2DA,MAAM,kBAAkB;AACxB,MAAM,YAAY;AAClB,MAAM,aAAa;AACnB,MAAM,eAAe;AACrB,MAAM,oBAAoB;AAC1B,MAAM,eAAe;AACrB,MAAM,eAAe,KAAK,KAAK,SAAS,WAAW,gBAAgB;AACnE,MAAM,cAAc;AACpB,MAAM,iBAAiB;AACvB,MAAM,YAAY;AAClB,MAAM,eAAe;AACrB,MAAM,YAAY;AAClB,MAAM,cAAc;AACpB,MAAM,cAAc;AACpB,MAAM,cAAc;AACpB,MAAM,qBAAqB;;AAE3B,MAAM,2BAA2B;AACjC,MAAM,kBAAkB;;;;;AAKxB,MAAM,mBAAmB;AACzB,MAAM,mBAAmB;AACzB,MAAM,iBAAiB;AACvB,MAAM,eAAe;;AAmFrB,SAAgB,eAAe,KAAsB;CACnD,IAAI;EACF,QAAQ,KAAK,KAAK,CAAC;EACnB,OAAO;CACT,SAAS,OAAO;EAEd,OAAQ,MAAgC,SAAS;CACnD;AACF;AAEA,MAAM,eAAyB;CAC7B,SAAS;CACT,UAAU;CACV,aAAa;CACb,cAAc;CACd,OAAO;CACP,SAAS;CACT,KAAK,QAAQ;CACb,2BAAW,IAAI,KAAK;AACtB;AAEA,SAAgB,aAAa,QAA4B;CACvD,IAAI,WAAW,QAAQ,OAAA;CACvB,OAAO,WAAW,QAAQ,WAAW,SAAA,IAAA;AACvC;AAEA,SAAgB,aAAa,YAA4B;CACvD,OAAO,KAA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Q,CAAC,GAAG,OAAO,QAAQ,2CAA2C,aAAa,KAAK,GAAG;EAC7F;CACF;CACA,OAAO;AACT;;;;;;;;;AAUA,eAAsB,QAAQ,SAAsB,YAA+B,CAAC,GAAwB;CAC1G,MAAM,OAAiB;EAAE,GAAG;EAAc,GAAG;CAAU;CACvD,MAAM,OAAO,QAAQ,kBAAwB,CAAC;CAC9C,MAAM,WAAW,aAAa,QAAQ,UAAU;CAChD,MAAM,YAAY,cAAc,QAAQ,UAAU;CAClD,IAAI,OAAO,YAAY,UAAU,QAAQ,QAAQ,IAAI;CACrD,IAAI,CAAC,KAAK,UAAU;EAClB,IAAI,QAAQ,WAAW,cAAc,GAAG,cAAc,WAAW,KAAK,IAAI,CAAC,CAAC,YAAY,CAAC;EAEzF,OAAO,YAAY,QAAQ,CAAC,+BADb,KAAK,WAAW,KAAA,IAAY,oBAAoB,OAAO,OAAO,KAAK,OAAO,GAAG,IAC1B,EAAE,GAAG,IAAI;CAC7E;CACA,SAAS;EACP,MAAM,EAAE,UAAU;EAClB,MAAM,aAAa,SAAS,UAAU,OAAO,IAAI;EACjD,IAAI;EACJ,IAAI;GAEF,iBAAiB,SAAS;GAC1B,SAAS,MAAM,QAAQ,SAAS,MAAM,MAAM,IAAI;GAEhD,OAAO,OAAO,WAAW,UAAU,iBAAiB,SAAS,GAAG,SAAS,MAAM,QAAQ,SAAS,MAAM,MAAM,IAAI;EAClH,UAAU;GACR,YAAY,UAAU,KAAK;EAC7B;EACA,IAAI,OAAO,WAAW,UAAU,CAAC,GAAG,WAAW,SAAS,GAAG,OAAO;EAClE,OAAO,YAAY,UAAU,QAAQ,QAAQ,IAAI;EACjD,IAAI,CAAC,KAAK,UAAU,OAAO;CAC7B;AACF"}
@@ -0,0 +1,367 @@
1
+ const require_runtime = require("../../../_virtual/_rolldown/runtime.cjs");
2
+ let node_fs = require("node:fs");
3
+ node_fs = require_runtime.__toESM(node_fs, 1);
4
+ let node_path = require("node:path");
5
+ node_path = require_runtime.__toESM(node_path, 1);
6
+ let _agimon_ai_po_core_runtimeJson = require("@agimon-ai/po-core/runtimeJson");
7
+ let node_child_process = require("node:child_process");
8
+ let node_crypto = require("node:crypto");
9
+ node_crypto = require_runtime.__toESM(node_crypto, 1);
10
+ //#region src/composition/syncService/localBuilds.ts
11
+ /**
12
+ * Builds the packages sync roots name by local path, so the web, native and MCP builds read
13
+ * current output. Each package builds at most once per sync, in dependency order within the
14
+ * local set, with the package manager its nearest lockfile names. Install never runs.
15
+ */
16
+ const LOCAL_SOURCE_DIRECTORY = "src";
17
+ const PACKAGE_MANIFEST = "package.json";
18
+ const NODE_MODULES = "node_modules";
19
+ const LOCAL_BUILDS_FILE = node_path.default.join("build", "local-builds.json");
20
+ const BUILD_SCRIPT = "build";
21
+ /** Bytes of stderr kept per build while it runs; older output is dropped as it arrives. */
22
+ const STDERR_TAIL_BYTES = 65536;
23
+ /**
24
+ * A local build that runs longer than this is stopped and reported as failed. Sync holds its
25
+ * lock while a build runs, so a hung build must not hold it forever.
26
+ */
27
+ const LOCAL_BUILD_TIMEOUT_MS = 6e5;
28
+ /** How long a build's stderr may stay open after it exits, held by a process it left running. */
29
+ const STDERR_CLOSE_GRACE_MS = 1e3;
30
+ const MILLISECONDS_PER_SECOND = 1e3;
31
+ const LOGIN_SHELL_TIMEOUT_MS = 1e4;
32
+ const DEFAULT_PACKAGE_MANAGER = "npm";
33
+ const NO_SUCH_PROCESS = "ESRCH";
34
+ /** Checked nearest-first in each folder; the first lockfile found names the package manager. */
35
+ const LOCKFILES = [
36
+ ["pnpm-lock.yaml", "pnpm"],
37
+ ["bun.lock", "bun"],
38
+ ["bun.lockb", "bun"],
39
+ ["yarn.lock", "yarn"],
40
+ ["package-lock.json", "npm"]
41
+ ];
42
+ /** Variables a Po session or another harness exports; a package build must not see them. */
43
+ const HARNESS_PREFIXES = [
44
+ "PO_",
45
+ "PI_",
46
+ "CLAUDE_",
47
+ "CODEX_"
48
+ ];
49
+ const HARNESS_VARIABLES = /* @__PURE__ */ new Set([
50
+ "CLAUDECODE",
51
+ "MCP_UI_VIEWER",
52
+ "npm_config_user_agent"
53
+ ]);
54
+ const DEPENDENCY_FIELDS = [
55
+ "dependencies",
56
+ "devDependencies",
57
+ "peerDependencies",
58
+ "optionalDependencies"
59
+ ];
60
+ function sourceFiles(directory) {
61
+ let entries;
62
+ try {
63
+ entries = node_fs.default.readdirSync(directory, { withFileTypes: true });
64
+ } catch {
65
+ return [];
66
+ }
67
+ return entries.flatMap((entry) => {
68
+ const full = node_path.default.join(directory, entry.name);
69
+ if (entry.isDirectory()) return entry.name === NODE_MODULES ? [] : sourceFiles(full);
70
+ return entry.isFile() ? [full] : [];
71
+ });
72
+ }
73
+ /**
74
+ * The build stamp of a local package: an mtime and size signature over its `package.json`
75
+ * and every file under `src/`.
76
+ * ponytail: it misses edits to dependencies outside the package; a content hash is the upgrade.
77
+ */
78
+ function localBuildStamp(packageDirectory) {
79
+ const files = [node_path.default.join(packageDirectory, PACKAGE_MANIFEST), ...sourceFiles(node_path.default.join(packageDirectory, LOCAL_SOURCE_DIRECTORY))];
80
+ const hash = node_crypto.default.createHash("sha256");
81
+ for (const file of files.sort()) {
82
+ const relative = node_path.default.relative(packageDirectory, file);
83
+ try {
84
+ const stat = node_fs.default.statSync(file);
85
+ hash.update(`${relative}\0${String(stat.size)}\0${String(stat.mtimeMs)}\n`);
86
+ } catch {
87
+ hash.update(`${relative}\0missing\n`);
88
+ }
89
+ }
90
+ return hash.digest("hex");
91
+ }
92
+ function localBuildsPath(globalRoot) {
93
+ return node_path.default.join(globalRoot, LOCAL_BUILDS_FILE);
94
+ }
95
+ function readStamps(globalRoot) {
96
+ try {
97
+ const parsed = JSON.parse(node_fs.default.readFileSync(localBuildsPath(globalRoot), "utf8"));
98
+ return typeof parsed === "object" && parsed !== null ? parsed : {};
99
+ } catch {
100
+ return {};
101
+ }
102
+ }
103
+ function readManifest(directory) {
104
+ try {
105
+ return JSON.parse(node_fs.default.readFileSync(node_path.default.join(directory, PACKAGE_MANIFEST), "utf8"));
106
+ } catch {
107
+ return;
108
+ }
109
+ }
110
+ /** The package manager the nearest lockfile names, walking up from the package. */
111
+ function packageManagerFor(directory) {
112
+ let current = node_path.default.resolve(directory);
113
+ for (;;) {
114
+ for (const [lockfile, manager] of LOCKFILES) if (node_fs.default.existsSync(node_path.default.join(current, lockfile))) return manager;
115
+ const parent = node_path.default.dirname(current);
116
+ if (parent === current) return DEFAULT_PACKAGE_MANAGER;
117
+ current = parent;
118
+ }
119
+ }
120
+ function findOnPath(binary, searchPath) {
121
+ for (const directory of (searchPath ?? "").split(node_path.default.delimiter).filter(Boolean)) {
122
+ const candidate = node_path.default.join(directory, binary);
123
+ try {
124
+ node_fs.default.accessSync(candidate, node_fs.default.constants.X_OK);
125
+ if (node_fs.default.statSync(candidate).isFile()) return candidate;
126
+ } catch {}
127
+ }
128
+ }
129
+ /**
130
+ * The login shell's PATH. Desktop apps launched from Finder get a minimal PATH (inferred,
131
+ * not checked here), so a package manager installed through a shell profile is missing.
132
+ */
133
+ function loginShellPath(environment) {
134
+ const shell = environment.SHELL ?? "/bin/zsh";
135
+ const result = (0, node_child_process.spawnSync)(shell, ["-ilc", "printf %s \"$PATH\""], {
136
+ encoding: "utf8",
137
+ timeout: LOGIN_SHELL_TIMEOUT_MS
138
+ });
139
+ return result.status === 0 && result.stdout.trim() !== "" ? result.stdout.trim() : void 0;
140
+ }
141
+ /** The build environment: the caller's minus every `PO_*` and harness variable. */
142
+ function buildEnvironment(environment) {
143
+ return Object.fromEntries(Object.entries(environment).filter(([name]) => !HARNESS_VARIABLES.has(name) && !HARNESS_PREFIXES.some((prefix) => name.startsWith(prefix))));
144
+ }
145
+ function entryPaths(value) {
146
+ if (typeof value === "string") return [value];
147
+ if (Array.isArray(value)) return value.flatMap(entryPaths);
148
+ if (typeof value === "object" && value !== null) return Object.values(value).flatMap(entryPaths);
149
+ return [];
150
+ }
151
+ /** Whether every file `main`, `module` and `exports` name exists; false when they name none. */
152
+ function builtEntriesPresent(directory, manifest) {
153
+ const entries = [
154
+ manifest.main,
155
+ manifest.module,
156
+ manifest.exports
157
+ ].flatMap(entryPaths).filter((entry) => !entry.includes("*"));
158
+ return entries.length > 0 && entries.every((entry) => node_fs.default.existsSync(node_path.default.resolve(directory, entry)));
159
+ }
160
+ /** The directories ordered so each local package builds after the local packages it depends on. */
161
+ function dependencyOrder(directories, manifests) {
162
+ const byName = /* @__PURE__ */ new Map();
163
+ for (const directory of directories) {
164
+ const name = manifests.get(directory)?.name;
165
+ if (name !== void 0) byName.set(name, directory);
166
+ }
167
+ const ordered = [];
168
+ const visiting = /* @__PURE__ */ new Set();
169
+ const visit = (directory) => {
170
+ if (ordered.includes(directory) || visiting.has(directory)) return;
171
+ visiting.add(directory);
172
+ const manifest = manifests.get(directory);
173
+ for (const field of DEPENDENCY_FIELDS) {
174
+ const dependencies = manifest?.[field];
175
+ if (typeof dependencies !== "object" || dependencies === null) continue;
176
+ for (const name of Object.keys(dependencies)) {
177
+ const dependency = byName.get(name);
178
+ if (dependency !== void 0) visit(dependency);
179
+ }
180
+ }
181
+ visiting.delete(directory);
182
+ ordered.push(directory);
183
+ };
184
+ for (const directory of directories) visit(directory);
185
+ return ordered;
186
+ }
187
+ function stderrTail(stderr) {
188
+ return stderr.trimEnd().split("\n").filter(Boolean).slice(-20);
189
+ }
190
+ /** Signals that end this process; a build in its own process group would not receive them. */
191
+ const FORWARDED_SIGNALS = [
192
+ "SIGINT",
193
+ "SIGTERM",
194
+ "SIGHUP"
195
+ ];
196
+ const SEPARATE_PROCESS_GROUPS = process.platform !== "win32";
197
+ /**
198
+ * Kills the build and everything it started. The build leads its own process group, so the
199
+ * package manager's tsc or vite children die with it.
200
+ * ponytail: Windows has no process groups here, so only the package manager is killed there;
201
+ * `taskkill /T /F` is the upgrade if Windows builds must stop their children too.
202
+ */
203
+ function killBuild(child) {
204
+ if (!SEPARATE_PROCESS_GROUPS || child.pid === void 0) {
205
+ child.kill("SIGKILL");
206
+ return;
207
+ }
208
+ try {
209
+ process.kill(-child.pid, "SIGKILL");
210
+ } catch (error) {
211
+ if (error.code !== NO_SUCH_PROCESS) child.kill("SIGKILL");
212
+ }
213
+ }
214
+ /**
215
+ * Runs one build script without buffering its output: stdout is discarded and only the stderr
216
+ * tail is kept. A build still running after `timeoutMs` is killed with every process it started
217
+ * and reported as timed out. A build that exits while something it started still holds stderr
218
+ * open has that process group killed when the grace ends, so nothing writes after it returns.
219
+ */
220
+ function runBuildScript(binary, directory, environment, timeoutMs) {
221
+ return new Promise((resolve) => {
222
+ let tail = Buffer.alloc(0);
223
+ let timedOut = false;
224
+ let leftRunning = false;
225
+ let settled = false;
226
+ let grace;
227
+ const child = (0, node_child_process.spawn)(binary, ["run", BUILD_SCRIPT], {
228
+ cwd: directory,
229
+ env: environment,
230
+ stdio: [
231
+ "ignore",
232
+ "ignore",
233
+ "pipe"
234
+ ],
235
+ detached: SEPARATE_PROCESS_GROUPS
236
+ });
237
+ const forward = (signal) => {
238
+ killBuild(child);
239
+ if (process.listenerCount(signal) > 1) return;
240
+ process.removeListener(signal, forward);
241
+ process.kill(process.pid, signal);
242
+ };
243
+ if (SEPARATE_PROCESS_GROUPS) for (const signal of FORWARDED_SIGNALS) process.on(signal, forward);
244
+ const finish = (result) => {
245
+ if (settled) return;
246
+ settled = true;
247
+ clearTimeout(timer);
248
+ clearTimeout(grace);
249
+ for (const signal of FORWARDED_SIGNALS) process.removeListener(signal, forward);
250
+ child.stderr?.destroy();
251
+ resolve({
252
+ ...result,
253
+ timedOut,
254
+ leftRunning,
255
+ stderr: tail.toString("utf8")
256
+ });
257
+ };
258
+ const timer = setTimeout(() => {
259
+ timedOut = true;
260
+ killBuild(child);
261
+ }, timeoutMs);
262
+ child.stderr?.on("data", (chunk) => {
263
+ tail = Buffer.concat([tail, chunk]);
264
+ if (tail.length > STDERR_TAIL_BYTES) tail = tail.subarray(tail.length - STDERR_TAIL_BYTES);
265
+ });
266
+ child.on("error", (error) => finish({
267
+ status: null,
268
+ signal: null,
269
+ error
270
+ }));
271
+ child.on("close", (status, signal) => finish({
272
+ status,
273
+ signal
274
+ }));
275
+ child.on("exit", (status, signal) => {
276
+ grace = setTimeout(() => {
277
+ if (!timedOut) leftRunning = true;
278
+ killBuild(child);
279
+ finish({
280
+ status,
281
+ signal
282
+ });
283
+ }, timedOut ? 0 : STDERR_CLOSE_GRACE_MS);
284
+ });
285
+ });
286
+ }
287
+ /**
288
+ * Builds every local package that changed since its last successful build, and returns each
289
+ * directory's outcome. A failure never stops the others.
290
+ */
291
+ async function buildLocalPackages(input) {
292
+ const { globalRoot, environment, onCommand, onNotice } = input;
293
+ const timeoutMs = input.timeoutMs ?? 6e5;
294
+ const directories = [...new Set(input.directories)];
295
+ const manifests = new Map(directories.map((directory) => [directory, readManifest(directory)]));
296
+ const stamps = readStamps(globalRoot);
297
+ const outcomes = /* @__PURE__ */ new Map();
298
+ const childEnvironment = buildEnvironment(environment);
299
+ let searchPath = environment.PATH;
300
+ let loginPathTried = false;
301
+ const resolveBinary = (manager) => {
302
+ const found = findOnPath(manager, searchPath);
303
+ if (found !== void 0 || loginPathTried || process.platform !== "darwin") return found;
304
+ loginPathTried = true;
305
+ const loginPath = loginShellPath(environment);
306
+ if (loginPath === void 0) return void 0;
307
+ searchPath = loginPath;
308
+ childEnvironment.PATH = loginPath;
309
+ return findOnPath(manager, searchPath);
310
+ };
311
+ for (const directory of dependencyOrder(directories, manifests)) {
312
+ const manifest = manifests.get(directory);
313
+ if (manifest === void 0) {
314
+ outcomes.set(directory, {
315
+ status: "failed",
316
+ reason: `'${directory}' has no readable package.json`
317
+ });
318
+ continue;
319
+ }
320
+ const stamp = localBuildStamp(directory);
321
+ if (stamps[directory] === stamp) {
322
+ outcomes.set(directory, { status: "cached" });
323
+ continue;
324
+ }
325
+ if (typeof manifest.scripts?.[BUILD_SCRIPT] !== "string") {
326
+ outcomes.set(directory, builtEntriesPresent(directory, manifest) ? { status: "cached" } : {
327
+ status: "failed",
328
+ reason: "it has no build script and no built entries"
329
+ });
330
+ continue;
331
+ }
332
+ const manager = packageManagerFor(directory);
333
+ const binary = resolveBinary(manager);
334
+ if (binary === void 0) {
335
+ outcomes.set(directory, {
336
+ status: "failed",
337
+ reason: `${manager} is not on PATH`
338
+ });
339
+ continue;
340
+ }
341
+ onCommand(`${binary} run ${BUILD_SCRIPT} (in ${directory})`);
342
+ onNotice(`building ${manifest.name ?? directory}`);
343
+ const result = await runBuildScript(binary, directory, childEnvironment, timeoutMs);
344
+ if (result.status === 0 && !result.timedOut && !result.leftRunning) {
345
+ stamps[directory] = localBuildStamp(directory);
346
+ (0, _agimon_ai_po_core_runtimeJson.writeFileAtomic)(localBuildsPath(globalRoot), `${JSON.stringify(stamps, null, 2)}\n`);
347
+ outcomes.set(directory, { status: "built" });
348
+ continue;
349
+ }
350
+ const exit = result.timedOut ? `timed out after ${String(timeoutMs / MILLISECONDS_PER_SECOND)} s` : result.status === 0 && result.leftRunning ? "it exited but left processes running, which were stopped" : result.error?.message ?? `exit ${String(result.status ?? result.signal)}`;
351
+ outcomes.set(directory, {
352
+ status: "failed",
353
+ reason: `${manager} run ${BUILD_SCRIPT} failed (${exit})`,
354
+ stderr: stderrTail(result.stderr)
355
+ });
356
+ }
357
+ return outcomes;
358
+ }
359
+ //#endregion
360
+ exports.LOCAL_BUILD_TIMEOUT_MS = LOCAL_BUILD_TIMEOUT_MS;
361
+ exports.buildEnvironment = buildEnvironment;
362
+ exports.buildLocalPackages = buildLocalPackages;
363
+ exports.localBuildStamp = localBuildStamp;
364
+ exports.localBuildsPath = localBuildsPath;
365
+ exports.packageManagerFor = packageManagerFor;
366
+
367
+ //# sourceMappingURL=localBuilds.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"localBuilds.cjs","names":["path","fs","crypto","spawnSync","spawn"],"sources":["../../../../src/composition/syncService/localBuilds.ts"],"sourcesContent":["import { type ChildProcess, spawn, spawnSync } from 'node:child_process';\nimport crypto from 'node:crypto';\nimport fs from 'node:fs';\nimport path from 'node:path';\n\nimport { writeFileAtomic } from '@agimon-ai/po-core/runtimeJson';\n\n/**\n * Builds the packages sync roots name by local path, so the web, native and MCP builds read\n * current output. Each package builds at most once per sync, in dependency order within the\n * local set, with the package manager its nearest lockfile names. Install never runs.\n */\n\nconst LOCAL_SOURCE_DIRECTORY = 'src';\nconst PACKAGE_MANIFEST = 'package.json';\nconst NODE_MODULES = 'node_modules';\nconst LOCAL_BUILDS_FILE = path.join('build', 'local-builds.json');\nconst BUILD_SCRIPT = 'build';\nconst STDERR_TAIL_LINES = 20;\n/** Bytes of stderr kept per build while it runs; older output is dropped as it arrives. */\nconst STDERR_TAIL_BYTES = 64 * 1024;\n/**\n * A local build that runs longer than this is stopped and reported as failed. Sync holds its\n * lock while a build runs, so a hung build must not hold it forever.\n */\nexport const LOCAL_BUILD_TIMEOUT_MS = 10 * 60 * 1000;\n/** How long a build's stderr may stay open after it exits, held by a process it left running. */\nconst STDERR_CLOSE_GRACE_MS = 1000;\nconst MILLISECONDS_PER_SECOND = 1000;\nconst LOGIN_SHELL_TIMEOUT_MS = 10_000;\nconst DEFAULT_PACKAGE_MANAGER = 'npm';\nconst NO_SUCH_PROCESS = 'ESRCH';\n/** Checked nearest-first in each folder; the first lockfile found names the package manager. */\nconst LOCKFILES: readonly (readonly [string, string])[] = [\n ['pnpm-lock.yaml', 'pnpm'],\n ['bun.lock', 'bun'],\n ['bun.lockb', 'bun'],\n ['yarn.lock', 'yarn'],\n ['package-lock.json', 'npm'],\n];\n/** Variables a Po session or another harness exports; a package build must not see them. */\nconst HARNESS_PREFIXES = ['PO_', 'PI_', 'CLAUDE_', 'CODEX_'];\nconst HARNESS_VARIABLES = new Set(['CLAUDECODE', 'MCP_UI_VIEWER', 'npm_config_user_agent']);\nconst DEPENDENCY_FIELDS = ['dependencies', 'devDependencies', 'peerDependencies', 'optionalDependencies'];\n\nexport interface LocalPackage {\n /** The selector as a root's configuration names it. */\n selector: string;\n directory: string;\n}\n\nexport type LocalBuildOutcome =\n | { status: 'built' | 'cached' }\n | { status: 'failed'; reason: string; stderr?: string[] };\n\nexport interface LocalBuildInput {\n globalRoot: string;\n environment: NodeJS.ProcessEnv;\n directories: readonly string[];\n /** Receives each command line as it starts. */\n onCommand: (command: string) => void;\n onNotice: (message: string) => void;\n /** Overrides `LOCAL_BUILD_TIMEOUT_MS`. */\n timeoutMs?: number;\n}\n\ninterface Manifest {\n name?: string;\n main?: unknown;\n module?: unknown;\n exports?: unknown;\n scripts?: Record<string, unknown>;\n [field: string]: unknown;\n}\n\nfunction sourceFiles(directory: string): string[] {\n let entries: fs.Dirent[];\n try {\n entries = fs.readdirSync(directory, { withFileTypes: true });\n } catch {\n // A package without a source folder has only its manifest to stamp.\n return [];\n }\n return entries.flatMap((entry) => {\n const full = path.join(directory, entry.name);\n if (entry.isDirectory()) return entry.name === NODE_MODULES ? [] : sourceFiles(full);\n return entry.isFile() ? [full] : [];\n });\n}\n\n/**\n * The build stamp of a local package: an mtime and size signature over its `package.json`\n * and every file under `src/`.\n * ponytail: it misses edits to dependencies outside the package; a content hash is the upgrade.\n */\nexport function localBuildStamp(packageDirectory: string): string {\n const files = [\n path.join(packageDirectory, PACKAGE_MANIFEST),\n ...sourceFiles(path.join(packageDirectory, LOCAL_SOURCE_DIRECTORY)),\n ];\n const hash = crypto.createHash('sha256');\n for (const file of files.sort()) {\n const relative = path.relative(packageDirectory, file);\n try {\n const stat = fs.statSync(file);\n hash.update(`${relative}\\0${String(stat.size)}\\0${String(stat.mtimeMs)}\\n`);\n } catch {\n // Recorded as missing, so the stamp moves when the file appears.\n hash.update(`${relative}\\0missing\\n`);\n }\n }\n return hash.digest('hex');\n}\n\nexport function localBuildsPath(globalRoot: string): string {\n return path.join(globalRoot, LOCAL_BUILDS_FILE);\n}\n\nfunction readStamps(globalRoot: string): Record<string, string> {\n try {\n const parsed = JSON.parse(fs.readFileSync(localBuildsPath(globalRoot), 'utf8')) as unknown;\n return typeof parsed === 'object' && parsed !== null ? (parsed as Record<string, string>) : {};\n } catch {\n // Missing or unreadable: every package builds once.\n return {};\n }\n}\n\nfunction readManifest(directory: string): Manifest | undefined {\n try {\n return JSON.parse(fs.readFileSync(path.join(directory, PACKAGE_MANIFEST), 'utf8')) as Manifest;\n } catch {\n return undefined;\n }\n}\n\n/** The package manager the nearest lockfile names, walking up from the package. */\nexport function packageManagerFor(directory: string): string {\n let current = path.resolve(directory);\n for (;;) {\n for (const [lockfile, manager] of LOCKFILES) if (fs.existsSync(path.join(current, lockfile))) return manager;\n const parent = path.dirname(current);\n if (parent === current) return DEFAULT_PACKAGE_MANAGER;\n current = parent;\n }\n}\n\nfunction findOnPath(binary: string, searchPath: string | undefined): string | undefined {\n for (const directory of (searchPath ?? '').split(path.delimiter).filter(Boolean)) {\n const candidate = path.join(directory, binary);\n try {\n fs.accessSync(candidate, fs.constants.X_OK);\n if (fs.statSync(candidate).isFile()) return candidate;\n } catch {\n // Not in this folder.\n }\n }\n return undefined;\n}\n\n/**\n * The login shell's PATH. Desktop apps launched from Finder get a minimal PATH (inferred,\n * not checked here), so a package manager installed through a shell profile is missing.\n */\nfunction loginShellPath(environment: NodeJS.ProcessEnv): string | undefined {\n const shell = environment.SHELL ?? '/bin/zsh';\n const result = spawnSync(shell, ['-ilc', 'printf %s \"$PATH\"'], {\n encoding: 'utf8',\n timeout: LOGIN_SHELL_TIMEOUT_MS,\n });\n return result.status === 0 && result.stdout.trim() !== '' ? result.stdout.trim() : undefined;\n}\n\n/** The build environment: the caller's minus every `PO_*` and harness variable. */\nexport function buildEnvironment(environment: NodeJS.ProcessEnv): NodeJS.ProcessEnv {\n return Object.fromEntries(\n Object.entries(environment).filter(\n ([name]) => !HARNESS_VARIABLES.has(name) && !HARNESS_PREFIXES.some((prefix) => name.startsWith(prefix)),\n ),\n );\n}\n\nfunction entryPaths(value: unknown): string[] {\n if (typeof value === 'string') return [value];\n if (Array.isArray(value)) return value.flatMap(entryPaths);\n if (typeof value === 'object' && value !== null) return Object.values(value).flatMap(entryPaths);\n return [];\n}\n\n/** Whether every file `main`, `module` and `exports` name exists; false when they name none. */\nfunction builtEntriesPresent(directory: string, manifest: Manifest): boolean {\n const entries = [manifest.main, manifest.module, manifest.exports]\n .flatMap(entryPaths)\n .filter((entry) => !entry.includes('*'));\n return entries.length > 0 && entries.every((entry) => fs.existsSync(path.resolve(directory, entry)));\n}\n\n/** The directories ordered so each local package builds after the local packages it depends on. */\nfunction dependencyOrder(directories: readonly string[], manifests: Map<string, Manifest | undefined>): string[] {\n const byName = new Map<string, string>();\n for (const directory of directories) {\n const name = manifests.get(directory)?.name;\n if (name !== undefined) byName.set(name, directory);\n }\n const ordered: string[] = [];\n const visiting = new Set<string>();\n const visit = (directory: string): void => {\n if (ordered.includes(directory) || visiting.has(directory)) return;\n visiting.add(directory);\n const manifest = manifests.get(directory);\n for (const field of DEPENDENCY_FIELDS) {\n const dependencies = manifest?.[field];\n if (typeof dependencies !== 'object' || dependencies === null) continue;\n for (const name of Object.keys(dependencies)) {\n const dependency = byName.get(name);\n if (dependency !== undefined) visit(dependency);\n }\n }\n visiting.delete(directory);\n ordered.push(directory);\n };\n for (const directory of directories) visit(directory);\n return ordered;\n}\n\nfunction stderrTail(stderr: string): string[] {\n return stderr.trimEnd().split('\\n').filter(Boolean).slice(-STDERR_TAIL_LINES);\n}\n\ninterface BuildRun {\n status: number | null;\n signal: NodeJS.Signals | null;\n error?: Error;\n timedOut: boolean;\n /** It exited while a process it started still held stderr open; that process was stopped. */\n leftRunning: boolean;\n /** The last `STDERR_TAIL_BYTES` of stderr. */\n stderr: string;\n}\n\n/** Signals that end this process; a build in its own process group would not receive them. */\nconst FORWARDED_SIGNALS: readonly NodeJS.Signals[] = ['SIGINT', 'SIGTERM', 'SIGHUP'];\nconst SEPARATE_PROCESS_GROUPS = process.platform !== 'win32';\n\n/**\n * Kills the build and everything it started. The build leads its own process group, so the\n * package manager's tsc or vite children die with it.\n * ponytail: Windows has no process groups here, so only the package manager is killed there;\n * `taskkill /T /F` is the upgrade if Windows builds must stop their children too.\n */\nfunction killBuild(child: ChildProcess): void {\n if (!SEPARATE_PROCESS_GROUPS || child.pid === undefined) {\n child.kill('SIGKILL');\n return;\n }\n try {\n process.kill(-child.pid, 'SIGKILL');\n } catch (error) {\n // ESRCH: every process of the group has exited already, which is the goal. Anything else\n // (EPERM) falls back to the package manager alone rather than crash inside a timer.\n if ((error as NodeJS.ErrnoException).code !== NO_SUCH_PROCESS) child.kill('SIGKILL');\n }\n}\n\n/**\n * Runs one build script without buffering its output: stdout is discarded and only the stderr\n * tail is kept. A build still running after `timeoutMs` is killed with every process it started\n * and reported as timed out. A build that exits while something it started still holds stderr\n * open has that process group killed when the grace ends, so nothing writes after it returns.\n */\nfunction runBuildScript(\n binary: string,\n directory: string,\n environment: NodeJS.ProcessEnv,\n timeoutMs: number,\n): Promise<BuildRun> {\n return new Promise((resolve) => {\n let tail = Buffer.alloc(0);\n let timedOut = false;\n let leftRunning = false;\n let settled = false;\n let grace: NodeJS.Timeout | undefined;\n // Its own process group, so a kill reaches its children. Still awaited: never unref'd.\n const child = spawn(binary, ['run', BUILD_SCRIPT], {\n cwd: directory,\n env: environment,\n stdio: ['ignore', 'ignore', 'pipe'],\n detached: SEPARATE_PROCESS_GROUPS,\n });\n // A detached build no longer gets the terminal's Ctrl+C, so this process passes it on.\n const forward = (signal: NodeJS.Signals): void => {\n killBuild(child);\n if (process.listenerCount(signal) > 1) return;\n // Only this handler was listening: end as the signal would have without it.\n process.removeListener(signal, forward);\n process.kill(process.pid, signal);\n };\n if (SEPARATE_PROCESS_GROUPS) for (const signal of FORWARDED_SIGNALS) process.on(signal, forward);\n const finish = (result: Pick<BuildRun, 'status' | 'signal' | 'error'>): void => {\n if (settled) return;\n settled = true;\n clearTimeout(timer);\n clearTimeout(grace);\n for (const signal of FORWARDED_SIGNALS) process.removeListener(signal, forward);\n child.stderr?.destroy();\n resolve({ ...result, timedOut, leftRunning, stderr: tail.toString('utf8') });\n };\n const timer = setTimeout(() => {\n timedOut = true;\n killBuild(child);\n }, timeoutMs);\n child.stderr?.on('data', (chunk: Buffer) => {\n tail = Buffer.concat([tail, chunk]);\n if (tail.length > STDERR_TAIL_BYTES) tail = tail.subarray(tail.length - STDERR_TAIL_BYTES);\n });\n child.on('error', (error) => finish({ status: null, signal: null, error }));\n child.on('close', (status, signal) => finish({ status, signal }));\n // A process the build left running can hold stderr open, so 'close' may never come.\n child.on('exit', (status, signal) => {\n grace = setTimeout(\n () => {\n if (!timedOut) leftRunning = true;\n killBuild(child);\n finish({ status, signal });\n },\n timedOut ? 0 : STDERR_CLOSE_GRACE_MS,\n );\n });\n });\n}\n\n/**\n * Builds every local package that changed since its last successful build, and returns each\n * directory's outcome. A failure never stops the others.\n */\nexport async function buildLocalPackages(input: LocalBuildInput): Promise<Map<string, LocalBuildOutcome>> {\n const { globalRoot, environment, onCommand, onNotice } = input;\n const timeoutMs = input.timeoutMs ?? LOCAL_BUILD_TIMEOUT_MS;\n const directories = [...new Set(input.directories)];\n const manifests = new Map(directories.map((directory) => [directory, readManifest(directory)]));\n const stamps = readStamps(globalRoot);\n const outcomes = new Map<string, LocalBuildOutcome>();\n const childEnvironment = buildEnvironment(environment);\n let searchPath = environment.PATH;\n let loginPathTried = false;\n const resolveBinary = (manager: string): string | undefined => {\n const found = findOnPath(manager, searchPath);\n if (found !== undefined || loginPathTried || process.platform !== 'darwin') return found;\n loginPathTried = true;\n const loginPath = loginShellPath(environment);\n if (loginPath === undefined) return undefined;\n searchPath = loginPath;\n childEnvironment.PATH = loginPath;\n return findOnPath(manager, searchPath);\n };\n\n for (const directory of dependencyOrder(directories, manifests)) {\n const manifest = manifests.get(directory);\n if (manifest === undefined) {\n outcomes.set(directory, { status: 'failed', reason: `'${directory}' has no readable package.json` });\n continue;\n }\n const stamp = localBuildStamp(directory);\n // ponytail: an unchanged stamp skips the build even when a dependency outside the\n // package changed; a content hash over the dependency closure is the upgrade.\n if (stamps[directory] === stamp) {\n outcomes.set(directory, { status: 'cached' });\n continue;\n }\n if (typeof manifest.scripts?.[BUILD_SCRIPT] !== 'string') {\n outcomes.set(\n directory,\n builtEntriesPresent(directory, manifest)\n ? { status: 'cached' }\n : { status: 'failed', reason: 'it has no build script and no built entries' },\n );\n continue;\n }\n const manager = packageManagerFor(directory);\n const binary = resolveBinary(manager);\n if (binary === undefined) {\n outcomes.set(directory, { status: 'failed', reason: `${manager} is not on PATH` });\n continue;\n }\n const command = `${binary} run ${BUILD_SCRIPT} (in ${directory})`;\n onCommand(command);\n onNotice(`building ${manifest.name ?? directory}`);\n const result = await runBuildScript(binary, directory, childEnvironment, timeoutMs);\n if (result.status === 0 && !result.timedOut && !result.leftRunning) {\n // The stamp after the build, as the sync pointer records it: a build that writes into\n // src/ or package.json must not look changed to the next sync.\n stamps[directory] = localBuildStamp(directory);\n writeFileAtomic(localBuildsPath(globalRoot), `${JSON.stringify(stamps, null, 2)}\\n`);\n outcomes.set(directory, { status: 'built' });\n continue;\n }\n const exit = result.timedOut\n ? `timed out after ${String(timeoutMs / MILLISECONDS_PER_SECOND)} s`\n : result.status === 0 && result.leftRunning\n ? 'it exited but left processes running, which were stopped'\n : (result.error?.message ?? `exit ${String(result.status ?? result.signal)}`);\n outcomes.set(directory, {\n status: 'failed',\n reason: `${manager} run ${BUILD_SCRIPT} failed (${exit})`,\n stderr: stderrTail(result.stderr),\n });\n }\n return outcomes;\n}\n"],"mappings":";;;;;;;;;;;;;;;AAaA,MAAM,yBAAyB;AAC/B,MAAM,mBAAmB;AACzB,MAAM,eAAe;AACrB,MAAM,oBAAoBA,UAAAA,QAAK,KAAK,SAAS,mBAAmB;AAChE,MAAM,eAAe;;AAGrB,MAAM,oBAAoB;;;;;AAK1B,MAAa,yBAAyB;;AAEtC,MAAM,wBAAwB;AAC9B,MAAM,0BAA0B;AAChC,MAAM,yBAAyB;AAC/B,MAAM,0BAA0B;AAChC,MAAM,kBAAkB;;AAExB,MAAM,YAAoD;CACxD,CAAC,kBAAkB,MAA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