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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (621) hide show
  1. package/LICENSE +97 -8
  2. package/README.md +37 -722
  3. package/dist/apiContracts.cjs.map +1 -1
  4. package/dist/apiContracts.d.mts +2 -2
  5. package/dist/bin/cli.cjs +12 -7
  6. package/dist/bin/cli.cjs.map +1 -1
  7. package/dist/bin/cli.mjs +12 -7
  8. package/dist/bin/cli.mjs.map +1 -1
  9. package/dist/bin/poRunner.cjs +24 -7
  10. package/dist/bin/poRunner.cjs.map +1 -1
  11. package/dist/bin/poRunner.d.mts +8 -0
  12. package/dist/bin/poRunner.d.mts.map +1 -1
  13. package/dist/bin/poRunner.mjs +24 -7
  14. package/dist/bin/poRunner.mjs.map +1 -1
  15. package/dist/bin/serve.cjs +28 -17
  16. package/dist/bin/serve.cjs.map +1 -1
  17. package/dist/bin/serve.mjs +28 -17
  18. package/dist/bin/serve.mjs.map +1 -1
  19. package/dist/builders/cli/extensionAssembler/index.cjs +53 -40
  20. package/dist/builders/cli/extensionAssembler/index.cjs.map +1 -1
  21. package/dist/builders/cli/extensionAssembler/index.d.mts +11 -6
  22. package/dist/builders/cli/extensionAssembler/index.d.mts.map +1 -1
  23. package/dist/builders/cli/extensionAssembler/index.mjs +53 -41
  24. package/dist/builders/cli/extensionAssembler/index.mjs.map +1 -1
  25. package/dist/catalog/index.json +662 -105
  26. package/dist/cli.cjs +9 -14
  27. package/dist/cli.d.mts +1 -3
  28. package/dist/cli.mjs +1 -3
  29. package/dist/commands.cjs +13 -15
  30. package/dist/commands.d.mts +1 -2
  31. package/dist/commands.mjs +1 -2
  32. package/dist/config.cjs +9 -14
  33. package/dist/config.d.mts +3 -2
  34. package/dist/config.mjs +3 -2
  35. package/dist/extensions/server.cjs +30 -23
  36. package/dist/extensions/server.cjs.map +1 -1
  37. package/dist/extensions/server.d.mts.map +1 -1
  38. package/dist/extensions/server.mjs +31 -24
  39. package/dist/extensions/server.mjs.map +1 -1
  40. package/dist/harnessContext.cjs +0 -1
  41. package/dist/harnessContext.d.mts +2 -2
  42. package/dist/harnessContext.mjs +1 -1
  43. package/dist/harnessState.cjs +2 -1
  44. package/dist/help.cjs +9 -11
  45. package/dist/help.d.mts +1 -2
  46. package/dist/help.mjs +1 -2
  47. package/dist/index.cjs +40 -67
  48. package/dist/index.d.mts +7 -16
  49. package/dist/index.mjs +7 -14
  50. package/dist/matrixOptions.cjs +10 -5
  51. package/dist/matrixOptions.d.mts +2 -2
  52. package/dist/matrixOptions.mjs +1 -1
  53. package/dist/package.cjs +11 -0
  54. package/dist/package.cjs.map +1 -0
  55. package/dist/package.mjs +6 -0
  56. package/dist/package.mjs.map +1 -0
  57. package/dist/projectTrust.cjs +3 -0
  58. package/dist/projectTrust.d.mts +2 -2
  59. package/dist/projectTrust.mjs +1 -1
  60. package/dist/repository.cjs +1 -0
  61. package/dist/repository.d.mts +2 -2
  62. package/dist/repository.mjs +1 -1
  63. package/dist/services.cjs +5 -20
  64. package/dist/services.d.mts +3 -8
  65. package/dist/services.mjs +3 -8
  66. package/dist/shared.cjs +4 -17
  67. package/dist/shared.d.mts +2 -2
  68. package/dist/shared.mjs +1 -1
  69. package/dist/src/bin/agentDirectory.cjs +19 -15
  70. package/dist/src/bin/agentDirectory.cjs.map +1 -1
  71. package/dist/src/bin/agentDirectory.mjs +16 -13
  72. package/dist/src/bin/agentDirectory.mjs.map +1 -1
  73. package/dist/src/builders/apiContractExport/index.cjs +23 -22
  74. package/dist/src/builders/apiContractExport/index.cjs.map +1 -1
  75. package/dist/src/builders/apiContractExport/index.mjs +22 -21
  76. package/dist/src/builders/apiContractExport/index.mjs.map +1 -1
  77. package/dist/src/builders/cli/entryResolution.cjs +2 -2
  78. package/dist/src/builders/cli/entryResolution.cjs.map +1 -1
  79. package/dist/src/builders/cli/entryResolution.mjs +1 -1
  80. package/dist/src/builders/cli/entryResolution.mjs.map +1 -1
  81. package/dist/src/builders/cli/harnessContext.cjs +38 -43
  82. package/dist/src/builders/cli/harnessContext.cjs.map +1 -1
  83. package/dist/src/builders/cli/harnessContext.d.mts +11 -10
  84. package/dist/src/builders/cli/harnessContext.d.mts.map +1 -1
  85. package/dist/src/builders/cli/harnessContext.mjs +37 -41
  86. package/dist/src/builders/cli/harnessContext.mjs.map +1 -1
  87. package/dist/src/builders/cli/sessionComposition.cjs +23 -12
  88. package/dist/src/builders/cli/sessionComposition.cjs.map +1 -1
  89. package/dist/src/builders/cli/sessionComposition.mjs +23 -12
  90. package/dist/src/builders/cli/sessionComposition.mjs.map +1 -1
  91. package/dist/src/builders/isolate/compile.cjs +226 -0
  92. package/dist/src/builders/isolate/compile.cjs.map +1 -0
  93. package/dist/src/builders/isolate/compile.mjs +222 -0
  94. package/dist/src/builders/isolate/compile.mjs.map +1 -0
  95. package/dist/src/builders/isolate/index.cjs +195 -0
  96. package/dist/src/builders/isolate/index.cjs.map +1 -0
  97. package/dist/src/builders/isolate/index.mjs +192 -0
  98. package/dist/src/builders/isolate/index.mjs.map +1 -0
  99. package/dist/src/builders/isolate/membrane.cjs +198 -0
  100. package/dist/src/builders/isolate/membrane.cjs.map +1 -0
  101. package/dist/src/builders/isolate/membrane.mjs +198 -0
  102. package/dist/src/builders/isolate/membrane.mjs.map +1 -0
  103. package/dist/src/builders/isolate/names.cjs +10 -0
  104. package/dist/src/builders/isolate/names.cjs.map +1 -0
  105. package/dist/src/builders/isolate/names.mjs +9 -0
  106. package/dist/src/builders/isolate/names.mjs.map +1 -0
  107. package/dist/src/builders/native/index.cjs +229 -67
  108. package/dist/src/builders/native/index.cjs.map +1 -1
  109. package/dist/src/builders/native/index.d.mts +4 -2
  110. package/dist/src/builders/native/index.d.mts.map +1 -1
  111. package/dist/src/builders/native/index.mjs +229 -68
  112. package/dist/src/builders/native/index.mjs.map +1 -1
  113. package/dist/src/builders/npm/index.cjs +76 -0
  114. package/dist/src/builders/npm/index.cjs.map +1 -0
  115. package/dist/src/builders/npm/index.mjs +73 -0
  116. package/dist/src/builders/npm/index.mjs.map +1 -0
  117. package/dist/src/builders/server/backgroundSync.cjs +62 -39
  118. package/dist/src/builders/server/backgroundSync.cjs.map +1 -1
  119. package/dist/src/builders/server/backgroundSync.mjs +62 -38
  120. package/dist/src/builders/server/backgroundSync.mjs.map +1 -1
  121. package/dist/src/builders/server/bundlerService.cjs +165 -35
  122. package/dist/src/builders/server/bundlerService.cjs.map +1 -1
  123. package/dist/src/builders/server/bundlerService.mjs +164 -36
  124. package/dist/src/builders/server/bundlerService.mjs.map +1 -1
  125. package/dist/src/builders/server/capabilities.cjs +103 -0
  126. package/dist/src/builders/server/capabilities.cjs.map +1 -0
  127. package/dist/src/builders/server/capabilities.mjs +101 -0
  128. package/dist/src/builders/server/capabilities.mjs.map +1 -0
  129. package/dist/src/builders/server/computerUseBinding.cjs +62 -10
  130. package/dist/src/builders/server/computerUseBinding.cjs.map +1 -1
  131. package/dist/src/builders/server/computerUseBinding.mjs +60 -8
  132. package/dist/src/builders/server/computerUseBinding.mjs.map +1 -1
  133. package/dist/src/builders/server/computerUseRecordings.cjs +152 -51
  134. package/dist/src/builders/server/computerUseRecordings.cjs.map +1 -1
  135. package/dist/src/builders/server/computerUseRecordings.mjs +158 -59
  136. package/dist/src/builders/server/computerUseRecordings.mjs.map +1 -1
  137. package/dist/src/builders/server/containedSessions.cjs +152 -0
  138. package/dist/src/builders/server/containedSessions.cjs.map +1 -0
  139. package/dist/src/builders/server/containedSessions.mjs +146 -0
  140. package/dist/src/builders/server/containedSessions.mjs.map +1 -0
  141. package/dist/src/builders/server/defaultWorkspace.cjs +46 -11
  142. package/dist/src/builders/server/defaultWorkspace.cjs.map +1 -1
  143. package/dist/src/builders/server/defaultWorkspace.mjs +42 -10
  144. package/dist/src/builders/server/defaultWorkspace.mjs.map +1 -1
  145. package/dist/src/builders/server/electronBinding.cjs +82 -0
  146. package/dist/src/builders/server/electronBinding.cjs.map +1 -0
  147. package/dist/src/builders/server/electronBinding.mjs +82 -0
  148. package/dist/src/builders/server/electronBinding.mjs.map +1 -0
  149. package/dist/src/builders/server/federation.cjs +364 -0
  150. package/dist/src/builders/server/federation.cjs.map +1 -0
  151. package/dist/src/builders/server/federation.mjs +363 -0
  152. package/dist/src/builders/server/federation.mjs.map +1 -0
  153. package/dist/src/builders/server/hostDisplayName.cjs +14 -0
  154. package/dist/src/builders/server/hostDisplayName.cjs.map +1 -0
  155. package/dist/src/builders/server/hostDisplayName.mjs +14 -0
  156. package/dist/src/builders/server/hostDisplayName.mjs.map +1 -0
  157. package/dist/src/builders/server/hostModelGateway.cjs +41 -0
  158. package/dist/src/builders/server/hostModelGateway.cjs.map +1 -0
  159. package/dist/src/builders/server/hostModelGateway.mjs +39 -0
  160. package/dist/src/builders/server/hostModelGateway.mjs.map +1 -0
  161. package/dist/src/builders/server/hostTeam.cjs +188 -0
  162. package/dist/src/builders/server/hostTeam.cjs.map +1 -0
  163. package/dist/src/builders/server/hostTeam.mjs +180 -0
  164. package/dist/src/builders/server/hostTeam.mjs.map +1 -0
  165. package/dist/src/builders/server/idleRestart.cjs +185 -40
  166. package/dist/src/builders/server/idleRestart.cjs.map +1 -1
  167. package/dist/src/builders/server/idleRestart.mjs +176 -39
  168. package/dist/src/builders/server/idleRestart.mjs.map +1 -1
  169. package/dist/src/builders/server/index.cjs +33 -19
  170. package/dist/src/builders/server/index.cjs.map +1 -1
  171. package/dist/src/builders/server/index.mjs +33 -18
  172. package/dist/src/builders/server/index.mjs.map +1 -1
  173. package/dist/src/builders/server/liveActivityPush.cjs +202 -0
  174. package/dist/src/builders/server/liveActivityPush.cjs.map +1 -0
  175. package/dist/src/builders/server/liveActivityPush.mjs +202 -0
  176. package/dist/src/builders/server/liveActivityPush.mjs.map +1 -0
  177. package/dist/src/builders/server/logSink.cjs +12 -10
  178. package/dist/src/builders/server/logSink.cjs.map +1 -1
  179. package/dist/src/builders/server/logSink.mjs +12 -10
  180. package/dist/src/builders/server/logSink.mjs.map +1 -1
  181. package/dist/src/builders/server/mcpApp.cjs +27 -20
  182. package/dist/src/builders/server/mcpApp.cjs.map +1 -1
  183. package/dist/src/builders/server/mcpApp.mjs +25 -18
  184. package/dist/src/builders/server/mcpApp.mjs.map +1 -1
  185. package/dist/src/builders/server/mcpAppBuild.cjs +61 -41
  186. package/dist/src/builders/server/mcpAppBuild.cjs.map +1 -1
  187. package/dist/src/builders/server/mcpAppBuild.d.mts +3 -6
  188. package/dist/src/builders/server/mcpAppBuild.d.mts.map +1 -1
  189. package/dist/src/builders/server/mcpAppBuild.mjs +61 -40
  190. package/dist/src/builders/server/mcpAppBuild.mjs.map +1 -1
  191. package/dist/src/builders/server/mcpBundle.cjs +20 -16
  192. package/dist/src/builders/server/mcpBundle.cjs.map +1 -1
  193. package/dist/src/builders/server/mcpBundle.d.mts +2 -1
  194. package/dist/src/builders/server/mcpBundle.d.mts.map +1 -1
  195. package/dist/src/builders/server/mcpBundle.mjs +20 -15
  196. package/dist/src/builders/server/mcpBundle.mjs.map +1 -1
  197. package/dist/src/builders/server/nativePush.cjs +229 -0
  198. package/dist/src/builders/server/nativePush.cjs.map +1 -0
  199. package/dist/src/builders/server/nativePush.mjs +228 -0
  200. package/dist/src/builders/server/nativePush.mjs.map +1 -0
  201. package/dist/src/builders/server/network.cjs +887 -0
  202. package/dist/src/builders/server/network.cjs.map +1 -0
  203. package/dist/src/builders/server/network.mjs +886 -0
  204. package/dist/src/builders/server/network.mjs.map +1 -0
  205. package/dist/src/builders/server/networkGateway.cjs +123 -0
  206. package/dist/src/builders/server/networkGateway.cjs.map +1 -0
  207. package/dist/src/builders/server/networkGateway.mjs +123 -0
  208. package/dist/src/builders/server/networkGateway.mjs.map +1 -0
  209. package/dist/src/builders/server/networkRelay.cjs +83 -0
  210. package/dist/src/builders/server/networkRelay.cjs.map +1 -0
  211. package/dist/src/builders/server/networkRelay.mjs +81 -0
  212. package/dist/src/builders/server/networkRelay.mjs.map +1 -0
  213. package/dist/src/builders/server/orgPluginLibraryBinding.cjs +72 -0
  214. package/dist/src/builders/server/orgPluginLibraryBinding.cjs.map +1 -0
  215. package/dist/src/builders/server/orgPluginLibraryBinding.mjs +72 -0
  216. package/dist/src/builders/server/orgPluginLibraryBinding.mjs.map +1 -0
  217. package/dist/src/builders/server/packageReloadCheck.cjs +46 -2
  218. package/dist/src/builders/server/packageReloadCheck.cjs.map +1 -1
  219. package/dist/src/builders/server/packageReloadCheck.mjs +46 -3
  220. package/dist/src/builders/server/packageReloadCheck.mjs.map +1 -1
  221. package/dist/src/builders/server/packageUrl.cjs +161 -58
  222. package/dist/src/builders/server/packageUrl.cjs.map +1 -1
  223. package/dist/src/builders/server/packageUrl.mjs +162 -58
  224. package/dist/src/builders/server/packageUrl.mjs.map +1 -1
  225. package/dist/src/builders/server/privateRelay.cjs +309 -0
  226. package/dist/src/builders/server/privateRelay.cjs.map +1 -0
  227. package/dist/src/builders/server/privateRelay.mjs +305 -0
  228. package/dist/src/builders/server/privateRelay.mjs.map +1 -0
  229. package/dist/src/builders/server/privateRelayCarrier.cjs +316 -0
  230. package/dist/src/builders/server/privateRelayCarrier.cjs.map +1 -0
  231. package/dist/src/builders/server/privateRelayCarrier.mjs +309 -0
  232. package/dist/src/builders/server/privateRelayCarrier.mjs.map +1 -0
  233. package/dist/src/builders/server/runtime.cjs +2731 -485
  234. package/dist/src/builders/server/runtime.cjs.map +1 -1
  235. package/dist/src/builders/server/runtime.mjs +2741 -499
  236. package/dist/src/builders/server/runtime.mjs.map +1 -1
  237. package/dist/src/builders/server/runtimeResources.cjs +37 -0
  238. package/dist/src/builders/server/runtimeResources.cjs.map +1 -1
  239. package/dist/src/builders/server/runtimeResources.mjs +38 -2
  240. package/dist/src/builders/server/runtimeResources.mjs.map +1 -1
  241. package/dist/src/builders/server/sandboxRouter.cjs +815 -0
  242. package/dist/src/builders/server/sandboxRouter.cjs.map +1 -0
  243. package/dist/src/builders/server/sandboxRouter.mjs +811 -0
  244. package/dist/src/builders/server/sandboxRouter.mjs.map +1 -0
  245. package/dist/src/builders/server/sandboxSessionHandoff.cjs +298 -0
  246. package/dist/src/builders/server/sandboxSessionHandoff.cjs.map +1 -0
  247. package/dist/src/builders/server/sandboxSessionHandoff.mjs +287 -0
  248. package/dist/src/builders/server/sandboxSessionHandoff.mjs.map +1 -0
  249. package/dist/src/builders/server/scopeReloadController.cjs +80 -0
  250. package/dist/src/builders/server/scopeReloadController.cjs.map +1 -0
  251. package/dist/src/builders/server/scopeReloadController.mjs +80 -0
  252. package/dist/src/builders/server/scopeReloadController.mjs.map +1 -0
  253. package/dist/src/builders/server/selectionStatus.cjs +2 -2
  254. package/dist/src/builders/server/selectionStatus.cjs.map +1 -1
  255. package/dist/src/builders/server/selectionStatus.mjs +2 -2
  256. package/dist/src/builders/server/selectionStatus.mjs.map +1 -1
  257. package/dist/src/builders/server/sessionArguments.cjs +65 -7
  258. package/dist/src/builders/server/sessionArguments.cjs.map +1 -1
  259. package/dist/src/builders/server/sessionArguments.mjs +64 -8
  260. package/dist/src/builders/server/sessionArguments.mjs.map +1 -1
  261. package/dist/src/builders/server/sessionRemoval.cjs +233 -0
  262. package/dist/src/builders/server/sessionRemoval.cjs.map +1 -0
  263. package/dist/src/builders/server/sessionRemoval.mjs +224 -0
  264. package/dist/src/builders/server/sessionRemoval.mjs.map +1 -0
  265. package/dist/src/builders/server/sessionSummaries.cjs +32 -0
  266. package/dist/src/builders/server/sessionSummaries.cjs.map +1 -0
  267. package/dist/src/builders/server/sessionSummaries.mjs +31 -0
  268. package/dist/src/builders/server/sessionSummaries.mjs.map +1 -0
  269. package/dist/src/builders/server/shutdown.cjs +23 -0
  270. package/dist/src/builders/server/shutdown.cjs.map +1 -1
  271. package/dist/src/builders/server/shutdown.mjs +21 -1
  272. package/dist/src/builders/server/shutdown.mjs.map +1 -1
  273. package/dist/src/builders/server/shutdownStack.cjs +44 -0
  274. package/dist/src/builders/server/shutdownStack.cjs.map +1 -0
  275. package/dist/src/builders/server/shutdownStack.mjs +43 -0
  276. package/dist/src/builders/server/shutdownStack.mjs.map +1 -0
  277. package/dist/src/builders/server/toolBoundaryHold.cjs +55 -0
  278. package/dist/src/builders/server/toolBoundaryHold.cjs.map +1 -0
  279. package/dist/src/builders/server/toolBoundaryHold.mjs +55 -0
  280. package/dist/src/builders/server/toolBoundaryHold.mjs.map +1 -0
  281. package/dist/src/builders/server/watcherService.cjs +55 -28
  282. package/dist/src/builders/server/watcherService.cjs.map +1 -1
  283. package/dist/src/builders/server/watcherService.mjs +55 -27
  284. package/dist/src/builders/server/watcherService.mjs.map +1 -1
  285. package/dist/src/builders/server/webTemplateDecision.cjs +7 -3
  286. package/dist/src/builders/server/webTemplateDecision.cjs.map +1 -1
  287. package/dist/src/builders/server/webTemplateDecision.mjs +7 -3
  288. package/dist/src/builders/server/webTemplateDecision.mjs.map +1 -1
  289. package/dist/src/builders/server/workspaceAdmission.cjs +96 -0
  290. package/dist/src/builders/server/workspaceAdmission.cjs.map +1 -0
  291. package/dist/src/builders/server/workspaceAdmission.mjs +90 -0
  292. package/dist/src/builders/server/workspaceAdmission.mjs.map +1 -0
  293. package/dist/src/builders/server/workspaceCheckout.cjs +16 -7
  294. package/dist/src/builders/server/workspaceCheckout.cjs.map +1 -1
  295. package/dist/src/builders/server/workspaceCheckout.mjs +16 -7
  296. package/dist/src/builders/server/workspaceCheckout.mjs.map +1 -1
  297. package/dist/src/builders/web/bundle.cjs +16 -14
  298. package/dist/src/builders/web/bundle.cjs.map +1 -1
  299. package/dist/src/builders/web/bundle.d.mts +3 -0
  300. package/dist/src/builders/web/bundle.d.mts.map +1 -1
  301. package/dist/src/builders/web/bundle.mjs +15 -13
  302. package/dist/src/builders/web/bundle.mjs.map +1 -1
  303. package/dist/src/builders/web/index.cjs +77 -59
  304. package/dist/src/builders/web/index.cjs.map +1 -1
  305. package/dist/src/builders/web/index.d.mts +19 -14
  306. package/dist/src/builders/web/index.d.mts.map +1 -1
  307. package/dist/src/builders/web/index.mjs +76 -58
  308. package/dist/src/builders/web/index.mjs.map +1 -1
  309. package/dist/src/builders/web/webPluginGenerate.cjs +84 -45
  310. package/dist/src/builders/web/webPluginGenerate.cjs.map +1 -1
  311. package/dist/src/builders/web/webPluginGenerate.d.mts +13 -4
  312. package/dist/src/builders/web/webPluginGenerate.d.mts.map +1 -1
  313. package/dist/src/builders/web/webPluginGenerate.mjs +82 -44
  314. package/dist/src/builders/web/webPluginGenerate.mjs.map +1 -1
  315. package/dist/src/builders/web/webPluginManifest.cjs +24 -17
  316. package/dist/src/builders/web/webPluginManifest.cjs.map +1 -1
  317. package/dist/src/builders/web/webPluginManifest.d.mts +11 -23
  318. package/dist/src/builders/web/webPluginManifest.d.mts.map +1 -1
  319. package/dist/src/builders/web/webPluginManifest.mjs +23 -16
  320. package/dist/src/builders/web/webPluginManifest.mjs.map +1 -1
  321. package/dist/src/builders/web/webPluginScan.cjs +11 -8
  322. package/dist/src/builders/web/webPluginScan.cjs.map +1 -1
  323. package/dist/src/builders/web/webPluginScan.d.mts +1 -1
  324. package/dist/src/builders/web/webPluginScan.d.mts.map +1 -1
  325. package/dist/src/builders/web/webPluginScan.mjs +10 -7
  326. package/dist/src/builders/web/webPluginScan.mjs.map +1 -1
  327. package/dist/src/builders/web/webPluginVite.cjs +5 -5
  328. package/dist/src/builders/web/webPluginVite.cjs.map +1 -1
  329. package/dist/src/builders/web/webPluginVite.d.mts +1 -1
  330. package/dist/src/builders/web/webPluginVite.d.mts.map +1 -1
  331. package/dist/src/builders/web/webPluginVite.mjs +3 -3
  332. package/dist/src/builders/web/webPluginVite.mjs.map +1 -1
  333. package/dist/src/cli/cliApp.cjs +18 -19
  334. package/dist/src/cli/cliApp.cjs.map +1 -1
  335. package/dist/src/cli/cliApp.d.mts +1 -1
  336. package/dist/src/cli/cliApp.d.mts.map +1 -1
  337. package/dist/src/cli/cliApp.mjs +18 -19
  338. package/dist/src/cli/cliApp.mjs.map +1 -1
  339. package/dist/src/cli/commands/api-export/index.cjs +14 -13
  340. package/dist/src/cli/commands/api-export/index.cjs.map +1 -1
  341. package/dist/src/cli/commands/api-export/index.mjs +13 -12
  342. package/dist/src/cli/commands/api-export/index.mjs.map +1 -1
  343. package/dist/src/cli/commands/doctor/help.cjs +4 -3
  344. package/dist/src/cli/commands/doctor/help.cjs.map +1 -1
  345. package/dist/src/cli/commands/doctor/help.d.mts.map +1 -1
  346. package/dist/src/cli/commands/doctor/help.mjs +4 -3
  347. package/dist/src/cli/commands/doctor/help.mjs.map +1 -1
  348. package/dist/src/cli/commands/doctor/index.cjs +30 -17
  349. package/dist/src/cli/commands/doctor/index.cjs.map +1 -1
  350. package/dist/src/cli/commands/doctor/index.d.mts +4 -4
  351. package/dist/src/cli/commands/doctor/index.d.mts.map +1 -1
  352. package/dist/src/cli/commands/doctor/index.mjs +28 -15
  353. package/dist/src/cli/commands/doctor/index.mjs.map +1 -1
  354. package/dist/src/cli/commands/emit-mcp/index.cjs +3 -2
  355. package/dist/src/cli/commands/emit-mcp/index.cjs.map +1 -1
  356. package/dist/src/cli/commands/emit-mcp/index.d.mts.map +1 -1
  357. package/dist/src/cli/commands/emit-mcp/index.mjs +3 -2
  358. package/dist/src/cli/commands/emit-mcp/index.mjs.map +1 -1
  359. package/dist/src/cli/commands/explain/index.cjs +53 -38
  360. package/dist/src/cli/commands/explain/index.cjs.map +1 -1
  361. package/dist/src/cli/commands/explain/index.d.mts +3 -4
  362. package/dist/src/cli/commands/explain/index.d.mts.map +1 -1
  363. package/dist/src/cli/commands/explain/index.mjs +52 -37
  364. package/dist/src/cli/commands/explain/index.mjs.map +1 -1
  365. package/dist/src/cli/commands/init/help.cjs +3 -2
  366. package/dist/src/cli/commands/init/help.cjs.map +1 -1
  367. package/dist/src/cli/commands/init/help.d.mts.map +1 -1
  368. package/dist/src/cli/commands/init/help.mjs +3 -2
  369. package/dist/src/cli/commands/init/help.mjs.map +1 -1
  370. package/dist/src/cli/commands/init/index.cjs +17 -12
  371. package/dist/src/cli/commands/init/index.cjs.map +1 -1
  372. package/dist/src/cli/commands/init/index.d.mts.map +1 -1
  373. package/dist/src/cli/commands/init/index.mjs +16 -11
  374. package/dist/src/cli/commands/init/index.mjs.map +1 -1
  375. package/dist/src/cli/commands/init/presenter.cjs +29 -21
  376. package/dist/src/cli/commands/init/presenter.cjs.map +1 -1
  377. package/dist/src/cli/commands/init/presenter.mjs +29 -21
  378. package/dist/src/cli/commands/init/presenter.mjs.map +1 -1
  379. package/dist/src/cli/commands/sync/help.cjs +7 -3
  380. package/dist/src/cli/commands/sync/help.cjs.map +1 -1
  381. package/dist/src/cli/commands/sync/help.d.mts.map +1 -1
  382. package/dist/src/cli/commands/sync/help.mjs +7 -3
  383. package/dist/src/cli/commands/sync/help.mjs.map +1 -1
  384. package/dist/src/cli/commands/sync/index.cjs +72 -40
  385. package/dist/src/cli/commands/sync/index.cjs.map +1 -1
  386. package/dist/src/cli/commands/sync/index.d.mts.map +1 -1
  387. package/dist/src/cli/commands/sync/index.mjs +69 -37
  388. package/dist/src/cli/commands/sync/index.mjs.map +1 -1
  389. package/dist/src/cli/commands/sync/presenter.cjs +10 -1
  390. package/dist/src/cli/commands/sync/presenter.cjs.map +1 -1
  391. package/dist/src/cli/commands/sync/presenter.d.mts +0 -9
  392. package/dist/src/cli/commands/sync/presenter.d.mts.map +1 -1
  393. package/dist/src/cli/commands/sync/presenter.mjs +10 -1
  394. package/dist/src/cli/commands/sync/presenter.mjs.map +1 -1
  395. package/dist/src/cli/commands/web/index.cjs +7 -6
  396. package/dist/src/cli/commands/web/index.cjs.map +1 -1
  397. package/dist/src/cli/commands/web/index.mjs +6 -5
  398. package/dist/src/cli/commands/web/index.mjs.map +1 -1
  399. package/dist/src/cli/harnessOptions.cjs +15 -24
  400. package/dist/src/cli/harnessOptions.cjs.map +1 -1
  401. package/dist/src/cli/harnessOptions.d.mts +2 -2
  402. package/dist/src/cli/harnessOptions.d.mts.map +1 -1
  403. package/dist/src/cli/harnessOptions.mjs +14 -22
  404. package/dist/src/cli/harnessOptions.mjs.map +1 -1
  405. package/dist/src/cli/help.cjs +20 -26
  406. package/dist/src/cli/help.cjs.map +1 -1
  407. package/dist/src/cli/help.d.mts +1 -2
  408. package/dist/src/cli/help.d.mts.map +1 -1
  409. package/dist/src/cli/help.mjs +15 -20
  410. package/dist/src/cli/help.mjs.map +1 -1
  411. package/dist/src/cli/locale.cjs +25 -0
  412. package/dist/src/cli/locale.cjs.map +1 -0
  413. package/dist/src/cli/locale.mjs +22 -0
  414. package/dist/src/cli/locale.mjs.map +1 -0
  415. package/dist/src/cli/matrixOptions.cjs +85 -37
  416. package/dist/src/cli/matrixOptions.cjs.map +1 -1
  417. package/dist/src/cli/matrixOptions.d.mts +22 -16
  418. package/dist/src/cli/matrixOptions.d.mts.map +1 -1
  419. package/dist/src/cli/matrixOptions.mjs +76 -33
  420. package/dist/src/cli/matrixOptions.mjs.map +1 -1
  421. package/dist/src/cli/options.cjs +51 -128
  422. package/dist/src/cli/options.cjs.map +1 -1
  423. package/dist/src/cli/options.d.mts +1 -1
  424. package/dist/src/cli/options.d.mts.map +1 -1
  425. package/dist/src/cli/options.mjs +53 -130
  426. package/dist/src/cli/options.mjs.map +1 -1
  427. package/dist/src/cli/router.cjs +0 -1
  428. package/dist/src/cli/router.cjs.map +1 -1
  429. package/dist/src/cli/router.d.mts +1 -1
  430. package/dist/src/cli/router.mjs +0 -1
  431. package/dist/src/cli/router.mjs.map +1 -1
  432. package/dist/src/cli/server/options.cjs +37 -7
  433. package/dist/src/cli/server/options.cjs.map +1 -1
  434. package/dist/src/cli/server/options.mjs +37 -7
  435. package/dist/src/cli/server/options.mjs.map +1 -1
  436. package/dist/src/cli/server/processGuards.cjs +22 -15
  437. package/dist/src/cli/server/processGuards.cjs.map +1 -1
  438. package/dist/src/cli/server/processGuards.mjs +21 -14
  439. package/dist/src/cli/server/processGuards.mjs.map +1 -1
  440. package/dist/src/cli/server/restartPolicy.cjs +38 -0
  441. package/dist/src/cli/server/restartPolicy.cjs.map +1 -0
  442. package/dist/src/cli/server/restartPolicy.d.mts +21 -0
  443. package/dist/src/cli/server/restartPolicy.d.mts.map +1 -0
  444. package/dist/src/cli/server/restartPolicy.mjs +36 -0
  445. package/dist/src/cli/server/restartPolicy.mjs.map +1 -0
  446. package/dist/src/cli/server/run.cjs +12 -11
  447. package/dist/src/cli/server/run.cjs.map +1 -1
  448. package/dist/src/cli/server/run.mjs +11 -10
  449. package/dist/src/cli/server/run.mjs.map +1 -1
  450. package/dist/src/cli/server/supervise.cjs +89 -0
  451. package/dist/src/cli/server/supervise.cjs.map +1 -0
  452. package/dist/src/cli/server/supervise.mjs +89 -0
  453. package/dist/src/cli/server/supervise.mjs.map +1 -0
  454. package/dist/src/composition/harnessState/index.cjs +2 -1
  455. package/dist/src/composition/harnessState/index.cjs.map +1 -1
  456. package/dist/src/composition/harnessState/index.d.mts +2 -1
  457. package/dist/src/composition/harnessState/index.d.mts.map +1 -1
  458. package/dist/src/composition/harnessState/index.mjs +2 -1
  459. package/dist/src/composition/harnessState/index.mjs.map +1 -1
  460. package/dist/src/composition/layerPackageInstaller/index.cjs +293 -86
  461. package/dist/src/composition/layerPackageInstaller/index.cjs.map +1 -1
  462. package/dist/src/composition/layerPackageInstaller/index.d.mts +25 -2
  463. package/dist/src/composition/layerPackageInstaller/index.d.mts.map +1 -1
  464. package/dist/src/composition/layerPackageInstaller/index.mjs +295 -94
  465. package/dist/src/composition/layerPackageInstaller/index.mjs.map +1 -1
  466. package/dist/src/composition/marketplaceCatalog/index.cjs +136 -0
  467. package/dist/src/composition/marketplaceCatalog/index.cjs.map +1 -0
  468. package/dist/src/composition/marketplaceCatalog/index.mjs +132 -0
  469. package/dist/src/composition/marketplaceCatalog/index.mjs.map +1 -0
  470. package/dist/src/composition/orgPluginActivation/index.cjs +179 -0
  471. package/dist/src/composition/orgPluginActivation/index.cjs.map +1 -0
  472. package/dist/src/composition/orgPluginActivation/index.mjs +177 -0
  473. package/dist/src/composition/orgPluginActivation/index.mjs.map +1 -0
  474. package/dist/src/composition/orgPluginLibrary/index.cjs +205 -0
  475. package/dist/src/composition/orgPluginLibrary/index.cjs.map +1 -0
  476. package/dist/src/composition/orgPluginLibrary/index.mjs +200 -0
  477. package/dist/src/composition/orgPluginLibrary/index.mjs.map +1 -0
  478. package/dist/src/composition/pluginMarketplace/index.cjs +304 -0
  479. package/dist/src/composition/pluginMarketplace/index.cjs.map +1 -0
  480. package/dist/src/composition/pluginMarketplace/index.mjs +302 -0
  481. package/dist/src/composition/pluginMarketplace/index.mjs.map +1 -0
  482. package/dist/src/composition/poHomeMigration/index.cjs +46 -26
  483. package/dist/src/composition/poHomeMigration/index.cjs.map +1 -1
  484. package/dist/src/composition/poHomeMigration/index.d.mts.map +1 -1
  485. package/dist/src/composition/poHomeMigration/index.mjs +45 -25
  486. package/dist/src/composition/poHomeMigration/index.mjs.map +1 -1
  487. package/dist/src/composition/projectTrust/index.cjs +40 -3
  488. package/dist/src/composition/projectTrust/index.cjs.map +1 -1
  489. package/dist/src/composition/projectTrust/index.d.mts +8 -0
  490. package/dist/src/composition/projectTrust/index.d.mts.map +1 -1
  491. package/dist/src/composition/projectTrust/index.mjs +33 -2
  492. package/dist/src/composition/projectTrust/index.mjs.map +1 -1
  493. package/dist/src/composition/repository/index.cjs +29 -12
  494. package/dist/src/composition/repository/index.cjs.map +1 -1
  495. package/dist/src/composition/repository/index.d.mts +10 -3
  496. package/dist/src/composition/repository/index.d.mts.map +1 -1
  497. package/dist/src/composition/repository/index.mjs +29 -13
  498. package/dist/src/composition/repository/index.mjs.map +1 -1
  499. package/dist/src/composition/syncPrune/index.cjs +23 -16
  500. package/dist/src/composition/syncPrune/index.cjs.map +1 -1
  501. package/dist/src/composition/syncPrune/index.d.mts.map +1 -1
  502. package/dist/src/composition/syncPrune/index.mjs +22 -15
  503. package/dist/src/composition/syncPrune/index.mjs.map +1 -1
  504. package/dist/src/composition/syncService/index.cjs +441 -194
  505. package/dist/src/composition/syncService/index.cjs.map +1 -1
  506. package/dist/src/composition/syncService/index.d.mts +4 -1
  507. package/dist/src/composition/syncService/index.d.mts.map +1 -1
  508. package/dist/src/composition/syncService/index.mjs +440 -196
  509. package/dist/src/composition/syncService/index.mjs.map +1 -1
  510. package/dist/src/composition/syncService/localBuilds.cjs +41 -37
  511. package/dist/src/composition/syncService/localBuilds.cjs.map +1 -1
  512. package/dist/src/composition/syncService/localBuilds.mjs +40 -37
  513. package/dist/src/composition/syncService/localBuilds.mjs.map +1 -1
  514. package/dist/src/composition/transitionLayers.cjs.map +1 -1
  515. package/dist/src/composition/transitionLayers.d.mts +3 -3
  516. package/dist/src/composition/transitionLayers.d.mts.map +1 -1
  517. package/dist/src/composition/transitionLayers.mjs.map +1 -1
  518. package/dist/src/composition/types/harness.d.mts +4 -9
  519. package/dist/src/composition/types/harness.d.mts.map +1 -1
  520. package/dist/src/extensions/setupDiagnostics.cjs +8 -8
  521. package/dist/src/extensions/setupDiagnostics.cjs.map +1 -1
  522. package/dist/src/extensions/setupDiagnostics.mjs +8 -8
  523. package/dist/src/extensions/setupDiagnostics.mjs.map +1 -1
  524. package/dist/webBuilder.cjs +1 -0
  525. package/dist/webBuilder.d.mts +2 -2
  526. package/dist/webBuilder.mjs +2 -2
  527. package/docs/server/api-export.md +9 -9
  528. package/docs/server/api.md +22 -125
  529. package/docs/server/getting-started.md +21 -85
  530. package/docs/server/index.md +13 -58
  531. package/docs/server/ipc.md +26 -72
  532. package/docs/server/lifecycle.md +18 -91
  533. package/docs/server/security.md +20 -80
  534. package/package.json +47 -67
  535. package/src/prompts/po-author-extension/SKILL.md +2 -2
  536. package/src/prompts/po-author-extension/references/extension-contract.md +4 -6
  537. package/dist/antigravity.cjs +0 -5
  538. package/dist/antigravity.d.mts +0 -2
  539. package/dist/antigravity.mjs +0 -1
  540. package/dist/codex.cjs +0 -8
  541. package/dist/codex.d.mts +0 -2
  542. package/dist/codex.mjs +0 -1
  543. package/dist/compatibility.cjs +0 -27
  544. package/dist/compatibility.d.mts +0 -6
  545. package/dist/compatibility.mjs +0 -6
  546. package/dist/compatibilityCommand.cjs +0 -4
  547. package/dist/compatibilityCommand.d.mts +0 -2
  548. package/dist/compatibilityCommand.mjs +0 -1
  549. package/dist/compatibilityContext.cjs +0 -3
  550. package/dist/compatibilityContext.d.mts +0 -2
  551. package/dist/compatibilityContext.mjs +0 -1
  552. package/dist/compatibilityOptions.cjs +0 -5
  553. package/dist/compatibilityOptions.d.mts +0 -2
  554. package/dist/compatibilityOptions.mjs +0 -1
  555. package/dist/process.cjs +0 -12
  556. package/dist/process.d.mts +0 -2
  557. package/dist/process.mjs +0 -1
  558. package/dist/src/builders/hooks/index.cjs +0 -238
  559. package/dist/src/builders/hooks/index.cjs.map +0 -1
  560. package/dist/src/builders/hooks/index.mjs +0 -231
  561. package/dist/src/builders/hooks/index.mjs.map +0 -1
  562. package/dist/src/cli/commands/compat/context.cjs +0 -115
  563. package/dist/src/cli/commands/compat/context.cjs.map +0 -1
  564. package/dist/src/cli/commands/compat/context.d.mts +0 -22
  565. package/dist/src/cli/commands/compat/context.d.mts.map +0 -1
  566. package/dist/src/cli/commands/compat/context.mjs +0 -110
  567. package/dist/src/cli/commands/compat/context.mjs.map +0 -1
  568. package/dist/src/cli/commands/compat/help.cjs +0 -26
  569. package/dist/src/cli/commands/compat/help.cjs.map +0 -1
  570. package/dist/src/cli/commands/compat/help.d.mts +0 -4
  571. package/dist/src/cli/commands/compat/help.d.mts.map +0 -1
  572. package/dist/src/cli/commands/compat/help.mjs +0 -25
  573. package/dist/src/cli/commands/compat/help.mjs.map +0 -1
  574. package/dist/src/cli/commands/compat/index.cjs +0 -73
  575. package/dist/src/cli/commands/compat/index.cjs.map +0 -1
  576. package/dist/src/cli/commands/compat/index.d.mts +0 -14
  577. package/dist/src/cli/commands/compat/index.d.mts.map +0 -1
  578. package/dist/src/cli/commands/compat/index.mjs +0 -70
  579. package/dist/src/cli/commands/compat/index.mjs.map +0 -1
  580. package/dist/src/cli/commands/compat/options.cjs +0 -88
  581. package/dist/src/cli/commands/compat/options.cjs.map +0 -1
  582. package/dist/src/cli/commands/compat/options.d.mts +0 -15
  583. package/dist/src/cli/commands/compat/options.d.mts.map +0 -1
  584. package/dist/src/cli/commands/compat/options.mjs +0 -86
  585. package/dist/src/cli/commands/compat/options.mjs.map +0 -1
  586. package/dist/src/cli/commands/compat/providers/antigravity.cjs +0 -294
  587. package/dist/src/cli/commands/compat/providers/antigravity.cjs.map +0 -1
  588. package/dist/src/cli/commands/compat/providers/antigravity.d.mts +0 -9
  589. package/dist/src/cli/commands/compat/providers/antigravity.d.mts.map +0 -1
  590. package/dist/src/cli/commands/compat/providers/antigravity.mjs +0 -289
  591. package/dist/src/cli/commands/compat/providers/antigravity.mjs.map +0 -1
  592. package/dist/src/cli/commands/compat/providers/codex.cjs +0 -178
  593. package/dist/src/cli/commands/compat/providers/codex.cjs.map +0 -1
  594. package/dist/src/cli/commands/compat/providers/codex.d.mts +0 -17
  595. package/dist/src/cli/commands/compat/providers/codex.d.mts.map +0 -1
  596. package/dist/src/cli/commands/compat/providers/codex.mjs +0 -170
  597. package/dist/src/cli/commands/compat/providers/codex.mjs.map +0 -1
  598. package/dist/src/cli/commands/compat/providers/index.cjs +0 -65
  599. package/dist/src/cli/commands/compat/providers/index.cjs.map +0 -1
  600. package/dist/src/cli/commands/compat/providers/index.d.mts +0 -15
  601. package/dist/src/cli/commands/compat/providers/index.d.mts.map +0 -1
  602. package/dist/src/cli/commands/compat/providers/index.mjs +0 -45
  603. package/dist/src/cli/commands/compat/providers/index.mjs.map +0 -1
  604. package/dist/src/cli/commands/compat/providers/process.cjs +0 -172
  605. package/dist/src/cli/commands/compat/providers/process.cjs.map +0 -1
  606. package/dist/src/cli/commands/compat/providers/process.d.mts +0 -33
  607. package/dist/src/cli/commands/compat/providers/process.d.mts.map +0 -1
  608. package/dist/src/cli/commands/compat/providers/process.mjs +0 -159
  609. package/dist/src/cli/commands/compat/providers/process.mjs.map +0 -1
  610. package/dist/src/cli/commands/compat/providers/shared.cjs +0 -76
  611. package/dist/src/cli/commands/compat/providers/shared.cjs.map +0 -1
  612. package/dist/src/cli/commands/compat/providers/shared.d.mts +0 -40
  613. package/dist/src/cli/commands/compat/providers/shared.d.mts.map +0 -1
  614. package/dist/src/cli/commands/compat/providers/shared.mjs +0 -61
  615. package/dist/src/cli/commands/compat/providers/shared.mjs.map +0 -1
  616. package/dist/src/cli/commands/compat/types.d.mts +0 -31
  617. package/dist/src/cli/commands/compat/types.d.mts.map +0 -1
  618. package/dist/src/cli/commands/init/constants.cjs +0 -11
  619. package/dist/src/cli/commands/init/constants.cjs.map +0 -1
  620. package/dist/src/cli/commands/init/constants.mjs +0 -11
  621. package/dist/src/cli/commands/init/constants.mjs.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"webPluginScan.mjs","names":[],"sources":["../../../../src/builders/web/webPluginScan.ts"],"sourcesContent":["import fs from 'node:fs';\nimport path from 'node:path';\n\nimport {\n type DeclaredWebPlugin,\n declaredPluginsOf,\n orderDeclaredPlugins,\n type PluginManifestField,\n WebPluginManifestError,\n} from './webPluginManifest';\n\n/**\n * Reads poWeb declarations from explicit package roots.\n *\n * No workspace walking and no hardcoded plugin names: the caller says which\n * packages are in play. At po-web's own build time that is just the host\n * package (its built-in plugins); at `po sync` time it is the installed\n * composition's package roots. A plugin package whose manifest is malformed\n * or whose entry file is missing is skipped with a notice, so one broken or\n * half-installed package never costs the rest of the cockpit; only the host's\n * own manifest still throws, because that is a build error of this package.\n *\n * `field` selects poNative for the native composition, which has no host\n * package: pass `undefined` as `hostDir` and only the plugin roots are read.\n */\nexport function scanWebPlugins(\n hostDir: string | undefined,\n pluginRoots: readonly string[] = [],\n onNotice: (message: string) => void = () => undefined,\n field: PluginManifestField = 'poWeb',\n): DeclaredWebPlugin[] {\n const seen = new Set<string>();\n const plugins: DeclaredWebPlugin[] = [];\n const hostResolved = hostDir === undefined ? undefined : path.resolve(hostDir);\n const kind = field === 'poNative' ? 'native' : 'web';\n for (const root of hostDir === undefined ? pluginRoots : [hostDir, ...pluginRoots]) {\n const resolved = path.resolve(root);\n if (seen.has(resolved)) continue;\n seen.add(resolved);\n try {\n plugins.push(...declaredPluginsIn(resolved, resolved === hostResolved, field));\n } catch (error) {\n if (resolved === hostResolved) throw error;\n const reason = error instanceof WebPluginManifestError ? error.message : String(error);\n onNotice(`${kind} plugin package ${resolved} skipped: ${reason}`);\n }\n }\n return orderDeclaredPlugins(plugins, onNotice, field);\n}\n\nfunction declaredPluginsIn(resolved: string, isHost: boolean, field: PluginManifestField): DeclaredWebPlugin[] {\n let manifest: Record<string, unknown>;\n try {\n manifest = JSON.parse(fs.readFileSync(path.join(resolved, 'package.json'), 'utf8')) as Record<string, unknown>;\n } catch (error) {\n throw new WebPluginManifestError(resolved, `package.json is unreadable: ${String(error)}`, field);\n }\n const declared = declaredPluginsOf(resolved, manifest, isHost, field);\n for (const plugin of declared) {\n const entryPath = path.join(resolved, plugin.client.entry);\n if (!fs.existsSync(entryPath)) {\n throw new WebPluginManifestError(resolved, `client.entry '${plugin.client.entry}' does not exist.`, field);\n }\n }\n return declared;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAyBA,SAAgB,eACd,SACA,cAAiC,CAAC,GAClC,iBAA4C,KAAA,GAC5C,QAA6B,SACR;CACrB,MAAM,uBAAO,IAAI,IAAY;CAC7B,MAAM,UAA+B,CAAC;CACtC,MAAM,eAAe,YAAY,KAAA,IAAY,KAAA,IAAY,KAAK,QAAQ,OAAO;CAC7E,MAAM,OAAO,UAAU,aAAa,WAAW;CAC/C,KAAK,MAAM,QAAQ,YAAY,KAAA,IAAY,cAAc,CAAC,SAAS,GAAG,WAAW,GAAG;EAClF,MAAM,WAAW,KAAK,QAAQ,IAAI;EAClC,IAAI,KAAK,IAAI,QAAQ,GAAG;EACxB,KAAK,IAAI,QAAQ;EACjB,IAAI;GACF,QAAQ,KAAK,GAAG,kBAAkB,UAAU,aAAa,cAAc,KAAK,CAAC;EAC/E,SAAS,OAAO;GACd,IAAI,aAAa,cAAc,MAAM;GAErC,SAAS,GAAG,KAAK,kBAAkB,SAAS,YAD7B,iBAAiB,yBAAyB,MAAM,UAAU,OAAO,KAAK,GACrB;EAClE;CACF;CACA,OAAO,qBAAqB,SAAS,UAAU,KAAK;AACtD;AAEA,SAAS,kBAAkB,UAAkB,QAAiB,OAAiD;CAC7G,IAAI;CACJ,IAAI;EACF,WAAW,KAAK,MAAM,GAAG,aAAa,KAAK,KAAK,UAAU,cAAc,GAAG,MAAM,CAAC;CACpF,SAAS,OAAO;EACd,MAAM,IAAI,uBAAuB,UAAU,+BAA+B,OAAO,KAAK,KAAK,KAAK;CAClG;CACA,MAAM,WAAW,kBAAkB,UAAU,UAAU,QAAQ,KAAK;CACpE,KAAK,MAAM,UAAU,UAAU;EAC7B,MAAM,YAAY,KAAK,KAAK,UAAU,OAAO,OAAO,KAAK;EACzD,IAAI,CAAC,GAAG,WAAW,SAAS,GAC1B,MAAM,IAAI,uBAAuB,UAAU,iBAAiB,OAAO,OAAO,MAAM,oBAAoB,KAAK;CAE7G;CACA,OAAO;AACT"}
1
+ {"version":3,"file":"webPluginScan.mjs","names":[],"sources":["../../../../src/builders/web/webPluginScan.ts"],"sourcesContent":["import fs from 'node:fs/promises';\nimport path from 'node:path';\n\nimport {\n type DeclaredWebPlugin,\n declaredPluginsOf,\n orderDeclaredPlugins,\n type PluginManifestField,\n WebPluginManifestError,\n} from './webPluginManifest';\n\n/**\n * Reads poWeb declarations from explicit package roots.\n *\n * No workspace walking and no hardcoded plugin names: the caller says which\n * packages are in play. At po-web's own build time that is just the host\n * package (its built-in plugins); at `po sync` time it is the installed\n * composition's package roots. A plugin package whose manifest is malformed\n * or whose entry file is missing is skipped with a notice, so one broken or\n * half-installed package never costs the rest of the cockpit; only the host's\n * own manifest still throws, because that is a build error of this package.\n *\n * `field` selects poNative for the native composition, which has no host\n * package: pass `undefined` as `hostDir` and only the plugin roots are read.\n */\nexport async function scanWebPlugins(\n hostDir: string | undefined,\n pluginRoots: readonly string[] = [],\n onNotice: (message: string) => void = () => undefined,\n field: PluginManifestField = 'poWeb',\n): Promise<DeclaredWebPlugin[]> {\n const seen = new Set<string>();\n const plugins: DeclaredWebPlugin[] = [];\n const hostResolved = hostDir === undefined ? undefined : path.resolve(hostDir);\n const kind = field === 'poNative' ? 'native' : 'web';\n for (const root of hostDir === undefined ? pluginRoots : [hostDir, ...pluginRoots]) {\n const resolved = path.resolve(root);\n if (seen.has(resolved)) continue;\n seen.add(resolved);\n try {\n plugins.push(...(await declaredPluginsIn(resolved, resolved === hostResolved, field)));\n } catch (error) {\n if (resolved === hostResolved) throw error;\n const reason = error instanceof WebPluginManifestError ? error.message : String(error);\n onNotice(`${kind} plugin package ${resolved} skipped: ${reason}`);\n }\n }\n return orderDeclaredPlugins(plugins, onNotice, field);\n}\n\nasync function declaredPluginsIn(\n resolved: string,\n isHost: boolean,\n field: PluginManifestField,\n): Promise<DeclaredWebPlugin[]> {\n let manifest: Record<string, unknown>;\n try {\n manifest = JSON.parse(await fs.readFile(path.join(resolved, 'package.json'), 'utf8')) as Record<string, unknown>;\n } catch (error) {\n throw new WebPluginManifestError(resolved, `package.json is unreadable: ${String(error)}`, field);\n }\n const declared = await declaredPluginsOf(resolved, manifest, isHost, field);\n for (const plugin of declared) {\n const entryPath = path.join(resolved, plugin.client.entry);\n await fs.access(entryPath).catch((error: NodeJS.ErrnoException) => {\n if (error.code === 'ENOENT')\n throw new WebPluginManifestError(resolved, `client.entry '${plugin.client.entry}' does not exist.`, field);\n throw error;\n });\n }\n return declared;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAyBA,eAAsB,eACpB,SACA,cAAiC,CAAC,GAClC,iBAA4C,KAAA,GAC5C,QAA6B,SACC;CAC9B,MAAM,uBAAO,IAAI,IAAY;CAC7B,MAAM,UAA+B,CAAC;CACtC,MAAM,eAAe,YAAY,KAAA,IAAY,KAAA,IAAY,KAAK,QAAQ,OAAO;CAC7E,MAAM,OAAO,UAAU,aAAa,WAAW;CAC/C,KAAK,MAAM,QAAQ,YAAY,KAAA,IAAY,cAAc,CAAC,SAAS,GAAG,WAAW,GAAG;EAClF,MAAM,WAAW,KAAK,QAAQ,IAAI;EAClC,IAAI,KAAK,IAAI,QAAQ,GAAG;EACxB,KAAK,IAAI,QAAQ;EACjB,IAAI;GACF,QAAQ,KAAK,GAAI,MAAM,kBAAkB,UAAU,aAAa,cAAc,KAAK,CAAE;EACvF,SAAS,OAAO;GACd,IAAI,aAAa,cAAc,MAAM;GAErC,SAAS,GAAG,KAAK,kBAAkB,SAAS,YAD7B,iBAAiB,yBAAyB,MAAM,UAAU,OAAO,KAAK,GACrB;EAClE;CACF;CACA,OAAO,qBAAqB,SAAS,UAAU,KAAK;AACtD;AAEA,eAAe,kBACb,UACA,QACA,OAC8B;CAC9B,IAAI;CACJ,IAAI;EACF,WAAW,KAAK,MAAM,MAAM,GAAG,SAAS,KAAK,KAAK,UAAU,cAAc,GAAG,MAAM,CAAC;CACtF,SAAS,OAAO;EACd,MAAM,IAAI,uBAAuB,UAAU,+BAA+B,OAAO,KAAK,KAAK,KAAK;CAClG;CACA,MAAM,WAAW,MAAM,kBAAkB,UAAU,UAAU,QAAQ,KAAK;CAC1E,KAAK,MAAM,UAAU,UAAU;EAC7B,MAAM,YAAY,KAAK,KAAK,UAAU,OAAO,OAAO,KAAK;EACzD,MAAM,GAAG,OAAO,SAAS,CAAC,CAAC,OAAO,UAAiC;GACjE,IAAI,MAAM,SAAS,UACjB,MAAM,IAAI,uBAAuB,UAAU,iBAAiB,OAAO,OAAO,MAAM,oBAAoB,KAAK;GAC3G,MAAM;EACR,CAAC;CACH;CACA,OAAO;AACT"}
@@ -2,11 +2,11 @@ const require_runtime = require("../../../_virtual/_rolldown/runtime.cjs");
2
2
  const require_index = require("./index.cjs");
3
3
  const require_sessionComposition = require("../cli/sessionComposition.cjs");
4
4
  const require_webDevRoots = require("./webDevRoots.cjs");
5
- let node_fs = require("node:fs");
6
- node_fs = require_runtime.__toESM(node_fs, 1);
5
+ let node_module = require("node:module");
7
6
  let node_path = require("node:path");
8
7
  node_path = require_runtime.__toESM(node_path, 1);
9
- let node_module = require("node:module");
8
+ let node_fs_promises = require("node:fs/promises");
9
+ node_fs_promises = require_runtime.__toESM(node_fs_promises, 1);
10
10
  //#region src/builders/web/webPluginVite.ts
11
11
  const PO_ROOT_ENV = "PO_ROOT";
12
12
  /**
@@ -98,7 +98,7 @@ async function esModuleExportNames(specifier, file, reader, seen = /* @__PURE__
98
98
  seen.add(file);
99
99
  let body;
100
100
  try {
101
- body = reader.parse(node_fs.default.readFileSync(file, "utf8")).body;
101
+ body = reader.parse(await node_fs_promises.default.readFile(file, "utf8")).body;
102
102
  } catch (error) {
103
103
  throw new Error(`The shared module '${specifier}' cannot be parsed at ${file}: ${error instanceof Error ? error.message : String(error)}`);
104
104
  }
@@ -224,7 +224,7 @@ function webPluginCssAlias(generated) {
224
224
  };
225
225
  }
226
226
  /** The plugin package roots the dev server should serve, from an explicit override or PO_ROOT. */
227
- function readDevPluginRoots(environment, homeDirectory) {
227
+ async function readDevPluginRoots(environment, homeDirectory) {
228
228
  const explicit = environment[require_webDevRoots.PLUGIN_ROOTS_ENV];
229
229
  if (explicit !== void 0 && explicit !== "") return require_webDevRoots.devPluginRoots({
230
230
  envValue: explicit,
@@ -1 +1 @@
1
- {"version":3,"file":"webPluginVite.cjs","names":["fs","path","createRequire","PLUGIN_ROOTS_ENV","devPluginRoots","compositionPackageRoots","rootCompositions"],"sources":["../../../../src/builders/web/webPluginVite.ts"],"sourcesContent":["import fs from 'node:fs';\nimport { createRequire } from 'node:module';\nimport path from 'node:path';\n\nimport type { Alias, Plugin } from 'vite';\n\nimport { rootCompositions } from '../cli/sessionComposition';\nimport { compositionPackageRoots } from './index';\nimport { devPluginRoots, PLUGIN_ROOTS_ENV } from './webDevRoots';\nimport type { WebPluginRegistryModules } from './webPluginGenerate';\n\nconst PO_ROOT_ENV = 'PO_ROOT';\n\n/**\n * The modules the cockpit supplies page-wide, rather than each plugin\n * carrying its own copy.\n *\n * Build-time metadata, and it stays here rather than in a browser-facing\n * barrel on purpose: exporting it from po-core/web put the literal list\n * into the shipped cockpit bundle, where a plugin's own specifier strings\n * would then appear as data.\n */\nexport const WEB_PLUGIN_RUNTIME_SPECIFIERS = [\n 'react',\n 'react/jsx-runtime',\n 'react/jsx-dev-runtime',\n 'react-dom',\n 'react-dom/client',\n '@tanstack/store',\n '@tanstack/react-store',\n '@tanstack/react-router',\n '@agimon-ai/po-web-dashboard',\n '@agimon-ai/po-web-dashboard/views',\n '@agimon-ai/po-core/web',\n '@agimon-ai/po-web-components',\n '@agimon-ai/po-web-security/browser',\n '@codemirror/state',\n '@codemirror/view',\n] as const;\n\nconst WEB_PLUGIN_RUNTIME_PROPERTIES: Record<(typeof WEB_PLUGIN_RUNTIME_SPECIFIERS)[number], string> = {\n react: 'react',\n 'react/jsx-runtime': 'reactJsxRuntime',\n 'react/jsx-dev-runtime': 'reactJsxDevRuntime',\n 'react-dom': 'reactDom',\n 'react-dom/client': 'reactDomClient',\n '@tanstack/store': 'tanstackStore',\n '@tanstack/react-store': 'tanstackReactStore',\n '@tanstack/react-router': 'tanstackRouter',\n '@agimon-ai/po-web-dashboard': 'dashboard',\n '@agimon-ai/po-web-dashboard/views': 'dashboardViews',\n '@agimon-ai/po-core/web': 'webContracts',\n '@agimon-ai/po-web-components': 'webComponents',\n '@agimon-ai/po-web-security/browser': 'webSecurityBrowser',\n '@codemirror/state': 'codemirrorState',\n '@codemirror/view': 'codemirrorView',\n};\n\ntype WebPluginRuntimeSpecifier = (typeof WEB_PLUGIN_RUNTIME_SPECIFIERS)[number];\n\n/** Expression for a shared module supplied by the session shell. */\nexport function webPluginRuntimeGlobal(specifier: WebPluginRuntimeSpecifier): string {\n return `globalThis.PoWebPluginRuntime.${WEB_PLUGIN_RUNTIME_PROPERTIES[specifier]}`;\n}\n\n/** The React family ships CommonJS, so its names come from loading it rather than parsing it. */\nconst COMMONJS_RUNTIME_SPECIFIERS: ReadonlySet<string> = new Set([\n 'react',\n 'react/jsx-runtime',\n 'react/jsx-dev-runtime',\n 'react-dom',\n 'react-dom/client',\n]);\n\nconst FACADE_PREFIX = '\\0po-web-runtime:';\n/** The chunk every facade lands in, so each shared module is read from the runtime once. */\nexport const WEB_PLUGIN_FACADE_CHUNK = 'po-web-runtime';\n\n/** True for a module id that is one of the shared-module facades. */\nexport function isWebPluginFacade(id: string): boolean {\n return id.startsWith(FACADE_PREFIX);\n}\n\n/** The ES module name of a default export. */\nconst DEFAULT_EXPORT = 'default';\n\ntype AstNode = { type: string; [key: string]: unknown };\n\nfunction patternNames(pattern: AstNode): string[] {\n switch (pattern.type) {\n case 'Identifier':\n return [pattern.name as string];\n case 'ObjectPattern':\n return (pattern.properties as AstNode[]).flatMap((property) =>\n patternNames((property.type === 'RestElement' ? property.argument : property.value) as AstNode),\n );\n case 'ArrayPattern':\n return (pattern.elements as (AstNode | null)[]).flatMap((element) => (element ? patternNames(element) : []));\n case 'RestElement':\n return patternNames(pattern.argument as AstNode);\n case 'AssignmentPattern':\n return patternNames(pattern.left as AstNode);\n default:\n return [];\n }\n}\n\nfunction exportedName(node: AstNode): string {\n return node.type === 'Identifier' ? (node.name as string) : String(node.value);\n}\n\n/** Static reading of an ES module's export names, as the facade plugin needs it. */\nexport interface ExportNameReader {\n parse: (code: string) => { body: unknown[] };\n /** Resolves a bare specifier from the file that imports it, to a file path. */\n resolve: (source: string, importer: string) => Promise<string | undefined>;\n}\n\n/**\n * The export names of an ES module file. `export *` is followed through relative paths,\n * and through a bare specifier only when that specifier is itself a shared module\n * (resolved from the re-exporting file, since that is the copy the runtime object holds).\n * Any other bare `export *` and any unparseable file fail the build.\n */\nexport async function esModuleExportNames(\n specifier: string,\n file: string,\n reader: ExportNameReader,\n seen: Set<string> = new Set(),\n): Promise<Set<string>> {\n const names = new Set<string>();\n if (seen.has(file)) return names;\n seen.add(file);\n let body: AstNode[];\n try {\n body = reader.parse(fs.readFileSync(file, 'utf8')).body as AstNode[];\n } catch (error) {\n throw new Error(\n `The shared module '${specifier}' cannot be parsed at ${file}: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n const shared: ReadonlySet<string> = new Set(WEB_PLUGIN_RUNTIME_SPECIFIERS);\n for (const node of body) {\n if (node.type === 'ExportDefaultDeclaration') names.add(DEFAULT_EXPORT);\n if (node.type === 'ExportNamedDeclaration') {\n const declaration = node.declaration as AstNode | null;\n if (declaration?.type === 'VariableDeclaration') {\n for (const declarator of declaration.declarations as AstNode[])\n for (const name of patternNames(declarator.id as AstNode)) names.add(name);\n } else if (declaration) {\n names.add((declaration.id as AstNode).name as string);\n }\n for (const entry of (node.specifiers as AstNode[] | undefined) ?? [])\n names.add(exportedName(entry.exported as AstNode));\n }\n if (node.type === 'ExportAllDeclaration') {\n if (node.exported) {\n names.add(exportedName(node.exported as AstNode));\n continue;\n }\n const source = String((node.source as AstNode).value);\n let target: string | undefined;\n if (source.startsWith('./') || source.startsWith('../')) target = path.resolve(path.dirname(file), source);\n else if (shared.has(source)) {\n target = await reader.resolve(source, file);\n if (target === undefined)\n throw new Error(\n `The shared module '${specifier}' re-exports '${source}', which does not resolve from ${file}.`,\n );\n } else\n throw new Error(\n `The shared module '${specifier}' re-exports everything from the bare specifier '${source}' (${file}), which is not a shared module; its names cannot be listed.`,\n );\n for (const name of await esModuleExportNames(specifier, target, reader, seen))\n if (name !== DEFAULT_EXPORT) names.add(name);\n }\n }\n return names;\n}\n\nconst IDENTIFIER = /^[A-Za-z_$][\\w$]*$/u;\n\n/** A module that reads one shared module from the page runtime and re-exports the given names. */\nexport function renderWebPluginFacade(specifier: WebPluginRuntimeSpecifier, names: Iterable<string>): string {\n const all = new Set(names);\n const lines = [`const runtime = ${webPluginRuntimeGlobal(specifier)};`];\n const exported: string[] = [];\n let index = 0;\n for (const name of [...all].sort()) {\n if (name === DEFAULT_EXPORT) continue;\n const local = `_${String(index++)}`;\n lines.push(`const ${local} = runtime[${JSON.stringify(name)}];`);\n exported.push(`${local} as ${IDENTIFIER.test(name) ? name : JSON.stringify(name)}`);\n }\n if (exported.length > 0) lines.push(`export { ${exported.join(', ')} };`);\n // CommonJS has no default export of its own; interop treats the whole object as one.\n if (all.has(DEFAULT_EXPORT)) lines.push('export default runtime[\"default\"];');\n else if (COMMONJS_RUNTIME_SPECIFIERS.has(specifier)) lines.push('export default runtime;');\n lines.push('');\n return lines.join('\\n');\n}\n\n/**\n * Resolves every shared runtime specifier to a virtual facade that re-exports, by name,\n * from `globalThis.PoWebPluginRuntime`, so ES-module slot entries can import them without\n * the page providing an import map. Names come from the host's own copy of each module.\n */\nexport function webPluginRuntimeFacadePlugin(hostRoot: string): Plugin {\n const shared: ReadonlySet<string> = new Set(WEB_PLUGIN_RUNTIME_SPECIFIERS);\n const hostImporter = path.join(hostRoot, 'package.json');\n const hostRequire = createRequire(hostImporter);\n return {\n name: 'po-web-runtime-facades',\n enforce: 'pre',\n resolveId(source) {\n return shared.has(source) ? `${FACADE_PREFIX}${source}` : null;\n },\n async load(id) {\n if (!isWebPluginFacade(id)) return null;\n const specifier = id.slice(FACADE_PREFIX.length) as WebPluginRuntimeSpecifier;\n if (COMMONJS_RUNTIME_SPECIFIERS.has(specifier))\n return renderWebPluginFacade(specifier, Object.keys(hostRequire(specifier) as object));\n const resolveFile = async (source: string, importer: string): Promise<string | undefined> => {\n const resolved = await this.resolve(source, importer, { skipSelf: true });\n return resolved ? (resolved.id.split('?')[0] ?? resolved.id) : undefined;\n };\n const file = await resolveFile(specifier, hostImporter);\n if (file === undefined) throw new Error(`The shared module '${specifier}' does not resolve from ${hostRoot}.`);\n const { parseAst } = await import('vite');\n return renderWebPluginFacade(\n specifier,\n await esModuleExportNames(specifier, file, { parse: (code) => parseAst(code), resolve: resolveFile }),\n );\n },\n };\n}\n\n/** Resolves generated JSX imports from the host instead of a plugin's optional React peer tree. */\nexport function webPluginRuntimeAliases(clientRoot: string): Alias[] {\n const runtimeRequire = createRequire(path.join(clientRoot, 'index.html'));\n return WEB_PLUGIN_RUNTIME_SPECIFIERS.filter((specifier) => specifier.startsWith('react/jsx-')).map((specifier) => ({\n find: new RegExp(`^${specifier.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&')}$`, 'u'),\n replacement: runtimeRequire.resolve(specifier),\n }));\n}\n\n/**\n * Swaps the committed builtin registry modules for generated ones. A\n * resolveId hook rather than resolve.alias because aliases match raw import\n * specifiers while these two are known by their resolved paths. Both the\n * sync-time build and the dev server use it, so a plugin edit in dev is the\n * same module the bundle would carry.\n */\nexport function webPluginOverridePlugin(clientRoot: string, generated: WebPluginRegistryModules): Plugin {\n const overrides = new Map([\n [path.join(clientRoot, 'app', 'webPlugins.generated.ts'), generated.clientModulePath],\n [path.join(clientRoot, 'styles', 'webPluginSources.generated.css'), generated.cssModulePath],\n ]);\n return {\n name: 'po-web-plugin-overrides',\n enforce: 'pre',\n async resolveId(source, importer, options) {\n if (!source.includes('webPlugins.generated') && !source.includes('webPluginSources.generated.css')) return null;\n const resolved = await this.resolve(source, importer, { ...options, skipSelf: true });\n if (!resolved) return null;\n return overrides.get(resolved.id) ?? null;\n },\n };\n}\n\n/**\n * The CSS sources module cannot ride the resolveId hook: Vite and Tailwind\n * resolve CSS @import through Vite's own id resolver, which consults aliases\n * but no plugin hooks. Without this the builtin (empty) @source list ships\n * and every plugin-only utility class is missing.\n */\nexport function webPluginCssAlias(generated: WebPluginRegistryModules): Alias {\n return { find: /^\\.\\/webPluginSources\\.generated\\.css$/, replacement: generated.cssModulePath };\n}\n\n/** The plugin package roots the dev server should serve, from an explicit override or PO_ROOT. */\nexport function readDevPluginRoots(environment: NodeJS.ProcessEnv, homeDirectory: string): string[] {\n const explicit = environment[PLUGIN_ROOTS_ENV];\n if (explicit !== undefined && explicit !== '') {\n return devPluginRoots({ envValue: explicit, rootsFileText: undefined, delimiter: path.delimiter });\n }\n const repoRoot = environment[PO_ROOT_ENV];\n if (repoRoot === undefined || repoRoot === '') return [];\n // Resolved live from the root's configuration and installed packages, as the server does.\n return compositionPackageRoots(rootCompositions({ root: repoRoot, homeDirectory, environment }));\n}\n"],"mappings":";;;;;;;;;;AAWA,MAAM,cAAc;;;;;;;;;;AAWpB,MAAa,gCAAgC;CAC3C;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAEA,MAAM,gCAAgG;CACpG,OAAO;CACP,qBAAqB;CACrB,yBAAyB;CACzB,aAAa;CACb,oBAAoB;CACpB,mBAAmB;CACnB,yBAAyB;CACzB,0BAA0B;CAC1B,+BAA+B;CAC/B,qCAAqC;CACrC,0BAA0B;CAC1B,gCAAgC;CAChC,sCAAsC;CACtC,qBAAqB;CACrB,oBAAoB;AACtB;;AAKA,SAAgB,uBAAuB,WAA8C;CACnF,OAAO,iCAAiC,8BAA8B;AACxE;;AAGA,MAAM,8CAAmD,IAAI,IAAI;CAC/D;CACA;CACA;CACA;CACA;AACF,CAAC;AAED,MAAM,gBAAgB;;AAEtB,MAAa,0BAA0B;;AAGvC,SAAgB,kBAAkB,IAAqB;CACrD,OAAO,GAAG,WAAW,aAAa;AACpC;;AAGA,MAAM,iBAAiB;AAIvB,SAAS,aAAa,SAA4B;CAChD,QAAQ,QAAQ,MAAhB;EACE,KAAK,cACH,OAAO,CAAC,QAAQ,IAAc;EAChC,KAAK,iBACH,OAAQ,QAAQ,WAAyB,SAAS,aAChD,aAAc,SAAS,SAAS,gBAAgB,SAAS,WAAW,SAAS,KAAiB,CAChG;EACF,KAAK,gBACH,OAAQ,QAAQ,SAAgC,SAAS,YAAa,UAAU,aAAa,OAAO,IAAI,CAAC,CAAE;EAC7G,KAAK,eACH,OAAO,aAAa,QAAQ,QAAmB;EACjD,KAAK,qBACH,OAAO,aAAa,QAAQ,IAAe;EAC7C,SACE,OAAO,CAAC;CACZ;AACF;AAEA,SAAS,aAAa,MAAuB;CAC3C,OAAO,KAAK,SAAS,eAAgB,KAAK,OAAkB,O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,YAAY,OAAO,yBAAyB,GAAG,UAAU,gBAAgB,GACpF,CAACA,UAAAA,QAAK,KAAK,YAAY,UAAU,gCAAgC,GAAG,UAAU,aAAa,CAC7F,CAAC;CACD,OAAO;EACL,MAAM;EACN,SAAS;EACT,MAAM,UAAU,QAAQ,UAAU,SAAS;GACzC,IAAI,CAAC,OAAO,SAAS,sBAAsB,KAAK,CAAC,OAAO,SAAS,gCAAgC,GAAG,OAAO;GAC3G,MAAM,WAAW,MAAM,KAAK,QAAQ,QAAQ,UAAU;IAAE,GAAG;IAAS,UAAU;GAAK,CAAC;GACpF,IAAI,CAAC,UAAU,OAAO;GACtB,OAAO,UAAU,IAAI,SAAS,EAAE,KAAK;EACvC;CACF;AACF;;;;;;;AAQA,SAAgB,kBAAkB,WAA4C;CAC5E,OAAO;EAAE,MAAM;EAA0C,aAAa,UAAU;CAAc;AAChG;;AAGA,SAAgB,mBAAmB,aAAgC,eAAiC;CAClG,MAAM,WAAW,YAAYE,oBAAAA;CAC7B,IAAI,aAAa,KAAA,KAAa,aAAa,IACzC,OAAOC,oBAAAA,eAAe;EAAE,UAAU;EAAU,eAAe,KAAA;EAAW,WAAWH,UAAAA,QAAK;CAAU,CAAC;CAEnG,MAAM,WAAW,YAAY;CAC7B,IAAI,aAAa,KAAA,KAAa,aAAa,IAAI,OAAO,CAAC;CAEvD,OAAOI,cAAAA,wBAAwBC,2BAAAA,iBAAiB;EAAE,MAAM;EAAU;EAAe;CAAY,CAAC,CAAC;AACjG"}
1
+ {"version":3,"file":"webPluginVite.cjs","names":["fs","path","createRequire","PLUGIN_ROOTS_ENV","devPluginRoots","compositionPackageRoots","rootCompositions"],"sources":["../../../../src/builders/web/webPluginVite.ts"],"sourcesContent":["import fs from 'node:fs/promises';\nimport { createRequire } from 'node:module';\nimport path from 'node:path';\n\nimport type { Alias, Plugin } from 'vite';\n\nimport { rootCompositions } from '../cli/sessionComposition';\nimport { compositionPackageRoots } from './index';\nimport { devPluginRoots, PLUGIN_ROOTS_ENV } from './webDevRoots';\nimport type { WebPluginRegistryModules } from './webPluginGenerate';\n\nconst PO_ROOT_ENV = 'PO_ROOT';\n\n/**\n * The modules the cockpit supplies page-wide, rather than each plugin\n * carrying its own copy.\n *\n * Build-time metadata, and it stays here rather than in a browser-facing\n * barrel on purpose: exporting it from po-core/web put the literal list\n * into the shipped cockpit bundle, where a plugin's own specifier strings\n * would then appear as data.\n */\nexport const WEB_PLUGIN_RUNTIME_SPECIFIERS = [\n 'react',\n 'react/jsx-runtime',\n 'react/jsx-dev-runtime',\n 'react-dom',\n 'react-dom/client',\n '@tanstack/store',\n '@tanstack/react-store',\n '@tanstack/react-router',\n '@agimon-ai/po-web-dashboard',\n '@agimon-ai/po-web-dashboard/views',\n '@agimon-ai/po-core/web',\n '@agimon-ai/po-web-components',\n '@agimon-ai/po-web-security/browser',\n '@codemirror/state',\n '@codemirror/view',\n] as const;\n\nconst WEB_PLUGIN_RUNTIME_PROPERTIES: Record<(typeof WEB_PLUGIN_RUNTIME_SPECIFIERS)[number], string> = {\n react: 'react',\n 'react/jsx-runtime': 'reactJsxRuntime',\n 'react/jsx-dev-runtime': 'reactJsxDevRuntime',\n 'react-dom': 'reactDom',\n 'react-dom/client': 'reactDomClient',\n '@tanstack/store': 'tanstackStore',\n '@tanstack/react-store': 'tanstackReactStore',\n '@tanstack/react-router': 'tanstackRouter',\n '@agimon-ai/po-web-dashboard': 'dashboard',\n '@agimon-ai/po-web-dashboard/views': 'dashboardViews',\n '@agimon-ai/po-core/web': 'webContracts',\n '@agimon-ai/po-web-components': 'webComponents',\n '@agimon-ai/po-web-security/browser': 'webSecurityBrowser',\n '@codemirror/state': 'codemirrorState',\n '@codemirror/view': 'codemirrorView',\n};\n\ntype WebPluginRuntimeSpecifier = (typeof WEB_PLUGIN_RUNTIME_SPECIFIERS)[number];\n\n/** Expression for a shared module supplied by the session shell. */\nexport function webPluginRuntimeGlobal(specifier: WebPluginRuntimeSpecifier): string {\n return `globalThis.PoWebPluginRuntime.${WEB_PLUGIN_RUNTIME_PROPERTIES[specifier]}`;\n}\n\n/** The React family ships CommonJS, so its names come from loading it rather than parsing it. */\nconst COMMONJS_RUNTIME_SPECIFIERS: ReadonlySet<string> = new Set([\n 'react',\n 'react/jsx-runtime',\n 'react/jsx-dev-runtime',\n 'react-dom',\n 'react-dom/client',\n]);\n\nconst FACADE_PREFIX = '\\0po-web-runtime:';\n/** The chunk every facade lands in, so each shared module is read from the runtime once. */\nexport const WEB_PLUGIN_FACADE_CHUNK = 'po-web-runtime';\n\n/** True for a module id that is one of the shared-module facades. */\nexport function isWebPluginFacade(id: string): boolean {\n return id.startsWith(FACADE_PREFIX);\n}\n\n/** The ES module name of a default export. */\nconst DEFAULT_EXPORT = 'default';\n\ntype AstNode = { type: string; [key: string]: unknown };\n\nfunction patternNames(pattern: AstNode): string[] {\n switch (pattern.type) {\n case 'Identifier':\n return [pattern.name as string];\n case 'ObjectPattern':\n return (pattern.properties as AstNode[]).flatMap((property) =>\n patternNames((property.type === 'RestElement' ? property.argument : property.value) as AstNode),\n );\n case 'ArrayPattern':\n return (pattern.elements as (AstNode | null)[]).flatMap((element) => (element ? patternNames(element) : []));\n case 'RestElement':\n return patternNames(pattern.argument as AstNode);\n case 'AssignmentPattern':\n return patternNames(pattern.left as AstNode);\n default:\n return [];\n }\n}\n\nfunction exportedName(node: AstNode): string {\n return node.type === 'Identifier' ? (node.name as string) : String(node.value);\n}\n\n/** Static reading of an ES module's export names, as the facade plugin needs it. */\nexport interface ExportNameReader {\n parse: (code: string) => { body: unknown[] };\n /** Resolves a bare specifier from the file that imports it, to a file path. */\n resolve: (source: string, importer: string) => Promise<string | undefined>;\n}\n\n/**\n * The export names of an ES module file. `export *` is followed through relative paths,\n * and through a bare specifier only when that specifier is itself a shared module\n * (resolved from the re-exporting file, since that is the copy the runtime object holds).\n * Any other bare `export *` and any unparseable file fail the build.\n */\nexport async function esModuleExportNames(\n specifier: string,\n file: string,\n reader: ExportNameReader,\n seen: Set<string> = new Set(),\n): Promise<Set<string>> {\n const names = new Set<string>();\n if (seen.has(file)) return names;\n seen.add(file);\n let body: AstNode[];\n try {\n body = reader.parse(await fs.readFile(file, 'utf8')).body as AstNode[];\n } catch (error) {\n throw new Error(\n `The shared module '${specifier}' cannot be parsed at ${file}: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n const shared: ReadonlySet<string> = new Set(WEB_PLUGIN_RUNTIME_SPECIFIERS);\n for (const node of body) {\n if (node.type === 'ExportDefaultDeclaration') names.add(DEFAULT_EXPORT);\n if (node.type === 'ExportNamedDeclaration') {\n const declaration = node.declaration as AstNode | null;\n if (declaration?.type === 'VariableDeclaration') {\n for (const declarator of declaration.declarations as AstNode[])\n for (const name of patternNames(declarator.id as AstNode)) names.add(name);\n } else if (declaration) {\n names.add((declaration.id as AstNode).name as string);\n }\n for (const entry of (node.specifiers as AstNode[] | undefined) ?? [])\n names.add(exportedName(entry.exported as AstNode));\n }\n if (node.type === 'ExportAllDeclaration') {\n if (node.exported) {\n names.add(exportedName(node.exported as AstNode));\n continue;\n }\n const source = String((node.source as AstNode).value);\n let target: string | undefined;\n if (source.startsWith('./') || source.startsWith('../')) target = path.resolve(path.dirname(file), source);\n else if (shared.has(source)) {\n target = await reader.resolve(source, file);\n if (target === undefined)\n throw new Error(\n `The shared module '${specifier}' re-exports '${source}', which does not resolve from ${file}.`,\n );\n } else\n throw new Error(\n `The shared module '${specifier}' re-exports everything from the bare specifier '${source}' (${file}), which is not a shared module; its names cannot be listed.`,\n );\n for (const name of await esModuleExportNames(specifier, target, reader, seen))\n if (name !== DEFAULT_EXPORT) names.add(name);\n }\n }\n return names;\n}\n\nconst IDENTIFIER = /^[A-Za-z_$][\\w$]*$/u;\n\n/** A module that reads one shared module from the page runtime and re-exports the given names. */\nexport function renderWebPluginFacade(specifier: WebPluginRuntimeSpecifier, names: Iterable<string>): string {\n const all = new Set(names);\n const lines = [`const runtime = ${webPluginRuntimeGlobal(specifier)};`];\n const exported: string[] = [];\n let index = 0;\n for (const name of [...all].sort()) {\n if (name === DEFAULT_EXPORT) continue;\n const local = `_${String(index++)}`;\n lines.push(`const ${local} = runtime[${JSON.stringify(name)}];`);\n exported.push(`${local} as ${IDENTIFIER.test(name) ? name : JSON.stringify(name)}`);\n }\n if (exported.length > 0) lines.push(`export { ${exported.join(', ')} };`);\n // CommonJS has no default export of its own; interop treats the whole object as one.\n if (all.has(DEFAULT_EXPORT)) lines.push('export default runtime[\"default\"];');\n else if (COMMONJS_RUNTIME_SPECIFIERS.has(specifier)) lines.push('export default runtime;');\n lines.push('');\n return lines.join('\\n');\n}\n\n/**\n * Resolves every shared runtime specifier to a virtual facade that re-exports, by name,\n * from `globalThis.PoWebPluginRuntime`, so ES-module slot entries can import them without\n * the page providing an import map. Names come from the host's own copy of each module.\n */\nexport function webPluginRuntimeFacadePlugin(hostRoot: string): Plugin {\n const shared: ReadonlySet<string> = new Set(WEB_PLUGIN_RUNTIME_SPECIFIERS);\n const hostImporter = path.join(hostRoot, 'package.json');\n const hostRequire = createRequire(hostImporter);\n return {\n name: 'po-web-runtime-facades',\n enforce: 'pre',\n resolveId(source) {\n return shared.has(source) ? `${FACADE_PREFIX}${source}` : null;\n },\n async load(id) {\n if (!isWebPluginFacade(id)) return null;\n const specifier = id.slice(FACADE_PREFIX.length) as WebPluginRuntimeSpecifier;\n if (COMMONJS_RUNTIME_SPECIFIERS.has(specifier))\n return renderWebPluginFacade(specifier, Object.keys(hostRequire(specifier) as object));\n const resolveFile = async (source: string, importer: string): Promise<string | undefined> => {\n const resolved = await this.resolve(source, importer, { skipSelf: true });\n return resolved ? (resolved.id.split('?')[0] ?? resolved.id) : undefined;\n };\n const file = await resolveFile(specifier, hostImporter);\n if (file === undefined) throw new Error(`The shared module '${specifier}' does not resolve from ${hostRoot}.`);\n const { parseAst } = await import('vite');\n return renderWebPluginFacade(\n specifier,\n await esModuleExportNames(specifier, file, { parse: (code) => parseAst(code), resolve: resolveFile }),\n );\n },\n };\n}\n\n/** Resolves generated JSX imports from the host instead of a plugin's optional React peer tree. */\nexport function webPluginRuntimeAliases(clientRoot: string): Alias[] {\n const runtimeRequire = createRequire(path.join(clientRoot, 'index.html'));\n return WEB_PLUGIN_RUNTIME_SPECIFIERS.filter((specifier) => specifier.startsWith('react/jsx-')).map((specifier) => ({\n find: new RegExp(`^${specifier.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&')}$`, 'u'),\n replacement: runtimeRequire.resolve(specifier),\n }));\n}\n\n/**\n * Swaps the committed builtin registry modules for generated ones. A\n * resolveId hook rather than resolve.alias because aliases match raw import\n * specifiers while these two are known by their resolved paths. Both the\n * sync-time build and the dev server use it, so a plugin edit in dev is the\n * same module the bundle would carry.\n */\nexport function webPluginOverridePlugin(clientRoot: string, generated: WebPluginRegistryModules): Plugin {\n const overrides = new Map([\n [path.join(clientRoot, 'app', 'webPlugins.generated.ts'), generated.clientModulePath],\n [path.join(clientRoot, 'styles', 'webPluginSources.generated.css'), generated.cssModulePath],\n ]);\n return {\n name: 'po-web-plugin-overrides',\n enforce: 'pre',\n async resolveId(source, importer, options) {\n if (!source.includes('webPlugins.generated') && !source.includes('webPluginSources.generated.css')) return null;\n const resolved = await this.resolve(source, importer, { ...options, skipSelf: true });\n if (!resolved) return null;\n return overrides.get(resolved.id) ?? null;\n },\n };\n}\n\n/**\n * The CSS sources module cannot ride the resolveId hook: Vite and Tailwind\n * resolve CSS @import through Vite's own id resolver, which consults aliases\n * but no plugin hooks. Without this the builtin (empty) @source list ships\n * and every plugin-only utility class is missing.\n */\nexport function webPluginCssAlias(generated: WebPluginRegistryModules): Alias {\n return { find: /^\\.\\/webPluginSources\\.generated\\.css$/, replacement: generated.cssModulePath };\n}\n\n/** The plugin package roots the dev server should serve, from an explicit override or PO_ROOT. */\nexport async function readDevPluginRoots(environment: NodeJS.ProcessEnv, homeDirectory: string): Promise<string[]> {\n const explicit = environment[PLUGIN_ROOTS_ENV];\n if (explicit !== undefined && explicit !== '') {\n return devPluginRoots({ envValue: explicit, rootsFileText: undefined, delimiter: path.delimiter });\n }\n const repoRoot = environment[PO_ROOT_ENV];\n if (repoRoot === undefined || repoRoot === '') return [];\n // Resolved live from the root's configuration and installed packages, as the server does.\n return compositionPackageRoots(rootCompositions({ root: repoRoot, homeDirectory, environment }));\n}\n"],"mappings":";;;;;;;;;;AAWA,MAAM,cAAc;;;;;;;;;;AAWpB,MAAa,gCAAgC;CAC3C;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAEA,MAAM,gCAAgG;CACpG,OAAO;CACP,qBAAqB;CACrB,yBAAyB;CACzB,aAAa;CACb,oBAAoB;CACpB,mBAAmB;CACnB,yBAAyB;CACzB,0BAA0B;CAC1B,+BAA+B;CAC/B,qCAAqC;CACrC,0BAA0B;CAC1B,gCAAgC;CAChC,sCAAsC;CACtC,qBAAqB;CACrB,oBAAoB;AACtB;;AAKA,SAAgB,uBAAuB,WAA8C;CACnF,OAAO,iCAAiC,8BAA8B;AACxE;;AAGA,MAAM,8CAAmD,IAAI,IAAI;CAC/D;CACA;CACA;CACA;CACA;AACF,CAAC;AAED,MAAM,gBAAgB;;AAEtB,MAAa,0BAA0B;;AAGvC,SAAgB,kBAAkB,IAAqB;CACrD,OAAO,GAAG,WAAW,aAAa;AACpC;;AAGA,MAAM,iBAAiB;AAIvB,SAAS,aAAa,SAA4B;CAChD,QAAQ,QAAQ,MAAhB;EACE,KAAK,cACH,OAAO,CAAC,QAAQ,IAAc;EAChC,KAAK,iBACH,OAAQ,QAAQ,WAAyB,SAAS,aAChD,aAAc,SAAS,SAAS,gBAAgB,SAAS,WAAW,SAAS,KAAiB,CAChG;EACF,KAAK,gBACH,OAAQ,QAAQ,SAAgC,SAAS,YAAa,UAAU,aAAa,OAAO,IAAI,CAAC,CAAE;EAC7G,KAAK,eACH,OAAO,aAAa,QAAQ,QAAmB;EACjD,KAAK,qBACH,OAAO,aAAa,QAAQ,IAAe;EAC7C,S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;;;;;;;;AASA,SAAgB,wBAAwB,YAAoB,WAA6C;CACvG,MAAM,4BAAY,IAAI,IAAI,CACxB,CAACA,UAAAA,QAAK,KAAK,YAAY,OAAO,yBAAyB,GAAG,UAAU,gBAAgB,GACpF,CAACA,UAAAA,QAAK,KAAK,YAAY,UAAU,gCAAgC,GAAG,UAAU,aAAa,CAC7F,CAAC;CACD,OAAO;EACL,MAAM;EACN,SAAS;EACT,MAAM,UAAU,QAAQ,UAAU,SAAS;GACzC,IAAI,CAAC,OAAO,SAAS,sBAAsB,KAAK,CAAC,OAAO,SAAS,gCAAgC,GAAG,OAAO;GAC3G,MAAM,WAAW,MAAM,KAAK,QAAQ,QAAQ,UAAU;IAAE,GAAG;IAAS,UAAU;GAAK,CAAC;GACpF,IAAI,CAAC,UAAU,OAAO;GACtB,OAAO,UAAU,IAAI,SAAS,EAAE,KAAK;EACvC;CACF;AACF;;;;;;;AAQA,SAAgB,kBAAkB,WAA4C;CAC5E,OAAO;EAAE,MAAM;EAA0C,aAAa,UAAU;CAAc;AAChG;;AAGA,eAAsB,mBAAmB,aAAgC,eAA0C;CACjH,MAAM,WAAW,YAAYE,oBAAAA;CAC7B,IAAI,aAAa,KAAA,KAAa,aAAa,IACzC,OAAOC,oBAAAA,eAAe;EAAE,UAAU;EAAU,eAAe,KAAA;EAAW,WAAWH,UAAAA,QAAK;CAAU,CAAC;CAEnG,MAAM,WAAW,YAAY;CAC7B,IAAI,aAAa,KAAA,KAAa,aAAa,IAAI,OAAO,CAAC;CAEvD,OAAOI,cAAAA,wBAAwBC,2BAAAA,iBAAiB;EAAE,MAAM;EAAU;EAAe;CAAY,CAAC,CAAC;AACjG"}
@@ -59,7 +59,7 @@ export declare function webPluginOverridePlugin(clientRoot: string, generated: W
59
59
  */
60
60
  export declare function webPluginCssAlias(generated: WebPluginRegistryModules): Alias;
61
61
  /** The plugin package roots the dev server should serve, from an explicit override or PO_ROOT. */
62
- export declare function readDevPluginRoots(environment: NodeJS.ProcessEnv, homeDirectory: string): string[];
62
+ export declare function readDevPluginRoots(environment: NodeJS.ProcessEnv, homeDirectory: string): Promise<string[]>;
63
63
  //#endregion
64
64
  export {};
65
65
  //# sourceMappingURL=webPluginVite.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"webPluginVite.d.mts","names":[],"sources":["../../../../src/builders/web/webPluginVite.ts"],"mappings":";;;;;;;;;;;;qBAsBa;KAoCR,oCAAoC;;wBAGzB,uBAAuB,WAAW;;qBAerC;;wBAGG,kBAAkB;;iBAiCjB;EACf,QAAQ;IAAmB;;;EAE3B,UAAU,gBAAgB,qBAAqB;;;;;;;;wBAS3B,oBACpB,mBACA,cACA,QAAQ,kBACR,OAAM,cACL,QAAQ;;wBAsDK,sBAAsB,WAAW,2BAA2B,OAAO;;;;;;wBAwBnE,6BAA6B,mBAAmB;;wBA+BhD,wBAAwB,qBAAqB;;;;;;;;wBAe7C,wBAAwB,oBAAoB,WAAW,2BAA2B;;;;;;;wBAuBlF,kBAAkB,WAAW,2BAA2B;;wBAKxD,mBAAmB,aAAa,OAAO,YAAY"}
1
+ {"version":3,"file":"webPluginVite.d.mts","names":[],"sources":["../../../../src/builders/web/webPluginVite.ts"],"mappings":";;;;;;;;;;;;qBAsBa;KAoCR,oCAAoC;;wBAGzB,uBAAuB,WAAW;;qBAerC;;wBAGG,kBAAkB;;iBAiCjB;EACf,QAAQ;IAAmB;;;EAE3B,UAAU,gBAAgB,qBAAqB;;;;;;;;wBAS3B,oBACpB,mBACA,cACA,QAAQ,kBACR,OAAM,cACL,QAAQ;;wBAsDK,sBAAsB,WAAW,2BAA2B,OAAO;;;;;;wBAwBnE,6BAA6B,mBAAmB;;wBA+BhD,wBAAwB,qBAAqB;;;;;;;;wBAe7C,wBAAwB,oBAAoB,WAAW,2BAA2B;;;;;;;wBAuBlF,kBAAkB,WAAW,2BAA2B;;wBAKlD,mBAAmB,aAAa,OAAO,YAAY,wBAAwB"}
@@ -2,8 +2,8 @@ import { compositionPackageRoots } from "./index.mjs";
2
2
  import { rootCompositions } from "../cli/sessionComposition.mjs";
3
3
  import { PLUGIN_ROOTS_ENV, devPluginRoots } from "./webDevRoots.mjs";
4
4
  import { createRequire } from "node:module";
5
- import fs from "node:fs";
6
5
  import path from "node:path";
6
+ import fs from "node:fs/promises";
7
7
  //#region src/builders/web/webPluginVite.ts
8
8
  const PO_ROOT_ENV = "PO_ROOT";
9
9
  /**
@@ -95,7 +95,7 @@ async function esModuleExportNames(specifier, file, reader, seen = /* @__PURE__
95
95
  seen.add(file);
96
96
  let body;
97
97
  try {
98
- body = reader.parse(fs.readFileSync(file, "utf8")).body;
98
+ body = reader.parse(await fs.readFile(file, "utf8")).body;
99
99
  } catch (error) {
100
100
  throw new Error(`The shared module '${specifier}' cannot be parsed at ${file}: ${error instanceof Error ? error.message : String(error)}`);
101
101
  }
@@ -221,7 +221,7 @@ function webPluginCssAlias(generated) {
221
221
  };
222
222
  }
223
223
  /** The plugin package roots the dev server should serve, from an explicit override or PO_ROOT. */
224
- function readDevPluginRoots(environment, homeDirectory) {
224
+ async function readDevPluginRoots(environment, homeDirectory) {
225
225
  const explicit = environment[PLUGIN_ROOTS_ENV];
226
226
  if (explicit !== void 0 && explicit !== "") return devPluginRoots({
227
227
  envValue: explicit,
@@ -1 +1 @@
1
- {"version":3,"file":"webPluginVite.mjs","names":[],"sources":["../../../../src/builders/web/webPluginVite.ts"],"sourcesContent":["import fs from 'node:fs';\nimport { createRequire } from 'node:module';\nimport path from 'node:path';\n\nimport type { Alias, Plugin } from 'vite';\n\nimport { rootCompositions } from '../cli/sessionComposition';\nimport { compositionPackageRoots } from './index';\nimport { devPluginRoots, PLUGIN_ROOTS_ENV } from './webDevRoots';\nimport type { WebPluginRegistryModules } from './webPluginGenerate';\n\nconst PO_ROOT_ENV = 'PO_ROOT';\n\n/**\n * The modules the cockpit supplies page-wide, rather than each plugin\n * carrying its own copy.\n *\n * Build-time metadata, and it stays here rather than in a browser-facing\n * barrel on purpose: exporting it from po-core/web put the literal list\n * into the shipped cockpit bundle, where a plugin's own specifier strings\n * would then appear as data.\n */\nexport const WEB_PLUGIN_RUNTIME_SPECIFIERS = [\n 'react',\n 'react/jsx-runtime',\n 'react/jsx-dev-runtime',\n 'react-dom',\n 'react-dom/client',\n '@tanstack/store',\n '@tanstack/react-store',\n '@tanstack/react-router',\n '@agimon-ai/po-web-dashboard',\n '@agimon-ai/po-web-dashboard/views',\n '@agimon-ai/po-core/web',\n '@agimon-ai/po-web-components',\n '@agimon-ai/po-web-security/browser',\n '@codemirror/state',\n '@codemirror/view',\n] as const;\n\nconst WEB_PLUGIN_RUNTIME_PROPERTIES: Record<(typeof WEB_PLUGIN_RUNTIME_SPECIFIERS)[number], string> = {\n react: 'react',\n 'react/jsx-runtime': 'reactJsxRuntime',\n 'react/jsx-dev-runtime': 'reactJsxDevRuntime',\n 'react-dom': 'reactDom',\n 'react-dom/client': 'reactDomClient',\n '@tanstack/store': 'tanstackStore',\n '@tanstack/react-store': 'tanstackReactStore',\n '@tanstack/react-router': 'tanstackRouter',\n '@agimon-ai/po-web-dashboard': 'dashboard',\n '@agimon-ai/po-web-dashboard/views': 'dashboardViews',\n '@agimon-ai/po-core/web': 'webContracts',\n '@agimon-ai/po-web-components': 'webComponents',\n '@agimon-ai/po-web-security/browser': 'webSecurityBrowser',\n '@codemirror/state': 'codemirrorState',\n '@codemirror/view': 'codemirrorView',\n};\n\ntype WebPluginRuntimeSpecifier = (typeof WEB_PLUGIN_RUNTIME_SPECIFIERS)[number];\n\n/** Expression for a shared module supplied by the session shell. */\nexport function webPluginRuntimeGlobal(specifier: WebPluginRuntimeSpecifier): string {\n return `globalThis.PoWebPluginRuntime.${WEB_PLUGIN_RUNTIME_PROPERTIES[specifier]}`;\n}\n\n/** The React family ships CommonJS, so its names come from loading it rather than parsing it. */\nconst COMMONJS_RUNTIME_SPECIFIERS: ReadonlySet<string> = new Set([\n 'react',\n 'react/jsx-runtime',\n 'react/jsx-dev-runtime',\n 'react-dom',\n 'react-dom/client',\n]);\n\nconst FACADE_PREFIX = '\\0po-web-runtime:';\n/** The chunk every facade lands in, so each shared module is read from the runtime once. */\nexport const WEB_PLUGIN_FACADE_CHUNK = 'po-web-runtime';\n\n/** True for a module id that is one of the shared-module facades. */\nexport function isWebPluginFacade(id: string): boolean {\n return id.startsWith(FACADE_PREFIX);\n}\n\n/** The ES module name of a default export. */\nconst DEFAULT_EXPORT = 'default';\n\ntype AstNode = { type: string; [key: string]: unknown };\n\nfunction patternNames(pattern: AstNode): string[] {\n switch (pattern.type) {\n case 'Identifier':\n return [pattern.name as string];\n case 'ObjectPattern':\n return (pattern.properties as AstNode[]).flatMap((property) =>\n patternNames((property.type === 'RestElement' ? property.argument : property.value) as AstNode),\n );\n case 'ArrayPattern':\n return (pattern.elements as (AstNode | null)[]).flatMap((element) => (element ? patternNames(element) : []));\n case 'RestElement':\n return patternNames(pattern.argument as AstNode);\n case 'AssignmentPattern':\n return patternNames(pattern.left as AstNode);\n default:\n return [];\n }\n}\n\nfunction exportedName(node: AstNode): string {\n return node.type === 'Identifier' ? (node.name as string) : String(node.value);\n}\n\n/** Static reading of an ES module's export names, as the facade plugin needs it. */\nexport interface ExportNameReader {\n parse: (code: string) => { body: unknown[] };\n /** Resolves a bare specifier from the file that imports it, to a file path. */\n resolve: (source: string, importer: string) => Promise<string | undefined>;\n}\n\n/**\n * The export names of an ES module file. `export *` is followed through relative paths,\n * and through a bare specifier only when that specifier is itself a shared module\n * (resolved from the re-exporting file, since that is the copy the runtime object holds).\n * Any other bare `export *` and any unparseable file fail the build.\n */\nexport async function esModuleExportNames(\n specifier: string,\n file: string,\n reader: ExportNameReader,\n seen: Set<string> = new Set(),\n): Promise<Set<string>> {\n const names = new Set<string>();\n if (seen.has(file)) return names;\n seen.add(file);\n let body: AstNode[];\n try {\n body = reader.parse(fs.readFileSync(file, 'utf8')).body as AstNode[];\n } catch (error) {\n throw new Error(\n `The shared module '${specifier}' cannot be parsed at ${file}: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n const shared: ReadonlySet<string> = new Set(WEB_PLUGIN_RUNTIME_SPECIFIERS);\n for (const node of body) {\n if (node.type === 'ExportDefaultDeclaration') names.add(DEFAULT_EXPORT);\n if (node.type === 'ExportNamedDeclaration') {\n const declaration = node.declaration as AstNode | null;\n if (declaration?.type === 'VariableDeclaration') {\n for (const declarator of declaration.declarations as AstNode[])\n for (const name of patternNames(declarator.id as AstNode)) names.add(name);\n } else if (declaration) {\n names.add((declaration.id as AstNode).name as string);\n }\n for (const entry of (node.specifiers as AstNode[] | undefined) ?? [])\n names.add(exportedName(entry.exported as AstNode));\n }\n if (node.type === 'ExportAllDeclaration') {\n if (node.exported) {\n names.add(exportedName(node.exported as AstNode));\n continue;\n }\n const source = String((node.source as AstNode).value);\n let target: string | undefined;\n if (source.startsWith('./') || source.startsWith('../')) target = path.resolve(path.dirname(file), source);\n else if (shared.has(source)) {\n target = await reader.resolve(source, file);\n if (target === undefined)\n throw new Error(\n `The shared module '${specifier}' re-exports '${source}', which does not resolve from ${file}.`,\n );\n } else\n throw new Error(\n `The shared module '${specifier}' re-exports everything from the bare specifier '${source}' (${file}), which is not a shared module; its names cannot be listed.`,\n );\n for (const name of await esModuleExportNames(specifier, target, reader, seen))\n if (name !== DEFAULT_EXPORT) names.add(name);\n }\n }\n return names;\n}\n\nconst IDENTIFIER = /^[A-Za-z_$][\\w$]*$/u;\n\n/** A module that reads one shared module from the page runtime and re-exports the given names. */\nexport function renderWebPluginFacade(specifier: WebPluginRuntimeSpecifier, names: Iterable<string>): string {\n const all = new Set(names);\n const lines = [`const runtime = ${webPluginRuntimeGlobal(specifier)};`];\n const exported: string[] = [];\n let index = 0;\n for (const name of [...all].sort()) {\n if (name === DEFAULT_EXPORT) continue;\n const local = `_${String(index++)}`;\n lines.push(`const ${local} = runtime[${JSON.stringify(name)}];`);\n exported.push(`${local} as ${IDENTIFIER.test(name) ? name : JSON.stringify(name)}`);\n }\n if (exported.length > 0) lines.push(`export { ${exported.join(', ')} };`);\n // CommonJS has no default export of its own; interop treats the whole object as one.\n if (all.has(DEFAULT_EXPORT)) lines.push('export default runtime[\"default\"];');\n else if (COMMONJS_RUNTIME_SPECIFIERS.has(specifier)) lines.push('export default runtime;');\n lines.push('');\n return lines.join('\\n');\n}\n\n/**\n * Resolves every shared runtime specifier to a virtual facade that re-exports, by name,\n * from `globalThis.PoWebPluginRuntime`, so ES-module slot entries can import them without\n * the page providing an import map. Names come from the host's own copy of each module.\n */\nexport function webPluginRuntimeFacadePlugin(hostRoot: string): Plugin {\n const shared: ReadonlySet<string> = new Set(WEB_PLUGIN_RUNTIME_SPECIFIERS);\n const hostImporter = path.join(hostRoot, 'package.json');\n const hostRequire = createRequire(hostImporter);\n return {\n name: 'po-web-runtime-facades',\n enforce: 'pre',\n resolveId(source) {\n return shared.has(source) ? `${FACADE_PREFIX}${source}` : null;\n },\n async load(id) {\n if (!isWebPluginFacade(id)) return null;\n const specifier = id.slice(FACADE_PREFIX.length) as WebPluginRuntimeSpecifier;\n if (COMMONJS_RUNTIME_SPECIFIERS.has(specifier))\n return renderWebPluginFacade(specifier, Object.keys(hostRequire(specifier) as object));\n const resolveFile = async (source: string, importer: string): Promise<string | undefined> => {\n const resolved = await this.resolve(source, importer, { skipSelf: true });\n return resolved ? (resolved.id.split('?')[0] ?? resolved.id) : undefined;\n };\n const file = await resolveFile(specifier, hostImporter);\n if (file === undefined) throw new Error(`The shared module '${specifier}' does not resolve from ${hostRoot}.`);\n const { parseAst } = await import('vite');\n return renderWebPluginFacade(\n specifier,\n await esModuleExportNames(specifier, file, { parse: (code) => parseAst(code), resolve: resolveFile }),\n );\n },\n };\n}\n\n/** Resolves generated JSX imports from the host instead of a plugin's optional React peer tree. */\nexport function webPluginRuntimeAliases(clientRoot: string): Alias[] {\n const runtimeRequire = createRequire(path.join(clientRoot, 'index.html'));\n return WEB_PLUGIN_RUNTIME_SPECIFIERS.filter((specifier) => specifier.startsWith('react/jsx-')).map((specifier) => ({\n find: new RegExp(`^${specifier.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&')}$`, 'u'),\n replacement: runtimeRequire.resolve(specifier),\n }));\n}\n\n/**\n * Swaps the committed builtin registry modules for generated ones. A\n * resolveId hook rather than resolve.alias because aliases match raw import\n * specifiers while these two are known by their resolved paths. Both the\n * sync-time build and the dev server use it, so a plugin edit in dev is the\n * same module the bundle would carry.\n */\nexport function webPluginOverridePlugin(clientRoot: string, generated: WebPluginRegistryModules): Plugin {\n const overrides = new Map([\n [path.join(clientRoot, 'app', 'webPlugins.generated.ts'), generated.clientModulePath],\n [path.join(clientRoot, 'styles', 'webPluginSources.generated.css'), generated.cssModulePath],\n ]);\n return {\n name: 'po-web-plugin-overrides',\n enforce: 'pre',\n async resolveId(source, importer, options) {\n if (!source.includes('webPlugins.generated') && !source.includes('webPluginSources.generated.css')) return null;\n const resolved = await this.resolve(source, importer, { ...options, skipSelf: true });\n if (!resolved) return null;\n return overrides.get(resolved.id) ?? null;\n },\n };\n}\n\n/**\n * The CSS sources module cannot ride the resolveId hook: Vite and Tailwind\n * resolve CSS @import through Vite's own id resolver, which consults aliases\n * but no plugin hooks. Without this the builtin (empty) @source list ships\n * and every plugin-only utility class is missing.\n */\nexport function webPluginCssAlias(generated: WebPluginRegistryModules): Alias {\n return { find: /^\\.\\/webPluginSources\\.generated\\.css$/, replacement: generated.cssModulePath };\n}\n\n/** The plugin package roots the dev server should serve, from an explicit override or PO_ROOT. */\nexport function readDevPluginRoots(environment: NodeJS.ProcessEnv, homeDirectory: string): string[] {\n const explicit = environment[PLUGIN_ROOTS_ENV];\n if (explicit !== undefined && explicit !== '') {\n return devPluginRoots({ envValue: explicit, rootsFileText: undefined, delimiter: path.delimiter });\n }\n const repoRoot = environment[PO_ROOT_ENV];\n if (repoRoot === undefined || repoRoot === '') return [];\n // Resolved live from the root's configuration and installed packages, as the server does.\n return compositionPackageRoots(rootCompositions({ root: repoRoot, homeDirectory, environment }));\n}\n"],"mappings":";;;;;;;AA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C,OAAO,SAAS,sBAAsB,KAAK,CAAC,OAAO,SAAS,gCAAgC,GAAG,OAAO;GAC3G,MAAM,WAAW,MAAM,KAAK,QAAQ,QAAQ,UAAU;IAAE,GAAG;IAAS,UAAU;GAAK,CAAC;GACpF,IAAI,CAAC,UAAU,OAAO;GACtB,OAAO,UAAU,IAAI,SAAS,EAAE,KAAK;EACvC;CACF;AACF;;;;;;;AAQA,SAAgB,kBAAkB,WAA4C;CAC5E,OAAO;EAAE,MAAM;EAA0C,aAAa,UAAU;CAAc;AAChG;;AAGA,SAAgB,mBAAmB,aAAgC,eAAiC;CAClG,MAAM,WAAW,YAAY;CAC7B,IAAI,aAAa,KAAA,KAAa,aAAa,IACzC,OAAO,eAAe;EAAE,UAAU;EAAU,eAAe,KAAA;EAAW,WAAW,KAAK;CAAU,CAAC;CAEnG,MAAM,WAAW,YAAY;CAC7B,IAAI,aAAa,KAAA,KAAa,aAAa,IAAI,OAAO,CAAC;CAEvD,OAAO,wBAAwB,iBAAiB;EAAE,MAAM;EAAU;EAAe;CAAY,CAAC,CAAC;AACjG"}
1
+ {"version":3,"file":"webPluginVite.mjs","names":[],"sources":["../../../../src/builders/web/webPluginVite.ts"],"sourcesContent":["import fs from 'node:fs/promises';\nimport { createRequire } from 'node:module';\nimport path from 'node:path';\n\nimport type { Alias, Plugin } from 'vite';\n\nimport { rootCompositions } from '../cli/sessionComposition';\nimport { compositionPackageRoots } from './index';\nimport { devPluginRoots, PLUGIN_ROOTS_ENV } from './webDevRoots';\nimport type { WebPluginRegistryModules } from './webPluginGenerate';\n\nconst PO_ROOT_ENV = 'PO_ROOT';\n\n/**\n * The modules the cockpit supplies page-wide, rather than each plugin\n * carrying its own copy.\n *\n * Build-time metadata, and it stays here rather than in a browser-facing\n * barrel on purpose: exporting it from po-core/web put the literal list\n * into the shipped cockpit bundle, where a plugin's own specifier strings\n * would then appear as data.\n */\nexport const WEB_PLUGIN_RUNTIME_SPECIFIERS = [\n 'react',\n 'react/jsx-runtime',\n 'react/jsx-dev-runtime',\n 'react-dom',\n 'react-dom/client',\n '@tanstack/store',\n '@tanstack/react-store',\n '@tanstack/react-router',\n '@agimon-ai/po-web-dashboard',\n '@agimon-ai/po-web-dashboard/views',\n '@agimon-ai/po-core/web',\n '@agimon-ai/po-web-components',\n '@agimon-ai/po-web-security/browser',\n '@codemirror/state',\n '@codemirror/view',\n] as const;\n\nconst WEB_PLUGIN_RUNTIME_PROPERTIES: Record<(typeof WEB_PLUGIN_RUNTIME_SPECIFIERS)[number], string> = {\n react: 'react',\n 'react/jsx-runtime': 'reactJsxRuntime',\n 'react/jsx-dev-runtime': 'reactJsxDevRuntime',\n 'react-dom': 'reactDom',\n 'react-dom/client': 'reactDomClient',\n '@tanstack/store': 'tanstackStore',\n '@tanstack/react-store': 'tanstackReactStore',\n '@tanstack/react-router': 'tanstackRouter',\n '@agimon-ai/po-web-dashboard': 'dashboard',\n '@agimon-ai/po-web-dashboard/views': 'dashboardViews',\n '@agimon-ai/po-core/web': 'webContracts',\n '@agimon-ai/po-web-components': 'webComponents',\n '@agimon-ai/po-web-security/browser': 'webSecurityBrowser',\n '@codemirror/state': 'codemirrorState',\n '@codemirror/view': 'codemirrorView',\n};\n\ntype WebPluginRuntimeSpecifier = (typeof WEB_PLUGIN_RUNTIME_SPECIFIERS)[number];\n\n/** Expression for a shared module supplied by the session shell. */\nexport function webPluginRuntimeGlobal(specifier: WebPluginRuntimeSpecifier): string {\n return `globalThis.PoWebPluginRuntime.${WEB_PLUGIN_RUNTIME_PROPERTIES[specifier]}`;\n}\n\n/** The React family ships CommonJS, so its names come from loading it rather than parsing it. */\nconst COMMONJS_RUNTIME_SPECIFIERS: ReadonlySet<string> = new Set([\n 'react',\n 'react/jsx-runtime',\n 'react/jsx-dev-runtime',\n 'react-dom',\n 'react-dom/client',\n]);\n\nconst FACADE_PREFIX = '\\0po-web-runtime:';\n/** The chunk every facade lands in, so each shared module is read from the runtime once. */\nexport const WEB_PLUGIN_FACADE_CHUNK = 'po-web-runtime';\n\n/** True for a module id that is one of the shared-module facades. */\nexport function isWebPluginFacade(id: string): boolean {\n return id.startsWith(FACADE_PREFIX);\n}\n\n/** The ES module name of a default export. */\nconst DEFAULT_EXPORT = 'default';\n\ntype AstNode = { type: string; [key: string]: unknown };\n\nfunction patternNames(pattern: AstNode): string[] {\n switch (pattern.type) {\n case 'Identifier':\n return [pattern.name as string];\n case 'ObjectPattern':\n return (pattern.properties as AstNode[]).flatMap((property) =>\n patternNames((property.type === 'RestElement' ? property.argument : property.value) as AstNode),\n );\n case 'ArrayPattern':\n return (pattern.elements as (AstNode | null)[]).flatMap((element) => (element ? patternNames(element) : []));\n case 'RestElement':\n return patternNames(pattern.argument as AstNode);\n case 'AssignmentPattern':\n return patternNames(pattern.left as AstNode);\n default:\n return [];\n }\n}\n\nfunction exportedName(node: AstNode): string {\n return node.type === 'Identifier' ? (node.name as string) : String(node.value);\n}\n\n/** Static reading of an ES module's export names, as the facade plugin needs it. */\nexport interface ExportNameReader {\n parse: (code: string) => { body: unknown[] };\n /** Resolves a bare specifier from the file that imports it, to a file path. */\n resolve: (source: string, importer: string) => Promise<string | undefined>;\n}\n\n/**\n * The export names of an ES module file. `export *` is followed through relative paths,\n * and through a bare specifier only when that specifier is itself a shared module\n * (resolved from the re-exporting file, since that is the copy the runtime object holds).\n * Any other bare `export *` and any unparseable file fail the build.\n */\nexport async function esModuleExportNames(\n specifier: string,\n file: string,\n reader: ExportNameReader,\n seen: Set<string> = new Set(),\n): Promise<Set<string>> {\n const names = new Set<string>();\n if (seen.has(file)) return names;\n seen.add(file);\n let body: AstNode[];\n try {\n body = reader.parse(await fs.readFile(file, 'utf8')).body as AstNode[];\n } catch (error) {\n throw new Error(\n `The shared module '${specifier}' cannot be parsed at ${file}: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n const shared: ReadonlySet<string> = new Set(WEB_PLUGIN_RUNTIME_SPECIFIERS);\n for (const node of body) {\n if (node.type === 'ExportDefaultDeclaration') names.add(DEFAULT_EXPORT);\n if (node.type === 'ExportNamedDeclaration') {\n const declaration = node.declaration as AstNode | null;\n if (declaration?.type === 'VariableDeclaration') {\n for (const declarator of declaration.declarations as AstNode[])\n for (const name of patternNames(declarator.id as AstNode)) names.add(name);\n } else if (declaration) {\n names.add((declaration.id as AstNode).name as string);\n }\n for (const entry of (node.specifiers as AstNode[] | undefined) ?? [])\n names.add(exportedName(entry.exported as AstNode));\n }\n if (node.type === 'ExportAllDeclaration') {\n if (node.exported) {\n names.add(exportedName(node.exported as AstNode));\n continue;\n }\n const source = String((node.source as AstNode).value);\n let target: string | undefined;\n if (source.startsWith('./') || source.startsWith('../')) target = path.resolve(path.dirname(file), source);\n else if (shared.has(source)) {\n target = await reader.resolve(source, file);\n if (target === undefined)\n throw new Error(\n `The shared module '${specifier}' re-exports '${source}', which does not resolve from ${file}.`,\n );\n } else\n throw new Error(\n `The shared module '${specifier}' re-exports everything from the bare specifier '${source}' (${file}), which is not a shared module; its names cannot be listed.`,\n );\n for (const name of await esModuleExportNames(specifier, target, reader, seen))\n if (name !== DEFAULT_EXPORT) names.add(name);\n }\n }\n return names;\n}\n\nconst IDENTIFIER = /^[A-Za-z_$][\\w$]*$/u;\n\n/** A module that reads one shared module from the page runtime and re-exports the given names. */\nexport function renderWebPluginFacade(specifier: WebPluginRuntimeSpecifier, names: Iterable<string>): string {\n const all = new Set(names);\n const lines = [`const runtime = ${webPluginRuntimeGlobal(specifier)};`];\n const exported: string[] = [];\n let index = 0;\n for (const name of [...all].sort()) {\n if (name === DEFAULT_EXPORT) continue;\n const local = `_${String(index++)}`;\n lines.push(`const ${local} = runtime[${JSON.stringify(name)}];`);\n exported.push(`${local} as ${IDENTIFIER.test(name) ? name : JSON.stringify(name)}`);\n }\n if (exported.length > 0) lines.push(`export { ${exported.join(', ')} };`);\n // CommonJS has no default export of its own; interop treats the whole object as one.\n if (all.has(DEFAULT_EXPORT)) lines.push('export default runtime[\"default\"];');\n else if (COMMONJS_RUNTIME_SPECIFIERS.has(specifier)) lines.push('export default runtime;');\n lines.push('');\n return lines.join('\\n');\n}\n\n/**\n * Resolves every shared runtime specifier to a virtual facade that re-exports, by name,\n * from `globalThis.PoWebPluginRuntime`, so ES-module slot entries can import them without\n * the page providing an import map. Names come from the host's own copy of each module.\n */\nexport function webPluginRuntimeFacadePlugin(hostRoot: string): Plugin {\n const shared: ReadonlySet<string> = new Set(WEB_PLUGIN_RUNTIME_SPECIFIERS);\n const hostImporter = path.join(hostRoot, 'package.json');\n const hostRequire = createRequire(hostImporter);\n return {\n name: 'po-web-runtime-facades',\n enforce: 'pre',\n resolveId(source) {\n return shared.has(source) ? `${FACADE_PREFIX}${source}` : null;\n },\n async load(id) {\n if (!isWebPluginFacade(id)) return null;\n const specifier = id.slice(FACADE_PREFIX.length) as WebPluginRuntimeSpecifier;\n if (COMMONJS_RUNTIME_SPECIFIERS.has(specifier))\n return renderWebPluginFacade(specifier, Object.keys(hostRequire(specifier) as object));\n const resolveFile = async (source: string, importer: string): Promise<string | undefined> => {\n const resolved = await this.resolve(source, importer, { skipSelf: true });\n return resolved ? (resolved.id.split('?')[0] ?? resolved.id) : undefined;\n };\n const file = await resolveFile(specifier, hostImporter);\n if (file === undefined) throw new Error(`The shared module '${specifier}' does not resolve from ${hostRoot}.`);\n const { parseAst } = await import('vite');\n return renderWebPluginFacade(\n specifier,\n await esModuleExportNames(specifier, file, { parse: (code) => parseAst(code), resolve: resolveFile }),\n );\n },\n };\n}\n\n/** Resolves generated JSX imports from the host instead of a plugin's optional React peer tree. */\nexport function webPluginRuntimeAliases(clientRoot: string): Alias[] {\n const runtimeRequire = createRequire(path.join(clientRoot, 'index.html'));\n return WEB_PLUGIN_RUNTIME_SPECIFIERS.filter((specifier) => specifier.startsWith('react/jsx-')).map((specifier) => ({\n find: new RegExp(`^${specifier.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&')}$`, 'u'),\n replacement: runtimeRequire.resolve(specifier),\n }));\n}\n\n/**\n * Swaps the committed builtin registry modules for generated ones. A\n * resolveId hook rather than resolve.alias because aliases match raw import\n * specifiers while these two are known by their resolved paths. Both the\n * sync-time build and the dev server use it, so a plugin edit in dev is the\n * same module the bundle would carry.\n */\nexport function webPluginOverridePlugin(clientRoot: string, generated: WebPluginRegistryModules): Plugin {\n const overrides = new Map([\n [path.join(clientRoot, 'app', 'webPlugins.generated.ts'), generated.clientModulePath],\n [path.join(clientRoot, 'styles', 'webPluginSources.generated.css'), generated.cssModulePath],\n ]);\n return {\n name: 'po-web-plugin-overrides',\n enforce: 'pre',\n async resolveId(source, importer, options) {\n if (!source.includes('webPlugins.generated') && !source.includes('webPluginSources.generated.css')) return null;\n const resolved = await this.resolve(source, importer, { ...options, skipSelf: true });\n if (!resolved) return null;\n return overrides.get(resolved.id) ?? null;\n },\n };\n}\n\n/**\n * The CSS sources module cannot ride the resolveId hook: Vite and Tailwind\n * resolve CSS @import through Vite's own id resolver, which consults aliases\n * but no plugin hooks. Without this the builtin (empty) @source list ships\n * and every plugin-only utility class is missing.\n */\nexport function webPluginCssAlias(generated: WebPluginRegistryModules): Alias {\n return { find: /^\\.\\/webPluginSources\\.generated\\.css$/, replacement: generated.cssModulePath };\n}\n\n/** The plugin package roots the dev server should serve, from an explicit override or PO_ROOT. */\nexport async function readDevPluginRoots(environment: NodeJS.ProcessEnv, homeDirectory: string): Promise<string[]> {\n const explicit = environment[PLUGIN_ROOTS_ENV];\n if (explicit !== undefined && explicit !== '') {\n return devPluginRoots({ envValue: explicit, rootsFileText: undefined, delimiter: path.delimiter });\n }\n const repoRoot = environment[PO_ROOT_ENV];\n if (repoRoot === undefined || repoRoot === '') return [];\n // Resolved live from the root's configuration and installed packages, as the server does.\n return compositionPackageRoots(rootCompositions({ root: repoRoot, homeDirectory, environment }));\n}\n"],"mappings":";;;;;;;AAWA,MAAM,cAAc;;;;;;;;;;AAWpB,MAAa,gCAAgC;CAC3C;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CAC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,QAAQ,UAAU;IAAE,GAAG;IAAS,UAAU;GAAK,CAAC;GACpF,IAAI,CAAC,UAAU,OAAO;GACtB,OAAO,UAAU,IAAI,SAAS,EAAE,KAAK;EACvC;CACF;AACF;;;;;;;AAQA,SAAgB,kBAAkB,WAA4C;CAC5E,OAAO;EAAE,MAAM;EAA0C,aAAa,UAAU;CAAc;AAChG;;AAGA,eAAsB,mBAAmB,aAAgC,eAA0C;CACjH,MAAM,WAAW,YAAY;CAC7B,IAAI,aAAa,KAAA,KAAa,aAAa,IACzC,OAAO,eAAe;EAAE,UAAU;EAAU,eAAe,KAAA;EAAW,WAAW,KAAK;CAAU,CAAC;CAEnG,MAAM,WAAW,YAAY;CAC7B,IAAI,aAAa,KAAA,KAAa,aAAa,IAAI,OAAO,CAAC;CAEvD,OAAO,wBAAwB,iBAAiB;EAAE,MAAM;EAAU;EAAe;CAAY,CAAC,CAAC;AACjG"}
@@ -1,7 +1,7 @@
1
+ const require_locale = require("./locale.cjs");
1
2
  const require_help = require("./help.cjs");
2
3
  const require_options = require("./options.cjs");
3
4
  //#region src/cli/cliApp.ts
4
- const NO_HARNESS_COMMAND = "No harness command selected: pass --explain or --emit-mcp, or run po to start po-web.";
5
5
  /**
6
6
  * Main CLI Application
7
7
  *
@@ -11,7 +11,7 @@ const NO_HARNESS_COMMAND = "No harness command selected: pass --explain or --emi
11
11
  async function selectHarnessCommand(options) {
12
12
  if (options.emitMcp) return (await Promise.resolve().then(() => require("./commands/emit-mcp/index.cjs"))).runEmitMcp;
13
13
  if (options.explain) return (await Promise.resolve().then(() => require("./commands/explain/index.cjs"))).runExplain;
14
- throw new Error(NO_HARNESS_COMMAND);
14
+ throw new Error(require_locale.cliText("cli.error.noHarnessCommand", "No harness command selected: pass --explain or --emit-mcp, or run po to start po-web."));
15
15
  }
16
16
  async function selectLegacyCommand(options) {
17
17
  if (options.emitMcp) {
@@ -22,7 +22,7 @@ async function selectLegacyCommand(options) {
22
22
  const { ExplainCommand } = await Promise.resolve().then(() => require("./commands/explain/index.cjs"));
23
23
  return new ExplainCommand();
24
24
  }
25
- throw new Error(NO_HARNESS_COMMAND);
25
+ throw new Error(require_locale.cliText("cli.error.noHarnessCommand", "No harness command selected: pass --explain or --emit-mcp, or run po to start po-web."));
26
26
  }
27
27
  /**
28
28
  * The terminal app reads only what sync prepared. Packages the selected layers name that do not
@@ -35,17 +35,17 @@ async function requestUnsyncedPackages(repoRoot, context) {
35
35
  Promise.resolve().then(() => require("../../builders/cli/extensionAssembler/index.cjs")),
36
36
  Promise.resolve().then(() => require("../builders/server/backgroundSync.cjs"))
37
37
  ]);
38
- const missing = missingLayerPackageSpecifiers(context.majorModesConfig, context.selectedLayers, createLayerResolvers(repoRoot, context.environment));
38
+ const missing = missingLayerPackageSpecifiers(context.presetsConfig, context.selectedLayers, createLayerResolvers(repoRoot, context.environment));
39
39
  if (missing.length === 0) return;
40
40
  const notice = (message) => {
41
41
  process.stderr.write(`${message}\n`);
42
42
  };
43
- notice(createBackgroundSync({
43
+ notice(await createBackgroundSync({
44
44
  environment: context.environment,
45
45
  onNotice: notice,
46
46
  detached: true,
47
47
  repoRoot
48
- }).request("the terminal app found unsynced packages") ? `Po is syncing ${missing.join(", ")} in the background; they arrive on the next launch.` : `${missing.join(", ")} ${missing.length === 1 ? "is" : "are"} not synced; run po sync to prepare them.`);
48
+ }).request("the terminal app found unsynced packages") ? require_locale.cliText("cli.packages.backgroundSync", "Po is syncing {packages} in the background; they arrive on the next launch.", { packages: missing.join(", ") }) : missing.length === 1 ? require_locale.cliText("cli.packages.unsyncedOne", "{packages} is not synced; run po sync to prepare them.", { packages: missing.join(", ") }) : require_locale.cliText("cli.packages.unsyncedMany", "{packages} are not synced; run po sync to prepare them.", { packages: missing.join(", ") }));
49
49
  }
50
50
  /** Only the diagnostic commands consume a harness context; bare `po` runs po-web. */
51
51
  function wantsHarnessCommand(options) {
@@ -54,24 +54,26 @@ function wantsHarnessCommand(options) {
54
54
  function createCliApplication(initialTelemetry) {
55
55
  let telemetry = initialTelemetry;
56
56
  let ownsTelemetry = false;
57
- async function getTelemetry() {
57
+ async function getTelemetry(environment, cwd) {
58
58
  if (telemetry) return telemetry;
59
59
  const { createHarnessTelemetry } = await import("@agimon-ai/po-core/runtimeLogSinkTelemetry");
60
- telemetry = createHarnessTelemetry({ deferSpans: true });
60
+ telemetry = createHarnessTelemetry({
61
+ env: environment,
62
+ cwd,
63
+ deferSpans: true
64
+ });
61
65
  ownsTelemetry = true;
62
66
  return telemetry;
63
67
  }
64
68
  async function runHarness(options) {
65
- const telemetry = await getTelemetry();
69
+ const telemetry = await getTelemetry(options.environment ?? process.env, options.cwd);
66
70
  const [{ buildHarnessContext }, { HARNESS_EVENT }] = await Promise.all([Promise.resolve().then(() => require("../builders/cli/harnessContext.cjs")), import("@agimon-ai/po-core/runtimeLogSinkTelemetry")]);
67
71
  return telemetry.runInSpan("po_pi.run", {
68
- "harness.major_mode": options.majorMode,
72
+ "harness.preset": options.preset,
69
73
  "harness.domain_count": options.domains.length,
70
74
  "harness.agents": options.agents,
71
75
  "harness.mcp": options.mcp,
72
- "harness.hooks": options.hooks,
73
- ...options.profile ? { "harness.profile": options.profile } : {},
74
- ...options.preset ? { "harness.preset": options.preset } : {}
76
+ ...options.profile ? { "harness.profile": options.profile } : {}
75
77
  }, async () => {
76
78
  const context = await buildHarnessContext(options, telemetry);
77
79
  try {
@@ -86,6 +88,7 @@ function createCliApplication(initialTelemetry) {
86
88
  });
87
89
  }
88
90
  async function run(args) {
91
+ if (args[0] === "compat") throw new Error(require_locale.cliText("cli.error.retiredCompat", "po compat has been retired. Use native Po sessions."));
89
92
  if (args[0] === "init") {
90
93
  const { runInit } = await Promise.resolve().then(() => require("./commands/init/index.cjs"));
91
94
  return runInit(args);
@@ -102,10 +105,6 @@ function createCliApplication(initialTelemetry) {
102
105
  const { runDoctor } = await Promise.resolve().then(() => require("./commands/doctor/index.cjs"));
103
106
  return runDoctor(args);
104
107
  }
105
- if (args[0] === "compat") {
106
- const [{ runCompatibility }, telemetry] = await Promise.all([Promise.resolve().then(() => require("./commands/compat/index.cjs")), getTelemetry()]);
107
- return runCompatibility(args, void 0, void 0, telemetry);
108
- }
109
108
  const initial = require_options.parseHarnessArgs(args);
110
109
  if (initial.help) {
111
110
  require_help.printHelp();
@@ -119,9 +118,9 @@ function createCliApplication(initialTelemetry) {
119
118
  const { runPoWeb } = await Promise.resolve().then(() => require("./commands/web/index.cjs"));
120
119
  return runPoWeb(args);
121
120
  }
122
- const telemetry = await getTelemetry();
121
+ const telemetry = await getTelemetry(process.env, process.cwd());
123
122
  const [{ resolveHarnessOptions }, { toFailureReporter }] = await Promise.all([Promise.resolve().then(() => require("./harnessOptions.cjs")), import("@agimon-ai/po-core/runtimeLogSinkTelemetry")]);
124
- return runHarness(resolveHarnessOptions({
123
+ return runHarness(await resolveHarnessOptions({
125
124
  args,
126
125
  report: toFailureReporter(telemetry)
127
126
  }));
@@ -1 +1 @@
1
- {"version":3,"file":"cliApp.cjs","names":["parseHarnessArgs","HARNESS_VERSION"],"sources":["../../../src/cli/cliApp.ts"],"sourcesContent":["import type { HarnessTelemetry } from '@agimon-ai/po-core/runtimeLogSinkTelemetry';\n\nimport type { HarnessOptions } from '../composition/types/harness';\nimport type { BaseCommand } from './commands/baseCommand';\nimport { HARNESS_VERSION, printHelp } from './help';\nimport { parseHarnessArgs } from './options';\n\nconst NO_HARNESS_COMMAND = 'No harness command selected: pass --explain or --emit-mcp, or run po to start po-web.';\n\n/**\n * Main CLI Application\n *\n * Owns command registration and dispatch. Preparation is shared: the context\n * is built once and handed to whichever command claims the run.\n */\nasync function selectHarnessCommand(\n options: HarnessOptions,\n): Promise<\n (context: import('../builders/cli/harnessContext').HarnessContext, telemetry: HarnessTelemetry) => Promise<number>\n> {\n if (options.emitMcp) return (await import('./commands/emit-mcp')).runEmitMcp;\n if (options.explain) return (await import('./commands/explain')).runExplain;\n throw new Error(NO_HARNESS_COMMAND);\n}\nasync function selectLegacyCommand(options: HarnessOptions): Promise<BaseCommand> {\n if (options.emitMcp) {\n const { EmitMcpCommand } = await import('./commands/emit-mcp');\n return new EmitMcpCommand();\n }\n if (options.explain) {\n const { ExplainCommand } = await import('./commands/explain');\n return new ExplainCommand();\n }\n throw new Error(NO_HARNESS_COMMAND);\n}\n/**\n * The terminal app reads only what sync prepared. Packages the selected layers name that do not\n * resolve yet start a detached background sync from the repository, which registers it as a\n * workspace so sync covers its packages, and they arrive on the next launch.\n */\nexport async function requestUnsyncedPackages(\n repoRoot: string,\n context: Pick<\n import('../builders/cli/harnessContext').HarnessContext,\n 'majorModesConfig' | 'selectedLayers' | 'environment'\n >,\n): Promise<void> {\n const [{ missingLayerPackageSpecifiers }, { createLayerResolvers }, { createBackgroundSync }] = await Promise.all([\n import('../composition/layerPackageInstaller'),\n import('../builders/cli/extensionAssembler'),\n import('../builders/server/backgroundSync'),\n ]);\n const missing = missingLayerPackageSpecifiers(\n context.majorModesConfig,\n context.selectedLayers,\n createLayerResolvers(repoRoot, context.environment),\n );\n if (missing.length === 0) return;\n const notice = (message: string): void => {\n process.stderr.write(`${message}\\n`);\n };\n const started = createBackgroundSync({\n environment: context.environment,\n onNotice: notice,\n detached: true,\n repoRoot,\n }).request('the terminal app found unsynced packages');\n notice(\n started\n ? `Po is syncing ${missing.join(', ')} in the background; they arrive on the next launch.`\n : `${missing.join(', ')} ${missing.length === 1 ? 'is' : 'are'} not synced; run po sync to prepare them.`,\n );\n}\n/** Only the diagnostic commands consume a harness context; bare `po` runs po-web. */\nfunction wantsHarnessCommand(options: Pick<HarnessOptions, 'emitMcp' | 'explain'>): boolean {\n return Boolean(options.emitMcp) || options.explain;\n}\nfunction createCliApplication(initialTelemetry?: HarnessTelemetry) {\n let telemetry = initialTelemetry;\n let ownsTelemetry = false;\n async function getTelemetry(): Promise<HarnessTelemetry> {\n if (telemetry) return telemetry;\n const { createHarnessTelemetry } = await import('@agimon-ai/po-core/runtimeLogSinkTelemetry');\n // Telemetry's transport graph costs roughly one launcher budget slice by\n // itself. Startup callbacks and lifecycle events buffer until shutdown, so\n // transport initialization cannot compete with the Pi child for input.\n telemetry = createHarnessTelemetry({ deferSpans: true });\n ownsTelemetry = true;\n return telemetry;\n }\n\n async function runHarness(options: HarnessOptions): Promise<number> {\n const telemetry = await getTelemetry();\n const [{ buildHarnessContext }, { HARNESS_EVENT }] = await Promise.all([\n import('../builders/cli/harnessContext'),\n import('@agimon-ai/po-core/runtimeLogSinkTelemetry'),\n ]);\n return telemetry.runInSpan(\n 'po_pi.run',\n {\n 'harness.major_mode': options.majorMode,\n 'harness.domain_count': options.domains.length,\n 'harness.agents': options.agents,\n 'harness.mcp': options.mcp,\n 'harness.hooks': options.hooks,\n ...(options.profile ? { 'harness.profile': options.profile } : {}),\n ...(options.preset ? { 'harness.preset': options.preset } : {}),\n },\n async () => {\n const context = await buildHarnessContext(options, telemetry);\n try {\n await requestUnsyncedPackages(options.repoRoot, context);\n const command = await selectHarnessCommand(context.options);\n // Selection uses the same resolved options used to build the context.\n return await command(context, telemetry);\n } catch (error) {\n await telemetry.recordError(HARNESS_EVENT.cliFailed, error);\n throw error;\n } finally {\n await context.cleanup();\n }\n },\n );\n }\n\n async function run(args: string[]): Promise<number> {\n if (args[0] === 'init') {\n const { runInit } = await import('./commands/init');\n return runInit(args);\n }\n if (args[0] === 'sync') {\n const { runSync } = await import('./commands/sync/workflow');\n return runSync(args);\n }\n if (args[0] === 'api-export') {\n const { runApiExport } = await import('./commands/api-export');\n return runApiExport(args);\n }\n if (args[0] === 'doctor') {\n const { runDoctor } = await import('./commands/doctor');\n return runDoctor(args);\n }\n if (args[0] === 'compat') {\n const [{ runCompatibility }, telemetry] = await Promise.all([import('./commands/compat'), getTelemetry()]);\n return runCompatibility(args, undefined, undefined, telemetry);\n }\n\n // The first pass resolves --cwd without touching repository configuration,\n // which keeps help and version available even when modes.yaml is malformed.\n const initial = parseHarnessArgs(args);\n if (initial.help) {\n printHelp();\n return 0;\n }\n if (initial.version) {\n process.stdout.write(`${HARNESS_VERSION}\\n`);\n return 0;\n }\n // Bare `po` serves the web console. po-web owns its own arguments, so they\n // pass through untouched and never reach repository configuration here.\n if (!wantsHarnessCommand(initial.options)) {\n const { runPoWeb } = await import('./commands/web');\n return runPoWeb(args);\n }\n const telemetry = await getTelemetry();\n const [{ resolveHarnessOptions }, { toFailureReporter }] = await Promise.all([\n import('./harnessOptions'),\n import('@agimon-ai/po-core/runtimeLogSinkTelemetry'),\n ]);\n return runHarness(resolveHarnessOptions({ args, report: toFailureReporter(telemetry) }));\n }\n\n async function shutdown(): Promise<void> {\n if (ownsTelemetry) await telemetry?.shutdown();\n }\n return { run, runHarness, shutdown };\n}\n/** Public compatibility API; execution is implemented by the application functions. */\nexport class CliApp {\n private readonly app: ReturnType<typeof createCliApplication>;\n constructor(telemetry?: HarnessTelemetry) {\n this.app = createCliApplication(telemetry);\n }\n selectCommand(options: HarnessOptions): Promise<BaseCommand> {\n return selectLegacyCommand(options);\n }\n runHarness(options: HarnessOptions): Promise<number> {\n return this.app.runHarness(options);\n }\n run(args: string[]): Promise<number> {\n return this.app.run(args);\n }\n shutdown(): Promise<void> {\n return this.app.shutdown();\n }\n}\n\n/**\n * Convenience wrapper kept so the binary and tests need no CliApp knowledge.\n *\n * Telemetry is shut down here rather than inside runHarness, because this is\n * the only scope that owns the process: flushing earlier would drop the records\n * a later command still emits.\n */\nexport async function runCli(args: string[]): Promise<number> {\n const app = createCliApplication();\n try {\n return await app.run(args);\n } finally {\n await app.shutdown();\n }\n}\n\n/** Runs an already-resolved option set, skipping argument parsing. */\nexport async function runHarness(options: HarnessOptions): Promise<number> {\n const app = createCliApplication();\n try {\n return await app.runHarness(options);\n } finally {\n await app.shutdown();\n }\n}\n"],"mappings":";;;AAOA,MAAM,qBAAqB;;;;;;;AAQ3B,eAAe,qBACb,SAGA;CACA,IAAI,QAAQ,SAAS,QAAQ,MAAA,QAAA,QAAA,CAAA,CAAA,WAAA,QAAM,+BAAA,CAAA,EAAA,CAA+B;C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AAE,CAAC,CAAC;CACzF;CAEA,eAAe,WAA0B;EACvC,IAAI,eAAe,MAAM,WAAW,SAAS;CAC/C;CACA,OAAO;EAAE;EAAK;EAAY;CAAS;AACrC;;AAEA,IAAa,SAAb,MAAoB;CAClB;CACA,YAAY,WAA8B;EACxC,KAAK,MAAM,qBAAqB,SAAS;CAC3C;CACA,cAAc,SAA+C;EAC3D,OAAO,oBAAoB,OAAO;CACpC;CACA,WAAW,SAA0C;EACnD,OAAO,KAAK,IAAI,WAAW,OAAO;CACpC;CACA,IAAI,MAAiC;EACnC,OAAO,KAAK,IAAI,IAAI,IAAI;CAC1B;CACA,WAA0B;EACxB,OAAO,KAAK,IAAI,SAAS;CAC3B;AACF;;;;;;;;AASA,eAAsB,OAAO,MAAiC;CAC5D,MAAM,MAAM,qBAAqB;CACjC,IAAI;EACF,OAAO,MAAM,IAAI,IAAI,IAAI;CAC3B,UAAU;EACR,MAAM,IAAI,SAAS;CACrB;AACF;;AAGA,eAAsB,WAAW,SAA0C;CACzE,MAAM,MAAM,qBAAqB;CACjC,IAAI;EACF,OAAO,MAAM,IAAI,WAAW,OAAO;CACrC,UAAU;EACR,MAAM,IAAI,SAAS;CACrB;AACF"}
1
+ {"version":3,"file":"cliApp.cjs","names":["cliText","parseHarnessArgs","HARNESS_VERSION"],"sources":["../../../src/cli/cliApp.ts"],"sourcesContent":["import type { HarnessTelemetry } from '@agimon-ai/po-core/runtimeLogSinkTelemetry';\n\nimport type { HarnessOptions } from '../composition/types/harness';\nimport type { BaseCommand } from './commands/baseCommand';\nimport { HARNESS_VERSION, printHelp } from './help';\nimport { cliText } from './locale';\nimport { parseHarnessArgs } from './options';\n\n/**\n * Main CLI Application\n *\n * Owns command registration and dispatch. Preparation is shared: the context\n * is built once and handed to whichever command claims the run.\n */\nasync function selectHarnessCommand(\n options: HarnessOptions,\n): Promise<\n (context: import('../builders/cli/harnessContext').HarnessContext, telemetry: HarnessTelemetry) => Promise<number>\n> {\n if (options.emitMcp) return (await import('./commands/emit-mcp')).runEmitMcp;\n if (options.explain) return (await import('./commands/explain')).runExplain;\n throw new Error(\n cliText(\n 'cli.error.noHarnessCommand',\n 'No harness command selected: pass --explain or --emit-mcp, or run po to start po-web.',\n ),\n );\n}\nasync function selectLegacyCommand(options: HarnessOptions): Promise<BaseCommand> {\n if (options.emitMcp) {\n const { EmitMcpCommand } = await import('./commands/emit-mcp');\n return new EmitMcpCommand();\n }\n if (options.explain) {\n const { ExplainCommand } = await import('./commands/explain');\n return new ExplainCommand();\n }\n throw new Error(\n cliText(\n 'cli.error.noHarnessCommand',\n 'No harness command selected: pass --explain or --emit-mcp, or run po to start po-web.',\n ),\n );\n}\n/**\n * The terminal app reads only what sync prepared. Packages the selected layers name that do not\n * resolve yet start a detached background sync from the repository, which registers it as a\n * workspace so sync covers its packages, and they arrive on the next launch.\n */\nexport async function requestUnsyncedPackages(\n repoRoot: string,\n context: Pick<\n import('../builders/cli/harnessContext').HarnessContext,\n 'presetsConfig' | 'selectedLayers' | 'environment'\n >,\n): Promise<void> {\n const [{ missingLayerPackageSpecifiers }, { createLayerResolvers }, { createBackgroundSync }] = await Promise.all([\n import('../composition/layerPackageInstaller'),\n import('../builders/cli/extensionAssembler'),\n import('../builders/server/backgroundSync'),\n ]);\n const missing = missingLayerPackageSpecifiers(\n context.presetsConfig,\n context.selectedLayers,\n createLayerResolvers(repoRoot, context.environment),\n );\n if (missing.length === 0) return;\n const notice = (message: string): void => {\n process.stderr.write(`${message}\\n`);\n };\n const started = await createBackgroundSync({\n environment: context.environment,\n onNotice: notice,\n detached: true,\n repoRoot,\n }).request('the terminal app found unsynced packages');\n notice(\n started\n ? cliText(\n 'cli.packages.backgroundSync',\n 'Po is syncing {packages} in the background; they arrive on the next launch.',\n { packages: missing.join(', ') },\n )\n : missing.length === 1\n ? cliText('cli.packages.unsyncedOne', '{packages} is not synced; run po sync to prepare them.', {\n packages: missing.join(', '),\n })\n : cliText('cli.packages.unsyncedMany', '{packages} are not synced; run po sync to prepare them.', {\n packages: missing.join(', '),\n }),\n );\n}\n/** Only the diagnostic commands consume a harness context; bare `po` runs po-web. */\nfunction wantsHarnessCommand(options: Pick<HarnessOptions, 'emitMcp' | 'explain'>): boolean {\n return Boolean(options.emitMcp) || options.explain;\n}\nfunction createCliApplication(initialTelemetry?: HarnessTelemetry) {\n let telemetry = initialTelemetry;\n let ownsTelemetry = false;\n async function getTelemetry(environment: NodeJS.ProcessEnv, cwd: string): Promise<HarnessTelemetry> {\n if (telemetry) return telemetry;\n const { createHarnessTelemetry } = await import('@agimon-ai/po-core/runtimeLogSinkTelemetry');\n // Telemetry's transport graph costs roughly one launcher budget slice by\n // itself. Startup callbacks and lifecycle events buffer until shutdown, so\n // transport initialization cannot compete with the Pi child for input.\n telemetry = createHarnessTelemetry({ env: environment, cwd, deferSpans: true });\n ownsTelemetry = true;\n return telemetry;\n }\n\n async function runHarness(options: HarnessOptions): Promise<number> {\n const telemetry = await getTelemetry(options.environment ?? process.env, options.cwd);\n const [{ buildHarnessContext }, { HARNESS_EVENT }] = await Promise.all([\n import('../builders/cli/harnessContext'),\n import('@agimon-ai/po-core/runtimeLogSinkTelemetry'),\n ]);\n return telemetry.runInSpan(\n 'po_pi.run',\n {\n 'harness.preset': options.preset,\n 'harness.domain_count': options.domains.length,\n 'harness.agents': options.agents,\n 'harness.mcp': options.mcp,\n ...(options.profile ? { 'harness.profile': options.profile } : {}),\n },\n async () => {\n const context = await buildHarnessContext(options, telemetry);\n try {\n await requestUnsyncedPackages(options.repoRoot, context);\n const command = await selectHarnessCommand(context.options);\n // Selection uses the same resolved options used to build the context.\n return await command(context, telemetry);\n } catch (error) {\n await telemetry.recordError(HARNESS_EVENT.cliFailed, error);\n throw error;\n } finally {\n await context.cleanup();\n }\n },\n );\n }\n\n async function run(args: string[]): Promise<number> {\n if (args[0] === 'compat')\n throw new Error(cliText('cli.error.retiredCompat', 'po compat has been retired. Use native Po sessions.'));\n if (args[0] === 'init') {\n const { runInit } = await import('./commands/init');\n return runInit(args);\n }\n if (args[0] === 'sync') {\n const { runSync } = await import('./commands/sync/workflow');\n return runSync(args);\n }\n if (args[0] === 'api-export') {\n const { runApiExport } = await import('./commands/api-export');\n return runApiExport(args);\n }\n if (args[0] === 'doctor') {\n const { runDoctor } = await import('./commands/doctor');\n return runDoctor(args);\n }\n\n // The first pass resolves --cwd without touching repository configuration,\n // which keeps help and version available even when presets.yaml is malformed.\n const initial = parseHarnessArgs(args);\n if (initial.help) {\n printHelp();\n return 0;\n }\n if (initial.version) {\n process.stdout.write(`${HARNESS_VERSION}\\n`);\n return 0;\n }\n // Bare `po` serves the web console. po-web owns its own arguments, so they\n // pass through untouched and never reach repository configuration here.\n if (!wantsHarnessCommand(initial.options)) {\n const { runPoWeb } = await import('./commands/web');\n return runPoWeb(args);\n }\n const telemetry = await getTelemetry(process.env, process.cwd());\n const [{ resolveHarnessOptions }, { toFailureReporter }] = await Promise.all([\n import('./harnessOptions'),\n import('@agimon-ai/po-core/runtimeLogSinkTelemetry'),\n ]);\n const options = await resolveHarnessOptions({ args, report: toFailureReporter(telemetry) });\n return runHarness(options);\n }\n\n async function shutdown(): Promise<void> {\n if (ownsTelemetry) await telemetry?.shutdown();\n }\n return { run, runHarness, shutdown };\n}\n/** Public compatibility API; execution is implemented by the application functions. */\nexport class CliApp {\n private readonly app: ReturnType<typeof createCliApplication>;\n constructor(telemetry?: HarnessTelemetry) {\n this.app = createCliApplication(telemetry);\n }\n selectCommand(options: HarnessOptions): Promise<BaseCommand> {\n return selectLegacyCommand(options);\n }\n runHarness(options: HarnessOptions): Promise<number> {\n return this.app.runHarness(options);\n }\n run(args: string[]): Promise<number> {\n return this.app.run(args);\n }\n shutdown(): Promise<void> {\n return this.app.shutdown();\n }\n}\n\n/**\n * Convenience wrapper kept so the binary and tests need no CliApp knowledge.\n *\n * Telemetry is shut down here rather than inside runHarness, because this is\n * the only scope that owns the process: flushing earlier would drop the records\n * a later command still emits.\n */\nexport async function runCli(args: string[]): Promise<number> {\n const app = createCliApplication();\n try {\n return await app.run(args);\n } finally {\n await app.shutdown();\n }\n}\n\n/** Runs an already-resolved option set, skipping argument parsing. */\nexport async function runHarness(options: HarnessOptions): Promise<number> {\n const app = createCliApplication();\n try {\n return await app.runHarness(options);\n } finally {\n await app.shutdown();\n }\n}\n"],"mappings":";;;;;;;;;;AAcA,eAAe,qBACb,SAGA;CACA,IAAI,QAAQ,SAAS,QAAQ,MAAA,QAAA,QAAA,CAAA,CAAA,WAAA,QAAM,+BAAA,CAAA,EAAA,CAA+B;CAClE,IAAI,QAAQ,SAAS,QAAQ,MAAA,QAAA,QAAA,CAAA,CAAA,WAAA,QAAM,8BAAA,CAAA,EAAA,CAA8B;CACjE,MAAM,IAAI,MACRA,eAAAA,QACE,8BACA,uFACF,CACF;AACF;AACA,eAAe,oBAAoB,SAA+C;CAChF,IAAI,QAAQ,SAAS;EACnB,MAAM,EAAE,mBAAmB,MAAA,QAAA,QAAA,CAAA,CAAA,WAAA,QAAM,+BAAA,CAAA;EACjC,OAAO,IAAI,eAAe;CAC5B;CACA,IAAI,QAAQ,SAAS;EACnB,MAAM,EAAE,mBAAmB,MAAA,QAAA,QAAA,CAAA,CAAA,WAAA,QAAM,8BAAA,CAAA;EACjC,OAAO,IAAI,eAAe;CAC5B;CACA,MAAM,IAAI,MACRA,eAAAA,QACE,8BACA,uFACF,CACF;AACF;;;;;;AAMA,eAAsB,wBACpB,UACA,SAIe;CACf,MAAM,CAAC,EAAE,iCAAiC,EAAE,wBAAwB,EAAE,0BAA0B,MAAM,QAAQ,IAAI;EAChH,QAAA,QAAA,CAAA,CAAA,WAAA,QAAA,gDAAA,CAAA;EACA,QAAA,QAAA,CAAA,CAAA,WAAA,QAAA,iDAAA,CAAA;EACA,QAAA,QAAA,CAAA,CAAA,WAAA,QAAA,uCAAA,CAAA;CACF,CAAC;CACD,MAAM,UAAU,8BACd,QAAQ,eACR,QAAQ,gBACR,qBAAqB,UAAU,QAAQ,WAAW,CACpD;CACA,IAAI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et start a detached background sync from the repository, which registers it as a
9
9
  * workspace so sync covers its packages, and they arrive on the next launch.
10
10
  */
11
- export declare function requestUnsyncedPackages(repoRoot: string, context: Pick<HarnessContext, 'majorModesConfig' | 'selectedLayers' | 'environment'>): Promise<void>;
11
+ export declare function requestUnsyncedPackages(repoRoot: string, context: Pick<HarnessContext, 'presetsConfig' | 'selectedLayers' | 'environment'>): Promise<void>;
12
12
  /** Public compatibility API; execution is implemented by the application functions. */
13
13
  export declare class CliApp {
14
14
  private readonly app;
@@ -1 +1 @@
1
- {"version":3,"file":"cliApp.d.mts","names":["_$___builders_cli_harnessContext0.HarnessContext"],"sources":["../../../src/cli/cliApp.ts"],"mappings":";;;;;;;;;;wBAwCsB,wBACpB,kBACA,SAAS,KAFWA,yEAMnB;;qBAoIU;mBACM;EACjB,YAAY,YAAY;EAGxB,cAAc,SAAS,iBAAiB,QAAQ;EAGhD,WAAW,SAAS,iBAAiB;EAGrC,IAAI,iBAAiB;EAGrB,YAAY;;;;;;;;;wBAYQ,OAAO,iBAAiB;;wBAUxB,WAAW,SAAS,iBAAiB"}
1
+ {"version":3,"file":"cliApp.d.mts","names":["_$___builders_cli_harnessContext0.HarnessContext"],"sources":["../../../src/cli/cliApp.ts"],"mappings":";;;;;;;;;;wBAiDsB,wBACpB,kBACA,SAAS,KAFWA,sEAMnB;;qBA2IU;mBACM;EACjB,YAAY,YAAY;EAGxB,cAAc,SAAS,iBAAiB,QAAQ;EAGhD,WAAW,SAAS,iBAAiB;EAGrC,IAAI,iBAAiB;EAGrB,YAAY;;;;;;;;;wBAYQ,OAAO,iBAAiB;;wBAUxB,WAAW,SAAS,iBAAiB"}
@@ -1,7 +1,7 @@
1
+ import { cliText } from "./locale.mjs";
1
2
  import { HARNESS_VERSION, printHelp } from "./help.mjs";
2
3
  import { parseHarnessArgs } from "./options.mjs";
3
4
  //#region src/cli/cliApp.ts
4
- const NO_HARNESS_COMMAND = "No harness command selected: pass --explain or --emit-mcp, or run po to start po-web.";
5
5
  /**
6
6
  * Main CLI Application
7
7
  *
@@ -11,7 +11,7 @@ const NO_HARNESS_COMMAND = "No harness command selected: pass --explain or --emi
11
11
  async function selectHarnessCommand(options) {
12
12
  if (options.emitMcp) return (await import("./commands/emit-mcp/index.mjs")).runEmitMcp;
13
13
  if (options.explain) return (await import("./commands/explain/index.mjs")).runExplain;
14
- throw new Error(NO_HARNESS_COMMAND);
14
+ throw new Error(cliText("cli.error.noHarnessCommand", "No harness command selected: pass --explain or --emit-mcp, or run po to start po-web."));
15
15
  }
16
16
  async function selectLegacyCommand(options) {
17
17
  if (options.emitMcp) {
@@ -22,7 +22,7 @@ async function selectLegacyCommand(options) {
22
22
  const { ExplainCommand } = await import("./commands/explain/index.mjs");
23
23
  return new ExplainCommand();
24
24
  }
25
- throw new Error(NO_HARNESS_COMMAND);
25
+ throw new Error(cliText("cli.error.noHarnessCommand", "No harness command selected: pass --explain or --emit-mcp, or run po to start po-web."));
26
26
  }
27
27
  /**
28
28
  * The terminal app reads only what sync prepared. Packages the selected layers name that do not
@@ -35,17 +35,17 @@ async function requestUnsyncedPackages(repoRoot, context) {
35
35
  import("../../builders/cli/extensionAssembler/index.mjs"),
36
36
  import("../builders/server/backgroundSync.mjs")
37
37
  ]);
38
- const missing = missingLayerPackageSpecifiers(context.majorModesConfig, context.selectedLayers, createLayerResolvers(repoRoot, context.environment));
38
+ const missing = missingLayerPackageSpecifiers(context.presetsConfig, context.selectedLayers, createLayerResolvers(repoRoot, context.environment));
39
39
  if (missing.length === 0) return;
40
40
  const notice = (message) => {
41
41
  process.stderr.write(`${message}\n`);
42
42
  };
43
- notice(createBackgroundSync({
43
+ notice(await createBackgroundSync({
44
44
  environment: context.environment,
45
45
  onNotice: notice,
46
46
  detached: true,
47
47
  repoRoot
48
- }).request("the terminal app found unsynced packages") ? `Po is syncing ${missing.join(", ")} in the background; they arrive on the next launch.` : `${missing.join(", ")} ${missing.length === 1 ? "is" : "are"} not synced; run po sync to prepare them.`);
48
+ }).request("the terminal app found unsynced packages") ? cliText("cli.packages.backgroundSync", "Po is syncing {packages} in the background; they arrive on the next launch.", { packages: missing.join(", ") }) : missing.length === 1 ? cliText("cli.packages.unsyncedOne", "{packages} is not synced; run po sync to prepare them.", { packages: missing.join(", ") }) : cliText("cli.packages.unsyncedMany", "{packages} are not synced; run po sync to prepare them.", { packages: missing.join(", ") }));
49
49
  }
50
50
  /** Only the diagnostic commands consume a harness context; bare `po` runs po-web. */
51
51
  function wantsHarnessCommand(options) {
@@ -54,24 +54,26 @@ function wantsHarnessCommand(options) {
54
54
  function createCliApplication(initialTelemetry) {
55
55
  let telemetry = initialTelemetry;
56
56
  let ownsTelemetry = false;
57
- async function getTelemetry() {
57
+ async function getTelemetry(environment, cwd) {
58
58
  if (telemetry) return telemetry;
59
59
  const { createHarnessTelemetry } = await import("@agimon-ai/po-core/runtimeLogSinkTelemetry");
60
- telemetry = createHarnessTelemetry({ deferSpans: true });
60
+ telemetry = createHarnessTelemetry({
61
+ env: environment,
62
+ cwd,
63
+ deferSpans: true
64
+ });
61
65
  ownsTelemetry = true;
62
66
  return telemetry;
63
67
  }
64
68
  async function runHarness(options) {
65
- const telemetry = await getTelemetry();
69
+ const telemetry = await getTelemetry(options.environment ?? process.env, options.cwd);
66
70
  const [{ buildHarnessContext }, { HARNESS_EVENT }] = await Promise.all([import("../builders/cli/harnessContext.mjs"), import("@agimon-ai/po-core/runtimeLogSinkTelemetry")]);
67
71
  return telemetry.runInSpan("po_pi.run", {
68
- "harness.major_mode": options.majorMode,
72
+ "harness.preset": options.preset,
69
73
  "harness.domain_count": options.domains.length,
70
74
  "harness.agents": options.agents,
71
75
  "harness.mcp": options.mcp,
72
- "harness.hooks": options.hooks,
73
- ...options.profile ? { "harness.profile": options.profile } : {},
74
- ...options.preset ? { "harness.preset": options.preset } : {}
76
+ ...options.profile ? { "harness.profile": options.profile } : {}
75
77
  }, async () => {
76
78
  const context = await buildHarnessContext(options, telemetry);
77
79
  try {
@@ -86,6 +88,7 @@ function createCliApplication(initialTelemetry) {
86
88
  });
87
89
  }
88
90
  async function run(args) {
91
+ if (args[0] === "compat") throw new Error(cliText("cli.error.retiredCompat", "po compat has been retired. Use native Po sessions."));
89
92
  if (args[0] === "init") {
90
93
  const { runInit } = await import("./commands/init/index.mjs");
91
94
  return runInit(args);
@@ -102,10 +105,6 @@ function createCliApplication(initialTelemetry) {
102
105
  const { runDoctor } = await import("./commands/doctor/index.mjs");
103
106
  return runDoctor(args);
104
107
  }
105
- if (args[0] === "compat") {
106
- const [{ runCompatibility }, telemetry] = await Promise.all([import("./commands/compat/index.mjs"), getTelemetry()]);
107
- return runCompatibility(args, void 0, void 0, telemetry);
108
- }
109
108
  const initial = parseHarnessArgs(args);
110
109
  if (initial.help) {
111
110
  printHelp();
@@ -119,9 +118,9 @@ function createCliApplication(initialTelemetry) {
119
118
  const { runPoWeb } = await import("./commands/web/index.mjs");
120
119
  return runPoWeb(args);
121
120
  }
122
- const telemetry = await getTelemetry();
121
+ const telemetry = await getTelemetry(process.env, process.cwd());
123
122
  const [{ resolveHarnessOptions }, { toFailureReporter }] = await Promise.all([import("./harnessOptions.mjs"), import("@agimon-ai/po-core/runtimeLogSinkTelemetry")]);
124
- return runHarness(resolveHarnessOptions({
123
+ return runHarness(await resolveHarnessOptions({
125
124
  args,
126
125
  report: toFailureReporter(telemetry)
127
126
  }));