@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,15 +1,18 @@
1
1
  import { poPackageRoot } from "../../builders/cli/entryResolution.mjs";
2
2
  import { createLayerResolvers } from "../../../builders/cli/extensionAssembler/index.mjs";
3
- import fs from "node:fs";
4
- import path from "node:path";
5
- import { writeFileAtomic } from "@agimon-ai/po-core/runtimeJson";
6
3
  import os from "node:os";
7
- import { isLocalPackageSpecifier } from "@agimon-ai/po-config/majorModes";
8
- import { consumerPackageEntry, splitPackageSpecifier, testPackageRoot } from "@agimon-ai/po-core/moduleResolution";
4
+ import { formatMessage } from "@agimon-ai/po-core/locale";
5
+ import { poHomeDirectory, poRuntimeDirectory } from "@agimon-ai/po-core/runtimePiSettings";
6
+ import path from "node:path";
7
+ import fs from "node:fs/promises";
8
+ import { createNodePlatform } from "@agimon-ai/po-core/nodePlatform";
9
+ import { BACKGROUND_CONTEXT, getOrThrow, readTextIfExists, writeFileAtomic } from "@agimon-ai/po-core/platform";
10
+ import { isLocalPackageSpecifier } from "@agimon-ai/po-config/presets";
11
+ import { checkoutPackageRoot, consumerPackageEntry, splitPackageSpecifier } from "@agimon-ai/po-core/moduleResolution";
9
12
  import crypto from "node:crypto";
10
13
  import zlib from "node:zlib";
11
14
  import { installRuntimePackages, resolveNewest } from "@agimon-ai/po-core/runtimePackages";
12
- import { poHomeDirectory, poRuntimeDirectory } from "@agimon-ai/po-core/runtimePiSettings";
15
+ import { fetchVerifiedPluginArchive, verifiedArchiveFiles } from "@agimon-ai/po-core/verifiedArchive";
13
16
  //#region src/composition/layerPackageInstaller/index.ts
14
17
  const NPM_SOURCE_PREFIX = "npm:";
15
18
  const FILE_SPECIFIER_PREFIX = "file:";
@@ -29,6 +32,9 @@ const BUNDLED_CATALOG_SEGMENTS = [
29
32
  "catalog",
30
33
  "index.json"
31
34
  ];
35
+ /** The catalogue a checkout build writes beside `dist`, where a rebuild does not wipe it. Never published. */
36
+ const CHECKOUT_CATALOG_FILE = "catalog.json";
37
+ const NO_CURATED_CATALOG = "This CLI has no curated release catalog.";
32
38
  /** upm error codes that mean the registry could not be reached, so the store may still answer. */
33
39
  const NETWORK_FAILURE_CODES = /* @__PURE__ */ new Set([
34
40
  "ENETWORK",
@@ -45,7 +51,7 @@ function overridePackageName(selector) {
45
51
  * cannot carry these fixes in their own manifests.
46
52
  */
47
53
  const SAFE_TRANSITIVE_OVERRIDES = {
48
- "@earendil-works/pi-codemode": "1.3.0",
54
+ "@earendil-works/pi-codemode": "1.6.1",
49
55
  "@hono/node-server@2.0.0 - 2.0.9": "^2.0.10",
50
56
  "@opentelemetry/core@2.0.0 - 2.7.999": "2.8.0",
51
57
  "brace-expansion@1.0.0 - 1.1.20": "^1.1.21",
@@ -58,16 +64,16 @@ const SAFE_TRANSITIVE_OVERRIDES = {
58
64
  "undici@7.0.0 - 7.29.0": "^7.29.1"
59
65
  };
60
66
  const SAFE_TRANSITIVE_PACKAGE_NAMES = new Set(Object.keys(SAFE_TRANSITIVE_OVERRIDES).map(overridePackageName));
61
- function isRecord$1(value) {
67
+ function isRecord(value) {
62
68
  return typeof value === "object" && value !== null && !Array.isArray(value);
63
69
  }
64
70
  function recordValue(value) {
65
- return isRecord$1(value) ? { ...value } : {};
71
+ return isRecord(value) ? { ...value } : {};
66
72
  }
67
73
  function withoutConflictingTransitiveOverrides(value) {
68
74
  const overrides = recordValue(value);
69
75
  for (const [selector, replacement] of Object.entries(overrides)) if (SAFE_TRANSITIVE_PACKAGE_NAMES.has(overridePackageName(selector))) delete overrides[selector];
70
- else if (isRecord$1(replacement)) overrides[selector] = withoutConflictingTransitiveOverrides(replacement);
76
+ else if (isRecord(replacement)) overrides[selector] = withoutConflictingTransitiveOverrides(replacement);
71
77
  return overrides;
72
78
  }
73
79
  /** Earlier versions overrode catalog packages with relative `file:` targets; any other override is not Po's. */
@@ -94,8 +100,11 @@ function resolvePackageEntries(resolvers, specifier) {
94
100
  const entry = resolvers.optionalPackageEntry(specifier);
95
101
  return entry ? [entry] : void 0;
96
102
  }
97
- function readRuntimeManifest(manifestPath) {
98
- const current = fs.existsSync(manifestPath) ? fs.readFileSync(manifestPath, "utf8") : void 0;
103
+ async function readRuntimeManifest(manifestPath) {
104
+ const current = await fs.readFile(manifestPath, "utf8").catch((error) => {
105
+ if (error.code === "ENOENT") return void 0;
106
+ throw error;
107
+ });
99
108
  if (current === void 0) return {
100
109
  current,
101
110
  manifest: {
@@ -104,17 +113,16 @@ function readRuntimeManifest(manifestPath) {
104
113
  }
105
114
  };
106
115
  const parsed = JSON.parse(current);
107
- if (!isRecord$1(parsed)) throw new Error(`Po runtime package manifest at ${manifestPath} must be a JSON object.`);
116
+ if (!isRecord(parsed)) throw new Error(`Po runtime package manifest at ${manifestPath} must be a JSON object.`);
108
117
  return {
109
118
  current,
110
119
  manifest: parsed
111
120
  };
112
121
  }
113
122
  /** Names the runtime manifest already declares: what earlier runs, from any root, installed there. */
114
- function declaredRuntimePackages(runtimeDirectory) {
123
+ async function declaredRuntimePackages(runtimeDirectory) {
115
124
  const manifestPath = path.join(runtimeDirectory, PACKAGE_MANIFEST);
116
- if (!fs.existsSync(manifestPath)) return /* @__PURE__ */ new Set();
117
- return new Set(Object.keys(recordValue(readRuntimeManifest(manifestPath).manifest.dependencies)));
125
+ return new Set(Object.keys(recordValue((await readRuntimeManifest(manifestPath)).manifest.dependencies)));
118
126
  }
119
127
  /**
120
128
  * Adds a package set and the patched transitive policy to the shared runtime manifest.
@@ -126,14 +134,16 @@ function declaredRuntimePackages(runtimeDirectory) {
126
134
  * `pnpm.overrides` are written; upm reads both.
127
135
  * With `exact`, declared names outside `sources` are dropped instead of kept.
128
136
  */
129
- function ensureManagedPackageManifest(runtimeDirectory, sources, targets = /* @__PURE__ */ new Map(), catalogWorkspaces = {}, exact = false) {
137
+ async function ensureManagedPackageManifest(runtimeDirectory, sources, targets = /* @__PURE__ */ new Map(), catalogWorkspaces = {}, exact = false, preserveWorkspaces = false) {
130
138
  const manifestPath = path.join(runtimeDirectory, PACKAGE_MANIFEST);
131
- const { current, manifest } = readRuntimeManifest(manifestPath);
139
+ const { current, manifest } = await readRuntimeManifest(manifestPath);
132
140
  const declared = recordValue(manifest.dependencies);
133
141
  const sourceNames = new Set(sources.map(packageName));
134
142
  const dependencies = exact ? Object.fromEntries(Object.entries(declared).filter(([name]) => sourceNames.has(name))) : declared;
135
143
  for (const [name, declared] of Object.entries(dependencies)) if (Object.hasOwn(catalogWorkspaces, name)) dependencies[name] = CATALOG_WORKSPACE_TARGET;
136
- else if (typeof declared === "string" && (declared.startsWith(FILE_SPECIFIER_PREFIX) || declared.startsWith(WORKSPACE_SPECIFIER_PREFIX))) dependencies[name] = UNPINNED_PACKAGE_RANGE;
144
+ else if (typeof declared === "string" && (declared.startsWith(FILE_SPECIFIER_PREFIX) || declared.startsWith(WORKSPACE_SPECIFIER_PREFIX))) {
145
+ if (!preserveWorkspaces) dependencies[name] = UNPINNED_PACKAGE_RANGE;
146
+ }
137
147
  for (const source of sources) {
138
148
  const name = packageName(source);
139
149
  const target = targets.get(name);
@@ -141,7 +151,12 @@ function ensureManagedPackageManifest(runtimeDirectory, sources, targets = /* @_
141
151
  else if (!Object.hasOwn(dependencies, name)) dependencies[name] = UNPINNED_PACKAGE_RANGE;
142
152
  }
143
153
  manifest.dependencies = dependencies;
144
- const workspaces = Object.values(catalogWorkspaces).sort();
154
+ const keptWorkspaces = [];
155
+ if (preserveWorkspaces) for (const relative of stringList(manifest.workspaces) ?? []) {
156
+ const previous = await readRuntimeManifest(path.join(runtimeDirectory, relative, PACKAGE_MANIFEST));
157
+ if (typeof previous.manifest.name === "string" && !Object.hasOwn(catalogWorkspaces, previous.manifest.name)) keptWorkspaces.push(relative);
158
+ }
159
+ const workspaces = [.../* @__PURE__ */ new Set([...keptWorkspaces, ...Object.values(catalogWorkspaces)])].sort();
145
160
  if (workspaces.length > 0) manifest.workspaces = workspaces;
146
161
  else delete manifest.workspaces;
147
162
  manifest.overrides = {
@@ -156,8 +171,8 @@ function ensureManagedPackageManifest(runtimeDirectory, sources, targets = /* @_
156
171
  manifest.pnpm = pnpm;
157
172
  const serialized = `${JSON.stringify(manifest, null, 2)}\n`;
158
173
  if (serialized === current) return false;
159
- fs.mkdirSync(runtimeDirectory, { recursive: true });
160
- writeFileAtomic(manifestPath, serialized);
174
+ await fs.mkdir(runtimeDirectory, { recursive: true });
175
+ await writeFileAtomic(createNodePlatform().env(runtimeDirectory), manifestPath, serialized, BACKGROUND_CONTEXT);
161
176
  return true;
162
177
  }
163
178
  /** Finds required npm packages selected by defaults and active layers that Po cannot resolve. */
@@ -165,9 +180,12 @@ function missingLayerPackageSpecifiers(config, layers, resolvers) {
165
180
  return configuredPackageSpecifiers(config, layers).filter((specifier) => resolvePackageEntries(resolvers, specifier) === void 0);
166
181
  }
167
182
  /** Whether `root`'s own node_modules chain holds the package, walked the way Node looks it up from `root`. */
168
- function ownsPackage(name, root) {
183
+ async function ownsPackage(name, root) {
169
184
  for (let directory = path.resolve(root);; directory = path.dirname(directory)) {
170
- if (fs.existsSync(path.join(directory, NODE_MODULES, name, PACKAGE_MANIFEST))) return true;
185
+ if (await fs.access(path.join(directory, NODE_MODULES, name, PACKAGE_MANIFEST)).then(() => true, (error) => {
186
+ if (error.code === "ENOENT") return false;
187
+ throw error;
188
+ })) return true;
171
189
  if (path.dirname(directory) === directory) return false;
172
190
  }
173
191
  }
@@ -177,8 +195,10 @@ function ownsPackage(name, root) {
177
195
  * already or not yet. Sync declares exactly these, over every root, in the runtime manifest; a
178
196
  * name the runtime already provides still counts, or the next exact manifest would drop it.
179
197
  */
180
- function runtimeLayerPackageSpecifiers(config, layers, root) {
181
- return configuredPackageSpecifiers(config, layers).filter((specifier) => !ownsPackage(splitPackageSpecifier(specifier).name, root));
198
+ async function runtimeLayerPackageSpecifiers(config, layers, root) {
199
+ const specifiers = configuredPackageSpecifiers(config, layers);
200
+ const owned = await Promise.all(specifiers.map((specifier) => ownsPackage(splitPackageSpecifier(specifier).name, root)));
201
+ return specifiers.filter((_specifier, index) => !owned[index]);
182
202
  }
183
203
  function packageName(source) {
184
204
  const specifier = source.startsWith(NPM_SOURCE_PREFIX) ? source.slice(4) : source;
@@ -210,19 +230,23 @@ function defaultBundledCatalogPath() {
210
230
  * The first catalogue present: `PO_PACKAGE_CATALOG` (desktop's archives), then the one
211
231
  * a release bundles into the CLI. With neither, the runtime installs only what roots name.
212
232
  */
213
- function packageCatalogPath(environment) {
233
+ async function packageCatalogPath(environment) {
214
234
  const configured = environment[PACKAGE_CATALOG_ENV]?.trim();
215
235
  if (configured) return configured;
216
236
  const bundledCatalogPath = defaultBundledCatalogPath();
217
- return bundledCatalogPath !== void 0 && fs.existsSync(bundledCatalogPath) ? bundledCatalogPath : void 0;
237
+ if (bundledCatalogPath === void 0) return void 0;
238
+ return fs.access(bundledCatalogPath).then(() => bundledCatalogPath, (error) => {
239
+ if (error.code === "ENOENT") return void 0;
240
+ throw error;
241
+ });
218
242
  }
219
- function readPackageCatalog(manifestPath) {
243
+ async function readPackageCatalog(manifestPath) {
220
244
  if (!manifestPath) return EMPTY_CATALOG;
221
- const parsed = JSON.parse(fs.readFileSync(manifestPath, "utf8"));
222
- if (!isRecord$1(parsed) || parsed.version !== 1 || !isRecord$1(parsed.packages)) throw new Error(`Unsupported Po package catalog: ${manifestPath}`);
245
+ const parsed = JSON.parse(await fs.readFile(manifestPath, "utf8"));
246
+ if (!isRecord(parsed) || parsed.version !== 1 || !isRecord(parsed.packages)) throw new Error(`Unsupported Po package catalog: ${manifestPath}`);
223
247
  const packages = /* @__PURE__ */ new Map();
224
248
  for (const [name, value] of Object.entries(parsed.packages)) {
225
- if (!isRecord$1(value) || !Array.isArray(value.dependencies) || value.archive !== void 0 && typeof value.archive !== "string" || value.version !== void 0 && typeof value.version !== "string" || value.archive === void 0 && value.version === void 0) throw new Error(`Invalid package entry for ${name} in ${manifestPath}`);
249
+ if (!isRecord(value) || !Array.isArray(value.dependencies) || value.archive !== void 0 && typeof value.archive !== "string" || value.version !== void 0 && typeof value.version !== "string" || value.archive === void 0 && value.version === void 0) throw new Error(`Invalid package entry for ${name} in ${manifestPath}`);
226
250
  const dependencies = stringList(value.dependencies);
227
251
  if (!dependencies) throw new Error(`Invalid dependencies for ${name} in ${manifestPath}`);
228
252
  const version = typeof value.version === "string" ? value.version : void 0;
@@ -234,7 +258,10 @@ function readPackageCatalog(manifestPath) {
234
258
  continue;
235
259
  }
236
260
  const archive = path.resolve(path.dirname(manifestPath), value.archive);
237
- if (!fs.existsSync(archive)) throw new Error(`Po package catalog archive is missing: ${archive}`);
261
+ await fs.access(archive).catch((error) => {
262
+ if (error.code === "ENOENT") throw new Error(`Po package catalog archive is missing: ${archive}`);
263
+ throw error;
264
+ });
238
265
  packages.set(name, {
239
266
  archive,
240
267
  version,
@@ -250,12 +277,18 @@ function readPackageCatalog(manifestPath) {
250
277
  install
251
278
  };
252
279
  }
280
+ /** All distribution catalog names, or undefined when no authoritative catalog is available. */
281
+ async function catalogPackageNames(environment) {
282
+ const catalogPath = await packageCatalogPath(environment);
283
+ if (catalogPath === void 0) return void 0;
284
+ return new Set((await readPackageCatalog(catalogPath)).packages.keys());
285
+ }
253
286
  /**
254
287
  * The catalogue's `install` list as exact `name@version` specifiers for
255
288
  * `EnsureLayerPackagesOptions.specifiers`; empty when no catalogue is present.
256
289
  */
257
- function catalogInstallSpecifiers(environment = process.env) {
258
- const catalog = readPackageCatalog(packageCatalogPath(environment));
290
+ async function catalogInstallSpecifiers(environment = process.env) {
291
+ const catalog = await readPackageCatalog(await packageCatalogPath(environment));
259
292
  return catalog.install.map((name) => {
260
293
  const version = catalog.packages.get(name)?.version;
261
294
  return version ? `${name}@${version}` : name;
@@ -266,19 +299,19 @@ function catalogInstallSpecifiers(environment = process.env) {
266
299
  * resolves a bare name (its own node_modules, then the shared runtime). The global web build
267
300
  * covers them, so every first-party plugin has a slot; a name not installed yet is left out.
268
301
  */
269
- function catalogPackageRoots(globalRoot, environment = process.env) {
302
+ async function catalogPackageRoots(globalRoot, environment = process.env) {
270
303
  const roots = [];
271
- for (const name of readPackageCatalog(packageCatalogPath(environment)).install) {
304
+ for (const name of (await readPackageCatalog(await packageCatalogPath(environment))).install) {
272
305
  const manifest = consumerPackageEntry(`${name}/${PACKAGE_MANIFEST}`, globalRoot, environment);
273
- if (manifest !== void 0) roots.push(path.dirname(fs.realpathSync(manifest)));
306
+ if (manifest !== void 0) roots.push(path.dirname(await fs.realpath(manifest)));
274
307
  }
275
308
  return roots;
276
309
  }
277
310
  /** SHA-256 of the catalogue file in use, or `none` when no catalogue is present. */
278
- function packageCatalogHash(environment = process.env) {
279
- const catalogPath = packageCatalogPath(environment);
311
+ async function packageCatalogHash(environment = process.env) {
312
+ const catalogPath = await packageCatalogPath(environment);
280
313
  if (!catalogPath) return "none";
281
- return crypto.createHash("sha256").update(fs.readFileSync(catalogPath)).digest("hex");
314
+ return crypto.createHash("sha256").update(await fs.readFile(catalogPath)).digest("hex");
282
315
  }
283
316
  /** Exact target per catalogue name: its staged workspace for an archive, else its registry version. */
284
317
  function catalogTargets(catalog) {
@@ -321,8 +354,8 @@ function paxPath(data) {
321
354
  * directory (`package/`) as npm does. Only files and directories are written: npm package
322
355
  * archives carry no links, and an entry that would land outside `destination` is refused.
323
356
  */
324
- function extractPackageArchive(archive, destination) {
325
- const data = zlib.gunzipSync(fs.readFileSync(archive));
357
+ async function extractPackageArchive(archive, destination) {
358
+ const data = zlib.gunzipSync(await fs.readFile(archive));
326
359
  let offset = 0;
327
360
  let nextPath;
328
361
  while (offset + TAR_BLOCK_SIZE <= data.length) {
@@ -346,12 +379,12 @@ function extractPackageArchive(archive, destination) {
346
379
  const target = path.resolve(destination, relative);
347
380
  if (!target.startsWith(`${destination}${path.sep}`)) throw new Error(`Po package catalog archive ${archive} has an entry outside the package: ${name}`);
348
381
  if (type === "5") {
349
- fs.mkdirSync(target, { recursive: true });
382
+ await fs.mkdir(target, { recursive: true });
350
383
  continue;
351
384
  }
352
- fs.mkdirSync(path.dirname(target), { recursive: true });
385
+ await fs.mkdir(path.dirname(target), { recursive: true });
353
386
  const executable = (tarNumber(header, 100, 8) & TAR_EXECUTABLE_BITS) !== 0;
354
- fs.writeFileSync(target, body, { mode: executable ? 493 : 420 });
387
+ await fs.writeFile(target, body, { mode: executable ? 493 : 420 });
355
388
  }
356
389
  }
357
390
  /** Dependency fields of a staged manifest that may name another catalogue package. */
@@ -371,40 +404,49 @@ const STAGED_DEPENDENCY_FIELDS = [
371
404
  * workspace would otherwise install, are dropped. The hash covers the archive bytes and the
372
405
  * catalogue's archive names, everything that rewrite reads, so a staged directory is reused.
373
406
  */
374
- function stageCatalogArchive(runtimeDirectory, archive, archiveNames) {
375
- const hash = crypto.createHash("sha256").update(fs.readFileSync(archive)).update(`\0${[...archiveNames].sort().join("\n")}`).digest("hex");
407
+ async function stageCatalogArchive(runtimeDirectory, archive, archiveNames, nonce = "") {
408
+ const hash = crypto.createHash("sha256").update(await fs.readFile(archive)).update(`\0${[...archiveNames].sort().join("\n")}`).update(nonce).digest("hex");
376
409
  const relative = `${CATALOG_STAGING_DIRECTORY}/${hash}`;
377
410
  const directory = path.join(runtimeDirectory, CATALOG_STAGING_DIRECTORY, hash);
378
411
  const stagedManifest = path.join(directory, PACKAGE_MANIFEST);
379
- if (!fs.existsSync(stagedManifest)) {
412
+ const existing = await fs.readFile(stagedManifest, "utf8").catch((error) => {
413
+ if (error.code === "ENOENT") return void 0;
414
+ throw error;
415
+ });
416
+ if (existing === void 0) {
380
417
  const temporary = `${directory}.${String(process.pid)}.${crypto.randomUUID()}.tmp`;
381
418
  try {
382
- extractPackageArchive(archive, temporary);
419
+ await extractPackageArchive(archive, temporary);
383
420
  const manifestPath = path.join(temporary, PACKAGE_MANIFEST);
384
- if (!fs.existsSync(manifestPath)) throw new Error(`Po package catalog archive has no package.json: ${archive}`);
385
- const manifest = JSON.parse(fs.readFileSync(manifestPath, "utf8"));
386
- if (!isRecord$1(manifest)) throw new Error(`Po package catalog archive has an invalid package.json: ${archive}`);
421
+ const bytes = await fs.readFile(manifestPath, "utf8").catch((error) => {
422
+ if (error.code === "ENOENT") throw new Error(`Po package catalog archive has no package.json: ${archive}`);
423
+ throw error;
424
+ });
425
+ const manifest = JSON.parse(bytes);
426
+ if (!isRecord(manifest)) throw new Error(`Po package catalog archive has an invalid package.json: ${archive}`);
387
427
  delete manifest.devDependencies;
388
428
  for (const field of STAGED_DEPENDENCY_FIELDS) {
389
- if (!isRecord$1(manifest[field])) continue;
429
+ if (!isRecord(manifest[field])) continue;
390
430
  const declared = { ...manifest[field] };
391
431
  for (const name of Object.keys(declared)) if (archiveNames.has(name)) declared[name] = CATALOG_WORKSPACE_TARGET;
392
432
  manifest[field] = declared;
393
433
  }
394
- fs.writeFileSync(manifestPath, `${JSON.stringify(manifest, null, 2)}\n`);
434
+ await fs.writeFile(manifestPath, `${JSON.stringify(manifest, null, 2)}\n`);
395
435
  try {
396
- fs.renameSync(temporary, directory);
436
+ await fs.rename(temporary, directory);
397
437
  } catch (error) {
398
- if (!fs.existsSync(stagedManifest)) throw error;
438
+ await fs.access(stagedManifest).catch(() => {
439
+ throw error;
440
+ });
399
441
  }
400
442
  } finally {
401
- fs.rmSync(temporary, {
443
+ await fs.rm(temporary, {
402
444
  recursive: true,
403
445
  force: true
404
446
  });
405
447
  }
406
448
  }
407
- const staged = recordValue(JSON.parse(fs.readFileSync(stagedManifest, "utf8")));
449
+ const staged = recordValue(JSON.parse(existing ?? await fs.readFile(stagedManifest, "utf8")));
408
450
  return {
409
451
  relative,
410
452
  dependencies: STAGED_DEPENDENCY_FIELDS.flatMap((field) => Object.keys(recordValue(staged[field]))).filter((name) => archiveNames.has(name))
@@ -415,14 +457,14 @@ function stageCatalogArchive(runtimeDirectory, archive, archiveNames) {
415
457
  * name in turn, since a staged manifest's `workspace:*` needs that workspace present. The
416
458
  * result, name to staged directory, feeds `ensureManagedPackageManifest`.
417
459
  */
418
- function stageCatalogArchives(runtimeDirectory, catalog, names) {
460
+ async function stageCatalogArchives(runtimeDirectory, catalog, names) {
419
461
  const archiveNames = new Set([...catalog.packages].flatMap(([name, entry]) => entry.archive === void 0 ? [] : [name]));
420
462
  const staged = {};
421
463
  const pending = [...names].filter((name) => archiveNames.has(name));
422
464
  while (pending.length > 0) {
423
465
  const name = pending.shift();
424
466
  if (Object.hasOwn(staged, name)) continue;
425
- const { relative, dependencies } = stageCatalogArchive(runtimeDirectory, catalog.packages.get(name).archive, archiveNames);
467
+ const { relative, dependencies } = await stageCatalogArchive(runtimeDirectory, catalog.packages.get(name).archive, archiveNames, catalog.packages.get(name).stagingNonce);
426
468
  staged[name] = relative;
427
469
  pending.push(...dependencies);
428
470
  }
@@ -433,18 +475,21 @@ function stageCatalogArchives(runtimeDirectory, catalog, names) {
433
475
  * folder names. An install never calls this: a running server imports from these folders (its
434
476
  * `.po-snapshots` live there), so sync prunes them under the same gate as the runtime store.
435
477
  */
436
- function pruneStagedCatalogArchives(runtimeDirectory) {
478
+ async function pruneStagedCatalogArchives(runtimeDirectory) {
437
479
  const stagingDirectory = path.join(runtimeDirectory, CATALOG_STAGING_DIRECTORY);
438
- if (!fs.existsSync(stagingDirectory)) return [];
439
- const { manifest } = readRuntimeManifest(path.join(runtimeDirectory, PACKAGE_MANIFEST));
480
+ const entries = await fs.readdir(stagingDirectory).catch((error) => {
481
+ if (error.code === "ENOENT") return [];
482
+ throw error;
483
+ });
484
+ const { manifest } = await readRuntimeManifest(path.join(runtimeDirectory, PACKAGE_MANIFEST));
440
485
  const kept = new Set((stringList(manifest.workspaces) ?? []).map((relative) => path.basename(relative)));
441
- return fs.readdirSync(stagingDirectory).filter((entry) => !kept.has(entry)).map((entry) => {
442
- fs.rmSync(path.join(stagingDirectory, entry), {
486
+ return Promise.all(entries.filter((entry) => !kept.has(entry)).map(async (entry) => {
487
+ await fs.rm(path.join(stagingDirectory, entry), {
443
488
  recursive: true,
444
489
  force: true
445
490
  });
446
491
  return entry;
447
- });
492
+ }));
448
493
  }
449
494
  /** Splits `name@version` (scoped or not); the version is absent for a bare name or subpath. */
450
495
  function splitVersionedSpecifier(specifier) {
@@ -465,16 +510,13 @@ function npmSources(specifiers, catalog, targets, includeCatalogDependencies = f
465
510
  return `${NPM_SOURCE_PREFIX}${name}${target ? `@${target}` : ""}`;
466
511
  });
467
512
  }
468
- function pluralize(count, noun) {
469
- return `${count} ${noun}${count === 1 ? "" : "s"}`;
470
- }
513
+ const englishProgress = (_key, fallback, vars) => formatMessage(fallback, vars);
471
514
  /** Version of a package inside the shared runtime, absent when Po did not install it there. */
472
- function managedPackageVersion(runtimeDirectory, name) {
515
+ async function managedPackageVersion(runtimeDirectory, name) {
473
516
  const manifestPath = path.join(runtimeDirectory, NODE_MODULES, name, PACKAGE_MANIFEST);
474
- if (!fs.existsSync(manifestPath)) return void 0;
475
517
  try {
476
- const parsed = JSON.parse(fs.readFileSync(manifestPath, "utf8"));
477
- return isRecord$1(parsed) && typeof parsed.version === "string" ? parsed.version : void 0;
518
+ const parsed = JSON.parse(await fs.readFile(manifestPath, "utf8"));
519
+ return isRecord(parsed) && typeof parsed.version === "string" ? parsed.version : void 0;
478
520
  } catch {
479
521
  return;
480
522
  }
@@ -486,13 +528,13 @@ function errorCode(error) {
486
528
  * Installs the runtime, and when the registry cannot be reached installs it again offline:
487
529
  * an unchanged lockfile whose packages the store already holds needs no network.
488
530
  */
489
- async function installWithOfflineRetry(install, options, onProgress) {
531
+ async function installWithOfflineRetry(install, options, onProgress, t = englishProgress) {
490
532
  try {
491
533
  await install(options);
492
534
  } catch (error) {
493
535
  const code = errorCode(error);
494
536
  if (typeof code !== "string" || !NETWORK_FAILURE_CODES.has(code)) throw error;
495
- onProgress?.(`the registry is unreachable (${code}); installing offline from the store`);
537
+ onProgress?.(t("cli.sync.install.registryOffline", "the registry is unreachable ({code}); installing offline from the store", { code }));
496
538
  try {
497
539
  await install({
498
540
  ...options,
@@ -511,11 +553,11 @@ async function installWithOfflineRetry(install, options, onProgress) {
511
553
  * repository's own modules is not sync's to move, and a package that is not
512
554
  * installed yet is already covered by the missing-package path.
513
555
  */
514
- async function resolveUpdates(runtimeDirectory, sources, publishedVersion, onProgress) {
515
- const managed = sources.map((source) => ({
556
+ async function resolveUpdates(runtimeDirectory, sources, publishedVersion, onProgress, t = englishProgress) {
557
+ const managed = (await Promise.all(sources.map(async (source) => ({
516
558
  name: packageName(source),
517
- from: managedPackageVersion(runtimeDirectory, packageName(source))
518
- })).filter((entry) => entry.from !== void 0);
559
+ from: await managedPackageVersion(runtimeDirectory, packageName(source))
560
+ })))).filter((entry) => entry.from !== void 0);
519
561
  const checked = await Promise.all(managed.map(async (entry) => {
520
562
  try {
521
563
  return {
@@ -534,7 +576,11 @@ async function resolveUpdates(runtimeDirectory, sources, publishedVersion, onPro
534
576
  for (const entry of checked) {
535
577
  if (entry.to === void 0) {
536
578
  unchecked.push(entry.name);
537
- onProgress?.(`kept ${entry.name} ${entry.from}: ${entry.failure ?? "no published version"}`);
579
+ onProgress?.(t("cli.sync.install.keptVersion", "kept {name} {version}: {reason}", {
580
+ name: entry.name,
581
+ version: entry.from,
582
+ reason: entry.failure ?? t("cli.sync.install.noPublishedVersion", "no published version")
583
+ }));
538
584
  continue;
539
585
  }
540
586
  if (entry.to === entry.from) continue;
@@ -568,11 +614,12 @@ async function ensureLayerPackages(options, dependencies = {}) {
568
614
  const homeDirectory = environment.HOME ?? os.homedir();
569
615
  const poHome = poHomeDirectory(homeDirectory, environment);
570
616
  const runtimeDirectory = poRuntimeDirectory(homeDirectory, environment);
617
+ const npmrcFiles = [path.join(options.repoRoot, ".npmrc")];
571
618
  const resolvers = dependencies.resolvers ?? createLayerResolvers(options.repoRoot, environment);
572
- const external = (specifier) => testPackageRoot(packageName(specifier), environment) === void 0;
619
+ const external = (specifier) => checkoutPackageRoot(packageName(specifier), environment) === void 0;
573
620
  const configured = configuredPackageSpecifiers(options.config, options.layers).filter(external);
574
621
  const missing = configured.filter((specifier) => resolvePackageEntries(resolvers, specifier) === void 0);
575
- const declared = declaredRuntimePackages(runtimeDirectory);
622
+ const declared = await declaredRuntimePackages(runtimeDirectory);
576
623
  const managed = configured.filter((specifier) => missing.includes(specifier) || declared.has(splitPackageSpecifier(specifier).name));
577
624
  const requested = (options.specifiers ?? []).filter(external).map(splitVersionedSpecifier);
578
625
  if (managed.length === 0 && requested.length === 0 && options.exactManifest !== true) return {
@@ -580,15 +627,16 @@ async function ensureLayerPackages(options, dependencies = {}) {
580
627
  updated: [],
581
628
  unchecked: []
582
629
  };
583
- const catalog = readPackageCatalog(packageCatalogPath(environment));
630
+ const catalog = dependencies.catalog ?? await readPackageCatalog(await packageCatalogPath(environment));
584
631
  const pins = catalogTargets(catalog);
585
632
  for (const { name, version } of requested) if (version !== void 0 && catalog.packages.get(name)?.archive === void 0) pins.set(name, version);
586
- const requestedMissing = requested.filter(({ name, version }) => {
587
- const installed = managedPackageVersion(runtimeDirectory, name);
633
+ const requestedMissing = [];
634
+ for (const { name, version } of requested) {
635
+ const installed = await managedPackageVersion(runtimeDirectory, name);
588
636
  const entry = catalog.packages.get(name);
589
637
  const expected = entry?.archive === void 0 ? version : entry.version;
590
- return installed === void 0 || expected !== void 0 && installed !== expected;
591
- }).map(({ name }) => name);
638
+ if (installed === void 0 || expected !== void 0 && installed !== expected) requestedMissing.push(name);
639
+ }
592
640
  const missingSources = npmSources([...missing, ...requestedMissing], catalog, pins);
593
641
  const sources = npmSources([...managed, ...requested.map(({ name }) => name)], catalog, pins, true).filter(external);
594
642
  const missingCount = missing.length + requestedMissing.length;
@@ -596,8 +644,10 @@ async function ensureLayerPackages(options, dependencies = {}) {
596
644
  const registrySources = sources.filter((source) => !fixedNames.has(packageName(source)));
597
645
  const { updated, unchecked } = options.refresh ? await resolveUpdates(runtimeDirectory, registrySources, dependencies.publishedVersion ?? ((name) => resolveNewest(name, {
598
646
  dir: runtimeDirectory,
599
- poHome
600
- })), options.onProgress) : {
647
+ poHome,
648
+ npmrcFiles,
649
+ environment
650
+ })), options.onProgress, options.translateProgress) : {
601
651
  updated: [],
602
652
  unchecked: []
603
653
  };
@@ -606,22 +656,26 @@ async function ensureLayerPackages(options, dependencies = {}) {
606
656
  return target ? [[packageName(source), target]] : [];
607
657
  }));
608
658
  for (const update of updated) targets.set(update.name, update.to);
609
- const manifestChanged = ensureManagedPackageManifest(runtimeDirectory, sources, targets, stageCatalogArchives(runtimeDirectory, catalog, /* @__PURE__ */ new Set([...sources.map(packageName), ...options.exactManifest === true ? [] : declared])), options.exactManifest === true);
659
+ const manifestChanged = await ensureManagedPackageManifest(runtimeDirectory, sources, targets, await stageCatalogArchives(runtimeDirectory, catalog, /* @__PURE__ */ new Set([...sources.map(packageName), ...options.exactManifest === true ? [] : declared])), options.exactManifest === true, options.preserveWorkspaces === true);
610
660
  if (missingCount === 0 && !manifestChanged) return {
611
661
  installed: [],
612
662
  updated: [],
613
663
  unchecked
614
664
  };
615
- options.onProgress?.(`installing ${updated.length > 0 ? pluralize(updated.length, "update") : missingCount > 0 ? pluralize(missingCount, "missing package") : "the package manifest"}`);
665
+ const t = options.translateProgress ?? englishProgress;
666
+ const updates = updated.length;
667
+ options.onProgress?.(updates > 0 ? updates === 1 ? t("cli.sync.install.updateOne", "installing {count} update", { count: updates }) : t("cli.sync.install.updateMany", "installing {count} updates", { count: updates }) : missingCount > 0 ? missingCount === 1 ? t("cli.sync.install.missingOne", "installing {count} missing package", { count: missingCount }) : t("cli.sync.install.missingMany", "installing {count} missing packages", { count: missingCount }) : t("cli.sync.install.manifest", "installing the package manifest"));
616
668
  try {
617
669
  await installWithOfflineRetry(dependencies.install ?? installRuntimePackages, {
618
670
  dir: runtimeDirectory,
619
671
  poHome,
672
+ npmrcFiles,
673
+ environment,
620
674
  preferOffline: options.refresh !== true,
621
675
  log: (message, level) => {
622
676
  if (level === "warn") options.onProgress?.(message);
623
677
  }
624
- }, options.onProgress);
678
+ }, options.onProgress, t);
625
679
  } catch (error) {
626
680
  throw new Error(`Failed to reconcile Po layer package(s): ${(manifestChanged ? sources : missingSources).join(", ")}: ${error instanceof Error ? error.message : String(error)}`, { cause: error });
627
681
  }
@@ -633,7 +687,154 @@ async function ensureLayerPackages(options, dependencies = {}) {
633
687
  unchecked
634
688
  };
635
689
  }
690
+ /** One selector per name in the shared runtime. Caller holds the sync lock throughout. */
691
+ async function ensureRuntimeImportPackage(name, version, options) {
692
+ const environment = {
693
+ ...options.environment,
694
+ HOME: options.homeDirectory
695
+ };
696
+ const poHome = poHomeDirectory(options.homeDirectory, environment);
697
+ const directory = poRuntimeDirectory(options.homeDirectory, environment);
698
+ const manifestPath = path.join(directory, PACKAGE_MANIFEST);
699
+ const { manifest } = await readRuntimeManifest(manifestPath);
700
+ const declared = recordValue(manifest.dependencies);
701
+ const imports = recordValue(manifest.poCodemodeDependencies);
702
+ const imported = recordValue(imports[name]);
703
+ const catalog = await readPackageCatalog(await packageCatalogPath(environment));
704
+ if (catalog.packages.has(name) || Object.hasOwn(declared, name) && declared[name] !== imported.selector) throw new Error(`Cannot import ${name}: Po manages this runtime dependency (${JSON.stringify(declared[name] ?? "catalogue")}).`);
705
+ if (Object.hasOwn(imports, name) && imported.selector !== version) throw new Error(`Cannot import ${name}@${version}: the hub already uses ${name}@${String(imported.selector)}.`);
706
+ const installed = await managedPackageVersion(directory, name);
707
+ if (declared[name] === version && installed !== void 0 && imported.resolved === installed) return;
708
+ manifest.poCodemodeDependencies = {
709
+ ...imports,
710
+ [name]: { selector: version }
711
+ };
712
+ await writeFileAtomic(createNodePlatform().env(directory), manifestPath, `${JSON.stringify(manifest, null, 2)}\n`, BACKGROUND_CONTEXT);
713
+ const pins = /* @__PURE__ */ new Map([[name, version]]);
714
+ const sources = npmSources([`${name}@${version}`], catalog, pins, true);
715
+ await ensureManagedPackageManifest(directory, sources, pins, await stageCatalogArchives(directory, catalog, /* @__PURE__ */ new Set([...sources.map(packageName), ...Object.keys(declared)])));
716
+ await installWithOfflineRetry(installRuntimePackages, {
717
+ dir: directory,
718
+ poHome,
719
+ environment,
720
+ preferOffline: true
721
+ }, void 0);
722
+ const resolved = await managedPackageVersion(directory, name);
723
+ if (resolved === void 0) throw new Error(`Runtime import ${name}@${version} was not installed.`);
724
+ const reconciled = (await readRuntimeManifest(manifestPath)).manifest;
725
+ reconciled.poCodemodeDependencies = {
726
+ ...recordValue(reconciled.poCodemodeDependencies),
727
+ [name]: {
728
+ selector: version,
729
+ resolved
730
+ }
731
+ };
732
+ await writeFileAtomic(createNodePlatform().env(directory), manifestPath, `${JSON.stringify(reconciled, null, 2)}\n`, BACKGROUND_CONTEXT);
733
+ }
734
+ /**
735
+ * Only the CLI's own catalog is authoritative for marketplace installs: the one a release
736
+ * bundles, else the one a checkout build writes at the package root.
737
+ */
738
+ async function readCuratedCatalog(fs, packageRoot) {
739
+ let root = packageRoot;
740
+ try {
741
+ root ??= poPackageRoot();
742
+ } catch (error) {
743
+ throw new Error(NO_CURATED_CATALOG, { cause: error });
744
+ }
745
+ const text = await readTextIfExists(fs, path.join(root, ...BUNDLED_CATALOG_SEGMENTS), BACKGROUND_CONTEXT) ?? await readTextIfExists(fs, path.join(root, CHECKOUT_CATALOG_FILE), BACKGROUND_CONTEXT);
746
+ if (text === void 0) throw new Error(NO_CURATED_CATALOG);
747
+ return JSON.parse(text);
748
+ }
749
+ /** Capture before ensureLayerPackages changes the shared manifest or lockfile. Caller holds withSyncLock. */
750
+ async function stageRuntimeManifest(fs, directory) {
751
+ const files = await Promise.all(["package.json", "upm.lock"].map(async (name) => {
752
+ const file = path.join(directory, name);
753
+ return {
754
+ file,
755
+ text: await readTextIfExists(fs, file, BACKGROUND_CONTEXT)
756
+ };
757
+ }));
758
+ return async () => {
759
+ for (const { file, text } of files) if (text === void 0) getOrThrow(await fs.remove(file, { force: true }, BACKGROUND_CONTEXT));
760
+ else await writeFileAtomic(fs, file, text, BACKGROUND_CONTEXT);
761
+ };
762
+ }
763
+ /** Shared verified extraction seam. It never installs dependencies or imports package code. */
764
+ async function stageCuratedArchive(options, directory, pin, bytes, archiveNames) {
765
+ const hash = crypto.createHash("sha256").update(bytes).digest("hex");
766
+ if (pin.privateArchive) {
767
+ if (hash !== pin.privateArchive.sha256) throw new Error("Organization plugin archive digest mismatch.");
768
+ const compiledWasm = pin.privateArchive.compiledWasm;
769
+ await verifiedArchiveFiles(bytes, pin.integrity, compiledWasm?.length ? { compiledWasm: {
770
+ paths: compiledWasm,
771
+ fileBytes: 33554432
772
+ } } : void 0);
773
+ }
774
+ const archive = path.join(directory, pin.privateArchive ? "org-library" : "marketplace", `${hash}.tgz`);
775
+ getOrThrow(await options.fs.createDir(path.dirname(archive), { recursive: true }, BACKGROUND_CONTEXT));
776
+ await writeFileAtomic(options.fs, archive, bytes, BACKGROUND_CONTEXT);
777
+ const stagingNonce = pin.registry !== void 0 || pin.privateArchive !== void 0 ? crypto.randomUUID() : void 0;
778
+ const staged = await stageCatalogArchive(directory, archive, archiveNames, stagingNonce);
779
+ const manifest = JSON.parse(getOrThrow(await options.fs.readTextFile(path.join(directory, staged.relative, PACKAGE_MANIFEST), BACKGROUND_CONTEXT)));
780
+ if (manifest.name !== pin.name || manifest.version !== pin.version) throw new Error(`Catalog target mismatch for ${pin.name}@${pin.version}.`);
781
+ return {
782
+ directory: path.join(directory, staged.relative),
783
+ entry: {
784
+ archive,
785
+ version: pin.version,
786
+ dependencies: [],
787
+ stagingNonce
788
+ }
789
+ };
790
+ }
791
+ /** Private host-admitted bytes only, with no registry, package manager, or executable verification. */
792
+ async function stagePrivateOrgPackage(options) {
793
+ if (options.pin.registry !== void 0) throw new Error("Private archives cannot select a registry.");
794
+ return (await stageCuratedArchive(options, poRuntimeDirectory(options.homeDirectory, options.environment), options.pin, await options.pin.privateArchive.read(), /* @__PURE__ */ new Set([options.pin.name]))).directory;
795
+ }
796
+ /** Verify bytes before extraction or upm sees them. Registry URLs are derived, never catalog or client URLs. */
797
+ async function installCuratedPackages(options) {
798
+ const environment = {
799
+ ...options.environment,
800
+ HOME: options.homeDirectory,
801
+ PO_HOME: poHomeDirectory(options.homeDirectory, options.environment)
802
+ };
803
+ const directory = poRuntimeDirectory(options.homeDirectory, environment);
804
+ options.signal.throwIfAborted();
805
+ const declared = await declaredRuntimePackages(directory);
806
+ if ((await Promise.all(options.packages.map(async ({ name, version, registry, privateArchive }) => registry === void 0 && privateArchive === void 0 && (checkoutPackageRoot(name, environment) !== void 0 || declared.has(name) && await managedPackageVersion(directory, name) === version)))).every(Boolean)) return;
807
+ const packages = /* @__PURE__ */ new Map();
808
+ for (const pin of options.packages) {
809
+ options.signal.throwIfAborted();
810
+ const bytes = pin.privateArchive ? await pin.privateArchive.read() : (await fetchVerifiedPluginArchive({
811
+ ...pin,
812
+ registry: pin.registry ?? "https://registry.npmjs.org",
813
+ fetch: options.fetch,
814
+ signal: options.signal
815
+ })).bytes;
816
+ options.signal.throwIfAborted();
817
+ const staged = await stageCuratedArchive(options, directory, pin, bytes, new Set(options.packages.map(({ name }) => name)));
818
+ packages.set(pin.name, staged.entry);
819
+ }
820
+ options.signal.throwIfAborted();
821
+ await ensureLayerPackages({
822
+ repoRoot: options.repoRoot,
823
+ environment,
824
+ config: {
825
+ defaultPreset: "marketplace",
826
+ preset: {},
827
+ layers: {}
828
+ },
829
+ layers: [],
830
+ preserveWorkspaces: true,
831
+ specifiers: options.packages.map(({ name, version }) => `${name}@${version}`)
832
+ }, { catalog: {
833
+ packages,
834
+ install: []
835
+ } });
836
+ }
636
837
  //#endregion
637
- export { SAFE_TRANSITIVE_OVERRIDES, catalogInstallSpecifiers, catalogPackageRoots, ensureLayerPackages, ensureManagedPackageManifest, missingLayerPackageSpecifiers, packageCatalogHash, pruneStagedCatalogArchives, runtimeLayerPackageSpecifiers };
838
+ export { SAFE_TRANSITIVE_OVERRIDES, catalogInstallSpecifiers, catalogPackageNames, catalogPackageRoots, ensureLayerPackages, ensureManagedPackageManifest, ensureRuntimeImportPackage, installCuratedPackages, missingLayerPackageSpecifiers, packageCatalogHash, pruneStagedCatalogArchives, readCuratedCatalog, runtimeLayerPackageSpecifiers, stagePrivateOrgPackage, stageRuntimeManifest };
638
839
 
639
840
  //# sourceMappingURL=index.mjs.map