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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (621) hide show
  1. package/LICENSE +97 -8
  2. package/README.md +37 -722
  3. package/dist/apiContracts.cjs.map +1 -1
  4. package/dist/apiContracts.d.mts +2 -2
  5. package/dist/bin/cli.cjs +12 -7
  6. package/dist/bin/cli.cjs.map +1 -1
  7. package/dist/bin/cli.mjs +12 -7
  8. package/dist/bin/cli.mjs.map +1 -1
  9. package/dist/bin/poRunner.cjs +24 -7
  10. package/dist/bin/poRunner.cjs.map +1 -1
  11. package/dist/bin/poRunner.d.mts +8 -0
  12. package/dist/bin/poRunner.d.mts.map +1 -1
  13. package/dist/bin/poRunner.mjs +24 -7
  14. package/dist/bin/poRunner.mjs.map +1 -1
  15. package/dist/bin/serve.cjs +28 -17
  16. package/dist/bin/serve.cjs.map +1 -1
  17. package/dist/bin/serve.mjs +28 -17
  18. package/dist/bin/serve.mjs.map +1 -1
  19. package/dist/builders/cli/extensionAssembler/index.cjs +53 -40
  20. package/dist/builders/cli/extensionAssembler/index.cjs.map +1 -1
  21. package/dist/builders/cli/extensionAssembler/index.d.mts +11 -6
  22. package/dist/builders/cli/extensionAssembler/index.d.mts.map +1 -1
  23. package/dist/builders/cli/extensionAssembler/index.mjs +53 -41
  24. package/dist/builders/cli/extensionAssembler/index.mjs.map +1 -1
  25. package/dist/catalog/index.json +662 -105
  26. package/dist/cli.cjs +9 -14
  27. package/dist/cli.d.mts +1 -3
  28. package/dist/cli.mjs +1 -3
  29. package/dist/commands.cjs +13 -15
  30. package/dist/commands.d.mts +1 -2
  31. package/dist/commands.mjs +1 -2
  32. package/dist/config.cjs +9 -14
  33. package/dist/config.d.mts +3 -2
  34. package/dist/config.mjs +3 -2
  35. package/dist/extensions/server.cjs +30 -23
  36. package/dist/extensions/server.cjs.map +1 -1
  37. package/dist/extensions/server.d.mts.map +1 -1
  38. package/dist/extensions/server.mjs +31 -24
  39. package/dist/extensions/server.mjs.map +1 -1
  40. package/dist/harnessContext.cjs +0 -1
  41. package/dist/harnessContext.d.mts +2 -2
  42. package/dist/harnessContext.mjs +1 -1
  43. package/dist/harnessState.cjs +2 -1
  44. package/dist/help.cjs +9 -11
  45. package/dist/help.d.mts +1 -2
  46. package/dist/help.mjs +1 -2
  47. package/dist/index.cjs +40 -67
  48. package/dist/index.d.mts +7 -16
  49. package/dist/index.mjs +7 -14
  50. package/dist/matrixOptions.cjs +10 -5
  51. package/dist/matrixOptions.d.mts +2 -2
  52. package/dist/matrixOptions.mjs +1 -1
  53. package/dist/package.cjs +11 -0
  54. package/dist/package.cjs.map +1 -0
  55. package/dist/package.mjs +6 -0
  56. package/dist/package.mjs.map +1 -0
  57. package/dist/projectTrust.cjs +3 -0
  58. package/dist/projectTrust.d.mts +2 -2
  59. package/dist/projectTrust.mjs +1 -1
  60. package/dist/repository.cjs +1 -0
  61. package/dist/repository.d.mts +2 -2
  62. package/dist/repository.mjs +1 -1
  63. package/dist/services.cjs +5 -20
  64. package/dist/services.d.mts +3 -8
  65. package/dist/services.mjs +3 -8
  66. package/dist/shared.cjs +4 -17
  67. package/dist/shared.d.mts +2 -2
  68. package/dist/shared.mjs +1 -1
  69. package/dist/src/bin/agentDirectory.cjs +19 -15
  70. package/dist/src/bin/agentDirectory.cjs.map +1 -1
  71. package/dist/src/bin/agentDirectory.mjs +16 -13
  72. package/dist/src/bin/agentDirectory.mjs.map +1 -1
  73. package/dist/src/builders/apiContractExport/index.cjs +23 -22
  74. package/dist/src/builders/apiContractExport/index.cjs.map +1 -1
  75. package/dist/src/builders/apiContractExport/index.mjs +22 -21
  76. package/dist/src/builders/apiContractExport/index.mjs.map +1 -1
  77. package/dist/src/builders/cli/entryResolution.cjs +2 -2
  78. package/dist/src/builders/cli/entryResolution.cjs.map +1 -1
  79. package/dist/src/builders/cli/entryResolution.mjs +1 -1
  80. package/dist/src/builders/cli/entryResolution.mjs.map +1 -1
  81. package/dist/src/builders/cli/harnessContext.cjs +38 -43
  82. package/dist/src/builders/cli/harnessContext.cjs.map +1 -1
  83. package/dist/src/builders/cli/harnessContext.d.mts +11 -10
  84. package/dist/src/builders/cli/harnessContext.d.mts.map +1 -1
  85. package/dist/src/builders/cli/harnessContext.mjs +37 -41
  86. package/dist/src/builders/cli/harnessContext.mjs.map +1 -1
  87. package/dist/src/builders/cli/sessionComposition.cjs +23 -12
  88. package/dist/src/builders/cli/sessionComposition.cjs.map +1 -1
  89. package/dist/src/builders/cli/sessionComposition.mjs +23 -12
  90. package/dist/src/builders/cli/sessionComposition.mjs.map +1 -1
  91. package/dist/src/builders/isolate/compile.cjs +226 -0
  92. package/dist/src/builders/isolate/compile.cjs.map +1 -0
  93. package/dist/src/builders/isolate/compile.mjs +222 -0
  94. package/dist/src/builders/isolate/compile.mjs.map +1 -0
  95. package/dist/src/builders/isolate/index.cjs +195 -0
  96. package/dist/src/builders/isolate/index.cjs.map +1 -0
  97. package/dist/src/builders/isolate/index.mjs +192 -0
  98. package/dist/src/builders/isolate/index.mjs.map +1 -0
  99. package/dist/src/builders/isolate/membrane.cjs +198 -0
  100. package/dist/src/builders/isolate/membrane.cjs.map +1 -0
  101. package/dist/src/builders/isolate/membrane.mjs +198 -0
  102. package/dist/src/builders/isolate/membrane.mjs.map +1 -0
  103. package/dist/src/builders/isolate/names.cjs +10 -0
  104. package/dist/src/builders/isolate/names.cjs.map +1 -0
  105. package/dist/src/builders/isolate/names.mjs +9 -0
  106. package/dist/src/builders/isolate/names.mjs.map +1 -0
  107. package/dist/src/builders/native/index.cjs +229 -67
  108. package/dist/src/builders/native/index.cjs.map +1 -1
  109. package/dist/src/builders/native/index.d.mts +4 -2
  110. package/dist/src/builders/native/index.d.mts.map +1 -1
  111. package/dist/src/builders/native/index.mjs +229 -68
  112. package/dist/src/builders/native/index.mjs.map +1 -1
  113. package/dist/src/builders/npm/index.cjs +76 -0
  114. package/dist/src/builders/npm/index.cjs.map +1 -0
  115. package/dist/src/builders/npm/index.mjs +73 -0
  116. package/dist/src/builders/npm/index.mjs.map +1 -0
  117. package/dist/src/builders/server/backgroundSync.cjs +62 -39
  118. package/dist/src/builders/server/backgroundSync.cjs.map +1 -1
  119. package/dist/src/builders/server/backgroundSync.mjs +62 -38
  120. package/dist/src/builders/server/backgroundSync.mjs.map +1 -1
  121. package/dist/src/builders/server/bundlerService.cjs +165 -35
  122. package/dist/src/builders/server/bundlerService.cjs.map +1 -1
  123. package/dist/src/builders/server/bundlerService.mjs +164 -36
  124. package/dist/src/builders/server/bundlerService.mjs.map +1 -1
  125. package/dist/src/builders/server/capabilities.cjs +103 -0
  126. package/dist/src/builders/server/capabilities.cjs.map +1 -0
  127. package/dist/src/builders/server/capabilities.mjs +101 -0
  128. package/dist/src/builders/server/capabilities.mjs.map +1 -0
  129. package/dist/src/builders/server/computerUseBinding.cjs +62 -10
  130. package/dist/src/builders/server/computerUseBinding.cjs.map +1 -1
  131. package/dist/src/builders/server/computerUseBinding.mjs +60 -8
  132. package/dist/src/builders/server/computerUseBinding.mjs.map +1 -1
  133. package/dist/src/builders/server/computerUseRecordings.cjs +152 -51
  134. package/dist/src/builders/server/computerUseRecordings.cjs.map +1 -1
  135. package/dist/src/builders/server/computerUseRecordings.mjs +158 -59
  136. package/dist/src/builders/server/computerUseRecordings.mjs.map +1 -1
  137. package/dist/src/builders/server/containedSessions.cjs +152 -0
  138. package/dist/src/builders/server/containedSessions.cjs.map +1 -0
  139. package/dist/src/builders/server/containedSessions.mjs +146 -0
  140. package/dist/src/builders/server/containedSessions.mjs.map +1 -0
  141. package/dist/src/builders/server/defaultWorkspace.cjs +46 -11
  142. package/dist/src/builders/server/defaultWorkspace.cjs.map +1 -1
  143. package/dist/src/builders/server/defaultWorkspace.mjs +42 -10
  144. package/dist/src/builders/server/defaultWorkspace.mjs.map +1 -1
  145. package/dist/src/builders/server/electronBinding.cjs +82 -0
  146. package/dist/src/builders/server/electronBinding.cjs.map +1 -0
  147. package/dist/src/builders/server/electronBinding.mjs +82 -0
  148. package/dist/src/builders/server/electronBinding.mjs.map +1 -0
  149. package/dist/src/builders/server/federation.cjs +364 -0
  150. package/dist/src/builders/server/federation.cjs.map +1 -0
  151. package/dist/src/builders/server/federation.mjs +363 -0
  152. package/dist/src/builders/server/federation.mjs.map +1 -0
  153. package/dist/src/builders/server/hostDisplayName.cjs +14 -0
  154. package/dist/src/builders/server/hostDisplayName.cjs.map +1 -0
  155. package/dist/src/builders/server/hostDisplayName.mjs +14 -0
  156. package/dist/src/builders/server/hostDisplayName.mjs.map +1 -0
  157. package/dist/src/builders/server/hostModelGateway.cjs +41 -0
  158. package/dist/src/builders/server/hostModelGateway.cjs.map +1 -0
  159. package/dist/src/builders/server/hostModelGateway.mjs +39 -0
  160. package/dist/src/builders/server/hostModelGateway.mjs.map +1 -0
  161. package/dist/src/builders/server/hostTeam.cjs +188 -0
  162. package/dist/src/builders/server/hostTeam.cjs.map +1 -0
  163. package/dist/src/builders/server/hostTeam.mjs +180 -0
  164. package/dist/src/builders/server/hostTeam.mjs.map +1 -0
  165. package/dist/src/builders/server/idleRestart.cjs +185 -40
  166. package/dist/src/builders/server/idleRestart.cjs.map +1 -1
  167. package/dist/src/builders/server/idleRestart.mjs +176 -39
  168. package/dist/src/builders/server/idleRestart.mjs.map +1 -1
  169. package/dist/src/builders/server/index.cjs +33 -19
  170. package/dist/src/builders/server/index.cjs.map +1 -1
  171. package/dist/src/builders/server/index.mjs +33 -18
  172. package/dist/src/builders/server/index.mjs.map +1 -1
  173. package/dist/src/builders/server/liveActivityPush.cjs +202 -0
  174. package/dist/src/builders/server/liveActivityPush.cjs.map +1 -0
  175. package/dist/src/builders/server/liveActivityPush.mjs +202 -0
  176. package/dist/src/builders/server/liveActivityPush.mjs.map +1 -0
  177. package/dist/src/builders/server/logSink.cjs +12 -10
  178. package/dist/src/builders/server/logSink.cjs.map +1 -1
  179. package/dist/src/builders/server/logSink.mjs +12 -10
  180. package/dist/src/builders/server/logSink.mjs.map +1 -1
  181. package/dist/src/builders/server/mcpApp.cjs +27 -20
  182. package/dist/src/builders/server/mcpApp.cjs.map +1 -1
  183. package/dist/src/builders/server/mcpApp.mjs +25 -18
  184. package/dist/src/builders/server/mcpApp.mjs.map +1 -1
  185. package/dist/src/builders/server/mcpAppBuild.cjs +61 -41
  186. package/dist/src/builders/server/mcpAppBuild.cjs.map +1 -1
  187. package/dist/src/builders/server/mcpAppBuild.d.mts +3 -6
  188. package/dist/src/builders/server/mcpAppBuild.d.mts.map +1 -1
  189. package/dist/src/builders/server/mcpAppBuild.mjs +61 -40
  190. package/dist/src/builders/server/mcpAppBuild.mjs.map +1 -1
  191. package/dist/src/builders/server/mcpBundle.cjs +20 -16
  192. package/dist/src/builders/server/mcpBundle.cjs.map +1 -1
  193. package/dist/src/builders/server/mcpBundle.d.mts +2 -1
  194. package/dist/src/builders/server/mcpBundle.d.mts.map +1 -1
  195. package/dist/src/builders/server/mcpBundle.mjs +20 -15
  196. package/dist/src/builders/server/mcpBundle.mjs.map +1 -1
  197. package/dist/src/builders/server/nativePush.cjs +229 -0
  198. package/dist/src/builders/server/nativePush.cjs.map +1 -0
  199. package/dist/src/builders/server/nativePush.mjs +228 -0
  200. package/dist/src/builders/server/nativePush.mjs.map +1 -0
  201. package/dist/src/builders/server/network.cjs +887 -0
  202. package/dist/src/builders/server/network.cjs.map +1 -0
  203. package/dist/src/builders/server/network.mjs +886 -0
  204. package/dist/src/builders/server/network.mjs.map +1 -0
  205. package/dist/src/builders/server/networkGateway.cjs +123 -0
  206. package/dist/src/builders/server/networkGateway.cjs.map +1 -0
  207. package/dist/src/builders/server/networkGateway.mjs +123 -0
  208. package/dist/src/builders/server/networkGateway.mjs.map +1 -0
  209. package/dist/src/builders/server/networkRelay.cjs +83 -0
  210. package/dist/src/builders/server/networkRelay.cjs.map +1 -0
  211. package/dist/src/builders/server/networkRelay.mjs +81 -0
  212. package/dist/src/builders/server/networkRelay.mjs.map +1 -0
  213. package/dist/src/builders/server/orgPluginLibraryBinding.cjs +72 -0
  214. package/dist/src/builders/server/orgPluginLibraryBinding.cjs.map +1 -0
  215. package/dist/src/builders/server/orgPluginLibraryBinding.mjs +72 -0
  216. package/dist/src/builders/server/orgPluginLibraryBinding.mjs.map +1 -0
  217. package/dist/src/builders/server/packageReloadCheck.cjs +46 -2
  218. package/dist/src/builders/server/packageReloadCheck.cjs.map +1 -1
  219. package/dist/src/builders/server/packageReloadCheck.mjs +46 -3
  220. package/dist/src/builders/server/packageReloadCheck.mjs.map +1 -1
  221. package/dist/src/builders/server/packageUrl.cjs +161 -58
  222. package/dist/src/builders/server/packageUrl.cjs.map +1 -1
  223. package/dist/src/builders/server/packageUrl.mjs +162 -58
  224. package/dist/src/builders/server/packageUrl.mjs.map +1 -1
  225. package/dist/src/builders/server/privateRelay.cjs +309 -0
  226. package/dist/src/builders/server/privateRelay.cjs.map +1 -0
  227. package/dist/src/builders/server/privateRelay.mjs +305 -0
  228. package/dist/src/builders/server/privateRelay.mjs.map +1 -0
  229. package/dist/src/builders/server/privateRelayCarrier.cjs +316 -0
  230. package/dist/src/builders/server/privateRelayCarrier.cjs.map +1 -0
  231. package/dist/src/builders/server/privateRelayCarrier.mjs +309 -0
  232. package/dist/src/builders/server/privateRelayCarrier.mjs.map +1 -0
  233. package/dist/src/builders/server/runtime.cjs +2731 -485
  234. package/dist/src/builders/server/runtime.cjs.map +1 -1
  235. package/dist/src/builders/server/runtime.mjs +2741 -499
  236. package/dist/src/builders/server/runtime.mjs.map +1 -1
  237. package/dist/src/builders/server/runtimeResources.cjs +37 -0
  238. package/dist/src/builders/server/runtimeResources.cjs.map +1 -1
  239. package/dist/src/builders/server/runtimeResources.mjs +38 -2
  240. package/dist/src/builders/server/runtimeResources.mjs.map +1 -1
  241. package/dist/src/builders/server/sandboxRouter.cjs +815 -0
  242. package/dist/src/builders/server/sandboxRouter.cjs.map +1 -0
  243. package/dist/src/builders/server/sandboxRouter.mjs +811 -0
  244. package/dist/src/builders/server/sandboxRouter.mjs.map +1 -0
  245. package/dist/src/builders/server/sandboxSessionHandoff.cjs +298 -0
  246. package/dist/src/builders/server/sandboxSessionHandoff.cjs.map +1 -0
  247. package/dist/src/builders/server/sandboxSessionHandoff.mjs +287 -0
  248. package/dist/src/builders/server/sandboxSessionHandoff.mjs.map +1 -0
  249. package/dist/src/builders/server/scopeReloadController.cjs +80 -0
  250. package/dist/src/builders/server/scopeReloadController.cjs.map +1 -0
  251. package/dist/src/builders/server/scopeReloadController.mjs +80 -0
  252. package/dist/src/builders/server/scopeReloadController.mjs.map +1 -0
  253. package/dist/src/builders/server/selectionStatus.cjs +2 -2
  254. package/dist/src/builders/server/selectionStatus.cjs.map +1 -1
  255. package/dist/src/builders/server/selectionStatus.mjs +2 -2
  256. package/dist/src/builders/server/selectionStatus.mjs.map +1 -1
  257. package/dist/src/builders/server/sessionArguments.cjs +65 -7
  258. package/dist/src/builders/server/sessionArguments.cjs.map +1 -1
  259. package/dist/src/builders/server/sessionArguments.mjs +64 -8
  260. package/dist/src/builders/server/sessionArguments.mjs.map +1 -1
  261. package/dist/src/builders/server/sessionRemoval.cjs +233 -0
  262. package/dist/src/builders/server/sessionRemoval.cjs.map +1 -0
  263. package/dist/src/builders/server/sessionRemoval.mjs +224 -0
  264. package/dist/src/builders/server/sessionRemoval.mjs.map +1 -0
  265. package/dist/src/builders/server/sessionSummaries.cjs +32 -0
  266. package/dist/src/builders/server/sessionSummaries.cjs.map +1 -0
  267. package/dist/src/builders/server/sessionSummaries.mjs +31 -0
  268. package/dist/src/builders/server/sessionSummaries.mjs.map +1 -0
  269. package/dist/src/builders/server/shutdown.cjs +23 -0
  270. package/dist/src/builders/server/shutdown.cjs.map +1 -1
  271. package/dist/src/builders/server/shutdown.mjs +21 -1
  272. package/dist/src/builders/server/shutdown.mjs.map +1 -1
  273. package/dist/src/builders/server/shutdownStack.cjs +44 -0
  274. package/dist/src/builders/server/shutdownStack.cjs.map +1 -0
  275. package/dist/src/builders/server/shutdownStack.mjs +43 -0
  276. package/dist/src/builders/server/shutdownStack.mjs.map +1 -0
  277. package/dist/src/builders/server/toolBoundaryHold.cjs +55 -0
  278. package/dist/src/builders/server/toolBoundaryHold.cjs.map +1 -0
  279. package/dist/src/builders/server/toolBoundaryHold.mjs +55 -0
  280. package/dist/src/builders/server/toolBoundaryHold.mjs.map +1 -0
  281. package/dist/src/builders/server/watcherService.cjs +55 -28
  282. package/dist/src/builders/server/watcherService.cjs.map +1 -1
  283. package/dist/src/builders/server/watcherService.mjs +55 -27
  284. package/dist/src/builders/server/watcherService.mjs.map +1 -1
  285. package/dist/src/builders/server/webTemplateDecision.cjs +7 -3
  286. package/dist/src/builders/server/webTemplateDecision.cjs.map +1 -1
  287. package/dist/src/builders/server/webTemplateDecision.mjs +7 -3
  288. package/dist/src/builders/server/webTemplateDecision.mjs.map +1 -1
  289. package/dist/src/builders/server/workspaceAdmission.cjs +96 -0
  290. package/dist/src/builders/server/workspaceAdmission.cjs.map +1 -0
  291. package/dist/src/builders/server/workspaceAdmission.mjs +90 -0
  292. package/dist/src/builders/server/workspaceAdmission.mjs.map +1 -0
  293. package/dist/src/builders/server/workspaceCheckout.cjs +16 -7
  294. package/dist/src/builders/server/workspaceCheckout.cjs.map +1 -1
  295. package/dist/src/builders/server/workspaceCheckout.mjs +16 -7
  296. package/dist/src/builders/server/workspaceCheckout.mjs.map +1 -1
  297. package/dist/src/builders/web/bundle.cjs +16 -14
  298. package/dist/src/builders/web/bundle.cjs.map +1 -1
  299. package/dist/src/builders/web/bundle.d.mts +3 -0
  300. package/dist/src/builders/web/bundle.d.mts.map +1 -1
  301. package/dist/src/builders/web/bundle.mjs +15 -13
  302. package/dist/src/builders/web/bundle.mjs.map +1 -1
  303. package/dist/src/builders/web/index.cjs +77 -59
  304. package/dist/src/builders/web/index.cjs.map +1 -1
  305. package/dist/src/builders/web/index.d.mts +19 -14
  306. package/dist/src/builders/web/index.d.mts.map +1 -1
  307. package/dist/src/builders/web/index.mjs +76 -58
  308. package/dist/src/builders/web/index.mjs.map +1 -1
  309. package/dist/src/builders/web/webPluginGenerate.cjs +84 -45
  310. package/dist/src/builders/web/webPluginGenerate.cjs.map +1 -1
  311. package/dist/src/builders/web/webPluginGenerate.d.mts +13 -4
  312. package/dist/src/builders/web/webPluginGenerate.d.mts.map +1 -1
  313. package/dist/src/builders/web/webPluginGenerate.mjs +82 -44
  314. package/dist/src/builders/web/webPluginGenerate.mjs.map +1 -1
  315. package/dist/src/builders/web/webPluginManifest.cjs +24 -17
  316. package/dist/src/builders/web/webPluginManifest.cjs.map +1 -1
  317. package/dist/src/builders/web/webPluginManifest.d.mts +11 -23
  318. package/dist/src/builders/web/webPluginManifest.d.mts.map +1 -1
  319. package/dist/src/builders/web/webPluginManifest.mjs +23 -16
  320. package/dist/src/builders/web/webPluginManifest.mjs.map +1 -1
  321. package/dist/src/builders/web/webPluginScan.cjs +11 -8
  322. package/dist/src/builders/web/webPluginScan.cjs.map +1 -1
  323. package/dist/src/builders/web/webPluginScan.d.mts +1 -1
  324. package/dist/src/builders/web/webPluginScan.d.mts.map +1 -1
  325. package/dist/src/builders/web/webPluginScan.mjs +10 -7
  326. package/dist/src/builders/web/webPluginScan.mjs.map +1 -1
  327. package/dist/src/builders/web/webPluginVite.cjs +5 -5
  328. package/dist/src/builders/web/webPluginVite.cjs.map +1 -1
  329. package/dist/src/builders/web/webPluginVite.d.mts +1 -1
  330. package/dist/src/builders/web/webPluginVite.d.mts.map +1 -1
  331. package/dist/src/builders/web/webPluginVite.mjs +3 -3
  332. package/dist/src/builders/web/webPluginVite.mjs.map +1 -1
  333. package/dist/src/cli/cliApp.cjs +18 -19
  334. package/dist/src/cli/cliApp.cjs.map +1 -1
  335. package/dist/src/cli/cliApp.d.mts +1 -1
  336. package/dist/src/cli/cliApp.d.mts.map +1 -1
  337. package/dist/src/cli/cliApp.mjs +18 -19
  338. package/dist/src/cli/cliApp.mjs.map +1 -1
  339. package/dist/src/cli/commands/api-export/index.cjs +14 -13
  340. package/dist/src/cli/commands/api-export/index.cjs.map +1 -1
  341. package/dist/src/cli/commands/api-export/index.mjs +13 -12
  342. package/dist/src/cli/commands/api-export/index.mjs.map +1 -1
  343. package/dist/src/cli/commands/doctor/help.cjs +4 -3
  344. package/dist/src/cli/commands/doctor/help.cjs.map +1 -1
  345. package/dist/src/cli/commands/doctor/help.d.mts.map +1 -1
  346. package/dist/src/cli/commands/doctor/help.mjs +4 -3
  347. package/dist/src/cli/commands/doctor/help.mjs.map +1 -1
  348. package/dist/src/cli/commands/doctor/index.cjs +30 -17
  349. package/dist/src/cli/commands/doctor/index.cjs.map +1 -1
  350. package/dist/src/cli/commands/doctor/index.d.mts +4 -4
  351. package/dist/src/cli/commands/doctor/index.d.mts.map +1 -1
  352. package/dist/src/cli/commands/doctor/index.mjs +28 -15
  353. package/dist/src/cli/commands/doctor/index.mjs.map +1 -1
  354. package/dist/src/cli/commands/emit-mcp/index.cjs +3 -2
  355. package/dist/src/cli/commands/emit-mcp/index.cjs.map +1 -1
  356. package/dist/src/cli/commands/emit-mcp/index.d.mts.map +1 -1
  357. package/dist/src/cli/commands/emit-mcp/index.mjs +3 -2
  358. package/dist/src/cli/commands/emit-mcp/index.mjs.map +1 -1
  359. package/dist/src/cli/commands/explain/index.cjs +53 -38
  360. package/dist/src/cli/commands/explain/index.cjs.map +1 -1
  361. package/dist/src/cli/commands/explain/index.d.mts +3 -4
  362. package/dist/src/cli/commands/explain/index.d.mts.map +1 -1
  363. package/dist/src/cli/commands/explain/index.mjs +52 -37
  364. package/dist/src/cli/commands/explain/index.mjs.map +1 -1
  365. package/dist/src/cli/commands/init/help.cjs +3 -2
  366. package/dist/src/cli/commands/init/help.cjs.map +1 -1
  367. package/dist/src/cli/commands/init/help.d.mts.map +1 -1
  368. package/dist/src/cli/commands/init/help.mjs +3 -2
  369. package/dist/src/cli/commands/init/help.mjs.map +1 -1
  370. package/dist/src/cli/commands/init/index.cjs +17 -12
  371. package/dist/src/cli/commands/init/index.cjs.map +1 -1
  372. package/dist/src/cli/commands/init/index.d.mts.map +1 -1
  373. package/dist/src/cli/commands/init/index.mjs +16 -11
  374. package/dist/src/cli/commands/init/index.mjs.map +1 -1
  375. package/dist/src/cli/commands/init/presenter.cjs +29 -21
  376. package/dist/src/cli/commands/init/presenter.cjs.map +1 -1
  377. package/dist/src/cli/commands/init/presenter.mjs +29 -21
  378. package/dist/src/cli/commands/init/presenter.mjs.map +1 -1
  379. package/dist/src/cli/commands/sync/help.cjs +7 -3
  380. package/dist/src/cli/commands/sync/help.cjs.map +1 -1
  381. package/dist/src/cli/commands/sync/help.d.mts.map +1 -1
  382. package/dist/src/cli/commands/sync/help.mjs +7 -3
  383. package/dist/src/cli/commands/sync/help.mjs.map +1 -1
  384. package/dist/src/cli/commands/sync/index.cjs +72 -40
  385. package/dist/src/cli/commands/sync/index.cjs.map +1 -1
  386. package/dist/src/cli/commands/sync/index.d.mts.map +1 -1
  387. package/dist/src/cli/commands/sync/index.mjs +69 -37
  388. package/dist/src/cli/commands/sync/index.mjs.map +1 -1
  389. package/dist/src/cli/commands/sync/presenter.cjs +10 -1
  390. package/dist/src/cli/commands/sync/presenter.cjs.map +1 -1
  391. package/dist/src/cli/commands/sync/presenter.d.mts +0 -9
  392. package/dist/src/cli/commands/sync/presenter.d.mts.map +1 -1
  393. package/dist/src/cli/commands/sync/presenter.mjs +10 -1
  394. package/dist/src/cli/commands/sync/presenter.mjs.map +1 -1
  395. package/dist/src/cli/commands/web/index.cjs +7 -6
  396. package/dist/src/cli/commands/web/index.cjs.map +1 -1
  397. package/dist/src/cli/commands/web/index.mjs +6 -5
  398. package/dist/src/cli/commands/web/index.mjs.map +1 -1
  399. package/dist/src/cli/harnessOptions.cjs +15 -24
  400. package/dist/src/cli/harnessOptions.cjs.map +1 -1
  401. package/dist/src/cli/harnessOptions.d.mts +2 -2
  402. package/dist/src/cli/harnessOptions.d.mts.map +1 -1
  403. package/dist/src/cli/harnessOptions.mjs +14 -22
  404. package/dist/src/cli/harnessOptions.mjs.map +1 -1
  405. package/dist/src/cli/help.cjs +20 -26
  406. package/dist/src/cli/help.cjs.map +1 -1
  407. package/dist/src/cli/help.d.mts +1 -2
  408. package/dist/src/cli/help.d.mts.map +1 -1
  409. package/dist/src/cli/help.mjs +15 -20
  410. package/dist/src/cli/help.mjs.map +1 -1
  411. package/dist/src/cli/locale.cjs +25 -0
  412. package/dist/src/cli/locale.cjs.map +1 -0
  413. package/dist/src/cli/locale.mjs +22 -0
  414. package/dist/src/cli/locale.mjs.map +1 -0
  415. package/dist/src/cli/matrixOptions.cjs +85 -37
  416. package/dist/src/cli/matrixOptions.cjs.map +1 -1
  417. package/dist/src/cli/matrixOptions.d.mts +22 -16
  418. package/dist/src/cli/matrixOptions.d.mts.map +1 -1
  419. package/dist/src/cli/matrixOptions.mjs +76 -33
  420. package/dist/src/cli/matrixOptions.mjs.map +1 -1
  421. package/dist/src/cli/options.cjs +51 -128
  422. package/dist/src/cli/options.cjs.map +1 -1
  423. package/dist/src/cli/options.d.mts +1 -1
  424. package/dist/src/cli/options.d.mts.map +1 -1
  425. package/dist/src/cli/options.mjs +53 -130
  426. package/dist/src/cli/options.mjs.map +1 -1
  427. package/dist/src/cli/router.cjs +0 -1
  428. package/dist/src/cli/router.cjs.map +1 -1
  429. package/dist/src/cli/router.d.mts +1 -1
  430. package/dist/src/cli/router.mjs +0 -1
  431. package/dist/src/cli/router.mjs.map +1 -1
  432. package/dist/src/cli/server/options.cjs +37 -7
  433. package/dist/src/cli/server/options.cjs.map +1 -1
  434. package/dist/src/cli/server/options.mjs +37 -7
  435. package/dist/src/cli/server/options.mjs.map +1 -1
  436. package/dist/src/cli/server/processGuards.cjs +22 -15
  437. package/dist/src/cli/server/processGuards.cjs.map +1 -1
  438. package/dist/src/cli/server/processGuards.mjs +21 -14
  439. package/dist/src/cli/server/processGuards.mjs.map +1 -1
  440. package/dist/src/cli/server/restartPolicy.cjs +38 -0
  441. package/dist/src/cli/server/restartPolicy.cjs.map +1 -0
  442. package/dist/src/cli/server/restartPolicy.d.mts +21 -0
  443. package/dist/src/cli/server/restartPolicy.d.mts.map +1 -0
  444. package/dist/src/cli/server/restartPolicy.mjs +36 -0
  445. package/dist/src/cli/server/restartPolicy.mjs.map +1 -0
  446. package/dist/src/cli/server/run.cjs +12 -11
  447. package/dist/src/cli/server/run.cjs.map +1 -1
  448. package/dist/src/cli/server/run.mjs +11 -10
  449. package/dist/src/cli/server/run.mjs.map +1 -1
  450. package/dist/src/cli/server/supervise.cjs +89 -0
  451. package/dist/src/cli/server/supervise.cjs.map +1 -0
  452. package/dist/src/cli/server/supervise.mjs +89 -0
  453. package/dist/src/cli/server/supervise.mjs.map +1 -0
  454. package/dist/src/composition/harnessState/index.cjs +2 -1
  455. package/dist/src/composition/harnessState/index.cjs.map +1 -1
  456. package/dist/src/composition/harnessState/index.d.mts +2 -1
  457. package/dist/src/composition/harnessState/index.d.mts.map +1 -1
  458. package/dist/src/composition/harnessState/index.mjs +2 -1
  459. package/dist/src/composition/harnessState/index.mjs.map +1 -1
  460. package/dist/src/composition/layerPackageInstaller/index.cjs +293 -86
  461. package/dist/src/composition/layerPackageInstaller/index.cjs.map +1 -1
  462. package/dist/src/composition/layerPackageInstaller/index.d.mts +25 -2
  463. package/dist/src/composition/layerPackageInstaller/index.d.mts.map +1 -1
  464. package/dist/src/composition/layerPackageInstaller/index.mjs +295 -94
  465. package/dist/src/composition/layerPackageInstaller/index.mjs.map +1 -1
  466. package/dist/src/composition/marketplaceCatalog/index.cjs +136 -0
  467. package/dist/src/composition/marketplaceCatalog/index.cjs.map +1 -0
  468. package/dist/src/composition/marketplaceCatalog/index.mjs +132 -0
  469. package/dist/src/composition/marketplaceCatalog/index.mjs.map +1 -0
  470. package/dist/src/composition/orgPluginActivation/index.cjs +179 -0
  471. package/dist/src/composition/orgPluginActivation/index.cjs.map +1 -0
  472. package/dist/src/composition/orgPluginActivation/index.mjs +177 -0
  473. package/dist/src/composition/orgPluginActivation/index.mjs.map +1 -0
  474. package/dist/src/composition/orgPluginLibrary/index.cjs +205 -0
  475. package/dist/src/composition/orgPluginLibrary/index.cjs.map +1 -0
  476. package/dist/src/composition/orgPluginLibrary/index.mjs +200 -0
  477. package/dist/src/composition/orgPluginLibrary/index.mjs.map +1 -0
  478. package/dist/src/composition/pluginMarketplace/index.cjs +304 -0
  479. package/dist/src/composition/pluginMarketplace/index.cjs.map +1 -0
  480. package/dist/src/composition/pluginMarketplace/index.mjs +302 -0
  481. package/dist/src/composition/pluginMarketplace/index.mjs.map +1 -0
  482. package/dist/src/composition/poHomeMigration/index.cjs +46 -26
  483. package/dist/src/composition/poHomeMigration/index.cjs.map +1 -1
  484. package/dist/src/composition/poHomeMigration/index.d.mts.map +1 -1
  485. package/dist/src/composition/poHomeMigration/index.mjs +45 -25
  486. package/dist/src/composition/poHomeMigration/index.mjs.map +1 -1
  487. package/dist/src/composition/projectTrust/index.cjs +40 -3
  488. package/dist/src/composition/projectTrust/index.cjs.map +1 -1
  489. package/dist/src/composition/projectTrust/index.d.mts +8 -0
  490. package/dist/src/composition/projectTrust/index.d.mts.map +1 -1
  491. package/dist/src/composition/projectTrust/index.mjs +33 -2
  492. package/dist/src/composition/projectTrust/index.mjs.map +1 -1
  493. package/dist/src/composition/repository/index.cjs +29 -12
  494. package/dist/src/composition/repository/index.cjs.map +1 -1
  495. package/dist/src/composition/repository/index.d.mts +10 -3
  496. package/dist/src/composition/repository/index.d.mts.map +1 -1
  497. package/dist/src/composition/repository/index.mjs +29 -13
  498. package/dist/src/composition/repository/index.mjs.map +1 -1
  499. package/dist/src/composition/syncPrune/index.cjs +23 -16
  500. package/dist/src/composition/syncPrune/index.cjs.map +1 -1
  501. package/dist/src/composition/syncPrune/index.d.mts.map +1 -1
  502. package/dist/src/composition/syncPrune/index.mjs +22 -15
  503. package/dist/src/composition/syncPrune/index.mjs.map +1 -1
  504. package/dist/src/composition/syncService/index.cjs +441 -194
  505. package/dist/src/composition/syncService/index.cjs.map +1 -1
  506. package/dist/src/composition/syncService/index.d.mts +4 -1
  507. package/dist/src/composition/syncService/index.d.mts.map +1 -1
  508. package/dist/src/composition/syncService/index.mjs +440 -196
  509. package/dist/src/composition/syncService/index.mjs.map +1 -1
  510. package/dist/src/composition/syncService/localBuilds.cjs +41 -37
  511. package/dist/src/composition/syncService/localBuilds.cjs.map +1 -1
  512. package/dist/src/composition/syncService/localBuilds.mjs +40 -37
  513. package/dist/src/composition/syncService/localBuilds.mjs.map +1 -1
  514. package/dist/src/composition/transitionLayers.cjs.map +1 -1
  515. package/dist/src/composition/transitionLayers.d.mts +3 -3
  516. package/dist/src/composition/transitionLayers.d.mts.map +1 -1
  517. package/dist/src/composition/transitionLayers.mjs.map +1 -1
  518. package/dist/src/composition/types/harness.d.mts +4 -9
  519. package/dist/src/composition/types/harness.d.mts.map +1 -1
  520. package/dist/src/extensions/setupDiagnostics.cjs +8 -8
  521. package/dist/src/extensions/setupDiagnostics.cjs.map +1 -1
  522. package/dist/src/extensions/setupDiagnostics.mjs +8 -8
  523. package/dist/src/extensions/setupDiagnostics.mjs.map +1 -1
  524. package/dist/webBuilder.cjs +1 -0
  525. package/dist/webBuilder.d.mts +2 -2
  526. package/dist/webBuilder.mjs +2 -2
  527. package/docs/server/api-export.md +9 -9
  528. package/docs/server/api.md +22 -125
  529. package/docs/server/getting-started.md +21 -85
  530. package/docs/server/index.md +13 -58
  531. package/docs/server/ipc.md +26 -72
  532. package/docs/server/lifecycle.md +18 -91
  533. package/docs/server/security.md +20 -80
  534. package/package.json +47 -67
  535. package/src/prompts/po-author-extension/SKILL.md +2 -2
  536. package/src/prompts/po-author-extension/references/extension-contract.md +4 -6
  537. package/dist/antigravity.cjs +0 -5
  538. package/dist/antigravity.d.mts +0 -2
  539. package/dist/antigravity.mjs +0 -1
  540. package/dist/codex.cjs +0 -8
  541. package/dist/codex.d.mts +0 -2
  542. package/dist/codex.mjs +0 -1
  543. package/dist/compatibility.cjs +0 -27
  544. package/dist/compatibility.d.mts +0 -6
  545. package/dist/compatibility.mjs +0 -6
  546. package/dist/compatibilityCommand.cjs +0 -4
  547. package/dist/compatibilityCommand.d.mts +0 -2
  548. package/dist/compatibilityCommand.mjs +0 -1
  549. package/dist/compatibilityContext.cjs +0 -3
  550. package/dist/compatibilityContext.d.mts +0 -2
  551. package/dist/compatibilityContext.mjs +0 -1
  552. package/dist/compatibilityOptions.cjs +0 -5
  553. package/dist/compatibilityOptions.d.mts +0 -2
  554. package/dist/compatibilityOptions.mjs +0 -1
  555. package/dist/process.cjs +0 -12
  556. package/dist/process.d.mts +0 -2
  557. package/dist/process.mjs +0 -1
  558. package/dist/src/builders/hooks/index.cjs +0 -238
  559. package/dist/src/builders/hooks/index.cjs.map +0 -1
  560. package/dist/src/builders/hooks/index.mjs +0 -231
  561. package/dist/src/builders/hooks/index.mjs.map +0 -1
  562. package/dist/src/cli/commands/compat/context.cjs +0 -115
  563. package/dist/src/cli/commands/compat/context.cjs.map +0 -1
  564. package/dist/src/cli/commands/compat/context.d.mts +0 -22
  565. package/dist/src/cli/commands/compat/context.d.mts.map +0 -1
  566. package/dist/src/cli/commands/compat/context.mjs +0 -110
  567. package/dist/src/cli/commands/compat/context.mjs.map +0 -1
  568. package/dist/src/cli/commands/compat/help.cjs +0 -26
  569. package/dist/src/cli/commands/compat/help.cjs.map +0 -1
  570. package/dist/src/cli/commands/compat/help.d.mts +0 -4
  571. package/dist/src/cli/commands/compat/help.d.mts.map +0 -1
  572. package/dist/src/cli/commands/compat/help.mjs +0 -25
  573. package/dist/src/cli/commands/compat/help.mjs.map +0 -1
  574. package/dist/src/cli/commands/compat/index.cjs +0 -73
  575. package/dist/src/cli/commands/compat/index.cjs.map +0 -1
  576. package/dist/src/cli/commands/compat/index.d.mts +0 -14
  577. package/dist/src/cli/commands/compat/index.d.mts.map +0 -1
  578. package/dist/src/cli/commands/compat/index.mjs +0 -70
  579. package/dist/src/cli/commands/compat/index.mjs.map +0 -1
  580. package/dist/src/cli/commands/compat/options.cjs +0 -88
  581. package/dist/src/cli/commands/compat/options.cjs.map +0 -1
  582. package/dist/src/cli/commands/compat/options.d.mts +0 -15
  583. package/dist/src/cli/commands/compat/options.d.mts.map +0 -1
  584. package/dist/src/cli/commands/compat/options.mjs +0 -86
  585. package/dist/src/cli/commands/compat/options.mjs.map +0 -1
  586. package/dist/src/cli/commands/compat/providers/antigravity.cjs +0 -294
  587. package/dist/src/cli/commands/compat/providers/antigravity.cjs.map +0 -1
  588. package/dist/src/cli/commands/compat/providers/antigravity.d.mts +0 -9
  589. package/dist/src/cli/commands/compat/providers/antigravity.d.mts.map +0 -1
  590. package/dist/src/cli/commands/compat/providers/antigravity.mjs +0 -289
  591. package/dist/src/cli/commands/compat/providers/antigravity.mjs.map +0 -1
  592. package/dist/src/cli/commands/compat/providers/codex.cjs +0 -178
  593. package/dist/src/cli/commands/compat/providers/codex.cjs.map +0 -1
  594. package/dist/src/cli/commands/compat/providers/codex.d.mts +0 -17
  595. package/dist/src/cli/commands/compat/providers/codex.d.mts.map +0 -1
  596. package/dist/src/cli/commands/compat/providers/codex.mjs +0 -170
  597. package/dist/src/cli/commands/compat/providers/codex.mjs.map +0 -1
  598. package/dist/src/cli/commands/compat/providers/index.cjs +0 -65
  599. package/dist/src/cli/commands/compat/providers/index.cjs.map +0 -1
  600. package/dist/src/cli/commands/compat/providers/index.d.mts +0 -15
  601. package/dist/src/cli/commands/compat/providers/index.d.mts.map +0 -1
  602. package/dist/src/cli/commands/compat/providers/index.mjs +0 -45
  603. package/dist/src/cli/commands/compat/providers/index.mjs.map +0 -1
  604. package/dist/src/cli/commands/compat/providers/process.cjs +0 -172
  605. package/dist/src/cli/commands/compat/providers/process.cjs.map +0 -1
  606. package/dist/src/cli/commands/compat/providers/process.d.mts +0 -33
  607. package/dist/src/cli/commands/compat/providers/process.d.mts.map +0 -1
  608. package/dist/src/cli/commands/compat/providers/process.mjs +0 -159
  609. package/dist/src/cli/commands/compat/providers/process.mjs.map +0 -1
  610. package/dist/src/cli/commands/compat/providers/shared.cjs +0 -76
  611. package/dist/src/cli/commands/compat/providers/shared.cjs.map +0 -1
  612. package/dist/src/cli/commands/compat/providers/shared.d.mts +0 -40
  613. package/dist/src/cli/commands/compat/providers/shared.d.mts.map +0 -1
  614. package/dist/src/cli/commands/compat/providers/shared.mjs +0 -61
  615. package/dist/src/cli/commands/compat/providers/shared.mjs.map +0 -1
  616. package/dist/src/cli/commands/compat/types.d.mts +0 -31
  617. package/dist/src/cli/commands/compat/types.d.mts.map +0 -1
  618. package/dist/src/cli/commands/init/constants.cjs +0 -11
  619. package/dist/src/cli/commands/init/constants.cjs.map +0 -1
  620. package/dist/src/cli/commands/init/constants.mjs +0 -11
  621. package/dist/src/cli/commands/init/constants.mjs.map +0 -1
@@ -0,0 +1,90 @@
1
+ import path from "node:path";
2
+ import { readWorkspaceDeclarations } from "@agimon-ai/po-config/config";
3
+ import { BACKGROUND_CONTEXT, getOrThrow } from "@agimon-ai/po-core/platform";
4
+ import { identifyWorkspace, readWorkspaceMarker } from "@agimon-ai/po-core/history";
5
+ //#region src/builders/server/workspaceAdmission.ts
6
+ /** Declaration association must stay on its source root, including after a YAML edit or restore. */
7
+ async function assertWorkspaceDeclarationRoot(files, root, declaration) {
8
+ if (declaration.path === void 0) return;
9
+ const target = path.resolve(root, declaration.path);
10
+ if (getOrThrow(await files.canonicalPath(target, BACKGROUND_CONTEXT)) !== root) throw new Error(`Workspace '${declaration.name}' must use its declaration repository root (path: .); subfolder and cross-repository paths are not supported.`);
11
+ }
12
+ /** Refresh validates associations again, since an admitted declaration can change its path later. */
13
+ async function readAdmittedWorkspaceDeclarations(files, root, records) {
14
+ const result = await readWorkspaceDeclarations({
15
+ fs: files,
16
+ repositoryRoot: root,
17
+ context: BACKGROUND_CONTEXT
18
+ });
19
+ const associated = new Set(records.filter((record) => record.root === root).map((record) => record.declaration));
20
+ await Promise.all(result.declarations.filter((entry) => associated.has(entry.name)).map((entry) => assertWorkspaceDeclarationRoot(files, root, entry)));
21
+ return result;
22
+ }
23
+ /** A broken remembered workspace must not prevent unrelated workspaces or the server from starting. */
24
+ async function refreshRememberedWorkspaceDeclarations(records, refresh, onNotice) {
25
+ const roots = new Set(records.filter((record) => record.sandbox === void 0).map((record) => record.root));
26
+ await Promise.all([...roots].map(async (root) => {
27
+ try {
28
+ await refresh(root);
29
+ } catch (error) {
30
+ onNotice(`Workspace declarations at '${root}' are unavailable: ${error instanceof Error ? error.message : String(error)}`);
31
+ }
32
+ }));
33
+ }
34
+ /** Resolves admission policy without mutating records, so siblings retain their own identity and policy. */
35
+ async function resolveWorkspaceAdmission(records, checkoutRoot, requested, config) {
36
+ let declarationInstructions;
37
+ if (requested.declaration !== void 0 && requested.workspaceId === void 0) {
38
+ if (records.some((record) => record.root === checkoutRoot && record.sandbox !== void 0)) throw new Error("Declared workspaces cannot use a sandboxed folder.");
39
+ const { declarations } = await readWorkspaceDeclarations({
40
+ fs: config.files,
41
+ repositoryRoot: checkoutRoot,
42
+ context: BACKGROUND_CONTEXT
43
+ });
44
+ const declaration = declarations.find((entry) => entry.name === requested.declaration);
45
+ if (declaration === void 0) throw new Error(`Workspace '${requested.declaration}' is not declared in this folder.`);
46
+ await assertWorkspaceDeclarationRoot(config.files, checkoutRoot, declaration);
47
+ declarationInstructions = declaration.instructions;
48
+ }
49
+ const marker = readWorkspaceMarker(checkoutRoot);
50
+ const { id, root, moved } = identifyWorkspace({
51
+ records,
52
+ checkoutRoot,
53
+ marker,
54
+ declaration: requested.declaration
55
+ });
56
+ const previous = records.find((record) => record.id === id);
57
+ const owner = records.find((record) => record.root === root);
58
+ return {
59
+ record: {
60
+ ...previous,
61
+ id,
62
+ root,
63
+ ...requested.kind === void 0 ? {} : { kind: requested.kind },
64
+ ...requested.declaration === void 0 ? { name: requested.name?.trim() || previous?.name } : {
65
+ name: previous?.name ?? requested.declaration,
66
+ declaration: requested.declaration,
67
+ repositoryId: previous?.repositoryId ?? marker ?? owner?.repositoryId ?? owner?.id ?? id
68
+ },
69
+ ...previous === void 0 && declarationInstructions !== void 0 ? { instructions: declarationInstructions } : {},
70
+ ...requested.declaration !== void 0 || requested.instructions === void 0 ? {} : { instructions: requested.instructions }
71
+ },
72
+ moved,
73
+ siblings: moved && previous !== void 0 ? records.filter((sibling) => sibling.root === previous.root && (sibling.repositoryId ?? sibling.id) === (previous.repositoryId ?? previous.id)).map((sibling) => ({
74
+ ...sibling,
75
+ root
76
+ })) : []
77
+ };
78
+ }
79
+ /** Host-local prompt args, never persisted back into session policy or open-session records. */
80
+ function workspaceSessionAgentArgs(args, workspace, parentSessionId) {
81
+ return parentSessionId === void 0 && workspace?.instructions ? [
82
+ ...args,
83
+ "--append-system-prompt",
84
+ `Workspace instructions:\n${workspace.instructions}`
85
+ ] : [...args];
86
+ }
87
+ //#endregion
88
+ export { assertWorkspaceDeclarationRoot, readAdmittedWorkspaceDeclarations, refreshRememberedWorkspaceDeclarations, resolveWorkspaceAdmission, workspaceSessionAgentArgs };
89
+
90
+ //# sourceMappingURL=workspaceAdmission.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workspaceAdmission.mjs","names":[],"sources":["../../../../src/builders/server/workspaceAdmission.ts"],"sourcesContent":["import path from 'node:path';\n\nimport { readWorkspaceDeclarations } from '@agimon-ai/po-config/config';\nimport { identifyWorkspace, readWorkspaceMarker, type WorkspaceRecord } from '@agimon-ai/po-core/history';\nimport { BACKGROUND_CONTEXT, getOrThrow, type FileSystem } from '@agimon-ai/po-core/platform';\n\nexport interface WorkspaceAdmissionOptions {\n /** Assigned only by the host's workspace-free session allocator. */\n kind?: 'session';\n name?: string;\n declaration?: string;\n instructions?: string;\n /** Internal readmission of a stored record, without reimporting repository policy. */\n workspaceId?: string;\n}\n\n/** Declaration association must stay on its source root, including after a YAML edit or restore. */\nexport async function assertWorkspaceDeclarationRoot(\n files: FileSystem,\n root: string,\n declaration: { name: string; path?: string },\n): Promise<void> {\n if (declaration.path === undefined) return;\n const target = path.resolve(root, declaration.path);\n const declaredRoot = getOrThrow(await files.canonicalPath(target, BACKGROUND_CONTEXT));\n // ponytail: cross-repository paths need durable declaration-source identity before they can retain metadata.\n if (declaredRoot !== root)\n throw new Error(\n `Workspace '${declaration.name}' must use its declaration repository root (path: .); subfolder and cross-repository paths are not supported.`,\n );\n}\n\n/** Refresh validates associations again, since an admitted declaration can change its path later. */\nexport async function readAdmittedWorkspaceDeclarations(\n files: FileSystem,\n root: string,\n records: readonly WorkspaceRecord[],\n) {\n const result = await readWorkspaceDeclarations({ fs: files, repositoryRoot: root, context: BACKGROUND_CONTEXT });\n const associated = new Set(records.filter((record) => record.root === root).map((record) => record.declaration));\n await Promise.all(\n result.declarations\n .filter((entry) => associated.has(entry.name))\n .map((entry) => assertWorkspaceDeclarationRoot(files, root, entry)),\n );\n return result;\n}\n\n/** A broken remembered workspace must not prevent unrelated workspaces or the server from starting. */\nexport async function refreshRememberedWorkspaceDeclarations(\n records: readonly WorkspaceRecord[],\n refresh: (root: string) => Promise<void>,\n onNotice: (message: string) => void,\n): Promise<void> {\n const roots = new Set(records.filter((record) => record.sandbox === undefined).map((record) => record.root));\n await Promise.all(\n [...roots].map(async (root) => {\n try {\n await refresh(root);\n } catch (error) {\n onNotice(\n `Workspace declarations at '${root}' are unavailable: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n }),\n );\n}\n\n/** Resolves admission policy without mutating records, so siblings retain their own identity and policy. */\nexport async function resolveWorkspaceAdmission(\n records: readonly WorkspaceRecord[],\n checkoutRoot: string,\n requested: WorkspaceAdmissionOptions,\n config: { files: FileSystem; environment: NodeJS.ProcessEnv; homeDirectory: string },\n): Promise<{ record: WorkspaceRecord; moved: boolean; siblings: WorkspaceRecord[] }> {\n let declarationInstructions: string | undefined;\n if (requested.declaration !== undefined && requested.workspaceId === undefined) {\n if (records.some((record) => record.root === checkoutRoot && record.sandbox !== undefined))\n throw new Error('Declared workspaces cannot use a sandboxed folder.');\n const { declarations } = await readWorkspaceDeclarations({\n fs: config.files,\n repositoryRoot: checkoutRoot,\n context: BACKGROUND_CONTEXT,\n });\n const declaration = declarations.find((entry) => entry.name === requested.declaration);\n if (declaration === undefined)\n throw new Error(`Workspace '${requested.declaration}' is not declared in this folder.`);\n await assertWorkspaceDeclarationRoot(config.files, checkoutRoot, declaration);\n declarationInstructions = declaration.instructions;\n }\n const marker = readWorkspaceMarker(checkoutRoot);\n const { id, root, moved } = identifyWorkspace({ records, checkoutRoot, marker, declaration: requested.declaration });\n const previous = records.find((record) => record.id === id);\n const owner = records.find((record) => record.root === root);\n const record: WorkspaceRecord = {\n ...previous,\n id,\n root,\n ...(requested.kind === undefined ? {} : { kind: requested.kind }),\n ...(requested.declaration === undefined\n ? { name: requested.name?.trim() || previous?.name }\n : {\n name: previous?.name ?? requested.declaration,\n declaration: requested.declaration,\n repositoryId: previous?.repositoryId ?? marker ?? owner?.repositoryId ?? owner?.id ?? id,\n }),\n ...(previous === undefined && declarationInstructions !== undefined\n ? { instructions: declarationInstructions }\n : {}),\n ...(requested.declaration !== undefined || requested.instructions === undefined\n ? {}\n : { instructions: requested.instructions }),\n };\n const siblings =\n moved && previous !== undefined\n ? records\n .filter(\n (sibling) =>\n sibling.root === previous.root &&\n (sibling.repositoryId ?? sibling.id) === (previous.repositoryId ?? previous.id),\n )\n .map((sibling) => ({ ...sibling, root }))\n : [];\n return { record, moved, siblings };\n}\n\n/** Host-local prompt args, never persisted back into session policy or open-session records. */\nexport function workspaceSessionAgentArgs(\n args: readonly string[],\n workspace: WorkspaceRecord | undefined,\n parentSessionId?: string,\n): string[] {\n return parentSessionId === undefined && workspace?.instructions\n ? [...args, '--append-system-prompt', `Workspace instructions:\\n${workspace.instructions}`]\n : [...args];\n}\n"],"mappings":";;;;;;AAiBA,eAAsB,+BACpB,OACA,MACA,aACe;CACf,IAAI,YAAY,SAAS,KAAA,GAAW;CACpC,MAAM,SAAS,KAAK,QAAQ,MAAM,YAAY,IAAI;CAGlD,IAFqB,WAAW,MAAM,MAAM,cAAc,QAAQ,kBAA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A4B,UAAU;CAAc,IACxF,CAAC,GAAG,IAAI;AACd"}
@@ -1,28 +1,37 @@
1
1
  const require_runtime = require("../../../_virtual/_rolldown/runtime.cjs");
2
2
  const require_index = require("../../composition/repository/index.cjs");
3
- let node_fs = require("node:fs");
4
- node_fs = require_runtime.__toESM(node_fs, 1);
3
+ let node_fs_promises = require("node:fs/promises");
4
+ node_fs_promises = require_runtime.__toESM(node_fs_promises, 1);
5
5
  let _agimon_ai_po_core_history = require("@agimon-ai/po-core/history");
6
6
  //#region src/builders/server/workspaceCheckout.ts
7
7
  /**
8
8
  * The recorded workspace a directory's checkout belongs to: its root, a
9
- * subdirectory, or a worktree whose git data names it. Undefined for a
9
+ * subdirectory, or a worktree whose git data names it. An exact root match wins
10
+ * without reading the checkout's marker. Undefined for a
10
11
  * directory that is not a checkout of any recorded workspace, or whose
11
12
  * workspace root has gone, so a caller never admits a new workspace by accident.
12
13
  */
13
- function checkoutWorkspaceId(records, cwd) {
14
- let checkoutRoot;
14
+ async function checkoutWorkspaceId(records, cwd, preferredWorkspaceId) {
15
+ let target;
15
16
  try {
16
- checkoutRoot = node_fs.default.realpathSync(require_index.findRepositoryRoot(cwd));
17
+ target = await node_fs_promises.default.realpath(cwd);
17
18
  } catch {
18
19
  return;
19
20
  }
21
+ const checkoutRoot = await require_index.resolveWorkspaceRoot(target);
22
+ const preferred = records.find((record) => record.id === preferredWorkspaceId);
23
+ if (preferred?.root === checkoutRoot) return preferred.id;
24
+ const exact = records.find((record) => record.root === checkoutRoot && record.declaration === void 0) ?? records.find((record) => record.root === checkoutRoot);
25
+ if (exact !== void 0) return exact.id;
26
+ const marker = (0, _agimon_ai_po_core_history.readWorkspaceMarker)(checkoutRoot);
20
27
  const identity = (0, _agimon_ai_po_core_history.identifyWorkspace)({
21
28
  records,
22
29
  checkoutRoot,
23
- marker: (0, _agimon_ai_po_core_history.readWorkspaceMarker)(checkoutRoot)
30
+ marker,
31
+ declaration: preferred?.declaration
24
32
  });
25
33
  if (identity.moved || !records.some((record) => record.id === identity.id)) return void 0;
34
+ if (preferred !== void 0) return identity.id === preferred.id && (preferred.repositoryId ?? preferred.id) === marker ? preferred.id : void 0;
26
35
  return identity.id;
27
36
  }
28
37
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"workspaceCheckout.cjs","names":["fs","findRepositoryRoot","identifyWorkspace","readWorkspaceMarker"],"sources":["../../../../src/builders/server/workspaceCheckout.ts"],"sourcesContent":["import fs from 'node:fs';\n\nimport { identifyWorkspace, readWorkspaceMarker } from '@agimon-ai/po-core/history';\n\nimport { findRepositoryRoot } from '../../composition/repository';\n\n/**\n * The recorded workspace a directory's checkout belongs to: its root, a\n * subdirectory, or a worktree whose git data names it. Undefined for a\n * directory that is not a checkout of any recorded workspace, or whose\n * workspace root has gone, so a caller never admits a new workspace by accident.\n */\nexport function checkoutWorkspaceId(records: readonly { id: string; root: string }[], cwd: string): string | undefined {\n let checkoutRoot: string;\n try {\n checkoutRoot = fs.realpathSync(findRepositoryRoot(cwd));\n } catch {\n return undefined;\n }\n const identity = identifyWorkspace({ records, checkoutRoot, marker: readWorkspaceMarker(checkoutRoot) });\n if (identity.moved || !records.some((record) => record.id === identity.id)) return undefined;\n return identity.id;\n}\n"],"mappings":";;;;;;;;;;;;AAYA,SAAgB,oBAAoB,SAAkD,KAAiC;CACrH,IAAI;CACJ,IAAI;EACF,eAAeA,QAAAA,QAAG,aAAaC,cAAAA,mBAAmB,GAAG,CAAC;CACxD,QAAQ;EACN;CACF;CACA,MAAM,YAAA,GAAWC,2BAAAA,kBAAAA,CAAkB;EAAE;EAAS;EAAc,SAAA,GAAQC,2BAAAA,oBAAAA,CAAoB,YAAY;CAAE,CAAC;CACvG,IAAI,SAAS,SAAS,CAAC,QAAQ,MAAM,WAAW,OAAO,OAAO,SAAS,EAAE,GAAG,OAAO,KAAA;CACnF,OAAO,SAAS;AAClB"}
1
+ {"version":3,"file":"workspaceCheckout.cjs","names":["fs","resolveWorkspaceRoot","readWorkspaceMarker","identifyWorkspace"],"sources":["../../../../src/builders/server/workspaceCheckout.ts"],"sourcesContent":["import fs from 'node:fs/promises';\n\nimport { identifyWorkspace, readWorkspaceMarker } from '@agimon-ai/po-core/history';\n\nimport { resolveWorkspaceRoot } from '../../composition/repository';\n\n/**\n * The recorded workspace a directory's checkout belongs to: its root, a\n * subdirectory, or a worktree whose git data names it. An exact root match wins\n * without reading the checkout's marker. Undefined for a\n * directory that is not a checkout of any recorded workspace, or whose\n * workspace root has gone, so a caller never admits a new workspace by accident.\n */\nexport async function checkoutWorkspaceId(\n records: readonly { id: string; root: string; repositoryId?: string; declaration?: string }[],\n cwd: string,\n preferredWorkspaceId?: string,\n): Promise<string | undefined> {\n let target: string;\n try {\n // Walk the target's real ancestors, never a symlink's lexical checkout.\n target = await fs.realpath(cwd);\n } catch {\n // An unavailable directory cannot establish workspace membership.\n return undefined;\n }\n const checkoutRoot = await resolveWorkspaceRoot(target);\n const preferred = records.find((record) => record.id === preferredWorkspaceId);\n if (preferred?.root === checkoutRoot) return preferred.id;\n const exact =\n records.find((record) => record.root === checkoutRoot && record.declaration === undefined) ??\n records.find((record) => record.root === checkoutRoot);\n if (exact !== undefined) return exact.id;\n // sync: po-core/history exposes only Node-only sync workspace identity APIs across this package boundary.\n const marker = readWorkspaceMarker(checkoutRoot);\n const identity = identifyWorkspace({ records, checkoutRoot, marker, declaration: preferred?.declaration });\n if (identity.moved || !records.some((record) => record.id === identity.id)) return undefined;\n if (preferred !== undefined)\n return identity.id === preferred.id && (preferred.repositoryId ?? preferred.id) === marker\n ? preferred.id\n : undefined;\n return identity.id;\n}\n"],"mappings":";;;;;;;;;;;;;AAaA,eAAsB,oBACpB,SACA,KACA,sBAC6B;CAC7B,IAAI;CACJ,IAAI;EAEF,SAAS,MAAMA,iBAAAA,QAAG,SAAS,GAAG;CAChC,QAAQ;EAEN;CACF;CACA,MAAM,eAAe,MAAMC,cAAAA,qBAAqB,MAAM;CACtD,MAAM,YAAY,QAAQ,MAAM,WAAW,OAAO,OAAO,oBAAoB;CAC7E,IAAI,WAAW,SAAS,cAAc,OAAO,UAAU;CACvD,MAAM,QACJ,QAAQ,MAAM,WAAW,OAAO,SAAS,gBAAgB,OAAO,gBAAgB,KAAA,CAAS,KACzF,QAAQ,MAAM,WAAW,OAAO,SAAS,YAAY;CACvD,IAAI,UAAU,KAAA,GAAW,OAAO,MAAM;CAEtC,MAAM,UAAA,GAASC,2BAAAA,oBAAAA,CAAoB,YAAY;CAC/C,MAAM,YAAA,GAAWC,2BAAAA,kBAAAA,CAAkB;EAAE;EAAS;EAAc;EAAQ,aAAa,WAAW;CAAY,CAAC;CACzG,IAAI,SAAS,SAAS,CAAC,QAAQ,MAAM,WAAW,OAAO,OAAO,SAAS,EAAE,GAAG,OAAO,KAAA;CACnF,IAAI,cAAc,KAAA,GAChB,OAAO,SAAS,OAAO,UAAU,OAAO,UAAU,gBAAgB,UAAU,QAAQ,SAChF,UAAU,KACV,KAAA;CACN,OAAO,SAAS;AAClB"}
@@ -1,26 +1,35 @@
1
- import { findRepositoryRoot } from "../../composition/repository/index.mjs";
2
- import fs from "node:fs";
1
+ import { resolveWorkspaceRoot } from "../../composition/repository/index.mjs";
2
+ import fs from "node:fs/promises";
3
3
  import { identifyWorkspace, readWorkspaceMarker } from "@agimon-ai/po-core/history";
4
4
  //#region src/builders/server/workspaceCheckout.ts
5
5
  /**
6
6
  * The recorded workspace a directory's checkout belongs to: its root, a
7
- * subdirectory, or a worktree whose git data names it. Undefined for a
7
+ * subdirectory, or a worktree whose git data names it. An exact root match wins
8
+ * without reading the checkout's marker. Undefined for a
8
9
  * directory that is not a checkout of any recorded workspace, or whose
9
10
  * workspace root has gone, so a caller never admits a new workspace by accident.
10
11
  */
11
- function checkoutWorkspaceId(records, cwd) {
12
- let checkoutRoot;
12
+ async function checkoutWorkspaceId(records, cwd, preferredWorkspaceId) {
13
+ let target;
13
14
  try {
14
- checkoutRoot = fs.realpathSync(findRepositoryRoot(cwd));
15
+ target = await fs.realpath(cwd);
15
16
  } catch {
16
17
  return;
17
18
  }
19
+ const checkoutRoot = await resolveWorkspaceRoot(target);
20
+ const preferred = records.find((record) => record.id === preferredWorkspaceId);
21
+ if (preferred?.root === checkoutRoot) return preferred.id;
22
+ const exact = records.find((record) => record.root === checkoutRoot && record.declaration === void 0) ?? records.find((record) => record.root === checkoutRoot);
23
+ if (exact !== void 0) return exact.id;
24
+ const marker = readWorkspaceMarker(checkoutRoot);
18
25
  const identity = identifyWorkspace({
19
26
  records,
20
27
  checkoutRoot,
21
- marker: readWorkspaceMarker(checkoutRoot)
28
+ marker,
29
+ declaration: preferred?.declaration
22
30
  });
23
31
  if (identity.moved || !records.some((record) => record.id === identity.id)) return void 0;
32
+ if (preferred !== void 0) return identity.id === preferred.id && (preferred.repositoryId ?? preferred.id) === marker ? preferred.id : void 0;
24
33
  return identity.id;
25
34
  }
26
35
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"workspaceCheckout.mjs","names":[],"sources":["../../../../src/builders/server/workspaceCheckout.ts"],"sourcesContent":["import fs from 'node:fs';\n\nimport { identifyWorkspace, readWorkspaceMarker } from '@agimon-ai/po-core/history';\n\nimport { findRepositoryRoot } from '../../composition/repository';\n\n/**\n * The recorded workspace a directory's checkout belongs to: its root, a\n * subdirectory, or a worktree whose git data names it. Undefined for a\n * directory that is not a checkout of any recorded workspace, or whose\n * workspace root has gone, so a caller never admits a new workspace by accident.\n */\nexport function checkoutWorkspaceId(records: readonly { id: string; root: string }[], cwd: string): string | undefined {\n let checkoutRoot: string;\n try {\n checkoutRoot = fs.realpathSync(findRepositoryRoot(cwd));\n } catch {\n return undefined;\n }\n const identity = identifyWorkspace({ records, checkoutRoot, marker: readWorkspaceMarker(checkoutRoot) });\n if (identity.moved || !records.some((record) => record.id === identity.id)) return undefined;\n return identity.id;\n}\n"],"mappings":";;;;;;;;;;AAYA,SAAgB,oBAAoB,SAAkD,KAAiC;CACrH,IAAI;CACJ,IAAI;EACF,eAAe,GAAG,aAAa,mBAAmB,GAAG,CAAC;CACxD,QAAQ;EACN;CACF;CACA,MAAM,WAAW,kBAAkB;EAAE;EAAS;EAAc,QAAQ,oBAAoB,YAAY;CAAE,CAAC;CACvG,IAAI,SAAS,SAAS,CAAC,QAAQ,MAAM,WAAW,OAAO,OAAO,SAAS,EAAE,GAAG,OAAO,KAAA;CACnF,OAAO,SAAS;AAClB"}
1
+ {"version":3,"file":"workspaceCheckout.mjs","names":[],"sources":["../../../../src/builders/server/workspaceCheckout.ts"],"sourcesContent":["import fs from 'node:fs/promises';\n\nimport { identifyWorkspace, readWorkspaceMarker } from '@agimon-ai/po-core/history';\n\nimport { resolveWorkspaceRoot } from '../../composition/repository';\n\n/**\n * The recorded workspace a directory's checkout belongs to: its root, a\n * subdirectory, or a worktree whose git data names it. An exact root match wins\n * without reading the checkout's marker. Undefined for a\n * directory that is not a checkout of any recorded workspace, or whose\n * workspace root has gone, so a caller never admits a new workspace by accident.\n */\nexport async function checkoutWorkspaceId(\n records: readonly { id: string; root: string; repositoryId?: string; declaration?: string }[],\n cwd: string,\n preferredWorkspaceId?: string,\n): Promise<string | undefined> {\n let target: string;\n try {\n // Walk the target's real ancestors, never a symlink's lexical checkout.\n target = await fs.realpath(cwd);\n } catch {\n // An unavailable directory cannot establish workspace membership.\n return undefined;\n }\n const checkoutRoot = await resolveWorkspaceRoot(target);\n const preferred = records.find((record) => record.id === preferredWorkspaceId);\n if (preferred?.root === checkoutRoot) return preferred.id;\n const exact =\n records.find((record) => record.root === checkoutRoot && record.declaration === undefined) ??\n records.find((record) => record.root === checkoutRoot);\n if (exact !== undefined) return exact.id;\n // sync: po-core/history exposes only Node-only sync workspace identity APIs across this package boundary.\n const marker = readWorkspaceMarker(checkoutRoot);\n const identity = identifyWorkspace({ records, checkoutRoot, marker, declaration: preferred?.declaration });\n if (identity.moved || !records.some((record) => record.id === identity.id)) return undefined;\n if (preferred !== undefined)\n return identity.id === preferred.id && (preferred.repositoryId ?? preferred.id) === marker\n ? preferred.id\n : undefined;\n return identity.id;\n}\n"],"mappings":";;;;;;;;;;;AAaA,eAAsB,oBACpB,SACA,KACA,sBAC6B;CAC7B,IAAI;CACJ,IAAI;EAEF,SAAS,MAAM,GAAG,SAAS,GAAG;CAChC,QAAQ;EAEN;CACF;CACA,MAAM,eAAe,MAAM,qBAAqB,MAAM;CACtD,MAAM,YAAY,QAAQ,MAAM,WAAW,OAAO,OAAO,oBAAoB;CAC7E,IAAI,WAAW,SAAS,cAAc,OAAO,UAAU;CACvD,MAAM,QACJ,QAAQ,MAAM,WAAW,OAAO,SAAS,gBAAgB,OAAO,gBAAgB,KAAA,CAAS,KACzF,QAAQ,MAAM,WAAW,OAAO,SAAS,YAAY;CACvD,IAAI,UAAU,KAAA,GAAW,OAAO,MAAM;CAEtC,MAAM,SAAS,oBAAoB,YAAY;CAC/C,MAAM,WAAW,kBAAkB;EAAE;EAAS;EAAc;EAAQ,aAAa,WAAW;CAAY,CAAC;CACzG,IAAI,SAAS,SAAS,CAAC,QAAQ,MAAM,WAAW,OAAO,OAAO,SAAS,EAAE,GAAG,OAAO,KAAA;CACnF,IAAI,cAAc,KAAA,GAChB,OAAO,SAAS,OAAO,UAAU,OAAO,UAAU,gBAAgB,UAAU,QAAQ,SAChF,UAAU,KACV,KAAA;CACN,OAAO,SAAS;AAClB"}
@@ -4,10 +4,10 @@ const require_bundleAssetPolicy = require("./bundleAssetPolicy.cjs");
4
4
  const require_webDevRoots = require("./webDevRoots.cjs");
5
5
  const require_webPluginGenerate = require("./webPluginGenerate.cjs");
6
6
  const require_webPluginVite = require("./webPluginVite.cjs");
7
- let node_fs = require("node:fs");
8
- node_fs = require_runtime.__toESM(node_fs, 1);
9
7
  let node_path = require("node:path");
10
8
  node_path = require_runtime.__toESM(node_path, 1);
9
+ let node_fs_promises = require("node:fs/promises");
10
+ node_fs_promises = require_runtime.__toESM(node_fs_promises, 1);
11
11
  //#region src/builders/web/bundle.ts
12
12
  /** Shared runtime packages every plugin's client code must resolve to the host copies. */
13
13
  const DEDUPED_RUNTIMES = [
@@ -74,14 +74,14 @@ function manifestClosure(manifest, entryKey) {
74
74
  async function bundleCockpitWeb(options) {
75
75
  const notice = options.onNotice ?? (() => {});
76
76
  const hostRoot = options.hostRoot;
77
- const plugins = require_webPluginScan.scanWebPlugins(hostRoot, options.pluginRoots, notice);
77
+ const plugins = await require_webPluginScan.scanWebPlugins(hostRoot, options.pluginRoots, notice);
78
78
  notice(`bundling the cockpit with ${String(plugins.length)} web plugin(s): ${plugins.map((p) => p.pluginId).join(", ")}`);
79
79
  const generatedDir = node_path.default.join(options.outDir, "generated");
80
80
  const assetsDir = node_path.default.join(options.outDir, "web");
81
81
  const pluginsDir = node_path.default.join(options.outDir, "plugins");
82
- const generated = require_webPluginGenerate.writeSyncWebPluginModules(plugins, generatedDir, hostRoot);
82
+ const generated = await require_webPluginGenerate.writeSyncWebPluginModules(plugins, generatedDir, hostRoot);
83
83
  const roots = [...new Set(options.pluginRoots.map((root) => node_path.default.resolve(root)))];
84
- node_fs.default.writeFileSync(node_path.default.join(options.outDir, require_webDevRoots.PLUGIN_ROOTS_FILE), `${JSON.stringify(roots, null, 2)}\n`);
84
+ await node_fs_promises.default.writeFile(node_path.default.join(options.outDir, require_webDevRoots.PLUGIN_ROOTS_FILE), `${JSON.stringify(roots, null, 2)}\n`);
85
85
  const { build } = await import("vite");
86
86
  const { default: react } = await import("@vitejs/plugin-react");
87
87
  const { default: tailwindcss } = await import("@tailwindcss/vite");
@@ -112,6 +112,7 @@ async function bundleCockpitWeb(options) {
112
112
  envDir: false,
113
113
  logLevel: "warn",
114
114
  base: "./",
115
+ root: hostRoot,
115
116
  plugins: [
116
117
  require_webPluginVite.webPluginRuntimeFacadePlugin(hostRoot),
117
118
  react(),
@@ -142,13 +143,13 @@ async function bundleCockpitWeb(options) {
142
143
  }
143
144
  }
144
145
  });
145
- const manifest = JSON.parse(node_fs.default.readFileSync(node_path.default.join(pluginsDir, "manifest.json"), "utf8"));
146
- const manifestRoot = node_fs.default.realpathSync(process.cwd());
147
- const closures = new Map(plugins.map((plugin) => {
148
- const entryPath = node_fs.default.realpathSync(generated.slotEntryPaths[plugin.slot]);
146
+ const manifest = JSON.parse(await node_fs_promises.default.readFile(node_path.default.join(pluginsDir, "manifest.json"), "utf8"));
147
+ const manifestRoot = await node_fs_promises.default.realpath(hostRoot);
148
+ const closures = new Map(await Promise.all(plugins.map(async (plugin) => {
149
+ const entryPath = await node_fs_promises.default.realpath(generated.slotEntryPaths[plugin.slot]);
149
150
  return [plugin.slot, manifestClosure(manifest, node_path.default.relative(manifestRoot, entryPath).split(node_path.default.sep).join("/"))];
150
- }));
151
- const styles = require_webPluginGenerate.writeWebPluginStyleEntries(plugins, generatedDir, hostRoot);
151
+ })));
152
+ const styles = await require_webPluginGenerate.writeWebPluginStyleEntries(plugins, generatedDir, hostRoot);
152
153
  const stylesRoot = node_path.default.dirname(styles.baseEntryPath);
153
154
  await build({
154
155
  configFile: false,
@@ -174,8 +175,8 @@ async function bundleCockpitWeb(options) {
174
175
  }
175
176
  }
176
177
  });
177
- const styleManifest = JSON.parse(node_fs.default.readFileSync(node_path.default.join(pluginsDir, "styles.manifest.json"), "utf8"));
178
- node_fs.default.rmSync(node_path.default.join(pluginsDir, "styles.manifest.json"));
178
+ const styleManifest = JSON.parse(await node_fs_promises.default.readFile(node_path.default.join(pluginsDir, "styles.manifest.json"), "utf8"));
179
+ await node_fs_promises.default.rm(node_path.default.join(pluginsDir, "styles.manifest.json"));
179
180
  const emitted = (entry) => {
180
181
  const record = styleManifest[node_path.default.relative(stylesRoot, entry).split(node_path.default.sep).join("/")];
181
182
  const file = record?.file?.endsWith(".css") ? record.file : record?.css?.[0];
@@ -191,7 +192,7 @@ async function bundleCockpitWeb(options) {
191
192
  return [plugin.slot, entry === void 0 ? base : emitted(entry)];
192
193
  }));
193
194
  const pluginStyles = Object.fromEntries([...slotStyles].map(([slot, style]) => [slot, style.file]));
194
- node_fs.default.writeFileSync(node_path.default.join(pluginsDir, "index.html"), "<!doctype html>\n<title>Po plugin composition</title>\n");
195
+ await node_fs_promises.default.writeFile(node_path.default.join(pluginsDir, "index.html"), "<!doctype html>\n<title>Po plugin composition</title>\n");
195
196
  return {
196
197
  assetsDir,
197
198
  pluginsDir,
@@ -205,6 +206,7 @@ async function bundleCockpitWeb(options) {
205
206
  slot: plugin.slot,
206
207
  packageDir: plugin.packageDir,
207
208
  isHost: plugin.isHost,
209
+ ...plugin.brain === void 0 ? {} : { brain: plugin.brain },
208
210
  entry: closure.entry,
209
211
  files: [.../* @__PURE__ */ new Set([
210
212
  ...closure.files,
@@ -1 +1 @@
1
- {"version":3,"file":"bundle.cjs","names":["scanWebPlugins","path","writeSyncWebPluginModules","PLUGIN_ROOTS_FILE","webPluginOverridePlugin","bundleAssetPolicyPlugin","webPluginRuntimeAliases","webPluginCssAlias","webPluginRuntimeFacadePlugin","isWebPluginFacade","WEB_PLUGIN_FACADE_CHUNK","fs","writeWebPluginStyleEntries","BASE_STYLE_ENTRY","pluginStyleEntryName"],"sources":["../../../../src/builders/web/bundle.ts"],"sourcesContent":["import fs from 'node:fs';\nimport path from 'node:path';\n\nimport { bundleAssetPolicyPlugin } from './bundleAssetPolicy';\nimport { PLUGIN_ROOTS_FILE } from './webDevRoots';\nimport {\n BASE_STYLE_ENTRY,\n pluginStyleEntryName,\n writeSyncWebPluginModules,\n writeWebPluginStyleEntries,\n} from './webPluginGenerate';\nimport { scanWebPlugins } from './webPluginScan';\nimport {\n isWebPluginFacade,\n WEB_PLUGIN_FACADE_CHUNK,\n webPluginCssAlias,\n webPluginOverridePlugin,\n webPluginRuntimeAliases,\n webPluginRuntimeFacadePlugin,\n} from './webPluginVite';\n\n/** Shared runtime packages every plugin's client code must resolve to the host copies. */\nconst DEDUPED_RUNTIMES = [\n 'react',\n 'react-dom',\n '@tanstack/store',\n '@tanstack/react-store',\n '@tanstack/react-router',\n '@agimon-ai/po-core',\n '@agimon-ai/po-web-dashboard',\n '@agimon-ai/po-web-components',\n // The sealed transport is a module singleton whose nonce counters every\n // plugin shares; a second copy would start counting at zero.\n '@agimon-ai/po-web-security',\n // CodeMirror's state and view are singletons in all but name: a document\n // built against one copy is rejected by an editor from the other, and a\n // grammar chunk resolved separately from the editor is exactly how a second\n // copy appears.\n '@codemirror/state',\n '@codemirror/view',\n];\n\nexport interface BundleCockpitWebOptions {\n hostRoot: string;\n /** Package roots to scan for poWeb manifests, usually the installed composition. */\n pluginRoots: readonly string[];\n /** Output directory; receives web/, plugins/, generated/, and pluginRoots.json. */\n outDir: string;\n onNotice?: (message: string) => void;\n}\n\nexport interface BundleCockpitWebResult {\n /** The cockpit shell with the host's own plugins; every other plugin ships in pluginsDir. */\n assetsDir: string;\n /** Standalone session plugin composition artifacts. */\n pluginsDir: string;\n pluginIds: string[];\n /** Every declared plugin copy with its slot and the files its slot entry reaches. */\n plugins: WebPluginBuildRecord[];\n /** The shared content-hashed Tailwind stylesheet below pluginsDir, keyed by slot. */\n pluginStyles: Record<string, string>;\n /** The same shared stylesheet, also loaded by mounts without plugins. */\n baseStyle: string;\n}\n\n/** One plugin copy in a build: its slot entry and the emitted files that entry can load. */\nexport interface WebPluginBuildRecord {\n pluginId: string;\n slot: string;\n packageDir: string;\n isHost: boolean;\n /** The slot entry module below pluginsDir. */\n entry: string;\n /** Every file the entry reaches through imports, plus the shared stylesheet and its assets. */\n files: string[];\n /** The stylesheets of the entry's static import closure, which a mount loads up front. */\n css: string[];\n}\n\ninterface ManifestChunk {\n file: string;\n imports?: string[];\n dynamicImports?: string[];\n css?: string[];\n assets?: string[];\n}\n\n/**\n * The files one manifest entry reaches: `files` follows static and dynamic imports and holds\n * every chunk, asset, and stylesheet on the way; `css` follows static imports only.\n */\nexport function manifestClosure(\n manifest: Readonly<Record<string, ManifestChunk>>,\n entryKey: string,\n): { entry: string; files: string[]; css: string[] } {\n const chunkOf = (key: string): ManifestChunk => {\n const chunk = manifest[key];\n if (chunk === undefined) throw new Error(`The composition manifest has no chunk '${key}'.`);\n return chunk;\n };\n const files = new Set<string>();\n const visited = new Set<string>();\n const walk = (key: string): void => {\n if (visited.has(key)) return;\n visited.add(key);\n const chunk = chunkOf(key);\n files.add(chunk.file);\n for (const file of [...(chunk.css ?? []), ...(chunk.assets ?? [])]) files.add(file);\n for (const next of [...(chunk.imports ?? []), ...(chunk.dynamicImports ?? [])]) walk(next);\n };\n walk(entryKey);\n const css = new Set<string>();\n const staticVisited = new Set<string>();\n const walkStatic = (key: string): void => {\n if (staticVisited.has(key)) return;\n staticVisited.add(key);\n const chunk = chunkOf(key);\n for (const file of chunk.css ?? []) css.add(file);\n for (const next of chunk.imports ?? []) walkStatic(next);\n };\n walkStatic(entryKey);\n return { entry: chunkOf(entryKey).file, files: [...files], css: [...css] };\n}\n\n/**\n * Builds the cockpit SPA against the installed plugin set.\n *\n * This is what `po sync` calls: manifests come from the given package\n * roots (no hardcoded plugin dependencies anywhere), the generated entry\n * modules are aliased over the committed builtin registry, and Vite compiles\n * the host shell and, separately, each plugin's shipped web source into one\n * ES-module composition with an entry per slot, so each plugin and its assets ship once.\n * The roots file beside\n * the bundle lets the dev server serve the same composition with hot reload.\n */\nexport async function bundleCockpitWeb(options: BundleCockpitWebOptions): Promise<BundleCockpitWebResult> {\n const notice = options.onNotice ?? ((): void => {});\n const hostRoot = options.hostRoot;\n const plugins = scanWebPlugins(hostRoot, options.pluginRoots, notice);\n notice(\n `bundling the cockpit with ${String(plugins.length)} web plugin(s): ${plugins.map((p) => p.pluginId).join(', ')}`,\n );\n\n const generatedDir = path.join(options.outDir, 'generated');\n const assetsDir = path.join(options.outDir, 'web');\n const pluginsDir = path.join(options.outDir, 'plugins');\n const generated = writeSyncWebPluginModules(plugins, generatedDir, hostRoot);\n const roots = [...new Set(options.pluginRoots.map((root) => path.resolve(root)))];\n fs.writeFileSync(path.join(options.outDir, PLUGIN_ROOTS_FILE), `${JSON.stringify(roots, null, 2)}\\n`);\n\n // Vite and its plugins are regular dependencies so this works from an\n // installed package, not only the workspace.\n const { build } = await import('vite');\n const { default: react } = await import('@vitejs/plugin-react');\n const { default: tailwindcss } = await import('@tailwindcss/vite');\n\n const clientRoot = path.join(hostRoot, 'src', 'web');\n\n // The shell carries only the host's own plugins; the rest load from the composition below.\n await build({\n configFile: false,\n envDir: false,\n logLevel: 'warn',\n root: clientRoot,\n plugins: [webPluginOverridePlugin(clientRoot, generated.shell), react(), tailwindcss(), bundleAssetPolicyPlugin()],\n resolve: {\n dedupe: [...DEDUPED_RUNTIMES],\n alias: [...webPluginRuntimeAliases(clientRoot), webPluginCssAlias(generated.shell)],\n },\n build: {\n outDir: assetsDir,\n emptyOutDir: true,\n sourcemap: false,\n },\n });\n\n // One ES-module composition: an entry per slot exporting its webPlugin, shared chunks\n // between them, and the shared runtime modules read from the page through facades.\n await build({\n configFile: false,\n envDir: false,\n logLevel: 'warn',\n base: './',\n plugins: [webPluginRuntimeFacadePlugin(hostRoot), react(), tailwindcss()],\n resolve: {\n dedupe: [...DEDUPED_RUNTIMES],\n alias: [webPluginCssAlias(generated)],\n },\n build: {\n cssCodeSplit: true,\n modulePreload: false,\n outDir: pluginsDir,\n emptyOutDir: true,\n sourcemap: false,\n assetsInlineLimit: 0,\n manifest: 'manifest.json',\n rollupOptions: {\n input: generated.slotEntryPaths,\n // Each slot entry is loaded for its webPlugin export, so it must keep it.\n preserveEntrySignatures: 'exports-only',\n output: {\n format: 'es',\n entryFileNames: 'slots/[name]-[hash].js',\n chunkFileNames: 'chunks/[name]-[hash].js',\n assetFileNames: 'assets/[name]-[hash][extname]',\n manualChunks: (id) => (isWebPluginFacade(id) ? WEB_PLUGIN_FACADE_CHUNK : undefined),\n },\n },\n },\n });\n const manifest = JSON.parse(fs.readFileSync(path.join(pluginsDir, 'manifest.json'), 'utf8')) as Record<\n string,\n ManifestChunk\n >;\n // Manifest keys are the entry sources relative to the build root, which is the working directory.\n const manifestRoot = fs.realpathSync(process.cwd());\n const closures = new Map(\n plugins.map((plugin) => {\n const entryPath = fs.realpathSync(generated.slotEntryPaths[plugin.slot]);\n return [plugin.slot, manifestClosure(manifest, path.relative(manifestRoot, entryPath).split(path.sep).join('/'))];\n }),\n );\n\n // One content-hashed Tailwind stylesheet for the shell, fallback template, and all plugins.\n const styles = writeWebPluginStyleEntries(plugins, generatedDir, hostRoot);\n const stylesRoot = path.dirname(styles.baseEntryPath);\n await build({\n configFile: false,\n envDir: false,\n logLevel: 'warn',\n root: stylesRoot,\n base: './',\n plugins: [tailwindcss()],\n resolve: {\n alias: [{ find: /^\\.\\/webPluginSources\\.generated\\.css$/, replacement: styles.baseSourcesPath }],\n },\n build: {\n cssCodeSplit: true,\n outDir: pluginsDir,\n emptyOutDir: false,\n sourcemap: false,\n assetsInlineLimit: 0,\n manifest: 'styles.manifest.json',\n rollupOptions: {\n input: Object.fromEntries([\n [BASE_STYLE_ENTRY, styles.baseEntryPath],\n ...[...styles.pluginEntryPaths].map(([slot, entry]) => [pluginStyleEntryName(slot), entry]),\n ]),\n output: { assetFileNames: 'assets/[name]-[hash][extname]' },\n },\n },\n });\n const styleManifest = JSON.parse(fs.readFileSync(path.join(pluginsDir, 'styles.manifest.json'), 'utf8')) as Record<\n string,\n { file?: string; css?: string[]; assets?: string[] }\n >;\n fs.rmSync(path.join(pluginsDir, 'styles.manifest.json'));\n const emitted = (entry: string): { file: string; assets: string[] } => {\n const record = styleManifest[path.relative(stylesRoot, entry).split(path.sep).join('/')];\n const file = record?.file?.endsWith('.css') ? record.file : record?.css?.[0];\n if (file === undefined) throw new Error(`The stylesheet entry '${entry}' emitted no CSS file.`);\n return { file, assets: record?.assets ?? [] };\n };\n const base = emitted(styles.baseEntryPath);\n const slotStyles = new Map(\n plugins.map((plugin) => {\n const entry = styles.pluginEntryPaths.get(plugin.slot);\n return [plugin.slot, entry === undefined ? base : emitted(entry)];\n }),\n );\n const pluginStyles = Object.fromEntries([...slotStyles].map(([slot, style]) => [slot, style.file]));\n fs.writeFileSync(path.join(pluginsDir, 'index.html'), '<!doctype html>\\n<title>Po plugin composition</title>\\n');\n\n return {\n assetsDir,\n pluginsDir,\n pluginIds: plugins.map((plugin) => plugin.pluginId),\n plugins: plugins.map((plugin) => {\n const closure = closures.get(plugin.slot);\n const style = slotStyles.get(plugin.slot);\n if (closure === undefined || style === undefined) throw new Error(`The slot '${plugin.slot}' emitted no entry.`);\n return {\n pluginId: plugin.pluginId,\n slot: plugin.slot,\n packageDir: plugin.packageDir,\n isHost: plugin.isHost,\n entry: closure.entry,\n // The shared stylesheet and its fonts must be verified for every slot.\n files: [...new Set([...closure.files, style.file, ...style.assets])],\n css: closure.css,\n };\n }),\n pluginStyles,\n baseStyle: base.file,\n };\n}\n"],"mappings":";;;;;;;;;;;;AAsBA,MAAM,mBAAmB;CACvB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CAGA;CAKA;CACA;AACF;;;;;AAmDA,SAAgB,gBACd,UACA,UACmD;CACnD,MAAM,WAAW,QAA+B;EAC9C,MAAM,QAAQ,SAAS;EACvB,IAAI,UAAU,KAAA,GAAW,MAAM,IAAI,MAAM,0CAA0C,IAAI,GAAG;EAC1F,OAAO;CACT;CACA,MAAM,wBAAQ,IAAI,IAAY;CAC9B,MAAM,0BAAU,IAAI,IAAY;CAChC,MAAM,QAAQ,QAAsB;EAClC,IAAI,QAAQ,IAAI,GAAG,GAAG;EACtB,QAAQ,IAAI,GAAG;EACf,MAAM,QAAQ,QAAQ,GAAG;EACzB,MAAM,IAAI,MAAM,IAAI;EACpB,KAAK,MAAM,QAAQ,CAAC,GAAI,MAAM,OAAO,CAAC,GAAI,GAAI,MAAM,UAAU,CAAC,CAAE,GAAG,MAAM,IAAI,IAAI;EAClF,KAAK,MAAM,QAAQ,CAAC,GAAI,MAAM,WAAW,CAAC,GAAI,GAAI,MAAM,kBAAkB,CAAC,CAAE,GAAG,KAAK,IAAI;CAC3F;CACA,KAAK,QAAQ;CACb,MAAM,sBAAM,IAAI,IAAY;CAC5B,MAAM,gCAAgB,IAAI,IAAY;CACtC,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webPluginRuntimeAliases","webPluginCssAlias","webPluginRuntimeFacadePlugin","isWebPluginFacade","WEB_PLUGIN_FACADE_CHUNK","writeWebPluginStyleEntries","BASE_STYLE_ENTRY","pluginStyleEntryName"],"sources":["../../../../src/builders/web/bundle.ts"],"sourcesContent":["import fs from 'node:fs/promises';\nimport path from 'node:path';\n\nimport { bundleAssetPolicyPlugin } from './bundleAssetPolicy';\nimport { PLUGIN_ROOTS_FILE } from './webDevRoots';\nimport {\n BASE_STYLE_ENTRY,\n pluginStyleEntryName,\n writeSyncWebPluginModules,\n writeWebPluginStyleEntries,\n} from './webPluginGenerate';\nimport type { DeclaredWebPlugin } from './webPluginManifest';\nimport { scanWebPlugins } from './webPluginScan';\nimport {\n isWebPluginFacade,\n WEB_PLUGIN_FACADE_CHUNK,\n webPluginCssAlias,\n webPluginOverridePlugin,\n webPluginRuntimeAliases,\n webPluginRuntimeFacadePlugin,\n} from './webPluginVite';\n\n/** Shared runtime packages every plugin's client code must resolve to the host copies. */\nconst DEDUPED_RUNTIMES = [\n 'react',\n 'react-dom',\n '@tanstack/store',\n '@tanstack/react-store',\n '@tanstack/react-router',\n '@agimon-ai/po-core',\n '@agimon-ai/po-web-dashboard',\n '@agimon-ai/po-web-components',\n // The sealed transport is a module singleton whose nonce counters every\n // plugin shares; a second copy would start counting at zero.\n '@agimon-ai/po-web-security',\n // CodeMirror's state and view are singletons in all but name: a document\n // built against one copy is rejected by an editor from the other, and a\n // grammar chunk resolved separately from the editor is exactly how a second\n // copy appears.\n '@codemirror/state',\n '@codemirror/view',\n];\n\nexport interface BundleCockpitWebOptions {\n hostRoot: string;\n /** Package roots to scan for poWeb manifests, usually the installed composition. */\n pluginRoots: readonly string[];\n /** Output directory; receives web/, plugins/, generated/, and pluginRoots.json. */\n outDir: string;\n onNotice?: (message: string) => void;\n}\n\nexport interface BundleCockpitWebResult {\n /** The cockpit shell with the host's own plugins; every other plugin ships in pluginsDir. */\n assetsDir: string;\n /** Standalone session plugin composition artifacts. */\n pluginsDir: string;\n pluginIds: string[];\n /** Every declared plugin copy with its slot and the files its slot entry reaches. */\n plugins: WebPluginBuildRecord[];\n /** The shared content-hashed Tailwind stylesheet below pluginsDir, keyed by slot. */\n pluginStyles: Record<string, string>;\n /** The same shared stylesheet, also loaded by mounts without plugins. */\n baseStyle: string;\n}\n\n/** One plugin copy in a build: its slot entry and the emitted files that entry can load. */\nexport interface WebPluginBuildRecord {\n pluginId: string;\n slot: string;\n packageDir: string;\n isHost: boolean;\n /** Descriptions from the same package manifest used to build this plugin copy. */\n brain?: DeclaredWebPlugin['brain'];\n /** The slot entry module below pluginsDir. */\n entry: string;\n /** Every file the entry reaches through imports, plus the shared stylesheet and its assets. */\n files: string[];\n /** The stylesheets of the entry's static import closure, which a mount loads up front. */\n css: string[];\n}\n\ninterface ManifestChunk {\n file: string;\n imports?: string[];\n dynamicImports?: string[];\n css?: string[];\n assets?: string[];\n}\n\n/**\n * The files one manifest entry reaches: `files` follows static and dynamic imports and holds\n * every chunk, asset, and stylesheet on the way; `css` follows static imports only.\n */\nexport function manifestClosure(\n manifest: Readonly<Record<string, ManifestChunk>>,\n entryKey: string,\n): { entry: string; files: string[]; css: string[] } {\n const chunkOf = (key: string): ManifestChunk => {\n const chunk = manifest[key];\n if (chunk === undefined) throw new Error(`The composition manifest has no chunk '${key}'.`);\n return chunk;\n };\n const files = new Set<string>();\n const visited = new Set<string>();\n const walk = (key: string): void => {\n if (visited.has(key)) return;\n visited.add(key);\n const chunk = chunkOf(key);\n files.add(chunk.file);\n for (const file of [...(chunk.css ?? []), ...(chunk.assets ?? [])]) files.add(file);\n for (const next of [...(chunk.imports ?? []), ...(chunk.dynamicImports ?? [])]) walk(next);\n };\n walk(entryKey);\n const css = new Set<string>();\n const staticVisited = new Set<string>();\n const walkStatic = (key: string): void => {\n if (staticVisited.has(key)) return;\n staticVisited.add(key);\n const chunk = chunkOf(key);\n for (const file of chunk.css ?? []) css.add(file);\n for (const next of chunk.imports ?? []) walkStatic(next);\n };\n walkStatic(entryKey);\n return { entry: chunkOf(entryKey).file, files: [...files], css: [...css] };\n}\n\n/**\n * Builds the cockpit SPA against the installed plugin set.\n *\n * This is what `po sync` calls: manifests come from the given package\n * roots (no hardcoded plugin dependencies anywhere), the generated entry\n * modules are aliased over the committed builtin registry, and Vite compiles\n * the host shell and, separately, each plugin's shipped web source into one\n * ES-module composition with an entry per slot, so each plugin and its assets ship once.\n * The roots file beside\n * the bundle lets the dev server serve the same composition with hot reload.\n */\nexport async function bundleCockpitWeb(options: BundleCockpitWebOptions): Promise<BundleCockpitWebResult> {\n const notice = options.onNotice ?? ((): void => {});\n const hostRoot = options.hostRoot;\n const plugins = await scanWebPlugins(hostRoot, options.pluginRoots, notice);\n notice(\n `bundling the cockpit with ${String(plugins.length)} web plugin(s): ${plugins.map((p) => p.pluginId).join(', ')}`,\n );\n\n const generatedDir = path.join(options.outDir, 'generated');\n const assetsDir = path.join(options.outDir, 'web');\n const pluginsDir = path.join(options.outDir, 'plugins');\n const generated = await writeSyncWebPluginModules(plugins, generatedDir, hostRoot);\n const roots = [...new Set(options.pluginRoots.map((root) => path.resolve(root)))];\n await fs.writeFile(path.join(options.outDir, PLUGIN_ROOTS_FILE), `${JSON.stringify(roots, null, 2)}\\n`);\n\n // Vite and its plugins are regular dependencies so this works from an\n // installed package, not only the workspace.\n const { build } = await import('vite');\n const { default: react } = await import('@vitejs/plugin-react');\n const { default: tailwindcss } = await import('@tailwindcss/vite');\n\n const clientRoot = path.join(hostRoot, 'src', 'web');\n\n // The shell carries only the host's own plugins; the rest load from the composition below.\n await build({\n configFile: false,\n envDir: false,\n logLevel: 'warn',\n root: clientRoot,\n plugins: [webPluginOverridePlugin(clientRoot, generated.shell), react(), tailwindcss(), bundleAssetPolicyPlugin()],\n resolve: {\n dedupe: [...DEDUPED_RUNTIMES],\n alias: [...webPluginRuntimeAliases(clientRoot), webPluginCssAlias(generated.shell)],\n },\n build: {\n outDir: assetsDir,\n emptyOutDir: true,\n sourcemap: false,\n },\n });\n\n // One ES-module composition: an entry per slot exporting its webPlugin, shared chunks\n // between them, and the shared runtime modules read from the page through facades.\n await build({\n configFile: false,\n envDir: false,\n logLevel: 'warn',\n base: './',\n // Deduped runtimes resolve from the build root; the host's copy is the one the page runtime holds,\n // and the one the facades read their export names from. The working directory may not have one.\n root: hostRoot,\n plugins: [webPluginRuntimeFacadePlugin(hostRoot), react(), tailwindcss()],\n resolve: {\n dedupe: [...DEDUPED_RUNTIMES],\n alias: [webPluginCssAlias(generated)],\n },\n build: {\n cssCodeSplit: true,\n modulePreload: false,\n outDir: pluginsDir,\n emptyOutDir: true,\n sourcemap: false,\n assetsInlineLimit: 0,\n manifest: 'manifest.json',\n rollupOptions: {\n input: generated.slotEntryPaths,\n // Each slot entry is loaded for its webPlugin export, so it must keep it.\n preserveEntrySignatures: 'exports-only',\n output: {\n format: 'es',\n entryFileNames: 'slots/[name]-[hash].js',\n chunkFileNames: 'chunks/[name]-[hash].js',\n assetFileNames: 'assets/[name]-[hash][extname]',\n manualChunks: (id) => (isWebPluginFacade(id) ? WEB_PLUGIN_FACADE_CHUNK : undefined),\n },\n },\n },\n });\n const manifest = JSON.parse(await fs.readFile(path.join(pluginsDir, 'manifest.json'), 'utf8')) as Record<\n string,\n ManifestChunk\n >;\n // Manifest keys are the entry sources relative to the build root.\n const manifestRoot = await fs.realpath(hostRoot);\n const closures = new Map(\n await Promise.all(\n plugins.map(async (plugin) => {\n const entryPath = await fs.realpath(generated.slotEntryPaths[plugin.slot]);\n return [\n plugin.slot,\n manifestClosure(manifest, path.relative(manifestRoot, entryPath).split(path.sep).join('/')),\n ] as const;\n }),\n ),\n );\n\n // One content-hashed Tailwind stylesheet for the shell, fallback template, and all plugins.\n const styles = await writeWebPluginStyleEntries(plugins, generatedDir, hostRoot);\n const stylesRoot = path.dirname(styles.baseEntryPath);\n await build({\n configFile: false,\n envDir: false,\n logLevel: 'warn',\n root: stylesRoot,\n base: './',\n plugins: [tailwindcss()],\n resolve: {\n alias: [{ find: /^\\.\\/webPluginSources\\.generated\\.css$/, replacement: styles.baseSourcesPath }],\n },\n build: {\n cssCodeSplit: true,\n outDir: pluginsDir,\n emptyOutDir: false,\n sourcemap: false,\n assetsInlineLimit: 0,\n manifest: 'styles.manifest.json',\n rollupOptions: {\n input: Object.fromEntries([\n [BASE_STYLE_ENTRY, styles.baseEntryPath],\n ...[...styles.pluginEntryPaths].map(([slot, entry]) => [pluginStyleEntryName(slot), entry]),\n ]),\n output: { assetFileNames: 'assets/[name]-[hash][extname]' },\n },\n },\n });\n const styleManifest = JSON.parse(await fs.readFile(path.join(pluginsDir, 'styles.manifest.json'), 'utf8')) as Record<\n string,\n { file?: string; css?: string[]; assets?: string[] }\n >;\n await fs.rm(path.join(pluginsDir, 'styles.manifest.json'));\n const emitted = (entry: string): { file: string; assets: string[] } => {\n const record = styleManifest[path.relative(stylesRoot, entry).split(path.sep).join('/')];\n const file = record?.file?.endsWith('.css') ? record.file : record?.css?.[0];\n if (file === undefined) throw new Error(`The stylesheet entry '${entry}' emitted no CSS file.`);\n return { file, assets: record?.assets ?? [] };\n };\n const base = emitted(styles.baseEntryPath);\n const slotStyles = new Map(\n plugins.map((plugin) => {\n const entry = styles.pluginEntryPaths.get(plugin.slot);\n return [plugin.slot, entry === undefined ? base : emitted(entry)];\n }),\n );\n const pluginStyles = Object.fromEntries([...slotStyles].map(([slot, style]) => [slot, style.file]));\n await fs.writeFile(path.join(pluginsDir, 'index.html'), '<!doctype html>\\n<title>Po plugin composition</title>\\n');\n\n return {\n assetsDir,\n pluginsDir,\n pluginIds: plugins.map((plugin) => plugin.pluginId),\n plugins: plugins.map((plugin) => {\n const closure = closures.get(plugin.slot);\n const style = slotStyles.get(plugin.slot);\n if (closure === undefined || style === undefined) throw new Error(`The slot '${plugin.slot}' emitted no entry.`);\n return {\n pluginId: plugin.pluginId,\n slot: plugin.slot,\n packageDir: plugin.packageDir,\n isHost: plugin.isHost,\n ...(plugin.brain === undefined ? {} : { brain: plugin.brain }),\n entry: closure.entry,\n // The shared stylesheet and its fonts must be verified for every slot.\n files: [...new Set([...closure.files, style.file, ...style.assets])],\n css: closure.css,\n };\n }),\n pluginStyles,\n baseStyle: base.file,\n };\n}\n"],"mappings":";;;;;;;;;;;;AAuBA,MAAM,mBAAmB;CACvB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CAGA;CAKA;CACA;AACF;;;;;AAqDA,SAAgB,gBACd,UACA,UACmD;CACnD,MAAM,WAAW,QAA+B;EAC9C,MAAM,QAAQ,SAAS;EACvB,IAAI,UAAU,KAAA,GAAW,MAAM,IAAI,MAAM,0CAA0C,IAAI,GAAG;EAC1F,OAAO;CACT;CACA,MAAM,wBAAQ,IAAI,IAAY;CAC9B,MAAM,0BAAU,IAAI,IAAY;CAChC,MAAM,QAAQ,QAAsB;EAClC,IAAI,QAAQ,IAAI,GAAG,GAAG;EACtB,QAAQ,IAAI,GAAG;EACf,MAAM,QAAQ,QAAQ,GAAG;EACzB,MAAM,IAAI,MAAM,IAAI;EACpB,KAAK,MAAM,QAAQ,CAAC,GAAI,MAAM,OAAO,CAAC,GAAI,GAAI,MAAM,UAAU,CAAC,CAAE,GAAG,MAAM,IAAI,IAAI;EAClF,KAAK,MAAM,QAAQ,CAAC,GAAI,MAAM,WAAW,CAAC,GAAI,GAAI,MAAM,kBAAkB,CAAC,CAAE,GAAG,KAAK,IAAI;CAC3F;CACA,KAAK,QAAQ;CACb,MAAM,sBAAM,IAAI,IAAY;CAC5B,MAAM,gCAAgB,IAAI,IAAY;CACtC,MAAM,cAAc,QAAsB;EACxC,IAAI,cAAc,IAAI,GAAG,GAAG;EAC5B,cAAc,IAAI,GAAG;EACrB,MAAM,QAAQ,QAAQ,GAAG;EACzB,KAAK,MAAM,QAAQ,MAAM,OAAO,CAAC,GAAG,IAAI,IAAI,IAAI;EAChD,KAAK,MAAM,QAAQ,MAAM,WAAW,CAAC,GAAG,WAAW,IAAI;CACzD;CACA,WAAW,QAAQ;CACnB,OAA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zC,MAAM,aAAa,IAAI,IACrB,QAAQ,KAAK,WAAW;EACtB,MAAM,QAAQ,OAAO,iBAAiB,IAAI,OAAO,IAAI;EACrD,OAAO,CAAC,OAAO,MAAM,UAAU,KAAA,IAAY,OAAO,QAAQ,KAAK,CAAC;CAClE,CAAC,CACH;CACA,MAAM,eAAe,OAAO,YAAY,CAAC,GAAG,UAAU,CAAC,CAAC,KAAK,CAAC,MAAM,WAAW,CAAC,MAAM,MAAM,IAAI,CAAC,CAAC;CAClG,MAAME,iBAAAA,QAAG,UAAUF,UAAAA,QAAK,KAAK,YAAY,YAAY,GAAG,yDAAyD;CAEjH,OAAO;EACL;EACA;EACA,WAAW,QAAQ,KAAK,WAAW,OAAO,QAAQ;EAClD,SAAS,QAAQ,KAAK,WAAW;GAC/B,MAAM,UAAU,SAAS,IAAI,OAAO,IAAI;GACxC,MAAM,QAAQ,WAAW,IAAI,OAAO,IAAI;GACxC,IAAI,YAAY,KAAA,KAAa,UAAU,KAAA,GAAW,MAAM,IAAI,MAAM,aAAa,OAAO,KAAK,oBAAoB;GAC/G,OAAO;IACL,UAAU,OAAO;IACjB,MAAM,OAAO;IACb,YAAY,OAAO;IACnB,QAAQ,OAAO;IACf,GAAI,OAAO,UAAU,KAAA,IAAY,CAAC,IAAI,EAAE,OAAO,OAAO,MAAM;IAC5D,OAAO,QAAQ;IAEf,OAAO,CAAC,mBAAG,IAAI,IAAI;KAAC,GAAG,QAAQ;KAAO,MAAM;KAAM,GAAG,MAAM;IAAM,CAAC,CAAC;IACnE,KAAK,QAAQ;GACf;EACF,CAAC;EACD;EACA,WAAW,KAAK;CAClB;AACF"}
@@ -1,3 +1,4 @@
1
+ import { DeclaredWebPlugin } from "./webPluginManifest.mjs";
1
2
  //#region src/builders/web/bundle.d.ts
2
3
  export interface BundleCockpitWebOptions {
3
4
  hostRoot: string;
@@ -26,6 +27,8 @@ export interface WebPluginBuildRecord {
26
27
  slot: string;
27
28
  packageDir: string;
28
29
  isHost: boolean;
30
+ /** Descriptions from the same package manifest used to build this plugin copy. */
31
+ brain?: DeclaredWebPlugin['brain'];
29
32
  /** The slot entry module below pluginsDir. */
30
33
  entry: string;
31
34
  /** Every file the entry reaches through imports, plus the shared stylesheet and its assets. */
@@ -1 +1 @@
1
- {"version":3,"file":"bundle.d.mts","names":[],"sources":["../../../../src/builders/web/bundle.ts"],"mappings":";iBA0CiB;EACf;;EAEA;;EAEA;EACA,YAAY;;iBAGG;;EAEf;;EAEA;EACA;;EAEA,SAAS;;EAET,cAAc;;EAEd;;;iBAIe;EACf;EACA;EACA;EACA;;EAEA;;EAEA;;EAEA;;UAGQ;EACR;EACA;EACA;EACA;EACA;;;;;;wBAOc,gBACd,UAAU,SAAS,eAAe,iBAClC;EACG;EAAe;EAAiB;;;;;;;;;;;;;wBAyCf,iBAAiB,SAAS,0BAA0B,QAAQ"}
1
+ {"version":3,"file":"bundle.d.mts","names":[],"sources":["../../../../src/builders/web/bundle.ts"],"mappings":";;iBA2CiB;EACf;;EAEA;;EAEA;EACA,YAAY;;iBAGG;;EAEf;;EAEA;EACA;;EAEA,SAAS;;EAET,cAAc;;EAEd;;;iBAIe;EACf;EACA;EACA;EACA;;EAEA,QAAQ;;EAER;;EAEA;;EAEA;;UAGQ;EACR;EACA;EACA;EACA;EACA;;;;;;wBAOc,gBACd,UAAU,SAAS,eAAe,iBAClC;EACG;EAAe;EAAiB;;;;;;;;;;;;;wBAyCf,iBAAiB,SAAS,0BAA0B,QAAQ"}
@@ -3,8 +3,8 @@ import { bundleAssetPolicyPlugin } from "./bundleAssetPolicy.mjs";
3
3
  import { PLUGIN_ROOTS_FILE } from "./webDevRoots.mjs";
4
4
  import { BASE_STYLE_ENTRY, pluginStyleEntryName, writeSyncWebPluginModules, writeWebPluginStyleEntries } from "./webPluginGenerate.mjs";
5
5
  import { WEB_PLUGIN_FACADE_CHUNK, isWebPluginFacade, webPluginCssAlias, webPluginOverridePlugin, webPluginRuntimeAliases, webPluginRuntimeFacadePlugin } from "./webPluginVite.mjs";
6
- import fs from "node:fs";
7
6
  import path from "node:path";
7
+ import fs from "node:fs/promises";
8
8
  //#region src/builders/web/bundle.ts
9
9
  /** Shared runtime packages every plugin's client code must resolve to the host copies. */
10
10
  const DEDUPED_RUNTIMES = [
@@ -71,14 +71,14 @@ function manifestClosure(manifest, entryKey) {
71
71
  async function bundleCockpitWeb(options) {
72
72
  const notice = options.onNotice ?? (() => {});
73
73
  const hostRoot = options.hostRoot;
74
- const plugins = scanWebPlugins(hostRoot, options.pluginRoots, notice);
74
+ const plugins = await scanWebPlugins(hostRoot, options.pluginRoots, notice);
75
75
  notice(`bundling the cockpit with ${String(plugins.length)} web plugin(s): ${plugins.map((p) => p.pluginId).join(", ")}`);
76
76
  const generatedDir = path.join(options.outDir, "generated");
77
77
  const assetsDir = path.join(options.outDir, "web");
78
78
  const pluginsDir = path.join(options.outDir, "plugins");
79
- const generated = writeSyncWebPluginModules(plugins, generatedDir, hostRoot);
79
+ const generated = await writeSyncWebPluginModules(plugins, generatedDir, hostRoot);
80
80
  const roots = [...new Set(options.pluginRoots.map((root) => path.resolve(root)))];
81
- fs.writeFileSync(path.join(options.outDir, PLUGIN_ROOTS_FILE), `${JSON.stringify(roots, null, 2)}\n`);
81
+ await fs.writeFile(path.join(options.outDir, PLUGIN_ROOTS_FILE), `${JSON.stringify(roots, null, 2)}\n`);
82
82
  const { build } = await import("vite");
83
83
  const { default: react } = await import("@vitejs/plugin-react");
84
84
  const { default: tailwindcss } = await import("@tailwindcss/vite");
@@ -109,6 +109,7 @@ async function bundleCockpitWeb(options) {
109
109
  envDir: false,
110
110
  logLevel: "warn",
111
111
  base: "./",
112
+ root: hostRoot,
112
113
  plugins: [
113
114
  webPluginRuntimeFacadePlugin(hostRoot),
114
115
  react(),
@@ -139,13 +140,13 @@ async function bundleCockpitWeb(options) {
139
140
  }
140
141
  }
141
142
  });
142
- const manifest = JSON.parse(fs.readFileSync(path.join(pluginsDir, "manifest.json"), "utf8"));
143
- const manifestRoot = fs.realpathSync(process.cwd());
144
- const closures = new Map(plugins.map((plugin) => {
145
- const entryPath = fs.realpathSync(generated.slotEntryPaths[plugin.slot]);
143
+ const manifest = JSON.parse(await fs.readFile(path.join(pluginsDir, "manifest.json"), "utf8"));
144
+ const manifestRoot = await fs.realpath(hostRoot);
145
+ const closures = new Map(await Promise.all(plugins.map(async (plugin) => {
146
+ const entryPath = await fs.realpath(generated.slotEntryPaths[plugin.slot]);
146
147
  return [plugin.slot, manifestClosure(manifest, path.relative(manifestRoot, entryPath).split(path.sep).join("/"))];
147
- }));
148
- const styles = writeWebPluginStyleEntries(plugins, generatedDir, hostRoot);
148
+ })));
149
+ const styles = await writeWebPluginStyleEntries(plugins, generatedDir, hostRoot);
149
150
  const stylesRoot = path.dirname(styles.baseEntryPath);
150
151
  await build({
151
152
  configFile: false,
@@ -171,8 +172,8 @@ async function bundleCockpitWeb(options) {
171
172
  }
172
173
  }
173
174
  });
174
- const styleManifest = JSON.parse(fs.readFileSync(path.join(pluginsDir, "styles.manifest.json"), "utf8"));
175
- fs.rmSync(path.join(pluginsDir, "styles.manifest.json"));
175
+ const styleManifest = JSON.parse(await fs.readFile(path.join(pluginsDir, "styles.manifest.json"), "utf8"));
176
+ await fs.rm(path.join(pluginsDir, "styles.manifest.json"));
176
177
  const emitted = (entry) => {
177
178
  const record = styleManifest[path.relative(stylesRoot, entry).split(path.sep).join("/")];
178
179
  const file = record?.file?.endsWith(".css") ? record.file : record?.css?.[0];
@@ -188,7 +189,7 @@ async function bundleCockpitWeb(options) {
188
189
  return [plugin.slot, entry === void 0 ? base : emitted(entry)];
189
190
  }));
190
191
  const pluginStyles = Object.fromEntries([...slotStyles].map(([slot, style]) => [slot, style.file]));
191
- fs.writeFileSync(path.join(pluginsDir, "index.html"), "<!doctype html>\n<title>Po plugin composition</title>\n");
192
+ await fs.writeFile(path.join(pluginsDir, "index.html"), "<!doctype html>\n<title>Po plugin composition</title>\n");
192
193
  return {
193
194
  assetsDir,
194
195
  pluginsDir,
@@ -202,6 +203,7 @@ async function bundleCockpitWeb(options) {
202
203
  slot: plugin.slot,
203
204
  packageDir: plugin.packageDir,
204
205
  isHost: plugin.isHost,
206
+ ...plugin.brain === void 0 ? {} : { brain: plugin.brain },
205
207
  entry: closure.entry,
206
208
  files: [.../* @__PURE__ */ new Set([
207
209
  ...closure.files,
@@ -1 +1 @@
1
- {"version":3,"file":"bundle.mjs","names":[],"sources":["../../../../src/builders/web/bundle.ts"],"sourcesContent":["import fs from 'node:fs';\nimport path from 'node:path';\n\nimport { bundleAssetPolicyPlugin } from './bundleAssetPolicy';\nimport { PLUGIN_ROOTS_FILE } from './webDevRoots';\nimport {\n BASE_STYLE_ENTRY,\n pluginStyleEntryName,\n writeSyncWebPluginModules,\n writeWebPluginStyleEntries,\n} from './webPluginGenerate';\nimport { scanWebPlugins } from './webPluginScan';\nimport {\n isWebPluginFacade,\n WEB_PLUGIN_FACADE_CHUNK,\n webPluginCssAlias,\n webPluginOverridePlugin,\n webPluginRuntimeAliases,\n webPluginRuntimeFacadePlugin,\n} from './webPluginVite';\n\n/** Shared runtime packages every plugin's client code must resolve to the host copies. */\nconst DEDUPED_RUNTIMES = [\n 'react',\n 'react-dom',\n '@tanstack/store',\n '@tanstack/react-store',\n '@tanstack/react-router',\n '@agimon-ai/po-core',\n '@agimon-ai/po-web-dashboard',\n '@agimon-ai/po-web-components',\n // The sealed transport is a module singleton whose nonce counters every\n // plugin shares; a second copy would start counting at zero.\n '@agimon-ai/po-web-security',\n // CodeMirror's state and view are singletons in all but name: a document\n // built against one copy is rejected by an editor from the other, and a\n // grammar chunk resolved separately from the editor is exactly how a second\n // copy appears.\n '@codemirror/state',\n '@codemirror/view',\n];\n\nexport interface BundleCockpitWebOptions {\n hostRoot: string;\n /** Package roots to scan for poWeb manifests, usually the installed composition. */\n pluginRoots: readonly string[];\n /** Output directory; receives web/, plugins/, generated/, and pluginRoots.json. */\n outDir: string;\n onNotice?: (message: string) => void;\n}\n\nexport interface BundleCockpitWebResult {\n /** The cockpit shell with the host's own plugins; every other plugin ships in pluginsDir. */\n assetsDir: string;\n /** Standalone session plugin composition artifacts. */\n pluginsDir: string;\n pluginIds: string[];\n /** Every declared plugin copy with its slot and the files its slot entry reaches. */\n plugins: WebPluginBuildRecord[];\n /** The shared content-hashed Tailwind stylesheet below pluginsDir, keyed by slot. */\n pluginStyles: Record<string, string>;\n /** The same shared stylesheet, also loaded by mounts without plugins. */\n baseStyle: string;\n}\n\n/** One plugin copy in a build: its slot entry and the emitted files that entry can load. */\nexport interface WebPluginBuildRecord {\n pluginId: string;\n slot: string;\n packageDir: string;\n isHost: boolean;\n /** The slot entry module below pluginsDir. */\n entry: string;\n /** Every file the entry reaches through imports, plus the shared stylesheet and its assets. */\n files: string[];\n /** The stylesheets of the entry's static import closure, which a mount loads up front. */\n css: string[];\n}\n\ninterface ManifestChunk {\n file: string;\n imports?: string[];\n dynamicImports?: string[];\n css?: string[];\n assets?: string[];\n}\n\n/**\n * The files one manifest entry reaches: `files` follows static and dynamic imports and holds\n * every chunk, asset, and stylesheet on the way; `css` follows static imports only.\n */\nexport function manifestClosure(\n manifest: Readonly<Record<string, ManifestChunk>>,\n entryKey: string,\n): { entry: string; files: string[]; css: string[] } {\n const chunkOf = (key: string): ManifestChunk => {\n const chunk = manifest[key];\n if (chunk === undefined) throw new Error(`The composition manifest has no chunk '${key}'.`);\n return chunk;\n };\n const files = new Set<string>();\n const visited = new Set<string>();\n const walk = (key: string): void => {\n if (visited.has(key)) return;\n visited.add(key);\n const chunk = chunkOf(key);\n files.add(chunk.file);\n for (const file of [...(chunk.css ?? []), ...(chunk.assets ?? [])]) files.add(file);\n for (const next of [...(chunk.imports ?? []), ...(chunk.dynamicImports ?? [])]) walk(next);\n };\n walk(entryKey);\n const css = new Set<string>();\n const staticVisited = new Set<string>();\n const walkStatic = (key: string): void => {\n if (staticVisited.has(key)) return;\n staticVisited.add(key);\n const chunk = chunkOf(key);\n for (const file of chunk.css ?? []) css.add(file);\n for (const next of chunk.imports ?? []) walkStatic(next);\n };\n walkStatic(entryKey);\n return { entry: chunkOf(entryKey).file, files: [...files], css: [...css] };\n}\n\n/**\n * Builds the cockpit SPA against the installed plugin set.\n *\n * This is what `po sync` calls: manifests come from the given package\n * roots (no hardcoded plugin dependencies anywhere), the generated entry\n * modules are aliased over the committed builtin registry, and Vite compiles\n * the host shell and, separately, each plugin's shipped web source into one\n * ES-module composition with an entry per slot, so each plugin and its assets ship once.\n * The roots file beside\n * the bundle lets the dev server serve the same composition with hot reload.\n */\nexport async function bundleCockpitWeb(options: BundleCockpitWebOptions): Promise<BundleCockpitWebResult> {\n const notice = options.onNotice ?? ((): void => {});\n const hostRoot = options.hostRoot;\n const plugins = scanWebPlugins(hostRoot, options.pluginRoots, notice);\n notice(\n `bundling the cockpit with ${String(plugins.length)} web plugin(s): ${plugins.map((p) => p.pluginId).join(', ')}`,\n );\n\n const generatedDir = path.join(options.outDir, 'generated');\n const assetsDir = path.join(options.outDir, 'web');\n const pluginsDir = path.join(options.outDir, 'plugins');\n const generated = writeSyncWebPluginModules(plugins, generatedDir, hostRoot);\n const roots = [...new Set(options.pluginRoots.map((root) => path.resolve(root)))];\n fs.writeFileSync(path.join(options.outDir, PLUGIN_ROOTS_FILE), `${JSON.stringify(roots, null, 2)}\\n`);\n\n // Vite and its plugins are regular dependencies so this works from an\n // installed package, not only the workspace.\n const { build } = await import('vite');\n const { default: react } = await import('@vitejs/plugin-react');\n const { default: tailwindcss } = await import('@tailwindcss/vite');\n\n const clientRoot = path.join(hostRoot, 'src', 'web');\n\n // The shell carries only the host's own plugins; the rest load from the composition below.\n await build({\n configFile: false,\n envDir: false,\n logLevel: 'warn',\n root: clientRoot,\n plugins: [webPluginOverridePlugin(clientRoot, generated.shell), react(), tailwindcss(), bundleAssetPolicyPlugin()],\n resolve: {\n dedupe: [...DEDUPED_RUNTIMES],\n alias: [...webPluginRuntimeAliases(clientRoot), webPluginCssAlias(generated.shell)],\n },\n build: {\n outDir: assetsDir,\n emptyOutDir: true,\n sourcemap: false,\n },\n });\n\n // One ES-module composition: an entry per slot exporting its webPlugin, shared chunks\n // between them, and the shared runtime modules read from the page through facades.\n await build({\n configFile: false,\n envDir: false,\n logLevel: 'warn',\n base: './',\n plugins: [webPluginRuntimeFacadePlugin(hostRoot), react(), tailwindcss()],\n resolve: {\n dedupe: [...DEDUPED_RUNTIMES],\n alias: [webPluginCssAlias(generated)],\n },\n build: {\n cssCodeSplit: true,\n modulePreload: false,\n outDir: pluginsDir,\n emptyOutDir: true,\n sourcemap: false,\n assetsInlineLimit: 0,\n manifest: 'manifest.json',\n rollupOptions: {\n input: generated.slotEntryPaths,\n // Each slot entry is loaded for its webPlugin export, so it must keep it.\n preserveEntrySignatures: 'exports-only',\n output: {\n format: 'es',\n entryFileNames: 'slots/[name]-[hash].js',\n chunkFileNames: 'chunks/[name]-[hash].js',\n assetFileNames: 'assets/[name]-[hash][extname]',\n manualChunks: (id) => (isWebPluginFacade(id) ? WEB_PLUGIN_FACADE_CHUNK : undefined),\n },\n },\n },\n });\n const manifest = JSON.parse(fs.readFileSync(path.join(pluginsDir, 'manifest.json'), 'utf8')) as Record<\n string,\n ManifestChunk\n >;\n // Manifest keys are the entry sources relative to the build root, which is the working directory.\n const manifestRoot = fs.realpathSync(process.cwd());\n const closures = new Map(\n plugins.map((plugin) => {\n const entryPath = fs.realpathSync(generated.slotEntryPaths[plugin.slot]);\n return [plugin.slot, manifestClosure(manifest, path.relative(manifestRoot, entryPath).split(path.sep).join('/'))];\n }),\n );\n\n // One content-hashed Tailwind stylesheet for the shell, fallback template, and all plugins.\n const styles = writeWebPluginStyleEntries(plugins, generatedDir, hostRoot);\n const stylesRoot = path.dirname(styles.baseEntryPath);\n await build({\n configFile: false,\n envDir: false,\n logLevel: 'warn',\n root: stylesRoot,\n base: './',\n plugins: [tailwindcss()],\n resolve: {\n alias: [{ find: /^\\.\\/webPluginSources\\.generated\\.css$/, replacement: styles.baseSourcesPath }],\n },\n build: {\n cssCodeSplit: true,\n outDir: pluginsDir,\n emptyOutDir: false,\n sourcemap: false,\n assetsInlineLimit: 0,\n manifest: 'styles.manifest.json',\n rollupOptions: {\n input: Object.fromEntries([\n [BASE_STYLE_ENTRY, styles.baseEntryPath],\n ...[...styles.pluginEntryPaths].map(([slot, entry]) => [pluginStyleEntryName(slot), entry]),\n ]),\n output: { assetFileNames: 'assets/[name]-[hash][extname]' },\n },\n },\n });\n const styleManifest = JSON.parse(fs.readFileSync(path.join(pluginsDir, 'styles.manifest.json'), 'utf8')) as Record<\n string,\n { file?: string; css?: string[]; assets?: string[] }\n >;\n fs.rmSync(path.join(pluginsDir, 'styles.manifest.json'));\n const emitted = (entry: string): { file: string; assets: string[] } => {\n const record = styleManifest[path.relative(stylesRoot, entry).split(path.sep).join('/')];\n const file = record?.file?.endsWith('.css') ? record.file : record?.css?.[0];\n if (file === undefined) throw new Error(`The stylesheet entry '${entry}' emitted no CSS file.`);\n return { file, assets: record?.assets ?? [] };\n };\n const base = emitted(styles.baseEntryPath);\n const slotStyles = new Map(\n plugins.map((plugin) => {\n const entry = styles.pluginEntryPaths.get(plugin.slot);\n return [plugin.slot, entry === undefined ? base : emitted(entry)];\n }),\n );\n const pluginStyles = Object.fromEntries([...slotStyles].map(([slot, style]) => [slot, style.file]));\n fs.writeFileSync(path.join(pluginsDir, 'index.html'), '<!doctype html>\\n<title>Po plugin composition</title>\\n');\n\n return {\n assetsDir,\n pluginsDir,\n pluginIds: plugins.map((plugin) => plugin.pluginId),\n plugins: plugins.map((plugin) => {\n const closure = closures.get(plugin.slot);\n const style = slotStyles.get(plugin.slot);\n if (closure === undefined || style === undefined) throw new Error(`The slot '${plugin.slot}' emitted no entry.`);\n return {\n pluginId: plugin.pluginId,\n slot: plugin.slot,\n packageDir: plugin.packageDir,\n isHost: plugin.isHost,\n entry: closure.entry,\n // The shared stylesheet and its fonts must be verified for every slot.\n files: [...new Set([...closure.files, style.file, ...style.assets])],\n css: closure.css,\n };\n }),\n p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I,OAAO,IAAI;GACxC,MAAM,QAAQ,WAAW,IAAI,OAAO,IAAI;GACxC,IAAI,YAAY,KAAA,KAAa,UAAU,KAAA,GAAW,MAAM,IAAI,MAAM,aAAa,OAAO,KAAK,oBAAoB;GAC/G,OAAO;IACL,UAAU,OAAO;IACjB,MAAM,OAAO;IACb,YAAY,OAAO;IACnB,QAAQ,OAAO;IACf,OAAO,QAAQ;IAEf,OAAO,CAAC,mBAAG,IAAI,IAAI;KAAC,GAAG,QAAQ;KAAO,MAAM;KAAM,GAAG,MAAM;IAAM,CAAC,CAAC;IACnE,KAAK,QAAQ;GACf;EACF,CAAC;EACD;EACA,WAAW,KAAK;CAClB;AACF"}
1
+ {"version":3,"file":"bundle.mjs","names":[],"sources":["../../../../src/builders/web/bundle.ts"],"sourcesContent":["import fs from 'node:fs/promises';\nimport path from 'node:path';\n\nimport { bundleAssetPolicyPlugin } from './bundleAssetPolicy';\nimport { PLUGIN_ROOTS_FILE } from './webDevRoots';\nimport {\n BASE_STYLE_ENTRY,\n pluginStyleEntryName,\n writeSyncWebPluginModules,\n writeWebPluginStyleEntries,\n} from './webPluginGenerate';\nimport type { DeclaredWebPlugin } from './webPluginManifest';\nimport { scanWebPlugins } from './webPluginScan';\nimport {\n isWebPluginFacade,\n WEB_PLUGIN_FACADE_CHUNK,\n webPluginCssAlias,\n webPluginOverridePlugin,\n webPluginRuntimeAliases,\n webPluginRuntimeFacadePlugin,\n} from './webPluginVite';\n\n/** Shared runtime packages every plugin's client code must resolve to the host copies. */\nconst DEDUPED_RUNTIMES = [\n 'react',\n 'react-dom',\n '@tanstack/store',\n '@tanstack/react-store',\n '@tanstack/react-router',\n '@agimon-ai/po-core',\n '@agimon-ai/po-web-dashboard',\n '@agimon-ai/po-web-components',\n // The sealed transport is a module singleton whose nonce counters every\n // plugin shares; a second copy would start counting at zero.\n '@agimon-ai/po-web-security',\n // CodeMirror's state and view are singletons in all but name: a document\n // built against one copy is rejected by an editor from the other, and a\n // grammar chunk resolved separately from the editor is exactly how a second\n // copy appears.\n '@codemirror/state',\n '@codemirror/view',\n];\n\nexport interface BundleCockpitWebOptions {\n hostRoot: string;\n /** Package roots to scan for poWeb manifests, usually the installed composition. */\n pluginRoots: readonly string[];\n /** Output directory; receives web/, plugins/, generated/, and pluginRoots.json. */\n outDir: string;\n onNotice?: (message: string) => void;\n}\n\nexport interface BundleCockpitWebResult {\n /** The cockpit shell with the host's own plugins; every other plugin ships in pluginsDir. */\n assetsDir: string;\n /** Standalone session plugin composition artifacts. */\n pluginsDir: string;\n pluginIds: string[];\n /** Every declared plugin copy with its slot and the files its slot entry reaches. */\n plugins: WebPluginBuildRecord[];\n /** The shared content-hashed Tailwind stylesheet below pluginsDir, keyed by slot. */\n pluginStyles: Record<string, string>;\n /** The same shared stylesheet, also loaded by mounts without plugins. */\n baseStyle: string;\n}\n\n/** One plugin copy in a build: its slot entry and the emitted files that entry can load. */\nexport interface WebPluginBuildRecord {\n pluginId: string;\n slot: string;\n packageDir: string;\n isHost: boolean;\n /** Descriptions from the same package manifest used to build this plugin copy. */\n brain?: DeclaredWebPlugin['brain'];\n /** The slot entry module below pluginsDir. */\n entry: string;\n /** Every file the entry reaches through imports, plus the shared stylesheet and its assets. */\n files: string[];\n /** The stylesheets of the entry's static import closure, which a mount loads up front. */\n css: string[];\n}\n\ninterface ManifestChunk {\n file: string;\n imports?: string[];\n dynamicImports?: string[];\n css?: string[];\n assets?: string[];\n}\n\n/**\n * The files one manifest entry reaches: `files` follows static and dynamic imports and holds\n * every chunk, asset, and stylesheet on the way; `css` follows static imports only.\n */\nexport function manifestClosure(\n manifest: Readonly<Record<string, ManifestChunk>>,\n entryKey: string,\n): { entry: string; files: string[]; css: string[] } {\n const chunkOf = (key: string): ManifestChunk => {\n const chunk = manifest[key];\n if (chunk === undefined) throw new Error(`The composition manifest has no chunk '${key}'.`);\n return chunk;\n };\n const files = new Set<string>();\n const visited = new Set<string>();\n const walk = (key: string): void => {\n if (visited.has(key)) return;\n visited.add(key);\n const chunk = chunkOf(key);\n files.add(chunk.file);\n for (const file of [...(chunk.css ?? []), ...(chunk.assets ?? [])]) files.add(file);\n for (const next of [...(chunk.imports ?? []), ...(chunk.dynamicImports ?? [])]) walk(next);\n };\n walk(entryKey);\n const css = new Set<string>();\n const staticVisited = new Set<string>();\n const walkStatic = (key: string): void => {\n if (staticVisited.has(key)) return;\n staticVisited.add(key);\n const chunk = chunkOf(key);\n for (const file of chunk.css ?? []) css.add(file);\n for (const next of chunk.imports ?? []) walkStatic(next);\n };\n walkStatic(entryKey);\n return { entry: chunkOf(entryKey).file, files: [...files], css: [...css] };\n}\n\n/**\n * Builds the cockpit SPA against the installed plugin set.\n *\n * This is what `po sync` calls: manifests come from the given package\n * roots (no hardcoded plugin dependencies anywhere), the generated entry\n * modules are aliased over the committed builtin registry, and Vite compiles\n * the host shell and, separately, each plugin's shipped web source into one\n * ES-module composition with an entry per slot, so each plugin and its assets ship once.\n * The roots file beside\n * the bundle lets the dev server serve the same composition with hot reload.\n */\nexport async function bundleCockpitWeb(options: BundleCockpitWebOptions): Promise<BundleCockpitWebResult> {\n const notice = options.onNotice ?? ((): void => {});\n const hostRoot = options.hostRoot;\n const plugins = await scanWebPlugins(hostRoot, options.pluginRoots, notice);\n notice(\n `bundling the cockpit with ${String(plugins.length)} web plugin(s): ${plugins.map((p) => p.pluginId).join(', ')}`,\n );\n\n const generatedDir = path.join(options.outDir, 'generated');\n const assetsDir = path.join(options.outDir, 'web');\n const pluginsDir = path.join(options.outDir, 'plugins');\n const generated = await writeSyncWebPluginModules(plugins, generatedDir, hostRoot);\n const roots = [...new Set(options.pluginRoots.map((root) => path.resolve(root)))];\n await fs.writeFile(path.join(options.outDir, PLUGIN_ROOTS_FILE), `${JSON.stringify(roots, null, 2)}\\n`);\n\n // Vite and its plugins are regular dependencies so this works from an\n // installed package, not only the workspace.\n const { build } = await import('vite');\n const { default: react } = await import('@vitejs/plugin-react');\n const { default: tailwindcss } = await import('@tailwindcss/vite');\n\n const clientRoot = path.join(hostRoot, 'src', 'web');\n\n // The shell carries only the host's own plugins; the rest load from the composition below.\n await build({\n configFile: false,\n envDir: false,\n logLevel: 'warn',\n root: clientRoot,\n plugins: [webPluginOverridePlugin(clientRoot, generated.shell), react(), tailwindcss(), bundleAssetPolicyPlugin()],\n resolve: {\n dedupe: [...DEDUPED_RUNTIMES],\n alias: [...webPluginRuntimeAliases(clientRoot), webPluginCssAlias(generated.shell)],\n },\n build: {\n outDir: assetsDir,\n emptyOutDir: true,\n sourcemap: false,\n },\n });\n\n // One ES-module composition: an entry per slot exporting its webPlugin, shared chunks\n // between them, and the shared runtime modules read from the page through facades.\n await build({\n configFile: false,\n envDir: false,\n logLevel: 'warn',\n base: './',\n // Deduped runtimes resolve from the build root; the host's copy is the one the page runtime holds,\n // and the one the facades read their export names from. The working directory may not have one.\n root: hostRoot,\n plugins: [webPluginRuntimeFacadePlugin(hostRoot), react(), tailwindcss()],\n resolve: {\n dedupe: [...DEDUPED_RUNTIMES],\n alias: [webPluginCssAlias(generated)],\n },\n build: {\n cssCodeSplit: true,\n modulePreload: false,\n outDir: pluginsDir,\n emptyOutDir: true,\n sourcemap: false,\n assetsInlineLimit: 0,\n manifest: 'manifest.json',\n rollupOptions: {\n input: generated.slotEntryPaths,\n // Each slot entry is loaded for its webPlugin export, so it must keep it.\n preserveEntrySignatures: 'exports-only',\n output: {\n format: 'es',\n entryFileNames: 'slots/[name]-[hash].js',\n chunkFileNames: 'chunks/[name]-[hash].js',\n assetFileNames: 'assets/[name]-[hash][extname]',\n manualChunks: (id) => (isWebPluginFacade(id) ? WEB_PLUGIN_FACADE_CHUNK : undefined),\n },\n },\n },\n });\n const manifest = JSON.parse(await fs.readFile(path.join(pluginsDir, 'manifest.json'), 'utf8')) as Record<\n string,\n ManifestChunk\n >;\n // Manifest keys are the entry sources relative to the build root.\n const manifestRoot = await fs.realpath(hostRoot);\n const closures = new Map(\n await Promise.all(\n plugins.map(async (plugin) => {\n const entryPath = await fs.realpath(generated.slotEntryPaths[plugin.slot]);\n return [\n plugin.slot,\n manifestClosure(manifest, path.relative(manifestRoot, entryPath).split(path.sep).join('/')),\n ] as const;\n }),\n ),\n );\n\n // One content-hashed Tailwind stylesheet for the shell, fallback template, and all plugins.\n const styles = await writeWebPluginStyleEntries(plugins, generatedDir, hostRoot);\n const stylesRoot = path.dirname(styles.baseEntryPath);\n await build({\n configFile: false,\n envDir: false,\n logLevel: 'warn',\n root: stylesRoot,\n base: './',\n plugins: [tailwindcss()],\n resolve: {\n alias: [{ find: /^\\.\\/webPluginSources\\.generated\\.css$/, replacement: styles.baseSourcesPath }],\n },\n build: {\n cssCodeSplit: true,\n outDir: pluginsDir,\n emptyOutDir: false,\n sourcemap: false,\n assetsInlineLimit: 0,\n manifest: 'styles.manifest.json',\n rollupOptions: {\n input: Object.fromEntries([\n [BASE_STYLE_ENTRY, styles.baseEntryPath],\n ...[...styles.pluginEntryPaths].map(([slot, entry]) => [pluginStyleEntryName(slot), entry]),\n ]),\n output: { assetFileNames: 'assets/[name]-[hash][extname]' },\n },\n },\n });\n const styleManifest = JSON.parse(await fs.readFile(path.join(pluginsDir, 'styles.manifest.json'), 'utf8')) as Record<\n string,\n { file?: string; css?: string[]; assets?: string[] }\n >;\n await fs.rm(path.join(pluginsDir, 'styles.manifest.json'));\n const emitted = (entry: string): { file: string; assets: string[] } => {\n const record = styleManifest[path.relative(stylesRoot, entry).split(path.sep).join('/')];\n const file = record?.file?.endsWith('.css') ? record.file : record?.css?.[0];\n if (file === undefined) throw new Error(`The stylesheet entry '${entry}' emitted no CSS file.`);\n return { file, assets: record?.assets ?? [] };\n };\n const base = emitted(styles.baseEntryPath);\n const slotStyles = new Map(\n plugins.map((plugin) => {\n const entry = styles.pluginEntryPaths.get(plugin.slot);\n return [plugin.slot, entry === undefined ? base : emitted(entry)];\n }),\n );\n const pluginStyles = Object.fromEntries([...slotStyles].map(([slot, style]) => [slot, style.file]));\n await fs.writeFile(path.join(pluginsDir, 'index.html'), '<!doctype html>\\n<title>Po plugin composition</title>\\n');\n\n return {\n assetsDir,\n pluginsDir,\n pluginIds: plugins.map((plugin) => plugin.pluginId),\n plugins: plugins.map((plugin) => {\n const closure = closures.get(plugin.slot);\n const style = slotStyles.get(plugin.slot);\n if (closure === undefined || style === undefined) throw new Error(`The slot '${plugin.slot}' emitted no entry.`);\n return {\n pluginId: plugin.pluginId,\n slot: plugin.slot,\n packageDir: plugin.packageDir,\n isHost: plugin.isHost,\n ...(plugin.brain === undefined ? {} : { brain: plugin.brain }),\n entry: closure.entry,\n // The shared stylesheet and its fonts must be verified for every slot.\n files: [...new Set([...closure.files, style.file, ...style.assets])],\n css: closure.css,\n };\n }),\n pluginStyles,\n baseStyle: base.file,\n };\n}\n"],"mappings":";;;;;;;;;AAuBA,MAAM,mBAAmB;CACvB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CAGA;CAKA;CACA;AACF;;;;;AAqDA,SAAgB,gBACd,UACA,UACmD;CACnD,MAAM,WAAW,QAA+B;EAC9C,MAAM,QAAQ,SAAS;EACvB,IAAI,UAAU,KAAA,GAAW,MAAM,IAAI,MAAM,0CAA0C,IAAI,GAAG;EAC1F,OAAO;CACT;CACA,MAAM,wBAAQ,IAAI,IAAY;CAC9B,MAAM,0BAAU,IAAI,IAAY;CAChC,MAAM,QAAQ,QAAsB;EAClC,IAAI,QAAQ,IAAI,GAAG,GAAG;EACtB,QAAQ,IAAI,GAAG;EACf,MAAM,QAAQ,QAAQ,GAAG;EACzB,MAAM,IAAI,MAAM,IAAI;EACpB,KAAK,MAAM,QAAQ,CAAC,GAAI,MAAM,OAAO,CAAC,GAAI,GAAI,MAAM,UAAU,CAAC,CAAE,GAAG,MAAM,IAAI,IAAI;EAClF,KAAK,MAAM,QAAQ,CAAC,GAAI,MAAM,WAAW,CAAC,GAAI,GAAI,MAAM,kBAAkB,CAAC,CAAE,GAAG,KAAK,IAAI;CAC3F;CACA,KAAK,QAAQ;CACb,MAAM,sBAAM,IAAI,IA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