@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,808 @@
1
+ const require_runtime = require("../../../_virtual/_rolldown/runtime.cjs");
2
+ const require_entryResolution = require("../../builders/cli/entryResolution.cjs");
3
+ const require_index = require("../../builders/web/index.cjs");
4
+ const require_index$1 = require("../../builders/native/index.cjs");
5
+ const require_index$2 = require("../layerPackageInstaller/index.cjs");
6
+ const require_sessionComposition = require("../../builders/cli/sessionComposition.cjs");
7
+ const require_mcpAppBuild = require("../../builders/server/mcpAppBuild.cjs");
8
+ const require_mcpBundle = require("../../builders/server/mcpBundle.cjs");
9
+ const require_index$3 = require("../syncPrune/index.cjs");
10
+ const require_localBuilds = require("./localBuilds.cjs");
11
+ let node_fs = require("node:fs");
12
+ node_fs = require_runtime.__toESM(node_fs, 1);
13
+ let node_path = require("node:path");
14
+ node_path = require_runtime.__toESM(node_path, 1);
15
+ let _agimon_ai_po_core_runtimeJson = require("@agimon-ai/po-core/runtimeJson");
16
+ let node_child_process = require("node:child_process");
17
+ let _agimon_ai_po_config_config = require("@agimon-ai/po-config/config");
18
+ let _agimon_ai_po_config_majorModes = require("@agimon-ai/po-config/majorModes");
19
+ let _agimon_ai_po_core_piSettings = require("@agimon-ai/po-core/piSettings");
20
+ let node_crypto = require("node:crypto");
21
+ node_crypto = require_runtime.__toESM(node_crypto, 1);
22
+ let _agimon_ai_po_core_history = require("@agimon-ai/po-core/history");
23
+ //#region src/composition/syncService/index.ts
24
+ /**
25
+ * The sync service: installs what the configuration names, ensures the global builds,
26
+ * prunes, and reports what happened as one `SyncReport`.
27
+ *
28
+ * The roots are the Po home, every registered workspace whose folder exists, and the
29
+ * repository sync runs from, which it registers. One install covers the catalogue and every
30
+ * root's published packages. When the signature over the catalogue, each root's selection,
31
+ * each local package's build stamp and the host identity (the po package and po-web host
32
+ * versions) matches `current.json` and every artifact it names exists, sync returns `noop`
33
+ * without installing or building. The pointer records that identity, so a server from another
34
+ * Po install can tell the build is not its own.
35
+ *
36
+ * Only one sync runs at a time per Po home, guarded by `<po home>/build/.sync.lock`. A CLI
37
+ * run that finds the lock held reports `busy`. A background run instead leaves
38
+ * `.sync.rerun`, and the holder runs once more, so the background request is never lost.
39
+ */
40
+ const BUILD_DIRECTORY = "build";
41
+ const LOCK_FILE = ".sync.lock";
42
+ const RERUN_FILE = ".sync.rerun";
43
+ const POINTER_FILE = "current.json";
44
+ const LAST_ATTEMPT_FILE = "last-attempt.json";
45
+ const MCP_APP_FILE = "index.html";
46
+ const HOOK_EMITTER = node_path.default.join("tools", "harness", "emit-hooks.mjs");
47
+ const ROOTS_LABEL = "roots";
48
+ const PACKAGES_LABEL = "packages";
49
+ const WEB_LABEL = "web";
50
+ const NATIVE_LABEL = "native";
51
+ const MCP_LABEL = "mcp app";
52
+ const PRUNE_LABEL = "prune";
53
+ const HOOKS_LABEL = "hooks";
54
+ const LOCAL_LABEL = "local";
55
+ const BYTES_PER_MEGABYTE = 1048576;
56
+ /** A lock file younger than this that cannot be parsed is still being written by its owner. */
57
+ const UNREADABLE_LOCK_GRACE_MS = 1e4;
58
+ const NO_SUCH_PROCESS = "ESRCH";
59
+ /**
60
+ * Bumped when the pointer gains a field a reader relies on, so an older pointer never matches
61
+ * the fast-exit signature and the next sync rewrites it. 2: per-root `fingerprints`. 3: `host`.
62
+ */
63
+ const SIGNATURE_FORMAT = 3;
64
+ const PACKAGE_MANIFEST = "package.json";
65
+ const ALREADY_EXISTS = "EEXIST";
66
+ const NO_SUCH_FILE = "ENOENT";
67
+ /** `process.kill(pid, 0)` probes without signalling; only ESRCH means the process is gone. */
68
+ function processIsAlive(pid) {
69
+ try {
70
+ process.kill(pid, 0);
71
+ return true;
72
+ } catch (error) {
73
+ return error.code !== NO_SUCH_PROCESS;
74
+ }
75
+ }
76
+ const DEFAULT_DEPS = {
77
+ install: require_index$2.ensureLayerPackages,
78
+ buildWeb: require_index.ensureGlobalWebBuild,
79
+ buildNative: require_index$1.ensureGlobalNativeBuild,
80
+ bundleMcpApp: require_mcpAppBuild.ensureMcpAppBuild,
81
+ prune: require_index$3.pruneAfterSync,
82
+ isAlive: processIsAlive,
83
+ pid: process.pid,
84
+ now: () => /* @__PURE__ */ new Date()
85
+ };
86
+ function syncExitCode(status) {
87
+ if (status === "busy") return 75;
88
+ return status === "ok" || status === "noop" ? 0 : 1;
89
+ }
90
+ function syncLockPath(globalRoot) {
91
+ return node_path.default.join(globalRoot, BUILD_DIRECTORY, LOCK_FILE);
92
+ }
93
+ function syncRerunPath(globalRoot) {
94
+ return node_path.default.join(globalRoot, BUILD_DIRECTORY, RERUN_FILE);
95
+ }
96
+ function pluralize(count, noun) {
97
+ return `${String(count)} ${noun}${count === 1 ? "" : "s"}`;
98
+ }
99
+ function errorMessage(error) {
100
+ return error instanceof Error ? error.message : String(error);
101
+ }
102
+ function packageSummary(result) {
103
+ const parts = [];
104
+ if (result.updated.length > 0) parts.push(`updated ${pluralize(result.updated.length, "package")}`);
105
+ if (result.installed.length > 0) parts.push(`installed ${pluralize(result.installed.length, "missing package")}`);
106
+ if (parts.length === 0) parts.push("already up to date");
107
+ if (result.unchecked.length > 0) parts.push(`${pluralize(result.unchecked.length, "package")} left unchecked`);
108
+ return parts.join(", ");
109
+ }
110
+ function formatSyncResult(result) {
111
+ return [
112
+ `packages: ${packageSummary(result.packages)}`,
113
+ `web: ${result.web.status === "skipped" ? result.web.reason : `${result.web.key} (${result.web.status})`}`,
114
+ ...result.native === void 0 ? [] : [`native: ${result.native.status === "skipped" ? result.native.reason : `${result.native.key} (${result.native.status})`}`],
115
+ ...result.mcpApp === void 0 ? [] : [`mcp app: ${result.mcpApp}`],
116
+ ""
117
+ ].join("\n");
118
+ }
119
+ function workspaceRegistry(homeDirectory, environment, onNotice) {
120
+ return (0, _agimon_ai_po_core_history.createWorkspaceRegistry)({
121
+ directory: node_path.default.join((0, _agimon_ai_po_core_piSettings.piAgentDirectory)(environment, homeDirectory), "server"),
122
+ onNotice
123
+ });
124
+ }
125
+ /**
126
+ * Each root's compositions, resolved the way the server resolves them: a selection that does
127
+ * not resolve yet (an unbuilt local package, say) is left out with a diagnostic instead of
128
+ * failing the whole root, so sync and the server derive the same web, MCP and fingerprint
129
+ * inputs. A root that cannot be composed at all maps to why.
130
+ */
131
+ function composeRoots(roots, homeDirectory, environment) {
132
+ return new Map(roots.map((root) => {
133
+ try {
134
+ return [root, require_sessionComposition.rootCompositions({
135
+ root,
136
+ homeDirectory,
137
+ environment,
138
+ tolerateUnsynced: true
139
+ })];
140
+ } catch (error) {
141
+ return [root, error instanceof Error ? error : new Error(String(error))];
142
+ }
143
+ }));
144
+ }
145
+ /** Each root's composition package roots; a root that cannot be composed is left out with a notice. */
146
+ function packageRootsByRoot(composed, onNotice) {
147
+ return new Map([...composed].map(([root, compositions]) => {
148
+ if (!(compositions instanceof Error)) return [root, require_index.compositionPackageRoots(compositions)];
149
+ onNotice(`'${root}' is left out of the web build: ${compositions.message}`);
150
+ return [root, []];
151
+ }));
152
+ }
153
+ /** The selectors a lenient composition left out, each once with the first diagnostic that explains it. */
154
+ function skippedSelections(compositions) {
155
+ const skipped = /* @__PURE__ */ new Map();
156
+ for (const composition of compositions) for (const selection of composition.selections) if (selection.outcome === "missing-optional" && !selection.optional && !skipped.has(selection.selector)) skipped.set(selection.selector, selection.diagnostic ?? "it does not resolve");
157
+ return [...skipped].map(([selector, reason]) => ({
158
+ selector,
159
+ reason
160
+ }));
161
+ }
162
+ /**
163
+ * The plugin roots one global web build covers: every installed catalogue package, so each
164
+ * first-party plugin has a slot whether or not a config names it yet, then each root's own
165
+ * composition package roots. Sync builds with these and the server derives the same key.
166
+ */
167
+ function webPluginRootsOf(globalRoot, rootPackageRoots, environment) {
168
+ return [...require_index$2.catalogPackageRoots(globalRoot, environment), ...[...rootPackageRoots.values()].flat()];
169
+ }
170
+ /**
171
+ * Every package root the global web build covers: the catalogue packages, the global root,
172
+ * every workspace the server has admitted, and `targetRoot`, which the server admits when it
173
+ * opens it. A root whose configuration cannot be read is left out with a notice, as sync
174
+ * leaves it out of the build when it cannot compose it.
175
+ */
176
+ function globalWebPluginRoots(targetRoot, homeDirectory, environment, onNotice) {
177
+ const globalRoot = (0, _agimon_ai_po_config_config.globalDoomConfigDirectory)(homeDirectory);
178
+ const admitted = workspaceRegistry(homeDirectory, environment, onNotice).list().map((workspace) => workspace.root).filter((root) => node_fs.default.existsSync(root));
179
+ return webPluginRootsOf(globalRoot, packageRootsByRoot(composeRoots([.../* @__PURE__ */ new Set([
180
+ globalRoot,
181
+ ...admitted,
182
+ targetRoot
183
+ ])], homeDirectory, environment), onNotice), environment);
184
+ }
185
+ /**
186
+ * Registers the repository as a workspace the way the server admits one, so one repository
187
+ * never gets two ids, and returns the workspace root it belongs to.
188
+ */
189
+ function registerRepository(registry, repoRoot, onNotice) {
190
+ const checkoutRoot = node_fs.default.realpathSync(repoRoot);
191
+ const { id, root, moved } = (0, _agimon_ai_po_core_history.identifyWorkspace)({
192
+ records: registry.list(),
193
+ checkoutRoot,
194
+ marker: (0, _agimon_ai_po_core_history.readWorkspaceMarker)(checkoutRoot)
195
+ });
196
+ const record = registry.list().find((workspace) => workspace.id === id);
197
+ if (record === void 0 || moved) registry.add({
198
+ id,
199
+ root,
200
+ ...record?.name === void 0 ? {} : { name: record.name }
201
+ });
202
+ if (moved) onNotice(`workspace '${id}' moved to '${root}'`);
203
+ try {
204
+ if ((0, _agimon_ai_po_core_history.readWorkspaceMarker)(root) === void 0) (0, _agimon_ai_po_core_history.writeWorkspaceMarker)(root, id);
205
+ } catch (error) {
206
+ onNotice(`'${root}' id could not be recorded in its git data: ${errorMessage(error)}`);
207
+ }
208
+ return root;
209
+ }
210
+ /**
211
+ * The roots this sync covers: the Po home, every registered workspace whose folder exists,
212
+ * and the repository, registered first. Entries whose folder is gone are removed with a warning.
213
+ */
214
+ function resolveRoots(options, progress) {
215
+ const notice = (message) => progress.line(ROOTS_LABEL, message);
216
+ const registry = workspaceRegistry(options.homeDirectory, options.environment, notice);
217
+ const repository = options.repoRoot === void 0 || node_path.default.resolve(options.repoRoot) === node_path.default.resolve(options.globalRoot) ? void 0 : registerRepository(registry, options.repoRoot, notice);
218
+ const live = [];
219
+ for (const workspace of registry.list()) {
220
+ if (node_fs.default.existsSync(workspace.root)) {
221
+ live.push(workspace.root);
222
+ continue;
223
+ }
224
+ notice(`warning: removed workspace '${workspace.id}': '${workspace.root}' no longer exists`);
225
+ registry.remove(workspace.id);
226
+ }
227
+ return [.../* @__PURE__ */ new Set([
228
+ options.globalRoot,
229
+ ...live,
230
+ ...repository === void 0 ? [] : [repository]
231
+ ])];
232
+ }
233
+ /** The packages a root's layers name by local path, each resolved against its layer's base directory. */
234
+ function localPackages(config) {
235
+ const definitions = [...config.default ? [config.default] : [], ...Object.values(config.layers)];
236
+ const packages = /* @__PURE__ */ new Map();
237
+ for (const definition of definitions) for (const configured of definition.packages ?? []) {
238
+ const selector = typeof configured === "string" ? configured : configured.name;
239
+ if (!(0, _agimon_ai_po_config_majorModes.isLocalPackageSpecifier)(selector)) continue;
240
+ const directory = node_path.default.resolve(definition.baseDirectory, selector);
241
+ if (!packages.has(directory)) packages.set(directory, {
242
+ selector,
243
+ directory
244
+ });
245
+ }
246
+ return [...packages.values()];
247
+ }
248
+ /**
249
+ * SHA-256 over every mode's composition fingerprint, or why the root cannot be composed. The
250
+ * pointer records it per root, so a server can tell a root whose selection changed since the
251
+ * last sync by computing it again with the environment sync ran under.
252
+ */
253
+ function rootSelectionFingerprint(root, homeDirectory, environment) {
254
+ try {
255
+ const fingerprints = require_sessionComposition.rootCompositions({
256
+ root,
257
+ homeDirectory,
258
+ environment,
259
+ tolerateUnsynced: true
260
+ }).map((composition) => composition.fingerprint);
261
+ return node_crypto.default.createHash("sha256").update(fingerprints.join("\n")).digest("hex");
262
+ } catch (error) {
263
+ return `unresolved:${errorMessage(error)}`;
264
+ }
265
+ }
266
+ /** The po package version this process runs from, or why it cannot be read. */
267
+ function poPackageVersion() {
268
+ try {
269
+ const manifest = JSON.parse(node_fs.default.readFileSync(node_path.default.join(require_entryResolution.poPackageRoot(), PACKAGE_MANIFEST), "utf8"));
270
+ return typeof manifest.version === "string" ? manifest.version : "unversioned";
271
+ } catch (error) {
272
+ return `unreadable:${errorMessage(error)}`;
273
+ }
274
+ }
275
+ /**
276
+ * The Po install a sync or a server runs from: its po package version and the po-web host
277
+ * version it builds with. Sync records it in the pointer; a server whose identity differs
278
+ * refuses that pointer's builds and syncs with its own install.
279
+ */
280
+ function syncHostIdentity(globalRoot, environment) {
281
+ return `po@${poPackageVersion()}+po-web@${require_index.webHostVersion(globalRoot, environment)}`;
282
+ }
283
+ /** The fast-exit signature: catalogue hash, each root's selection and local build stamps, host identity. */
284
+ function syncSignature(options, roots, catalogueHash) {
285
+ const { homeDirectory, environment } = options;
286
+ const value = {
287
+ format: SIGNATURE_FORMAT,
288
+ catalogueHash,
289
+ roots: roots.map((root) => ({
290
+ root,
291
+ selection: rootSelectionFingerprint(root, homeDirectory, environment),
292
+ local: localPackages((0, _agimon_ai_po_config_majorModes.loadMajorModesConfigLenient)(root, homeDirectory, environment).config).map(({ directory }) => [directory, require_localBuilds.localBuildStamp(directory)])
293
+ })),
294
+ host: syncHostIdentity(options.globalRoot, environment)
295
+ };
296
+ return node_crypto.default.createHash("sha256").update(JSON.stringify(value)).digest("hex");
297
+ }
298
+ function syncPointerPath(globalRoot) {
299
+ return node_path.default.join(globalRoot, BUILD_DIRECTORY, POINTER_FILE);
300
+ }
301
+ function syncLastAttemptPath(globalRoot) {
302
+ return node_path.default.join(globalRoot, BUILD_DIRECTORY, LAST_ATTEMPT_FILE);
303
+ }
304
+ /** The current pointer, or undefined when sync has not written one yet or it is unreadable. */
305
+ function readSyncPointer(globalRoot) {
306
+ try {
307
+ const parsed = JSON.parse(node_fs.default.readFileSync(syncPointerPath(globalRoot), "utf8"));
308
+ return typeof parsed.signature === "string" && typeof parsed.generation === "number" ? parsed : void 0;
309
+ } catch {
310
+ return;
311
+ }
312
+ }
313
+ /** The files whose presence proves each artifact a pointer names is complete. */
314
+ function pointerArtifacts(globalRoot, pointer) {
315
+ const build = node_path.default.join(globalRoot, BUILD_DIRECTORY);
316
+ return [
317
+ ...pointer.webKey === null ? [] : [node_path.default.join(build, WEB_LABEL, pointer.webKey, require_index.BUILD_RECORD)],
318
+ ...pointer.nativeKey === null ? [] : [node_path.default.join(build, NATIVE_LABEL, pointer.nativeKey, require_index.BUILD_RECORD)],
319
+ ...pointer.mcpKeys.map((key) => node_path.default.join(build, "mcp-app", key, MCP_APP_FILE))
320
+ ];
321
+ }
322
+ /** The report of the last sync attempt, successful or not, or undefined when there is none. */
323
+ function readSyncLastAttempt(globalRoot) {
324
+ try {
325
+ const parsed = JSON.parse(node_fs.default.readFileSync(syncLastAttemptPath(globalRoot), "utf8"));
326
+ return Array.isArray(parsed.roots) ? parsed : void 0;
327
+ } catch {
328
+ return;
329
+ }
330
+ }
331
+ function writeJsonFile(file, value) {
332
+ (0, _agimon_ai_po_core_runtimeJson.writeFileAtomic)(file, `${JSON.stringify(value, null, 2)}\n`);
333
+ }
334
+ function readHolder(lockPath) {
335
+ try {
336
+ const parsed = JSON.parse(node_fs.default.readFileSync(lockPath, "utf8"));
337
+ return typeof parsed.pid === "number" ? parsed : void 0;
338
+ } catch {
339
+ return;
340
+ }
341
+ }
342
+ function lockIsStale(lockPath, deps) {
343
+ const holder = readHolder(lockPath);
344
+ if (holder !== void 0) return !deps.isAlive(holder.pid);
345
+ try {
346
+ return deps.now().getTime() - node_fs.default.statSync(lockPath).mtimeMs > UNREADABLE_LOCK_GRACE_MS;
347
+ } catch {
348
+ return true;
349
+ }
350
+ }
351
+ function tryCreateLock(lockPath, holder) {
352
+ try {
353
+ const descriptor = node_fs.default.openSync(lockPath, "wx");
354
+ try {
355
+ node_fs.default.writeSync(descriptor, JSON.stringify(holder));
356
+ } finally {
357
+ node_fs.default.closeSync(descriptor);
358
+ }
359
+ return true;
360
+ } catch (error) {
361
+ if (error.code === ALREADY_EXISTS) return false;
362
+ throw error;
363
+ }
364
+ }
365
+ /**
366
+ * Takes over a lock judged stale. Removing it by path could remove a lock another taker created
367
+ * since the check, so it is first renamed to a name only this process knows and checked again
368
+ * there: a lock that turns out live is linked back (link never replaces), a stale one is dropped
369
+ * before the exclusive create, which at most one taker wins.
370
+ */
371
+ function takeOverStaleLock(lockPath, holder, deps) {
372
+ const moved = `${lockPath}.${String(deps.pid)}.${node_crypto.default.randomUUID()}.stale`;
373
+ try {
374
+ node_fs.default.renameSync(lockPath, moved);
375
+ } catch (error) {
376
+ if (error.code === NO_SUCH_FILE) return tryCreateLock(lockPath, holder);
377
+ throw error;
378
+ }
379
+ try {
380
+ if (!lockIsStale(moved, deps)) {
381
+ try {
382
+ node_fs.default.linkSync(moved, lockPath);
383
+ } catch (error) {
384
+ if (error.code !== ALREADY_EXISTS) throw error;
385
+ }
386
+ return false;
387
+ }
388
+ } finally {
389
+ node_fs.default.rmSync(moved, { force: true });
390
+ }
391
+ return tryCreateLock(lockPath, holder);
392
+ }
393
+ /** Creates the lock, taking over one whose holder is dead. Never inspects other processes beyond `kill(pid, 0)`. */
394
+ function acquireLock(lockPath, origin, deps) {
395
+ node_fs.default.mkdirSync(node_path.default.dirname(lockPath), { recursive: true });
396
+ const token = node_crypto.default.randomUUID();
397
+ const holder = {
398
+ pid: deps.pid,
399
+ token,
400
+ startedAt: deps.now().toISOString(),
401
+ origin
402
+ };
403
+ if (tryCreateLock(lockPath, holder)) return {
404
+ acquired: true,
405
+ token
406
+ };
407
+ if (lockIsStale(lockPath, deps) && takeOverStaleLock(lockPath, holder, deps)) return {
408
+ acquired: true,
409
+ token
410
+ };
411
+ return {
412
+ acquired: false,
413
+ holder: readHolder(lockPath)
414
+ };
415
+ }
416
+ /**
417
+ * The lock as the holder with `token` sees it: undefined while the lock still names it, else
418
+ * the busy report to stop with. A takeover that moved a live lock aside can let a third taker
419
+ * create a new one, so a holder checks before each step whose overlap would do harm.
420
+ */
421
+ function lostLock(lockPath, token, deps) {
422
+ const holder = readHolder(lockPath);
423
+ if (holder?.token === token) return void 0;
424
+ return emptyReport("busy", [`po sync lost its lock to ${holder === void 0 ? "another process" : `pid ${String(holder.pid)}`}`], deps);
425
+ }
426
+ function releaseLock(lockPath, token) {
427
+ if (readHolder(lockPath)?.token === token) node_fs.default.rmSync(lockPath, { force: true });
428
+ }
429
+ /** Consumes the rerun marker; true when a background run asked for another pass. */
430
+ function takeRerunRequest(rerunPath) {
431
+ if (!node_fs.default.existsSync(rerunPath)) return false;
432
+ node_fs.default.rmSync(rerunPath, { force: true });
433
+ return true;
434
+ }
435
+ function emptyReport(status, errors, deps) {
436
+ return {
437
+ status,
438
+ generation: null,
439
+ catalogueHash: null,
440
+ webKey: null,
441
+ mcpKeys: [],
442
+ roots: [],
443
+ commands: [],
444
+ errors,
445
+ finishedAt: deps.now().toISOString()
446
+ };
447
+ }
448
+ /** A step reporter over the event stream, mirroring the presenter's start/done/line. */
449
+ function steps(emit) {
450
+ return {
451
+ start(label, message) {
452
+ emit({
453
+ type: "start",
454
+ label,
455
+ message
456
+ });
457
+ return (summary) => emit({
458
+ type: "done",
459
+ label,
460
+ summary
461
+ });
462
+ },
463
+ line(label, message) {
464
+ emit({
465
+ type: "line",
466
+ label,
467
+ message
468
+ });
469
+ }
470
+ };
471
+ }
472
+ /**
473
+ * Drops old builds and unreferenced store content once installs and builds are done.
474
+ * Never fatal: a failed prune leaves everything for the next explicit sync.
475
+ */
476
+ async function pruneStep(progress, prune, input) {
477
+ const done = progress.start(PRUNE_LABEL, "dropping old builds and unused packages");
478
+ try {
479
+ const result = await prune(input);
480
+ const runtime = "skipped" in result.runtime ? result.runtime.skipped : `${(result.runtime.bytes / BYTES_PER_MEGABYTE).toFixed(1)} MB of packages released`;
481
+ done(`removed ${pluralize(result.builds.length, "old build")}, ${runtime}`);
482
+ } catch (error) {
483
+ done(`failed: ${errorMessage(error)}`);
484
+ }
485
+ }
486
+ /** Regenerates the hook files the other frontends read before any harness code runs, in a root that has the emitter. */
487
+ function emitFrontendHooks(root, progress, commands) {
488
+ const emitter = node_path.default.join(root, HOOK_EMITTER);
489
+ if (!node_fs.default.existsSync(emitter)) return;
490
+ commands.push(`${process.execPath} ${emitter} --write`);
491
+ const result = (0, node_child_process.spawnSync)(process.execPath, [emitter, "--write"], {
492
+ cwd: root,
493
+ encoding: "utf8"
494
+ });
495
+ if (result.status === 0) {
496
+ progress.line(HOOKS_LABEL, `regenerated for Claude Code and Codex in '${root}'`);
497
+ return;
498
+ }
499
+ progress.line(HOOKS_LABEL, `emit-hooks failed in '${root}' (${result.stderr?.trim() || `exit ${String(result.status)}`})`);
500
+ }
501
+ /** A path with its symlinks resolved, or as given when it does not exist. */
502
+ function realPath(file) {
503
+ try {
504
+ return node_fs.default.realpathSync(file);
505
+ } catch {
506
+ return node_path.default.resolve(file);
507
+ }
508
+ }
509
+ /**
510
+ * One sync pass under the lock. A failed step ends the pass with a `failed` report and leaves
511
+ * the pointer alone; a lock that no longer names this holder (`lost`) ends it as busy.
512
+ */
513
+ async function syncOnce(options, deps, emit, lost) {
514
+ const { homeDirectory, environment, globalRoot } = options;
515
+ const progress = steps(emit);
516
+ const commands = [];
517
+ const roots = resolveRoots(options, progress);
518
+ const catalogueHash = require_index$2.packageCatalogHash(environment);
519
+ const previous = readSyncPointer(globalRoot);
520
+ if (previous !== void 0 && (options.origin === "background" || previous.roots.every((root) => root.unsynced.length === 0)) && previous.signature === syncSignature(options, roots, catalogueHash) && pointerArtifacts(globalRoot, previous).every((file) => node_fs.default.existsSync(file))) {
521
+ progress.line(ROOTS_LABEL, `nothing changed since generation ${String(previous.generation)}`);
522
+ return {
523
+ ...emptyReport("noop", [], deps),
524
+ generation: previous.generation,
525
+ catalogueHash,
526
+ webKey: previous.webKey,
527
+ mcpKeys: previous.mcpKeys,
528
+ roots: previous.roots
529
+ };
530
+ }
531
+ const unsynced = new Map(roots.map((root) => [root, []]));
532
+ const report = (status, errors, webKey, mcpKeys) => {
533
+ const rootReports = roots.map((root) => {
534
+ const entries = unsynced.get(root) ?? [];
535
+ return {
536
+ root,
537
+ status: status === "ok" && entries.length > 0 ? "partial" : status,
538
+ unsynced: entries
539
+ };
540
+ });
541
+ return {
542
+ ...emptyReport(status === "ok" && rootReports.some((root) => root.status === "partial") ? "partial" : status, errors, deps),
543
+ generation: previous?.generation ?? null,
544
+ catalogueHash,
545
+ webKey,
546
+ mcpKeys,
547
+ roots: rootReports,
548
+ commands
549
+ };
550
+ };
551
+ const lostBeforeInstall = lost();
552
+ if (lostBeforeInstall !== void 0) return lostBeforeInstall;
553
+ const packagesDone = progress.start(PACKAGES_LABEL, "checking configured packages for updates");
554
+ let packages;
555
+ try {
556
+ const configOf = (root) => (0, _agimon_ai_po_config_majorModes.loadMajorModesConfigLenient)(root, homeDirectory, environment).config;
557
+ const globalConfig = configOf(globalRoot);
558
+ const specifiers = new Set(require_index$2.catalogInstallSpecifiers(environment));
559
+ for (const root of roots) {
560
+ const config = configOf(root);
561
+ for (const specifier of require_index$2.runtimeLayerPackageSpecifiers(config, Object.keys(config.layers), root)) specifiers.add(specifier);
562
+ }
563
+ packages = await deps.install({
564
+ repoRoot: globalRoot,
565
+ config: globalConfig,
566
+ layers: Object.keys(globalConfig.layers),
567
+ environment,
568
+ refresh: options.origin === "cli",
569
+ specifiers: [...specifiers],
570
+ exactManifest: true,
571
+ onProgress: (message) => progress.line(PACKAGES_LABEL, message)
572
+ });
573
+ } catch (error) {
574
+ packagesDone("failed");
575
+ return report("failed", [`Installing packages failed: ${errorMessage(error)}`], null, []);
576
+ }
577
+ packagesDone(packageSummary(packages));
578
+ const localByRoot = new Map(roots.map((root) => [root, localPackages((0, _agimon_ai_po_config_majorModes.loadMajorModesConfigLenient)(root, homeDirectory, environment).config)]));
579
+ const localDirectories = [...localByRoot.values()].flat().map(({ directory }) => directory);
580
+ if (localDirectories.length > 0) {
581
+ const localDone = progress.start(LOCAL_LABEL, "building local packages");
582
+ const outcomes = await require_localBuilds.buildLocalPackages({
583
+ globalRoot,
584
+ environment,
585
+ directories: localDirectories,
586
+ onCommand: (command) => commands.push(command),
587
+ onNotice: (message) => progress.line(LOCAL_LABEL, message)
588
+ });
589
+ let failed = 0;
590
+ for (const [root, packagesOfRoot] of localByRoot) for (const { selector, directory } of packagesOfRoot) {
591
+ const outcome = outcomes.get(directory);
592
+ if (outcome?.status !== "failed") continue;
593
+ unsynced.get(root)?.push({
594
+ selector,
595
+ reason: outcome.reason,
596
+ ...outcome.stderr === void 0 ? {} : { stderr: outcome.stderr }
597
+ });
598
+ }
599
+ for (const outcome of outcomes.values()) if (outcome.status === "failed") failed += 1;
600
+ localDone(failed === 0 ? `${pluralize(outcomes.size, "package")} ready` : `${String(failed)} failed`);
601
+ }
602
+ const composed = composeRoots(roots, homeDirectory, environment);
603
+ for (const [root, compositions] of composed) {
604
+ if (compositions instanceof Error) continue;
605
+ const entries = unsynced.get(root) ?? [];
606
+ for (const skipped of skippedSelections(compositions)) if (!entries.some((entry) => entry.selector === skipped.selector)) entries.push(skipped);
607
+ }
608
+ const webDone = progress.start(WEB_LABEL, "ensuring the global web build");
609
+ let rootPackageRoots = packageRootsByRoot(composed, (message) => progress.line(WEB_LABEL, message));
610
+ const buildWeb = (packageRoots) => deps.buildWeb({
611
+ poHome: globalRoot,
612
+ pluginRoots: webPluginRootsOf(globalRoot, packageRoots, environment),
613
+ environment,
614
+ onNotice: (message) => progress.line(WEB_LABEL, message)
615
+ });
616
+ let built = await buildWeb(rootPackageRoots);
617
+ if (built.status === "failed") {
618
+ const local = new Set(localDirectories.map(realPath));
619
+ const withoutLocal = new Map([...rootPackageRoots].map(([root, packageRoots]) => [root, packageRoots.filter((packageRoot) => !local.has(realPath(packageRoot)))]));
620
+ const leftOut = [...rootPackageRoots].some(([root, packageRoots]) => withoutLocal.get(root)?.length !== packageRoots.length);
621
+ const retried = leftOut ? await buildWeb(withoutLocal) : built;
622
+ if (retried.status === "failed") {
623
+ webDone("failed");
624
+ const retryReason = leftOut ? `; without local copies: ${retried.reason}` : "";
625
+ return report("failed", [`The global web build failed: ${built.reason}${retryReason}`], null, []);
626
+ }
627
+ for (const [root, packagesOfRoot] of localByRoot) {
628
+ const included = new Set((rootPackageRoots.get(root) ?? []).map(realPath));
629
+ const entries = unsynced.get(root) ?? [];
630
+ for (const { selector, directory } of packagesOfRoot) if (included.has(realPath(directory)) && !entries.some((entry) => entry.selector === selector)) entries.push({
631
+ selector,
632
+ reason: `left out of the web build, which failed with it: ${built.reason}`
633
+ });
634
+ }
635
+ progress.line(WEB_LABEL, `built without local copies after: ${built.reason}`);
636
+ rootPackageRoots = withoutLocal;
637
+ built = retried;
638
+ }
639
+ const pluginRoots = webPluginRootsOf(globalRoot, rootPackageRoots, environment);
640
+ const web = built.status === "skipped" ? built : {
641
+ status: built.status,
642
+ key: built.build.key
643
+ };
644
+ webDone(web.status === "skipped" ? web.reason : `${web.key} (${web.status})`);
645
+ const webKey = web.status === "skipped" ? null : web.key;
646
+ const nativeDone = progress.start(NATIVE_LABEL, "ensuring the global native build");
647
+ const nativeBuilt = await deps.buildNative({
648
+ poHome: globalRoot,
649
+ pluginRoots,
650
+ onNotice: (message) => progress.line(NATIVE_LABEL, message)
651
+ });
652
+ if (nativeBuilt.status === "failed") {
653
+ nativeDone("failed");
654
+ return report("failed", [`The global native build failed: ${nativeBuilt.reason}`], webKey, []);
655
+ }
656
+ const native = nativeBuilt.status === "skipped" ? nativeBuilt : {
657
+ status: nativeBuilt.status,
658
+ key: nativeBuilt.build.key
659
+ };
660
+ nativeDone(native.status === "skipped" ? native.reason : `${native.key} (${native.status})`);
661
+ const nativeKey = native.status === "skipped" ? null : native.key;
662
+ const mcpDone = progress.start(MCP_LABEL, "ensuring the MCP app build of each root");
663
+ const mcpKeys = [];
664
+ for (const [root, compositions] of composed) {
665
+ if (compositions instanceof Error) {
666
+ progress.line(MCP_LABEL, `'${root}' is left out of the MCP app build: ${compositions.message}`);
667
+ continue;
668
+ }
669
+ try {
670
+ const app = await deps.bundleMcpApp({
671
+ poHome: globalRoot,
672
+ candidates: require_mcpBundle.mcpPluginCandidates(compositions)
673
+ });
674
+ if (app !== void 0 && !mcpKeys.includes(app.key)) mcpKeys.push(app.key);
675
+ } catch (error) {
676
+ unsynced.get(root)?.push({
677
+ selector: MCP_LABEL,
678
+ reason: `the MCP app build failed: ${errorMessage(error)}`
679
+ });
680
+ }
681
+ }
682
+ mcpDone(mcpKeys.length === 0 ? "no MCP UI widgets" : mcpKeys.join(", "));
683
+ const mcpApp = mcpKeys.length === 0 ? void 0 : mcpKeys.join(", ");
684
+ const missing = pointerArtifacts(globalRoot, {
685
+ webKey,
686
+ nativeKey,
687
+ mcpKeys
688
+ }).filter((file) => !node_fs.default.existsSync(file));
689
+ if (missing.length > 0) return report("failed", [`Build artifacts are missing: ${missing.join(", ")}`], webKey, mcpKeys);
690
+ if (built.status !== "skipped") for (const [root, packageRoots] of rootPackageRoots) for (const [pluginId, slots] of require_index.duplicatePluginCopies(built.build, packageRoots)) unsynced.get(root)?.push({
691
+ selector: pluginId,
692
+ reason: `two copies of plugin '${pluginId}' are selected (${slots.join(", ")})`
693
+ });
694
+ const succeeded = report("ok", [], webKey, mcpKeys);
695
+ const generation = (previous?.generation ?? 0) + 1;
696
+ const pointer = {
697
+ generation,
698
+ signature: syncSignature(options, roots, catalogueHash),
699
+ catalogueHash,
700
+ webKey,
701
+ nativeKey,
702
+ mcpKeys,
703
+ roots: succeeded.roots,
704
+ commands,
705
+ fingerprints: Object.fromEntries(roots.map((root) => [root, rootSelectionFingerprint(root, homeDirectory, environment)])),
706
+ host: syncHostIdentity(globalRoot, environment)
707
+ };
708
+ const lostBeforePointer = lost();
709
+ if (lostBeforePointer !== void 0) return lostBeforePointer;
710
+ writeJsonFile(syncPointerPath(globalRoot), pointer);
711
+ await pruneStep(progress, deps.prune, {
712
+ homeDirectory,
713
+ environment,
714
+ buildsRoot: globalRoot,
715
+ ...webKey === null ? {} : { webKey },
716
+ ...nativeKey === null ? {} : { nativeKey },
717
+ ...mcpKeys.length === 0 ? {} : { mcpAppKeys: mcpKeys }
718
+ });
719
+ for (const root of /* @__PURE__ */ new Set([...roots, ...options.repoRoot === void 0 ? [] : [realPath(options.repoRoot)]])) emitFrontendHooks(root, progress, commands);
720
+ emit({
721
+ type: "result",
722
+ result: {
723
+ packages,
724
+ web,
725
+ native,
726
+ ...mcpApp === void 0 ? {} : { mcpApp }
727
+ }
728
+ });
729
+ return {
730
+ ...succeeded,
731
+ generation
732
+ };
733
+ }
734
+ /**
735
+ * One pass whose report lands in `last-attempt.json`, so a failed background run leaves its
736
+ * reasons. A pass that lost the lock leaves the file to the holder that took it.
737
+ */
738
+ async function attempt(options, deps, emit, lost) {
739
+ let report;
740
+ try {
741
+ report = await syncOnce(options, deps, emit, lost);
742
+ } catch (error) {
743
+ report = emptyReport("failed", [`po sync failed: ${errorMessage(error)}`], deps);
744
+ }
745
+ if (report.status === "busy") return report;
746
+ try {
747
+ writeJsonFile(syncLastAttemptPath(options.globalRoot), report);
748
+ } catch (error) {
749
+ report = {
750
+ ...report,
751
+ errors: [...report.errors, `last-attempt.json could not be written: ${errorMessage(error)}`]
752
+ };
753
+ }
754
+ return report;
755
+ }
756
+ /**
757
+ * Runs sync under the Po home lock and reports the outcome.
758
+ *
759
+ * Busy when another live sync holds the lock; a background caller leaves a rerun marker
760
+ * first. The holder repeats its pass while a marker is present. A marker that lands after
761
+ * its last check but before the release is caught after the release: the holder takes the
762
+ * lock again and runs once more, or leaves the marker to whoever took the lock first.
763
+ */
764
+ async function runSync(options, overrides = {}) {
765
+ const deps = {
766
+ ...DEFAULT_DEPS,
767
+ ...overrides
768
+ };
769
+ const emit = options.onEvent ?? (() => {});
770
+ const lockPath = syncLockPath(options.globalRoot);
771
+ const rerunPath = syncRerunPath(options.globalRoot);
772
+ let lock = acquireLock(lockPath, options.origin, deps);
773
+ if (!lock.acquired) {
774
+ if (options.origin === "background") node_fs.default.writeFileSync(rerunPath, deps.now().toISOString());
775
+ return emptyReport("busy", [`po sync is already running (${lock.holder === void 0 ? "another process" : `pid ${String(lock.holder.pid)}`})`], deps);
776
+ }
777
+ for (;;) {
778
+ const { token } = lock;
779
+ const lost = () => lostLock(lockPath, token, deps);
780
+ let report;
781
+ try {
782
+ takeRerunRequest(rerunPath);
783
+ report = await attempt(options, deps, emit, lost);
784
+ while (report.status !== "busy" && takeRerunRequest(rerunPath)) report = await attempt(options, deps, emit, lost);
785
+ } finally {
786
+ releaseLock(lockPath, token);
787
+ }
788
+ if (report.status === "busy" || !node_fs.default.existsSync(rerunPath)) return report;
789
+ lock = acquireLock(lockPath, options.origin, deps);
790
+ if (!lock.acquired) return report;
791
+ }
792
+ }
793
+ //#endregion
794
+ exports.formatSyncResult = formatSyncResult;
795
+ exports.globalWebPluginRoots = globalWebPluginRoots;
796
+ exports.processIsAlive = processIsAlive;
797
+ exports.readSyncLastAttempt = readSyncLastAttempt;
798
+ exports.readSyncPointer = readSyncPointer;
799
+ exports.rootSelectionFingerprint = rootSelectionFingerprint;
800
+ exports.runSync = runSync;
801
+ exports.syncExitCode = syncExitCode;
802
+ exports.syncHostIdentity = syncHostIdentity;
803
+ exports.syncLastAttemptPath = syncLastAttemptPath;
804
+ exports.syncLockPath = syncLockPath;
805
+ exports.syncPointerPath = syncPointerPath;
806
+ exports.syncRerunPath = syncRerunPath;
807
+
808
+ //# sourceMappingURL=index.cjs.map