@agimon-ai/po 0.0.0-alpha.0

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 (560) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +755 -0
  3. package/assets/banner.png +0 -0
  4. package/assets/banner.svg +25 -0
  5. package/assets/favicon.svg +15 -0
  6. package/assets/logo-light.png +0 -0
  7. package/assets/logo-light.svg +25 -0
  8. package/assets/logo.png +0 -0
  9. package/assets/logo.svg +25 -0
  10. package/assets/mascot.png +0 -0
  11. package/assets/mascot.svg +25 -0
  12. package/dist/_virtual/_rolldown/runtime.cjs +23 -0
  13. package/dist/antigravity.cjs +5 -0
  14. package/dist/antigravity.d.mts +2 -0
  15. package/dist/antigravity.mjs +2 -0
  16. package/dist/apiContracts.cjs +11 -0
  17. package/dist/apiContracts.cjs.map +1 -0
  18. package/dist/apiContracts.d.mts +52 -0
  19. package/dist/apiContracts.d.mts.map +1 -0
  20. package/dist/apiContracts.mjs +7 -0
  21. package/dist/apiContracts.mjs.map +1 -0
  22. package/dist/baseCommand.cjs +3 -0
  23. package/dist/baseCommand.d.mts +2 -0
  24. package/dist/baseCommand.mjs +2 -0
  25. package/dist/bin/cli.cjs +24 -0
  26. package/dist/bin/cli.cjs.map +1 -0
  27. package/dist/bin/cli.d.mts +1 -0
  28. package/dist/bin/cli.mjs +25 -0
  29. package/dist/bin/cli.mjs.map +1 -0
  30. package/dist/bin/doomRunner.cjs +33 -0
  31. package/dist/bin/doomRunner.cjs.map +1 -0
  32. package/dist/bin/doomRunner.d.mts +4 -0
  33. package/dist/bin/doomRunner.d.mts.map +1 -0
  34. package/dist/bin/doomRunner.mjs +32 -0
  35. package/dist/bin/doomRunner.mjs.map +1 -0
  36. package/dist/bin/serve.cjs +30 -0
  37. package/dist/bin/serve.cjs.map +1 -0
  38. package/dist/bin/serve.d.mts +1 -0
  39. package/dist/bin/serve.mjs +31 -0
  40. package/dist/bin/serve.mjs.map +1 -0
  41. package/dist/builders/cli/extensionAssembler/index.cjs +342 -0
  42. package/dist/builders/cli/extensionAssembler/index.cjs.map +1 -0
  43. package/dist/builders/cli/extensionAssembler/index.d.mts +85 -0
  44. package/dist/builders/cli/extensionAssembler/index.d.mts.map +1 -0
  45. package/dist/builders/cli/extensionAssembler/index.mjs +335 -0
  46. package/dist/builders/cli/extensionAssembler/index.mjs.map +1 -0
  47. package/dist/catalog/index.json +430 -0
  48. package/dist/cli.cjs +28 -0
  49. package/dist/cli.d.mts +11 -0
  50. package/dist/cli.mjs +11 -0
  51. package/dist/cliApp.cjs +6 -0
  52. package/dist/cliApp.d.mts +2 -0
  53. package/dist/cliApp.mjs +2 -0
  54. package/dist/codex.cjs +8 -0
  55. package/dist/codex.d.mts +2 -0
  56. package/dist/codex.mjs +2 -0
  57. package/dist/commands.cjs +18 -0
  58. package/dist/commands.d.mts +9 -0
  59. package/dist/commands.mjs +9 -0
  60. package/dist/compatibility.cjs +27 -0
  61. package/dist/compatibility.d.mts +6 -0
  62. package/dist/compatibility.mjs +6 -0
  63. package/dist/compatibilityCommand.cjs +4 -0
  64. package/dist/compatibilityCommand.d.mts +2 -0
  65. package/dist/compatibilityCommand.mjs +2 -0
  66. package/dist/compatibilityContext.cjs +3 -0
  67. package/dist/compatibilityContext.d.mts +2 -0
  68. package/dist/compatibilityContext.mjs +2 -0
  69. package/dist/compatibilityOptions.cjs +5 -0
  70. package/dist/compatibilityOptions.d.mts +2 -0
  71. package/dist/compatibilityOptions.mjs +2 -0
  72. package/dist/config.cjs +163 -0
  73. package/dist/config.d.mts +7 -0
  74. package/dist/config.mjs +7 -0
  75. package/dist/doctorCommand.cjs +5 -0
  76. package/dist/doctorCommand.d.mts +2 -0
  77. package/dist/doctorCommand.mjs +2 -0
  78. package/dist/emitMcpCommand.cjs +4 -0
  79. package/dist/emitMcpCommand.d.mts +2 -0
  80. package/dist/emitMcpCommand.mjs +2 -0
  81. package/dist/explainCommand.cjs +5 -0
  82. package/dist/explainCommand.d.mts +2 -0
  83. package/dist/explainCommand.mjs +2 -0
  84. package/dist/extensions/server.cjs +39 -0
  85. package/dist/extensions/server.cjs.map +1 -0
  86. package/dist/extensions/server.d.mts +5 -0
  87. package/dist/extensions/server.d.mts.map +1 -0
  88. package/dist/extensions/server.mjs +34 -0
  89. package/dist/extensions/server.mjs.map +1 -0
  90. package/dist/harnessContext.cjs +5 -0
  91. package/dist/harnessContext.d.mts +2 -0
  92. package/dist/harnessContext.mjs +2 -0
  93. package/dist/harnessState.cjs +19 -0
  94. package/dist/harnessState.d.mts +2 -0
  95. package/dist/harnessState.mjs +2 -0
  96. package/dist/help.cjs +12 -0
  97. package/dist/help.d.mts +6 -0
  98. package/dist/help.mjs +6 -0
  99. package/dist/index.cjs +306 -0
  100. package/dist/index.d.mts +40 -0
  101. package/dist/index.mjs +37 -0
  102. package/dist/initCommand.cjs +4 -0
  103. package/dist/initCommand.d.mts +2 -0
  104. package/dist/initCommand.mjs +2 -0
  105. package/dist/matrixOptions.cjs +28 -0
  106. package/dist/matrixOptions.d.mts +2 -0
  107. package/dist/matrixOptions.mjs +2 -0
  108. package/dist/matrixSwitcher.cjs +11 -0
  109. package/dist/matrixSwitcher.d.mts +3 -0
  110. package/dist/matrixSwitcher.mjs +3 -0
  111. package/dist/mcpFilter.cjs +9 -0
  112. package/dist/mcpFilter.d.mts +1 -0
  113. package/dist/mcpFilter.mjs +2 -0
  114. package/dist/options.cjs +3 -0
  115. package/dist/options.d.mts +2 -0
  116. package/dist/options.mjs +2 -0
  117. package/dist/process.cjs +12 -0
  118. package/dist/process.d.mts +2 -0
  119. package/dist/process.mjs +2 -0
  120. package/dist/projectTrust.cjs +6 -0
  121. package/dist/projectTrust.d.mts +2 -0
  122. package/dist/projectTrust.mjs +2 -0
  123. package/dist/repository.cjs +5 -0
  124. package/dist/repository.d.mts +2 -0
  125. package/dist/repository.mjs +2 -0
  126. package/dist/resourceCollector.cjs +9 -0
  127. package/dist/resourceCollector.d.mts +1 -0
  128. package/dist/resourceCollector.mjs +2 -0
  129. package/dist/router.cjs +6 -0
  130. package/dist/router.d.mts +2 -0
  131. package/dist/router.mjs +2 -0
  132. package/dist/services.cjs +97 -0
  133. package/dist/services.d.mts +12 -0
  134. package/dist/services.mjs +12 -0
  135. package/dist/shared.cjs +18 -0
  136. package/dist/shared.d.mts +2 -0
  137. package/dist/shared.mjs +2 -0
  138. package/dist/src/bin/agentDirectory.cjs +27 -0
  139. package/dist/src/bin/agentDirectory.cjs.map +1 -0
  140. package/dist/src/bin/agentDirectory.mjs +26 -0
  141. package/dist/src/bin/agentDirectory.mjs.map +1 -0
  142. package/dist/src/builders/apiContractExport/index.cjs +126 -0
  143. package/dist/src/builders/apiContractExport/index.cjs.map +1 -0
  144. package/dist/src/builders/apiContractExport/index.mjs +123 -0
  145. package/dist/src/builders/apiContractExport/index.mjs.map +1 -0
  146. package/dist/src/builders/cli/entryResolution.cjs +39 -0
  147. package/dist/src/builders/cli/entryResolution.cjs.map +1 -0
  148. package/dist/src/builders/cli/entryResolution.mjs +35 -0
  149. package/dist/src/builders/cli/entryResolution.mjs.map +1 -0
  150. package/dist/src/builders/cli/harnessContext.cjs +175 -0
  151. package/dist/src/builders/cli/harnessContext.cjs.map +1 -0
  152. package/dist/src/builders/cli/harnessContext.d.mts +48 -0
  153. package/dist/src/builders/cli/harnessContext.d.mts.map +1 -0
  154. package/dist/src/builders/cli/harnessContext.mjs +167 -0
  155. package/dist/src/builders/cli/harnessContext.mjs.map +1 -0
  156. package/dist/src/builders/cli/sessionComposition.cjs +27 -0
  157. package/dist/src/builders/cli/sessionComposition.cjs.map +1 -0
  158. package/dist/src/builders/cli/sessionComposition.mjs +26 -0
  159. package/dist/src/builders/cli/sessionComposition.mjs.map +1 -0
  160. package/dist/src/builders/hooks/index.cjs +238 -0
  161. package/dist/src/builders/hooks/index.cjs.map +1 -0
  162. package/dist/src/builders/hooks/index.mjs +231 -0
  163. package/dist/src/builders/hooks/index.mjs.map +1 -0
  164. package/dist/src/builders/native/index.cjs +176 -0
  165. package/dist/src/builders/native/index.cjs.map +1 -0
  166. package/dist/src/builders/native/index.d.mts +36 -0
  167. package/dist/src/builders/native/index.d.mts.map +1 -0
  168. package/dist/src/builders/native/index.mjs +170 -0
  169. package/dist/src/builders/native/index.mjs.map +1 -0
  170. package/dist/src/builders/server/backgroundSync.cjs +333 -0
  171. package/dist/src/builders/server/backgroundSync.cjs.map +1 -0
  172. package/dist/src/builders/server/backgroundSync.mjs +320 -0
  173. package/dist/src/builders/server/backgroundSync.mjs.map +1 -0
  174. package/dist/src/builders/server/computerUseBinding.cjs +273 -0
  175. package/dist/src/builders/server/computerUseBinding.cjs.map +1 -0
  176. package/dist/src/builders/server/computerUseBinding.mjs +269 -0
  177. package/dist/src/builders/server/computerUseBinding.mjs.map +1 -0
  178. package/dist/src/builders/server/computerUseRecordings.cjs +188 -0
  179. package/dist/src/builders/server/computerUseRecordings.cjs.map +1 -0
  180. package/dist/src/builders/server/computerUseRecordings.mjs +184 -0
  181. package/dist/src/builders/server/computerUseRecordings.mjs.map +1 -0
  182. package/dist/src/builders/server/defaultWorkspace.cjs +38 -0
  183. package/dist/src/builders/server/defaultWorkspace.cjs.map +1 -0
  184. package/dist/src/builders/server/defaultWorkspace.mjs +35 -0
  185. package/dist/src/builders/server/defaultWorkspace.mjs.map +1 -0
  186. package/dist/src/builders/server/idleRestart.cjs +149 -0
  187. package/dist/src/builders/server/idleRestart.cjs.map +1 -0
  188. package/dist/src/builders/server/idleRestart.mjs +136 -0
  189. package/dist/src/builders/server/idleRestart.mjs.map +1 -0
  190. package/dist/src/builders/server/index.cjs +63 -0
  191. package/dist/src/builders/server/index.cjs.map +1 -0
  192. package/dist/src/builders/server/index.mjs +60 -0
  193. package/dist/src/builders/server/index.mjs.map +1 -0
  194. package/dist/src/builders/server/logSink.cjs +57 -0
  195. package/dist/src/builders/server/logSink.cjs.map +1 -0
  196. package/dist/src/builders/server/logSink.mjs +57 -0
  197. package/dist/src/builders/server/logSink.mjs.map +1 -0
  198. package/dist/src/builders/server/mcpApp.cjs +152 -0
  199. package/dist/src/builders/server/mcpApp.cjs.map +1 -0
  200. package/dist/src/builders/server/mcpApp.d.mts +18 -0
  201. package/dist/src/builders/server/mcpApp.d.mts.map +1 -0
  202. package/dist/src/builders/server/mcpApp.mjs +147 -0
  203. package/dist/src/builders/server/mcpApp.mjs.map +1 -0
  204. package/dist/src/builders/server/mcpAppBuild.cjs +111 -0
  205. package/dist/src/builders/server/mcpAppBuild.cjs.map +1 -0
  206. package/dist/src/builders/server/mcpAppBuild.d.mts +24 -0
  207. package/dist/src/builders/server/mcpAppBuild.d.mts.map +1 -0
  208. package/dist/src/builders/server/mcpAppBuild.mjs +105 -0
  209. package/dist/src/builders/server/mcpAppBuild.mjs.map +1 -0
  210. package/dist/src/builders/server/mcpBundle.cjs +87 -0
  211. package/dist/src/builders/server/mcpBundle.cjs.map +1 -0
  212. package/dist/src/builders/server/mcpBundle.d.mts +23 -0
  213. package/dist/src/builders/server/mcpBundle.d.mts.map +1 -0
  214. package/dist/src/builders/server/mcpBundle.mjs +84 -0
  215. package/dist/src/builders/server/mcpBundle.mjs.map +1 -0
  216. package/dist/src/builders/server/packageReloadCheck.cjs +62 -0
  217. package/dist/src/builders/server/packageReloadCheck.cjs.map +1 -0
  218. package/dist/src/builders/server/packageReloadCheck.mjs +61 -0
  219. package/dist/src/builders/server/packageReloadCheck.mjs.map +1 -0
  220. package/dist/src/builders/server/packageUrl.cjs +210 -0
  221. package/dist/src/builders/server/packageUrl.cjs.map +1 -0
  222. package/dist/src/builders/server/packageUrl.mjs +203 -0
  223. package/dist/src/builders/server/packageUrl.mjs.map +1 -0
  224. package/dist/src/builders/server/runtime.cjs +1428 -0
  225. package/dist/src/builders/server/runtime.cjs.map +1 -0
  226. package/dist/src/builders/server/runtime.mjs +1420 -0
  227. package/dist/src/builders/server/runtime.mjs.map +1 -0
  228. package/dist/src/builders/server/runtimeResources.cjs +72 -0
  229. package/dist/src/builders/server/runtimeResources.cjs.map +1 -0
  230. package/dist/src/builders/server/runtimeResources.mjs +71 -0
  231. package/dist/src/builders/server/runtimeResources.mjs.map +1 -0
  232. package/dist/src/builders/server/selectionStatus.cjs +12 -0
  233. package/dist/src/builders/server/selectionStatus.cjs.map +1 -0
  234. package/dist/src/builders/server/selectionStatus.mjs +12 -0
  235. package/dist/src/builders/server/selectionStatus.mjs.map +1 -0
  236. package/dist/src/builders/server/sessionArguments.cjs +63 -0
  237. package/dist/src/builders/server/sessionArguments.cjs.map +1 -0
  238. package/dist/src/builders/server/sessionArguments.mjs +62 -0
  239. package/dist/src/builders/server/sessionArguments.mjs.map +1 -0
  240. package/dist/src/builders/server/shutdown.cjs +16 -0
  241. package/dist/src/builders/server/shutdown.cjs.map +1 -0
  242. package/dist/src/builders/server/shutdown.mjs +16 -0
  243. package/dist/src/builders/server/shutdown.mjs.map +1 -0
  244. package/dist/src/builders/server/webTemplateDecision.cjs +34 -0
  245. package/dist/src/builders/server/webTemplateDecision.cjs.map +1 -0
  246. package/dist/src/builders/server/webTemplateDecision.mjs +32 -0
  247. package/dist/src/builders/server/webTemplateDecision.mjs.map +1 -0
  248. package/dist/src/builders/server/workspaceCheckout.cjs +31 -0
  249. package/dist/src/builders/server/workspaceCheckout.cjs.map +1 -0
  250. package/dist/src/builders/server/workspaceCheckout.mjs +29 -0
  251. package/dist/src/builders/server/workspaceCheckout.mjs.map +1 -0
  252. package/dist/src/builders/web/bundle.cjs +225 -0
  253. package/dist/src/builders/web/bundle.cjs.map +1 -0
  254. package/dist/src/builders/web/bundle.d.mts +65 -0
  255. package/dist/src/builders/web/bundle.d.mts.map +1 -0
  256. package/dist/src/builders/web/bundle.mjs +221 -0
  257. package/dist/src/builders/web/bundle.mjs.map +1 -0
  258. package/dist/src/builders/web/bundleAssetPolicy.cjs +96 -0
  259. package/dist/src/builders/web/bundleAssetPolicy.cjs.map +1 -0
  260. package/dist/src/builders/web/bundleAssetPolicy.d.mts +22 -0
  261. package/dist/src/builders/web/bundleAssetPolicy.d.mts.map +1 -0
  262. package/dist/src/builders/web/bundleAssetPolicy.mjs +95 -0
  263. package/dist/src/builders/web/bundleAssetPolicy.mjs.map +1 -0
  264. package/dist/src/builders/web/index.cjs +361 -0
  265. package/dist/src/builders/web/index.cjs.map +1 -0
  266. package/dist/src/builders/web/index.d.mts +109 -0
  267. package/dist/src/builders/web/index.d.mts.map +1 -0
  268. package/dist/src/builders/web/index.mjs +342 -0
  269. package/dist/src/builders/web/index.mjs.map +1 -0
  270. package/dist/src/builders/web/webDevRoots.cjs +27 -0
  271. package/dist/src/builders/web/webDevRoots.cjs.map +1 -0
  272. package/dist/src/builders/web/webDevRoots.d.mts +22 -0
  273. package/dist/src/builders/web/webDevRoots.d.mts.map +1 -0
  274. package/dist/src/builders/web/webDevRoots.mjs +25 -0
  275. package/dist/src/builders/web/webDevRoots.mjs.map +1 -0
  276. package/dist/src/builders/web/webPluginGenerate.cjs +188 -0
  277. package/dist/src/builders/web/webPluginGenerate.cjs.map +1 -0
  278. package/dist/src/builders/web/webPluginGenerate.d.mts +56 -0
  279. package/dist/src/builders/web/webPluginGenerate.d.mts.map +1 -0
  280. package/dist/src/builders/web/webPluginGenerate.mjs +178 -0
  281. package/dist/src/builders/web/webPluginGenerate.mjs.map +1 -0
  282. package/dist/src/builders/web/webPluginManifest.cjs +128 -0
  283. package/dist/src/builders/web/webPluginManifest.cjs.map +1 -0
  284. package/dist/src/builders/web/webPluginManifest.d.mts +64 -0
  285. package/dist/src/builders/web/webPluginManifest.d.mts.map +1 -0
  286. package/dist/src/builders/web/webPluginManifest.mjs +118 -0
  287. package/dist/src/builders/web/webPluginManifest.mjs.map +1 -0
  288. package/dist/src/builders/web/webPluginScan.cjs +57 -0
  289. package/dist/src/builders/web/webPluginScan.cjs.map +1 -0
  290. package/dist/src/builders/web/webPluginScan.d.mts +19 -0
  291. package/dist/src/builders/web/webPluginScan.d.mts.map +1 -0
  292. package/dist/src/builders/web/webPluginScan.mjs +54 -0
  293. package/dist/src/builders/web/webPluginScan.mjs.map +1 -0
  294. package/dist/src/builders/web/webPluginVite.cjs +255 -0
  295. package/dist/src/builders/web/webPluginVite.cjs.map +1 -0
  296. package/dist/src/builders/web/webPluginVite.d.mts +64 -0
  297. package/dist/src/builders/web/webPluginVite.d.mts.map +1 -0
  298. package/dist/src/builders/web/webPluginVite.mjs +242 -0
  299. package/dist/src/builders/web/webPluginVite.mjs.map +1 -0
  300. package/dist/src/cli/cliApp.cjs +187 -0
  301. package/dist/src/cli/cliApp.cjs.map +1 -0
  302. package/dist/src/cli/cliApp.d.mts +32 -0
  303. package/dist/src/cli/cliApp.d.mts.map +1 -0
  304. package/dist/src/cli/cliApp.mjs +184 -0
  305. package/dist/src/cli/cliApp.mjs.map +1 -0
  306. package/dist/src/cli/commands/api-export/index.cjs +66 -0
  307. package/dist/src/cli/commands/api-export/index.cjs.map +1 -0
  308. package/dist/src/cli/commands/api-export/index.mjs +62 -0
  309. package/dist/src/cli/commands/api-export/index.mjs.map +1 -0
  310. package/dist/src/cli/commands/baseCommand.cjs +16 -0
  311. package/dist/src/cli/commands/baseCommand.cjs.map +1 -0
  312. package/dist/src/cli/commands/baseCommand.d.mts +24 -0
  313. package/dist/src/cli/commands/baseCommand.d.mts.map +1 -0
  314. package/dist/src/cli/commands/baseCommand.mjs +16 -0
  315. package/dist/src/cli/commands/baseCommand.mjs.map +1 -0
  316. package/dist/src/cli/commands/compat/context.cjs +115 -0
  317. package/dist/src/cli/commands/compat/context.cjs.map +1 -0
  318. package/dist/src/cli/commands/compat/context.d.mts +22 -0
  319. package/dist/src/cli/commands/compat/context.d.mts.map +1 -0
  320. package/dist/src/cli/commands/compat/context.mjs +110 -0
  321. package/dist/src/cli/commands/compat/context.mjs.map +1 -0
  322. package/dist/src/cli/commands/compat/help.cjs +26 -0
  323. package/dist/src/cli/commands/compat/help.cjs.map +1 -0
  324. package/dist/src/cli/commands/compat/help.d.mts +4 -0
  325. package/dist/src/cli/commands/compat/help.d.mts.map +1 -0
  326. package/dist/src/cli/commands/compat/help.mjs +25 -0
  327. package/dist/src/cli/commands/compat/help.mjs.map +1 -0
  328. package/dist/src/cli/commands/compat/index.cjs +73 -0
  329. package/dist/src/cli/commands/compat/index.cjs.map +1 -0
  330. package/dist/src/cli/commands/compat/index.d.mts +14 -0
  331. package/dist/src/cli/commands/compat/index.d.mts.map +1 -0
  332. package/dist/src/cli/commands/compat/index.mjs +70 -0
  333. package/dist/src/cli/commands/compat/index.mjs.map +1 -0
  334. package/dist/src/cli/commands/compat/options.cjs +88 -0
  335. package/dist/src/cli/commands/compat/options.cjs.map +1 -0
  336. package/dist/src/cli/commands/compat/options.d.mts +15 -0
  337. package/dist/src/cli/commands/compat/options.d.mts.map +1 -0
  338. package/dist/src/cli/commands/compat/options.mjs +86 -0
  339. package/dist/src/cli/commands/compat/options.mjs.map +1 -0
  340. package/dist/src/cli/commands/compat/providers/antigravity.cjs +294 -0
  341. package/dist/src/cli/commands/compat/providers/antigravity.cjs.map +1 -0
  342. package/dist/src/cli/commands/compat/providers/antigravity.d.mts +9 -0
  343. package/dist/src/cli/commands/compat/providers/antigravity.d.mts.map +1 -0
  344. package/dist/src/cli/commands/compat/providers/antigravity.mjs +289 -0
  345. package/dist/src/cli/commands/compat/providers/antigravity.mjs.map +1 -0
  346. package/dist/src/cli/commands/compat/providers/codex.cjs +178 -0
  347. package/dist/src/cli/commands/compat/providers/codex.cjs.map +1 -0
  348. package/dist/src/cli/commands/compat/providers/codex.d.mts +17 -0
  349. package/dist/src/cli/commands/compat/providers/codex.d.mts.map +1 -0
  350. package/dist/src/cli/commands/compat/providers/codex.mjs +170 -0
  351. package/dist/src/cli/commands/compat/providers/codex.mjs.map +1 -0
  352. package/dist/src/cli/commands/compat/providers/index.cjs +65 -0
  353. package/dist/src/cli/commands/compat/providers/index.cjs.map +1 -0
  354. package/dist/src/cli/commands/compat/providers/index.d.mts +15 -0
  355. package/dist/src/cli/commands/compat/providers/index.d.mts.map +1 -0
  356. package/dist/src/cli/commands/compat/providers/index.mjs +45 -0
  357. package/dist/src/cli/commands/compat/providers/index.mjs.map +1 -0
  358. package/dist/src/cli/commands/compat/providers/process.cjs +172 -0
  359. package/dist/src/cli/commands/compat/providers/process.cjs.map +1 -0
  360. package/dist/src/cli/commands/compat/providers/process.d.mts +33 -0
  361. package/dist/src/cli/commands/compat/providers/process.d.mts.map +1 -0
  362. package/dist/src/cli/commands/compat/providers/process.mjs +159 -0
  363. package/dist/src/cli/commands/compat/providers/process.mjs.map +1 -0
  364. package/dist/src/cli/commands/compat/providers/shared.cjs +76 -0
  365. package/dist/src/cli/commands/compat/providers/shared.cjs.map +1 -0
  366. package/dist/src/cli/commands/compat/providers/shared.d.mts +40 -0
  367. package/dist/src/cli/commands/compat/providers/shared.d.mts.map +1 -0
  368. package/dist/src/cli/commands/compat/providers/shared.mjs +61 -0
  369. package/dist/src/cli/commands/compat/providers/shared.mjs.map +1 -0
  370. package/dist/src/cli/commands/compat/types.d.mts +31 -0
  371. package/dist/src/cli/commands/compat/types.d.mts.map +1 -0
  372. package/dist/src/cli/commands/doctor/help.cjs +19 -0
  373. package/dist/src/cli/commands/doctor/help.cjs.map +1 -0
  374. package/dist/src/cli/commands/doctor/help.d.mts +4 -0
  375. package/dist/src/cli/commands/doctor/help.d.mts.map +1 -0
  376. package/dist/src/cli/commands/doctor/help.mjs +19 -0
  377. package/dist/src/cli/commands/doctor/help.mjs.map +1 -0
  378. package/dist/src/cli/commands/doctor/index.cjs +118 -0
  379. package/dist/src/cli/commands/doctor/index.cjs.map +1 -0
  380. package/dist/src/cli/commands/doctor/index.d.mts +33 -0
  381. package/dist/src/cli/commands/doctor/index.d.mts.map +1 -0
  382. package/dist/src/cli/commands/doctor/index.mjs +113 -0
  383. package/dist/src/cli/commands/doctor/index.mjs.map +1 -0
  384. package/dist/src/cli/commands/emit-mcp/index.cjs +32 -0
  385. package/dist/src/cli/commands/emit-mcp/index.cjs.map +1 -0
  386. package/dist/src/cli/commands/emit-mcp/index.d.mts +19 -0
  387. package/dist/src/cli/commands/emit-mcp/index.d.mts.map +1 -0
  388. package/dist/src/cli/commands/emit-mcp/index.mjs +31 -0
  389. package/dist/src/cli/commands/emit-mcp/index.mjs.map +1 -0
  390. package/dist/src/cli/commands/explain/index.cjs +155 -0
  391. package/dist/src/cli/commands/explain/index.cjs.map +1 -0
  392. package/dist/src/cli/commands/explain/index.d.mts +57 -0
  393. package/dist/src/cli/commands/explain/index.d.mts.map +1 -0
  394. package/dist/src/cli/commands/explain/index.mjs +150 -0
  395. package/dist/src/cli/commands/explain/index.mjs.map +1 -0
  396. package/dist/src/cli/commands/init/constants.cjs +11 -0
  397. package/dist/src/cli/commands/init/constants.cjs.map +1 -0
  398. package/dist/src/cli/commands/init/constants.mjs +11 -0
  399. package/dist/src/cli/commands/init/constants.mjs.map +1 -0
  400. package/dist/src/cli/commands/init/help.cjs +17 -0
  401. package/dist/src/cli/commands/init/help.cjs.map +1 -0
  402. package/dist/src/cli/commands/init/help.d.mts +4 -0
  403. package/dist/src/cli/commands/init/help.d.mts.map +1 -0
  404. package/dist/src/cli/commands/init/help.mjs +17 -0
  405. package/dist/src/cli/commands/init/help.mjs.map +1 -0
  406. package/dist/src/cli/commands/init/index.cjs +67 -0
  407. package/dist/src/cli/commands/init/index.cjs.map +1 -0
  408. package/dist/src/cli/commands/init/index.d.mts +12 -0
  409. package/dist/src/cli/commands/init/index.d.mts.map +1 -0
  410. package/dist/src/cli/commands/init/index.mjs +63 -0
  411. package/dist/src/cli/commands/init/index.mjs.map +1 -0
  412. package/dist/src/cli/commands/init/presenter.cjs +140 -0
  413. package/dist/src/cli/commands/init/presenter.cjs.map +1 -0
  414. package/dist/src/cli/commands/init/presenter.d.mts +8 -0
  415. package/dist/src/cli/commands/init/presenter.d.mts.map +1 -0
  416. package/dist/src/cli/commands/init/presenter.mjs +140 -0
  417. package/dist/src/cli/commands/init/presenter.mjs.map +1 -0
  418. package/dist/src/cli/commands/sync/help.cjs +34 -0
  419. package/dist/src/cli/commands/sync/help.cjs.map +1 -0
  420. package/dist/src/cli/commands/sync/help.d.mts +4 -0
  421. package/dist/src/cli/commands/sync/help.d.mts.map +1 -0
  422. package/dist/src/cli/commands/sync/help.mjs +34 -0
  423. package/dist/src/cli/commands/sync/help.mjs.map +1 -0
  424. package/dist/src/cli/commands/sync/index.cjs +215 -0
  425. package/dist/src/cli/commands/sync/index.cjs.map +1 -0
  426. package/dist/src/cli/commands/sync/index.d.mts +20 -0
  427. package/dist/src/cli/commands/sync/index.d.mts.map +1 -0
  428. package/dist/src/cli/commands/sync/index.mjs +206 -0
  429. package/dist/src/cli/commands/sync/index.mjs.map +1 -0
  430. package/dist/src/cli/commands/sync/presenter.cjs +58 -0
  431. package/dist/src/cli/commands/sync/presenter.cjs.map +1 -0
  432. package/dist/src/cli/commands/sync/presenter.d.mts +16 -0
  433. package/dist/src/cli/commands/sync/presenter.d.mts.map +1 -0
  434. package/dist/src/cli/commands/sync/presenter.mjs +57 -0
  435. package/dist/src/cli/commands/sync/presenter.mjs.map +1 -0
  436. package/dist/src/cli/commands/sync/workflow.cjs +16 -0
  437. package/dist/src/cli/commands/sync/workflow.cjs.map +1 -0
  438. package/dist/src/cli/commands/sync/workflow.mjs +16 -0
  439. package/dist/src/cli/commands/sync/workflow.mjs.map +1 -0
  440. package/dist/src/cli/commands/web/index.cjs +88 -0
  441. package/dist/src/cli/commands/web/index.cjs.map +1 -0
  442. package/dist/src/cli/commands/web/index.mjs +85 -0
  443. package/dist/src/cli/commands/web/index.mjs.map +1 -0
  444. package/dist/src/cli/harnessOptions.cjs +70 -0
  445. package/dist/src/cli/harnessOptions.cjs.map +1 -0
  446. package/dist/src/cli/harnessOptions.d.mts +26 -0
  447. package/dist/src/cli/harnessOptions.d.mts.map +1 -0
  448. package/dist/src/cli/harnessOptions.mjs +66 -0
  449. package/dist/src/cli/harnessOptions.mjs.map +1 -0
  450. package/dist/src/cli/help.cjs +82 -0
  451. package/dist/src/cli/help.cjs.map +1 -0
  452. package/dist/src/cli/help.d.mts +10 -0
  453. package/dist/src/cli/help.d.mts.map +1 -0
  454. package/dist/src/cli/help.mjs +78 -0
  455. package/dist/src/cli/help.mjs.map +1 -0
  456. package/dist/src/cli/matrixOptions.cjs +178 -0
  457. package/dist/src/cli/matrixOptions.cjs.map +1 -0
  458. package/dist/src/cli/matrixOptions.d.mts +90 -0
  459. package/dist/src/cli/matrixOptions.d.mts.map +1 -0
  460. package/dist/src/cli/matrixOptions.mjs +151 -0
  461. package/dist/src/cli/matrixOptions.mjs.map +1 -0
  462. package/dist/src/cli/options.cjs +281 -0
  463. package/dist/src/cli/options.cjs.map +1 -0
  464. package/dist/src/cli/options.d.mts +5 -0
  465. package/dist/src/cli/options.d.mts.map +1 -0
  466. package/dist/src/cli/options.mjs +279 -0
  467. package/dist/src/cli/options.mjs.map +1 -0
  468. package/dist/src/cli/router.cjs +57 -0
  469. package/dist/src/cli/router.cjs.map +1 -0
  470. package/dist/src/cli/router.d.mts +32 -0
  471. package/dist/src/cli/router.d.mts.map +1 -0
  472. package/dist/src/cli/router.mjs +54 -0
  473. package/dist/src/cli/router.mjs.map +1 -0
  474. package/dist/src/cli/server/options.cjs +71 -0
  475. package/dist/src/cli/server/options.cjs.map +1 -0
  476. package/dist/src/cli/server/options.mjs +70 -0
  477. package/dist/src/cli/server/options.mjs.map +1 -0
  478. package/dist/src/cli/server/processGuards.cjs +83 -0
  479. package/dist/src/cli/server/processGuards.cjs.map +1 -0
  480. package/dist/src/cli/server/processGuards.mjs +79 -0
  481. package/dist/src/cli/server/processGuards.mjs.map +1 -0
  482. package/dist/src/cli/server/run.cjs +69 -0
  483. package/dist/src/cli/server/run.cjs.map +1 -0
  484. package/dist/src/cli/server/run.mjs +66 -0
  485. package/dist/src/cli/server/run.mjs.map +1 -0
  486. package/dist/src/composition/harnessState/index.cjs +48 -0
  487. package/dist/src/composition/harnessState/index.cjs.map +1 -0
  488. package/dist/src/composition/harnessState/index.d.mts +19 -0
  489. package/dist/src/composition/harnessState/index.d.mts.map +1 -0
  490. package/dist/src/composition/harnessState/index.mjs +34 -0
  491. package/dist/src/composition/harnessState/index.mjs.map +1 -0
  492. package/dist/src/composition/layerPackageInstaller/index.cjs +651 -0
  493. package/dist/src/composition/layerPackageInstaller/index.cjs.map +1 -0
  494. package/dist/src/composition/layerPackageInstaller/index.d.mts +74 -0
  495. package/dist/src/composition/layerPackageInstaller/index.d.mts.map +1 -0
  496. package/dist/src/composition/layerPackageInstaller/index.mjs +637 -0
  497. package/dist/src/composition/layerPackageInstaller/index.mjs.map +1 -0
  498. package/dist/src/composition/poHomeMigration/index.cjs +234 -0
  499. package/dist/src/composition/poHomeMigration/index.cjs.map +1 -0
  500. package/dist/src/composition/poHomeMigration/index.d.mts +12 -0
  501. package/dist/src/composition/poHomeMigration/index.d.mts.map +1 -0
  502. package/dist/src/composition/poHomeMigration/index.mjs +226 -0
  503. package/dist/src/composition/poHomeMigration/index.mjs.map +1 -0
  504. package/dist/src/composition/projectTrust/index.cjs +51 -0
  505. package/dist/src/composition/projectTrust/index.cjs.map +1 -0
  506. package/dist/src/composition/projectTrust/index.d.mts +22 -0
  507. package/dist/src/composition/projectTrust/index.d.mts.map +1 -0
  508. package/dist/src/composition/projectTrust/index.mjs +48 -0
  509. package/dist/src/composition/projectTrust/index.mjs.map +1 -0
  510. package/dist/src/composition/repository/index.cjs +68 -0
  511. package/dist/src/composition/repository/index.cjs.map +1 -0
  512. package/dist/src/composition/repository/index.d.mts +22 -0
  513. package/dist/src/composition/repository/index.d.mts.map +1 -0
  514. package/dist/src/composition/repository/index.mjs +63 -0
  515. package/dist/src/composition/repository/index.mjs.map +1 -0
  516. package/dist/src/composition/syncPrune/index.cjs +85 -0
  517. package/dist/src/composition/syncPrune/index.cjs.map +1 -0
  518. package/dist/src/composition/syncPrune/index.d.mts +33 -0
  519. package/dist/src/composition/syncPrune/index.d.mts.map +1 -0
  520. package/dist/src/composition/syncPrune/index.mjs +82 -0
  521. package/dist/src/composition/syncPrune/index.mjs.map +1 -0
  522. package/dist/src/composition/syncService/index.cjs +808 -0
  523. package/dist/src/composition/syncService/index.cjs.map +1 -0
  524. package/dist/src/composition/syncService/index.d.mts +65 -0
  525. package/dist/src/composition/syncService/index.d.mts.map +1 -0
  526. package/dist/src/composition/syncService/index.mjs +792 -0
  527. package/dist/src/composition/syncService/index.mjs.map +1 -0
  528. package/dist/src/composition/syncService/localBuilds.cjs +367 -0
  529. package/dist/src/composition/syncService/localBuilds.cjs.map +1 -0
  530. package/dist/src/composition/syncService/localBuilds.mjs +358 -0
  531. package/dist/src/composition/syncService/localBuilds.mjs.map +1 -0
  532. package/dist/src/composition/transitionLayers.cjs +17 -0
  533. package/dist/src/composition/transitionLayers.cjs.map +1 -0
  534. package/dist/src/composition/transitionLayers.d.mts +6 -0
  535. package/dist/src/composition/transitionLayers.d.mts.map +1 -0
  536. package/dist/src/composition/transitionLayers.mjs +16 -0
  537. package/dist/src/composition/transitionLayers.mjs.map +1 -0
  538. package/dist/src/composition/types/harness.d.mts +52 -0
  539. package/dist/src/composition/types/harness.d.mts.map +1 -0
  540. package/dist/src/extensions/setupDiagnostics.cjs +65 -0
  541. package/dist/src/extensions/setupDiagnostics.cjs.map +1 -0
  542. package/dist/src/extensions/setupDiagnostics.mjs +64 -0
  543. package/dist/src/extensions/setupDiagnostics.mjs.map +1 -0
  544. package/dist/utils.cjs +4 -0
  545. package/dist/utils.d.mts +2 -0
  546. package/dist/utils.mjs +2 -0
  547. package/dist/webBuilder.cjs +59 -0
  548. package/dist/webBuilder.d.mts +9 -0
  549. package/dist/webBuilder.mjs +9 -0
  550. package/docs/server/api-export.md +86 -0
  551. package/docs/server/api.md +144 -0
  552. package/docs/server/getting-started.md +114 -0
  553. package/docs/server/index.md +67 -0
  554. package/docs/server/ipc.md +97 -0
  555. package/docs/server/lifecycle.md +108 -0
  556. package/docs/server/security.md +101 -0
  557. package/llms.txt +12 -0
  558. package/package.json +295 -0
  559. package/src/prompts/po-author-extension/SKILL.md +35 -0
  560. package/src/prompts/po-author-extension/references/extension-contract.md +134 -0
@@ -0,0 +1,147 @@
1
+ import { createRequire } from "node:module";
2
+ import fs from "node:fs";
3
+ import path from "node:path";
4
+ import crypto from "node:crypto";
5
+ //#region src/builders/server/mcpApp.ts
6
+ /** Resolve generator-owned inputs before looking up an immutable build. */
7
+ function mcpAppInputs(componentsRoot) {
8
+ const require = createRequire(import.meta.url);
9
+ const root = componentsRoot ?? path.dirname(require.resolve("@agimon-ai/po-web-components/package.json"));
10
+ const coreManifest = require.resolve("@agimon-ai/po-core/package.json");
11
+ const reactRequire = createRequire(coreManifest);
12
+ const fonts = mcpAppFonts(root);
13
+ const inputs = /* @__PURE__ */ new Set([
14
+ import.meta.filename,
15
+ coreManifest,
16
+ ...fonts
17
+ ]);
18
+ for (const css of fonts) for (const match of fs.readFileSync(css, "utf8").matchAll(/url\(['"]?([^)'" ]+\.woff2)['"]?\)/gu)) inputs.add(path.resolve(path.dirname(css), match[1]));
19
+ for (const directory of [
20
+ path.join(root, "dist"),
21
+ path.join(root, "styles"),
22
+ path.dirname(reactRequire.resolve("react/package.json")),
23
+ path.dirname(reactRequire.resolve("react-dom/package.json")),
24
+ path.dirname(require.resolve("tailwindcss/package.json"))
25
+ ]) for (const file of fs.readdirSync(directory, { recursive: true })) if (typeof file === "string" && /\.(?:[cm]?js|css|json)$/u.test(file)) inputs.add(path.join(directory, file));
26
+ inputs.add(path.join(root, "package.json"));
27
+ return [...inputs].sort();
28
+ }
29
+ function mcpAppFonts(componentsRoot) {
30
+ const require = createRequire(path.join(componentsRoot, "package.json"));
31
+ return ["@fontsource-variable/ibm-plex-sans/index.css", "@fontsource-variable/jetbrains-mono/index.css"].map((font) => require.resolve(font));
32
+ }
33
+ /** Composes the installed packages' browser registries. No tool names or presentation policies live here. */
34
+ async function bundleMcpApp(sources, outputDirectory) {
35
+ if (sources.length === 0) return void 0;
36
+ const names = /* @__PURE__ */ new Set();
37
+ for (const source of sources) for (const name of source.widgets) {
38
+ if (names.has(name)) throw new Error(`Duplicate MCP widget '${name}'`);
39
+ names.add(name);
40
+ }
41
+ const runtimeRequire = createRequire(import.meta.url);
42
+ const coreRoot = path.dirname(runtimeRequire.resolve("@agimon-ai/po-core/package.json"));
43
+ const componentsRoot = path.dirname(runtimeRequire.resolve("@agimon-ai/po-web-components/package.json"));
44
+ const componentsManifest = JSON.parse(fs.readFileSync(path.join(componentsRoot, "package.json"), "utf8"));
45
+ const appEntry = path.resolve(componentsRoot, componentsManifest.exports["./mcpWidget"].import);
46
+ const reactRequire = createRequire(path.join(coreRoot, "package.json"));
47
+ const directory = path.join(outputDirectory, "ui");
48
+ fs.mkdirSync(directory, { recursive: true });
49
+ const outputRoot = fs.realpathSync(outputDirectory);
50
+ const entry = path.join(directory, "entry.js");
51
+ const css = path.join(directory, "app.css");
52
+ const relative = (file) => file.split(path.sep).join("/");
53
+ fs.writeFileSync(entry, [
54
+ `import { mountMcpApp } from ${JSON.stringify(relative(appEntry))};`,
55
+ ...mcpAppFonts(componentsRoot).map((font) => `import ${JSON.stringify(relative(font))};`),
56
+ "import './app.css';",
57
+ ...sources.map((source, index) => `import { widgets as widgets${index} } from ${JSON.stringify(relative(source.file))};`),
58
+ "const widgets = Object.create(null);",
59
+ ...sources.flatMap((source, index) => source.widgets.map((name) => `widgets[${JSON.stringify(name)}] = widgets${index}[${JSON.stringify(name)}];`)),
60
+ "void mountMcpApp(widgets);",
61
+ ""
62
+ ].join("\n"));
63
+ fs.writeFileSync(css, [
64
+ `@import ${JSON.stringify(relative(runtimeRequire.resolve("tailwindcss/index.css")))};`,
65
+ `@import ${JSON.stringify(relative(path.join(componentsRoot, "styles/mcp.css")))};`,
66
+ `@source ${JSON.stringify(relative(path.join(componentsRoot, "dist")))};`,
67
+ ...sources.map((source) => `@source ${JSON.stringify(relative(source.file))};`),
68
+ "body { font-family: var(--font-sans, \"IBM Plex Sans Variable\", system-ui, sans-serif); }",
69
+ "code, pre, kbd, samp { font-family: var(--font-mono, \"JetBrains Mono Variable\", monospace); }",
70
+ ""
71
+ ].join("\n"));
72
+ const inputs = /* @__PURE__ */ new Set([
73
+ ...mcpAppInputs(),
74
+ appEntry,
75
+ path.join(coreRoot, "package.json"),
76
+ path.join(componentsRoot, "package.json")
77
+ ]);
78
+ for (const root of [path.join(componentsRoot, "styles"), path.dirname(runtimeRequire.resolve("tailwindcss/package.json"))]) for (const file of fs.readdirSync(root, { recursive: true })) if (typeof file === "string" && file.endsWith(".css")) inputs.add(path.join(root, file));
79
+ const { build } = await import("vite");
80
+ const { default: tailwindcss } = await import("@tailwindcss/vite");
81
+ const built = await build({
82
+ configFile: false,
83
+ envDir: false,
84
+ root: directory,
85
+ logLevel: "warn",
86
+ define: { "process.env.NODE_ENV": JSON.stringify("production") },
87
+ plugins: [tailwindcss(), {
88
+ name: "po-mcp-inputs",
89
+ generateBundle() {
90
+ for (const id of this.getModuleIds()) {
91
+ const file = id.split("?")[0];
92
+ if (file.includes("\0") || !path.isAbsolute(file) || !fs.existsSync(file) || !fs.statSync(file).isFile()) continue;
93
+ const resolved = fs.realpathSync(file);
94
+ const withinOutput = path.relative(outputRoot, resolved);
95
+ if (withinOutput !== "" && !withinOutput.startsWith("..") && !path.isAbsolute(withinOutput)) continue;
96
+ inputs.add(resolved);
97
+ }
98
+ }
99
+ }],
100
+ resolve: { alias: [{
101
+ find: /^@agimon-ai\/po-web-components$/u,
102
+ replacement: appEntry
103
+ }, ...[
104
+ "react",
105
+ "react/jsx-runtime",
106
+ "react/jsx-dev-runtime",
107
+ "react-dom",
108
+ "react-dom/client"
109
+ ].map((specifier) => ({
110
+ find: new RegExp(`^${specifier.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}$`, "u"),
111
+ replacement: reactRequire.resolve(specifier)
112
+ }))] },
113
+ build: {
114
+ write: false,
115
+ emptyOutDir: false,
116
+ sourcemap: false,
117
+ cssCodeSplit: false,
118
+ assetsInlineLimit: Infinity,
119
+ lib: {
120
+ entry,
121
+ formats: ["iife"],
122
+ name: "PoMcpApp",
123
+ fileName: "app",
124
+ cssFileName: "app"
125
+ }
126
+ }
127
+ });
128
+ const output = (Array.isArray(built) ? built : [built]).flatMap((bundle) => "output" in bundle ? bundle.output : []);
129
+ const scripts = output.filter((item) => item.type === "chunk");
130
+ const styles = output.filter((item) => item.type === "asset").filter((item) => item.fileName.endsWith(".css"));
131
+ if (scripts.length !== 1 || scripts[0].imports.some((file) => file !== scripts[0].fileName) || scripts[0].dynamicImports.length || output.length !== scripts.length + styles.length) throw new Error(`The composed MCP app must contain one self-contained script and inline CSS only: ${output.map((item) => item.fileName).join(", ")}; imports: ${scripts.flatMap((item) => [...item.imports, ...item.dynamicImports]).join(", ")}`);
132
+ const script = scripts[0].code.replace(/<\/script/giu, "<\\/script");
133
+ const html = `<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><title>Po tools</title><style>${styles.map((item) => typeof item.source === "string" ? item.source : Buffer.from(item.source).toString("utf8")).join("\n").replace(/<\/style/giu, "<\\/style")}</style></head><body><div id="root"></div><script>${script}<\/script></body></html>`;
134
+ fs.writeFileSync(path.join(directory, "index.html"), html);
135
+ return {
136
+ file: "./ui/index.html",
137
+ sha256: crypto.createHash("sha256").update(html).digest("hex"),
138
+ inputs: [...inputs].sort().map((file) => ({
139
+ path: file,
140
+ sha256: crypto.createHash("sha256").update(fs.readFileSync(file)).digest("hex")
141
+ }))
142
+ };
143
+ }
144
+ //#endregion
145
+ export { bundleMcpApp, mcpAppInputs };
146
+
147
+ //# sourceMappingURL=mcpApp.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mcpApp.mjs","names":[],"sources":["../../../../src/builders/server/mcpApp.ts"],"sourcesContent":["import crypto from 'node:crypto';\nimport fs from 'node:fs';\nimport { createRequire } from 'node:module';\nimport path from 'node:path';\n\n/** The built MCP App HTML, its digest, and the files it was built from. */\nexport interface McpAppBundle {\n readonly file: string;\n readonly sha256: string;\n readonly inputs: readonly { readonly path: string; readonly sha256: string }[];\n}\n\nexport interface McpAppSource {\n readonly file: string;\n readonly widgets: readonly string[];\n}\n\n/** Resolve generator-owned inputs before looking up an immutable build. */\nexport function mcpAppInputs(componentsRoot?: string): string[] {\n const require = createRequire(import.meta.url);\n const root = componentsRoot ?? path.dirname(require.resolve('@agimon-ai/po-web-components/package.json'));\n const coreManifest = require.resolve('@agimon-ai/po-core/package.json');\n const reactRequire = createRequire(coreManifest);\n const fonts = mcpAppFonts(root);\n const inputs = new Set<string>([import.meta.filename, coreManifest, ...fonts]);\n for (const css of fonts) {\n for (const match of fs.readFileSync(css, 'utf8').matchAll(/url\\(['\"]?([^)'\" ]+\\.woff2)['\"]?\\)/gu))\n inputs.add(path.resolve(path.dirname(css), match[1]!));\n }\n for (const directory of [\n path.join(root, 'dist'),\n path.join(root, 'styles'),\n path.dirname(reactRequire.resolve('react/package.json')),\n path.dirname(reactRequire.resolve('react-dom/package.json')),\n path.dirname(require.resolve('tailwindcss/package.json')),\n ]) {\n for (const file of fs.readdirSync(directory, { recursive: true })) {\n if (typeof file === 'string' && /\\.(?:[cm]?js|css|json)$/u.test(file)) inputs.add(path.join(directory, file));\n }\n }\n inputs.add(path.join(root, 'package.json'));\n return [...inputs].sort();\n}\n\nfunction mcpAppFonts(componentsRoot: string): string[] {\n const require = createRequire(path.join(componentsRoot, 'package.json'));\n return ['@fontsource-variable/ibm-plex-sans/index.css', '@fontsource-variable/jetbrains-mono/index.css'].map((font) =>\n require.resolve(font),\n );\n}\n\n/** Composes the installed packages' browser registries. No tool names or presentation policies live here. */\nexport async function bundleMcpApp(\n sources: readonly McpAppSource[],\n outputDirectory: string,\n): Promise<McpAppBundle | undefined> {\n if (sources.length === 0) return undefined;\n const names = new Set<string>();\n for (const source of sources) {\n for (const name of source.widgets) {\n if (names.has(name)) throw new Error(`Duplicate MCP widget '${name}'`);\n names.add(name);\n }\n }\n const runtimeRequire = createRequire(import.meta.url);\n const coreRoot = path.dirname(runtimeRequire.resolve('@agimon-ai/po-core/package.json'));\n const componentsRoot = path.dirname(runtimeRequire.resolve('@agimon-ai/po-web-components/package.json'));\n const componentsManifest = JSON.parse(fs.readFileSync(path.join(componentsRoot, 'package.json'), 'utf8')) as {\n exports: Record<string, { import: string }>;\n };\n const appEntry = path.resolve(componentsRoot, componentsManifest.exports['./mcpWidget']!.import);\n const reactRequire = createRequire(path.join(coreRoot, 'package.json'));\n const directory = path.join(outputDirectory, 'ui');\n fs.mkdirSync(directory, { recursive: true });\n const outputRoot = fs.realpathSync(outputDirectory);\n const entry = path.join(directory, 'entry.js');\n const css = path.join(directory, 'app.css');\n const relative = (file: string): string => file.split(path.sep).join('/');\n fs.writeFileSync(\n entry,\n [\n `import { mountMcpApp } from ${JSON.stringify(relative(appEntry))};`,\n ...mcpAppFonts(componentsRoot).map((font) => `import ${JSON.stringify(relative(font))};`),\n \"import './app.css';\",\n ...sources.map(\n (source, index) => `import { widgets as widgets${index} } from ${JSON.stringify(relative(source.file))};`,\n ),\n 'const widgets = Object.create(null);',\n ...sources.flatMap((source, index) =>\n source.widgets.map((name) => `widgets[${JSON.stringify(name)}] = widgets${index}[${JSON.stringify(name)}];`),\n ),\n 'void mountMcpApp(widgets);',\n '',\n ].join('\\n'),\n );\n fs.writeFileSync(\n css,\n [\n `@import ${JSON.stringify(relative(runtimeRequire.resolve('tailwindcss/index.css')))};`,\n `@import ${JSON.stringify(relative(path.join(componentsRoot, 'styles/mcp.css')))};`,\n `@source ${JSON.stringify(relative(path.join(componentsRoot, 'dist')))};`,\n ...sources.map((source) => `@source ${JSON.stringify(relative(source.file))};`),\n 'body { font-family: var(--font-sans, \"IBM Plex Sans Variable\", system-ui, sans-serif); }',\n 'code, pre, kbd, samp { font-family: var(--font-mono, \"JetBrains Mono Variable\", monospace); }',\n '',\n ].join('\\n'),\n );\n const inputs = new Set<string>([\n ...mcpAppInputs(),\n appEntry,\n path.join(coreRoot, 'package.json'),\n path.join(componentsRoot, 'package.json'),\n ]);\n for (const root of [\n path.join(componentsRoot, 'styles'),\n path.dirname(runtimeRequire.resolve('tailwindcss/package.json')),\n ]) {\n for (const file of fs.readdirSync(root, { recursive: true })) {\n if (typeof file === 'string' && file.endsWith('.css')) inputs.add(path.join(root, file));\n }\n }\n const { build } = await import('vite');\n const { default: tailwindcss } = await import('@tailwindcss/vite');\n const built = await build({\n configFile: false,\n envDir: false,\n root: directory,\n logLevel: 'warn',\n // Library builds leave this React branch intact unless it is replaced explicitly.\n define: { 'process.env.NODE_ENV': JSON.stringify('production') },\n plugins: [\n tailwindcss(),\n {\n name: 'po-mcp-inputs',\n generateBundle() {\n for (const id of this.getModuleIds()) {\n const file = id.split('?')[0]!;\n if (file.includes('\\0') || !path.isAbsolute(file) || !fs.existsSync(file) || !fs.statSync(file).isFile())\n continue;\n const resolved = fs.realpathSync(file);\n const withinOutput = path.relative(outputRoot, resolved);\n if (withinOutput !== '' && !withinOutput.startsWith('..') && !path.isAbsolute(withinOutput)) continue;\n inputs.add(resolved);\n }\n },\n },\n ],\n resolve: {\n alias: [\n { find: /^@agimon-ai\\/po-web-components$/u, replacement: appEntry },\n ...['react', 'react/jsx-runtime', 'react/jsx-dev-runtime', 'react-dom', 'react-dom/client'].map(\n (specifier) => ({\n find: new RegExp(`^${specifier.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&')}$`, 'u'),\n replacement: reactRequire.resolve(specifier),\n }),\n ),\n ],\n },\n build: {\n write: false,\n emptyOutDir: false,\n sourcemap: false,\n cssCodeSplit: false,\n // Vite library mode always inlines assets, regardless of this limit.\n assetsInlineLimit: Infinity,\n lib: { entry, formats: ['iife'], name: 'PoMcpApp', fileName: 'app', cssFileName: 'app' },\n },\n });\n const bundles = Array.isArray(built) ? built : [built];\n const output = bundles.flatMap((bundle) => ('output' in bundle ? bundle.output : []));\n const scripts = output.filter((item) => item.type === 'chunk');\n const styles = output.filter((item) => item.type === 'asset').filter((item) => item.fileName.endsWith('.css'));\n if (\n scripts.length !== 1 ||\n scripts[0]!.imports.some((file) => file !== scripts[0]!.fileName) ||\n scripts[0]!.dynamicImports.length ||\n output.length !== scripts.length + styles.length\n )\n throw new Error(\n `The composed MCP app must contain one self-contained script and inline CSS only: ${output.map((item) => item.fileName).join(', ')}; imports: ${scripts.flatMap((item) => [...item.imports, ...item.dynamicImports]).join(', ')}`,\n );\n const script = scripts[0]!.code.replace(/<\\/script/giu, '<\\\\/script');\n const style = styles\n .map((item) => (typeof item.source === 'string' ? item.source : Buffer.from(item.source).toString('utf8')))\n .join('\\n')\n .replace(/<\\/style/giu, '<\\\\/style');\n const html = `<!doctype html><html lang=\"en\"><head><meta charset=\"utf-8\"><meta name=\"viewport\" content=\"width=device-width, initial-scale=1\"><title>Po tools</title><style>${style}</style></head><body><div id=\"root\"></div><script>${script}</script></body></html>`;\n fs.writeFileSync(path.join(directory, 'index.html'), html);\n // Only immutable HTML is served. The generated imports remain useful for diagnosing a sync build.\n return {\n file: './ui/index.html',\n sha256: crypto.createHash('sha256').update(html).digest('hex'),\n inputs: [...inputs]\n .sort()\n .map((file) => ({ path: file, sha256: crypto.createHash('sha256').update(fs.readFileSync(file)).digest('hex') })),\n };\n}\n"],"mappings":";;;;;;AAkBA,SAAgB,aAAa,gBAAmC;CAC9D,MAAM,UAAU,cAAc,YAAY,GAAG;CAC7C,MAAM,OAAO,kBAAkB,KAAK,QAAQ,QAAQ,QAAQ,2CAA2C,CAAC;CACxG,MAAM,eAAe,QAAQ,QAAQ,iCAAiC;CACtE,MAAM,eAAe,cAAc,YAAY;CAC/C,MAAM,QAAQ,YAAY,IAAI;CAC9B,MAAM,yBAAS,IAAI,IAAY;EAAC,YAAY;EAAU;EAAc,GAAG;CAAK,CAAC;CAC7E,KAAK,MAAM,OAAO,OAChB,KAAK,MAAM,SAAS,GAAG,aAAa,KAAK,MAAM,CAAC,CAAC,SAAS,sCAAsC,GAC9F,OAAO,IAAI,KAAK,QAAQ,KAAK,QAAQ,GAAG,GAAG,MAAM,EAAG,CAAC;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,eAAe,WACuJ,EAAE,oDAAoD,OAAO;CAC9O,GAAG,cAAc,KAAK,KAAK,WAAW,YAAY,GAAG,IAAI;CAEzD,OAAO;EACL,MAAM;EACN,QAAQ,OAAO,WAAW,QAAQ,CAAC,CAAC,OAAO,IAAI,CAAC,CAAC,OAAO,KAAK;EAC7D,QAAQ,CAAC,GAAG,MAAM,CAAC,CAChB,KAAK,CAAC,CACN,KAAK,UAAU;GAAE,MAAM;GAAM,QAAQ,OAAO,WAAW,QAAQ,CAAC,CAAC,OAAO,GAAG,aAAa,IAAI,CAAC,CAAC,CAAC,OAAO,KAAK;EAAE,EAAE;CACpH;AACF"}
@@ -0,0 +1,111 @@
1
+ const require_runtime = require("../../../_virtual/_rolldown/runtime.cjs");
2
+ const require_packageUrl = require("./packageUrl.cjs");
3
+ const require_mcpApp = require("./mcpApp.cjs");
4
+ let node_fs = require("node:fs");
5
+ node_fs = require_runtime.__toESM(node_fs, 1);
6
+ let node_path = require("node:path");
7
+ node_path = require_runtime.__toESM(node_path, 1);
8
+ let node_crypto = require("node:crypto");
9
+ node_crypto = require_runtime.__toESM(node_crypto, 1);
10
+ //#region src/builders/server/mcpAppBuild.ts
11
+ function widgetSources(candidates) {
12
+ const sources = [];
13
+ for (const { declaration } of candidates) {
14
+ if (!declaration.ui || declaration.ui.widgets.length === 0) continue;
15
+ const root = node_fs.default.realpathSync(declaration.packageDir);
16
+ const file = node_fs.default.realpathSync(node_path.default.resolve(root, declaration.ui.dist));
17
+ const relative = node_path.default.relative(root, file);
18
+ if (relative === ".." || relative.startsWith(`..${node_path.default.sep}`) || node_path.default.isAbsolute(relative)) throw new Error(`MCP UI entry escapes package: ${declaration.packageName}`);
19
+ sources.push({
20
+ file,
21
+ widgets: declaration.ui.widgets
22
+ });
23
+ }
24
+ return sources;
25
+ }
26
+ /** Content key over every widget package's files, so any source change moves it. */
27
+ function mcpAppKey(candidates, inputs) {
28
+ const hash = node_crypto.default.createHash("sha256");
29
+ let any = false;
30
+ for (const { declaration } of candidates) {
31
+ if (!declaration.ui || declaration.ui.widgets.length === 0) continue;
32
+ any = true;
33
+ const root = node_fs.default.realpathSync(declaration.packageDir);
34
+ const entry = node_path.default.resolve(root, declaration.ui.dist);
35
+ hash.update(`${declaration.packageName}\0${root}\0${declaration.ui.widgets.join(",")}\0`);
36
+ hash.update(require_packageUrl.statSignature(root, require_packageUrl.snapshotFiles(root, entry)));
37
+ hash.update("\n");
38
+ }
39
+ if (!any) return void 0;
40
+ for (const file of [...inputs ?? require_mcpApp.mcpAppInputs(), __filename].sort()) {
41
+ hash.update(`${file}\0`);
42
+ hash.update(node_crypto.default.createHash("sha256").update(node_fs.default.readFileSync(file)).digest());
43
+ }
44
+ return hash.digest("hex").slice(0, 32);
45
+ }
46
+ function mcpAppFile(poHome, key) {
47
+ return node_path.default.join(poHome, "build", "mcp-app", key, "index.html");
48
+ }
49
+ function loadedBuild(key, file) {
50
+ const html = node_fs.default.readFileSync(file, "utf8");
51
+ return {
52
+ key,
53
+ file,
54
+ html,
55
+ sha256: node_crypto.default.createHash("sha256").update(html).digest("hex")
56
+ };
57
+ }
58
+ /**
59
+ * Reads the MCP app sync built for these candidates, without building anything.
60
+ *
61
+ * Undefined when no candidate declares UI widgets. Otherwise the key, plus the build when its
62
+ * file exists; a missing build means sync has not prepared this widget set yet.
63
+ */
64
+ function readMcpAppBuild(input) {
65
+ const key = mcpAppKey(input.candidates);
66
+ if (key === void 0) return void 0;
67
+ const file = mcpAppFile(input.poHome, key);
68
+ return node_fs.default.existsSync(file) ? {
69
+ key,
70
+ build: loadedBuild(key, file)
71
+ } : { key };
72
+ }
73
+ /**
74
+ * Builds the composed MCP App HTML for live MCP plugins at `<home>/build/mcp-app/<key>/index.html`.
75
+ *
76
+ * An existing key is reused without building. A new key builds into a temporary
77
+ * sibling directory and is renamed into place.
78
+ */
79
+ async function ensureMcpAppBuild(input) {
80
+ const key = mcpAppKey(input.candidates);
81
+ if (key === void 0) return void 0;
82
+ const file = mcpAppFile(input.poHome, key);
83
+ const directory = node_path.default.dirname(file);
84
+ const parent = node_path.default.dirname(directory);
85
+ if (!node_fs.default.existsSync(file)) {
86
+ node_fs.default.mkdirSync(parent, { recursive: true });
87
+ const temporary = node_fs.default.mkdtempSync(node_path.default.join(parent, `.${key}-`));
88
+ try {
89
+ const built = await (input.bundle ?? require_mcpApp.bundleMcpApp)(widgetSources(input.candidates), temporary);
90
+ if (built === void 0) return void 0;
91
+ node_fs.default.copyFileSync(node_path.default.join(temporary, built.file), node_path.default.join(temporary, "index.html"));
92
+ try {
93
+ node_fs.default.renameSync(temporary, directory);
94
+ } catch (error) {
95
+ if (!node_fs.default.existsSync(file)) throw error;
96
+ }
97
+ } finally {
98
+ node_fs.default.rmSync(temporary, {
99
+ recursive: true,
100
+ force: true
101
+ });
102
+ }
103
+ }
104
+ return loadedBuild(key, file);
105
+ }
106
+ //#endregion
107
+ exports.ensureMcpAppBuild = ensureMcpAppBuild;
108
+ exports.mcpAppKey = mcpAppKey;
109
+ exports.readMcpAppBuild = readMcpAppBuild;
110
+
111
+ //# sourceMappingURL=mcpAppBuild.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mcpAppBuild.cjs","names":["fs","path","crypto","statSignature","snapshotFiles","mcpAppInputs","bundleMcpApp"],"sources":["../../../../src/builders/server/mcpAppBuild.ts"],"sourcesContent":["import crypto from 'node:crypto';\nimport fs from 'node:fs';\nimport path from 'node:path';\n\nimport { bundleMcpApp, mcpAppInputs, type McpAppSource } from './mcpApp';\nimport type { McpPluginCandidate } from './mcpBundle';\nimport { snapshotFiles, statSignature } from './packageUrl';\n\nexport interface McpAppBuild {\n readonly key: string;\n readonly file: string;\n readonly html: string;\n readonly sha256: string;\n}\n\nexport interface McpAppBuildInput {\n readonly poHome: string;\n readonly candidates: readonly McpPluginCandidate[];\n /** Test seam; defaults to `bundleMcpApp`. */\n readonly bundle?: typeof bundleMcpApp;\n}\n\nfunction widgetSources(candidates: readonly McpPluginCandidate[]): McpAppSource[] {\n const sources: McpAppSource[] = [];\n for (const { declaration } of candidates) {\n if (!declaration.ui || declaration.ui.widgets.length === 0) continue;\n const root = fs.realpathSync(declaration.packageDir);\n const file = fs.realpathSync(path.resolve(root, declaration.ui.dist));\n const relative = path.relative(root, file);\n if (relative === '..' || relative.startsWith(`..${path.sep}`) || path.isAbsolute(relative))\n throw new Error(`MCP UI entry escapes package: ${declaration.packageName}`);\n sources.push({ file, widgets: declaration.ui.widgets });\n }\n return sources;\n}\n\n/** Content key over every widget package's files, so any source change moves it. */\nexport function mcpAppKey(candidates: readonly McpPluginCandidate[], inputs?: readonly string[]): string | undefined {\n const hash = crypto.createHash('sha256');\n let any = false;\n for (const { declaration } of candidates) {\n if (!declaration.ui || declaration.ui.widgets.length === 0) continue;\n any = true;\n const root = fs.realpathSync(declaration.packageDir);\n const entry = path.resolve(root, declaration.ui.dist);\n hash.update(`${declaration.packageName}\\0${root}\\0${declaration.ui.widgets.join(',')}\\0`);\n hash.update(statSignature(root, snapshotFiles(root, entry)));\n hash.update('\\n');\n }\n if (!any) return undefined;\n for (const file of [...(inputs ?? mcpAppInputs()), import.meta.filename].sort()) {\n hash.update(`${file}\\0`);\n hash.update(crypto.createHash('sha256').update(fs.readFileSync(file)).digest());\n }\n return hash.digest('hex').slice(0, 32);\n}\n\nfunction mcpAppFile(poHome: string, key: string): string {\n return path.join(poHome, 'build', 'mcp-app', key, 'index.html');\n}\n\nfunction loadedBuild(key: string, file: string): McpAppBuild {\n const html = fs.readFileSync(file, 'utf8');\n return { key, file, html, sha256: crypto.createHash('sha256').update(html).digest('hex') };\n}\n\n/**\n * Reads the MCP app sync built for these candidates, without building anything.\n *\n * Undefined when no candidate declares UI widgets. Otherwise the key, plus the build when its\n * file exists; a missing build means sync has not prepared this widget set yet.\n */\nexport function readMcpAppBuild(\n input: Pick<McpAppBuildInput, 'poHome' | 'candidates'>,\n): { key: string; build?: McpAppBuild } | undefined {\n const key = mcpAppKey(input.candidates);\n if (key === undefined) return undefined;\n const file = mcpAppFile(input.poHome, key);\n return fs.existsSync(file) ? { key, build: loadedBuild(key, file) } : { key };\n}\n\n/**\n * Builds the composed MCP App HTML for live MCP plugins at `<home>/build/mcp-app/<key>/index.html`.\n *\n * An existing key is reused without building. A new key builds into a temporary\n * sibling directory and is renamed into place.\n */\nexport async function ensureMcpAppBuild(input: McpAppBuildInput): Promise<McpAppBuild | undefined> {\n const key = mcpAppKey(input.candidates);\n if (key === undefined) return undefined;\n const file = mcpAppFile(input.poHome, key);\n const directory = path.dirname(file);\n const parent = path.dirname(directory);\n if (!fs.existsSync(file)) {\n fs.mkdirSync(parent, { recursive: true });\n const temporary = fs.mkdtempSync(path.join(parent, `.${key}-`));\n try {\n const built = await (input.bundle ?? bundleMcpApp)(widgetSources(input.candidates), temporary);\n if (built === undefined) return undefined;\n fs.copyFileSync(path.join(temporary, built.file), path.join(temporary, 'index.html'));\n try {\n fs.renameSync(temporary, directory);\n } catch (error) {\n // A concurrent build of the same key already published it.\n if (!fs.existsSync(file)) throw error;\n }\n } finally {\n fs.rmSync(temporary, { recursive: true, force: true });\n }\n }\n return loadedBuild(key, file);\n}\n"],"mappings":";;;;;;;;;;AAsBA,SAAS,cAAc,YAA2D;CAChF,MAAM,UAA0B,CAAC;CACjC,KAAK,MAAM,EAAE,iBAAiB,YAAY;EACxC,IAAI,CAAC,YAAY,MAAM,YAAY,GAAG,QAAQ,WAAW,GAAG;EAC5D,MAAM,OAAOA,QAAAA,QAAG,aAAa,YAAY,UAAU;EACnD,MAAM,OAAOA,QAAAA,QAAG,aAAaC,UAAAA,QAAK,QAAQ,MAAM,YAAY,GAAG,IAAI,CAAC;EACpE,MAAM,WAAWA,UAAAA,QAAK,SAAS,MAAM,IAAI;EACzC,IAAI,aAAa,QAAQ,SAAS,WAAW,KAAKA,UAAAA,QAAK,KAAK,KAAKA,UAAAA,QAAK,WAAW,QAAQ,GACvF,MAAM,IAAI,MAAM,iCAAiC,YAAY,aAAa;EAC5E,QAAQ,KAAK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AY,KAAK,IAAI;AAC9B"}
@@ -0,0 +1,24 @@
1
+ import { bundleMcpApp } from "./mcpApp.mjs";
2
+ import { McpPluginCandidate } from "./mcpBundle.mjs";
3
+ //#region src/builders/server/mcpAppBuild.d.ts
4
+ export interface McpAppBuild {
5
+ readonly key: string;
6
+ readonly file: string;
7
+ readonly html: string;
8
+ readonly sha256: string;
9
+ }
10
+ export interface McpAppBuildInput {
11
+ readonly poHome: string;
12
+ readonly candidates: readonly McpPluginCandidate[];
13
+ /** Test seam; defaults to `bundleMcpApp`. */
14
+ readonly bundle?: typeof bundleMcpApp;
15
+ }
16
+ /**
17
+ * Builds the composed MCP App HTML for live MCP plugins at `<home>/build/mcp-app/<key>/index.html`.
18
+ *
19
+ * An existing key is reused without building. A new key builds into a temporary
20
+ * sibling directory and is renamed into place.
21
+ */
22
+ export declare function ensureMcpAppBuild(input: McpAppBuildInput): Promise<McpAppBuild | undefined>;
23
+ //#endregion
24
+ //# sourceMappingURL=mcpAppBuild.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mcpAppBuild.d.mts","names":[],"sources":["../../../../src/builders/server/mcpAppBuild.ts"],"mappings":";;;iBAQiB;WACN;WACA;WACA;WACA;;iBAGM;WACN;WACA,qBAAqB;;WAErB,gBAAgB;;;;;;;;wBAoEL,kBAAkB,OAAO,mBAAmB,QAAQ"}
@@ -0,0 +1,105 @@
1
+ import { snapshotFiles, statSignature } from "./packageUrl.mjs";
2
+ import { bundleMcpApp, mcpAppInputs } from "./mcpApp.mjs";
3
+ import fs from "node:fs";
4
+ import path from "node:path";
5
+ import crypto from "node:crypto";
6
+ //#region src/builders/server/mcpAppBuild.ts
7
+ function widgetSources(candidates) {
8
+ const sources = [];
9
+ for (const { declaration } of candidates) {
10
+ if (!declaration.ui || declaration.ui.widgets.length === 0) continue;
11
+ const root = fs.realpathSync(declaration.packageDir);
12
+ const file = fs.realpathSync(path.resolve(root, declaration.ui.dist));
13
+ const relative = path.relative(root, file);
14
+ if (relative === ".." || relative.startsWith(`..${path.sep}`) || path.isAbsolute(relative)) throw new Error(`MCP UI entry escapes package: ${declaration.packageName}`);
15
+ sources.push({
16
+ file,
17
+ widgets: declaration.ui.widgets
18
+ });
19
+ }
20
+ return sources;
21
+ }
22
+ /** Content key over every widget package's files, so any source change moves it. */
23
+ function mcpAppKey(candidates, inputs) {
24
+ const hash = crypto.createHash("sha256");
25
+ let any = false;
26
+ for (const { declaration } of candidates) {
27
+ if (!declaration.ui || declaration.ui.widgets.length === 0) continue;
28
+ any = true;
29
+ const root = fs.realpathSync(declaration.packageDir);
30
+ const entry = path.resolve(root, declaration.ui.dist);
31
+ hash.update(`${declaration.packageName}\0${root}\0${declaration.ui.widgets.join(",")}\0`);
32
+ hash.update(statSignature(root, snapshotFiles(root, entry)));
33
+ hash.update("\n");
34
+ }
35
+ if (!any) return void 0;
36
+ for (const file of [...inputs ?? mcpAppInputs(), import.meta.filename].sort()) {
37
+ hash.update(`${file}\0`);
38
+ hash.update(crypto.createHash("sha256").update(fs.readFileSync(file)).digest());
39
+ }
40
+ return hash.digest("hex").slice(0, 32);
41
+ }
42
+ function mcpAppFile(poHome, key) {
43
+ return path.join(poHome, "build", "mcp-app", key, "index.html");
44
+ }
45
+ function loadedBuild(key, file) {
46
+ const html = fs.readFileSync(file, "utf8");
47
+ return {
48
+ key,
49
+ file,
50
+ html,
51
+ sha256: crypto.createHash("sha256").update(html).digest("hex")
52
+ };
53
+ }
54
+ /**
55
+ * Reads the MCP app sync built for these candidates, without building anything.
56
+ *
57
+ * Undefined when no candidate declares UI widgets. Otherwise the key, plus the build when its
58
+ * file exists; a missing build means sync has not prepared this widget set yet.
59
+ */
60
+ function readMcpAppBuild(input) {
61
+ const key = mcpAppKey(input.candidates);
62
+ if (key === void 0) return void 0;
63
+ const file = mcpAppFile(input.poHome, key);
64
+ return fs.existsSync(file) ? {
65
+ key,
66
+ build: loadedBuild(key, file)
67
+ } : { key };
68
+ }
69
+ /**
70
+ * Builds the composed MCP App HTML for live MCP plugins at `<home>/build/mcp-app/<key>/index.html`.
71
+ *
72
+ * An existing key is reused without building. A new key builds into a temporary
73
+ * sibling directory and is renamed into place.
74
+ */
75
+ async function ensureMcpAppBuild(input) {
76
+ const key = mcpAppKey(input.candidates);
77
+ if (key === void 0) return void 0;
78
+ const file = mcpAppFile(input.poHome, key);
79
+ const directory = path.dirname(file);
80
+ const parent = path.dirname(directory);
81
+ if (!fs.existsSync(file)) {
82
+ fs.mkdirSync(parent, { recursive: true });
83
+ const temporary = fs.mkdtempSync(path.join(parent, `.${key}-`));
84
+ try {
85
+ const built = await (input.bundle ?? bundleMcpApp)(widgetSources(input.candidates), temporary);
86
+ if (built === void 0) return void 0;
87
+ fs.copyFileSync(path.join(temporary, built.file), path.join(temporary, "index.html"));
88
+ try {
89
+ fs.renameSync(temporary, directory);
90
+ } catch (error) {
91
+ if (!fs.existsSync(file)) throw error;
92
+ }
93
+ } finally {
94
+ fs.rmSync(temporary, {
95
+ recursive: true,
96
+ force: true
97
+ });
98
+ }
99
+ }
100
+ return loadedBuild(key, file);
101
+ }
102
+ //#endregion
103
+ export { ensureMcpAppBuild, mcpAppKey, readMcpAppBuild };
104
+
105
+ //# sourceMappingURL=mcpAppBuild.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mcpAppBuild.mjs","names":[],"sources":["../../../../src/builders/server/mcpAppBuild.ts"],"sourcesContent":["import crypto from 'node:crypto';\nimport fs from 'node:fs';\nimport path from 'node:path';\n\nimport { bundleMcpApp, mcpAppInputs, type McpAppSource } from './mcpApp';\nimport type { McpPluginCandidate } from './mcpBundle';\nimport { snapshotFiles, statSignature } from './packageUrl';\n\nexport interface McpAppBuild {\n readonly key: string;\n readonly file: string;\n readonly html: string;\n readonly sha256: string;\n}\n\nexport interface McpAppBuildInput {\n readonly poHome: string;\n readonly candidates: readonly McpPluginCandidate[];\n /** Test seam; defaults to `bundleMcpApp`. */\n readonly bundle?: typeof bundleMcpApp;\n}\n\nfunction widgetSources(candidates: readonly McpPluginCandidate[]): McpAppSource[] {\n const sources: McpAppSource[] = [];\n for (const { declaration } of candidates) {\n if (!declaration.ui || declaration.ui.widgets.length === 0) continue;\n const root = fs.realpathSync(declaration.packageDir);\n const file = fs.realpathSync(path.resolve(root, declaration.ui.dist));\n const relative = path.relative(root, file);\n if (relative === '..' || relative.startsWith(`..${path.sep}`) || path.isAbsolute(relative))\n throw new Error(`MCP UI entry escapes package: ${declaration.packageName}`);\n sources.push({ file, widgets: declaration.ui.widgets });\n }\n return sources;\n}\n\n/** Content key over every widget package's files, so any source change moves it. */\nexport function mcpAppKey(candidates: readonly McpPluginCandidate[], inputs?: readonly string[]): string | undefined {\n const hash = crypto.createHash('sha256');\n let any = false;\n for (const { declaration } of candidates) {\n if (!declaration.ui || declaration.ui.widgets.length === 0) continue;\n any = true;\n const root = fs.realpathSync(declaration.packageDir);\n const entry = path.resolve(root, declaration.ui.dist);\n hash.update(`${declaration.packageName}\\0${root}\\0${declaration.ui.widgets.join(',')}\\0`);\n hash.update(statSignature(root, snapshotFiles(root, entry)));\n hash.update('\\n');\n }\n if (!any) return undefined;\n for (const file of [...(inputs ?? mcpAppInputs()), import.meta.filename].sort()) {\n hash.update(`${file}\\0`);\n hash.update(crypto.createHash('sha256').update(fs.readFileSync(file)).digest());\n }\n return hash.digest('hex').slice(0, 32);\n}\n\nfunction mcpAppFile(poHome: string, key: string): string {\n return path.join(poHome, 'build', 'mcp-app', key, 'index.html');\n}\n\nfunction loadedBuild(key: string, file: string): McpAppBuild {\n const html = fs.readFileSync(file, 'utf8');\n return { key, file, html, sha256: crypto.createHash('sha256').update(html).digest('hex') };\n}\n\n/**\n * Reads the MCP app sync built for these candidates, without building anything.\n *\n * Undefined when no candidate declares UI widgets. Otherwise the key, plus the build when its\n * file exists; a missing build means sync has not prepared this widget set yet.\n */\nexport function readMcpAppBuild(\n input: Pick<McpAppBuildInput, 'poHome' | 'candidates'>,\n): { key: string; build?: McpAppBuild } | undefined {\n const key = mcpAppKey(input.candidates);\n if (key === undefined) return undefined;\n const file = mcpAppFile(input.poHome, key);\n return fs.existsSync(file) ? { key, build: loadedBuild(key, file) } : { key };\n}\n\n/**\n * Builds the composed MCP App HTML for live MCP plugins at `<home>/build/mcp-app/<key>/index.html`.\n *\n * An existing key is reused without building. A new key builds into a temporary\n * sibling directory and is renamed into place.\n */\nexport async function ensureMcpAppBuild(input: McpAppBuildInput): Promise<McpAppBuild | undefined> {\n const key = mcpAppKey(input.candidates);\n if (key === undefined) return undefined;\n const file = mcpAppFile(input.poHome, key);\n const directory = path.dirname(file);\n const parent = path.dirname(directory);\n if (!fs.existsSync(file)) {\n fs.mkdirSync(parent, { recursive: true });\n const temporary = fs.mkdtempSync(path.join(parent, `.${key}-`));\n try {\n const built = await (input.bundle ?? bundleMcpApp)(widgetSources(input.candidates), temporary);\n if (built === undefined) return undefined;\n fs.copyFileSync(path.join(temporary, built.file), path.join(temporary, 'index.html'));\n try {\n fs.renameSync(temporary, directory);\n } catch (error) {\n // A concurrent build of the same key already published it.\n if (!fs.existsSync(file)) throw error;\n }\n } finally {\n fs.rmSync(temporary, { recursive: true, force: true });\n }\n }\n return loadedBuild(key, file);\n}\n"],"mappings":";;;;;;AAsBA,SAAS,cAAc,YAA2D;CAChF,MAAM,UAA0B,CAAC;CACjC,KAAK,MAAM,EAAE,iBAAiB,YAAY;EACxC,IAAI,CAAC,YAAY,MAAM,YAAY,GAAG,QAAQ,WAAW,GAAG;EAC5D,MAAM,OAAO,GAAG,aAAa,YAAY,UAAU;EACnD,MAAM,OAAO,GAAG,aAAa,KAAK,QAAQ,MAAM,YAAY,GAAG,IAAI,CAAC;EACpE,MAAM,WAAW,KAAK,SAAS,MAAM,IAAI;EACzC,IAAI,aAAa,QAAQ,SAAS,WAAW,KAAK,KAAK,KAAK,KAAK,KAAK,WAAW,QAAQ,GACvF,MAAM,IAAI,MAAM,iCAAiC,YAAY,aAAa;EAC5E,QAAQ,KAAK;GAAE;GAAM,SAAS,YA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;CACtC,IAAI,QAAQ,KAAA,GAAW,OAAO,KAAA;CAC9B,MAAM,OAAO,WAAW,MAAM,QAAQ,GAAG;CACzC,OAAO,GAAG,WAAW,IAAI,IAAI;EAAE;EAAK,OAAO,YAAY,KAAK,IAAI;CAAE,IAAI,EAAE,IAAI;AAC9E;;;;;;;AAQA,eAAsB,kBAAkB,OAA2D;CACjG,MAAM,MAAM,UAAU,MAAM,UAAU;CACtC,IAAI,QAAQ,KAAA,GAAW,OAAO,KAAA;CAC9B,MAAM,OAAO,WAAW,MAAM,QAAQ,GAAG;CACzC,MAAM,YAAY,KAAK,QAAQ,IAAI;CACnC,MAAM,SAAS,KAAK,QAAQ,SAAS;CACrC,IAAI,CAAC,GAAG,WAAW,IAAI,GAAG;EACxB,GAAG,UAAU,QAAQ,EAAE,WAAW,KAAK,CAAC;EACxC,MAAM,YAAY,GAAG,YAAY,KAAK,KAAK,QAAQ,IAAI,IAAI,EAAE,CAAC;EAC9D,IAAI;GACF,MAAM,QAAQ,OAAO,MAAM,UAAU,aAAA,CAAc,cAAc,MAAM,UAAU,GAAG,SAAS;GAC7F,IAAI,UAAU,KAAA,GAAW,OAAO,KAAA;GAChC,GAAG,aAAa,KAAK,KAAK,WAAW,MAAM,IAAI,GAAG,KAAK,KAAK,WAAW,YAAY,CAAC;GACpF,IAAI;IACF,GAAG,WAAW,WAAW,SAAS;GACpC,SAAS,OAAO;IAEd,IAAI,CAAC,GAAG,WAAW,IAAI,GAAG,MAAM;GAClC;EACF,UAAU;GACR,GAAG,OAAO,WAAW;IAAE,WAAW;IAAM,OAAO;GAAK,CAAC;EACvD;CACF;CACA,OAAO,YAAY,KAAK,IAAI;AAC9B"}
@@ -0,0 +1,87 @@
1
+ const require_runtime = require("../../../_virtual/_rolldown/runtime.cjs");
2
+ let node_fs = require("node:fs");
3
+ node_fs = require_runtime.__toESM(node_fs, 1);
4
+ let node_path = require("node:path");
5
+ node_path = require_runtime.__toESM(node_path, 1);
6
+ //#region src/builders/server/mcpBundle.ts
7
+ function packageRootOf(entry) {
8
+ let directory = node_path.default.dirname(node_fs.default.realpathSync(entry));
9
+ for (;;) {
10
+ if (node_fs.default.existsSync(node_path.default.join(directory, "package.json"))) return directory;
11
+ const parent = node_path.default.dirname(directory);
12
+ if (parent === directory) throw new Error(`No package manifest owns ${entry}`);
13
+ directory = parent;
14
+ }
15
+ }
16
+ function packagePath(packageDir, field, value) {
17
+ if (typeof value !== "string" || !value.startsWith("./") || value.includes("..")) throw new Error(`poMcp ${field} in ${packageDir} must be a package-relative ./path with no '..'.`);
18
+ return value;
19
+ }
20
+ function declaredMcpPlugin(packageDir, manifest) {
21
+ const value = manifest.poMcp;
22
+ if (value === void 0) return void 0;
23
+ if (typeof value !== "object" || value === null || Array.isArray(value)) throw new Error(`poMcp manifest in ${packageDir} must be an object.`);
24
+ const declaration = value;
25
+ if (!Array.isArray(declaration.scopes) || declaration.scopes.length !== 1 || declaration.scopes[0] !== "session") throw new Error(`poMcp scopes in ${packageDir} must be exactly ['session'].`);
26
+ const packageName = manifest.name;
27
+ if (typeof packageName !== "string" || packageName === "") throw new Error(`Package in ${packageDir} has no name.`);
28
+ let ui;
29
+ if (declaration.ui !== void 0) {
30
+ const value = declaration.ui;
31
+ if (typeof value !== "object" || value === null || !Array.isArray(value.widgets) || value.widgets.some((key) => typeof key !== "string" || !key.startsWith(`${packageName}/`)) || new Set(value.widgets).size !== value.widgets.length) throw new Error(`Invalid MCP widget manifest in ${packageDir}`);
32
+ ui = {
33
+ dist: packagePath(packageDir, "ui.dist", value.dist),
34
+ widgets: value.widgets
35
+ };
36
+ }
37
+ return {
38
+ packageName,
39
+ packageDir,
40
+ ...ui === void 0 ? {} : { ui },
41
+ entry: packagePath(packageDir, "entry", declaration.entry),
42
+ dist: packagePath(packageDir, "dist", declaration.dist)
43
+ };
44
+ }
45
+ /**
46
+ * The MCP plugins the given compositions select, in first-selection order.
47
+ *
48
+ * A package that two different directories claim is ambiguous, and a built
49
+ * entry that resolves outside its package is refused.
50
+ */
51
+ function mcpPluginCandidates(compositions) {
52
+ const packages = /* @__PURE__ */ new Map();
53
+ for (const composition of compositions) {
54
+ const majorMode = composition.majorMode?.name;
55
+ if (!majorMode) throw new Error("An MCP bundle composition needs its major mode");
56
+ for (const root of new Set(composition.packageEntries.map(packageRootOf))) {
57
+ const declaration = declaredMcpPlugin(root, JSON.parse(node_fs.default.readFileSync(node_path.default.join(root, "package.json"), "utf8")));
58
+ if (declaration === void 0) continue;
59
+ const previous = packages.get(declaration.packageName);
60
+ if (previous && previous.declaration.packageDir !== root) throw new Error(`Ambiguous MCP bundle package: ${declaration.packageName}`);
61
+ const candidate = previous ?? {
62
+ declaration,
63
+ owners: []
64
+ };
65
+ const layers = composition.selections.filter((selection) => selection.outcome === "resolved" && selection.path && packageRootOf(selection.path) === root).map((selection) => selection.layer);
66
+ for (const layer of new Set(layers.length > 0 ? layers : ["default"])) if (!candidate.owners.some((owner) => owner.majorMode === majorMode && owner.layer === layer)) candidate.owners.push({
67
+ majorMode,
68
+ layer
69
+ });
70
+ packages.set(declaration.packageName, candidate);
71
+ }
72
+ }
73
+ return [...packages.values()].map(({ declaration, owners }) => {
74
+ const module = node_fs.default.realpathSync(node_path.default.resolve(declaration.packageDir, declaration.dist));
75
+ const relative = node_path.default.relative(declaration.packageDir, module);
76
+ if (relative === ".." || relative.startsWith(`..${node_path.default.sep}`) || node_path.default.isAbsolute(relative)) throw new Error(`MCP entry escapes package: ${declaration.packageName}`);
77
+ return {
78
+ declaration,
79
+ module,
80
+ owners
81
+ };
82
+ });
83
+ }
84
+ //#endregion
85
+ exports.mcpPluginCandidates = mcpPluginCandidates;
86
+
87
+ //# sourceMappingURL=mcpBundle.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mcpBundle.cjs","names":["path","fs"],"sources":["../../../../src/builders/server/mcpBundle.ts"],"sourcesContent":["import fs from 'node:fs';\nimport path from 'node:path';\n\nimport type { DoomServerBundleOwner } from '@agimon-ai/po-core/serverFacet';\n\nimport type { ExtensionComposition } from '../cli/extensionAssembler';\n\nexport interface DeclaredMcpPlugin {\n readonly packageName: string;\n readonly packageDir: string;\n readonly entry: string;\n readonly dist: string;\n readonly ui?: { readonly dist: string; readonly widgets: readonly string[] };\n}\n\nfunction packageRootOf(entry: string): string {\n let directory = path.dirname(fs.realpathSync(entry));\n for (;;) {\n if (fs.existsSync(path.join(directory, 'package.json'))) return directory;\n const parent = path.dirname(directory);\n if (parent === directory) throw new Error(`No package manifest owns ${entry}`);\n directory = parent;\n }\n}\n\nfunction packagePath(packageDir: string, field: string, value: unknown): string {\n if (typeof value !== 'string' || !value.startsWith('./') || value.includes('..'))\n throw new Error(`poMcp ${field} in ${packageDir} must be a package-relative ./path with no '..'.`);\n return value;\n}\n\nfunction declaredMcpPlugin(packageDir: string, manifest: Record<string, unknown>): DeclaredMcpPlugin | undefined {\n const value = manifest.poMcp;\n if (value === undefined) return undefined;\n if (typeof value !== 'object' || value === null || Array.isArray(value))\n throw new Error(`poMcp manifest in ${packageDir} must be an object.`);\n const declaration = value as Record<string, unknown>;\n if (!Array.isArray(declaration.scopes) || declaration.scopes.length !== 1 || declaration.scopes[0] !== 'session')\n throw new Error(`poMcp scopes in ${packageDir} must be exactly ['session'].`);\n const packageName = manifest.name;\n if (typeof packageName !== 'string' || packageName === '') throw new Error(`Package in ${packageDir} has no name.`);\n let ui: DeclaredMcpPlugin['ui'];\n if (declaration.ui !== undefined) {\n const value = declaration.ui as { dist?: unknown; widgets?: unknown } | null;\n if (\n typeof value !== 'object' ||\n value === null ||\n !Array.isArray(value.widgets) ||\n value.widgets.some((key: unknown) => typeof key !== 'string' || !key.startsWith(`${packageName}/`)) ||\n new Set(value.widgets).size !== value.widgets.length\n )\n throw new Error(`Invalid MCP widget manifest in ${packageDir}`);\n ui = { dist: packagePath(packageDir, 'ui.dist', value.dist), widgets: value.widgets as string[] };\n }\n return {\n packageName,\n packageDir,\n ...(ui === undefined ? {} : { ui }),\n entry: packagePath(packageDir, 'entry', declaration.entry),\n dist: packagePath(packageDir, 'dist', declaration.dist),\n };\n}\n\n/** One MCP plugin a composition set selects, with the built entry a host imports. */\nexport interface McpPluginCandidate {\n readonly declaration: DeclaredMcpPlugin;\n /** Absolute, symlink-resolved path of the package's built `dist` entry. */\n readonly module: string;\n /** Every major mode and layer that admitted the package. */\n readonly owners: readonly DoomServerBundleOwner[];\n}\n\n/**\n * The MCP plugins the given compositions select, in first-selection order.\n *\n * A package that two different directories claim is ambiguous, and a built\n * entry that resolves outside its package is refused.\n */\nexport function mcpPluginCandidates(compositions: readonly ExtensionComposition[]): McpPluginCandidate[] {\n const packages = new Map<string, { declaration: DeclaredMcpPlugin; owners: DoomServerBundleOwner[] }>();\n for (const composition of compositions) {\n const majorMode = composition.majorMode?.name;\n if (!majorMode) throw new Error('An MCP bundle composition needs its major mode');\n for (const root of new Set(composition.packageEntries.map(packageRootOf))) {\n const manifest = JSON.parse(fs.readFileSync(path.join(root, 'package.json'), 'utf8')) as Record<string, unknown>;\n const declaration = declaredMcpPlugin(root, manifest);\n if (declaration === undefined) continue;\n const previous = packages.get(declaration.packageName);\n if (previous && previous.declaration.packageDir !== root)\n throw new Error(`Ambiguous MCP bundle package: ${declaration.packageName}`);\n const candidate = previous ?? { declaration, owners: [] };\n const layers = composition.selections\n .filter(\n (selection) => selection.outcome === 'resolved' && selection.path && packageRootOf(selection.path) === root,\n )\n .map((selection) => selection.layer);\n for (const layer of new Set(layers.length > 0 ? layers : ['default'])) {\n if (!candidate.owners.some((owner) => owner.majorMode === majorMode && owner.layer === layer))\n candidate.owners.push({ majorMode, layer });\n }\n packages.set(declaration.packageName, candidate);\n }\n }\n return [...packages.values()].map(({ declaration, owners }) => {\n const module = fs.realpathSync(path.resolve(declaration.packageDir, declaration.dist));\n const relative = path.relative(declaration.packageDir, module);\n if (relative === '..' || relative.startsWith(`..${path.sep}`) || path.isAbsolute(relative))\n throw new Error(`MCP entry escapes package: ${declaration.packageName}`);\n return { declaration, module, owners };\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c,aAAa,MAAM,UAAU,KAAK,GAC1F,UAAU,OAAO,KAAK;IAAE;IAAW;GAAM,CAAC;GAE9C,SAAS,IAAI,YAAY,aAAa,SAAS;EACjD;CACF;CACA,OAAO,CAAC,GAAG,SAAS,OAAO,CAAC,CAAC,CAAC,KAAK,EAAE,aAAa,aAAa;EAC7D,MAAM,SAASC,QAAAA,QAAG,aAAaD,UAAAA,QAAK,QAAQ,YAAY,YAAY,YAAY,IAAI,CAAC;EACrF,MAAM,WAAWA,UAAAA,QAAK,SAAS,YAAY,YAAY,MAAM;EAC7D,IAAI,aAAa,QAAQ,SAAS,WAAW,KAAKA,UAAAA,QAAK,KAAK,KAAKA,UAAAA,QAAK,WAAW,QAAQ,GACvF,MAAM,IAAI,MAAM,8BAA8B,YAAY,aAAa;EACzE,OAAO;GAAE;GAAa;GAAQ;EAAO;CACvC,CAAC;AACH"}
@@ -0,0 +1,23 @@
1
+ import "../../../builders/cli/extensionAssembler/index.mjs";
2
+ import { DoomServerBundleOwner } from "@agimon-ai/po-core/serverFacet";
3
+ //#region src/builders/server/mcpBundle.d.ts
4
+ export interface DeclaredMcpPlugin {
5
+ readonly packageName: string;
6
+ readonly packageDir: string;
7
+ readonly entry: string;
8
+ readonly dist: string;
9
+ readonly ui?: {
10
+ readonly dist: string;
11
+ readonly widgets: readonly string[];
12
+ };
13
+ }
14
+ /** One MCP plugin a composition set selects, with the built entry a host imports. */
15
+ export interface McpPluginCandidate {
16
+ readonly declaration: DeclaredMcpPlugin;
17
+ /** Absolute, symlink-resolved path of the package's built `dist` entry. */
18
+ readonly module: string;
19
+ /** Every major mode and layer that admitted the package. */
20
+ readonly owners: readonly DoomServerBundleOwner[];
21
+ }
22
+ //#endregion
23
+ //# sourceMappingURL=mcpBundle.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mcpBundle.d.mts","names":[],"sources":["../../../../src/builders/server/mcpBundle.ts"],"mappings":";;;iBAOiB;WACN;WACA;WACA;WACA;WACA;aAAgB;aAAuB;;;;iBAoDjC;WACN,aAAa;;WAEb;;WAEA,iBAAiB"}