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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (631) hide show
  1. package/LICENSE +97 -8
  2. package/README.md +37 -722
  3. package/dist/apiContracts.cjs.map +1 -1
  4. package/dist/apiContracts.d.mts +2 -2
  5. package/dist/bin/cli.cjs +12 -7
  6. package/dist/bin/cli.cjs.map +1 -1
  7. package/dist/bin/cli.mjs +12 -7
  8. package/dist/bin/cli.mjs.map +1 -1
  9. package/dist/bin/poRunner.cjs +24 -7
  10. package/dist/bin/poRunner.cjs.map +1 -1
  11. package/dist/bin/poRunner.d.mts +8 -0
  12. package/dist/bin/poRunner.d.mts.map +1 -1
  13. package/dist/bin/poRunner.mjs +24 -7
  14. package/dist/bin/poRunner.mjs.map +1 -1
  15. package/dist/bin/serve.cjs +28 -17
  16. package/dist/bin/serve.cjs.map +1 -1
  17. package/dist/bin/serve.mjs +28 -17
  18. package/dist/bin/serve.mjs.map +1 -1
  19. package/dist/builders/cli/extensionAssembler/index.cjs +53 -40
  20. package/dist/builders/cli/extensionAssembler/index.cjs.map +1 -1
  21. package/dist/builders/cli/extensionAssembler/index.d.mts +11 -6
  22. package/dist/builders/cli/extensionAssembler/index.d.mts.map +1 -1
  23. package/dist/builders/cli/extensionAssembler/index.mjs +53 -41
  24. package/dist/builders/cli/extensionAssembler/index.mjs.map +1 -1
  25. package/dist/catalog/index.json +662 -105
  26. package/dist/cli.cjs +9 -14
  27. package/dist/cli.d.mts +1 -3
  28. package/dist/cli.mjs +1 -3
  29. package/dist/commands.cjs +13 -15
  30. package/dist/commands.d.mts +1 -2
  31. package/dist/commands.mjs +1 -2
  32. package/dist/config.cjs +9 -14
  33. package/dist/config.d.mts +3 -2
  34. package/dist/config.mjs +3 -2
  35. package/dist/extensions/server.cjs +30 -23
  36. package/dist/extensions/server.cjs.map +1 -1
  37. package/dist/extensions/server.d.mts.map +1 -1
  38. package/dist/extensions/server.mjs +31 -24
  39. package/dist/extensions/server.mjs.map +1 -1
  40. package/dist/harnessContext.cjs +0 -1
  41. package/dist/harnessContext.d.mts +2 -2
  42. package/dist/harnessContext.mjs +1 -1
  43. package/dist/harnessState.cjs +2 -1
  44. package/dist/help.cjs +9 -11
  45. package/dist/help.d.mts +1 -2
  46. package/dist/help.mjs +1 -2
  47. package/dist/index.cjs +40 -67
  48. package/dist/index.d.mts +7 -16
  49. package/dist/index.mjs +7 -14
  50. package/dist/locales/vi.cjs +218 -0
  51. package/dist/locales/vi.cjs.map +1 -0
  52. package/dist/locales/vi.mjs +213 -0
  53. package/dist/locales/vi.mjs.map +1 -0
  54. package/dist/locales/zh-CN.cjs +218 -0
  55. package/dist/locales/zh-CN.cjs.map +1 -0
  56. package/dist/locales/zh-CN.mjs +213 -0
  57. package/dist/locales/zh-CN.mjs.map +1 -0
  58. package/dist/matrixOptions.cjs +10 -5
  59. package/dist/matrixOptions.d.mts +2 -2
  60. package/dist/matrixOptions.mjs +1 -1
  61. package/dist/package.cjs +11 -0
  62. package/dist/package.cjs.map +1 -0
  63. package/dist/package.mjs +6 -0
  64. package/dist/package.mjs.map +1 -0
  65. package/dist/projectTrust.cjs +3 -0
  66. package/dist/projectTrust.d.mts +2 -2
  67. package/dist/projectTrust.mjs +1 -1
  68. package/dist/repository.cjs +1 -0
  69. package/dist/repository.d.mts +2 -2
  70. package/dist/repository.mjs +1 -1
  71. package/dist/services.cjs +5 -20
  72. package/dist/services.d.mts +3 -8
  73. package/dist/services.mjs +3 -8
  74. package/dist/shared.cjs +4 -17
  75. package/dist/shared.d.mts +2 -2
  76. package/dist/shared.mjs +1 -1
  77. package/dist/src/bin/agentDirectory.cjs +19 -15
  78. package/dist/src/bin/agentDirectory.cjs.map +1 -1
  79. package/dist/src/bin/agentDirectory.mjs +16 -13
  80. package/dist/src/bin/agentDirectory.mjs.map +1 -1
  81. package/dist/src/builders/apiContractExport/index.cjs +23 -22
  82. package/dist/src/builders/apiContractExport/index.cjs.map +1 -1
  83. package/dist/src/builders/apiContractExport/index.mjs +22 -21
  84. package/dist/src/builders/apiContractExport/index.mjs.map +1 -1
  85. package/dist/src/builders/cli/entryResolution.cjs +2 -2
  86. package/dist/src/builders/cli/entryResolution.cjs.map +1 -1
  87. package/dist/src/builders/cli/entryResolution.mjs +1 -1
  88. package/dist/src/builders/cli/entryResolution.mjs.map +1 -1
  89. package/dist/src/builders/cli/harnessContext.cjs +38 -43
  90. package/dist/src/builders/cli/harnessContext.cjs.map +1 -1
  91. package/dist/src/builders/cli/harnessContext.d.mts +11 -10
  92. package/dist/src/builders/cli/harnessContext.d.mts.map +1 -1
  93. package/dist/src/builders/cli/harnessContext.mjs +37 -41
  94. package/dist/src/builders/cli/harnessContext.mjs.map +1 -1
  95. package/dist/src/builders/cli/sessionComposition.cjs +23 -12
  96. package/dist/src/builders/cli/sessionComposition.cjs.map +1 -1
  97. package/dist/src/builders/cli/sessionComposition.mjs +23 -12
  98. package/dist/src/builders/cli/sessionComposition.mjs.map +1 -1
  99. package/dist/src/builders/isolate/compile.cjs +226 -0
  100. package/dist/src/builders/isolate/compile.cjs.map +1 -0
  101. package/dist/src/builders/isolate/compile.mjs +222 -0
  102. package/dist/src/builders/isolate/compile.mjs.map +1 -0
  103. package/dist/src/builders/isolate/index.cjs +195 -0
  104. package/dist/src/builders/isolate/index.cjs.map +1 -0
  105. package/dist/src/builders/isolate/index.mjs +192 -0
  106. package/dist/src/builders/isolate/index.mjs.map +1 -0
  107. package/dist/src/builders/isolate/membrane.cjs +198 -0
  108. package/dist/src/builders/isolate/membrane.cjs.map +1 -0
  109. package/dist/src/builders/isolate/membrane.mjs +198 -0
  110. package/dist/src/builders/isolate/membrane.mjs.map +1 -0
  111. package/dist/src/builders/isolate/names.cjs +10 -0
  112. package/dist/src/builders/isolate/names.cjs.map +1 -0
  113. package/dist/src/builders/isolate/names.mjs +9 -0
  114. package/dist/src/builders/isolate/names.mjs.map +1 -0
  115. package/dist/src/builders/native/index.cjs +229 -67
  116. package/dist/src/builders/native/index.cjs.map +1 -1
  117. package/dist/src/builders/native/index.d.mts +4 -2
  118. package/dist/src/builders/native/index.d.mts.map +1 -1
  119. package/dist/src/builders/native/index.mjs +229 -68
  120. package/dist/src/builders/native/index.mjs.map +1 -1
  121. package/dist/src/builders/npm/index.cjs +76 -0
  122. package/dist/src/builders/npm/index.cjs.map +1 -0
  123. package/dist/src/builders/npm/index.mjs +73 -0
  124. package/dist/src/builders/npm/index.mjs.map +1 -0
  125. package/dist/src/builders/server/backgroundSync.cjs +62 -39
  126. package/dist/src/builders/server/backgroundSync.cjs.map +1 -1
  127. package/dist/src/builders/server/backgroundSync.mjs +62 -38
  128. package/dist/src/builders/server/backgroundSync.mjs.map +1 -1
  129. package/dist/src/builders/server/bundlerService.cjs +165 -35
  130. package/dist/src/builders/server/bundlerService.cjs.map +1 -1
  131. package/dist/src/builders/server/bundlerService.mjs +164 -36
  132. package/dist/src/builders/server/bundlerService.mjs.map +1 -1
  133. package/dist/src/builders/server/capabilities.cjs +103 -0
  134. package/dist/src/builders/server/capabilities.cjs.map +1 -0
  135. package/dist/src/builders/server/capabilities.mjs +101 -0
  136. package/dist/src/builders/server/capabilities.mjs.map +1 -0
  137. package/dist/src/builders/server/computerUseBinding.cjs +62 -10
  138. package/dist/src/builders/server/computerUseBinding.cjs.map +1 -1
  139. package/dist/src/builders/server/computerUseBinding.mjs +60 -8
  140. package/dist/src/builders/server/computerUseBinding.mjs.map +1 -1
  141. package/dist/src/builders/server/computerUseRecordings.cjs +152 -51
  142. package/dist/src/builders/server/computerUseRecordings.cjs.map +1 -1
  143. package/dist/src/builders/server/computerUseRecordings.mjs +158 -59
  144. package/dist/src/builders/server/computerUseRecordings.mjs.map +1 -1
  145. package/dist/src/builders/server/containedSessions.cjs +152 -0
  146. package/dist/src/builders/server/containedSessions.cjs.map +1 -0
  147. package/dist/src/builders/server/containedSessions.mjs +146 -0
  148. package/dist/src/builders/server/containedSessions.mjs.map +1 -0
  149. package/dist/src/builders/server/defaultWorkspace.cjs +46 -11
  150. package/dist/src/builders/server/defaultWorkspace.cjs.map +1 -1
  151. package/dist/src/builders/server/defaultWorkspace.mjs +42 -10
  152. package/dist/src/builders/server/defaultWorkspace.mjs.map +1 -1
  153. package/dist/src/builders/server/electronBinding.cjs +82 -0
  154. package/dist/src/builders/server/electronBinding.cjs.map +1 -0
  155. package/dist/src/builders/server/electronBinding.mjs +82 -0
  156. package/dist/src/builders/server/electronBinding.mjs.map +1 -0
  157. package/dist/src/builders/server/federation.cjs +364 -0
  158. package/dist/src/builders/server/federation.cjs.map +1 -0
  159. package/dist/src/builders/server/federation.mjs +363 -0
  160. package/dist/src/builders/server/federation.mjs.map +1 -0
  161. package/dist/src/builders/server/hostDisplayName.cjs +14 -0
  162. package/dist/src/builders/server/hostDisplayName.cjs.map +1 -0
  163. package/dist/src/builders/server/hostDisplayName.mjs +14 -0
  164. package/dist/src/builders/server/hostDisplayName.mjs.map +1 -0
  165. package/dist/src/builders/server/hostModelGateway.cjs +41 -0
  166. package/dist/src/builders/server/hostModelGateway.cjs.map +1 -0
  167. package/dist/src/builders/server/hostModelGateway.mjs +39 -0
  168. package/dist/src/builders/server/hostModelGateway.mjs.map +1 -0
  169. package/dist/src/builders/server/hostTeam.cjs +188 -0
  170. package/dist/src/builders/server/hostTeam.cjs.map +1 -0
  171. package/dist/src/builders/server/hostTeam.mjs +180 -0
  172. package/dist/src/builders/server/hostTeam.mjs.map +1 -0
  173. package/dist/src/builders/server/idleRestart.cjs +185 -40
  174. package/dist/src/builders/server/idleRestart.cjs.map +1 -1
  175. package/dist/src/builders/server/idleRestart.mjs +176 -39
  176. package/dist/src/builders/server/idleRestart.mjs.map +1 -1
  177. package/dist/src/builders/server/index.cjs +58 -19
  178. package/dist/src/builders/server/index.cjs.map +1 -1
  179. package/dist/src/builders/server/index.mjs +57 -19
  180. package/dist/src/builders/server/index.mjs.map +1 -1
  181. package/dist/src/builders/server/liveActivityPush.cjs +202 -0
  182. package/dist/src/builders/server/liveActivityPush.cjs.map +1 -0
  183. package/dist/src/builders/server/liveActivityPush.mjs +202 -0
  184. package/dist/src/builders/server/liveActivityPush.mjs.map +1 -0
  185. package/dist/src/builders/server/logSink.cjs +12 -10
  186. package/dist/src/builders/server/logSink.cjs.map +1 -1
  187. package/dist/src/builders/server/logSink.mjs +12 -10
  188. package/dist/src/builders/server/logSink.mjs.map +1 -1
  189. package/dist/src/builders/server/mcpApp.cjs +27 -20
  190. package/dist/src/builders/server/mcpApp.cjs.map +1 -1
  191. package/dist/src/builders/server/mcpApp.mjs +25 -18
  192. package/dist/src/builders/server/mcpApp.mjs.map +1 -1
  193. package/dist/src/builders/server/mcpAppBuild.cjs +61 -41
  194. package/dist/src/builders/server/mcpAppBuild.cjs.map +1 -1
  195. package/dist/src/builders/server/mcpAppBuild.d.mts +3 -6
  196. package/dist/src/builders/server/mcpAppBuild.d.mts.map +1 -1
  197. package/dist/src/builders/server/mcpAppBuild.mjs +61 -40
  198. package/dist/src/builders/server/mcpAppBuild.mjs.map +1 -1
  199. package/dist/src/builders/server/mcpBundle.cjs +20 -16
  200. package/dist/src/builders/server/mcpBundle.cjs.map +1 -1
  201. package/dist/src/builders/server/mcpBundle.d.mts +2 -1
  202. package/dist/src/builders/server/mcpBundle.d.mts.map +1 -1
  203. package/dist/src/builders/server/mcpBundle.mjs +20 -15
  204. package/dist/src/builders/server/mcpBundle.mjs.map +1 -1
  205. package/dist/src/builders/server/nativePush.cjs +229 -0
  206. package/dist/src/builders/server/nativePush.cjs.map +1 -0
  207. package/dist/src/builders/server/nativePush.mjs +228 -0
  208. package/dist/src/builders/server/nativePush.mjs.map +1 -0
  209. package/dist/src/builders/server/network.cjs +887 -0
  210. package/dist/src/builders/server/network.cjs.map +1 -0
  211. package/dist/src/builders/server/network.mjs +886 -0
  212. package/dist/src/builders/server/network.mjs.map +1 -0
  213. package/dist/src/builders/server/networkGateway.cjs +123 -0
  214. package/dist/src/builders/server/networkGateway.cjs.map +1 -0
  215. package/dist/src/builders/server/networkGateway.mjs +123 -0
  216. package/dist/src/builders/server/networkGateway.mjs.map +1 -0
  217. package/dist/src/builders/server/networkRelay.cjs +83 -0
  218. package/dist/src/builders/server/networkRelay.cjs.map +1 -0
  219. package/dist/src/builders/server/networkRelay.mjs +81 -0
  220. package/dist/src/builders/server/networkRelay.mjs.map +1 -0
  221. package/dist/src/builders/server/orgPluginLibraryBinding.cjs +72 -0
  222. package/dist/src/builders/server/orgPluginLibraryBinding.cjs.map +1 -0
  223. package/dist/src/builders/server/orgPluginLibraryBinding.mjs +72 -0
  224. package/dist/src/builders/server/orgPluginLibraryBinding.mjs.map +1 -0
  225. package/dist/src/builders/server/packageReloadCheck.cjs +46 -2
  226. package/dist/src/builders/server/packageReloadCheck.cjs.map +1 -1
  227. package/dist/src/builders/server/packageReloadCheck.mjs +46 -3
  228. package/dist/src/builders/server/packageReloadCheck.mjs.map +1 -1
  229. package/dist/src/builders/server/packageUrl.cjs +161 -58
  230. package/dist/src/builders/server/packageUrl.cjs.map +1 -1
  231. package/dist/src/builders/server/packageUrl.mjs +162 -58
  232. package/dist/src/builders/server/packageUrl.mjs.map +1 -1
  233. package/dist/src/builders/server/privateRelay.cjs +309 -0
  234. package/dist/src/builders/server/privateRelay.cjs.map +1 -0
  235. package/dist/src/builders/server/privateRelay.mjs +305 -0
  236. package/dist/src/builders/server/privateRelay.mjs.map +1 -0
  237. package/dist/src/builders/server/privateRelayCarrier.cjs +316 -0
  238. package/dist/src/builders/server/privateRelayCarrier.cjs.map +1 -0
  239. package/dist/src/builders/server/privateRelayCarrier.mjs +309 -0
  240. package/dist/src/builders/server/privateRelayCarrier.mjs.map +1 -0
  241. package/dist/src/builders/server/runtime.cjs +2750 -486
  242. package/dist/src/builders/server/runtime.cjs.map +1 -1
  243. package/dist/src/builders/server/runtime.mjs +2760 -500
  244. package/dist/src/builders/server/runtime.mjs.map +1 -1
  245. package/dist/src/builders/server/runtimeResources.cjs +37 -0
  246. package/dist/src/builders/server/runtimeResources.cjs.map +1 -1
  247. package/dist/src/builders/server/runtimeResources.mjs +38 -2
  248. package/dist/src/builders/server/runtimeResources.mjs.map +1 -1
  249. package/dist/src/builders/server/sandboxRouter.cjs +815 -0
  250. package/dist/src/builders/server/sandboxRouter.cjs.map +1 -0
  251. package/dist/src/builders/server/sandboxRouter.mjs +811 -0
  252. package/dist/src/builders/server/sandboxRouter.mjs.map +1 -0
  253. package/dist/src/builders/server/sandboxSessionHandoff.cjs +298 -0
  254. package/dist/src/builders/server/sandboxSessionHandoff.cjs.map +1 -0
  255. package/dist/src/builders/server/sandboxSessionHandoff.mjs +287 -0
  256. package/dist/src/builders/server/sandboxSessionHandoff.mjs.map +1 -0
  257. package/dist/src/builders/server/scopeReloadController.cjs +80 -0
  258. package/dist/src/builders/server/scopeReloadController.cjs.map +1 -0
  259. package/dist/src/builders/server/scopeReloadController.mjs +80 -0
  260. package/dist/src/builders/server/scopeReloadController.mjs.map +1 -0
  261. package/dist/src/builders/server/selectionStatus.cjs +2 -2
  262. package/dist/src/builders/server/selectionStatus.cjs.map +1 -1
  263. package/dist/src/builders/server/selectionStatus.mjs +2 -2
  264. package/dist/src/builders/server/selectionStatus.mjs.map +1 -1
  265. package/dist/src/builders/server/sessionArguments.cjs +65 -7
  266. package/dist/src/builders/server/sessionArguments.cjs.map +1 -1
  267. package/dist/src/builders/server/sessionArguments.mjs +64 -8
  268. package/dist/src/builders/server/sessionArguments.mjs.map +1 -1
  269. package/dist/src/builders/server/sessionRemoval.cjs +233 -0
  270. package/dist/src/builders/server/sessionRemoval.cjs.map +1 -0
  271. package/dist/src/builders/server/sessionRemoval.mjs +224 -0
  272. package/dist/src/builders/server/sessionRemoval.mjs.map +1 -0
  273. package/dist/src/builders/server/sessionSummaries.cjs +32 -0
  274. package/dist/src/builders/server/sessionSummaries.cjs.map +1 -0
  275. package/dist/src/builders/server/sessionSummaries.mjs +31 -0
  276. package/dist/src/builders/server/sessionSummaries.mjs.map +1 -0
  277. package/dist/src/builders/server/shutdown.cjs +23 -0
  278. package/dist/src/builders/server/shutdown.cjs.map +1 -1
  279. package/dist/src/builders/server/shutdown.mjs +21 -1
  280. package/dist/src/builders/server/shutdown.mjs.map +1 -1
  281. package/dist/src/builders/server/shutdownStack.cjs +44 -0
  282. package/dist/src/builders/server/shutdownStack.cjs.map +1 -0
  283. package/dist/src/builders/server/shutdownStack.mjs +43 -0
  284. package/dist/src/builders/server/shutdownStack.mjs.map +1 -0
  285. package/dist/src/builders/server/toolBoundaryHold.cjs +55 -0
  286. package/dist/src/builders/server/toolBoundaryHold.cjs.map +1 -0
  287. package/dist/src/builders/server/toolBoundaryHold.mjs +55 -0
  288. package/dist/src/builders/server/toolBoundaryHold.mjs.map +1 -0
  289. package/dist/src/builders/server/watcherService.cjs +55 -28
  290. package/dist/src/builders/server/watcherService.cjs.map +1 -1
  291. package/dist/src/builders/server/watcherService.mjs +55 -27
  292. package/dist/src/builders/server/watcherService.mjs.map +1 -1
  293. package/dist/src/builders/server/webTemplateDecision.cjs +7 -3
  294. package/dist/src/builders/server/webTemplateDecision.cjs.map +1 -1
  295. package/dist/src/builders/server/webTemplateDecision.mjs +7 -3
  296. package/dist/src/builders/server/webTemplateDecision.mjs.map +1 -1
  297. package/dist/src/builders/server/workspaceAdmission.cjs +96 -0
  298. package/dist/src/builders/server/workspaceAdmission.cjs.map +1 -0
  299. package/dist/src/builders/server/workspaceAdmission.mjs +90 -0
  300. package/dist/src/builders/server/workspaceAdmission.mjs.map +1 -0
  301. package/dist/src/builders/server/workspaceCheckout.cjs +16 -7
  302. package/dist/src/builders/server/workspaceCheckout.cjs.map +1 -1
  303. package/dist/src/builders/server/workspaceCheckout.mjs +16 -7
  304. package/dist/src/builders/server/workspaceCheckout.mjs.map +1 -1
  305. package/dist/src/builders/web/bundle.cjs +16 -14
  306. package/dist/src/builders/web/bundle.cjs.map +1 -1
  307. package/dist/src/builders/web/bundle.d.mts +3 -0
  308. package/dist/src/builders/web/bundle.d.mts.map +1 -1
  309. package/dist/src/builders/web/bundle.mjs +15 -13
  310. package/dist/src/builders/web/bundle.mjs.map +1 -1
  311. package/dist/src/builders/web/index.cjs +92 -59
  312. package/dist/src/builders/web/index.cjs.map +1 -1
  313. package/dist/src/builders/web/index.d.mts +21 -14
  314. package/dist/src/builders/web/index.d.mts.map +1 -1
  315. package/dist/src/builders/web/index.mjs +91 -59
  316. package/dist/src/builders/web/index.mjs.map +1 -1
  317. package/dist/src/builders/web/webPluginGenerate.cjs +84 -45
  318. package/dist/src/builders/web/webPluginGenerate.cjs.map +1 -1
  319. package/dist/src/builders/web/webPluginGenerate.d.mts +13 -4
  320. package/dist/src/builders/web/webPluginGenerate.d.mts.map +1 -1
  321. package/dist/src/builders/web/webPluginGenerate.mjs +82 -44
  322. package/dist/src/builders/web/webPluginGenerate.mjs.map +1 -1
  323. package/dist/src/builders/web/webPluginManifest.cjs +24 -17
  324. package/dist/src/builders/web/webPluginManifest.cjs.map +1 -1
  325. package/dist/src/builders/web/webPluginManifest.d.mts +11 -23
  326. package/dist/src/builders/web/webPluginManifest.d.mts.map +1 -1
  327. package/dist/src/builders/web/webPluginManifest.mjs +23 -16
  328. package/dist/src/builders/web/webPluginManifest.mjs.map +1 -1
  329. package/dist/src/builders/web/webPluginScan.cjs +11 -8
  330. package/dist/src/builders/web/webPluginScan.cjs.map +1 -1
  331. package/dist/src/builders/web/webPluginScan.d.mts +1 -1
  332. package/dist/src/builders/web/webPluginScan.d.mts.map +1 -1
  333. package/dist/src/builders/web/webPluginScan.mjs +10 -7
  334. package/dist/src/builders/web/webPluginScan.mjs.map +1 -1
  335. package/dist/src/builders/web/webPluginVite.cjs +5 -5
  336. package/dist/src/builders/web/webPluginVite.cjs.map +1 -1
  337. package/dist/src/builders/web/webPluginVite.d.mts +1 -1
  338. package/dist/src/builders/web/webPluginVite.d.mts.map +1 -1
  339. package/dist/src/builders/web/webPluginVite.mjs +3 -3
  340. package/dist/src/builders/web/webPluginVite.mjs.map +1 -1
  341. package/dist/src/cli/cliApp.cjs +18 -19
  342. package/dist/src/cli/cliApp.cjs.map +1 -1
  343. package/dist/src/cli/cliApp.d.mts +1 -1
  344. package/dist/src/cli/cliApp.d.mts.map +1 -1
  345. package/dist/src/cli/cliApp.mjs +18 -19
  346. package/dist/src/cli/cliApp.mjs.map +1 -1
  347. package/dist/src/cli/commands/api-export/index.cjs +14 -13
  348. package/dist/src/cli/commands/api-export/index.cjs.map +1 -1
  349. package/dist/src/cli/commands/api-export/index.mjs +13 -12
  350. package/dist/src/cli/commands/api-export/index.mjs.map +1 -1
  351. package/dist/src/cli/commands/doctor/help.cjs +4 -3
  352. package/dist/src/cli/commands/doctor/help.cjs.map +1 -1
  353. package/dist/src/cli/commands/doctor/help.d.mts.map +1 -1
  354. package/dist/src/cli/commands/doctor/help.mjs +4 -3
  355. package/dist/src/cli/commands/doctor/help.mjs.map +1 -1
  356. package/dist/src/cli/commands/doctor/index.cjs +30 -17
  357. package/dist/src/cli/commands/doctor/index.cjs.map +1 -1
  358. package/dist/src/cli/commands/doctor/index.d.mts +4 -4
  359. package/dist/src/cli/commands/doctor/index.d.mts.map +1 -1
  360. package/dist/src/cli/commands/doctor/index.mjs +28 -15
  361. package/dist/src/cli/commands/doctor/index.mjs.map +1 -1
  362. package/dist/src/cli/commands/emit-mcp/index.cjs +3 -2
  363. package/dist/src/cli/commands/emit-mcp/index.cjs.map +1 -1
  364. package/dist/src/cli/commands/emit-mcp/index.d.mts.map +1 -1
  365. package/dist/src/cli/commands/emit-mcp/index.mjs +3 -2
  366. package/dist/src/cli/commands/emit-mcp/index.mjs.map +1 -1
  367. package/dist/src/cli/commands/explain/index.cjs +53 -38
  368. package/dist/src/cli/commands/explain/index.cjs.map +1 -1
  369. package/dist/src/cli/commands/explain/index.d.mts +3 -4
  370. package/dist/src/cli/commands/explain/index.d.mts.map +1 -1
  371. package/dist/src/cli/commands/explain/index.mjs +52 -37
  372. package/dist/src/cli/commands/explain/index.mjs.map +1 -1
  373. package/dist/src/cli/commands/init/help.cjs +3 -2
  374. package/dist/src/cli/commands/init/help.cjs.map +1 -1
  375. package/dist/src/cli/commands/init/help.d.mts.map +1 -1
  376. package/dist/src/cli/commands/init/help.mjs +3 -2
  377. package/dist/src/cli/commands/init/help.mjs.map +1 -1
  378. package/dist/src/cli/commands/init/index.cjs +17 -12
  379. package/dist/src/cli/commands/init/index.cjs.map +1 -1
  380. package/dist/src/cli/commands/init/index.d.mts.map +1 -1
  381. package/dist/src/cli/commands/init/index.mjs +16 -11
  382. package/dist/src/cli/commands/init/index.mjs.map +1 -1
  383. package/dist/src/cli/commands/init/presenter.cjs +29 -21
  384. package/dist/src/cli/commands/init/presenter.cjs.map +1 -1
  385. package/dist/src/cli/commands/init/presenter.mjs +29 -21
  386. package/dist/src/cli/commands/init/presenter.mjs.map +1 -1
  387. package/dist/src/cli/commands/sync/help.cjs +7 -3
  388. package/dist/src/cli/commands/sync/help.cjs.map +1 -1
  389. package/dist/src/cli/commands/sync/help.d.mts.map +1 -1
  390. package/dist/src/cli/commands/sync/help.mjs +7 -3
  391. package/dist/src/cli/commands/sync/help.mjs.map +1 -1
  392. package/dist/src/cli/commands/sync/index.cjs +72 -40
  393. package/dist/src/cli/commands/sync/index.cjs.map +1 -1
  394. package/dist/src/cli/commands/sync/index.d.mts.map +1 -1
  395. package/dist/src/cli/commands/sync/index.mjs +69 -37
  396. package/dist/src/cli/commands/sync/index.mjs.map +1 -1
  397. package/dist/src/cli/commands/sync/presenter.cjs +10 -1
  398. package/dist/src/cli/commands/sync/presenter.cjs.map +1 -1
  399. package/dist/src/cli/commands/sync/presenter.d.mts +0 -9
  400. package/dist/src/cli/commands/sync/presenter.d.mts.map +1 -1
  401. package/dist/src/cli/commands/sync/presenter.mjs +10 -1
  402. package/dist/src/cli/commands/sync/presenter.mjs.map +1 -1
  403. package/dist/src/cli/commands/web/index.cjs +7 -6
  404. package/dist/src/cli/commands/web/index.cjs.map +1 -1
  405. package/dist/src/cli/commands/web/index.mjs +6 -5
  406. package/dist/src/cli/commands/web/index.mjs.map +1 -1
  407. package/dist/src/cli/harnessOptions.cjs +15 -24
  408. package/dist/src/cli/harnessOptions.cjs.map +1 -1
  409. package/dist/src/cli/harnessOptions.d.mts +2 -2
  410. package/dist/src/cli/harnessOptions.d.mts.map +1 -1
  411. package/dist/src/cli/harnessOptions.mjs +14 -22
  412. package/dist/src/cli/harnessOptions.mjs.map +1 -1
  413. package/dist/src/cli/help.cjs +20 -26
  414. package/dist/src/cli/help.cjs.map +1 -1
  415. package/dist/src/cli/help.d.mts +1 -2
  416. package/dist/src/cli/help.d.mts.map +1 -1
  417. package/dist/src/cli/help.mjs +15 -20
  418. package/dist/src/cli/help.mjs.map +1 -1
  419. package/dist/src/cli/locale.cjs +30 -0
  420. package/dist/src/cli/locale.cjs.map +1 -0
  421. package/dist/src/cli/locale.mjs +27 -0
  422. package/dist/src/cli/locale.mjs.map +1 -0
  423. package/dist/src/cli/matrixOptions.cjs +85 -37
  424. package/dist/src/cli/matrixOptions.cjs.map +1 -1
  425. package/dist/src/cli/matrixOptions.d.mts +22 -16
  426. package/dist/src/cli/matrixOptions.d.mts.map +1 -1
  427. package/dist/src/cli/matrixOptions.mjs +76 -33
  428. package/dist/src/cli/matrixOptions.mjs.map +1 -1
  429. package/dist/src/cli/options.cjs +51 -128
  430. package/dist/src/cli/options.cjs.map +1 -1
  431. package/dist/src/cli/options.d.mts +1 -1
  432. package/dist/src/cli/options.d.mts.map +1 -1
  433. package/dist/src/cli/options.mjs +53 -130
  434. package/dist/src/cli/options.mjs.map +1 -1
  435. package/dist/src/cli/router.cjs +0 -1
  436. package/dist/src/cli/router.cjs.map +1 -1
  437. package/dist/src/cli/router.d.mts +1 -1
  438. package/dist/src/cli/router.mjs +0 -1
  439. package/dist/src/cli/router.mjs.map +1 -1
  440. package/dist/src/cli/server/options.cjs +37 -7
  441. package/dist/src/cli/server/options.cjs.map +1 -1
  442. package/dist/src/cli/server/options.mjs +37 -7
  443. package/dist/src/cli/server/options.mjs.map +1 -1
  444. package/dist/src/cli/server/processGuards.cjs +22 -15
  445. package/dist/src/cli/server/processGuards.cjs.map +1 -1
  446. package/dist/src/cli/server/processGuards.mjs +21 -14
  447. package/dist/src/cli/server/processGuards.mjs.map +1 -1
  448. package/dist/src/cli/server/restartPolicy.cjs +38 -0
  449. package/dist/src/cli/server/restartPolicy.cjs.map +1 -0
  450. package/dist/src/cli/server/restartPolicy.d.mts +21 -0
  451. package/dist/src/cli/server/restartPolicy.d.mts.map +1 -0
  452. package/dist/src/cli/server/restartPolicy.mjs +36 -0
  453. package/dist/src/cli/server/restartPolicy.mjs.map +1 -0
  454. package/dist/src/cli/server/run.cjs +12 -11
  455. package/dist/src/cli/server/run.cjs.map +1 -1
  456. package/dist/src/cli/server/run.mjs +11 -10
  457. package/dist/src/cli/server/run.mjs.map +1 -1
  458. package/dist/src/cli/server/supervise.cjs +89 -0
  459. package/dist/src/cli/server/supervise.cjs.map +1 -0
  460. package/dist/src/cli/server/supervise.mjs +89 -0
  461. package/dist/src/cli/server/supervise.mjs.map +1 -0
  462. package/dist/src/composition/harnessState/index.cjs +2 -1
  463. package/dist/src/composition/harnessState/index.cjs.map +1 -1
  464. package/dist/src/composition/harnessState/index.d.mts +2 -1
  465. package/dist/src/composition/harnessState/index.d.mts.map +1 -1
  466. package/dist/src/composition/harnessState/index.mjs +2 -1
  467. package/dist/src/composition/harnessState/index.mjs.map +1 -1
  468. package/dist/src/composition/layerPackageInstaller/index.cjs +293 -86
  469. package/dist/src/composition/layerPackageInstaller/index.cjs.map +1 -1
  470. package/dist/src/composition/layerPackageInstaller/index.d.mts +25 -2
  471. package/dist/src/composition/layerPackageInstaller/index.d.mts.map +1 -1
  472. package/dist/src/composition/layerPackageInstaller/index.mjs +295 -94
  473. package/dist/src/composition/layerPackageInstaller/index.mjs.map +1 -1
  474. package/dist/src/composition/marketplaceCatalog/index.cjs +136 -0
  475. package/dist/src/composition/marketplaceCatalog/index.cjs.map +1 -0
  476. package/dist/src/composition/marketplaceCatalog/index.mjs +132 -0
  477. package/dist/src/composition/marketplaceCatalog/index.mjs.map +1 -0
  478. package/dist/src/composition/orgPluginActivation/index.cjs +179 -0
  479. package/dist/src/composition/orgPluginActivation/index.cjs.map +1 -0
  480. package/dist/src/composition/orgPluginActivation/index.mjs +177 -0
  481. package/dist/src/composition/orgPluginActivation/index.mjs.map +1 -0
  482. package/dist/src/composition/orgPluginLibrary/index.cjs +205 -0
  483. package/dist/src/composition/orgPluginLibrary/index.cjs.map +1 -0
  484. package/dist/src/composition/orgPluginLibrary/index.mjs +200 -0
  485. package/dist/src/composition/orgPluginLibrary/index.mjs.map +1 -0
  486. package/dist/src/composition/pluginMarketplace/index.cjs +304 -0
  487. package/dist/src/composition/pluginMarketplace/index.cjs.map +1 -0
  488. package/dist/src/composition/pluginMarketplace/index.mjs +302 -0
  489. package/dist/src/composition/pluginMarketplace/index.mjs.map +1 -0
  490. package/dist/src/composition/poHomeMigration/index.cjs +46 -26
  491. package/dist/src/composition/poHomeMigration/index.cjs.map +1 -1
  492. package/dist/src/composition/poHomeMigration/index.d.mts.map +1 -1
  493. package/dist/src/composition/poHomeMigration/index.mjs +45 -25
  494. package/dist/src/composition/poHomeMigration/index.mjs.map +1 -1
  495. package/dist/src/composition/projectTrust/index.cjs +40 -3
  496. package/dist/src/composition/projectTrust/index.cjs.map +1 -1
  497. package/dist/src/composition/projectTrust/index.d.mts +8 -0
  498. package/dist/src/composition/projectTrust/index.d.mts.map +1 -1
  499. package/dist/src/composition/projectTrust/index.mjs +33 -2
  500. package/dist/src/composition/projectTrust/index.mjs.map +1 -1
  501. package/dist/src/composition/repository/index.cjs +29 -12
  502. package/dist/src/composition/repository/index.cjs.map +1 -1
  503. package/dist/src/composition/repository/index.d.mts +10 -3
  504. package/dist/src/composition/repository/index.d.mts.map +1 -1
  505. package/dist/src/composition/repository/index.mjs +29 -13
  506. package/dist/src/composition/repository/index.mjs.map +1 -1
  507. package/dist/src/composition/syncPrune/index.cjs +23 -16
  508. package/dist/src/composition/syncPrune/index.cjs.map +1 -1
  509. package/dist/src/composition/syncPrune/index.d.mts.map +1 -1
  510. package/dist/src/composition/syncPrune/index.mjs +22 -15
  511. package/dist/src/composition/syncPrune/index.mjs.map +1 -1
  512. package/dist/src/composition/syncService/index.cjs +441 -194
  513. package/dist/src/composition/syncService/index.cjs.map +1 -1
  514. package/dist/src/composition/syncService/index.d.mts +4 -1
  515. package/dist/src/composition/syncService/index.d.mts.map +1 -1
  516. package/dist/src/composition/syncService/index.mjs +440 -196
  517. package/dist/src/composition/syncService/index.mjs.map +1 -1
  518. package/dist/src/composition/syncService/localBuilds.cjs +41 -37
  519. package/dist/src/composition/syncService/localBuilds.cjs.map +1 -1
  520. package/dist/src/composition/syncService/localBuilds.mjs +40 -37
  521. package/dist/src/composition/syncService/localBuilds.mjs.map +1 -1
  522. package/dist/src/composition/transitionLayers.cjs.map +1 -1
  523. package/dist/src/composition/transitionLayers.d.mts +3 -3
  524. package/dist/src/composition/transitionLayers.d.mts.map +1 -1
  525. package/dist/src/composition/transitionLayers.mjs.map +1 -1
  526. package/dist/src/composition/types/harness.d.mts +4 -9
  527. package/dist/src/composition/types/harness.d.mts.map +1 -1
  528. package/dist/src/extensions/setupDiagnostics.cjs +8 -8
  529. package/dist/src/extensions/setupDiagnostics.cjs.map +1 -1
  530. package/dist/src/extensions/setupDiagnostics.mjs +8 -8
  531. package/dist/src/extensions/setupDiagnostics.mjs.map +1 -1
  532. package/dist/webBuilder.cjs +2 -0
  533. package/dist/webBuilder.d.mts +3 -3
  534. package/dist/webBuilder.mjs +3 -3
  535. package/docs/server/api-export.md +9 -9
  536. package/docs/server/api.md +22 -125
  537. package/docs/server/getting-started.md +21 -85
  538. package/docs/server/index.md +13 -58
  539. package/docs/server/ipc.md +26 -72
  540. package/docs/server/lifecycle.md +18 -91
  541. package/docs/server/security.md +20 -80
  542. package/locales/vi.json +208 -0
  543. package/locales/zh-CN.json +208 -0
  544. package/package.json +52 -69
  545. package/src/prompts/po-author-extension/SKILL.md +2 -2
  546. package/src/prompts/po-author-extension/references/extension-contract.md +4 -6
  547. package/dist/antigravity.cjs +0 -5
  548. package/dist/antigravity.d.mts +0 -2
  549. package/dist/antigravity.mjs +0 -1
  550. package/dist/codex.cjs +0 -8
  551. package/dist/codex.d.mts +0 -2
  552. package/dist/codex.mjs +0 -1
  553. package/dist/compatibility.cjs +0 -27
  554. package/dist/compatibility.d.mts +0 -6
  555. package/dist/compatibility.mjs +0 -6
  556. package/dist/compatibilityCommand.cjs +0 -4
  557. package/dist/compatibilityCommand.d.mts +0 -2
  558. package/dist/compatibilityCommand.mjs +0 -1
  559. package/dist/compatibilityContext.cjs +0 -3
  560. package/dist/compatibilityContext.d.mts +0 -2
  561. package/dist/compatibilityContext.mjs +0 -1
  562. package/dist/compatibilityOptions.cjs +0 -5
  563. package/dist/compatibilityOptions.d.mts +0 -2
  564. package/dist/compatibilityOptions.mjs +0 -1
  565. package/dist/process.cjs +0 -12
  566. package/dist/process.d.mts +0 -2
  567. package/dist/process.mjs +0 -1
  568. package/dist/src/builders/hooks/index.cjs +0 -238
  569. package/dist/src/builders/hooks/index.cjs.map +0 -1
  570. package/dist/src/builders/hooks/index.mjs +0 -231
  571. package/dist/src/builders/hooks/index.mjs.map +0 -1
  572. package/dist/src/cli/commands/compat/context.cjs +0 -115
  573. package/dist/src/cli/commands/compat/context.cjs.map +0 -1
  574. package/dist/src/cli/commands/compat/context.d.mts +0 -22
  575. package/dist/src/cli/commands/compat/context.d.mts.map +0 -1
  576. package/dist/src/cli/commands/compat/context.mjs +0 -110
  577. package/dist/src/cli/commands/compat/context.mjs.map +0 -1
  578. package/dist/src/cli/commands/compat/help.cjs +0 -26
  579. package/dist/src/cli/commands/compat/help.cjs.map +0 -1
  580. package/dist/src/cli/commands/compat/help.d.mts +0 -4
  581. package/dist/src/cli/commands/compat/help.d.mts.map +0 -1
  582. package/dist/src/cli/commands/compat/help.mjs +0 -25
  583. package/dist/src/cli/commands/compat/help.mjs.map +0 -1
  584. package/dist/src/cli/commands/compat/index.cjs +0 -73
  585. package/dist/src/cli/commands/compat/index.cjs.map +0 -1
  586. package/dist/src/cli/commands/compat/index.d.mts +0 -14
  587. package/dist/src/cli/commands/compat/index.d.mts.map +0 -1
  588. package/dist/src/cli/commands/compat/index.mjs +0 -70
  589. package/dist/src/cli/commands/compat/index.mjs.map +0 -1
  590. package/dist/src/cli/commands/compat/options.cjs +0 -88
  591. package/dist/src/cli/commands/compat/options.cjs.map +0 -1
  592. package/dist/src/cli/commands/compat/options.d.mts +0 -15
  593. package/dist/src/cli/commands/compat/options.d.mts.map +0 -1
  594. package/dist/src/cli/commands/compat/options.mjs +0 -86
  595. package/dist/src/cli/commands/compat/options.mjs.map +0 -1
  596. package/dist/src/cli/commands/compat/providers/antigravity.cjs +0 -294
  597. package/dist/src/cli/commands/compat/providers/antigravity.cjs.map +0 -1
  598. package/dist/src/cli/commands/compat/providers/antigravity.d.mts +0 -9
  599. package/dist/src/cli/commands/compat/providers/antigravity.d.mts.map +0 -1
  600. package/dist/src/cli/commands/compat/providers/antigravity.mjs +0 -289
  601. package/dist/src/cli/commands/compat/providers/antigravity.mjs.map +0 -1
  602. package/dist/src/cli/commands/compat/providers/codex.cjs +0 -178
  603. package/dist/src/cli/commands/compat/providers/codex.cjs.map +0 -1
  604. package/dist/src/cli/commands/compat/providers/codex.d.mts +0 -17
  605. package/dist/src/cli/commands/compat/providers/codex.d.mts.map +0 -1
  606. package/dist/src/cli/commands/compat/providers/codex.mjs +0 -170
  607. package/dist/src/cli/commands/compat/providers/codex.mjs.map +0 -1
  608. package/dist/src/cli/commands/compat/providers/index.cjs +0 -65
  609. package/dist/src/cli/commands/compat/providers/index.cjs.map +0 -1
  610. package/dist/src/cli/commands/compat/providers/index.d.mts +0 -15
  611. package/dist/src/cli/commands/compat/providers/index.d.mts.map +0 -1
  612. package/dist/src/cli/commands/compat/providers/index.mjs +0 -45
  613. package/dist/src/cli/commands/compat/providers/index.mjs.map +0 -1
  614. package/dist/src/cli/commands/compat/providers/process.cjs +0 -172
  615. package/dist/src/cli/commands/compat/providers/process.cjs.map +0 -1
  616. package/dist/src/cli/commands/compat/providers/process.d.mts +0 -33
  617. package/dist/src/cli/commands/compat/providers/process.d.mts.map +0 -1
  618. package/dist/src/cli/commands/compat/providers/process.mjs +0 -159
  619. package/dist/src/cli/commands/compat/providers/process.mjs.map +0 -1
  620. package/dist/src/cli/commands/compat/providers/shared.cjs +0 -76
  621. package/dist/src/cli/commands/compat/providers/shared.cjs.map +0 -1
  622. package/dist/src/cli/commands/compat/providers/shared.d.mts +0 -40
  623. package/dist/src/cli/commands/compat/providers/shared.d.mts.map +0 -1
  624. package/dist/src/cli/commands/compat/providers/shared.mjs +0 -61
  625. package/dist/src/cli/commands/compat/providers/shared.mjs.map +0 -1
  626. package/dist/src/cli/commands/compat/types.d.mts +0 -31
  627. package/dist/src/cli/commands/compat/types.d.mts.map +0 -1
  628. package/dist/src/cli/commands/init/constants.cjs +0 -11
  629. package/dist/src/cli/commands/init/constants.cjs.map +0 -1
  630. package/dist/src/cli/commands/init/constants.mjs +0 -11
  631. package/dist/src/cli/commands/init/constants.mjs.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"webPluginGenerate.mjs","names":[],"sources":["../../../../src/builders/web/webPluginGenerate.ts"],"sourcesContent":["import fs from 'node:fs';\nimport { createRequire } from 'node:module';\nimport path from 'node:path';\nimport { pathToFileURL } from 'node:url';\n\nimport type { DeclaredWebPlugin } from './webPluginManifest';\nimport { scanWebPlugins } from './webPluginScan';\n\nconst HEADER = '// Generated by po web builder. Do not edit by hand.';\n/** The template po-web renders when a composition names none, so its classes always compile. */\nconst FALLBACK_TEMPLATE_PACKAGE = '@agimon-ai/po-template-advanced';\nexport const BUILTIN_CLIENT_MODULE = path.join('src', 'web', 'app', 'webPlugins.generated.ts');\nexport const BUILTIN_CSS_MODULE = path.join('src', 'web', 'styles', 'webPluginSources.generated.css');\n\n/**\n * The import name of one plugin copy, derived from its slot so two copies of one pluginId\n * never collide. A host slot is its kebab-case pluginId and keeps the committed module's\n * names; a copy slot's '.' becomes '_', which no host name can contain.\n */\nfunction slotIdentifier(slot: string): string {\n return slot.replace(/-([a-z0-9])/g, (_, ch: string) => ch.toUpperCase()).replace(/[^A-Za-z0-9_$]/g, '_');\n}\n\nfunction relativeImport(fromDir: string, toFile: string): string {\n const spec = path.relative(fromDir, toFile).split(path.sep).join('/');\n return spec.startsWith('.') ? spec : `./${spec}`;\n}\n\nfunction renderClientModule(\n plugins: readonly DeclaredWebPlugin[],\n style: 'relative' | 'absolute',\n packageRoot: string,\n): string {\n const lines = [HEADER, \"import type { WebPluginDefinition } from '@agimon-ai/po-core/web';\"];\n const names: string[] = [];\n const fromDir = path.join(packageRoot, 'src', 'web', 'app');\n for (const plugin of plugins) {\n const name = `${slotIdentifier(plugin.slot)}Plugin`;\n names.push(name);\n const entry = path.join(plugin.packageDir, plugin.client.entry);\n // The committed builtin module keeps machine-neutral relative imports; the\n // sync-generated module lives outside src, is aliased over the committed\n // path, and resolves imports against its real location, so every entry\n // becomes an absolute file URL into the installed packages.\n const specifier =\n style === 'relative' ? relativeImport(fromDir, entry) : pathToFileURL(fs.realpathSync(entry)).href;\n lines.push(`import { webPlugin as ${name} } from '${specifier}';`);\n }\n lines.push('', `export const webPlugins: readonly WebPluginDefinition[] = [${names.join(', ')}];`, '');\n return lines.join('\\n');\n}\n\n/**\n * The directory Tailwind scans for a plugin's class names.\n *\n * `src/extensions` wins, because a plugin's components colocate with the routed\n * file that renders them, in private `_components` and `_lib` folders. The\n * legacy `src/web` root is only a fallback: `existsSync` is true for a\n * half-emptied directory holding nothing but a tsconfig, and packages have been\n * in exactly that state, so preferring it would hand Tailwind a directory with\n * no components in it and silently drop every class.\n *\n * The client entry's own directory is the last resort. It is published through\n * `src/exports/webClient.ts`, a one-line re-export, or generated outside `src`\n * entirely, so it holds no components either.\n */\nfunction pluginSourceRoot(plugin: DeclaredWebPlugin): string {\n const routingRoot = path.join(plugin.packageDir, 'src', 'extensions');\n if (fs.existsSync(routingRoot)) return routingRoot;\n const webRoot = path.join(plugin.packageDir, 'src', 'web');\n if (fs.existsSync(webRoot)) return webRoot;\n return path.dirname(path.join(plugin.packageDir, plugin.client.entry));\n}\n\n/**\n * Where Tailwind finds the fallback template's classes. app.css names it by a\n * path from its own folder into po-web's node_modules, which holds only in\n * this repository; an installed po-web has the template beside it instead,\n * so a sync build that scanned only that path shipped the cockpit without the\n * template's responsive layout. Resolving it as Node does works in both.\n */\nfunction fallbackTemplateSourceRoot(packageRoot: string): string | undefined {\n let manifest: string;\n try {\n manifest = createRequire(path.join(packageRoot, 'package.json')).resolve(\n `${FALLBACK_TEMPLATE_PACKAGE}/package.json`,\n );\n } catch {\n // Not installed: the cockpit then has no fallback template to render either.\n return undefined;\n }\n const extensions = path.join(path.dirname(manifest), 'dist', 'extensions');\n return fs.existsSync(extensions) ? extensions : undefined;\n}\n\nfunction renderCssModule(plugins: readonly DeclaredWebPlugin[], leadingSourceRoots: readonly string[]): string {\n // Sync CSS is compiled from a generated directory, so Tailwind cannot infer\n // the stable shell tree from app.css. Its caller names that tree explicitly\n // so later plugin utilities do not override missing responsive shell utilities.\n const lines = [`/* ${HEADER.slice(3)} */`, ...leadingSourceRoots.map((root) => `@source \"${root}\";`)];\n for (const plugin of plugins) {\n if (plugin.isHost) continue;\n lines.push(`@source \"${pluginSourceRoot(plugin)}\";`);\n }\n lines.push('');\n return lines.join('\\n');\n}\n\n/** The committed client registry, rendered from the host package alone. */\nexport function renderBuiltinWebPluginModules(packageRoot: string): Map<string, string> {\n const plugins = scanWebPlugins(packageRoot);\n return new Map([\n [BUILTIN_CLIENT_MODULE, renderClientModule(plugins, 'relative', packageRoot)],\n [BUILTIN_CSS_MODULE, renderCssModule(plugins, [])],\n ]);\n}\n\n/**\n * Keeps the committed client registry fresh: write-if-changed locally,\n * check-only (throw) in CI. Both vite.config.ts and tsdown.config.ts call\n * this at config-load time.\n */\nexport function ensureBuiltinWebPluginModules({\n packageRoot,\n check = false,\n}: {\n packageRoot: string;\n check?: boolean;\n}): void {\n const stale: string[] = [];\n for (const [relativePath, content] of renderBuiltinWebPluginModules(packageRoot)) {\n const filePath = path.join(packageRoot, relativePath);\n const existing = fs.existsSync(filePath) ? fs.readFileSync(filePath, 'utf8') : undefined;\n if (existing === content) continue;\n if (check) {\n stale.push(relativePath);\n continue;\n }\n fs.mkdirSync(path.dirname(filePath), { recursive: true });\n fs.writeFileSync(filePath, content);\n }\n if (stale.length > 0) {\n throw new Error(\n `Stale generated web plugin modules: ${stale.join(', ')}. Run pnpm build in po-web and commit them.`,\n );\n }\n}\n\n/** A client plugin registry and the Tailwind source list that goes with it. */\nexport interface WebPluginRegistryModules {\n clientModulePath: string;\n cssModulePath: string;\n}\n\nexport interface SyncGeneratedModules extends WebPluginRegistryModules {\n /** One entry module per slot, each re-exporting only that copy's `webPlugin`. */\n slotEntryPaths: Record<string, string>;\n /**\n * The signed shell's registry: host plugins only. Every other plugin reaches the\n * browser through its slot entry, and the global mount replaces the shell's\n * registry once it loads, so compiling them into the shell too shipped each plugin's\n * code and emitted assets (the voice VAD model among them) a second time.\n */\n shell: WebPluginRegistryModules;\n}\n\nexport interface WebPluginStyleEntries {\n /** Shell, fallback-template, and plugin sources, aliased over app.css's source list. */\n baseSourcesPath: string;\n /** The shared Tailwind entry every mount loads. */\n baseEntryPath: string;\n /** ponytail: empty compatibility field; remove only with a public webBuilder API change. */\n pluginEntryPaths: Map<string, string>;\n}\n\n/** The shared stylesheet's Rollup input name. */\nexport const BASE_STYLE_ENTRY = 'base';\nexport const pluginStyleEntryName = (slot: string): string => `plugin-${slot}`;\n\n/** One Tailwind entry for the whole build, so later sheets cannot override earlier variants. */\nexport function writeWebPluginStyleEntries(\n plugins: readonly DeclaredWebPlugin[],\n generatedDir: string,\n packageRoot: string,\n): WebPluginStyleEntries {\n const stylesDir = path.join(generatedDir, 'styles');\n fs.mkdirSync(stylesDir, { recursive: true });\n const fallbackTemplate = fallbackTemplateSourceRoot(packageRoot);\n const baseSourcesPath = path.join(generatedDir, 'webPluginBaseSources.generated.css');\n fs.writeFileSync(\n baseSourcesPath,\n renderCssModule(plugins, [\n path.join(packageRoot, 'src', 'web'),\n ...(fallbackTemplate === undefined ? [] : [fallbackTemplate]),\n ]),\n );\n // Resolvers follow real paths (a temp dir under /var is /private/var), so relate real paths.\n const appCss = relativeImport(\n fs.realpathSync(stylesDir),\n fs.realpathSync(path.join(packageRoot, 'src', 'web', 'styles', 'app.css')),\n );\n const baseEntryPath = path.join(stylesDir, `${BASE_STYLE_ENTRY}.css`);\n fs.writeFileSync(baseEntryPath, `/* ${HEADER.slice(3)} */\\n@import '${appCss}';\\n`);\n const pluginEntryPaths = new Map<string, string>();\n return { baseSourcesPath, baseEntryPath, pluginEntryPaths };\n}\n\n/**\n * The sync-time variant: renders the full client plugin set (host built-ins plus\n * the installed composition's packages) into a generation directory the bundler\n * aliases over the committed builtin modules.\n */\nexport function writeSyncWebPluginModules(\n plugins: readonly DeclaredWebPlugin[],\n generatedDir: string,\n packageRoot: string,\n): SyncGeneratedModules {\n fs.mkdirSync(generatedDir, { recursive: true });\n const clientModulePath = path.join(generatedDir, 'webPlugins.generated.ts');\n const cssModulePath = path.join(generatedDir, 'webPluginSources.generated.css');\n fs.writeFileSync(clientModulePath, renderClientModule(plugins, 'absolute', packageRoot));\n // Tailwind styles compile separately as one shared sheet, so slot entries carry none.\n const slotsDir = path.join(generatedDir, 'slots');\n fs.mkdirSync(slotsDir, { recursive: true });\n const slotEntryPaths: Record<string, string> = {};\n for (const plugin of plugins) {\n const entryPath = path.join(slotsDir, `${plugin.slot}.ts`);\n const specifier = pathToFileURL(fs.realpathSync(path.join(plugin.packageDir, plugin.client.entry))).href;\n fs.writeFileSync(entryPath, `${HEADER}\\nexport { webPlugin } from '${specifier}';\\n`);\n slotEntryPaths[plugin.slot] = entryPath;\n }\n const fallbackTemplate = fallbackTemplateSourceRoot(packageRoot);\n const leadingSourceRoots = [\n path.join(packageRoot, 'src', 'web'),\n ...(fallbackTemplate === undefined ? [] : [fallbackTemplate]),\n ];\n fs.writeFileSync(cssModulePath, renderCssModule(plugins, leadingSourceRoots));\n const hostPlugins = plugins.filter((plugin) => plugin.isHost);\n const shell = {\n clientModulePath: path.join(generatedDir, 'webPluginShell.generated.ts'),\n cssModulePath: path.join(generatedDir, 'webPluginShellSources.generated.css'),\n };\n fs.writeFileSync(shell.clientModulePath, renderClientModule(hostPlugins, 'absolute', packageRoot));\n fs.writeFileSync(shell.cssModulePath, renderCssModule(hostPlugins, leadingSourceRoots));\n return {\n clientModulePath,\n slotEntryPaths,\n cssModulePath,\n shell,\n };\n}\n"],"mappings":";;;;;;AAQA,MAAM,SAAS;;AAEf,MAAM,4BAA4B;AAClC,MAAa,wBAAwB,KAAK,KAAK,OAAO,OAAO,OAAO,yBAAyB;AAC7F,MAAa,qBAAqB,KAAK,KAAK,OAAO,OAAO,UAAU,gCAAgC;;;;;;AAOpG,SAAS,eAAe,MAAsB;CAC5C,OAAO,KAAK,QAAQ,iBAAiB,GAAG,OAAe,GAAG,YAAY,CAAC,CAAC,CAAC,QAAQ,mBAAmB,GAAG;AACzG;AAEA,SAAS,eAAe,SAAiB,QAAwB;CAC/D,MAAM,OAAO,KAAK,SAAS,SAAS,MAAM,CAAC,CAAC,MAAM,KAAK,GAAG,CAAC,CAAC,KAAK,GAAG;CACpE,OAAO,KAAK,WAAW,GAAG,IAAI,OAAO,KAAK;AAC5C;AAEA,SAAS,mBACP,SACA,OACA,aACQ;CACR,MAAM,QAAQ,CAAC,QAAQ,oEAAoE;CAC3F,MAAM,QAAkB,CAAC;CACzB,MAAM,UAAU,KAAK,KAAK,aAAa,OAAO,OAAO,KAAK;CAC1D,KAAK,MAAM,UAAU,SAAS;EAC5B,MAAM,OAAO,GAAG,eAAe,OAAO,IAAI,EAAE;EAC5C,MAAM,KAAK,IAAI;EACf,MAAM,QAAQ,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9E;CACA,GAAG,cAAc,MAAM,kBAAkB,mBAAmB,aAAa,YAAY,WAAW,CAAC;CACjG,GAAG,cAAc,MAAM,eAAe,gBAAgB,aAAa,kBAAkB,CAAC;CACtF,OAAO;EACL;EACA;EACA;EACA;CACF;AACF"}
1
+ {"version":3,"file":"webPluginGenerate.mjs","names":[],"sources":["../../../../src/builders/web/webPluginGenerate.ts"],"sourcesContent":["import { createHash } from 'node:crypto';\nimport fs from 'node:fs/promises';\nimport { createRequire } from 'node:module';\nimport path from 'node:path';\nimport { pathToFileURL } from 'node:url';\n\nimport type { DeclaredWebPlugin } from './webPluginManifest';\nimport { scanWebPlugins } from './webPluginScan';\n\nconst HEADER = '// Generated by po web builder. Do not edit by hand.';\n/** The templates po-web bundles: Elegant is the default, Advanced and Desktop the alternatives, so all always compile. */\nconst FALLBACK_TEMPLATE_PACKAGES = [\n '@agimon-ai/po-template-elegant',\n '@agimon-ai/po-template-advanced',\n '@agimon-ai/po-template-desktop',\n];\nexport const BUILTIN_CLIENT_MODULE = path.join('src', 'web', 'app', 'webPlugins.generated.ts');\nexport const BUILTIN_CSS_MODULE = path.join('src', 'web', 'styles', 'webPluginSources.generated.css');\n\n/**\n * The import name of one plugin copy, derived from its slot so two copies of one pluginId\n * never collide. A host slot is its kebab-case pluginId and keeps the committed module's\n * names; a copy slot's '.' becomes '_', which no host name can contain.\n */\nfunction slotIdentifier(slot: string): string {\n return slot.replace(/-([a-z0-9])/g, (_, ch: string) => ch.toUpperCase()).replace(/[^A-Za-z0-9_$]/g, '_');\n}\n\nfunction relativeImport(fromDir: string, toFile: string): string {\n const spec = path.relative(fromDir, toFile).split(path.sep).join('/');\n return spec.startsWith('.') ? spec : `./${spec}`;\n}\n\n/**\n * v1 content identity: SHA-256 of a domain-separated JSON tuple containing the\n * package name, declared version (empty for unpublished packages), declared entry\n * path and its exact bytes (base64). Installation paths, slots and mtimes never\n * enter the digest, so the same published package is reproducible across hosts.\n * Version binds transitive package content; entry bytes also detect local entry\n * edits. This is not a digest of the dependency graph or a code-signing claim.\n */\nexport async function webPluginPackageFingerprint(plugin: DeclaredWebPlugin): Promise<string> {\n const manifest: { version?: unknown } = JSON.parse(\n await fs.readFile(path.join(plugin.packageDir, 'package.json'), 'utf8'),\n );\n const entry = await fs.readFile(path.join(plugin.packageDir, plugin.client.entry));\n return createHash('sha256')\n .update(\n JSON.stringify([\n 'po/web-plugin-package/v1',\n plugin.packageName,\n typeof manifest.version === 'string' ? manifest.version : '',\n plugin.client.entry,\n entry.toString('base64'),\n ]),\n )\n .digest('hex');\n}\n\nasync function renderClientModule(\n plugins: readonly DeclaredWebPlugin[],\n style: 'relative' | 'absolute',\n packageRoot: string,\n): Promise<string> {\n const lines = [HEADER, \"import type { WebPluginDefinition } from '@agimon-ai/po-core/web';\"];\n const names: string[] = [];\n const fromDir = path.join(packageRoot, 'src', 'web', 'app');\n for (const plugin of plugins) {\n const name = `${slotIdentifier(plugin.slot)}Plugin`;\n names.push(name);\n const entry = path.join(plugin.packageDir, plugin.client.entry);\n // The committed builtin module keeps machine-neutral relative imports; the\n // sync-generated module lives outside src, is aliased over the committed\n // path, and resolves imports against its real location, so every entry\n // becomes an absolute file URL into the installed packages.\n const specifier =\n style === 'relative' ? relativeImport(fromDir, entry) : pathToFileURL(await fs.realpath(entry)).href;\n lines.push(`import { webPlugin as ${name} } from '${specifier}';`);\n }\n const packages = await Promise.all(\n plugins.map(async (plugin) => ({\n packageName: plugin.packageName,\n pluginId: plugin.pluginId,\n fingerprint: await webPluginPackageFingerprint(plugin),\n })),\n );\n lines.push(\n '',\n `export const webPlugins: readonly WebPluginDefinition[] = [${names.join(', ')}];`,\n `export const webPluginPackages: readonly { packageName: string; pluginId: string; fingerprint: string }[] = ${JSON.stringify(packages)};`,\n '',\n );\n return lines.join('\\n');\n}\n\n/**\n * The directory Tailwind scans for a plugin's class names.\n *\n * `src/extensions` wins, because a plugin's components colocate with the routed\n * file that renders them, in private `_components` and `_lib` folders. The\n * legacy `src/web` root is only a fallback: an existence check passes for a\n * half-emptied directory holding nothing but a tsconfig, and packages have been\n * in exactly that state, so preferring it would hand Tailwind a directory with\n * no components in it and silently drop every class.\n *\n * The client entry's own directory is the last resort. It is published through\n * `src/exports/webClient.ts`, a one-line re-export, or generated outside `src`\n * entirely, so it holds no components either.\n */\nasync function pluginSourceRoot(plugin: DeclaredWebPlugin): Promise<string> {\n for (const root of [path.join(plugin.packageDir, 'src', 'extensions'), path.join(plugin.packageDir, 'src', 'web')]) {\n const exists = await fs.access(root).then(\n () => true,\n (error: NodeJS.ErrnoException) => {\n if (error.code === 'ENOENT') return false;\n throw error;\n },\n );\n if (exists) return root;\n }\n return path.dirname(path.join(plugin.packageDir, plugin.client.entry));\n}\n\n/**\n * Where Tailwind finds a bundled template's classes. app.css names it by a\n * path from its own folder into po-web's node_modules, which holds only in\n * this repository; an installed po-web has the template beside it instead,\n * so a sync build that scanned only that path shipped the cockpit without the\n * template's responsive layout. Resolving it as Node does works in both.\n */\nasync function fallbackTemplateSourceRoot(packageRoot: string, name: string): Promise<string | undefined> {\n let manifest: string;\n try {\n manifest = createRequire(path.join(packageRoot, 'package.json')).resolve(`${name}/package.json`);\n } catch {\n // Not installed: the cockpit then has no fallback template to render either.\n return undefined;\n }\n const extensions = path.join(path.dirname(manifest), 'dist', 'extensions');\n return fs.access(extensions).then(\n () => extensions,\n (error: NodeJS.ErrnoException) => {\n if (error.code === 'ENOENT') return undefined;\n throw error;\n },\n );\n}\n\n/** Every bundled template that is installed, in FALLBACK_TEMPLATE_PACKAGES order. */\nasync function fallbackTemplateSourceRoots(packageRoot: string): Promise<string[]> {\n const roots = await Promise.all(\n FALLBACK_TEMPLATE_PACKAGES.map((name) => fallbackTemplateSourceRoot(packageRoot, name)),\n );\n return roots.filter((root) => root !== undefined);\n}\n\nasync function renderCssModule(\n plugins: readonly DeclaredWebPlugin[],\n leadingSourceRoots: readonly string[],\n): Promise<string> {\n // Sync CSS is compiled from a generated directory, so Tailwind cannot infer\n // the stable shell tree from app.css. Its caller names that tree explicitly\n // so later plugin utilities do not override missing responsive shell utilities.\n const lines = [`/* ${HEADER.slice(3)} */`, ...leadingSourceRoots.map((root) => `@source \"${root}\";`)];\n for (const plugin of plugins) {\n if (plugin.isHost) continue;\n lines.push(`@source \"${await pluginSourceRoot(plugin)}\";`);\n }\n lines.push('');\n return lines.join('\\n');\n}\n\n/** The committed client registry, rendered from the host package alone. */\nexport async function renderBuiltinWebPluginModules(packageRoot: string): Promise<Map<string, string>> {\n const plugins = await scanWebPlugins(packageRoot);\n return new Map([\n [BUILTIN_CLIENT_MODULE, await renderClientModule(plugins, 'relative', packageRoot)],\n [BUILTIN_CSS_MODULE, await renderCssModule(plugins, [])],\n ]);\n}\n\n/**\n * Keeps the committed client registry fresh: write-if-changed locally,\n * check-only (throw) in CI. Both vite.config.ts and tsdown.config.ts call\n * this at config-load time.\n */\nexport async function ensureBuiltinWebPluginModules({\n packageRoot,\n check = false,\n}: {\n packageRoot: string;\n check?: boolean;\n}): Promise<void> {\n const stale: string[] = [];\n for (const [relativePath, content] of await renderBuiltinWebPluginModules(packageRoot)) {\n const filePath = path.join(packageRoot, relativePath);\n const existing = await fs.readFile(filePath, 'utf8').catch((error: NodeJS.ErrnoException) => {\n if (error.code === 'ENOENT') return undefined;\n throw error;\n });\n if (existing === content) continue;\n if (check) {\n stale.push(relativePath);\n continue;\n }\n await fs.mkdir(path.dirname(filePath), { recursive: true });\n await fs.writeFile(filePath, content);\n }\n if (stale.length > 0) {\n throw new Error(\n `Stale generated web plugin modules: ${stale.join(', ')}. Run pnpm build in po-web and commit them.`,\n );\n }\n}\n\n/** A client plugin registry and the Tailwind source list that goes with it. */\nexport interface WebPluginRegistryModules {\n clientModulePath: string;\n cssModulePath: string;\n}\n\nexport interface SyncGeneratedModules extends WebPluginRegistryModules {\n /** One entry module per slot, each re-exporting only that copy's `webPlugin`. */\n slotEntryPaths: Record<string, string>;\n /**\n * The signed shell's registry: host plugins only. Every other plugin reaches the\n * browser through its slot entry, and the global mount replaces the shell's\n * registry once it loads, so compiling them into the shell too shipped each plugin's\n * code and emitted assets (the voice VAD model among them) a second time.\n */\n shell: WebPluginRegistryModules;\n}\n\nexport interface WebPluginStyleEntries {\n /** Shell, fallback-template, and plugin sources, aliased over app.css's source list. */\n baseSourcesPath: string;\n /** The shared Tailwind entry every mount loads. */\n baseEntryPath: string;\n /** ponytail: empty compatibility field; remove only with a public webBuilder API change. */\n pluginEntryPaths: Map<string, string>;\n}\n\n/** The shared stylesheet's Rollup input name. */\nexport const BASE_STYLE_ENTRY = 'base';\nexport const pluginStyleEntryName = (slot: string): string => `plugin-${slot}`;\n\n/** One Tailwind entry for the whole build, so later sheets cannot override earlier variants. */\nexport async function writeWebPluginStyleEntries(\n plugins: readonly DeclaredWebPlugin[],\n generatedDir: string,\n packageRoot: string,\n): Promise<WebPluginStyleEntries> {\n const stylesDir = path.join(generatedDir, 'styles');\n await fs.mkdir(stylesDir, { recursive: true });\n const fallbackTemplates = await fallbackTemplateSourceRoots(packageRoot);\n const baseSourcesPath = path.join(generatedDir, 'webPluginBaseSources.generated.css');\n await fs.writeFile(\n baseSourcesPath,\n await renderCssModule(plugins, [path.join(packageRoot, 'src', 'web'), ...fallbackTemplates]),\n );\n // Resolvers follow real paths (a temp dir under /var is /private/var), so relate real paths.\n const appCss = relativeImport(\n await fs.realpath(stylesDir),\n await fs.realpath(path.join(packageRoot, 'src', 'web', 'styles', 'app.css')),\n );\n const baseEntryPath = path.join(stylesDir, `${BASE_STYLE_ENTRY}.css`);\n await fs.writeFile(baseEntryPath, `/* ${HEADER.slice(3)} */\\n@import '${appCss}';\\n`);\n const pluginEntryPaths = new Map<string, string>();\n return { baseSourcesPath, baseEntryPath, pluginEntryPaths };\n}\n\n/**\n * The sync-time variant: renders the full client plugin set (host built-ins plus\n * the installed composition's packages) into a generation directory the bundler\n * aliases over the committed builtin modules.\n */\nexport async function writeSyncWebPluginModules(\n plugins: readonly DeclaredWebPlugin[],\n generatedDir: string,\n packageRoot: string,\n): Promise<SyncGeneratedModules> {\n await fs.mkdir(generatedDir, { recursive: true });\n const clientModulePath = path.join(generatedDir, 'webPlugins.generated.ts');\n const cssModulePath = path.join(generatedDir, 'webPluginSources.generated.css');\n await fs.writeFile(clientModulePath, await renderClientModule(plugins, 'absolute', packageRoot));\n // Tailwind styles compile separately as one shared sheet, so slot entries carry none.\n const slotsDir = path.join(generatedDir, 'slots');\n await fs.mkdir(slotsDir, { recursive: true });\n const slotEntryPaths: Record<string, string> = {};\n for (const plugin of plugins) {\n const entryPath = path.join(slotsDir, `${plugin.slot}.ts`);\n const specifier = pathToFileURL(await fs.realpath(path.join(plugin.packageDir, plugin.client.entry))).href;\n await fs.writeFile(entryPath, `${HEADER}\\nexport { webPlugin } from '${specifier}';\\n`);\n slotEntryPaths[plugin.slot] = entryPath;\n }\n const leadingSourceRoots = [\n path.join(packageRoot, 'src', 'web'),\n ...(await fallbackTemplateSourceRoots(packageRoot)),\n ];\n await fs.writeFile(cssModulePath, await renderCssModule(plugins, leadingSourceRoots));\n const hostPlugins = plugins.filter((plugin) => plugin.isHost);\n const shell = {\n clientModulePath: path.join(generatedDir, 'webPluginShell.generated.ts'),\n cssModulePath: path.join(generatedDir, 'webPluginShellSources.generated.css'),\n };\n await fs.writeFile(shell.clientModulePath, await renderClientModule(hostPlugins, 'absolute', packageRoot));\n await fs.writeFile(shell.cssModulePath, await renderCssModule(hostPlugins, leadingSourceRoots));\n return {\n clientModulePath,\n slotEntryPaths,\n cssModulePath,\n shell,\n };\n}\n"],"mappings":";;;;;;;AASA,MAAM,SAAS;;AAEf,MAAM,6BAA6B;CACjC;CACA;CACA;AACF;AACA,MAAa,wBAAwB,KAAK,KAAK,OAAO,OAAO,OAAO,yBAAyB;AAC7F,MAAa,qBAAqB,KAAK,KAAK,OAAO,OAAO,UAAU,gCAAgC;;;;;;AAOpG,SAAS,eAAe,MAAsB;CAC5C,OAAO,KAAK,QAAQ,iBAAiB,GAAG,OAAe,GAAG,Y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B,KAAK,KAAK,aAAa,OAAO,KAAK,GACnC,GAAI,MAAM,4BAA4B,WAAW,CACnD;CACA,MAAM,GAAG,UAAU,eAAe,MAAM,gBAAgB,SAAS,kBAAkB,CAAC;CACpF,MAAM,cAAc,QAAQ,QAAQ,WAAW,OAAO,MAAM;CAC5D,MAAM,QAAQ;EACZ,kBAAkB,KAAK,KAAK,cAAc,6BAA6B;EACvE,eAAe,KAAK,KAAK,cAAc,qCAAqC;CAC9E;CACA,MAAM,GAAG,UAAU,MAAM,kBAAkB,MAAM,mBAAmB,aAAa,YAAY,WAAW,CAAC;CACzG,MAAM,GAAG,UAAU,MAAM,eAAe,MAAM,gBAAgB,aAAa,kBAAkB,CAAC;CAC9F,OAAO;EACL;EACA;EACA;EACA;CACF;AACF"}
@@ -1,8 +1,9 @@
1
1
  const require_runtime = require("../../../_virtual/_rolldown/runtime.cjs");
2
- let node_fs = require("node:fs");
3
- node_fs = require_runtime.__toESM(node_fs, 1);
4
2
  let node_path = require("node:path");
5
3
  node_path = require_runtime.__toESM(node_path, 1);
4
+ let node_fs_promises = require("node:fs/promises");
5
+ node_fs_promises = require_runtime.__toESM(node_fs_promises, 1);
6
+ let _agimon_ai_po_core_serverPlugin = require("@agimon-ai/po-core/serverPlugin");
6
7
  let node_crypto = require("node:crypto");
7
8
  node_crypto = require_runtime.__toESM(node_crypto, 1);
8
9
  //#region src/builders/web/webPluginManifest.ts
@@ -16,9 +17,9 @@ node_crypto = require_runtime.__toESM(node_crypto, 1);
16
17
  * Plugins are independent: a manifest names no other plugin, and the order
17
18
  * plugins install in is only a tiebreak (registrationOrder, then pluginId),
18
19
  * because every relation between two plugins resolves by name once all of
19
- * them are installed. Web copies keep distinct slots so each mount can select its
20
+ * them are installed. Package copies keep distinct slots so each mount can select its
20
21
  * own package; only repeated declarations of the same slot are dropped. Native
21
- * plugins still share one pluginId registry. Malformed blocks are scan errors.
22
+ * bundling still chooses one module per pluginId after retaining all admission roots.
22
23
  *
23
24
  * The native app's poNative blocks share this exact shape, so the same
24
25
  * validation reads either field.
@@ -44,11 +45,11 @@ function normalizeEntry(packageDir, kind, value, field) {
44
45
  }
45
46
  const SLOT_HASH_LENGTH = 8;
46
47
  /** The slot of one installed plugin copy; see DeclaredWebPlugin.slot. */
47
- function pluginSlot(plugin) {
48
+ async function pluginSlot(plugin) {
48
49
  if (plugin.isHost) return plugin.pluginId;
49
50
  let directory;
50
51
  try {
51
- directory = node_fs.default.realpathSync(plugin.packageDir);
52
+ directory = await node_fs_promises.default.realpath(plugin.packageDir);
52
53
  } catch {
53
54
  directory = node_path.default.resolve(plugin.packageDir);
54
55
  }
@@ -62,21 +63,24 @@ function pluginBlocksOf(manifest, field = "poWeb") {
62
63
  return Array.isArray(value) ? value : [value];
63
64
  }
64
65
  /** Validates one manifest's blocks into declared plugins; throws WebPluginManifestError on bad shape. */
65
- function declaredPluginsOf(packageDir, manifest, isHost, field = "poWeb") {
66
+ async function declaredPluginsOf(packageDir, manifest, isHost, field = "poWeb") {
66
67
  const plugins = [];
67
68
  for (const block of pluginBlocksOf(manifest, field)) {
68
69
  if (!isRecord(block)) throw new WebPluginManifestError(packageDir, "each block must be an object.", field);
69
- const { pluginId, registrationOrder = DEFAULT_REGISTRATION_ORDER, client, scopes } = block;
70
+ const { pluginId, registrationOrder = DEFAULT_REGISTRATION_ORDER, client } = block;
71
+ const scopes = block.scopes;
72
+ if (Array.isArray(scopes) && scopes.includes("global")) throw new WebPluginManifestError(packageDir, "The 'global' scope was renamed to 'host'; resync the plugin.", field);
70
73
  if (!Array.isArray(scopes) || scopes.length === 0 || scopes.some((scope) => ![
71
- "global",
74
+ "host",
72
75
  "workspace",
73
76
  "session"
74
- ].includes(scope))) throw new WebPluginManifestError(packageDir, "scopes must explicitly name global, workspace, or session; resync the plugin.", field);
77
+ ].includes(scope))) throw new WebPluginManifestError(packageDir, "scopes must explicitly name host, workspace, or session; resync the plugin.", field);
75
78
  if (typeof pluginId !== "string" || !PLUGIN_ID_PATTERN.test(pluginId)) throw new WebPluginManifestError(packageDir, `pluginId '${String(pluginId)}' must be kebab-case.`, field);
76
79
  if (!Number.isInteger(registrationOrder) || registrationOrder < 0) throw new WebPluginManifestError(packageDir, `'${pluginId}' needs a non-negative integer registrationOrder.`, field);
80
+ const metadata = field === "poWeb" ? (0, _agimon_ai_po_core_serverPlugin.parsePoWebBrainMetadata)(block.brain) : void 0;
77
81
  plugins.push({
78
82
  pluginId,
79
- slot: pluginSlot({
83
+ slot: await pluginSlot({
80
84
  pluginId,
81
85
  packageDir,
82
86
  isHost
@@ -86,7 +90,11 @@ function declaredPluginsOf(packageDir, manifest, isHost, field = "poWeb") {
86
90
  packageName: typeof manifest.name === "string" ? manifest.name : packageDir,
87
91
  isHost,
88
92
  client: normalizeEntry(packageDir, "client", client, field),
89
- scopes
93
+ scopes,
94
+ ...metadata && typeof manifest.name === "string" && /^(?:@[a-z0-9._-]+\/)?[a-z0-9._-]+$/iu.test(manifest.name) ? { brain: {
95
+ packageName: manifest.name,
96
+ metadata
97
+ } } : {}
90
98
  });
91
99
  }
92
100
  return plugins;
@@ -97,19 +105,18 @@ function compareCodeUnits(left, right) {
97
105
  }
98
106
  const byInstallOrder = (left, right) => left.registrationOrder - right.registrationOrder || compareCodeUnits(left.pluginId, right.pluginId) || compareCodeUnits(left.packageDir, right.packageDir);
99
107
  /**
100
- * Deterministic install order with duplicate web slots removed. Different package
101
- * copies survive the build; mount selection resolves shared pluginIds later.
102
- * The native registry is still keyed by pluginId, so it keeps only the first copy.
108
+ * Deterministic install order with duplicate slots removed. Different package
109
+ * copies survive the scan so mount selection can recognize every selected root.
103
110
  */
104
111
  function orderDeclaredPlugins(plugins, onNotice = () => void 0, field = "poWeb") {
105
112
  const sorted = [...plugins].sort(byInstallOrder);
106
113
  const byKey = /* @__PURE__ */ new Map();
107
114
  const kept = [];
108
115
  for (const plugin of sorted) {
109
- const key = field === "poNative" ? plugin.pluginId : plugin.slot;
116
+ const key = plugin.slot;
110
117
  const holder = byKey.get(key);
111
118
  if (holder !== void 0) {
112
- onNotice(`web plugin '${plugin.pluginId}' from ${plugin.packageDir} is skipped: ${holder.packageDir} already declares it.`);
119
+ onNotice(`${field === "poNative" ? "native" : "web"} plugin '${plugin.pluginId}' from ${plugin.packageDir} is skipped: ${holder.packageDir} already declares it.`);
113
120
  continue;
114
121
  }
115
122
  byKey.set(key, plugin);
@@ -1 +1 @@
1
- {"version":3,"file":"webPluginManifest.cjs","names":["fs","path","crypto"],"sources":["../../../../src/builders/web/webPluginManifest.ts"],"sourcesContent":["/**\n * The poWeb manifest vocabulary: how a package declares its web plugin in\n * package.json, validated and ordered; the filesystem is read only to name each\n * copy's slot by its real directory. The\n * scan adapter feeds this from real manifests; the sync bundler feeds it from\n * the installed composition's package roots.\n *\n * Plugins are independent: a manifest names no other plugin, and the order\n * plugins install in is only a tiebreak (registrationOrder, then pluginId),\n * because every relation between two plugins resolves by name once all of\n * them are installed. Web copies keep distinct slots so each mount can select its\n * own package; only repeated declarations of the same slot are dropped. Native\n * plugins still share one pluginId registry. Malformed blocks are scan errors.\n *\n * The native app's poNative blocks share this exact shape, so the same\n * validation reads either field.\n */\n\nimport crypto from 'node:crypto';\nimport fs from 'node:fs';\nimport path from 'node:path';\n\nconst PLUGIN_ID_PATTERN = /^[a-z][a-z0-9]*(-[a-z0-9]+)*$/;\n\n/** The order a plugin installs at when its manifest names none. */\nexport const DEFAULT_REGISTRATION_ORDER = 1000;\n\nexport interface WebPluginEntryDeclaration {\n /** Package-relative ./path to the source entry. */\n entry: string;\n}\n\nexport interface DeclaredWebPlugin {\n pluginId: string;\n /**\n * The registry name of this installed copy: the pluginId for a host plugin, otherwise\n * `${pluginId}.${first 8 hex of sha256(realpath(packageDir))}`, so two copies of one\n * pluginId installed from different directories never share a name.\n */\n slot: string;\n registrationOrder: number;\n packageDir: string;\n packageName: string;\n isHost: boolean;\n client: WebPluginEntryDeclaration;\n scopes: readonly ('global' | 'workspace' | 'session')[];\n}\n\n/** The package.json field a plugin block lives in: the browser cockpit's or the native app's. */\nexport type PluginManifestField = 'poWeb' | 'poNative';\n\nexport class WebPluginManifestError extends Error {\n constructor(packageDir: string, message: string, field: PluginManifestField = 'poWeb') {\n super(`${field} manifest in ${packageDir}: ${message}`);\n this.name = 'WebPluginManifestError';\n }\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\nfunction normalizeEntry(\n packageDir: string,\n kind: string,\n value: unknown,\n field: PluginManifestField,\n): WebPluginEntryDeclaration {\n const raw = typeof value === 'string' ? { entry: value } : value;\n if (!isRecord(raw)) throw new WebPluginManifestError(packageDir, `${kind} must be a path or {entry}.`, field);\n const { entry } = raw;\n if (typeof entry !== 'string' || !entry.startsWith('./') || entry.includes('..')) {\n throw new WebPluginManifestError(\n packageDir,\n `${kind}.entry must be a package-relative ./path with no '..'.`,\n field,\n );\n }\n return { entry };\n}\n\nconst SLOT_HASH_LENGTH = 8;\n\n/** The slot of one installed plugin copy; see DeclaredWebPlugin.slot. */\nexport function pluginSlot(plugin: { pluginId: string; packageDir: string; isHost: boolean }): string {\n if (plugin.isHost) return plugin.pluginId;\n let directory: string;\n try {\n directory = fs.realpathSync(plugin.packageDir);\n } catch {\n // A directory that no longer exists has no real path; its resolved path still names it stably.\n directory = path.resolve(plugin.packageDir);\n }\n const digest = crypto.createHash('sha256').update(directory).digest('hex');\n return `${plugin.pluginId}.${digest.slice(0, SLOT_HASH_LENGTH)}`;\n}\n\n/** The field's value normalized to a list: one plugin object or an array of them. */\nexport function pluginBlocksOf(manifest: Record<string, unknown>, field: PluginManifestField = 'poWeb'): unknown[] {\n const value = manifest[field];\n if (value === undefined) return [];\n return Array.isArray(value) ? value : [value];\n}\n\n/** Validates one manifest's blocks into declared plugins; throws WebPluginManifestError on bad shape. */\nexport function declaredPluginsOf(\n packageDir: string,\n manifest: Record<string, unknown>,\n isHost: boolean,\n field: PluginManifestField = 'poWeb',\n): DeclaredWebPlugin[] {\n const plugins: DeclaredWebPlugin[] = [];\n for (const block of pluginBlocksOf(manifest, field)) {\n if (!isRecord(block)) throw new WebPluginManifestError(packageDir, 'each block must be an object.', field);\n const { pluginId, registrationOrder = DEFAULT_REGISTRATION_ORDER, client, scopes } = block;\n if (\n !Array.isArray(scopes) ||\n scopes.length === 0 ||\n scopes.some((scope) => !['global', 'workspace', 'session'].includes(scope))\n ) {\n throw new WebPluginManifestError(\n packageDir,\n 'scopes must explicitly name global, workspace, or session; resync the plugin.',\n field,\n );\n }\n if (typeof pluginId !== 'string' || !PLUGIN_ID_PATTERN.test(pluginId)) {\n throw new WebPluginManifestError(packageDir, `pluginId '${String(pluginId)}' must be kebab-case.`, field);\n }\n if (!Number.isInteger(registrationOrder) || (registrationOrder as number) < 0) {\n throw new WebPluginManifestError(\n packageDir,\n `'${pluginId}' needs a non-negative integer registrationOrder.`,\n field,\n );\n }\n plugins.push({\n pluginId,\n slot: pluginSlot({ pluginId, packageDir, isHost }),\n registrationOrder: registrationOrder as number,\n packageDir,\n packageName: typeof manifest.name === 'string' ? manifest.name : packageDir,\n isHost,\n client: normalizeEntry(packageDir, 'client', client, field),\n scopes,\n });\n }\n return plugins;\n}\n\n/** Code-unit order, never the locale's: the same packages must order the same on every machine. */\nexport function compareCodeUnits(left: string, right: string): number {\n return left < right ? -1 : left > right ? 1 : 0;\n}\n\nconst byInstallOrder = (left: DeclaredWebPlugin, right: DeclaredWebPlugin): number =>\n left.registrationOrder - right.registrationOrder ||\n compareCodeUnits(left.pluginId, right.pluginId) ||\n compareCodeUnits(left.packageDir, right.packageDir);\n\n/**\n * Deterministic install order with duplicate web slots removed. Different package\n * copies survive the build; mount selection resolves shared pluginIds later.\n * The native registry is still keyed by pluginId, so it keeps only the first copy.\n */\nexport function orderDeclaredPlugins(\n plugins: readonly DeclaredWebPlugin[],\n onNotice: (message: string) => void = () => undefined,\n field: PluginManifestField = 'poWeb',\n): DeclaredWebPlugin[] {\n const sorted = [...plugins].sort(byInstallOrder);\n const byKey = new Map<string, DeclaredWebPlugin>();\n const kept: DeclaredWebPlugin[] = [];\n for (const plugin of sorted) {\n const key = field === 'poNative' ? plugin.pluginId : plugin.slot;\n const holder = byKey.get(key);\n if (holder !== undefined) {\n onNotice(\n `web plugin '${plugin.pluginId}' from ${plugin.packageDir} is skipped: ${holder.packageDir} already declares it.`,\n );\n continue;\n }\n byKey.set(key, plugin);\n kept.push(plugin);\n }\n return kept;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAsBA,MAAM,oBAAoB;;AAG1B,MAAa,6BAA6B;AA0B1C,IAAa,yBAAb,cAA4C,MAAM;CAChD,YAAY,YAAoB,SAAiB,QAA6B,SAAS;EACrF,MAAM,GAAG,MAAM,eAAe,WAAW,IAAI,SAAS;EACtD,KAAK,OAAO;CACd;AACF;AAEA,SAAS,SAAS,OAAkD;CAClE,OAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK;AAC5E;AAEA,SAAS,eACP,YACA,MACA,OACA,OAC2B;CAC3B,MAAM,MAAM,OAAO,UAAU,WAAW,EAAE,OAAO,MAAM,IAAI;CAC3D,IAAI,CAAC,SAAS,GAAG,GAAG,MAAM,IAAI,uBAAuB,YAAY,GAAG,KAAK,8BAA8B,KAAK;CAC5G,MAAM,EAAE,UAAU;CAClB,IAAI,OAAO,UAAU,YAAY,CAAC,MAAM,WAAW,IAAI,KAAK,MAAM,SAAS,IAAI,GAC7E,MAAM,IAAI,uBACR,YACA,GAAG,KAAK,yDACR,KACF;CAEF,OAAO,EAAE,MAAM;AACjB;AAEA,MAAM,mBAAmB;;AAGzB,SAAgB,WAAW,QAA2E;CACpG,IAAI,OAAO,QAAQ,OAAO,OAAO;CACjC,IAAI;CACJ,IAAI;EACF,YAAYA,QAAAA,QAAG,aAAa,OAAO,UAAU;CAC/C,QAAQ;EAEN,YAAYC,UAAAA,QAAK,QAAQ,OAAO,UAAU;CAC5C;CACA,MAAM,SAASC,YAAA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uB;CACpE,OAAO,OAAO,QAAQ,KAAK,OAAO,QAAQ,IAAI;AAChD;AAEA,MAAM,kBAAkB,MAAyB,UAC/C,KAAK,oBAAoB,MAAM,qBAC/B,iBAAiB,KAAK,UAAU,MAAM,QAAQ,KAC9C,iBAAiB,KAAK,YAAY,MAAM,UAAU;;;;;;AAOpD,SAAgB,qBACd,SACA,iBAA4C,KAAA,GAC5C,QAA6B,SACR;CACrB,MAAM,SAAS,CAAC,GAAG,OAAO,CAAC,CAAC,KAAK,cAAc;CAC/C,MAAM,wBAAQ,IAAI,IAA+B;CACjD,MAAM,OAA4B,CAAC;CACnC,KAAK,MAAM,UAAU,QAAQ;EAC3B,MAAM,MAAM,UAAU,aAAa,OAAO,WAAW,OAAO;EAC5D,MAAM,SAAS,MAAM,IAAI,GAAG;EAC5B,IAAI,WAAW,KAAA,GAAW;GACxB,SACE,eAAe,OAAO,SAAS,SAAS,OAAO,WAAW,eAAe,OAAO,WAAW,sBAC7F;GACA;EACF;EACA,MAAM,IAAI,KAAK,MAAM;EACrB,KAAK,KAAK,MAAM;CAClB;CACA,OAAO;AACT"}
1
+ {"version":3,"file":"webPluginManifest.cjs","names":["fs","path","crypto","parsePoWebBrainMetadata"],"sources":["../../../../src/builders/web/webPluginManifest.ts"],"sourcesContent":["/**\n * The poWeb manifest vocabulary: how a package declares its web plugin in\n * package.json, validated and ordered; the filesystem is read only to name each\n * copy's slot by its real directory. The\n * scan adapter feeds this from real manifests; the sync bundler feeds it from\n * the installed composition's package roots.\n *\n * Plugins are independent: a manifest names no other plugin, and the order\n * plugins install in is only a tiebreak (registrationOrder, then pluginId),\n * because every relation between two plugins resolves by name once all of\n * them are installed. Package copies keep distinct slots so each mount can select its\n * own package; only repeated declarations of the same slot are dropped. Native\n * bundling still chooses one module per pluginId after retaining all admission roots.\n *\n * The native app's poNative blocks share this exact shape, so the same\n * validation reads either field.\n */\n\nimport crypto from 'node:crypto';\nimport fs from 'node:fs/promises';\nimport path from 'node:path';\n\nimport { parsePoWebBrainMetadata, type PoWebBrainMetadata } from '@agimon-ai/po-core/serverPlugin';\nconst PLUGIN_ID_PATTERN = /^[a-z][a-z0-9]*(-[a-z0-9]+)*$/;\n\n/** The order a plugin installs at when its manifest names none. */\nexport const DEFAULT_REGISTRATION_ORDER = 1000;\n\nexport interface WebPluginEntryDeclaration {\n /** Package-relative ./path to the source entry. */\n entry: string;\n}\n\nexport interface DeclaredWebPlugin {\n pluginId: string;\n /**\n * The registry name of this installed copy: the pluginId for a host plugin, otherwise\n * `${pluginId}.${first 8 hex of sha256(realpath(packageDir))}`, so two copies of one\n * pluginId installed from different directories never share a name.\n */\n slot: string;\n registrationOrder: number;\n packageDir: string;\n packageName: string;\n isHost: boolean;\n client: WebPluginEntryDeclaration;\n scopes: readonly ('host' | 'workspace' | 'session')[];\n /** Validated descriptive metadata frozen into this exact built plugin generation. */\n brain?: { packageName: string; metadata: PoWebBrainMetadata };\n}\n\n/** The package.json field a plugin block lives in: the browser cockpit's or the native app's. */\nexport type PluginManifestField = 'poWeb' | 'poNative';\n\nexport class WebPluginManifestError extends Error {\n constructor(packageDir: string, message: string, field: PluginManifestField = 'poWeb') {\n super(`${field} manifest in ${packageDir}: ${message}`);\n this.name = 'WebPluginManifestError';\n }\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\nfunction normalizeEntry(\n packageDir: string,\n kind: string,\n value: unknown,\n field: PluginManifestField,\n): WebPluginEntryDeclaration {\n const raw = typeof value === 'string' ? { entry: value } : value;\n if (!isRecord(raw)) throw new WebPluginManifestError(packageDir, `${kind} must be a path or {entry}.`, field);\n const { entry } = raw;\n if (typeof entry !== 'string' || !entry.startsWith('./') || entry.includes('..')) {\n throw new WebPluginManifestError(\n packageDir,\n `${kind}.entry must be a package-relative ./path with no '..'.`,\n field,\n );\n }\n return { entry };\n}\n\nconst SLOT_HASH_LENGTH = 8;\n\n/** The slot of one installed plugin copy; see DeclaredWebPlugin.slot. */\nexport async function pluginSlot(plugin: { pluginId: string; packageDir: string; isHost: boolean }): Promise<string> {\n if (plugin.isHost) return plugin.pluginId;\n let directory: string;\n try {\n directory = await fs.realpath(plugin.packageDir);\n } catch {\n // A directory that no longer exists has no real path; its resolved path still names it stably.\n directory = path.resolve(plugin.packageDir);\n }\n const digest = crypto.createHash('sha256').update(directory).digest('hex');\n return `${plugin.pluginId}.${digest.slice(0, SLOT_HASH_LENGTH)}`;\n}\n\n/** The field's value normalized to a list: one plugin object or an array of them. */\nexport function pluginBlocksOf(manifest: Record<string, unknown>, field: PluginManifestField = 'poWeb'): unknown[] {\n const value = manifest[field];\n if (value === undefined) return [];\n return Array.isArray(value) ? value : [value];\n}\n\n/** Validates one manifest's blocks into declared plugins; throws WebPluginManifestError on bad shape. */\nexport async function declaredPluginsOf(\n packageDir: string,\n manifest: Record<string, unknown>,\n isHost: boolean,\n field: PluginManifestField = 'poWeb',\n): Promise<DeclaredWebPlugin[]> {\n const plugins: DeclaredWebPlugin[] = [];\n for (const block of pluginBlocksOf(manifest, field)) {\n if (!isRecord(block)) throw new WebPluginManifestError(packageDir, 'each block must be an object.', field);\n const { pluginId, registrationOrder = DEFAULT_REGISTRATION_ORDER, client } = block;\n const scopes: unknown = block.scopes;\n if (Array.isArray(scopes) && scopes.includes('global')) {\n throw new WebPluginManifestError(\n packageDir,\n \"The 'global' scope was renamed to 'host'; resync the plugin.\",\n field,\n );\n }\n if (\n !Array.isArray(scopes) ||\n scopes.length === 0 ||\n scopes.some((scope) => !['host', 'workspace', 'session'].includes(scope))\n ) {\n throw new WebPluginManifestError(\n packageDir,\n 'scopes must explicitly name host, workspace, or session; resync the plugin.',\n field,\n );\n }\n if (typeof pluginId !== 'string' || !PLUGIN_ID_PATTERN.test(pluginId)) {\n throw new WebPluginManifestError(packageDir, `pluginId '${String(pluginId)}' must be kebab-case.`, field);\n }\n if (!Number.isInteger(registrationOrder) || (registrationOrder as number) < 0) {\n throw new WebPluginManifestError(\n packageDir,\n `'${pluginId}' needs a non-negative integer registrationOrder.`,\n field,\n );\n }\n const metadata = field === 'poWeb' ? parsePoWebBrainMetadata(block.brain) : undefined;\n plugins.push({\n pluginId,\n slot: await pluginSlot({ pluginId, packageDir, isHost }),\n registrationOrder: registrationOrder as number,\n packageDir,\n packageName: typeof manifest.name === 'string' ? manifest.name : packageDir,\n isHost,\n client: normalizeEntry(packageDir, 'client', client, field),\n scopes,\n ...(metadata && typeof manifest.name === 'string' && /^(?:@[a-z0-9._-]+\\/)?[a-z0-9._-]+$/iu.test(manifest.name)\n ? { brain: { packageName: manifest.name, metadata } }\n : {}),\n });\n }\n return plugins;\n}\n\n/** Code-unit order, never the locale's: the same packages must order the same on every machine. */\nexport function compareCodeUnits(left: string, right: string): number {\n return left < right ? -1 : left > right ? 1 : 0;\n}\n\nconst byInstallOrder = (left: DeclaredWebPlugin, right: DeclaredWebPlugin): number =>\n left.registrationOrder - right.registrationOrder ||\n compareCodeUnits(left.pluginId, right.pluginId) ||\n compareCodeUnits(left.packageDir, right.packageDir);\n\n/**\n * Deterministic install order with duplicate slots removed. Different package\n * copies survive the scan so mount selection can recognize every selected root.\n */\nexport function orderDeclaredPlugins(\n plugins: readonly DeclaredWebPlugin[],\n onNotice: (message: string) => void = () => undefined,\n field: PluginManifestField = 'poWeb',\n): DeclaredWebPlugin[] {\n const sorted = [...plugins].sort(byInstallOrder);\n const byKey = new Map<string, DeclaredWebPlugin>();\n const kept: DeclaredWebPlugin[] = [];\n for (const plugin of sorted) {\n const key = plugin.slot;\n const holder = byKey.get(key);\n if (holder !== undefined) {\n onNotice(\n `${field === 'poNative' ? 'native' : 'web'} plugin '${plugin.pluginId}' from ${plugin.packageDir} is skipped: ${holder.packageDir} already declares it.`,\n );\n continue;\n }\n byKey.set(key, plugin);\n kept.push(plugin);\n }\n return kept;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAuBA,MAAM,oBAAoB;;AAG1B,MAAa,6BAA6B;AA4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O,OAAO,QAAQ,KAAK,OAAO,QAAQ,IAAI;AAChD;AAEA,MAAM,kBAAkB,MAAyB,UAC/C,KAAK,oBAAoB,MAAM,qBAC/B,iBAAiB,KAAK,UAAU,MAAM,QAAQ,KAC9C,iBAAiB,KAAK,YAAY,MAAM,UAAU;;;;;AAMpD,SAAgB,qBACd,SACA,iBAA4C,KAAA,GAC5C,QAA6B,SACR;CACrB,MAAM,SAAS,CAAC,GAAG,OAAO,CAAC,CAAC,KAAK,cAAc;CAC/C,MAAM,wBAAQ,IAAI,IAA+B;CACjD,MAAM,OAA4B,CAAC;CACnC,KAAK,MAAM,UAAU,QAAQ;EAC3B,MAAM,MAAM,OAAO;EACnB,MAAM,SAAS,MAAM,IAAI,GAAG;EAC5B,IAAI,WAAW,KAAA,GAAW;GACxB,SACE,GAAG,UAAU,aAAa,WAAW,MAAM,WAAW,OAAO,SAAS,SAAS,OAAO,WAAW,eAAe,OAAO,WAAW,sBACpI;GACA;EACF;EACA,MAAM,IAAI,KAAK,MAAM;EACrB,KAAK,KAAK,MAAM;CAClB;CACA,OAAO;AACT"}
@@ -1,21 +1,5 @@
1
+ import { PoWebBrainMetadata } from "@agimon-ai/po-core/serverPlugin";
1
2
  //#region src/builders/web/webPluginManifest.d.ts
2
- /**
3
- * The poWeb manifest vocabulary: how a package declares its web plugin in
4
- * package.json, validated and ordered; the filesystem is read only to name each
5
- * copy's slot by its real directory. The
6
- * scan adapter feeds this from real manifests; the sync bundler feeds it from
7
- * the installed composition's package roots.
8
- *
9
- * Plugins are independent: a manifest names no other plugin, and the order
10
- * plugins install in is only a tiebreak (registrationOrder, then pluginId),
11
- * because every relation between two plugins resolves by name once all of
12
- * them are installed. Web copies keep distinct slots so each mount can select its
13
- * own package; only repeated declarations of the same slot are dropped. Native
14
- * plugins still share one pluginId registry. Malformed blocks are scan errors.
15
- *
16
- * The native app's poNative blocks share this exact shape, so the same
17
- * validation reads either field.
18
- */
19
3
  /** The order a plugin installs at when its manifest names none. */
20
4
  export declare const DEFAULT_REGISTRATION_ORDER = 1000;
21
5
  export interface WebPluginEntryDeclaration {
@@ -35,7 +19,12 @@ export interface DeclaredWebPlugin {
35
19
  packageName: string;
36
20
  isHost: boolean;
37
21
  client: WebPluginEntryDeclaration;
38
- scopes: readonly ('global' | 'workspace' | 'session')[];
22
+ scopes: readonly ('host' | 'workspace' | 'session')[];
23
+ /** Validated descriptive metadata frozen into this exact built plugin generation. */
24
+ brain?: {
25
+ packageName: string;
26
+ metadata: PoWebBrainMetadata;
27
+ };
39
28
  }
40
29
  /** The package.json field a plugin block lives in: the browser cockpit's or the native app's. */
41
30
  export type PluginManifestField = 'poWeb' | 'poNative';
@@ -47,17 +36,16 @@ export declare function pluginSlot(plugin: {
47
36
  pluginId: string;
48
37
  packageDir: string;
49
38
  isHost: boolean;
50
- }): string;
39
+ }): Promise<string>;
51
40
  /** The field's value normalized to a list: one plugin object or an array of them. */
52
41
  export declare function pluginBlocksOf(manifest: Record<string, unknown>, field?: PluginManifestField): unknown[];
53
42
  /** Validates one manifest's blocks into declared plugins; throws WebPluginManifestError on bad shape. */
54
- export declare function declaredPluginsOf(packageDir: string, manifest: Record<string, unknown>, isHost: boolean, field?: PluginManifestField): DeclaredWebPlugin[];
43
+ export declare function declaredPluginsOf(packageDir: string, manifest: Record<string, unknown>, isHost: boolean, field?: PluginManifestField): Promise<DeclaredWebPlugin[]>;
55
44
  /** Code-unit order, never the locale's: the same packages must order the same on every machine. */
56
45
  export declare function compareCodeUnits(left: string, right: string): number;
57
46
  /**
58
- * Deterministic install order with duplicate web slots removed. Different package
59
- * copies survive the build; mount selection resolves shared pluginIds later.
60
- * The native registry is still keyed by pluginId, so it keeps only the first copy.
47
+ * Deterministic install order with duplicate slots removed. Different package
48
+ * copies survive the scan so mount selection can recognize every selected root.
61
49
  */
62
50
  export declare function orderDeclaredPlugins(plugins: readonly DeclaredWebPlugin[], onNotice?: (message: string) => void, field?: PluginManifestField): DeclaredWebPlugin[];
63
51
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"webPluginManifest.d.mts","names":[],"sources":["../../../../src/builders/web/webPluginManifest.ts"],"mappings":";;;;;;;;;;;;;;;;;;;qBAyBa;iBAEI;;EAEf;;iBAGe;EACf;;;;;;EAMA;EACA;EACA;EACA;EACA;EACA,QAAQ;EACR;;;YAIU;qBAEC,+BAA+B;EAC1C,YAAY,oBAAoB,iBAAiB,QAAO;;;wBAgC1C,WAAW;EAAU;EAAkB;EAAoB;;;wBAc3D,eAAe,UAAU,yBAAyB,QAAO;;wBAOzD,kBACd,oBACA,UAAU,yBACV,iBACA,QAAO,sBACN;;wBAyCa,iBAAiB,cAAc;;;;;;wBAc/B,qBACd,kBAAkB,qBAClB,YAAW,0BACX,QAAO,sBACN"}
1
+ {"version":3,"file":"webPluginManifest.d.mts","names":[],"sources":["../../../../src/builders/web/webPluginManifest.ts"],"mappings":";;;qBA0Ba;iBAEI;;EAEf;;iBAGe;EACf;;;;;;EAMA;EACA;EACA;EACA;EACA;EACA,QAAQ;EACR;;EAEA;IAAU;IAAqB,UAAU;;;;YAI/B;qBAEC,+BAA+B;EAC1C,YAAY,oBAAoB,iBAAiB,QAAO;;;wBAgCpC,WAAW;EAAU;EAAkB;EAAoB;IAAoB;;wBAcrF,eAAe,UAAU,yBAAyB,QAAO;;wBAOnD,kBACpB,oBACA,UAAU,yBACV,iBACA,QAAO,sBACN,QAAQ;;wBAqDK,iBAAiB,cAAc;;;;;wBAa/B,qBACd,kBAAkB,qBAClB,YAAW,0BACX,QAAO,sBACN"}
@@ -1,5 +1,6 @@
1
- import fs from "node:fs";
2
1
  import path from "node:path";
2
+ import fs from "node:fs/promises";
3
+ import { parsePoWebBrainMetadata } from "@agimon-ai/po-core/serverPlugin";
3
4
  import crypto from "node:crypto";
4
5
  //#region src/builders/web/webPluginManifest.ts
5
6
  /**
@@ -12,9 +13,9 @@ import crypto from "node:crypto";
12
13
  * Plugins are independent: a manifest names no other plugin, and the order
13
14
  * plugins install in is only a tiebreak (registrationOrder, then pluginId),
14
15
  * because every relation between two plugins resolves by name once all of
15
- * them are installed. Web copies keep distinct slots so each mount can select its
16
+ * them are installed. Package copies keep distinct slots so each mount can select its
16
17
  * own package; only repeated declarations of the same slot are dropped. Native
17
- * plugins still share one pluginId registry. Malformed blocks are scan errors.
18
+ * bundling still chooses one module per pluginId after retaining all admission roots.
18
19
  *
19
20
  * The native app's poNative blocks share this exact shape, so the same
20
21
  * validation reads either field.
@@ -40,11 +41,11 @@ function normalizeEntry(packageDir, kind, value, field) {
40
41
  }
41
42
  const SLOT_HASH_LENGTH = 8;
42
43
  /** The slot of one installed plugin copy; see DeclaredWebPlugin.slot. */
43
- function pluginSlot(plugin) {
44
+ async function pluginSlot(plugin) {
44
45
  if (plugin.isHost) return plugin.pluginId;
45
46
  let directory;
46
47
  try {
47
- directory = fs.realpathSync(plugin.packageDir);
48
+ directory = await fs.realpath(plugin.packageDir);
48
49
  } catch {
49
50
  directory = path.resolve(plugin.packageDir);
50
51
  }
@@ -58,21 +59,24 @@ function pluginBlocksOf(manifest, field = "poWeb") {
58
59
  return Array.isArray(value) ? value : [value];
59
60
  }
60
61
  /** Validates one manifest's blocks into declared plugins; throws WebPluginManifestError on bad shape. */
61
- function declaredPluginsOf(packageDir, manifest, isHost, field = "poWeb") {
62
+ async function declaredPluginsOf(packageDir, manifest, isHost, field = "poWeb") {
62
63
  const plugins = [];
63
64
  for (const block of pluginBlocksOf(manifest, field)) {
64
65
  if (!isRecord(block)) throw new WebPluginManifestError(packageDir, "each block must be an object.", field);
65
- const { pluginId, registrationOrder = DEFAULT_REGISTRATION_ORDER, client, scopes } = block;
66
+ const { pluginId, registrationOrder = DEFAULT_REGISTRATION_ORDER, client } = block;
67
+ const scopes = block.scopes;
68
+ if (Array.isArray(scopes) && scopes.includes("global")) throw new WebPluginManifestError(packageDir, "The 'global' scope was renamed to 'host'; resync the plugin.", field);
66
69
  if (!Array.isArray(scopes) || scopes.length === 0 || scopes.some((scope) => ![
67
- "global",
70
+ "host",
68
71
  "workspace",
69
72
  "session"
70
- ].includes(scope))) throw new WebPluginManifestError(packageDir, "scopes must explicitly name global, workspace, or session; resync the plugin.", field);
73
+ ].includes(scope))) throw new WebPluginManifestError(packageDir, "scopes must explicitly name host, workspace, or session; resync the plugin.", field);
71
74
  if (typeof pluginId !== "string" || !PLUGIN_ID_PATTERN.test(pluginId)) throw new WebPluginManifestError(packageDir, `pluginId '${String(pluginId)}' must be kebab-case.`, field);
72
75
  if (!Number.isInteger(registrationOrder) || registrationOrder < 0) throw new WebPluginManifestError(packageDir, `'${pluginId}' needs a non-negative integer registrationOrder.`, field);
76
+ const metadata = field === "poWeb" ? parsePoWebBrainMetadata(block.brain) : void 0;
73
77
  plugins.push({
74
78
  pluginId,
75
- slot: pluginSlot({
79
+ slot: await pluginSlot({
76
80
  pluginId,
77
81
  packageDir,
78
82
  isHost
@@ -82,7 +86,11 @@ function declaredPluginsOf(packageDir, manifest, isHost, field = "poWeb") {
82
86
  packageName: typeof manifest.name === "string" ? manifest.name : packageDir,
83
87
  isHost,
84
88
  client: normalizeEntry(packageDir, "client", client, field),
85
- scopes
89
+ scopes,
90
+ ...metadata && typeof manifest.name === "string" && /^(?:@[a-z0-9._-]+\/)?[a-z0-9._-]+$/iu.test(manifest.name) ? { brain: {
91
+ packageName: manifest.name,
92
+ metadata
93
+ } } : {}
86
94
  });
87
95
  }
88
96
  return plugins;
@@ -93,19 +101,18 @@ function compareCodeUnits(left, right) {
93
101
  }
94
102
  const byInstallOrder = (left, right) => left.registrationOrder - right.registrationOrder || compareCodeUnits(left.pluginId, right.pluginId) || compareCodeUnits(left.packageDir, right.packageDir);
95
103
  /**
96
- * Deterministic install order with duplicate web slots removed. Different package
97
- * copies survive the build; mount selection resolves shared pluginIds later.
98
- * The native registry is still keyed by pluginId, so it keeps only the first copy.
104
+ * Deterministic install order with duplicate slots removed. Different package
105
+ * copies survive the scan so mount selection can recognize every selected root.
99
106
  */
100
107
  function orderDeclaredPlugins(plugins, onNotice = () => void 0, field = "poWeb") {
101
108
  const sorted = [...plugins].sort(byInstallOrder);
102
109
  const byKey = /* @__PURE__ */ new Map();
103
110
  const kept = [];
104
111
  for (const plugin of sorted) {
105
- const key = field === "poNative" ? plugin.pluginId : plugin.slot;
112
+ const key = plugin.slot;
106
113
  const holder = byKey.get(key);
107
114
  if (holder !== void 0) {
108
- onNotice(`web plugin '${plugin.pluginId}' from ${plugin.packageDir} is skipped: ${holder.packageDir} already declares it.`);
115
+ onNotice(`${field === "poNative" ? "native" : "web"} plugin '${plugin.pluginId}' from ${plugin.packageDir} is skipped: ${holder.packageDir} already declares it.`);
109
116
  continue;
110
117
  }
111
118
  byKey.set(key, plugin);
@@ -1 +1 @@
1
- {"version":3,"file":"webPluginManifest.mjs","names":[],"sources":["../../../../src/builders/web/webPluginManifest.ts"],"sourcesContent":["/**\n * The poWeb manifest vocabulary: how a package declares its web plugin in\n * package.json, validated and ordered; the filesystem is read only to name each\n * copy's slot by its real directory. The\n * scan adapter feeds this from real manifests; the sync bundler feeds it from\n * the installed composition's package roots.\n *\n * Plugins are independent: a manifest names no other plugin, and the order\n * plugins install in is only a tiebreak (registrationOrder, then pluginId),\n * because every relation between two plugins resolves by name once all of\n * them are installed. Web copies keep distinct slots so each mount can select its\n * own package; only repeated declarations of the same slot are dropped. Native\n * plugins still share one pluginId registry. Malformed blocks are scan errors.\n *\n * The native app's poNative blocks share this exact shape, so the same\n * validation reads either field.\n */\n\nimport crypto from 'node:crypto';\nimport fs from 'node:fs';\nimport path from 'node:path';\n\nconst PLUGIN_ID_PATTERN = /^[a-z][a-z0-9]*(-[a-z0-9]+)*$/;\n\n/** The order a plugin installs at when its manifest names none. */\nexport const DEFAULT_REGISTRATION_ORDER = 1000;\n\nexport interface WebPluginEntryDeclaration {\n /** Package-relative ./path to the source entry. */\n entry: string;\n}\n\nexport interface DeclaredWebPlugin {\n pluginId: string;\n /**\n * The registry name of this installed copy: the pluginId for a host plugin, otherwise\n * `${pluginId}.${first 8 hex of sha256(realpath(packageDir))}`, so two copies of one\n * pluginId installed from different directories never share a name.\n */\n slot: string;\n registrationOrder: number;\n packageDir: string;\n packageName: string;\n isHost: boolean;\n client: WebPluginEntryDeclaration;\n scopes: readonly ('global' | 'workspace' | 'session')[];\n}\n\n/** The package.json field a plugin block lives in: the browser cockpit's or the native app's. */\nexport type PluginManifestField = 'poWeb' | 'poNative';\n\nexport class WebPluginManifestError extends Error {\n constructor(packageDir: string, message: string, field: PluginManifestField = 'poWeb') {\n super(`${field} manifest in ${packageDir}: ${message}`);\n this.name = 'WebPluginManifestError';\n }\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\nfunction normalizeEntry(\n packageDir: string,\n kind: string,\n value: unknown,\n field: PluginManifestField,\n): WebPluginEntryDeclaration {\n const raw = typeof value === 'string' ? { entry: value } : value;\n if (!isRecord(raw)) throw new WebPluginManifestError(packageDir, `${kind} must be a path or {entry}.`, field);\n const { entry } = raw;\n if (typeof entry !== 'string' || !entry.startsWith('./') || entry.includes('..')) {\n throw new WebPluginManifestError(\n packageDir,\n `${kind}.entry must be a package-relative ./path with no '..'.`,\n field,\n );\n }\n return { entry };\n}\n\nconst SLOT_HASH_LENGTH = 8;\n\n/** The slot of one installed plugin copy; see DeclaredWebPlugin.slot. */\nexport function pluginSlot(plugin: { pluginId: string; packageDir: string; isHost: boolean }): string {\n if (plugin.isHost) return plugin.pluginId;\n let directory: string;\n try {\n directory = fs.realpathSync(plugin.packageDir);\n } catch {\n // A directory that no longer exists has no real path; its resolved path still names it stably.\n directory = path.resolve(plugin.packageDir);\n }\n const digest = crypto.createHash('sha256').update(directory).digest('hex');\n return `${plugin.pluginId}.${digest.slice(0, SLOT_HASH_LENGTH)}`;\n}\n\n/** The field's value normalized to a list: one plugin object or an array of them. */\nexport function pluginBlocksOf(manifest: Record<string, unknown>, field: PluginManifestField = 'poWeb'): unknown[] {\n const value = manifest[field];\n if (value === undefined) return [];\n return Array.isArray(value) ? value : [value];\n}\n\n/** Validates one manifest's blocks into declared plugins; throws WebPluginManifestError on bad shape. */\nexport function declaredPluginsOf(\n packageDir: string,\n manifest: Record<string, unknown>,\n isHost: boolean,\n field: PluginManifestField = 'poWeb',\n): DeclaredWebPlugin[] {\n const plugins: DeclaredWebPlugin[] = [];\n for (const block of pluginBlocksOf(manifest, field)) {\n if (!isRecord(block)) throw new WebPluginManifestError(packageDir, 'each block must be an object.', field);\n const { pluginId, registrationOrder = DEFAULT_REGISTRATION_ORDER, client, scopes } = block;\n if (\n !Array.isArray(scopes) ||\n scopes.length === 0 ||\n scopes.some((scope) => !['global', 'workspace', 'session'].includes(scope))\n ) {\n throw new WebPluginManifestError(\n packageDir,\n 'scopes must explicitly name global, workspace, or session; resync the plugin.',\n field,\n );\n }\n if (typeof pluginId !== 'string' || !PLUGIN_ID_PATTERN.test(pluginId)) {\n throw new WebPluginManifestError(packageDir, `pluginId '${String(pluginId)}' must be kebab-case.`, field);\n }\n if (!Number.isInteger(registrationOrder) || (registrationOrder as number) < 0) {\n throw new WebPluginManifestError(\n packageDir,\n `'${pluginId}' needs a non-negative integer registrationOrder.`,\n field,\n );\n }\n plugins.push({\n pluginId,\n slot: pluginSlot({ pluginId, packageDir, isHost }),\n registrationOrder: registrationOrder as number,\n packageDir,\n packageName: typeof manifest.name === 'string' ? manifest.name : packageDir,\n isHost,\n client: normalizeEntry(packageDir, 'client', client, field),\n scopes,\n });\n }\n return plugins;\n}\n\n/** Code-unit order, never the locale's: the same packages must order the same on every machine. */\nexport function compareCodeUnits(left: string, right: string): number {\n return left < right ? -1 : left > right ? 1 : 0;\n}\n\nconst byInstallOrder = (left: DeclaredWebPlugin, right: DeclaredWebPlugin): number =>\n left.registrationOrder - right.registrationOrder ||\n compareCodeUnits(left.pluginId, right.pluginId) ||\n compareCodeUnits(left.packageDir, right.packageDir);\n\n/**\n * Deterministic install order with duplicate web slots removed. Different package\n * copies survive the build; mount selection resolves shared pluginIds later.\n * The native registry is still keyed by pluginId, so it keeps only the first copy.\n */\nexport function orderDeclaredPlugins(\n plugins: readonly DeclaredWebPlugin[],\n onNotice: (message: string) => void = () => undefined,\n field: PluginManifestField = 'poWeb',\n): DeclaredWebPlugin[] {\n const sorted = [...plugins].sort(byInstallOrder);\n const byKey = new Map<string, DeclaredWebPlugin>();\n const kept: DeclaredWebPlugin[] = [];\n for (const plugin of sorted) {\n const key = field === 'poNative' ? plugin.pluginId : plugin.slot;\n const holder = byKey.get(key);\n if (holder !== undefined) {\n onNotice(\n `web plugin '${plugin.pluginId}' from ${plugin.packageDir} is skipped: ${holder.packageDir} already declares it.`,\n );\n continue;\n }\n byKey.set(key, plugin);\n kept.push(plugin);\n }\n return kept;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAsBA,MAAM,oBAAoB;;AAG1B,MAAa,6BAA6B;AA0B1C,IAAa,yBAAb,cAA4C,MAAM;CAChD,YAAY,YAAoB,SAAiB,QAA6B,SAAS;EACrF,MAAM,GAAG,MAAM,eAAe,WAAW,IAAI,SAAS;EACtD,KAAK,OAAO;CACd;AACF;AAEA,SAAS,SAAS,OAAkD;CAClE,OAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK;AAC5E;AAEA,SAAS,eACP,YACA,MACA,OACA,OAC2B;CAC3B,MAAM,MAAM,OAAO,UAAU,WAAW,EAAE,OAAO,MAAM,IAAI;CAC3D,IAAI,CAAC,SAAS,GAAG,GAAG,MAAM,IAAI,uBAAuB,YAAY,GAAG,KAAK,8BAA8B,KAAK;CAC5G,MAAM,EAAE,UAAU;CAClB,IAAI,OAAO,UAAU,YAAY,CAAC,MAAM,WAAW,IAAI,KAAK,MAAM,SAAS,IAAI,GAC7E,MAAM,IAAI,uBACR,YACA,GAAG,KAAK,yDACR,KACF;CAEF,OAAO,EAAE,MAAM;AACjB;AAEA,MAAM,mBAAmB;;AAGzB,SAAgB,WAAW,QAA2E;CACpG,I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aAAa,OAAO,SAAS,SAAS,WAAW,SAAS,OAAO;GACjE;GACA,QAAQ,eAAe,YAAY,UAAU,QAAQ,KAAK;GAC1D;EACF,CAAC;CACH;CACA,OAAO;AACT;;AAGA,SAAgB,iBAAiB,MAAc,OAAuB;CACpE,OAAO,OAAO,QAAQ,KAAK,OAAO,QAAQ,IAAI;AAChD;AAEA,MAAM,kBAAkB,MAAyB,UAC/C,KAAK,oBAAoB,MAAM,qBAC/B,iBAAiB,KAAK,UAAU,MAAM,QAAQ,KAC9C,iBAAiB,KAAK,YAAY,MAAM,UAAU;;;;;;AAOpD,SAAgB,qBACd,SACA,iBAA4C,KAAA,GAC5C,QAA6B,SACR;CACrB,MAAM,SAAS,CAAC,GAAG,OAAO,CAAC,CAAC,KAAK,cAAc;CAC/C,MAAM,wBAAQ,IAAI,IAA+B;CACjD,MAAM,OAA4B,CAAC;CACnC,KAAK,MAAM,UAAU,QAAQ;EAC3B,MAAM,MAAM,UAAU,aAAa,OAAO,WAAW,OAAO;EAC5D,MAAM,SAAS,MAAM,IAAI,GAAG;EAC5B,IAAI,WAAW,KAAA,GAAW;GACxB,SACE,eAAe,OAAO,SAAS,SAAS,OAAO,WAAW,eAAe,OAAO,WAAW,sBAC7F;GACA;EACF;EACA,MAAM,IAAI,KAAK,MAAM;EACrB,KAAK,KAAK,MAAM;CAClB;CACA,OAAO;AACT"}
1
+ {"version":3,"file":"webPluginManifest.mjs","names":[],"sources":["../../../../src/builders/web/webPluginManifest.ts"],"sourcesContent":["/**\n * The poWeb manifest vocabulary: how a package declares its web plugin in\n * package.json, validated and ordered; the filesystem is read only to name each\n * copy's slot by its real directory. The\n * scan adapter feeds this from real manifests; the sync bundler feeds it from\n * the installed composition's package roots.\n *\n * Plugins are independent: a manifest names no other plugin, and the order\n * plugins install in is only a tiebreak (registrationOrder, then pluginId),\n * because every relation between two plugins resolves by name once all of\n * them are installed. Package copies keep distinct slots so each mount can select its\n * own package; only repeated declarations of the same slot are dropped. Native\n * bundling still chooses one module per pluginId after retaining all admission roots.\n *\n * The native app's poNative blocks share this exact shape, so the same\n * validation reads either field.\n */\n\nimport crypto from 'node:crypto';\nimport fs from 'node:fs/promises';\nimport path from 'node:path';\n\nimport { parsePoWebBrainMetadata, type PoWebBrainMetadata } from '@agimon-ai/po-core/serverPlugin';\nconst PLUGIN_ID_PATTERN = /^[a-z][a-z0-9]*(-[a-z0-9]+)*$/;\n\n/** The order a plugin installs at when its manifest names none. */\nexport const DEFAULT_REGISTRATION_ORDER = 1000;\n\nexport interface WebPluginEntryDeclaration {\n /** Package-relative ./path to the source entry. */\n entry: string;\n}\n\nexport interface DeclaredWebPlugin {\n pluginId: string;\n /**\n * The registry name of this installed copy: the pluginId for a host plugin, otherwise\n * `${pluginId}.${first 8 hex of sha256(realpath(packageDir))}`, so two copies of one\n * pluginId installed from different directories never share a name.\n */\n slot: string;\n registrationOrder: number;\n packageDir: string;\n packageName: string;\n isHost: boolean;\n client: WebPluginEntryDeclaration;\n scopes: readonly ('host' | 'workspace' | 'session')[];\n /** Validated descriptive metadata frozen into this exact built plugin generation. */\n brain?: { packageName: string; metadata: PoWebBrainMetadata };\n}\n\n/** The package.json field a plugin block lives in: the browser cockpit's or the native app's. */\nexport type PluginManifestField = 'poWeb' | 'poNative';\n\nexport class WebPluginManifestError extends Error {\n constructor(packageDir: string, message: string, field: PluginManifestField = 'poWeb') {\n super(`${field} manifest in ${packageDir}: ${message}`);\n this.name = 'WebPluginManifestError';\n }\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\nfunction normalizeEntry(\n packageDir: string,\n kind: string,\n value: unknown,\n field: PluginManifestField,\n): WebPluginEntryDeclaration {\n const raw = typeof value === 'string' ? { entry: value } : value;\n if (!isRecord(raw)) throw new WebPluginManifestError(packageDir, `${kind} must be a path or {entry}.`, field);\n const { entry } = raw;\n if (typeof entry !== 'string' || !entry.startsWith('./') || entry.includes('..')) {\n throw new WebPluginManifestError(\n packageDir,\n `${kind}.entry must be a package-relative ./path with no '..'.`,\n field,\n );\n }\n return { entry };\n}\n\nconst SLOT_HASH_LENGTH = 8;\n\n/** The slot of one installed plugin copy; see DeclaredWebPlugin.slot. */\nexport async function pluginSlot(plugin: { pluginId: string; packageDir: string; isHost: boolean }): Promise<string> {\n if (plugin.isHost) return plugin.pluginId;\n let directory: string;\n try {\n directory = await fs.realpath(plugin.packageDir);\n } catch {\n // A directory that no longer exists has no real path; its resolved path still names it stably.\n directory = path.resolve(plugin.packageDir);\n }\n const digest = crypto.createHash('sha256').update(directory).digest('hex');\n return `${plugin.pluginId}.${digest.slice(0, SLOT_HASH_LENGTH)}`;\n}\n\n/** The field's value normalized to a list: one plugin object or an array of them. */\nexport function pluginBlocksOf(manifest: Record<string, unknown>, field: PluginManifestField = 'poWeb'): unknown[] {\n const value = manifest[field];\n if (value === undefined) return [];\n return Array.isArray(value) ? value : [value];\n}\n\n/** Validates one manifest's blocks into declared plugins; throws WebPluginManifestError on bad shape. */\nexport async function declaredPluginsOf(\n packageDir: string,\n manifest: Record<string, unknown>,\n isHost: boolean,\n field: PluginManifestField = 'poWeb',\n): Promise<DeclaredWebPlugin[]> {\n const plugins: DeclaredWebPlugin[] = [];\n for (const block of pluginBlocksOf(manifest, field)) {\n if (!isRecord(block)) throw new WebPluginManifestError(packageDir, 'each block must be an object.', field);\n const { pluginId, registrationOrder = DEFAULT_REGISTRATION_ORDER, client } = block;\n const scopes: unknown = block.scopes;\n if (Array.isArray(scopes) && scopes.includes('global')) {\n throw new WebPluginManifestError(\n packageDir,\n \"The 'global' scope was renamed to 'host'; resync the plugin.\",\n field,\n );\n }\n if (\n !Array.isArray(scopes) ||\n scopes.length === 0 ||\n scopes.some((scope) => !['host', 'workspace', 'session'].includes(scope))\n ) {\n throw new WebPluginManifestError(\n packageDir,\n 'scopes must explicitly name host, workspace, or session; resync the plugin.',\n field,\n );\n }\n if (typeof pluginId !== 'string' || !PLUGIN_ID_PATTERN.test(pluginId)) {\n throw new WebPluginManifestError(packageDir, `pluginId '${String(pluginId)}' must be kebab-case.`, field);\n }\n if (!Number.isInteger(registrationOrder) || (registrationOrder as number) < 0) {\n throw new WebPluginManifestError(\n packageDir,\n `'${pluginId}' needs a non-negative integer registrationOrder.`,\n field,\n );\n }\n const metadata = field === 'poWeb' ? parsePoWebBrainMetadata(block.brain) : undefined;\n plugins.push({\n pluginId,\n slot: await pluginSlot({ pluginId, packageDir, isHost }),\n registrationOrder: registrationOrder as number,\n packageDir,\n packageName: typeof manifest.name === 'string' ? manifest.name : packageDir,\n isHost,\n client: normalizeEntry(packageDir, 'client', client, field),\n scopes,\n ...(metadata && typeof manifest.name === 'string' && /^(?:@[a-z0-9._-]+\\/)?[a-z0-9._-]+$/iu.test(manifest.name)\n ? { brain: { packageName: manifest.name, metadata } }\n : {}),\n });\n }\n return plugins;\n}\n\n/** Code-unit order, never the locale's: the same packages must order the same on every machine. */\nexport function compareCodeUnits(left: string, right: string): number {\n return left < right ? -1 : left > right ? 1 : 0;\n}\n\nconst byInstallOrder = (left: DeclaredWebPlugin, right: DeclaredWebPlugin): number =>\n left.registrationOrder - right.registrationOrder ||\n compareCodeUnits(left.pluginId, right.pluginId) ||\n compareCodeUnits(left.packageDir, right.packageDir);\n\n/**\n * Deterministic install order with duplicate slots removed. Different package\n * copies survive the scan so mount selection can recognize every selected root.\n */\nexport function orderDeclaredPlugins(\n plugins: readonly DeclaredWebPlugin[],\n onNotice: (message: string) => void = () => undefined,\n field: PluginManifestField = 'poWeb',\n): DeclaredWebPlugin[] {\n const sorted = [...plugins].sort(byInstallOrder);\n const byKey = new Map<string, DeclaredWebPlugin>();\n const kept: DeclaredWebPlugin[] = [];\n for (const plugin of sorted) {\n const key = plugin.slot;\n const holder = byKey.get(key);\n if (holder !== undefined) {\n onNotice(\n `${field === 'poNative' ? 'native' : 'web'} plugin '${plugin.pluginId}' from ${plugin.packageDir} is skipped: ${holder.packageDir} already declares it.`,\n );\n continue;\n }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AAC;EACP,CAAC;CACH;CACA,OAAO;AACT;;AAGA,SAAgB,iBAAiB,MAAc,OAAuB;CACpE,OAAO,OAAO,QAAQ,KAAK,OAAO,QAAQ,IAAI;AAChD;AAEA,MAAM,kBAAkB,MAAyB,UAC/C,KAAK,oBAAoB,MAAM,qBAC/B,iBAAiB,KAAK,UAAU,MAAM,QAAQ,KAC9C,iBAAiB,KAAK,YAAY,MAAM,UAAU;;;;;AAMpD,SAAgB,qBACd,SACA,iBAA4C,KAAA,GAC5C,QAA6B,SACR;CACrB,MAAM,SAAS,CAAC,GAAG,OAAO,CAAC,CAAC,KAAK,cAAc;CAC/C,MAAM,wBAAQ,IAAI,IAA+B;CACjD,MAAM,OAA4B,CAAC;CACnC,KAAK,MAAM,UAAU,QAAQ;EAC3B,MAAM,MAAM,OAAO;EACnB,MAAM,SAAS,MAAM,IAAI,GAAG;EAC5B,IAAI,WAAW,KAAA,GAAW;GACxB,SACE,GAAG,UAAU,aAAa,WAAW,MAAM,WAAW,OAAO,SAAS,SAAS,OAAO,WAAW,eAAe,OAAO,WAAW,sBACpI;GACA;EACF;EACA,MAAM,IAAI,KAAK,MAAM;EACrB,KAAK,KAAK,MAAM;CAClB;CACA,OAAO;AACT"}
@@ -1,9 +1,9 @@
1
1
  const require_runtime = require("../../../_virtual/_rolldown/runtime.cjs");
2
2
  const require_webPluginManifest = require("./webPluginManifest.cjs");
3
- let node_fs = require("node:fs");
4
- node_fs = require_runtime.__toESM(node_fs, 1);
5
3
  let node_path = require("node:path");
6
4
  node_path = require_runtime.__toESM(node_path, 1);
5
+ let node_fs_promises = require("node:fs/promises");
6
+ node_fs_promises = require_runtime.__toESM(node_fs_promises, 1);
7
7
  //#region src/builders/web/webPluginScan.ts
8
8
  /**
9
9
  * Reads poWeb declarations from explicit package roots.
@@ -19,7 +19,7 @@ node_path = require_runtime.__toESM(node_path, 1);
19
19
  * `field` selects poNative for the native composition, which has no host
20
20
  * package: pass `undefined` as `hostDir` and only the plugin roots are read.
21
21
  */
22
- function scanWebPlugins(hostDir, pluginRoots = [], onNotice = () => void 0, field = "poWeb") {
22
+ async function scanWebPlugins(hostDir, pluginRoots = [], onNotice = () => void 0, field = "poWeb") {
23
23
  const seen = /* @__PURE__ */ new Set();
24
24
  const plugins = [];
25
25
  const hostResolved = hostDir === void 0 ? void 0 : node_path.default.resolve(hostDir);
@@ -29,7 +29,7 @@ function scanWebPlugins(hostDir, pluginRoots = [], onNotice = () => void 0, fiel
29
29
  if (seen.has(resolved)) continue;
30
30
  seen.add(resolved);
31
31
  try {
32
- plugins.push(...declaredPluginsIn(resolved, resolved === hostResolved, field));
32
+ plugins.push(...await declaredPluginsIn(resolved, resolved === hostResolved, field));
33
33
  } catch (error) {
34
34
  if (resolved === hostResolved) throw error;
35
35
  onNotice(`${kind} plugin package ${resolved} skipped: ${error instanceof require_webPluginManifest.WebPluginManifestError ? error.message : String(error)}`);
@@ -37,17 +37,20 @@ function scanWebPlugins(hostDir, pluginRoots = [], onNotice = () => void 0, fiel
37
37
  }
38
38
  return require_webPluginManifest.orderDeclaredPlugins(plugins, onNotice, field);
39
39
  }
40
- function declaredPluginsIn(resolved, isHost, field) {
40
+ async function declaredPluginsIn(resolved, isHost, field) {
41
41
  let manifest;
42
42
  try {
43
- manifest = JSON.parse(node_fs.default.readFileSync(node_path.default.join(resolved, "package.json"), "utf8"));
43
+ manifest = JSON.parse(await node_fs_promises.default.readFile(node_path.default.join(resolved, "package.json"), "utf8"));
44
44
  } catch (error) {
45
45
  throw new require_webPluginManifest.WebPluginManifestError(resolved, `package.json is unreadable: ${String(error)}`, field);
46
46
  }
47
- const declared = require_webPluginManifest.declaredPluginsOf(resolved, manifest, isHost, field);
47
+ const declared = await require_webPluginManifest.declaredPluginsOf(resolved, manifest, isHost, field);
48
48
  for (const plugin of declared) {
49
49
  const entryPath = node_path.default.join(resolved, plugin.client.entry);
50
- if (!node_fs.default.existsSync(entryPath)) throw new require_webPluginManifest.WebPluginManifestError(resolved, `client.entry '${plugin.client.entry}' does not exist.`, field);
50
+ await node_fs_promises.default.access(entryPath).catch((error) => {
51
+ if (error.code === "ENOENT") throw new require_webPluginManifest.WebPluginManifestError(resolved, `client.entry '${plugin.client.entry}' does not exist.`, field);
52
+ throw error;
53
+ });
51
54
  }
52
55
  return declared;
53
56
  }
@@ -1 +1 @@
1
- {"version":3,"file":"webPluginScan.cjs","names":["path","WebPluginManifestError","orderDeclaredPlugins","fs","declaredPluginsOf"],"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,IAAYA,UAAAA,QAAK,QAAQ,OAAO;CAC7E,MAAM,OAAO,UAAU,aAAa,WAAW;CAC/C,KAAK,MAAM,QAAQ,YAAY,KAAA,IAAY,cAAc,CAAC,SAAS,GAAG,WAAW,GAAG;EAClF,MAAM,WAAWA,UAAAA,QAAK,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,iBAAiBC,0BAAAA,yBAAyB,MAAM,UAAU,OAAO,KAAK,GACrB;EAClE;CACF;CACA,OAAOC,0BAAAA,qBAAqB,SAAS,UAAU,KAAK;AACtD;AAEA,SAAS,kBAAkB,UAAkB,QAAiB,OAAiD;CAC7G,IAAI;CACJ,IAAI;EACF,WAAW,KAAK,MAAMC,QAAAA,QAAG,aAAaH,UAAAA,QAAK,KAAK,UAAU,cAAc,GAAG,MAAM,CAAC;CACpF,SAAS,OAAO;EACd,MAAM,IAAIC,0BAAAA,uBAAuB,UAAU,+BAA+B,OAAO,KAAK,KAAK,KAAK;CAClG;CACA,MAAM,WAAWG,0BAAAA,kBAAkB,UAAU,UAAU,QAAQ,KAAK;CACpE,KAAK,MAAM,UAAU,UAAU;EAC7B,MAAM,YAAYJ,UAAAA,QAAK,KAAK,UAAU,OAAO,OAAO,KAAK;EACzD,IAAI,CAACG,QAAAA,QAAG,WAAW,SAAS,GAC1B,MAAM,IAAIF,0BAAAA,uBAAuB,UAAU,iBAAiB,OAAO,OAAO,MAAM,oBAAoB,KAAK;CAE7G;CACA,OAAO;AACT"}
1
+ {"version":3,"file":"webPluginScan.cjs","names":["path","WebPluginManifestError","orderDeclaredPlugins","fs","declaredPluginsOf"],"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,IAAYA,UAAAA,QAAK,QAAQ,OAAO;CAC7E,MAAM,OAAO,UAAU,aAAa,WAAW;CAC/C,KAAK,MAAM,QAAQ,YAAY,KAAA,IAAY,cAAc,CAAC,SAAS,GAAG,WAAW,GAAG;EAClF,MAAM,WAAWA,UAAAA,QAAK,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,iBAAiBC,0BAAAA,yBAAyB,MAAM,UAAU,OAAO,KAAK,GACrB;EAClE;CACF;CACA,OAAOC,0BAAAA,qBAAqB,SAAS,UAAU,KAAK;AACtD;AAEA,eAAe,kBACb,UACA,QACA,OAC8B;CAC9B,IAAI;CACJ,IAAI;EACF,WAAW,KAAK,MAAM,MAAMC,iBAAAA,QAAG,SAASH,UAAAA,QAAK,KAAK,UAAU,cAAc,GAAG,MAAM,CAAC;CACtF,SAAS,OAAO;EACd,MAAM,IAAIC,0BAAAA,uBAAuB,UAAU,+BAA+B,OAAO,KAAK,KAAK,KAAK;CAClG;CACA,MAAM,WAAW,MAAMG,0BAAAA,kBAAkB,UAAU,UAAU,QAAQ,KAAK;CAC1E,KAAK,MAAM,UAAU,UAAU;EAC7B,MAAM,YAAYJ,UAAAA,QAAK,KAAK,UAAU,OAAO,OAAO,KAAK;EACzD,MAAMG,iBAAAA,QAAG,OAAO,SAAS,CAAC,CAAC,OAAO,UAAiC;GACjE,IAAI,MAAM,SAAS,UACjB,MAAM,IAAIF,0BAAAA,uBAAuB,UAAU,iBAAiB,OAAO,OAAO,MAAM,oBAAoB,KAAK;GAC3G,MAAM;EACR,CAAC;CACH;CACA,OAAO;AACT"}
@@ -14,6 +14,6 @@ import { DeclaredWebPlugin, PluginManifestField } from "./webPluginManifest.mjs"
14
14
  * `field` selects poNative for the native composition, which has no host
15
15
  * package: pass `undefined` as `hostDir` and only the plugin roots are read.
16
16
  */
17
- export declare function scanWebPlugins(hostDir: string | undefined, pluginRoots?: readonly string[], onNotice?: (message: string) => void, field?: PluginManifestField): DeclaredWebPlugin[];
17
+ export declare function scanWebPlugins(hostDir: string | undefined, pluginRoots?: readonly string[], onNotice?: (message: string) => void, field?: PluginManifestField): Promise<DeclaredWebPlugin[]>;
18
18
  //#endregion
19
19
  //# sourceMappingURL=webPluginScan.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"webPluginScan.d.mts","names":[],"sources":["../../../../src/builders/web/webPluginScan.ts"],"mappings":";;;;;;;;;;;;;;;;wBAyBgB,eACd,6BACA,iCACA,YAAW,0BACX,QAAO,sBACN"}
1
+ {"version":3,"file":"webPluginScan.d.mts","names":[],"sources":["../../../../src/builders/web/webPluginScan.ts"],"mappings":";;;;;;;;;;;;;;;;wBAyBsB,eACpB,6BACA,iCACA,YAAW,0BACX,QAAO,sBACN,QAAQ"}
@@ -1,6 +1,6 @@
1
1
  import { WebPluginManifestError, declaredPluginsOf, orderDeclaredPlugins } from "./webPluginManifest.mjs";
2
- import fs from "node:fs";
3
2
  import path from "node:path";
3
+ import fs from "node:fs/promises";
4
4
  //#region src/builders/web/webPluginScan.ts
5
5
  /**
6
6
  * Reads poWeb declarations from explicit package roots.
@@ -16,7 +16,7 @@ import path from "node:path";
16
16
  * `field` selects poNative for the native composition, which has no host
17
17
  * package: pass `undefined` as `hostDir` and only the plugin roots are read.
18
18
  */
19
- function scanWebPlugins(hostDir, pluginRoots = [], onNotice = () => void 0, field = "poWeb") {
19
+ async function scanWebPlugins(hostDir, pluginRoots = [], onNotice = () => void 0, field = "poWeb") {
20
20
  const seen = /* @__PURE__ */ new Set();
21
21
  const plugins = [];
22
22
  const hostResolved = hostDir === void 0 ? void 0 : path.resolve(hostDir);
@@ -26,7 +26,7 @@ function scanWebPlugins(hostDir, pluginRoots = [], onNotice = () => void 0, fiel
26
26
  if (seen.has(resolved)) continue;
27
27
  seen.add(resolved);
28
28
  try {
29
- plugins.push(...declaredPluginsIn(resolved, resolved === hostResolved, field));
29
+ plugins.push(...await declaredPluginsIn(resolved, resolved === hostResolved, field));
30
30
  } catch (error) {
31
31
  if (resolved === hostResolved) throw error;
32
32
  onNotice(`${kind} plugin package ${resolved} skipped: ${error instanceof WebPluginManifestError ? error.message : String(error)}`);
@@ -34,17 +34,20 @@ function scanWebPlugins(hostDir, pluginRoots = [], onNotice = () => void 0, fiel
34
34
  }
35
35
  return orderDeclaredPlugins(plugins, onNotice, field);
36
36
  }
37
- function declaredPluginsIn(resolved, isHost, field) {
37
+ async function declaredPluginsIn(resolved, isHost, field) {
38
38
  let manifest;
39
39
  try {
40
- manifest = JSON.parse(fs.readFileSync(path.join(resolved, "package.json"), "utf8"));
40
+ manifest = JSON.parse(await fs.readFile(path.join(resolved, "package.json"), "utf8"));
41
41
  } catch (error) {
42
42
  throw new WebPluginManifestError(resolved, `package.json is unreadable: ${String(error)}`, field);
43
43
  }
44
- const declared = declaredPluginsOf(resolved, manifest, isHost, field);
44
+ const declared = await declaredPluginsOf(resolved, manifest, isHost, field);
45
45
  for (const plugin of declared) {
46
46
  const entryPath = path.join(resolved, plugin.client.entry);
47
- if (!fs.existsSync(entryPath)) throw new WebPluginManifestError(resolved, `client.entry '${plugin.client.entry}' does not exist.`, field);
47
+ await fs.access(entryPath).catch((error) => {
48
+ if (error.code === "ENOENT") throw new WebPluginManifestError(resolved, `client.entry '${plugin.client.entry}' does not exist.`, field);
49
+ throw error;
50
+ });
48
51
  }
49
52
  return declared;
50
53
  }