@agimon-ai/po 0.0.0-alpha.21 → 0.0.0-alpha.210

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 (621) hide show
  1. package/LICENSE +97 -8
  2. package/README.md +37 -722
  3. package/dist/apiContracts.cjs.map +1 -1
  4. package/dist/apiContracts.d.mts +2 -2
  5. package/dist/bin/cli.cjs +12 -7
  6. package/dist/bin/cli.cjs.map +1 -1
  7. package/dist/bin/cli.mjs +12 -7
  8. package/dist/bin/cli.mjs.map +1 -1
  9. package/dist/bin/poRunner.cjs +24 -7
  10. package/dist/bin/poRunner.cjs.map +1 -1
  11. package/dist/bin/poRunner.d.mts +8 -0
  12. package/dist/bin/poRunner.d.mts.map +1 -1
  13. package/dist/bin/poRunner.mjs +24 -7
  14. package/dist/bin/poRunner.mjs.map +1 -1
  15. package/dist/bin/serve.cjs +28 -17
  16. package/dist/bin/serve.cjs.map +1 -1
  17. package/dist/bin/serve.mjs +28 -17
  18. package/dist/bin/serve.mjs.map +1 -1
  19. package/dist/builders/cli/extensionAssembler/index.cjs +53 -40
  20. package/dist/builders/cli/extensionAssembler/index.cjs.map +1 -1
  21. package/dist/builders/cli/extensionAssembler/index.d.mts +11 -6
  22. package/dist/builders/cli/extensionAssembler/index.d.mts.map +1 -1
  23. package/dist/builders/cli/extensionAssembler/index.mjs +53 -41
  24. package/dist/builders/cli/extensionAssembler/index.mjs.map +1 -1
  25. package/dist/catalog/index.json +662 -105
  26. package/dist/cli.cjs +9 -14
  27. package/dist/cli.d.mts +1 -3
  28. package/dist/cli.mjs +1 -3
  29. package/dist/commands.cjs +13 -15
  30. package/dist/commands.d.mts +1 -2
  31. package/dist/commands.mjs +1 -2
  32. package/dist/config.cjs +9 -14
  33. package/dist/config.d.mts +3 -2
  34. package/dist/config.mjs +3 -2
  35. package/dist/extensions/server.cjs +30 -23
  36. package/dist/extensions/server.cjs.map +1 -1
  37. package/dist/extensions/server.d.mts.map +1 -1
  38. package/dist/extensions/server.mjs +31 -24
  39. package/dist/extensions/server.mjs.map +1 -1
  40. package/dist/harnessContext.cjs +0 -1
  41. package/dist/harnessContext.d.mts +2 -2
  42. package/dist/harnessContext.mjs +1 -1
  43. package/dist/harnessState.cjs +2 -1
  44. package/dist/help.cjs +9 -11
  45. package/dist/help.d.mts +1 -2
  46. package/dist/help.mjs +1 -2
  47. package/dist/index.cjs +40 -67
  48. package/dist/index.d.mts +7 -16
  49. package/dist/index.mjs +7 -14
  50. package/dist/matrixOptions.cjs +10 -5
  51. package/dist/matrixOptions.d.mts +2 -2
  52. package/dist/matrixOptions.mjs +1 -1
  53. package/dist/package.cjs +11 -0
  54. package/dist/package.cjs.map +1 -0
  55. package/dist/package.mjs +6 -0
  56. package/dist/package.mjs.map +1 -0
  57. package/dist/projectTrust.cjs +3 -0
  58. package/dist/projectTrust.d.mts +2 -2
  59. package/dist/projectTrust.mjs +1 -1
  60. package/dist/repository.cjs +1 -0
  61. package/dist/repository.d.mts +2 -2
  62. package/dist/repository.mjs +1 -1
  63. package/dist/services.cjs +5 -20
  64. package/dist/services.d.mts +3 -8
  65. package/dist/services.mjs +3 -8
  66. package/dist/shared.cjs +4 -17
  67. package/dist/shared.d.mts +2 -2
  68. package/dist/shared.mjs +1 -1
  69. package/dist/src/bin/agentDirectory.cjs +19 -15
  70. package/dist/src/bin/agentDirectory.cjs.map +1 -1
  71. package/dist/src/bin/agentDirectory.mjs +16 -13
  72. package/dist/src/bin/agentDirectory.mjs.map +1 -1
  73. package/dist/src/builders/apiContractExport/index.cjs +23 -22
  74. package/dist/src/builders/apiContractExport/index.cjs.map +1 -1
  75. package/dist/src/builders/apiContractExport/index.mjs +22 -21
  76. package/dist/src/builders/apiContractExport/index.mjs.map +1 -1
  77. package/dist/src/builders/cli/entryResolution.cjs +2 -2
  78. package/dist/src/builders/cli/entryResolution.cjs.map +1 -1
  79. package/dist/src/builders/cli/entryResolution.mjs +1 -1
  80. package/dist/src/builders/cli/entryResolution.mjs.map +1 -1
  81. package/dist/src/builders/cli/harnessContext.cjs +38 -43
  82. package/dist/src/builders/cli/harnessContext.cjs.map +1 -1
  83. package/dist/src/builders/cli/harnessContext.d.mts +11 -10
  84. package/dist/src/builders/cli/harnessContext.d.mts.map +1 -1
  85. package/dist/src/builders/cli/harnessContext.mjs +37 -41
  86. package/dist/src/builders/cli/harnessContext.mjs.map +1 -1
  87. package/dist/src/builders/cli/sessionComposition.cjs +23 -12
  88. package/dist/src/builders/cli/sessionComposition.cjs.map +1 -1
  89. package/dist/src/builders/cli/sessionComposition.mjs +23 -12
  90. package/dist/src/builders/cli/sessionComposition.mjs.map +1 -1
  91. package/dist/src/builders/isolate/compile.cjs +226 -0
  92. package/dist/src/builders/isolate/compile.cjs.map +1 -0
  93. package/dist/src/builders/isolate/compile.mjs +222 -0
  94. package/dist/src/builders/isolate/compile.mjs.map +1 -0
  95. package/dist/src/builders/isolate/index.cjs +195 -0
  96. package/dist/src/builders/isolate/index.cjs.map +1 -0
  97. package/dist/src/builders/isolate/index.mjs +192 -0
  98. package/dist/src/builders/isolate/index.mjs.map +1 -0
  99. package/dist/src/builders/isolate/membrane.cjs +198 -0
  100. package/dist/src/builders/isolate/membrane.cjs.map +1 -0
  101. package/dist/src/builders/isolate/membrane.mjs +198 -0
  102. package/dist/src/builders/isolate/membrane.mjs.map +1 -0
  103. package/dist/src/builders/isolate/names.cjs +10 -0
  104. package/dist/src/builders/isolate/names.cjs.map +1 -0
  105. package/dist/src/builders/isolate/names.mjs +9 -0
  106. package/dist/src/builders/isolate/names.mjs.map +1 -0
  107. package/dist/src/builders/native/index.cjs +229 -67
  108. package/dist/src/builders/native/index.cjs.map +1 -1
  109. package/dist/src/builders/native/index.d.mts +4 -2
  110. package/dist/src/builders/native/index.d.mts.map +1 -1
  111. package/dist/src/builders/native/index.mjs +229 -68
  112. package/dist/src/builders/native/index.mjs.map +1 -1
  113. package/dist/src/builders/npm/index.cjs +76 -0
  114. package/dist/src/builders/npm/index.cjs.map +1 -0
  115. package/dist/src/builders/npm/index.mjs +73 -0
  116. package/dist/src/builders/npm/index.mjs.map +1 -0
  117. package/dist/src/builders/server/backgroundSync.cjs +62 -39
  118. package/dist/src/builders/server/backgroundSync.cjs.map +1 -1
  119. package/dist/src/builders/server/backgroundSync.mjs +62 -38
  120. package/dist/src/builders/server/backgroundSync.mjs.map +1 -1
  121. package/dist/src/builders/server/bundlerService.cjs +165 -35
  122. package/dist/src/builders/server/bundlerService.cjs.map +1 -1
  123. package/dist/src/builders/server/bundlerService.mjs +164 -36
  124. package/dist/src/builders/server/bundlerService.mjs.map +1 -1
  125. package/dist/src/builders/server/capabilities.cjs +103 -0
  126. package/dist/src/builders/server/capabilities.cjs.map +1 -0
  127. package/dist/src/builders/server/capabilities.mjs +101 -0
  128. package/dist/src/builders/server/capabilities.mjs.map +1 -0
  129. package/dist/src/builders/server/computerUseBinding.cjs +62 -10
  130. package/dist/src/builders/server/computerUseBinding.cjs.map +1 -1
  131. package/dist/src/builders/server/computerUseBinding.mjs +60 -8
  132. package/dist/src/builders/server/computerUseBinding.mjs.map +1 -1
  133. package/dist/src/builders/server/computerUseRecordings.cjs +152 -51
  134. package/dist/src/builders/server/computerUseRecordings.cjs.map +1 -1
  135. package/dist/src/builders/server/computerUseRecordings.mjs +158 -59
  136. package/dist/src/builders/server/computerUseRecordings.mjs.map +1 -1
  137. package/dist/src/builders/server/containedSessions.cjs +152 -0
  138. package/dist/src/builders/server/containedSessions.cjs.map +1 -0
  139. package/dist/src/builders/server/containedSessions.mjs +146 -0
  140. package/dist/src/builders/server/containedSessions.mjs.map +1 -0
  141. package/dist/src/builders/server/defaultWorkspace.cjs +46 -11
  142. package/dist/src/builders/server/defaultWorkspace.cjs.map +1 -1
  143. package/dist/src/builders/server/defaultWorkspace.mjs +42 -10
  144. package/dist/src/builders/server/defaultWorkspace.mjs.map +1 -1
  145. package/dist/src/builders/server/electronBinding.cjs +82 -0
  146. package/dist/src/builders/server/electronBinding.cjs.map +1 -0
  147. package/dist/src/builders/server/electronBinding.mjs +82 -0
  148. package/dist/src/builders/server/electronBinding.mjs.map +1 -0
  149. package/dist/src/builders/server/federation.cjs +364 -0
  150. package/dist/src/builders/server/federation.cjs.map +1 -0
  151. package/dist/src/builders/server/federation.mjs +363 -0
  152. package/dist/src/builders/server/federation.mjs.map +1 -0
  153. package/dist/src/builders/server/hostDisplayName.cjs +14 -0
  154. package/dist/src/builders/server/hostDisplayName.cjs.map +1 -0
  155. package/dist/src/builders/server/hostDisplayName.mjs +14 -0
  156. package/dist/src/builders/server/hostDisplayName.mjs.map +1 -0
  157. package/dist/src/builders/server/hostModelGateway.cjs +41 -0
  158. package/dist/src/builders/server/hostModelGateway.cjs.map +1 -0
  159. package/dist/src/builders/server/hostModelGateway.mjs +39 -0
  160. package/dist/src/builders/server/hostModelGateway.mjs.map +1 -0
  161. package/dist/src/builders/server/hostTeam.cjs +188 -0
  162. package/dist/src/builders/server/hostTeam.cjs.map +1 -0
  163. package/dist/src/builders/server/hostTeam.mjs +180 -0
  164. package/dist/src/builders/server/hostTeam.mjs.map +1 -0
  165. package/dist/src/builders/server/idleRestart.cjs +185 -40
  166. package/dist/src/builders/server/idleRestart.cjs.map +1 -1
  167. package/dist/src/builders/server/idleRestart.mjs +176 -39
  168. package/dist/src/builders/server/idleRestart.mjs.map +1 -1
  169. package/dist/src/builders/server/index.cjs +33 -19
  170. package/dist/src/builders/server/index.cjs.map +1 -1
  171. package/dist/src/builders/server/index.mjs +33 -18
  172. package/dist/src/builders/server/index.mjs.map +1 -1
  173. package/dist/src/builders/server/liveActivityPush.cjs +202 -0
  174. package/dist/src/builders/server/liveActivityPush.cjs.map +1 -0
  175. package/dist/src/builders/server/liveActivityPush.mjs +202 -0
  176. package/dist/src/builders/server/liveActivityPush.mjs.map +1 -0
  177. package/dist/src/builders/server/logSink.cjs +12 -10
  178. package/dist/src/builders/server/logSink.cjs.map +1 -1
  179. package/dist/src/builders/server/logSink.mjs +12 -10
  180. package/dist/src/builders/server/logSink.mjs.map +1 -1
  181. package/dist/src/builders/server/mcpApp.cjs +27 -20
  182. package/dist/src/builders/server/mcpApp.cjs.map +1 -1
  183. package/dist/src/builders/server/mcpApp.mjs +25 -18
  184. package/dist/src/builders/server/mcpApp.mjs.map +1 -1
  185. package/dist/src/builders/server/mcpAppBuild.cjs +61 -41
  186. package/dist/src/builders/server/mcpAppBuild.cjs.map +1 -1
  187. package/dist/src/builders/server/mcpAppBuild.d.mts +3 -6
  188. package/dist/src/builders/server/mcpAppBuild.d.mts.map +1 -1
  189. package/dist/src/builders/server/mcpAppBuild.mjs +61 -40
  190. package/dist/src/builders/server/mcpAppBuild.mjs.map +1 -1
  191. package/dist/src/builders/server/mcpBundle.cjs +20 -16
  192. package/dist/src/builders/server/mcpBundle.cjs.map +1 -1
  193. package/dist/src/builders/server/mcpBundle.d.mts +2 -1
  194. package/dist/src/builders/server/mcpBundle.d.mts.map +1 -1
  195. package/dist/src/builders/server/mcpBundle.mjs +20 -15
  196. package/dist/src/builders/server/mcpBundle.mjs.map +1 -1
  197. package/dist/src/builders/server/nativePush.cjs +229 -0
  198. package/dist/src/builders/server/nativePush.cjs.map +1 -0
  199. package/dist/src/builders/server/nativePush.mjs +228 -0
  200. package/dist/src/builders/server/nativePush.mjs.map +1 -0
  201. package/dist/src/builders/server/network.cjs +887 -0
  202. package/dist/src/builders/server/network.cjs.map +1 -0
  203. package/dist/src/builders/server/network.mjs +886 -0
  204. package/dist/src/builders/server/network.mjs.map +1 -0
  205. package/dist/src/builders/server/networkGateway.cjs +123 -0
  206. package/dist/src/builders/server/networkGateway.cjs.map +1 -0
  207. package/dist/src/builders/server/networkGateway.mjs +123 -0
  208. package/dist/src/builders/server/networkGateway.mjs.map +1 -0
  209. package/dist/src/builders/server/networkRelay.cjs +83 -0
  210. package/dist/src/builders/server/networkRelay.cjs.map +1 -0
  211. package/dist/src/builders/server/networkRelay.mjs +81 -0
  212. package/dist/src/builders/server/networkRelay.mjs.map +1 -0
  213. package/dist/src/builders/server/orgPluginLibraryBinding.cjs +72 -0
  214. package/dist/src/builders/server/orgPluginLibraryBinding.cjs.map +1 -0
  215. package/dist/src/builders/server/orgPluginLibraryBinding.mjs +72 -0
  216. package/dist/src/builders/server/orgPluginLibraryBinding.mjs.map +1 -0
  217. package/dist/src/builders/server/packageReloadCheck.cjs +46 -2
  218. package/dist/src/builders/server/packageReloadCheck.cjs.map +1 -1
  219. package/dist/src/builders/server/packageReloadCheck.mjs +46 -3
  220. package/dist/src/builders/server/packageReloadCheck.mjs.map +1 -1
  221. package/dist/src/builders/server/packageUrl.cjs +161 -58
  222. package/dist/src/builders/server/packageUrl.cjs.map +1 -1
  223. package/dist/src/builders/server/packageUrl.mjs +162 -58
  224. package/dist/src/builders/server/packageUrl.mjs.map +1 -1
  225. package/dist/src/builders/server/privateRelay.cjs +309 -0
  226. package/dist/src/builders/server/privateRelay.cjs.map +1 -0
  227. package/dist/src/builders/server/privateRelay.mjs +305 -0
  228. package/dist/src/builders/server/privateRelay.mjs.map +1 -0
  229. package/dist/src/builders/server/privateRelayCarrier.cjs +316 -0
  230. package/dist/src/builders/server/privateRelayCarrier.cjs.map +1 -0
  231. package/dist/src/builders/server/privateRelayCarrier.mjs +309 -0
  232. package/dist/src/builders/server/privateRelayCarrier.mjs.map +1 -0
  233. package/dist/src/builders/server/runtime.cjs +2731 -485
  234. package/dist/src/builders/server/runtime.cjs.map +1 -1
  235. package/dist/src/builders/server/runtime.mjs +2741 -499
  236. package/dist/src/builders/server/runtime.mjs.map +1 -1
  237. package/dist/src/builders/server/runtimeResources.cjs +37 -0
  238. package/dist/src/builders/server/runtimeResources.cjs.map +1 -1
  239. package/dist/src/builders/server/runtimeResources.mjs +38 -2
  240. package/dist/src/builders/server/runtimeResources.mjs.map +1 -1
  241. package/dist/src/builders/server/sandboxRouter.cjs +815 -0
  242. package/dist/src/builders/server/sandboxRouter.cjs.map +1 -0
  243. package/dist/src/builders/server/sandboxRouter.mjs +811 -0
  244. package/dist/src/builders/server/sandboxRouter.mjs.map +1 -0
  245. package/dist/src/builders/server/sandboxSessionHandoff.cjs +298 -0
  246. package/dist/src/builders/server/sandboxSessionHandoff.cjs.map +1 -0
  247. package/dist/src/builders/server/sandboxSessionHandoff.mjs +287 -0
  248. package/dist/src/builders/server/sandboxSessionHandoff.mjs.map +1 -0
  249. package/dist/src/builders/server/scopeReloadController.cjs +80 -0
  250. package/dist/src/builders/server/scopeReloadController.cjs.map +1 -0
  251. package/dist/src/builders/server/scopeReloadController.mjs +80 -0
  252. package/dist/src/builders/server/scopeReloadController.mjs.map +1 -0
  253. package/dist/src/builders/server/selectionStatus.cjs +2 -2
  254. package/dist/src/builders/server/selectionStatus.cjs.map +1 -1
  255. package/dist/src/builders/server/selectionStatus.mjs +2 -2
  256. package/dist/src/builders/server/selectionStatus.mjs.map +1 -1
  257. package/dist/src/builders/server/sessionArguments.cjs +65 -7
  258. package/dist/src/builders/server/sessionArguments.cjs.map +1 -1
  259. package/dist/src/builders/server/sessionArguments.mjs +64 -8
  260. package/dist/src/builders/server/sessionArguments.mjs.map +1 -1
  261. package/dist/src/builders/server/sessionRemoval.cjs +233 -0
  262. package/dist/src/builders/server/sessionRemoval.cjs.map +1 -0
  263. package/dist/src/builders/server/sessionRemoval.mjs +224 -0
  264. package/dist/src/builders/server/sessionRemoval.mjs.map +1 -0
  265. package/dist/src/builders/server/sessionSummaries.cjs +32 -0
  266. package/dist/src/builders/server/sessionSummaries.cjs.map +1 -0
  267. package/dist/src/builders/server/sessionSummaries.mjs +31 -0
  268. package/dist/src/builders/server/sessionSummaries.mjs.map +1 -0
  269. package/dist/src/builders/server/shutdown.cjs +23 -0
  270. package/dist/src/builders/server/shutdown.cjs.map +1 -1
  271. package/dist/src/builders/server/shutdown.mjs +21 -1
  272. package/dist/src/builders/server/shutdown.mjs.map +1 -1
  273. package/dist/src/builders/server/shutdownStack.cjs +44 -0
  274. package/dist/src/builders/server/shutdownStack.cjs.map +1 -0
  275. package/dist/src/builders/server/shutdownStack.mjs +43 -0
  276. package/dist/src/builders/server/shutdownStack.mjs.map +1 -0
  277. package/dist/src/builders/server/toolBoundaryHold.cjs +55 -0
  278. package/dist/src/builders/server/toolBoundaryHold.cjs.map +1 -0
  279. package/dist/src/builders/server/toolBoundaryHold.mjs +55 -0
  280. package/dist/src/builders/server/toolBoundaryHold.mjs.map +1 -0
  281. package/dist/src/builders/server/watcherService.cjs +55 -28
  282. package/dist/src/builders/server/watcherService.cjs.map +1 -1
  283. package/dist/src/builders/server/watcherService.mjs +55 -27
  284. package/dist/src/builders/server/watcherService.mjs.map +1 -1
  285. package/dist/src/builders/server/webTemplateDecision.cjs +7 -3
  286. package/dist/src/builders/server/webTemplateDecision.cjs.map +1 -1
  287. package/dist/src/builders/server/webTemplateDecision.mjs +7 -3
  288. package/dist/src/builders/server/webTemplateDecision.mjs.map +1 -1
  289. package/dist/src/builders/server/workspaceAdmission.cjs +96 -0
  290. package/dist/src/builders/server/workspaceAdmission.cjs.map +1 -0
  291. package/dist/src/builders/server/workspaceAdmission.mjs +90 -0
  292. package/dist/src/builders/server/workspaceAdmission.mjs.map +1 -0
  293. package/dist/src/builders/server/workspaceCheckout.cjs +16 -7
  294. package/dist/src/builders/server/workspaceCheckout.cjs.map +1 -1
  295. package/dist/src/builders/server/workspaceCheckout.mjs +16 -7
  296. package/dist/src/builders/server/workspaceCheckout.mjs.map +1 -1
  297. package/dist/src/builders/web/bundle.cjs +16 -14
  298. package/dist/src/builders/web/bundle.cjs.map +1 -1
  299. package/dist/src/builders/web/bundle.d.mts +3 -0
  300. package/dist/src/builders/web/bundle.d.mts.map +1 -1
  301. package/dist/src/builders/web/bundle.mjs +15 -13
  302. package/dist/src/builders/web/bundle.mjs.map +1 -1
  303. package/dist/src/builders/web/index.cjs +77 -59
  304. package/dist/src/builders/web/index.cjs.map +1 -1
  305. package/dist/src/builders/web/index.d.mts +19 -14
  306. package/dist/src/builders/web/index.d.mts.map +1 -1
  307. package/dist/src/builders/web/index.mjs +76 -58
  308. package/dist/src/builders/web/index.mjs.map +1 -1
  309. package/dist/src/builders/web/webPluginGenerate.cjs +84 -45
  310. package/dist/src/builders/web/webPluginGenerate.cjs.map +1 -1
  311. package/dist/src/builders/web/webPluginGenerate.d.mts +13 -4
  312. package/dist/src/builders/web/webPluginGenerate.d.mts.map +1 -1
  313. package/dist/src/builders/web/webPluginGenerate.mjs +82 -44
  314. package/dist/src/builders/web/webPluginGenerate.mjs.map +1 -1
  315. package/dist/src/builders/web/webPluginManifest.cjs +24 -17
  316. package/dist/src/builders/web/webPluginManifest.cjs.map +1 -1
  317. package/dist/src/builders/web/webPluginManifest.d.mts +11 -23
  318. package/dist/src/builders/web/webPluginManifest.d.mts.map +1 -1
  319. package/dist/src/builders/web/webPluginManifest.mjs +23 -16
  320. package/dist/src/builders/web/webPluginManifest.mjs.map +1 -1
  321. package/dist/src/builders/web/webPluginScan.cjs +11 -8
  322. package/dist/src/builders/web/webPluginScan.cjs.map +1 -1
  323. package/dist/src/builders/web/webPluginScan.d.mts +1 -1
  324. package/dist/src/builders/web/webPluginScan.d.mts.map +1 -1
  325. package/dist/src/builders/web/webPluginScan.mjs +10 -7
  326. package/dist/src/builders/web/webPluginScan.mjs.map +1 -1
  327. package/dist/src/builders/web/webPluginVite.cjs +5 -5
  328. package/dist/src/builders/web/webPluginVite.cjs.map +1 -1
  329. package/dist/src/builders/web/webPluginVite.d.mts +1 -1
  330. package/dist/src/builders/web/webPluginVite.d.mts.map +1 -1
  331. package/dist/src/builders/web/webPluginVite.mjs +3 -3
  332. package/dist/src/builders/web/webPluginVite.mjs.map +1 -1
  333. package/dist/src/cli/cliApp.cjs +18 -19
  334. package/dist/src/cli/cliApp.cjs.map +1 -1
  335. package/dist/src/cli/cliApp.d.mts +1 -1
  336. package/dist/src/cli/cliApp.d.mts.map +1 -1
  337. package/dist/src/cli/cliApp.mjs +18 -19
  338. package/dist/src/cli/cliApp.mjs.map +1 -1
  339. package/dist/src/cli/commands/api-export/index.cjs +14 -13
  340. package/dist/src/cli/commands/api-export/index.cjs.map +1 -1
  341. package/dist/src/cli/commands/api-export/index.mjs +13 -12
  342. package/dist/src/cli/commands/api-export/index.mjs.map +1 -1
  343. package/dist/src/cli/commands/doctor/help.cjs +4 -3
  344. package/dist/src/cli/commands/doctor/help.cjs.map +1 -1
  345. package/dist/src/cli/commands/doctor/help.d.mts.map +1 -1
  346. package/dist/src/cli/commands/doctor/help.mjs +4 -3
  347. package/dist/src/cli/commands/doctor/help.mjs.map +1 -1
  348. package/dist/src/cli/commands/doctor/index.cjs +30 -17
  349. package/dist/src/cli/commands/doctor/index.cjs.map +1 -1
  350. package/dist/src/cli/commands/doctor/index.d.mts +4 -4
  351. package/dist/src/cli/commands/doctor/index.d.mts.map +1 -1
  352. package/dist/src/cli/commands/doctor/index.mjs +28 -15
  353. package/dist/src/cli/commands/doctor/index.mjs.map +1 -1
  354. package/dist/src/cli/commands/emit-mcp/index.cjs +3 -2
  355. package/dist/src/cli/commands/emit-mcp/index.cjs.map +1 -1
  356. package/dist/src/cli/commands/emit-mcp/index.d.mts.map +1 -1
  357. package/dist/src/cli/commands/emit-mcp/index.mjs +3 -2
  358. package/dist/src/cli/commands/emit-mcp/index.mjs.map +1 -1
  359. package/dist/src/cli/commands/explain/index.cjs +53 -38
  360. package/dist/src/cli/commands/explain/index.cjs.map +1 -1
  361. package/dist/src/cli/commands/explain/index.d.mts +3 -4
  362. package/dist/src/cli/commands/explain/index.d.mts.map +1 -1
  363. package/dist/src/cli/commands/explain/index.mjs +52 -37
  364. package/dist/src/cli/commands/explain/index.mjs.map +1 -1
  365. package/dist/src/cli/commands/init/help.cjs +3 -2
  366. package/dist/src/cli/commands/init/help.cjs.map +1 -1
  367. package/dist/src/cli/commands/init/help.d.mts.map +1 -1
  368. package/dist/src/cli/commands/init/help.mjs +3 -2
  369. package/dist/src/cli/commands/init/help.mjs.map +1 -1
  370. package/dist/src/cli/commands/init/index.cjs +17 -12
  371. package/dist/src/cli/commands/init/index.cjs.map +1 -1
  372. package/dist/src/cli/commands/init/index.d.mts.map +1 -1
  373. package/dist/src/cli/commands/init/index.mjs +16 -11
  374. package/dist/src/cli/commands/init/index.mjs.map +1 -1
  375. package/dist/src/cli/commands/init/presenter.cjs +29 -21
  376. package/dist/src/cli/commands/init/presenter.cjs.map +1 -1
  377. package/dist/src/cli/commands/init/presenter.mjs +29 -21
  378. package/dist/src/cli/commands/init/presenter.mjs.map +1 -1
  379. package/dist/src/cli/commands/sync/help.cjs +7 -3
  380. package/dist/src/cli/commands/sync/help.cjs.map +1 -1
  381. package/dist/src/cli/commands/sync/help.d.mts.map +1 -1
  382. package/dist/src/cli/commands/sync/help.mjs +7 -3
  383. package/dist/src/cli/commands/sync/help.mjs.map +1 -1
  384. package/dist/src/cli/commands/sync/index.cjs +72 -40
  385. package/dist/src/cli/commands/sync/index.cjs.map +1 -1
  386. package/dist/src/cli/commands/sync/index.d.mts.map +1 -1
  387. package/dist/src/cli/commands/sync/index.mjs +69 -37
  388. package/dist/src/cli/commands/sync/index.mjs.map +1 -1
  389. package/dist/src/cli/commands/sync/presenter.cjs +10 -1
  390. package/dist/src/cli/commands/sync/presenter.cjs.map +1 -1
  391. package/dist/src/cli/commands/sync/presenter.d.mts +0 -9
  392. package/dist/src/cli/commands/sync/presenter.d.mts.map +1 -1
  393. package/dist/src/cli/commands/sync/presenter.mjs +10 -1
  394. package/dist/src/cli/commands/sync/presenter.mjs.map +1 -1
  395. package/dist/src/cli/commands/web/index.cjs +7 -6
  396. package/dist/src/cli/commands/web/index.cjs.map +1 -1
  397. package/dist/src/cli/commands/web/index.mjs +6 -5
  398. package/dist/src/cli/commands/web/index.mjs.map +1 -1
  399. package/dist/src/cli/harnessOptions.cjs +15 -24
  400. package/dist/src/cli/harnessOptions.cjs.map +1 -1
  401. package/dist/src/cli/harnessOptions.d.mts +2 -2
  402. package/dist/src/cli/harnessOptions.d.mts.map +1 -1
  403. package/dist/src/cli/harnessOptions.mjs +14 -22
  404. package/dist/src/cli/harnessOptions.mjs.map +1 -1
  405. package/dist/src/cli/help.cjs +20 -26
  406. package/dist/src/cli/help.cjs.map +1 -1
  407. package/dist/src/cli/help.d.mts +1 -2
  408. package/dist/src/cli/help.d.mts.map +1 -1
  409. package/dist/src/cli/help.mjs +15 -20
  410. package/dist/src/cli/help.mjs.map +1 -1
  411. package/dist/src/cli/locale.cjs +25 -0
  412. package/dist/src/cli/locale.cjs.map +1 -0
  413. package/dist/src/cli/locale.mjs +22 -0
  414. package/dist/src/cli/locale.mjs.map +1 -0
  415. package/dist/src/cli/matrixOptions.cjs +85 -37
  416. package/dist/src/cli/matrixOptions.cjs.map +1 -1
  417. package/dist/src/cli/matrixOptions.d.mts +22 -16
  418. package/dist/src/cli/matrixOptions.d.mts.map +1 -1
  419. package/dist/src/cli/matrixOptions.mjs +76 -33
  420. package/dist/src/cli/matrixOptions.mjs.map +1 -1
  421. package/dist/src/cli/options.cjs +51 -128
  422. package/dist/src/cli/options.cjs.map +1 -1
  423. package/dist/src/cli/options.d.mts +1 -1
  424. package/dist/src/cli/options.d.mts.map +1 -1
  425. package/dist/src/cli/options.mjs +53 -130
  426. package/dist/src/cli/options.mjs.map +1 -1
  427. package/dist/src/cli/router.cjs +0 -1
  428. package/dist/src/cli/router.cjs.map +1 -1
  429. package/dist/src/cli/router.d.mts +1 -1
  430. package/dist/src/cli/router.mjs +0 -1
  431. package/dist/src/cli/router.mjs.map +1 -1
  432. package/dist/src/cli/server/options.cjs +37 -7
  433. package/dist/src/cli/server/options.cjs.map +1 -1
  434. package/dist/src/cli/server/options.mjs +37 -7
  435. package/dist/src/cli/server/options.mjs.map +1 -1
  436. package/dist/src/cli/server/processGuards.cjs +22 -15
  437. package/dist/src/cli/server/processGuards.cjs.map +1 -1
  438. package/dist/src/cli/server/processGuards.mjs +21 -14
  439. package/dist/src/cli/server/processGuards.mjs.map +1 -1
  440. package/dist/src/cli/server/restartPolicy.cjs +38 -0
  441. package/dist/src/cli/server/restartPolicy.cjs.map +1 -0
  442. package/dist/src/cli/server/restartPolicy.d.mts +21 -0
  443. package/dist/src/cli/server/restartPolicy.d.mts.map +1 -0
  444. package/dist/src/cli/server/restartPolicy.mjs +36 -0
  445. package/dist/src/cli/server/restartPolicy.mjs.map +1 -0
  446. package/dist/src/cli/server/run.cjs +12 -11
  447. package/dist/src/cli/server/run.cjs.map +1 -1
  448. package/dist/src/cli/server/run.mjs +11 -10
  449. package/dist/src/cli/server/run.mjs.map +1 -1
  450. package/dist/src/cli/server/supervise.cjs +89 -0
  451. package/dist/src/cli/server/supervise.cjs.map +1 -0
  452. package/dist/src/cli/server/supervise.mjs +89 -0
  453. package/dist/src/cli/server/supervise.mjs.map +1 -0
  454. package/dist/src/composition/harnessState/index.cjs +2 -1
  455. package/dist/src/composition/harnessState/index.cjs.map +1 -1
  456. package/dist/src/composition/harnessState/index.d.mts +2 -1
  457. package/dist/src/composition/harnessState/index.d.mts.map +1 -1
  458. package/dist/src/composition/harnessState/index.mjs +2 -1
  459. package/dist/src/composition/harnessState/index.mjs.map +1 -1
  460. package/dist/src/composition/layerPackageInstaller/index.cjs +293 -86
  461. package/dist/src/composition/layerPackageInstaller/index.cjs.map +1 -1
  462. package/dist/src/composition/layerPackageInstaller/index.d.mts +25 -2
  463. package/dist/src/composition/layerPackageInstaller/index.d.mts.map +1 -1
  464. package/dist/src/composition/layerPackageInstaller/index.mjs +295 -94
  465. package/dist/src/composition/layerPackageInstaller/index.mjs.map +1 -1
  466. package/dist/src/composition/marketplaceCatalog/index.cjs +136 -0
  467. package/dist/src/composition/marketplaceCatalog/index.cjs.map +1 -0
  468. package/dist/src/composition/marketplaceCatalog/index.mjs +132 -0
  469. package/dist/src/composition/marketplaceCatalog/index.mjs.map +1 -0
  470. package/dist/src/composition/orgPluginActivation/index.cjs +179 -0
  471. package/dist/src/composition/orgPluginActivation/index.cjs.map +1 -0
  472. package/dist/src/composition/orgPluginActivation/index.mjs +177 -0
  473. package/dist/src/composition/orgPluginActivation/index.mjs.map +1 -0
  474. package/dist/src/composition/orgPluginLibrary/index.cjs +205 -0
  475. package/dist/src/composition/orgPluginLibrary/index.cjs.map +1 -0
  476. package/dist/src/composition/orgPluginLibrary/index.mjs +200 -0
  477. package/dist/src/composition/orgPluginLibrary/index.mjs.map +1 -0
  478. package/dist/src/composition/pluginMarketplace/index.cjs +304 -0
  479. package/dist/src/composition/pluginMarketplace/index.cjs.map +1 -0
  480. package/dist/src/composition/pluginMarketplace/index.mjs +302 -0
  481. package/dist/src/composition/pluginMarketplace/index.mjs.map +1 -0
  482. package/dist/src/composition/poHomeMigration/index.cjs +46 -26
  483. package/dist/src/composition/poHomeMigration/index.cjs.map +1 -1
  484. package/dist/src/composition/poHomeMigration/index.d.mts.map +1 -1
  485. package/dist/src/composition/poHomeMigration/index.mjs +45 -25
  486. package/dist/src/composition/poHomeMigration/index.mjs.map +1 -1
  487. package/dist/src/composition/projectTrust/index.cjs +40 -3
  488. package/dist/src/composition/projectTrust/index.cjs.map +1 -1
  489. package/dist/src/composition/projectTrust/index.d.mts +8 -0
  490. package/dist/src/composition/projectTrust/index.d.mts.map +1 -1
  491. package/dist/src/composition/projectTrust/index.mjs +33 -2
  492. package/dist/src/composition/projectTrust/index.mjs.map +1 -1
  493. package/dist/src/composition/repository/index.cjs +29 -12
  494. package/dist/src/composition/repository/index.cjs.map +1 -1
  495. package/dist/src/composition/repository/index.d.mts +10 -3
  496. package/dist/src/composition/repository/index.d.mts.map +1 -1
  497. package/dist/src/composition/repository/index.mjs +29 -13
  498. package/dist/src/composition/repository/index.mjs.map +1 -1
  499. package/dist/src/composition/syncPrune/index.cjs +23 -16
  500. package/dist/src/composition/syncPrune/index.cjs.map +1 -1
  501. package/dist/src/composition/syncPrune/index.d.mts.map +1 -1
  502. package/dist/src/composition/syncPrune/index.mjs +22 -15
  503. package/dist/src/composition/syncPrune/index.mjs.map +1 -1
  504. package/dist/src/composition/syncService/index.cjs +441 -194
  505. package/dist/src/composition/syncService/index.cjs.map +1 -1
  506. package/dist/src/composition/syncService/index.d.mts +4 -1
  507. package/dist/src/composition/syncService/index.d.mts.map +1 -1
  508. package/dist/src/composition/syncService/index.mjs +440 -196
  509. package/dist/src/composition/syncService/index.mjs.map +1 -1
  510. package/dist/src/composition/syncService/localBuilds.cjs +41 -37
  511. package/dist/src/composition/syncService/localBuilds.cjs.map +1 -1
  512. package/dist/src/composition/syncService/localBuilds.mjs +40 -37
  513. package/dist/src/composition/syncService/localBuilds.mjs.map +1 -1
  514. package/dist/src/composition/transitionLayers.cjs.map +1 -1
  515. package/dist/src/composition/transitionLayers.d.mts +3 -3
  516. package/dist/src/composition/transitionLayers.d.mts.map +1 -1
  517. package/dist/src/composition/transitionLayers.mjs.map +1 -1
  518. package/dist/src/composition/types/harness.d.mts +4 -9
  519. package/dist/src/composition/types/harness.d.mts.map +1 -1
  520. package/dist/src/extensions/setupDiagnostics.cjs +8 -8
  521. package/dist/src/extensions/setupDiagnostics.cjs.map +1 -1
  522. package/dist/src/extensions/setupDiagnostics.mjs +8 -8
  523. package/dist/src/extensions/setupDiagnostics.mjs.map +1 -1
  524. package/dist/webBuilder.cjs +1 -0
  525. package/dist/webBuilder.d.mts +2 -2
  526. package/dist/webBuilder.mjs +2 -2
  527. package/docs/server/api-export.md +9 -9
  528. package/docs/server/api.md +22 -125
  529. package/docs/server/getting-started.md +21 -85
  530. package/docs/server/index.md +13 -58
  531. package/docs/server/ipc.md +26 -72
  532. package/docs/server/lifecycle.md +18 -91
  533. package/docs/server/security.md +20 -80
  534. package/package.json +47 -67
  535. package/src/prompts/po-author-extension/SKILL.md +2 -2
  536. package/src/prompts/po-author-extension/references/extension-contract.md +4 -6
  537. package/dist/antigravity.cjs +0 -5
  538. package/dist/antigravity.d.mts +0 -2
  539. package/dist/antigravity.mjs +0 -1
  540. package/dist/codex.cjs +0 -8
  541. package/dist/codex.d.mts +0 -2
  542. package/dist/codex.mjs +0 -1
  543. package/dist/compatibility.cjs +0 -27
  544. package/dist/compatibility.d.mts +0 -6
  545. package/dist/compatibility.mjs +0 -6
  546. package/dist/compatibilityCommand.cjs +0 -4
  547. package/dist/compatibilityCommand.d.mts +0 -2
  548. package/dist/compatibilityCommand.mjs +0 -1
  549. package/dist/compatibilityContext.cjs +0 -3
  550. package/dist/compatibilityContext.d.mts +0 -2
  551. package/dist/compatibilityContext.mjs +0 -1
  552. package/dist/compatibilityOptions.cjs +0 -5
  553. package/dist/compatibilityOptions.d.mts +0 -2
  554. package/dist/compatibilityOptions.mjs +0 -1
  555. package/dist/process.cjs +0 -12
  556. package/dist/process.d.mts +0 -2
  557. package/dist/process.mjs +0 -1
  558. package/dist/src/builders/hooks/index.cjs +0 -238
  559. package/dist/src/builders/hooks/index.cjs.map +0 -1
  560. package/dist/src/builders/hooks/index.mjs +0 -231
  561. package/dist/src/builders/hooks/index.mjs.map +0 -1
  562. package/dist/src/cli/commands/compat/context.cjs +0 -115
  563. package/dist/src/cli/commands/compat/context.cjs.map +0 -1
  564. package/dist/src/cli/commands/compat/context.d.mts +0 -22
  565. package/dist/src/cli/commands/compat/context.d.mts.map +0 -1
  566. package/dist/src/cli/commands/compat/context.mjs +0 -110
  567. package/dist/src/cli/commands/compat/context.mjs.map +0 -1
  568. package/dist/src/cli/commands/compat/help.cjs +0 -26
  569. package/dist/src/cli/commands/compat/help.cjs.map +0 -1
  570. package/dist/src/cli/commands/compat/help.d.mts +0 -4
  571. package/dist/src/cli/commands/compat/help.d.mts.map +0 -1
  572. package/dist/src/cli/commands/compat/help.mjs +0 -25
  573. package/dist/src/cli/commands/compat/help.mjs.map +0 -1
  574. package/dist/src/cli/commands/compat/index.cjs +0 -73
  575. package/dist/src/cli/commands/compat/index.cjs.map +0 -1
  576. package/dist/src/cli/commands/compat/index.d.mts +0 -14
  577. package/dist/src/cli/commands/compat/index.d.mts.map +0 -1
  578. package/dist/src/cli/commands/compat/index.mjs +0 -70
  579. package/dist/src/cli/commands/compat/index.mjs.map +0 -1
  580. package/dist/src/cli/commands/compat/options.cjs +0 -88
  581. package/dist/src/cli/commands/compat/options.cjs.map +0 -1
  582. package/dist/src/cli/commands/compat/options.d.mts +0 -15
  583. package/dist/src/cli/commands/compat/options.d.mts.map +0 -1
  584. package/dist/src/cli/commands/compat/options.mjs +0 -86
  585. package/dist/src/cli/commands/compat/options.mjs.map +0 -1
  586. package/dist/src/cli/commands/compat/providers/antigravity.cjs +0 -294
  587. package/dist/src/cli/commands/compat/providers/antigravity.cjs.map +0 -1
  588. package/dist/src/cli/commands/compat/providers/antigravity.d.mts +0 -9
  589. package/dist/src/cli/commands/compat/providers/antigravity.d.mts.map +0 -1
  590. package/dist/src/cli/commands/compat/providers/antigravity.mjs +0 -289
  591. package/dist/src/cli/commands/compat/providers/antigravity.mjs.map +0 -1
  592. package/dist/src/cli/commands/compat/providers/codex.cjs +0 -178
  593. package/dist/src/cli/commands/compat/providers/codex.cjs.map +0 -1
  594. package/dist/src/cli/commands/compat/providers/codex.d.mts +0 -17
  595. package/dist/src/cli/commands/compat/providers/codex.d.mts.map +0 -1
  596. package/dist/src/cli/commands/compat/providers/codex.mjs +0 -170
  597. package/dist/src/cli/commands/compat/providers/codex.mjs.map +0 -1
  598. package/dist/src/cli/commands/compat/providers/index.cjs +0 -65
  599. package/dist/src/cli/commands/compat/providers/index.cjs.map +0 -1
  600. package/dist/src/cli/commands/compat/providers/index.d.mts +0 -15
  601. package/dist/src/cli/commands/compat/providers/index.d.mts.map +0 -1
  602. package/dist/src/cli/commands/compat/providers/index.mjs +0 -45
  603. package/dist/src/cli/commands/compat/providers/index.mjs.map +0 -1
  604. package/dist/src/cli/commands/compat/providers/process.cjs +0 -172
  605. package/dist/src/cli/commands/compat/providers/process.cjs.map +0 -1
  606. package/dist/src/cli/commands/compat/providers/process.d.mts +0 -33
  607. package/dist/src/cli/commands/compat/providers/process.d.mts.map +0 -1
  608. package/dist/src/cli/commands/compat/providers/process.mjs +0 -159
  609. package/dist/src/cli/commands/compat/providers/process.mjs.map +0 -1
  610. package/dist/src/cli/commands/compat/providers/shared.cjs +0 -76
  611. package/dist/src/cli/commands/compat/providers/shared.cjs.map +0 -1
  612. package/dist/src/cli/commands/compat/providers/shared.d.mts +0 -40
  613. package/dist/src/cli/commands/compat/providers/shared.d.mts.map +0 -1
  614. package/dist/src/cli/commands/compat/providers/shared.mjs +0 -61
  615. package/dist/src/cli/commands/compat/providers/shared.mjs.map +0 -1
  616. package/dist/src/cli/commands/compat/types.d.mts +0 -31
  617. package/dist/src/cli/commands/compat/types.d.mts.map +0 -1
  618. package/dist/src/cli/commands/init/constants.cjs +0 -11
  619. package/dist/src/cli/commands/init/constants.cjs.map +0 -1
  620. package/dist/src/cli/commands/init/constants.mjs +0 -11
  621. package/dist/src/cli/commands/init/constants.mjs.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":["path","ensureLayerPackages","ensureGlobalWebBuild","ensureGlobalNativeBuild","ensureMcpAppBuild","pruneAfterSync","createWorkspaceRegistry","piAgentDirectory","rootCompositions","compositionPackageRoots","catalogPackageRoots","globalPoConfigDirectory","fs","identifyWorkspace","readWorkspaceMarker","isLocalPackageSpecifier","testPackageRoot","splitPackageSpecifier","crypto","poPackageRoot","webHostVersion","loadMajorModesConfigLenient","localBuildStamp","BUILD_RECORD","spawnSync","mcpAppKey","mcpPluginCandidates","packageCatalogHash","catalogInstallSpecifiers","runtimeLayerPackageSpecifiers","buildLocalPackages","duplicatePluginCopies"],"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 { globalPoConfigDirectory } 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 { splitPackageSpecifier, testPackageRoot } from '@agimon-ai/po-core/moduleResolution';\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, mcpAppKey } 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 = globalPoConfigDirectory(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/** Local-path selections and checkout test overrides, stamped and built by the same local build pipeline. */\nfunction localPackages(\n config: ReturnType<typeof loadMajorModesConfigLenient>['config'],\n environment: NodeJS.ProcessEnv,\n): 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 const directory = isLocalPackageSpecifier(selector)\n ? path.resolve(definition.baseDirectory, selector)\n : testPackageRoot(splitPackageSpecifier(selector).name, environment);\n if (directory === undefined) continue;\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 const checkout =\n environment.PO_TEST === '1' && environment.PO_TEST_PACKAGES\n ? `+checkout@${crypto.createHash('sha256').update(environment.PO_TEST_PACKAGES).digest('hex')}`\n : '';\n return `po@${poPackageVersion()}+po-web@${webHostVersion(globalRoot, environment)}${checkout}`;\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, environment).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 * Whether the MCP app build the server will look for exists for every root. Its key hashes the\n * widget packages' built files, which the signature does not cover, so a rebuilt `dist/` moves\n * the key without moving the signature.\n */\nfunction mcpAppsBuilt(\n globalRoot: string,\n roots: readonly string[],\n homeDirectory: string,\n environment: NodeJS.ProcessEnv,\n): boolean {\n for (const compositions of composeRoots(roots, homeDirectory, environment).values()) {\n if (compositions instanceof Error) continue;\n let key: string | undefined;\n try {\n key = mcpAppKey(mcpPluginCandidates(compositions));\n } catch {\n // A widget package that cannot be read: not built; the full pass reports why.\n return false;\n }\n if (key !== undefined && !fs.existsSync(path.join(globalRoot, BUILD_DIRECTORY, 'mcp-app', key, MCP_APP_FILE)))\n return false;\n }\n return true;\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 mcpAppsBuilt(globalRoot, roots, homeDirectory, environment)\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) => [\n root,\n localPackages(loadMajorModesConfigLenient(root, homeDirectory, environment).config, environment),\n ]),\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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4DA,MAAM,kBAAkB;AACxB,MAAM,YAAY;AAClB,MAAM,aAAa;AACnB,MAAM,eAAe;AACrB,MAAM,oBAAoB;AAC1B,MAAM,eAAe;AACrB,MAAM,eAAeA,UAAAA,QAAK,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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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,CAACnB,QAAAA,QAAG,WAAW,SAAS,GAAG,OAAO;EAClE,OAAO,YAAY,UAAU,QAAQ,QAAQ,IAAI;EACjD,IAAI,CAAC,KAAK,UAAU,OAAO;CAC7B;AACF"}
1
+ {"version":3,"file":"index.cjs","names":["ensureLayerPackages","ensureGlobalWebBuild","ensureGlobalNativeBuild","ensureMcpAppBuild","pruneAfterSync","path","formatMessage","createWorkspaceRegistry","piAgentDirectory","rootCompositions","compositionPackageRoots","catalogPackageRoots","globalPoConfigDirectory","localWorkspaceRecords","fs","identifyWorkspace","readWorkspaceMarker","statSync","loadPresetsConfigLenient","isLocalPackageSpecifier","checkoutPackageRoot","splitPackageSpecifier","readTrustedWorkspaces","readLocalBuildStamps","localBuildStamp","crypto","poPackageRoot","webHostVersion","readGlobalWebBuildStatus","BUILD_RECORD","writeFileAtomic","createNodePlatform","BACKGROUND_CONTEXT","wait","mcpAppKey","mcpPluginCandidates","packageCatalogHash","catalogInstallSpecifiers","runtimeLayerPackageSpecifiers","writeTrustedWorkspaces","buildLocalPackages","duplicatePluginCopies"],"sources":["../../../../src/composition/syncService/index.ts"],"sourcesContent":["import crypto from 'node:crypto';\nimport { statSync } from 'node:fs';\nimport fs from 'node:fs/promises';\nimport path from 'node:path';\nimport { setTimeout as wait } from 'node:timers/promises';\n\nimport { globalPoConfigDirectory } from '@agimon-ai/po-config/config';\nimport { isLocalPackageSpecifier } from '@agimon-ai/po-config/presets';\nimport { loadPresetsConfigLenient } from '@agimon-ai/po-config/sync';\nimport {\n createWorkspaceRegistry,\n identifyWorkspace,\n localWorkspaceRecords,\n readWorkspaceMarker,\n type WorkspaceRegistry,\n writeWorkspaceMarker,\n} from '@agimon-ai/po-core/history';\nimport { formatMessage } from '@agimon-ai/po-core/locale';\nimport { splitPackageSpecifier, checkoutPackageRoot } from '@agimon-ai/po-core/moduleResolution';\nimport { createNodePlatform } from '@agimon-ai/po-core/nodePlatform';\nimport { piAgentDirectory } from '@agimon-ai/po-core/piSettings';\nimport { BACKGROUND_CONTEXT, writeFileAtomic } from '@agimon-ai/po-core/platform';\n\nimport { poPackageRoot } from '../../builders/cli/entryResolution';\nimport { rootCompositions } from '../../builders/cli/sessionComposition';\nimport { ensureGlobalNativeBuild } from '../../builders/native';\nimport { ensureMcpAppBuild, mcpAppKey } from '../../builders/server/mcpAppBuild';\nimport { mcpPluginCandidates } from '../../builders/server/mcpBundle';\nimport {\n BUILD_RECORD,\n compositionPackageRoots,\n duplicatePluginCopies,\n ensureGlobalWebBuild,\n readGlobalWebBuildStatus,\n webHostVersion,\n} from '../../builders/web';\nimport {\n catalogInstallSpecifiers,\n catalogPackageRoots,\n ensureLayerPackages,\n type LayerPackageResult,\n packageCatalogHash,\n runtimeLayerPackageSpecifiers,\n} from '../layerPackageInstaller';\nimport { readTrustedWorkspaces, writeTrustedWorkspaces } from '../projectTrust';\nimport { pruneAfterSync, type SyncPruneInput } from '../syncPrune';\nimport { buildLocalPackages, type LocalPackage, localBuildStamp, readLocalBuildStamps } 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 ROOTS_LABEL = 'roots';\nconst PACKAGES_LABEL = 'packages';\nconst WEB_LABEL = 'web';\nconst NATIVE_LABEL = 'native';\nconst MCP_LABEL = 'mcp app';\nconst ARTIFACT_BUILDS_SKIPPED = 'skipped (--skip-artifact-builds)';\nconst NATIVE_DEFERRED = 'deferred until a native client connects';\nconst PRUNE_LABEL = 'prune';\nconst LOCAL_LABEL = 'local';\nexport const LOCAL_NOT_TRUSTED = 'not built: workspace not trusted';\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/** A build a pass may leave to a later one, because only some clients need it. */\nexport type DeferredArtifact = 'native' | 'mcp-app';\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 and synced as a root.\n * Undefined with `--global`, which registers nothing.\n */\n repoRoot?: string;\n origin: SyncOrigin;\n onEvent?: (event: SyncEvent) => void;\n /** Human CLI progress only. Omit for JSON, persisted reports and background logs. */\n translateProgress?: SyncTranslate;\n /** Carries the display text beside, never inside, the raw report error. */\n onErrorPresentation?: (raw: string, display: string) => void;\n /**\n * Installs packages and builds local ones, but skips the web, native and MCP app builds. The pointer\n * still moves, naming no build. A contained server runs sync this way, because its host serves the UI.\n */\n skipArtifactBuilds?: boolean;\n /**\n * Builds this pass leaves to a later one. The pointer keeps the previous pointer's builds of\n * that kind that still exist, so they keep serving (and survive prune) until a pass builds it.\n */\n deferArtifacts?: readonly DeferredArtifact[];\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 errorMessage(error: unknown): string {\n return error instanceof Error ? error.message : String(error);\n}\n\ntype SyncTranslate = (key: string, fallback: string, vars?: Readonly<Record<string, string | number>>) => string;\nconst englishMessage: SyncTranslate = (_key, fallback, vars) => formatMessage(fallback, vars);\n\nfunction errorText(options: SyncOptions): SyncTranslate {\n return (key, fallback, vars) => {\n const raw = englishMessage(key, fallback, vars);\n if (options.onErrorPresentation && options.translateProgress)\n options.onErrorPresentation(raw, options.translateProgress(key, fallback, vars));\n return raw;\n };\n}\n\nfunction packageSummary(result: SyncResult['packages'], t: SyncTranslate = englishMessage): string {\n const parts: string[] = [];\n if (result.updated.length > 0) {\n const count = result.updated.length;\n parts.push(\n count === 1\n ? t('cli.sync.updatedOne', 'updated {count} package', { count })\n : t('cli.sync.updatedMany', 'updated {count} packages', { count }),\n );\n }\n if (result.installed.length > 0) {\n const count = result.installed.length;\n parts.push(\n count === 1\n ? t('cli.sync.installedOne', 'installed {count} missing package', { count })\n : t('cli.sync.installedMany', 'installed {count} missing packages', { count }),\n );\n }\n if (parts.length === 0) parts.push(t('cli.sync.alreadyCurrent', 'already up to date'));\n if (result.unchecked.length > 0) {\n const count = result.unchecked.length;\n parts.push(\n count === 1\n ? t('cli.sync.uncheckedOne', '{count} package left unchecked', { count })\n : t('cli.sync.uncheckedMany', '{count} packages left unchecked', { count }),\n );\n }\n return parts.join(', ');\n}\n\nfunction artifactSummary(artifact: SyncResult['web'], t: SyncTranslate, skipped?: string): string {\n if (artifact.status === 'skipped') return skipped ?? artifact.reason;\n const status = artifact.status === 'built' ? t('cli.sync.built', 'built') : t('cli.sync.cached', 'cached');\n return `${artifact.key} (${status})`;\n}\n\n/** Human presentation only. The service report and JSON events retain their stable raw fields. */\nexport function formatSyncResult(result: SyncResult, t: SyncTranslate = englishMessage): string {\n return [\n t('cli.sync.result.packages', 'packages: {summary}', { summary: packageSummary(result.packages, t) }),\n t('cli.sync.result.web', 'web: {summary}', {\n summary: artifactSummary(result.web, t),\n }),\n ...(result.native === undefined\n ? []\n : [\n t('cli.sync.result.native', 'native: {summary}', {\n summary: artifactSummary(result.native, t),\n }),\n ]),\n ...(result.mcpApp === undefined\n ? []\n : [t('cli.sync.result.mcp', 'mcp app: {summary}', { summary: 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. */\nasync function packageRootsByRoot(\n composed: ReadonlyMap<string, RootCompositions | Error>,\n onNotice: (message: string) => void,\n t: SyncTranslate,\n): Promise<Map<string, string[]>> {\n return new Map(\n await Promise.all(\n [...composed].map(async ([root, compositions]): Promise<[string, string[]]> => {\n if (!(compositions instanceof Error)) return [root, await compositionPackageRoots(compositions)];\n onNotice(\n t('cli.sync.progress.webLeftOut', \"'{root}' is left out of the web build: {reason}\", {\n root,\n reason: compositions.message,\n }),\n );\n return [root, []];\n }),\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 */\nasync function webPluginRootsOf(\n globalRoot: string,\n rootPackageRoots: ReadonlyMap<string, readonly string[]>,\n environment: NodeJS.ProcessEnv,\n): Promise<string[]> {\n return [...(await 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 async function globalWebPluginRoots(\n targetRoot: string,\n homeDirectory: string,\n environment: NodeJS.ProcessEnv,\n onNotice: (message: string) => void,\n t: SyncTranslate = englishMessage,\n): Promise<string[]> {\n const globalRoot = globalPoConfigDirectory(homeDirectory, environment);\n const roots = await admittedRoots(targetRoot, homeDirectory, environment, onNotice);\n return webPluginRootsOf(\n globalRoot,\n await packageRootsByRoot(composeRoots(roots, homeDirectory, environment), onNotice, t),\n environment,\n );\n}\n\n/**\n * The Po home, every registered workspace whose folder exists and `targetRoot`, read without\n * registering or removing anything. The server admits `targetRoot` when it opens it, but never\n * serves a sandboxed one on the host.\n */\nasync function admittedRoots(\n targetRoot: string,\n homeDirectory: string,\n environment: NodeJS.ProcessEnv,\n onNotice: (message: string) => void,\n): Promise<string[]> {\n const globalRoot = globalPoConfigDirectory(homeDirectory, environment);\n const records = workspaceRegistry(homeDirectory, environment, onNotice).list();\n const admitted: string[] = [];\n for (const workspace of environment.PO_CHECKOUT_PACKAGES !== undefined ? [] : localWorkspaceRecords(records))\n if (\n await fs.access(workspace.root).then(\n () => true,\n () => false,\n )\n )\n admitted.push(workspace.root);\n const sandboxedRoots = new Set(records.filter((record) => record.sandbox !== undefined).map((record) => record.root));\n return [...new Set([globalRoot, ...admitted, targetRoot])].filter((root) => !sandboxedRoots.has(root));\n}\n\n/**\n * Registers the repository the way the server admits it, relocating its sibling workspaces\n * together after a move, and returns the workspace root it belongs to. A repository whose workspace\n * runs in a sandbox is left alone, and returns undefined: it is not re-added or renamed, and its\n * marker is neither read nor written, because the marker lives behind the repository's `.git`\n * pointer, which the sandbox can control.\n */\nasync function registerRepository(\n registry: WorkspaceRegistry,\n repoRoot: string,\n onNotice: (message: string) => void,\n t: SyncTranslate,\n): Promise<string | undefined> {\n const checkoutRoot = await fs.realpath(repoRoot);\n if (registry.list().some((workspace) => workspace.root === checkoutRoot && workspace.sandbox !== undefined))\n return undefined;\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?.sandbox !== undefined) return undefined;\n if (record === undefined) registry.add({ id, root });\n if (moved && record !== undefined) {\n const repositoryId = record.repositoryId ?? record.id;\n for (const sibling of registry.list()) {\n if (sibling.root !== record.root || (sibling.repositoryId ?? sibling.id) !== repositoryId) continue;\n registry.add({ ...sibling, root });\n onNotice(t('cli.sync.progress.workspaceMoved', \"workspace '{id}' moved to '{root}'\", { id: sibling.id, root }));\n }\n }\n try {\n if (readWorkspaceMarker(root) === undefined) writeWorkspaceMarker(root, id);\n } catch (error) {\n onNotice(\n t('cli.sync.progress.workspaceMarkerFailed', \"'{root}' id could not be recorded in its git data: {reason}\", {\n root,\n reason: errorMessage(error),\n }),\n );\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 * Test mode covers only the Po home and the folder it was given, so another folder opened in the\n * test console never blocks or rebuilds the checkout's sync.\n */\nasync function resolveRoots(\n options: SyncOptions,\n progress: Steps,\n): Promise<{ roots: string[]; repository: string | undefined }> {\n const t = options.translateProgress ?? englishMessage;\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 : await registerRepository(registry, options.repoRoot, notice, t);\n const live: string[] = [];\n for (const workspace of options.environment.PO_CHECKOUT_PACKAGES !== undefined\n ? []\n : localWorkspaceRecords(registry.list())) {\n if (\n await fs.access(workspace.root).then(\n () => true,\n () => false,\n )\n ) {\n live.push(workspace.root);\n continue;\n }\n notice(\n t('cli.sync.progress.workspaceRemoved', \"warning: removed workspace '{id}': '{root}' no longer exists\", {\n id: workspace.id,\n root: workspace.root,\n }),\n );\n registry.remove(workspace.id);\n }\n return {\n roots: [...new Set([options.globalRoot, ...live, ...(repository === undefined ? [] : [repository])])],\n repository,\n };\n}\n\ntype PresetsConfig = ReturnType<typeof loadPresetsConfigLenient>['config'];\n\n/**\n * Each root's presets configuration, parsed once per pass while its `presets.yaml` is unchanged.\n * Scoped to one caller, never module state, so a later pass always reads the files again.\n */\nfunction presetsReader(homeDirectory: string, environment: NodeJS.ProcessEnv): (root: string) => PresetsConfig {\n const parsed = new Map<string, PresetsConfig>();\n return (root) => {\n let mtime = 'missing';\n try {\n mtime = String(statSync(path.join(root, '.po', 'presets.yaml')).mtimeMs);\n } catch {\n // No workspace presets file: the key still names the root.\n }\n const key = `${root}\\0${mtime}`;\n let config = parsed.get(key);\n if (config === undefined) {\n config = loadPresetsConfigLenient(root, homeDirectory, environment).config;\n parsed.set(key, config);\n }\n return config;\n };\n}\n\ninterface RootLocalPackage extends LocalPackage {\n /** The workspace whose configuration names it by path; absent for the Po home and checkout test overrides. */\n workspace?: string;\n}\n\nfunction isWithin(parent: string, child: string): boolean {\n const relative = path.relative(parent, child);\n return relative === '' || (!relative.startsWith('..') && !path.isAbsolute(relative));\n}\n\n/** Local-path selections and checkout test overrides, stamped and built by the same local build pipeline. */\nfunction localPackages(\n config: PresetsConfig,\n environment: NodeJS.ProcessEnv,\n root: string,\n globalRoot: string,\n): RootLocalPackage[] {\n const definitions = [...(config.default ? [config.default] : []), ...Object.values(config.layers)];\n const packages = new Map<string, RootLocalPackage>();\n for (const definition of definitions)\n for (const configured of definition.packages ?? []) {\n const selector = typeof configured === 'string' ? configured : configured.name;\n const local = isLocalPackageSpecifier(selector);\n const directory = local\n ? path.resolve(definition.baseDirectory, selector)\n : checkoutPackageRoot(splitPackageSpecifier(selector).name, environment);\n if (directory === undefined) continue;\n // A layer the Po home declares keeps the home's trust inside any root that loads it.\n const workspace =\n local && !isWithin(path.resolve(globalRoot), path.resolve(definition.baseDirectory)) ? root : undefined;\n if (!packages.has(directory))\n packages.set(directory, { selector, directory, ...(workspace === undefined ? {} : { workspace }) });\n }\n return [...packages.values()];\n}\n\nasync function canonical(file: string): Promise<string> {\n return fs.realpath(file).catch(() => path.resolve(file));\n}\n\n/**\n * Why sync must not run a local package's build script, or undefined when it may. A workspace's\n * package must stay inside the workspace, symbolic links resolved, and the workspace must be trusted.\n */\nasync function localBuildRefusal(local: RootLocalPackage, trusted: ReadonlySet<string>): Promise<string | undefined> {\n if (local.workspace === undefined) return undefined;\n if (!isWithin(await canonical(local.workspace), await canonical(local.directory)))\n return `not built: '${local.selector}' resolves outside workspace '${local.workspace}'`;\n return trusted.has(local.workspace) ? undefined : LOCAL_NOT_TRUSTED;\n}\n\n/**\n * The trusted workspaces, and whether the record must be written. The first read after upgrade\n * finds no record and imports every root that has a package with a local build stamp.\n */\nasync function workspaceTrust(\n globalRoot: string,\n localByRoot: ReadonlyMap<string, readonly RootLocalPackage[]>,\n): Promise<{ trusted: Set<string>; changed: boolean }> {\n const recorded = await readTrustedWorkspaces(globalRoot);\n if (recorded !== undefined) return { trusted: recorded, changed: false };\n // ponytail: migration bridge for workspaces built before trust was recorded; remove after two releases.\n const stamps = await readLocalBuildStamps(globalRoot);\n const trusted = new Set<string>();\n for (const [root, packages] of localByRoot)\n if (packages.some((local) => local.workspace !== undefined && typeof stamps[local.directory] === 'string'))\n trusted.add(root);\n return { trusted, changed: true };\n}\n\n/**\n * What `po sync --check` reports about local packages across every admitted root: trusted ones\n * whose build stamp moved since their last build are stale; refused ones are reported apart.\n */\nexport async function localBuildReadiness(\n targetRoot: string,\n homeDirectory: string,\n environment: NodeJS.ProcessEnv,\n): Promise<{ stale: string[]; refused: string[] }> {\n const globalRoot = globalPoConfigDirectory(homeDirectory, environment);\n const presetsOf = presetsReader(homeDirectory, environment);\n const roots = await admittedRoots(targetRoot, homeDirectory, environment, () => undefined);\n const localByRoot = new Map(\n roots.map((root) => [root, localPackages(presetsOf(root), environment, root, globalRoot)] as const),\n );\n const { trusted } = await workspaceTrust(globalRoot, localByRoot);\n const stamps = await readLocalBuildStamps(globalRoot);\n const stale: string[] = [];\n const refused: string[] = [];\n for (const [root, packages] of localByRoot)\n for (const local of packages) {\n const refusal = await localBuildRefusal(local, trusted);\n if (refusal !== undefined) {\n refused.push(`${local.selector} in ${root}: ${refusal}`);\n continue;\n }\n const manifest = await fs\n .readFile(path.join(local.directory, PACKAGE_MANIFEST), 'utf8')\n .then((text) => JSON.parse(text) as { scripts?: Record<string, unknown> })\n .catch(() => undefined);\n // A package without a build script is never stamped; the build step checks its entries.\n if (typeof manifest?.scripts?.build !== 'string') continue;\n if (stamps[local.directory] !== (await localBuildStamp(local.directory)))\n stale.push(`local package is not built: ${local.selector} (${local.directory})`);\n }\n return { stale, refused };\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. */\nasync function poPackageVersion(): Promise<string> {\n try {\n const manifest = JSON.parse(await fs.readFile(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 async function syncHostIdentity(globalRoot: string, environment: NodeJS.ProcessEnv): Promise<string> {\n const checkout = environment.PO_CHECKOUT_PACKAGES\n ? `+checkout@${crypto\n .createHash('sha256')\n .update(JSON.stringify([environment.PO_ENVIRONMENT, environment.PO_HOME, environment.PO_CHECKOUT_PACKAGES]))\n .digest('hex')}`\n : '';\n return `po@${await poPackageVersion()}+po-web@${await webHostVersion(globalRoot, environment)}${checkout}`;\n}\n\n/** The fast-exit signature: catalogue, root selections/local stamps, host identity and derived web build. */\nasync function syncSignature(\n options: SyncOptions,\n roots: readonly string[],\n catalogueHash: string,\n presetsOf: (root: string) => PresetsConfig,\n): Promise<string> {\n const { homeDirectory, environment } = options;\n const value = {\n format: SIGNATURE_FORMAT,\n catalogueHash,\n roots: await Promise.all(\n roots.map(async (root) => ({\n root,\n selection: rootSelectionFingerprint(root, homeDirectory, environment),\n local: await Promise.all(\n localPackages(presetsOf(root), environment, root, options.globalRoot).map(async ({ directory }) => [\n directory,\n await localBuildStamp(directory),\n ]),\n ),\n })),\n ),\n host: await syncHostIdentity(options.globalRoot, environment),\n web:\n options.skipArtifactBuilds === true\n ? undefined\n : await readGlobalWebBuildStatus({\n poHome: options.globalRoot,\n pluginRoots: await globalWebPluginRoots(options.globalRoot, homeDirectory, environment, () => undefined),\n environment,\n }),\n // A pass without builds never stands in for one with them.\n ...(options.skipArtifactBuilds === true ? { skipArtifactBuilds: true } : {}),\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 /** The builds this pass deferred; their keys were carried from an earlier pass and may be stale. */\n deferred?: DeferredArtifact[];\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 async function readSyncPointer(globalRoot: string): Promise<SyncPointer | undefined> {\n try {\n const parsed = JSON.parse(await fs.readFile(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/** Whether every artifact `pointer` names exists. */\nasync function artifactsExist(\n globalRoot: string,\n pointer: Pick<SyncPointer, 'webKey' | 'nativeKey' | 'mcpKeys'>,\n): Promise<boolean> {\n const present = await Promise.all(\n pointerArtifacts(globalRoot, pointer).map((file) =>\n fs.access(file).then(\n () => true,\n () => false,\n ),\n ),\n );\n return present.every(Boolean);\n}\n\n/** The report of the last sync attempt, successful or not, or undefined when there is none. */\nexport async function readSyncLastAttempt(globalRoot: string): Promise<SyncReport | undefined> {\n try {\n const parsed = JSON.parse(await fs.readFile(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\nasync function writeJsonFile(file: string, value: unknown): Promise<void> {\n await writeFileAtomic(\n createNodePlatform().env(path.dirname(file)),\n file,\n `${JSON.stringify(value, null, 2)}\\n`,\n BACKGROUND_CONTEXT,\n );\n}\n\ntype LockAttempt = { acquired: true; token: string } | { acquired: false; holder: SyncLockHolder | undefined };\n\nasync function readHolder(lockPath: string): Promise<SyncLockHolder | undefined> {\n try {\n const parsed = JSON.parse(await fs.readFile(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\nasync function lockIsStale(lockPath: string, deps: SyncDeps): Promise<boolean> {\n const holder = await readHolder(lockPath);\n if (holder !== undefined) return !deps.isAlive(holder.pid);\n try {\n return deps.now().getTime() - (await fs.stat(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\nasync function tryCreateLock(lockPath: string, holder: SyncLockHolder): Promise<boolean> {\n try {\n const descriptor = await fs.open(lockPath, 'wx');\n try {\n await descriptor.writeFile(JSON.stringify(holder));\n } finally {\n await descriptor.close();\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 */\nasync function takeOverStaleLock(lockPath: string, holder: SyncLockHolder, deps: SyncDeps): Promise<boolean> {\n const moved = `${lockPath}.${String(deps.pid)}.${crypto.randomUUID()}.stale`;\n try {\n await fs.rename(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 (!(await lockIsStale(moved, deps))) {\n try {\n await fs.link(moved, lockPath);\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code !== ALREADY_EXISTS) throw error;\n }\n return false;\n }\n } finally {\n await fs.rm(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)`. */\nasync function acquireLock(lockPath: string, origin: SyncOrigin, deps: SyncDeps): Promise<LockAttempt> {\n await fs.mkdir(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 (await 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 ((await lockIsStale(lockPath, deps)) && (await takeOverStaleLock(lockPath, holder, deps)))\n return { acquired: true, token };\n return { acquired: false, holder: await 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 */\nasync function lostLock(\n lockPath: string,\n token: string,\n deps: SyncDeps,\n options: SyncOptions,\n): Promise<SyncReport | undefined> {\n const holder = await readHolder(lockPath);\n if (holder?.token === token) return undefined;\n const by = holder === undefined ? 'another process' : `pid ${String(holder.pid)}`;\n const t = errorText(options);\n return emptyReport(\n 'busy',\n [t('cli.sync.failure.lockLost', 'po sync lost its lock to {holder}', { holder: by })],\n deps,\n );\n}\n\nasync function releaseLock(lockPath: string, token: string): Promise<void> {\n if ((await readHolder(lockPath))?.token === token) await fs.rm(lockPath, { force: true });\n}\n\n/** Serializes runtime npm imports with sync, including sync's child process. */\nexport async function withSyncLock<T>(\n globalRoot: string,\n signal: AbortSignal | undefined,\n action: () => Promise<T>,\n): Promise<T> {\n const waiting = AbortSignal.any([AbortSignal.timeout(120_000), ...(signal ? [signal] : [])]);\n const lockPath = syncLockPath(globalRoot);\n for (;;) {\n waiting.throwIfAborted();\n const lock = await acquireLock(lockPath, 'background', DEFAULT_DEPS);\n if (!lock.acquired) {\n await wait(50, undefined, { signal: waiting });\n continue;\n }\n try {\n waiting.throwIfAborted();\n if ((await readHolder(lockPath))?.token !== lock.token) continue;\n // upm cannot abort safely. Keep the lock until installation settles.\n return await action();\n } finally {\n await releaseLock(lockPath, lock.token);\n }\n }\n}\n\n/** Consumes the rerun marker; true when a background run asked for another pass. */\nasync function takeRerunRequest(rerunPath: string): Promise<boolean> {\n try {\n await fs.unlink(rerunPath);\n return true;\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === NO_SUCH_FILE) return false;\n throw error;\n }\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(\n progress: Steps,\n prune: SyncDeps['prune'],\n input: SyncPruneInput,\n t: SyncTranslate,\n): Promise<void> {\n const done = progress.start(PRUNE_LABEL, t('cli.sync.progress.pruning', '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 : t('cli.sync.progress.bytesReleased', '{size} MB of packages released', {\n size: (result.runtime.bytes / BYTES_PER_MEGABYTE).toFixed(1),\n });\n const count = result.builds.length;\n done(\n count === 1\n ? t('cli.sync.progress.prunedOne', 'removed {count} old build, {runtime}', { count, runtime })\n : t('cli.sync.progress.prunedMany', 'removed {count} old builds, {runtime}', { count, runtime }),\n );\n } catch (error) {\n done(t('cli.sync.progress.pruneFailed', 'failed: {reason}', { reason: errorMessage(error) }));\n }\n}\n\n/** A path with its symlinks resolved, or as given when it does not exist. */\nasync function realPath(file: string): Promise<string> {\n try {\n return await fs.realpath(file);\n } catch {\n // Missing: compare it as written.\n return path.resolve(file);\n }\n}\n\n/**\n * Whether the MCP app build the server will look for exists for every root. Its key hashes the\n * widget packages' built files, which the signature does not cover, so a rebuilt `dist/` moves\n * the key without moving the signature.\n */\nasync function mcpAppsBuilt(\n globalRoot: string,\n roots: readonly string[],\n homeDirectory: string,\n environment: NodeJS.ProcessEnv,\n): Promise<boolean> {\n for (const compositions of composeRoots(roots, homeDirectory, environment).values()) {\n if (compositions instanceof Error) continue;\n let key: string | undefined;\n try {\n key = await mcpAppKey(await mcpPluginCandidates(compositions));\n } catch {\n // A widget package that cannot be read: not built; the full pass reports why.\n return false;\n }\n if (\n key !== undefined &&\n !(await fs.access(path.join(globalRoot, BUILD_DIRECTORY, 'mcp-app', key, MCP_APP_FILE)).then(\n () => true,\n () => false,\n ))\n )\n return false;\n }\n return true;\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: () => Promise<SyncReport | undefined>,\n): Promise<SyncReport> {\n const { homeDirectory, environment, globalRoot } = options;\n const progress = steps(emit);\n const t = options.translateProgress ?? englishMessage;\n const failure = (make: (t: SyncTranslate) => string) => make(errorText(options));\n const commands: string[] = [];\n const { roots, repository } = await resolveRoots(options, progress);\n const presetsOf = presetsReader(homeDirectory, environment);\n const catalogueHash = await packageCatalogHash(environment);\n const previous = await readSyncPointer(globalRoot);\n const skipBuilds = options.skipArtifactBuilds === true;\n // Deferring means nothing when no artifact is built at all.\n const deferred = new Set(skipBuilds ? [] : (options.deferArtifacts ?? []));\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 === (await syncSignature(options, roots, catalogueHash, presetsOf)) &&\n // A pointer that deferred a build this pass wants is not current; one that built more is.\n (previous.deferred ?? []).every((kind) => deferred.has(kind)) &&\n (await artifactsExist(globalRoot, previous)) &&\n (skipBuilds || deferred.has('mcp-app') || (await mcpAppsBuilt(globalRoot, roots, homeDirectory, environment)))\n ) {\n progress.line(\n ROOTS_LABEL,\n t('cli.sync.progress.noChanges', 'nothing changed since generation {generation}', {\n generation: previous.generation,\n }),\n );\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 = await lost();\n if (lostBeforeInstall !== undefined) return lostBeforeInstall;\n const packagesDone = progress.start(\n PACKAGES_LABEL,\n t('cli.sync.progress.checkingPackages', 'checking configured packages for updates'),\n );\n let packages: SyncResult['packages'];\n try {\n const configOf = presetsOf;\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(await catalogInstallSpecifiers(environment));\n for (const root of roots) {\n const config = configOf(root);\n for (const specifier of await 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 ...(options.translateProgress ? { translateProgress: options.translateProgress } : {}),\n });\n } catch (error) {\n packagesDone(t('cli.sync.progress.failed', 'failed'));\n return report(\n 'failed',\n [\n failure((t) =>\n t('cli.sync.failure.install', 'Installing packages failed: {reason}', { reason: errorMessage(error) }),\n ),\n ],\n null,\n [],\n );\n }\n packagesDone(packageSummary(packages, t));\n\n const localByRoot = new Map(\n roots.map((root) => [root, localPackages(presetsOf(root), environment, root, globalRoot)] as const),\n );\n const trust = await workspaceTrust(globalRoot, localByRoot);\n // A person running sync in a workspace trusts it to build its own local packages.\n if (options.origin === 'cli' && repository !== undefined && !trust.trusted.has(repository)) {\n trust.trusted.add(repository);\n trust.changed = true;\n }\n if (trust.changed) await writeTrustedWorkspaces(globalRoot, trust.trusted);\n const localDirectories: string[] = [];\n for (const [root, packagesOfRoot] of localByRoot)\n for (const local of packagesOfRoot) {\n const refusal = await localBuildRefusal(local, trust.trusted);\n if (refusal === undefined) localDirectories.push(local.directory);\n else unsynced.get(root)?.push({ selector: local.selector, reason: refusal });\n }\n if (localDirectories.length > 0) {\n const localDone = progress.start(LOCAL_LABEL, t('cli.sync.progress.buildingLocal', 'building local packages'));\n const outcomes = await buildLocalPackages({\n globalRoot,\n environment,\n directories: localDirectories,\n onCommand: (command) => commands.push(command),\n onNotice: (_message, packageName) =>\n progress.line(LOCAL_LABEL, t('cli.sync.progress.buildingPackage', 'building {name}', { name: packageName })),\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 const count = outcomes.size;\n localDone(\n failed > 0\n ? t('cli.sync.progress.localFailed', '{count} failed', { count: failed })\n : count === 1\n ? t('cli.sync.progress.localReadyOne', '{count} package ready', { count })\n : t('cli.sync.progress.localReadyMany', '{count} packages ready', { count }),\n );\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, t('cli.sync.progress.buildingWeb', 'ensuring the global web build'));\n let rootPackageRoots = await packageRootsByRoot(composed, (message) => progress.line(WEB_LABEL, message), t);\n const buildWeb = async (packageRoots: Map<string, string[]>) =>\n deps.buildWeb({\n poHome: globalRoot,\n pluginRoots: await webPluginRootsOf(globalRoot, packageRoots, environment),\n environment,\n onNotice: (message) => progress.line(WEB_LABEL, message),\n });\n let built: Awaited<ReturnType<typeof buildWeb>> = skipBuilds\n ? { status: 'skipped', reason: ARTIFACT_BUILDS_SKIPPED }\n : await buildWeb(rootPackageRoots);\n if (built.status === 'failed') {\n const buildFailure = built.reason;\n // A local copy is the likeliest cause; one retry without them keeps the rest serving.\n const local = new Set(await Promise.all(localDirectories.map(realPath)));\n const withoutLocal = new Map<string, string[]>();\n for (const [root, packageRoots] of rootPackageRoots) {\n const resolved = await Promise.all(packageRoots.map(realPath));\n withoutLocal.set(\n root,\n packageRoots.filter((_, index) => !local.has(resolved[index]!)),\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(t('cli.sync.progress.failed', 'failed'));\n const reason = leftOut\n ? failure((t) =>\n t('cli.sync.failure.webRetry', 'The global web build failed: {reason}; without local copies: {retry}', {\n reason: buildFailure,\n retry: retried.reason,\n }),\n )\n : failure((t) => t('cli.sync.failure.web', 'The global web build failed: {reason}', { reason: buildFailure }));\n return report('failed', [reason], null, []);\n }\n for (const [root, packagesOfRoot] of localByRoot) {\n const included = new Set(await Promise.all((rootPackageRoots.get(root) ?? []).map(realPath)));\n const entries = unsynced.get(root) ?? [];\n for (const { selector, directory } of packagesOfRoot)\n if (included.has(await 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: ${buildFailure}`,\n });\n }\n progress.line(\n WEB_LABEL,\n t('cli.sync.progress.webRetried', 'built without local copies after: {reason}', { reason: built.reason }),\n );\n rootPackageRoots = withoutLocal;\n built = retried;\n }\n const pluginRoots = await webPluginRootsOf(globalRoot, rootPackageRoots, environment);\n const web: SyncResult['web'] = built.status === 'skipped' ? built : { status: built.status, key: built.build.key };\n const skipped = skipBuilds ? t('cli.sync.progress.skipped', 'skipped (--skip-artifact-builds)') : undefined;\n webDone(artifactSummary(web, t, skipped));\n const webKey = web.status === 'skipped' ? null : web.key;\n\n const nativeDone = progress.start(\n NATIVE_LABEL,\n t('cli.sync.progress.buildingNative', 'ensuring the global native build'),\n );\n const nativeBuilt: Awaited<ReturnType<SyncDeps['buildNative']>> = skipBuilds\n ? { status: 'skipped', reason: ARTIFACT_BUILDS_SKIPPED }\n : deferred.has('native')\n ? { status: 'skipped', reason: NATIVE_DEFERRED }\n : await deps.buildNative({\n poHome: globalRoot,\n pluginRoots,\n onNotice: (message) => progress.line(NATIVE_LABEL, message),\n });\n if (nativeBuilt.status === 'failed') {\n nativeDone(t('cli.sync.progress.failed', 'failed'));\n return report(\n 'failed',\n [\n failure((t) =>\n t('cli.sync.failure.native', 'The global native build failed: {reason}', { reason: nativeBuilt.reason }),\n ),\n ],\n webKey,\n [],\n );\n }\n const native: NonNullable<SyncResult['native']> =\n nativeBuilt.status === 'skipped' ? nativeBuilt : { status: nativeBuilt.status, key: nativeBuilt.build.key };\n nativeDone(\n artifactSummary(\n native,\n t,\n skipped ??\n (deferred.has('native')\n ? t('cli.sync.progress.nativeDeferred', 'deferred until a native client connects')\n : undefined),\n ),\n );\n let 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(\n MCP_LABEL,\n t('cli.sync.progress.buildingMcp', 'ensuring the MCP app build of each root'),\n );\n let mcpKeys: string[] = [];\n for (const [root, compositions] of skipBuilds || deferred.has('mcp-app') ? [] : composed) {\n if (compositions instanceof Error) {\n progress.line(\n MCP_LABEL,\n t('cli.sync.progress.mcpLeftOut', \"'{root}' is left out of the MCP app build: {reason}\", {\n root,\n reason: compositions.message,\n }),\n );\n continue;\n }\n try {\n const app = await deps.bundleMcpApp({ poHome: globalRoot, candidates: await 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(\n skipped ??\n (deferred.has('mcp-app')\n ? t('cli.sync.progress.mcpDeferred', 'deferred until a session needs MCP widgets')\n : mcpKeys.length === 0\n ? t('cli.sync.progress.noMcpWidgets', 'no MCP UI widgets')\n : mcpKeys.join(', ')),\n );\n const mcpApp = mcpKeys.length === 0 ? undefined : mcpKeys.join(', ');\n\n // A deferred kind keeps the previous builds that still exist, so they serve until a pass builds it.\n if (deferred.has('native') && previous?.nativeKey)\n if (await artifactsExist(globalRoot, { webKey: null, nativeKey: previous.nativeKey, mcpKeys: [] }))\n nativeKey = previous.nativeKey;\n if (deferred.has('mcp-app') && previous !== undefined) {\n const present = await Promise.all(\n previous.mcpKeys.map((key) => artifactsExist(globalRoot, { webKey: null, nativeKey: null, mcpKeys: [key] })),\n );\n mcpKeys = previous.mcpKeys.filter((_, index) => present[index]);\n }\n\n // The pointer names only artifacts that exist; a missing one keeps the previous pointer.\n const artifacts = pointerArtifacts(globalRoot, { webKey, nativeKey, mcpKeys });\n const present = await Promise.all(\n artifacts.map((file) =>\n fs.access(file).then(\n () => true,\n () => false,\n ),\n ),\n );\n const missing = artifacts.filter((_, index) => !present[index]);\n if (missing.length > 0)\n return report(\n 'failed',\n [\n failure((t) =>\n t('cli.sync.failure.missingArtifacts', 'Build artifacts are missing: {paths}', { paths: missing.join(', ') }),\n ),\n ],\n webKey,\n mcpKeys,\n );\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: await syncSignature(options, roots, catalogueHash, presetsOf),\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: await syncHostIdentity(globalRoot, environment),\n ...(deferred.size === 0 ? {} : { deferred: [...deferred].sort() }),\n };\n const lostBeforePointer = await lost();\n if (lostBeforePointer !== undefined) return lostBeforePointer;\n await writeJsonFile(syncPointerPath(globalRoot), pointer);\n\n await pruneStep(\n progress,\n deps.prune,\n {\n homeDirectory,\n environment,\n buildsRoot: globalRoot,\n ...(webKey === null ? {} : { webKey }),\n ...(nativeKey === null ? {} : { nativeKey }),\n ...(mcpKeys.length === 0 ? {} : { mcpAppKeys: mcpKeys }),\n },\n t,\n );\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: () => Promise<SyncReport | undefined>,\n): Promise<SyncReport> {\n const t = errorText(options);\n let report: SyncReport;\n try {\n report = await syncOnce(options, deps, emit, lost);\n } catch (error) {\n report = emptyReport(\n 'failed',\n [t('cli.sync.failure.sync', 'po sync failed: {reason}', { reason: errorMessage(error) })],\n deps,\n );\n }\n if (report.status === 'busy') return report;\n try {\n await writeJsonFile(syncLastAttemptPath(options.globalRoot), report);\n } catch (error) {\n report = {\n ...report,\n errors: [\n ...report.errors,\n t('cli.sync.failure.reportWrite', 'last-attempt.json could not be written: {reason}', {\n reason: errorMessage(error),\n }),\n ],\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 = await acquireLock(lockPath, options.origin, deps);\n if (!lock.acquired) {\n if (options.origin === 'background') await fs.writeFile(rerunPath, deps.now().toISOString());\n const holder = lock.holder === undefined ? 'another process' : `pid ${String(lock.holder.pid)}`;\n const t = errorText(options);\n return emptyReport(\n 'busy',\n [t('cli.sync.failure.lockBusy', 'po sync is already running ({holder})', { holder })],\n deps,\n );\n }\n for (;;) {\n const { token } = lock;\n const lost = () => lostLock(lockPath, token, deps, options);\n let report: SyncReport;\n try {\n // A marker left before this pass started is satisfied by this pass.\n await 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' && (await takeRerunRequest(rerunPath)))\n report = await attempt(options, deps, emit, lost);\n } finally {\n await releaseLock(lockPath, token);\n }\n if (\n report.status === 'busy' ||\n !(await fs.access(rerunPath).then(\n () => true,\n () => false,\n ))\n )\n return report;\n lock = await acquireLock(lockPath, options.origin, deps);\n if (!lock.acquired) return report;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmEA,MAAM,kBAAkB;AACxB,MAAM,YAAY;AAClB,MAAM,aAAa;AACnB,MAAM,eAAe;AACrB,MAAM,oBAAoB;AAC1B,MAAM,eAAe;AACrB,MAAM,cAAc;AACpB,MAAM,iBAAiB;AACvB,MAAM,YAAY;AAClB,MAAM,eAAe;AACrB,MAAM,YAAY;AAClB,MAAM,0BAA0B;AAChC,MAAM,kBAAkB;AACxB,MAAM,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AE5F,OAAO,YACL,QACA,CAHQ,UAAU,OAGjB,CAAC,CAAC,6BAA6B,yCAAyC,EAAE,OAAO,CAAC,CAAC,GACpF,IACF;CACF;CACA,SAAS;EACP,MAAM,EAAE,UAAU;EAClB,MAAM,aAAa,SAAS,UAAU,OAAO,MAAM,OAAO;EAC1D,IAAI;EACJ,IAAI;GAEF,MAAM,iBAAiB,SAAS;GAChC,SAAS,MAAM,QAAQ,SAAS,MAAM,MAAM,IAAI;GAEhD,OAAO,OAAO,WAAW,UAAW,MAAM,iBAAiB,SAAS,GAClE,SAAS,MAAM,QAAQ,SAAS,MAAM,MAAM,IAAI;EACpD,UAAU;GACR,MAAM,YAAY,UAAU,KAAK;EACnC;EACA,IACE,OAAO,WAAW,UAClB,CAAE,MAAMA,iBAAAA,QAAG,OAAO,SAAS,CAAC,CAAC,WACrB,YACA,KACR,GAEA,OAAO;EACT,OAAO,MAAM,YAAY,UAAU,QAAQ,QAAQ,IAAI;EACvD,IAAI,CAAC,KAAK,UAAU,OAAO;CAC7B;AACF"}
@@ -60,6 +60,9 @@ export interface SyncDeps {
60
60
  pid: number;
61
61
  now: () => Date;
62
62
  }
63
- export declare function formatSyncResult(result: SyncResult): string;
63
+ type SyncTranslate = (key: string, fallback: string, vars?: Readonly<Record<string, string | number>>) => string;
64
+ /** Human presentation only. The service report and JSON events retain their stable raw fields. */
65
+ export declare function formatSyncResult(result: SyncResult, t?: SyncTranslate): string;
64
66
  //#endregion
67
+ export {};
65
68
  //# sourceMappingURL=index.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","names":[],"sources":["../../../../src/composition/syncService/index.ts"],"mappings":";;;;;;YA8FY;iBAEK;EACf,UAAU,KAAK;;EAEf;IAAO;IAA4B;;IAAkB;IAAmB;;;EAExE;IAAW;IAA4B;;IAAkB;IAAmB;;;EAE5E;;iBAGe;EACf;EACA;EACA;IAAY;IAAkB;IAAgB;;;iBAG/B;EACf,QAAQ;;EAER;;EAEA;EACA;EACA;EACA,OAAO;;EAEP;EACA;EACA;;iBAgCe;EACf,gBAAgB;EAChB,iBAAiB;EACjB,oBAAoB;EACpB,qBAAqB;EACrB,cAAc;;EAEd,UAAU;EACV;EACA,WAAW;;wBAuDG,iBAAiB,QAAQ"}
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../../../../src/composition/syncService/index.ts"],"mappings":";;;;;;YAsGY;iBAIK;EACf,UAAU,KAAK;;EAEf;IAAO;IAA4B;;IAAkB;IAAmB;;;EAExE;IAAW;IAA4B;;IAAkB;IAAmB;;;EAE5E;;iBAGe;EACf;EACA;EACA;IAAY;IAAkB;IAAgB;;;iBAG/B;EACf,QAAQ;;EAER;;EAEA;EACA;EACA;EACA,OAAO;;EAEP;EACA;EACA;;iBA8Ce;EACf,gBAAgB;EAChB,iBAAiB;EACjB,oBAAoB;EACpB,qBAAqB;EACrB,cAAc;;EAEd,UAAU;EACV;EACA,WAAW;;KA0CR,iBAAiB,aAAa,kBAAkB,OAAO,SAAS;;wBAiDrD,iBAAiB,QAAQ,YAAY,IAAG"}