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

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 (631) 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/locales/vi.cjs +218 -0
  51. package/dist/locales/vi.cjs.map +1 -0
  52. package/dist/locales/vi.mjs +213 -0
  53. package/dist/locales/vi.mjs.map +1 -0
  54. package/dist/locales/zh-CN.cjs +218 -0
  55. package/dist/locales/zh-CN.cjs.map +1 -0
  56. package/dist/locales/zh-CN.mjs +213 -0
  57. package/dist/locales/zh-CN.mjs.map +1 -0
  58. package/dist/matrixOptions.cjs +10 -5
  59. package/dist/matrixOptions.d.mts +2 -2
  60. package/dist/matrixOptions.mjs +1 -1
  61. package/dist/package.cjs +11 -0
  62. package/dist/package.cjs.map +1 -0
  63. package/dist/package.mjs +6 -0
  64. package/dist/package.mjs.map +1 -0
  65. package/dist/projectTrust.cjs +3 -0
  66. package/dist/projectTrust.d.mts +2 -2
  67. package/dist/projectTrust.mjs +1 -1
  68. package/dist/repository.cjs +1 -0
  69. package/dist/repository.d.mts +2 -2
  70. package/dist/repository.mjs +1 -1
  71. package/dist/services.cjs +5 -20
  72. package/dist/services.d.mts +3 -8
  73. package/dist/services.mjs +3 -8
  74. package/dist/shared.cjs +4 -17
  75. package/dist/shared.d.mts +2 -2
  76. package/dist/shared.mjs +1 -1
  77. package/dist/src/bin/agentDirectory.cjs +19 -15
  78. package/dist/src/bin/agentDirectory.cjs.map +1 -1
  79. package/dist/src/bin/agentDirectory.mjs +16 -13
  80. package/dist/src/bin/agentDirectory.mjs.map +1 -1
  81. package/dist/src/builders/apiContractExport/index.cjs +23 -22
  82. package/dist/src/builders/apiContractExport/index.cjs.map +1 -1
  83. package/dist/src/builders/apiContractExport/index.mjs +22 -21
  84. package/dist/src/builders/apiContractExport/index.mjs.map +1 -1
  85. package/dist/src/builders/cli/entryResolution.cjs +2 -2
  86. package/dist/src/builders/cli/entryResolution.cjs.map +1 -1
  87. package/dist/src/builders/cli/entryResolution.mjs +1 -1
  88. package/dist/src/builders/cli/entryResolution.mjs.map +1 -1
  89. package/dist/src/builders/cli/harnessContext.cjs +38 -43
  90. package/dist/src/builders/cli/harnessContext.cjs.map +1 -1
  91. package/dist/src/builders/cli/harnessContext.d.mts +11 -10
  92. package/dist/src/builders/cli/harnessContext.d.mts.map +1 -1
  93. package/dist/src/builders/cli/harnessContext.mjs +37 -41
  94. package/dist/src/builders/cli/harnessContext.mjs.map +1 -1
  95. package/dist/src/builders/cli/sessionComposition.cjs +23 -12
  96. package/dist/src/builders/cli/sessionComposition.cjs.map +1 -1
  97. package/dist/src/builders/cli/sessionComposition.mjs +23 -12
  98. package/dist/src/builders/cli/sessionComposition.mjs.map +1 -1
  99. package/dist/src/builders/isolate/compile.cjs +226 -0
  100. package/dist/src/builders/isolate/compile.cjs.map +1 -0
  101. package/dist/src/builders/isolate/compile.mjs +222 -0
  102. package/dist/src/builders/isolate/compile.mjs.map +1 -0
  103. package/dist/src/builders/isolate/index.cjs +195 -0
  104. package/dist/src/builders/isolate/index.cjs.map +1 -0
  105. package/dist/src/builders/isolate/index.mjs +192 -0
  106. package/dist/src/builders/isolate/index.mjs.map +1 -0
  107. package/dist/src/builders/isolate/membrane.cjs +198 -0
  108. package/dist/src/builders/isolate/membrane.cjs.map +1 -0
  109. package/dist/src/builders/isolate/membrane.mjs +198 -0
  110. package/dist/src/builders/isolate/membrane.mjs.map +1 -0
  111. package/dist/src/builders/isolate/names.cjs +10 -0
  112. package/dist/src/builders/isolate/names.cjs.map +1 -0
  113. package/dist/src/builders/isolate/names.mjs +9 -0
  114. package/dist/src/builders/isolate/names.mjs.map +1 -0
  115. package/dist/src/builders/native/index.cjs +229 -67
  116. package/dist/src/builders/native/index.cjs.map +1 -1
  117. package/dist/src/builders/native/index.d.mts +4 -2
  118. package/dist/src/builders/native/index.d.mts.map +1 -1
  119. package/dist/src/builders/native/index.mjs +229 -68
  120. package/dist/src/builders/native/index.mjs.map +1 -1
  121. package/dist/src/builders/npm/index.cjs +76 -0
  122. package/dist/src/builders/npm/index.cjs.map +1 -0
  123. package/dist/src/builders/npm/index.mjs +73 -0
  124. package/dist/src/builders/npm/index.mjs.map +1 -0
  125. package/dist/src/builders/server/backgroundSync.cjs +62 -39
  126. package/dist/src/builders/server/backgroundSync.cjs.map +1 -1
  127. package/dist/src/builders/server/backgroundSync.mjs +62 -38
  128. package/dist/src/builders/server/backgroundSync.mjs.map +1 -1
  129. package/dist/src/builders/server/bundlerService.cjs +165 -35
  130. package/dist/src/builders/server/bundlerService.cjs.map +1 -1
  131. package/dist/src/builders/server/bundlerService.mjs +164 -36
  132. package/dist/src/builders/server/bundlerService.mjs.map +1 -1
  133. package/dist/src/builders/server/capabilities.cjs +103 -0
  134. package/dist/src/builders/server/capabilities.cjs.map +1 -0
  135. package/dist/src/builders/server/capabilities.mjs +101 -0
  136. package/dist/src/builders/server/capabilities.mjs.map +1 -0
  137. package/dist/src/builders/server/computerUseBinding.cjs +62 -10
  138. package/dist/src/builders/server/computerUseBinding.cjs.map +1 -1
  139. package/dist/src/builders/server/computerUseBinding.mjs +60 -8
  140. package/dist/src/builders/server/computerUseBinding.mjs.map +1 -1
  141. package/dist/src/builders/server/computerUseRecordings.cjs +152 -51
  142. package/dist/src/builders/server/computerUseRecordings.cjs.map +1 -1
  143. package/dist/src/builders/server/computerUseRecordings.mjs +158 -59
  144. package/dist/src/builders/server/computerUseRecordings.mjs.map +1 -1
  145. package/dist/src/builders/server/containedSessions.cjs +152 -0
  146. package/dist/src/builders/server/containedSessions.cjs.map +1 -0
  147. package/dist/src/builders/server/containedSessions.mjs +146 -0
  148. package/dist/src/builders/server/containedSessions.mjs.map +1 -0
  149. package/dist/src/builders/server/defaultWorkspace.cjs +46 -11
  150. package/dist/src/builders/server/defaultWorkspace.cjs.map +1 -1
  151. package/dist/src/builders/server/defaultWorkspace.mjs +42 -10
  152. package/dist/src/builders/server/defaultWorkspace.mjs.map +1 -1
  153. package/dist/src/builders/server/electronBinding.cjs +82 -0
  154. package/dist/src/builders/server/electronBinding.cjs.map +1 -0
  155. package/dist/src/builders/server/electronBinding.mjs +82 -0
  156. package/dist/src/builders/server/electronBinding.mjs.map +1 -0
  157. package/dist/src/builders/server/federation.cjs +364 -0
  158. package/dist/src/builders/server/federation.cjs.map +1 -0
  159. package/dist/src/builders/server/federation.mjs +363 -0
  160. package/dist/src/builders/server/federation.mjs.map +1 -0
  161. package/dist/src/builders/server/hostDisplayName.cjs +14 -0
  162. package/dist/src/builders/server/hostDisplayName.cjs.map +1 -0
  163. package/dist/src/builders/server/hostDisplayName.mjs +14 -0
  164. package/dist/src/builders/server/hostDisplayName.mjs.map +1 -0
  165. package/dist/src/builders/server/hostModelGateway.cjs +41 -0
  166. package/dist/src/builders/server/hostModelGateway.cjs.map +1 -0
  167. package/dist/src/builders/server/hostModelGateway.mjs +39 -0
  168. package/dist/src/builders/server/hostModelGateway.mjs.map +1 -0
  169. package/dist/src/builders/server/hostTeam.cjs +188 -0
  170. package/dist/src/builders/server/hostTeam.cjs.map +1 -0
  171. package/dist/src/builders/server/hostTeam.mjs +180 -0
  172. package/dist/src/builders/server/hostTeam.mjs.map +1 -0
  173. package/dist/src/builders/server/idleRestart.cjs +185 -40
  174. package/dist/src/builders/server/idleRestart.cjs.map +1 -1
  175. package/dist/src/builders/server/idleRestart.mjs +176 -39
  176. package/dist/src/builders/server/idleRestart.mjs.map +1 -1
  177. package/dist/src/builders/server/index.cjs +58 -19
  178. package/dist/src/builders/server/index.cjs.map +1 -1
  179. package/dist/src/builders/server/index.mjs +57 -19
  180. package/dist/src/builders/server/index.mjs.map +1 -1
  181. package/dist/src/builders/server/liveActivityPush.cjs +202 -0
  182. package/dist/src/builders/server/liveActivityPush.cjs.map +1 -0
  183. package/dist/src/builders/server/liveActivityPush.mjs +202 -0
  184. package/dist/src/builders/server/liveActivityPush.mjs.map +1 -0
  185. package/dist/src/builders/server/logSink.cjs +12 -10
  186. package/dist/src/builders/server/logSink.cjs.map +1 -1
  187. package/dist/src/builders/server/logSink.mjs +12 -10
  188. package/dist/src/builders/server/logSink.mjs.map +1 -1
  189. package/dist/src/builders/server/mcpApp.cjs +27 -20
  190. package/dist/src/builders/server/mcpApp.cjs.map +1 -1
  191. package/dist/src/builders/server/mcpApp.mjs +25 -18
  192. package/dist/src/builders/server/mcpApp.mjs.map +1 -1
  193. package/dist/src/builders/server/mcpAppBuild.cjs +61 -41
  194. package/dist/src/builders/server/mcpAppBuild.cjs.map +1 -1
  195. package/dist/src/builders/server/mcpAppBuild.d.mts +3 -6
  196. package/dist/src/builders/server/mcpAppBuild.d.mts.map +1 -1
  197. package/dist/src/builders/server/mcpAppBuild.mjs +61 -40
  198. package/dist/src/builders/server/mcpAppBuild.mjs.map +1 -1
  199. package/dist/src/builders/server/mcpBundle.cjs +20 -16
  200. package/dist/src/builders/server/mcpBundle.cjs.map +1 -1
  201. package/dist/src/builders/server/mcpBundle.d.mts +2 -1
  202. package/dist/src/builders/server/mcpBundle.d.mts.map +1 -1
  203. package/dist/src/builders/server/mcpBundle.mjs +20 -15
  204. package/dist/src/builders/server/mcpBundle.mjs.map +1 -1
  205. package/dist/src/builders/server/nativePush.cjs +229 -0
  206. package/dist/src/builders/server/nativePush.cjs.map +1 -0
  207. package/dist/src/builders/server/nativePush.mjs +228 -0
  208. package/dist/src/builders/server/nativePush.mjs.map +1 -0
  209. package/dist/src/builders/server/network.cjs +887 -0
  210. package/dist/src/builders/server/network.cjs.map +1 -0
  211. package/dist/src/builders/server/network.mjs +886 -0
  212. package/dist/src/builders/server/network.mjs.map +1 -0
  213. package/dist/src/builders/server/networkGateway.cjs +123 -0
  214. package/dist/src/builders/server/networkGateway.cjs.map +1 -0
  215. package/dist/src/builders/server/networkGateway.mjs +123 -0
  216. package/dist/src/builders/server/networkGateway.mjs.map +1 -0
  217. package/dist/src/builders/server/networkRelay.cjs +83 -0
  218. package/dist/src/builders/server/networkRelay.cjs.map +1 -0
  219. package/dist/src/builders/server/networkRelay.mjs +81 -0
  220. package/dist/src/builders/server/networkRelay.mjs.map +1 -0
  221. package/dist/src/builders/server/orgPluginLibraryBinding.cjs +72 -0
  222. package/dist/src/builders/server/orgPluginLibraryBinding.cjs.map +1 -0
  223. package/dist/src/builders/server/orgPluginLibraryBinding.mjs +72 -0
  224. package/dist/src/builders/server/orgPluginLibraryBinding.mjs.map +1 -0
  225. package/dist/src/builders/server/packageReloadCheck.cjs +46 -2
  226. package/dist/src/builders/server/packageReloadCheck.cjs.map +1 -1
  227. package/dist/src/builders/server/packageReloadCheck.mjs +46 -3
  228. package/dist/src/builders/server/packageReloadCheck.mjs.map +1 -1
  229. package/dist/src/builders/server/packageUrl.cjs +161 -58
  230. package/dist/src/builders/server/packageUrl.cjs.map +1 -1
  231. package/dist/src/builders/server/packageUrl.mjs +162 -58
  232. package/dist/src/builders/server/packageUrl.mjs.map +1 -1
  233. package/dist/src/builders/server/privateRelay.cjs +309 -0
  234. package/dist/src/builders/server/privateRelay.cjs.map +1 -0
  235. package/dist/src/builders/server/privateRelay.mjs +305 -0
  236. package/dist/src/builders/server/privateRelay.mjs.map +1 -0
  237. package/dist/src/builders/server/privateRelayCarrier.cjs +316 -0
  238. package/dist/src/builders/server/privateRelayCarrier.cjs.map +1 -0
  239. package/dist/src/builders/server/privateRelayCarrier.mjs +309 -0
  240. package/dist/src/builders/server/privateRelayCarrier.mjs.map +1 -0
  241. package/dist/src/builders/server/runtime.cjs +2750 -486
  242. package/dist/src/builders/server/runtime.cjs.map +1 -1
  243. package/dist/src/builders/server/runtime.mjs +2760 -500
  244. package/dist/src/builders/server/runtime.mjs.map +1 -1
  245. package/dist/src/builders/server/runtimeResources.cjs +37 -0
  246. package/dist/src/builders/server/runtimeResources.cjs.map +1 -1
  247. package/dist/src/builders/server/runtimeResources.mjs +38 -2
  248. package/dist/src/builders/server/runtimeResources.mjs.map +1 -1
  249. package/dist/src/builders/server/sandboxRouter.cjs +815 -0
  250. package/dist/src/builders/server/sandboxRouter.cjs.map +1 -0
  251. package/dist/src/builders/server/sandboxRouter.mjs +811 -0
  252. package/dist/src/builders/server/sandboxRouter.mjs.map +1 -0
  253. package/dist/src/builders/server/sandboxSessionHandoff.cjs +298 -0
  254. package/dist/src/builders/server/sandboxSessionHandoff.cjs.map +1 -0
  255. package/dist/src/builders/server/sandboxSessionHandoff.mjs +287 -0
  256. package/dist/src/builders/server/sandboxSessionHandoff.mjs.map +1 -0
  257. package/dist/src/builders/server/scopeReloadController.cjs +80 -0
  258. package/dist/src/builders/server/scopeReloadController.cjs.map +1 -0
  259. package/dist/src/builders/server/scopeReloadController.mjs +80 -0
  260. package/dist/src/builders/server/scopeReloadController.mjs.map +1 -0
  261. package/dist/src/builders/server/selectionStatus.cjs +2 -2
  262. package/dist/src/builders/server/selectionStatus.cjs.map +1 -1
  263. package/dist/src/builders/server/selectionStatus.mjs +2 -2
  264. package/dist/src/builders/server/selectionStatus.mjs.map +1 -1
  265. package/dist/src/builders/server/sessionArguments.cjs +65 -7
  266. package/dist/src/builders/server/sessionArguments.cjs.map +1 -1
  267. package/dist/src/builders/server/sessionArguments.mjs +64 -8
  268. package/dist/src/builders/server/sessionArguments.mjs.map +1 -1
  269. package/dist/src/builders/server/sessionRemoval.cjs +233 -0
  270. package/dist/src/builders/server/sessionRemoval.cjs.map +1 -0
  271. package/dist/src/builders/server/sessionRemoval.mjs +224 -0
  272. package/dist/src/builders/server/sessionRemoval.mjs.map +1 -0
  273. package/dist/src/builders/server/sessionSummaries.cjs +32 -0
  274. package/dist/src/builders/server/sessionSummaries.cjs.map +1 -0
  275. package/dist/src/builders/server/sessionSummaries.mjs +31 -0
  276. package/dist/src/builders/server/sessionSummaries.mjs.map +1 -0
  277. package/dist/src/builders/server/shutdown.cjs +23 -0
  278. package/dist/src/builders/server/shutdown.cjs.map +1 -1
  279. package/dist/src/builders/server/shutdown.mjs +21 -1
  280. package/dist/src/builders/server/shutdown.mjs.map +1 -1
  281. package/dist/src/builders/server/shutdownStack.cjs +44 -0
  282. package/dist/src/builders/server/shutdownStack.cjs.map +1 -0
  283. package/dist/src/builders/server/shutdownStack.mjs +43 -0
  284. package/dist/src/builders/server/shutdownStack.mjs.map +1 -0
  285. package/dist/src/builders/server/toolBoundaryHold.cjs +55 -0
  286. package/dist/src/builders/server/toolBoundaryHold.cjs.map +1 -0
  287. package/dist/src/builders/server/toolBoundaryHold.mjs +55 -0
  288. package/dist/src/builders/server/toolBoundaryHold.mjs.map +1 -0
  289. package/dist/src/builders/server/watcherService.cjs +55 -28
  290. package/dist/src/builders/server/watcherService.cjs.map +1 -1
  291. package/dist/src/builders/server/watcherService.mjs +55 -27
  292. package/dist/src/builders/server/watcherService.mjs.map +1 -1
  293. package/dist/src/builders/server/webTemplateDecision.cjs +7 -3
  294. package/dist/src/builders/server/webTemplateDecision.cjs.map +1 -1
  295. package/dist/src/builders/server/webTemplateDecision.mjs +7 -3
  296. package/dist/src/builders/server/webTemplateDecision.mjs.map +1 -1
  297. package/dist/src/builders/server/workspaceAdmission.cjs +96 -0
  298. package/dist/src/builders/server/workspaceAdmission.cjs.map +1 -0
  299. package/dist/src/builders/server/workspaceAdmission.mjs +90 -0
  300. package/dist/src/builders/server/workspaceAdmission.mjs.map +1 -0
  301. package/dist/src/builders/server/workspaceCheckout.cjs +16 -7
  302. package/dist/src/builders/server/workspaceCheckout.cjs.map +1 -1
  303. package/dist/src/builders/server/workspaceCheckout.mjs +16 -7
  304. package/dist/src/builders/server/workspaceCheckout.mjs.map +1 -1
  305. package/dist/src/builders/web/bundle.cjs +16 -14
  306. package/dist/src/builders/web/bundle.cjs.map +1 -1
  307. package/dist/src/builders/web/bundle.d.mts +3 -0
  308. package/dist/src/builders/web/bundle.d.mts.map +1 -1
  309. package/dist/src/builders/web/bundle.mjs +15 -13
  310. package/dist/src/builders/web/bundle.mjs.map +1 -1
  311. package/dist/src/builders/web/index.cjs +92 -59
  312. package/dist/src/builders/web/index.cjs.map +1 -1
  313. package/dist/src/builders/web/index.d.mts +21 -14
  314. package/dist/src/builders/web/index.d.mts.map +1 -1
  315. package/dist/src/builders/web/index.mjs +91 -59
  316. package/dist/src/builders/web/index.mjs.map +1 -1
  317. package/dist/src/builders/web/webPluginGenerate.cjs +84 -45
  318. package/dist/src/builders/web/webPluginGenerate.cjs.map +1 -1
  319. package/dist/src/builders/web/webPluginGenerate.d.mts +13 -4
  320. package/dist/src/builders/web/webPluginGenerate.d.mts.map +1 -1
  321. package/dist/src/builders/web/webPluginGenerate.mjs +82 -44
  322. package/dist/src/builders/web/webPluginGenerate.mjs.map +1 -1
  323. package/dist/src/builders/web/webPluginManifest.cjs +24 -17
  324. package/dist/src/builders/web/webPluginManifest.cjs.map +1 -1
  325. package/dist/src/builders/web/webPluginManifest.d.mts +11 -23
  326. package/dist/src/builders/web/webPluginManifest.d.mts.map +1 -1
  327. package/dist/src/builders/web/webPluginManifest.mjs +23 -16
  328. package/dist/src/builders/web/webPluginManifest.mjs.map +1 -1
  329. package/dist/src/builders/web/webPluginScan.cjs +11 -8
  330. package/dist/src/builders/web/webPluginScan.cjs.map +1 -1
  331. package/dist/src/builders/web/webPluginScan.d.mts +1 -1
  332. package/dist/src/builders/web/webPluginScan.d.mts.map +1 -1
  333. package/dist/src/builders/web/webPluginScan.mjs +10 -7
  334. package/dist/src/builders/web/webPluginScan.mjs.map +1 -1
  335. package/dist/src/builders/web/webPluginVite.cjs +5 -5
  336. package/dist/src/builders/web/webPluginVite.cjs.map +1 -1
  337. package/dist/src/builders/web/webPluginVite.d.mts +1 -1
  338. package/dist/src/builders/web/webPluginVite.d.mts.map +1 -1
  339. package/dist/src/builders/web/webPluginVite.mjs +3 -3
  340. package/dist/src/builders/web/webPluginVite.mjs.map +1 -1
  341. package/dist/src/cli/cliApp.cjs +18 -19
  342. package/dist/src/cli/cliApp.cjs.map +1 -1
  343. package/dist/src/cli/cliApp.d.mts +1 -1
  344. package/dist/src/cli/cliApp.d.mts.map +1 -1
  345. package/dist/src/cli/cliApp.mjs +18 -19
  346. package/dist/src/cli/cliApp.mjs.map +1 -1
  347. package/dist/src/cli/commands/api-export/index.cjs +14 -13
  348. package/dist/src/cli/commands/api-export/index.cjs.map +1 -1
  349. package/dist/src/cli/commands/api-export/index.mjs +13 -12
  350. package/dist/src/cli/commands/api-export/index.mjs.map +1 -1
  351. package/dist/src/cli/commands/doctor/help.cjs +4 -3
  352. package/dist/src/cli/commands/doctor/help.cjs.map +1 -1
  353. package/dist/src/cli/commands/doctor/help.d.mts.map +1 -1
  354. package/dist/src/cli/commands/doctor/help.mjs +4 -3
  355. package/dist/src/cli/commands/doctor/help.mjs.map +1 -1
  356. package/dist/src/cli/commands/doctor/index.cjs +30 -17
  357. package/dist/src/cli/commands/doctor/index.cjs.map +1 -1
  358. package/dist/src/cli/commands/doctor/index.d.mts +4 -4
  359. package/dist/src/cli/commands/doctor/index.d.mts.map +1 -1
  360. package/dist/src/cli/commands/doctor/index.mjs +28 -15
  361. package/dist/src/cli/commands/doctor/index.mjs.map +1 -1
  362. package/dist/src/cli/commands/emit-mcp/index.cjs +3 -2
  363. package/dist/src/cli/commands/emit-mcp/index.cjs.map +1 -1
  364. package/dist/src/cli/commands/emit-mcp/index.d.mts.map +1 -1
  365. package/dist/src/cli/commands/emit-mcp/index.mjs +3 -2
  366. package/dist/src/cli/commands/emit-mcp/index.mjs.map +1 -1
  367. package/dist/src/cli/commands/explain/index.cjs +53 -38
  368. package/dist/src/cli/commands/explain/index.cjs.map +1 -1
  369. package/dist/src/cli/commands/explain/index.d.mts +3 -4
  370. package/dist/src/cli/commands/explain/index.d.mts.map +1 -1
  371. package/dist/src/cli/commands/explain/index.mjs +52 -37
  372. package/dist/src/cli/commands/explain/index.mjs.map +1 -1
  373. package/dist/src/cli/commands/init/help.cjs +3 -2
  374. package/dist/src/cli/commands/init/help.cjs.map +1 -1
  375. package/dist/src/cli/commands/init/help.d.mts.map +1 -1
  376. package/dist/src/cli/commands/init/help.mjs +3 -2
  377. package/dist/src/cli/commands/init/help.mjs.map +1 -1
  378. package/dist/src/cli/commands/init/index.cjs +17 -12
  379. package/dist/src/cli/commands/init/index.cjs.map +1 -1
  380. package/dist/src/cli/commands/init/index.d.mts.map +1 -1
  381. package/dist/src/cli/commands/init/index.mjs +16 -11
  382. package/dist/src/cli/commands/init/index.mjs.map +1 -1
  383. package/dist/src/cli/commands/init/presenter.cjs +29 -21
  384. package/dist/src/cli/commands/init/presenter.cjs.map +1 -1
  385. package/dist/src/cli/commands/init/presenter.mjs +29 -21
  386. package/dist/src/cli/commands/init/presenter.mjs.map +1 -1
  387. package/dist/src/cli/commands/sync/help.cjs +7 -3
  388. package/dist/src/cli/commands/sync/help.cjs.map +1 -1
  389. package/dist/src/cli/commands/sync/help.d.mts.map +1 -1
  390. package/dist/src/cli/commands/sync/help.mjs +7 -3
  391. package/dist/src/cli/commands/sync/help.mjs.map +1 -1
  392. package/dist/src/cli/commands/sync/index.cjs +72 -40
  393. package/dist/src/cli/commands/sync/index.cjs.map +1 -1
  394. package/dist/src/cli/commands/sync/index.d.mts.map +1 -1
  395. package/dist/src/cli/commands/sync/index.mjs +69 -37
  396. package/dist/src/cli/commands/sync/index.mjs.map +1 -1
  397. package/dist/src/cli/commands/sync/presenter.cjs +10 -1
  398. package/dist/src/cli/commands/sync/presenter.cjs.map +1 -1
  399. package/dist/src/cli/commands/sync/presenter.d.mts +0 -9
  400. package/dist/src/cli/commands/sync/presenter.d.mts.map +1 -1
  401. package/dist/src/cli/commands/sync/presenter.mjs +10 -1
  402. package/dist/src/cli/commands/sync/presenter.mjs.map +1 -1
  403. package/dist/src/cli/commands/web/index.cjs +7 -6
  404. package/dist/src/cli/commands/web/index.cjs.map +1 -1
  405. package/dist/src/cli/commands/web/index.mjs +6 -5
  406. package/dist/src/cli/commands/web/index.mjs.map +1 -1
  407. package/dist/src/cli/harnessOptions.cjs +15 -24
  408. package/dist/src/cli/harnessOptions.cjs.map +1 -1
  409. package/dist/src/cli/harnessOptions.d.mts +2 -2
  410. package/dist/src/cli/harnessOptions.d.mts.map +1 -1
  411. package/dist/src/cli/harnessOptions.mjs +14 -22
  412. package/dist/src/cli/harnessOptions.mjs.map +1 -1
  413. package/dist/src/cli/help.cjs +20 -26
  414. package/dist/src/cli/help.cjs.map +1 -1
  415. package/dist/src/cli/help.d.mts +1 -2
  416. package/dist/src/cli/help.d.mts.map +1 -1
  417. package/dist/src/cli/help.mjs +15 -20
  418. package/dist/src/cli/help.mjs.map +1 -1
  419. package/dist/src/cli/locale.cjs +30 -0
  420. package/dist/src/cli/locale.cjs.map +1 -0
  421. package/dist/src/cli/locale.mjs +27 -0
  422. package/dist/src/cli/locale.mjs.map +1 -0
  423. package/dist/src/cli/matrixOptions.cjs +85 -37
  424. package/dist/src/cli/matrixOptions.cjs.map +1 -1
  425. package/dist/src/cli/matrixOptions.d.mts +22 -16
  426. package/dist/src/cli/matrixOptions.d.mts.map +1 -1
  427. package/dist/src/cli/matrixOptions.mjs +76 -33
  428. package/dist/src/cli/matrixOptions.mjs.map +1 -1
  429. package/dist/src/cli/options.cjs +51 -128
  430. package/dist/src/cli/options.cjs.map +1 -1
  431. package/dist/src/cli/options.d.mts +1 -1
  432. package/dist/src/cli/options.d.mts.map +1 -1
  433. package/dist/src/cli/options.mjs +53 -130
  434. package/dist/src/cli/options.mjs.map +1 -1
  435. package/dist/src/cli/router.cjs +0 -1
  436. package/dist/src/cli/router.cjs.map +1 -1
  437. package/dist/src/cli/router.d.mts +1 -1
  438. package/dist/src/cli/router.mjs +0 -1
  439. package/dist/src/cli/router.mjs.map +1 -1
  440. package/dist/src/cli/server/options.cjs +37 -7
  441. package/dist/src/cli/server/options.cjs.map +1 -1
  442. package/dist/src/cli/server/options.mjs +37 -7
  443. package/dist/src/cli/server/options.mjs.map +1 -1
  444. package/dist/src/cli/server/processGuards.cjs +22 -15
  445. package/dist/src/cli/server/processGuards.cjs.map +1 -1
  446. package/dist/src/cli/server/processGuards.mjs +21 -14
  447. package/dist/src/cli/server/processGuards.mjs.map +1 -1
  448. package/dist/src/cli/server/restartPolicy.cjs +38 -0
  449. package/dist/src/cli/server/restartPolicy.cjs.map +1 -0
  450. package/dist/src/cli/server/restartPolicy.d.mts +21 -0
  451. package/dist/src/cli/server/restartPolicy.d.mts.map +1 -0
  452. package/dist/src/cli/server/restartPolicy.mjs +36 -0
  453. package/dist/src/cli/server/restartPolicy.mjs.map +1 -0
  454. package/dist/src/cli/server/run.cjs +12 -11
  455. package/dist/src/cli/server/run.cjs.map +1 -1
  456. package/dist/src/cli/server/run.mjs +11 -10
  457. package/dist/src/cli/server/run.mjs.map +1 -1
  458. package/dist/src/cli/server/supervise.cjs +89 -0
  459. package/dist/src/cli/server/supervise.cjs.map +1 -0
  460. package/dist/src/cli/server/supervise.mjs +89 -0
  461. package/dist/src/cli/server/supervise.mjs.map +1 -0
  462. package/dist/src/composition/harnessState/index.cjs +2 -1
  463. package/dist/src/composition/harnessState/index.cjs.map +1 -1
  464. package/dist/src/composition/harnessState/index.d.mts +2 -1
  465. package/dist/src/composition/harnessState/index.d.mts.map +1 -1
  466. package/dist/src/composition/harnessState/index.mjs +2 -1
  467. package/dist/src/composition/harnessState/index.mjs.map +1 -1
  468. package/dist/src/composition/layerPackageInstaller/index.cjs +293 -86
  469. package/dist/src/composition/layerPackageInstaller/index.cjs.map +1 -1
  470. package/dist/src/composition/layerPackageInstaller/index.d.mts +25 -2
  471. package/dist/src/composition/layerPackageInstaller/index.d.mts.map +1 -1
  472. package/dist/src/composition/layerPackageInstaller/index.mjs +295 -94
  473. package/dist/src/composition/layerPackageInstaller/index.mjs.map +1 -1
  474. package/dist/src/composition/marketplaceCatalog/index.cjs +136 -0
  475. package/dist/src/composition/marketplaceCatalog/index.cjs.map +1 -0
  476. package/dist/src/composition/marketplaceCatalog/index.mjs +132 -0
  477. package/dist/src/composition/marketplaceCatalog/index.mjs.map +1 -0
  478. package/dist/src/composition/orgPluginActivation/index.cjs +179 -0
  479. package/dist/src/composition/orgPluginActivation/index.cjs.map +1 -0
  480. package/dist/src/composition/orgPluginActivation/index.mjs +177 -0
  481. package/dist/src/composition/orgPluginActivation/index.mjs.map +1 -0
  482. package/dist/src/composition/orgPluginLibrary/index.cjs +205 -0
  483. package/dist/src/composition/orgPluginLibrary/index.cjs.map +1 -0
  484. package/dist/src/composition/orgPluginLibrary/index.mjs +200 -0
  485. package/dist/src/composition/orgPluginLibrary/index.mjs.map +1 -0
  486. package/dist/src/composition/pluginMarketplace/index.cjs +304 -0
  487. package/dist/src/composition/pluginMarketplace/index.cjs.map +1 -0
  488. package/dist/src/composition/pluginMarketplace/index.mjs +302 -0
  489. package/dist/src/composition/pluginMarketplace/index.mjs.map +1 -0
  490. package/dist/src/composition/poHomeMigration/index.cjs +46 -26
  491. package/dist/src/composition/poHomeMigration/index.cjs.map +1 -1
  492. package/dist/src/composition/poHomeMigration/index.d.mts.map +1 -1
  493. package/dist/src/composition/poHomeMigration/index.mjs +45 -25
  494. package/dist/src/composition/poHomeMigration/index.mjs.map +1 -1
  495. package/dist/src/composition/projectTrust/index.cjs +40 -3
  496. package/dist/src/composition/projectTrust/index.cjs.map +1 -1
  497. package/dist/src/composition/projectTrust/index.d.mts +8 -0
  498. package/dist/src/composition/projectTrust/index.d.mts.map +1 -1
  499. package/dist/src/composition/projectTrust/index.mjs +33 -2
  500. package/dist/src/composition/projectTrust/index.mjs.map +1 -1
  501. package/dist/src/composition/repository/index.cjs +29 -12
  502. package/dist/src/composition/repository/index.cjs.map +1 -1
  503. package/dist/src/composition/repository/index.d.mts +10 -3
  504. package/dist/src/composition/repository/index.d.mts.map +1 -1
  505. package/dist/src/composition/repository/index.mjs +29 -13
  506. package/dist/src/composition/repository/index.mjs.map +1 -1
  507. package/dist/src/composition/syncPrune/index.cjs +23 -16
  508. package/dist/src/composition/syncPrune/index.cjs.map +1 -1
  509. package/dist/src/composition/syncPrune/index.d.mts.map +1 -1
  510. package/dist/src/composition/syncPrune/index.mjs +22 -15
  511. package/dist/src/composition/syncPrune/index.mjs.map +1 -1
  512. package/dist/src/composition/syncService/index.cjs +441 -194
  513. package/dist/src/composition/syncService/index.cjs.map +1 -1
  514. package/dist/src/composition/syncService/index.d.mts +4 -1
  515. package/dist/src/composition/syncService/index.d.mts.map +1 -1
  516. package/dist/src/composition/syncService/index.mjs +440 -196
  517. package/dist/src/composition/syncService/index.mjs.map +1 -1
  518. package/dist/src/composition/syncService/localBuilds.cjs +41 -37
  519. package/dist/src/composition/syncService/localBuilds.cjs.map +1 -1
  520. package/dist/src/composition/syncService/localBuilds.mjs +40 -37
  521. package/dist/src/composition/syncService/localBuilds.mjs.map +1 -1
  522. package/dist/src/composition/transitionLayers.cjs.map +1 -1
  523. package/dist/src/composition/transitionLayers.d.mts +3 -3
  524. package/dist/src/composition/transitionLayers.d.mts.map +1 -1
  525. package/dist/src/composition/transitionLayers.mjs.map +1 -1
  526. package/dist/src/composition/types/harness.d.mts +4 -9
  527. package/dist/src/composition/types/harness.d.mts.map +1 -1
  528. package/dist/src/extensions/setupDiagnostics.cjs +8 -8
  529. package/dist/src/extensions/setupDiagnostics.cjs.map +1 -1
  530. package/dist/src/extensions/setupDiagnostics.mjs +8 -8
  531. package/dist/src/extensions/setupDiagnostics.mjs.map +1 -1
  532. package/dist/webBuilder.cjs +2 -0
  533. package/dist/webBuilder.d.mts +3 -3
  534. package/dist/webBuilder.mjs +3 -3
  535. package/docs/server/api-export.md +9 -9
  536. package/docs/server/api.md +22 -125
  537. package/docs/server/getting-started.md +21 -85
  538. package/docs/server/index.md +13 -58
  539. package/docs/server/ipc.md +26 -72
  540. package/docs/server/lifecycle.md +18 -91
  541. package/docs/server/security.md +20 -80
  542. package/locales/vi.json +208 -0
  543. package/locales/zh-CN.json +208 -0
  544. package/package.json +52 -69
  545. package/src/prompts/po-author-extension/SKILL.md +2 -2
  546. package/src/prompts/po-author-extension/references/extension-contract.md +4 -6
  547. package/dist/antigravity.cjs +0 -5
  548. package/dist/antigravity.d.mts +0 -2
  549. package/dist/antigravity.mjs +0 -1
  550. package/dist/codex.cjs +0 -8
  551. package/dist/codex.d.mts +0 -2
  552. package/dist/codex.mjs +0 -1
  553. package/dist/compatibility.cjs +0 -27
  554. package/dist/compatibility.d.mts +0 -6
  555. package/dist/compatibility.mjs +0 -6
  556. package/dist/compatibilityCommand.cjs +0 -4
  557. package/dist/compatibilityCommand.d.mts +0 -2
  558. package/dist/compatibilityCommand.mjs +0 -1
  559. package/dist/compatibilityContext.cjs +0 -3
  560. package/dist/compatibilityContext.d.mts +0 -2
  561. package/dist/compatibilityContext.mjs +0 -1
  562. package/dist/compatibilityOptions.cjs +0 -5
  563. package/dist/compatibilityOptions.d.mts +0 -2
  564. package/dist/compatibilityOptions.mjs +0 -1
  565. package/dist/process.cjs +0 -12
  566. package/dist/process.d.mts +0 -2
  567. package/dist/process.mjs +0 -1
  568. package/dist/src/builders/hooks/index.cjs +0 -238
  569. package/dist/src/builders/hooks/index.cjs.map +0 -1
  570. package/dist/src/builders/hooks/index.mjs +0 -231
  571. package/dist/src/builders/hooks/index.mjs.map +0 -1
  572. package/dist/src/cli/commands/compat/context.cjs +0 -115
  573. package/dist/src/cli/commands/compat/context.cjs.map +0 -1
  574. package/dist/src/cli/commands/compat/context.d.mts +0 -22
  575. package/dist/src/cli/commands/compat/context.d.mts.map +0 -1
  576. package/dist/src/cli/commands/compat/context.mjs +0 -110
  577. package/dist/src/cli/commands/compat/context.mjs.map +0 -1
  578. package/dist/src/cli/commands/compat/help.cjs +0 -26
  579. package/dist/src/cli/commands/compat/help.cjs.map +0 -1
  580. package/dist/src/cli/commands/compat/help.d.mts +0 -4
  581. package/dist/src/cli/commands/compat/help.d.mts.map +0 -1
  582. package/dist/src/cli/commands/compat/help.mjs +0 -25
  583. package/dist/src/cli/commands/compat/help.mjs.map +0 -1
  584. package/dist/src/cli/commands/compat/index.cjs +0 -73
  585. package/dist/src/cli/commands/compat/index.cjs.map +0 -1
  586. package/dist/src/cli/commands/compat/index.d.mts +0 -14
  587. package/dist/src/cli/commands/compat/index.d.mts.map +0 -1
  588. package/dist/src/cli/commands/compat/index.mjs +0 -70
  589. package/dist/src/cli/commands/compat/index.mjs.map +0 -1
  590. package/dist/src/cli/commands/compat/options.cjs +0 -88
  591. package/dist/src/cli/commands/compat/options.cjs.map +0 -1
  592. package/dist/src/cli/commands/compat/options.d.mts +0 -15
  593. package/dist/src/cli/commands/compat/options.d.mts.map +0 -1
  594. package/dist/src/cli/commands/compat/options.mjs +0 -86
  595. package/dist/src/cli/commands/compat/options.mjs.map +0 -1
  596. package/dist/src/cli/commands/compat/providers/antigravity.cjs +0 -294
  597. package/dist/src/cli/commands/compat/providers/antigravity.cjs.map +0 -1
  598. package/dist/src/cli/commands/compat/providers/antigravity.d.mts +0 -9
  599. package/dist/src/cli/commands/compat/providers/antigravity.d.mts.map +0 -1
  600. package/dist/src/cli/commands/compat/providers/antigravity.mjs +0 -289
  601. package/dist/src/cli/commands/compat/providers/antigravity.mjs.map +0 -1
  602. package/dist/src/cli/commands/compat/providers/codex.cjs +0 -178
  603. package/dist/src/cli/commands/compat/providers/codex.cjs.map +0 -1
  604. package/dist/src/cli/commands/compat/providers/codex.d.mts +0 -17
  605. package/dist/src/cli/commands/compat/providers/codex.d.mts.map +0 -1
  606. package/dist/src/cli/commands/compat/providers/codex.mjs +0 -170
  607. package/dist/src/cli/commands/compat/providers/codex.mjs.map +0 -1
  608. package/dist/src/cli/commands/compat/providers/index.cjs +0 -65
  609. package/dist/src/cli/commands/compat/providers/index.cjs.map +0 -1
  610. package/dist/src/cli/commands/compat/providers/index.d.mts +0 -15
  611. package/dist/src/cli/commands/compat/providers/index.d.mts.map +0 -1
  612. package/dist/src/cli/commands/compat/providers/index.mjs +0 -45
  613. package/dist/src/cli/commands/compat/providers/index.mjs.map +0 -1
  614. package/dist/src/cli/commands/compat/providers/process.cjs +0 -172
  615. package/dist/src/cli/commands/compat/providers/process.cjs.map +0 -1
  616. package/dist/src/cli/commands/compat/providers/process.d.mts +0 -33
  617. package/dist/src/cli/commands/compat/providers/process.d.mts.map +0 -1
  618. package/dist/src/cli/commands/compat/providers/process.mjs +0 -159
  619. package/dist/src/cli/commands/compat/providers/process.mjs.map +0 -1
  620. package/dist/src/cli/commands/compat/providers/shared.cjs +0 -76
  621. package/dist/src/cli/commands/compat/providers/shared.cjs.map +0 -1
  622. package/dist/src/cli/commands/compat/providers/shared.d.mts +0 -40
  623. package/dist/src/cli/commands/compat/providers/shared.d.mts.map +0 -1
  624. package/dist/src/cli/commands/compat/providers/shared.mjs +0 -61
  625. package/dist/src/cli/commands/compat/providers/shared.mjs.map +0 -1
  626. package/dist/src/cli/commands/compat/types.d.mts +0 -31
  627. package/dist/src/cli/commands/compat/types.d.mts.map +0 -1
  628. package/dist/src/cli/commands/init/constants.cjs +0 -11
  629. package/dist/src/cli/commands/init/constants.cjs.map +0 -1
  630. package/dist/src/cli/commands/init/constants.mjs +0 -11
  631. package/dist/src/cli/commands/init/constants.mjs.map +0 -1
@@ -1,22 +1,24 @@
1
- import fs from "node:fs";
2
1
  import path from "node:path";
2
+ import fs from "node:fs/promises";
3
3
  import { globalPoConfigDirectory } from "@agimon-ai/po-config/config";
4
- import { hasRepositoryPoDirectory } from "@agimon-ai/po-core/piSettings";
4
+ import { createNodePlatform } from "@agimon-ai/po-core/nodePlatform";
5
+ import { hasRepositoryPoDirectoryAsync } from "@agimon-ai/po-core/piSettings";
6
+ import { BACKGROUND_CONTEXT } from "@agimon-ai/po-core/platform";
5
7
  //#region src/composition/repository/index.ts
6
8
  /** Git's root marker, which may be a directory or a worktree pointer file. */
7
9
  const GIT_DIRECTORY = ".git";
8
10
  /** A Pi project that has been configured, rather than any stray `.pi` folder. */
9
11
  const PI_SETTINGS = path.join(".pi", "settings.json");
10
- function isDirectory(target) {
12
+ async function isDirectory(target) {
11
13
  try {
12
- return fs.statSync(target).isDirectory();
14
+ return (await fs.stat(target)).isDirectory();
13
15
  } catch {
14
16
  return false;
15
17
  }
16
18
  }
17
- function isFile(target) {
19
+ async function isFile(target) {
18
20
  try {
19
- return fs.statSync(target).isFile();
21
+ return (await fs.stat(target)).isFile();
20
22
  } catch {
21
23
  return false;
22
24
  }
@@ -29,9 +31,9 @@ function isFile(target) {
29
31
  * repository-local configuration. Build-tooling markers remain deliberately
30
32
  * excluded because they do not establish a repository boundary.
31
33
  */
32
- function isRepositoryRoot(directory) {
34
+ async function isRepositoryRoot(directory) {
33
35
  const gitMarker = path.join(directory, GIT_DIRECTORY);
34
- return hasRepositoryPoDirectory(directory) || isFile(path.join(directory, PI_SETTINGS)) || isDirectory(gitMarker) || isFile(gitMarker);
36
+ return await hasRepositoryPoDirectoryAsync(createNodePlatform().env(directory), directory, BACKGROUND_CONTEXT, void 0, process.env) || await isFile(path.join(directory, PI_SETTINGS)) || await isDirectory(gitMarker) || await isFile(gitMarker);
35
37
  }
36
38
  /**
37
39
  * Walks up from `start` looking for the repository root.
@@ -40,24 +42,38 @@ function isRepositoryRoot(directory) {
40
42
  * resolves to the repository that configured Po rather than to a parent
41
43
  * checkout that happens to sit above it.
42
44
  */
43
- function findRepositoryRoot(start) {
45
+ async function findRepositoryRoot(start) {
44
46
  let directory = path.resolve(start);
45
47
  while (true) {
46
- if (isRepositoryRoot(directory)) return directory;
48
+ if (await isRepositoryRoot(directory)) return directory;
47
49
  const parent = path.dirname(directory);
48
50
  if (parent === directory) throw new Error(`Could not find repository root from ${start}`);
49
51
  directory = parent;
50
52
  }
51
53
  }
54
+ /**
55
+ * The workspace root for a directory: its repository root, or the directory itself when no
56
+ * repository marks it, so any folder can be a workspace. Canonical (symlinks resolved), the
57
+ * form the server compares workspace roots and saved session checkouts in. A missing
58
+ * directory outside any repository resolves to its absolute path.
59
+ */
60
+ async function resolveWorkspaceRoot(start) {
61
+ try {
62
+ return await fs.realpath(await findRepositoryRoot(start));
63
+ } catch {
64
+ const directory = path.resolve(start);
65
+ return await isDirectory(directory) ? fs.realpath(directory) : directory;
66
+ }
67
+ }
52
68
  /** Uses the nearest repository when one exists, otherwise the user's global Po composition. */
53
- function resolvePoConfigurationRoot(start, homeDirectory) {
69
+ async function resolvePoConfigurationRoot(start, homeDirectory) {
54
70
  try {
55
- return findRepositoryRoot(start);
71
+ return await findRepositoryRoot(start);
56
72
  } catch {
57
73
  return globalPoConfigDirectory(homeDirectory);
58
74
  }
59
75
  }
60
76
  //#endregion
61
- export { findRepositoryRoot, isRepositoryRoot, resolvePoConfigurationRoot };
77
+ export { findRepositoryRoot, isRepositoryRoot, resolvePoConfigurationRoot, resolveWorkspaceRoot };
62
78
 
63
79
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":[],"sources":["../../../../src/composition/repository/index.ts"],"sourcesContent":["import fs from 'node:fs';\nimport path from 'node:path';\n\nimport { globalPoConfigDirectory } from '@agimon-ai/po-config/config';\nimport { hasRepositoryPoDirectory } from '@agimon-ai/po-core/piSettings';\n\n/** Git's root marker, which may be a directory or a worktree pointer file. */\nconst GIT_DIRECTORY = '.git';\n/** A Pi project that has been configured, rather than any stray `.pi` folder. */\nconst PI_SETTINGS = path.join('.pi', 'settings.json');\n\nfunction isDirectory(target: string): boolean {\n try {\n return fs.statSync(target).isDirectory();\n } catch {\n return false;\n }\n}\n\nfunction isFile(target: string): boolean {\n try {\n return fs.statSync(target).isFile();\n } catch {\n return false;\n }\n}\n\n/**\n * True when a directory carries a marker Po Pi is willing to treat as a root.\n *\n * Po and Pi markers identify configured projects. A Git marker also counts so\n * personal configuration can be synchronized into a new checkout before it has\n * repository-local configuration. Build-tooling markers remain deliberately\n * excluded because they do not establish a repository boundary.\n */\nexport function isRepositoryRoot(directory: string): boolean {\n const gitMarker = path.join(directory, GIT_DIRECTORY);\n return (\n hasRepositoryPoDirectory(directory) ||\n isFile(path.join(directory, PI_SETTINGS)) ||\n isDirectory(gitMarker) ||\n isFile(gitMarker)\n );\n}\n\n/**\n * Walks up from `start` looking for the repository root.\n *\n * The nearest marked ancestor wins, so a session started in a subdirectory\n * resolves to the repository that configured Po rather than to a parent\n * checkout that happens to sit above it.\n */\nexport function findRepositoryRoot(start: string): string {\n let directory = path.resolve(start);\n while (true) {\n if (isRepositoryRoot(directory)) return directory;\n const parent = path.dirname(directory);\n if (parent === directory) throw new Error(`Could not find repository root from ${start}`);\n directory = parent;\n }\n}\n\n/** Uses the nearest repository when one exists, otherwise the user's global Po composition. */\nexport function resolvePoConfigurationRoot(start: string, homeDirectory: string): string {\n try {\n return findRepositoryRoot(start);\n } catch {\n return globalPoConfigDirectory(homeDirectory);\n }\n}\n"],"mappings":";;;;;;AAOA,MAAM,gBAAgB;;AAEtB,MAAM,cAAc,KAAK,KAAK,OAAO,eAAe;AAEpD,SAAS,YAAY,QAAyB;CAC5C,IAAI;EACF,OAAO,GAAG,SAAS,MAAM,CAAC,CAAC,YAAY;CACzC,QAAQ;EACN,OAAO;CACT;AACF;AAEA,SAAS,OAAO,QAAyB;CACvC,IAAI;EACF,OAAO,GAAG,SAAS,MAAM,CAAC,CAAC,OAAO;CACpC,QAAQ;EACN,OAAO;CACT;AACF;;;;;;;;;AAUA,SAAgB,iBAAiB,WAA4B;CAC3D,MAAM,YAAY,KAAK,KAAK,WAAW,aAAa;CACpD,OACE,yBAAyB,SAAS,KAClC,OAAO,KAAK,KAAK,WAAW,WAAW,CAAC,KACxC,YAAY,SAAS,KACrB,OAAO,SAAS;AAEpB;;;;;;;;AASA,SAAgB,mBAAmB,OAAuB;CACxD,IAAI,YAAY,KAAK,QAAQ,KAAK;CAClC,OAAO,MAAM;EACX,IAAI,iBAAiB,SAAS,GAAG,OAAO;EACxC,MAAM,SAAS,KAAK,QAAQ,SAAS;EACrC,IAAI,WAAW,WAAW,MAAM,IAAI,MAAM,uCAAuC,OAAO;EACxF,YAAY;CACd;AACF;;AAGA,SAAgB,2BAA2B,OAAe,eAA+B;CACvF,IAAI;EACF,OAAO,mBAAmB,KAAK;CACjC,QAAQ;EACN,OAAO,wBAAwB,aAAa;CAC9C;AACF"}
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../../../../src/composition/repository/index.ts"],"sourcesContent":["import fs from 'node:fs/promises';\nimport path from 'node:path';\n\nimport { globalPoConfigDirectory } from '@agimon-ai/po-config/config';\nimport { createNodePlatform } from '@agimon-ai/po-core/nodePlatform';\nimport { hasRepositoryPoDirectoryAsync } from '@agimon-ai/po-core/piSettings';\nimport { BACKGROUND_CONTEXT } from '@agimon-ai/po-core/platform';\n\n/** Git's root marker, which may be a directory or a worktree pointer file. */\nconst GIT_DIRECTORY = '.git';\n/** A Pi project that has been configured, rather than any stray `.pi` folder. */\nconst PI_SETTINGS = path.join('.pi', 'settings.json');\n\nasync function isDirectory(target: string): Promise<boolean> {\n try {\n return (await fs.stat(target)).isDirectory();\n } catch {\n return false;\n }\n}\n\nasync function isFile(target: string): Promise<boolean> {\n try {\n return (await fs.stat(target)).isFile();\n } catch {\n return false;\n }\n}\n\n/**\n * True when a directory carries a marker Po Pi is willing to treat as a root.\n *\n * Po and Pi markers identify configured projects. A Git marker also counts so\n * personal configuration can be synchronized into a new checkout before it has\n * repository-local configuration. Build-tooling markers remain deliberately\n * excluded because they do not establish a repository boundary.\n */\nexport async function isRepositoryRoot(directory: string): Promise<boolean> {\n const gitMarker = path.join(directory, GIT_DIRECTORY);\n return (\n // CLI composition root: the process environment is the admitted one here.\n (await hasRepositoryPoDirectoryAsync(\n createNodePlatform().env(directory),\n directory,\n BACKGROUND_CONTEXT,\n undefined,\n process.env,\n )) ||\n (await isFile(path.join(directory, PI_SETTINGS))) ||\n (await isDirectory(gitMarker)) ||\n (await isFile(gitMarker))\n );\n}\n\n/**\n * Walks up from `start` looking for the repository root.\n *\n * The nearest marked ancestor wins, so a session started in a subdirectory\n * resolves to the repository that configured Po rather than to a parent\n * checkout that happens to sit above it.\n */\nexport async function findRepositoryRoot(start: string): Promise<string> {\n let directory = path.resolve(start);\n while (true) {\n if (await isRepositoryRoot(directory)) return directory;\n const parent = path.dirname(directory);\n if (parent === directory) throw new Error(`Could not find repository root from ${start}`);\n directory = parent;\n }\n}\n\n/**\n * The workspace root for a directory: its repository root, or the directory itself when no\n * repository marks it, so any folder can be a workspace. Canonical (symlinks resolved), the\n * form the server compares workspace roots and saved session checkouts in. A missing\n * directory outside any repository resolves to its absolute path.\n */\nexport async function resolveWorkspaceRoot(start: string): Promise<string> {\n try {\n return await fs.realpath(await findRepositoryRoot(start));\n } catch {\n // No repository above it: the directory is its own root.\n const directory = path.resolve(start);\n return (await isDirectory(directory)) ? fs.realpath(directory) : directory;\n }\n}\n/** Uses the nearest repository when one exists, otherwise the user's global Po composition. */\nexport async function resolvePoConfigurationRoot(start: string, homeDirectory: string): Promise<string> {\n try {\n return await findRepositoryRoot(start);\n } catch {\n return globalPoConfigDirectory(homeDirectory);\n }\n}\n"],"mappings":";;;;;;;;AASA,MAAM,gBAAgB;;AAEtB,MAAM,cAAc,KAAK,KAAK,OAAO,eAAe;AAEpD,eAAe,YAAY,QAAkC;CAC3D,IAAI;EACF,QAAQ,MAAM,GAAG,KAAK,MAAM,EAAA,CAAG,YAAY;CAC7C,QAAQ;EACN,OAAO;CACT;AACF;AAEA,eAAe,OAAO,QAAkC;CACtD,IAAI;EACF,QAAQ,MAAM,GAAG,KAAK,MAAM,EAAA,CAAG,OAAO;CACxC,QAAQ;EACN,OAAO;CACT;AACF;;;;;;;;;AAUA,eAAsB,iBAAiB,WAAqC;CAC1E,MAAM,YAAY,KAAK,KAAK,WAAW,aAAa;CACpD,OAEG,MAAM,8BACL,mBAAmB,CAAC,CAAC,IAAI,SAAS,GAClC,WACA,oBACA,KAAA,GACA,QAAQ,GACV,KACC,MAAM,OAAO,KAAK,KAAK,WAAW,WAAW,CAAC,KAC9C,MAAM,YAAY,SAAS,KAC3B,MAAM,OAAO,SAAS;AAE3B;;;;;;;;AASA,eAAsB,mBAAmB,OAAgC;CACvE,IAAI,YAAY,KAAK,QAAQ,KAAK;CAClC,OAAO,MAAM;EACX,IAAI,MAAM,iBAAiB,SAAS,GAAG,OAAO;EAC9C,MAAM,SAAS,KAAK,QAAQ,SAAS;EACrC,IAAI,WAAW,WAAW,MAAM,IAAI,MAAM,uCAAuC,OAAO;EACxF,YAAY;CACd;AACF;;;;;;;AAQA,eAAsB,qBAAqB,OAAgC;CACzE,IAAI;EACF,OAAO,MAAM,GAAG,SAAS,MAAM,mBAAmB,KAAK,CAAC;CAC1D,QAAQ;EAEN,MAAM,YAAY,KAAK,QAAQ,KAAK;EACpC,OAAQ,MAAM,YAAY,SAAS,IAAK,GAAG,SAAS,SAAS,IAAI;CACnE;AACF;;AAEA,eAAsB,2BAA2B,OAAe,eAAwC;CACtG,IAAI;EACF,OAAO,MAAM,mBAAmB,KAAK;CACvC,QAAQ;EACN,OAAO,wBAAwB,aAAa;CAC9C;AACF"}
@@ -1,12 +1,12 @@
1
1
  const require_runtime = require("../../../_virtual/_rolldown/runtime.cjs");
2
2
  const require_index = require("../layerPackageInstaller/index.cjs");
3
3
  const require_index$1 = require("../poHomeMigration/index.cjs");
4
- let node_fs = require("node:fs");
5
- node_fs = require_runtime.__toESM(node_fs, 1);
4
+ let _agimon_ai_po_core_runtimePiSettings = require("@agimon-ai/po-core/runtimePiSettings");
6
5
  let node_path = require("node:path");
7
6
  node_path = require_runtime.__toESM(node_path, 1);
7
+ let node_fs_promises = require("node:fs/promises");
8
+ node_fs_promises = require_runtime.__toESM(node_fs_promises, 1);
8
9
  let _agimon_ai_po_core_runtimePackages = require("@agimon-ai/po-core/runtimePackages");
9
- let _agimon_ai_po_core_runtimePiSettings = require("@agimon-ai/po-core/runtimePiSettings");
10
10
  //#region src/composition/syncPrune/index.ts
11
11
  /**
12
12
  * What an explicit `po sync` drops once its installs and builds are done:
@@ -34,41 +34,48 @@ const TEMPORARY_PREFIX = ".";
34
34
  * Removes every build of one kind except the current keys and the most recently written
35
35
  * other key, the one a client that has not refreshed yet may still load.
36
36
  */
37
- function pruneBuilds(buildsRoot, kind, currentKeys) {
37
+ async function pruneBuilds(buildsRoot, kind, currentKeys) {
38
38
  if (currentKeys.length === 0) return [];
39
39
  const directory = node_path.default.join(buildsRoot, BUILD_DIRECTORY, kind);
40
- if (!node_fs.default.existsSync(directory)) return [];
41
- return node_fs.default.readdirSync(directory, { withFileTypes: true }).filter((entry) => entry.isDirectory() && !entry.name.startsWith(TEMPORARY_PREFIX) && !currentKeys.includes(entry.name)).map((entry) => ({
40
+ const entries = await node_fs_promises.default.readdir(directory, { withFileTypes: true }).catch((error) => {
41
+ if (error.code === "ENOENT") return [];
42
+ throw error;
43
+ });
44
+ const others = (await Promise.all(entries.filter((entry) => entry.isDirectory() && !entry.name.startsWith(TEMPORARY_PREFIX) && !currentKeys.includes(entry.name)).map(async (entry) => ({
42
45
  name: entry.name,
43
- modified: node_fs.default.statSync(node_path.default.join(directory, entry.name)).mtimeMs
44
- })).sort((left, right) => right.modified - left.modified).slice(1).map((entry) => {
45
- node_fs.default.rmSync(node_path.default.join(directory, entry.name), {
46
+ modified: (await node_fs_promises.default.stat(node_path.default.join(directory, entry.name))).mtimeMs
47
+ })))).sort((left, right) => right.modified - left.modified);
48
+ return Promise.all(others.slice(1).map(async (entry) => {
49
+ await node_fs_promises.default.rm(node_path.default.join(directory, entry.name), {
46
50
  recursive: true,
47
51
  force: true
48
52
  });
49
53
  return `${kind}/${entry.name}`;
50
- });
54
+ }));
51
55
  }
52
56
  async function pruneAfterSync(input) {
53
57
  const poHome = (0, _agimon_ai_po_core_runtimePiSettings.poHomeDirectory)(input.homeDirectory, input.environment);
54
58
  const builds = [
55
- ...pruneBuilds(input.buildsRoot, BUILD_KINDS.web, input.webKey === void 0 ? [] : [input.webKey]),
56
- ...pruneBuilds(input.buildsRoot, BUILD_KINDS.native, input.nativeKey === void 0 ? [] : [input.nativeKey]),
57
- ...pruneBuilds(input.buildsRoot, BUILD_KINDS.mcpApp, input.mcpAppKeys ?? [])
59
+ ...await pruneBuilds(input.buildsRoot, BUILD_KINDS.web, input.webKey === void 0 ? [] : [input.webKey]),
60
+ ...await pruneBuilds(input.buildsRoot, BUILD_KINDS.native, input.nativeKey === void 0 ? [] : [input.nativeKey]),
61
+ ...await pruneBuilds(input.buildsRoot, BUILD_KINDS.mcpApp, input.mcpAppKeys ?? [])
58
62
  ];
59
- const hosts = require_index$1.otherPoHosts(poHome, input.scan ?? require_index$1.systemHostScan, input.selfPid ?? process.pid);
63
+ const hosts = await require_index$1.otherPoHosts(poHome, input.scan ?? require_index$1.systemHostScan, input.selfPid ?? process.pid);
60
64
  if (hosts.status === "running") return {
61
65
  status: "pruned",
62
66
  builds,
63
67
  runtime: { skipped: hosts.reason }
64
68
  };
65
69
  const runtimeDirectory = (0, _agimon_ai_po_core_runtimePiSettings.poRuntimeDirectory)(input.homeDirectory, input.environment);
66
- if (!node_fs.default.existsSync(node_path.default.join(runtimeDirectory, RUNTIME_MANIFEST))) return {
70
+ if (!await node_fs_promises.default.access(node_path.default.join(runtimeDirectory, RUNTIME_MANIFEST)).then(() => true, (error) => {
71
+ if (error.code === "ENOENT") return false;
72
+ throw error;
73
+ })) return {
67
74
  status: "pruned",
68
75
  builds,
69
76
  runtime: { skipped: "no runtime packages are installed" }
70
77
  };
71
- require_index.pruneStagedCatalogArchives(runtimeDirectory);
78
+ await require_index.pruneStagedCatalogArchives(runtimeDirectory);
72
79
  const result = await (input.pruneRuntime ?? _agimon_ai_po_core_runtimePackages.pruneRuntimePackages)({
73
80
  dir: runtimeDirectory,
74
81
  poHome
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":["path","fs","poHomeDirectory","otherPoHosts","systemHostScan","poRuntimeDirectory","pruneRuntimePackages"],"sources":["../../../../src/composition/syncPrune/index.ts"],"sourcesContent":["import fs from 'node:fs';\nimport path from 'node:path';\n\nimport { pruneRuntimePackages } from '@agimon-ai/po-core/runtimePackages';\nimport { poHomeDirectory, poRuntimeDirectory } from '@agimon-ai/po-core/runtimePiSettings';\n\nimport { pruneStagedCatalogArchives } from '../layerPackageInstaller';\nimport { type HostScan, otherPoHosts, systemHostScan } from '../poHomeMigration';\n\n/**\n * What an explicit `po sync` drops once its installs and builds are done:\n * - the runtime project's stale entries and store content nothing references (upm's prune,\n * which keeps anything written in the last hour);\n * - global web, native and MCP app builds other than the current key and the one before it.\n *\n * Sync calls this under its lock. Builds are pruned even while a Po server runs: the server\n * serves copies it publishes into `~/.po/server`, not these folders. The runtime is pruned only\n * when no other Po host runs, judged by the same scan that retires `~/.pi/.po`: a running server\n * may be installing into it, and upm's prune cannot be told to keep the previous manifest's\n * packages, so the runtime store grows while a server stays up. The staged catalogue archives\n * under `runtime/catalog` share that gate: a running server imports from them.\n */\n\nconst BUILD_DIRECTORY = 'build';\nconst BUILD_KINDS = { web: 'web', native: 'native', mcpApp: 'mcp-app' } as const;\nconst RUNTIME_MANIFEST = 'package.json';\n/** Builds an in-flight build writes start with a dot; they are never touched. */\nconst TEMPORARY_PREFIX = '.';\n\nexport interface SyncPruneInput {\n homeDirectory: string;\n environment: NodeJS.ProcessEnv;\n /** The root the global builds live under: `<root>/build/web/<key>`, `<root>/build/mcp-app/<key>`. */\n buildsRoot: string;\n /** The current global web build key; without one the web builds are left alone. */\n webKey?: string;\n /** The current global native build key; without one the native builds are left alone. */\n nativeKey?: string;\n /** The current MCP app build keys, one per distinct widget set; without any the MCP app builds are left alone. */\n mcpAppKeys?: readonly string[];\n /** Test seams. */\n scan?: HostScan;\n selfPid?: number;\n pruneRuntime?: typeof pruneRuntimePackages;\n}\n\nexport interface SyncPruneResult {\n status: 'pruned';\n /** Build directories removed, as `<kind>/<key>`. */\n builds: string[];\n /** Store bytes upm released, or why the runtime was not pruned. */\n runtime: { bytes: number } | { skipped: string };\n}\n\n/**\n * Removes every build of one kind except the current keys and the most recently written\n * other key, the one a client that has not refreshed yet may still load.\n */\nfunction pruneBuilds(buildsRoot: string, kind: string, currentKeys: readonly string[]): string[] {\n if (currentKeys.length === 0) return [];\n const directory = path.join(buildsRoot, BUILD_DIRECTORY, kind);\n if (!fs.existsSync(directory)) return [];\n const others = fs\n .readdirSync(directory, { withFileTypes: true })\n .filter(\n (entry) => entry.isDirectory() && !entry.name.startsWith(TEMPORARY_PREFIX) && !currentKeys.includes(entry.name),\n )\n .map((entry) => ({ name: entry.name, modified: fs.statSync(path.join(directory, entry.name)).mtimeMs }))\n .sort((left, right) => right.modified - left.modified);\n return others.slice(1).map((entry) => {\n fs.rmSync(path.join(directory, entry.name), { recursive: true, force: true });\n return `${kind}/${entry.name}`;\n });\n}\n\nexport async function pruneAfterSync(input: SyncPruneInput): Promise<SyncPruneResult> {\n const poHome = poHomeDirectory(input.homeDirectory, input.environment);\n const builds = [\n ...pruneBuilds(input.buildsRoot, BUILD_KINDS.web, input.webKey === undefined ? [] : [input.webKey]),\n ...pruneBuilds(input.buildsRoot, BUILD_KINDS.native, input.nativeKey === undefined ? [] : [input.nativeKey]),\n ...pruneBuilds(input.buildsRoot, BUILD_KINDS.mcpApp, input.mcpAppKeys ?? []),\n ];\n // ponytail: upm's prune has no keep-list, so the previous manifest cannot be protected while a\n // server runs; the runtime and its staged catalogue folders stay gated on no other host. A keep\n // option in upm is the upgrade.\n const hosts = otherPoHosts(poHome, input.scan ?? systemHostScan, input.selfPid ?? process.pid);\n if (hosts.status === 'running') return { status: 'pruned', builds, runtime: { skipped: hosts.reason } };\n const runtimeDirectory = poRuntimeDirectory(input.homeDirectory, input.environment);\n if (!fs.existsSync(path.join(runtimeDirectory, RUNTIME_MANIFEST))) {\n return { status: 'pruned', builds, runtime: { skipped: 'no runtime packages are installed' } };\n }\n pruneStagedCatalogArchives(runtimeDirectory);\n const result = await (input.pruneRuntime ?? pruneRuntimePackages)({ dir: runtimeDirectory, poHome });\n return {\n status: 'pruned',\n builds,\n runtime: { bytes: result.content.bytes + (result.entries?.bytes ?? 0) },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAuBA,MAAM,kBAAkB;AACxB,MAAM,cAAc;CAAE,KAAK;CAAO,QAAQ;CAAU,QAAQ;AAAU;AACtE,MAAM,mBAAmB;;AAEzB,MAAM,mBAAmB;;;;;AA+BzB,SAAS,YAAY,YAAoB,MAAc,aAA0C;CAC/F,IAAI,YAAY,WAAW,GAAG,OAAO,CAAC;CACtC,MAAM,YAAYA,UAAAA,QAAK,KAAK,YAAY,iBAAiB,IAAI;CAC7D,IAAI,CAACC,QAAAA,QAAG,WAAW,SAAS,GAAG,OAAO,CAAC;CAQvC,OAPeA,QAAAA,QACZ,YAAY,WAAW,EAAE,eAAe,KAAK,CAAC,CAAC,CAC/C,QACE,UAAU,MAAM,YAAY,KAAK,CAAC,MAAM,KAAK,WAAW,gBAAgB,KAAK,CAAC,YAAY,SAAS,MAAM,IAAI,CAChH,CAAC,CACA,KAAK,WAAW;EAAE,MAAM,MAAM;EAAM,UAAUA,QAAAA,QAAG,SAASD,UAAAA,QAAK,KAAK,WAAW,MAAM,IAAI,CAAC,CAAC,CAAC;CAAQ,EAAE,CAAC,CACvG,MAAM,MAAM,UAAU,MAAM,WAAW,KAAK,QACnC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,UAAU;EACpC,QAAA,QAAG,OAAOA,UAAAA,QAAK,KAAK,WAAW,MAAM,IAAI,GAAG;GAAE,WAAW;GAAM,OAAO;EAAK,CAAC;EAC5E,OAAO,GAAG,KAAK,GAAG,MAAM;CAC1B,CAAC;AACH;AAEA,eAAsB,eAAe,OAAiD;CACpF,MAAM,UAAA,GAASE,qCAAAA,gBAAAA,CAAgB,MAAM,eAAe,MAAM,WAAW;CACrE,MAAM,SAAS;EACb,GAAG,YAAY,MAAM,YAAY,YAAY,KAAK,MAAM,WAAW,KAAA,IAAY,CAAC,IAAI,CAAC,MAAM,MAAM,CAAC;EAClG,GAAG,YAAY,MAAM,YAAY,YAAY,QAAQ,MAAM,cAAc,KAAA,IAAY,CAAC,IAAI,CAAC,MAAM,SAAS,CAAC;EAC3G,GAAG,YAAY,MAAM,YAAY,YAAY,QAAQ,MAAM,cAAc,CAAC,CAAC;CAC7E;CAIA,MAAM,QAAQC,gBAAAA,aAAa,QAAQ,MAAM,QAAQC,gBAAAA,gBAAgB,MAAM,WAAW,QAAQ,GAAG;CAC7F,IAAI,MAAM,WAAW,WAAW,OAAO;EAAE,QAAQ;EAAU;EAAQ,SAAS,EAAE,SAAS,MAAM,OAAO;CAAE;CACtG,MAAM,oBAAA,GAAmBC,qCAAAA,mBAAAA,CAAmB,MAAM,eAAe,MAAM,WAAW;CAClF,IAAI,CAACJ,QAAAA,QAAG,WAAWD,UAAAA,QAAK,KAAK,kBAAkB,gBAAgB,CAAC,GAC9D,OAAO;EAAE,QAAQ;EAAU;EAAQ,SAAS,EAAE,SAAS,oCAAoC;CAAE;CAE/F,cAAA,2BAA2B,gBAAgB;CAC3C,MAAM,SAAS,OAAO,MAAM,gBAAgBM,mCAAAA,qBAAAA,CAAsB;EAAE,KAAK;EAAkB;CAAO,CAAC;CACnG,OAAO;EACL,QAAQ;EACR;EACA,SAAS,EAAE,OAAO,OAAO,QAAQ,SAAS,OAAO,SAAS,SAAS,GAAG;CACxE;AACF"}
1
+ {"version":3,"file":"index.cjs","names":["path","fs","poHomeDirectory","otherPoHosts","systemHostScan","poRuntimeDirectory","pruneStagedCatalogArchives","pruneRuntimePackages"],"sources":["../../../../src/composition/syncPrune/index.ts"],"sourcesContent":["import fs from 'node:fs/promises';\nimport path from 'node:path';\n\nimport { pruneRuntimePackages } from '@agimon-ai/po-core/runtimePackages';\nimport { poHomeDirectory, poRuntimeDirectory } from '@agimon-ai/po-core/runtimePiSettings';\n\nimport { pruneStagedCatalogArchives } from '../layerPackageInstaller';\nimport { type HostScan, otherPoHosts, systemHostScan } from '../poHomeMigration';\n\n/**\n * What an explicit `po sync` drops once its installs and builds are done:\n * - the runtime project's stale entries and store content nothing references (upm's prune,\n * which keeps anything written in the last hour);\n * - global web, native and MCP app builds other than the current key and the one before it.\n *\n * Sync calls this under its lock. Builds are pruned even while a Po server runs: the server\n * serves copies it publishes into `~/.po/server`, not these folders. The runtime is pruned only\n * when no other Po host runs, judged by the same scan that retires `~/.pi/.po`: a running server\n * may be installing into it, and upm's prune cannot be told to keep the previous manifest's\n * packages, so the runtime store grows while a server stays up. The staged catalogue archives\n * under `runtime/catalog` share that gate: a running server imports from them.\n */\n\nconst BUILD_DIRECTORY = 'build';\nconst BUILD_KINDS = { web: 'web', native: 'native', mcpApp: 'mcp-app' } as const;\nconst RUNTIME_MANIFEST = 'package.json';\n/** Builds an in-flight build writes start with a dot; they are never touched. */\nconst TEMPORARY_PREFIX = '.';\n\nexport interface SyncPruneInput {\n homeDirectory: string;\n environment: NodeJS.ProcessEnv;\n /** The root the global builds live under: `<root>/build/web/<key>`, `<root>/build/mcp-app/<key>`. */\n buildsRoot: string;\n /** The current global web build key; without one the web builds are left alone. */\n webKey?: string;\n /** The current global native build key; without one the native builds are left alone. */\n nativeKey?: string;\n /** The current MCP app build keys, one per distinct widget set; without any the MCP app builds are left alone. */\n mcpAppKeys?: readonly string[];\n /** Test seams. */\n scan?: HostScan;\n selfPid?: number;\n pruneRuntime?: typeof pruneRuntimePackages;\n}\n\nexport interface SyncPruneResult {\n status: 'pruned';\n /** Build directories removed, as `<kind>/<key>`. */\n builds: string[];\n /** Store bytes upm released, or why the runtime was not pruned. */\n runtime: { bytes: number } | { skipped: string };\n}\n\n/**\n * Removes every build of one kind except the current keys and the most recently written\n * other key, the one a client that has not refreshed yet may still load.\n */\nasync function pruneBuilds(buildsRoot: string, kind: string, currentKeys: readonly string[]): Promise<string[]> {\n if (currentKeys.length === 0) return [];\n const directory = path.join(buildsRoot, BUILD_DIRECTORY, kind);\n const entries = await fs.readdir(directory, { withFileTypes: true }).catch((error: NodeJS.ErrnoException) => {\n if (error.code === 'ENOENT') return [];\n throw error;\n });\n const others = (\n await Promise.all(\n entries\n .filter(\n (entry) =>\n entry.isDirectory() && !entry.name.startsWith(TEMPORARY_PREFIX) && !currentKeys.includes(entry.name),\n )\n .map(async (entry) => ({\n name: entry.name,\n modified: (await fs.stat(path.join(directory, entry.name))).mtimeMs,\n })),\n )\n ).sort((left, right) => right.modified - left.modified);\n return Promise.all(\n others.slice(1).map(async (entry) => {\n await fs.rm(path.join(directory, entry.name), { recursive: true, force: true });\n return `${kind}/${entry.name}`;\n }),\n );\n}\n\nexport async function pruneAfterSync(input: SyncPruneInput): Promise<SyncPruneResult> {\n const poHome = poHomeDirectory(input.homeDirectory, input.environment);\n const builds = [\n ...(await pruneBuilds(input.buildsRoot, BUILD_KINDS.web, input.webKey === undefined ? [] : [input.webKey])),\n ...(await pruneBuilds(\n input.buildsRoot,\n BUILD_KINDS.native,\n input.nativeKey === undefined ? [] : [input.nativeKey],\n )),\n ...(await pruneBuilds(input.buildsRoot, BUILD_KINDS.mcpApp, input.mcpAppKeys ?? [])),\n ];\n // ponytail: upm's prune has no keep-list, so the previous manifest cannot be protected while a\n // server runs; the runtime and its staged catalogue folders stay gated on no other host. A keep\n // option in upm is the upgrade.\n const hosts = await otherPoHosts(poHome, input.scan ?? systemHostScan, input.selfPid ?? process.pid);\n if (hosts.status === 'running') return { status: 'pruned', builds, runtime: { skipped: hosts.reason } };\n const runtimeDirectory = poRuntimeDirectory(input.homeDirectory, input.environment);\n if (\n !(await fs.access(path.join(runtimeDirectory, RUNTIME_MANIFEST)).then(\n () => true,\n (error: NodeJS.ErrnoException) => {\n if (error.code === 'ENOENT') return false;\n throw error;\n },\n ))\n ) {\n return { status: 'pruned', builds, runtime: { skipped: 'no runtime packages are installed' } };\n }\n await pruneStagedCatalogArchives(runtimeDirectory);\n const result = await (input.pruneRuntime ?? pruneRuntimePackages)({ dir: runtimeDirectory, poHome });\n return {\n status: 'pruned',\n builds,\n runtime: { bytes: result.content.bytes + (result.entries?.bytes ?? 0) },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAuBA,MAAM,kBAAkB;AACxB,MAAM,cAAc;CAAE,KAAK;CAAO,QAAQ;CAAU,QAAQ;AAAU;AACtE,MAAM,mBAAmB;;AAEzB,MAAM,mBAAmB;;;;;AA+BzB,eAAe,YAAY,YAAoB,MAAc,aAAmD;CAC9G,IAAI,YAAY,WAAW,GAAG,OAAO,CAAC;CACtC,MAAM,YAAYA,UAAAA,QAAK,KAAK,YAAY,iBAAiB,IAAI;CAC7D,MAAM,UAAU,MAAMC,iBAAAA,QAAG,QAAQ,WAAW,EAAE,eAAe,KAAK,CAAC,CAAC,CAAC,OAAO,UAAiC;EAC3G,IAAI,MAAM,SAAS,UAAU,OAAO,CAAC;EACrC,MAAM;CACR,CAAC;CACD,MAAM,UACJ,MAAM,QAAQ,IACZ,QACG,QACE,UACC,MAAM,YAAY,KAAK,CAAC,MAAM,KAAK,WAAW,gBAAgB,KAAK,CAAC,YAAY,SAAS,MAAM,IAAI,CACvG,CAAC,CACA,IAAI,OAAO,WAAW;EACrB,MAAM,MAAM;EACZ,WAAW,MAAMA,iBAAAA,QAAG,KAAKD,UAAAA,QAAK,KAAK,WAAW,MAAM,IAAI,CAAC,EAAA,CAAG;CAC9D,EAAE,CACN,EAAA,CACA,MAAM,MAAM,UAAU,MAAM,WAAW,KAAK,QAAQ;CACtD,OAAO,QAAQ,IACb,OAAO,MAAM,CAAC,CAAC,CAAC,IAAI,OAAO,UAAU;EACnC,MAAMC,iBAAAA,QAAG,GAAGD,UAAAA,QAAK,KAAK,WAAW,MAAM,IAAI,GAAG;GAAE,WAAW;GAAM,OAAO;EAAK,CAAC;EAC9E,OAAO,GAAG,KAAK,GAAG,MAAM;CAC1B,CAAC,CACH;AACF;AAEA,eAAsB,eAAe,OAAiD;CACpF,MAAM,UAAA,GAASE,qCAAAA,gBAAAA,CAAgB,MAAM,eAAe,MAAM,WAAW;CACrE,MAAM,SAAS;EACb,GAAI,MAAM,YAAY,MAAM,YAAY,YAAY,KAAK,MAAM,WAAW,KAAA,IAAY,CAAC,IAAI,CAAC,MAAM,MAAM,CAAC;EACzG,GAAI,MAAM,YACR,MAAM,YACN,YAAY,QACZ,MAAM,cAAc,KAAA,IAAY,CAAC,IAAI,CAAC,MAAM,SAAS,CACvD;EACA,GAAI,MAAM,YAAY,MAAM,YAAY,YAAY,QAAQ,MAAM,cAAc,CAAC,CAAC;CACpF;CAIA,MAAM,QAAQ,MAAMC,gBAAAA,aAAa,QAAQ,MAAM,QAAQC,gBAAAA,gBAAgB,MAAM,WAAW,QAAQ,GAAG;CACnG,IAAI,MAAM,WAAW,WAAW,OAAO;EAAE,QAAQ;EAAU;EAAQ,SAAS,EAAE,SAAS,MAAM,OAAO;CAAE;CACtG,MAAM,oBAAA,GAAmBC,qCAAAA,mBAAAA,CAAmB,MAAM,eAAe,MAAM,WAAW;CAClF,IACE,CAAE,MAAMJ,iBAAAA,QAAG,OAAOD,UAAAA,QAAK,KAAK,kBAAkB,gBAAgB,CAAC,CAAC,CAAC,WACzD,OACL,UAAiC;EAChC,IAAI,MAAM,SAAS,UAAU,OAAO;EACpC,MAAM;CACR,CACF,GAEA,OAAO;EAAE,QAAQ;EAAU;EAAQ,SAAS,EAAE,SAAS,oCAAoC;CAAE;CAE/F,MAAMM,cAAAA,2BAA2B,gBAAgB;CACjD,MAAM,SAAS,OAAO,MAAM,gBAAgBC,mCAAAA,qBAAAA,CAAsB;EAAE,KAAK;EAAkB;CAAO,CAAC;CACnG,OAAO;EACL,QAAQ;EACR;EACA,SAAS,EAAE,OAAO,OAAO,QAAQ,SAAS,OAAO,SAAS,SAAS,GAAG;CACxE;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","names":[],"sources":["../../../../src/composition/syncPrune/index.ts"],"mappings":";;;iBA6BiB;EACf;EACA,aAAa,OAAO;;EAEpB;;EAEA;;EAEA;;EAEA;;EAEA,OAAO;EACP;EACA,sBAAsB;;iBAGP;EACf;;EAEA;;EAEA;IAAW;;IAAoB;;;wBAwBX,eAAe,OAAO,iBAAiB,QAAQ"}
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../../../../src/composition/syncPrune/index.ts"],"mappings":";;;iBA6BiB;EACf;EACA,aAAa,OAAO;;EAEpB;;EAEA;;EAEA;;EAEA;;EAEA,OAAO;EACP;EACA,sBAAsB;;iBAGP;EACf;;EAEA;;EAEA;IAAW;;IAAoB;;;wBAmCX,eAAe,OAAO,iBAAiB,QAAQ"}
@@ -1,9 +1,9 @@
1
1
  import { pruneStagedCatalogArchives } from "../layerPackageInstaller/index.mjs";
2
2
  import { otherPoHosts, systemHostScan } from "../poHomeMigration/index.mjs";
3
- import fs from "node:fs";
3
+ import { poHomeDirectory, poRuntimeDirectory } from "@agimon-ai/po-core/runtimePiSettings";
4
4
  import path from "node:path";
5
+ import fs from "node:fs/promises";
5
6
  import { pruneRuntimePackages } from "@agimon-ai/po-core/runtimePackages";
6
- import { poHomeDirectory, poRuntimeDirectory } from "@agimon-ai/po-core/runtimePiSettings";
7
7
  //#region src/composition/syncPrune/index.ts
8
8
  /**
9
9
  * What an explicit `po sync` drops once its installs and builds are done:
@@ -31,41 +31,48 @@ const TEMPORARY_PREFIX = ".";
31
31
  * Removes every build of one kind except the current keys and the most recently written
32
32
  * other key, the one a client that has not refreshed yet may still load.
33
33
  */
34
- function pruneBuilds(buildsRoot, kind, currentKeys) {
34
+ async function pruneBuilds(buildsRoot, kind, currentKeys) {
35
35
  if (currentKeys.length === 0) return [];
36
36
  const directory = path.join(buildsRoot, BUILD_DIRECTORY, kind);
37
- if (!fs.existsSync(directory)) return [];
38
- return fs.readdirSync(directory, { withFileTypes: true }).filter((entry) => entry.isDirectory() && !entry.name.startsWith(TEMPORARY_PREFIX) && !currentKeys.includes(entry.name)).map((entry) => ({
37
+ const entries = await fs.readdir(directory, { withFileTypes: true }).catch((error) => {
38
+ if (error.code === "ENOENT") return [];
39
+ throw error;
40
+ });
41
+ const others = (await Promise.all(entries.filter((entry) => entry.isDirectory() && !entry.name.startsWith(TEMPORARY_PREFIX) && !currentKeys.includes(entry.name)).map(async (entry) => ({
39
42
  name: entry.name,
40
- modified: fs.statSync(path.join(directory, entry.name)).mtimeMs
41
- })).sort((left, right) => right.modified - left.modified).slice(1).map((entry) => {
42
- fs.rmSync(path.join(directory, entry.name), {
43
+ modified: (await fs.stat(path.join(directory, entry.name))).mtimeMs
44
+ })))).sort((left, right) => right.modified - left.modified);
45
+ return Promise.all(others.slice(1).map(async (entry) => {
46
+ await fs.rm(path.join(directory, entry.name), {
43
47
  recursive: true,
44
48
  force: true
45
49
  });
46
50
  return `${kind}/${entry.name}`;
47
- });
51
+ }));
48
52
  }
49
53
  async function pruneAfterSync(input) {
50
54
  const poHome = poHomeDirectory(input.homeDirectory, input.environment);
51
55
  const builds = [
52
- ...pruneBuilds(input.buildsRoot, BUILD_KINDS.web, input.webKey === void 0 ? [] : [input.webKey]),
53
- ...pruneBuilds(input.buildsRoot, BUILD_KINDS.native, input.nativeKey === void 0 ? [] : [input.nativeKey]),
54
- ...pruneBuilds(input.buildsRoot, BUILD_KINDS.mcpApp, input.mcpAppKeys ?? [])
56
+ ...await pruneBuilds(input.buildsRoot, BUILD_KINDS.web, input.webKey === void 0 ? [] : [input.webKey]),
57
+ ...await pruneBuilds(input.buildsRoot, BUILD_KINDS.native, input.nativeKey === void 0 ? [] : [input.nativeKey]),
58
+ ...await pruneBuilds(input.buildsRoot, BUILD_KINDS.mcpApp, input.mcpAppKeys ?? [])
55
59
  ];
56
- const hosts = otherPoHosts(poHome, input.scan ?? systemHostScan, input.selfPid ?? process.pid);
60
+ const hosts = await otherPoHosts(poHome, input.scan ?? systemHostScan, input.selfPid ?? process.pid);
57
61
  if (hosts.status === "running") return {
58
62
  status: "pruned",
59
63
  builds,
60
64
  runtime: { skipped: hosts.reason }
61
65
  };
62
66
  const runtimeDirectory = poRuntimeDirectory(input.homeDirectory, input.environment);
63
- if (!fs.existsSync(path.join(runtimeDirectory, RUNTIME_MANIFEST))) return {
67
+ if (!await fs.access(path.join(runtimeDirectory, RUNTIME_MANIFEST)).then(() => true, (error) => {
68
+ if (error.code === "ENOENT") return false;
69
+ throw error;
70
+ })) return {
64
71
  status: "pruned",
65
72
  builds,
66
73
  runtime: { skipped: "no runtime packages are installed" }
67
74
  };
68
- pruneStagedCatalogArchives(runtimeDirectory);
75
+ await pruneStagedCatalogArchives(runtimeDirectory);
69
76
  const result = await (input.pruneRuntime ?? pruneRuntimePackages)({
70
77
  dir: runtimeDirectory,
71
78
  poHome
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":[],"sources":["../../../../src/composition/syncPrune/index.ts"],"sourcesContent":["import fs from 'node:fs';\nimport path from 'node:path';\n\nimport { pruneRuntimePackages } from '@agimon-ai/po-core/runtimePackages';\nimport { poHomeDirectory, poRuntimeDirectory } from '@agimon-ai/po-core/runtimePiSettings';\n\nimport { pruneStagedCatalogArchives } from '../layerPackageInstaller';\nimport { type HostScan, otherPoHosts, systemHostScan } from '../poHomeMigration';\n\n/**\n * What an explicit `po sync` drops once its installs and builds are done:\n * - the runtime project's stale entries and store content nothing references (upm's prune,\n * which keeps anything written in the last hour);\n * - global web, native and MCP app builds other than the current key and the one before it.\n *\n * Sync calls this under its lock. Builds are pruned even while a Po server runs: the server\n * serves copies it publishes into `~/.po/server`, not these folders. The runtime is pruned only\n * when no other Po host runs, judged by the same scan that retires `~/.pi/.po`: a running server\n * may be installing into it, and upm's prune cannot be told to keep the previous manifest's\n * packages, so the runtime store grows while a server stays up. The staged catalogue archives\n * under `runtime/catalog` share that gate: a running server imports from them.\n */\n\nconst BUILD_DIRECTORY = 'build';\nconst BUILD_KINDS = { web: 'web', native: 'native', mcpApp: 'mcp-app' } as const;\nconst RUNTIME_MANIFEST = 'package.json';\n/** Builds an in-flight build writes start with a dot; they are never touched. */\nconst TEMPORARY_PREFIX = '.';\n\nexport interface SyncPruneInput {\n homeDirectory: string;\n environment: NodeJS.ProcessEnv;\n /** The root the global builds live under: `<root>/build/web/<key>`, `<root>/build/mcp-app/<key>`. */\n buildsRoot: string;\n /** The current global web build key; without one the web builds are left alone. */\n webKey?: string;\n /** The current global native build key; without one the native builds are left alone. */\n nativeKey?: string;\n /** The current MCP app build keys, one per distinct widget set; without any the MCP app builds are left alone. */\n mcpAppKeys?: readonly string[];\n /** Test seams. */\n scan?: HostScan;\n selfPid?: number;\n pruneRuntime?: typeof pruneRuntimePackages;\n}\n\nexport interface SyncPruneResult {\n status: 'pruned';\n /** Build directories removed, as `<kind>/<key>`. */\n builds: string[];\n /** Store bytes upm released, or why the runtime was not pruned. */\n runtime: { bytes: number } | { skipped: string };\n}\n\n/**\n * Removes every build of one kind except the current keys and the most recently written\n * other key, the one a client that has not refreshed yet may still load.\n */\nfunction pruneBuilds(buildsRoot: string, kind: string, currentKeys: readonly string[]): string[] {\n if (currentKeys.length === 0) return [];\n const directory = path.join(buildsRoot, BUILD_DIRECTORY, kind);\n if (!fs.existsSync(directory)) return [];\n const others = fs\n .readdirSync(directory, { withFileTypes: true })\n .filter(\n (entry) => entry.isDirectory() && !entry.name.startsWith(TEMPORARY_PREFIX) && !currentKeys.includes(entry.name),\n )\n .map((entry) => ({ name: entry.name, modified: fs.statSync(path.join(directory, entry.name)).mtimeMs }))\n .sort((left, right) => right.modified - left.modified);\n return others.slice(1).map((entry) => {\n fs.rmSync(path.join(directory, entry.name), { recursive: true, force: true });\n return `${kind}/${entry.name}`;\n });\n}\n\nexport async function pruneAfterSync(input: SyncPruneInput): Promise<SyncPruneResult> {\n const poHome = poHomeDirectory(input.homeDirectory, input.environment);\n const builds = [\n ...pruneBuilds(input.buildsRoot, BUILD_KINDS.web, input.webKey === undefined ? [] : [input.webKey]),\n ...pruneBuilds(input.buildsRoot, BUILD_KINDS.native, input.nativeKey === undefined ? [] : [input.nativeKey]),\n ...pruneBuilds(input.buildsRoot, BUILD_KINDS.mcpApp, input.mcpAppKeys ?? []),\n ];\n // ponytail: upm's prune has no keep-list, so the previous manifest cannot be protected while a\n // server runs; the runtime and its staged catalogue folders stay gated on no other host. A keep\n // option in upm is the upgrade.\n const hosts = otherPoHosts(poHome, input.scan ?? systemHostScan, input.selfPid ?? process.pid);\n if (hosts.status === 'running') return { status: 'pruned', builds, runtime: { skipped: hosts.reason } };\n const runtimeDirectory = poRuntimeDirectory(input.homeDirectory, input.environment);\n if (!fs.existsSync(path.join(runtimeDirectory, RUNTIME_MANIFEST))) {\n return { status: 'pruned', builds, runtime: { skipped: 'no runtime packages are installed' } };\n }\n pruneStagedCatalogArchives(runtimeDirectory);\n const result = await (input.pruneRuntime ?? pruneRuntimePackages)({ dir: runtimeDirectory, poHome });\n return {\n status: 'pruned',\n builds,\n runtime: { bytes: result.content.bytes + (result.entries?.bytes ?? 0) },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAuBA,MAAM,kBAAkB;AACxB,MAAM,cAAc;CAAE,KAAK;CAAO,QAAQ;CAAU,QAAQ;AAAU;AACtE,MAAM,mBAAmB;;AAEzB,MAAM,mBAAmB;;;;;AA+BzB,SAAS,YAAY,YAAoB,MAAc,aAA0C;CAC/F,IAAI,YAAY,WAAW,GAAG,OAAO,CAAC;CACtC,MAAM,YAAY,KAAK,KAAK,YAAY,iBAAiB,IAAI;CAC7D,IAAI,CAAC,GAAG,WAAW,SAAS,GAAG,OAAO,CAAC;CAQvC,OAPe,GACZ,YAAY,WAAW,EAAE,eAAe,KAAK,CAAC,CAAC,CAC/C,QACE,UAAU,MAAM,YAAY,KAAK,CAAC,MAAM,KAAK,WAAW,gBAAgB,KAAK,CAAC,YAAY,SAAS,MAAM,IAAI,CAChH,CAAC,CACA,KAAK,WAAW;EAAE,MAAM,MAAM;EAAM,UAAU,GAAG,SAAS,KAAK,KAAK,WAAW,MAAM,IAAI,CAAC,CAAC,CAAC;CAAQ,EAAE,CAAC,CACvG,MAAM,MAAM,UAAU,MAAM,WAAW,KAAK,QACnC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,UAAU;EACpC,GAAG,OAAO,KAAK,KAAK,WAAW,MAAM,IAAI,GAAG;GAAE,WAAW;GAAM,OAAO;EAAK,CAAC;EAC5E,OAAO,GAAG,KAAK,GAAG,MAAM;CAC1B,CAAC;AACH;AAEA,eAAsB,eAAe,OAAiD;CACpF,MAAM,SAAS,gBAAgB,MAAM,eAAe,MAAM,WAAW;CACrE,MAAM,SAAS;EACb,GAAG,YAAY,MAAM,YAAY,YAAY,KAAK,MAAM,WAAW,KAAA,IAAY,CAAC,IAAI,CAAC,MAAM,MAAM,CAAC;EAClG,GAAG,YAAY,MAAM,YAAY,YAAY,QAAQ,MAAM,cAAc,KAAA,IAAY,CAAC,IAAI,CAAC,MAAM,SAAS,CAAC;EAC3G,GAAG,YAAY,MAAM,YAAY,YAAY,QAAQ,MAAM,cAAc,CAAC,CAAC;CAC7E;CAIA,MAAM,QAAQ,aAAa,QAAQ,MAAM,QAAQ,gBAAgB,MAAM,WAAW,QAAQ,GAAG;CAC7F,IAAI,MAAM,WAAW,WAAW,OAAO;EAAE,QAAQ;EAAU;EAAQ,SAAS,EAAE,SAAS,MAAM,OAAO;CAAE;CACtG,MAAM,mBAAmB,mBAAmB,MAAM,eAAe,MAAM,WAAW;CAClF,IAAI,CAAC,GAAG,WAAW,KAAK,KAAK,kBAAkB,gBAAgB,CAAC,GAC9D,OAAO;EAAE,QAAQ;EAAU;EAAQ,SAAS,EAAE,SAAS,oCAAoC;CAAE;CAE/F,2BAA2B,gBAAgB;CAC3C,MAAM,SAAS,OAAO,MAAM,gBAAgB,qBAAA,CAAsB;EAAE,KAAK;EAAkB;CAAO,CAAC;CACnG,OAAO;EACL,QAAQ;EACR;EACA,SAAS,EAAE,OAAO,OAAO,QAAQ,SAAS,OAAO,SAAS,SAAS,GAAG;CACxE;AACF"}
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../../../../src/composition/syncPrune/index.ts"],"sourcesContent":["import fs from 'node:fs/promises';\nimport path from 'node:path';\n\nimport { pruneRuntimePackages } from '@agimon-ai/po-core/runtimePackages';\nimport { poHomeDirectory, poRuntimeDirectory } from '@agimon-ai/po-core/runtimePiSettings';\n\nimport { pruneStagedCatalogArchives } from '../layerPackageInstaller';\nimport { type HostScan, otherPoHosts, systemHostScan } from '../poHomeMigration';\n\n/**\n * What an explicit `po sync` drops once its installs and builds are done:\n * - the runtime project's stale entries and store content nothing references (upm's prune,\n * which keeps anything written in the last hour);\n * - global web, native and MCP app builds other than the current key and the one before it.\n *\n * Sync calls this under its lock. Builds are pruned even while a Po server runs: the server\n * serves copies it publishes into `~/.po/server`, not these folders. The runtime is pruned only\n * when no other Po host runs, judged by the same scan that retires `~/.pi/.po`: a running server\n * may be installing into it, and upm's prune cannot be told to keep the previous manifest's\n * packages, so the runtime store grows while a server stays up. The staged catalogue archives\n * under `runtime/catalog` share that gate: a running server imports from them.\n */\n\nconst BUILD_DIRECTORY = 'build';\nconst BUILD_KINDS = { web: 'web', native: 'native', mcpApp: 'mcp-app' } as const;\nconst RUNTIME_MANIFEST = 'package.json';\n/** Builds an in-flight build writes start with a dot; they are never touched. */\nconst TEMPORARY_PREFIX = '.';\n\nexport interface SyncPruneInput {\n homeDirectory: string;\n environment: NodeJS.ProcessEnv;\n /** The root the global builds live under: `<root>/build/web/<key>`, `<root>/build/mcp-app/<key>`. */\n buildsRoot: string;\n /** The current global web build key; without one the web builds are left alone. */\n webKey?: string;\n /** The current global native build key; without one the native builds are left alone. */\n nativeKey?: string;\n /** The current MCP app build keys, one per distinct widget set; without any the MCP app builds are left alone. */\n mcpAppKeys?: readonly string[];\n /** Test seams. */\n scan?: HostScan;\n selfPid?: number;\n pruneRuntime?: typeof pruneRuntimePackages;\n}\n\nexport interface SyncPruneResult {\n status: 'pruned';\n /** Build directories removed, as `<kind>/<key>`. */\n builds: string[];\n /** Store bytes upm released, or why the runtime was not pruned. */\n runtime: { bytes: number } | { skipped: string };\n}\n\n/**\n * Removes every build of one kind except the current keys and the most recently written\n * other key, the one a client that has not refreshed yet may still load.\n */\nasync function pruneBuilds(buildsRoot: string, kind: string, currentKeys: readonly string[]): Promise<string[]> {\n if (currentKeys.length === 0) return [];\n const directory = path.join(buildsRoot, BUILD_DIRECTORY, kind);\n const entries = await fs.readdir(directory, { withFileTypes: true }).catch((error: NodeJS.ErrnoException) => {\n if (error.code === 'ENOENT') return [];\n throw error;\n });\n const others = (\n await Promise.all(\n entries\n .filter(\n (entry) =>\n entry.isDirectory() && !entry.name.startsWith(TEMPORARY_PREFIX) && !currentKeys.includes(entry.name),\n )\n .map(async (entry) => ({\n name: entry.name,\n modified: (await fs.stat(path.join(directory, entry.name))).mtimeMs,\n })),\n )\n ).sort((left, right) => right.modified - left.modified);\n return Promise.all(\n others.slice(1).map(async (entry) => {\n await fs.rm(path.join(directory, entry.name), { recursive: true, force: true });\n return `${kind}/${entry.name}`;\n }),\n );\n}\n\nexport async function pruneAfterSync(input: SyncPruneInput): Promise<SyncPruneResult> {\n const poHome = poHomeDirectory(input.homeDirectory, input.environment);\n const builds = [\n ...(await pruneBuilds(input.buildsRoot, BUILD_KINDS.web, input.webKey === undefined ? [] : [input.webKey])),\n ...(await pruneBuilds(\n input.buildsRoot,\n BUILD_KINDS.native,\n input.nativeKey === undefined ? [] : [input.nativeKey],\n )),\n ...(await pruneBuilds(input.buildsRoot, BUILD_KINDS.mcpApp, input.mcpAppKeys ?? [])),\n ];\n // ponytail: upm's prune has no keep-list, so the previous manifest cannot be protected while a\n // server runs; the runtime and its staged catalogue folders stay gated on no other host. A keep\n // option in upm is the upgrade.\n const hosts = await otherPoHosts(poHome, input.scan ?? systemHostScan, input.selfPid ?? process.pid);\n if (hosts.status === 'running') return { status: 'pruned', builds, runtime: { skipped: hosts.reason } };\n const runtimeDirectory = poRuntimeDirectory(input.homeDirectory, input.environment);\n if (\n !(await fs.access(path.join(runtimeDirectory, RUNTIME_MANIFEST)).then(\n () => true,\n (error: NodeJS.ErrnoException) => {\n if (error.code === 'ENOENT') return false;\n throw error;\n },\n ))\n ) {\n return { status: 'pruned', builds, runtime: { skipped: 'no runtime packages are installed' } };\n }\n await pruneStagedCatalogArchives(runtimeDirectory);\n const result = await (input.pruneRuntime ?? pruneRuntimePackages)({ dir: runtimeDirectory, poHome });\n return {\n status: 'pruned',\n builds,\n runtime: { bytes: result.content.bytes + (result.entries?.bytes ?? 0) },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAuBA,MAAM,kBAAkB;AACxB,MAAM,cAAc;CAAE,KAAK;CAAO,QAAQ;CAAU,QAAQ;AAAU;AACtE,MAAM,mBAAmB;;AAEzB,MAAM,mBAAmB;;;;;AA+BzB,eAAe,YAAY,YAAoB,MAAc,aAAmD;CAC9G,IAAI,YAAY,WAAW,GAAG,OAAO,CAAC;CACtC,MAAM,YAAY,KAAK,KAAK,YAAY,iBAAiB,IAAI;CAC7D,MAAM,UAAU,MAAM,GAAG,QAAQ,WAAW,EAAE,eAAe,KAAK,CAAC,CAAC,CAAC,OAAO,UAAiC;EAC3G,IAAI,MAAM,SAAS,UAAU,OAAO,CAAC;EACrC,MAAM;CACR,CAAC;CACD,MAAM,UACJ,MAAM,QAAQ,IACZ,QACG,QACE,UACC,MAAM,YAAY,KAAK,CAAC,MAAM,KAAK,WAAW,gBAAgB,KAAK,CAAC,YAAY,SAAS,MAAM,IAAI,CACvG,CAAC,CACA,IAAI,OAAO,WAAW;EACrB,MAAM,MAAM;EACZ,WAAW,MAAM,GAAG,KAAK,KAAK,KAAK,WAAW,MAAM,IAAI,CAAC,EAAA,CAAG;CAC9D,EAAE,CACN,EAAA,CACA,MAAM,MAAM,UAAU,MAAM,WAAW,KAAK,QAAQ;CACtD,OAAO,QAAQ,IACb,OAAO,MAAM,CAAC,CAAC,CAAC,IAAI,OAAO,UAAU;EACnC,MAAM,GAAG,GAAG,KAAK,KAAK,WAAW,MAAM,IAAI,GAAG;GAAE,WAAW;GAAM,OAAO;EAAK,CAAC;EAC9E,OAAO,GAAG,KAAK,GAAG,MAAM;CAC1B,CAAC,CACH;AACF;AAEA,eAAsB,eAAe,OAAiD;CACpF,MAAM,SAAS,gBAAgB,MAAM,eAAe,MAAM,WAAW;CACrE,MAAM,SAAS;EACb,GAAI,MAAM,YAAY,MAAM,YAAY,YAAY,KAAK,MAAM,WAAW,KAAA,IAAY,CAAC,IAAI,CAAC,MAAM,MAAM,CAAC;EACzG,GAAI,MAAM,YACR,MAAM,YACN,YAAY,QACZ,MAAM,cAAc,KAAA,IAAY,CAAC,IAAI,CAAC,MAAM,SAAS,CACvD;EACA,GAAI,MAAM,YAAY,MAAM,YAAY,YAAY,QAAQ,MAAM,cAAc,CAAC,CAAC;CACpF;CAIA,MAAM,QAAQ,MAAM,aAAa,QAAQ,MAAM,QAAQ,gBAAgB,MAAM,WAAW,QAAQ,GAAG;CACnG,IAAI,MAAM,WAAW,WAAW,OAAO;EAAE,QAAQ;EAAU;EAAQ,SAAS,EAAE,SAAS,MAAM,OAAO;CAAE;CACtG,MAAM,mBAAmB,mBAAmB,MAAM,eAAe,MAAM,WAAW;CAClF,IACE,CAAE,MAAM,GAAG,OAAO,KAAK,KAAK,kBAAkB,gBAAgB,CAAC,CAAC,CAAC,WACzD,OACL,UAAiC;EAChC,IAAI,MAAM,SAAS,UAAU,OAAO;EACpC,MAAM;CACR,CACF,GAEA,OAAO;EAAE,QAAQ;EAAU;EAAQ,SAAS,EAAE,SAAS,oCAAoC;CAAE;CAE/F,MAAM,2BAA2B,gBAAgB;CACjD,MAAM,SAAS,OAAO,MAAM,gBAAgB,qBAAA,CAAsB;EAAE,KAAK;EAAkB;CAAO,CAAC;CACnG,OAAO;EACL,QAAQ;EACR;EACA,SAAS,EAAE,OAAO,OAAO,QAAQ,SAAS,OAAO,SAAS,SAAS,GAAG;CACxE;AACF"}