@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.
- package/LICENSE +21 -0
- package/README.md +755 -0
- package/assets/banner.png +0 -0
- package/assets/banner.svg +25 -0
- package/assets/favicon.svg +15 -0
- package/assets/logo-light.png +0 -0
- package/assets/logo-light.svg +25 -0
- package/assets/logo.png +0 -0
- package/assets/logo.svg +25 -0
- package/assets/mascot.png +0 -0
- package/assets/mascot.svg +25 -0
- package/dist/_virtual/_rolldown/runtime.cjs +23 -0
- package/dist/antigravity.cjs +5 -0
- package/dist/antigravity.d.mts +2 -0
- package/dist/antigravity.mjs +2 -0
- package/dist/apiContracts.cjs +11 -0
- package/dist/apiContracts.cjs.map +1 -0
- package/dist/apiContracts.d.mts +52 -0
- package/dist/apiContracts.d.mts.map +1 -0
- package/dist/apiContracts.mjs +7 -0
- package/dist/apiContracts.mjs.map +1 -0
- package/dist/baseCommand.cjs +3 -0
- package/dist/baseCommand.d.mts +2 -0
- package/dist/baseCommand.mjs +2 -0
- package/dist/bin/cli.cjs +24 -0
- package/dist/bin/cli.cjs.map +1 -0
- package/dist/bin/cli.d.mts +1 -0
- package/dist/bin/cli.mjs +25 -0
- package/dist/bin/cli.mjs.map +1 -0
- package/dist/bin/doomRunner.cjs +33 -0
- package/dist/bin/doomRunner.cjs.map +1 -0
- package/dist/bin/doomRunner.d.mts +4 -0
- package/dist/bin/doomRunner.d.mts.map +1 -0
- package/dist/bin/doomRunner.mjs +32 -0
- package/dist/bin/doomRunner.mjs.map +1 -0
- package/dist/bin/serve.cjs +30 -0
- package/dist/bin/serve.cjs.map +1 -0
- package/dist/bin/serve.d.mts +1 -0
- package/dist/bin/serve.mjs +31 -0
- package/dist/bin/serve.mjs.map +1 -0
- package/dist/builders/cli/extensionAssembler/index.cjs +342 -0
- package/dist/builders/cli/extensionAssembler/index.cjs.map +1 -0
- package/dist/builders/cli/extensionAssembler/index.d.mts +85 -0
- package/dist/builders/cli/extensionAssembler/index.d.mts.map +1 -0
- package/dist/builders/cli/extensionAssembler/index.mjs +335 -0
- package/dist/builders/cli/extensionAssembler/index.mjs.map +1 -0
- package/dist/catalog/index.json +430 -0
- package/dist/cli.cjs +28 -0
- package/dist/cli.d.mts +11 -0
- package/dist/cli.mjs +11 -0
- package/dist/cliApp.cjs +6 -0
- package/dist/cliApp.d.mts +2 -0
- package/dist/cliApp.mjs +2 -0
- package/dist/codex.cjs +8 -0
- package/dist/codex.d.mts +2 -0
- package/dist/codex.mjs +2 -0
- package/dist/commands.cjs +18 -0
- package/dist/commands.d.mts +9 -0
- package/dist/commands.mjs +9 -0
- package/dist/compatibility.cjs +27 -0
- package/dist/compatibility.d.mts +6 -0
- package/dist/compatibility.mjs +6 -0
- package/dist/compatibilityCommand.cjs +4 -0
- package/dist/compatibilityCommand.d.mts +2 -0
- package/dist/compatibilityCommand.mjs +2 -0
- package/dist/compatibilityContext.cjs +3 -0
- package/dist/compatibilityContext.d.mts +2 -0
- package/dist/compatibilityContext.mjs +2 -0
- package/dist/compatibilityOptions.cjs +5 -0
- package/dist/compatibilityOptions.d.mts +2 -0
- package/dist/compatibilityOptions.mjs +2 -0
- package/dist/config.cjs +163 -0
- package/dist/config.d.mts +7 -0
- package/dist/config.mjs +7 -0
- package/dist/doctorCommand.cjs +5 -0
- package/dist/doctorCommand.d.mts +2 -0
- package/dist/doctorCommand.mjs +2 -0
- package/dist/emitMcpCommand.cjs +4 -0
- package/dist/emitMcpCommand.d.mts +2 -0
- package/dist/emitMcpCommand.mjs +2 -0
- package/dist/explainCommand.cjs +5 -0
- package/dist/explainCommand.d.mts +2 -0
- package/dist/explainCommand.mjs +2 -0
- package/dist/extensions/server.cjs +39 -0
- package/dist/extensions/server.cjs.map +1 -0
- package/dist/extensions/server.d.mts +5 -0
- package/dist/extensions/server.d.mts.map +1 -0
- package/dist/extensions/server.mjs +34 -0
- package/dist/extensions/server.mjs.map +1 -0
- package/dist/harnessContext.cjs +5 -0
- package/dist/harnessContext.d.mts +2 -0
- package/dist/harnessContext.mjs +2 -0
- package/dist/harnessState.cjs +19 -0
- package/dist/harnessState.d.mts +2 -0
- package/dist/harnessState.mjs +2 -0
- package/dist/help.cjs +12 -0
- package/dist/help.d.mts +6 -0
- package/dist/help.mjs +6 -0
- package/dist/index.cjs +306 -0
- package/dist/index.d.mts +40 -0
- package/dist/index.mjs +37 -0
- package/dist/initCommand.cjs +4 -0
- package/dist/initCommand.d.mts +2 -0
- package/dist/initCommand.mjs +2 -0
- package/dist/matrixOptions.cjs +28 -0
- package/dist/matrixOptions.d.mts +2 -0
- package/dist/matrixOptions.mjs +2 -0
- package/dist/matrixSwitcher.cjs +11 -0
- package/dist/matrixSwitcher.d.mts +3 -0
- package/dist/matrixSwitcher.mjs +3 -0
- package/dist/mcpFilter.cjs +9 -0
- package/dist/mcpFilter.d.mts +1 -0
- package/dist/mcpFilter.mjs +2 -0
- package/dist/options.cjs +3 -0
- package/dist/options.d.mts +2 -0
- package/dist/options.mjs +2 -0
- package/dist/process.cjs +12 -0
- package/dist/process.d.mts +2 -0
- package/dist/process.mjs +2 -0
- package/dist/projectTrust.cjs +6 -0
- package/dist/projectTrust.d.mts +2 -0
- package/dist/projectTrust.mjs +2 -0
- package/dist/repository.cjs +5 -0
- package/dist/repository.d.mts +2 -0
- package/dist/repository.mjs +2 -0
- package/dist/resourceCollector.cjs +9 -0
- package/dist/resourceCollector.d.mts +1 -0
- package/dist/resourceCollector.mjs +2 -0
- package/dist/router.cjs +6 -0
- package/dist/router.d.mts +2 -0
- package/dist/router.mjs +2 -0
- package/dist/services.cjs +97 -0
- package/dist/services.d.mts +12 -0
- package/dist/services.mjs +12 -0
- package/dist/shared.cjs +18 -0
- package/dist/shared.d.mts +2 -0
- package/dist/shared.mjs +2 -0
- package/dist/src/bin/agentDirectory.cjs +27 -0
- package/dist/src/bin/agentDirectory.cjs.map +1 -0
- package/dist/src/bin/agentDirectory.mjs +26 -0
- package/dist/src/bin/agentDirectory.mjs.map +1 -0
- package/dist/src/builders/apiContractExport/index.cjs +126 -0
- package/dist/src/builders/apiContractExport/index.cjs.map +1 -0
- package/dist/src/builders/apiContractExport/index.mjs +123 -0
- package/dist/src/builders/apiContractExport/index.mjs.map +1 -0
- package/dist/src/builders/cli/entryResolution.cjs +39 -0
- package/dist/src/builders/cli/entryResolution.cjs.map +1 -0
- package/dist/src/builders/cli/entryResolution.mjs +35 -0
- package/dist/src/builders/cli/entryResolution.mjs.map +1 -0
- package/dist/src/builders/cli/harnessContext.cjs +175 -0
- package/dist/src/builders/cli/harnessContext.cjs.map +1 -0
- package/dist/src/builders/cli/harnessContext.d.mts +48 -0
- package/dist/src/builders/cli/harnessContext.d.mts.map +1 -0
- package/dist/src/builders/cli/harnessContext.mjs +167 -0
- package/dist/src/builders/cli/harnessContext.mjs.map +1 -0
- package/dist/src/builders/cli/sessionComposition.cjs +27 -0
- package/dist/src/builders/cli/sessionComposition.cjs.map +1 -0
- package/dist/src/builders/cli/sessionComposition.mjs +26 -0
- package/dist/src/builders/cli/sessionComposition.mjs.map +1 -0
- package/dist/src/builders/hooks/index.cjs +238 -0
- package/dist/src/builders/hooks/index.cjs.map +1 -0
- package/dist/src/builders/hooks/index.mjs +231 -0
- package/dist/src/builders/hooks/index.mjs.map +1 -0
- package/dist/src/builders/native/index.cjs +176 -0
- package/dist/src/builders/native/index.cjs.map +1 -0
- package/dist/src/builders/native/index.d.mts +36 -0
- package/dist/src/builders/native/index.d.mts.map +1 -0
- package/dist/src/builders/native/index.mjs +170 -0
- package/dist/src/builders/native/index.mjs.map +1 -0
- package/dist/src/builders/server/backgroundSync.cjs +333 -0
- package/dist/src/builders/server/backgroundSync.cjs.map +1 -0
- package/dist/src/builders/server/backgroundSync.mjs +320 -0
- package/dist/src/builders/server/backgroundSync.mjs.map +1 -0
- package/dist/src/builders/server/computerUseBinding.cjs +273 -0
- package/dist/src/builders/server/computerUseBinding.cjs.map +1 -0
- package/dist/src/builders/server/computerUseBinding.mjs +269 -0
- package/dist/src/builders/server/computerUseBinding.mjs.map +1 -0
- package/dist/src/builders/server/computerUseRecordings.cjs +188 -0
- package/dist/src/builders/server/computerUseRecordings.cjs.map +1 -0
- package/dist/src/builders/server/computerUseRecordings.mjs +184 -0
- package/dist/src/builders/server/computerUseRecordings.mjs.map +1 -0
- package/dist/src/builders/server/defaultWorkspace.cjs +38 -0
- package/dist/src/builders/server/defaultWorkspace.cjs.map +1 -0
- package/dist/src/builders/server/defaultWorkspace.mjs +35 -0
- package/dist/src/builders/server/defaultWorkspace.mjs.map +1 -0
- package/dist/src/builders/server/idleRestart.cjs +149 -0
- package/dist/src/builders/server/idleRestart.cjs.map +1 -0
- package/dist/src/builders/server/idleRestart.mjs +136 -0
- package/dist/src/builders/server/idleRestart.mjs.map +1 -0
- package/dist/src/builders/server/index.cjs +63 -0
- package/dist/src/builders/server/index.cjs.map +1 -0
- package/dist/src/builders/server/index.mjs +60 -0
- package/dist/src/builders/server/index.mjs.map +1 -0
- package/dist/src/builders/server/logSink.cjs +57 -0
- package/dist/src/builders/server/logSink.cjs.map +1 -0
- package/dist/src/builders/server/logSink.mjs +57 -0
- package/dist/src/builders/server/logSink.mjs.map +1 -0
- package/dist/src/builders/server/mcpApp.cjs +152 -0
- package/dist/src/builders/server/mcpApp.cjs.map +1 -0
- package/dist/src/builders/server/mcpApp.d.mts +18 -0
- package/dist/src/builders/server/mcpApp.d.mts.map +1 -0
- package/dist/src/builders/server/mcpApp.mjs +147 -0
- package/dist/src/builders/server/mcpApp.mjs.map +1 -0
- package/dist/src/builders/server/mcpAppBuild.cjs +111 -0
- package/dist/src/builders/server/mcpAppBuild.cjs.map +1 -0
- package/dist/src/builders/server/mcpAppBuild.d.mts +24 -0
- package/dist/src/builders/server/mcpAppBuild.d.mts.map +1 -0
- package/dist/src/builders/server/mcpAppBuild.mjs +105 -0
- package/dist/src/builders/server/mcpAppBuild.mjs.map +1 -0
- package/dist/src/builders/server/mcpBundle.cjs +87 -0
- package/dist/src/builders/server/mcpBundle.cjs.map +1 -0
- package/dist/src/builders/server/mcpBundle.d.mts +23 -0
- package/dist/src/builders/server/mcpBundle.d.mts.map +1 -0
- package/dist/src/builders/server/mcpBundle.mjs +84 -0
- package/dist/src/builders/server/mcpBundle.mjs.map +1 -0
- package/dist/src/builders/server/packageReloadCheck.cjs +62 -0
- package/dist/src/builders/server/packageReloadCheck.cjs.map +1 -0
- package/dist/src/builders/server/packageReloadCheck.mjs +61 -0
- package/dist/src/builders/server/packageReloadCheck.mjs.map +1 -0
- package/dist/src/builders/server/packageUrl.cjs +210 -0
- package/dist/src/builders/server/packageUrl.cjs.map +1 -0
- package/dist/src/builders/server/packageUrl.mjs +203 -0
- package/dist/src/builders/server/packageUrl.mjs.map +1 -0
- package/dist/src/builders/server/runtime.cjs +1428 -0
- package/dist/src/builders/server/runtime.cjs.map +1 -0
- package/dist/src/builders/server/runtime.mjs +1420 -0
- package/dist/src/builders/server/runtime.mjs.map +1 -0
- package/dist/src/builders/server/runtimeResources.cjs +72 -0
- package/dist/src/builders/server/runtimeResources.cjs.map +1 -0
- package/dist/src/builders/server/runtimeResources.mjs +71 -0
- package/dist/src/builders/server/runtimeResources.mjs.map +1 -0
- package/dist/src/builders/server/selectionStatus.cjs +12 -0
- package/dist/src/builders/server/selectionStatus.cjs.map +1 -0
- package/dist/src/builders/server/selectionStatus.mjs +12 -0
- package/dist/src/builders/server/selectionStatus.mjs.map +1 -0
- package/dist/src/builders/server/sessionArguments.cjs +63 -0
- package/dist/src/builders/server/sessionArguments.cjs.map +1 -0
- package/dist/src/builders/server/sessionArguments.mjs +62 -0
- package/dist/src/builders/server/sessionArguments.mjs.map +1 -0
- package/dist/src/builders/server/shutdown.cjs +16 -0
- package/dist/src/builders/server/shutdown.cjs.map +1 -0
- package/dist/src/builders/server/shutdown.mjs +16 -0
- package/dist/src/builders/server/shutdown.mjs.map +1 -0
- package/dist/src/builders/server/webTemplateDecision.cjs +34 -0
- package/dist/src/builders/server/webTemplateDecision.cjs.map +1 -0
- package/dist/src/builders/server/webTemplateDecision.mjs +32 -0
- package/dist/src/builders/server/webTemplateDecision.mjs.map +1 -0
- package/dist/src/builders/server/workspaceCheckout.cjs +31 -0
- package/dist/src/builders/server/workspaceCheckout.cjs.map +1 -0
- package/dist/src/builders/server/workspaceCheckout.mjs +29 -0
- package/dist/src/builders/server/workspaceCheckout.mjs.map +1 -0
- package/dist/src/builders/web/bundle.cjs +225 -0
- package/dist/src/builders/web/bundle.cjs.map +1 -0
- package/dist/src/builders/web/bundle.d.mts +65 -0
- package/dist/src/builders/web/bundle.d.mts.map +1 -0
- package/dist/src/builders/web/bundle.mjs +221 -0
- package/dist/src/builders/web/bundle.mjs.map +1 -0
- package/dist/src/builders/web/bundleAssetPolicy.cjs +96 -0
- package/dist/src/builders/web/bundleAssetPolicy.cjs.map +1 -0
- package/dist/src/builders/web/bundleAssetPolicy.d.mts +22 -0
- package/dist/src/builders/web/bundleAssetPolicy.d.mts.map +1 -0
- package/dist/src/builders/web/bundleAssetPolicy.mjs +95 -0
- package/dist/src/builders/web/bundleAssetPolicy.mjs.map +1 -0
- package/dist/src/builders/web/index.cjs +361 -0
- package/dist/src/builders/web/index.cjs.map +1 -0
- package/dist/src/builders/web/index.d.mts +109 -0
- package/dist/src/builders/web/index.d.mts.map +1 -0
- package/dist/src/builders/web/index.mjs +342 -0
- package/dist/src/builders/web/index.mjs.map +1 -0
- package/dist/src/builders/web/webDevRoots.cjs +27 -0
- package/dist/src/builders/web/webDevRoots.cjs.map +1 -0
- package/dist/src/builders/web/webDevRoots.d.mts +22 -0
- package/dist/src/builders/web/webDevRoots.d.mts.map +1 -0
- package/dist/src/builders/web/webDevRoots.mjs +25 -0
- package/dist/src/builders/web/webDevRoots.mjs.map +1 -0
- package/dist/src/builders/web/webPluginGenerate.cjs +188 -0
- package/dist/src/builders/web/webPluginGenerate.cjs.map +1 -0
- package/dist/src/builders/web/webPluginGenerate.d.mts +56 -0
- package/dist/src/builders/web/webPluginGenerate.d.mts.map +1 -0
- package/dist/src/builders/web/webPluginGenerate.mjs +178 -0
- package/dist/src/builders/web/webPluginGenerate.mjs.map +1 -0
- package/dist/src/builders/web/webPluginManifest.cjs +128 -0
- package/dist/src/builders/web/webPluginManifest.cjs.map +1 -0
- package/dist/src/builders/web/webPluginManifest.d.mts +64 -0
- package/dist/src/builders/web/webPluginManifest.d.mts.map +1 -0
- package/dist/src/builders/web/webPluginManifest.mjs +118 -0
- package/dist/src/builders/web/webPluginManifest.mjs.map +1 -0
- package/dist/src/builders/web/webPluginScan.cjs +57 -0
- package/dist/src/builders/web/webPluginScan.cjs.map +1 -0
- package/dist/src/builders/web/webPluginScan.d.mts +19 -0
- package/dist/src/builders/web/webPluginScan.d.mts.map +1 -0
- package/dist/src/builders/web/webPluginScan.mjs +54 -0
- package/dist/src/builders/web/webPluginScan.mjs.map +1 -0
- package/dist/src/builders/web/webPluginVite.cjs +255 -0
- package/dist/src/builders/web/webPluginVite.cjs.map +1 -0
- package/dist/src/builders/web/webPluginVite.d.mts +64 -0
- package/dist/src/builders/web/webPluginVite.d.mts.map +1 -0
- package/dist/src/builders/web/webPluginVite.mjs +242 -0
- package/dist/src/builders/web/webPluginVite.mjs.map +1 -0
- package/dist/src/cli/cliApp.cjs +187 -0
- package/dist/src/cli/cliApp.cjs.map +1 -0
- package/dist/src/cli/cliApp.d.mts +32 -0
- package/dist/src/cli/cliApp.d.mts.map +1 -0
- package/dist/src/cli/cliApp.mjs +184 -0
- package/dist/src/cli/cliApp.mjs.map +1 -0
- package/dist/src/cli/commands/api-export/index.cjs +66 -0
- package/dist/src/cli/commands/api-export/index.cjs.map +1 -0
- package/dist/src/cli/commands/api-export/index.mjs +62 -0
- package/dist/src/cli/commands/api-export/index.mjs.map +1 -0
- package/dist/src/cli/commands/baseCommand.cjs +16 -0
- package/dist/src/cli/commands/baseCommand.cjs.map +1 -0
- package/dist/src/cli/commands/baseCommand.d.mts +24 -0
- package/dist/src/cli/commands/baseCommand.d.mts.map +1 -0
- package/dist/src/cli/commands/baseCommand.mjs +16 -0
- package/dist/src/cli/commands/baseCommand.mjs.map +1 -0
- package/dist/src/cli/commands/compat/context.cjs +115 -0
- package/dist/src/cli/commands/compat/context.cjs.map +1 -0
- package/dist/src/cli/commands/compat/context.d.mts +22 -0
- package/dist/src/cli/commands/compat/context.d.mts.map +1 -0
- package/dist/src/cli/commands/compat/context.mjs +110 -0
- package/dist/src/cli/commands/compat/context.mjs.map +1 -0
- package/dist/src/cli/commands/compat/help.cjs +26 -0
- package/dist/src/cli/commands/compat/help.cjs.map +1 -0
- package/dist/src/cli/commands/compat/help.d.mts +4 -0
- package/dist/src/cli/commands/compat/help.d.mts.map +1 -0
- package/dist/src/cli/commands/compat/help.mjs +25 -0
- package/dist/src/cli/commands/compat/help.mjs.map +1 -0
- package/dist/src/cli/commands/compat/index.cjs +73 -0
- package/dist/src/cli/commands/compat/index.cjs.map +1 -0
- package/dist/src/cli/commands/compat/index.d.mts +14 -0
- package/dist/src/cli/commands/compat/index.d.mts.map +1 -0
- package/dist/src/cli/commands/compat/index.mjs +70 -0
- package/dist/src/cli/commands/compat/index.mjs.map +1 -0
- package/dist/src/cli/commands/compat/options.cjs +88 -0
- package/dist/src/cli/commands/compat/options.cjs.map +1 -0
- package/dist/src/cli/commands/compat/options.d.mts +15 -0
- package/dist/src/cli/commands/compat/options.d.mts.map +1 -0
- package/dist/src/cli/commands/compat/options.mjs +86 -0
- package/dist/src/cli/commands/compat/options.mjs.map +1 -0
- package/dist/src/cli/commands/compat/providers/antigravity.cjs +294 -0
- package/dist/src/cli/commands/compat/providers/antigravity.cjs.map +1 -0
- package/dist/src/cli/commands/compat/providers/antigravity.d.mts +9 -0
- package/dist/src/cli/commands/compat/providers/antigravity.d.mts.map +1 -0
- package/dist/src/cli/commands/compat/providers/antigravity.mjs +289 -0
- package/dist/src/cli/commands/compat/providers/antigravity.mjs.map +1 -0
- package/dist/src/cli/commands/compat/providers/codex.cjs +178 -0
- package/dist/src/cli/commands/compat/providers/codex.cjs.map +1 -0
- package/dist/src/cli/commands/compat/providers/codex.d.mts +17 -0
- package/dist/src/cli/commands/compat/providers/codex.d.mts.map +1 -0
- package/dist/src/cli/commands/compat/providers/codex.mjs +170 -0
- package/dist/src/cli/commands/compat/providers/codex.mjs.map +1 -0
- package/dist/src/cli/commands/compat/providers/index.cjs +65 -0
- package/dist/src/cli/commands/compat/providers/index.cjs.map +1 -0
- package/dist/src/cli/commands/compat/providers/index.d.mts +15 -0
- package/dist/src/cli/commands/compat/providers/index.d.mts.map +1 -0
- package/dist/src/cli/commands/compat/providers/index.mjs +45 -0
- package/dist/src/cli/commands/compat/providers/index.mjs.map +1 -0
- package/dist/src/cli/commands/compat/providers/process.cjs +172 -0
- package/dist/src/cli/commands/compat/providers/process.cjs.map +1 -0
- package/dist/src/cli/commands/compat/providers/process.d.mts +33 -0
- package/dist/src/cli/commands/compat/providers/process.d.mts.map +1 -0
- package/dist/src/cli/commands/compat/providers/process.mjs +159 -0
- package/dist/src/cli/commands/compat/providers/process.mjs.map +1 -0
- package/dist/src/cli/commands/compat/providers/shared.cjs +76 -0
- package/dist/src/cli/commands/compat/providers/shared.cjs.map +1 -0
- package/dist/src/cli/commands/compat/providers/shared.d.mts +40 -0
- package/dist/src/cli/commands/compat/providers/shared.d.mts.map +1 -0
- package/dist/src/cli/commands/compat/providers/shared.mjs +61 -0
- package/dist/src/cli/commands/compat/providers/shared.mjs.map +1 -0
- package/dist/src/cli/commands/compat/types.d.mts +31 -0
- package/dist/src/cli/commands/compat/types.d.mts.map +1 -0
- package/dist/src/cli/commands/doctor/help.cjs +19 -0
- package/dist/src/cli/commands/doctor/help.cjs.map +1 -0
- package/dist/src/cli/commands/doctor/help.d.mts +4 -0
- package/dist/src/cli/commands/doctor/help.d.mts.map +1 -0
- package/dist/src/cli/commands/doctor/help.mjs +19 -0
- package/dist/src/cli/commands/doctor/help.mjs.map +1 -0
- package/dist/src/cli/commands/doctor/index.cjs +118 -0
- package/dist/src/cli/commands/doctor/index.cjs.map +1 -0
- package/dist/src/cli/commands/doctor/index.d.mts +33 -0
- package/dist/src/cli/commands/doctor/index.d.mts.map +1 -0
- package/dist/src/cli/commands/doctor/index.mjs +113 -0
- package/dist/src/cli/commands/doctor/index.mjs.map +1 -0
- package/dist/src/cli/commands/emit-mcp/index.cjs +32 -0
- package/dist/src/cli/commands/emit-mcp/index.cjs.map +1 -0
- package/dist/src/cli/commands/emit-mcp/index.d.mts +19 -0
- package/dist/src/cli/commands/emit-mcp/index.d.mts.map +1 -0
- package/dist/src/cli/commands/emit-mcp/index.mjs +31 -0
- package/dist/src/cli/commands/emit-mcp/index.mjs.map +1 -0
- package/dist/src/cli/commands/explain/index.cjs +155 -0
- package/dist/src/cli/commands/explain/index.cjs.map +1 -0
- package/dist/src/cli/commands/explain/index.d.mts +57 -0
- package/dist/src/cli/commands/explain/index.d.mts.map +1 -0
- package/dist/src/cli/commands/explain/index.mjs +150 -0
- package/dist/src/cli/commands/explain/index.mjs.map +1 -0
- package/dist/src/cli/commands/init/constants.cjs +11 -0
- package/dist/src/cli/commands/init/constants.cjs.map +1 -0
- package/dist/src/cli/commands/init/constants.mjs +11 -0
- package/dist/src/cli/commands/init/constants.mjs.map +1 -0
- package/dist/src/cli/commands/init/help.cjs +17 -0
- package/dist/src/cli/commands/init/help.cjs.map +1 -0
- package/dist/src/cli/commands/init/help.d.mts +4 -0
- package/dist/src/cli/commands/init/help.d.mts.map +1 -0
- package/dist/src/cli/commands/init/help.mjs +17 -0
- package/dist/src/cli/commands/init/help.mjs.map +1 -0
- package/dist/src/cli/commands/init/index.cjs +67 -0
- package/dist/src/cli/commands/init/index.cjs.map +1 -0
- package/dist/src/cli/commands/init/index.d.mts +12 -0
- package/dist/src/cli/commands/init/index.d.mts.map +1 -0
- package/dist/src/cli/commands/init/index.mjs +63 -0
- package/dist/src/cli/commands/init/index.mjs.map +1 -0
- package/dist/src/cli/commands/init/presenter.cjs +140 -0
- package/dist/src/cli/commands/init/presenter.cjs.map +1 -0
- package/dist/src/cli/commands/init/presenter.d.mts +8 -0
- package/dist/src/cli/commands/init/presenter.d.mts.map +1 -0
- package/dist/src/cli/commands/init/presenter.mjs +140 -0
- package/dist/src/cli/commands/init/presenter.mjs.map +1 -0
- package/dist/src/cli/commands/sync/help.cjs +34 -0
- package/dist/src/cli/commands/sync/help.cjs.map +1 -0
- package/dist/src/cli/commands/sync/help.d.mts +4 -0
- package/dist/src/cli/commands/sync/help.d.mts.map +1 -0
- package/dist/src/cli/commands/sync/help.mjs +34 -0
- package/dist/src/cli/commands/sync/help.mjs.map +1 -0
- package/dist/src/cli/commands/sync/index.cjs +215 -0
- package/dist/src/cli/commands/sync/index.cjs.map +1 -0
- package/dist/src/cli/commands/sync/index.d.mts +20 -0
- package/dist/src/cli/commands/sync/index.d.mts.map +1 -0
- package/dist/src/cli/commands/sync/index.mjs +206 -0
- package/dist/src/cli/commands/sync/index.mjs.map +1 -0
- package/dist/src/cli/commands/sync/presenter.cjs +58 -0
- package/dist/src/cli/commands/sync/presenter.cjs.map +1 -0
- package/dist/src/cli/commands/sync/presenter.d.mts +16 -0
- package/dist/src/cli/commands/sync/presenter.d.mts.map +1 -0
- package/dist/src/cli/commands/sync/presenter.mjs +57 -0
- package/dist/src/cli/commands/sync/presenter.mjs.map +1 -0
- package/dist/src/cli/commands/sync/workflow.cjs +16 -0
- package/dist/src/cli/commands/sync/workflow.cjs.map +1 -0
- package/dist/src/cli/commands/sync/workflow.mjs +16 -0
- package/dist/src/cli/commands/sync/workflow.mjs.map +1 -0
- package/dist/src/cli/commands/web/index.cjs +88 -0
- package/dist/src/cli/commands/web/index.cjs.map +1 -0
- package/dist/src/cli/commands/web/index.mjs +85 -0
- package/dist/src/cli/commands/web/index.mjs.map +1 -0
- package/dist/src/cli/harnessOptions.cjs +70 -0
- package/dist/src/cli/harnessOptions.cjs.map +1 -0
- package/dist/src/cli/harnessOptions.d.mts +26 -0
- package/dist/src/cli/harnessOptions.d.mts.map +1 -0
- package/dist/src/cli/harnessOptions.mjs +66 -0
- package/dist/src/cli/harnessOptions.mjs.map +1 -0
- package/dist/src/cli/help.cjs +82 -0
- package/dist/src/cli/help.cjs.map +1 -0
- package/dist/src/cli/help.d.mts +10 -0
- package/dist/src/cli/help.d.mts.map +1 -0
- package/dist/src/cli/help.mjs +78 -0
- package/dist/src/cli/help.mjs.map +1 -0
- package/dist/src/cli/matrixOptions.cjs +178 -0
- package/dist/src/cli/matrixOptions.cjs.map +1 -0
- package/dist/src/cli/matrixOptions.d.mts +90 -0
- package/dist/src/cli/matrixOptions.d.mts.map +1 -0
- package/dist/src/cli/matrixOptions.mjs +151 -0
- package/dist/src/cli/matrixOptions.mjs.map +1 -0
- package/dist/src/cli/options.cjs +281 -0
- package/dist/src/cli/options.cjs.map +1 -0
- package/dist/src/cli/options.d.mts +5 -0
- package/dist/src/cli/options.d.mts.map +1 -0
- package/dist/src/cli/options.mjs +279 -0
- package/dist/src/cli/options.mjs.map +1 -0
- package/dist/src/cli/router.cjs +57 -0
- package/dist/src/cli/router.cjs.map +1 -0
- package/dist/src/cli/router.d.mts +32 -0
- package/dist/src/cli/router.d.mts.map +1 -0
- package/dist/src/cli/router.mjs +54 -0
- package/dist/src/cli/router.mjs.map +1 -0
- package/dist/src/cli/server/options.cjs +71 -0
- package/dist/src/cli/server/options.cjs.map +1 -0
- package/dist/src/cli/server/options.mjs +70 -0
- package/dist/src/cli/server/options.mjs.map +1 -0
- package/dist/src/cli/server/processGuards.cjs +83 -0
- package/dist/src/cli/server/processGuards.cjs.map +1 -0
- package/dist/src/cli/server/processGuards.mjs +79 -0
- package/dist/src/cli/server/processGuards.mjs.map +1 -0
- package/dist/src/cli/server/run.cjs +69 -0
- package/dist/src/cli/server/run.cjs.map +1 -0
- package/dist/src/cli/server/run.mjs +66 -0
- package/dist/src/cli/server/run.mjs.map +1 -0
- package/dist/src/composition/harnessState/index.cjs +48 -0
- package/dist/src/composition/harnessState/index.cjs.map +1 -0
- package/dist/src/composition/harnessState/index.d.mts +19 -0
- package/dist/src/composition/harnessState/index.d.mts.map +1 -0
- package/dist/src/composition/harnessState/index.mjs +34 -0
- package/dist/src/composition/harnessState/index.mjs.map +1 -0
- package/dist/src/composition/layerPackageInstaller/index.cjs +651 -0
- package/dist/src/composition/layerPackageInstaller/index.cjs.map +1 -0
- package/dist/src/composition/layerPackageInstaller/index.d.mts +74 -0
- package/dist/src/composition/layerPackageInstaller/index.d.mts.map +1 -0
- package/dist/src/composition/layerPackageInstaller/index.mjs +637 -0
- package/dist/src/composition/layerPackageInstaller/index.mjs.map +1 -0
- package/dist/src/composition/poHomeMigration/index.cjs +234 -0
- package/dist/src/composition/poHomeMigration/index.cjs.map +1 -0
- package/dist/src/composition/poHomeMigration/index.d.mts +12 -0
- package/dist/src/composition/poHomeMigration/index.d.mts.map +1 -0
- package/dist/src/composition/poHomeMigration/index.mjs +226 -0
- package/dist/src/composition/poHomeMigration/index.mjs.map +1 -0
- package/dist/src/composition/projectTrust/index.cjs +51 -0
- package/dist/src/composition/projectTrust/index.cjs.map +1 -0
- package/dist/src/composition/projectTrust/index.d.mts +22 -0
- package/dist/src/composition/projectTrust/index.d.mts.map +1 -0
- package/dist/src/composition/projectTrust/index.mjs +48 -0
- package/dist/src/composition/projectTrust/index.mjs.map +1 -0
- package/dist/src/composition/repository/index.cjs +68 -0
- package/dist/src/composition/repository/index.cjs.map +1 -0
- package/dist/src/composition/repository/index.d.mts +22 -0
- package/dist/src/composition/repository/index.d.mts.map +1 -0
- package/dist/src/composition/repository/index.mjs +63 -0
- package/dist/src/composition/repository/index.mjs.map +1 -0
- package/dist/src/composition/syncPrune/index.cjs +85 -0
- package/dist/src/composition/syncPrune/index.cjs.map +1 -0
- package/dist/src/composition/syncPrune/index.d.mts +33 -0
- package/dist/src/composition/syncPrune/index.d.mts.map +1 -0
- package/dist/src/composition/syncPrune/index.mjs +82 -0
- package/dist/src/composition/syncPrune/index.mjs.map +1 -0
- package/dist/src/composition/syncService/index.cjs +808 -0
- package/dist/src/composition/syncService/index.cjs.map +1 -0
- package/dist/src/composition/syncService/index.d.mts +65 -0
- package/dist/src/composition/syncService/index.d.mts.map +1 -0
- package/dist/src/composition/syncService/index.mjs +792 -0
- package/dist/src/composition/syncService/index.mjs.map +1 -0
- package/dist/src/composition/syncService/localBuilds.cjs +367 -0
- package/dist/src/composition/syncService/localBuilds.cjs.map +1 -0
- package/dist/src/composition/syncService/localBuilds.mjs +358 -0
- package/dist/src/composition/syncService/localBuilds.mjs.map +1 -0
- package/dist/src/composition/transitionLayers.cjs +17 -0
- package/dist/src/composition/transitionLayers.cjs.map +1 -0
- package/dist/src/composition/transitionLayers.d.mts +6 -0
- package/dist/src/composition/transitionLayers.d.mts.map +1 -0
- package/dist/src/composition/transitionLayers.mjs +16 -0
- package/dist/src/composition/transitionLayers.mjs.map +1 -0
- package/dist/src/composition/types/harness.d.mts +52 -0
- package/dist/src/composition/types/harness.d.mts.map +1 -0
- package/dist/src/extensions/setupDiagnostics.cjs +65 -0
- package/dist/src/extensions/setupDiagnostics.cjs.map +1 -0
- package/dist/src/extensions/setupDiagnostics.mjs +64 -0
- package/dist/src/extensions/setupDiagnostics.mjs.map +1 -0
- package/dist/utils.cjs +4 -0
- package/dist/utils.d.mts +2 -0
- package/dist/utils.mjs +2 -0
- package/dist/webBuilder.cjs +59 -0
- package/dist/webBuilder.d.mts +9 -0
- package/dist/webBuilder.mjs +9 -0
- package/docs/server/api-export.md +86 -0
- package/docs/server/api.md +144 -0
- package/docs/server/getting-started.md +114 -0
- package/docs/server/index.md +67 -0
- package/docs/server/ipc.md +97 -0
- package/docs/server/lifecycle.md +108 -0
- package/docs/server/security.md +101 -0
- package/llms.txt +12 -0
- package/package.json +295 -0
- package/src/prompts/po-author-extension/SKILL.md +35 -0
- package/src/prompts/po-author-extension/references/extension-contract.md +134 -0
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
const require_runtime = require("../../../_virtual/_rolldown/runtime.cjs");
|
|
2
|
+
const require_webPluginScan = require("../web/webPluginScan.cjs");
|
|
3
|
+
const require_index = require("../web/index.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 _agimon_ai_po_core_native = require("@agimon-ai/po-core/native");
|
|
9
|
+
let _agimon_ai_po_web_security = require("@agimon-ai/po-web-security");
|
|
10
|
+
let rolldown = require("rolldown");
|
|
11
|
+
//#region src/builders/native/index.ts
|
|
12
|
+
/**
|
|
13
|
+
* The one global native composition: every package's `poNative` client bundled into a single
|
|
14
|
+
* CommonJS file the po-native shell evaluates against its own host modules.
|
|
15
|
+
*
|
|
16
|
+
* It shares the web build's key, temporary directory, rename and `build.json` handling, and
|
|
17
|
+
* runs rolldown in process: the input is already built per package, so the bundle only joins
|
|
18
|
+
* those files and checks that every bare import is one the shell provides.
|
|
19
|
+
*/
|
|
20
|
+
/** Bumped whenever the build's output layout changes, so an old layout is never reused. */
|
|
21
|
+
const GLOBAL_NATIVE_BUILD_FORMAT = "global-native-1";
|
|
22
|
+
const ENTRY_FILE = "entry.mjs";
|
|
23
|
+
const PLUGINS_DIRECTORY = "plugins";
|
|
24
|
+
const HOST_MODULES = new Set(_agimon_ai_po_core_native.NATIVE_HOST_MODULE_IDS);
|
|
25
|
+
/** The build key for these plugin roots and where its build lives, without building anything. */
|
|
26
|
+
function resolveGlobalNativeBuild(input) {
|
|
27
|
+
const pluginRoots = [...new Set(input.pluginRoots.map((root) => node_path.default.resolve(root)))].sort();
|
|
28
|
+
let plugins;
|
|
29
|
+
let key;
|
|
30
|
+
try {
|
|
31
|
+
plugins = require_webPluginScan.scanWebPlugins(void 0, pluginRoots, input.onNotice ?? (() => {}), "poNative");
|
|
32
|
+
if (plugins.length === 0) return {
|
|
33
|
+
status: "skipped",
|
|
34
|
+
reason: "no package declares a native plugin; no native composition is published"
|
|
35
|
+
};
|
|
36
|
+
key = require_index.globalBuildKey(GLOBAL_NATIVE_BUILD_FORMAT, void 0, plugins);
|
|
37
|
+
} catch (error) {
|
|
38
|
+
return {
|
|
39
|
+
status: "failed",
|
|
40
|
+
reason: error instanceof Error ? error.message : String(error)
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
const buildsRoot = node_path.default.join(input.poHome, "build", "native");
|
|
44
|
+
return {
|
|
45
|
+
status: "resolved",
|
|
46
|
+
plugins,
|
|
47
|
+
key,
|
|
48
|
+
buildsRoot,
|
|
49
|
+
directory: node_path.default.join(buildsRoot, key)
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
function readBuildRecord(directory) {
|
|
53
|
+
const record = require_index.readBuildJson(directory);
|
|
54
|
+
if (record === void 0) return void 0;
|
|
55
|
+
return {
|
|
56
|
+
...record,
|
|
57
|
+
pluginsDirectory: node_path.default.join(directory, PLUGINS_DIRECTORY)
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
/** The complete global native build of one key, or undefined when it is not there. Never builds. */
|
|
61
|
+
function readGlobalNativeBuildRecord(poHome, key) {
|
|
62
|
+
return readBuildRecord(node_path.default.join(poHome, "build", "native", key));
|
|
63
|
+
}
|
|
64
|
+
/** The generated entry: each plugin's `nativePlugin` export, in install order. */
|
|
65
|
+
function renderEntry(plugins) {
|
|
66
|
+
const lines = plugins.map((plugin, index) => `import { nativePlugin as pN${String(index)} } from ${JSON.stringify(node_fs.default.realpathSync(node_path.default.join(plugin.packageDir, plugin.client.entry)))};`);
|
|
67
|
+
lines.push(`export const plugins = [${plugins.map((_, index) => `pN${String(index)}`).join(", ")}];`, "");
|
|
68
|
+
return lines.join("\n");
|
|
69
|
+
}
|
|
70
|
+
const isBareSpecifier = (source) => !source.startsWith(".") && !source.startsWith("\0") && !node_path.default.isAbsolute(source);
|
|
71
|
+
/** Bundles the plugins into `<outDir>/plugins/composition.js`: CommonJS, one file, host modules external. */
|
|
72
|
+
async function bundleNativeComposition(plugins, outDir, onNotice) {
|
|
73
|
+
const entryFile = node_path.default.join(outDir, ENTRY_FILE);
|
|
74
|
+
node_fs.default.writeFileSync(entryFile, renderEntry(plugins));
|
|
75
|
+
try {
|
|
76
|
+
const bundle = await (0, rolldown.rolldown)({
|
|
77
|
+
input: entryFile,
|
|
78
|
+
cwd: outDir,
|
|
79
|
+
platform: "neutral",
|
|
80
|
+
external: (id) => HOST_MODULES.has(id),
|
|
81
|
+
onLog: (level, log) => {
|
|
82
|
+
if (level === "warn") onNotice(log.message);
|
|
83
|
+
},
|
|
84
|
+
plugins: [{
|
|
85
|
+
name: "po-native-host-modules",
|
|
86
|
+
resolveId(source, importer) {
|
|
87
|
+
if (importer === void 0 || !isBareSpecifier(source)) return null;
|
|
88
|
+
if (HOST_MODULES.has(source)) return {
|
|
89
|
+
id: source,
|
|
90
|
+
external: true
|
|
91
|
+
};
|
|
92
|
+
this.error(`'${source}' imported by ${importer} is not a native host module; a native plugin may import only: ${_agimon_ai_po_core_native.NATIVE_HOST_MODULE_IDS.join(", ")}.`);
|
|
93
|
+
}
|
|
94
|
+
}]
|
|
95
|
+
});
|
|
96
|
+
try {
|
|
97
|
+
const { output } = await bundle.generate({
|
|
98
|
+
format: "cjs",
|
|
99
|
+
codeSplitting: false,
|
|
100
|
+
exports: "named"
|
|
101
|
+
});
|
|
102
|
+
const [chunk] = output;
|
|
103
|
+
if (output.length !== 1 || chunk.type !== "chunk") throw new Error(`The native composition must be exactly one file; the build produced ${String(output.length)}.`);
|
|
104
|
+
const bytes = Buffer.byteLength(chunk.code);
|
|
105
|
+
if (bytes > _agimon_ai_po_web_security.NATIVE_COMPOSITION_MAX_BYTES) throw new Error(`The native composition is ${String(bytes)} bytes, over the ${String(_agimon_ai_po_web_security.NATIVE_COMPOSITION_MAX_BYTES)} byte limit.`);
|
|
106
|
+
const pluginsDirectory = node_path.default.join(outDir, PLUGINS_DIRECTORY);
|
|
107
|
+
node_fs.default.mkdirSync(pluginsDirectory, { recursive: true });
|
|
108
|
+
node_fs.default.writeFileSync(node_path.default.join(pluginsDirectory, _agimon_ai_po_web_security.NATIVE_ENTRY_PATH.replace(/^\//, "")), chunk.code);
|
|
109
|
+
} finally {
|
|
110
|
+
await bundle.close();
|
|
111
|
+
}
|
|
112
|
+
} finally {
|
|
113
|
+
node_fs.default.rmSync(entryFile, { force: true });
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
/** Whether the global native build for these plugin roots exists, for a check that must not build. */
|
|
117
|
+
function readGlobalNativeBuildStatus(input) {
|
|
118
|
+
const resolved = resolveGlobalNativeBuild(input);
|
|
119
|
+
if (resolved.status !== "resolved") return resolved;
|
|
120
|
+
return {
|
|
121
|
+
status: readBuildRecord(resolved.directory) === void 0 ? "missing" : "current",
|
|
122
|
+
key: resolved.key
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Ensures the one global native build for the given plugin roots exists and returns it.
|
|
127
|
+
*
|
|
128
|
+
* The output is `<home>/build/native/<key>/plugins/composition.js`, built in a temporary
|
|
129
|
+
* directory and renamed into place; an existing key builds nothing.
|
|
130
|
+
*/
|
|
131
|
+
async function ensureGlobalNativeBuild(input) {
|
|
132
|
+
const notice = input.onNotice ?? (() => {});
|
|
133
|
+
const resolved = resolveGlobalNativeBuild(input);
|
|
134
|
+
if (resolved.status !== "resolved") return resolved;
|
|
135
|
+
const { plugins, key, buildsRoot, directory } = resolved;
|
|
136
|
+
const existing = readBuildRecord(directory);
|
|
137
|
+
if (existing !== void 0) return {
|
|
138
|
+
status: "cached",
|
|
139
|
+
build: existing
|
|
140
|
+
};
|
|
141
|
+
return require_index.singleFlightBuild(key, async () => {
|
|
142
|
+
try {
|
|
143
|
+
await require_index.buildKeyDirectory(buildsRoot, key, directory, async (temporary) => {
|
|
144
|
+
await bundleNativeComposition(plugins, temporary, notice);
|
|
145
|
+
return {
|
|
146
|
+
key,
|
|
147
|
+
plugins: plugins.map(({ pluginId, packageDir, isHost }) => ({
|
|
148
|
+
pluginId,
|
|
149
|
+
packageDir,
|
|
150
|
+
isHost
|
|
151
|
+
}))
|
|
152
|
+
};
|
|
153
|
+
});
|
|
154
|
+
const build = readBuildRecord(directory);
|
|
155
|
+
if (build === void 0) throw new Error(`The native build '${key}' was not recorded.`);
|
|
156
|
+
return {
|
|
157
|
+
status: "built",
|
|
158
|
+
build
|
|
159
|
+
};
|
|
160
|
+
} catch (error) {
|
|
161
|
+
return {
|
|
162
|
+
status: "failed",
|
|
163
|
+
reason: error instanceof Error ? error.message : String(error)
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
/** The `poNative.pluginId` values a mount runs: those of its own package roots. */
|
|
169
|
+
const mountNativePluginIds = require_index.mountWebPluginIds;
|
|
170
|
+
//#endregion
|
|
171
|
+
exports.ensureGlobalNativeBuild = ensureGlobalNativeBuild;
|
|
172
|
+
exports.mountNativePluginIds = mountNativePluginIds;
|
|
173
|
+
exports.readGlobalNativeBuildRecord = readGlobalNativeBuildRecord;
|
|
174
|
+
exports.readGlobalNativeBuildStatus = readGlobalNativeBuildStatus;
|
|
175
|
+
|
|
176
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["NATIVE_HOST_MODULE_IDS","path","scanWebPlugins","globalBuildKey","readBuildJson","fs","NATIVE_COMPOSITION_MAX_BYTES","NATIVE_ENTRY_PATH","singleFlightBuild","buildKeyDirectory","mountWebPluginIds"],"sources":["../../../../src/builders/native/index.ts"],"sourcesContent":["import fs from 'node:fs';\nimport path from 'node:path';\n\nimport { NATIVE_HOST_MODULE_IDS } from '@agimon-ai/po-core/native';\nimport type { GlobalNativeBuild } from '@agimon-ai/po-core/webCompositions';\nimport { NATIVE_COMPOSITION_MAX_BYTES, NATIVE_ENTRY_PATH } from '@agimon-ai/po-web-security';\nimport { rolldown } from 'rolldown';\n\nimport { buildKeyDirectory, globalBuildKey, mountWebPluginIds, readBuildJson, singleFlightBuild } from '../web';\nimport type { DeclaredWebPlugin } from '../web/webPluginManifest';\nimport { scanWebPlugins } from '../web/webPluginScan';\n\n/**\n * The one global native composition: every package's `poNative` client bundled into a single\n * CommonJS file the po-native shell evaluates against its own host modules.\n *\n * It shares the web build's key, temporary directory, rename and `build.json` handling, and\n * runs rolldown in process: the input is already built per package, so the bundle only joins\n * those files and checks that every bare import is one the shell provides.\n */\n\n/** Bumped whenever the build's output layout changes, so an old layout is never reused. */\nconst GLOBAL_NATIVE_BUILD_FORMAT = 'global-native-1';\nconst ENTRY_FILE = 'entry.mjs';\nconst PLUGINS_DIRECTORY = 'plugins';\nconst HOST_MODULES: ReadonlySet<string> = new Set(NATIVE_HOST_MODULE_IDS);\n\n/** One build's record: the publishable build plus each plugin's package, for resolving a mount's plugins. */\nexport interface GlobalNativeBuildRecord extends GlobalNativeBuild {\n plugins: { pluginId: string; packageDir: string; isHost: boolean }[];\n}\n\nexport interface GlobalNativeBuildInput {\n /** Po's global home; builds land in `<home>/build/native/<key>/`. */\n poHome: string;\n /** The union of every scope's package roots; roots without a poNative block are ignored. */\n pluginRoots: readonly string[];\n onNotice?: (message: string) => void;\n}\n\nexport type GlobalNativeBuildResult =\n | { status: 'built' | 'cached'; build: GlobalNativeBuildRecord }\n | { status: 'skipped'; reason: string }\n | { status: 'failed'; reason: string };\n\ntype ResolvedGlobalNativeBuild =\n | {\n status: 'resolved';\n plugins: DeclaredWebPlugin[];\n key: string;\n buildsRoot: string;\n directory: string;\n }\n | { status: 'skipped'; reason: string }\n | { status: 'failed'; reason: string };\n\n/** The build key for these plugin roots and where its build lives, without building anything. */\nfunction resolveGlobalNativeBuild(input: GlobalNativeBuildInput): ResolvedGlobalNativeBuild {\n const pluginRoots = [...new Set(input.pluginRoots.map((root) => path.resolve(root)))].sort();\n let plugins: DeclaredWebPlugin[];\n let key: string;\n try {\n plugins = scanWebPlugins(undefined, pluginRoots, input.onNotice ?? ((): void => {}), 'poNative');\n if (plugins.length === 0)\n return { status: 'skipped', reason: 'no package declares a native plugin; no native composition is published' };\n key = globalBuildKey(GLOBAL_NATIVE_BUILD_FORMAT, undefined, plugins);\n } catch (error) {\n return { status: 'failed', reason: error instanceof Error ? error.message : String(error) };\n }\n const buildsRoot = path.join(input.poHome, 'build', 'native');\n return { status: 'resolved', plugins, key, buildsRoot, directory: path.join(buildsRoot, key) };\n}\n\nfunction readBuildRecord(directory: string): GlobalNativeBuildRecord | undefined {\n const record = readBuildJson<Omit<GlobalNativeBuildRecord, 'pluginsDirectory'>>(directory);\n if (record === undefined) return undefined;\n return { ...record, pluginsDirectory: path.join(directory, PLUGINS_DIRECTORY) };\n}\n\n/** The complete global native build of one key, or undefined when it is not there. Never builds. */\nexport function readGlobalNativeBuildRecord(poHome: string, key: string): GlobalNativeBuildRecord | undefined {\n return readBuildRecord(path.join(poHome, 'build', 'native', key));\n}\n\n/** The generated entry: each plugin's `nativePlugin` export, in install order. */\nfunction renderEntry(plugins: readonly DeclaredWebPlugin[]): string {\n const lines = plugins.map(\n (plugin, index) =>\n `import { nativePlugin as pN${String(index)} } from ${JSON.stringify(fs.realpathSync(path.join(plugin.packageDir, plugin.client.entry)))};`,\n );\n lines.push(`export const plugins = [${plugins.map((_, index) => `pN${String(index)}`).join(', ')}];`, '');\n return lines.join('\\n');\n}\n\nconst isBareSpecifier = (source: string): boolean =>\n !source.startsWith('.') && !source.startsWith('\\0') && !path.isAbsolute(source);\n\n/** Bundles the plugins into `<outDir>/plugins/composition.js`: CommonJS, one file, host modules external. */\nasync function bundleNativeComposition(\n plugins: readonly DeclaredWebPlugin[],\n outDir: string,\n onNotice: (message: string) => void,\n): Promise<void> {\n const entryFile = path.join(outDir, ENTRY_FILE);\n fs.writeFileSync(entryFile, renderEntry(plugins));\n try {\n const bundle = await rolldown({\n input: entryFile,\n cwd: outDir,\n platform: 'neutral',\n external: (id) => HOST_MODULES.has(id),\n onLog: (level, log) => {\n if (level === 'warn') onNotice(log.message);\n },\n plugins: [\n {\n name: 'po-native-host-modules',\n resolveId(source, importer) {\n if (importer === undefined || !isBareSpecifier(source)) return null;\n if (HOST_MODULES.has(source)) return { id: source, external: true };\n this.error(\n `'${source}' imported by ${importer} is not a native host module; a native plugin may import only: ${NATIVE_HOST_MODULE_IDS.join(', ')}.`,\n );\n },\n },\n ],\n });\n try {\n const { output } = await bundle.generate({ format: 'cjs', codeSplitting: false, exports: 'named' });\n const [chunk] = output;\n if (output.length !== 1 || chunk.type !== 'chunk')\n throw new Error(\n `The native composition must be exactly one file; the build produced ${String(output.length)}.`,\n );\n const bytes = Buffer.byteLength(chunk.code);\n if (bytes > NATIVE_COMPOSITION_MAX_BYTES)\n throw new Error(\n `The native composition is ${String(bytes)} bytes, over the ${String(NATIVE_COMPOSITION_MAX_BYTES)} byte limit.`,\n );\n const pluginsDirectory = path.join(outDir, PLUGINS_DIRECTORY);\n fs.mkdirSync(pluginsDirectory, { recursive: true });\n fs.writeFileSync(path.join(pluginsDirectory, NATIVE_ENTRY_PATH.replace(/^\\//, '')), chunk.code);\n } finally {\n await bundle.close();\n }\n } finally {\n fs.rmSync(entryFile, { force: true });\n }\n}\n\n/** Whether the global native build for these plugin roots exists, for a check that must not build. */\nexport function readGlobalNativeBuildStatus(\n input: GlobalNativeBuildInput,\n):\n | { status: 'current' | 'missing'; key: string }\n | { status: 'skipped'; reason: string }\n | { status: 'failed'; reason: string } {\n const resolved = resolveGlobalNativeBuild(input);\n if (resolved.status !== 'resolved') return resolved;\n return { status: readBuildRecord(resolved.directory) === undefined ? 'missing' : 'current', key: resolved.key };\n}\n\n/**\n * Ensures the one global native build for the given plugin roots exists and returns it.\n *\n * The output is `<home>/build/native/<key>/plugins/composition.js`, built in a temporary\n * directory and renamed into place; an existing key builds nothing.\n */\nexport async function ensureGlobalNativeBuild(input: GlobalNativeBuildInput): Promise<GlobalNativeBuildResult> {\n const notice = input.onNotice ?? ((): void => {});\n const resolved = resolveGlobalNativeBuild(input);\n if (resolved.status !== 'resolved') return resolved;\n const { plugins, key, buildsRoot, directory } = resolved;\n const existing = readBuildRecord(directory);\n if (existing !== undefined) return { status: 'cached', build: existing };\n return singleFlightBuild(key, async (): Promise<GlobalNativeBuildResult> => {\n try {\n await buildKeyDirectory(buildsRoot, key, directory, async (temporary) => {\n await bundleNativeComposition(plugins, temporary, notice);\n return {\n key,\n plugins: plugins.map(({ pluginId, packageDir, isHost }) => ({ pluginId, packageDir, isHost })),\n };\n });\n const build = readBuildRecord(directory);\n if (build === undefined) throw new Error(`The native build '${key}' was not recorded.`);\n return { status: 'built', build };\n } catch (error) {\n return { status: 'failed', reason: error instanceof Error ? error.message : String(error) };\n }\n });\n}\n\n/** The `poNative.pluginId` values a mount runs: those of its own package roots. */\nexport const mountNativePluginIds: (build: GlobalNativeBuildRecord, packageRoots: readonly string[]) => string[] =\n mountWebPluginIds;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAsBA,MAAM,6BAA6B;AACnC,MAAM,aAAa;AACnB,MAAM,oBAAoB;AAC1B,MAAM,eAAoC,IAAI,IAAIA,0BAAAA,sBAAsB;;AAgCxE,SAAS,yBAAyB,OAA0D;CAC1F,MAAM,cAAc,CAAC,GAAG,IAAI,IAAI,MAAM,YAAY,KAAK,SAASC,UAAAA,QAAK,QAAQ,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK;CAC3F,IAAI;CACJ,IAAI;CACJ,IAAI;EACF,UAAUC,sBAAAA,eAAe,KAAA,GAAW,aAAa,MAAM,mBAAyB,CAAC,IAAI,UAAU;EAC/F,IAAI,QAAQ,WAAW,GACrB,OAAO;GAAE,QAAQ;GAAW,QAAQ;EAA0E;EAChH,MAAMC,cAAAA,eAAe,4BAA4B,KAAA,GAAW,OAAO;CACrE,SAAS,OAAO;EACd,OAAO;GAAE,QAAQ;GAAU,QAAQ,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;EAAE;CAC5F;CACA,MAAM,aAAaF,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AAS,SAAS,MAAM,KAAA,IAAY,YAAY;EAAW,KAAK,SAAS;CAAI;AAChH;;;;;;;AAQA,eAAsB,wBAAwB,OAAiE;CAC7G,MAAM,SAAS,MAAM,mBAAyB,CAAC;CAC/C,MAAM,WAAW,yBAAyB,KAAK;CAC/C,IAAI,SAAS,WAAW,YAAY,OAAO;CAC3C,MAAM,EAAE,SAAS,KAAK,YAAY,cAAc;CAChD,MAAM,WAAW,gBAAgB,SAAS;CAC1C,IAAI,aAAa,KAAA,GAAW,OAAO;EAAE,QAAQ;EAAU,OAAO;CAAS;CACvE,OAAOC,cAAAA,kBAAkB,KAAK,YAA8C;EAC1E,IAAI;GACF,MAAMC,cAAAA,kBAAkB,YAAY,KAAK,WAAW,OAAO,cAAc;IACvE,MAAM,wBAAwB,SAAS,WAAW,MAAM;IACxD,OAAO;KACL;KACA,SAAS,QAAQ,KAAK,EAAE,UAAU,YAAY,cAAc;MAAE;MAAU;MAAY;KAAO,EAAE;IAC/F;GACF,CAAC;GACD,MAAM,QAAQ,gBAAgB,SAAS;GACvC,IAAI,UAAU,KAAA,GAAW,MAAM,IAAI,MAAM,qBAAqB,IAAI,oBAAoB;GACtF,OAAO;IAAE,QAAQ;IAAS;GAAM;EAClC,SAAS,OAAO;GACd,OAAO;IAAE,QAAQ;IAAU,QAAQ,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;GAAE;EAC5F;CACF,CAAC;AACH;;AAGA,MAAa,uBACXC,cAAAA"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { GlobalNativeBuild } from "@agimon-ai/po-core/webCompositions";
|
|
2
|
+
//#region src/builders/native/index.d.ts
|
|
3
|
+
/** One build's record: the publishable build plus each plugin's package, for resolving a mount's plugins. */
|
|
4
|
+
export interface GlobalNativeBuildRecord extends GlobalNativeBuild {
|
|
5
|
+
plugins: {
|
|
6
|
+
pluginId: string;
|
|
7
|
+
packageDir: string;
|
|
8
|
+
isHost: boolean;
|
|
9
|
+
}[];
|
|
10
|
+
}
|
|
11
|
+
export interface GlobalNativeBuildInput {
|
|
12
|
+
/** Po's global home; builds land in `<home>/build/native/<key>/`. */
|
|
13
|
+
poHome: string;
|
|
14
|
+
/** The union of every scope's package roots; roots without a poNative block are ignored. */
|
|
15
|
+
pluginRoots: readonly string[];
|
|
16
|
+
onNotice?: (message: string) => void;
|
|
17
|
+
}
|
|
18
|
+
export type GlobalNativeBuildResult = {
|
|
19
|
+
status: 'built' | 'cached';
|
|
20
|
+
build: GlobalNativeBuildRecord;
|
|
21
|
+
} | {
|
|
22
|
+
status: 'skipped';
|
|
23
|
+
reason: string;
|
|
24
|
+
} | {
|
|
25
|
+
status: 'failed';
|
|
26
|
+
reason: string;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Ensures the one global native build for the given plugin roots exists and returns it.
|
|
30
|
+
*
|
|
31
|
+
* The output is `<home>/build/native/<key>/plugins/composition.js`, built in a temporary
|
|
32
|
+
* directory and renamed into place; an existing key builds nothing.
|
|
33
|
+
*/
|
|
34
|
+
export declare function ensureGlobalNativeBuild(input: GlobalNativeBuildInput): Promise<GlobalNativeBuildResult>;
|
|
35
|
+
//#endregion
|
|
36
|
+
//# sourceMappingURL=index.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../../../../src/builders/native/index.ts"],"mappings":";;;iBA4BiB,gCAAgC;EAC/C;IAAW;IAAkB;IAAoB;;;iBAGlC;;EAEf;;EAEA;EACA,YAAY;;YAGF;EACN;EAA4B,OAAO;;EACnC;EAAmB;;EACnB;EAAkB;;;;;;;;wBA6HF,wBAAwB,OAAO,yBAAyB,QAAQ"}
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import { scanWebPlugins } from "../web/webPluginScan.mjs";
|
|
2
|
+
import { buildKeyDirectory, globalBuildKey, mountWebPluginIds, readBuildJson, singleFlightBuild } from "../web/index.mjs";
|
|
3
|
+
import fs from "node:fs";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import { NATIVE_HOST_MODULE_IDS } from "@agimon-ai/po-core/native";
|
|
6
|
+
import { NATIVE_COMPOSITION_MAX_BYTES, NATIVE_ENTRY_PATH } from "@agimon-ai/po-web-security";
|
|
7
|
+
import { rolldown } from "rolldown";
|
|
8
|
+
//#region src/builders/native/index.ts
|
|
9
|
+
/**
|
|
10
|
+
* The one global native composition: every package's `poNative` client bundled into a single
|
|
11
|
+
* CommonJS file the po-native shell evaluates against its own host modules.
|
|
12
|
+
*
|
|
13
|
+
* It shares the web build's key, temporary directory, rename and `build.json` handling, and
|
|
14
|
+
* runs rolldown in process: the input is already built per package, so the bundle only joins
|
|
15
|
+
* those files and checks that every bare import is one the shell provides.
|
|
16
|
+
*/
|
|
17
|
+
/** Bumped whenever the build's output layout changes, so an old layout is never reused. */
|
|
18
|
+
const GLOBAL_NATIVE_BUILD_FORMAT = "global-native-1";
|
|
19
|
+
const ENTRY_FILE = "entry.mjs";
|
|
20
|
+
const PLUGINS_DIRECTORY = "plugins";
|
|
21
|
+
const HOST_MODULES = new Set(NATIVE_HOST_MODULE_IDS);
|
|
22
|
+
/** The build key for these plugin roots and where its build lives, without building anything. */
|
|
23
|
+
function resolveGlobalNativeBuild(input) {
|
|
24
|
+
const pluginRoots = [...new Set(input.pluginRoots.map((root) => path.resolve(root)))].sort();
|
|
25
|
+
let plugins;
|
|
26
|
+
let key;
|
|
27
|
+
try {
|
|
28
|
+
plugins = scanWebPlugins(void 0, pluginRoots, input.onNotice ?? (() => {}), "poNative");
|
|
29
|
+
if (plugins.length === 0) return {
|
|
30
|
+
status: "skipped",
|
|
31
|
+
reason: "no package declares a native plugin; no native composition is published"
|
|
32
|
+
};
|
|
33
|
+
key = globalBuildKey(GLOBAL_NATIVE_BUILD_FORMAT, void 0, plugins);
|
|
34
|
+
} catch (error) {
|
|
35
|
+
return {
|
|
36
|
+
status: "failed",
|
|
37
|
+
reason: error instanceof Error ? error.message : String(error)
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
const buildsRoot = path.join(input.poHome, "build", "native");
|
|
41
|
+
return {
|
|
42
|
+
status: "resolved",
|
|
43
|
+
plugins,
|
|
44
|
+
key,
|
|
45
|
+
buildsRoot,
|
|
46
|
+
directory: path.join(buildsRoot, key)
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
function readBuildRecord(directory) {
|
|
50
|
+
const record = readBuildJson(directory);
|
|
51
|
+
if (record === void 0) return void 0;
|
|
52
|
+
return {
|
|
53
|
+
...record,
|
|
54
|
+
pluginsDirectory: path.join(directory, PLUGINS_DIRECTORY)
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
/** The complete global native build of one key, or undefined when it is not there. Never builds. */
|
|
58
|
+
function readGlobalNativeBuildRecord(poHome, key) {
|
|
59
|
+
return readBuildRecord(path.join(poHome, "build", "native", key));
|
|
60
|
+
}
|
|
61
|
+
/** The generated entry: each plugin's `nativePlugin` export, in install order. */
|
|
62
|
+
function renderEntry(plugins) {
|
|
63
|
+
const lines = plugins.map((plugin, index) => `import { nativePlugin as pN${String(index)} } from ${JSON.stringify(fs.realpathSync(path.join(plugin.packageDir, plugin.client.entry)))};`);
|
|
64
|
+
lines.push(`export const plugins = [${plugins.map((_, index) => `pN${String(index)}`).join(", ")}];`, "");
|
|
65
|
+
return lines.join("\n");
|
|
66
|
+
}
|
|
67
|
+
const isBareSpecifier = (source) => !source.startsWith(".") && !source.startsWith("\0") && !path.isAbsolute(source);
|
|
68
|
+
/** Bundles the plugins into `<outDir>/plugins/composition.js`: CommonJS, one file, host modules external. */
|
|
69
|
+
async function bundleNativeComposition(plugins, outDir, onNotice) {
|
|
70
|
+
const entryFile = path.join(outDir, ENTRY_FILE);
|
|
71
|
+
fs.writeFileSync(entryFile, renderEntry(plugins));
|
|
72
|
+
try {
|
|
73
|
+
const bundle = await rolldown({
|
|
74
|
+
input: entryFile,
|
|
75
|
+
cwd: outDir,
|
|
76
|
+
platform: "neutral",
|
|
77
|
+
external: (id) => HOST_MODULES.has(id),
|
|
78
|
+
onLog: (level, log) => {
|
|
79
|
+
if (level === "warn") onNotice(log.message);
|
|
80
|
+
},
|
|
81
|
+
plugins: [{
|
|
82
|
+
name: "po-native-host-modules",
|
|
83
|
+
resolveId(source, importer) {
|
|
84
|
+
if (importer === void 0 || !isBareSpecifier(source)) return null;
|
|
85
|
+
if (HOST_MODULES.has(source)) return {
|
|
86
|
+
id: source,
|
|
87
|
+
external: true
|
|
88
|
+
};
|
|
89
|
+
this.error(`'${source}' imported by ${importer} is not a native host module; a native plugin may import only: ${NATIVE_HOST_MODULE_IDS.join(", ")}.`);
|
|
90
|
+
}
|
|
91
|
+
}]
|
|
92
|
+
});
|
|
93
|
+
try {
|
|
94
|
+
const { output } = await bundle.generate({
|
|
95
|
+
format: "cjs",
|
|
96
|
+
codeSplitting: false,
|
|
97
|
+
exports: "named"
|
|
98
|
+
});
|
|
99
|
+
const [chunk] = output;
|
|
100
|
+
if (output.length !== 1 || chunk.type !== "chunk") throw new Error(`The native composition must be exactly one file; the build produced ${String(output.length)}.`);
|
|
101
|
+
const bytes = Buffer.byteLength(chunk.code);
|
|
102
|
+
if (bytes > NATIVE_COMPOSITION_MAX_BYTES) throw new Error(`The native composition is ${String(bytes)} bytes, over the ${String(NATIVE_COMPOSITION_MAX_BYTES)} byte limit.`);
|
|
103
|
+
const pluginsDirectory = path.join(outDir, PLUGINS_DIRECTORY);
|
|
104
|
+
fs.mkdirSync(pluginsDirectory, { recursive: true });
|
|
105
|
+
fs.writeFileSync(path.join(pluginsDirectory, NATIVE_ENTRY_PATH.replace(/^\//, "")), chunk.code);
|
|
106
|
+
} finally {
|
|
107
|
+
await bundle.close();
|
|
108
|
+
}
|
|
109
|
+
} finally {
|
|
110
|
+
fs.rmSync(entryFile, { force: true });
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
/** Whether the global native build for these plugin roots exists, for a check that must not build. */
|
|
114
|
+
function readGlobalNativeBuildStatus(input) {
|
|
115
|
+
const resolved = resolveGlobalNativeBuild(input);
|
|
116
|
+
if (resolved.status !== "resolved") return resolved;
|
|
117
|
+
return {
|
|
118
|
+
status: readBuildRecord(resolved.directory) === void 0 ? "missing" : "current",
|
|
119
|
+
key: resolved.key
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Ensures the one global native build for the given plugin roots exists and returns it.
|
|
124
|
+
*
|
|
125
|
+
* The output is `<home>/build/native/<key>/plugins/composition.js`, built in a temporary
|
|
126
|
+
* directory and renamed into place; an existing key builds nothing.
|
|
127
|
+
*/
|
|
128
|
+
async function ensureGlobalNativeBuild(input) {
|
|
129
|
+
const notice = input.onNotice ?? (() => {});
|
|
130
|
+
const resolved = resolveGlobalNativeBuild(input);
|
|
131
|
+
if (resolved.status !== "resolved") return resolved;
|
|
132
|
+
const { plugins, key, buildsRoot, directory } = resolved;
|
|
133
|
+
const existing = readBuildRecord(directory);
|
|
134
|
+
if (existing !== void 0) return {
|
|
135
|
+
status: "cached",
|
|
136
|
+
build: existing
|
|
137
|
+
};
|
|
138
|
+
return singleFlightBuild(key, async () => {
|
|
139
|
+
try {
|
|
140
|
+
await buildKeyDirectory(buildsRoot, key, directory, async (temporary) => {
|
|
141
|
+
await bundleNativeComposition(plugins, temporary, notice);
|
|
142
|
+
return {
|
|
143
|
+
key,
|
|
144
|
+
plugins: plugins.map(({ pluginId, packageDir, isHost }) => ({
|
|
145
|
+
pluginId,
|
|
146
|
+
packageDir,
|
|
147
|
+
isHost
|
|
148
|
+
}))
|
|
149
|
+
};
|
|
150
|
+
});
|
|
151
|
+
const build = readBuildRecord(directory);
|
|
152
|
+
if (build === void 0) throw new Error(`The native build '${key}' was not recorded.`);
|
|
153
|
+
return {
|
|
154
|
+
status: "built",
|
|
155
|
+
build
|
|
156
|
+
};
|
|
157
|
+
} catch (error) {
|
|
158
|
+
return {
|
|
159
|
+
status: "failed",
|
|
160
|
+
reason: error instanceof Error ? error.message : String(error)
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
/** The `poNative.pluginId` values a mount runs: those of its own package roots. */
|
|
166
|
+
const mountNativePluginIds = mountWebPluginIds;
|
|
167
|
+
//#endregion
|
|
168
|
+
export { ensureGlobalNativeBuild, mountNativePluginIds, readGlobalNativeBuildRecord, readGlobalNativeBuildStatus };
|
|
169
|
+
|
|
170
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../../../src/builders/native/index.ts"],"sourcesContent":["import fs from 'node:fs';\nimport path from 'node:path';\n\nimport { NATIVE_HOST_MODULE_IDS } from '@agimon-ai/po-core/native';\nimport type { GlobalNativeBuild } from '@agimon-ai/po-core/webCompositions';\nimport { NATIVE_COMPOSITION_MAX_BYTES, NATIVE_ENTRY_PATH } from '@agimon-ai/po-web-security';\nimport { rolldown } from 'rolldown';\n\nimport { buildKeyDirectory, globalBuildKey, mountWebPluginIds, readBuildJson, singleFlightBuild } from '../web';\nimport type { DeclaredWebPlugin } from '../web/webPluginManifest';\nimport { scanWebPlugins } from '../web/webPluginScan';\n\n/**\n * The one global native composition: every package's `poNative` client bundled into a single\n * CommonJS file the po-native shell evaluates against its own host modules.\n *\n * It shares the web build's key, temporary directory, rename and `build.json` handling, and\n * runs rolldown in process: the input is already built per package, so the bundle only joins\n * those files and checks that every bare import is one the shell provides.\n */\n\n/** Bumped whenever the build's output layout changes, so an old layout is never reused. */\nconst GLOBAL_NATIVE_BUILD_FORMAT = 'global-native-1';\nconst ENTRY_FILE = 'entry.mjs';\nconst PLUGINS_DIRECTORY = 'plugins';\nconst HOST_MODULES: ReadonlySet<string> = new Set(NATIVE_HOST_MODULE_IDS);\n\n/** One build's record: the publishable build plus each plugin's package, for resolving a mount's plugins. */\nexport interface GlobalNativeBuildRecord extends GlobalNativeBuild {\n plugins: { pluginId: string; packageDir: string; isHost: boolean }[];\n}\n\nexport interface GlobalNativeBuildInput {\n /** Po's global home; builds land in `<home>/build/native/<key>/`. */\n poHome: string;\n /** The union of every scope's package roots; roots without a poNative block are ignored. */\n pluginRoots: readonly string[];\n onNotice?: (message: string) => void;\n}\n\nexport type GlobalNativeBuildResult =\n | { status: 'built' | 'cached'; build: GlobalNativeBuildRecord }\n | { status: 'skipped'; reason: string }\n | { status: 'failed'; reason: string };\n\ntype ResolvedGlobalNativeBuild =\n | {\n status: 'resolved';\n plugins: DeclaredWebPlugin[];\n key: string;\n buildsRoot: string;\n directory: string;\n }\n | { status: 'skipped'; reason: string }\n | { status: 'failed'; reason: string };\n\n/** The build key for these plugin roots and where its build lives, without building anything. */\nfunction resolveGlobalNativeBuild(input: GlobalNativeBuildInput): ResolvedGlobalNativeBuild {\n const pluginRoots = [...new Set(input.pluginRoots.map((root) => path.resolve(root)))].sort();\n let plugins: DeclaredWebPlugin[];\n let key: string;\n try {\n plugins = scanWebPlugins(undefined, pluginRoots, input.onNotice ?? ((): void => {}), 'poNative');\n if (plugins.length === 0)\n return { status: 'skipped', reason: 'no package declares a native plugin; no native composition is published' };\n key = globalBuildKey(GLOBAL_NATIVE_BUILD_FORMAT, undefined, plugins);\n } catch (error) {\n return { status: 'failed', reason: error instanceof Error ? error.message : String(error) };\n }\n const buildsRoot = path.join(input.poHome, 'build', 'native');\n return { status: 'resolved', plugins, key, buildsRoot, directory: path.join(buildsRoot, key) };\n}\n\nfunction readBuildRecord(directory: string): GlobalNativeBuildRecord | undefined {\n const record = readBuildJson<Omit<GlobalNativeBuildRecord, 'pluginsDirectory'>>(directory);\n if (record === undefined) return undefined;\n return { ...record, pluginsDirectory: path.join(directory, PLUGINS_DIRECTORY) };\n}\n\n/** The complete global native build of one key, or undefined when it is not there. Never builds. */\nexport function readGlobalNativeBuildRecord(poHome: string, key: string): GlobalNativeBuildRecord | undefined {\n return readBuildRecord(path.join(poHome, 'build', 'native', key));\n}\n\n/** The generated entry: each plugin's `nativePlugin` export, in install order. */\nfunction renderEntry(plugins: readonly DeclaredWebPlugin[]): string {\n const lines = plugins.map(\n (plugin, index) =>\n `import { nativePlugin as pN${String(index)} } from ${JSON.stringify(fs.realpathSync(path.join(plugin.packageDir, plugin.client.entry)))};`,\n );\n lines.push(`export const plugins = [${plugins.map((_, index) => `pN${String(index)}`).join(', ')}];`, '');\n return lines.join('\\n');\n}\n\nconst isBareSpecifier = (source: string): boolean =>\n !source.startsWith('.') && !source.startsWith('\\0') && !path.isAbsolute(source);\n\n/** Bundles the plugins into `<outDir>/plugins/composition.js`: CommonJS, one file, host modules external. */\nasync function bundleNativeComposition(\n plugins: readonly DeclaredWebPlugin[],\n outDir: string,\n onNotice: (message: string) => void,\n): Promise<void> {\n const entryFile = path.join(outDir, ENTRY_FILE);\n fs.writeFileSync(entryFile, renderEntry(plugins));\n try {\n const bundle = await rolldown({\n input: entryFile,\n cwd: outDir,\n platform: 'neutral',\n external: (id) => HOST_MODULES.has(id),\n onLog: (level, log) => {\n if (level === 'warn') onNotice(log.message);\n },\n plugins: [\n {\n name: 'po-native-host-modules',\n resolveId(source, importer) {\n if (importer === undefined || !isBareSpecifier(source)) return null;\n if (HOST_MODULES.has(source)) return { id: source, external: true };\n this.error(\n `'${source}' imported by ${importer} is not a native host module; a native plugin may import only: ${NATIVE_HOST_MODULE_IDS.join(', ')}.`,\n );\n },\n },\n ],\n });\n try {\n const { output } = await bundle.generate({ format: 'cjs', codeSplitting: false, exports: 'named' });\n const [chunk] = output;\n if (output.length !== 1 || chunk.type !== 'chunk')\n throw new Error(\n `The native composition must be exactly one file; the build produced ${String(output.length)}.`,\n );\n const bytes = Buffer.byteLength(chunk.code);\n if (bytes > NATIVE_COMPOSITION_MAX_BYTES)\n throw new Error(\n `The native composition is ${String(bytes)} bytes, over the ${String(NATIVE_COMPOSITION_MAX_BYTES)} byte limit.`,\n );\n const pluginsDirectory = path.join(outDir, PLUGINS_DIRECTORY);\n fs.mkdirSync(pluginsDirectory, { recursive: true });\n fs.writeFileSync(path.join(pluginsDirectory, NATIVE_ENTRY_PATH.replace(/^\\//, '')), chunk.code);\n } finally {\n await bundle.close();\n }\n } finally {\n fs.rmSync(entryFile, { force: true });\n }\n}\n\n/** Whether the global native build for these plugin roots exists, for a check that must not build. */\nexport function readGlobalNativeBuildStatus(\n input: GlobalNativeBuildInput,\n):\n | { status: 'current' | 'missing'; key: string }\n | { status: 'skipped'; reason: string }\n | { status: 'failed'; reason: string } {\n const resolved = resolveGlobalNativeBuild(input);\n if (resolved.status !== 'resolved') return resolved;\n return { status: readBuildRecord(resolved.directory) === undefined ? 'missing' : 'current', key: resolved.key };\n}\n\n/**\n * Ensures the one global native build for the given plugin roots exists and returns it.\n *\n * The output is `<home>/build/native/<key>/plugins/composition.js`, built in a temporary\n * directory and renamed into place; an existing key builds nothing.\n */\nexport async function ensureGlobalNativeBuild(input: GlobalNativeBuildInput): Promise<GlobalNativeBuildResult> {\n const notice = input.onNotice ?? ((): void => {});\n const resolved = resolveGlobalNativeBuild(input);\n if (resolved.status !== 'resolved') return resolved;\n const { plugins, key, buildsRoot, directory } = resolved;\n const existing = readBuildRecord(directory);\n if (existing !== undefined) return { status: 'cached', build: existing };\n return singleFlightBuild(key, async (): Promise<GlobalNativeBuildResult> => {\n try {\n await buildKeyDirectory(buildsRoot, key, directory, async (temporary) => {\n await bundleNativeComposition(plugins, temporary, notice);\n return {\n key,\n plugins: plugins.map(({ pluginId, packageDir, isHost }) => ({ pluginId, packageDir, isHost })),\n };\n });\n const build = readBuildRecord(directory);\n if (build === undefined) throw new Error(`The native build '${key}' was not recorded.`);\n return { status: 'built', build };\n } catch (error) {\n return { status: 'failed', reason: error instanceof Error ? error.message : String(error) };\n }\n });\n}\n\n/** The `poNative.pluginId` values a mount runs: those of its own package roots. */\nexport const mountNativePluginIds: (build: GlobalNativeBuildRecord, packageRoots: readonly string[]) => string[] =\n mountWebPluginIds;\n"],"mappings":";;;;;;;;;;;;;;;;;AAsBA,MAAM,6BAA6B;AACn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